OpenCode Go balance pill at the right end of the composer tool row: rolling/weekly/monthly quota remaining straight from the Zen usage endpoint, with hover detail and warn/danger coloring.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-go-balance
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:iamfromchangsha/dsh-go-balance
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
Live OpenCode Go subscription balance for DeepSeek Harness (DSH) Web UI: a pill at the right end of the composer tool row showing the rolling / weekly / monthly quota remaining, straight from the same OpenCode Zen usage endpoint the Go dashboard reads — no estimation.
Features
- Real balance, not an estimate — polls
https://opencode.ai/zen/go/v1/usagewith your Go API key and renders the exact same numbers as the Go dashboard. - Compact pill —
Go 96% · 94% · 97%(rolling / weekly / monthly remaining), right before the send button. - Hover detail — used percent, reset time of each window, and data freshness in the tooltip.
- Warn / danger coloring — the pill turns yellow when any window is below 30% remaining, red below 15%.
- Resilient — a failed refresh keeps the last known snapshot, dimmed and marked stale; the pill hides entirely while nothing is known (e.g. the credential is not configured).
- Credential-safe — the API key is resolved at runtime from the DSH credential service (
OPENCODE_ZERO_API_KEY) and never leaves the host process; no key is stored in this repository or shipped to the browser.
Screenshots



Install
dsh plugin --profile web add dsh-go-balance
Then restart DSH (dsh web). The plugin appends itself to the profile bundle layer automatically; nothing else to configure.
Alternatively, install straight from this repository:
dsh plugin --profile web add github:iamfromchangsha/dsh-go-balance
For a local checkout:
# from the plugin repo
dsh plugin --profile web add file:./ # relative file spec, anchored to your cwd
Credential
The plugin reads the OpenCode Go API key from the DSH credential service under the reference OPENCODE_ZERO_API_KEY (your $DSH_HOME/.credentials.yaml or process environment). It is resolved per refresh inside the host process only.
Config
The bundle row exposes one optional key:
| Key | Default | Meaning |
|---|---|---|
intervalMs |
60000 |
How often the host re-polls the OpenCode Zen usage endpoint. |
Override it in the profile patch layer ($DSH_HOME/profiles/web/cordis.patch.yml):
- id: go-balance
config:
intervalMs: 120000
How it works
One npm package hosts both halves of the plugin:
- Host half (
lib/index.js) — thegoUsageservice: resolvesOPENCODE_ZERO_API_KEYthroughctx.credentials, polls the Zen usage endpoint on a timer (plus lazily when a request finds the cache older than 30s), validates the response shape, and serves the snapshot atGET /go-usage. - Browser half (
lib/client.js) — registers into theconversation.input.rightslot (right end of the composer tool row), re-reads/go-usageevery 60 seconds and whenever the tab becomes visible again.
Security & robustness
- Concurrency-deduped refresh — refresh calls share one in-flight promise, so the timer and lazy requests never pile up against the upstream API.
- Error hygiene & key safety — browser-facing errors carry only a
code(plus an optional HTTPstatus); internal details such as DNS failure messages go to the host log only, and any occurrence of the key in a log line is replaced with[REDACTED]. The key travels only asAuthorization: Bearer <key>to opencode.ai, lives in host process memory, and never touches disk, logs, or the/go-usageroute. - Route hardening — the DSH webServer enforces no auth of its own ("No TLS, auth, or origin policy"), so the loopback bind is the boundary;
/go-usageadditionally rejects browser cross-origin reads (non-loopbackOrigin→ 403) and applies an in-memory per-address rate limit of 120 requests/minute (429). The snapshot carries only quota percentages and reset times — never the key or any identity. - Range validation —
percentmust be a finite number in[0, 100]; malformed upstream values drop the whole snapshot and keep the last good one.
Development
node --check lib/index.js && node --check lib/client.js
lib/client.js is committed and shipped; no build step runs on install.
Limitations
- Requires an active OpenCode Go subscription and the
OPENCODE_ZERO_API_KEYcredential on the DSH host. - Web surface only (the slot it renders into is part of the DSH Web UI).
- The snapshot is a user-facing reference for the current account quota; it is not a billing record.
License
Links
More in this category
bowenliang123/dsh-context★ 1556
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 344
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 214
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 202
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 168
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 120
Personal center for DeepSeek Harness: cross-session usage statistics, per-model cost estimation, global custom instructions, a global font-size adjuster, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.