@ohgodtamit/pi-usage 0.1.0-alpha.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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 615f326: Introduce the @ohgodtamit/pi-usage package with cost and token attribution, live provider quotas, incremental caching, model-registry credential resolution, and complete usage and provenance documentation.
8
+ - e01c7c9: Add an eight-view keyboard TUI with RPC-compatible paginated rendering and navigation, delegation analytics, progress and freshness reporting, headless guards, and broad provider compatibility.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christopher Tam
4
+ Copyright (c) 2026 ZaganJade
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,403 @@
1
+ # @ohgodtamit/pi-usage
2
+
3
+ A Claude Code–style `/usage` panel for [pi](https://github.com/earendil-works/pi-mono).
4
+
5
+ Shows how your spend and tokens are distributed across **models, skills, plugins,
6
+ tools, projects, and delegated child sessions**, bucketed by time window — with
7
+ always-visible **5-hour** and **weekly** quota bars. The Overview includes input,
8
+ output, cache-read/cache-write, reasoning (as an output subset), component costs,
9
+ and the cache-input reuse ratio. Mirrors the layout and wording of Claude Code's
10
+ `/usage` screen.
11
+
12
+ ---
13
+
14
+ ## 🚀 Install
15
+
16
+ > ⚠️ **Use `pi install` — NOT `npm install`.**
17
+ > Plain `npm install` only drops files in `node_modules`. Pi does **not** scan
18
+ > that folder, so the package is **never detected** and `/usage` won't appear.
19
+ > You must register it with `pi install` so it lands in `"packages"` in
20
+ > `~/.pi/agent/settings.json`.
21
+
22
+ ```bash
23
+ pi install npm:@ohgodtamit/pi-usage@alpha
24
+ ```
25
+
26
+ The `alpha` tag is required until the first stable release is available on `latest`.
27
+
28
+ Then inside pi:
29
+
30
+ ```
31
+ /reload
32
+ ```
33
+
34
+ Verify it loaded:
35
+
36
+ ```bash
37
+ pi list # should show npm:@ohgodtamit/pi-usage@alpha
38
+ ```
39
+
40
+ Type `/` — `/usage` should appear in slash autocomplete.
41
+
42
+ **Don't do this** (common mistake — package installs but pi ignores it):
43
+
44
+ ```bash
45
+ npm install -g @ohgodtamit/pi-usage@alpha # ❌ pi will not detect this
46
+ ```
47
+
48
+ ---
49
+
50
+ ### Overview (`/usage`)
51
+
52
+ Eight views via `Tab` or `1`–`8`. The navigation bar is a **two-row menu**: colored icon tabs on top, plus **Pi-chan** (the panel mascot) with a contextual hint for the active view. Overview shows quota bars, headline stats, active provider, top consumer, a trend sparkline, and compact top models.
53
+
54
+ ```
55
+ ────────────────────────────────────────────────────────────────
56
+ Usage ──────────────────────────────── 5H │ DAY │ WEEK │ ALL
57
+
58
+ ╭─ views ◈1 Overview │ ◎2 Models │ … │ ✦8 Wrapped ─────────╮
59
+ (◕‿◕) Pi-chan Quota bars & headline stats… Tab · 1-8 jump
60
+
61
+ Showing: last 24 hours last activity 2m ago · 254 sessions
62
+
63
+ 5-hour quota ████░░░░░░░░░░░░ 12% used / 145.9M · 88% left · resets 4h 58m
64
+ Weekly quota ██████░░░░░░░░░░ 55% used / 176.7M · 45% left · resets 11h 49m
65
+ live from provider
66
+
67
+ ↑51.8M ↓3.7M ⚡97.7M 145.9M tokens · 855 turns
68
+
69
+ Top consumer
70
+ 73% of usage came from model glm-5.2
71
+
72
+ Trend ▁▂▃▅▆▅▄▃▂▁▂▃ Jun 10 → Jun 17
73
+
74
+ Top models % tokens
75
+ glm-5.2 73% ███████████████ 106.5M
76
+
77
+ → Tab or 1-8 to explore · ✦8 opens Wrapped AI
78
+ ```
79
+
80
+ ### Models view (`/usage-models`)
81
+
82
+ Full attribution breakdown — model table with tok/s, Skills, **Bundles** (`@debug`, …), Plugin usage (with contributing skills/tools), **Tools** (per-tool glyphs and share bars), and Projects.
83
+
84
+ ```
85
+ Models % tokens tok/s
86
+ glm-5.2 73% ███████████████ 106.5M 142/s
87
+ tok/s · est. avg output speed
88
+
89
+ Skills % tokens
90
+ systematic-debugging 18% ███░░░░░░░░░░░░ 25.4M
91
+
92
+ Bundles % tokens
93
+ @debug 22% ████░░░░░░░░░░░ 31.1M
94
+
95
+ Plugin usage % tokens via
96
+ frontend-design 12% ██░░░░░░ 720k frontend-design
97
+ (core / no plugin) 59% ██████░░ 3.6M builtin tools only
98
+
99
+ ⚙ Pi-chan tracked these tool calls
100
+ Tools % tokens
101
+ ↳ read 34% ██████░░░░░░░░░ 48.2M
102
+ $ bash 22% ████░░░░░░░░░░░ 31.1M
103
+ ✎ write 18% ███░░░░░░░░░░░░ 25.4M
104
+ glyph · tool type hint
105
+ ```
106
+
107
+ ### Wrapped AI (`/usage-wrapped`)
108
+
109
+ Year-in-review report with a **professional layout** and **Pi-chan** as a sidebar accent. Pose and footer caption react to your stats (streak, peak hour, top model). Cycle years with `[` / `]` or `y`.
110
+
111
+ ```
112
+ Wrapped 2025 ◂ [ ] ▸ · y ─────────────────────────────
113
+
114
+ ∧_∧ │ 145.9M tokens tokens
115
+ (◕‿◕)│ 855 turns · 89 active days · 4 models · 2 providers
116
+ /つ ✦│ Favorite model glm-5.2 Top provider zai
117
+ ~~ │ Longest streak 12 days Peak hour 11 PM
118
+
119
+ Highlights ────────────────────────────────────────────────
120
+ Models used 4 Providers 2
121
+ Projects 8 Top project my-app
122
+
123
+ Monthly activity ──────────────────────────────────────────
124
+ tokens by month
125
+ ▄▄▄ ▄▄▄
126
+ ███ ░░░ ███ ░░░ …
127
+ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
128
+ Less ·▪▩▣█ More
129
+ Peak month Mar 48.2M · 6 active months
130
+
131
+ Rankings ──────────────────────────────────────────────────
132
+ Models
133
+ glm-5.2 73% ███████████████ 106.5M
134
+ Providers
135
+ zai 81% ██████████████░ 118.2M
136
+
137
+ (≧◡≦) │ Pi-chan 73% of usage on glm-5.2.
138
+ ```
139
+
140
+ ## Views
141
+
142
+ The panel is organized into eight **menu views**, switchable inside `/usage` and openable directly via shortcuts:
143
+
144
+ | View | Shows |
145
+ |------|-------|
146
+ | **Overview** | Quota bars, headline stats, active-provider quota, top consumer, a 30-day trend sparkline, and the top models. |
147
+ | **Models** | Detailed model table with tok/s, plus **Skills**, **Bundles** (`@name` from pi-multi-skill), Plugin usage, **Tools** (glyph + share bar), and Projects breakdowns. |
148
+ | **Delegation** | Direct vs delegated token composition, child-session/profile and parent groupings, transcript-backed run rows, and estimated concurrency/overlap statistics. Works without a delegation framework. |
149
+ | **Daily** | Per-day rows with an activity bar plus exact cost, tokens, uptime (active span), and the day's top model; topped with all-time totals (uptime / tokens / cost). Sortable by date or usage. |
150
+ | **Stats** | GitHub-style contribution graph with month labels, an interactive time-range selector (all / 7d / 30d via `a`/`w`/`m`), and a two-column summary (total, turns, active days, favorite model, current/longest streak, busiest day, peak hour, averages) plus a fun usage comparison. |
151
+ | **Hourly** | Time-of-day breakdown (0–23h, all days combined): activity bars, tokens, turns, and top model per hour — spot your peak coding windows. |
152
+ | **Providers** | Usage by provider/backend (e.g. `zai`, `openai-codex`, `9Router`): share bars, tokens, project count, and top model per provider. Sortable by usage or name. |
153
+ | **Wrapped AI** | Year-in-review report: headline totals, Highlights grid, **Stats-style monthly heatmap**, model/provider rankings with share bars, and a Pi-chan footer insight. Sidebar mascot pose reacts to streaks and peak hours. Cycle years with `[` / `]` or `y`. |
154
+
155
+ ## UI — Pi-chan & navigation
156
+
157
+ The panel uses a lightweight TUI mascot, **Pi-chan**, to make navigation feel friendlier without sacrificing readability:
158
+
159
+ | Element | Behavior |
160
+ |---------|----------|
161
+ | **View tabs** | Each of the eight views has an icon (`◈` Overview, `◎` Models, `✦` Wrapped, …) and a distinct accent color when selected. The rail picks the richest label style that fits; on very narrow terminals it collapses to the active tab with its neighbours and a `n/8` position. |
162
+ | **Hint row** | Pi-chan's face plus a one-line description of the active view (e.g. "Year in review — [ ] or y to change year" on Wrapped). |
163
+ | **Wrapped sidebar** | On wide terminals, Pi-chan sits beside the hero stats with a vertical rule; pose changes for celebrate / night-owl / curious / empty-year moods. |
164
+ | **Tools glyphs** | Common tool names show a type hint prefix (`↳` read, `$` bash, `✎` write, `⌕` grep, …) with per-row share bars. |
165
+ | **Wrapped sections** | Hairline section headers (`Highlights`, `Monthly activity`, `Rankings`) match the Stats/Daily report rhythm. |
166
+ | **Monthly activity** | Stats-style vertical heatmap (12 month columns, graded `█` blocks, `Less → More` legend, peak-month callout). Narrow terminals fall back to horizontal share bars. |
167
+
168
+ Pi-chan copy is informational, not decorative — footer captions summarize your standout stat in plain language.
169
+
170
+ ## Commands
171
+
172
+ | Command | Description |
173
+ |---------|-------------|
174
+ | `/usage` | Open the interactive usage panel (Overview view). |
175
+ | `/usage-models` | Open the panel directly on the **Models** view. |
176
+ | `/usage-delegation` | Open the panel directly on the **Delegation** view. |
177
+ | `/usage-daily` | Open the panel directly on the **Daily** summary view. |
178
+ | `/usage-stats` | Open the panel directly on the **Stats** (contribution graph) view. |
179
+ | `/usage-hourly` | Open the panel directly on the **Hourly** (time-of-day) view. |
180
+ | `/usage-providers` | Open the panel directly on the **Providers** view. |
181
+ | `/usage-agents` | Compatibility alias for `/usage-providers`. |
182
+ | `/usage-wrapped` | Open the panel directly on the **Wrapped AI** year-in-review view. |
183
+ | `/usage-config` | Set your 5-hour and weekly USD budgets. |
184
+ | `/usage-pricing` | Set a manual per-model price ($/M tokens) so cost shows for token-priced / proxied models pi records as $0. |
185
+ | `/usage-widget` | Toggle a compact always-on spend widget above the editor. |
186
+
187
+ ### Keys inside `/usage`
188
+
189
+ | Key | Action |
190
+ |-----|--------|
191
+ | `Tab` / `Shift+Tab`, `←` / `→` | Switch view (Overview ↔ … ↔ Wrapped AI) |
192
+ | `1`–`8` | Jump to Overview / Models / Delegation / Daily / Stats / Hourly / Providers / Wrapped |
193
+ | `5` / `d` / `w` / `a` | Switch window (5 hours / day / week / all). On Overview & Models all four work; on Delegation use `d`/`w`/`a` (`5` opens **Stats**, as on every other view). |
194
+ | `a` / `w` / `m` | Stats range: all time / last 7 days / last 30 days (Stats view) |
195
+ | `c` / `t` / `n` | Models or Providers view: sort by usage (`c`/`t`) or name (`n`) |
196
+ | `t` / `c` / `d` | Daily view: sort by tokens / cost / date — press the same key again to flip ascending ↔ descending |
197
+ | `[` / `]` / `y` | Wrapped AI: previous / next calendar year |
198
+ | `j` `k` / `↑` `↓` | Scroll • `space`/`ctrl+d` half-page down, `ctrl+u`/`b` up |
199
+ | `g` / `G` | Jump to top / bottom |
200
+ | `r` | Force re-scan of sessions |
201
+ | `s` | Set budgets (same as `/usage-config`) |
202
+ | `q` / `esc` | Close |
203
+
204
+ ## Configuration
205
+
206
+ `~/.pi/agent/usage.json` (auto-created on first change):
207
+
208
+ ```json
209
+ {
210
+ "fiveHourLimit": 20,
211
+ "weeklyLimit": 100,
212
+ "fiveHourTokenLimit": 2000000,
213
+ "weeklyTokenLimit": 10000000,
214
+ "showWidget": false,
215
+ "excludeProjects": ["/tmp/throwaway"],
216
+ "maxSessions": 1000,
217
+ "modelPrices": {
218
+ "claude-opus-4.7": { "input": 15, "output": 75, "cacheRead": 1.5, "cacheWrite": 18.75 },
219
+ "glm-5-turbo": { "input": 0.6, "output": 2.2 }
220
+ }
221
+ }
222
+ ```
223
+
224
+ - `fiveHourLimit` / `weeklyLimit` — USD budgets for **priced** providers (e.g.
225
+ Anthropic, OpenAI metered). `0`/omitted shows raw spend with no bar.
226
+ - `fiveHourTokenLimit` / `weeklyTokenLimit` — token budgets for **token-priced**
227
+ providers (e.g. zai/GLM, where per-token cost is unknown). `0`/omitted shows
228
+ raw token usage with no bar.
229
+ - `showWidget` — keep a one-line spend summary above the editor.
230
+ - `excludeProjects` — cwd prefixes to skip during aggregation.
231
+ - `maxSessions` — safety cap on top-level sessions; selected roots' nested child transcripts do not consume the cap.
232
+ - `modelPrices` — prices in **USD per 1M tokens** used to compute cost for
233
+ token-priced / proxied models that pi records with `$0` (e.g. zai/GLM, 9Router
234
+ `kr/…`, `cx/…`). The extension **ships with default prices** for common models
235
+ (`src/prices.ts`, taken from official provider pricing pages); your
236
+ `modelPrices` entries **override** those per key. A cost recorded by pi always
237
+ wins; the price table only fills gaps. Keys match the model ID exactly, or by
238
+ **base name** (after the last `/`) so `claude-opus-4.7` covers
239
+ `kr/claude-opus-4.7` and `cx/claude-opus-4.7`. Set entries interactively with
240
+ `/usage-pricing`. Prices are estimates — verify against your provider.
241
+
242
+ ### Adaptive units
243
+
244
+ The quota bars, headline stats, and breakdown sections automatically switch
245
+ **unit** based on the active provider:
246
+
247
+ - **USD** when the selected window has meaningful $ cost (priced providers).
248
+ - **Tokens** when the window's cost is 0 (token-priced providers like zai/GLM,
249
+ where the model has no pricing in pi's registry). For these, tokens are the
250
+ real usage signal — the panel shows e.g. `1.3M / 2M (63%)` against your
251
+ `fiveHourTokenLimit`, and the live per-minute rate-limit headers below give
252
+ the real-time "remaining this window" from the provider.
253
+
254
+ ## Performance
255
+
256
+ The first scan parses every session file once (can take a few seconds for large
257
+ histories). Results are then cached **per session file** to
258
+ `~/.pi/agent/usage-cache.json`, keyed by each file's mtime + size. Subsequent
259
+ opens — even after restarting pi — only re-parse sessions that actually changed,
260
+ so the panel comes up in well under a second instead of re-reading everything.
261
+ The cache is rebuilt automatically if you change `modelPrices` (costs are baked
262
+ in at parse time) or when the cache schema version bumps (currently **v6**, which adds raw child summaries and per-file delegation records for post-assembly enrichment). Legacy turns normalize as direct usage.
263
+ Delete `~/.pi/agent/usage-cache.json` to force a full re-scan.
264
+
265
+ ## How it works
266
+
267
+ Pi records per-turn usage (tokens + cost) on every assistant message across session files in `~/.pi/agent/sessions/`. Selected top-level sessions are capped by `maxSessions`; nested `tasks/` and `subagents/` child transcripts are discovered recursively and counted authoritatively without adding parent tool-result summaries. Optional `subagents:record` custom entries enrich labels and precise timing, but no roster package is required. This extension opens each file once,
268
+ walks the entries, and attributes every assistant turn to:
269
+
270
+ - **model** — from `message.model`
271
+ - **project** — from the session's working directory
272
+ - **skill** — detected via `parseSkillBlocks()` on the preceding user message (multi-skill aware — every `<skill name="…">` in a `/skills` activation is counted separately)
273
+ - **bundle** — detected via `bundles="…"` on `<manually_attached_skills>` (e.g. `@bmad-planning`, `@debug`)
274
+ - **plugins / tools** — from the tool calls in the assistant message, mapped to
275
+ their owning package via `pi.getAllTools()` / `pi.getCommands()`
276
+
277
+ When using **pi-multi-skill**, a single `/skills @debug,frontend-design` turn attributes usage to both `systematic-debugging` and `frontend-design` in the Skills section, and `@debug` in the **Bundles** section when a preset bundle was used.
278
+
279
+ Like Claude Code, these are **independent characteristics** of your usage, not a
280
+ disjoint partition — a single turn can contribute to several buckets, so
281
+ percentages need not sum to 100% across categories.
282
+
283
+ ### Active provider quota
284
+
285
+ Beyond your own session history, the panel also surfaces the **active
286
+ provider's** view of your quota. It detects the active provider from `ctx.model`
287
+ and shows:
288
+
289
+ - **OpenAI Codex (subscription, e.g. ChatGPT Plus/Pro via Codex CLI)** — the
290
+ 5-hour and weekly windows come from `/backend-api/wham/usage` using the
291
+ request-time OAuth token resolved and refreshed by Pi. The ChatGPT account ID
292
+ is read from that fresh token. Captured `x-codex-*` response headers remain a
293
+ fallback when available. Also shows the plan name and purchased credits
294
+ balance when reported.
295
+ - **ZAI (GLM coding plans)** — the authoritative **5-hour** and **weekly**
296
+ quota is fetched live from ZAI's subscription API
297
+ (`https://api.z.ai/api/monitor/usage/quota/limit`, undocumented but used by
298
+ the ZAI management UI). It reports the upstream used/remaining percentage
299
+ with a live reset countdown — **no budget config needed**, these ARE the
300
+ plan's 5h/weekly limits straight from the source. Also shows web-search
301
+ quota when present. (Two endpoints are tried: `api.z.ai` intl +
302
+ `open.bigmodel.cn` CN.)
303
+ - **OpenRouter** — account credits remaining (`/api/v1/credits`).
304
+ - **OpenAI** — 5h/7d spend via `/v1/organization/costs` (+ monthly hard limit
305
+ when readable).
306
+ - **Other / fallback** — when a provider has no upstream quota API, the bars
307
+ fall back to session-derived usage (USD or tokens) against an optional
308
+ user budget via `/usage-config`.
309
+ - **Rate-limit windows** — captured universally from every provider HTTP
310
+ response (Anthropic, OpenAI, OpenRouter, Google, …) via the
311
+ `after_provider_response` event, with live reset countdowns.
312
+
313
+ Credentials are resolved through `ctx.modelRegistry`, the same public API Pi
314
+ uses for provider authentication and OAuth refresh. Providers without a live
315
+ quota integration can still surface captured rate-limit headers.
316
+
317
+ > **Why budgets are user-defined:** pi works with any provider, so it has no
318
+ > built-in quota (unlike Claude Code's subscription). Set limits that match your
319
+ > plan and the panel tracks progress against them.
320
+
321
+ ## Files
322
+
323
+ | File | Purpose |
324
+ |------|---------|
325
+ | `index.ts` | Entry point — registers commands (incl. `/usage-models`, `/usage-daily`, `/usage-stats`), orchestrates scan + widget |
326
+ | `view.ts` | The interactive TUI panel (`UsageView`) — Pi-chan menu, Overview / Models / … / Wrapped AI views |
327
+ | `mascot.ts` | Pi-chan ASCII art, view tab icons, tool glyphs, Wrapped captions |
328
+ | `aggregate.ts` | Session scanning + windowing + attribution; multi-skill `skills[]`; legacy turn normalization |
329
+ | `provider.ts` | Active-provider detection + rate-limit parsing + live quota fetch |
330
+ | `config.ts` | Load/save `~/.pi/agent/usage.json` (merges bundled default prices) |
331
+ | `cache.ts` | Persistent incremental scan cache (`~/.pi/agent/usage-cache.json`) |
332
+ | `prices.ts` | Bundled default model prices ($/M tokens) from official provider pricing pages |
333
+ | `format.ts` | Token/currency/bar/label formatting helpers |
334
+ | `freshness.ts` | Report-cache freshness decision (TTL + new-turn invalidation), unit-tested in isolation |
335
+ | `zai.ts` | Pure ZAI quota-limit classification, dependency-free for unit testing |
336
+
337
+ ## Install
338
+
339
+ Use **`pi install`**, not plain `npm install`. Pi registers packages in `settings.json` under `"packages"` and loads extensions from the `pi.extensions` manifest in `package.json`.
340
+
341
+ ```bash
342
+ pi install npm:@ohgodtamit/pi-usage@alpha
343
+ ```
344
+
345
+ The `alpha` tag is required until the first stable release is available on `latest`.
346
+
347
+ Then run `/reload` in pi (or restart the CLI). Commands like `/usage` should appear in slash autocomplete.
348
+
349
+ Quick test without persisting to settings:
350
+
351
+ ```bash
352
+ pi -e npm:@ohgodtamit/pi-usage@alpha
353
+ ```
354
+
355
+ From this repository checkout:
356
+
357
+ ```bash
358
+ pi install ./packages/pi-usage
359
+ ```
360
+
361
+ From a local path:
362
+
363
+ ```bash
364
+ pi install ./packages/pi-usage
365
+ ```
366
+
367
+ ### Troubleshooting
368
+
369
+ | Symptom | Fix |
370
+ |---------|-----|
371
+ | `/usage` not in autocomplete | Run `pi install npm:@ohgodtamit/pi-usage@alpha`, then `/reload` |
372
+ | Installed with `npm install -g` but pi ignores it | Use `pi install npm:@ohgodtamit/pi-usage@alpha` instead |
373
+ | Added `npm:...` to `"extensions"` in settings | Wrong key — use `"packages"`, or run `pi install` |
374
+ | Extension listed but disabled | Run `pi config` and enable the extension resource |
375
+
376
+ Verify install:
377
+
378
+ ```bash
379
+ pi list
380
+ # should show: npm:@ohgodtamit/pi-usage@alpha
381
+ ```
382
+
383
+ > **Note:** `npm install` only downloads the package to disk. Pi does not auto-scan global or local `node_modules` — you must register the package with `pi install` so it appears in `"packages"`.
384
+
385
+ No build step; pi loads TypeScript directly via jiti.
386
+
387
+ ## Changelog
388
+
389
+ Upstream donor release history (this fork starts at 0.1.0 and pins `@zaganjade/pi-usage` 1.9.2):
390
+
391
+ ### v1.9.0
392
+
393
+ - **Pi-chan navigation** — two-row menu with icon tabs and per-view hints
394
+ - **Wrapped AI** — report layout (Highlights / Monthly activity / Rankings), sidebar mascot, footer caption
395
+ - **Monthly activity** — vertical heatmap aligned with Stats view (`Less → More` legend, peak-month callout)
396
+ - **Tools section** — per-tool glyphs and colored share bars
397
+ - **Bundle attribution** — `Bundles` breakdown for `@bundle` activations from pi-multi-skill
398
+ - **Multi-skill skills[]** — every skill in a chain attributed separately
399
+ - **Cache v4** — `skills[]`, `bundles[]`, `tools[]` on each turn; legacy entries normalized on load
400
+
401
+ ### v1.8.0
402
+
403
+ - Seven views including Wrapped AI, Agents, Hourly; live ZAI/Codex quota; incremental scan cache
@@ -0,0 +1,54 @@
1
+ # Third-Party Notices
2
+
3
+ ## `@zaganjade/pi-usage@1.9.2`
4
+
5
+ `@ohgodtamit/pi-usage` is a fork of `@zaganjade/pi-usage` 1.9.2 by ZaganJade, licensed under the MIT License.
6
+
7
+ - Pinned commit: `2de5ac6bd6a802338d78e9daba1f29a4a74e29d3`
8
+ - Pinned source: https://github.com/ZaganJade/pi-extension/tree/2de5ac6bd6a802338d78e9daba1f29a4a74e29d3/usage
9
+ - Author: ZaganJade
10
+ - License: MIT
11
+
12
+ ## Path-level derivation inventory
13
+
14
+ Paths are relative to the package root. Every listed donor path is pinned to the commit above and is authored by ZaganJade under the MIT License.
15
+
16
+ | Destination path | Donor path | Derivation |
17
+ | --- | --- | --- |
18
+ | `src/{config.ts,format.ts,freshness.ts,prices.ts,zai.ts}` | `usage/src/{config.ts,format.ts,freshness.ts,prices.ts,zai.ts}` | Copied; formatting-only changes may be applied by this repository. |
19
+ | `src/aggregate.ts` | `usage/src/aggregate.ts` | Adapted on top of the donor scanner: recursive delegated child discovery, optional `subagents:record` enrichment, direct/delegated partitions, token-composition totals, and concurrency statistics. Core attribution (model/project/skill/bundle/plugin/tool) is retained donor code. |
20
+ | `src/cache.ts` | `usage/src/cache.ts` | Adapted for cache v6: raw per-session child summaries, per-file delegation records, exclusion fingerprints, and the reworked entry shape. Donor structure and load/save behavior retained. |
21
+ | `src/view.ts` | `usage/src/view.ts` | Adapted to add the Delegation view and a final line-width clamp, rename the Agents view to Providers, and render token composition and concurrency stats. Donor view layout, quota bars, and other views are retained. |
22
+ | `src/mascot.ts` | `usage/src/mascot.ts` | Adapted to add the Delegation view tab and rename the Agents tab to Providers. Donor poses, glyphs, and captions are retained. |
23
+ | `src/index.ts` | `usage/src/index.ts` | Adapted to pass the extension context's model registry into provider credential resolution and to register the new `/usage-delegation` and `/usage-providers` commands (with `/usage-agents` kept as an alias). Commands, widget behavior, and UI behavior are otherwise retained. |
24
+ | `src/provider.ts` | `usage/src/provider.ts` | Adapted to replace unavailable `AuthStorage` methods with public model-registry credential APIs and derive the Codex account ID from the refreshed access token. |
25
+ | `test/{freshness.test.ts,provider.test.ts}` | `usage/src/{freshness.test.ts,provider.test.ts}` | Copied upstream behavioral tests (kept out of the published tarball); test-runner imports adapted to the repository's Vitest workspace. |
26
+ | `test/provider-credentials.test.ts` | `usage/src/provider.ts` | Local regression tests for the adapted credential and Codex quota behavior. |
27
+
28
+ `test/aggregate.test.ts` and `test/discovery.test.ts` are new local work and are not adapted from donor code.
29
+
30
+ Pinned source URLs for each row are formed by appending the donor path to https://github.com/ZaganJade/pi-extension/blob/2de5ac6bd6a802338d78e9daba1f29a4a74e29d3/ (use `/tree/` for grouped paths).
31
+
32
+ ## Retained donor license text
33
+
34
+ MIT License
35
+
36
+ Copyright (c) 2026 ZaganJade
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining a copy
39
+ of this software and associated documentation files (the "Software"), to deal
40
+ in the Software without restriction, including without limitation the rights
41
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
42
+ copies of the Software, and to permit persons to whom the Software is
43
+ furnished to do so, subject to the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be included in all
46
+ copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
49
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
50
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
51
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
52
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
53
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54
+ SOFTWARE.