pi-mono-usage

Pi extension that aggregates local session usage, cost and sustainability impact

Packages

Package details

extension

Install pi-mono-usage from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-mono-usage
Package
pi-mono-usage
Version
0.1.1
Published
May 10, 2026
Downloads
68/mo · 7/wk
Author
emanuelcasco
License
unknown
Types
extension
Size
49.9 KB
Dependencies
1 dependency · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

usage extension

Adds a /usage slash command that reads your local pi session files, aggregates token spend, and renders an inline dashboard with three views.

Install

pi install npm:pi-mono-usage

Views

  • Summary — totals, top providers, and an environmental footprint estimate (kWh, kg CO₂e, real-world equivalences) computed from impact-equivalences.
  • Providers — per-provider table that expands into per-model rows. Includes session/call counts, cost, and token breakdown (input, output, cache).
  • Patterns — cost-driver insights for the selected period: parallel sessions, oversized contexts, large uncached prompts, marathon sessions, and top-session concentration.

Period selector

Tab between Today, This Week, Last Week, and All Time. Each period is computed once on open from the same parsed dataset, so cycling is instant.

Keybindings

Key Action
Tab / / Cycle period
v Cycle view
1 / 2 / 3 Jump to Summary / Providers / Patterns
/ Move provider cursor (Providers view)
Enter / Space Expand / collapse a provider
q / Esc Close the panel

Data source

Reads ~/.pi/agent/sessions/**/*.jsonl (or $PI_CODING_AGENT_DIR/sessions). For each assistant message with a usage block, the extension records cost and token counts. Duplicate turns from branched session files are deduplicated by a fingerprint over timestamp + token counts.

Sustainability estimate

The Summary view feeds the period's charged tokens (input + output + cacheWrite) into impact-equivalences estimateAiImpact, which returns electricity (kWh) and carbon (kg CO₂e) ranges along with formatted real-world equivalences (e.g. "~X average US households for a day"). Estimates are illustrative — see the package's source attribution for boundaries and assumptions.