dsh-token-dash 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -21,6 +21,8 @@
21
21
 
22
22
  - **未获明确授权不得改代码**。用户只要求“更新文档 / 记 issue / 完善设计 / 检查文档”时,仅可改 `docs/`、`AGENTS.md`、`README*`;禁止编辑 `client.js`、`index.js`、`src/`、`test/`、`scripts/`、`tools/`、`package.json`、`locale/`,也不得测试、打包或安装插件。
23
23
  - 代码实施需明确口令(“开始修改 / 可以改代码 / 执行 / 开始开发”);文档确认与代码实施分轮进行,不混在同一轮。
24
+ - **issue 文档必须先于代码**(强制顺序,无例外):任何带 issue 编号的改动,顺序固定为「先写 / 更新 issue 文档(现象、根因、期望、影响面、验收方式)→ 再改代码」。禁止先改代码再补 issue,也不允许把 issue 与代码写在同一次编辑里。
25
+ - issue 已终态(`[已修复]` / `[已放弃]`)后再次动手,必须先按 plan-workflow 的重开规则恢复非终态,再改代码。
24
26
  - plan / checklist 记录不等于实施授权;发现文档与代码不一致时先报告,未获授权不得顺手修。
25
27
 
26
28
  ## 3. 代码与架构约束
@@ -39,6 +41,7 @@
39
41
  - 同一时间只推进一个主 feature;优先恢复已有 plan,不新建重复计划。
40
42
  - 施工与走查用 `checklist` skill 维护 `docs/checklist/active/`(单层,不建项目域子目录);回写完成 + 用户明确指令后才归档。
41
43
  - 每次实现完成、测试通过或发布后,回写 plan 的 §3.0/§5 与 checklist 的阶段 / 测试 / 执行日志,避免状态只留在对话里。
44
+ - 固定落地顺序:**issue 文档 → 代码 → 测试 → 回写验收**。issue 段先落定现象 / 根因 / 期望 / 影响面 / 验收方式,代码只实现已写下的结论;实现中发现结论有误,先回改 issue 再继续改代码。
42
45
 
43
46
  ### 4.2 预览与原型
44
47
 
package/README.en.md CHANGED
@@ -30,24 +30,28 @@
30
30
 
31
31
  **Three entry points, one local ledger**: the composer-footer-right Pill shows the current model; the floating panel shows budget, balance and the usage table; the full dashboard shows every provider card and model breakdown. No duplicated accounting between pages.
32
32
 
33
- ## Provider matrix
34
-
35
- | Provider | Billing | Credential | What you get |
36
- |---|---|---|---|
37
- | DeepSeek | API usage | DS account wallet / `DEEPSEEK_API_KEY` | Balance, month-to-date spend, budget |
38
- | Zhipu GLM Coding | Subscription / API usage | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | 5h + weekly windows |
39
- | Kimi Coding | Subscription / API usage | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`, optional `MOONSHOT_API_KEY` | 5h + weekly/monthly windows; falls back to balance |
40
- | OpenRouter | API usage | `OPENROUTER_API_KEY` | Credits (USD) |
41
- | Qwen | API usage | `DASHSCOPE_API_KEY` (CNY) / `DASHSCOPE_INTL_API_KEY` (USD) | Usage only; balance unsupported |
42
- | OpenCode Go | Subscription | `OPENCODE_GO_API_KEY` | 5h / weekly / monthly windows (USD) |
43
- | Command Code | Subscription | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | 5h + weekly windows, credits (CNY) |
44
- | Ollama Cloud | API usage | `OLLAMA_API_KEY` | Plan + purchased credits (USD), plan usage, 30-day channel usage |
33
+ ## Supported API scope
34
+
35
+ Only the official endpoints listed below are called. Any other provider is still recorded (priced by model name) but gets no balance or quota card.
36
+
37
+ | Provider | Credential | Official endpoints called | Billing | What you get |
38
+ |---|---|---|---|---|
39
+ | DeepSeek | DS account wallet / `DEEPSEEK_API_KEY` | `GET api.deepseek.com/user/balance` | API usage | Balance, month-to-date spend, budget |
40
+ | Zhipu GLM Coding | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | `GET bigmodel.cn/api/monitor/usage/quota/limit` | Subscription / API usage | 5h + weekly windows |
41
+ | Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`, optional `MOONSHOT_API_KEY` | `GET api.kimi.com/coding/v1/usages`; falls back to `GET api.moonshot.cn/v1/users/me/balance` | Subscription / API usage | 5h + weekly/monthly windows; falls back to balance |
42
+ | OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API usage | Credits (USD) |
43
+ | Qwen | `DASHSCOPE_API_KEY` (CNY) / `DASHSCOPE_INTL_API_KEY` (USD) | No balance endpoint | API usage | Local usage only; balance unsupported |
44
+ | OpenCode Go | `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`, falls back to `GET opencode.ai/api/v1/usage` | Subscription | 5h / weekly / monthly windows (USD) |
45
+ | Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | `GET api.commandcode.ai/alpha/billing/credits` (with `orgId`) | Subscription | 5h + weekly windows, credits (CNY) |
46
+ | Ollama Cloud | `OLLAMA_API_KEY` | `GET ollama.com/api/balance`; `GET ollama.com/api/usage?range=30d` | API usage | Plan + purchased credits (USD), plan usage, cycle, 30-day channel usage |
47
+ | Any other provider (self-hosted, relay, local Ollama) | None | No endpoint | API usage | Priced by model name only; unpriced rows can be backfilled |
45
48
 
