Skip to content

feat(crush): map the hook events Crush v0.99.0 fires - #3708

Merged
dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3672-crush-hook-events
Oct 30, 2026
Merged

dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3672-crush-hook-events

Conversation

@dyoshikawa

@dyoshikawa dyoshikawa commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Crush v0.99.0 (stable, 2026-10-29) fires 13 hook events instead of PreToolUse alone, and it now validates hooks when it loads the config. rulesync still wrote only PreToolUse and skipped every other event. This PR maps the rest. I checked the mapping against internal/hooks/events.go, internal/config/hooks.go and docs/hooks/README.md at the v0.99.0 tag.

  • Event mapping (both directions): postToolUse, postToolUseFailure, permissionRequest, sessionStart, sessionEnd, stopFailure, preCompact and postCompact keep their names (PascalCase in Crush). Three are renamed: beforeSubmitPrompt ⇄ TurnStart, stop ⇄ TurnEnd and stopCancelled ⇄ Interrupt. PermissionResult has no canonical counterpart, so it stays under the crush.hooks override. Import now puts mapped events back into the shared hooks block.
  • Matcher rule: Crush refuses to load the whole config when a matcher sits on an event without a tool. The adapter now drops the matcher with a warning on every event except PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest and PermissionResult. The check covers override keys too, in any spelling Crush accepts (for example turn_start).
  • Override keys: a crush.hooks key is now resolved to its event in any spelling (stop, TurnEnd, turn_end). It replaces the shared entries of that event, and override keys that name the same event are concatenated. Before this, TurnEnd silently replaced the shared stop hooks while turn_end became a second key.
  • Docs: the Crush hooks notes in docs/reference/file-formats.md and the generated hook event matrix are updated.
  • Tests: new unit tests cover the full mapping in both directions and the matcher drop. The e2e cases now cover postToolUse, sessionStart (with its matcher dropped), stop → TurnEnd, and the import of TurnEnd / PermissionResult.

Left open

The issue also suggests warning when a key under crush.hooks is one Crush would reject as an unknown event. This PR does not do that, so it uses Refs.

Refs #3672

🤖 Generated with Claude Code

https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth

dyoshikawa and others added 3 commits October 31, 2026 01:27
Crush v0.99.0 (stable, 2026-10-29) grows its hooks from PreToolUse alone
to 13 events and validates them at load time. Map the twelve that have a
canonical counterpart (postToolUse, postToolUseFailure, permissionRequest,
sessionStart, sessionEnd, beforeSubmitPrompt -> TurnStart, stop -> TurnEnd,
stopFailure, stopCancelled -> Interrupt, preCompact, postCompact) in both
directions. PermissionResult has no canonical event and stays under the
crush.hooks override.

Crush now rejects the whole config when a matcher is set on an event that
carries no tool, so the adapter drops the matcher with a warning on every
event except PreToolUse, PostToolUse, PostToolUseFailure,
PermissionRequest and PermissionResult.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
An override keyed by a Crush event name (`TurnEnd`) silently replaced the
shared entries of the same event, while `turn_end` became a second key
that Crush concatenates on top. Resolve every override key to its event
first, whatever spelling it uses: the override replaces the shared
entries of that event, and override keys naming the same event are
concatenated in order. Keys with no canonical event (PermissionResult)
are still written verbatim, folded by Crush's normalized spelling.

Also correct which Crush events can block or halt in the docs and pin
the hooks docs link to v0.99.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
@dyoshikawa
dyoshikawa merged commit 53918eb into main Oct 30, 2026
9 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3672-crush-hook-events branch October 30, 2026 17:43
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.

1 participant