Skip to content

feat(ccusage): add all-agent coding usage reports#1000

Merged
ryoppippi merged 20 commits into
mainfrom
feat/consolidate-agent-usage
May 16, 2026
Merged

feat(ccusage): add all-agent coding usage reports#1000
ryoppippi merged 20 commits into
mainfrom
feat/consolidate-agent-usage

Conversation

@ryoppippi
Copy link
Copy Markdown
Owner

@ryoppippi ryoppippi commented May 15, 2026

Summary

  • Add all-agent usage reports to ccusage as the default ccusage / ccusage daily experience.
  • Add agent-first namespaces such as ccusage codex daily, ccusage opencode weekly, ccusage amp session, and ccusage pi daily.
  • Keep --agent out of the CLI contract and reject report flag aliases like --daily.
  • Convert legacy companion packages into thin wrappers that depend on ccusage and print deprecation guidance.
  • Port agent loaders onto shared ccusage primitives for traversal, JSONL parsing, SQLite reads, pricing, stdout writes, worker chunking, and responsive table rendering.
  • Add all-agent grouped rows with parent All rows and per-agent child rows, plus responsive full/compact table fallback.
  • Tighten table width selection so narrow panes compact before columns overflow, while wide panes keep detailed columns.
  • Add file snapshots for CLI integration output, including all-agent JSON/table output and direct agent namespace JSON/table output.
  • Add a small internal ANSI color helper for logger labels, matching consola-style info cyan and warn yellow without adding picocolors to the logger path.
  • Add a repo-local cmux-debug skill and keep the cmux workflow in plan.md using portable placeholders.

Notes

  • OpenCode loads both SQLite and JSON data and contributes to all-agent totals.
  • --offline is forwarded through agent namespaces and avoids LiteLLM fetches in smoke tests.
  • Pricing fetches are deduped through the shared pricing fetcher when online pricing is needed.
  • The public naming is all / all-agent; --agent was not added.
  • Amp report boxes render before online pricing logs, Amp totals include cache tokens, and compact/pricing notices render without extra blank lines.

Bundle size

  • pnpm run build reports apps/ccusage bundled JS at 131.12 KB main + 77.17 KB data-loader, with sourcemap-heavy local dist at 1.55 MB total.
  • Earlier successful local npm pack --json --dry-run for apps/ccusage: 63,225 bytes packed / 281,505 bytes unpacked / 12 entries.
  • This remains well below the 1 MB packed budget.

Local smoke timings

Built CLI, local real data, offline JSON output:

  • ./dist/cli.js --offline --json --since 20260514 --until 20260515: 21.06s real
  • ./dist/cli.js codex --offline --json --since 20260514 --until 20260515: 25.02s real
  • ./dist/cli.js opencode --offline --json: 0.21s real
  • ./dist/cli.js amp --offline --json: 0.10s real
  • ./dist/cli.js pi --offline --json: 0.11s real

The Codex/all timings are dominated by the large local Codex history on this machine.

Verification

Latest local verification on this branch:

  • pnpm vitest run packages/internal/src/logger.ts apps/ccusage/test/cli-output.test.ts: pass
  • pnpm vitest run packages/terminal/src/table.ts: pass
  • pnpm vitest run apps/ccusage/test/cli-output.test.ts -u: pass
  • pnpm run format: pass
  • pnpm typecheck: pass
  • pnpm run test: 430 passed, 1 skipped (431 total)
  • pnpm run build: pass
  • cmux visual capture on the target surface with ./dist/cli.js amp at 145 columns

Latest PR checks on GitHub:

  • lint-check: pass
  • test: pass
  • schema-check: pass
  • spell-check: pass
  • compare: pass
  • npm publish dry run / pkg.pr.new: pass
  • preview E2E on ubuntu, macOS, and Windows: pass
  • CodeRabbit: pass
  • Cubic: pass
  • Cloudflare Workers build: still running

Review notes

Actionable CodeRabbit and Cubic comments have been reviewed against the current code. Valid issues were fixed in follow-up commits; intentionally skipped items were stale or not applicable to this implementation plan.

Summary by CodeRabbit

  • New Features

    • Unified multi‑agent reporting (per‑agent attribution) and new "all" aggregation/reporting commands.
    • Deprecated agent wrappers now forward to the unified ccusage CLI with a deprecation notice.
  • Improvements

    • Added --offline / -O to use cached pricing.
    • Tables include an Agent column, now account for cache tokens in totals, and have improved responsive sizing/compact‑mode hints.
    • Faster data loading via parallel parsing.
  • Documentation

    • Guides and READMEs updated for the unified multi‑agent workflow.

ryoppippi added 6 commits May 15, 2026 15:28
Add dependency-free filesystem traversal, JSONL, SQLite, worker, and deprecated CLI wrapper helpers so agent implementations can reuse the ccusage runtime foundation instead of keeping separate copies.

Extend terminal rendering with all-agent responsive layouts, stdout-safe writes, shared pricing fetch dedupe, and regression coverage for compact/full table switching in real terminal widths.
Make ccusage daily/monthly/weekly/session aggregate detected coding agents by default, with agent-first namespaces such as ccusage codex daily and ccusage opencode weekly.

Keep all-agent rendering on the shared usage table, group rows by period with parent All rows and child agent rows, reject --agent/report flag aliases, and add CLI snapshot coverage for the new contract.
Move Codex, OpenCode, Amp, and pi-agent loading paths away from the old tinyglobby/fast-sort style and onto the shared traversal, JSONL, SQLite, sorting, pricing, and stdout helpers.

Preserve agent-specific accounting such as Codex speed pricing, OpenCode JSON plus SQLite inputs, Amp credits, and pi-agent cache reads while aligning dates, offline pricing behaviour, and table output with ccusage.
Convert the companion package entrypoints into compatibility wrappers that depend on ccusage and emit the deprecation path before forwarding to the agent namespace.

Keep the existing package binaries, remove obsolete runtime dependencies from the wrapper packages, and update the lockfile so the wrappers stay tiny.
Update user-facing docs for ccusage as the all-agent entrypoint, describe legacy package forwarding, and keep agent-specific examples on the new namespace contract.

Record the implementation plan, verification expectations, CodeRabbit/Cubic review loop, performance checks, and cmux terminal capture workflow for visual debugging.
Keep the pi compatibility wrapper in the shape produced by the build tooling so repeated builds do not leave package.json dirty.

Use the generated pi binary name when stripping passthrough arguments while continuing to document ccusage-pi as a user alias.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Unifies agent CLIs under ccusage, adds worker-thread parsing and shared fs/jsonl/sqlite/workers utilities, centralizes/deduplicates pricing fetches, implements an all-agent aggregation command, updates per-agent commands to support --offline and standardized output, extends terminal tables with Agent support and responsive sizing, and updates schema/docs/tests/snapshots.

Changes

Multi-Agent Consolidation