46
49
  - Save keys under the names above in DSH's credential settings; the plugin reads them through the host `credentials` service, not environment variables or local login files.
47
50
  - Ollama is added through DSH's custom OpenAI-compatible provider: the route id must be `ollama` (the key reference is derived as `<ROUTE>_API_KEY` → `OLLAMA_API_KEY`). Any other id will not resolve the key and the balance card will not appear.
48
51
  - Keys are detected automatically; GLM / Kimi / OpenCode Go / Command Code can be re-detected from the dashboard footer.
49
52
  - Subscription models count toward Tokens but not cost; billing mode is pinned per key instead of following quota flakiness.
50
53
  - Balance, quota and usage are separate; a balance failure never resets today's Token ledger to zero.
54
+ - **Not covered**: no cookies, no provider console scraping, no host config or local login state; balances come from official endpoints only, never through a relay; prices come from the community catalog and OpenRouter's public prices, not from provider bills, so every amount is a local estimate.
51
55
 
52
56
  ## Interface
53
57
 
@@ -80,7 +84,7 @@ Screenshots use mock data so the full layout is visible at once.
80
84
  - Subscription windows use three slots: first left, second center, third right; two windows occupy the first two slots.
81
85
  - Model column is capped at 150; Tokens / requests / hit rate are right-aligned.
82
86
 
83
- **P3 · Full dashboard**: cards for 8 providers, summary band, 8-column model breakdown and a settings capsule; the page owns its scrollbar at the window edge.
87
+ **P3 · Full dashboard**: cards for 8 providers, a four-cell summary (cost / real tokens / requests / cache hit rate), usage trend bars, 8-column model breakdown and a settings capsule; the page owns its scrollbar at the window edge.
84
88
 
85
89
  <p align="center">
86
90
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/settings.png" alt="Full dashboard" />
@@ -107,7 +111,7 @@ dsh plugin --profile desktop add github:spartawhy117/dsh-token-dash
107
111
  dsh plugin --profile desktop add /path/to/dsh-token-dash-x.y.z.tgz
