tokenleak 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +373 -19
  2. package/package.json +1 -1
  3. package/tokenleak +26116 -13924
package/README.md CHANGED
@@ -1,24 +1,46 @@
1
1
  # Tokenleak
2
2
 
3
- See where your AI tokens actually go. Tokenleak reads usage data from **Claude Code**, **Codex**, **Cursor**, **Pi (`pi-mono`)**, and **OpenCode**, then renders terminal dashboards, heatmaps, compare reports, explain/focus reports, and shareable image cards from the CLI.
3
+ See where your AI tokens actually go. Tokenleak reads usage data from **Claude Code**, **Codex**, **Cursor**, **Gemini**, **GitHub Copilot**, **Amp**, **Codebuff**, **Droid**, **Qwen**, **Roo Code**, **Kilo Code**, **Kimi**, **Kilo CLI**, **Mux**, **Crush**, **OpenClaw**, **Hermes**, **Goose**, **Antigravity**, **Zed Agent**, **Kiro**, **Trae**, **Synthetic**, **Pi (`pi-mono`)**, and **OpenCode**, then renders terminal dashboards, heatmaps, compare reports, explain/focus reports, and shareable image cards from the CLI.
4
4
 
5
- ![Tokenleak preview card](./docs/preview.png)
5
+ ![Tokenleak OpenTUI overview](./docs/tui-overview.png)
6
6
 
7
7
  ## Overview
8
8
 
9
9
  Tokenleak auto-detects supported providers from their local logs and storage. This is the quick scan of where it looks before it renders dashboards, reports, and images:
10
10
 
11
- | Client | Local data location | Provider key and aliases | Supported |
12
- | ------ | ------------------- | ------------------------ | --------- |
13
- | Claude Code | `~/.claude/projects/**/*.jsonl` | `claude-code`, `anthropic`, `claude`, `claudecode` | Yes |
14
- | Codex | `~/.codex/sessions/**/*.jsonl` | `codex`, `openai` | Yes |
15
- | Cursor | `~/.config/tokenleak/cursor-cache/usage*.csv` after `tokenleak cursor login` | `cursor`, `cursor-ide`, `cursoride` | Yes |
16
- | OpenCode | `~/.local/share/opencode/storage/message/<session>/*.json` or `~/.config/opencode/storage/message/<session>/*.json`<br />Legacy: `~/.opencode/opencode.db`, `~/.opencode/sessions.db`, `~/.opencode/sessions/*.json` | `open-code`, `opencode`, `open_code` | Yes |
17
- | Pi (`pi-mono`) | `~/.pi/agent/sessions/**/*.jsonl` | `pi`, `pi-mono` | Yes |
11
+ | Icon | Client | Local data location | Provider key and aliases | Supported |
12
+ | ---- | ------ | ------------------- | ------------------------ | --------- |
13
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=claude.ai&sz=64" alt="Claude Code icon" /> | Claude Code | `~/.claude/projects/**/*.jsonl` | `claude-code`, `anthropic`, `claude`, `claudecode` | Yes |
14
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=openai.com&sz=64" alt="Codex icon" /> | Codex | `~/.codex/sessions/**/*.jsonl` | `codex`, `openai` | Yes |
15
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=cursor.com&sz=64" alt="Cursor icon" /> | Cursor | `~/.config/tokenleak/cursor-cache/usage*.csv` after `tokenleak cursor login` | `cursor`, `cursor-ide`, `cursoride` | Yes |
16
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=gemini.google.com&sz=64" alt="Gemini icon" /> | Gemini | `~/.gemini/tmp/**/*.{json,jsonl}` | `gemini`, `google` | Yes |
17
+ | <img width="36" height="36" src="https://cdn.simpleicons.org/githubcopilot/000000" alt="GitHub Copilot icon" /> | GitHub Copilot | `~/.copilot/otel/**/*.jsonl` | `copilot`, `github-copilot`, `copilot-otel` | Yes |
18
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=ampcode.com&sz=64" alt="Amp icon" /> | Amp | `${XDG_DATA_HOME:-~/.local/share}/amp/threads/T-*.json` | `amp`, `sourcegraph-amp` | Yes |
19
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=codebuff.com&sz=64" alt="Codebuff icon" /> | Codebuff | `~/.config/manicode/projects/**/chats/**/chat-messages.json` | `codebuff`, `manicode` | Yes |
20
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=factory.ai&sz=64" alt="Droid icon" /> | Droid | `~/.factory/sessions/*.settings.json` | `droid`, `factory` | Yes |
21
+ | <img width="36" height="36" src="https://avatars.githubusercontent.com/QwenLM?s=64" alt="Qwen icon" /> | Qwen | `~/.qwen/projects/**/*.jsonl` | `qwen` | Yes |
22
+ | <img width="36" height="36" src="https://avatars.githubusercontent.com/RooCodeInc?s=64" alt="Roo Code icon" /> | Roo Code | `~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/tasks/**/ui_messages.json` | `roo-code`, `roo`, `roocode` | Yes |
23
+ | <img width="36" height="36" src="https://avatars.githubusercontent.com/Kilo-Org?s=64" alt="Kilo Code icon" /> | Kilo Code | `~/.config/Code/User/globalStorage/kilocode.kilo-code/tasks/**/ui_messages.json` | `kilo-code`, `kilocode` | Yes |
24
+ | <img width="36" height="36" src="https://avatars.githubusercontent.com/MoonshotAI?s=64" alt="Kimi icon" /> | Kimi CLI | `~/.kimi/sessions/**/wire.jsonl` | `kimi`, `kimi-cli` | Yes |
25
+ | <img width="36" height="36" src="https://avatars.githubusercontent.com/Kilo-Org?s=64" alt="Kilo CLI icon" /> | Kilo CLI | `~/.local/share/kilo/kilo.db` | `kilo`, `kilo-cli` | Yes |
26
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=coder.com&sz=64" alt="Mux icon" /> | Mux | `~/.mux/sessions/**/session-usage.json` | `mux` | Yes |
27
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=crush.ai&sz=64" alt="Crush icon" /> | Crush | `${XDG_DATA_HOME:-~/.local/share}/crush/projects.json` project databases | `crush` | Yes |
28
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=openclaw.ai&sz=64" alt="OpenClaw icon" /> | OpenClaw | `~/.openclaw/agents/**/*.jsonl*` | `openclaw`, `open-claw` | Yes |
29
+ | <img width="36" height="36" src="https://avatars.githubusercontent.com/NousResearch?s=64" alt="Hermes icon" /> | Hermes | `${HERMES_HOME:-~/.hermes}/state.db` | `hermes`, `hermes-agent` | Yes |
30
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=block.github.io&sz=64" alt="Goose icon" /> | Goose | `${XDG_DATA_HOME:-~/.local/share}/goose/sessions/sessions.db` | `goose` | Yes |
31
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=antigravity.google&sz=64" alt="Antigravity icon" /> | Antigravity | `~/.config/tokenleak/antigravity-cache/sessions/*.jsonl` cache | `antigravity` | Yes |
32
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=zed.dev&sz=64" alt="Zed icon" /> | Zed Agent | `${XDG_DATA_HOME:-~/.local/share}/zed/threads/threads.db` | `zed`, `zed-agent` | Yes |
33
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=kiro.dev&sz=64" alt="Kiro icon" /> | Kiro | `~/.kiro/sessions/cli/*.json` | `kiro` | Yes |
34
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=trae.ai&sz=64" alt="Trae icon" /> | Trae | `~/.config/tokenleak/trae-cache/sessions/*.json` cache | `trae` | Yes |
35
+ | <img width="36" height="36" src="https://www.google.com/s2/favicons?domain=synthetic.new&sz=64" alt="Synthetic icon" /> | Synthetic | `~/.local/share/octofriend/sqlite.db` | `synthetic`, `octofriend` | Yes |
36
+ | <img width="36" height="36" src="https://opencode.ai/favicon.ico" alt="OpenCode icon" /> | OpenCode | `~/.local/share/opencode/storage/message/<session>/*.json` or `~/.config/opencode/storage/message/<session>/*.json`<br />Legacy: `~/.opencode/opencode.db`, `~/.opencode/sessions.db`, `~/.opencode/sessions/*.json` | `open-code`, `opencode`, `open_code` | Yes |
37
+ | <img width="36" height="36" src="https://pi.dev/logo.svg" alt="Pi icon" /> | Pi (`pi-mono`) | `~/.pi/agent/sessions/**/*.jsonl` | `pi`, `pi-mono` | Yes |
18
38
 
