一个为 opencode.ai Zen 套餐提供实时用量与可用模型展示的 DeepSeek Harness(DSH) 动态插件。 A DeepSeek Harness (DSH) dynamic plugin that shows real-time opencode.ai Zen quota usage and available models.
-
Live quota & plan models (
host.js) Polls opencode.ai every 30s, reads the available models of the current plan and three usage windows 5h / 1w / 1m:- Usage:
GET https://opencode.ai/zen/go/v1/usage→{ usage: { rolling, weekly, monthly: { status, percent, resetsAt } } } - Models:
GET …/zen/go/v1/models(go family) /GET …/zen/v1/models(zen family) - API keys come from DSH
credentialsand never appear in any RPC payload.
- Usage:
-
Settings → Models rows (
client.js→ocu-models) Compact inline usage mini-bars (5h / 1w / 1m) + plan model count in the free space between the provider name and its action buttons; hovering a row shows a full usage card (reset times + available models). -
Context ring (ContextMeter) (
client.js→ocu-ring) When the active model belongs to an opencode provider:- Hover: the native tooltip is suppressed and replaced by a DSH-styled usage bubble above the ring.
- Click: the native panel stays, and the usage block is appended inside the panel's lower part (no layout reflow — space is reserved before the first paint via a
MutationObserver).
The progress bar color changes continuously with usage (green → amber → red via
color-mixon theme tokens, theme-aware), and the ring keeps its stock behaviour for non-opencode models.
-
实时用量与可用模型(
host.js) 每 30 秒轮询 opencode.ai,读取当前套餐的可模型列表与 5h / 1w / 1m 三档用量:- 用量:
GET https://opencode.ai/zen/go/v1/usage→{ usage: { rolling, weekly, monthly: { status, percent, resetsAt } } } - 模型:
GET …/zen/go/v1/models(go 系)/GET …/zen/v1/models(zen 系) - API key 经 DSH
credentials解析,不经过任何 RPC 返回。
- 用量:
-
“设置 → 模型”行内用量(
client.js→ocu-models) 在 provider 名称与操作按钮之间的空白处内联显示 5h / 1w / 1m 迷你用量条与套餐可用模型数; 悬停该行显示完整用量卡片(含重置时间与可用模型数)。 -
上下文圆圈(ContextMeter)(
client.js→ocu-ring) 当当前模型属于 opencode 系 Provider 时:- 悬停:抑制原生 tooltip,改为在上方显示 DSH 风格的用量气泡;
- 点击:保留原生面板,并把用量块追加进面板内部下方(用
MutationObserver在首帧绘制前占位,面板布局不重排)。
进度条颜色随用量连续渐变(绿 → 黄 → 红,基于主题 token 的
color-mix,明暗主题自适应); 非 opencode 模型时上下文保持原生行为不变。
DSH 动态插件仅在当前会话进程内生效(进程重启后丢失),应在 DSH GUI 中通过 Cordis 插件流程定义并运行。
# The plugin is distributed as host.js (Host half) + client.js (Client half).
# In DSH: define a dynamic plugin with the two halves below and run it.
# code.host = contents of host.js
# code.client = contents of client.jsPrereguisites / 前置条件:
- 本机可访问
https://opencode.ai。 curl.exe(Windows 自带)或curl,用于携带Authorization请求头(DSH 的web.fetch不允许自定义该头)。- 凭据写入
~/.dsh/.credentials.yaml:OPENCODE_GO_API_KEY/OPENCODE_API_KEY(或把 opencode 自身的~/.local/share/opencode/auth.json内容写入 DSH 凭据)。
针对 settings → llm-pi-ai.providers 中每一项,命中以下任一即为“opencode 系”:
- provider id 为
opencode/opencode-go; - 或
apiKeyEnv以OPENCODE开头; - 或
baseURL含opencode.ai。
无任何匹配时回退扫描 OPENCODE_GO_API_KEY / OPENCODE_API_KEY 两个标准环境变量名。
相同 key 的多个 Provider 只抓取一次。
| File | Role |
|---|---|
host.js |
Host half: polling fetch, snapshot cache, ocu/state RPC |
client.js |
Client half: models-page inline bars + ring hover/click overlays |
GitHub topics:deepseek-harness, deepseek, dsh, cordis, plugin, opencode, opencode-zen, llm, usage, javascript
MIT(如需其他协议,在 issue 中说明即可 / open an issue to request a change)。