Preface¶
The philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” When building agents locally or via APIs, it is necessary to track OpenCode Zen balance and Go usage windows in real time. dsh-opencode-usage is a Web GUI plugin that directly displays the OpenCode Zen balance and Go usage windows on the composer tool row. Through a concentric-circle button, you can view rolling 5-hour/weekly/monthly usage.
Plugin Positioning¶
- Plugin name:
dsh-opencode-usage - Maintainer:
zzh799 - Core value: In the DSH Web interface, view the OpenCode Zen balance and Go usage windows through the composer tool row.
Core Features¶
The plugin provides the following main capabilities:
- Ring chart display: Displays rolling 5-hour, weekly, and monthly usage windows on the composer button.
- Usage panel: Click the button to open a panel showing window details, with manual refresh support.
- Built-in configuration editing: The panel includes a configuration editor that only masks the tail of the cookie. The full cookie never leaves the host.
- Smart cookie normalization: Supports pasting a raw auth token, a complete header, or any intermediate content.
- Anti-abuse mechanism: Built-in server-side cache (5 minutes by default) and a 60-second failure cooldown to avoid frequent requests to opencode.ai.
- Optional peak clock: Can be enabled by setting
showPeakClockin the configuration.
Installation and Enabling¶
The plugin requires DSH’s webServer service.
dsh plugin --profile web add /path/to/dsh-opencode-usage
Configuration¶
Configuration priority is: environment variables > config file ($DSH_HOME/ocgo-usage.json) > default values.
Environment Variables and Configuration Items¶
| Environment Variable | Config File Key | Default Value | Description |
|---|---|---|---|
OPENCODE_GO_COOKIE |
cookie |
— | OpenCode Go session cookie (automatically normalized) |
OPENCODE_GO_WORKSPACE_ID |
workspaceID |
— | OpenCode workspace id |
OPENCODE_GO_BASE_URL |
baseUrl |
https://opencode.ai |
Provider base URL |
OPENCODE_GO_CACHE_TTL |
cacheTTL |
300 |
Cache duration, limited to [60, 3600] seconds |
OPENCODE_GO_TIMEOUT_MS |
timeoutMs |
15000 |
Request timeout |
| — | showPeakClock |
false |
Whether to display the peak clock |
Security and Permissions¶
- Cookie security: Cookies are never recorded or logged.
- File permissions: The config file is written using
chmod 600.
API Usage¶
The plugin provides same-origin JSON interfaces for invocation:
* GET /api/opencode-usage: Get the cached usage view.
* GET /api/opencode-usage/refresh: Force a new provider query.
* GET /api/opencode-usage/config: Get the masked configuration view.
* POST /api/opencode-usage/config: Write cookie / workspace / showPeakClock. After a successful write, the cache is immediately invalidated.
Applicable Scenarios and Notes¶
- This plugin runs with the permissions of the current DSH process. Please inspect the source code and license before installing.
- The plugin depends on the
webServerservice. If the Web interface is not enabled, the plugin will not work.
Conclusion¶
With this plugin, developers can directly view OpenCode resource consumption in the DSH Web interface without switching pages or using external tools for queries. For more details, refer to the GitHub repository.