fix(init): use canonical PostToolUse hook event (fixes #1)#2
Open
CircleFiller wants to merge 1 commit intovincent-k2026:masterfrom
Open
fix(init): use canonical PostToolUse hook event (fixes #1)#2CircleFiller wants to merge 1 commit intovincent-k2026:masterfrom
CircleFiller wants to merge 1 commit intovincent-k2026:masterfrom
Conversation
`runInit()` was writing the hook under `PostToolExecution`, which isn't
a valid Claude Code hook event. Result: `claude /doctor` flagged an
unknown settings key, and the hook never fired, so `events.json` stayed
empty and the pet had no tool activity to react to.
Also fixes the entry shape — Claude Code's canonical form is
`{matcher, hooks: [{type, command}]}`, not the flat `{matcher, command}`.
Changes:
- `PostToolExecution` → `PostToolUse` everywhere in init/uninstall.
- Writes entries in the wrapped canonical shape.
- Migrates any legacy `PostToolExecution` entries onto `PostToolUse` on
re-init, so existing users upgrade cleanly without losing the hook.
- Uninstall sweeps both keys so lingering legacy entries are cleaned too.
- Codachi-detection helper now matches both the wrapped and legacy flat
shapes when deciding whether to replace vs preserve an entry.
Adds `src/init.test.ts` (11 tests) covering the shape, key, idempotency,
legacy migration, unrelated-hook preservation, and uninstall cleanup.
Full suite: 381 tests pass (was 370).
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1.
Summary
PostToolExecution→PostToolUseacrossrunInit/runUninstall. The former isn't a valid Claude Code hook event, so/doctorflagged it and the hook never fired — meaningevents.jsonstayed empty and the pet had nothing to react to (defeated the main selling point).{matcher, hooks: [{type, command}]}shape.PostToolExecutionentries ontoPostToolUseon re-init so existing users upgrade cleanly with a singlenpx codachi init.runUninstallsweeps both keys so lingering legacy entries also get cleaned.New tests
Adds
src/init.test.ts(11 tests) covering:PostToolUsekey is used (andPostToolExecutionis not).statusLineis set.PostToolExecutionentries migrate ontoPostToolUse.PostToolUseentries from other tools are preserved.mcpServers) are preserved.PostToolUseandPostToolExecution.Full suite: 381 tests pass (was 370).
Test plan
npm test— all 381 pass.npm run buildclean.PostToolExecutionentry → it cleanly migrated,/doctorpasses.npx codachi initon a fresh config, confirm/doctoris happy and~/.claude/plugins/codachi/events.jsonstarts gaining entries.🤖 Generated with Claude Code