GeezerVison is showing github.com — feat(opencode): add CLI command to view Go usage limits by Nigmat-future · Pull Request #32913 · anomalyco/opencode
Conversation
Issue for this PR
Closes #9281
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Go subscribers currently only see their usage limits when they hit a 429 GoUsageLimitError — there's no way to check proactively. This adds an opencode usage CLI command so users can see how much of their 5-hour, weekly, and monthly quota is used at any time.
Server side — new GET /zen/go/v1/usage endpoint (packages/console/app/src/routes/zen/go/v1/usage.ts). It authenticates via the same Authorization: Bearer <key> header used by the chat completions endpoint, queries LiteTable / SubscriptionTable / BillingTable, and runs the existing Subscription.analyzeRollingUsage / analyzeWeeklyUsage / analyzeMonthlyUsage functions to compute usage percent and reset time for each window. Returns JSON with plan, windows[] (name, status, usagePercent, resetInSec, used, limit), and useBalance. Handles lite (Go), black, and free tiers.
CLI side — new opencode usage command (packages/opencode/src/cli/cmd/usage.ts). It resolves the opencode provider's API key and base URL from the loaded provider config, calls the usage endpoint, and prints a formatted summary with progress bars and reset countdowns. Registered in packages/opencode/src/index.ts alongside stats.
How did you verify your code works?
- Verified the endpoint follows the same auth pattern (
KeyTable join) and reuses the same Subscription.analyze* functions as the existing billing validation in handler.ts.
- Confirmed the CLI command resolves the provider key and API URL the same way
models.ts does via Provider.Service.
- Checked that
UI.Style constants (TEXT_DIM, TEXT_WARNING, TEXT_SUCCESS, etc.) used in the output formatter exist in packages/opencode/src/cli/ui.ts.
- Verified the branch name (
usage-cli), commit format (feat(opencode): …), and target branch (dev) conform to AGENTS.md.
Screenshots / recordings
Example output:
┌──────────────────────────────────────────────────────────┐
│ GO USAGE │
├──────────────────────────────────────────────────────────┤
│ Plan Go (Lite) │
│ Use Balance Off │
├──────────────────────────────────────────────────────────┤
│ ● 5-hour limit $8.42 / $12.00 70% ███████░░░ │
│ Resets in 2h 15m │
├──────────────────────────────────────────────────────────┤
│ ● Weekly limit $18.30 / $30.00 61% ██████░░░░ │
│ Resets in 3d 4h │
├──────────────────────────────────────────────────────────┤
│ ● Monthly limit $22.10 / $60.00 37% ███░░░░░░░ │
│ Resets in 12d │
└──────────────────────────────────────────────────────────┘
Manage your plan at https://opencode.ai/go
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
csanthiago, heyyouhere, and mvallebr reacted with thumbs up emoji
Add a new `opencode usage` command that lets users proactively check
their OpenCode Go subscription usage (5-hour, weekly, and monthly
limits) without having to hit a rate limit first.
Server-side: new GET /zen/go/v1/usage endpoint that authenticates
via the API key and returns current usage data with percentages and
reset times for each limit window.
CLI-side: new `opencode usage` command that calls the endpoint and
displays a formatted usage summary with progress bars.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 11, 2026
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.
— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|