build: update gunshi to 0.31#1040
Conversation
Update gunshi and @gunshi/docs to 0.31.0 so ccusage uses the latest CLI API and bundled Gunshi docs. Adapt command typings to GunshiParams-based Command generics introduced after 0.27, and use Gunshi nested subCommands for agent report namespaces instead of rewriting agent/report arguments to flat internal command keys. Gunshi 0.31 requires Node.js >=22; ccusage already requires Node >=22.11.0, so this stays within the package engine range.
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughRefactors the ccusage CLI from flat ChangesGunshi CLI Refactor to Nested Subcommands
Sequence DiagramsequenceDiagram
participant CLI as CLI Invocation
participant Agent as Agent Root Command
participant Report as Report Subcommand
participant Config as withCcusageConfig
participant Run as Command run()
CLI->>Agent: invoke agent (e.g., codex)
Agent->>Report: dispatch to report subcommand (e.g., daily)
Report->>Config: execute wrapped command
Config->>Config: load config and merge CLI args
Config->>Run: invoke report.run() with merged values
Run->>Run: execute report logic
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 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 docstrings
🧪 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 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | efc1cf2 | Commit Preview URL Branch Preview URL |
May 17 2026, 07:11 PM |
commit: |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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. |
Switch the ccusage package ESLint preset to app mode now that the package is used as the bundled CLI rather than a library surface. This lets direct define() command factories keep Gunshi inferred command types instead of carrying redundant explicit GunshiCommand return annotations. Keep the explicit GunshiCommand helper only at the config wrapper boundary where the wrapper adds a config argument and forwards a merged context to another command runner. Also update the repo-local Gunshi TypeScript guidance so future command factories do not reintroduce unnecessary return annotations.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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/commands/index.ts`:
- Around line 160-192: Top-level agent entries (codex/opencode/amp/pi) are wired
to the daily leaf runners (codexDailyCommand, opencodeDailyCommand,
ampDailyCommand, piDailyCommand) so invoking e.g. "ccusage codex" immediately
runs the report; change this by either replacing those bindings with a dedicated
parent command that only declares subcommands (no run handler) or by adding an
omitted-guard in the existing handlers: inside withCcusageConfig or inside each
of codexDailyCommand/opencodeDailyCommand/ampDailyCommand/piDailyCommand check
ctx.omitted (or equivalent) and only delegate to the daily runner when a
subcommand was provided, otherwise return/print help; update references where
withCommandName(withSubCommands(...), 'codex'|'opencode'|'amp'|'pi') is created
so the parent no longer unconditionally executes the daily run.
🪄 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: e4aa7490-131f-4b38-a980-5924ec04255d
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
apps/ccusage/scripts/generate-json-schema.tsapps/ccusage/src/commands/agent.tsapps/ccusage/src/commands/all.tsapps/ccusage/src/commands/codex.tsapps/ccusage/src/commands/index.tspnpm-workspace.yaml
Remove the reusable GunshiCommand alias and direct SubCommandable imports from the nested command wiring and schema generator. The config wrapper now keeps inference through define() and uses only a local replay cast at the runner adapter boundary. The TypeScript skill now records the rule as guidance instead of teaching agents to copy a concrete Command helper type.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Exercise ccusage codex without an explicit report so the CLI test suite documents that agent namespaces keep the existing daily default while using Gunshi nested subcommands.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
# Conflicts: # pnpm-lock.yaml # pnpm-workspace.yaml
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Keep the pre-nested agent:report command names working by normalizing them to the new Gunshi nested command path before validation and dispatch. This avoids a CLI compatibility regression for users who invoked the old flat subcommand names directly while retaining the documented ccusage <agent> <report> interface.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Use typos accepted wording in the compatibility comment added for legacy agent command aliases.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Version check
Validation
Summary by cubic
Upgraded
gunshiand@gunshi/docsto 0.31.0, moved agent reports to nested subCommands with adailydefault, and kept legacyagent:reportaliases working. This also simplifies command typing via inference and keeps config schema generation aligned.Bug Fixes
agent:reportinvocations to nested commands (e.g.,codex:monthly->codex monthly) to avoid a CLI compatibility break.Refactors
subCommands; removed argument rewriting and replaced it with a small pre-dispatch normalizer only for legacy colon aliases.GunshiCommandalias; the config wrapper usesdefine(...)with a local cast at the boundary.subCommands(Map/Object) and emit per-agent report schemas.Written for commit efc1cf2. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
New Features
ccusage codex daily) instead of flatagent:reportnames.Behavior Changes
codex:monthly) are accepted and normalized to the new nested form.Documentation
Tests
Dependencies