Repository navigation
feat(kiro): run user hooks in Chat - #46030
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
|
Merged current main into this branch (no code changes) so CI picks up the max-lines fix from #46033, which broke the static analysis job here. |
|
Thanks @LDH1103, this was exactly the right fix and a really thorough write-up. I confirmed on kiro-cli 3.5.0 that the opt-in is what loads the hooks, then merged it as is. Much appreciated! |
ELI5
Kiro lets people add hooks: small scripts that run when a chat starts, before a tool runs, and so on. They ran in Kiro's terminal UI but not in Orca's Kiro chats. Now they run in both.
What Changed
Before: Kiro chats ignored the user's hooks in
KIRO_HOME/hooks(default~/.kiro/hooks). APreToolUsehook that blocks a command or asks first did nothing in Chat, though it worked in a Kiro terminal tab.After:
KIRO_HOME/hooks, as Kiro's TUI does.PreToolUsehook that exits 2 stops the tool. The chat shows the tool row as failed, and the model gets the hook's reason.PreToolUsehook that answersaskarrives as an ordinary permission request, titled with the hook's reason. Full access approves it like any other request Kiro sends. Ask mode gets the existing Allow/Deny card.Mechanism: Kiro V3 over ACP builds its hook runtime only when the client sends
clientCapabilities._meta.kiro.hooksatinitialize.KIRO_ACP_DIALECTinsrc/main/acp/acp-dialects/kiro-dialect.tsnow sets{ enabled: true, v2: true }there, the value Kiro's TUI sends.acp-session-runtime.tsalready spreads a dialect'sclientCapabilitiesintoinitialize, as it does for Cursor's_meta. The launch spec comment that said V3 runs no user hooks in Chat is updated.Why
A hook is usually a guard, so skipping it in Chat is the surprising part: the same command that a hook blocks in the terminal ran in a chat. One capability flag fixes it with no new code path. Kiro loads, runs and reports the hooks itself, over ACP messages Orca already renders.
Considered and not done: claiming hook-ask requests so they always show a card, even in Full access. Full access already approves every permission request Kiro sends, and a hook ask is the same request.
Linked Issue
Fixes #46029
Visual Proof
Before: nothing to see. The hooks didn't run, so the blocked command ran too.
After, in a hidden Windows dev build with a test hooks file (the UI is in Korean). The hook blocked
echo BLOCKPROBE2, so its row shows as failed ("1 실패"). Forecho ASKPROBE2the hook asked ("orca e2e hook asks"), Full access approved, and the command ran ("0 종료"):Testing
Windows 11, kiro-cli 3.1.0, a real Kiro account, dev build with
ORCA_BACKGROUND_LAUNCH=1, driven over CDP. A tempKIRO_HOMEheld one hooks file withSessionStart,UserPromptSubmit,PreToolUse(matcher: '*') andStophooks. Each ran a.cmdthat logs its trigger, and flag files madePreToolUseblock (exit 2) or ask.Raw ACP: without the opt-in, none of the hooks ran. With it, all four ran. A block sent a failed
tool_call_updatewith no permission request. An ask sent a pendingtool_calland thensession/request_permissionwith Allow/Deny.Dev build, Full access: the hooks logged all four triggers. The blocked command shows as a failed row and the model replied with the hook's reason. The asked command was approved and ran.
Maintainer check, macOS, kiro-cli 3.5.0 over raw ACP (throwaway HOME and KIRO_HOME, no account): with the opt-in, Kiro sends
_kiro/hooks/didChangelisting the hooks file andsession.new.timinggains ahooksphase. Without it, neither happens. Turns need a real account, so block and ask were not re-run on 3.5.0.Not run: Ask mode's card for a hook ask, kiro-cli 3.5.0, macOS, Linux, SSH and the phone app.
Automated: none added. The change is one capability object, and spreading it into
initializeis existing code.pnpm check:changed --base=upstream/mainpassed (26 checks).I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
orca-agent-status.json, installed for terminal status) is in the same folder, so it also runs in chats now. Chat sessions start without the pane hook env, so it has nothing to report there (read from the code).Back out with a plain revert.
Level: Low
AI Disclosure
Written with Claude Code (Claude Opus 5.5).
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
KIRO_HOME, as its TUI does.KIRO_HOME/hooks.initialize. Kiro's hook load adds 4-6 ms tosession/new(3 runs, kiro-cli 3.5.0). Orca's own status hook, which now also runs in chats, exits early because chat sessions stripORCA_PANE_KEYand the hook env (STRUCTURED_CHILD_ENV_TO_DELETE): median 15.2 ms, p90 23.4 ms per trigger over 30 runs, exit 0, no output, nothing posted. That is about 2 runs per turn plus 2 per tool call, the same as in a Kiro terminal.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)