108
112
  ```
109
113
 
110
- Update: run `update` with the same name, or use the `⤓` button on the right of “Pricing & version” in settings. Remove: run `remove` with the same name; data stays in `$DSH_HOME/dsh-token-dash/`.
114
+ Update: run `update` with the same name, or use the update button on the right of “Pricing & version” in settings. The plugin checks once at every DSH start and every 4 hours while running; when a new version exists the button shows the version number directly, so one click is enough. Remove: run `remove` with the same name; data stays in `$DSH_HOME/dsh-token-dash/`.
111
115
 
112
116
  > If the plugin disappears from the profile after a DSH 0.2.2 upgrade, reinstall the same tarball. The ledger and settings are not deleted with the plugin package.
113
117
 
@@ -117,7 +121,7 @@ Update: run `update` with the same name, or use the `⤓` button on the right of
117
121
  - The UI currently ships Chinese / English only. Other DSH languages (Japanese, German, Russian, etc.) fall back to English.
118
122
  - After a DSH upgrade the plugin may disappear from the profile; reinstall the same tarball — the ledger is not deleted.
119
123
  - Qwen tracks usage only; its balance endpoint is unsupported. Other balances/quotas follow what each API returns.
120
- - A USD-billed provider that only matches the CNY price table shows "Unpriced" with a reason instead of rendering CNY numbers as USD; add a `currency: "USD"` entry to `prefs.json` `priceOverrides` for exact amounts.
124
+ - A USD-billed provider that only matches the CNY price table shows "Unpriced" with a reason instead of rendering CNY numbers as USD.
121
125
  - Ollama's balance and usage endpoints share a 10 requests/minute limit; when rate limited the card keeps the last values with a "Rate limited" note and recovers automatically.
122
126
  - Upstream APIs are rate-limited; successful results are cached for 60s, failures for 10s, and concurrent requests are coalesced.
123
127
 
package/README.md CHANGED
@@ -30,24 +30,28 @@
30
30
 
31
31
  **三个入口,一份数据**:输入框底栏右侧 Pill 看当前模型;浮层看预算、余额与用量表;整页看 8 家供应商的全量卡片与模型明细。所有页面共用同一份本地账本,不重复计算。
32
32
 
33
- ## 支持矩阵
34
-
35
- | 供应商 | 计费形态 | 凭据 | 能看到什么 |
36
- |---|---|---|---|
37
- | DeepSeek | API 用量 | DS 账号钱包 / `DEEPSEEK_API_KEY` | 账户余额、本月已花、预算 |
38
- | Zhipu GLM Coding | 订阅 / API 用量 | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | 5h + 周窗口 |
39
- | Kimi Coding | 订阅 / API 用量 | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`,可选 `MOONSHOT_API_KEY` | 5h + 周/月窗口;订阅查询失败可回落余额 |
40
- | OpenRouter | API 用量 | `OPENROUTER_API_KEY` | Credits(USD) |
41
- | Qwen | API 用量 | `DASHSCOPE_API_KEY`(CNY)/ `DASHSCOPE_INTL_API_KEY`(USD) | 仅用量;余额不支持 |
42
- | OpenCode Go | 订阅 | `OPENCODE_GO_API_KEY` | 5h / 周 / 月窗口(USD) |
43
- | Command Code | 订阅 | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | 5h + 周窗口、Credits(CNY) |
44
- | Ollama Cloud | API 用量 | `OLLAMA_API_KEY` | 套餐剩余 + 购买余额(USD)、套餐已用、渠道 30 天用量 |
33
+ ## 支持的 API 范围
34
+
35
+ 只读取下表列出的官方接口;未列出的供应商仍可记账(按模型名计价),但没有余额/配额卡片。
36
+
37
+ | 供应商 | 支持的凭据 | 调用的官方接口 | 计费形态 | 展示内容 |
38
+ |---|---|---|---|---|
39
+ | DeepSeek | DS 账号钱包 / `DEEPSEEK_API_KEY` | `GET api.deepseek.com/user/balance` | API 用量 | 账户余额、本月已花、预算 |
40
+ | Zhipu GLM Coding | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | `GET bigmodel.cn/api/monitor/usage/quota/limit` | 订阅 / API 用量 | 5h + 周窗口 |
41
+ | Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`,可选 `MOONSHOT_API_KEY` | `GET api.kimi.com/coding/v1/usages`;回落 `GET api.moonshot.cn/v1/users/me/balance` | 订阅 / API 用量 | 5h + 周/月窗口;订阅查询失败可回落余额 |
42
+ | OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API 用量 | Credits(USD) |
43
+ | Qwen | `DASHSCOPE_API_KEY`(CNY)/ `DASHSCOPE_INTL_API_KEY`(USD) | 不请求余额接口 | API 用量 | 仅本地用量;余额不支持 |
44
+ | OpenCode Go | `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`,回落 `GET opencode.ai/api/v1/usage` | 订阅 | 5h / 周 / 月窗口(USD) |
45
+ | Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | `GET api.commandcode.ai/alpha/billing/credits`(带 `orgId`) | 订阅 | 5h + 周窗口、Credits(CNY) |
46
+ | Ollama Cloud | `OLLAMA_API_KEY` | `GET ollama.com/api/balance`;`GET ollama.com/api/usage?range=30d` | API 用量 | 套餐剩余 + 购买余额(USD)、套餐已用、周期、渠道 30 天用量 |
47
+ | 其他任意 provider(自建、中转、Ollama 本地) | 无需凭据 | 不请求任何接口 | API 用量 | 只按模型名计价;未定价可补算 |
45
48
 
46
49
  - 在 DSH 的凭据设置中按上表名称保存 Key;插件只通过宿主 `credentials` 读取,不读环境变量或本机登录文件。
47
50
  - Ollama 在 DSH 里需要用「自定义 OpenAI 兼容供应商」接入:route id 必须填 `ollama`(凭据按 `<ROUTE>_API_KEY` 派生成 `OLLAMA_API_KEY`),自定义名填别的会取不到 Key,余额卡也不会出现。
48
51
  - 填 Key 后自动探测;GLM / Kimi / OpenCode Go / Command Code 可在「全量看板」底部重新检测订阅。
49
52
  - 订阅模型计入 Tokens,但不计费用;计费形态按 Key 固化,不随配额接口抖动。
50
53
  - 余额、配额、用量分开展示;余额失败不会把当天的 Token 记账清零。
54
+ - **不覆盖**:不读 Cookie、不抓供应商控制台页面、不读宿主配置文件或本机登录态;余额只查官方接口,不经第三方中转;价格来自社区价目表与 OpenRouter 公开价,不来自供应商账单,金额均为本地估算。
51
55
 
52
56
  ## 界面
53
57
 
@@ -80,7 +84,7 @@
80
84
  - 订阅窗口固定三槽位:第 1 窗左、第 2 窗中、第 3 窗右;只有两窗时占前两个槽位。
81
85
  - 模型列上限 150,Tokens / 请求 / 命中右对齐;长模型名用省略号,悬浮可看全名。
82
86
 
83
- **P3 · 整页看板**:8 家供应商卡片、摘要带、8 列模型明细、底部设置胶囊;页面自己滚动,滚动条贴窗口右缘。
87
+ **P3 · 整页看板**:8 家供应商卡片、四格摘要带(总费用 / 真实 Tokens / 总请求数 / 缓存命中率)、用量趋势柱、8 列模型明细、底部设置胶囊;页面自己滚动,滚动条贴窗口右缘。
84
88
 
85
89
  <p align="center">
86
90
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/settings.png" alt="整页看板" />
@@ -106,7 +110,7 @@ dsh plugin --profile desktop add github:spartawhy117/dsh-token-dash
106
110
  dsh plugin --profile desktop add /path/to/dsh-token-dash-x.y.z.tgz
107
111
  ```
