Skip to content

fix(kiro): Fix Kiro IDE session parsing — context.messages, .kiro-server path, workspace-sessions#618

Open
Enclavet wants to merge 1 commit into
getagentseal:mainfrom
Enclavet:fix-kiro-ide-parsing
Open

fix(kiro): Fix Kiro IDE session parsing — context.messages, .kiro-server path, workspace-sessions#618
Enclavet wants to merge 1 commit into
getagentseal:mainfrom
Enclavet:fix-kiro-ide-parsing

Conversation

@Enclavet

@Enclavet Enclavet commented Jul 4, 2026

Copy link
Copy Markdown

Problem

The Kiro provider returns 0 calls on both Linux remote dev boxes and Windows despite hundreds of session files existing on disk. Three independent issues combine to make the provider non-functional:

  1. extractText misses the entries key — Kiro IDE stores message content in context.messages[].entries (not .content), so the recursive text extractor never finds it and returns 0 chars for every file.

  2. parseModernExecution only checks top-level conversation arrays — Current Kiro builds store messages at data.context.messages, not data.messages. The parser never looks inside data.context.

  3. getKiroAgentDir missing .kiro-server path on Linux — Remote dev boxes (common at AWS/Amazon) store Kiro data at ~/.kiro-server/data/User/globalStorage/kiro.kiroagent instead of ~/.config/Kiro/.... Without the fallback, discovery returns 0 sources on Linux.

  4. Newer Kiro builds write to workspace-sessions/ — Post-June 2026 Kiro stores session state in kiro.kiroagent/workspace-sessions/<base64>/<sessionId>.json with a history[].message format that the provider doesn't discover or parse.

Fix

  1. Add 'entries' to extractText() recursion keys
  2. Check data.context[key] before data[key] for conversation arrays in parseModernExecution
  3. Add existsSync check for ~/.kiro-server/data/... in getKiroAgentDir() (Linux only)
  4. New discovery path for workspace-sessions/<base64>/*.json + parser for history[].message format
  5. Extract tool names from usageSummary[].usedTools when present (structured billing data)
  6. Add chatSessionId to session ID resolution chain
  7. Add Kiro-specific tool name mappings (executeBash → Bash, fsWrite → Edit, grepSearch → Grep, etc.)

Impact

Environment Before After
Linux remote dev box 0 calls 7,637 calls, $940
Windows 0 calls 937 calls, $367

Testing

  • 6 new test cases covering context.messages with entries, usageSummary tool extraction, execution index skipping, workspace-sessions discovery/parsing, stub-only sessions, and sessions.json skipping
  • All 42 kiro tests pass
  • Verified on Windows (cleared ~/.cache/codeburn/session-cache.json required after upgrade since stale cache stores empty parse results from the broken code)

Note for users upgrading

After installing this version, delete ~/.cache/codeburn/session-cache.json (or equivalent) to force a fresh parse. The old cache stores "0 results" for every Kiro IDE file from when the parser was broken — the fingerprint-based cache won't re-parse unchanged files without clearing it.

@ozymandiashh

Copy link
Copy Markdown
Collaborator

Thanks for jumping on the Kiro parsing fix. There are a few things I need fixed before I can merge this:

  1. Add cache invalidation for the Kiro parser fix.

Kiro is not in PROVIDER_PARSE_VERSIONS in src/session-cache.ts:110-122, and computeEnvFingerprint() only includes a parser version when the provider has an entry there (src/session-cache.ts:136-141). For unchanged files, parseProviderSources() reuses cached entries unless cachedFileNeedsProviderReparse() says otherwise (src/parser.ts:1992-1998), and that currently returns false for Kiro (src/parser.ts:1910-1924).

So if a user already has a Kiro source file cached as turns: [] from the old broken parser, this PR can still show 0 calls until they manually clear cache. Please add a Kiro parser version, for example kiro: 'ide-parsing-v1', or equivalent invalidation.

Also please add a regression test that goes through parseAllSessions() with an existing Kiro zero-turn session-cache.json entry. The current Kiro tests parse provider sources directly, so they do not cover the stale-cache path.

  1. Avoid double-counting workspace-session stubs and execution files.

Discovery includes both nested execution files and workspace-session JSON files (src/providers/kiro.ts:768-780, src/providers/kiro.ts:789-805). Execution parsing uses kiro:${sessionId}:${executionId} (src/providers/kiro.ts:353-354), but workspace-session parsing emits a separate call keyed only by session (src/providers/kiro.ts:597-617, src/providers/kiro.ts:633-652).

That means a workspace-session entry that references the same executionId can be counted once from the execution file and once again from the workspace-session file. The test at tests/providers/kiro.test.ts:900-925 is the risky case: the assistant only says "On it.", the real output is in execution files, but the workspace-session still emits input tokens. Please either dedupe against referenced execution IDs or skip stub-only workspace-session entries when the execution file is present.

  1. Actually scan both Linux Kiro roots.

The comment says to check both paths, but getKiroAgentDir() returns ~/.kiro-server/... as soon as it exists and never scans ~/.config/Kiro/... (src/providers/kiro.ts:677-681). Since createKiroProvider() passes one agentDir into discovery (src/providers/kiro.ts:813-817, src/providers/kiro.ts:835-836), this can still miss current sessions if .kiro-server exists but is stale or empty while .config/Kiro has data.

The targeted Kiro test file passes locally for me: npm run test -- tests/providers/kiro.test.ts reports 42 passing tests. Once the three issues above are fixed, I am good to merge this.

…geSummary tools, workspace-sessions

Four fixes for the Kiro IDE provider:

1. Add 'entries' to extractText() key list — Kiro IDE stores message
   content in context.messages[].entries (not .content), causing the
   parser to extract 0 chars from every execution file.

2. Check data.context[key] for conversation arrays in parseModernExecution
   — current Kiro builds store messages at data.context.messages, not at
   the top-level data.messages path the parser was checking.

3. Scan both ~/.kiro-server/data/... AND ~/.config/Kiro/... on Linux —
   remote dev boxes use .kiro-server while local installs use .config/Kiro.
   Both can have data simultaneously; the old code short-circuited on the
   first path found.

4. Discover and parse workspace-sessions/<base64>/*.json files — newer
   Kiro builds write session state here with history[].message format.
   Skips stub entries (executionId refs + 'On it.' only) to avoid
   double-counting with execution files parsed separately.

5. Add kiro: 'ide-parsing-v1' to PROVIDER_PARSE_VERSIONS for automatic
   cache invalidation — users upgrading from the broken parser will get
   a fresh re-parse without manually clearing session-cache.json.

Bonus: Extract tool names from usageSummary[].usedTools, add chatSessionId
to session ID resolution, add Kiro-specific tool name mappings.

AI-Origin: human
@Enclavet Enclavet force-pushed the fix-kiro-ide-parsing branch from 09b9e32 to 9c2ac6e Compare July 5, 2026 01:38
@Enclavet

Enclavet commented Jul 5, 2026

Copy link
Copy Markdown
Author

Updated PR with fixes.

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.

3 participants