Cursor Agent provider misses CLI sessions stored in `~/.cursor/chats/**/store.db`
Summary
CodeBurn misses recent Cursor Agent CLI sessions because the cursor-agent provider discovers only transcript exports under ~/.cursor/projects/**/agent-transcripts/. Recent sessions are stored locally in per-session SQLite databases at:
~/.cursor/chats/<hash>/<session-id>/store.dbThe separate cursor provider does not cover these databases either; it reads Cursor IDE state from the platform-specific globalStorage/state.vscdb.
The agent-tools/*.txt files observed alongside recent sessions are terminal-output captures, not conversation transcripts or usage records.
Current CodeBurn behavior
src/providers/cursor-agent.ts probes only:
~/.cursor/projects/
~/.cursor/ai-tracking/ai-code-tracking.dbIts discovery logic enters only directories named agent-transcripts and parses JSONL or legacy TXT transcripts.
src/providers/cursor.ts reads only Cursor IDE state.vscdb.
Neither provider discovers ~/.cursor/chats/**/store.db, so store-only sessions—and sessions whose transcript export is absent, delayed, or incomplete—are silently omitted.
Observed store.db format
Each session store contains:
| Table | Columns | Purpose |
|---|---|---|
meta |
key TEXT PRIMARY KEY, value TEXT |
Root metadata under key 0; the value is hex-encoded UTF-8 JSON. |
blobs |
id TEXT PRIMARY KEY, data BLOB |
Content-addressed conversation-state graph; IDs are 64-character hexadecimal strings. |
Decoded root metadata includes:
| Field | Meaning |
|---|---|
agentId |
Session ID; matches the containing directory. |
latestRootBlobId |
Current conversation-state root. |
name |
Session title. |
mode, isRunEverything |
Execution mode. |
createdAt |
Unix milliseconds. |
lastUsedModel |
Last selected model. |
blobEncryptionKey |
Local decryption material. |
Resolving the graph from latestRootBlobId yields structured user, assistant, and tool records, including conversation text, reasoning blocks, tool calls, tool results, request/model fields, and internal timestamps. Some observed stores also contain token- or context-related fields.
blobEncryptionKey is sensitive local material and must never be included in logs, diagnostics, errors, cache keys, exports, snapshots, or committed fixtures.
The attribution DB is not a fallback
~/.cursor/ai-tracking/ai-code-tracking.db tracks AI-authored code attribution and related metadata. It may help enrich a session with model or project information, but it does not contain the complete current conversation stream or reliable request-level usage records.
It cannot substitute for reading store.db.
Expected behavior
CodeBurn should discover and reconstruct Cursor Agent sessions from ~/.cursor/chats/**/store.db, including sessions that have no matching transcript export.
For the same session UUID, source precedence should be:
store.db- JSONL transcript
- Legacy TXT transcript
A malformed or unsupported store may fall back to a matching transcript, but a successfully decoded store and its transcript must not both be counted.
Suggested implementation
- Add
~/.cursor/chatstocursor-agentdiscovery andprobeRoots(). - Discover
chats/*/*/store.dbwithout following arbitrary symlink trees. - Open each SQLite database read-only and validate the expected
metaandblobsschema. - Hex-decode
meta['0'], validateagentId, and begin reconstruction atlatestRootBlobId. - Reconstruct the reachable blob graph while tolerating unknown protobuf fields and message block types.
- Use validated internal request/message timestamps when present.
- Use session metadata only as an explicitly session-level timestamp fallback; do not report database file mtime as an exact request timestamp.
- Prefer explicit request-level input, output, and cache counters only after validating their semantics.
- Do not treat a running context-window gauge as exact billed token usage.
- Estimate only missing token components and preserve exact/estimated provenance in the emitted calls.
- Deduplicate matching stores and transcripts using the session UUID plus stable request ID or turn index.
- Include each database’s WAL state in cache invalidation so active sessions refresh correctly.
- Retain the existing JSONL/TXT parser as a compatibility fallback.
Acceptance criteria
- A store-only Cursor Agent session appears under
--provider cursor-agent. - User and assistant messages are reconstructed in order.
- Structured tool calls and tool results are retained.
- Valid internal timestamps determine date attribution.
- Explicit, semantically validated token counts take precedence over estimation.
- Estimated values remain visibly identified as estimated.
- A store and matching transcript produce one set of calls.
- An unsupported or corrupt store can fall back to its transcript without double-counting.
blobEncryptionKeycannot reach logs, errors, caches, exports, snapshots, or fixtures.- Active WAL changes invalidate cached results.
Tests should cover:
- An empty chats directory.
- A valid minimal store.
- A multi-turn blob graph.
- Malformed hex metadata.
- Missing or invalid root/blob references.
- Unknown protobuf fields and message variants.
- Seconds versus milliseconds timestamp validation.
- Exact, partial, gauge-only, and absent token data.
- Store/transcript deduplication.
- Transcript fallback after store decoding fails.
- WAL-aware cache invalidation.
- Secret-redaction behavior.
Source: getagentseal/codeburn