Layer / File(s) Summary
Foundation: internal utilities
packages/internal/src/fs.ts, packages/internal/src/jsonl.ts, packages/internal/src/sqlite.ts, packages/internal/src/workers.ts, packages/internal/src/colors.ts, packages/internal/src/logger.ts, packages/internal/src/pricing.ts
Add recursive file collection, JSONL streaming, SQLite backend abstraction, worker-thread sizing/chunking, color helpers, multi-line logger boxes, and deduplicating/shared LiteLLM pricing loader.
Workerized loaders
apps/amp/src/data-loader.ts, apps/codex/src/data-loader.ts, apps/opencode/src/data-loader.ts, apps/pi/src/data-loader.ts
Move per-agent parsing to worker-thread pipelines using collectFilesRecursive/processJSONLFileByLine and ordered result aggregation; add per-agent worker entrypoints.
Pricing & pricing sources
apps/amp/src/pricing.ts, apps/codex/src/pricing.ts
Allow injected LiteLLMPricingFetcher with ownership tracking; Amp.calculateCost now loads pricing then computes price via pricing-driven mapping; add tests for cached formats.
CLI routing & all-agent command
apps/ccusage/src/commands/index.ts, apps/ccusage/src/commands/all.ts, packages/internal/src/deprecated-agent-cli.ts
Introduce agent-prefixed subcommands, argument normalization/validation, the unified all-agent report (detects agents, loads per-agent rows, aggregates by period), and a deprecated-agent wrapper that forwards to ccusage.
Per-agent command updates
apps/amp/src/commands/*, apps/opencode/src/commands/*, apps/codex/src/commands/*, apps/pi/src/commands/*, apps/ccusage/src/commands/*
Add --offline/-O; route output through writeStdoutLine; use logger.box/logger.info for headers/compact-mode messages; include cache tokens in totals; adjust ResponsiveTable params.
Terminal & table rendering
packages/terminal/src/table.ts
Add Agent column support, per-mode min widths and flexible-column indices, prefer process.stdout.columns, update model-name formatting, and expose createUsageReportTable helpers.
Config, docs, tests, snapshots
apps/ccusage/config-schema.json, docs/**, apps/ccusage/test/**, snapshot files
Add per-agent command namespaces to schema with strict option sets; update docs to multi-agent framing; centralize CLI test env helpers; add all-agent tests and many updated snapshots.
Package/build updates
packages/internal/package.json, packages/terminal/package.json, agent package.json files, apps/ccusage/tsdown.config.ts, apps/ccusage/scripts/bench.mjs
Add internal exports, update dependencies to use @ccusage/internal, add workspace ccusage deps, expand tsdown include list, and update benchmark entrypoint.

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

"A rabbit hopped through log-filled night,
Workers parsing by lantern-light;
Tables stretch and agents meet,
Costs align, snapshots neat—
Hop on, ccusage, all-agent flight! 🐇"

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/consolidate-agent-usage

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

ccusage performance comparison

This compares the PR build against the base branch build on the same CI runner.

Committed fixture performance

Committed small fixture for stable PR-to-PR feedback and output-shape regressions.

Fixture: apps/ccusage/test/fixtures/claude
Runtime: package ccusage bin from apps/ccusage/package.json through bun -b, --offline --json, measured by hyperfine with 2 warmups and 7 runs.

Command Base median PR median PR vs base
daily --offline --json 79.3ms 137.9ms 0.58x
session --offline --json 77.7ms 143.3ms 0.54x
blocks --offline --json 79.0ms 142.8ms 0.55x

Large real-world-shaped fixture performance

Generated fixture around 1 GiB shaped from aggregate local Claude-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 fixture.

Fixture: /home/runner/work/_temp/ccusage-large-fixture
Runtime: package ccusage bin from apps/ccusage/package.json through bun -b, --offline --json, measured by hyperfine with 0 warmups and 1 runs.

Command Base median PR median PR vs base
daily --offline --json 1.419s 1.435s 0.99x

Package size

Package artifact Base PR Delta Ratio
packed ccusage-*.tgz 43.29 KiB 64.02 KiB +20.73 KiB 0.68x

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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 15, 2026

Open in StackBlitz

@ccusage/amp

npx https://pkg.pr.new/ryoppippi/ccusage/@ccusage/amp@1000

ccusage

npx https://pkg.pr.new/ryoppippi/ccusage@1000

@ccusage/codex

npx https://pkg.pr.new/ryoppippi/ccusage/@ccusage/codex@1000

@ccusage/opencode

npx https://pkg.pr.new/ryoppippi/ccusage/@ccusage/opencode@1000

@ccusage/pi

npx https://pkg.pr.new/ryoppippi/ccusage/@ccusage/pi@1000

commit: ebfc4cc

Remove the environment-derived timezone default from the Codex Gunshi args so generated ccusage config schema no longer depends on the machine timezone. Runtime behavior still falls back through the existing system-timezone path when the option is omitted. Also normalize plan.md spelling to satisfy typos.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 15, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
⛔ Deployment terminated
View logs
ccusage-guide ebfc4cc May 15 2026, 07:48 PM

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 18

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/guide/getting-started.md (1)

59-64: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Generalize column descriptions to match multi-agent output.

At Line 61-63, wording is still Claude-specific (“Claude models”, “sent to Claude”, “received from Claude”), which conflicts with the new all-agent framing.

🤖 Prompt for 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.

In `@docs/guide/getting-started.md` around lines 59 - 64, The bullets under the
usage table are still Claude-specific; update the "Models", "Input", and
"Output" lines to neutral, multi-agent wording: change "Which Claude models were
used (Sonnet, Opus, etc.)" to "Which models were used (e.g., Sonnet, Opus,
Claude, etc.)" and replace "Number of input tokens sent to Claude" / "Number of
output tokens received from Claude" with "Number of input tokens sent to the
agent/model" and "Number of output tokens received from the agent/model"
respectively so the descriptions apply to any agent.
🧹 Nitpick comments (1)
apps/ccusage/src/commands/all.ts (1)

109-125: ⚡ Quick win

Remove or wire up --all.

The option is declared in allArgs, but resolveAllAgents() ignores options and loadAllRowsWithContext() always loads every agent anyway. Right now the help text promises a mode switch that never happens.

Also applies to: 159-162, 681-689

🤖 Prompt for 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.

In `@apps/ccusage/src/commands/all.ts` around lines 109 - 125, The declared --all
flag is unused: modify the command handler so the options object (the boolean at
all/ allArgs) is passed into resolveAllAgents() and/or loadAllRowsWithContext()
and ensure those functions accept and respect an options.all boolean (or add a
parameter like loadAllRowsWithContext(loadAll: boolean)) so that when
options.all is true you load every agent and when false you keep the current
filtered behavior; alternatively, remove the all flag if you prefer not to
support it — update resolveAllAgents(), loadAllRowsWithContext(), and the
command invocation sites to consistently read options.all and branch
accordingly.
🤖 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/config-schema.json`:
- Around line 1013-1017: The JSON schema has timezone defaults set to
"Europe/London" causing CI mismatch; update the default value for the timezone
property (the schema entries whose "description"/"markdownDescription" read
"Timezone for date grouping (IANA)") from "Europe/London" to "UTC" in all
occurrences (including the other two blocks referenced), then regenerate the
schema artifacts by running the project generation command (pnpm run
generate:schema) so docs/public/config-schema.json is updated.

In `@apps/ccusage/src/commands/all.ts`:
- Around line 579-583: The per-row totalTokens currently only sums
event.inputTokens + event.outputTokens and omits Amp cache tokens; update the
accumulation for group.row.totalTokens to also include
event.cacheCreationInputTokens and event.cacheReadInputTokens so totalTokens
reflects input, output, cacheCreationTokens and cacheReadTokens (ensure this
ties to the existing fields group.row.cacheCreationTokens and
group.row.cacheReadTokens and the event properties
cacheCreationInputTokens/cacheReadInputTokens).

In `@apps/ccusage/test/cli-output.test.ts`:
- Line 159: Update the Pi fixture's model ID used in the test—replace the
invalid 'claude-opus-4-5' value with the canonical LiteLLM model ID
'claude-opus-4-20250514' wherever the test sets model: 'claude-opus-4-5' (e.g.,
in the Pi fixture or variable that configures the model in cli-output.test.ts)
so the test uses the correct LiteLLM pricing/database identifier.

In `@apps/codex/package.json`:
- Around line 44-46: Move the "ccusage" entry out of the dependencies section in
package.json and add it under devDependencies instead so the dependencies object
stays empty for the bundled CLI; update the package.json keys (remove "ccusage"
from "dependencies" and add the same version/value under "devDependencies") and
ensure JSON remains valid (keep the exact version "workspace:*" for "ccusage").

In `@apps/codex/README.md`:
- Around line 20-21: The README's alias workflow still recommends the deprecated
wrapper "@ccusage/codex@latest"; update the alias section and all occurrences
(referenced strings "@ccusage/codex@latest" and any other `@ccusage/codex`
mentions) to instead recommend using the non-deprecated invocation ("npx
ccusage@latest codex" or "ccusage codex") so the docs are consistent with the
deprecation notice; search and replace those strings in the README (including
the alias workflow block and the other occurrences called out) and ensure
examples and explanatory text reflect the preferred commands.

In `@apps/opencode/package.json`:
- Around line 47-49: Move the "ccusage" entry out of the dependencies object
into devDependencies in apps/opencode/package.json so runtime deps are bundled;
specifically remove "ccusage": "workspace:*" from the "dependencies" section and
add the same key/value under "devDependencies" (ensure "dependencies" remains
empty or only contains true runtime items per guideline), preserving the version
spec "workspace:*" and package.json JSON validity.

In `@apps/opencode/README.md`:
- Around line 16-17: The README's alias examples still point at the deprecated
package; update any alias and example commands that reference
"@ccusage/opencode" to use the new ccusage-first form (e.g., replace occurrences
of aliases like alias opencode="npx `@ccusage/opencode`" with alias opencode="npx
ccusage@latest opencode" or the equivalent "npx ccusage opencode"), and apply
this change consistently for the sections mentioned (the block around the
compatibility note and the other example ranges). Ensure all displayed example
commands, alias snippets, and prose mention "npx ccusage@latest opencode" (or
"npx ccusage opencode") as the recommended invocation instead of the old
package.

In `@apps/pi/package.json`:
- Around line 56-58: Move the "ccusage" entry out of the dependencies object and
add it under devDependencies with the same version ("workspace:*"); specifically
remove the "ccusage": "workspace:*" line from the dependencies block and insert
it into devDependencies (ensuring there are no duplicate entries), then validate
the package.json is still valid JSON and that the dependencies object is empty
or only contains true runtime deps if any.

In `@apps/pi/README.md`:
- Around line 16-17: Update the alias instructions so they match the new
compatibility-wrapper guidance: replace any recommendations that use the
deprecated package alias like "@ccusage/pi@latest" with the wrapper-first form
"npx ccusage@latest pi" (or instruct using "ccusage pi" if already installed),
and ensure the README sections that mention aliases (the strings
"@ccusage/pi@latest", "ccusage/pi", or similar) are changed in all instances
(around lines referenced) to avoid recommending the deprecated wrapper-first
usage; keep the compatibility note "Prefer npx ccusage@latest pi" as the
canonical example and adjust nearby alias examples to forward to "ccusage pi".

In `@apps/pi/src/data-loader.ts`:
- Around line 259-266: The deduplication key `hash` (built in the loop over
fileResults/entry and stored in processedHashes) is too narrow—replace or widen
it so it includes a unique session identifier in addition to timestamp and
tokenTotal (e.g. include entry.sessionId or entry.session_token or another
per-session unique field on entry) so distinct sessions that share
timestamp+tokenTotal are not collapsed; if no explicit session id exists,
include a second differentiator such as entry.clientId or a short digest of
entry.id/entry metadata (or fallback to JSON.stringify(entry)) when constructing
the hash to ensure per-session uniqueness.

In `@docs/guide/getting-started.md`:
- Line 40: The fenced code block that contains the ASCII table (the block
starting with the box-drawing character '╭') is missing a language tag and
triggers MD040; update the opening fence from ``` to include a language
identifier (e.g., change it to ```text) so the block is explicitly marked as
plain text, preserving the existing block contents and closing fence unchanged.

In `@packages/internal/src/deprecated-agent-cli.ts`:
- Around line 44-48: The wrapper runDeprecatedAgentCli currently lets
resolveCcusageCliPath() rejection propagate; catch errors from
resolveCcusageCliPath() inside runDeprecatedAgentCli and return a numeric
failure code instead of throwing (e.g., return 1). Specifically, wrap the call
to resolveCcusageCliPath() (used to set cliPath) in a try/catch, log or write an
error message via process.stderr (preserving the existing
formatDeprecatedAgentWarning behavior), and return a non-zero exit code when
resolution fails so the function always resolves to a number rather than
rejecting.

In `@packages/internal/src/fs.ts`:
- Around line 17-20: The current try/catch around the readdir call swallows all
errors; change the catch to capture the thrown error (e.g., catch (err)) and
only suppress expected filesystem errors (check err.code against a whitelist
such as 'ENOENT', 'ENOTDIR', and optionally 'EACCES' if intended); for any other
err.code rethrow the error so failures aren't silently dropped. Locate the block
that calls readdir(directory, { withFileTypes: true }) and references entries
and directory, update the catch to inspect err.code and return only for the
allowed codes, otherwise throw err.

In `@packages/internal/src/pricing.ts`:
- Around line 227-234: The memoized pricingLoadPromise in ensurePricingLoaded
makes a failed load permanent; change ensurePricingLoaded so that when
loadPricing() rejects it clears pricingLoadPromise (so subsequent calls can
retry) while still returning the failure; specifically, wrap the Promise
returned by loadPricing() (the value assigned to this.pricingLoadPromise) with a
then/catch that on success sets this.cachedPricing and leaves pricingLoadPromise
as settled, and on error sets this.pricingLoadPromise = undefined before
rethrowing or returning the rejected Result; update references to
ensurePricingLoaded, pricingLoadPromise, loadPricing, cachedPricing (and respect
clearCache behavior) so transient failures are not sticky.

In `@packages/internal/src/workers.ts`:
- Around line 57-61: The function chunkIndexedItemsByFileSize must validate
chunkCount before using it to allocate and index into chunks to avoid runtime
errors when chunkCount is 0 or negative; add an early guard in
chunkIndexedItemsByFileSize that checks if chunkCount is a positive integer
(e.g., throw a RangeError or default to 1) and return or adjust accordingly, and
ensure the same validation is applied to the other chunk-allocation logic that
uses chunks and targetIndex so pushes into chunks[targetIndex] cannot fail due
to an invalid chunkCount.

In `@plan.md`:
- Line 66: Change the British spelling "behaviour" to the American spelling
"behavior" in the plan text — specifically replace "behaviour" (in the sentence
about Agent-specific options and aggregation behaviour) with "behavior" so the
file passes CI spelling checks.
- Line 141: The header "Optimisation Migration Requirements" uses British
spelling; update it to American spelling by renaming the heading to
"Optimization Migration Requirements" so CI passes (locate the header line
containing the exact phrase "Optimisation Migration Requirements" and replace
"Optimisation" with "Optimization").
- Line 154: Fix the American English spelling: update the sentence that
currently reads "When adding missing agent-specific subcommands, design their
cache behaviour at the same time instead of treating caching as a later
bolt-on." by replacing "behaviour" with "behavior" so it becomes "design their
cache behavior" to satisfy CI spelling checks.

---

Outside diff comments:
In `@docs/guide/getting-started.md`:
- Around line 59-64: The bullets under the usage table are still
Claude-specific; update the "Models", "Input", and "Output" lines to neutral,
multi-agent wording: change "Which Claude models were used (Sonnet, Opus, etc.)"
to "Which models were used (e.g., Sonnet, Opus, Claude, etc.)" and replace
"Number of input tokens sent to Claude" / "Number of output tokens received from
Claude" with "Number of input tokens sent to the agent/model" and "Number of
output tokens received from the agent/model" respectively so the descriptions
apply to any agent.

---

Nitpick comments:
In `@apps/ccusage/src/commands/all.ts`:
- Around line 109-125: The declared --all flag is unused: modify the command
handler so the options object (the boolean at all/ allArgs) is passed into
resolveAllAgents() and/or loadAllRowsWithContext() and ensure those functions
accept and respect an options.all boolean (or add a parameter like
loadAllRowsWithContext(loadAll: boolean)) so that when options.all is true you
load every agent and when false you keep the current filtered behavior;
alternatively, remove the all flag if you prefer not to support it — update
resolveAllAgents(), loadAllRowsWithContext(), and the command invocation sites
to consistently read options.all and branch accordingly.
🪄 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: e06007bc-8da2-43f9-b4e8-bf0580f1a02d

📥 Commits

Reviewing files that changed from the base of the PR and between 0377acc and 47f5a69.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (58)
  • apps/amp/package.json
  • apps/amp/src/_macro.ts
  • apps/amp/src/commands/daily.ts
  • apps/amp/src/commands/monthly.ts
  • apps/amp/src/commands/session.ts
  • apps/amp/src/data-loader.ts
  • apps/amp/src/index.ts
  • apps/amp/src/pricing.ts
  • apps/ccusage/README.md
  • apps/ccusage/config-schema.json
  • apps/ccusage/scripts/bench.mjs
  • apps/ccusage/src/commands/all.ts
  • apps/ccusage/src/commands/index.ts
  • apps/ccusage/test/cli-output.test.ts
  • apps/ccusage/test/snapshots/cli-output/daily-json.txt
  • apps/ccusage/test/snapshots/cli-output/daily-table.txt
  • apps/ccusage/test/snapshots/cli-output/monthly-json.txt
  • apps/ccusage/test/snapshots/cli-output/session-json.txt
  • apps/ccusage/test/snapshots/cli-output/session-table.txt
  • apps/ccusage/test/snapshots/cli-output/weekly-json.txt
  • apps/ccusage/tsdown.config.ts
  • apps/codex/README.md
  • apps/codex/package.json
  • apps/codex/src/command-utils.ts
  • apps/codex/src/daily-report.ts
  • apps/codex/src/data-loader.ts
  • apps/codex/src/index.ts
  • apps/codex/src/monthly-report.ts
  • apps/codex/src/pricing.ts
  • apps/opencode/README.md
  • apps/opencode/package.json
  • apps/opencode/src/commands/daily.ts
  • apps/opencode/src/commands/monthly.ts
  • apps/opencode/src/commands/session.ts
  • apps/opencode/src/commands/weekly.ts
  • apps/opencode/src/data-loader.ts
  • apps/opencode/src/index.ts
  • apps/pi/README.md
  • apps/pi/package.json
  • apps/pi/src/commands/daily.ts
  • apps/pi/src/commands/monthly.ts
  • apps/pi/src/commands/session.ts
  • apps/pi/src/data-loader.ts
  • apps/pi/src/index.ts
  • docs/guide/codex/index.md
  • docs/guide/getting-started.md
  • docs/guide/index.md
  • packages/internal/package.json
  • packages/internal/src/array.ts
  • packages/internal/src/deprecated-agent-cli.ts
  • packages/internal/src/fs.ts
  • packages/internal/src/jsonl.ts
  • packages/internal/src/logger.ts
  • packages/internal/src/pricing.ts
  • packages/internal/src/sqlite.ts
  • packages/internal/src/workers.ts
  • packages/terminal/src/table.ts
  • plan.md

Comment thread apps/ccusage/config-schema.json
Comment thread apps/ccusage/src/commands/all.ts Outdated
Comment thread apps/ccusage/test/cli-output.test.ts Outdated
Comment thread apps/codex/package.json
Comment thread apps/codex/README.md
Comment thread packages/internal/src/pricing.ts
Comment thread packages/internal/src/workers.ts
Comment thread plan.md Outdated
Comment thread plan.md Outdated
Comment thread plan.md Outdated
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

13 issues found across 59 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/amp/src/commands/daily.ts">

<violation number="1" location="apps/amp/src/commands/daily.ts:204">
P2: The leading `\n` in the message string breaks the tagged line format — `writeTaggedLine` already emits a blank line before the tag, so the extra newline splits the tag prefix from the message content. Remove the leading `\n` to keep the tagged output on one line.</violation>
</file>

<file name="apps/ccusage/config-schema.json">

<violation number="1" location="apps/ccusage/config-schema.json:429">
P2: Type mismatch: `contextLowThreshold` and `contextMediumThreshold` are declared as `"type": "string"` but have numeric `default` values (50 and 80). Either change the type to `"number"` or make the defaults string values (`"50"`, `"80"`). Since they represent numeric percentages, `"type": "number"` is likely correct.</violation>
</file>

<file name="apps/pi/README.md">

<violation number="1" location="apps/pi/README.md:16">
P2: The shell alias section immediately below still uses the deprecated `@ccusage/pi@latest` package. Update it to use `ccusage@latest pi` to stay consistent with the deprecation notice and the rest of this file.</violation>
</file>

<file name="apps/pi/package.json">

<violation number="1" location="apps/pi/package.json:27">
P2: Binary name `pi` is too generic and inconsistent with sibling packages (`ccusage-amp`, `ccusage-codex`, `ccusage-opencode`). Publishing an npm package with a `pi` binary risks name collisions with other tools. Consider keeping the `ccusage-pi` name for the binary, even if the package is deprecated.</violation>
</file>

<file name="packages/internal/src/sqlite.ts">

<violation number="1" location="packages/internal/src/sqlite.ts:80">
P2: The replacement `process.emitWarning` function only forwards the first argument. If a non-SQLite warning fires during the require with extra arguments (type, code, ctor), they are silently dropped. Use rest parameters to forward all arguments for non-suppressed warnings.</violation>
</file>

<file name="packages/internal/src/jsonl.ts">

<violation number="1" location="packages/internal/src/jsonl.ts:63">
P2: When running on Bun and the file exceeds `MAX_BUFFERED_JSONL_BYTES`, the Bun branch doesn't return `null`, causing a redundant fallthrough to the Node.js path that re-opens and re-stats the file. Add `return null` after the Bun size check to short-circuit.</violation>
</file>

<file name="apps/ccusage/src/commands/all.ts">

<violation number="1" location="apps/ccusage/src/commands/all.ts:583">
P2: Amp `totalTokens` excludes cache tokens, inconsistent with all other agents. This causes the aggregated "All" row totals to undercount when Amp has cache usage.</violation>
</file>

<file name="apps/amp/src/commands/session.ts">

<violation number="1" location="apps/amp/src/commands/session.ts:216">
P2: The leading `\n` in the message breaks the tagged log format. `writeTaggedLine` already outputs a blank line before the tag, so the embedded `\n` creates an extra blank line and causes "Running in Compact Mode" to appear on a new line without the logger prefix.</violation>
</file>

<file name="packages/internal/src/fs.ts">

<violation number="1" location="packages/internal/src/fs.ts:3">
P2: Move the `fs-fixture` import inside the `import.meta.vitest` guard to avoid bundling a test-only dependency into production. Unlike Node.js built-ins used elsewhere in this package, `fs-fixture` is an external test package whose tree-shaking depends on the production bundler proving it's side-effect-free.</violation>
</file>

<file name="packages/terminal/src/table.ts">

<violation number="1" location="packages/terminal/src/table.ts:854">
P2: `compactHeaders.indexOf('Models')` returns `-1` when `includeAgent` is true (compact headers are `['Date', 'Agent', 'Total Tokens', 'Cost (USD)']`). This `-1` passes downstream as a valid `flexibleColumnIndex`, triggering dead computation and fragile index lookups like `columnWidths[-1]`. Normalize to `undefined` when the header isn't found.</violation>
</file>

<file name="packages/internal/src/pricing.ts">

<violation number="1" location="packages/internal/src/pricing.ts:232">
P1: Reset `pricingLoadPromise` on failed pricing loads so transient fetch errors can recover on subsequent calls.</violation>
</file>

<file name="packages/internal/src/deprecated-agent-cli.ts">

<violation number="1" location="packages/internal/src/deprecated-agent-cli.ts:47">
P2: Handle `resolveCcusageCliPath()` failures inside the wrapper and return a non-zero exit code. Letting this throw causes the wrapper to reject instead of consistently returning an exit status.</violation>
</file>

<file name="apps/pi/src/data-loader.ts">

<violation number="1" location="apps/pi/src/data-loader.ts:261">
P1: The dedup key is too coarse; distinct pi-agent events with the same timestamp and total token count will be merged and dropped. Include stable identifiers (for example project/session/model/token components) in the hash so valid usage rows are not lost.</violation>
</file>

Tip: instead of fixing issues one by one fix them all with cubic
Partial review: This PR has more than 50 files, so cubic reviewed the highest-priority files first. During the trial, paid plans get a higher file limit.
You can try an ultrareview to bypass the file limit, comment @cubic-dev-ai ultrareview. Learn more.
Re-trigger cubic

Comment thread packages/internal/src/pricing.ts Outdated
Comment thread apps/pi/src/data-loader.ts Outdated
Comment thread apps/amp/src/commands/daily.ts Outdated
Comment thread apps/ccusage/config-schema.json
Comment thread apps/pi/README.md
Comment thread apps/ccusage/src/commands/all.ts Outdated
Comment thread apps/amp/src/commands/session.ts Outdated
Comment thread packages/internal/src/fs.ts Outdated
Comment thread packages/terminal/src/table.ts Outdated
Comment thread packages/internal/src/deprecated-agent-cli.ts Outdated
ryoppippi added 2 commits May 15, 2026 16:13
Include Amp cache tokens in all-agent totals, widen pi-agent deduplication keys, and harden shared wrapper/fs/worker/pricing helpers. Also updates docs examples to point aliases at the ccusage-first commands and refreshes schema metadata.
Remove extra compact-mode newlines from Amp logs, make statusline threshold schema numeric, avoid bundling fs-fixture in internal fs tests, short-circuit large Bun JSONL reads, forward process.emitWarning arguments, and normalize missing flexible table column indexes.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/pi/src/data-loader.ts`:
- Line 529: The test is using the deprecated model name `claude-opus-4-5` under
the `usage` object; update that string to one of the approved Claude 4 names
(`claude-sonnet-4-20250514` or `claude-opus-4-20250514`) and then adjust the
corresponding expected assertion (the assertion near the original line 559) to
match the new model name so the test expectation aligns with LiteLLM's pricing
database entry; locate the `usage` object in apps/pi/src/data-loader.ts and the
nearby assertion referencing the model and update both accordingly.
🪄 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: 65afa892-5a22-49a7-a9c3-8d37040b6891

📥 Commits

Reviewing files that changed from the base of the PR and between 47f5a69 and 2ba21e5.

📒 Files selected for processing (14)
  • apps/ccusage/config-schema.json
  • apps/ccusage/src/commands/all.ts
  • apps/ccusage/test/cli-output.test.ts
  • apps/codex/README.md
  • apps/codex/src/_shared-args.ts
  • apps/opencode/README.md
  • apps/pi/README.md
  • apps/pi/src/data-loader.ts
  • docs/guide/getting-started.md
  • packages/internal/src/deprecated-agent-cli.ts
  • packages/internal/src/fs.ts
  • packages/internal/src/pricing.ts
  • packages/internal/src/workers.ts
  • plan.md
💤 Files with no reviewable changes (1)
  • apps/codex/src/_shared-args.ts
✅ Files skipped from review due to trivial changes (3)
  • apps/pi/README.md
  • apps/opencode/README.md
  • docs/guide/getting-started.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/internal/src/pricing.ts
  • packages/internal/src/deprecated-agent-cli.ts
  • packages/internal/src/fs.ts
  • packages/internal/src/workers.ts
  • apps/ccusage/config-schema.json
  • apps/ccusage/test/cli-output.test.ts
  • apps/ccusage/src/commands/all.ts

Comment thread apps/pi/src/data-loader.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/ccusage/src/commands/statusline.ts (1)

157-158: ⚡ Quick win

Use the parsed thresholds for rendering, not raw ctx.values.

Line 157 and Line 158 validate/normalize thresholds, but Line 464 and Line 466 still read raw values. Reuse contextLowThreshold/contextMediumThreshold in formatContextInfo so validation and rendering stay consistent.

♻️ Proposed fix
-const formatContextInfo = (inputTokens: number, contextLimit: number): string => {
+const formatContextInfo = (
+	inputTokens: number,
+	contextLimit: number,
+	lowThreshold: number,
+	mediumThreshold: number,
+): string => {
 	const percentage = Math.round((inputTokens / contextLimit) * 100);
 	const color =
-		percentage < ctx.values.contextLowThreshold
+		percentage < lowThreshold
 			? pc.green
-			: percentage < ctx.values.contextMediumThreshold
+			: percentage < mediumThreshold
 				? pc.yellow
 				: pc.red;
 	const coloredPercentage = color(`${percentage}%`);
 	const tokenDisplay = inputTokens.toLocaleString();
 	return `${tokenDisplay} (${coloredPercentage})`;
 };
@@
-	return formatContextInfo(contextResult.inputTokens, contextResult.contextLimit);
+	return formatContextInfo(
+		contextResult.inputTokens,
+		contextResult.contextLimit,
+		contextLowThreshold,
+		contextMediumThreshold,
+	);

Also applies to: 461-468, 500-505

🤖 Prompt for 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.

In `@apps/ccusage/src/commands/statusline.ts` around lines 157 - 158, The code
parses/normalizes thresholds into contextLowThreshold and contextMediumThreshold
but still uses raw ctx.values.contextLowThreshold /
ctx.values.contextMediumThreshold when rendering; update formatContextInfo (and
all other spots in StatusLine where thresholds are read e.g., the blocks around
the other occurrences) to use the parsed variables contextLowThreshold and
contextMediumThreshold instead of ctx.values.* so the validated values are
rendered consistently (search for usages in formatContextInfo and the sections
around the other occurrences and replace with the parsed symbol names).
🤖 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 `@plan.md`:
- Around line 1-5: The document's main heading "Plan: Consolidate Agent Usage
CLIs into ccusage" is missing the required screenshot immediately after the H1;
add an image reference right after that H1 (using markdown image syntax)
pointing to the appropriate screenshot file (e.g., a new or existing file like
assets/images/ccusage-overview.png), include an informative alt text and brief
caption, and ensure the image path matches the repo's docs/assets location so it
renders in previews.
- Around line 807-823: The example in plan.md hardcodes machine-specific IDs
(workspace_id, surface_id, pane_id) and an absolute user path; update the
snippet to use placeholders/env vars (e.g., WORKSPACE_REF, SURFACE_REF,
PANE_REF, WORKSPACE_ID, SURFACE_ID, PANE_ID, PROJECT_DIR) and show how to
substitute them in the commands so the cmux send and cmux capture-pane lines
reference variables instead of literal IDs or /Users/... paths; locate the
workspace_ref/pane_ref/surface_ref and the cmux send/capture-pane command lines
and replace the concrete IDs and the /Users/... project path with those
placeholders and a short note to set the env vars before running.

---

Nitpick comments:
In `@apps/ccusage/src/commands/statusline.ts`:
- Around line 157-158: The code parses/normalizes thresholds into
contextLowThreshold and contextMediumThreshold but still uses raw
ctx.values.contextLowThreshold / ctx.values.contextMediumThreshold when
rendering; update formatContextInfo (and all other spots in StatusLine where
thresholds are read e.g., the blocks around the other occurrences) to use the
parsed variables contextLowThreshold and contextMediumThreshold instead of
ctx.values.* so the validated values are rendered consistently (search for
usages in formatContextInfo and the sections around the other occurrences and
replace with the parsed symbol names).
🪄 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: c28303c4-0680-4375-852d-c811840723a2

📥 Commits

Reviewing files that changed from the base of the PR and between 2ba21e5 and 89a102a.

📒 Files selected for processing (13)
  • .agents/skills/cmux-debug
  • .claude/skills/cmux-debug/SKILL.md
  • apps/amp/src/commands/daily.ts
  • apps/amp/src/commands/session.ts
  • apps/ccusage/config-schema.json
  • apps/ccusage/src/commands/statusline.ts
  • apps/pi/src/_pi-agent.ts
  • apps/pi/src/data-loader.ts
  • packages/internal/src/fs.ts
  • packages/internal/src/jsonl.ts
  • packages/internal/src/sqlite.ts
  • packages/terminal/src/table.ts
  • plan.md
✅ Files skipped from review due to trivial changes (2)
  • .claude/skills/cmux-debug/SKILL.md
  • apps/pi/src/_pi-agent.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/internal/src/fs.ts
  • apps/amp/src/commands/session.ts
  • packages/internal/src/sqlite.ts
  • apps/amp/src/commands/daily.ts
  • apps/pi/src/data-loader.ts
  • apps/ccusage/config-schema.json
  • packages/internal/src/jsonl.ts
  • packages/terminal/src/table.ts

Comment thread plan.md
Comment thread plan.md Outdated
ryoppippi added 3 commits May 15, 2026 16:42
Switch responsive tables to prefer compact output when the full layout would consume nearly all available terminal width, while still allowing wide terminals to keep the detailed columns.

Shorten wrapped Claude model names from agent integrations so the models column does not dominate tables.

Move Amp report headers before pricing work, include cache tokens in Amp totals, and add CLI integration snapshots for all-agent and direct agent outputs.

Document that human-readable CLI integration output needs file snapshots and that Vitest tests should use vi.stubEnv for env changes.
@ryoppippi ryoppippi changed the title feat(ccusage): consolidate coding agent usage reports feat(ccusage): add all-agent coding usage reports May 15, 2026
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 18 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/ccusage/test/snapshots/cli-output/all-agent-daily-json.txt">

<violation number="1" location="apps/ccusage/test/snapshots/cli-output/all-agent-daily-json.txt:16">
P2: `totalTokens` is inconsistent with the token component fields (should be 700), which bakes an incorrect expected JSON contract into the snapshot.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic
Re-trigger cubic

Comment thread apps/ccusage/test/snapshots/cli-output/all-agent-daily-json.txt Outdated
Remove the unconditional blank line before tagged log lines so pricing and compact-mode notices render as adjacent terminal lines.

Add a tiny internal ANSI color helper instead of depending on picocolors for logger labels; info follows consola cyan, warn uses yellow, errors use red, and tags use gray.

Render compact-mode notices before table output for agent report commands so snapshots and terminal output keep the notice attached to the resulting table.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 19 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/internal/src/logger.ts">

<violation number="1" location="packages/internal/src/logger.ts:161">
P2: This test is environment-dependent: it expects plain text even though color output is enabled on TTY/`FORCE_COLOR`. Make the test force `NO_COLOR` (and restore env) so it remains deterministic.</violation>
</file>

<file name="packages/internal/src/ansi-colors.ts">

<violation number="1" location="packages/internal/src/ansi-colors.ts:7">
P2: `NO_COLOR` handling is too aggressive and currently blocks forced color. Empty `NO_COLOR` should be ignored, and `FORCE_COLOR` should be evaluated first so explicit force settings can take effect.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic
Re-trigger cubic

Comment thread packages/internal/src/logger.ts
Comment thread packages/internal/src/ansi-colors.ts Outdated
ryoppippi added 3 commits May 15, 2026 19:11
Use the rendered table border width when deciding whether a table fits instead of over-counting each column separator. This prevents full layouts from falling into compact mode when the terminal is wide enough.

Measure multiline cells by the widest rendered line rather than the full newline-delimited string, which keeps model columns from expanding unnecessarily for multi-model rows.

Move compact mode notices below rendered tables across agent commands so the report stays visually grouped while retaining the warning.
@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented May 15, 2026

You're iterating quickly on this pull request. To help protect your rate limits, cubic has paused automatic reviews on new pushes for now—when you're ready for another review, comment @cubic-dev-ai review.

@ryoppippi
Copy link
Copy Markdown
Owner Author

@coderabbitai review\n@cubic-dev-ai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

@ryoppippi Sure, I'll review the changes in this PR!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ryoppippi
Copy link
Copy Markdown
Owner Author

@cubic-dev-ai review

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented May 15, 2026

@cubic-dev-ai review

@ryoppippi I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
apps/codex/package.json (1)

44-46: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Move ccusage to devDependencies.

This issue was previously flagged but not addressed. Codex ships as a bundled CLI where all runtime dependencies must be in devDependencies. The dependencies section should remain empty so the bundler owns the runtime payload.

📦 Proposed fix
-	"dependencies": {
-		"ccusage": "workspace:*"
-	},
 	"devDependencies": {
 		"@ccusage/internal": "workspace:*",
 		"@ccusage/terminal": "workspace:*",
 		"@praha/byethrow": "catalog:runtime",
 		"@ryoppippi/eslint-config": "catalog:lint",
 		"@typescript/native-preview": "catalog:types",
+		"ccusage": "workspace:*",
 		"clean-pkg-json": "catalog:release",

As per coding guidelines: "Package Codex as a bundled CLI and keep every runtime dependency in devDependencies so the bundle includes shipped code" and "All projects under apps/ ship as bundled CLIs/binaries. Treat their runtime dependencies as bundled assets: list everything in each app's devDependencies (never dependencies)."

🤖 Prompt for 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.

In `@apps/codex/package.json` around lines 44 - 46, Move the "ccusage" entry from
the package.json "dependencies" section into "devDependencies" and ensure the
"dependencies" object is left empty; update the package.json so that "ccusage":
"workspace:*" appears under "devDependencies" (not "dependencies") to comply
with the bundled-CLI rule for the Codex app.
apps/opencode/package.json (1)

47-49: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Move ccusage to devDependencies per coding guidelines.

OpenCode is packaged as a bundled CLI where all runtime dependencies must be in devDependencies. The dependencies section should remain empty so the bundler owns the runtime payload.

📦 Proposed fix
-	"dependencies": {
-		"ccusage": "workspace:*"
-	},
 	"devDependencies": {
 		"@ccusage/internal": "workspace:*",
 		"@ccusage/terminal": "workspace:*",
 		"@praha/byethrow": "catalog:runtime",
 		"@ryoppippi/eslint-config": "catalog:lint",
 		"@typescript/native-preview": "catalog:types",
+		"ccusage": "workspace:*",
 		"clean-pkg-json": "catalog:release",

As per coding guidelines: "Keep every runtime dependency in devDependencies because OpenCode is packaged as a bundled CLI" and "All projects under apps/ ship as bundled CLIs/binaries. Treat their runtime dependencies as bundled assets: list everything in each app's devDependencies (never dependencies)."

🤖 Prompt for 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.

In `@apps/opencode/package.json` around lines 47 - 49, Move the "ccusage" entry
out of the "dependencies" object and add it under "devDependencies" in
apps/opencode's package.json (update the "ccusage" version string exactly as
currently listed), leaving "dependencies" empty so the bundled CLI follows the
repo guideline; ensure package.json remains valid JSON (no duplicate keys) and
run the package manager install to update lockfiles if needed.
🧹 Nitpick comments (1)
packages/internal/src/colors.ts (1)

26-56: 💤 Low value

Consider adding JSDoc comments to exported utility functions.

The exported color formatter functions would benefit from brief JSDoc comments explaining their purpose and parameters, especially the optional stream parameter.

📝 Example JSDoc
+/**
+ * Apply cyan color formatting to text when color output is enabled.
+ * `@param` value - The text to format
+ * `@param` stream - Optional output stream (defaults to stdout)
+ * `@returns` The formatted text (or original text if color is disabled)
+ */
 export function cyan(value: string, stream?: WriteStream): string {
 	return colorize('cyan', value, stream);
 }

