dsh-opencode-go-usage: Persistent OpenCode Go Plan Quota Indicator Above the DSH Input Box

Introduction

When integrating the OpenCode Go route in DeepSeek Harness (DSH), quotas are usually counted based on three windows: rolling, weekly, and monthly. The official interface doesn’t necessarily provide real-time percentage and reset times near the input area; one has to check the usage page or remember the API manually. dsh-opencode-go-usage is a client-side DSH plugin released by maintainer daydream-wjh: it fixes a row of readings above the chat input box, displaying the percent of the three windows and the reset countdown of the most recent window; after expanding, you can see progress bars and the provider’s status. Below is an introduction to its capabilities, installation methods, and implementation boundaries.

What is it

Plugin repository: daydream-wjh/dsh-opencode-go-usage, current package.json version is 0.1.3, license MIT. Classified as a DSH client (dsh.client.platform: "web"), the host side registers the local route, while the browser side only reads and renders that route without holding the API Key. Data comes from fields like percent in the upstream GET https://opencode.ai/zen/go/v1/usage, normalized by the host into rolling / weekly / monthly windows, and provided to the page via GET /opencode-go/usage.

What is displayed on the interface

When collapsed, it’s a one-line summary, example form:

● OpenCode Go 限额   滚动 4% · 周 1% · 月 0% · 3 小时 39 分后重置        ⟳  ▾

Brief explanation of meanings:

  1. The three percentages correspond to the rolling, weekly, and monthly windows.
  2. The countdown corresponds to the most recently resetting window (usually the rolling window); the client recalculates locally every 30 seconds (TICK_MS), so there’s no need to wait for the next network poll.
  3. The dot color is taken from the highest usage among the three: below 70% is normal color, ≥70% warning, ≥100% error.
  4. ⟳ triggers ?force=1 to skip the host’s 20-second cache and read immediately; ▾ expands details, and the expanded state is saved in the localStorage key dsh.opencode-go-usage.expanded.

After expanding, table rows show percentages for each window, progress bars, and “Resets in x days y hours” (hover to see specific time); the footer shows upstream status and the last read time. When no Key is configured, it shows a line of gray text with a hint and lists attempted credential names; network or upstream 5xx failures show the reason, and the next 60-second poll retries automatically.

On the new chat page with a hero layout and centered enlarged input box, this line stays attached to the top of the input box and is the same width. The plugin uses flex: 0 0 auto on the root node to avoid being compressed to about 9px in a narrowed composerStack causing text clipping; there is a corresponding regression in verify/client.test.mjs.

How the Host and Client divide responsibilities

Side File Responsibilities
Host lib/index.js Parse Key from credentials, request upstream, cache for 20 seconds, register GET /opencode-go/usage
Client lib/client.js Only requests the local route mentioned above and renders it

The API Key only exists in .credentials.yaml or the launch environment; browser scripts do not access opencode.ai across domains. The route belongs to the connection trust fence along with built-in web routes and is only readable on locally authenticated pages.

Common route contracts (when failing, HTTP is still 200 with ok: false, making it convenient for readout components to retry normally):

GET /opencode-go/usage            → { ok: true, windows: { rolling, weekly, monthly }, ref, fetchedAt }
GET /opencode-go/usage?force=1    → Same as above, skips cache
GET /opencode-go/usage?ref=NAME   → Specifies the credential slot first (whitelist), falls back to default name on failure

No Key found returns code: "no-key"; auth failure returns code: "auth"; upstream exceptions map to upstream / timeout / network / payload, etc.

Rough flow for one read: read once on mount, then poll every 60 seconds (POLL_MS), skip if page is in background, read again if returns to foreground after an interval > 60s; if cache is hit within 20s by host, return directly with cached: true; merge concurrent requests (inflight); only successful results go into cache, failures are not cached so the next round retries immediately.

Installation and enabling

The plugin runs with current DSH process permissions; it is recommended to browse the repository source code and MIT license before installing. Community directory page: skillhub.cn plugin entry.

1. Prepare the OpenCode Go API Key

Choose one of the two methods.

Settings Page (Recommended): After installing, open Settings → OpenCode Go, paste the Key and save. The page only returns {configured, source, masked}, not the Key itself; after saving, the reading above the input box will immediately re-read with the new Key.

Credentials or Environment Variables: The host parses OPENCODE_API_KEY, OPENCODE_GO_API_KEY in order—first credentials.resolve, then launchEnvironment.get. You can write to ~/.dsh/.credentials.yaml, or export OPENCODE_API_KEY=... before launching DSH (when launching from the Dock on desktop, shell exports are usually not available, so writing to credentials is better). For multiple accounts, you can use ?ref=... (whitelisted slot) on the route.

This plugin does not read or write OpenCode config files, it only recognizes the two credential names above.

2. Install into profile

Recommended command (from repository README):

dsh plugin add github:daydream-wjh/dsh-opencode-go-usage

The root cordis.patch.yml of the repository inserts the host entry; the client enters the browser bundle via exports["./client"] in package.json. Refresh the page after installation.

If you choose to manually place it in local-plugins and register it in cordis.patch.yml, choose one of these two methods to avoid registering the same id twice. After modifying lib/*.js, you need to restart DSH (the host does not watch JS files in local-plugins).

After installation, a quota row should appear above the input box; if you only see gray text “OpenCode Go API Key not found (tried OPENCODE_API_KEY / OPENCODE_GO_API_KEY)”, it means the plugin is loaded and you need to complete the Key configuration.

Uninstall:

dsh plugin remove dsh-opencode-go-usage

Except for the localStorage expanded state, the plugin does not make other persistent writes.

Optional Configuration

apply(ctx, config) supports two numbers (both have defaults):

Key Default Meaning
cacheMs 20000 Host side cache duration for the same read
timeoutMs 8000 Upstream request timeout, returns code: "timeout" on timeout

Verification and compatibility

Tests in repository:

node --test verify/route.test.mjs verify/client.test.mjs

verify/route.test.mjs covers host routes, caching, force=1, missing Key and error mapping; verify/client.test.mjs covers rendering and flex: 0 0 auto regression.

Target environment is DSH desktop web platform client; depends on webServer, connection, uses credentials / launchEnvironment as needed. Upstream is https://opencode.ai/zen/go, the usage API is not publically documented, and field changes may fall into code: "payload", but the component will not crash.

Conclusion

dsh-opencode-go-usage puts the OpenCode Go window usage and reset countdown at the top of the input box, keeps the Key on the host side, and the browser only reads the local /opencode-go/usage. It is suitable for people who use OpenCode Go for a long time in DSH and want to see the quota at a glance while writing prompts. Directory and source code:

  • https://www.skillhub.cn/plugins/daydream-wjh/dsh-opencode-go-usage
  • https://github.com/daydream-wjh/dsh-opencode-go-usage
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye