dsh-token-dash 1.3.0 → 2.0.1

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
@@ -23,14 +23,12 @@
23
23
  <p align="center">
24
24
  <img src="https://img.shields.io/github/v/tag/spartawhy117/dsh-token-dash?label=version&sort=semver" alt="version" />
25
25
  <img src="https://img.shields.io/npm/dt/dsh-token-dash?logo=npm&label=npm%20downloads" alt="npm downloads" />
26
- <img src="https://img.shields.io/github/downloads/spartawhy117/dsh-token-dash/total?label=downloads" alt="downloads" />
27
- <img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
28
- <img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node" />
29
26
  <img src="https://img.shields.io/badge/DSH-0.2.2--rc.1_tested-4c8bf5" alt="DSH tested" />
27
+ <img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
30
28
  <a href="https://awesome-dsh-plugin.com/p/spartawhy117/dsh-token-dash"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-6ea8ff" alt="awesome-dsh-plugin" /></a>
31
29
  </p>
32
30
 
33
- **Three entry points, one local ledger**: the 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.
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.
34
32
 
35
33
  ## Provider matrix
36
34
 
@@ -53,7 +51,7 @@
53
51
 
54
52
  Screenshots use mock data so the full layout is visible at once.
55
53
 
56
- **P1 · Bottom bar Pill**: pay-as-you-go / subscription variants; click to open, click outside, `×` or `Esc` to close.
54
+ **P1 · Composer footer-right Pill**: pay-as-you-go / subscription variants; click to open, click outside, `×` or `Esc` to close.
57
55
 
58
56
  <p align="center">
59
57
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-api.png" alt="Pay-as-you-go pill" />
@@ -63,7 +61,7 @@ Screenshots use mock data so the full layout is visible at once.
63
61
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-sub.png" alt="Subscription pill" />
64
62
  </p>
65
63
 
66
- **P2 · Floating panel (current model)**: fixed 380, one row with four groups — used ring / used-budget / real balance / month-to-date spend — a full-width range control and the usage table.
64
+ **P2 · Floating panel (current model)**: fixed 380, one row with three groups — used ring / used-budget / real balance — with the balance right-aligned to the panel edge, a full-width range control and the usage table.
67
65
 
68
66
  <p align="center">
69
67
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/panel-api.png" alt="Floating panel - pay-as-you-go" />
@@ -89,6 +87,7 @@ Screenshots use mock data so the full layout is visible at once.
89
87
  - Pay-as-you-go card: budget input, planned balance, real balance, month-to-date spend; subscription card: one ring per window with remaining percentage and countdown.
90
88
  - Breakdown: model / Tokens / input / cache / output / requests / hit rate / cost; everything except the model column is right-aligned.
91
89
  - Settings capsule: refresh interval + account-balance toggle; logs, export/import, price table and version below.
90
+ - 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.
92
91
  - Spacing uses only 4 / 8 / 12 / 16 / 24 / 32; P2 and P3 share the same tokens.
93
92
 
94
93
  ## Install
@@ -113,6 +112,7 @@ Update: run `update` with the same name, or use the `⤓` button on the right of
113
112
  ## Compatibility & limitations
114
113
 
115
114
  - DSH `0.2.1+`; verified on `0.2.2-rc.1`. DSH 0.2.2 is a pre-release and itself requires Node 24.9.
115
+ - The UI currently ships Chinese / English only. Other DSH languages (Japanese, German, Russian, etc.) fall back to English.
116
116
  - After a DSH upgrade the plugin may disappear from the profile; reinstall the same tarball — the ledger is not deleted.
117
117
  - Qwen tracks usage only; its balance endpoint is unsupported. Other balances/quotas follow what each API returns.
118
118
  - Upstream APIs are rate-limited; successful results are cached for 60s, failures for 10s, and concurrent requests are coalesced.
@@ -144,7 +144,7 @@ Common events:
144
144
  ## Development
145
145
 
