Skip to content

fix(kimi-code): drop matchers on the matcher-less Kimi Code events - #2639

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2615-kimi-no-matcher-events
Aug 8, 2026
Merged

fix(kimi-code): drop matchers on the matcher-less Kimi Code events#2639
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2615-kimi-no-matcher-events

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Premise correction

The issue is right that rulesync emits matcher on Kimi Code events that cannot use one, but it names the wrong event set. Verified directly against the upstream Event Reference table (source):

  • The events whose "Matcher matches" column reads "Empty string" are exactly Stop, SessionHeartbeat, and Interrupt.
  • PermissionResult matches "Tool name", so a matcher there is meaningful. The issue lists it as matcher-less; it is not, and this PR keeps matchers on it.
  • The issue also omits Stop, which genuinely is matcher-less.

This PR therefore implements the corrected set rather than the one in the issue body.

Change

src/features/hooks/kimi-code-hooks.ts is a bespoke converter — it does not go through tool-hooks-converter.ts, so the shared noMatcherEvents mechanism does not apply. Added a local KIMI_CODE_NO_MATCHER_EVENTS set and a resolveMatcherPart helper used at the emission site: when the event is in the set and the definition carries a matcher, the matcher is skipped and a warning is logged with the same wording the shared converter uses (tool-hooks-converter.ts:806-810).

The set is keyed on native event names because the check runs after the canonical → native mapping, and SessionHeartbeat/Interrupt have no canonical counterpart at all — they are only reachable through a per-tool kimi-code override naming them directly.

Claude Code's CLAUDE_NO_MATCHER_EVENTS is deliberately not reused: Kimi Code's UserPromptSubmit matches the submitted prompt text, which Claude's does not, so the two sets are genuinely different.

The import path still preserves matchers, matching the asymmetry already documented at tool-hooks-converter.ts:843.

Tests

Added to kimi-code-hooks.test.ts: one case asserting all three matcher-less events drop the matcher and warn, and one asserting matchers survive on PermissionRequest, UserPromptSubmit, StopFailure, and PermissionResult with no warning at all.

Verification

  • pnpm cicheck
  • npx vitest run --config vitest.e2e.config.ts src/e2e/e2e-hooks.spec.ts

Closes #2615

Kimi Code's Event Reference documents Stop, SessionHeartbeat, and Interrupt
as matching an empty string, so a matcher on those events is a dead field.
Drop it with a warning at emission time, keyed on the native event name since
SessionHeartbeat and Interrupt are only reachable through a kimi-code override.

Closes #2615
@dyoshikawa
dyoshikawa merged commit 40a5671 into main Aug 8, 2026
9 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-2615-kimi-no-matcher-events branch August 8, 2026 18:50
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.

kimicode: matchers are emitted for matcher-less hook events, producing hooks that can never fire

2 participants