-
Notifications
You must be signed in to change notification settings - Fork 398
Description
Summary
pi is a terminal coding agent (by Mario Zechner) that supports both Anthropic and OpenAI (Codex) models. It stores session logs with full token usage and cost data, but CodexBar does not currently scan its log path.
Log path
~/.pi/agent/sessions/<project>/<timestamp>_<session-id>.jsonl
JSONL schema
Session header:
{"type":"session","id":"...","timestamp":"2026-02-16T13:24:12Z","cwd":"/Users/pd"}
{"type":"model_change","provider":"anthropic","modelId":"claude-opus-4-6"}Messages with usage (every assistant response):
{
"type": "message",
"timestamp": "2026-02-16T13:24:27Z",
"message": {
"role": "assistant",
"content": [...],
"usage": {
"input": 3740,
"output": 152,
"cacheRead": 0,
"cacheWrite": 5317,
"totalTokens": 3892,
"cost": {
"input": 0.0187,
"output": 0.0038,
"cacheRead": 0,
"cacheWrite": 0.033,
"total": 0.0225
}
}
}
}Provider routing
The model_change event includes a provider field:
"anthropic"→ could be attributed to Claude usage"openai-codex"→ could be attributed to Codex usage
This means pi usage could be routed to the correct existing CodexBar provider (Claude or Codex) without needing a separate pi provider — or it could be its own provider, whichever makes more sense.
Workaround
Currently using a converter script that reshapes pi JSONL into Claude Code / Codex CLI formats and drops them into ~/.claude/projects/ and ~/.codex/sessions/ so CostUsageScanner picks them up. Works, but inflates Claude/Codex totals with no way to distinguish pi usage.
Context
pi is installed via npm (@mariozechner/pi-coding-agent), uses the same underlying APIs as Claude Code and Codex CLI, and already computes cost per-message. The JSONL format is clean and consistent — should be straightforward to add a scanner for it.