146
146
  ```bash
147
- npm test # unit tests (79 passing)
147
+ npm test # unit tests (80 passing)
148
148
  npm run e2e # end-to-end (temp DSH_HOME + web profile + Playwright)
149
149
  npm run shots # regenerate the P1/P2/P3 screenshots in docs/pic from mock data
150
150
  npm run pack # build the release tarball into build/
package/README.md CHANGED
@@ -23,24 +23,22 @@
23
23
  <p align="center">
24
24
  <img src="https://img.shields.io/github/v/tag/spartawhy117/dsh-token-dash?label=version&sort=semver" alt="version" />
25
25
  <img src="https://img.shields.io/npm/dt/dsh-token-dash?logo=npm&label=npm%20downloads" alt="npm downloads" />
26
- <img src="https://img.shields.io/github/downloads/spartawhy117/dsh-token-dash/total?label=downloads" alt="downloads" />
27
- <img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
28
- <img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node" />
29
26
  <img src="https://img.shields.io/badge/DSH-0.2.2--rc.1_tested-4c8bf5" alt="DSH tested" />
27
+ <img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
30
28
  <a href="https://awesome-dsh-plugin.com/zh/p/spartawhy117/dsh-token-dash"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-6ea8ff" alt="awesome-dsh-plugin" /></a>
31
29
  </p>
32
30
 
33
- **三个入口,一份数据**:底栏 Pill 看当前模型;浮层看预算、余额与用量表;整页看 7 家供应商的全量卡片与模型明细。所有页面共用同一份本地账本,不重复计算。
31
+ **三个入口,一份数据**:输入框底栏右侧 Pill 看当前模型;浮层看预算、余额与用量表;整页看 7 家供应商的全量卡片与模型明细。所有页面共用同一份本地账本,不重复计算。
34
32
 
35
33
  ## 支持矩阵
36
34
 
37
35
  | 供应商 | 计费形态 | 凭据 | 能看到什么 |
38
36
  |---|---|---|---|
39
37
  | DeepSeek | 按量 | DS 账号钱包 / `DEEPSEEK_API_KEY` | 账户余额、本月已花、预算 |
40
- | 智谱 GLM Coding | 订阅 / 按量 | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | 5h + 周窗口 |
38
+ | Zhipu GLM Coding | 订阅 / 按量 | `ZHIPU_API_KEY` / `GLM_API_KEY` / `ZAI_API_KEY` | 5h + 周窗口 |
41
39
  | Kimi Coding | 订阅 / 按量 | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`,可选 `MOONSHOT_API_KEY` | 5h + 周/月窗口;订阅查询失败可回落余额 |
42
40
  | OpenRouter | 按量 | `OPENROUTER_API_KEY` | Credits(USD) |
43
- | 通义千问 | 按量 | `DASHSCOPE_API_KEY`(CNY)/ `DASHSCOPE_INTL_API_KEY`(USD) | 仅用量;余额不支持 |
41
+ | Qwen | 按量 | `DASHSCOPE_API_KEY`(CNY)/ `DASHSCOPE_INTL_API_KEY`(USD) | 仅用量;余额不支持 |
44
42
  | OpenCode Go | 订阅 | `OPENCODE_GO_API_KEY` | 5h / 周 / 月窗口(USD) |
45
43
  | Command Code | 订阅 | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | 5h + 周窗口、Credits(CNY) |
46
44
 
@@ -53,7 +51,7 @@
53
51
 
54
52
  以下截图使用假数据演示,便于一次看到完整效果。
55
53
 
56
- **P1 · 底栏 Pill**:按量 / 订阅两种形态,点击展开浮层,点击外部、`×` 或 `Esc` 收起。
54
+ **P1 · 输入框底栏右侧 Pill**:按量 / 订阅两种形态,点击展开浮层,点击外部、`×` 或 `Esc` 收起。
57
55
 
58
56
  <p align="center">
59
57
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-api.png" alt="按量 Pill" />
@@ -63,7 +61,7 @@
63
61
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-sub.png" alt="订阅 Pill" />
64
62
  </p>
65
63
 
