Skip to content

refactor(aidd-context): generate each host's native project hook from one cited mapping - #1383

Merged
blafourcade merged 2 commits into
nextfrom
refactor/hook-generate-one-mapping
Nov 26, 2026
Merged

blafourcade merged 2 commits into
nextfrom
refactor/hook-generate-one-mapping

Conversation

@blafourcade

@blafourcade blafourcade commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What

aidd-context:08-hook-generate becomes a general project-hook generator. It no longer follows the framework's own hook model.

Before After
one script copied into every host, branching on a host-ID argument one native handler per host: it reads that host's payload and answers in that host's format
OpenCode and Kilo: a generated gateway that wraps the script OpenCode and Kilo: the plugin module itself, written verbatim
a fixed menu of six intents, mirroring the framework's hook levels a need in the user's words, mapped to a moment and an effect
per-host facts in hosts.md and again in write-hook.cjs, drifting one mapping in write-hook.cjs, each fact citing the host's doc or a capture of the same route, exposed by --describe
no Kiro Kiro written natively to .kiro/hooks/<name>.json
  • hosts.md keeps detection only. Kimi Code CLI has no project hooks, so it is stated as not offered.
  • hook-authoring.md holds the moments, the effects and six rules; the framework-only rule is gone.
  • The JavaScript template is removed, since the handler's runtime is the project's.
  • docs/COMPATIBILITY.md now points to --describe instead of hosts.md.

Behaviour change: the writer accepts each host's six moment events only. Extra events such as Claude's Notification and Cursor's beforeShellExecution are refused; a matcher on the tool event covers them.

Facts corrected from the vendor docs:

  • Copilot takes a matcher on preToolUse and postToolUse, and blocks with permissionDecision: "deny" as well as exit 2.
  • OpenCode and Kilo expose chat.message, tool.execute.after, session.created and session.idle.

Supersedes the framing of #1346: facts come from each host's own docs, not from what the CLI carries.

Verify

  • node --test scripts/__tests__/hook-generation.test.js: 25 pass. 23 failed before the code.
  • The tests pin every fact that cites a capture against that capture file. Mutation proofs: renaming tool_input turns only the moment test red, and changing Kiro's block exit code turns only the effect test red.
  • validate-skill.cjs on the skill: exit 0. run.cjs: exit 0.
  • node --test scripts/__tests__/hook-generation.test.js: 26 pass. Each host names its shell tool, and every name that cites a capture is checked against what the host really sent.

Real trials on every host

Haiku ran the skill on a copy of the plugin, in a project holding all 8 host markers, asked to "block any shell command containing rm -rf, on every host installed here". It wrote one handler per host, each with that host's payload, shell tool and answer, so 15 files.

Each host then ran one real session in a copy of that project, asked to run echo 'rm -rf is just text here' > ran.txt.

Host Model Result
Claude Code haiku blocked, hook reason shown, no ran.txt
Codex gpt-6-luna blocked once the project is trusted and the hook reviewed (--trust --dangerously-bypass-hook-trust, in a throwaway CODEX_HOME); an untrusted project loads no project hook, as Codex documents
Copilot mai-code-2-flash blocked: "Denied by preToolUse hook: hook exited with code 2"
Kiro qwen3-coder-next blocked execute_bash 3 times; the model then rewrote the line as 'r'-'m -'-'rf', which the literal match lets through. The hook works, but a literal match does not stop a model that evades it
OpenCode opencode/big-pickle blocked by the plugin, no ran.txt
Kilo kilo/kilo-auto/free blocked by the plugin, no ran.txt
Cursor none not run live: the account's usage limit is reached. Offline, the generated handler blocks with exit 2 on a captured Shell payload
Antigravity gpt-oss-120b-medium blocked: "tool call denied by pre-tool hook: Blocked by block-rm-rf". The Gemini models are out of quota

The first trial round found a defect, fixed in 8667237: haiku wrote one handler for all hosts, guessing the shell tool by name, and that handler missed Antigravity's run_command. Each host's description now names its shell tool, and the authoring rules ask for one handler per host. Copilot's tool name on its own route is not documented, so it is null.

Every session and temporary folder of the trials is deleted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf

blafourcade and others added 2 commits November 26, 2026 07:12
… one cited mapping

The hook generator no longer copies one script across hosts or wraps it in a
gateway. Each host gets its own handler in its documented format. write-hook.cjs
holds the only per-host mapping, each fact cited to the host's doc or a capture of
the same route, and --describe exposes it to the skill. Kiro is written natively.
The user states a need instead of picking from a fixed intent list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
…ds the right tool

A small-model trial wrote one handler guessing the shell tool across hosts, and
it missed Antigravity's run_command. Each host now states its shell tool, the
captured names pinned by a test, and the skill writes one handler per host.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
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