xinman100/dsh-opencode-go-usage-plus ↗★ 1
dsh-plugin-opencode-go
OpenCode Go 套餐用量与花费实时展示插件:配额进度(滚动/周/月)+ 滚动/每周/每月用量统计(含重置剩余时间、总 token、总费用),侧边栏悬停面板 + 设置页卡片,密钥零存储
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 README ↗⚙️ 配置
插件行配置
| 字段 | 默认值 | 说明 |
|---|---|---|
credentialRef | OPENCODE_GO_API_KEY | 从 DSH 凭据服务解析的密钥名 |
baseUrl | https://opencode.ai | 配额 API 基地址 |
refreshMs | 60000 | 宿主轮询间隔(毫秒,下限 5000) |
官方花费明细凭据(可选,仅需一次)
「日/月/累计」统计需要浏览器 auth Cookie(与 Xenia 的 dsh-opencode-go-usage 面板共用同一配置文件):
- 浏览器登录
opencode.ai→ F12 → Application → Cookies → 复制auth值 - 打开
https://opencode.ai/workspace//usage,复制地址栏的wrk_xxx - 在设置页「OpenCode Go 用量」卡片粘贴两者 → 「保存并抓取」
凭据保存在 ~/.config/dsh-opencode-go-usage.json(仅本机)。未配置时配额功能不受影响。
插件行配置
| 字段 | 默认值 | 说明 |
|---|---|---|
credentialRef | OPENCODE_GO_API_KEY | 从 DSH 凭据服务解析的密钥名 |
baseUrl | https://opencode.ai | 配额 API 基地址 |
refreshMs | 60000 | 宿主轮询间隔(毫秒,下限 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" }
// 立即返回;官方明细抓取在后台进行,卡片下一次轮询即可看到结果