66
- **P2 · 浮层(当前模型)**:固定 380,单行四组「已用环 / 已用·预算 / 真实余额 / 本月已花」;时间范围撑满,下面是用量表。
64
+ **P2 · 浮层(当前模型)**:固定 380,单行三组「已用环 / 已用·预算 / 真实余额」,真实余额右对齐到面板右缘;时间范围撑满,下面是用量表。
67
65
 
68
66
  <p align="center">
69
67
  <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/panel-api.png" alt="浮层 · 按量形态" />
@@ -88,7 +86,7 @@
88
86
 
89
87
  - 按量卡:预算输入、计划余额、真实余额、本月已花;订阅卡:每个窗口一个环 + 剩余百分比 + 倒计时。
90
88
  - 明细表:模型 / Tokens / 输入 / 缓存 / 输出 / 请求 / 命中 / 费用;除模型列外全部右对齐。
91
- - 设置胶囊:第一行刷新间隔 + 账户余额开关;下面是日志、导出导入、价格表与版本。
89
+ - 设置区:胶囊外是「设置与数据管理」区块标题;胶囊内第一行刷新间隔 + 账户余额开关,下面是日志、导出导入、价格表与版本。
92
90
  - 间距只使用 4 / 8 / 12 / 16 / 24 / 32 六档,P2 / P3 同一套 token。
93
91
 
94
92
  ## 安装
@@ -113,8 +111,9 @@ dsh plugin --profile desktop add /path/to/dsh-token-dash-x.y.z.tgz
113
111
  ## 兼容与限制
114
112
 
115
113
  - DSH `0.2.1+`;已在 `0.2.2-rc.1` 上验证。DSH 0.2.2 是预发布版,且自身要求 Node 24.9。
114
+ - 界面语言当前仅中文 / English;选择日语、德语、俄语等其他 DSH 语言时,插件文案显示英文回退。
116
115
  - 升级 DSH 后插件可能从 profile 消失,重装同一个 tarball 即可,账本不会被删。
117
- - 通义千问只统计用量,余额接口不支持;其余供应商的余额/配额以接口实际返回为准。
116
+ - Qwen 只统计用量,余额接口不支持;其余供应商的余额/配额以接口实际返回为准。
118
117
  - 上游接口有速率限制;成功结果缓存 60s、失败结果缓存 10s,并发请求会合并。
119
118
 
120
119
  ## 数据与隐私
@@ -144,7 +143,7 @@ npm run logs -- --module provider,route # 缓存 / 路由异常
144
143
  ## 开发
145
144
 
