dsh-token-dash 2.3.1 → 2.5.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/README.en.md CHANGED
@@ -41,13 +41,14 @@ Only the official endpoints listed below are called. Any other provider is still
41
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
42
  | OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API usage | Credits (USD) |
43
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) |
44
+ | OpenCode Go | `OPENCODE_API_KEY` / `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
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
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
47
  | Any other provider (self-hosted, relay, local Ollama) | None | No endpoint | API usage | Priced by model name only; unpriced rows can be backfilled |
48
48
 
49
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.
50
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.
51
+ - OpenCode Go reads `OPENCODE_API_KEY`, the same name pi-ai uses for its routes, so configuring the LLM route is enough; `OPENCODE_GO_API_KEY` remains accepted. The `<ROUTE>_API_KEY` derivation applies to custom providers only — built-in providers get their names from the pi-ai catalog.
51
52
  - Keys are detected automatically; GLM / Kimi / OpenCode Go / Command Code can be re-detected from the dashboard footer.
52
53
  - Subscription models count toward Tokens but not cost; billing mode is pinned per key instead of following quota flakiness.
53
54
  - Balance, quota and usage are separate; a balance failure never resets today's Token ledger to zero.
@@ -57,7 +58,7 @@ Only the official endpoints listed below are called. Any other provider is still
57
58
 
58
59
  Screenshots use mock data so the full layout is visible at once.
59
60
 
60
- **P1 · Composer footer-right Pill**: API usage / subscription variants; click to open, click outside, `×` or `Esc` to close.
61
+ **P1 · Composer footer-right Pill**: API usage / subscription variants; click to open, click outside, `×` or `Esc` to close. The API variant shows one line of budget ring + today's spend + real balance; the subscription variant shows a ring per window. Colour only signals alerts — a healthy state stays neutral.
61
62
 
62
63
  <p align="center">
63
64
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/pill-api.png" alt="API usage pill" />
@@ -84,14 +85,16 @@ Screenshots use mock data so the full layout is visible at once.
84
85
  - Subscription windows use three slots: first left, second center, third right; two windows occupy the first two slots.
85
86
  - Model column is capped at 150; Tokens / requests / hit rate are right-aligned.
86
87
 
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.
88
+ **P3 · Full dashboard**: cards for 8 providers, a four-cell summary (real tokens / cost / cache hit rate / requests), a metric-switchable trend chart (including the dual-currency, dual-axis cost view), a model breakdown with subscription estimates, and a settings capsule; the page owns its scrollbar at the window edge.
88
89
 
89
90
  <p align="center">
90
91
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/settings.png" alt="Full dashboard" />
91
92
  </p>
92
93
 
93
- - API usage card: budget input, planned balance, real balance, month-to-date spend; subscription card: one ring per window with remaining percentage and countdown.
94
- - Breakdown: model / Tokens / input / cache / output / requests / hit rate / cost; everything except the model column is right-aligned.
94
+ - API usage card: budget input, planned balance, real balance, month-to-date spend; subscription card: one ring per window with remaining percentage and countdown, plus an estimated monthly value when available; cards no longer carry a status line.
95
+ - Trend chart: the vertical axis takes its own column outside the plot, with three ticks that follow the selected metric; three grid lines line up with those ticks; the hit-rate axis is pinned to 100% at the top, and a single 0% day cannot drag its floor back to zero. With **two currencies** the cost metric switches to a **dual-axis, two-bar** layout — CNY on the left axis, USD on the right, each scaled to its own maximum, with a colour legend in the header.
96
+ - Total cost tile: includes subscription estimates alongside actual billing, captioned “{n} currencies · incl. estimates”.
97
+ - Breakdown: its own section heading, then model / Tokens / input / cache / output / requests / hit rate / cost; everything except the model column is right-aligned. Cost is always marked `≈` as a local estimate, and subscription rows show what those tokens would cost at API rates (or “not priced”, or `—` when no estimate exists).
95
98
  - Settings capsule: refresh interval + account-balance toggle; logs, export/import, price table and version below.
96
99
  - The settings section has an external "Settings and data" title above the capsule; the capsule itself keeps the refresh interval, logs/data controls and version row.
97
100
  - Spacing uses only 4 / 8 / 12 / 16 / 24 / 32; P2 and P3 share the same tokens.
package/README.md CHANGED
@@ -41,13 +41,14 @@
41
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
42
  | OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API 用量 | Credits(USD) |
43
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) |
44
+ | OpenCode Go | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`,回落 `GET opencode.ai/api/v1/usage` | 订阅 | 5h / 周 / 月窗口(USD) |
45
45
  | Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | `GET api.commandcode.ai/alpha/billing/credits`(带 `orgId`) | 订阅 | 5h + 周窗口、Credits(CNY) |
46
46
  | Ollama Cloud | `OLLAMA_API_KEY` | `GET ollama.com/api/balance`;`GET ollama.com/api/usage?range=30d` | API 用量 | 套餐剩余 + 购买余额(USD)、套餐已用、周期、渠道 30 天用量 |
47
47
  | 其他任意 provider(自建、中转、Ollama 本地) | 无需凭据 | 不请求任何接口 | API 用量 | 只按模型名计价;未定价可补算 |
48
48
 