Based on learnings: "Utility functions should include JSDoc explaining their purpose" (packages/internal guideline).

🤖 Prompt for 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.

In `@packages/internal/src/colors.ts` around lines 26 - 56, Add concise JSDoc
comments to each exported color helper (blue, bold, cyan, dim, gray, green, red,
yellow) describing that they format the input string with the given color/style
and return the formatted string; document the parameters: value (string) and
optional stream (WriteStream) which selects whether to apply coloring, and
mention the return type (string); note that these helpers delegate to colorize
so reference colorize in the description and ensure tags (`@param`, `@returns`) are
present for each function.
🤖 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 `@packages/terminal/package.json`:
- Line 18: The package.json currently lists "@ccusage/internal": "workspace:*"
under dependencies; move that entry into devDependencies instead (preserve the
version "workspace:*"), removing it from dependencies and adding it to
devDependencies in the packages/terminal package.json, then reinstall or update
the lockfile so the change is reflected; verify no runtime imports require it to
remain a dependency before committing.

In `@packages/terminal/src/table.ts`:
- Around line 314-320: The compact-mode condition is inconsistent: code that
returns compact table config checks both this.compactHead and
this.compactColAligns, but elsewhere compact is activated by this.compactHead
alone, causing headers to stay full while rows are compact-filtered and misalign
columns; unify the checks so compact mode is enabled only when both header and
column alignment info exist (or change all checks to rely solely on
this.compactHead), and update the logic that builds compact rows/filtering to
use the same condition; specifically adjust the checks around compactMode,
compactHead, compactColAligns, compactMinColumnWidths and
compactFlexibleColumnIndex and the code that generates compact-filtered rows so
they all use the identical predicate to decide compact mode.

