dsh-opencode-go-usage: Monitoring OpenCode Go Plan Quota in DSH Web GUI

Introduction

When writing code with Composer in DeepSeek Harness (DSH), the interface typically displays a context meter. If you also subscribe to OpenCode Go, the quota is divided into windows such as 5-hour rolling, weekly, and monthly. These figures are located in the official console, separate from the current conversation interface. Switching back and forth often leads to discovering the quota is nearly exhausted only when it is too late.

Below is an introduction to the community plugin dsh-opencode-go-usage (maintained by lccc233). It transforms the three OpenCode Go quota windows into three small rings positioned in the Composer dock, immediately to the right of the context meter, with hover-to-expand details. Classified as a “Workflow” plugin, it targets developers who chat daily within the DSH Web GUI and need to monitor their OpenCode Go usage.

What is this?

dsh-opencode-go-usage is a DSH Web GUI plugin that displays the quota usage of the OpenCode Go plan next to the chat input box (composer dock). It does not register tools, inject system prompts, or subscribe to session events, thereby adding no model-facing tokens and not affecting the KV cache.

The data source is the OpenCode official API GET https://opencode.ai/zen/go/v1/usage (Authorization: Bearer <key>). The Host side resolves the API Key via ctx.credentials and proxies the request upstream. The browser only polls a snapshot route on the local loopback, meaning the key never enters the browser.

Interface and Data Meaning

In compact mode, three 14px rings (2px stroke) are always visible, corresponding to 5h rolling / weekly / monthly respectively, with no text on the rings. The fill ratio represents the used percentage (percent) for that window, with the remainder being 100 − percent.

Color thresholds (from source materials):

  • Used <60%: Green
  • Used ≥60%: Amber
  • Used ≥85%: Red
  • No data: Gray ring
  • Upstream failure: All three rings turn red

Hovering, focusing, or clicking expands the details: a 6px progress bar for each window, displaying the remaining ratio, reset countdown, sampling time, and manual refresh button. The title and aria-label attributes for the rings and rows contain readable summaries (e.g., 5h rolling · 3% used (97 left · resets in 3h25m)).

Example upstream JSON structure (subject to official fields):

{ "usage": {
    "rolling": { "status": "ok", "percent": 3,  "resetsAt": "2026-10-02T16:18:57.800Z" },
    "weekly":  { "status": "ok", "percent": 1,  "resetsAt": "2026-10-05T00:00:00.000Z" },
    "monthly": { "status": "ok", "percent": 59, "resetsAt": "2026-10-11T12:22:02.000Z" } } }

Environment and Dependencies

Please ensure the following before installation:

  1. DSH 0.2.0-rc.2 (the version used for plugin development and verification), with the Web GUI profile (@deepseek-ai/dsh-web-app) enabled, and access to the conversation.composer.dock slot (provided by @deepseek-ai/dsh-client-ui-conversation).
  2. A valid OpenCode Go subscription and API Key. The default credential reference is OPENCODE_GO_API_KEY (same as the llm-pi-ai provider). This can be configured in Settings → Models, written to ~/.dsh/.credentials.yaml, or exported as an environment variable with the same name.
  3. Windows, macOS, or Linux. Node 22+ is required for development verification.

Installation and Activation

The DSH home directory defaults to ~/.dsh (or %USERPROFILE%\.dsh on Windows). Profiles are located at ~/.dsh/profiles/<name>/; the desktop Electron app uses the desktop profile, and the examples below follow this convention.

Regardless of the path, enabling the plugin requires three things:

  1. The profile can resolve the package: ~/.dsh/profiles/<name>/node_modules/dsh-opencode-go-usage exists (physical directory, junction, or symlink).
  2. The package is recorded in the dependencies of ~/.dsh/profiles/<name>/package.json.
  3. A corresponding Loader insert line exists in ~/.dsh/profiles/<name>/cordis.patch.yml.

Use UTF-8 without BOM when modifying package.json and patches; Windows PowerShell’s Set-Content -Encoding UTF8 may write a BOM, causing DSH to fail in parsing the JSON.

Restart DSH after completing these steps. Fresh packages do not enter the Loader graph during config hot-reload and must be loaded at startup.

First, place the repository where the profile can resolve it, then link it into node_modules:

git clone https://github.com/lccc233/dsh-opencode-go-usage.git ~/.dsh/plugins/dsh-opencode-go-usage

