dsh-opencode-usage-dashboard 1.0.1 → 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.
Files changed (4) hide show
  1. package/README.md +49 -17
  2. package/client.js +963 -166
  3. package/package.json +1 -1
  4. package/start.mjs +37 -11
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/icon.svg" width="88" alt="OpenCode 用量面板 logo">
2
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/icon.svg" width="88" alt="OpenCode 用量面板 logo">
3
3
  </div>
4
4
 
5
5
  <h1 align="center">OpenCode 用量面板</h1>
@@ -26,7 +26,7 @@
26
26
  > 这是 DeepSeek Harness 的第三方插件,数据来自 OpenCode 官方。
27
27
 
28
28
  <div align="center">
29
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/screenshot-card.png" alt="侧栏用量卡片:用量、额度、预测、趋势、模型五个分块" width="320">
29
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/screenshot-card.png" alt="侧栏用量卡片:用量、额度、预测、趋势、模型五个分块" width="320">
30
30
  <br>
31
31
  <sub>侧栏卡片(浅色主题,示意数据):用量 · 额度 · 预测 · 趋势 · 模型</sub>
32
32
  </div>
@@ -50,12 +50,16 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
50
50
 
51
51
  ### 侧栏卡片
52
52
 
53
- 卡片放在侧栏设置按钮上方;侧栏收起时退化为一个百分比/金额小方块,展开后按偏好顺序显示五个分块。卡片顶部是账户入口:点账户名可切换组织和服务账号,右侧是刷新与设置按钮。
53
+ 卡片放在侧栏设置按钮上方;侧栏收起时退化为一个百分比/金额小方块,展开后按偏好顺序显示分块,默认只开「用量」和「额度重置时间」,其余在设置里随时打开。每个分块标题右侧有个箭头,点一下就把这一块收成一行(只留标题和它的关键数据,例如用量显示当日花费、额度显示本月已用、趋势显示最近一根、模型显示第一名),再点展开。卡片右上角还有收起按钮,收起后只剩一行「OpenCode + 本月剩余(没有月度额度时显示总花费)」,再点一下展开。卡片顶部有一条拖拽热区(悬停露出一小条横线),上下拖动直接调卡片限高,拖到内容放满、不再需要滚动时会自动关掉限高。卡片顶部是账户入口:点账户名可切换组织和服务账号,右侧是刷新、设置与收起按钮。
54
+
55
+ <p align="center">
56
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/card-resize.png" alt="卡片顶部拖拽条:悬停出现「上下拖动调整卡片限高」提示" width="420">
57
+ </p>
54
58
 
55
59
  #### 用量
56
60
 
57
61
  <p align="center">
58
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/card-today.png" alt="用量分块:本月剩余油表,以及今日、本周、本月的花费与请求数" width="300">
62
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/card-today.png" alt="用量分块:本月剩余油表,以及今日、本周、本月的花费与请求数" width="300">
59
63
  </p>
60
64
 
61
65
  - 今日花费、请求数、tokens;
@@ -66,7 +70,7 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
66
70
  #### 额度
67
71
 
68
72
  <p align="center">
69
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/card-quota.png" alt="额度分块:滚动、每周、每月三个窗口与重置倒计时" width="300">
73
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/card-quota.png" alt="额度分块:滚动、每周、每月三个窗口与重置倒计时" width="300">
70
74
  </p>
71
75
 
72
76
  - 滚动 5 小时、本周、本月三个窗口;
@@ -76,7 +80,7 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
76
80
  #### 预测
77
81
 
78
82
  <p align="center">
79
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/card-forecast.png" alt="预测分块:实测花费曲线、预测虚线与 50%/100% 预计日期" width="300">
83
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/card-forecast.png" alt="预测分块:实测花费曲线、预测虚线与 50%/100% 预计日期" width="300">
80
84
  </p>
81
85
 
82
86
  - 按当前计费周期的花费速度做线性外推;
@@ -86,7 +90,7 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
86
90
  #### 趋势
87
91
 
88
92
  <p align="center">
