@loommii/dsh-provider-usage 0.6.0 → 0.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 loommii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # dsh-provider-usage — DSH「用量中心」
2
2
 
3
- > 当前版本 **v0.6.0** · npm `@loommii/dsh-provider-usage` · [更新历史](docs/CHANGELOG.md)
3
+ > 当前版本 **v0.6.1** · npm `@loommii/dsh-provider-usage` · [更新历史](docs/CHANGELOG.md)
4
4
 
5
- DSH Web GUI 插件 **「用量中心」**:一个常驻右下角的用量卡片,实时显示你的 AI 服务用量 / 余额,不用再打开网页查。
5
+ DSH Web GUI 插件 **「用量中心」**:一个常驻右下角的用量卡片,实时显示你的 AI 服务用量 / 余额,不用再打开网页查;附带本地 Token 统计页,不联网也能看自己今天用了多少。
6
6
 
7
7
  ## v0.6.0 更新摘要
8
8
 
@@ -26,23 +26,36 @@ DSH Web GUI 插件 **「用量中心」**:一个常驻右下角的用量卡片
26
26
  - **常驻用量卡片**:右下角悬浮,一眼看到剩余量;可随意拖动,位置自动记住
27
27
  - **自动刷新**:每 30s 自动更新;想看最新数据点卡片上的 ↻ 立即重新查询
28
28
  - **多实例**:可以同时配置多个提供方(如多个 OpenCode Go 账号),点卡片 logo / 名称切换查看
29
+ - **本地 Token 统计**:自读本机 `$DSH_HOME/sessions` 会话文件,按天聚合今天的 Token 用量(总量 + 按模型汇总),**只读本地、不联网**;数据落盘 `$DSH_HOME/provider-usage/daily-stats/`,历史天封存只算今天
29
30
  - **状态提示**:正常 / 未更新 / 注意 / 错误,请求中显示「查询中」动画
30
31
  - **Key 安全**:密钥只在 DSH 进程内解析使用,界面上一律打码显示;自定义 Key 可加密保存在本机(AES-256 加密),不落明文
31
32
 
32
- ## 安装
33
+ ## 安装 / 卸载
33
34
 
34
- ```sh
35
- # 从 npm 安装
36
- dsh plugin --profile web add @loommii/dsh-provider-usage
35
+ ### GitHub
37
36
 
38
- # 从 GitHub 安装(等价,同一份代码 v0.6.0)
37
+ ```sh
38
+ # 安装
39
39
  dsh plugin --profile web add github:loommii/dsh-provider-usage
40
40
 
41
41
  # 安装指定版本(可选)
42
42
  dsh plugin --profile web add github:loommii/dsh-provider-usage#v0.6.0
