dsh-tokenlens 1.1.0 → 1.2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  本项目遵循 [Semantic Versioning](https://semver.org/):修复 = PATCH,新功能 = MINOR,不兼容变更 = MAJOR。发布时同步更新 `package.json` 的 `version`、`index.js` 的 `PLUGIN_VERSION` 与本文件(`node scripts/bump-version.mjs <version> "<note>"`);已发布的条目保持原样。
4
4
 
5
+ ## 1.2.0 — 2026-10-31
6
+
7
+ - feat(chart): 图表模式点击某一天的柱子可下钻查看**当天 24 小时**的 Token 消耗棒状图(横轴 00:00–23:00,悬浮显示小时与占比,回车/空格同样可操作,返回或再次点击回到日趋势)
8
+ - feat(chart): 小时数据覆盖全部 5 个本机 harness(DSH、ZCode、OpenCode CLI、WorkBuddy、Qoder);无小时数据的旧日期不可下钻,不伪造全零序列
9
+ - feat(chart): 图表模式「明细」的三张环形图(按 Harness / 按供应商 / Top 模型)新增 **今日 / 最近7天 / 最近X天(或最近30天)/ 总计** 窗口切换,默认总计;切换 scope 或数据/图表视图时保持,缺失窗口自动隐藏
10
+ - feat(wire): `stats.daily[]` 新增可选 `hours`(24 个本地小时 Token 整数)与 `providers[pid].hours`(v1.2.0 协议,已在 PROTOCOL 中写明)
11
+ - 测试:250 个自动化用例(新增 13 个:小时聚合、外部 harness 小时分组、下钻交互与窗口切换的前后端回归)
12
+
5
13
  ## 1.1.0 — 2026-10-30
6
14
 
7
15
  - feat(providers): 接入 Open Design(OpenDesign)只读额度查询——Design Plan 的 5 小时 / 7 天窗口已用百分比与重置时间,以及独立的钱包 USD 余额
package/PROTOCOL.md CHANGED
@@ -180,9 +180,19 @@ with `[path]`.
180
180
  { "key": "opencode-go/deepseek-v4.1-flash", "providerId": "opencode-go",
181
181
  "modelId": "deepseek-v4.1-flash",
182
182
  "today": { "total": …, "messages": … },
183
+ "last7Days": { "total": …, "messages": … },
183
184
  "last30Days": { "total": …, "messages": … },
184
185
  "allTime": { "total": …, "messages": … } }
185
186
  ],
