Introduction¶
When using OpenCode Go to run DSH agents, the usage windows for 5-hour, weekly, and monthly quotas are often scattered across the account side, making them difficult to view directly in the chat interface. A more common issue is that the agent has already made a request, only to discover that the quota is nearly exhausted, causing the task to stall midway or wasting an invocation.
dsh-opencode-go-quota is a DSH Web persistent plugin. It places the OpenCode Go quota status near the chat input box and writes a one-time quota reminder into the system prompt when the agent request enters a new tier. Below, we introduce its features, installation, and common configurations.
What This Is¶
The repository is named dsh-opencode-go-quota, maintained by GLFzr, and licensed under MIT. It addresses two problems:
- Quickly viewing the current OpenCode Go quota remaining in DSH Web.
- Injecting a one-time quota reminder into agent requests as needed, avoiding repeated prompts within the same tier.
The plugin reads the local OpenCode Go key, calls the official API, and provides it to the browser side and prompt injection via DSH’s internal routing.
Core Features¶
Quota Ring Next to the Input Box¶
A 22px progress ring is displayed to the left of the model selector in the chat input box:
- The center shows
5 / W / M, which can be clicked to cycle through the 5-hour, weekly, and monthly usage windows. - Hovering displays the used percentage and reset countdown.
- Colors indicate urgency: green
<30%, blue30-60%, orange60-80%, red≥80%. - Auto-refreshes every 5 minutes.
- When switching windows by clicking, if the data is older than 1 minute, it forces a refresh.
- When the quota reaches
≥80%, the ring flashes red with a pulse effect and displays a pause suggestion.
System Prompt Injection¶
With each agent request, the plugin dynamically injects the current quota status into the system prompt. This injection occurs only once when entering a new tier; subsequent requests within the same tier will not repeat the injection.
When data is unavailable, the prompt injection is empty, and the ring displays a gray !. Hovering reveals the error reason. This preserves debugging information without adding invalid prompts to the conversation.
Data Reading and API Calls¶
The plugin reads on the Host side:
~/.local/share/opencode/auth.json
It extracts the opencode-go.key from this file. If the environment variable OPENCODE_GO_API_KEY is set, it takes precedence. The auth.json tolerates UTF-8 BOM; missing file, parsing failure, or missing key will each trigger separate errors.
The plugin then calls the official API:
GET https://opencode.ai/zen/go/v1/usage
using Bearer authentication.
The results are provided to the browser side and prompt injection via the following route:
/ocg-quota/usage
The response includes thresholds.
Configuration Options¶
These items can be configured in cordis.yml: warnAt, criticalAt, escalateFrom, escalateStep, cacheTtl, weeklyWarnAt, monthlyWarnAt. For example:
- id: dsh-opencode-go-quota
config:
warnAt: 60
criticalAt: 80
escalateFrom: 90
escalateStep: 2
cacheTtl: 60
weeklyWarnAt: 90
monthlyWarnAt: 95
Failed results are short-cached for errorCacheTtl seconds, defaulting to 5 seconds.
Installation and Enabling¶
- Install via GitHub:
dsh plugin --profile web add github:GLFzr/dsh-opencode-go-quota
- Or install from a local path:
dsh plugin --profile web add <absolute path to this directory>
- After installation, restart
dsh webfor the changes to take effect.
Uninstallation:
dsh plugin --profile web remove dsh-opencode-go-quota
Typical Usage¶
Fixing Windows workspaceRoot¶
The plugin requires the host shell to run subprocesses. DSH’s Windows ACL sandbox requires that sandbox-policy.workspaceRoot does not contain the system TEMP directory. Starting dsh web from locations like the user home directory may trigger this restriction.
You can fix the workspace root in ~/.dsh/profiles/<profile>/cordis.patch.yml:
- id: sandbox-policy
config:
workspaceRoot: <absolute path to your workspace>
Then restart dsh web. A temporary workaround is to start dsh web from within the target workspace directory.
Handling Key Not Found¶
If you see opencode-go key not found:
- Check if
~/.local/share/opencode/auth.jsonexists and containsopencode-go.key. - Or set the environment variable
OPENCODE_GO_API_KEY, then restartdsh web. - If
auth.jsonhas aUTF-8 BOMor is corrupted, it may also cause key retrieval to fail; version0.3.2and later tolerate BOM and distinguish errors.
Use Cases and Notes¶
This is suitable for developers who use OpenCode Go quota in DSH Web and need the agent to be aware of the quota tier. Before and after use, note:
- The plugin reads local credentials and calls
https://opencode.ai/zen/go/v1/usage, so it runs with the currentdshprocess permissions; it is recommended to review the source code and theMITlicense before installation. - Quota (money) and token usage are different things. This plugin answers “how much quota remains” and does not replace token accounting; it can be installed alongside
dsh-token-ledger, and the two are independent. - On Windows, starting from the user home directory makes it more likely to encounter ACL sandbox restrictions; it is better to fix the
workspaceRootfirst.
Conclusion¶
dsh-opencode-go-quota turns the 5-hour, weekly, and monthly OpenCode Go quotas into a ring next to the input box and injects a reminder when the agent request enters a new tier. For DSH use cases that require controlling invocation pace and task boundaries, this is a fairly straightforward auxiliary component.
Repository address:
https://github.com/GLFzr/dsh-opencode-go-quota