pi-token-stats

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

pi-token-stats

Token and cost statistics extension for pi coding agent.

Features

  • Adds /tokens and /token-stats commands.
  • Scans pi session .jsonl files.
  • Aggregates input, output, cache read, cache write, total tokens, and cost.
  • Groups usage by provider/model.
  • Supports recent-day filters or all history.

Screenshot

pi-token-stats screenshot

Install

From npm

pi install npm:pi-token-stats

From git

pi install git:github.com/reaishijie/pi-token-stats

Install a pinned release/tag:

pi install git:github.com/reaishijie/pi-token-stats@v0.1.1

Local development

pi install /path/to/pi-token-stats
# or test once without installing
pi -e /path/to/pi-token-stats

Usage

/tokens
/tokens 7
/tokens 30
/tokens 0
/token-stats --days 7

Arguments:

  • no argument: last 30 days
  • 7: last 7 days
  • 30: last 30 days
  • 0: all history
  • --days N or -d N: last N days

Session directory

By default, the extension reads sessions from:

~/.pi/agent/sessions

It respects pi environment overrides:

  • PI_CODING_AGENT_SESSION_DIR
  • PI_CODING_AGENT_DIR

Package manifest

This package is discoverable as a pi package through the pi-package keyword and declares its extension entry under the pi.extensions field in package.json.

License

MIT