DeepSeek Harness plugin

packages/dsh-opencode-usage

OpenCode Go plan usage floating pill: three-window consumption percentages (rolling/weekly/monthly) with mini area charts, backed by background sampling against the official /v1/usage API.

Jump to install

Source facts

Repository
wingsky-1/dsh-plugin-hub
Latest update
Aug 18, 2026
Category
Usage & Billing
GitHub stars
0

Install

Start with a prompt that asks an agent to read the source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to read the page and repository first.

Do not install anything yet. Read this DeepSeek Harness plugin and explain what it does, which files, networks, or credentials it can access, and how to install and remove it.

Plugin page: https://deepseekplugins.org/plugins/wingsky-1/dsh-plugin-hub~23packages~2Fdsh-opencode-usage
GitHub: https://github.com/wingsky-1/dsh-plugin-hub/tree/main/packages/dsh-opencode-usage
Plugin: dsh-plugin-hub#packages/dsh-opencode-usage
Author: wingsky-1
Install command: dsh plugin --profile web add @wingsky-1/dsh-opencode-usage

Do not run the install command until I confirm.

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer2 files
README.mdSource · read only

@wingsky-1/dsh-opencode-usage

DSH(DeepSeek Harness)Web GUI 插件:OpenCode Go 套餐用量悬浮框 + 三窗口迷你图

聊天界面右上角常驻悬浮胶囊,实时显示 OpenCode Go 套餐三窗口消耗百分比 (颜色随消耗程度变化:>80% 黄、>95% 红),点击展开详情面板:

  • 三张迷你图卡片(rolling 5 小时滚动 / weekly / monthly),各窗口独立自适应

y 轴与 x 轴时间刻度、100% 配额参考虚线、重置标记线(按 resetsAt 反推)

  • 后台采样保历史连续(浏览器关闭也持续),数据来自官方 /v1/usage 接口

(权威数据,零本地计算)

安装

dsh plugin --profile web add @wingsky-1/dsh-opencode-usage

安装后重启一次 dsh web

数据源

插件直接调用 OpenCode Go 官方用量接口:

GET https://opencode.ai/zen/go/v1/usage
Authorization: Bearer <OPENCODE_GO_API_KEY>

响应带 30 秒 TTL 缓存(可配置),避免高频请求。

API Key 解析顺序

1. 插件配置 config.apiKey(显式指定,可选) 2. 环境变量 OPENCODE_GO_API_KEY 3. DSH 凭据文件 <DSH_HOME>/.credentials.yaml(DSH_HOME 优先,默认 ~/.dsh) 中的 OPENCODE_GO_API_KEY 4. OpenCode 自身 ~/.local/share/opencode/auth.jsonopencode-go (回退 opencode)条目

配置

默认值含义
enabledtrue插件开关
baseUrlhttps://opencode.ai/zen/go/v1/usage用量接口地址(可配置,即 token 转发目标
timeoutMs15000请求超时(毫秒)
cacheTtlMs30000用量缓存 TTL(毫秒)
limits{rolling:12, weekly:30, monthly:60}展示用限额(美元/窗口)
apiKey显式 API Key(缺省走凭据解析链)
maxAgeDays14历史采样保留天数(1–365)
sampleIntervalMs300000宿主后台采样间隔(30s–1h)
persistFile<DSH_HOME>/dsh-opencode-usage/history.json历史采样落盘路径

路由(全部 loopback 围栏)

路由说明
GET /api/dsh-opencode-usage/stats用量统计(TTL 缓存)
GET /api/dsh-opencode-usage/history[?days=N]历史采样序列
GET /api/dsh-opencode-usage/health健康检查

安全与边界

  • token 不落盘、不落日志、不进浏览器端:API Key 仅存于宿主进程内存,

浏览器只经 /stats 拿百分比数值(src/index.ts 凭据解析链 + stats 路由 均不回传 token)

  • baseUrl 可配置 = 你的 token 会发送到该地址:仅配置可信的用量接口;

默认官方 https://opencode.ai/zen/go/v1/usage

  • 历史采样落盘 0600 权限(tmp + rename 原子写),目录默认

<DSH_HOME>/dsh-opencode-usage/

  • 所有路由 loopback 围栏(非回环 403 / 方法错 405)
  • 官方接口请求频率受控:GUI 轮询 ≤1 次/60 秒 + 后台采样 ≤1 次/5 分钟

(各另有 30s TTL 缓存抑制重复请求),不会限流

验证

# 健康检查(回环)
curl -s http://127.0.0.1:3080/api/dsh-opencode-usage/health

# 源码在 src/,改后必须 build
pnpm --filter @wingsky-1/dsh-opencode-usage build
node test/smoke.mjs

License

MIT