tokenleak 1.3.0 → 2.1.0
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.
- package/README.md +96 -39
- package/package.json +3 -2
- package/tokenleak +7425 -2372
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
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.
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
@@ -39,18 +39,19 @@ npx tokenleak --help
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
After installing, run `tokenleak` in your terminal. It auto-detects supported providers from their local logs.
|
|
42
|
-
In an interactive TTY, plain `tokenleak`
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
42
|
+
In an interactive TTY, plain `tokenleak` launches a full-screen TUI dashboard with 8 views:
|
|
43
|
+
|
|
44
|
+
- **Overview** — heatmap, stats, providers, and top models
|
|
45
|
+
- **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
|
|
47
|
+
- **Focus** — deep-work session rankings scored by duration, density, and streaks
|
|
48
|
+
- **Explain** — narrative day-by-day usage breakdown
|
|
49
|
+
- **Compare** — side-by-side period comparison with deltas
|
|
50
|
+
- **Export** — save PNG, Wrapped PNG, or launch a live server
|
|
51
|
+
- **Wrapped** — Spotify-Wrapped-style stats card with achievements and usage breakdown
|
|
52
|
+
- **Replay** — chronological session timeline with flow blocks, pulse chart, and flow/think ratio
|
|
53
|
+
|
|
54
|
+
Use `tokenleak --legacy` to open the classic interactive launcher instead.
|
|
54
55
|
|
|
55
56
|
### From source
|
|
56
57
|
|
|
@@ -68,10 +69,13 @@ bun dist/tokenleak.js
|
|
|
68
69
|
## Usage
|
|
69
70
|
|
|
70
71
|
```bash
|
|
71
|
-
# Open the
|
|
72
|
+
# Open the TUI dashboard (TTY only)
|
|
72
73
|
tokenleak
|
|
73
74
|
|
|
74
|
-
#
|
|
75
|
+
# Open the classic interactive launcher
|
|
76
|
+
tokenleak --legacy
|
|
77
|
+
|
|
78
|
+
# Skip the TUI and render directly with flags
|
|
75
79
|
tokenleak --format terminal
|
|
76
80
|
|
|
77
81
|
# Start the local live dashboard server
|
|
@@ -107,6 +111,10 @@ tokenleak -o card.png
|
|
|
107
111
|
tokenleak explain 2026-03-10
|
|
108
112
|
tokenleak explain 2026-03-10 --format json
|
|
109
113
|
|
|
114
|
+
# Replay a day's session timeline
|
|
115
|
+
tokenleak replay
|
|
116
|
+
tokenleak replay 2026-03-10 --format json
|
|
117
|
+
|
|
110
118
|
# Rank deep-work sessions
|
|
111
119
|
tokenleak focus
|
|
112
120
|
tokenleak focus --provider codex --days 30
|
|
@@ -120,7 +128,7 @@ tokenleak --list-providers
|
|
|
120
128
|
|
|
121
129
|
### Analysis commands
|
|
122
130
|
|
|
123
|
-
Tokenleak ships
|
|
131
|
+
Tokenleak ships three dedicated investigation commands in addition to the main dashboard flow:
|
|
124
132
|
|
|
125
133
|
```bash
|
|
126
134
|
# Explain what drove a specific day
|
|
@@ -134,10 +142,17 @@ tokenleak focus --days 30
|
|
|
134
142
|
|
|
135
143
|
# Focus report as JSON
|
|
136
144
|
tokenleak focus --format json --provider pi --output focus.json
|
|
145
|
+
|
|
146
|
+
# Replay today's session timeline
|
|
147
|
+
tokenleak replay
|
|
148
|
+
|
|
149
|
+
# Replay a specific day with JSON output
|
|
150
|
+
tokenleak replay 2026-03-10 --format json --output replay.json
|
|
137
151
|
```
|
|
138
152
|
|
|
139
153
|
- `tokenleak explain <date>` builds a narrative day report with top providers, sessions, projects, models, and anomaly flags.
|
|
140
154
|
- `tokenleak focus` ranks sessions by a deep-work score derived from duration, token density, and project streak.
|
|
155
|
+
- `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.
|
|
141
156
|
|
|
142
157
|
### Cursor commands
|
|
143
158
|
|
|
@@ -150,18 +165,19 @@ tokenleak cursor accounts --json
|
|
|
150
165
|
tokenleak cursor switch work
|
|
151
166
|
tokenleak cursor logout --name work
|
|
152
167
|
tokenleak cursor logout --all --purge-cache
|
|
168
|
+
tokenleak cursor reset
|
|
153
169
|
```
|
|
154
170
|
|
|
155
171
|
- Getting a Cursor session token:
|
|
156
172
|
|
|
157
|
-
The exact
|
|
173
|
+
The exact browser wording may vary, but the reliable source of truth is the `WorkosCursorSessionToken` cookie:
|
|
158
174
|
|
|
159
175
|
1. Open Cursor and sign in.
|
|
160
176
|
2. Open `https://www.cursor.com/settings`.
|
|
161
|
-
3. Open your browser developer tools
|
|
162
|
-
4.
|
|
163
|
-
5.
|
|
164
|
-
6. Paste that token into `tokenleak cursor login --name <label>` when prompted
|
|
177
|
+
3. Open your browser developer tools.
|
|
178
|
+
4. Go to `Application` (or `Storage`) -> `Cookies` -> `https://www.cursor.com`.
|
|
179
|
+
5. Copy the value of the `WorkosCursorSessionToken` cookie.
|
|
180
|
+
6. Paste that token into `tokenleak cursor login --name <label>` when prompted, or into the TUI setup modal after pressing `c`.
|
|
165
181
|
|
|
166
182
|
- Local checkout flow:
|
|
167
183
|
|
|
@@ -183,6 +199,7 @@ bun packages/cli/dist/cli.js --provider cursor --format json
|
|
|
183
199
|
- Normal dashboard/report runs auto-refresh Cursor cache when you are logged in and Cursor is requested or available.
|
|
184
200
|
- If refresh fails but cached CSVs exist, Tokenleak falls back to the cached data.
|
|
185
201
|
- `tokenleak cursor status` only validates the saved session token. It does not mark Cursor as available by itself.
|
|
202
|
+
- `tokenleak cursor reset` clears saved Cursor credentials and the local Cursor cache so you can re-test the in-TUI setup flow from a clean state.
|
|
186
203
|
- `tokenleak --list-providers` reports whether local provider data exists. For Cursor, that means `cursor-cache/usage*.csv` must already be present.
|
|
187
204
|
- 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`.
|
|
188
205
|
- Cursor session tokens are stored in plaintext at `~/.config/tokenleak/cursor-credentials.json` (or under `TOKENLEAK_CURSOR_DIR`) with local-only file permissions.
|
|
@@ -265,6 +282,10 @@ When you use `--format png` or `--format svg`, Tokenleak enables expanded compar
|
|
|
265
282
|
|
|
266
283
|
Generate a Spotify-Wrapped-style story card as a tall PNG image showing your AI coding stats, streaks, model usage, habits, achievements, and more.
|
|
267
284
|
|
|
285
|
+
Current wrapped card generated from the latest Tokenleak build:
|
|
286
|
+
|
|
287
|
+

|
|
288
|
+
|
|
268
289
|
```bash
|
|
269
290
|
# Generate your wrapped card (dark theme, opens automatically)
|
|
270
291
|
tokenleak --format wrapped --open
|
|
@@ -280,7 +301,7 @@ The wrapped card includes 12 sections: title, big numbers, streak story, top mod
|
|
|
280
301
|
|
|
281
302
|
Achievements are computed from your actual data — earn badges like Streak Master (30+ day streak), Cache Master (>50% hit rate), Night Owl (>40% usage 10pm-6am), Power User (>10k avg daily tokens), and more.
|
|
282
303
|
|
|
283
|
-
The
|
|
304
|
+
The TUI dashboard includes a Wrapped view (press `8` or arrow to it). The classic launcher (`tokenleak --legacy`) also offers a guided Wrapped setup flow.
|
|
284
305
|
|
|
285
306
|
### Wrapped Live
|
|
286
307
|
|
|
@@ -297,9 +318,11 @@ tokenleak --wrapped-live --days 365 --claude
|
|
|
297
318
|
tokenleak --wrapped-live --provider claude-code,codex
|
|
298
319
|
```
|
|
299
320
|
|
|
300
|
-
|
|
321
|
+
`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.
|
|
322
|
+
|
|
323
|
+
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.
|
|
301
324
|
|
|
302
|
-
The
|
|
325
|
+
The classic launcher (`tokenleak --legacy`) includes Wrapped Live as a menu option.
|
|
303
326
|
|
|
304
327
|
### Model Efficiency Advisor
|
|
305
328
|
|
|
@@ -372,19 +395,48 @@ tokenleak --format json --upload gist
|
|
|
372
395
|
|
|
373
396
|
## Interactive modes
|
|
374
397
|
|
|
375
|
-
###
|
|
376
|
-
|
|
377
|
-
In a real TTY, `tokenleak` opens a launcher instead of rendering immediately. You can move with arrow keys, use number shortcuts, inspect the exact command preview before running it, and stay inside the same session after each command finishes.
|
|
398
|
+
### TUI dashboard (default)
|
|
378
399
|
|
|
379
|
-
|
|
400
|
+
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:
|
|
380
401
|
|
|
381
|
-
|
|
402
|
+
Latest OpenTUI screenshots from the current dashboard build:
|
|
382
403
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
404
|
+
| Overview | Matrix (page 4) |
|
|
405
|
+
| --- | --- |
|
|
406
|
+
|  |  |
|
|
407
|
+
| Advisor | Focus |
|
|
408
|
+
|  |  |
|
|
409
|
+
| Explain | Compare |
|
|
410
|
+
|  |  |
|
|
411
|
+
| Export | Wrapped |
|
|
412
|
+
|  |  |
|
|
413
|
+
|
|
414
|
+
| Key | Action |
|
|
415
|
+
| --- | --- |
|
|
416
|
+
| `←` / `→` | Switch between views |
|
|
417
|
+
| `Tab` / `>` | Next time period (1D → 7D → 30D → 90D → ALL) |
|
|
418
|
+
| `Shift+Tab` / `<` | Previous time period |
|
|
419
|
+
| `1`–`8` | Jump directly to a view |
|
|
420
|
+
| `j` / `k` | Scroll up/down in scrollable views |
|
|
421
|
+
| `[` / `]` | Matrix page navigation (in Matrix view) |
|
|
422
|
+
| `h` / `l` | Previous/next day (in Explain view) |
|
|
423
|
+
| `s` | Toggle sort mode (in Overview) |
|
|
424
|
+
| `r` | Refresh data |
|
|
425
|
+
| `c` | Open Cursor setup when the dashboard shows a Cursor auth/sync banner |
|
|
426
|
+
| `?` | Help overlay |
|
|
427
|
+
| `q` | Quit |
|
|
428
|
+
|
|
429
|
+
When Cursor needs setup, re-authentication, or a cache retry, the TUI shows a contextual banner. Press `c` to open the built-in Cursor setup flow, paste a session token, validate it, and sync usage CSVs without leaving the dashboard.
|
|
430
|
+
|
|
431
|
+
The Matrix view spans 4 pages:
|
|
432
|
+
1. Overview + time windows + providers + top models
|
|
433
|
+
2. Hour-of-day, day-of-week, I/O breakdown, monthly burn
|
|
434
|
+
3. Cache economics, cache ROI, session metrics, top projects
|
|
435
|
+
4. Model efficiency, attribution clusters, top sessions, cache ROI by model
|
|
436
|
+
|
|
437
|
+
### Classic launcher
|
|
438
|
+
|
|
439
|
+
`tokenleak --legacy` opens the previous interactive launcher with a numbered menu, command preview, and guided setup flows for exports, wrapped cards, and the live dashboard.
|
|
388
440
|
|
|
389
441
|
### Live dashboard
|
|
390
442
|
|
|
@@ -392,14 +444,15 @@ This mode uses event-level data when available, so session, token, project, attr
|
|
|
392
444
|
|
|
393
445
|
## All flags
|
|
394
446
|
|
|
395
|
-
When you run bare `tokenleak` in a real terminal, the
|
|
447
|
+
When you run bare `tokenleak` in a real terminal, the TUI dashboard launches. Pass flags to skip the TUI and render directly.
|
|
396
448
|
|
|
397
449
|
Subcommands:
|
|
398
450
|
|
|
399
451
|
- `tokenleak explain <date>` supports `--format terminal|json`, `--output`, `--width`, and the standard provider filters.
|
|
400
452
|
- `tokenleak focus` supports `--format terminal|json`, `--output`, `--width`, and the standard provider/date filters.
|
|
453
|
+
- `tokenleak replay [date]` supports `--format terminal|json`, `--output`, `--width`, and the standard provider filters. Date defaults to today.
|
|
401
454
|
- `tokenleak cursor --help` prints the Cursor auth/cache command help text.
|
|
402
|
-
- `tokenleak explain --help` and `tokenleak
|
|
455
|
+
- `tokenleak explain --help`, `tokenleak focus --help`, and `tokenleak replay --help` print the subcommand-specific help text.
|
|
403
456
|
|
|
404
457
|
| Flag | Alias | Default | Description |
|
|
405
458
|
| --- | --- | --- | --- |
|
|
@@ -426,6 +479,7 @@ Subcommands:
|
|
|
426
479
|
| `--live-server` | `-L` | `false` | Start the local browser dashboard |
|
|
427
480
|
| `--wrapped-live` | | `false` | Start the interactive AI Wrapped presentation in a browser |
|
|
428
481
|
| `--advisor` | | `false` | Run the model efficiency advisor |
|
|
482
|
+
| `--legacy` | | `false` | Open the classic interactive launcher instead of the TUI |
|
|
429
483
|
| `--no-color` | | `false` | Strip ANSI escape codes from terminal output |
|
|
430
484
|
| `--no-insights` | | `false` | Hide terminal insights |
|
|
431
485
|
| `--version` | | | Print version information |
|
|
@@ -568,10 +622,12 @@ The dedicated analysis commands also support JSON output:
|
|
|
568
622
|
```bash
|
|
569
623
|
tokenleak explain 2026-03-10 --format json
|
|
570
624
|
tokenleak focus --format json
|
|
625
|
+
tokenleak replay 2026-03-10 --format json
|
|
571
626
|
```
|
|
572
627
|
|
|
573
|
-
- `tokenleak explain ... --format json`
|
|
574
|
-
- `tokenleak focus ... --format json`
|
|
628
|
+
- An explain report (`tokenleak explain ... --format json`) includes a headline, summary bullets, evidence tables for providers/models/sessions, and anomaly flags.
|
|
629
|
+
- `tokenleak focus ... --format json` produces a ranked focus report with deep-work scores, durations, token densities, project streaks, and per-session rationales.
|
|
630
|
+
- 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.
|
|
575
631
|
|
|
576
632
|
When `--compare` is used with `--format json`, the output is a compare payload with:
|
|
577
633
|
|
|
@@ -743,12 +799,13 @@ tokenleak/
|
|
|
743
799
|
core/ Shared types, constants, aggregation engine
|
|
744
800
|
registry/ Provider parsers and model pricing
|
|
745
801
|
renderers/ JSON, SVG, PNG, and terminal output
|
|
802
|
+
tui/ Full-screen TUI dashboard (default interactive mode)
|
|
746
803
|
cli/ CLI entrypoint and config handling
|
|
747
804
|
mcp/ MCP server for AI assistant integration
|
|
748
805
|
scripts/
|
|
749
806
|
build-npm.ts Bundles CLI for npm publishing
|
|
750
807
|
dist/
|
|
751
|
-
tokenleak
|
|
808
|
+
tokenleak Bundled CLI (generated)
|
|
752
809
|
```
|
|
753
810
|
|
|
754
811
|
## Contributing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokenleak",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Visualise your AI coding-assistant token usage across providers — heatmaps, dashboards, and shareable cards.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"tokenleak"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"sharp": "^0.34.0"
|
|
13
|
+
"sharp": "^0.34.0",
|
|
14
|
+
"@opentui/core": "^0.1.88"
|
|
14
15
|
},
|
|
15
16
|
"engines": {
|
|
16
17
|
"bun": ">=1.0.0"
|