fix(core): detect hook_event_name from real Claude Code runtime#6
Merged
Conversation
Real Claude Code sends `hook_event_name` not `type`. Add it as the first candidate in extract_event_field so PreToolUse/PostToolUse events are recognized. Add real-format fixtures and tests. Closes #5 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code tool_use_id prefix (e.g. toolu_abc123). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
"hook_event_name":"PreToolUse"— not"type":"PreToolUse"extract_event_fieldinparse.rsonly checked["event", "hookEvent", "hook_event", "type"], missinghook_event_nameHookEventEvent::Notification, silently approving all tool calls"hook_event_name"as first candidate forCallerKind::ClaudeCodeChanges
core/src/parse.rs: prepend"hook_event_name"to ClaudeCode event field candidatescore/tests/fixtures/claude-code-pre-tool-hook-event-name.json: real-format PreToolUse fixturecore/tests/fixtures/claude-code-post-tool-hook-event-name.json: real-format PostToolUse fixture.cspell.json: addtoolu(Claude Code tool_use_id prefix)polyhook.wasmacross all SDK packagesTest plan
cargo test -p polyhook-core— 138 passedclaude_code_pre_tool_hook_event_nameassertsevent = "tool:before"claude_code_post_tool_hook_event_nameassertsevent = "tool:after"Closes #5
🤖 Generated with Claude Code