Repository navigation
Description
Add OpenCode Go (opencode.ai/zen/go) provider with live quota windows
TL;DR: Add a new telemetry provider that surfaces the live 5-hour and weekly usage windows plus the monthly USD credit balance for OpenCode Go subscriptions (Go $10/month) via the same Bearer API key the user already uses for /zen/go/v1/models.
Why
OpenCode Go is a $10/month coding-agent subscription with usage-windowed plans. From opencode.ai/docs/go/:
- 5-hour limit — $12 of usage
- Weekly limit — $30 of usage
- Monthly limit — $60 of usage
Users on Go today have no read-only way to surface their live quota in their DankBar without opening the Zen web console — same UX gap that motivated the merged Command Code provider (#21).
Proposed data source
Two endpoints under https://opencode.ai/zen/go/v1/, both authenticated with the same Bearer API key users already create in OpenCode Studio/Zen:
| Endpoint | Purpose | Stability |
|---|---|---|
GET /zen/go/v1/usage |
live 5h + weekly + monthly usage windows | ✅ shipped in v1.18.17 (PR #16513, closes #16017) |
GET /zen/go/v1/models |
public, no-auth — auth-only fallback when /usage fails | ✅ documented at opencode.ai/docs/zen |
The Bearer key is the same one users paste into DMS for any other OpenCode Zen provider — no cookies, no dashboard scraping, no auth-file reads required (env var OPENCODE_API_KEY).
Live verification
I have verified the response shape against the merged endpoint code (packages/console/app/src/routes/zen/go/v1/usage.ts, commit b5caa022):
// GET /zen/go/v1/usage
{
"useBalance": false,
"rollingUsage": {
"status": "ok" | "rate-limited",
"resetInSec": 12345,
"usagePercent": 0-100
},
"weeklyUsage": { "status": "ok" | "rate-limited", "resetInSec": 12345, "usagePercent": 0-100 },
"monthlyUsage": { "status": "ok" | "rate-limited", "resetInSec": 12345, "usagePercent": 0-100 }
}The endpoint returns usagePercent directly (server-side computation from Subscription.analyzeRollingUsage etc.) — we don't need to know the cap values in the adapter, which sidesteps the limits-drift problem.
resetInSec is "seconds until reset" → maps cleanly to the existing resetsAt schema (now + resetInSec in ISO 8601 UTC).
Honest coverage level
Quota (primary: 5h remaining %, secondary: weekly remaining %, credits: monthly remaining %). Falls back to Auth / configured when /v1/usage is unreachable (network, key invalid, no Go subscription), with a clear note in the card that quota windows are unavailable. Never fabricates a percentage — only renders what the API returned.
Error semantics (from usage.ts)
- 401 +
AuthError: "Missing API key."or"Unauthorized"→ key invalid/missing - 403 +
EntitlementError: "OpenCode Go subscription required."→ key valid but no Go plan - Any 5xx or network failure → fall back to
/v1/modelsfor auth-only check (mirrors Command Code's/provider/v1/modelsfallback)
Why this differs from scraping precedents
Unlike CodexBar's earlier rejection of a Command Code scraping approach (steipete/CodexBar#2629), OpenCode ships an official Bearer-authenticated usage endpoint. No cookies, no auth-file reads, no HTML scraping. The implementation is a 1:1 structural parallel to the merged Command Code provider (#21).
Implementation outline
Mirrors the existing fetch_commandcode_native structure:
providers/get-opencode-usage→ dispatches via the existingget-provider-wrapperfetch_opencode_nativereadsOPENCODE_API_KEY, tries/zen/go/v1/usage, falls back to/zen/go/v1/modelsfor auth-only on alpha failure- Widget/Settings/docs updates identical in shape to the Command Code entry, with primary = 5h, secondary = weekly, credits = monthly USD balance
- Provider ID stays
opencode(already inavailableProviderOptions) — only the display name isOpenCode Goand the mode changes frominformationaltotelemetry
Plan limits (for documentation only — not used by adapter)
- 5h: $12 of usage
- Weekly: $30 of usage
- Monthly: $60 of usage
- Subscription: $10/month
Questions for maintainers
- Comfortable with the v1.18.17 dependency? (stable since the merge; documented at
opencode.ai/docs/go.) - Preferred provider display name —
OpenCode Go(matches the plan name) vsOpenCode Zen GovsOpenCode (Go plan)? - Logo — reuse the existing
assets/provider-logos/opencode.svg(it currently represents the free OSS client) or want a dedicatedopencode-go.svg?
Happy to iterate on the PR per feedback before merge. The PR will be ready alongside this issue so you can review end-to-end.
Activity