Skip to content

fix(core): detect hook_event_name from real Claude Code runtime#6

Merged
tupe12334 merged 2 commits into
mainfrom
fix/hook-event-name-detection
Jun 2, 2026
Merged

fix(core): detect hook_event_name from real Claude Code runtime#6
tupe12334 merged 2 commits into
mainfrom
fix/hook-event-name-detection

Conversation

@tupe12334
Copy link
Copy Markdown
Owner

Summary

  • Real Claude Code sends "hook_event_name":"PreToolUse" — not "type":"PreToolUse"
  • extract_event_field in parse.rs only checked ["event", "hookEvent", "hook_event", "type"], missing hook_event_name
  • WASM fell through to HookEventEvent::Notification, silently approving all tool calls
  • Fix: add "hook_event_name" as first candidate for CallerKind::ClaudeCode

Changes

  • core/src/parse.rs: prepend "hook_event_name" to ClaudeCode event field candidates
  • core/tests/fixtures/claude-code-pre-tool-hook-event-name.json: real-format PreToolUse fixture
  • core/tests/fixtures/claude-code-post-tool-hook-event-name.json: real-format PostToolUse fixture
  • Two new parse tests covering the real Claude Code format
  • .cspell.json: add toolu (Claude Code tool_use_id prefix)
  • Rebuilt polyhook.wasm across all SDK packages

Test plan

  • cargo test -p polyhook-core — 138 passed
  • All SDK coverage checks pass (pre-push hook)
  • claude_code_pre_tool_hook_event_name asserts event = "tool:before"
  • claude_code_post_tool_hook_event_name asserts event = "tool:after"

Closes #5

🤖 Generated with Claude Code

tupe12334 and others added 2 commits June 2, 2026 21:56
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>
@tupe12334 tupe12334 merged commit 0cef7e8 into main Jun 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sdk): Claude Code sends "hook_event_name" not "type" — WASM fails to detect PreToolUse

1 participant