---

Duplicate comments:
In `@apps/codex/package.json`:
- Around line 44-46: Move the "ccusage" entry from the package.json
"dependencies" section into "devDependencies" and ensure the "dependencies"
object is left empty; update the package.json so that "ccusage": "workspace:*"
appears under "devDependencies" (not "dependencies") to comply with the
bundled-CLI rule for the Codex app.

In `@apps/opencode/package.json`:
- Around line 47-49: Move the "ccusage" entry out of the "dependencies" object
and add it under "devDependencies" in apps/opencode's package.json (update the
"ccusage" version string exactly as currently listed), leaving "dependencies"
empty so the bundled CLI follows the repo guideline; ensure package.json remains
valid JSON (no duplicate keys) and run the package manager install to update
lockfiles if needed.

---

Nitpick comments:
In `@packages/internal/src/colors.ts`:
- Around line 26-56: Add concise JSDoc comments to each exported color helper
(blue, bold, cyan, dim, gray, green, red, yellow) describing that they format
the input string with the given color/style and return the formatted string;
document the parameters: value (string) and optional stream (WriteStream) which
selects whether to apply coloring, and mention the return type (string); note
that these helpers delegate to colorize so reference colorize in the description
and ensure tags (`@param`, `@returns`) are present for each function.
🪄 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: a22f2100-2a08-4581-a545-f3101040c540

