Introduction

DSH extends the Web interface through plugins. If you use an OpenCode Go subscription on DSH Web, dsh-go-balance displays the remaining percentages of the rolling, weekly, and monthly quota windows on the right side of the input toolbar, making it convenient to view your quota status near the input area.

What is this?

dsh-go-balance is a DSH Web plugin maintained by iamfromchangsha and licensed under MIT. It targets the DSH Web UI, showing an OpenCode Go subscription balance capsule at the right end of the input box toolbar.

Core Features

  • Displays the OpenCode Go subscription balance capsule on the right side of the DSH Web input toolbar, showing remaining percentages for rolling, weekly, and monthly windows.
  • Uses an API key to poll https://opencode.ai/zen/go/v1/usage to obtain quota remaining data.
  • Hovering displays the used percentage, reset times for each window, and the data update time.
  • Low balance alerts: Turns yellow if any window remaining is below 30%, and turns red if below 15%.
  • On refresh failure, retains the last snapshot and dims the indicator; does not render if credentials are not configured or no data exists yet.
  • The API key is parsed by the DSH Credentials Service at runtime and stays only within the host process; the repository does not contain the key and does not send it to the browser.
  • Includes concurrent deduplication, error sanitization, Origin protection, per-address 120 requests/minute rate limiting, and percent range validation.

Installation and Activation

First, confirm you have a valid OpenCode Go subscription and prepare the OPENCODE_ZERO_API_KEY credentials.

  1. Install the plugin:
dsh plugin --profile web add dsh-go-balance
  1. Restart DSH:
dsh web

After installation, the plugin is automatically added to the profile’s bundle layer without requiring additional configuration.

You can also install from the GitHub repository:

dsh plugin --profile web add github:iamfromchangsha/dsh-go-balance

Perform a local development directory installation from the plugin repository directory:

dsh plugin --profile web add file:./

Typical Usage

Configure credentials: Set OPENCODE_ZERO_API_KEY in $DSH_HOME/.credentials.yaml or as a process environment variable. The value here is your Go subscription API key.

After restarting DSH, open the Web interface. The balance capsule will appear on the right side of the input toolbar. Hovering over the capsule allows you to check the used percentage, reset times for each window, and the data update time.

If you need to override the polling interval, configure it in $DSH_HOME/profiles/web/cordis.patch.yml:

- id: go-balance
  config:
    intervalMs: 120000

intervalMs is used to override the polling interval, with the unit (milliseconds) indicated by the key name.

When developing or validating plugin files, you can execute:

node --check lib/index.js && node --check lib/client.js

lib/client.js is committed with the repository and published with the package; no build is required during installation.

Security and Runtime Boundaries

  • The API key is sent to opencode.ai only via Authorization: Bearer.
  • The API key exists only in the host process memory; it is not written to disk, logged, or exposed via /go-usage.
  • The DSH webServer defaults to binding only to the loopback interface.
  • /go-usage blocks cross-origin reading by browsers from non-loopback Origin, with per-address 120 requests/minute memory-based rate limiting.
  • The plugin performs range validation on percent.

Applicable Scenarios and Notes

Suitable for developers who use OpenCode Go subscriptions on DSH Web and want to quickly check remaining quota. Note the following before use:

  • Requires a valid OpenCode Go subscription and the OPENCODE_ZERO_API_KEY credential configured on the DSH host.
  • Only supports the Web interface, as the rendering slot belongs to the DSH Web UI.
  • Snapshots are user-facing account quota references, not billing records.
  • The plugin runs with the current DSH process permissions; check the source code, dependencies, and license before installation.
  • peerDependencies requirements:
  • react ^18.2.0
  • @deepseek-ai/cordis ^4.0.1
  • @deepseek-ai/dsh-credentials ^0.1.0-rc.6

Links

GitHub:
https://github.com/iamfromchangsha/dsh-go-balance