dsh-token-dash 1.0.7 → 1.1.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/AGENTS.md CHANGED
@@ -19,6 +19,12 @@
19
19
 
20
20
  - 当前 active plan / checklist 不在此复制;进入目录后按文件头状态判断,避免本文件与文档状态漂移。
21
21
 
22
+ ## 变更授权
23
+
24
+ - **未获用户明确授权,不得直接修改代码**。用户只要求“更新文档 / 记 issue / 完善设计 / 检查文档”时,只允许修改 `docs/`、`AGENTS.md`、`README*` 等文档;禁止编辑 `client.js`、`index.js`、`src/`、`test/`、`scripts/`、`package.json`、`locale/`,也不得测试、打包或安装插件。
25
+ - 代码修改必须等待用户明确说“开始修改 / 可以改代码 / 执行 / 开始开发”等授权。文档确认与代码实施分开进行,禁止把文档和代码改动混在同一轮。
26
+ - plan / checklist 记录本身不等同于代码实施授权;即使文档已确认,也必须再收到用户明确的开始实施指令。发现文档与代码不一致时先报告,未获授权不得顺手修代码。
27
+
22
28
  ## 修改原则
23
29
 
24
30
  - 纯 ESM、零构建;宿主编排入口 `index.js`,客户端 `client.js`;client bundle id 必须等于包名。
package/README.en.md CHANGED
@@ -6,7 +6,8 @@
6
6
 
7
7
  <p align="center">
8
8
  Track daily/monthly model spend and budget headroom right next to the DSH input box:<br />
9
- paste an API Key and the plan is auto-detected (subscription or pay-as-you-go), set a monthly budget, and consumption is estimated locally in real time.
9
+ paste an API Key and the plan is auto-detected (subscription or pay-as-you-go), set a monthly budget, and consumption is estimated locally in real time;<br />
10
+ export the current month as a backup and import it back after switching machines or reinstalling.
10
11
  </p>
11
12
 
12
13
  <p align="center">
@@ -24,10 +25,10 @@
24
25
  </p>
25
26
 
26
27
  - **Providers**: DeepSeek (DS account / API key), GLM Coding (subscription), Kimi Coding (subscription), Kimi / OpenRouter / Qwen (pay-as-you-go; OpenRouter in USD, Qwen CNY domestic / USD international) — paste a key and the billing mode is detected automatically
27
- - **Pages**: bottom bar Pill → floating dashboard → settings; click the pill to expand, click outside to collapse
28
- - **Dashboard data**: per-provider monthly budget progress (used / total / percent), today's spend, account balance, subscription 5h/weekly windows with reset times, model costs grouped by currency, token usage with cache hit rate
29
- - **Settings**: per-provider monthly budget (with currency), three refresh intervals, balance toggle, log viewing / export, check for updates
30
- - **Data**: daily / monthly usage estimated locally (built-in price catalog + community price table), three-layer model attribution, read-only local sessions
28
+ - **Pages**: bottom bar Pill → floating dashboard (usage / settings tabs); click the pill to expand, click outside to collapse
29
+ - **Dashboard data**: time range (today / last 7 days / last 30 days / all), per-provider monthly budget progress (used / total / percent), today's spend, account balance, subscription 5h / weekly windows with reset times; two tiles for **total cost by currency** and **real Tokens (including cache read/write)**; per provider/model cost, requests and hit rate below
30
+ - **Settings**: per-provider monthly budget (with currency, defaults to 100 when empty), three refresh intervals, balance toggle, logs, data export / import, check for updates
31
+ - **Data**: daily / monthly usage estimated locally (built-in price catalog + community price table), three-layer model attribution, read-only local sessions; subscription models count toward Tokens but not cost, and the billing mode is pinned per key instead of following quota flakiness
31
32
 
32
33
  ---
33
34
 
@@ -43,103 +44,37 @@ dsh plugin --profile desktop add dsh-token-dash
43
44
  dsh plugin --profile desktop add github:spartawhy117/dsh-token-dash
44
45
 
45
46
  # Option 3: download dsh-token-dash-x.y.z.tgz from Releases and install locally (offline)
46
- dsh plugin --profile desktop add /path/to/dsh-token-dash-1.0.6.tgz
47
+ dsh plugin --profile desktop add /path/to/dsh-token-dash-1.1.0.tgz
47
48
  ```
48
49
 
49
- Update: run `update` with the same name, or use the in-app updater (settings → check for updates). Remove: run `remove` with the same name; data stays in `$DSH_HOME/dsh-token-dash/`.
50
+ 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/`.
50
51
 
