Skip to content

feat(cli): deliver kiro post tool use and stop hooks - #1363

Merged
blafourcade merged 13 commits into
nextfrom
feat/kiro-post-tool-and-stop-hooks
Nov 25, 2026
Merged

blafourcade merged 13 commits into
nextfrom
feat/kiro-post-tool-and-stop-hooks

Conversation

@blafourcade

@blafourcade blafourcade commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🎯 What & why

Delivers Kiro's PostToolUse and Stop hooks, not only SessionStart. Refs #1347.

🛠️ How it works

  • Profile maps SessionStart, PostToolUse, Stop. host-kiro.cjs lists the written file for fs_write and str_replace, carries the command of execute_bash, and continues the turn at Stop with a {"decision":"block","reason":...} on stdout (documented for the Agent Stop trigger, https://kiro.dev/docs/hooks/types/).
  • A PostToolUse plugin matcher is carried as Kiro tags, one hook per tag (Kiro treats a | matcher as a regex, so the plugin string cannot go through verbatim): Write, Edit and Delete become write, Bash, Shell and PowerShell become shell. A name Kiro has no tool for selects nothing and the hook is skipped with a warning. The matcher is read through the shared plugin hook shape; Kiro holds only its name-to-tag entries.
  • Hook names are <plugin>-<trigger>-<script>, with -write or -shell appended for a matched PostToolUse hook.
  • Probed on kiro-cli 3.6.0 (V3 engine), three free models. Payloads captured, not hand-derived: scripts/__tests__/fixtures/hook-payloads/kiro-PostToolUse.json (fs_write, read_file, execute_bash, str_replace), kiro-Stop.json.
  • Kept as-is from the shared adapter contract: path.resolve of a relative path, and the fs_write-without-text branch. Not from a Kiro capture.
  • docs/COMPATIBILITY.md is not edited here. The PR that owns it takes the replacement text for its Kiro lines, so this PR does not close the issue.

🧪 How to verify

  • make validate
  • pnpm exec lefthook run pre-commit --all-files
  • cd cli && pnpm exec lefthook run pre-push (9925 passed, 1 expected fail, 15 skipped; the OpenCode event-bridge flake failed once, rerun green)
  • cd cli && pnpm build (bundle 881.7 KB, budget 897 KB, +2.5 KB over 879.2 KB)

Test-first: the matcher, edit and shell tests were written first and failed on the missing matcher, the unlisted edited file and the missing command. Mutations of the shell tag, the trigger guard, the tag dedupe, and each name-to-tag entry (edit, delete, powershell) turn their own test red.

⚠️ Heads-up

Limits, not coded as workarounds:

  • Text printed by a PostToolUse hook did not reach the model (every shape tried, two models). A fix needed after a write is not deliverable on this host.
  • delete_file, fs_append and execute_pwsh appear only in the vendor docs: no payload captured, so Delete and PowerShell matcher names rest on the docs' tool families.
  • stopActive is always false: no payload field marks a continuation. No Stop loop was seen on 3.6.0.
  • A Stop command hook exiting 1 continues the turn, so a crashing Stop script continues it. Not audited here.
  • kiro-cli 3.6.0 only. Kiro IDE 1.0 loads the same .kiro/hooks/*.json and is unprobed; its docs say hook stdout reaches the agent.
  • Double run: a script installed in both home and project runs twice at PostToolUse and Stop. Two identical hooks in two files both ran; the home plus project case is unprobed.

✅ I certify

  • I DO CERTIFY I READ EACH LINE OF THE PULL REQUEST BECAUSE I AM A SOFTWARE ENGINEER, NOT A AI PUPPY.

🤖 Generated with Claude Code

blafourcade and others added 5 commits November 25, 2026 15:06
Map PostToolUse and Stop in the Kiro profile and read both in host-kiro,
from payloads captured on kiro-cli 3.6.0. Stop continues the turn with a
block decision; nothing is printed after a tool call, whose output the
model was not seen reading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A script paired across events (memory, artifacts) shared one hook name
under two triggers, and whether Kiro keys hooks by name is unprobed. The
name now carries the trigger. Pin the guards on a write with no path or
no text, and reword the Kiro payload limits to what the kept model
output shows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ss agents and hook matchers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… tools

A PostToolUse script no longer runs after every Kiro tool: the matcher is
translated to the tags Kiro selects by, one hook per tag. The adapter lists the
file of a str_replace edit and the command of an execute_bash call, from payloads
captured on kiro-cli 3.6.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
blafourcade and others added 7 commits November 25, 2026 17:51
…ok shape

Kiro tokenized a plugin matcher and restated the file-write names the
shared shape already holds. Export both from plugin-hooks-shape and keep
only the name-to-tag entries Kiro owns, each now guarded on its own.
Cite the vendor docs for the Stop block and the hook key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-tool-hooks' into feat/kiro-post-tool-and-stop-hooks
…ugh one shared reader

A plugin ships only plain `|` lists, so the regular expression branch and the
empty and star cases go; the reader is case-insensitive as the bridges are, and
the skipped-group warning has one builder other hosts reuse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tever their case

Kiro's tag map is profile data like agy's rename map, one reader selects
tools for both hosts and reads a name in any case, one builder words the
unmatched-matcher warning. A Kiro str_replace edit now carries what it
put and what it replaced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ro-post-tool-and-stop-hooks

Kiro reads a matcher through the shared hostToolNamesMatching and warns
through the shared matcherNamesNoToolWarning, with no copy of either.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd-stop-hooks

# Conflicts:
#	scripts/__tests__/fixtures/hook-payloads/README.md
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