Repository navigation
feat: name the silent no-op, and a doctor to ask about it (#200) - #201
Conversation
Claude Code reads hook registrations at session start, so a plugin enabled part-way through a session has none of them wired for the rest of it. PostToolUse never fires, nothing is captured, and hook-errors.log stays empty because nothing failed. The reporter lost a day to it and found a single session-start line as the only trace. It cannot be caught while it is happening, and that is worth stating plainly: no env var, file or command exposes which hooks are registered — /hooks is a UI a script cannot invoke — and SessionStart's `source` field is only startup/resume/clear/compact/fork, so a plugin-enable is indistinguishable from a fresh start. Every "detect it live" design was checked and none work. Afterwards, though, the signature is exact: a session where SessionStart ran and PostToolUse never did. PostToolUse now records the session id it saw; the next SessionStart compares it with the previous session's id and, if that session used tools at all, leaves a notice. The zero-tool guard matters — a conversation with no tool calls produces no PostToolUse either, and warning about that would be crying wolf. Identity rather than mtimes: the first cut compared timestamps and a test caught it reporting a HEALTHY session as broken, because bash 3.2's `-nt` resolves to the second and the sign of life landed inside the same one as the stamp. The notice is delivered through systemMessage, which is the only hook output the human sees. additionalContext reaches the model alone — which is the shape of the original bug, so it would have been the wrong channel. The ordinary path still prints exactly what it always did; only the notice case switches to JSON, and a test pins that so context injection cannot silently change. Adds /remember:doctor: resolved paths, detected tools, storage mode, whether the session dir Claude Code created matches the computed slug (#144), the last successful save, and whether PostToolUse has ever fired. OK/WARN/FAIL per line, one VERDICT. Two things its own tests found: an install predating the capture-alive marker was reported as "PostToolUse has never fired" while the next line printed a successful save — a working user sent off to restart for nothing; and the slug helpers are not guaranteed to be defined, so the report printed an empty slug as OK and skipped the #144 check entirely. It now says it could not check, which is not the same as no problem. Full suite 880 passed, 41 skipped. Reported by @fmanimashaun. Co-Authored-By: Max <noreply>
…rdict that misdiagnosed Four review passes on #201, four real defects. Recorded because each one was the feature failing in the shape of the bug it was written to fix. A pending notice could DESTROY the user's prompt. The systemMessage path builds its JSON with jq, and jq was the script's last command, so its exit status became the hook's. jq exits 2 on a usage error, and on UserPromptSubmit exit 2 blocks the prompt and erases what was typed — on every prompt with a notice pending, silently, with jq's stderr going to a log nobody reads. The JSON is now built first and printed only if it was produced, falling back to plain text, and the hook ends with an explicit exit 0. The check could not catch the incident it was written for. It was gated on a prior session-start stamp so a fresh install would not be warned about a session predating it — which removes the entire point: during a mid-session enable no hook runs, so no stamp is written, so the one case this exists to report was the exact case it stayed silent for. It could only ever have caught a recurrence. The gate is gone. A fresh install sees the notice once per project and the wording covers both readings. The doctor misdiagnosed the failure it was built to name. capture-alive was written after the hook's no-transcript early exit, so in a slug mismatch (#144) it was never written at all — and the verdict tested the generic "never fired" branch before the specific causes, so a slug mismatch AND a missing Python both came out as "restart Claude Code", which fixes neither, on the one line commands/doctor.md told the operator not to second-guess. A separate post-tool-ran marker now answers "is the hook wired" before every early exit, the verdict names specific causes first, and the command doc asks for the FAIL lines alongside the verdict rather than the verdict alone. The comment claiming capture-alive was written "unconditionally" was false in exactly that case. Fixed, and the write goes through a rename now — the lesson last-save.json learned in #140, since a truncate-then-write killed midway leaves an empty marker that matches no session and reports a healthy one as a gap. Test harness honesty: the fixture's config.json write is inert, because _LIB_MEMORY_DIR_LOADED=1 stops lib-memory-dir.sh before the config merge, so features.recovery reads true whatever the file says. It said it suppressed recovery; it does not, and a test that creates last-save.json while believing it would get a stray fork. Said outright now. Transcript ordering uses explicit spaced mtimes rather than a 50ms sleep — the same sub-second-resolution assumption that bit this feature once already. Known limits are now written down rather than discovered later: capture-alive is per project, so concurrent sessions on one project can produce a spurious notice; and a notice is consumed by the next prompt in any session. Full suite 882 passed, 41 skipped. Co-Authored-By: Max <noreply>
Review pass — four defects, all fixed in
|
…p-and-doctor # Conflicts: # CHANGELOG.md
Closes #200. Reported by @fmanimashaun.
The failure
Claude Code reads hook registrations at session start, so a plugin enabled part-way through a session has none of them wired for the rest of it.
PostToolUsenever fires, nothing is captured, andhook-errors.logstays empty because nothing failed. The reporter lost a day to it and found onesession-startline as the only trace.The plugin was working exactly as designed. It simply was not wired in — and there was no way for a user to discover that.
What can't be done, and why
Suggestion 1 in the issue was to have
SessionStartcheck whetherPostToolUseis registered. That is not possible, and it's worth recording so nobody re-attempts it:/hooksis a read-only UI a hook script cannot invoke.SessionStartcannot tell why it fired. Itssourcefield is onlystartup|resume|clear|compact|fork. A plugin-enable is indistinguishable from a fresh start.So the gap is undetectable while it is happening. What remains is detecting it afterwards.
What is done
Detection. The signature is exact: a session where
SessionStartran andPostToolUsenever did.PostToolUserecords the session id it saw; the nextSessionStartcompares that against the previous session's id and, if that session used tools at all, leaves a notice.The zero-tool guard is load-bearing: a conversation with no tool calls produces no
PostToolUseeither, and warning about it would be crying wolf.Identity rather than timestamps — the first cut compared mtimes and a test caught it calling a healthy session broken, because bash 3.2's
-ntresolves to the second and the sign of life landed inside the same one as the stamp.Delivery. Through
systemMessage, the only hook output the human sees.additionalContextreaches the model alone, which is the shape of the original bug and would have been the wrong channel. The ordinary path still prints exactly what it always did; only the notice case switches to JSON, and a test pins that so context injection cannot change silently./remember:doctor. Resolved paths, detected tools, storage mode, whether the session dir Claude Code created matches the computed slug (#144), the last successful save, and whetherPostToolUsehas ever fired.OK/WARN/FAILper line, oneVERDICT.README. A restart note in the install steps, and a section on the diagnostics command.
Two bugs its own tests found
capture-alivemarker was reported asFAIL PostToolUse has never fired— while the next line printed a successful save. Self-contradictory, and it would have sent every existing working user off to restart for nothing.lib-memory-dir.shreturns early, so the report printed an empty slug as OK and skipped the session_dir_slug() mis-slugs non-ASCII (CJK) paths under byte-wise sed, silently disabling saves #144 check entirely. It now says it could not check, which is not the same as no problem — that distinction being the entire subject of this issue.Tests
tests/test_capture_gap_notice.py(8) andtests/test_doctor.py(5). Verified against the pre-fix scripts: the four asserting new behaviour fail without it. The rest are false-alarm guards protecting the new logic — one of which caught the mtime bug above.Full suite: 880 passed, 41 skipped.
Not addressed here
/reload-pluginsexists but the docs do not say whether it re-registers hooks. If it does, the remedy is a reload rather than a restart and the README should say so. Worth raising upstream either way — "enabling a plugin silently does nothing until restart" is arguably a Claude Code issue, not a plugin one.@fmanimashaun offered to test on Windows/Git Bash, which we cannot do here — the scripts are written for bash 3.2 and MSYS, but that offer is worth taking up before release.