feat(kiro): add Kiro CLI session discovery and parsing (#476) - #502
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonmetadata for project name and per-turn metering, parses the Prompt/AssistantMessage/ToolResults NDJSON format, adds CLI tool-name mappings, and respectsKIRO_HOME.Review
.chator have no extension; CLI sources end in.jsonl. The newsource.path.endsWith('.jsonl')branch only catches CLI sessions, so IDE parsing is untouched. CLI and IDE scan directories are distinct.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.createKiroProvidergains 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)
metering_usage.valuesummed 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 (markedcostIsEstimated: falsewhen metering is present).outputChars === 0), which can under-attribute that turn's metering. Best-effort for a semi-structured format.Verification
npm run buildpasses.usage-aggregatortimeout flake (local data-volume; green on CI), unrelated.