Skip to content

Add Kiro CLI and Kiro IDE agent support#554

Open
alishakawaguchi wants to merge 42 commits intomainfrom
alisha/kiro-oneshot
Open

Add Kiro CLI and Kiro IDE agent support#554
alishakawaguchi wants to merge 42 commits intomainfrom
alisha/kiro-oneshot

Conversation

@alishakawaguchi
Copy link
Contributor

@alishakawaguchi alishakawaguchi commented Feb 28, 2026

Summary

  • Add Kiro agent integration (both CLI and IDE modes): hook installation, lifecycle event parsing, transcript analysis, and session management
  • Fix shared ReadAndParseHookInput stdin timeout bug that could drop data for any agent with slow EOF
  • Guard empty transcript fallback to Kiro-only, preventing silent data loss for other agents
  • Strategy fixes for TTY-based agents: commit linking, transcript backfill, rewind transcript clearing

Key changes

New agent package (cmd/entire/cli/agent/kiro/)

  • Full Agent interface implementation including HookSupport, TranscriptAnalyzer
  • Hook installation via .kiro/settings/hooks.json — works with both Kiro CLI and Kiro IDE
  • Lifecycle event parsing (session start/stop, turn start/end) from Kiro's hook format
  • Transcript extraction from Kiro's SQLite-backed session format

Shared hook input reading (cmd/entire/cli/agent/event.go)

  • Introduced ErrEmptyHookInput sentinel error for agents to handle gracefully
  • Two-phase stdin read: Peek(1) with 500ms timeout to detect empty pipe, then io.ReadAll without timeout once data is confirmed — fixes a bug where the old single-phase timeout could discard valid data if EOF was slow

Strategy fixes (cmd/entire/cli/strategy/)

  • Condensation: Empty transcript fallback now guarded by AgentTypeKiro check; other agents get an explicit error instead of silently proceeding with no data
  • Hooks: PrepareCommitMsg fast path extended for TTY-based agents (Kiro in tmux) via TerminalAgent interface — auto-links commits during ACTIVE sessions without prompting
  • Git: Backfill TranscriptPath in SaveStep for agents with deferred transcript persistence
  • Rewind: Clear TranscriptPath after rewind so condensation reads from the reset shadow branch, not the stale live transcript

E2E runner (e2e/agents/kiro.go)

  • Registers Kiro with the E2E framework
  • Supports both prompt and interactive session modes
  • Note: Kiro E2E tests cannot currently run in CI due to upstream issues:
  • Kiro agent has been removed from CI E2E workflows until these are resolved