51
52
  ---
52
53
 
53
54
  ## Interface
54
55
 
55
- ```text
56
- P1 · Bottom bar pill (click to open the dashboard)
57
- ┌──────────────────────────────────────────────────────────┐
58
- │ [API] Budget 91.9% · Today ¥0.04 · Balance ¥87.66⌃ │
59
- └──────────────────────────────────────────────────────────┘
60
- ┌──────────────────────────────────────────────────────────┐
61
- │ [Sub] 5h 42% · Week 18%⌃ │
62
- └──────────────────────────────────────────────────────────┘
63
-
64
- P2 · Floating dashboard (opens right above the pill; cards appear as API keys are detected)
65
- ┌──────────────────────────────────────────────────────────┐
66
- │ Token Dashboard Refresh Settings × │
67
- │ Pay-as-you-go (3 detected) just now │
68
- │ ┌──────────────────────────────────────────────────────┐ │
69
- │ │ DeepSeek Budget ¥91.90/¥100.00 · 91.9% Today Bal. │ │
70
- │ │ [=========================================-------] │ │
71
- │ └──────────────────────────────────────────────────────┘ │
72
- │ ┌──────────────────────────────────────────────────────┐ │
73
- │ │ OpenRouter Budget $22.80/$60.00 · 38.0% Today Bal. │ │
74
- │ │ [==================--------------------------------] │ │
75
- │ └──────────────────────────────────────────────────────┘ │
76
- │ ┌──────────────────────────────────────────────────────┐ │
77
- │ │ Qwen Budget ¥0.40/¥5.00 · 8.0% Today Bal. │ │
78
- │ │ [====----------------------------------------------] │ │
79
- │ └──────────────────────────────────────────────────────┘ │
80
- │ Subscriptions (2 detected) │
81
- │ ┌────────────────────────────┐ ┌────────────────────────┐ │
82
- │ │ GLM Coding │ │ Kimi Coding │ │
83
- │ │ 5h 42% Week 18% │ │ 5h 30% Week 12% │ │
84
- │ │ Resets 14:05 │ │ Resets 15:20 │ │
85
- │ └────────────────────────────┘ └────────────────────────┘ │
86
- │ API cost breakdown / this month local estimates │
87
- │ Model usage / this month total 1.31M │
88
- └──────────────────────────────────────────────────────────┘
89
-
90
- P3 · Settings
91
- ┌──────────────────────────────────────────────────────────┐
92
- │ ← Back Token Dashboard [Close] │
93
- │ API billing (3 detected) │
94
- │ DeepSeek Monthly budget [ 100.00 ] CNY │
95
- │ OpenRouter Monthly budget [ 60.00 ] USD │
96
- │ Qwen Monthly budget [ 5.00 ] CNY │
97
- │ Subscriptions (2 detected) [Rescan] │
98
- │ GLM Coding 5h 42% / Week 18% │
99
- │ Kimi Coding 5h 30% / Week 12% │
100
- │ Display │
101
- │ Refresh interval [30s] [1 min] [5 min] │
102
- │ Account balance [On] │
103
- │ Logs │
104
- │ View logs [Open log folder] [Export logs] │
105
- │ Pricing & version │
106
- │ View pricing DeepSeek GLM Kimi OpenRouter Qwen │
107
- │ Version 1.0.6 [Check update]│
108
- └──────────────────────────────────────────────────────────┘
109
-
110
- UI transitions
111
- click pill / Enter
112
- ┌──────────┐ ──────────────────→ ┌────────────┐
113
- │ P1 idle │ │ P2 dashboard│
114
- └──────────┘ ←────────────────── └────────────┘
115
- ↑ click pill / click outside / [×]
116
- │ │[Settings]
117
- │ ▼
118
- │ [← Back] / click outside ┌────────────┐
119
- └──────────────────────────── │ P3 settings │
120
- └────────────┘
121
- ```
56
+ Screenshots below use mock data so the full layout is visible at once:
122
57
 
123
- **P1 · Bottom bar pill** (home workspace row / activity row under the chat input)
58
+ **P1 · Bottom bar pill** (pay-as-you-go and subscription variants; click to open the panel, click outside or `×` to close)
124
59
 
125
60
  <p align="center">
126
- <img src="./docs/pic/pill-home.png" alt="Home pill" />
61
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-api.png" alt="Pay-as-you-go pill" />
127
62
  </p>
128
63
 
129
64
  <p align="center">
130
- <img src="./docs/pic/pill-session.png" alt="Session pill" />
65
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-sub.png" alt="Subscription pill" />
131
66
  </p>