108
112
 
109
- 更新:`update` 同名命令(npm / github: 各自同名),或在插件设置页「价格与版本」右侧的 `⤓` 内完成。卸载:`remove` 同名命令,数据保留在 `$DSH_HOME/dsh-token-dash/`。
113
+ 更新:`update` 同名命令(npm / github: 各自同名),或在插件设置页「价格与版本」右侧的更新按钮内完成——每次启动 DSH 与运行中每 4 小时会自动检查,发现新版本时按钮直接显示版本号,点一下即可。卸载:`remove` 同名命令,数据保留在 `$DSH_HOME/dsh-token-dash/`。
110
114
 
111
115
  > DSH 0.2.2 升级后如果插件从 profile 消失,重装同一个 tarball 即可;账本与设置不随插件包删除。
112
116
 
@@ -116,7 +120,7 @@ dsh plugin --profile desktop add /path/to/dsh-token-dash-x.y.z.tgz
116
120
  - 界面语言当前仅中文 / English;选择日语、德语、俄语等其他 DSH 语言时,插件文案显示英文回退。
117
121
  - 升级 DSH 后插件可能从 profile 消失,重装同一个 tarball 即可,账本不会被删。
118
122
  - Qwen 只统计用量,余额接口不支持;其余供应商的余额/配额以接口实际返回为准。
119
- - 美元结算的供应商如果只命中人民币价目表,该模型会显示「未定价」并给出原因(不会把人民币数值当成美元);需要更精确的金额时,可在 `prefs.json` 的 `priceOverrides` 里按 `currency: "USD"` 补单价。
123
+ - 美元结算的供应商如果只命中人民币价目表,该模型会显示「未定价」并给出原因,不会把人民币数值当成美元。
120
124
  - Ollama 的余额与用量接口共享 10 次/分钟限流;触发限流时卡片保留上次数值并标「限流中」,恢复后自动更新。
121
125
  - 上游接口有速率限制;成功结果缓存 60s、失败结果缓存 10s,并发请求会合并。
122
126