19
39
  - Use `CLAUDE_CONFIG_DIR` to override the Claude Code base directory.
20
40
  - Use `CODEX_HOME` to override the Codex base directory.
21
41
  - Use `TOKENLEAK_CURSOR_DIR` to override the Cursor credentials/cache directory.
42
+ - Use `TOKENLEAK_GEMINI_DIR`, `TOKENLEAK_COPILOT_OTEL_DIR`, `TOKENLEAK_AMP_DIR`, `TOKENLEAK_CODEBUFF_DIR`, `TOKENLEAK_DROID_DIR`, `TOKENLEAK_QWEN_DIR`, `TOKENLEAK_ROO_CODE_DIR`, `TOKENLEAK_KILO_CODE_DIR`, `TOKENLEAK_KIMI_DIR`, `TOKENLEAK_KILO_DIR`, `TOKENLEAK_MUX_DIR`, `TOKENLEAK_CRUSH_DIR`, `TOKENLEAK_OPENCLAW_DIR`, `TOKENLEAK_HERMES_DIR`, `TOKENLEAK_GOOSE_DIR`, `TOKENLEAK_ANTIGRAVITY_DIR`, `TOKENLEAK_ZED_DIR`, `TOKENLEAK_KIRO_DIR`, `TOKENLEAK_TRAE_DIR`, and `TOKENLEAK_SYNTHETIC_DIR` to override provider data locations.
43
+ - Hermes also honors `HERMES_HOME`.
22
44
  - Use `PI_CODING_AGENT_DIR` to override the Pi base directory.
