feat: add Pi provider for tracking Pi agent sessions#45
feat: add Pi provider for tracking Pi agent sessions#45acennan wants to merge 1 commit intogetagentseal:mainfrom
Conversation
- Adds support for Pi (pi.ai) as a new session provider. - Pi sessions are stored as JSONL files under `~/.pi/agent/sessions/<project-dir>/` and use OpenAI-compatible model IDs (gpt-5, gpt-5.4, gpt-4o, etc.). - `src/providers/pi.ts` (new): Pi provider - discovers JSONL session files, parses assistant turns, extracts token counts, tool calls, and bash commands, deduplicates via response ID with line-index fallback - `src/providers/types.ts`: added bashCommands field to `ParsedProviderCall` so all providers carry extracted bash command lists - `src/providers/index.ts`: registered Pi as a core provider alongside Claude and Codex - `src/providers/codex.ts`, `cursor.ts`: added `bashCommands: []` to satisfy the new required field on `ParsedProviderCall` - `src/parser.ts`: fixed bug where `providerCallToTurn` always emitted an empty bashCommands array instead of passing through the parsed commands - `src/classifier.ts`: added lowercase tool name variants (bash, edit, read, write) to match Pi's tool naming convention in JSONL output - `src/bash-utils.ts`: exclude `true`, `false`, and shell variable assignments from extracted commands; scan past leading `NAME=val` tokens so `FOO=bar ls` correctly records `ls` rather than being dropped - `package.json`: added pi to keywords - `tests/providers/pi.test.ts` (new): 16 unit tests covering session discovery, multi-turn parsing, tool/bash extraction, deduplication, zero-token filtering, and display name mapping - `tests/provider-registry.test.ts`: updated core provider list to include pi - [X] Unit tests pass (`npx vitest run`, 56 tests across 6 files); - [X] Manually verified via `npx tsx src/cli.ts` report and showing Pi sessions alongside Claude and Codex in the dashboard.
|
Hey @acennan, this is really solid work. Clean code, good test coverage, and you clearly studied the existing providers. Closest to merge-ready of any PR we've reviewed today. A few things to address: Rebase onto current main We merged an OpenCode provider and the Also drop the Normalize tool names in the provider Right now Pi yields lowercase tool names ( const toolNameMap: Record<string, string> = {
bash: 'Bash',
read: 'Read',
edit: 'Edit',
write: 'Write',
glob: 'Glob',
grep: 'Grep',
}Map tool names through it in the parser and in Drop the classifier.ts changes The lowercase additions to bash-utils.ts improvements are welcome The Registry test The provider-registry test now expects That's it. The parsing logic, test fixtures, dedup strategy, and session discovery are all good. Looking forward to the updated PR. |
|
One more thing -- once you've applied the changes, please run |
…, upstream test cases - Add thiserror 2.0 + anyhow 1.0 + rayon 1.12 to Cargo.toml - Add Period enum (Week/Today/Days30/Month/All) with clap::ValueEnum to types.rs - Add ProviderKind enum (Claude/Codex/Cursor/Opencode/Gemini/Copilot/Pi) with clap::ValueEnum to types.rs - Add codeburn::Error type with thiserror in lib.rs - Rewrite main.rs to use Period and ProviderKind enums throughout - Add Send+Sync bounds to Provider trait and all provider boxes - Use rayon::par_iter to parallelize non-Claude provider parsing in discover_and_parse - Add lowercase 'bash' to BASH_TOOL_NAMES (matches Pi provider tool names) - Add lowercase 'edit','write','read','grep','glob' to classifier tool lists - Add 17 new provider_test.rs tests ported from upstream PRs getagentseal#41/getagentseal#44/getagentseal#45: Pi: multi-project discovery, zero-token skip, multi-turn, bash extraction, dedup Copilot: model-change tracking, zero-token skip, dedup, tool display names, missing file Gemini: multi-message session, plain-string user message Types: Period enum values, ProviderKind::as_str, ProviderKind CLI parsing - Fix tempdir() in provider_test.rs to use atomic counter (unique per test) - 102 tests total (36 unit + 17 integration + 49 provider), all passing - cargo clippy -- -D warnings: clean Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/c9f2c300-e57c-487e-a117-10a592eee4c1 Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
|
Hey @acennan, merged your Pi provider to main. Your original commit (7ac512a) is preserved with your authorship intact. We added a few follow-ups on top:
Verified the cost math against your real Pi session data on our system: input + cacheRead + cacheWrite + output exactly equals totalTokens, confirming Anthropic-style accounting. No double-counting. Three review agents (code quality, regression, end-to-end) ran on separate sessions before merge. All clean. 93 tests pass. Will ship in the next npm release. Thanks for the contribution. |
Summary
~/.pi/agent/sessions/<project-dir>/and use OpenAI-compatible model IDs (gpt-5, gpt-5.4, gpt-4o, etc.).Changes
src/providers/pi.ts(new): Pi provider - discovers JSONL session files, parses assistant turns, extracts token counts, tool calls, and bash commands, deduplicates via response ID with line-index fallbacksrc/providers/types.ts: added bashCommands field toParsedProviderCallso all providers carry extracted bash command listssrc/providers/index.ts: registered Pi as a core provider alongside Claude and Codexsrc/providers/codex.ts,cursor.ts: addedbashCommands: []to satisfy the new required field onParsedProviderCallsrc/parser.ts: fixed bug whereproviderCallToTurnalways emitted an empty bashCommands array instead of passing through the parsed commandssrc/classifier.ts: added lowercase tool name variants (bash, edit, read, write) to match Pi's tool naming convention in JSONL outputsrc/bash-utils.ts: excludetrue,false, and shell variable assignments from extracted commands; scan past leadingNAME=valtokens soFOO=bar lscorrectly recordslsrather than being droppedpackage.json: added pi to keywordstests/providers/pi.test.ts(new): 16 unit tests covering session discovery, multi-turn parsing, tool/bash extraction, deduplication, zero-token filtering, and display name mappingtests/provider-registry.test.ts: updated core provider list to include piTesting
npx vitest run, 56 tests across 6 files);npx tsx src/cli.tsreport and showing Pi sessions alongside Claude and Codex in the dashboard.