Skip to content

fix(mod): only take ExitPlanMode PermissionRequest events (#2159) - #2160

Merged
backnotprop merged 1 commit into
mainfrom
fix/mod-permission-request-filter
Oct 25, 2026
Merged

backnotprop merged 1 commit into
mainfrom
fix/mod-permission-request-filter

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Part of #2159 (part 2 only).

What changed

The mod's classic.PermissionRequest hook (apps/hook/hooks/mod/register.ts) was registered with no matcher, so the engine selected it for every tool's permission prompt and returned next(e) for everything but ExitPlanMode. Under a guard plugin seated above the mod (cc-plugin-sec-default on Team/Enterprise accounts), that made Claude Code print plannotator: its classic.PermissionRequest hook was skipped… at the first permission prompt of any tool in every session.

It is now registered with the engine's own matcher, on('classic.PermissionRequest', { tool_name: PLAN_TOOL }, …) (the same on(event, matcher, hook) form command.run already uses; tool_name is a field of the PermissionRequest input in the engine's types). The engine no longer selects the hook for other tools. During a plan approval the guard can still skip it, and #2043's approval record answers that in the classic command hook, as before. ExitPlanMode behaviour is unchanged (allow with updatedInput.plan and setMode).

claude plugin validate apps/hook passes and lists classic.PermissionRequest{tool_name=?}.

Tests

  • apps/hook/hooks/mod/register.test.ts: the hook is registered once, with matcher { tool_name: 'ExitPlanMode' }; no wildcard or classic.* registration.
  • Engine harness (scripts/test-claude-code-mod.sh, apps/hook/tests/register.test.ts): the approved ExitPlanMode's permission prompt is answered by the mod (allow, updatedInput.plan, setMode) and the hooks beneath never run; a Bash permission prompt goes past the mod to the hooks beneath unchanged. Also fixes a stale harness assertion (the bundled Inbox tool list now has search). Harness: 38 pass, 0 fail (Claude Code 2.1.310).
  • bun test apps/hook/hooks/mod/ 190 pass; bun run typecheck clean.

Not in this PR

Part 1 of the issue (the prompt.context skip notice for the Inbox reminder, e.g. moving it to a SessionStart command hook) is a design decision left for the owner.

The mod's classic.PermissionRequest hook was registered with no matcher, so
under a guard plugin seated above (cc-plugin-sec-default on Team/Enterprise
accounts) Claude Code printed "its classic.PermissionRequest hook was skipped"
at the first permission prompt of any tool. Register it with the matcher
{ tool_name: 'ExitPlanMode' }; the plan approval path is unchanged (#2043's
approval record answers a skip there).

Tests: the registration's matcher (bun), and in the engine harness the
approved ExitPlanMode prompt answered by the mod with updatedInput.plan and
setMode while another tool's prompt goes past it; also updates a stale
harness assertion for the Inbox's search action.
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