📥 Commits

Reviewing files that changed from the base of the PR and between e4cb054 and f93fca0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (46)
  • CLAUDE.md
  • apps/amp/package.json
  • apps/amp/src/commands/daily.ts
  • apps/amp/src/commands/monthly.ts
  • apps/amp/src/commands/session.ts
  • apps/ccusage/package.json
  • apps/ccusage/src/_shared-args.ts
  • apps/ccusage/src/commands/all.ts
  • apps/ccusage/src/commands/blocks.ts
  • apps/ccusage/src/commands/daily.ts
  • apps/ccusage/src/commands/monthly.ts
  • apps/ccusage/src/commands/session.ts
  • apps/ccusage/src/commands/statusline.ts
  • apps/ccusage/src/commands/weekly.ts
  • apps/ccusage/test/cli-output.test.ts
  • apps/ccusage/test/snapshots/cli-output/all-agent-daily-json.txt
  • apps/ccusage/test/snapshots/cli-output/all-agent-daily-table.txt
  • apps/ccusage/test/snapshots/cli-output/amp-direct-compact-table.txt
  • apps/ccusage/test/snapshots/cli-output/amp-direct-daily-json.txt
  • apps/ccusage/test/snapshots/cli-output/amp-direct-full-table.txt
  • apps/ccusage/test/snapshots/cli-output/blocks-table.txt
  • apps/ccusage/test/snapshots/cli-output/codex-direct-daily-json.txt
  • apps/ccusage/test/snapshots/cli-output/daily-table.txt
  • apps/ccusage/test/snapshots/cli-output/opencode-direct-daily-json.txt
  • apps/ccusage/test/snapshots/cli-output/session-table.txt
  • apps/codex/package.json
  • apps/codex/src/_shared-args.ts
  • apps/codex/src/commands/daily.ts
  • apps/codex/src/commands/monthly.ts
  • apps/codex/src/commands/session.ts
  • apps/opencode/package.json
  • apps/opencode/src/commands/daily.ts
  • apps/opencode/src/commands/monthly.ts
  • apps/opencode/src/commands/session.ts
  • apps/opencode/src/commands/weekly.ts
  • apps/pi/package.json
  • apps/pi/src/commands/daily.ts
  • apps/pi/src/commands/monthly.ts
  • apps/pi/src/commands/session.ts
  • packages/internal/package.json
  • packages/internal/src/colors.ts
  • packages/internal/src/logger.ts
  • packages/terminal/CLAUDE.md
  • packages/terminal/package.json
  • packages/terminal/src/table.ts
  • plan.md
