xinman100/dsh-opencode-go-usage-plus1

dsh-plugin-opencode-go

OpenCode Go 套餐用量与花费实时展示插件:配额进度(滚动/周/月)+ 滚动/每周/每月用量统计(含重置剩余时间、总 token、总费用),侧边栏悬停面板 + 设置页卡片,密钥零存储

包名
dsh-plugin-opencode-go
版本
0.3.0
许可证
MIT
最近更新
2026年8月16日

安装

此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗

⚙️ 配置

插件行配置

字段默认值说明
credentialRefOPENCODE_GO_API_KEY从 DSH 凭据服务解析的密钥名
baseUrlhttps://opencode.ai配额 API 基地址
refreshMs60000宿主轮询间隔(毫秒,下限 5000)

官方花费明细凭据(可选,仅需一次)

「日/月/累计」统计需要浏览器 auth Cookie(与 Xenia 的 dsh-opencode-go-usage 面板共用同一配置文件):

  1. 浏览器登录 opencode.ai → F12 → Application → Cookies → 复制 auth
  2. 打开 https://opencode.ai/workspace//usage,复制地址栏的 wrk_xxx
  3. 在设置页「OpenCode Go 用量」卡片粘贴两者 → 「保存并抓取」

凭据保存在 ~/.config/dsh-opencode-go-usage.json(仅本机)。未配置时配额功能不受影响。

插件行配置

字段默认值说明
credentialRefOPENCODE_GO_API_KEY从 DSH 凭据服务解析的密钥名
baseUrlhttps://opencode.ai配额 API 基地址
refreshMs60000宿主轮询间隔(毫秒,下限 5000)

GET /api/opencode-go/usage

本地快照(配额 + 统计):

{
  "ok": true,
  "usage": {                       // 配额(官方 zen/go/v1/usage)
    "rolling":  { "percent": 1, "status": "ok", "resetsAt": "..." },
    "weekly":   { "percent": 62, "status": "ok", "resetsAt": "..." },
    "monthly":  { "percent": 59, "status": "ok", "resetsAt": "..." }
  },
  "fetchedAt": 1755,
  "keySource": "file",
  "credentialRef": "OPENCODE_GO_API_KEY",
  "quotaSource": "dashboard",       // dashboard(仪表盘解析)| api(Bearer 兜底)
  "stats": {                        // 官方 usage.list 统计(未配置时为 null)
    "rolling": { "requests": 964, "cost": 1.52, "tokens": 327041613, "tokensInput": 1636221, "tokensOutput": 530041, "tokensReasoning": 0, "tokensCacheRead": 324600841, "tokensCacheWrite": 0 },
    "weekly":  { "requests": 7217, "cost": 13.21, "tokens": 1931414647, "tokensInput": 22044225, "tokensOutput": 5827537, "tokensReasoning": 0, "tokensCacheRead": 1901419885, "tokensCacheWrite": 0 },
    "monthly": { "requests": 11095, "cost": 23.29, "tokens": 2748490805, "tokensInput": 55002423, "tokensOutput": 9075425, "tokensReasoning": 0, "tokensCacheRead": 2681730957, "tokensCacheWrite": 0 },
    "total":   { "requests": 11147, "cost": 23.29, "tokens": 2752232540, "tokensInput": 55371480, "tokensOutput": 9109677, "tokensReasoning": 0, "tokensCacheRead": 2685735383, "tokensCacheWrite": 0 },
    "fetchedAt": 1755,
    "truncated": false,
    "skippedPages": 0,
    "records": 11147
  },
  "statsConfigured": true,
  "statsError": null               // { type, message }:NotConfigured / NoRecords / StatsError
}

GET /api/opencode-go/usage/config

{ "ok": true, "configured": true }

POST /api/opencode-go/usage/config

// body
{ "authCookie": "Fe26.2**...", "workspaceId": "wrk_xxx" }
// 立即返回;官方明细抓取在后台进行,卡片下一次轮询即可看到结果