89
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/card-trend.png" alt="趋势分块:7 天或 24 小时的花费、tokens、请求数柱状图" width="300">
93
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/card-trend.png" alt="趋势分块:7 天或 24 小时的花费、tokens、请求数柱状图" width="300">
90
94
  </p>
91
95
 
92
96
  - 7 天 / 24 小时切换;
@@ -96,13 +100,29 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
96
100
  #### 模型
97
101
 
98
102
  <p align="center">
99
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/card-models.png" alt="模型分块:按花费排序的模型条形图" width="300">
103
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/card-models.png" alt="模型分块:按花费排序的模型条形图" width="300">
100
104
  </p>
101
105
 
102
106
  - 按花费排序,条形长度按最高花费归一化;
103
107
  - 最多显示四行;
104
108
  - 没有按模型计费记录时整块隐藏。
105
109
 
110
+ #### 分块收起
111
+
112
+ <p align="center">
113
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/card-part-collapsed.png" alt="分块收起:趋势和模型只留一行标题,右侧显示关键数据" width="300">
114
+ </p>
115
+
116
+ - 每个分块标题右侧有一个箭头,点一下收成一行,再点一下展开;
117
+ - 收起时标题右侧显示这一块的关键数据:
118
+ - 用量 → `当日 · $0.55`
119
+ - 额度重置时间 → `本月 · 23% 已用`
120
+ - 月度预测 → `11/27 · 163%`(重置日期 + 按当前速度的预测值)
121
+ - 趋势 → `11/01 · $0.55`(24 小时时是 `18:00 · $0.12`)
122
+ - 模型 → 只放第一名的模型名
123
+ - 卡片窄的时候这些文字会自动省略成 `…`,标题和箭头位置不动;
124
+ - 最后一个分块的提示气泡朝上弹,不会被卡片底边裁掉。
125
+
106
126
  ### 设置页
107
127
 
108
128
  设置 → OpenCode 套餐。Key 仍在 DSH 的 provider 设置里管理,这一页只读。
@@ -110,7 +130,7 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
110
130
  #### 账户
111
131
 
112
132
  <p align="center">
113
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/settings-account.png" alt="设置页账户面板:按组织分组的账户、服务账号、刷新间隔" width="640">
133
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/settings-account.png" alt="设置页账户面板:按组织分组的账户、服务账号、刷新间隔" width="640">
114
134
  </p>
115
135
 
116
136
  - 账户按组织分组,同一组织的 Key 合成一张卡;
@@ -121,23 +141,25 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
121
141
  #### 显示
122
142
 
123
143
  <p align="center">
124
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/settings-display.png" alt="设置页显示面板:卡片色条开关、色条颜色与四档进度条" width="640">
144
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/settings-display.png" alt="设置页显示面板:卡片色条开关、色条颜色与四档进度条" width="640">
125
145
  </p>
126
146
 
127
147
  - 卡片样式:开关控制是否显示左侧色条,旁边选色条颜色;
148
+ - 卡片限高:默认关闭;打开后分块区最高到设定像素,超出在卡片内滚动(卡片头和账户菜单不会被裁)。上限永远等于「内容自然高度 - 1px」,跟着内容实时变化,输入框只做范围保护;也可以直接拖卡片顶部的把手上下调,拖到顶(已经没有东西可滚)时会自动关掉限高一次;
128
149
  - 进度条分级:四档的名称、区间、颜色都可以改,区间首尾相接;
129
150
  - 「恢复默认」回到 0–50 绿、50–75 黄、75–90 橙、90–100 红。
130
151
 
131
152
  #### 卡片展示
132
153
 
133
154
  <p align="center">
134
- <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/a701fe3/docs/shots/settings-preview.png" alt="设置页卡片展示面板:五个分块的预览、勾选显示与拖拽排序" width="640">
155
+ <img src="https://raw.githubusercontent.com/zhxmt-xm/dsh-opencode-usage-dashboard/ed33013/docs/shots/settings-preview.png" alt="设置页卡片展示面板:一行一个分块,左边是开关,右边是侧栏里的实时渲染" width="640">
135
156
  </p>