💤 Files with no reviewable changes (1)
  • apps/ccusage/package.json
✅ Files skipped from review due to trivial changes (10)
  • apps/ccusage/test/snapshots/cli-output/all-agent-daily-json.txt
  • packages/terminal/CLAUDE.md
  • apps/ccusage/test/snapshots/cli-output/codex-direct-daily-json.txt
  • apps/ccusage/test/snapshots/cli-output/amp-direct-compact-table.txt
  • apps/ccusage/test/snapshots/cli-output/opencode-direct-daily-json.txt
  • apps/ccusage/test/snapshots/cli-output/amp-direct-full-table.txt
  • apps/ccusage/test/snapshots/cli-output/amp-direct-daily-json.txt
  • apps/ccusage/src/_shared-args.ts
  • apps/ccusage/test/snapshots/cli-output/session-table.txt
  • apps/ccusage/test/snapshots/cli-output/daily-table.txt
🚧 Files skipped from review as they are similar to previous changes (8)
  • apps/amp/package.json
  • packages/internal/package.json
  • apps/opencode/src/commands/session.ts
  • apps/codex/src/_shared-args.ts
  • apps/opencode/src/commands/weekly.ts
  • apps/ccusage/src/commands/statusline.ts
  • apps/pi/package.json
  • apps/opencode/src/commands/monthly.ts

