Skip to content

Add support for Kiro IDE v1.0 session format - #15

Open
saherr1969 wants to merge 6 commits into
pajaydev:mainfrom
saherr1969:feature/new-ide-session-reader
Open

Add support for Kiro IDE v1.0 session format#15
saherr1969 wants to merge 6 commits into
pajaydev:mainfrom
saherr1969:feature/new-ide-session-reader

Conversation

@saherr1969

@saherr1969 saherr1969 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What changed

  • New reader (server/ide-v2.ts) for the IDE v1.0 session format (~/.kiro/sessions/<workspace-hash>/<session-id>/)
  • Parses session.json + messages.jsonl (JSONL payload-type stream)
  • Extracts user messages, assistant responses, and tool calls
  • Merges with pre-v1.0 IDE sessions, deduplicating by conversationId (v1.0 preferred)
  • Fixes watcher crash on fresh IDE 1.0 installs (missing workspace-sessions dir)
  • Clarifies startup log messages to distinguish pre v1.0 vs v1.0 sources
  • Updates README "How It Works" section
  • Unit test suite for the IDE v1.0 reader (server/ide-v2.test.ts, 19 tests)

Files new and modified

  • server/ide-v2.ts (new)
  • server/ide-v2.test.ts (new — unit tests)
  • server/cli.ts
  • server/index.ts
  • README.md

Test results

  • All 45 tests pass (13 CLI v2 + 13 dist + 19 new IDE v2)
  • macOS: 2 sessions detected and parsed correctly (tool uses, markdown content)
  • Windows 11: 1 session detected and served, browser rendering confirmed
  • Auto-detection works when only IDE v1.0 data exists
  • Clean startup with no watcher errors on fresh installs

Note on CI impact

The new test file adds 19 tests to the test run. This will add a few seconds
to the GitHub Actions build-and-test job (measured ~20ms locally for the new
tests, but CI overhead may vary).

- New file server/ide-v2.ts: resolves workspace-hash dirs, parses
  session.json + messages.jsonl (JSONL payload-type format)
- Handles user, assistant, tool_call, turn_start/turn_end payloads
- Skips streaming placeholders ('...' content)
- server/cli.ts: integrates IDE V2 reader, updates detectSource()
  to check for new-format sessions, adds watchers and cleanup
- server/index.ts: adds ideV2Reader to ServerOptions, merges results
  into IDE path with deduplication (new format preferred)
Fresh Kiro IDE 1.0 installs have no workspace-sessions directory
(that was the pre-1.0 format). The watcher threw ENOENT on startup.
Now only creates the watcher if the directory actually exists.
- 15 tests for createIdeV2Reader: happy path, tool calls, turn
  boundaries, missing files, malformed data, sorting, path fallback,
  incomplete sessions, multiple workspaces
- 4 tests for resolveIdeV2WorkspaceDirs: non-existent path, empty
  path, excludes cli directory, ignores non-directory entries
@saherr1969

Copy link
Copy Markdown
Contributor Author

@pajaydev , I know the new reader is named v2 in the code files but it is designed to read the "new" JSON(L) files associated with Kiro IDE v1.0 application style.

Please let me know if you want me to change anything there if needed.

I really appreciate your tool! Especially because from one session to another, Kiro loses all memory of previous work unless it has some how been stored in steering which isn't even always referenced well.

Stephen

@pajaydev

Copy link
Copy Markdown
Owner

@saherr1969 Thanks for explaining, Shall we keep the files as ide-legacy.ts ? v2 is confusing

Comment thread server/ide-v2.ts
@@ -0,0 +1,234 @@
import { readdirSync, readFileSync, existsSync } from 'fs';

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Shall we rename this file to ide-legacy.ts as v2 is confusing here ?

Comment thread server/cli.ts
// Try to load both sources if available
const idePath = resolveIdePath(userPath);
const dbPath = resolveDbPath(userPath);
const hasIde = existsSync(join(idePath, 'workspace-sessions')) || existsSync(join(idePath, 'sessions'));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I believe we should also check hasOldIde || hasNewIde logic here?

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