pi-stats-footer
v0.4.0
Published
Compact two-line status footer for pi: model, tokens, cache hit rate, context usage, cost, run timer, agent loop count and current task.
Maintainers
Readme
pi-stats-footer
A compact, responsive two-line status footer for pi. It shows model, tokens, cache hit rate, context usage, cost, run timer, agent loop count and the current task — all at a glance while pi works.
Claude Sonnet · high │ ↑20.4k ↓1.5k │ cache 90% │ ctx 16%/1M │ $0.13 │ working 0:05
-> loop 3 │ Refactor the payment module to use the new billing API…Features
Line 1 — session stats
| Segment | Example | Description |
| --- | --- | --- |
| Model + thinking level | Claude Sonnet · high | Current model name (accent color) plus the thinking level, colored per level via theme colors (thinkingOff … thinkingMax). |
| Session tokens | ↑20.4k ↓1.5k | Total input (↑) and output (↓) tokens for the whole session, summed from assistant messages, tool results, branch summaries and compactions. |
| Cache hit rate | cache 90% | Prompt-cache hit rate = cacheRead / (input + cacheRead + cacheWrite). Shows - when there is no prompt traffic yet. |
| Context usage | ctx 16%/1M | Current context window usage as percent / window size, color-coded: green < 60%, yellow ≥ 60%, red ≥ 80%. Shows ctx ?/… when unknown. |
| Session cost | $0.13 | Accumulated cost of the session ($0.003 precision below $1). |
| Working timer | working 0:05 | Live elapsed time of the current agent run (ticks every second); freezes at the final duration once the agent settles (1:02:03 style once over an hour). |
Line 2 — current progress
| Segment | Example | Description |
| --- | --- | --- |
| Loop count | -> loop 3 | Agent turns taken so far on the current branch — one per assistant message, i.e. one LLM response plus its tool calls. Updates live while the agent works. |
| Current task | Refactor the payment… | Your last user message, sanitized to a single line and truncated with … to fit the terminal width. |
Behavior
- Width-aware rendering — segments are fitted to the terminal width in
priority order (model first); lower-priority segments drop out gracefully on
narrow terminals instead of wrapping. The model segment is hard-truncated
with
…only if it alone is wider than the terminal. - Ambiguous-width safe — East Asian Ambiguous characters (
│,↑,↓,·,—,…,“ ”…) are measured as 2 columns and one extra column of margin is reserved. CJK terminals/fonts often render these double-width even thoughwcwidthcounts them as 1; measuring them narrowly made fitted lines wrap onto a third row and clobber the tmux status bar. The conservative sizing only ever leaves a little unused space at the right edge. - Live updates — re-renders on branch changes, messages, model/thinking level switches and session info changes, plus a 1s ticker while the agent runs.
- Never crashes the TUI — rendering is fully defensive; on any unexpected state the footer simply returns nothing.
- Token counts are formatted compactly:
999,9.9k,20k,1.5M.
Styling
The footer uses your pi theme; no hard-coded colors:
- Model name,
->,loop N,workingtimer —accent - Tokens, cache rate, cost, task text —
dim - Separators (
│) —borderMuted - Thinking level —
thinkingOff/thinkingMinimal/thinkingLow/thinkingMedium/thinkingHigh/thinkingXhigh/thinkingMax(falls back tothinkingHighif a theme omitsthinkingMax) - Context usage —
success(< 60%),warning(≥ 60%),error(≥ 80%),dimwhen unknown
Install
From npm (recommended):
pi install npm:pi-stats-footer
pi install npm:[email protected] # pinned versionFrom git:
pi install git:github.com/WSure00/pi-stats-footerFrom a local clone:
pi install /path/to/pi-stats-footerTry without installing:
pi -e /path/to/pi-stats-footerManage
pi config # enable/disable the extension
pi update npm:pi-stats-footer # update
pi remove npm:pi-stats-footer # uninstallnpm
https://www.npmjs.com/package/pi-stats-footer
npm view pi-stats-footerLicense
MIT