136
157
 
137
- - 直接预览五个分块,勾选框控制侧栏显示 / 隐藏;
138
- - 拖拽分块标题调整顺序;
139
- - 趋势的 7 天 / 24 小时、花费 / tokens / 请求数切换也在这里;
140
- - 右上角 `?` 有操作提示。
158
+ - 一行一个分块:左边是该块的开关,右边就是它在侧栏里的真实渲染;
159
+ - 「在侧栏显示」控制整块;「收起」让这一块在侧栏里只留一行标题(收起时标题右侧显示它的关键数据,见上面的「分块收起」);用量块另有「本周」「本月」控制表格行,以及「简化版本」——只保留今日,油表缩到左侧、花费 / 请求数 / Tokens 各占一行,块高度从约 230px 降到约 75px;简化版打开时「本周 / 本月」置灰(选择保留);
160
+ - 悬停行标题时右侧浮出拖拽点,按住标题上下拖即可调整顺序;
161
+ - 趋势的 7 天 / 24 小时、花费 / tokens / 请求数切换直接在右侧预览里点;24 小时轴会按卡片实际宽度自动抽稀标签;
162
+ - 「简化版本」后面的 `?` 是这一项的说明,面板标题旁的 `?` 是操作提示。
141
163
 
142
164
  > 这里没有单独的「趋势图」设置面板:趋势的显示范围与指标就在卡片展示的预览里切换。
143
165
 
@@ -161,7 +183,17 @@ OpenCode 的额度、花费和用量分散在几个接口里:Go 订阅的滚
161
183
  - 一个 OpenCode Go 订阅,或仅有 Console 用量的 OpenCode 账户;
162
184
  - 能访问 `opencode.ai`。
163
185
 
164
- ### 从 GitHub 安装(推荐)
186
+ ### 从 DSH Market 安装(推荐)
187
+
188
+ 插件已经上架 DSH 插件市场:
189
+
190
+ 1. 打开 DSH → 设置 → **插件**(或插件市场);
191
+ 2. 搜索 `dsh-opencode-usage-dashboard` 或「OpenCode 用量看板」;
192
+ 3. 点 **安装**,装完在侧栏就能看到卡片,无需重启。
193
+
194
+ 市场里的版本号跟随 npm 发布;`1.2.0` 之后的功能(分块收起、统一提示气泡等)需要市场里的版本 ≥ 1.2.0。
195
+
196
+ ### 从 GitHub 安装
165
197
 
166
198
  ```sh
167
199
  dsh plugin --profile desktop add github:zhxmt-xm/dsh-opencode-usage-dashboard
@@ -194,7 +226,7 @@ npm start
194
226
 
195
227
  脚本固定执行“卸载 → 清理 `node_modules` 里的旧 junction/临时目录 → 安装所选来源”。DSH 卸载 `link:` 安装时不会删除 junction,直接切换会 `EPERM`,所以从 link 切到 GitHub 不要只靠 DSH 的卸载按钮。
196
228
 
197
- 运行前先完全退出 DSH(Windows 下脚本会检查),并确保 `dsh` 命令在 PATH 上。默认操作 `desktop` profile;需要指定其他 profile 或代理时:
229
+ 运行前不需要退出 DSH:`dsh plugin` 只是把参数转发给 profile 目录里的 pnpm,安装动作和运行中的 DSH 不冲突。profile 默认带 `@deepseek-ai/dsh-hmr`(`root` 为空,只盯 profile manifest 与 patch 文件),profile 一变 DSH 就会重新组合插件;只有它提示「请重启 DSH 使更改生效」(`package-moved`、`host-module` 这类情况)时才需要重启。真被文件占用(`EBUSY` / `EPERM`)时,脚本会提示你先退出 DSH 重跑。`dsh` 命令需要在 PATH 上。默认操作 `desktop` profile;需要指定其他 profile 或代理时:
198
230
 
199
231
  ```powershell
200
232
  $env:DSH_PROFILE = 'web'