Skip to content

feat(kiro): add Kiro CLI session discovery and parsing (#476) - #502

Merged
iamtoruk merged 1 commit into
mainfrom
kiro-cli-sessions-rebased
Jun 18, 2026
Merged

feat(kiro): add Kiro CLI session discovery and parsing (#476)#502
iamtoruk merged 1 commit into
mainfrom
kiro-cli-sessions-rebased

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

Supersedes #476 (rebased @inola-ww's commit onto current main; authorship preserved).

What it does

Adds support for Kiro CLI (kiro-cli chat) sessions stored in ~/.kiro/sessions/cli/*.jsonl, alongside the existing Kiro IDE detection. Reads the companion .json metadata for project name and per-turn metering, parses the Prompt/AssistantMessage/ToolResults NDJSON format, adds CLI tool-name mappings, and respects KIRO_HOME.

Review

  • No misrouting risk: IDE session source paths only ever end in .chat or have no extension; CLI sources end in .jsonl. The new source.path.endsWith('.jsonl') branch only catches CLI sessions, so IDE parsing is untouched. CLI and IDE scan directories are distinct.
  • Security: local file reads only (no network/exec); every JSON.parse (JSONL lines and metadata) is wrapped in try/catch, so a malformed file is skipped, not fatal. A missing CLI dir is caught and yields no sources.
  • Backward-compatible: createKiroProvider gains an optional 3rd param; when the IDE dir is overridden (tests) it points the CLI dir at a non-existent sibling so existing tests don't scan real sessions.

Notes (non-blocking, for the author/maintainers)

  • Cost is taken from metering_usage.value summed per turn, assuming the credit value equals USD. Worth confirming Kiro's credit-to-dollar unit; if it isn't 1:1, costs would be off (marked costIsEstimated: false when metering is present).
  • Turn/metering alignment is heuristic: an assistant turn with tool calls but no text output is skipped (outputChars === 0), which can under-attribute that turn's metering. Best-effort for a semi-structured format.

Verification

  • npm run build passes.
  • Kiro tests: 36 (32 existing unchanged + 4 new CLI tests).
  • Full suite: 1193/1194; the one failure is the pre-existing usage-aggregator timeout flake (local data-volume; green on CI), unrelated.

The Kiro provider previously only detected sessions from the Kiro IDE
(VS Code-based) stored in globalStorage. This adds support for Kiro CLI
(`kiro-cli chat`) sessions stored in ~/.kiro/sessions/cli/.

CLI sessions use a different format:
- .jsonl files with Prompt/AssistantMessage/ToolResults entries
- Companion .json files with session metadata, model info, and
  per-turn metering usage (credits)

Changes:
- Add CLI session discovery (scans ~/.kiro/sessions/cli/ for .jsonl)
- Add CLI JSONL parser that extracts turns, tools, and cost from
  metering_usage credits
- Add CLI tool name mappings (read, write, shell, grep, glob)
- Make CLI sessions dir configurable via third param to
  createKiroProvider for testability
- Add unit tests for CLI session discovery and parsing
@iamtoruk
iamtoruk merged commit 59efa7c into main Jun 18, 2026
3 checks passed
@iamtoruk
iamtoruk deleted the kiro-cli-sessions-rebased branch June 18, 2026 10:44
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.

2 participants