Skip to content

feat(kiro): report V3 engine (--v3) status through a global standalone hooks file - #24937

Closed
LDH1103 wants to merge 6 commits into
stablyai:mainfrom
LDH1103:feat/kiro-status-hooks
Closed

LDH1103 wants to merge 6 commits into
stablyai:mainfrom
LDH1103:feat/kiro-status-hooks

Conversation

@LDH1103

@LDH1103 LDH1103 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

#26695 made Kiro panes report working/done on Kiro's default engine by adding Orca's hooks to each custom agent config. Kiro's opt-in V3 engine (kiro-cli chat --v3) doesn't load those configs. It rejects them as "needs upgrading" and falls back to its built-in agent, and it only runs hooks from standalone ~/.kiro/hooks/*.json files. So a V3 pane still shows no status. This PR keeps #26695's default-engine integration as is and adds one Orca-owned standalone hooks file for V3.

This PR was rebuilt on top of #26695. Everything both PRs added (hook registry, resume argv and capability, /hook/kiro routing) now comes from main unchanged. What's left is V3 only.

What Changed

Before (on main): with --v3, a Kiro pane gets no status row. V3 never runs the agent-config hooks, and the PascalCase events it sends would be dropped by normalizeKiroEvent.

After: V3 panes go working on a prompt or tool and done on stop, with the provider sess_ id recorded for resume. The default engine behaves exactly as before.