Comment thread packages/terminal/package.json Outdated
Comment thread packages/terminal/src/table.ts Outdated
Add TTY-only per-agent progress indicators while the all report loads agent logs. JSON output keeps suppressing progress and logger output so automation receives clean structured data.

The all command now detects visible agents once before rendering, reuses that set for table loading, and reports row counts before the responsive table is printed.
@ryoppippi
Copy link
Copy Markdown
Owner Author

@coderabbitai review
@cubic-dev-ai review

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented May 15, 2026

@coderabbitai review
@cubic-dev-ai review

@ryoppippi I have started the AI code review. It will take a few minutes to complete.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

@ryoppippi Sure, I'll review the changes in this PR!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 15, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpicospinner@​3.0.09910010080100

View full report

Use compact headers as the single compact-mode predicate and synthesize left alignment when compact column alignments are omitted. This prevents rows from being compact-filtered while full headers remain active.

Move @ccusage/internal to terminal devDependencies to match the bundled workspace dependency policy.
@ryoppippi
Copy link
Copy Markdown
Owner Author

@coderabbitai review
@cubic-dev-ai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

@ryoppippi Sure, I'll review the changes in this PR!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented May 15, 2026

@coderabbitai review
@cubic-dev-ai review

@ryoppippi I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/terminal/package.json (1)

