Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/claude-code/hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"type": "command",
"command": "uv run --quiet --script \"${CLAUDE_PLUGIN_ROOT}/hooks/session_start.py\"",
"timeout": 20,
"timeout": 45,
"statusMessage": "Briefing from Basic Memory"
}
]
Expand Down
4 changes: 4 additions & 0 deletions plugins/claude-code/hooks/pre_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# "fastmcp==4.1.3",
# ]
# [tool.uv]
# # Compile the hook env at install. Hosts such as the Claude desktop app set
# # PYTHONDONTWRITEBYTECODE=1, so Python never caches bytecode at import and every
# # hook run would compile the whole import graph from source (#2101).
# compile-bytecode = true
# # The released Basic Memory runtime still pins the beta. Use the stable
# # version tested by core until the next runtime release carries this pin.
# override-dependencies = ["fastmcp==4.1.3"]
Expand Down
4 changes: 4 additions & 0 deletions plugins/claude-code/hooks/session_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# "fastmcp==4.1.3",
# ]
# [tool.uv]
# # Compile the hook env at install. Hosts such as the Claude desktop app set
# # PYTHONDONTWRITEBYTECODE=1, so Python never caches bytecode at import and every
# # hook run would compile the whole import graph from source (#2101).
# compile-bytecode = true
# # The released Basic Memory runtime still pins the beta. Use the stable
# # version tested by core until the next runtime release carries this pin.
# override-dependencies = ["fastmcp==4.1.3"]
Expand Down
4 changes: 4 additions & 0 deletions plugins/codex/hooks/pre_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# "fastmcp==4.1.3",
# ]
# [tool.uv]
# # Compile the hook env at install. Hosts such as the Claude desktop app set
# # PYTHONDONTWRITEBYTECODE=1, so Python never caches bytecode at import and every
# # hook run would compile the whole import graph from source (#2101).
# compile-bytecode = true
# # The released Basic Memory runtime still pins the beta. Use the stable
# # version tested by core until the next runtime release carries this pin.
# override-dependencies = ["fastmcp==4.1.3"]
Expand Down
4 changes: 4 additions & 0 deletions plugins/codex/hooks/session_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# "fastmcp==4.1.3",
# ]
# [tool.uv]
# # Compile the hook env at install. Hosts such as the Claude desktop app set
# # PYTHONDONTWRITEBYTECODE=1, so Python never caches bytecode at import and every
# # hook run would compile the whole import graph from source (#2101).
# compile-bytecode = true
# # The released Basic Memory runtime still pins the beta. Use the stable
# # version tested by core until the next runtime release carries this pin.
# override-dependencies = ["fastmcp==4.1.3"]
Expand Down
4 changes: 4 additions & 0 deletions scripts/validate_claude_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ def validate_claude_plugin(plugin_dir: Path) -> None:
)
if overrides != [core_fastmcp_pin]:
raise SystemExit(f"{script}: fastmcp override must match core pin {core_fastmcp_pin}")
# Hosts that set PYTHONDONTWRITEBYTECODE=1 never cache bytecode at import, so the
# hook env must be compiled at install or SessionStart outruns its timeout (#2101).
if not re.search(r"^# compile-bytecode = true$", text, re.MULTILINE):
raise SystemExit(f"{script}: [tool.uv] must set compile-bytecode = true")

# --- Output style ---
output_style = plugin_dir / "output-styles/basic-memory.md"
Expand Down
17 changes: 17 additions & 0 deletions tests/test_codex_plugin_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,23 @@ def test_codex_hook_fastmcp_pins_match_core_pyproject() -> None:
r'^# override-dependencies = \["fastmcp==([^\"]+)"\]$', shim, re.MULTILINE
)
assert overrides == [core.group(1)], name
assert re.search(r"^# compile-bytecode = true$", shim, re.MULTILINE), name


def test_claude_validator_requires_hook_bytecode_compilation(tmp_path: Path) -> None:
repo_root = Path(__file__).resolve().parents[1]
plugin_dir = tmp_path / "claude-code"
shutil.copytree(repo_root / "plugins/claude-code", plugin_dir)
script = plugin_dir / "hooks/session_start.py"
script.write_text(script.read_text().replace("# compile-bytecode = true\n", ""))
result = subprocess.run(
[sys.executable, str(repo_root / "scripts/validate_claude_plugin.py"), str(plugin_dir)],
capture_output=True,
text=True,
check=False,
)
assert result.returncode != 0
assert "must set compile-bytecode = true" in result.stderr


def test_claude_validator_rejects_stale_fastmcp_override(tmp_path: Path) -> None:
Expand Down
Loading