23
45
  - See [Provider details](#provider-details) for the parser behavior and per-provider notes.
24
46
 
@@ -39,16 +61,18 @@ npx tokenleak --help
39
61
  ```
40
62
 
41
63
  After installing, run `tokenleak` in your terminal. It auto-detects supported providers from their local logs.
42
- In an interactive TTY, plain `tokenleak` launches a full-screen TUI dashboard with 8 views:
64
+ In an interactive TTY, plain `tokenleak` launches a full-screen TUI dashboard with 10 views:
43
65
 
44
66
  - **Overview** — heatmap, stats, providers, and top models
45
67
  - **Matrix** — 4-page deep-dive with activity patterns, cache economics, sessions, model efficiency, attribution, and cache ROI by model
46
- - **Advisor** — model efficiency recommendations with projected savings
68
+ - **Advisor** — model efficiency recommendations, projected savings, and waste-pattern recipes
47
69
  - **Focus** — deep-work session rankings scored by duration, density, and streaks
48
70
  - **Explain** — narrative day-by-day usage breakdown
49
71
  - **Compare** — side-by-side period comparison with deltas
50
- - **Export** — save PNG, Wrapped PNG, or launch a live server
72
+ - **Export** — save PNG, Wrapped PNG, launch a live server, or copy an LLM-ready analysis prompt
51
73
  - **Wrapped** — Spotify-Wrapped-style stats card with achievements and usage breakdown
74
+ - **Replay** — chronological session timeline with flow blocks, pulse chart, and flow/think ratio
75
+ - **AI ROI** — token spend versus local Git output, including commits, changed lines, and cost/token ratios per repo
52
76
 
53
77
  Use `tokenleak --legacy` to open the classic interactive launcher instead.
54
78
 
@@ -89,6 +113,11 @@ tokenleak --format svg --output usage.svg
89
113
  # Export a PNG image
90
114
  tokenleak --format png --output usage.png
91
115
 
116
+ # Export anonymized aggregate data or an LLM-ready analysis prompt
117
+ tokenleak commons export --days 90 --output commons.json
118
+ tokenleak commons prompt --days 90 --clipboard
119
+ tokenleak commons prompt --provider claude,codex --output tokenleak-llm-prompt.md
120
+
92
121
  # Generate your AI Coding Wrapped story card
93
122
  tokenleak --format wrapped
94
123
  tokenleak --format wrapped --theme light --output my-wrapped.png --open
@@ -110,10 +139,26 @@ tokenleak -o card.png
110
139
  tokenleak explain 2026-03-10
111
140
  tokenleak explain 2026-03-10 --format json
112
141
 
142
+ # Replay a day's session timeline
143
+ tokenleak replay
144
+ tokenleak replay 2026-03-10 --format json
145
+
146
+ # Open the interactive replay scrub UI in your browser
147
+ tokenleak replay 2026-03-10 --interactive
148
+
113
149
  # Rank deep-work sessions
114
150
  tokenleak focus
115
151
  tokenleak focus --provider codex --days 30
116
152
 
153
+ # Compare AI token spend against local Git output
154
+ tokenleak nutrition
155
+ tokenleak nutrition --days 30 --format json
156
+
157
+ # Optimization intelligence
158
+ tokenleak simulate-routing --days 30
159
+ tokenleak waste --severity high
160
+ tokenleak behavior-diff --provider claude-code,codex --days 30 --format json
161
+
117
162
  # Authenticate Cursor and sync its local cache
118
163
  tokenleak cursor login --name work
119
164
 
@@ -123,7 +168,7 @@ tokenleak --list-providers
123
168
 
124
169
  ### Analysis commands
125
170
 
126
- Tokenleak ships two dedicated investigation commands in addition to the main dashboard flow:
171
+ Tokenleak ships dedicated investigation and optimization commands in addition to the main dashboard flow:
127
172
 
128
173
  ```bash
129
174
  # Explain what drove a specific day
@@ -137,10 +182,40 @@ tokenleak focus --days 30
137
182
 
138
183
  # Focus report as JSON
139
184
  tokenleak focus --format json --provider pi --output focus.json
185
+
186
+ # Replay today's session timeline
187
+ tokenleak replay
188
+
189
+ # Replay a specific day with JSON output
190
+ tokenleak replay 2026-03-10 --format json --output replay.json
191
+
192
+ # Open the day in an interactive browser scrub UI
193
+ tokenleak replay 2026-03-10 --interactive
194
+ tokenleak replay 2026-03-10 --interactive --open --port 4567
195
+
196
+ # Estimate AI ROI from token usage and local Git output
197
+ tokenleak nutrition --days 30
198
+
199
+ # Emit the AI ROI report as JSON
200
+ tokenleak nutrition --format json --output ai-roi.json
201
+
202
+ # Estimate savings from model routing
203
+ tokenleak simulate-routing --days 30
204
+
205
+ # Detect agent waste signals with evidence and recipes
206
+ tokenleak waste --days 30
207
+
208
+ # Compare two agent/provider/model cohorts
209
+ tokenleak behavior-diff --provider claude-code,codex --days 30
140
210
  ```
141
211
 
142
212
  - `tokenleak explain <date>` builds a narrative day report with top providers, sessions, projects, models, and anomaly flags.
143
213
  - `tokenleak focus` ranks sessions by a deep-work score derived from duration, token density, and project streak.
214
+ - `tokenleak replay [date]` shows a chronological timeline of all sessions for a day, clustering events into flow blocks with a pulse chart and flow/think ratio. Defaults to today. Pass `--interactive` (or `-i`) to open a browser scrub UI on `http://localhost:3567` — drag the timeline, press space to play the day at 60–600× speed, watch the cumulative cost odometer tick up. Combine with `--open` to launch the browser automatically.
215
+ - `tokenleak nutrition` powers the TUI **AI ROI** view. It resolves local Git repo roots from provider project paths, runs read-only `git log --numstat`, and reports tokens/cost per commit and changed line. `No Git signal` means Tokenleak saw AI usage for a repo path but found no commits in the selected date window; switch to a wider window or ensure the project path exists locally as a Git worktree.
216
+ - `tokenleak simulate-routing` re-prices historical events under conservative downgrade rules so pro users can estimate savings before changing model habits or team guidance.
217
+ - `tokenleak waste` detects deterministic waste signals such as context drag, repeated prompt clusters, model churn, cache misses, and premium models used for small tasks.
218
+ - `tokenleak behavior-diff` compares cohorts such as provider-vs-provider or model-vs-model and emits deterministic takeaways for engineering teams.
144
219
 
145
220
  ### Cursor commands
146
221
 
@@ -150,6 +225,7 @@ Use these commands to manage Cursor authentication and the local cache that Toke
150
225
  tokenleak cursor login --name work
151
226
  tokenleak cursor status
152
227
  tokenleak cursor accounts --json
228
+ tokenleak cursor doctor
153
229
  tokenleak cursor switch work
154
230
  tokenleak cursor logout --name work
155
231
  tokenleak cursor logout --all --purge-cache
@@ -192,6 +268,28 @@ bun packages/cli/dist/cli.js --provider cursor --format json
192
268
  - If `cursor status` is valid but `--list-providers` still shows Cursor as unavailable, run `tokenleak --provider cursor` once to sync the cache, then rerun `--list-providers`.
193
269
  - Cursor session tokens are stored in plaintext at `~/.config/tokenleak/cursor-credentials.json` (or under `TOKENLEAK_CURSOR_DIR`) with local-only file permissions.
194
270
 
271
+ #### Corporate VPN / protected network
272
+
273
+ If `tokenleak cursor login` works off VPN but fails on a company protected VPN with a connection, proxy, or certificate error, run the token-free doctor first:
274
+
275
+ ```bash
276
+ tokenleak cursor doctor
277
+ ```
278
+
279
+ For managed proxy networks, pass a Cursor-specific proxy or use your standard shell proxy variables:
280
+
281
+ ```bash
282
+ TOKENLEAK_CURSOR_PROXY=http://proxy.company:8080 tokenleak cursor doctor
283
+ ```
284
+
285
+ For TLS inspection networks, export the company root CA as a PEM file and point Tokenleak at it:
286
+
287
+ ```bash
288
+ TOKENLEAK_CURSOR_CA_FILE=/path/company-root-ca.pem tokenleak cursor doctor --with-token
289
+ ```
290
+
291
+ Tokenleak also honors `HTTPS_PROXY`, `HTTP_PROXY`, `NO_PROXY`, and `TOKENLEAK_CURSOR_TIMEOUT_MS` for Cursor API requests. `tokenleak cursor doctor --insecure-skip-tls-verify` exists only to prove that TLS inspection is the failure mode; do not use it for normal login or sync.
292
+
195
293
  ### Date filtering
196
294
 
197
295
  By default, Tokenleak shows the last **90 days** of usage.
@@ -270,6 +368,10 @@ When you use `--format png` or `--format svg`, Tokenleak enables expanded compar
270
368
 
271
369
  Generate a Spotify-Wrapped-style story card as a tall PNG image showing your AI coding stats, streaks, model usage, habits, achievements, and more.
272
370
 
371
+ Current wrapped card generated from the latest Tokenleak build:
372
+
373
+ ![Tokenleak AI Wrapped card](./docs/wrapped-card.png)
374
+
273
375
  ```bash
274
376
  # Generate your wrapped card (dark theme, opens automatically)
275
377
  tokenleak --format wrapped --open
@@ -302,7 +404,9 @@ tokenleak --wrapped-live --days 365 --claude
302
404
  tokenleak --wrapped-live --provider claude-code,codex
303
405
  ```
304
406
 
305
- The presentation uses the same 12 sections as the static wrapped card but rendered as navigable slides with an obsidian-and-gold design. Use arrow keys, click the nav buttons, or swipe on touch devices to move between slides.
407
+ `tokenleak --format wrapped` is the static export path: it writes a tall PNG you can attach to docs, posts, or issues. `tokenleak --wrapped-live` uses the same underlying stats, but serves them as a browser deck that is better for demos, screenshares, and walking through each section interactively.
408
+
409
+ The Wrapped Live server starts on `http://localhost:3456` and automatically increments to the next free port if `3456` is already taken. The presentation uses the same 12 sections as the static wrapped card but rendered as navigable slides with an obsidian-and-gold design. Use arrow keys, click the nav buttons, or swipe on touch devices to move between slides.
306
410
 
307
411
  The classic launcher (`tokenleak --legacy`) includes Wrapped Live as a menu option.
308
412
 
@@ -318,12 +422,14 @@ tokenleak --advisor
318
422
  tokenleak --advisor --days 30 --claude
319
423
  ```
320
424
 
321
- The advisor detects three types of opportunities:
425
+ The advisor detects optimization opportunities:
322
426
 
323
427
  - **Model downgrades** — identifies expensive models used for short outputs and suggests cheaper alternatives with concrete $/month savings
324
428
  - **Cache optimization** — flags low cache hit rates and poor reuse ratios
325
429
  - **Usage patterns** — warns about model concentration risk, cost trend increases, and burst days
326
430
 
431
+ In the TUI Advisor view, the same screen also includes **Waste Patterns**: deterministic findings such as context drag, burst spikes, wasted cache writes, and model-switch churn. Each finding includes severity, evidence, estimated savings where defensible, and a concrete local recipe for what to try next.
432
+
327
433
  Each recommendation includes current cost, projected cost, monthly savings, and a confidence level (high/medium/low). The advisor is also available as a `get_efficiency_advice` tool in the MCP server.
328
434
 
329
435
  ### Themes
@@ -379,7 +485,19 @@ tokenleak --format json --upload gist
379
485
 
380
486
  ### TUI dashboard (default)
381
487
 
382
- In a real TTY, `tokenleak` launches a full-screen terminal dashboard built with [@opentui/core](https://www.npmjs.com/package/@opentui/core). The TUI provides 8 views with keyboard and mouse navigation:
488
+ In a real TTY, `tokenleak` launches a full-screen terminal dashboard built with [@opentui/core](https://www.npmjs.com/package/@opentui/core). The TUI provides 8 views with keyboard and mouse navigation. The Advisor view includes both savings recommendations and waste-pattern recipes.
489
+
490
+ Latest OpenTUI screenshots from the current dashboard build:
491
+
492
+ | Overview | Matrix (page 4) |
493
+ | --- | --- |
494
+ | ![Overview view](./docs/tui-overview.png) | ![Matrix view](./docs/tui-matrix.png) |
495
+ | Advisor | Focus |
496
+ | ![Advisor view](./docs/tui-advisor.png) | ![Focus view](./docs/tui-focus.png) |
497
+ | Explain | Compare |
498
+ | ![Explain view](./docs/tui-explain.png) | ![Compare view](./docs/tui-compare.png) |
499
+ | Export | Wrapped |
500
+ | ![Export view](./docs/tui-export.png) | ![Wrapped view](./docs/tui-wrapped.png) |
383
501
 
384
502
  | Key | Action |
385
503
  | --- | --- |
@@ -420,8 +538,10 @@ Subcommands:
420
538
 
421
539
  - `tokenleak explain <date>` supports `--format terminal|json`, `--output`, `--width`, and the standard provider filters.
422
540
  - `tokenleak focus` supports `--format terminal|json`, `--output`, `--width`, and the standard provider/date filters.
541
+ - `tokenleak commons export` writes anonymized aggregate JSON; `tokenleak commons prompt` writes or copies a Markdown prompt for external LLM analysis; `tokenleak commons inspect <file>` validates a commons JSON export before sharing.
542
+ - `tokenleak replay [date]` supports `--format terminal|json`, `--output`, `--width`, and the standard provider filters. Date defaults to today. Add `-i`/`--interactive` to launch a local browser scrub UI on port 3567 (override with `--port`); add `--open` to auto-open the browser. `--format`, `--output`, and `--width` are ignored in interactive mode.
423
543
  - `tokenleak cursor --help` prints the Cursor auth/cache command help text.
424
- - `tokenleak explain --help` and `tokenleak focus --help` print the subcommand-specific help text.
544
+ - `tokenleak explain --help`, `tokenleak focus --help`, `tokenleak commons --help`, and `tokenleak replay --help` print the subcommand-specific help text.
425
545
 
426
546
  | Flag | Alias | Default | Description |
427
547
  | --- | --- | --- | --- |
@@ -491,6 +611,216 @@ Reads Cursor usage CSV exports from the local Tokenleak cache. The cache is popu
491
611
  | **Provider name** | `cursor` |
492
612
  | **Aliases** | `cursor-ide`, `cursoride` |
493
613
 
614
+ ### Gemini
615
+
616
+ Reads Gemini CLI session JSON, chat JSON, and JSONL usage records from the local Gemini temp directory.
617
+
618
+ | | |
619
+ | ----------------- | ----------------------------------------------------------- |
620
+ | **Data location** | `~/.gemini/tmp/**/*.{json,jsonl}` |
621
+ | **Override** | Set `TOKENLEAK_GEMINI_DIR` environment variable |
622
+ | **Provider name** | `gemini` |
623
+ | **Aliases** | `google` |
624
+
625
+ ### GitHub Copilot
626
+
627
+ Reads local Copilot OTEL JSONL spans and counts chat spans with `gen_ai.usage.*` token attributes.
628
+
629
+ | | |
630
+ | ----------------- | --------------------------------------------------------------- |
631
+ | **Data location** | `~/.copilot/otel/**/*.jsonl` |
632
+ | **Override** | Set `TOKENLEAK_COPILOT_OTEL_DIR` environment variable |
633
+ | **Provider name** | `copilot` |
634
+ | **Aliases** | `github-copilot`, `copilot-otel` |
635
+
636
+ ### Amp
637
+
638
+ Reads Sourcegraph Amp thread JSON files and combines usage ledger rows with message-level usage without double-counting matching entries.
639
+
640
+ | | |
641
+ | ----------------- | ---------------------------------------------------------------- |
642
+ | **Data location** | `${XDG_DATA_HOME:-~/.local/share}/amp/threads/T-*.json` |
643
+ | **Override** | Set `TOKENLEAK_AMP_DIR` environment variable |
644
+ | **Provider name** | `amp` |
645
+ | **Aliases** | `sourcegraph-amp` |
646
+
647
+ ### Codebuff
648
+
649
+ Reads Codebuff/Manicode chat history files and parses assistant usage from direct metadata or provider-options run-state fallbacks.
650
+
651
+ | | |
652
+ | ----------------- | -------------------------------------------------------------------- |
653
+ | **Data location** | `~/.config/manicode/projects/**/chats/**/chat-messages.json` |
654
+ | **Override** | Set `TOKENLEAK_CODEBUFF_DIR` environment variable |
655
+ | **Provider name** | `codebuff` |
656
+ | **Aliases** | `manicode` |
657
+
658
+ ### Droid
659
+
660
+ Reads Factory Droid session settings files and uses sibling JSONL session text to recover a model name when Droid only records a provider lock.
661
+
662
+ | | |
663
+ | ----------------- | ------------------------------------------------- |
664
+ | **Data location** | `~/.factory/sessions/*.settings.json` |
665
+ | **Override** | Set `TOKENLEAK_DROID_DIR` environment variable |
666
+ | **Provider name** | `droid` |
667
+ | **Aliases** | `factory` |
668
+
669
+ ### Qwen
670
+
671
+ Reads Qwen CLI project JSONL logs. Assistant records with `usageMetadata` are parsed for prompt, candidate, thought, and cached-content tokens.
672
+
673
+ | | |
674
+ | ----------------- | ----------------------------------------------- |
675
+ | **Data location** | `~/.qwen/projects/**/*.jsonl` |
676
+ | **Override** | Set `TOKENLEAK_QWEN_DIR` environment variable |
677
+ | **Provider name** | `qwen` |
678
+ | **Aliases** | None |
679
+
680
+ ### Roo Code and Kilo Code
681
+
682
+ Reads VS Code extension task logs from `ui_messages.json` and uses sibling `api_conversation_history.json` metadata to recover the selected model.
683
+
684
+ | | |
685
+ | ----------------- | ------------------------------------------------------------------------------------------------ |
686
+ | **Roo data** | `~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/tasks/**/ui_messages.json` |
687
+ | **Kilo data** | `~/.config/Code/User/globalStorage/kilocode.kilo-code/tasks/**/ui_messages.json` |
688
+ | **Override** | Set `TOKENLEAK_ROO_CODE_DIR` or `TOKENLEAK_KILO_CODE_DIR` environment variable |
689
+ | **Provider names** | `roo-code`, `kilo-code` |
690
+ | **Aliases** | `roo`, `roocode`, `kilocode` |
691
+
692
+ ### Kimi CLI
693
+
694
+ Reads Kimi CLI wire-protocol JSONL files. `StatusUpdate` messages provide input, output, and cache token counts.
695
+
696
+ | | |
697
+ | ----------------- | ------------------------------------------------- |
698
+ | **Data location** | `~/.kimi/sessions/**/wire.jsonl` |
699
+ | **Override** | Set `TOKENLEAK_KIMI_DIR` environment variable |
700
+ | **Provider name** | `kimi` |
701
+ | **Aliases** | `kimi-cli` |
702
+
703
+ ### Kilo CLI
704
+
705
+ Reads Kilo CLI SQLite usage rows from the local Kilo data directory. This is separate from the VS Code Kilo Code extension provider (`kilo-code`).
706
+
707
+ | | |
708
+ | ----------------- | ------------------------------------------------- |
709
+ | **Data location** | `~/.local/share/kilo/kilo.db` |
710
+ | **Override** | Set `TOKENLEAK_KILO_DIR` environment variable |
711
+ | **Provider name** | `kilo` |
712
+ | **Aliases** | `kilo-cli` |
713
+
714
+ ### Mux
715
+
716
+ Reads Mux session usage JSON files and preserves provider-reported per-model cost totals when present.
717
+
718
+ | | |
719
+ | ----------------- | ------------------------------------------------- |
720
+ | **Data location** | `~/.mux/sessions/**/session-usage.json` |
721
+ | **Override** | Set `TOKENLEAK_MUX_DIR` environment variable |
722
+ | **Provider name** | `mux` |
723
+ | **Aliases** | None |
724
+
725
+ ### Crush
726
+
727
+ Reads project-level Crush SQLite databases discovered from the Crush project registry. Crush exposes reliable session-level cost even when token breakdown is unavailable, so Tokenleak preserves cost without fabricating tokens.
728
+
729
+ | | |
730
+ | ----------------- | ------------------------------------------------------------------------ |
731
+ | **Data location** | `${XDG_DATA_HOME:-~/.local/share}/crush/projects.json` project registry |
732
+ | **Override** | Set `TOKENLEAK_CRUSH_DIR` environment variable |
733
+ | **Provider name** | `crush` |
734
+ | **Aliases** | None |
735
+
736
+ ### OpenClaw
737
+
738
+ Reads OpenClaw agent transcripts and optional `sessions.json` indexes. Model-change and model-snapshot records establish the model for assistant usage rows.
739
+
740
+ | | |
741
+ | ----------------- | --------------------------------------------------------- |
742
+ | **Data location** | `~/.openclaw/agents/**/*.jsonl*` |
743
+ | **Override** | Set `TOKENLEAK_OPENCLAW_DIR` environment variable |
744
+ | **Provider name** | `openclaw` |
745
+ | **Aliases** | `open-claw` |
746
+
747
+ ### Hermes
748
+
749
+ Reads aggregated Hermes Agent session rows from the local SQLite state database. The parser accepts schema variants where optional cost or cache columns are absent, as long as `id`, `model`, `started_at`, and at least one token or cost signal are present.
750
+
751
+ | | |
752
+ | ----------------- | ------------------------------------------------- |
753
+ | **Data location** | `${HERMES_HOME:-~/.hermes}/state.db` |
754
+ | **Override** | Set `HERMES_HOME` or `TOKENLEAK_HERMES_DIR` |
755
+ | **Provider name** | `hermes` |
756
+ | **Aliases** | `hermes-agent` |
757
+
758
+ ### Goose
759
+
760
+ Reads Goose session totals from the local `sessions.db` SQLite database. Tokenleak scans the XDG path by default; use the override for macOS Application Support or legacy Block/goose locations.
761
+
762
+ | | |
763
+ | ----------------- | --------------------------------------------------------------- |
764
+ | **Data location** | `${XDG_DATA_HOME:-~/.local/share}/goose/sessions/sessions.db` |
765
+ | **Override** | Set `TOKENLEAK_GOOSE_DIR` or `GOOSE_PATH_ROOT` |
766
+ | **Provider name** | `goose` |
767
+ | **Aliases** | None |
768
+
769
+ ### Antigravity
770
+
771
+ Reads normalized Antigravity JSONL cache files. Tokenleak does not currently connect to the local Antigravity language-server RPC or create this cache; place compatible JSONL artifacts in the cache directory first.
772
+
773
+ | | |
774
+ | ----------------- | ------------------------------------------------------------------ |
775
+ | **Data location** | `~/.config/tokenleak/antigravity-cache/sessions/*.jsonl` |
776
+ | **Override** | Set `TOKENLEAK_ANTIGRAVITY_DIR` environment variable |
777
+ | **Provider name** | `antigravity` |
778
+ | **Aliases** | None |
779
+
780
+ ### Zed Agent
781
+
782
+ Reads hosted Zed Agent rows from Zed's `threads.db`. External ACP agent rows are ignored to avoid double-counting usage that belongs to another provider.
783
+
784
+ | | |
785
+ | ----------------- | --------------------------------------------------------------------------- |
786
+ | **Data location** | `${XDG_DATA_HOME:-~/.local/share}/zed/threads/threads.db` |
787
+ | **Override** | Set `TOKENLEAK_ZED_DIR` environment variable |
788
+ | **Provider name** | `zed` |
789
+ | **Aliases** | `zed-agent` |
790
+
791
+ ### Kiro
792
+
793
+ Reads Kiro CLI session JSON files with explicit turn token metadata. SQLite import can be enabled by pointing the override at a compatible local data source.
794
+
795
+ | | |
796
+ | ----------------- | ------------------------------------------------- |
797
+ | **Data location** | `~/.kiro/sessions/cli/*.json` |
798
+ | **Override** | Set `TOKENLEAK_KIRO_DIR` environment variable |
799
+ | **Provider name** | `kiro` |
800
+ | **Aliases** | None |
801
+
802
+ ### Trae
803
+
804
+ Reads cached Trae usage API JSON files. Tokenleak does not currently authenticate with Trae or fetch this cache; export or sync compatible JSON first, then point Tokenleak at the cache.
805
+
806
+ | | |
807
+ | ----------------- | ---------------------------------------------------------- |
808
+ | **Data location** | `~/.config/tokenleak/trae-cache/sessions/*.json` |
809
+ | **Override** | Set `TOKENLEAK_TRAE_DIR` environment variable |
810
+ | **Provider name** | `trae` |
811
+ | **Aliases** | None |
812
+
813
+ ### Synthetic
814
+
815
+ Reads Octofriend/Synthetic SQLite token rows when available. Synthetic is also kept as an explicit provider filter so it does not duplicate unrelated provider usage during normal all-provider scans.
816
+
817
+ | | |
818
+ | ----------------- | ----------------------------------------------------- |
819
+ | **Data location** | `~/.local/share/octofriend/sqlite.db` |
820
+ | **Override** | Set `TOKENLEAK_SYNTHETIC_DIR` environment variable |
821
+ | **Provider name** | `synthetic` |
822
+ | **Aliases** | `octofriend` |
823
+
494
824
  ### OpenCode
495
825
 
496
826
  Reads usage data from current OpenCode message storage when available. Falls back to legacy SQLite databases or legacy JSON session files.
@@ -591,10 +921,12 @@ The dedicated analysis commands also support JSON output:
591
921
  ```bash
592
922
  tokenleak explain 2026-03-10 --format json
593
923
  tokenleak focus --format json
924
+ tokenleak replay 2026-03-10 --format json
594
925
  ```
595
926
 
596
- - `tokenleak explain ... --format json` returns an explain report with headline, summary bullets, evidence tables, and anomaly flags.
597
- - `tokenleak focus ... --format json` returns a ranked focus report with deep-work scores, durations, densities, streaks, and rationales per session.
927
+ - An explain report (`tokenleak explain ... --format json`) includes a headline, summary bullets, evidence tables for providers/models/sessions, and anomaly flags.
928
+ - `tokenleak focus ... --format json` produces a ranked focus report with deep-work scores, durations, token densities, project streaks, and per-session rationales.
929
+ - Use `tokenleak replay ... --format json` to get a replay report containing flow blocks, a token velocity time series, model switch annotations, and a day summary with flow/think ratio.
598
930
 
599
931
  When `--compare` is used with `--format json`, the output is a compare payload with:
600
932
 
@@ -662,6 +994,28 @@ All fields are optional. Only include the ones you want to override.
662
994
  | `CLAUDE_CONFIG_DIR` | `~/.claude` | Claude Code configuration directory |
663
995
  | `CODEX_HOME` | `~/.codex` | Codex home directory |
664
996
  | `TOKENLEAK_CURSOR_DIR` | `~/.config/tokenleak` | Cursor credentials/cache root (`cursor-credentials.json`, `cursor-cache/`) |
997
+ | `TOKENLEAK_GEMINI_DIR` | `~/.gemini/tmp` | Gemini CLI temp/session directory |
998
+ | `TOKENLEAK_COPILOT_OTEL_DIR` | `~/.copilot/otel` | GitHub Copilot OTEL JSONL directory |
999
+ | `TOKENLEAK_AMP_DIR` | `${XDG_DATA_HOME:-~/.local/share}/amp/threads` | Amp thread directory |
1000
+ | `TOKENLEAK_CODEBUFF_DIR` | `~/.config/manicode` | Codebuff/Manicode project chat root |
1001
+ | `TOKENLEAK_DROID_DIR` | `~/.factory/sessions` | Droid session settings directory |
1002
+ | `TOKENLEAK_QWEN_DIR` | `~/.qwen/projects` | Qwen project log directory |
1003
+ | `TOKENLEAK_ROO_CODE_DIR` | VS Code Roo Code task storage | Roo Code task-log directory |
1004
+ | `TOKENLEAK_KILO_CODE_DIR` | VS Code Kilo Code task storage | Kilo Code task-log directory |
1005
+ | `TOKENLEAK_KIMI_DIR` | `~/.kimi` | Kimi CLI root directory |
1006
+ | `TOKENLEAK_KILO_DIR` | `~/.local/share/kilo/kilo.db` | Kilo CLI SQLite database path |
1007
+ | `TOKENLEAK_MUX_DIR` | `~/.mux/sessions` | Mux session usage directory |
1008
+ | `TOKENLEAK_CRUSH_DIR` | Crush project registry discovery | Crush data directory or `crush.db` path |
1009
+ | `TOKENLEAK_OPENCLAW_DIR` | `~/.openclaw/agents` | OpenClaw agent transcript directory |
1010
+ | `TOKENLEAK_HERMES_DIR` | `~/.hermes` | Hermes directory containing `state.db` |
1011
+ | `HERMES_HOME` | `~/.hermes` | Hermes home directory |
1012
+ | `TOKENLEAK_GOOSE_DIR` | `${XDG_DATA_HOME:-~/.local/share}/goose/sessions/sessions.db` | Goose SQLite database path |
1013
+ | `GOOSE_PATH_ROOT` | unset | Goose root directory override |
1014
+ | `TOKENLEAK_ANTIGRAVITY_DIR` | `~/.config/tokenleak/antigravity-cache/sessions` | Antigravity normalized JSONL cache directory |
1015
+ | `TOKENLEAK_ZED_DIR` | `${XDG_DATA_HOME:-~/.local/share}/zed/threads/threads.db` | Zed Agent SQLite database path |
1016
+ | `TOKENLEAK_KIRO_DIR` | `~/.kiro/sessions/cli` | Kiro CLI session JSON directory |
1017
+ | `TOKENLEAK_TRAE_DIR` | `~/.config/tokenleak/trae-cache/sessions` | Trae cached usage JSON directory |
1018
+ | `TOKENLEAK_SYNTHETIC_DIR` | `~/.local/share/octofriend/sqlite.db` | Synthetic/Octofriend SQLite database path |
665
1019
  | `PI_CODING_AGENT_DIR` | `~/.pi/agent` | Pi coding agent directory (sessions live under `sessions/`) |
666
1020
 
667
1021
  ## What Tokenleak tracks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenleak",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Visualise your AI coding-assistant token usage across providers — heatmaps, dashboards, and shareable cards.",
5
5
  "type": "module",
6
6
  "bin": {