17-20: ⚡ Quick win

Consider moving remaining dependencies to devDependencies per repo guidelines.

The coding guideline states that dependencies should always be added as devDependencies unless explicitly requested otherwise. While @ccusage/internal was correctly moved to devDependencies in this PR, two dependencies remain in the dependencies block:

  • @oxc-project/runtime (catalog:build)
  • ansi-escapes (catalog:runtime)

Since this is a private package that exports TypeScript source files and follows a bundled workspace dependency policy, consider moving these to devDependencies in a follow-up change for full guideline compliance.

As per coding guidelines: "**/package.json: Dependencies should always be added as devDependencies unless explicitly requested otherwise."

🤖 Prompt for 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.

In `@packages/terminal/package.json` around lines 17 - 20, The package.json
currently lists `@oxc-project/runtime` and ansi-escapes under "dependencies"; move
these two entries into "devDependencies" to comply with the repo guideline that
non-runtime/private workspace packages be declared as devDependencies—update the
"dependencies" object to remove "@oxc-project/runtime" and "ansi-escapes" and
add them (with the same version specs "catalog:build" and "catalog:runtime") to
the "devDependencies" object in the same package.json so tools/readers can find
them under devDependencies.
🤖 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.

Nitpick comments:
In `@packages/terminal/package.json`:
- Around line 17-20: The package.json currently lists `@oxc-project/runtime` and
ansi-escapes under "dependencies"; move these two entries into "devDependencies"
to comply with the repo guideline that non-runtime/private workspace packages be
declared as devDependencies—update the "dependencies" object to remove
"@oxc-project/runtime" and "ansi-escapes" and add them (with the same version
specs "catalog:build" and "catalog:runtime") to the "devDependencies" object in
the same package.json so tools/readers can find them under devDependencies.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 883c1ce3-b402-4a1d-a6a7-2ea6f41d331b

📥 Commits

Reviewing files that changed from the base of the PR and between e44e5f7 and ebfc4cc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • packages/terminal/package.json
  • packages/terminal/src/table.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/terminal/src/table.ts

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/terminal/package.json">

<violation number="1" location="packages/terminal/package.json:22">
P2: `@ccusage/internal` is used by exported runtime code, so it should remain a regular dependency instead of a devDependency.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic
Re-trigger cubic

Comment thread packages/terminal/package.json
@ryoppippi ryoppippi merged commit f89c419 into main May 16, 2026
22 of 23 checks passed
@ryoppippi ryoppippi deleted the feat/consolidate-agent-usage branch May 16, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant