hooks: Claude Code SessionStart briefing and PreToolUse dead-end guard, release 6.11.0 #30
No reviewers
Labels
No labels
upstream-feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
tim/omnimem!30
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/claude-code-hooks-22"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #22.
Upstream's
omnimem hookreads its SQLite store directly. That does not transfer: here the store is Valkey behind the MCP server and the hook runs on the client machine. So this is a client script that talks to the server over MCP, plus two small additive server changes.What
claude_config/hooks/omnimem_hook.py: one file, Python standard library only.Edit/MultiEdit/Write/NotebookEdit/mutatingBashcall that puts an abandoned approach in place, with the reason and what worked instead.Answer to the issue's open question (what the matcher keys on): the text the call would put in place (
new_string,content, a mutating Bash command), neverold_string, matched as a whole abandoned name on word boundaries, ignoring case and separators.Read/Glob/Grepare never checked,ls vendor/kestrel-rspasses,cargo add kestrel-rsdoes not.Server side (additive, defaults unchanged):
warn_if_abandoned(query, project?, proposal?)andbriefing(read_only=True).Decisions to look at
MCP_TRANSPORT=http. The deprecated SSE transport needs a different protocol and is not supported; on a server still using it the script writes a one-line hint to stderr and does nothing. The shipped docs and code default are stillsse, so this is a deploy prerequisite.MCP_AUTH_TOKENbearer (works alongside OAuth via MultiAuth) fromOMNIMEM_TOKENin the environment; the script refuses to send it over cleartext http to a non-loopback host. No server auth change.warn_if_abandonedmatchesquery in name, so a short command likemakewould match any abandoned name containing it. A hook that can block work needs word boundaries, a 3-character minimum, and project scoping (records with no project apply everywhere).session-endhook (writes a session log; transcripts are where secrets surface and the redaction and dedup it needs are unmeasured) and an installer (settings.example.jsonis the complete entry).A bug the real run found
Ruff at
py314rewroteexcept (OSError, ValueError):in the script to the PEP 758 formexcept OSError, ValueError:, a SyntaxError before 3.14. The hook runs with the user'spython3(3.13 here); every test ran it with the 3.14 venv interpreter and stayed green. Found only when I ran the final script against a real server with the plainpython3. Fixed withper-file-target-version = py39forclaude_config/hooks/*.pyinruff.toml, plus two tests: a source check (runs in CI) and a run under any older interpreter on the machine (skips when there is none; CI's runner has only 3.14). Both fail on the bug (verified by putting it back).Verification
KestrelRsLikenot matched, wrong token failing open, session-start output. Under Python 3.13 and 3.12. About 30 ms per call locally.pytest: 2137 passed, 1 skipped (was 2086). New:test_hook_support.py(server side),test_claude_code_hook.py(script as a subprocess against a fake MCP server on a real socket, plus the old-Python guards).ruff check,ruff format --check, ASCII check, bandit on the changed files (no findings, no suppressions).claude_config/CLAUDE.mdtemplate still said abandoned + effort 4 auto-suppresses (removed in 6.10.0).Not measured: the guard's effect on the dead-end benchmark. The 27% figure in the benchmark README is for the prototype; this is its production form.
🤖 Generated with Claude Code