Repository navigation
feat(opencode): add CLI command to view Go usage limits - #32913
Closed
Nigmat-future wants to merge 1 commit into
Closed
Nigmat-future wants to merge 1 commit into
Nigmat-future wants to merge 1 commit into
Conversation
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.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This was referenced Aug 11, 2026
4 tasks
1 task done
Member
|
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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #9281
Type of change
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 anopencode usageCLI 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/usageendpoint (packages/console/app/src/routes/zen/go/v1/usage.ts). It authenticates via the sameAuthorization: Bearer <key>header used by the chat completions endpoint, queriesLiteTable/SubscriptionTable/BillingTable, and runs the existingSubscription.analyzeRollingUsage/analyzeWeeklyUsage/analyzeMonthlyUsagefunctions to compute usage percent and reset time for each window. Returns JSON withplan,windows[](name, status, usagePercent, resetInSec, used, limit), anduseBalance. Handles lite (Go), black, and free tiers.CLI side — new
opencode usagecommand (packages/opencode/src/cli/cmd/usage.ts). It resolves theopencodeprovider'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 inpackages/opencode/src/index.tsalongsidestats.How did you verify your code works?
KeyTablejoin) and reuses the sameSubscription.analyze*functions as the existing billing validation inhandler.ts.models.tsdoes viaProvider.Service.UI.Styleconstants (TEXT_DIM,TEXT_WARNING,TEXT_SUCCESS, etc.) used in the output formatter exist inpackages/opencode/src/cli/ui.ts.usage-cli), commit format (feat(opencode): …), and target branch (dev) conform toAGENTS.md.Screenshots / recordings
Example output:
Checklist