146
145
  ```bash
147
- npm test # 单元测试(79 通过)
146
+ npm test # 单元测试(80 通过)
148
147
  npm run e2e # 端到端(临时 DSH_HOME + web profile + Playwright)
149
148
  npm run shots # 用假数据重新生成 docs/pic 的 P1/P2/P3 截图
150
149
  npm run pack # 发布 tarball 生成到 build/
package/client.js CHANGED
@@ -104,6 +104,7 @@ window.__ModuleLoader__.load({
104
104
  '未配置凭据': 'No credentials', '刷新中': 'Refreshing',
105
105
  '编辑预算': 'Edit budget', '退出编辑': 'Exit editing',
106
106
  '设置与数据管理': 'Settings and data',
107
+ '语言跟随DSH设置;当前仅中文/English,其他语言回退英文': 'Language follows DSH settings; Chinese/English only; other languages fall back to English',
107
108
  '账户真实余额,不受预算影响': 'Account balance; not affected by budget',
108
109
  '本月累计消耗,等于已用/预算 的分子': 'Month-to-date spend; numerator of used/budget',
109
110
  '提示': 'Note',
@@ -320,7 +321,7 @@ window.__ModuleLoader__.load({
320
321
  borderRadius: 999, cursor: 'pointer', maxWidth: '100%', fontVariantNumeric: 'tabular-nums',
321
322
  border: `1px solid ${T.border}`, color: T.text,
322
323
  },
323
- pillWrap: { position: 'relative', display: 'inline-flex', alignItems: 'center', marginLeft: 8 },
324
+ pillWrap: { position: 'relative', display: 'inline-flex', alignItems: 'center', order: 10, marginLeft: 8 },
324
325
  pillHover: { background: 'color-mix(in srgb, currentColor 8%, transparent)' },
325
326
  hint: {
326
327
  position: 'absolute', right: 12, bottom: 30, padding: '5px 8px', borderRadius: 6,
@@ -393,7 +394,7 @@ window.__ModuleLoader__.load({
393
394
  card: { background: T.section, borderRadius: 10, padding: 10, marginTop: 10, display: 'grid', gap: 8 },
394
395
  link: { color: T.text, textDecoration: 'underline', cursor: 'pointer' },
395
396
  status: { minHeight: 15, fontSize: 10.5, color: T.muted, textAlign: 'right' },
396
- summaryRow: { display: 'flex', flexWrap: 'nowrap', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 24, fontSize: 12 },
397
+ summaryRow: { display: 'grid', gridTemplateColumns: 'auto minmax(120px,1.2fr) minmax(80px,1fr) minmax(0,1fr)', alignItems: 'center', columnGap: 12, minHeight: 24, fontSize: 12 },
397
398
  summaryCell: { display: 'flex', flexDirection: 'column', gap: 4, minWidth: 0, whiteSpace: 'nowrap' },
398
399
  summaryLabel: { color: T.muted, fontSize: 11 },
399
400
  summaryValue: { fontSize: 12, fontWeight: 600, fontVariantNumeric: 'tabular-nums' },
@@ -431,6 +432,8 @@ window.__ModuleLoader__.load({
431
432
  boardSection: { display: 'grid', gap: 12, minWidth: 0 },
432
433
  boardSectionHead: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, minHeight: 24 },
433
434
  sectionTitle: { fontSize: 13, fontWeight: 600 },
435
+ settingsHead: { display: 'flex', alignItems: 'baseline', flexWrap: 'wrap', gap: 8, minWidth: 0 },
436
+ settingsHint: { color: T.muted, fontSize: 11, lineHeight: '16px', minWidth: 0, overflowWrap: 'anywhere' },
434
437
  cardBox: {
435
438
  border: `1px solid ${T.border}`, borderRadius: 8, padding: 12, background: T.section,
436
439
  display: 'grid', gap: 4, minWidth: 0,
@@ -1215,7 +1218,7 @@ window.__ModuleLoader__.load({
1215
1218
  }, suffix === '' ? text : `${text} ${suffix}`)
1216
1219
  }
1217
1220
 
1218
- /** P2 API 主区:环+% / 已用·预算 / 真实余额 / 本月已花。 */
1221
+ /** P2 API 主区:环+% / 已用·预算 / 真实余额;第四格留空。 */
1219
1222
  function P2Summary({ provider, summary }) {
1220
1223
  const budget = provider.budget
1221
1224
  const hasBudget = budget !== undefined && budget.state !== 'unset' && budget.amount > 0
@@ -1238,18 +1241,18 @@ window.__ModuleLoader__.load({
1238
1241
  h('span', { style: styles.summaryValue },
1239
1242
  hasBudget ? `${fmtMoney(budget.used, provider.currency)} / ${fmtMoney(budget.amount, provider.currency)}` : '—')),
1240
1243
  h('span', {
1241
- 'data-testid': 'token-dash-summary-balance', style: styles.summaryCell,
1244
+ 'data-testid': 'token-dash-summary-balance',
1245
+ style: {
1246
+ ...styles.summaryCell,
1247
+ gridColumn: '3 / 5',
1248
+ justifySelf: 'end',
1249
+ alignItems: 'flex-end',
1250
+ textAlign: 'right',
1251
+ },
1242
1252
  title: tr('账户真实余额,不受预算影响'),
1243
1253
  },
1244
1254
  h('span', { style: styles.summaryLabel }, tr('真实余额')),
1245
- h('span', { style: styles.summaryValue }, balance ?? '—')),
1246
- h('span', {
1247
- 'data-testid': 'token-dash-summary-month',
1248
- style: { ...styles.summaryCell, alignItems: 'flex-end', textAlign: 'right' },
1249
- title: tr('本月累计消耗,等于已用/预算 的分子'),
1250
- },
1251
- h('span', { style: styles.summaryLabel }, tr('本月已花')),
1252
- h('span', { style: styles.summaryValue }, fmtMoney(provider.usage?.monthCost, provider.currency)))))
1255
+ h('span', { style: styles.summaryValue }, balance ?? '—'))))
1253
1256
  }
1254
1257
 
1255
1258
  /** P2 订阅窗口行:两段数字 + 倒计时 + 绝对时间(无「重置」后缀)。 */
@@ -1809,8 +1812,19 @@ window.__ModuleLoader__.load({
1809
1812
  rows: models,
1810
1813
  providerNames: Object.fromEntries(providers.map((provider) => [provider.id, provider.name])),
1811
1814
  })))),
1812
- h('div', { 'data-testid': 'token-dash-settings-capsule', style: styles.capsule },
1813
- h(SettingsRows, { summary, prefs, onSave: savePrefs, onRefresh: refresh, onRefreshSubs: refreshSubs }))))
1815
+ h('section', { style: styles.boardSection },
1816
+ h('div', { style: styles.boardSectionHead },
1817
+ h('div', { style: styles.settingsHead },
1818
+ h('b', {
1819
+ 'data-testid': 'token-dash-settings-title',
1820
+ style: styles.sectionTitle,
1821
+ }, tr('设置与数据管理')),
1822
+ h('span', {
1823
+ 'data-testid': 'token-dash-settings-locale-hint',
1824
+ style: styles.settingsHint,
1825
+ }, tr('语言跟随DSH设置;当前仅中文/English,其他语言回退英文')))),
1826
+ h('div', { 'data-testid': 'token-dash-settings-capsule', style: styles.capsule },
1827
+ h(SettingsRows, { summary, prefs, onSave: savePrefs, onRefresh: refresh, onRefreshSubs: refreshSubs })))))
1814
1828
  }
1815
1829
 
1816
1830
  return {
@@ -1847,13 +1861,9 @@ window.__ModuleLoader__.load({
1847
1861
  }).catch(() => {})
1848
1862
  } catch { /* ignore */ }
1849
1863
  }
1850
- slots.inject('conversation.hero.agentPreset', () => {
1851
- reportMount('conversation.hero.agentPreset')
1852
- return slots.register({ name: 'conversation.hero.agentPreset', id: 'token-dash-home', order: 10 }, LocaleRoot)
1853
- })
1854
1864
  slots.inject('conversation.composer.dock', () => {
1855
1865
  reportMount('conversation.composer.dock')
1856
- return slots.register({ name: 'conversation.composer.dock', id: 'token-dash-input', order: -1 }, LocaleRoot)
1866
+ return slots.register({ name: 'conversation.composer.dock', id: 'token-dash-input', order: 10 }, LocaleRoot)
1857
1867
  })
1858
1868
  slots.inject('main', () => {
1859
1869
  reportMount('main')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-token-dash",
3
- "version": "1.3.0",
3
+ "version": "2.0.1",
4
4
  "description": "DeepSeek Harness Token 看板:月度预算与订阅配额、账户余额、时间范围费用与真实 Tokens 明细,支持本地 JSON 导出 / 导入备份。",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/providers.js CHANGED
@@ -48,7 +48,7 @@ const PROVIDERS = {
48
48
  },
49
49
  zhipu: {
50
50
  id: 'zhipu',
51
- label: '智谱 AI',
51
+ label: 'Zhipu AI',
52
52
  currency: 'CNY',
53
53
  subscription: true,
54
54
  defaultModel: 'glm-5.3',
@@ -85,7 +85,7 @@ const PROVIDERS = {
85
85
  },
86
86
  qwen: {
87
87
  id: 'qwen',
88
- label: '通义千问',
88
+ label: 'Qwen',
89
89
  currency: 'CNY',
90
90
  subscription: false,
91
91
  defaultModel: 'qwen3.8-max',