43
+
44
+ # 卸载
45
+ dsh plugin --profile web remove @loommii/dsh-provider-usage
43
46
  ```
44
47
 
45
- 安装后重启 `dsh web` 即可在设置页看到「用量中心」。
48
+ ### npm
49
+
50
+ ```sh
51
+ # 安装
52
+ dsh plugin --profile web add @loommii/dsh-provider-usage
53
+
54
+ # 卸载
55
+ dsh plugin --profile web remove @loommii/dsh-provider-usage
56
+ ```
57
+
58
+ 安装 / 卸载后重启 `dsh web` 即可生效。
46
59
 
47
60
  > npm 包名为 `@loommii/dsh-provider-usage`(无 scope 的 `dsh-provider-usage` 在 npm 上已被他人占用)。
48
61
 
@@ -59,5 +72,22 @@ dsh plugin --profile web add github:loommii/dsh-provider-usage#v0.6.0
59
72
  ## 使用说明
60
73
 
61
74
  - 提供方实例的增删改、Key 设置都在 **设置 → 用量中心** 里完成,改动即时生效,无需重启
75
+ - 设置页有两个标签:「提供方」管理实例,「用量统计」查看本地 Token 统计
62
76
  - 设置保存在本机浏览器中;删掉实例不会上传或泄露任何 Key
63
77
  - 卡片拖动后的位置会自动保存,下次打开还是老位置
78
+
79
+ ## 配置项(可选)
80
+
81
+ 以下配置写入 profile 的 bundle 配置(`cordis.patch.yml` / 设置页),全部有合理默认值,不配也能用:
82
+
83
+ | 配置项 | 默认值 | 说明 |
84
+ |---|---|---|
85
+ | `baseUrl` | – | 仅覆盖 OpenCode Go 的查询地址(历史语义);其余提供方用内置官方地址 |
86
+ | `timeoutMs` | `15000` | 出站请求超时(上限 30000) |
87
+ | `subscriptionTimeoutMs` | `5000` | Command Code 订阅端点(次要端点)超时;慢网络可调大 |
88
+ | `maxSessions` | `30` | 本地 Token 统计扫描的会话文件数上限(上限 100) |
89
+ | `sessionsDir` | `$DSH_HOME/sessions` | 本地 Token 统计的会话目录覆盖 |
90
+
91
+ ## License
92
+
93
+ [MIT](LICENSE)
package/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.6.1(2026-08-31)
4
+
5
+ ### 修复
6
+ - 卡片 hover 标题 `title` 从空字符串改为显示当前提供方名(多 provider 时显示「点击切换」)
7
+
8
+ ### 小功能
9
+ - a11y:`prefers-reduced-motion` 媒体查询禁用呼吸动画与进度条扫光(尊重系统级无障碍偏好)
10
+
11
+ ### 文档
12
+ - 新增 `LICENSE`(MIT);`package.json` `files` 补全以确保 npm tarball 包含 LICENSE
13
+ - README:顶部副标题加「附带本地 Token 统计页」、功能列表新增 Token 统计要点、安装/卸载章节拆分 GitHub 与 npm 两栏、使用说明补「两个标签」提示、新增「配置项」表格、新增 License 章节
14
+
3
15
  ## v0.6.0(2026-08-31)
4
16
 
5
17
  > **npm 首发**:本版本同步发布至 npm `@loommii/dsh-provider-usage`(无 scope 的 `dsh-provider-usage` 包名已被他人占用,故改用账号 scope)。npm 与 GitHub 渠道**同号同码**(同一提交、同一 tag `v0.6.0`);scoped 包首次发布需 `--access public`(已在 `publishConfig` 配置),安装方无感。
package/lib/client.js CHANGED
@@ -68,7 +68,7 @@ window.__ModuleLoader__.load({
68
68
  // 用量统计页样式
69
69
  ".zGbnIq_statsGrid{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:12px 0;display:grid}.zGbnIq_stat{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);border-radius:10px;flex-direction:column;gap:3px;padding:10px 12px;display:flex}.zGbnIq_statValue{color:var(--dsw-alias-label-primary);font-size:17px;font-weight:600;font-variant-numeric:tabular-nums;line-height:24px;white-space:nowrap}.zGbnIq_cntCard{cursor:pointer;transition:border-color .15s,background .15s}.zGbnIq_cntCard:hover{border-color:var(--dsw-alias-border-l3);background:var(--dsw-alias-interactive-bg-hover-solid)}.zGbnIq_cntCard:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-border-l3);outline:none}.zGbnIq_statLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.zGbnIq_chips{flex-wrap:wrap;gap:6px;margin:10px 0 2px;display:flex}.zGbnIq_chip{border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;border-radius:999px;padding:2px 12px;font-size:12px;line-height:18px}.zGbnIq_chip:hover{color:var(--dsw-alias-label-primary)}.zGbnIq_chip[data-active=true]{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,transparent)}",
70
70
  ".zGbnIq_json{max-height:260px;overflow:auto;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;margin:10px 0 0;padding:8px 10px;color:var(--dsw-alias-label-secondary);font-family:var(--ds-font-family-code);font-size:12px;line-height:18px;white-space:pre-wrap;word-break:break-all}",
71
- ".zGbnIq_progress{height:3px;border-radius:999px;background:rgba(255,255,255,.08);overflow:hidden;position:relative;margin:8px 0 2px}.zGbnIq_progress i{position:absolute;top:0;bottom:0;width:36%;border-radius:999px;background:var(--dsw-alias-brand-primary,#6c8ef5);animation:zGbnIq-progress 1.2s ease-in-out infinite}@keyframes zGbnIq-progress{0%{left:-36%}100%{left:100%}}",
71
+ ".zGbnIq_progress{height:3px;border-radius:999px;background:rgba(255,255,255,.08);overflow:hidden;position:relative;margin:8px 0 2px}.zGbnIq_progress i{position:absolute;top:0;bottom:0;width:36%;border-radius:999px;background:var(--dsw-alias-brand-primary,#6c8ef5);animation:zGbnIq-progress 1.2s ease-in-out infinite}@keyframes zGbnIq-progress{0%{left:-36%}100%{left:100%}}@media (prefers-reduced-motion:reduce){.zGbnIq_progress i{animation:none;left:32%}}",
72
72
  ".zGbnIq_modelTable{width:100%;border-collapse:collapse;font-size:12px;line-height:18px}.zGbnIq_modelTable th,.zGbnIq_modelTable td{text-align:left;padding:5px 8px;vertical-align:middle;white-space:nowrap}.zGbnIq_modelTable thead th{color:var(--dsw-alias-label-tertiary);font-weight:500;border-bottom:1px solid var(--dsw-alias-border-l2)}.zGbnIq_modelTable tbody tr{border-bottom:1px solid var(--dsw-alias-border-l2)}.zGbnIq_modelTable tbody tr:last-child{border-bottom:none}.zGbnIq_modelTable tbody tr:hover{background:var(--dsw-alias-interactive-bg-hover)}.zGbnIq_modelTable .zGbnIq_num{text-align:right;font-variant-numeric:tabular-nums;overflow:visible}.zGbnIq_modelTable .zGbnIq_numText{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom}.zGbnIq_modelTable th.zGbnIq_candidateId{max-width:280px;overflow:visible;font-family:var(--ds-font-family-code);font-weight:400;font-size:13px}.zGbnIq_modelTable .zGbnIq_modelName{display:inline-block;max-width:280px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom}.dsh-pu-numCell{cursor:pointer;display:inline-block;max-width:100%;vertical-align:bottom}",
73
73
  // ── 常驻用量卡片(Rainytoken 暗色视觉:暖深底/草莓粉/三色窗口条)──
74
74
  '.dsh-pu-card{position:fixed;right:16px;bottom:16px;width:304px;box-sizing:border-box;border-radius:16px;pointer-events:auto;background:linear-gradient(180deg,#2A1F25 0%,#241A20 100%);border:1px solid #4D3A42;box-shadow:0 10px 28px rgba(31,20,25,.5),0 2px 6px rgba(31,20,25,.4);padding:14px 14px 12px;font-family:inherit;color:#EFE0E5;font-size:13px;line-height:1.5;touch-action:none;user-select:none;cursor:grab;transition:border-color .2s,transform .2s,box-shadow .2s}',
@@ -117,7 +117,7 @@ window.__ModuleLoader__.load({
117
117
  // ── 官方样式补充:状态点三态(官方只有 configured/missing)与添加按钮加号 ──
118
118
  '.zGbnIq_credentialDot.dsh-pu-dot-loading{background:var(--dsw-alias-state-success-primary,#22c55e);animation:dsh-pu-ms-breathe 1.2s ease-in-out infinite}',
119
119
  '.zGbnIq_credentialDot.dsh-pu-dot-gray{background:var(--dsw-alias-label-tertiary,#8b93a7)}',
120
- '@keyframes dsh-pu-ms-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.72)}}',
120
+ '@keyframes dsh-pu-ms-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.72)}}@media (prefers-reduced-motion:reduce){.dsh-pu-chip.dsh-pu-chip-loading i,.zGbnIq_credentialDot.dsh-pu-dot-loading{animation:none}}',
121
121
  '.ms-plus{color:var(--dsw-alias-brand-primary);font-size:15px;line-height:1}',
122
122
  ].join('');
123
123
  var tag = document.createElement('style');
@@ -457,7 +457,7 @@ window.__ModuleLoader__.load({
457
457
  React.createElement('div', { className: 'dsh-pu-card-head' },
458
458
  React.createElement('button', {
459
459
  type: 'button', className: 'dsh-pu-title-btn',
460
- title: multiple ? '选择提供方' : '',
460
+ title: multiple ? current.name + '(点击切换提供方)' : current.name,
461
461
  onClick: function (e) { if (draggedRef.current) { draggedRef.current = false; return; } e.stopPropagation(); if (multiple) setMenuOpen(!menuOpen); },
462
462
  },
463
463
  React.createElement('span', { className: 'dsh-pu-logo ' + logoClass }, logoEl),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loommii/dsh-provider-usage",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "DSH 插件(用量中心):常驻用量卡片 · 多提供方用量/余额查询(OpenCode Go 订阅 + DeepSeek 余额 + Command Code 订阅/余额,对齐 cc-switch 查询语义)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -10,6 +10,7 @@
10
10
  "files": [
11
11
  "lib",
12
12
  "cordis.patch.yml",
13
+ "LICENSE",
13
14
  "README.md",
14
15
  "docs/CHANGELOG.md"
15
16
  ],