iamfromchangsha/dsh-go-balance ↗★ 0
dsh-go-balance
OpenCode Go subscription balance widget for DeepSeek Harness Web: rolling/weekly/monthly quota remaining, shown at the right end of the composer tool row.
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:iamfromchangsha/dsh-go-balance说明文档
阅读完整 README ↗dsh-go-balance
给 DeepSeek Harness(DSH)Web 界面加一个 OpenCode Go 订阅余额小部件:在输入框工具行右侧(发送按钮旁)显示滚动 / 每周 / 每月三个配额窗口的剩余百分比,数据直接来自 OpenCode Zen 用量接口(Go 订阅仪表页同源),不是估算值。
功能
- 真实余额,非估算 — 用您的 Go API 密钥轮询
https://opencode.ai/zen/go/v1/usage,渲染与 Go 仪表页完全一致的数字。 - 紧凑胶囊 —
Go 96% · 94% · 97%(滚动 / 每周 / 每月剩余),位于发送按钮右侧。 - 悬停明细 — 已用百分比、各窗口重置时间、数据更新时间。
- 警示配色 — 任一窗口剩余低于 30% 变黄、低于 15% 变红。
- 容错 — 刷新失败保留上次快照并淡化标记;未配置凭据或尚无数据时不渲染。
- 凭据安全 — API 密钥运行时经 DSH 凭据服务解析(
OPENCODE_ZERO_API_KEY),只留在 host 进程内;本仓库不含任何密钥,也不会下发到浏览器。
安装
dsh plugin --profile web add dsh-go-balance
然后重启 DSH(dsh web)。插件会自动加入 profile 的 bundle 层,无需其他配置。
尚未发布 npm 包时,也可以直接从本仓库安装:
dsh plugin --profile web add github:iamfromchangsha/dsh-go-balance
本地开发目录安装:
# 在插件仓库目录下执行(相对路径锚定到当前目录)
dsh plugin --profile web add file:./
凭据
插件通过 DSH 凭据服务读取 OPENCODE_ZERO_API_KEY($DSH_HOME/.credentials.yaml 或进程环境变量,即您 Go 订阅的 API 密钥),每次刷新时在 host 进程内解析。
配置
bundle 行暴露一个可选键:
| 键 | 默认值 | 含义 |
|---|---|---|
intervalMs | 60000 | host 轮询 OpenCode Zen 用量接口的间隔(毫秒)。 |
在 profile 补丁层($DSH_HOME/profiles/web/cordis.patch.yml)覆盖:
- id: go-balance
config:
intervalMs: 120000
原理
一个 npm 包承载插件的两个半边:
- 节点半边(
lib/index.js)—goUsage服务:经ctx.credentials解析OPENCODE_ZERO_API_KEY,定时轮询 Zen 用量接口(请求发现缓存超过 30 秒也会顺手刷新),校验响应结构后在 提供快照。