zzh799/dsh-opencode-usage ↗★ 0
dsh-opencode-usage
OpenCode Zen + Go usage readout for the dsh web GUI: a composer button showing concentric rings (5h / weekly / monthly) that opens a usage panel.
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:zzh799/dsh-opencode-usage说明文档
阅读完整 README ↗dsh-opencode-usage
A dsh web GUI plugin that shows your OpenCode Zen balance and Go usage windows right in the composer tool row: a concentric-ring button (rolling 5h / weekly / monthly) that opens a usage panel.
- Host half (
src/index.ts→lib/index.js): resolves config from env vars and$DSH_HOME/ocgo-usage.json, fetches the opencode.ai SSR pages, and serves same-origin JSON endpoints with caching + failure cooldown. - Browser half (
src/client.tsx→lib/client.js): renders the concentric-ring composer button and usage panel, and the config editor (cookie values are only ever shown masked — the full cookie never leaves the host).
Features
- Rolling 5-hour / weekly / monthly usage rings on a single composer button
- Usage panel with window details and a manual refresh
- Built-in config editor in the panel (masked cookie tails only)
- Smart cookie normalization: paste the raw auth token, a full header, or anything in between
- Server-side cache (default 5 min) + 60 s failure cooldown so the poller never spams opencode.ai
- Optional peak-clock display (
showPeakClock)
Install
## Configuration
Priority: **env vars > config file (`$DSH_HOME/ocgo-usage.json`) > defaults.**
| Env var | Config file key | Default | Description |
| --- | --- | --- | --- |
| `OPENCODE_GO_COOKIE` | `cookie` | — | OpenCode Go session cookie (auto-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 TTL in seconds, clamped to `[60, 3600]` |
| `OPENCODE_GO_TIMEOUT_MS` | `timeoutMs` | `15000` | Fetch timeout in ms |
| — | `showPeakClock` | `false` | Show the peak-clock readout |
The cookie is **never logged**. You can also edit `cookie` / `workspaceID` /
`showPeakClock` from the panel's config editor; a successful write invalidates
the cache so the next poll uses the fresh values immediately.
Config file is written with `chmod 600`.