# dsh-opencode-go-usage-compact A collapsible **OpenCode GO** usage widget for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness). This is a modified fork of [`@astervolans/dsh-opencode-go-usage`](https://github.com/Astervolans/dsh-opencode-go-usage) `1.5.0` (itself a fork of [`yumusb/dsh-opencode-go-usage`](https://github.com/yumusb/dsh-opencode-go-usage)). It keeps the same usage source, same-origin proxy, `/opencode-go` command and `x-opencode-session` fix, and turns the sidebar footer into a collapsible one-line widget. [中文](README.md) ## Screenshots | Collapsed (default) | Expanded | |---|---| | ![Collapsed](docs/assets/collapsed.png) | ![Expanded](docs/assets/expanded.png) | - **Collapsed**: one line with all three percentages; the arrow sits in the middle of the divider and has no box. - **Expanded**: 5-hour / weekly / monthly quota bars, time-progress bars and reset countdowns. - The arrow points down when expanded and up when collapsed; clicking the arrow or the title row toggles it. - The state is persisted in `localStorage` and survives reloads. ## Features - Persistent sidebar-footer widget, collapsed by default; no workspace height cost - 5h / weekly / monthly quota percentages, time progress and reset time - **Same-origin proxy**: the host calls `https://opencode.ai/zen/go/v1/usage`; the browser only sees `/opencode-go/usage`, and the API key never enters the frontend - `/opencode-go` chat command with the same numbers as text - Runtime `x-opencode-session` injection, fixing OpenCode GO's `400 MissingSessionID` - Chinese / English follows the DSH UI language and switches live - No npm update check; updates come from GitHub ## Install Requires DSH `0.1.7` or newer (including `0.2.x`); verified on `0.2.1-rc.2`. Remove the original plugin first if it is installed, so both do not fight over the same usage route and `/opencode-go` command and show two widgets: ```bash dsh plugin --profile desktop remove @astervolans/dsh-opencode-go-usage ``` Then install this repository: ```bash dsh plugin --profile desktop add github:zhufei1000/dsh-opencode-go-usage-compact ``` Fully quit and reopen DSH. Web users should restart `dsh web` and refresh the page. For the **web profile**, replace `desktop` with `web`. The API key still comes from the DSH credential `OPENCODE_GO_API_KEY`; no extra configuration is needed. To set it: ```yaml OPENCODE_GO_API_KEY: sk-... ``` in `~/.dsh/.credentials.yaml`, or export `OPENCODE_GO_API_KEY`. ## Configuration Settings → Plugins → Plugin configuration. All fields are volatile and hot-apply: | Key | Default | Description | |---|---|---| | `apiKeyEnv` | `OPENCODE_GO_API_KEY` | credential reference for the API key | | `baseUrl` | `https://opencode.ai/zen/go` | OpenCode GO gateway base | | `cacheMs` | `30000` | host-side usage cache TTL | | `injectSessionHeader` | `true` | inject `x-opencode-session` into OpenCode GO requests | ## Differences from upstream 1.5.0 - Collapsible sidebar-footer widget; collapsed mode is one line - The handle is a bare arrow in a gap in the divider — no pill, border or background - Chinese compact labels use 「五小时 / 周 / 月」 so the Arabic `5` does not look smaller than the CJK labels - Host fix: `Request` inputs were stringified as `[object Request]`, so the session header was skipped - Preserve existing `Request` headers when injecting the session header - The title row no longer duplicates `role="button"`; the arrow is the single semantic control - The 30-second time-bar tick only runs while expanded - localStorage write moved out of the `setOpen` updater - Compact mode shows `—` instead of the loading text when data loaded but no windows are present - npm update check removed (distribution is via GitHub) See [CHANGELOG.md](CHANGELOG.md). ## Compatibility - DSH: `>=0.1.7-rc.1 <0.3.0` (peerDependencies) - Node.js: `>=18` - Verified on DSH `0.2.1-rc.2` If DSH's peer check rejects a version, explicitly allow it: ```bash dsh plugin --profile desktop allow-version dsh-opencode-go-usage-compact@1.5.1 --dsh-version --accept-risk ``` ## License MIT. This is a modified MIT project; see: - [LICENSE](LICENSE) - [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) Upstream copyright: Copyright (c) 2026 opencode-go-usage contributors. Fork modifications: Copyright (c) 2026 zhufei1000. `OpenCode GO` is an OpenCode product name; this project is not affiliated with OpenCode. ## Development `lib/client.js` is a hand-authored DSH client bundle (`window.__ModuleLoader__.load`); `lib/index.js` is the host half; `lib/opencode-session.js` handles session-header injection. There is no build step. ```bash node --check lib/index.js node --check lib/client.js node --check lib/opencode-session.js ```