dsh-tokenlens 1.7.2 → 1.7.4

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
@@ -4,6 +4,24 @@
4
4
 
5
5
  **版本记录约定**:同一发布日只保留一个章节,标题取当日**最后一个**已发布版本号;当日多次发布的改动合并到该章节,并在标题下注明当日实际发布过的版本号(npm 上仍可安装这些独立版本)。若当日已有发布,后续小改动不再单独增加版本号,而是并入下一篇日志。这样日志按天规整、不出现同日多个小版本。
6
6
 
7
+ ## 1.7.4 — 2026-11-06
8
+
9
+ (当日已发布版本:v1.6.5 / v1.6.6 / v1.6.7 / v1.7.0 / v1.7.1 / v1.7.2 / v1.7.3 / v1.7.4)
10
+
11
+ - **fix(ui): 供应商额度行只保留「加购」金额**——`剩余 $67.04` 与 `本月额度 $70.00` 都移除,v1.7.3 加的「模型等效额度」也一并去掉。这三个数放在一起互相矛盾(100 − 67.04 ≠ 实际消费),而本月百分比已在「本月」窗口行里表述,重复且易误读。现在该行只显示 `加购 $0.00`
12
+ - 清理随之无用的 5 个 i18n 文案键(`creditsRemaining` / `creditsGranted` / `creditsModelAllowance*`)
13
+ - wire 数据不变:`credits.remaining` / `granted` / `allowanceUsd` 仍然上报,仅界面不再展示(Agent 工具 `tokenlens_usage` 的读数不受影响)
14
+ - 测试:370(改写额度行断言为「只留加购、其余不得出现」)
15
+
16
+ ## 1.7.3 — 2026-11-06
17
+
18
+ (当日已发布版本:v1.6.5 / v1.6.6 / v1.6.7 / v1.7.0 / v1.7.1 / v1.7.2 / v1.7.3)
19
+
20
+ - **fix(commandcode): 本月百分比改回按额度池计算**——v1.7.2 按「所选模型的额度」当分母(GOAT + DeepSeek V4.1 Flash = $100),但控制台自己的每月限额是按**额度池**算的。同一笔 $2.94 消费:`2.94 / 70 = 4.2%`(控制台显示 4%),`2.94 / 100 = 2.9%`(v1.7.2 显示 2.9%)——所以那一版与你在控制台看到的数对不上。现在分母回到额度池,实机读数 `$2.96 / $70.00 · 4.23%`,与控制台一致
21
+ - **feat(commandcode): 模型额度改为参考信息**——$100 不是分母,而是「该模型折扣后能覆盖多少消费」。控制台有这张按模型表(`assets/plan-tiers-*.js`,已转录到 `lib/commandcode-plans.mjs`),插件把当前模型的等效额度作为一行带标签的补充信息显示,并说明「控制台按额度池计百分比」,不再悄悄替换分母
22
+ - 同步修正测试:改用实机真值(剩余 `67.087370791` + 本期消费 `2.912629209` = 额度池 `70.000000000`)而不是自造数,并断言**切换模型不会移动仪表指针**
23
+ - 测试:369 → 370
24
+
7
25
  ## 1.7.2 — 2026-11-06
8
26
 
9
27
  (当日已发布版本:v1.6.5 / v1.6.6 / v1.6.7 / v1.7.0 / v1.7.1 / v1.7.2)
package/README.en.md CHANGED
@@ -144,7 +144,7 @@ Host bridge route: `/api/tokenlens`; agent tool: `tokenlens_usage`.
144
144
 
145
145
  ## Development
146
146
 
147
- Node.js ≥ 24, zero runtime dependencies: `node --test` runs the 369 tests.
147
+ Node.js ≥ 24, zero runtime dependencies: `node --test` runs the 370 tests.
148
148
 
149
149
  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).
150
150
 
package/README.md CHANGED
@@ -445,7 +445,7 @@ Host 半注册 `tokenlens_usage`,参数 `action`(默认 `snapshot`)与可
445
445
 
446
446
  ## 验证
447
447
 