Windows (junction):

cmd /c mklink /J "%USERPROFILE%\.dsh\profiles\desktop\node_modules\dsh-opencode-go-usage" "%USERPROFILE%\.dsh\plugins\dsh-opencode-go-usage"

POSIX (symlink):

ln -s ~/.dsh/plugins/dsh-opencode-go-usage ~/.dsh/profiles/desktop/node_modules/dsh-opencode-go-usage

Register the dependency in ~/.dsh/profiles/desktop/package.json (path is relative to the profile directory):

{
  "name": "dsh-profile-desktop",
  "private": true,
  "dependencies": {
    "dsh-opencode-go-usage": "file:../../plugins/dsh-opencode-go-usage"
  }
}

Add the Loader line in ~/.dsh/profiles/desktop/cordis.patch.yml:

- insert:
    - id: opencode-go-usage
      name: "dsh-opencode-go-usage"
      config:
        apiKeyEnv: OPENCODE_GO_API_KEY
        endpoint: https://opencode.ai/zen/go/v1/usage
        refreshMs: 60000
        timeoutMs: 10000
        route: /opencode-go-usage/snapshot

Path B: Profile’s built-in plugin manager

If your environment has @deepseek-ai/dsh-plugin-manager deployed and the dsh CLI available, you can run this for non-desktop profiles:

dsh plugin --profile <name> add dsh-opencode-go-usage

This command handles dependency installation, bundle recording, and patch lines. Note: desktop profile cannot be managed this way (dsh plugin --profile desktop will be rejected); use Path A for desktop. This repository declares dsh.bundle.patch in package.json, which writes the same insert when installed as a bundle.

Path C: As a profile bundle

Add the package name to the profile’s package.json → dsh.profile.bundles. The repository’s bundled cordis.patch.yml will insert the Loader line:

{
  "dsh": { "profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app", "dsh-opencode-go-usage"] } }
}

The profile-level manually written line and the bundle-level use the same id: opencode-go-usage; profile-level config can override bundle-level config.

Configuration Options

Field Default Value Description
apiKeyEnv OPENCODE_GO_API_KEY Resolved via ctx.credentials on every refresh; falls back to the env var with the same name
apiKey — Plaintext Key (not recommended, will appear in patch)
endpoint https://opencode.ai/zen/go/v1/usage Quota API endpoint
refreshMs 60000 Cache duration; browser polls with the same interval
timeoutMs 10000 Timeout for single upstream request
route /opencode-go-usage/snapshot Local web service snapshot path

Verification and Daily Usage

After starting DSH, check the startup log for the dsh web: URL to find the port. First, use curl to confirm the Host half is loaded:

curl http://127.0.0.1:<port>/opencode-go-usage/snapshot/probe

The probe returns the plugin name, version (current package version 0.1.0), routes, and sampling time. A 404 indicates it is not loaded (wrong path, missing insert, or import failure).

Fetch the snapshot:

curl http://127.0.0.1:<port>/opencode-go-usage/snapshot

This returns the percent, resetsAt, and fields like stale, error for each window. Then, open the chat page in the Web GUI; three quota rings should appear to the right of the context meter in the Composer dock. Hover to see details.

To uninstall, remove the corresponding insert from cordis.patch.yml, remove the dependency from package.json, and delete the package from node_modules, then restart DSH (see the repository README for full steps).

Use Cases and Precautions

Suitable for: Developers already using Composer in DSH Web GUI (including desktop profile) who hold an OpenCode Go subscription and wish to observe the three quota windows in the same row as context usage.

Please note:

  • The plugin runs under the permissions of the current DSH process and calls the OpenCode quota API on your behalf. Before installation, read the GitHub Source Code and the MIT license to ensure the behavior meets your security policy.
  • The community directory SkillHub Plugin Page has no official affiliation with DeepSeek or HF (High-Flyer); the DSH ecosystem emphasizes “Everything is a plugin,” and directory sites are independent community indexes.
  • Refer to the README for version compatibility with DSH (development verified version 0.2.0-rc.2). If anomalies occur after upgrading DSH or the OpenCode API, compare against the lastError in probe/snapshot and the repository Issues.

Links

Through the steps above, you can attach the OpenCode Go rolling / weekly / monthly quotas next to the Composer without altering the conversation prompt, using color thresholds and hover details to avoid the issue of only discovering quota exhaustion when it happens.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye