pi-tokenburn 0.5.0 โ 0.5.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.
- package/README.md +83 -17
- package/extensions/tokenburn.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# pi-tokenburn
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/pi-tokenburn)
|
|
4
|
+
[](https://www.npmjs.com/package/pi-tokenburn)
|
|
5
|
+
[](https://github.com/sorinirimies/pi-tokenburn/actions/workflows/ci.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
3
8
|
Token usage and cost monitor with budgets, directly in your [Pi](https://github.com/earendil-works/pi-coding-agent) session.
|
|
4
9
|
|
|
5
10
|
TypeScript port of the pi collector from [tokenburn](https://github.com/sorinirimies/tokenburn).
|
|
6
11
|
Reads Pi's local session logs (`~/.pi/agent/sessions/**/*.jsonl`). **No network, zero prompt tokens.**
|
|
7
12
|
Totals match the `tokenburn` CLI exactly.
|
|
8
13
|
|
|
14
|
+
<img src="examples/vhs/generated/overview.gif" alt="pi-tokenburn: the live footer counter, a report with a daily chart, switching the footer period and a weekly chart" width="900">
|
|
15
|
+
|
|
9
16
|
## Features
|
|
10
17
|
|
|
11
18
|
- **Status bar:** `๐ฅ 1.20M ($52.79) [today]`, turns red with `OVER BUDGET` past your limit.
|
|
@@ -41,22 +48,53 @@ pi install git:github.com/sorinirimies/pi-tokenburn
|
|
|
41
48
|
| `/tokenburn disable` (`off`) | Turn tokenburn off: status line and panel cleared, **nothing runs in the background**. `chart` still works on demand |
|
|
42
49
|
| `/tokenburn enable` (`on`) | Turn it back on. Both are remembered across sessions |
|
|
43
50
|
|
|
51
|
+
### Previews
|
|
52
|
+
|
|
53
|
+
Recorded from a real pi with only this plugin loaded, on synthetic data.
|
|
54
|
+
|
|
55
|
+
**Switch what the bottom line shows** (`/tokenburn day|week|month|year|all`, or `cycle`):
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
**Charts** (`/tokenburn chart day|week|month|year|all`): the current period is green, with a peak and average footer:
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
**Budgets** (`/tokenburn budget day 150000`, `budget week $2.5`): the footer turns red past the limit, and the chart draws the budget line with over-budget columns in red:
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
**Live refresh:** the footer updates after every assistant message, not only when a turn ends (here a local mock model answers; pi writes the turn to its session log and the counter moves by itself):
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
**Enable / disable:** off means off (nothing runs in the background), and charts still work on demand:
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
**Tab-completion** uses pi's own menu, with a description for every option:
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
44
79
|
Tab-completion works for all of these. Unknown input prints usage instead of failing. `report <view>` is kept as an alias of `chart <view>`.
|
|
45
80
|
|
|
46
|
-
Chart example (`/tokenburn chart day`, with a
|
|
81
|
+
Chart example (`/tokenburn chart day`, with a 150k day budget):
|
|
47
82
|
|
|
48
83
|
```
|
|
49
|
-
Daily tokens ยท last 14 days โ budget
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
Daily tokens ยท last 14 days โ budget 150.0k
|
|
85
|
+
291.9k โ โโ โโ
|
|
86
|
+
โ โโ โโ
|
|
87
|
+
โ โโ โ
โ
โโ โโ
|
|
88
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ
|
|
89
|
+
146.0k โ โโ โโ โโ โโ โโ โโ
|
|
90
|
+
โ โโ โโ โโ โโ โโ โโ โโ โโ โโ
|
|
91
|
+
โโโ โโ โโ โโ โโ โโ โโ โโ โโ โโ
|
|
92
|
+
โโโ โโ โโ โ
โ
โโ โโ โโ โโ โโ โโ โโ โโ โโ โโ
|
|
93
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
94
|
+
26 27 28 29 30 01 02 03 04 05 06 07 08 09
|
|
95
|
+
Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr
|
|
96
|
+
โฒ
|
|
97
|
+
ฮฃ 1.74M ($4.81) ยท avg 124.4k/day ยท peak 291.9k (10-07 Wed)
|
|
60
98
|
```
|
|
61
99
|
|
|
62
100
|
Weeks start on Monday, in local time.
|
|
@@ -96,6 +134,17 @@ Refreshing is designed to cost nothing you can notice:
|
|
|
96
134
|
- **Never blocks:** refreshes are fire-and-forget and errors are swallowed; the timer is unref'd and cancelled at shutdown.
|
|
97
135
|
- **Off means off:** `/tokenburn disable` (or `"enabled": false`) reads no files and starts no timers.
|
|
98
136
|
|
|
137
|
+
## Demo recordings
|
|
138
|
+
|
|
139
|
+
The GIFs above live in [`examples/vhs/generated/`](examples/vhs/generated) and are stored with **Git LFS** (`git lfs install` once). They are recorded with [VHS](https://github.com/charmbracelet/vhs) from a **real pi** that loads only this extension, on **synthetic** data (`examples/vhs/fixture.sh`: 900 days of made-up sessions in `/tmp` with deliberately small numbers, and a local mock model for the live-refresh demo), never from real logs, paths or credentials:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
just vhs-all # every tape (examples/vhs/*.tape): needs vhs, ttyd, ffmpeg, pi, bun, python3
|
|
143
|
+
just vhs-tape charts # one tape
|
|
144
|
+
just vhs-list # list the tapes
|
|
145
|
+
just demo # try it yourself in a real pi on the same synthetic data
|
|
146
|
+
```
|
|
147
|
+
|
|
99
148
|
## Security notes
|
|
100
149
|
|
|
101
150
|
- **Local and read-only.** It reads pi's session logs and its own `tokenburn.json`. Nothing leaves your machine: no network, no telemetry, no shell commands, **zero runtime dependencies**.
|
|
@@ -120,15 +169,16 @@ CI scripts are [nushell](https://www.nushell.sh) (`scripts/`), the same ones loc
|
|
|
120
169
|
|
|
121
170
|
| Workflow | When | What |
|
|
122
171
|
|---|---|---|
|
|
123
|
-
| **CI** | push / PR | quality gate on Linux; tests on macOS
|
|
124
|
-
| **
|
|
125
|
-
| **
|
|
172
|
+
| **CI** | push / PR | quality gate on Linux; tests on macOS and Windows, and in extreme time zones |
|
|
173
|
+
| **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. Then it starts the nightly workflow so the update ships |
|
|
174
|
+
| **Nightly Dependency Update** | every night (GitHub 02:00 UTC, Gitea 02:30) 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 |
|
|
175
|
+
| **Release** | tag `vX.Y.Z` | validates the tag against `package.json`, runs the gate, `npm publish` (idempotent, with provenance), creates the release |
|
|
126
176
|
|
|
127
|
-
|
|
177
|
+
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.
|
|
128
178
|
|
|
129
179
|
Manual release: `just bump patch` (or `minor` / `major` / `X.Y.Z`), then `just release-push`.
|
|
130
180
|
|
|
131
|
-
**Secrets** (repo settings): `NPM_TOKEN`
|
|
181
|
+
**Secrets** (repo settings): `NPM_TOKEN` is an npm *granular access token* with publish rights and "bypass 2FA" (required for CI publishing). Optional: `GH_PAT` (lets a tag push trigger the release itself), `GITEA_TOKEN` (Gitea).
|
|
132
182
|
|
|
133
183
|
Commits follow [Conventional Commits](https://www.conventionalcommits.org); the changelog is generated by git-cliff.
|
|
134
184
|
|
|
@@ -136,4 +186,20 @@ Commits follow [Conventional Commits](https://www.conventionalcommits.org); the
|
|
|
136
186
|
|
|
137
187
|
Pi sessions only. For Zed, Claude Code, Codex, Gemini and more, use the Rust [tokenburn](https://github.com/sorinirimies/tokenburn).
|
|
138
188
|
|
|
189
|
+
## Related plugins
|
|
190
|
+
|
|
191
|
+
Three small [pi](https://github.com/earendil-works/pi-coding-agent) extensions that save tokens without adding anything to the system prompt:
|
|
192
|
+
|
|
193
|
+
| Plugin | What it does |
|
|
194
|
+
|---|---|
|
|
195
|
+
| [**pi-edit-first**](https://github.com/sorinirimies/pi-edit-first) | Blocks whole-file `write` rewrites and hand-written project manifests, steering the agent to targeted `edit` calls and scaffolders |
|
|
196
|
+
| [**pi-read-guard**](https://github.com/sorinirimies/pi-read-guard) | Blocks full reads of large files, steering the agent to `offset`/`limit` or search |
|
|
197
|
+
| [**pi-tokenburn**](https://github.com/sorinirimies/pi-tokenburn) | Live token and cost counter in pi's footer, with charts and budgets |
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
pi install npm:pi-edit-first
|
|
201
|
+
pi install npm:pi-read-guard
|
|
202
|
+
pi install npm:pi-tokenburn
|
|
203
|
+
```
|
|
204
|
+
|
|
139
205
|
MIT
|
package/extensions/tokenburn.ts
CHANGED
|
@@ -953,7 +953,7 @@ export default function tokenBurnExtension(pi: ExtensionAPI) {
|
|
|
953
953
|
rule,
|
|
954
954
|
...chart,
|
|
955
955
|
rule,
|
|
956
|
-
"
|
|
956
|
+
"chart <view> ยท <view> sets the status bar ยท cycle ยท window ยท budget ยท cache ยท live ยท on|off",
|
|
957
957
|
].join("\n"),
|
|
958
958
|
"info",
|
|
959
959
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-tokenburn",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Pi extension for live token usage monitoring and budget tracking (Day / Week / Month / Total). 0 prompt tokens.",
|
|
5
5
|
"keywords": ["pi-package", "pi-extension", "tokenburn", "tokens", "analytics", "budget", "stats"],
|
|
6
6
|
"license": "MIT",
|