448
- - `node --test`:**369 个自动化用例**,覆盖 Host 数据层、供应商适配器(含小米 MiMo 控制台 Cookie 适配器、Command Code 月度额度反推)、统计折叠、各 harness 读取、Design Plan 周期账本与额度计价、TPS 速度序列、窗口锚点切片、工作区自动识别、插件集成与浏览器端渲染 / 交互。
448
+ - `node --test`:**370 个自动化用例**,覆盖 Host 数据层、供应商适配器(含小米 MiMo 控制台 Cookie 适配器、Command Code 月度额度反推)、统计折叠、各 harness 读取、Design Plan 周期账本与额度计价、TPS 速度序列、窗口锚点切片、工作区自动识别、插件集成与浏览器端渲染 / 交互。
449
449
  - 在真实环境中验证过 **5 个 harness** 的数据源;本机统计与独立的 SQLite 查询、独立的日志解析逐项对账(差额为 0),跨 harness 合并与供应商映射算术自洽。
450
450
  - 供应商接口按各官方文档与参考客户端行为验证;未配置凭据时 chip 静默隐藏,接口异常时按可重试错误降级。
451
451
 
package/client.js CHANGED
@@ -197,8 +197,6 @@ window.__ModuleLoader__.load({
197
197
  balanceToppedUp: '充值 {amount}',
198
198
  balanceWallets: '钱包:{amounts}',
199
199
  balanceBonus: '奖励:{amounts}',
200
- creditsRemaining: '剩余 {amount}',
201
- creditsGranted: '本月额度 {amount}',
202
200
  creditsPurchased: '加购 {amount}',
203
201
  refresh: '刷新',
204
202
  refreshing: '正在刷新…',
@@ -473,8 +471,6 @@ window.__ModuleLoader__.load({
473
471
  balanceToppedUp: 'Topped up {amount}',
474
472
  balanceWallets: 'Wallets: {amounts}',
475
473
  balanceBonus: 'Bonus: {amounts}',
476
- creditsRemaining: 'Remaining {amount}',
477
- creditsGranted: 'Granted {amount}',
478
474
  creditsPurchased: 'Purchased {amount}',
479
475
  refresh: 'Refresh',
480
476
  refreshing: 'Refreshing…',
@@ -1096,6 +1092,13 @@ window.__ModuleLoader__.load({
1096
1092
  remaining: numberOrNull(raw.remaining),
1097
1093
  granted: numberOrNull(raw.granted),
1098
1094
  purchased: numberOrNull(raw.purchased),
1095
+ // v1.7.3: the per-model allowance is ADVERTISING, not the meter's
1096
+ // denominator — the console measures the monthly percentage against the
1097
+ // credit pool. It is kept only so the card can explain the difference.
1098
+ poolUsd: numberOrNull(raw.poolUsd),
1099
+ allowanceUsd: numberOrNull(raw.allowanceUsd),
1100
+ allowanceModel: typeof raw.allowanceModel === 'string' && raw.allowanceModel !== '' ? raw.allowanceModel : null,
1101
+ allowanceBasis: typeof raw.allowanceBasis === 'string' ? raw.allowanceBasis : null,
1099
1102
  }
1100
1103
  if (credits.remaining === null && credits.granted === null && credits.purchased === null) return null
1101
1104
  return credits
@@ -4351,19 +4354,15 @@ window.__ModuleLoader__.load({
4351
4354
  )
4352
4355
  }
4353
4356
 
4354
- /** The Command Code credits line (remaining / granted / purchased, USD). */
4357
+ /** The Command Code credits line (v1.7.4: the purchased amount only). */
4355
4358
  function buildCreditsLine(snapshot, t) {
4356
4359
  const credits = snapshot.credits
4357
4360
  if (credits === null) return null
4358
4361
  const parts = []
4359
- if (credits.remaining !== null) {
4360
- parts.push(
4361
- h('span', { key: 'remaining' }, t('creditsRemaining', { amount: formatMoney(credits.remaining, 'USD') })),
4362
- )
4363
- }
4364
- if (credits.granted !== null) {
4365
- parts.push(h('span', { key: 'granted' }, t('creditsGranted', { amount: formatMoney(credits.granted, 'USD') })))
4366
- }
4362
+ // v1.7.4: 「剩余」 and 「本月额度」 were dropped on request — the remaining
4363
+ // credits already appear nowhere else useful, and the granted/allowance
4364
+ // pair invited confusion with the monthly percentage (which the provider
4365
+ // measures against its own pool). Only the purchased amount is kept.
4367
4366
  if (credits.purchased !== null) {
4368
4367
  parts.push(
4369
4368
  h('span', { key: 'purchased' }, t('creditsPurchased', { amount: formatMoney(credits.purchased, 'USD') })),
package/index.js CHANGED
@@ -84,7 +84,7 @@ export const inject = []
84
84
  export const PLUGIN_NAME = 'dsh-tokenlens'
85
85
 
86
86
  /** Plugin version; mirrors package.json (kept here so diagnostics need no fs read). */
87
- export const PLUGIN_VERSION = '1.7.2'
87
+ export const PLUGIN_VERSION = '1.7.4'
88
88
 
89
89
  /** Documented defaults; every field of the raw row config is optional. */
90
90
  const DEFAULTS = {
package/lib/providers.mjs CHANGED
@@ -573,12 +573,16 @@ export function parseCommandCode(
573
573
  : remaining !== null && spend !== null
574
574
  ? remaining + spend
575
575
  : null
576
- // v1.7.2: the SELECTED MODEL's allowance sizes the month when the plan has a
577
- // per-model table (GOAT + DeepSeek V4.1 Flash = $100 even though the credit
578
- // pool is $70 — a discounted model stretches the same pool further). Without a
579
- // known model or plan the pool is used, so nothing is invented.
576
+ // v1.7.2: the SELECTED MODEL's advertised allowance (GOAT + DeepSeek V4.1 Flash
577
+ // = $100 even though the credit pool is $70 — a discounted model stretches the
578
+ // same pool further).
579
+ // v1.7.3: it is NOT the month's denominator. The provider's own console prints
580
+ // 每月限额 4% for $2.94 spent, and 2.94/70 = 4.2% while 2.94/100 = 2.9% — the
581
+ // console measures the percentage against the CREDIT POOL. Using the allowance
582
+ // made the plugin disagree with the console the user checks, so the pool stays
583
+ // the denominator and the allowance is reported as context only.
580
584
  const allowance = commandcodeAllowance(planId, selectedModel)
581
- const granted = allowance.basis === 'model' && allowance.allowanceUsd !== null ? allowance.allowanceUsd : poolGrant
585
+ const granted = poolGrant
582
586
  const monthlyUsed = poolGrant !== null && remaining !== null ? Math.max(0, poolGrant - remaining) : spend
583
587
  const monthlyPercent =
584
588
  granted !== null && granted > 0 && monthlyUsed !== null
@@ -618,12 +622,14 @@ export function parseCommandCode(
618
622
  ? null
619
623
  : {
620
624
  remaining,
621
- // `granted` is the allowance the month is measured against, so the
622
- // credits card and the monthly row agree. `poolUsd` keeps the plan's
623
- // real credit pool visible when a model allowance is larger.
625
+ // `granted` is the credit pool the month is measured against — the
626
+ // same denominator the provider's console uses.
624
627
  granted,
625
628
  purchased,
626
629
  poolUsd: poolGrant,
630
+ // Advertising only (v1.7.3): the allowance the console lists for the
631
+ // selected model. Never used to compute a percentage.
632
+ allowanceUsd: allowance.allowanceUsd,
627
633
  allowanceModel: allowance.basis === 'model' ? allowance.matched : null,
628
634
  allowanceBasis: allowance.basis,
629
635
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tokenlens",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "type": "module",
5
5
  "description": "dsh-TokenLens (词元透镜) — provider-aware plan capacity plus local token statistics (today/7d/30d/all-time, by harness/provider/model/workspace) for DSH.",
6
6
  "license": "MIT",