pi-tokenburn 0.7.1 → 0.7.3
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 +35 -18
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/pi-tokenburn)
|
|
5
5
|
[](https://github.com/sorinirimies/pi-tokenburn/actions/workflows/ci.yml)
|
|
6
6
|
[](LICENSE)
|
|
7
|
+
[](https://github.com/sorinirimies/pi-tokenburn/actions/workflows/security.yml)
|
|
8
|
+
[](https://github.com/sorinirimies/pi-tokenburn/actions/workflows/fuzz.yml)
|
|
7
9
|
|
|
8
10
|
Token usage and cost monitor with budgets, directly in your [Pi](https://github.com/earendil-works/pi-coding-agent) session.
|
|
9
11
|
|
|
@@ -19,9 +21,9 @@ Totals match the `tokenburn` CLI exactly.
|
|
|
19
21
|
- **Tables:** usage per model, provider, project and session, for any period, with cache hit %, savings, cost and share.
|
|
20
22
|
- **Filter and export:** limit everything to a provider, model or project; write csv or json.
|
|
21
23
|
- **Pricing:** a price table fills in (or overrides) costs the logs don't have.
|
|
22
|
-
- **Report chart:** `/tokenburn` shows the summary plus a vertical column chart (y-axis, budget line, current period marked, over-budget columns in red, peak/avg footer). Daily (14 days), weekly (8 weeks)
|
|
23
|
-
- **Status line:** `/tokenburn day|week|month|year|all` (or `cycle`) changes the period shown at the bottom. Charts live under `/tokenburn chart <view>`.
|
|
24
|
-
- **Window panel (optional):** Today / Week / Month / Total below the editor, with in/out tokens and cost.
|
|
24
|
+
- **Report chart:** `/tokenburn` shows the summary plus a vertical column chart (y-axis, budget line, current period marked, over-budget columns in red, peak/avg footer). Daily (14 days), weekly (8 weeks), monthly (6 months), yearly (5 years) or all-time.
|
|
25
|
+
- **Status line:** `/tokenburn hour|day|week|month|year|all` (or `cycle`) changes the period shown at the bottom. Charts live under `/tokenburn chart <view>`.
|
|
26
|
+
- **Window panel (optional):** Today / Week / Month / Year / Total below the editor, with in/out tokens and cost.
|
|
25
27
|
- **Budgets** per day, week and month, in tokens and/or dollars.
|
|
26
28
|
- **Live:** the bottom line updates after every assistant message, not only when a turn ends, at no measurable cost (see Performance).
|
|
27
29
|
- **Fast:** per-file cache keyed on mtime+size. First scan of ~400 MB of sessions takes under a second; refreshes after that take milliseconds. Refresh never blocks the agent loop.
|
|
@@ -44,23 +46,22 @@ pi install git:github.com/sorinirimies/pi-tokenburn
|
|
|
44
46
|
|
|
45
47
|
| Command | What it does |
|
|
46
48
|
|---|---|
|
|
47
|
-
| `/tokenburn day\|week\|month\|year\|all` | **Switch the bottom status line**: today, this week, this month, this year, or the all-time total |
|
|
49
|
+
| `/tokenburn hour\|day\|week\|month\|year\|all` | **Switch the bottom status line**: last 60 minutes, today, this week (from Monday), this month, this year, or the all-time total. `today` and `total` work as aliases of `day` and `all` |
|
|
48
50
|
| `/tokenburn chart <view>` | Report + **chart**. Views: `day` (14 days), `week` (8 weeks), `month` (6 months), `year` (5 years), `all` (whole history; monthly columns up to 18 months, yearly beyond) |
|
|
49
51
|
| `/tokenburn` | Report + daily chart (same as `/tokenburn chart day`) |
|
|
50
|
-
| `/tokenburn cycle` | Rotate the status line: today → week → month → year → total |
|
|
51
|
-
| `/tokenburn status <today\|week\|month\|year\|total>` | Explicit form of the first row |
|
|
52
|
-
| `/tokenburn models hour
|
|
53
|
-
| `/tokenburn providers hour
|
|
54
|
-
| `/tokenburn projects hour
|
|
55
|
-
| `/tokenburn sessions hour
|
|
52
|
+
| `/tokenburn cycle` | Rotate the status line: hour → today → week → month → year → total |
|
|
53
|
+
| `/tokenburn status <hour\|today\|week\|month\|year\|total>` | Explicit form of the first row |
|
|
54
|
+
| `/tokenburn models hour\|day\|week\|month\|year\|all` | **Table** of usage per model (tokens, in/out, cache hit %, cache savings, cost, share). `period` (optional, default `all`): `hour` (rolling last 60 min), `day` (since local midnight), `week` (since Monday), `month`, `year`, `all`. Optional `provider=x`, `model=x`, `project=x` (substring, this call only) narrow any table, e.g. `models week provider=anthropic` |
|
|
55
|
+
| `/tokenburn providers hour\|day\|week\|month\|year\|all` | Same table per provider; same period and filter arguments |
|
|
56
|
+
| `/tokenburn projects hour\|day\|week\|month\|year\|all` | Same table per project (session working directory) |
|
|
57
|
+
| `/tokenburn sessions hour\|day\|week\|month\|year\|all` | Leaderboard of the `n` costliest sessions: add a number for `n` (default 10), e.g. `sessions week 5` (`top` is an alias) |
|
|
56
58
|
| `/tokenburn session` | Spend of the **current** session, and its share of today |
|
|
57
59
|
| `/tokenburn filter <provider\|model\|project> <value>` | Limit everything (status line, report, tables, export) to matching usage (case-insensitive substring). `filter` shows it, `filter all` clears it |
|
|
58
|
-
| `/tokenburn export csv
|
|
60
|
+
| `/tokenburn export csv\|json` | Optional `[period]` and `[path]` follow the format. Writes one row per day × provider × model × project (default `tokenburn-<period>.<format>` in the current directory) |
|
|
59
61
|
| `/tokenburn warn <pct>` | Notify once when a budget reaches `pct` percent (default 80) and once when it is exceeded |
|
|
60
62
|
| `/tokenburn rate` | Toggle the burn rate in the status line (`42k/h`: tokens per hour averaged over the status period) |
|
|
61
63
|
| `/tokenburn hit` | Toggle the cache hit ratio (`95% hit`) in the status line |
|
|
62
64
|
| `/tokenburn saved` | Toggle the estimated cache savings (`~$12.40 saved`) in the status line |
|
|
63
|
-
| `/tokenburn hour` | Show the last 60 minutes in the status line (joins `day`, `week`, `month`, `year`, `all`) |
|
|
64
65
|
| `/tokenburn pricing` | Where costs come from (session logs vs your price table) and which models are unpriced |
|
|
65
66
|
| `/tokenburn price <model> <in> <out>` | Set a price in $ per million tokens (key `model` or `provider/model`); `price remove <model>` deletes it. `pricing mode <fill\|override>`: use the table only where the log has no cost (default), or always |
|
|
66
67
|
| `/tokenburn window` | Toggle the panel below the editor |
|
|
@@ -75,7 +76,7 @@ pi install git:github.com/sorinirimies/pi-tokenburn
|
|
|
75
76
|
|
|
76
77
|
Recorded from a real pi with only this plugin loaded, on synthetic data.
|
|
77
78
|
|
|
78
|
-
**Switch what the bottom line shows** (`/tokenburn hour
|
|
79
|
+
**Switch what the bottom line shows** (`/tokenburn hour`, `day`, `week`, `month`, `year`, `all`, or `cycle`):
|
|
79
80
|
|
|
80
81
|

|
|
81
82
|
|
|
@@ -152,15 +153,28 @@ Weeks start on Monday, in local time.
|
|
|
152
153
|
"showStatus": true,
|
|
153
154
|
"showWidget": false,
|
|
154
155
|
"statusWindow": "today",
|
|
156
|
+
"showRate": true,
|
|
157
|
+
"showHit": true,
|
|
158
|
+
"showSaved": true,
|
|
159
|
+
"warnPct": 80,
|
|
160
|
+
"filter": { "model": "acme-large" },
|
|
161
|
+
"prices": { "acme-large": { "input": 3, "output": 15, "cacheRead": 0.3, "cacheWrite": 3.75 } },
|
|
162
|
+
"priceMode": "fill",
|
|
155
163
|
"budgets": { "dayTokens": 5000000, "weekCost": 50 }
|
|
156
164
|
}
|
|
157
165
|
```
|
|
158
166
|
|
|
159
|
-
- `includeCache` (default `true`): count cache read/write tokens in totals, like the `tokenburn` CLI. Cache reads dominate (often 95%+ of tokens) but are billed far cheaper; set `false` to budget on input + output only.
|
|
160
|
-
|
|
161
167
|
- `enabled` (default `true`): master switch, same as `/tokenburn enable|disable`.
|
|
162
168
|
- `liveRefresh` (default `true`): refresh after each assistant message. `false` = only when a turn ends. `refreshMs` (default `750`, range 250 to 60000) is the coalescing delay.
|
|
169
|
+
- `includeCache` (default `true`): count cache read/write tokens in totals, like the `tokenburn` CLI. Cache reads dominate (often 95%+ of tokens) but are billed far cheaper; set `false` to budget on input + output only.
|
|
163
170
|
- `chartColor` (default `true`): color the chart using your pi theme (current period green, over-budget red, budget line yellow). Set `false` for plain text.
|
|
171
|
+
- `showStatus` / `showWidget` (defaults `true` / `false`): the bottom status line and the panel below the editor.
|
|
172
|
+
- `statusWindow` (default `today`): the status-line period, one of `hour`, `today`, `week`, `month`, `year`, `total`.
|
|
173
|
+
- `showRate` / `showHit` / `showSaved` (default `true`): the burn rate, cache hit ratio and estimated savings in the status line.
|
|
174
|
+
- `warnPct` (default `80`): notify once at this budget percentage and once when exceeded; `0` turns it off.
|
|
175
|
+
- `filter`: only count usage whose `provider`, `model` or `project` contains the value (case-insensitive); set by the `filter` command.
|
|
176
|
+
- `prices` / `priceMode` (default `fill`): price table in $ per million tokens, used where the log has no cost (`fill`) or always (`override`); set by the `price` command.
|
|
177
|
+
- `budgets`: `dayTokens`, `weekTokens`, `monthTokens`, `dayCost`, `weekCost`, `monthCost`.
|
|
164
178
|
|
|
165
179
|
Environment overrides for the session directory: `TOKENBURN_PI_SESSIONS`, `PI_CODING_AGENT_SESSION_DIR`, `PI_CODING_AGENT_DIR`.
|
|
166
180
|
|
|
@@ -197,7 +211,8 @@ bun install
|
|
|
197
211
|
just check # typecheck + tests + pack check + nushell tests (what CI runs)
|
|
198
212
|
just test # bun test only (with coverage)
|
|
199
213
|
just coverage # tests + a coverage table
|
|
200
|
-
just push-all # push main to every configured remote (origin + the Gitea instances)
|
|
214
|
+
just push-all # push main to every configured remote (origin + the Gitea instances)
|
|
215
|
+
just --list # everything else: pull-all, push-tags-all, release-all, sync-gitea-*, the *-force variants
|
|
201
216
|
```
|
|
202
217
|
|
|
203
218
|
**Coverage:** every `bun test` collects coverage (`bunfig.toml`) and **fails below 95% lines / 95% functions**. CI shows the table on the run page and uploads `lcov.info`.
|
|
@@ -232,15 +247,17 @@ CI scripts are [nushell](https://www.nushell.sh) (`scripts/`), the same ones loc
|
|
|
232
247
|
| Workflow | When | What |
|
|
233
248
|
|---|---|---|
|
|
234
249
|
| **CI** | push / PR | quality gate on Linux; tests on macOS and Windows, and in extreme time zones |
|
|
250
|
+
| **Fuzz** | nightly (GitHub 04:00 UTC, Gitea 04:30), and when the extension changes | seeded randomised robustness tests (`tests/fuzz.test.ts`), 200 000 runs per property nightly (5 000 when the extension changes; `just fuzz [iterations] [seed]` locally); a failure prints the seed that reproduces it |
|
|
251
|
+
| **Security** | nightly (GitHub 03:00 UTC, Gitea 03:30), and when dependencies change | `bun audit`: fails on any known vulnerability |
|
|
235
252
|
| **Auto-merge library updates** | CI finished on a Dependabot PR | **patch and minor** updates (GitHub Actions) are merged automatically, but only **after CI is green** on that exact commit; a **major** update waits for you. Needs the `GH_PAT` secret: action bumps change `.github/workflows/*`, which `GITHUB_TOKEN` may not merge |
|
|
236
253
|
| **Gitea Actions Update** | Mondays 03:15 UTC | Gitea has no Dependabot: moves the sha pins in `.gitea/workflows` to the newest release of the **same major** and commits `ci(deps)`; a new major is only reported |
|
|
237
254
|
| **Nightly Dependency Update** | every night (GitHub 02:00 UTC) and after each auto-merge | `bun update` within ranges, verify on all platforms, commit `chore(deps)`; then **build, tag and publish a new patch** whenever a library was upgraded or merged, or `feat`/`fix`/`perf` commits are waiting since the last tag |
|
|
238
255
|
| **Mirror GitHub** (Gitea) | hourly | Gitea has no nightly of its own: fast-forwards its `main` to GitHub's and pushes the new tags (starting Gitea's release for each), so the hosts never diverge; fails loudly if they did |
|
|
239
|
-
| **Release** | tag `vX.Y.Z
|
|
256
|
+
| **Release** | tag `vX.Y.Z`, or run it with a bump | validates the tag against `package.json`, runs the gate, `npm publish` (idempotent, with provenance), creates the release |
|
|
240
257
|
|
|
241
258
|
So library updates need no human: they are merged once CI passes, built, versioned and published as a patch. A downgrade, a failing check, or a major update stops the chain and waits for review.
|
|
242
259
|
|
|
243
|
-
Manual release: `just release patch` (or `minor` / `major` / `X.Y.Z`) bumps, tags and pushes to GitHub; `just release-all patch` pushes to every configured remote; `just push-release-all` pushes an existing bump.
|
|
260
|
+
Release from CI: **Actions → Release → Run workflow** with a bump (`patch`, `minor`, `major`), or `just release-ci minor`: runs the gate, bumps, writes the changelog, tags, pushes and publishes. Manual release: `just release patch` (or `minor` / `major` / `X.Y.Z`) bumps, tags and pushes to GitHub; `just release-all patch` pushes to every configured remote; `just push-release-all` pushes an existing bump.
|
|
244
261
|
|
|
245
262
|
**Secrets** (repo settings): `NPM_TOKEN` is an npm *granular access token* with publish rights and "bypass 2FA" (required for CI publishing). `GH_PAT` (classic PAT, `repo` + `workflow`: needed to auto-merge GitHub Actions bumps; also lets a tag push trigger the release itself). Optional: `GITEA_TOKEN` (Gitea).
|
|
246
263
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-tokenburn",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "Pi extension for live token usage monitoring and budget tracking (
|
|
3
|
+
"version": "0.7.3",
|
|
4
|
+
"description": "Pi extension for live token usage monitoring and budget tracking (hour / day / week / month / year / all). 0 prompt tokens.",
|
|
5
5
|
"keywords": ["pi-package", "pi-extension", "tokenburn", "tokens", "analytics", "budget", "stats"],
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "sorinirimies",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"@earendil-works/pi-coding-agent": "*"
|
|
26
26
|
},
|
|
27
27
|
"overrides": {
|
|
28
|
-
"undici": "8.12.3"
|
|
28
|
+
"undici": "8.12.3",
|
|
29
|
+
"minimatch": "11.0.3"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@earendil-works/pi-coding-agent": "^1.4.0",
|