132
67
 
133
- **P2 · Floating dashboard**
68
+ **P2 · Floating dashboard (usage tab)**: monthly budgets and subscriptions, time range, two summary tiles, per-model breakdown
134
69
 
135
70
  <p align="center">
136
- <img src="./docs/pic/panel-dashboard.png" alt="Dashboard" />
71
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/panel-dashboard.png" alt="Dashboard" />
137
72
  </p>
138
73
 
139
- **P3 · Settings**
74
+ **P3 · Settings tab**: API billing, subscriptions, display, data & logs, pricing & version
140
75
 
141
76
  <p align="center">
142
- <img src="./docs/pic/settings.png" alt="Settings" />
77
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/settings.png" alt="Settings" />
143
78
  </p>
144
79
 
145
80
  ---
@@ -155,11 +90,16 @@ npm run logs -- --module slot,adapter.* # filter by module
155
90
 
156
91
  Reads only local session `usage` (title-generation overhead excluded); balances come from official endpoints only, with credentials resolved by the host and never written to disk; costs are local estimates — no billing requests are ever made.
157
92
 
93
+ Backups happen entirely on disk: `Export data` writes one JSON file (settings + current-month usage, without subscription quotas or balances), `Import data` only parses that file, and the existing files are backed up before the current month is overwritten. No network involved.
94
+
95
+ ---
96
+
158
97
  ## Development
159
98
 
160
99
  ```bash
161
100
  npm test # unit tests
162
101
  npm run e2e # end-to-end (temp DSH_HOME + web profile + Playwright)
102
+ npm run shots # regenerate the P1/P2/P3 screenshots in docs/pic from mock data (tools/mock)
163
103
  npm run pack # build the release tarball into build/
164
104
  ```
165
105
 
package/README.md CHANGED
@@ -6,7 +6,8 @@
6
6
 
7
7
  <p align="center">
8
8
  在 DSH 输入框旁看清每日/每月模型消耗与预算余量:<br />
9
- API Key 一填即自动识别订阅还是按量计费,月度预算可设、消耗实时估算。
9
+ API Key 一填即自动识别订阅还是按量计费,月度预算可设、消耗实时估算;<br />
10
+ 当月数据可导出备份,换机或重装后一键导入恢复。
10
11
  </p>
11
12
 
12
13
  <p align="center">
@@ -24,10 +25,10 @@
24
25
  </p>
25
26
 
26
27
  - **厂商支持**:DeepSeek(DS 账号 / API Key)、GLM Coding(订阅)、Kimi Coding(订阅)、Kimi / OpenRouter / Qwen(按量,OpenRouter USD、Qwen 国内 CNY / 国际 USD)——填 Key 自动识别订阅或按量计费
27
- - **页面**:底栏 Pill → 浮层看板 → 设置;Pill 点击展开、点击浮层外收起
28
- - **看板数据**:各供应商月度预算进度(已用 / 总额 / 百分比)、今日消耗、账户余额、订阅 5h/周窗口与重置时间、按币种分组的模型费用、token 用量与缓存命中率
29
- - **设置**:按供应商的月度预算(带币种)、刷新间隔三档、账户余额开关、日志查看 / 导出、检查更新
30
- - **数据口径**:每日 / 每月用量本地估算(内置价格表 + 社区价格表),三层模型归属,只读本地会话
28
+ - **页面**:底栏 Pill → 浮层看板(用量 / 设置双 tab);Pill 点击展开、点击浮层外收起
29
+ - **看板数据**:时间范围(当天 / 近 7 天 / 近 30 天 / 全部)、本月预算进度(已用 / 总额 / 百分比)、今日消耗、账户余额、订阅 5h / 周窗口与重置时间;两格卡显示**总费用(按币种)**与**真实 Tokens(含缓存读写)**;下方按 provider / 模型列出费用、请求数与命中率
30
+ - **设置**:按供应商的月度预算(带币种,未填写默认 100)、刷新间隔三档、账户余额开关、日志、数据导出 / 导入、检查更新
31
+ - **数据口径**:每日 / 每月用量本地估算(内置价格表 + 社区价格表),三层模型归属,只读本地会话;订阅模型计入 Tokens 但不计费用,计费形态按 Key 固化,不随配额接口抖动
31
32
 
32
33
  ---
33
34
 
@@ -43,123 +44,37 @@ dsh plugin --profile desktop add dsh-token-dash
43
44
  dsh plugin --profile desktop add github:spartawhy117/dsh-token-dash
