fix: emit valid Claude Code hook schema in settings.json#180
Open
pashak1207 wants to merge 1 commit intotirth8205:mainfrom
Open
fix: emit valid Claude Code hook schema in settings.json#180pashak1207 wants to merge 1 commit intotirth8205:mainfrom
pashak1207 wants to merge 1 commit intotirth8205:mainfrom
Conversation
Claude Code rejects the file generated by `code-review-graph install`
with "Expected array, but received undefined" because each entry under
PostToolUse/SessionStart needs an inner `hooks: [{type, command}]`
array, not a flat `command:` field. On top of that, the generator
emits a `PreCommit` block — which isn't a Claude Code event at all.
Consequence: the entire settings.json is discarded, so neither the
PostToolUse auto-update hook nor the SessionStart status hook ever
fires.
This rewrites generate_hooks_config() to produce the correct schema,
drops the bogus PreCommit block, and narrows the PostToolUse matcher
from `Edit|Write|Bash` to `Edit|Write`. Bash calls in Claude Code
don't modify source files directly, so running an incremental graph
update after every shell command was just noise.
Tests in TestGenerateHooksConfig were updated to assert the new
schema, plus a new regression test (test_entries_use_claude_code_hook_schema)
guards against the flat-command shape recurring.
Fixes tirth8205#97, tirth8205#163, tirth8205#172.
|
FWIW: I applied these fixed to my local setup and can confirm |
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.
Claude Code rejects the file generated by
code-review-graph installwith "Expected array, but received undefined" because each entry under PostToolUse/SessionStart needs an innerhooks: [{type, command}]array, not a flatcommand:field. On top of that, the generator emits aPreCommitblock — which isn't a Claude Code event at all.Consequence: the entire settings.json is discarded, so neither the PostToolUse auto-update hook nor the SessionStart status hook ever fires.
This rewrites generate_hooks_config() to produce the correct schema, drops the bogus PreCommit block, and narrows the PostToolUse matcher from
Edit|Write|BashtoEdit|Write. Bash calls in Claude Code don't modify source files directly, so running an incremental graph update after every shell command was just noise.Tests in TestGenerateHooksConfig were updated to assert the new schema, plus a new regression test (test_entries_use_claude_code_hook_schema) guards against the flat-command shape recurring.
Fixes #97, #163, #172.