Skip to content

feat(cursor): support modern agent transcript JSONL sessions - #312

Open
lesbass wants to merge 1 commit into
melagiri:masterfrom
lesbass:feat/cursor-agent-transcripts
Open

feat(cursor): support modern agent transcript JSONL sessions#312
lesbass wants to merge 1 commit into
melagiri:masterfrom
lesbass:feat/cursor-agent-transcripts

Conversation

@lesbass

@lesbass lesbass commented Aug 11, 2026

Copy link
Copy Markdown

What

Add support for modern Cursor Agent transcript JSONL files under ~/.cursor/projects/*/agent-transcripts/*/*.jsonl, while preserving the existing SQLite provider for legacy Cursor sessions.

Fixes #311.

Why

Recent Cursor versions write Agent conversations as per-session JSONL transcripts. The existing provider only searches Cursor's VS Code-style workspaceStorage and globalStorage SQLite databases, so these newer sessions are silently missed during sync.

The new transcript format contains user and assistant records shaped as { role, message: { content } }, plus lifecycle records such as turn_ended. Content may be a string or an array containing text, thinking, and tool-use blocks.

How

cli/src/providers/cursor.ts

  • Discover main-session JSONL files under Cursor's modern agent-transcripts hierarchy.
  • Parse string and block-array message content.
  • Extract text, thinking, and tool-use inputs; skip lifecycle and malformed records safely.
  • Strip Cursor's <user_query> wrapper from human prompts.
  • Resolve project paths from worker.log when available, then fall back to best-effort decoding of Cursor's project slug.
  • Apply the existing project filter to modern transcript directories.
  • Keep session IDs compatible with existing Cursor records (cursor:<session-id>).
  • Prefer the richer legacy SQLite representation when the same UUID exists in both sources.
  • Support CURSOR_AGENT_HOME for copied/isolated Cursor data directories.

cli/src/providers/__tests__/cursor.test.ts

  • Add synthetic fixtures for modern JSONL discovery and parsing.
  • Cover string content, block-array content, thinking, tool calls, lifecycle records, malformed lines, and project filtering.

Documentation

  • Document the modern JSONL source alongside legacy SQLite storage.

Format limitations

  • Cursor's JSONL export may omit tool outputs, token usage, model metadata, and per-message timestamps.
  • The parser uses file birth/mtime as the session timestamp fallback when record timestamps are absent.
  • Subagent JSONL files are intentionally excluded from top-level session discovery.

Schema Impact

  • SQLite schema changed: no
  • Types changed: no
  • Server API changed: no
  • Backward compatible: yes

Testing

  • pnpm --filter @code-insights/cli build passes.
  • Full CLI suite passes: 582/582 tests across 28 test files.
  • Verified on a real recent Cursor macOS installation: modern transcript sessions are discovered and sync successfully.
  • Test fixtures are synthetic and contain no private transcript data.

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.

Cursor sync does not discover modern agent transcript JSONL sessions

1 participant