mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-07-21 15:04:34 +00:00
## What & why
The JetBrains Copilot plugin (IntelliJ, PyCharm, RubyMine, …) stores its
chat/agent sessions under `~/.config/github-copilot/<ide>/<kind>/<storeId>/` —
a location none of the existing Copilot sources (CLI JSONL, VS Code chat
sessions/transcripts, OTel SQLite) read. As a result all JetBrains Copilot
usage was silently uncounted in every CodeBurn report. This adds a reader for
that store so those sessions are discovered, priced, and attributed to the
right project.
## How it works
- **Reader.** The store's session content is a Nitrite `.db` — an H2 MVStore of
Java-serialized documents. It is scanned as `latin1` for byte-offset
stability: no Java deserializer, no new dependency, and it is not SQLite so
`node:sqlite` is not involved.
- **Reply text.** Assistant replies live in nested-escaped
`{"__first__":{"type":"Subgraph"…}}` blobs. The text is recovered by
unescaping one level at a time and, at the depth where the Markdown record's
`data` field is a well-formed one-level-escaped JSON document, reading it
structurally — so a reply containing its own quotes is never truncated or
duplicated (which would otherwise inflate the estimate).
- **Tokens/cost.** The store records no token counts, so output tokens are
estimated from the reply text (`CHARS_PER_TOKEN = 4`, re-decoded
latin1→utf8 so multibyte replies count by codepoint) and every call is marked
`costIsEstimated`. Failed generations (error status, no reply) are billed $0.
- **Sessions.** One `.db` holds many chat tabs; turns are grouped back to their
conversation GUID so the UI shows one session per tab, deduped by reply
content per conversation.
- **Project attribution**, most authoritative first:
1. the plugin-recorded `projectName` field (JetBrains Copilot 1.12+), joined
across kind dirs by store id — the billable turns live in
`chat-agent-sessions`, but the label is usually written into the sibling
`chat-sessions`/`chat-edit-sessions` store. Read length-delimited and
re-decoded latin1→utf8 so non-ASCII repo names round-trip.
2. the `.git` repo root of a referenced `file://` path.
3. a generic `copilot-jetbrains` bucket when neither signal exists.
The conversation title is a chat-thread name, not a project, so it is kept
out of the project field and surfaced as the session label instead.
Override the JetBrains github-copilot root with
`CODEBURN_COPILOT_JETBRAINS_DIR`.
## Docs
- `docs/providers/copilot.md` — full JetBrains section (store layout, latin1
scan, reply extraction, projectName precedence + cross-kind join).
- `docs/providers/README.md` — Copilot storage updated to note the Nitrite .db.
## How to verify
- `npm test -- copilot` and `npx tsc --noEmit` (fixtures reproduce the real
nested-escaped .db framing, including quote- and multibyte-bearing replies).
- End to end against a real install:
`CODEBURN_CACHE_DIR=$(mktemp -d) node dist/cli.js status --provider copilot \
--period all --format menubar-json`
— JetBrains sessions appear By-Project under their real repo names.
- Set `CODEBURN_COPILOT_JETBRAINS_DIR` to a fixture root to parse a controlled
store without touching the real config dir.
|
||
|---|---|---|
| .. | ||
| fixtures | ||
| providers | ||
| security | ||
| setup | ||
| sharing | ||
| antigravity-statusline.test.ts | ||
| audit-report.test.ts | ||
| bash-commands.test.ts | ||
| blob-to-text.test.ts | ||
| classifier.test.ts | ||
| cli-date.test.ts | ||
| cli-deepseek-v4-pricing.test.ts | ||
| cli-devin-model-variants.test.ts | ||
| cli-export-date-range.test.ts | ||
| cli-json-daily.test.ts | ||
| cli-model-savings.test.ts | ||
| cli-plan.test.ts | ||
| cli-price-override.test.ts | ||
| cli-provider-validation.test.ts | ||
| cli-proxy-path.test.ts | ||
| cli-status-menubar.test.ts | ||
| codex-credits.test.ts | ||
| compare-stats.test.ts | ||
| content-utils.test.ts | ||
| currency-rounding.test.ts | ||
| daily-cache.test.ts | ||
| dashboard.test.ts | ||
| date-range-filter.test.ts | ||
| day-aggregator-savings.test.ts | ||
| day-aggregator.test.ts | ||
| export.test.ts | ||
| fetch-utils.test.ts | ||
| fs-utils.test.ts | ||
| local-model-savings.test.ts | ||
| mcp-coverage.test.ts | ||
| mcp-redact.test.ts | ||
| mcp-server.test.ts | ||
| mcp-tables.test.ts | ||
| menubar-installer.test.ts | ||
| menubar-json.test.ts | ||
| menubar-savings.test.ts | ||
| minimax.test.ts | ||
| model-efficiency.test.ts | ||
| models-hoist.test.ts | ||
| models-report.test.ts | ||
| models.test.ts | ||
| optimize-fs.test.ts | ||
| optimize.test.ts | ||
| otel-cache-aggregation.test.ts | ||
| overview.test.ts | ||
| parser-claude-cwd.test.ts | ||
| parser-compact-entry.test.ts | ||
| parser-filter.test.ts | ||
| parser-gemini-cache.test.ts | ||
| parser-large-json-scanner.test.ts | ||
| parser-large-session.test.ts | ||
| parser-local-savings.test.ts | ||
| parser-mcp-inventory.test.ts | ||
| parser-number-helpers.test.ts | ||
| parser-proxy-codex-only.test.ts | ||
| parser-proxy-merge.test.ts | ||
| parser-proxy-pricing.test.ts | ||
| parser-skip-line.test.ts | ||
| parser-subagent-collection.test.ts | ||
| parser.test.ts | ||
| plan-usage.test.ts | ||
| plans.test.ts | ||
| pricing-fallback-data.test.ts | ||
| provider-registry.test.ts | ||
| provider-turn-grouping.test.ts | ||
| session-cache.test.ts | ||
| usage-aggregator.test.ts | ||
| web-dashboard.test.ts | ||
| yield.test.ts | ||