187
+ "daily": [ // <=120 days, ascending; chart series
188
+ { "day": "2026-10-25",
189
+ "total": { "total": 123456, "messages": 42 },
190
+ "hours": [0, 0, 0, 1234, 5678, …], // 24 integers: local-hour token totals
191
+ "providers": {
192
+ "opencode-go": { "total": 1234, "messages": 5,
193
+ "hours": [0, 0, 0, 500, 734, …] }
194
+ } }
195
+ ],
186
196
  "zcode": { // extra-harness detail
187
197
  "dbPath": "C:\\Users\\…\\.zcode\\cli\\db\\db.sqlite",
188
198
  "available": true, "error": null, "rows": 65, "cached": false,
@@ -263,6 +273,12 @@ with `[path]`.
263
273
  breakdown and top models are labeled DSH-only.
264
274
  - An unavailable/disabled statistics service answers
265
275
  `{ ok: false, error: { code: "stats-unavailable" } }`.
276
+ - **Hourly drill-down (v1.2.0)**: `daily[].hours` and
277
+ `daily[].providers[id].hours` are 24-element arrays of local-hour token totals
278
+ (`[0..23]`, rounded integers) used by the chart mode. Every bundled harness
279
+ contributes when it exposes event timestamps; a day without the field is not
280
+ drillable and the client must not invent an all-zero hour series. DST fall-back
281
+ hours collapse into one local hour slot.
266
282
 
267
283
  ## Error shape
268
284
 
@@ -416,9 +432,13 @@ configure the `opencode-go` provider.
416
432
  or a balance card; Command Code also shows remaining/granted credits;
417
433
  - **token statistics**: tabs 「当前供应商 · 全部 Harness」 (default; cards = that
418
434
  provider's tokens across DSH + ZCode) / 「全部 Harness」 (all providers);
419
- cards show 今日 / 最近30天 / 总计 (total tokens, input/output/cache, request
420
- count); a 「按 Harness」breakdown for the active scope; DSH provider
421
- breakdown and DSH top models; an unmapped-ZCode note when present;
435
+ cards show 今日 / 最近7天 / 最近X天(或最近30天) / 总计 (total tokens,
436
+ input/output/cache, request count); a 「按 Harness」breakdown for the active
437
+ scope; DSH provider breakdown and DSH top models; an unmapped-ZCode note when
438
+ present;
439
+ - **chart mode**: the daily bar chart, a click on a day bar drills into that
440
+ day's 24 local-hour bars (when the Host delivers `daily[].hours`), and the
441
+ 明细 donuts switch between 今日 / 最近7天 / 最近X天 / 总计;
422
442
  - refresh (usage + stats), last-updated/stale line, error banners, console link.
423
443
  3. Everything client-side must work with only the shell's seeded modules
424
444
  (`react`, `react-dom`, `@deepseek-ai/dsh-client-ui-primitives`) — no build step.
package/README.en.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  > One glance at your usage: plan capacity for the selected provider plus local token statistics across harnesses, right below the DSH composer.
11
11
 
12
- **dsh-TokenLens** is a usage plugin for DSH (DeepSeek Harness), version v1.1.0. It keeps two kinds of numbers separate:
12
+ **dsh-TokenLens** is a usage plugin for DSH (DeepSeek Harness), version v1.2.0. It keeps two kinds of numbers separate:
13
13
 
14
14
  - **Plan capacity** — the provider's authoritative server-side values (percentage windows, used / cap, balance or remaining credit);
15
15
  - **Local token stats** — tokens consumed on this machine across every connected harness, for the selected provider or for all providers combined.
@@ -20,7 +20,7 @@ Everything is computed locally: zero runtime dependencies, no external database,
20
20
 
21
21
  - **Usage chip below the composer** — follows the selected model provider and shows its plan capacity; providers without an adapter or credentials stay hidden.
22
22
  - **Details dialog** — plan capacity windows with reset times (plus an optional "consumed · estimated consumable" hint) and local token stats for today / last 7 days / last 30 days / all-time, scoped to the current provider or all harnesses.
23
- - **Data and chart modes** — tables, a daily trend chart and ring charts; breakdowns by harness, provider, top model and unmapped providers.
23
+ - **Data and chart modes** — tables, a daily trend chart and ring charts with breakdowns by harness, provider, top model and unmapped providers. In chart mode, clicking a day's bar drills into that day's 24 hourly bars; the 明细 rings switch between today / last 7 days / last X days (or last 30 days) / all time.
24
24
  - **Provider management page** — enabled / built-in / all filters, enable switches, credential status, console links, label editing, connection tests, subscription badges and plugin settings.
25
25
  - **Auto-discovery and agent tool** — providers configured in DSH Settings → Model Services are detected by route id or base-URL host and reuse their DSH credentials; `tokenlens_usage` lets the model query snapshots, local stats and diagnostics.
26
26
  - **Local-only** — 5 harnesses (DSH, ZCode, OpenCode CLI, WorkBuddy / CodeBuddy CLI, Qoder CN CLI), 25 built-in providers (16 with plan / balance adapters), read-only local data, no telemetry.
@@ -66,7 +66,7 @@ dsh plugin --profile <profile> add dsh-tokenlens
66
66
  Then make sure `dsh.profile.bundles` in `$DSH_HOME/profiles/<profile>/package.json` contains `"dsh-tokenlens"`:
67
67
 
68
68
  ```jsonc
69
- { "dependencies": { "dsh-tokenlens": "^1.1.0" },
69
+ { "dependencies": { "dsh-tokenlens": "^1.2.0" },
70
70
  "dsh": { "profile": { "bundles": ["…", "dsh-tokenlens"] } } }
71
71
  ```
72
72
 
@@ -134,7 +134,7 @@ Host bridge route: `/api/tokenlens`; agent tool: `tokenlens_usage`.
134
134
 
135
135
  ## Development
136
136
 
137
- Node.js ≥ 24, zero runtime dependencies: `node --test` runs the 237 tests.
137
+ Node.js ≥ 24, zero runtime dependencies: `node --test` runs the 250 tests.
138
138
 
139
139
  Release: `node scripts/bump-version.mjs <version> "<note>"` updates `package.json`, `PLUGIN_VERSION` and `CHANGELOG.md`; see [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).
140
140
 
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  > **一眼看清你的用量**:在 DSH 输入框下方显示当前供应商的套餐容量,并汇总本机跨 Harness 的 Token 消耗。
11
11
 
12
- **dsh-TokenLens(词元透镜)** 是 DSH(DeepSeek Harness)的用量插件(v1.1.0,公开版本)。它把两类数字**按不同口径**分开呈现:
12
+ **dsh-TokenLens(词元透镜)** 是 DSH(DeepSeek Harness)的用量插件(v1.2.0,公开版本)。它把两类数字**按不同口径**分开呈现:
13
13
 
14
14
  - **套餐容量**(供应商服务端权威值):百分比窗口、`已用 / 上限`、账户余额或剩余额度;
15
15
  - **本机 Token 统计**(本机记录):当前供应商在本机所有已接入 Harness 上的合计用量,也可切到「全部 Harness」看总账。
@@ -39,7 +39,7 @@
39
39
  - **详情弹窗**(点击 chip 打开):
40
40
  - **套餐容量**:5 小时 / 本周 / 本月等原生窗口的已用百分比、重置时间与绝对重置日期;余额类供应商显示余额。每个窗口附带一行 `已消耗 · 预计可消耗` 估算(由本机 Token 记录 ÷ 套餐百分比推算,仅供参考)。
41
41
  - **本机 Token 统计**:今日 / 最近 7 天 / 最近 30 天 / 总计(订阅类供应商显示「最近 X 天」生效窗口),可按「当前供应商 · 全部 Harness」与「全部 Harness」两个视角查看。
42
- - **明细与图表**:按 Harness、按供应商、Top 模型、未映射供应商分组;支持「数据」(表格)与「图表」(每日趋势柱状图 + 环形占比图)两种模式切换。
42
+ - **明细与图表**:按 Harness、按供应商、Top 模型、未映射供应商分组;支持「数据」(表格)与「图表」两种模式切换。图表模式里点击某一天的柱子可下钻查看**当天 24 小时**的 Token 消耗,底部「明细」环形图支持 **今日 / 最近 7 天 / 最近 X 天(或最近 30 天)/ 总计** 窗口切换。
43
43
  - **工作区徽标**(实验性):左侧工作区列表的名称旁显示该工作区的本机 Token 合计,悬浮卡片显示今日 / 7 天 / 30 天 / 总计;纯展示,找不到对应 UI 时自动降级。
44
44
  - **供应商管理页**:「已配置 / 内置 / 全部」筛选、启用开关、凭据状态、控制台链接、短标签与全名编辑、测试连接、已订阅徽章;另有「插件设置」可配置标签样式、默认展示模式、默认统计范围与明细展开状态。
45
45
  - **自动识别**:在 DSH「设置 → 模型服务」中配置过的供应商会自动出现在管理页,并按路由 id 或 baseURL 主机匹配内置用量适配器,自动继承 DSH 中的凭据,无需重复填写。
@@ -106,7 +106,7 @@ dsh plugin --profile <profile> add dsh-tokenlens
106
106
  ```jsonc
107
107
  {
108
108
  "dependencies": {
109
- "dsh-tokenlens": "^1.1.0"
109
+ "dsh-tokenlens": "^1.2.0"
110
110
  },
111
111
  "dsh": {
112
112
  "profile": {
@@ -389,7 +389,7 @@ Host 半注册 `tokenlens_usage`,参数 `action`(默认 `snapshot`)与可
389
389
 
390
390
  ## 验证
391
391
 
392
- - `node --test`:**237 个自动化用例**,覆盖 Host 数据层、供应商适配器、统计折叠、各 harness 读取、插件集成与浏览器端渲染 / 交互。
392
+ - `node --test`:**250 个自动化用例**,覆盖 Host 数据层、供应商适配器、统计折叠、各 harness 读取、插件集成与浏览器端渲染 / 交互。
393
393
  - 在真实环境中验证过 **5 个 harness** 的数据源;本机统计与独立的 SQLite 查询、独立的日志解析逐项对账(差额为 0),跨 harness 合并与供应商映射算术自洽。
394
394
  - 供应商接口按各官方文档与参考客户端行为验证;未配置凭据时 chip 静默隐藏,接口异常时按可重试错误降级。
395
395
 
@@ -400,7 +400,7 @@ Host 半注册 `tokenlens_usage`,参数 `action`(默认 `snapshot`)与可
400
400
  ```powershell
401
401
  git clone https://github.com/daigahou/dsh-tokenlens.git
402
402
  cd dsh-tokenlens
403
- node --test # 237 个用例
403
+ node --test # 250 个用例
404
404
  ```
405
405
 
406
406
  本地联调安装方式见[方式 C](#方式-c本地开发从源码-link)。