44
45
 
45
46
  # 方式三:从 Releases 下载 dsh-token-dash-x.y.z.tgz 后本地安装(离线场景)
46
- dsh plugin --profile desktop add /path/to/dsh-token-dash-1.0.6.tgz
47
+ dsh plugin --profile desktop add /path/to/dsh-token-dash-1.1.0.tgz
47
48
  ```
48
49
 
49
- 更新:`update` 同名命令(npm / github: 各自同名),或在插件设置页(P3 → 检查更新)内完成。卸载:`remove` 同名命令,数据保留在 `$DSH_HOME/dsh-token-dash/`。
50
+ 更新:`update` 同名命令(npm / github: 各自同名),或在插件设置页「价格与版本」右侧的 `⤓` 内完成。卸载:`remove` 同名命令,数据保留在 `$DSH_HOME/dsh-token-dash/`。
50
51
 
51
52
  ---
52
53
 
53
54
  ## 界面
54
55
 
55
- ```text
56
- P1 · 底栏 Pill(点击展开看板)
57
- ┌──────────────────────────────────────────────────────────┐
58
- │ [API] 预算 91.9% · 今日 ¥0.04 · 余额 ¥87.66⌃ │
59
- └──────────────────────────────────────────────────────────┘
60
- ┌──────────────────────────────────────────────────────────┐
61
- │ [订阅] 5h 42% · 周 18%⌃ │
62
- └──────────────────────────────────────────────────────────┘
63
-
64
- P2 · 浮层看板(pill 正上方弹出;卡片与行随 API Key 侦测动态显示)
65
- ┌──────────────────────────────────────────────────────────┐
66
- │ Token 看板 刷新 设置 关闭│
67
- │ API 按量(已检测 3) 刚刚 │
68
- │ ┌──────────────────────────────────────────────────────┐ │
69
- │ │ DeepSeek 预算 ¥91.90/¥100.00 · 91.9% 今日 余额 │ │
70
- │ │ [=========================================-------] │ │
71
- │ └──────────────────────────────────────────────────────┘ │
72
- │ ┌──────────────────────────────────────────────────────┐ │
73
- │ │ OpenRouter 预算 $22.80/$60.00 · 38.0% 今日 余额 │ │
74
- │ │ [==================--------------------------------] │ │
75
- │ └──────────────────────────────────────────────────────┘ │
76
- │ ┌──────────────────────────────────────────────────────┐ │
77
- │ │ 通义千问 预算 ¥0.40/¥5.00 · 8.0% 今日 余额 │ │
78
- │ │ [====----------------------------------------------] │ │
79
- │ └──────────────────────────────────────────────────────┘ │
80
- │ 订阅套餐(已检测 2) │
81
- │ ┌────────────────────────────┐ ┌────────────────────────┐ │
82
- │ │ GLM Coding │ │ Kimi Coding │ │
83
- │ │ 5h 42% 周 18% │ │ 5h 30% 周 12% │ │
84
- │ │ 重置 14:05 │ │ 重置 15:20 │ │
85
- │ └────────────────────────────┘ └────────────────────────┘ │
86
- │ API 费用明细 / 本月 DSH 本机估算 │
87
- │ CNY 合计 ¥92.30 │
88
- │ DeepSeek / DeepSeek-V4.1-Flash 99.6% ¥91.90 │
89
- │ 通义千问 / Qwen3.8-Max 0.4% ¥0.40 │
90
- │ USD 合计 $22.80 │
91
- │ OpenRouter / DeepSeek-V4.1-Flash 100.0% $22.80 │
92
- │ 模型用量明细 / 本月 合计 1.31M│
93
- │ 模型 请求 输入 命中 输出 │
94
- │ DeepSeek / V4.1-Flash 48 0.11M 0.20M 0.02M│
95
- │ OpenRouter / V4.1-Flash 12 0.02M 0.01M 0.01M│
96
- │ 通义千问 / Qwen3.8-Max 24 0.05M 0.02M 0.01M│
97
- │ GLM Coding / GLM-5.3 64 0.30M 0.52M 0.04M│
98
- └──────────────────────────────────────────────────────────┘
99
-
100
- P3 · 设置
101
- ┌──────────────────────────────────────────────────────────┐
102
- │ ← 返回 Token 看板 [关闭] │
103
- │ API 计费(已检测 3) │
104
- │ ┌──────────────────────────────────────────────────────┐ │
105
- │ │ DeepSeek 月度预算 [ 100.00 ] CNY │ │
106
- │ │ OpenRouter 月度预算 [ 60.00 ] USD │ │
107
- │ │ 通义千问 月度预算 [ 5.00 ] CNY │ │
108
- │ └──────────────────────────────────────────────────────┘ │
109
- │ 订阅计费(已检测 2) [重新检测] │
110
- │ ┌──────────────────────────────────────────────────────┐ │
111
- │ │ GLM Coding 5h 42% / 周 18% │ │
112
- │ │ Kimi Coding 5h 30% / 周 12% │ │
113
- │ └──────────────────────────────────────────────────────┘ │
114
- │ 显示 │
115
- │ ┌──────────────────────────────────────────────────────┐ │
116
- │ │ 刷新间隔 [30 秒] [ 1 分钟 ] [5 分钟] │ │
117
- │ │ 账户余额 [开] │ │
118
- │ └──────────────────────────────────────────────────────┘ │
119
- │ 日志 │
120
- │ ┌──────────────────────────────────────────────────────┐ │
121
- │ │ 查看日志 [打开日志文件夹] [导出日志] │ │
122
- │ └──────────────────────────────────────────────────────┘ │
123
- │ 价格与版本 │
124
- │ ┌──────────────────────────────────────────────────────┐ │
125
- │ │ 查看价格明细 DeepSeek GLM Kimi OpenRouter Qwen │ │
126
- │ │ 版本 1.0.6 [检查更新] │ │
127
- │ └──────────────────────────────────────────────────────┘ │
128
- └──────────────────────────────────────────────────────────┘
129
-
130
- UI 交互转移
131
- 点击 Pill / Enter
132
- ┌──────────┐ ──────────────────→ ┌──────────┐
133
- │ P1 收起 │ │ P2 看板 │
134
- └──────────┘ ←────────────────── └──────────┘
135
- ↑ 点击 Pill / 点击浮层外 / 「关闭」
136
- │ │「设置」
137
- │ ▼
138
- │ 「← 返回」/ 点击浮层外 ┌──────────┐
139
- └───────────────────────── │ P3 设置 │
140
- └──────────┘
141
- ```
56
+ 以下截图使用假数据演示,便于一次看到完整效果:
142
57
 
143
- **P1 · 底栏 Pill**(首页工作区行 / 会话输入框下方活动行)
58
+ **P1 · 底栏 Pill**(按量 / 订阅两种形态;点击展开看板,点击浮层外或 `×` 收起)
144
59
 
145
60
  <p align="center">
146
- <img src="./docs/pic/pill-home.png" alt="首页 Pill" />
61
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-api.png" alt="按量 Pill" />
147
62
  </p>
148
63
 
149
64
  <p align="center">
150
- <img src="./docs/pic/pill-session.png" alt="会话 Pill" />
65
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-sub.png" alt="订阅 Pill" />
151
66
  </p>
152
67
 
153
- **P2 · 浮层看板**
68
+ **P2 · 浮层看板(用量 tab)**:本月预算与订阅、时间范围、两格统计卡、按模型明细
154
69
 
155
70
  <p align="center">
156
- <img src="./docs/pic/panel-dashboard.png" alt="浮层看板" />
71
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/panel-dashboard.png" alt="浮层看板" />
157
72
  </p>
158
73
 
159
- **P3 · 设置**
74
+ **P3 · 设置 tab**:API 计费、订阅、显示、数据与日志、价格与版本
160
75
 
161
76
  <p align="center">
162
- <img src="./docs/pic/settings.png" alt="设置" />
77
+ <img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/settings.png" alt="设置" />
163
78
  </p>
164
79
 
165
80
  ---
@@ -175,11 +90,16 @@ npm run logs -- --module slot,adapter.* # 按模块过滤
175
90
 
176
91
  只读本地会话 `usage`,不统计标题生成开销;余额仅访问官方接口,凭据经宿主解析不落盘;费用为本地估算,不发起计费请求。
177
92
 
93
+ 数据备份在本地完成:`导出数据` 生成一个 JSON 文件(设置 + 当月使用数据,不含订阅配额与余额),`导入数据` 只解析该文件,覆盖当月前自动备份原文件,全过程不经过网络。
94
+
95
+ ---
96
+
178
97
  ## 开发
179
98
 
180
99
  ```bash
181
100
  npm test # 单元测试
182
101
  npm run e2e # 端到端(临时 DSH_HOME + web profile + Playwright)
102
+ npm run shots # 用假数据重新生成 docs/pic 的 P1/P2/P3 截图(tools/mock)
183
103
  npm run pack # 发布 tarball 生成到 build/
184
104
  ```
185
105