pi-exit-summary0.1.0
Pi extension that prints a provider-neutral token usage summary when Pi exits
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-exit-summary
A Pi extension that prints a Codex-style token usage summary when you exit Pi:
Token usage: total=23,253 input=22,544 (+104,960 cached) output=709 (reasoning 57) cost=$0.42
To resume this session: pi --session 3fb0c1e2-...
(The second line is printed by Pi itself; this extension adds the first.)
Install
pi install npm:pi-exit-summary
Try it once without installing:
pi -e npm:pi-exit-summary
How it works
- Hooks the
session_shutdownevent and prints one line after the terminal has been restored, right before Pi's own "To resume this session" hint. - Usage totals are computed from session entries: assistant messages, tool-result nested usage, standalone usage entries (e.g. cache warming), compaction summaries, and branch summaries — the same sources Pi uses for its session totals.
- Provider-neutral by design: Pi normalizes usage for every provider (Anthropic, OpenAI, Google, custom providers) into one
Usageshape before it reaches session entries, so this works with any API. Providers that do not report cache or reasoning tokens simply omit those segments.
Behavior notes
- Interactive TUI mode only; print/JSON/RPC output stays clean.
- Silent when the session recorded no model usage.
reasoningis displayed as a subset ofoutput, matching provider semantics (never double-counted).costuses the per-model rates Pi already computes; zero-cost setups (e.g. subscriptions) omit the segment.
License
MIT