49
49
  - 在 DSH 的凭据设置中按上表名称保存 Key;插件只通过宿主 `credentials` 读取,不读环境变量或本机登录文件。
50
50
  - Ollama 在 DSH 里需要用「自定义 OpenAI 兼容供应商」接入:route id 必须填 `ollama`(凭据按 `<ROUTE>_API_KEY` 派生成 `OLLAMA_API_KEY`),自定义名填别的会取不到 Key,余额卡也不会出现。
51
+ - OpenCode Go 的 `OPENCODE_API_KEY` 与 pi-ai 路由配置同名,配好 LLM 路由后无需再填第二份;旧名 `OPENCODE_GO_API_KEY` 仍兼容。`<ROUTE>_API_KEY` 派生只适用于自定义供应商,内置供应商的凭据名由 pi-ai 目录决定。
51
52
  - 填 Key 后自动探测;GLM / Kimi / OpenCode Go / Command Code 可在「全量看板」底部重新检测订阅。
52
53
  - 订阅模型计入 Tokens,但不计费用;计费形态按 Key 固化,不随配额接口抖动。
53
54
  - 余额、配额、用量分开展示;余额失败不会把当天的 Token 记账清零。
@@ -57,7 +58,7 @@
57
58
 
58
59
  以下截图使用假数据演示,便于一次看到完整效果。
59
60
 
60
- **P1 · 输入框底栏右侧 Pill**:API 用量 / 订阅两种形态,点击展开浮层,点击外部、`×` 或 `Esc` 收起。
61
+ **P1 · 输入框底栏右侧 Pill**:API 用量 / 订阅两种形态,点击展开浮层,点击外部、`×` 或 `Esc` 收起。API 态一行显示「预算环 + 今日花费 + 真实余额」,订阅态显示各窗口的用量环;颜色只表达告警,正常时保持中性色。
61
62
 
62
63
  <p align="center">
63
64
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-api.png" alt="API 用量 Pill" />
@@ -84,14 +85,16 @@
84
85
  - 订阅窗口固定三槽位:第 1 窗左、第 2 窗中、第 3 窗右;只有两窗时占前两个槽位。
85
86
  - 模型列上限 150,Tokens / 请求 / 命中右对齐;长模型名用省略号,悬浮可看全名。
86
87
 
87
- **P3 · 整页看板**:8 家供应商卡片、四格摘要带(总费用 / 真实 Tokens / 总请求数 / 缓存命中率)、用量趋势柱、8 列模型明细、底部设置胶囊;页面自己滚动,滚动条贴窗口右缘。
88
+ **P3 · 整页看板**:8 家供应商卡片、四格摘要带(真实 Tokens / 总费用 / 缓存命中率 / 总请求数)、可切指标的趋势图(含双币种双轴成本柱)、模型明细区块(含订阅估算价)、底部设置胶囊;页面自己滚动,滚动条贴窗口右缘。
88
89
 
89
90
  <p align="center">
90
91
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/settings.png" alt="整页看板" />
91
92
  </p>
92
93
 
93
- - API 用量卡:预算输入、计划余额、真实余额、本月已花;订阅卡:每个窗口一个环 + 剩余百分比 + 倒计时。
94
- - 明细表:模型 / Tokens / 输入 / 缓存 / 输出 / 请求 / 命中 / 费用;除模型列外全部右对齐。
94
+ - API 用量卡:预算输入、计划余额、真实余额、本月已花;订阅卡:每个窗口一个环 + 剩余百分比 + 倒计时;有估算数据时订阅卡底部显示「本月估算」,卡片不再附带状态行。
95
+ - 趋势图:纵坐标独立占左侧一列(在绘图区之外),三档刻度随指标切换;上 / 中 / 下三条网格线与刻度对齐;命中率轴顶档固定 100%,单个 0% 日不会把下限拉回 0。切到「费用」且出现两种币种时改为**双轴双柱**:人民币走左轴、美元走右轴,各自按自身最大值缩放,标题行给色块图例。
96
+ - 四格总费用:与实际计费同列,**含订阅估算**,副行标注「{n} 个币种 · 含估算」。
97
+ - 明细表:独立「模型明细」区块,模型 / Tokens / 输入 / 缓存 / 输出 / 请求 / 命中 / 费用;除模型列外全部右对齐。费用一律以 `≈` 标注为本地估算,订阅行给出「若按 API 计」的估算金额(无价显示「未定价」,无估算数据显示 `—`)。
95
98
  - 设置区:胶囊外是「设置与数据管理」区块标题;胶囊内第一行刷新间隔 + 账户余额开关,下面是日志、导出导入、价格表与版本。
96
99
  - 间距只使用 4 / 8 / 12 / 16 / 24 / 32 六档,P2 / P3 同一套 token。
97
100
 
@@ -153,6 +156,7 @@ npm run logs -- --module provider,route # 缓存 / 路由异常
153
156
  ```bash
154
157
  npm test # 单元测试(80 通过)
155
158
  npm run e2e # 端到端(临时 DSH_HOME + web profile + Playwright)
159
+ npm run stats # npm 下载量、版本分布与装机估算(只读公开接口,按 UTC 日统计)
156
160
  npm run shots # 用假数据重新生成 docs/pic 的 P1/P2/P3 截图
157
161
  npm run pack # 发布 tarball 生成到 build/
158
162
  ```