feat(ccusage): support comma-separated agent paths#1011
Conversation
Add shared path-list parsing so Codex, OpenCode, Amp, and pi-agent can read usage data from comma-separated directory lists. This aligns the newer agent adapters with Claude path handling while preserving the existing single-directory defaults. Codex now aggregates all CODEX_HOME session roots and checks each home for fast pricing config. OpenCode and Amp discover files across all valid data roots, and pi-agent accepts comma-separated --pi-path and PI_AGENT_DIR values. Regenerate the config schema so piPath autocomplete documents comma-separated session directories.
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdapters (AMP, Codex, OpenCode, PI-Agent) now accept comma-separated data-directory inputs, discover multiple existing directories, and aggregate usage/events across them. A new path-list utility normalizes and filters path lists; CLI, schema, README, and guides updated to document comma-separated inputs. ChangesMulti-directory path support across adapters
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Actions performedReview triggered.
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | 7a3d29f | Commit Preview URL Branch Preview URL |
May 17 2026, 01:34 AM |
@ccusage/amp
ccusage
@ccusage/codex
@ccusage/opencode
@ccusage/pi
commit: |
ccusage performance comparisonThis compares the PR build against the base branch build on the same CI runner. Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Package size
Lower medians and smaller packed package sizes are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/ccusage/src/adapter/opencode/loader.ts`:
- Around line 190-196: The loop over openCodePaths currently pushes all
dbMessages.entries regardless of prior seenIds, causing duplicates; update the
logic in the for (const openCodePath of openCodePaths) loop that calls
loadOpenCodeMessagesFromDb to filter dbMessages.entries by whether their id is
already in the seenIds Set before appending to entries, and for each appended
entry add its id to seenIds (or otherwise merge dbMessages.seenIds only for
newly appended ids) so duplicates across roots are not double-counted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bc27b3ab-fefc-4241-96a5-1863f7acd26d
📒 Files selected for processing (13)
apps/ccusage/config-schema.jsonapps/ccusage/src/adapter/amp/parser.tsapps/ccusage/src/adapter/amp/paths.tsapps/ccusage/src/adapter/codex/parser.tsapps/ccusage/src/adapter/codex/paths.tsapps/ccusage/src/adapter/codex/pricing.tsapps/ccusage/src/adapter/opencode/index.tsapps/ccusage/src/adapter/opencode/loader.tsapps/ccusage/src/adapter/opencode/paths.tsapps/ccusage/src/adapter/path-list.tsapps/ccusage/src/adapter/pi/parser.tsapps/ccusage/src/adapter/pi/paths.tsapps/ccusage/src/commands/agent.ts
Filter OpenCode DB records by message id before appending them to the aggregated result. This prevents repeated database rows from multiple OPENCODE_DATA_DIR roots from being counted twice. Add a SQLite-backed regression test that creates two OpenCode roots with the same message id and confirms only one usage entry is returned.
Document comma-separated data directory support for Codex, OpenCode, Amp, and pi-agent after the source-focused documentation restructure from main. The docs now show environment variable examples for multiple roots, note Codex speed auto detection across CODEX_HOME roots, and describe piPath support in the JSON config schema.
Remove a duplicated comma-separated pi-agent path example from the package README after adding the docs coverage.
Summary
Verification
Summary by cubic
Adds comma-separated directory support for Codex, OpenCode, Amp, and pi-agent, aggregating usage across all valid paths while keeping single-directory defaults. Docs and help are updated; Codex fast-tier auto-detection checks all
CODEX_HOMEroots; OpenCode DB messages are deduplicated across roots.New Features
CODEX_HOME,OPENCODE_DATA_DIR,AMP_DATA_DIR,PI_AGENT_DIR, and--pi-path.config.tomlfrom everyCODEX_HOMEwhen--speed auto.Bug Fixes
OPENCODE_DATA_DIRroots.Written for commit 7a3d29f. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
New Features
Documentation
Tests