Mechanism:

  • src/main/kiro/standalone-hook-settings.ts, src/main/kiro/standalone-hooks.ts (new): build, install, remove and report ~/.kiro/hooks/orca-agent-status.json (Kiro's v1 standalone format).
  • KiroHookService (hook-service.ts) calls into the new module:
    • install() / installRemote() write the script first, then the V3 file, then the agent configs as before. The V3 file goes in even with zero custom agents, since V3 applies it to the built-in default agent too.
    • remove() clears both.
    • getStatus() keeps the agent-config status as the primary state. A V3 file error is appended to the detail and lowers installed to partial.
  • kiro-events.ts, kiro-tool-fields.ts, provider-event-routing.ts: V3 sends Claude's PascalCase names.
    • UserPromptSubmit/PreToolUse/PostToolUse map to working, and Stop/SessionEnd map to done.
    • SessionStart is ignored: V3 fires it lazily, right before the first prompt.
    • UserPromptSubmit is a new-turn boundary.
    • The camelCase default-engine mapping is unchanged.
  • Docs: the Kiro row in the supported agents table now names both mechanisms.

Why

Probed with kiro-cli 2.27.1 on Windows 11. Each hook logged its stdin.

Run Result
--v2, agent config with embedded hooks, plus a standalone file Only the agent-config hooks fire (userPromptSubmit, stop). The standalone file never runs, so there is no double report.
--v3, the same default-engine agent config agent "…" needs upgrading for this agent engine, using "default". No agent-config hook fires.
--v3, KIRO_HOME pointed at a temp dir Hooks under $KIRO_HOME/hooks don't fire, and the session is written to the real ~/.kiro/sessions/. V3 ignores KIRO_HOME, so the V3 file goes under the home's .kiro, unlike #26695's KIRO_HOME-aware agents dir.
--v3, default agent, standalone file using Orca's encoded PowerShell launcher SessionStart, UserPromptSubmit and Stop arrive with the sess_… id on stdin.

Resume needs no change. getAgentResumeArgv('kiro') already appends --resume-id <id>, and kiro-cli reopens a sess_ id on the V3 engine and agent it was created with (verified on 2.27.0 in the previous revision of this PR).

Linked Issue

Refs #24177. #26695 covers the default engine; this adds --v3.

Visual Proof

N/A, no UI changes. The status rows are the same ones #26695 drives.

Hook firing for the rebuilt version is in the table above. The previous revision of this PR was run end to end in a pnpm dev build with --v3: orca-dev worktree ps showed working → done, and the pane resumed after a crash.

Testing

Automated (Windows 11):

  • New src/main/kiro/standalone-hooks.test.ts (21) and standalone-hooks-remote.test.ts (3):
    • v1 file with six triggers
    • doc-only names (PromptSubmit, AgentStop) not registered
    • byte-identical reinstall
    • partial and malformed files
    • every non-Orca shape refused and preserved
    • mixed-file removal
    • path stays under home when KIRO_HOME is set
    • install with zero agents
    • status combination
    • remove() clearing both files
    • POSIX remote install from a Windows host
  • kiro-events.test.ts: V3 payloads captured from kiro-cli 2.27, including a string tool_response. Unknown and doc-only names map to null. The one main expectation this changes on purpose is Stop, which used to map to null.
  • agent-session-resume.test.ts, tui-agent-startup-kiro-resume.test.ts, quit-capture: sess_ ids and a --v3 --agent command override.
  • All of feat(kiro): report Kiro agent status and list Kiro sessions in history #26695's Kiro tests pass unchanged, including the hook-service suite.
  • Kiro-related files: 13 files, 239 passed.
  • Wider run over src/main/agent-hooks and src/shared/agent-hook-listener: 1,925 passed, 8 failed. All 8 fail locally on Windows because /bin/sh, Git Bash and tmux are unavailable. They are in hook-script-outside-orca, installer-utils, local-tmux-managed-pty and spool, and src/main/agent-hooks is identical to main.
  • run-typecheck-projects-in-parallel exit 0. oxlint (with max-lines), anti-slop, code-quality (native and type-aware), the max-lines ratchet and reliability gates all pass.

Not live-tested: macOS, Linux and SSH, and kiro-cli 2.28+ (#26695 was validated on 2.29).

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Implemented with Claude Opus 5.5 (Anthropic) through Claude Code, directed and reviewed by me. The kiro-cli behavior above was measured on a real install, not taken from docs.

Review

Known limits:

  • If a user runs kiro-cli agent upgrade on agents that already carry Orca's hooks, the universal format keeps those hooks and V3 runs them too, so each event posts twice. The states are identical; repeated done doesn't re-notify, but a second UserPromptSubmit restarts the turn timer. main's installer reports such array-form hooks as unsupported and leaves them alone.
  • Remote uninstall is not implemented, the same as for the agent configs.
  • On V3 there is no permission-request hook, so an approval prompt reads as working. Stop has no final assistant text.
  • V3 appends an empty Output: / Exit Code: 0 block to the prompt for each UserPromptSubmit command hook, even when the hook prints nothing. Harmless, but the model sometimes mentions it (seen on kiro-cli 2.29.1).

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Companion PR #24938 was rebuilt the same way: it adds V3's session store to the Kiro history #26695 introduced.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…essions

kiro-cli 2.27 runs standalone hook files from ~/.kiro/hooks/*.json in its V3
engine and passes Claude-style events (SessionStart, UserPromptSubmit,
PreToolUse, PostToolUse, Stop, SessionEnd) with session_id/cwd/tool fields,
and the hook process inherits the PTY env. Orca now installs one Orca-owned
hooks file there (local and SSH) that runs the shared curl script, so Kiro
panes report working/done like the other hooked agents.

The events reuse the Claude-compatible lifecycle normalizer. SessionStart is
dropped because Kiro creates its session lazily right before the first
prompt. No synthetic title is added, so hookless (V2) Kiro keeps its current
tui-idle behavior.

The hook session_id is also recorded as Kiro's provider session, and Kiro
joins the resumable agents with `--resume-id`; kiro-cli reopens a session
with the engine and agent it was created under. The resume capability is
gated for older hosts like the other late additions.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one scope question and a doc nitpick.

Reviewed changes

This PR wires Kiro into Orca's managed-hook status and session-resume machinery, following the existing DSH/ZCode/Kimi pattern:

  • Managed hooks for Kiro — new src/main/kiro/hook-service.ts and hook-settings.ts install/remove an Orca-owned ~/.kiro/hooks/orca-agent-status.json (Kiro v1 standalone format) plus the shared launcher kiro-hook.{sh,cmd}, and register it across the install/refresh/remove/status and remote (SSH/WSL) installer registries.
  • Event mapping — /hook/kiro routing reuses normalizeCompatibleLifecycleEvent and the Claude tool-field extractor. SessionStart is dropped (Kiro creates its session lazily, right before the first prompt); UserPromptSubmit/tool events report working; Stop/SessionEnd report done; isNewTurnEvent is UserPromptSubmit.
  • Resume — kiro joins RESUMABLE_TUI_AGENTS, getAgentResumeArgv returns ['kiro-cli', '--resume-id', id] (only the flag is appended, since kiro-cli chat --tui ... already carries the subcommand), gated by the new agent-session.kiro-resume.v1 capability.
  • Deliberately unchanged — getTuiAgentRestSignal('kiro') stays none and no agent-state-rules file is added, so Kiro stays identity-only in the tui-idle hook lane, avoiding the #24177 regression for hookless V2 Kiro.

I read the full diff and ran the touched suites locally (src/main/kiro, src/main/agent-hooks, plus the shared resume/startup/event tests): 1192 passed, 11 skipped, 0 failed. The implementation is consistent with the neighbouring agent services and the tests pin exact behavior (byte-identical idempotency, malformed-file error, foreign-file preservation, exact resume launch command). No correctness or security issue found.

ℹ️ Kiro hooks can install and report installed while never firing

install() writes the hooks file for every detected Kiro install, and the managed-hooks status reader reports it installed, but kiro-cli only loads ~/.kiro/hooks/*.json under the --v3 engine. The default launchCmd (kiro-cli chat --tui) therefore leaves status silent, so a user can see Kiro's hooks as installed in settings while no status row ever appears. The PR body flags this as a maintainer call — worth confirming whether the default Kiro launch command should carry --v3, or whether the settings/status surface should qualify Kiro as opt-in. Not blocking; the feature is correct whenever --v3 is configured.

ℹ️ Nitpicks

  • docs/site/content/docs/agents/supported.mdx:43 still lists Kiro as plain "Auto-setup". Every other hook/status-capable agent names those capabilities in that column; adding a Kiro hook/status/resume note (with the --v3 qualifier) would keep the table accurate.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee831026-37ff-4329-98f7-0cf042150f14
📥 Commits

Reviewing files that changed from the base of the PR and between 3bb5aa0 and 213c4f8.

📒 Files selected for processing (19)
  • config/tsconfig.cli.json
  • src/main/agent-hooks/managed-agent-hook-registry.ts
  • src/main/agent-hooks/managed-hook-command-contract.test.ts
  • src/main/agent-hooks/remote-hook-service-registry-coverage.test.ts
  • src/main/agent-hooks/remote-managed-hook-installers.ts
  • src/main/agent-hooks/server-retired-pane-new-turn.test.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.test.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.ts
  • src/shared/agent-hook-listener/provider-dispatch.ts
  • src/shared/agent-hook-listener/provider-event-routing.ts
  • src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts
  • src/shared/agent-hook-listener/source-routing.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-hook-types.ts
  • src/shared/agent-resume-argv.ts
  • src/shared/agent-session-resume-runtime-capabilities.ts
  • src/shared/agent-session-resume.test.ts
  • src/shared/agent-session-resume.ts
  • src/shared/protocol-version.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough
📝 Walkthrough

Walkthrough

Adds managed Kiro hook settings, local and remote installation, status reporting, script refresh, and removal. Registers Kiro with managed-hook operations and routes its lifecycle and tool events through shared hook handling. Adds Kiro session-ID extraction, resume-command generation, and runtime capability mapping. Updates supported-agent documentation to describe Kiro hook status and resume support and the V3 engine requirement.

Changes Summary
Kiro hooks Adds local and remote hook management and lifecycle-event routing.
Kiro resume Adds provider-session extraction, resume-command generation, and runtime capability mapping.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 213c4

A malformed Kiro hooks file may be reported as installed even if its hooks do not run. This is a bounded configuration risk; verify status against Kiro’s actual hook acceptance behavior.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 213c4

The change reuses existing access controls, but installation can replace a same-named user configuration without positive ownership evidence. The demonstrated issue is account-local; remote cleanup and recovery coverage remain incomplete.

Retained concerns

  • Low · architecture · observed: Installation treats an existing same-named file with empty, missing, or non-array hooks as Orca-owned because ownership is defined by an all-entries predicate. Local and remote installation then replace the entire file, discarding unrelated user fields. This is an introduced configuration-ownership defect, not an established cross-user attack path.
Security review details

Security Blast Radius

  • inferred — The demonstrated configuration-ownership issue affects the same-named file in a selected execution account’s home. It does not establish cross-user access or privilege escalation. A holder of the existing listener token can supply pane and session metadata, but that bearer-token trust model predates this PR.

Trust Boundaries and Controls

  • observed — The HTTP listener authenticates the hook token before parsing the body or resolving the provider route. Shared envelope validation checks pane shape and tab consistency, and status disposition retains closed-pane and retired/restarted launch-token fences for Kiro.

Resilience and Maintainability Implications

  • observed — The host-authoritative resume path canonicalizes provider identity, creates a namespace-scoped claim, checks enabled state and cancellation before terminal creation, and rejects automatic requests based only on legacy renderer records. SSH scopes without namespace proof request the existing legacy route before launch side effects.

Hardening Proposals

  • proposed — Distinguish a missing configuration file from a present file lacking positive ownership evidence before whole-file replacement. Preserve unrelated fields or refuse replacement when ownership cannot be established.
Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 25 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check Warning The description identifies issue #24177 and related PR #26695, and the implementation addresses Kiro V3 hook-based status reporting. However, the required issue reference is written as 'Refs #24177' r… Add a direct link to issue #24177, or use the repository-required linked-issue format such as 'Fixes #24177' when appropriate.
Passed Passed checks: 3 passed
Check name Status Explanation
Out of Scope Changes check Passed The changes remain focused on Kiro hook installation, lifecycle event routing, status reporting, session resume support, tests, and documentation. These areas align with the stated objectives.
Title check Passed The title clearly identifies the main change: adding V3 status reporting through a standalone Kiro hooks file.
Description check Passed The description is detailed and covers the required sections, including user impact, implementation, rationale, testing, issue reference, visual proof, AI disclosure, risks, and checklist status. Mino…
Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 25 files. (1 skipped: 1 unsupported.)

Full details: Linked Issues check

Explanation

The description identifies issue #24177 and related PR #26695, and the implementation addresses Kiro V3 hook-based status reporting. However, the required issue reference is written as 'Refs #24177' rather than as a direct issue link.

  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95b33768-06af-4541-b10a-8b6485d93708
📥 Commits

Reviewing files that changed from the base of the PR and between ac46d9e and c1c5db7.

📒 Files selected for processing (24)
  • config/tsconfig.cli.json
  • src/main/agent-hooks/managed-agent-hook-registry.ts
  • src/main/agent-hooks/managed-hook-command-contract.test.ts
  • src/main/agent-hooks/remote-hook-service-registry-coverage.test.ts
  • src/main/agent-hooks/remote-managed-hook-installers.ts
  • src/main/agent-hooks/server-retired-pane-new-turn.test.ts
  • src/main/kiro/hook-service-remote.test.ts
  • src/main/kiro/hook-service.test.ts
  • src/main/kiro/hook-service.ts
  • src/main/kiro/hook-settings.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.test.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.ts
  • src/renderer/src/store/slices/agent-status-quit-capture-resumable-agents.test.ts
  • src/shared/agent-hook-listener/provider-dispatch.ts
  • src/shared/agent-hook-listener/provider-event-routing.ts
  • src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts
  • src/shared/agent-hook-listener/providers/kiro-events.test.ts
  • src/shared/agent-hook-listener/source-routing.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-hook-types.ts
  • src/shared/agent-session-resume.test.ts
  • src/shared/agent-session-resume.ts
  • src/shared/protocol-version.ts
  • src/shared/tui-agent-startup-kiro-resume.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/main/kiro/hook-service.ts Resolved
Comment thread src/main/kiro/hook-service.ts Resolved
Comment thread src/main/kiro/hook-settings.ts Resolved
- install() and installRemote() now leave a same-named
  ~/.kiro/hooks/orca-agent-status.json alone, and report an error, when it
  holds any hook that does not run Orca's script or cannot be parsed.
  Before, they rewrote the file whole.
- remove() deletes the file only when every hook in it runs Orca's script,
  so a file that mixes in someone else's hooks is kept.
- getStatus() reports `installed` only for entries Kiro would run: the file
  must be `version: "v1"`, and entries marked `enabled: false` do not count.
- The supported agents table now names Kiro's hooks/status/resume support
  and its V3 requirement.
@LDH1103

LDH1103 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews. The three CodeRabbit findings are addressed in 1df7733.

@pullfrog's notes:

  • Docs: the supported agents table now names Kiro's hooks/status/resume and its --v3 requirement.
  • installed while V2 never fires: I left the default launchCmd alone, because adding --v3 changes the engine for every Kiro user. Happy to flip it, or to qualify Kiro's status in settings, if maintainers prefer either.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (c1c5db7 → 1df7733), a hardening pass that keeps Orca's Kiro hook install from clobbering hooks someone else wrote:

  • Foreign-file guard on install — install() and installRemote() read the existing ~/.kiro/hooks/orca-agent-status.json first and return state: error, writing nothing, when it holds any hook that does not run Orca's script or cannot be parsed, instead of rewriting it whole.
  • Conservative removal — remove() unlinks the file only when every hook in it runs Orca's script, so a file that mixes in someone else's hooks is preserved.
  • Active-only status — getStatus() counts only entries Kiro would run: the file must be version: "v1", and entries marked enabled: false no longer count, so a disabled or non-v1 file reports partial rather than installed.
  • Docs — the supported-agents table now names Kiro's hooks/status/resume support and its --v3 requirement.
  • Tests — new local and remote cases pin foreign-file refusal, unparseable-file refusal, mixed-file preservation, and disabled/non-v1 status.

I read the full incremental diff and the full PR diff, and ran the touched suites locally: 20 passed, 0 failed. The new tests exercise the exact pre-fix bugs (the old install() rewrote the file whole; the old remove() deleted on any managed entry), so they are real coverage rather than tautologies.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e89f37fb-7cfd-4908-aa00-3cb85314a106
📥 Commits

Reviewing files that changed from the base of the PR and between c1c5db7 and 1df7733.

📒 Files selected for processing (5)
  • docs/site/content/docs/agents/supported.mdx
  • src/main/kiro/hook-service-remote.test.ts
  • src/main/kiro/hook-service.test.ts
  • src/main/kiro/hook-service.ts
  • src/main/kiro/hook-settings.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/kiro/hook-service-remote.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment thread src/main/kiro/hook-service.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior Pullfrog review (c1c5db7c70): the fix commit 1df7733f47, which hardens Kiro hook-file ownership and status counting, plus the doc update. The three CodeRabbit ownership/status findings are all addressed.

  • Ownership guard on install and remove — install(), installRemote(), and remove() read the existing orca-agent-status.json first and only rewrite or delete it when every entry runs Orca's managed script, so a foreign or mixed same-named file is preserved and reported as error instead of being clobbered.
  • Active-only status counting — getStatus() now counts only entries Kiro would run (requires version: "v1" and skips enabled: false), so a disabled or non-v1 hook set reports partial rather than installed.
  • Doc alignment — the supported-agents table names Kiro's hooks/status/resume and the --v3 requirement.

Verification on the branch: src/main/kiro plus the shared Kiro event/resume suites pass (22 tests), src/main/agent-hooks passes (1120 passed, 11 skipped), node typecheck is clean, oxlint is clean, and the changed-code quality gate reports 0 findings.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since the prior Pullfrog review (1df7733 → 3bb5aa0): a single fix that makes KiroHookService.remove() clear Orca's hooks from a mixed file instead of leaving the whole file (and Orca's hooks) in place.

  • Selective removal from a mixed file — when ~/.kiro/hooks/orca-agent-status.json holds Orca's hooks alongside hooks someone else added, remove() now rewrites it with only Orca's entries dropped (new removeManagedKiroHooks) rather than leaving the file untouched, so an uninstall actually clears Orca's entries while keeping the user's.
  • Whole-file delete preserved for Orca-owned files — a file whose every hook runs Orca's script is still unlinked, and remove() returns early for an unreadable file or one with no managed hooks.
  • Test rewritten — the mixed-file case now asserts the on-disk result is { version: 'v1', hooks: [userHook] } with status not_installed; the previous version asserted the mixed file survived verbatim.

I read the incremental range-diff and the full PR diff, and re-ran the Kiro plus shared resume/event suites: 68 passed, 0 failed. The rewritten test would fail against the pre-fix remove() (which never wrote a stripped file), so it is real coverage rather than a tautology.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

# Conflicts:
#	src/main/agent-hooks/managed-agent-hook-registry.ts
#	src/main/agent-hooks/managed-hook-command-contract.test.ts
#	src/main/agent-hooks/remote-hook-service-registry-coverage.test.ts
#	src/main/agent-hooks/remote-managed-hook-installers.ts
#	src/main/agent-hooks/server-retired-pane-new-turn.test.ts
#	src/renderer/src/runtime/agent-resume-host-authority-capability.ts
#	src/shared/agent-hook-listener/providers/compatible-lifecycle-events.ts
#	src/shared/agent-hook-listener/source-routing.ts
#	src/shared/agent-hook-relay.ts
#	src/shared/agent-hook-types.ts
#	src/shared/agent-session-resume.test.ts
#	src/shared/agent-session-resume.ts
#	src/shared/protocol-version.ts
@ryoupr

ryoupr commented Oct 7, 2026

Copy link
Copy Markdown

Thanks a lot for working on this! I use kiro-cli inside Orca and ran into the same problem, so this PR is very welcome.

It would also help beyond the sidebar status: right now Kiro panes don't show up in the "Send notes to" menu (Markdown review notes / Annotate AI Diff), since that menu only lists panes with hook status or a recognized agent title. With the hook rows from this PR, Kiro should appear there too.

A small thing I noticed while reading main (not verified at runtime, so I may be wrong): once a hook row is older than AGENT_STATUS_STALE_AFTER_MS (30 min), a pane stays selectable only if its terminal title shows an agent is still running. Since kiro-cli emits no title, an idle Kiro pane might become "Agent status is stale" after 30 minutes. Probably out of scope here — just sharing in case it's useful.

Happy to help test on macOS if that would be useful.

@LDH1103

LDH1103 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ryoupr, and thanks for reading main this closely!

"Send notes to": Yes. That menu builds its terminal targets from the hook status rows (deriveTerminalAgentSendTargets in running-agent-targets.ts), so once Kiro reports through the managed hooks in this PR, a Kiro pane gets a row and should show up there too.

Stale after 30 minutes: Your reading matches mine. Once a hook row is older than AGENT_STATUS_STALE_AFTER_MS, the pane stays selectable only if a live terminal title shows the agent is still there, and Orca has no Kiro title pattern, so an idle Kiro pane would read "Agent status is stale". ZCode had the same gap and closed it with a synthetic title: Orca writes ZCode ready from the hook state, backed by a captured transcript showing ZCode emits no OSC title. Kiro could take the same route. I'd rather do that in a follow-up PR with its own transcript than grow this one.

macOS testing: That would be really helpful, since my testing so far has been on Windows. If you have time, on this branch with kiro-cli chat --tui --v3:

  1. the sidebar status goes working → done across a turn,
  2. the pane appears in "Send notes to",
  3. quitting and reopening Orca resumes the Kiro session.

@w-felipe360

Copy link
Copy Markdown
Contributor

Hi @LDH1103, I opened #26695 without having seen this PR or #24938, sorry about the overlap.

The two seem to cover different Kiro engines. Yours uses the V3 standalone hooks in ~/.kiro/hooks/ and the V3 session store. Mine targets the V2 engine that Orca launches by default (kiro-cli chat --tui): it adds the hooks to each agent file in ~/.kiro/agents/ and reads history from ~/.kiro/sessions/cli/. That's the case you mentioned above, where the hooks don't fire unless Kiro runs with --v3.

Both PRs add src/main/kiro/hook-service.ts, so only one of them can merge as is. I can rebase mine onto yours as a V2 fallback, or close it if the maintainers would rather keep this one.

Takes main's default-engine Kiro integration (stablyai#26695) for every file both
sides added: hook registry, remote installers, resume argv and capability,
and the /hook/kiro event routing. The V3 standalone hooks are re-applied on
top in the next commit.
… file

Kiro's opt-in V3 engine (--v3) refuses default-engine agent configs and
loads ~/.kiro/hooks/*.json instead, so the hooks stablyai#26695 installs into each
agent never fire there. Install one Orca-owned standalone hooks file next to
them, locally and over SSH, and normalize V3's PascalCase events on the same
/hook/kiro route.

- The file always lives under the home's .kiro, not KIRO_HOME: kiro-cli
  2.27.1 V3 ignores KIRO_HOME for both hooks and sessions.
- It is installed even with no custom agent, since V3 applies it to the
  built-in default agent too.
- A same-named file Orca did not write (other entries, unknown fields, a
  non-v1 version, unparsable JSON) is left untouched and reported as an
  error, matching the default-engine installer.
- SessionStart is ignored: V3 fires it lazily right before the first prompt.
@LDH1103 LDH1103 changed the title feat(kiro): report Kiro status through managed hooks and resume its sessions feat(kiro): report V3 engine (--v3) status through a global standalone hooks file Oct 10, 2026
@LDH1103

LDH1103 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

I rebuilt this PR on top of #26695. Thanks @w-felipe360 for flagging the overlap, and @nwparker for sorting out the two engines in your review there.

Everything both PRs added now comes from main unchanged: the agent-config hooks, the registry, the resume argv and capability, and the /hook/kiro routing. What's left is V3 only:

  • an Orca-owned ~/.kiro/hooks/orca-agent-status.json
  • normalization for V3's PascalCase events

Here is what I measured on kiro-cli 2.27.1. V3 rejects default-engine agent configs as "needs upgrading", so #26695's hooks never fire under --v3, and V3 reads only standalone hook files. It also ignores KIRO_HOME, which is why this file lives under the home's .kiro. The updated description has the probe table and the known limits.

#24938 got the same treatment for V3 session history.

@ryoupr

ryoupr commented Oct 15, 2026

Copy link
Copy Markdown

@LDH1103

Thanks for rebuilding this on top of #26695! I tested the current head (6f488b7) on macOS. Short version: all three of your checks pass. Details below.

Setup

  • macOS 26.6.2 (Apple Silicon), kiro-cli 2.29.1, pnpm dev build of this branch
  • Kiro ran as kiro-cli chat --tui --trust-all-tools --v3 --agent kiro_default, launched from the tab bar after setting Arguments in Settings → Agents. kiro_default doesn't exist, so Kiro falls back to the built-in default agent. I did this to keep my own agent's hooks out of the test.
  • Everything below was observed with this setup.

1. Sidebar status: working → done ✅
Working on a prompt (with toolName=execute_bash while a tool runs), done on Stop. (screenshots 1, 2)

2. "Send notes to" ✅
The Kiro pane is listed and selectable. Sending a Markdown review note delivers File: README.md / Source: markdown / Line 3 / Excerpt: … / User comment: "…", Kiro acts on it, and the note is cleared. Two observations:

  • Kiro panes idle for more than 30 minutes (40m and 31m ago) were disabled with "Agent status is stale", while one from 14m ago was selectable. That's the gap we talked about, now reproduced with real Kiro panes. (screenshot 3)
  • A freshly started Kiro pane isn't listed until its first prompt, since this PR ignores SessionStart.

3. Quit and reopen

  • Quit → reopen: the daemon keeps running, so Orca warm-reattaches to the same kiro-cli process (same PIDs, no --resume-id). Status still updates afterwards. ✅
  • Workspace Sleep → reopen: Orca runs kiro-cli chat --tui --trust-all-tools --v3 --agent kiro_default --resume-id sess_…, and the conversation comes back. ✅ (screenshot 4)
  • Daemon crash (kill -9 on the daemon, then quit and relaunch Orca): same command line, conversation restored. ✅ (screenshot 5)
    A pane I had started with orca terminal create --command (so no saved launch config) was resumed without --v3, and it still came back in the V3 UI with its history, which matches your note about sess_ ids.
  • Settings → Terminal → Manage Sessions → restart the daemon (also from the status bar): the daemon restarts, but no terminal comes back. A plain shell tab didn't come back either (console: [terminal-lifecycle] mounted terminal leaf has saved PTY but no live transport), so this looks unrelated to this PR, and I couldn't use it to test resume.
More details: hook probe, tests, and other notes

Hook probe outside Orca (kiro-cli 2.29.1)

  • A standalone hooks file that logs stdin, in a --tui --v3 session: all six triggers fired with PascalCase hook_event_name and sess_ ids, including PreToolUse/PostToolUse (tool_name: "execute_bash", string tool_response) and SessionEnd (reason: "shutdown"). Feeding these payloads to normalizeKiroEvent gives: ignored → working → working → working → done → done.
  • With --no-interactive, SessionEnd didn't arrive. kiro-cli aborted on exit (libc++abi: … mutex lock failed), so that's probably on the kiro-cli side.
  • --v3 --resume-id sess_… reopened the conversation.

Tests on macOS

  • Kiro-related test files: 154 passed, 1 failed. The failure is a cross-version test that needs git tags my shallow clone didn't have.
  • The suites that need /bin/sh, which you couldn't run on Windows, pass: hook-script-outside-orca (4), installer-utils (71 passed, 3 skipped), spool (9). I didn't run local-tmux-managed-pty (no tmux here).
  • pnpm typecheck passes.

Other notes

  • It looks like V3 appends an empty Output: / Exit Code: 0 block to the prompt for each UserPromptSubmit command hook, even when the hook prints nothing. With only Orca's hook active, Kiro quoted my previous prompt as "Reply with just OK" (followed by an empty "Output:" and "Exit Code: 0"). Harmless, but the model sometimes mentions it.
  • My own agent config uses the universal format (array hooks). On 2.29.1, --v3 loads it and runs its hooks. The installer left it alone (no kiro-hook.sh entries), so there were no duplicate Orca hooks.
  • To run pnpm dev I worked around pnpm dev: workbench and right sidebar crash with "does not provide an export named 'GrowingByteBuffer'" #27238 locally; unrelated to this PR.

Screenshots:

  1. working
01-working
  1. done
02-done
  1. "Send notes to" with two stale Kiro panes
03-send-notes-menu
  1. resumed after Sleep
04-resume-after-sleep
  1. resumed after a daemon crash
05-resume-after-daemon-crash

@LDH1103

LDH1103 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks so much, @ryoupr. This is exactly the coverage I couldn't get on Windows, and the screenshots make it easy to follow.

A few notes on what you found:

  • kiro-cli 2.29.1: Good to know the PascalCase event names and sess_ ids still hold on 2.29.1. I had only probed 2.27.1.
  • /bin/sh suites: Thanks for running hook-script-outside-orca, installer-utils and spool. Those were the gap in my own testing. The one failing cross-version test needs git tags, so the shallow clone explains it.
  • Stale after 30 minutes: Thanks for reproducing it with real Kiro panes. I'll still handle it in a follow-up PR with a synthetic Kiro title, the way ZCode did, and link your screenshot there as the repro.
  • New pane missing until the first prompt: That's expected. On 2.27.1, V3 fired SessionStart lazily, right before the first prompt, so handling it wouldn't list the pane any earlier.
  • Empty Output: / Exit Code: 0 block: Orca's hook prints nothing, so that block comes from V3 itself. I'll add it to the known limits in the description.
  • Daemon restart from Manage Sessions: Agreed, that's separate from this PR, since a plain shell tab didn't come back either.
  • SessionEnd with --no-interactive: Agreed, that looks like kiro-cli aborting on exit rather than anything Orca can catch.

It's also good to see your universal-format agent config left alone. That confirms the installer doesn't touch configs it doesn't support.

Thanks again for taking the time to test all of this.

nwparker added a commit that referenced this pull request Oct 25, 2026
…default agent (#33660)

Kiro's V3 engine (default from Kiro CLI 3.0) now reports status in Orca: Orca installs a global hooks file under KIRO_HOME/hooks (covering the built-in default agent, local and remote, never overwriting user files) and recognizes V3's PascalCase hook events.

Fixes #31577
Supersedes #24937

Co-authored-by: Dongho Lee <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Thanks @LDH1103! Your commits landed in #33660 (merged, with co-author credit), rebased onto current main; the follow-up moves the V3 hooks file under KIRO_HOME, since kiro-cli 2.31+ reads global hooks there.

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.

4 participants