dsh-ocgo-ring
OpenCode Go quota ring for DeepSeek Harness: three windows beside the composer context meter.
- Stars
- 0
- Language
- JavaScript
- Created
- Oct 22, 2026
- Updated
- Oct 22, 2026
Introduction
dsh-ocgo-ring
给 DeepSeek Harness 的 OpenCode Go 套餐余量环:常驻在输入框下方、上下文用量环的右侧(圆环 + 百分比),点击展开三个窗口的余量小浮窗,并可直接点选圆环显示哪一个。

功能
- 紧凑常驻:14px 圆环 + 百分比,紧挨 DSH 自带的上下文用量环右侧;圆环填充和数字都表示剩余(
100% − 已用)。 - 默认滚动窗口:默认显示 rolling(5 小时)窗口;点击圆环打开小浮窗。
- 三个窗口:浮窗里列出
滚动 / 每周 / 每月,每行显示余量百分比、4px 进度条和重置倒计时。 - 点选切换:点击任意一行即可切换圆环显示的窗口;选择写入
localStorage(键ocgo-ring.metric),刷新/重启后保留。 - rate-limited 提示:窗口进入限流状态时,圆环和行内数字使用琥珀色(
--dsw-alias-state-warn-primary)。 - 与上下文用量浮窗同款样式:复用同一套
useAnchoredPosition/useDismissOnOutsidePointer和 UI 令牌,面板位置、圆角、阴影、字号一致。 - API key 不出主机:浏览器只拿百分比;Host 端 60 秒缓存,多标签页不会重复请求上游。
安装
要求:DSH 0.2.1-rc.2 及以上(Web / Desktop),以及 OpenCode Go 订阅。
-
克隆仓库:
git clone https://github.com/LCspax/dsh-ocgo-ring.git -
把 OpenCode Go 的 API key 写进 DSH 凭据存储(
~/.dsh/.credentials.yaml):OPENCODE_GO_API_KEY: sk-... -
安装插件(仓库根目录就是插件包):
- DSH 桌面版:侧栏「插件」→「添加插件」→ 填本地目录的绝对路径;
- 或 CLI:
dsh plugin --profile <profile> add <path-to-repo>。
-
首次安装完成后重启一次 DSH(Host 路由需要重新加载),再刷新页面。
配置
当前为固定配置(改 index.js 顶部常量即可):
| 项 | 值 |
|---|---|
| 凭据引用 | OPENCODE_GO_API_KEY |
| 上游接口 | https://opencode.ai/zen/go/v1/usage |
| Host 缓存 | 60 秒 |
| 前端轮询 | 60 秒 |
| 同源路由 | GET /ocgo-ring/usage |
工作方式
DSH 浏览器
└─ client.js 注册到 conversation.composer.dock(order 1 → 上下文用量环右侧)
│ fetch('/ocgo-ring/usage') 每 60s
▼
DSH Host
└─ index.js 读 ctx.credentials('OPENCODE_GO_API_KEY')
│ GET https://opencode.ai/zen/go/v1/usage(缓存 60s)
▼
OpenCode Go
- 上游返回每个窗口的已用百分比;插件在浏览器端换算成余量。
client.js是手写的window.__ModuleLoader__.loadbundle(不依赖构建工具),改完 DSH 客户端会自动热重载(约 1 秒)。- Host 半改动需要重启 DSH 或触发一次重组。
目录结构
.
├── index.js # Host 半:同源代理路由
├── client.js # 浏览器半:圆环 + 浮窗
├── cordis.patch.yml # Loader 补丁
├── package.json
├── locale/
│ ├── zh.json # 插件标题 / 描述
│ └── en.json
├── icon.svg
└── docs/preview.png
开发
node --check index.js
node --check client.js
改 client.js 保存即可看到 DSH 页面热更新;改 index.js 需要重启 DSH。
已知限制
- 仅在 DSH 0.2.1-rc.2(Windows)上验证;依赖
conversation.composer.dock与@deepseek-ai/dsh-client-ui-primitives的公开接口。 - 上游接口字段若发生变化,浮窗会显示「暂时取不到用量」,圆环保持空环。
- 当前显示的是余量;若更习惯「已用」,改
remainingOf()及行内百分比即可。
隐私
- API key 只在 Host 进程内使用,从不下发到浏览器。
- 不采集遥测;插件只访问 OpenCode Go 的官方 usage 接口。
License
MIT © 2026 LCspax
English
A quota ring for the OpenCode Go plan, sitting right of DeepSeek Harness's own context meter under the composer: ring + percentage of remaining quota. Click the ring to open a small popover listing the rolling (5h), weekly, and monthly windows; click a row to choose which window the ring shows (persisted in localStorage). The host proxies GET /ocgo-ring/usage with OPENCODE_GO_API_KEY, caches for 60 s, and never exposes the key to the browser.
Requires DSH >= 0.2.1-rc.2. Clone, add OPENCODE_GO_API_KEY to ~/.dsh/.credentials.yaml, install the repo directory as a plugin, restart DSH once.