Test plan

  • Unit tests for hooks, lifecycle, types, transcript, and agent registration (cmd/entire/cli/agent/kiro/*_test.go)
  • All tests pass: mise run test:ci (unit + integration + canary)
  • E2E validated manually with Kiro CLI and Kiro IDE locally
  • Lint clean: mise run fmt && mise run lint

🤖 Generated with Claude Code

Screenshot 2026-03-05 at 4 07 50 PM

alishakawaguchi and others added 9 commits February 26, 2026 15:35
Flip the implementer procedure from unit-test-first TDD to E2E-driven
development where E2E tests are the primary spec and unit tests are
written after each E2E test passes to lock in behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 3b9c57f41fc2
Replace hardcoded method names and event types with source-file references
so skill files age gracefully when interfaces change. Split ambiguous
AGENT_SLUG parameter into AGENT_PACKAGE (Go dirs), AGENT_KEY (registry),
and AGENT_SLUG (E2E/scripts). Add hook-only scope section to SKILL.md
and remove checklist from researcher exclusion list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: f5f2b5651f79
Implement full agent integration for Amazon's Kiro AI coding CLI,
following established patterns from OpenCode (SQLite-backed transcripts)
and Cursor (JSON hooks file). Includes core agent, lifecycle hook
handling (5 hooks via stdin JSON), hook installation to
.kiro/agents/entire.json, transcript analysis with SQLite3 CLI access,
E2E agent runner, and comprehensive unit tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: f8edcbac7a08
Enforce strict discipline: E2E tests drive development, unit tests are
written last. Previously the skill interleaved unit test writing after
each E2E tier, which meant unit tests were written to match assumed
behavior rather than observed behavior from actual E2E runs.

Key changes:
- Remove all "After passing, write unit tests" blocks from Steps 4-12
- Add Step 13 (Full E2E Suite Pass) to run complete suite before unit tests
- Add Step 14 (Write Unit Tests) consolidated with golden fixture guidance
- Rename Phase 2 to "Write E2E Runner" (no test scenarios, runner only)
- Add "Core Rule: E2E-First TDD" section to SKILL.md and implementer.md
- Delete test-writer Step 6 (Write E2E Test Scenarios)
- Update all step references and renumber to 1-16

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 2ca049d51515
Implement the Kiro (Amazon AI coding CLI) agent for the Entire CLI,
following the E2E-first TDD approach. Kiro runs inside tmux (has TTY),
requiring special handling in the prepare-commit-msg fast path via
agentUsesTerminal() to distinguish agent commits from human commits.

Key changes:
- cmd/entire/cli/agent/kiro/: Full agent package (hooks, lifecycle,
  types, session ID via SQLite, transcript parsing)
- e2e/agents/kiro.go: E2E test driver with KiroSession wrapper using
  end-of-line prompt pattern to avoid matching echoed input
- strategy/manual_commit_hooks.go: Restore hasTTY() + add
  agentUsesTerminal() for TTY-based agents like Kiro
- strategy/manual_commit_rewind.go: Clear TranscriptPath on rewind
  so condensation reads from shadow branch, not stale transcript
- lifecycle.go, manual_commit_git.go: TranscriptPath backfill for
  agents with deferred transcript persistence
- .github/workflows/e2e*.yml: Add kiro to CI matrix and options

108 unit tests across 4 test files, all E2E and integration tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 4a7c9d636b45
Each phase and implementation step now includes a `/commit` instruction
so progress is committed incrementally rather than piling up uncommitted.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 92e9dafcd86f
@alishakawaguchi alishakawaguchi requested a review from a team as a code owner February 28, 2026 00:12
Copilot AI review requested due to automatic review settings February 28, 2026 00:12
@cursor
Copy link

cursor bot commented Feb 28, 2026

PR Summary

Medium Risk
Introduces a new agent and modifies git-hook/condensation/rewind flows, which can affect checkpoint linking and session state handling across commits; changes are well-covered by extensive unit and e2e tests but touch core workflow paths.

Overview
Adds first-class support for the Amazon Kiro agent, including a new cmd/entire/cli/agent/kiro implementation (hook installation/uninstallation, lifecycle hook parsing with stable session IDs, transcript caching/analysis for both CLI and IDE formats, and session read/write).

Updates manual-commit behavior to better handle deferred transcript availability and terminal-emulator agents: commit hooks can auto-link during active Kiro sessions, condensation no longer fails when no live transcript exists yet, transcript paths are backfilled on turn end/save, and rewinds clear TranscriptPath to force shadow-branch-based extraction.

Expands E2E support and docs to include Kiro: registers a kiro-cli-chat runner with CI auth checks/SIGV4 support, updates workflow permissions, and extends E2E matrices/options and task help text.

Written by Cursor Bugbot for commit 9677610. Configure here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds first-class support for the Kiro (Amazon) agent to Entire CLI, including hook installation/parsing and an E2E runner, and updates strategy/lifecycle handling for edge cases discovered during integration (notably deferred transcripts and mid-turn commits).

Changes:

  • Add a new cmd/entire/cli/agent/kiro/ package implementing hook support and lifecycle parsing (with SQLite transcript caching).
  • Add a Kiro E2E agent runner and wire Kiro into E2E task help text and CI workflows.
  • Adjust manual-commit strategy and lifecycle to better handle mid-turn commits, deferred transcript availability, and rewind/condensation edge cases.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
scripts/test-kiro-agent-integration.sh Adds a manual script intended to validate Kiro hook firing/stdin payloads.
mise-tasks/test/e2e/_default Updates E2E task help text to include kiro as an agent option.
e2e/agents/kiro.go Adds Kiro implementation for the E2E harness (tmux interactive mode + retry gating).
cmd/entire/cli/strategy/manual_commit_rewind.go Clears TranscriptPath after rewinds so post-rewind condensation uses the shadow branch state.
cmd/entire/cli/strategy/manual_commit_hooks.go Updates prepare-commit-msg behavior for “TTY agents” (e.g., Kiro) and active-session commit linking.
cmd/entire/cli/strategy/manual_commit_git.go Backfills TranscriptPath during SaveStep for deferred transcript persistence.
cmd/entire/cli/strategy/manual_commit_condensation.go Allows condensation to proceed with minimal session data when transcript isn’t available mid-session.
cmd/entire/cli/lifecycle.go Passes transcript ref into turn-end transitions and backfills session TranscriptPath when needed.
cmd/entire/cli/hooks_cmd.go Registers the Kiro agent package via blank import.
cmd/entire/cli/agent/registry.go Adds AgentNameKiro / AgentTypeKiro constants.
cmd/entire/cli/agent/kiro/types.go Defines Kiro hook stdin payload types and .kiro/agents/entire.json structures.
cmd/entire/cli/agent/kiro/types_test.go Adds unit tests for Kiro hook JSON parsing and config marshaling.
cmd/entire/cli/agent/kiro/lifecycle.go Implements lifecycle event parsing + session-id caching.
cmd/entire/cli/agent/kiro/lifecycle_test.go Adds unit tests for Kiro lifecycle parsing and cache behavior.
cmd/entire/cli/agent/kiro/hooks.go Implements Kiro hook install/uninstall/detect for .kiro/agents/entire.json.
cmd/entire/cli/agent/kiro/hooks_test.go Adds unit tests for hook installation/idempotency/detection.
cmd/entire/cli/agent/kiro/kiro.go Implements Kiro agent identity, transcript caching via sqlite3, session read/write behavior.
cmd/entire/cli/agent/kiro/kiro_test.go Adds unit tests for Kiro agent methods (with one incomplete DetectPresence test).
cmd/entire/cli/agent/kiro/AGENT.md Adds a Kiro integration one-pager documenting hooks/config/transcripts.
.github/workflows/e2e.yml Adds kiro to the E2E matrix and installs kiro-cli.
.github/workflows/e2e-isolated.yml Adds kiro as an isolated E2E workflow option and installs kiro-cli.
.claude/skills/agent-integration/test-writer.md Refocuses “write-tests” phase on creating the E2E runner only.
.claude/skills/agent-integration/researcher.md Refactors research output into a persistent AGENT.md one-pager.
.claude/skills/agent-integration/implementer.md Reworks the workflow to strict E2E-first TDD with unit tests written last.
.claude/skills/agent-integration/SKILL.md Updates skill definition to reflect E2E-first TDD and new phase outputs.
.claude/plugins/agent-integration/commands/write-tests.md Updates command description to “Create E2E agent runner (no unit tests)”.
.claude/plugins/agent-integration/commands/implement.md Updates implement command description (contains a spelling typo).
Comments suppressed due to low confidence (1)

.github/workflows/e2e-isolated.yml:50

  • This workflow now allows selecting kiro, but the bootstrap step runs without E2E_AGENT set and without any Kiro auth configuration. Since the Kiro runner’s Bootstrap() checks kiro-cli whoami on CI, selecting kiro is likely to fail unless the workflow also provisions credentials (or skips the auth check). Consider setting E2E_AGENT=${{ inputs.agent }} for the bootstrap step and documenting/gating Kiro behind an auth secret or condition.
      - name: Install agent CLI
        run: |
          case "${{ inputs.agent }}" in
            claude-code) curl -fsSL https://claude.ai/install.sh | bash ;;
            opencode)    curl -fsSL https://opencode.ai/install | bash ;;
            gemini-cli)  npm install -g @google/gemini-cli ;;
            kiro)        curl -fsSL https://cli.kiro.dev/install | bash ;;
          esac
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Bootstrap agent
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
        run: go run ./e2e/bootstrap

alishakawaguchi and others added 13 commits February 27, 2026 16:51
…cation

- Remove unreachable os.Stat branch in ensureCachedTranscript mock path
- Replace hardcoded hook count with len(k.HookNames()) to stay in sync
- Extract escapeSQLString helper to deduplicate SQL escaping in two queries
- Remove always-true len(sessionsWithContent) > 0 guard in PrepareCommitMsg

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: d5916dab4271
Remove empty TestDetectPresence_WithKiroDir (never called DetectPresence),
rewrite TestDetectPresence_WithoutKiroDir to actually assert found==false,
and expand TestAgentNameConstants to cover all 5 agents plus type constants.

Add new tests for escapeSQLString, multi-chunk transcript roundtrip,
InstallHooks count invariant, and stop event TranscriptRef pipeline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 947278b9b8ac
Resolve merge conflict markers in e2e.yml and manual_commit_hooks.go
from merging main into the kiro-oneshot branch. Strip ENTIRE_TEST_TTY
from Kiro's E2E tmux sessions so agents exercise real TTY detection
paths, matching the pattern established in PR #579.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 838559434a74
Support the Kiro IDE (VS Code extension) alongside the existing CLI agent
hooks. IDE hooks use standalone .kiro/hooks/*.kiro.hook files with env var
data delivery (e.g., USER_PROMPT) instead of JSON on stdin.

- Install 4 IDE hook files (promptSubmit, agentStop, preToolUse, postToolUse)
  alongside 5 CLI hooks in entire.json
- Handle empty stdin gracefully via ErrEmptyHookInput sentinel error and
  readHookInputOrEmpty helper for IDE mode fallback
- Add SIGV4/OIDC auth path for Kiro E2E tests on CI
- Add AWS credential configuration to both e2e.yml and e2e-isolated.yml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 30aa8bd9b67f
ReadAndParseHookInput blocked forever when the Kiro IDE kept stdin open
without sending EOF. Add a 500ms timeout that races io.ReadAll against a
timer, returning ErrEmptyHookInput on timeout (same as empty stdin).

Additionally, the stop hook failed with "transcript file not specified"
because ensureCachedTranscript returns empty when SQLite is unavailable
in IDE mode. Add a placeholder transcript fallback ({}) so the lifecycle
handler can proceed with file-diff checkpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 486d5ddca3f0
Implement the TranscriptAnalyzer interface for the Kiro agent, enabling
transcript position tracking, modified file extraction, prompt extraction,
and session summary from Kiro's JSON conversation format.

Fix the stop hook returning exit code 1 on empty repositories by changing
handleLifecycleTurnEnd to return nil instead of SilentError for the benign
empty-repo skip condition. This prevents Kiro IDE from reporting spurious
"Hook execution failed with exit code 1" errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 1c9dc44f36aa
The Kiro IDE stores conversations in a different location and format than
the Kiro CLI. The IDE uses JSON files with sequential {role, content}
messages (Anthropic API format) in workspace-specific directories, while
the CLI uses paired user+assistant entries in SQLite.

This adds dual-format transcript parsing that detects and normalizes IDE
format at parse time, so all downstream extraction (prompts, summary,
modified files) works unchanged. Also adds IDE transcript discovery via
the sessions.json index in the IDE's workspace-sessions directory.

The stop hook fallback chain is now: SQLite → IDE files → placeholder.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 1a5342ba9a60
…x logic

Add readAndParseTranscript() with errTranscriptEmpty sentinel to consolidate
4 copies of the read+parse pattern in kiro.go, and hookCmdPrefix() to replace
3 inline if/else blocks computing the same command prefix in hooks.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 642452f534a0
Entire-Checkpoint: 131e0561f16e
@alishakawaguchi alishakawaguchi marked this pull request as draft March 4, 2026 19:52
Add TerminalAgent optional interface to the agent package so the strategy
layer can detect terminal-based agents without hardcoding agent types.
Kiro implements UsesTerminal() and the strategy's agentUsesTerminal()
now delegates to the registry-based IsTerminalAgent() helper. Also
documents the intentional goroutine leak in ReadAndParseHookInput.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 684de188aaaa
alishakawaguchi and others added 17 commits March 4, 2026 12:32
…rmat

Address two real bugs from PR #554 review:

1. Session ID cache (`kiro-active-session`) was never cleared after stop,
   causing subsequent sessions to reuse the stale ID if agentSpawn didn't
   fire (e.g., Kiro resume). Now cleared at end of parseStop.

2. Test script `capture.json` used bare hook map instead of the
   kiroAgentFile format (name + tools + hooks nesting), so Kiro would
   silently ignore all hooks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 86fa3f63d68c
Replace silenced errcheck suppressions with logging.Debug calls for
best-effort transcript errors, document terminal agent auto-link
behavior, and convert isFileModificationTool to O(1) map lookup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: f922d9b1933f
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 79471e60efdd
GitHub Actions doesn't support `matrix` context in job-level `if`
conditions. Replace the static matrix + invalid `if` with a setup job
that computes the agent list dynamically, so dispatching a single agent
only runs that agent's matrix entry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 903a8ba0f594
Kiro authenticates via AWS SIGV4 env vars which don't propagate through
tmux (tmux sessions inherit the server's environment, not the client's).
Wrap kiro-cli commands with `env KEY=VALUE ...` in both RunPrompt and
StartSession, matching the existing pattern in claude.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: f716701a8e72
SIGV4 auth only works with --no-interactive, not the interactive TUI.
Replace tmux-based RunPrompt/StartSession with pipe-based exec.CommandContext
that runs kiro-cli chat --no-interactive per prompt. Sessions now execute
a fresh --no-interactive command per Send() (same pattern as setup-kiro-action).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 36dd4c8e03f8
The desktop app wrapper (kiro-cli) ignores AMAZON_Q_SIGV4 and always
forces browser OAuth, causing immediate failures in CI. The standalone
kiro-cli-chat binary supports headless SIGV4 auth.

- Update Binary()/LookPath/Bootstrap to use kiro-cli-chat
- Replace curl installer with direct binary download (v1.27.0)
- Update README with kiro-cli-chat requirement and local install docs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 90a21c6174a9
The directory doesn't exist by default on GitHub Actions runners,
causing `cp` to fail.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: aa4117c712aa
Replace manual kiro-cli-chat install block with clouatre-labs/setup-kiro-action@v1
which handles install, caching, and SIGV4 env var setup. Move AWS credentials
step before the action so OIDC creds are available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: f2c89e5213ba
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: a88d31cda152
SIGV4 auth was never ported to kiro-cli-chat (the binary ignores
AMAZON_Q_SIGV4 entirely). Replace AWS OIDC credential flow with
device-flow token: write KIRO_AUTH_TOKEN secret to the SSO cache
path that kiro-cli-chat reads automatically.

- Remove AWS OIDC step and setup-kiro-action from e2e-isolated
- Remove id-token:write permission from e2e-isolated
- Add kiro manual install (v1.27.0) to e2e-isolated case block
- Add "Inject Kiro auth token" step to both workflows
- Remove AMAZON_Q_SIGV4 and AWS_REGION env vars from both workflows

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: f221288e2f62
Replace SIGV4-based auth with device-flow token injection using
sqlite3 schema creation and python3 parameterized insert for both
e2e and e2e-isolated workflows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: ba36cd0fff63
Kiro is being dropped as a supported agent for E2E testing. Remove all
Kiro references from both e2e.yml and e2e-isolated.yml: workflow_dispatch
options, default matrix agents, CLI install case blocks, and auth token
injection steps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: d3231440c261
@alishakawaguchi alishakawaguchi marked this pull request as ready for review March 5, 2026 23:29
@alishakawaguchi
Copy link
Contributor Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

alishakawaguchi and others added 2 commits March 5, 2026 15:41
Two fixes from PR review:

1. event.go: Replace single-phase io.ReadAll+timeout with two-phase
   Peek(1)+timeout then ReadAll. The old approach could discard valid
   data if an agent wrote to stdin but took >500ms to send EOF.

2. manual_commit_condensation.go: Guard empty session data fallback
   with AgentTypeKiro check. Non-Kiro agents hitting this path now
   get an explicit error instead of silently proceeding with no data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: f62798c3821b
@alishakawaguchi alishakawaguchi changed the title Add Kiro agent integration with E2E-first TDD Add Kiro CLI and Kiro IDE agent support Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants