dsh-all-usage 1.0.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/LICENSE +21 -0
- package/README.md +146 -0
- package/assets/screenshot-1.png +0 -0
- package/assets/screenshot-2.png +0 -0
- package/cordis.patch.yml +5 -0
- package/lib/client.js +1063 -0
- package/lib/index.js +630 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-all-usage contributors
|
|
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
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# dsh-all-usage
|
|
2
|
+
|
|
3
|
+
[](https://awesome-dsh-plugin.com)
|
|
4
|
+
|
|
5
|
+
[中文](#中文) · [English](#english)
|
|
6
|
+
|
|
7
|
+
## 中文
|
|
8
|
+
|
|
9
|
+
DeepSeek Harness 全量用量看板:按模型、供应商、工作区和时间范围分析 Token、缓存与账户余额。
|
|
10
|
+
|
|
11
|
+
### 功能
|
|
12
|
+
|
|
13
|
+
- **热力图**:53 周使用热力图;按工作区筛选并查看每日回合与 Token 明细
|
|
14
|
+
- **模型统计**:支持混合查看、按模型合并、按供应商汇总三种维度,展示调用次数、各类 Token 与缓存命中率
|
|
15
|
+
- **摘要与工作区**:Token 用量、缓存命中、账户余额、连续使用、工作区 Token 分布和明细
|
|
16
|
+
- **导出**:按当前时间范围和模型聚合方式导出 CSV
|
|
17
|
+
- **时间范围**:今日、近 30 天、近 90 天、全部
|
|
18
|
+
- **工作区别名**:在侧栏入口打开看板后管理,持久化保存到 $DSH_HOME/storages 的 KV 单元 `all-usage-aliases`
|
|
19
|
+
- **界面语言**:在看板顶部切换中文与 English;选择会保存到浏览器本地
|
|
20
|
+
|
|
21
|
+
### 截图 / Screenshots
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
### 安装
|
|
28
|
+
|
|
29
|
+
本插件是标准的 DSH 社区插件包(声明 `dsh.bundle` manifest 与 Web Client),数据全部来自持久化会话日志,安装后自动回填历史。
|
|
30
|
+
|
|
31
|
+
#### 官方插件命令(推荐)
|
|
32
|
+
|
|
33
|
+
~~~bash
|
|
34
|
+
dsh plugin --profile web add github:ParticleLight/dsh-all-usage
|
|
35
|
+
~~~
|
|
36
|
+
|
|
37
|
+
安装命令会装配 bundle;随后刷新浏览器页面以加载 Client,无需手动修改 profile。若当前 DSH 版本未动态装配新包,请按 DSH 的提示重载包或重启进程。
|
|
38
|
+
|
|
39
|
+
#### 手动注册(本地包)
|
|
40
|
+
|
|
41
|
+
1. 把本目录放入任意位置,并在 $DSH_HOME/profiles/node_modules/ 下创建指向本目录的符号链接(Windows 用 junction):
|
|
42
|
+
|
|
43
|
+
~~~powershell
|
|
44
|
+
New-Item -ItemType Junction -Path (Join-Path $env:DSH_HOME 'profiles/node_modules/dsh-all-usage') -Target '<本目录绝对路径>'
|
|
45
|
+
~~~
|
|
46
|
+
|
|
47
|
+
2. 在 $DSH_HOME/profiles/web/cordis.patch.yml 添加一行:
|
|
48
|
+
|
|
49
|
+
~~~yaml
|
|
50
|
+
- insert:
|
|
51
|
+
- id: all-usage
|
|
52
|
+
name: dsh-all-usage
|
|
53
|
+
~~~
|
|
54
|
+
|
|
55
|
+
用户 patch 层会被热重载:保存后刷新页面即可。
|
|
56
|
+
|
|
57
|
+
### 架构
|
|
58
|
+
|
|
59
|
+
- **Host 端**(`lib/index.js`):扫描持久化会话日志聚合用量(`turn/end` + `assistant/message.usage`),监听 `session/event` 实时折叠;通过 `webServer` 服务注册数据路由:
|
|
60
|
+
- `GET /api/all-usage` — 统计快照
|
|
61
|
+
- `GET /api/all-usage/balance?force=1` — 账户余额(复用 `llm-deepseek` 的 API Key 配置)
|
|
62
|
+
- `POST /api/all-usage/alias` — 设置工作区别名
|
|
63
|
+
- **Client 端**(`lib/client.js`):`window.__ModuleLoader__` 工厂格式的浏览器 bundle,注册侧边栏「用量统计」入口(`sidebar.footer.action` 槽位)。所有 API 仅接受本机 loopback 请求并拒绝显式跨域请求;余额读取与别名写入还要求插件启动时生成、仅在当前进程有效的令牌(余额 GET 兼容浏览器省略 Origin)。英文模式的日期分桶、范围筛选、连续使用、热力图和导出时间统一按 UTC;中文模式按本地时区。
|
|
64
|
+
|
|
65
|
+
### 数据说明
|
|
66
|
+
|
|
67
|
+
- 使用次数与 Token 全部来自 DSH 持久化会话日志,插件激活时会自动回填全部历史,插件卸载/重启后数据不丢
|
|
68
|
+
- 同一会话的同一 `turn / step` 只保留一份最终 usage;重试或替换消息会替换旧贡献,不重复累计
|
|
69
|
+
- 看板中的总处理量 = 输入 + 输出 + 缓存读写 + 推理;缓存命中表示复用的上下文 Token,不等于新生成 Token 或实际费用
|
|
70
|
+
- 余额查询走 DeepSeek 官方 `/user/balance` 接口;未配置 API Key 时卡片显示引导文案
|
|
71
|
+
- 仅统计能归属到已注册工作区(按会话 cwd 匹配)的会话
|
|
72
|
+
|
|
73
|
+
### 开发
|
|
74
|
+
|
|
75
|
+
- 修改 `lib/client.js` 后刷新页面即可;修改 `lib/index.js` 后,需由 DSH 重载该包或重启进程,单纯刷新页面不会替换已运行的 Host 代码
|
|
76
|
+
- 插件包无第三方依赖:Host 端只使用 Cordis 服务,Client 端只使用 runtime 提供的 React 模块
|
|
77
|
+
|
|
78
|
+
## English
|
|
79
|
+
|
|
80
|
+
A full usage dashboard for DeepSeek Harness. Analyze tokens, cache behavior, account balance, and activity by model, provider, workspace, and time range.
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
- **Heatmap**: a 53-week activity heatmap with workspace filters and daily turn/token details
|
|
85
|
+
- **Model analytics**: mixed view, model-merged view, and provider summary with calls, token categories, and cache hit rate
|
|
86
|
+
- **Summary and workspaces**: processed tokens, cache hits, account balance, usage streaks, workspace distribution, and details
|
|
87
|
+
- **CSV export**: export data using the selected time range and aggregation mode
|
|
88
|
+
- **Time ranges**: today, last 30 days, last 90 days, or all time
|
|
89
|
+
- **Workspace aliases**: manage aliases from the sidebar dashboard; values persist in the $DSH_HOME/storages KV cell `all-usage-aliases`
|
|
90
|
+
- **Interface language**: switch between Chinese and English from the dashboard header; your choice persists locally in the browser
|
|
91
|
+
|
|
92
|
+
### Installation
|
|
93
|
+
|
|
94
|
+
This is a standard DSH community bundle. It declares a `dsh.bundle` manifest and a web client, and backfills its data from persisted session logs after installation.
|
|
95
|
+
|
|
96
|
+
#### Official plugin command (recommended)
|
|
97
|
+
|
|
98
|
+
~~~bash
|
|
99
|
+
dsh plugin --profile web add github:ParticleLight/dsh-all-usage
|
|
100
|
+
~~~
|
|
101
|
+
|
|
102
|
+
The installation command assembles the bundle. Refresh the browser page to load the client; no manual profile edits are required. If your DSH version does not dynamically assemble newly installed packages, use its supported package reload or restart the process.
|
|
103
|
+
|
|
104
|
+
#### Manual local registration
|
|
105
|
+
|
|
106
|
+
1. Place this directory anywhere and create a symlink to it under $DSH_HOME/profiles/node_modules/ (use a junction on Windows):
|
|
107
|
+
|
|
108
|
+
~~~powershell
|
|
109
|
+
New-Item -ItemType Junction -Path (Join-Path $env:DSH_HOME 'profiles/node_modules/dsh-all-usage') -Target '<absolute plugin path>'
|
|
110
|
+
~~~
|
|
111
|
+
|
|
112
|
+
2. Add this entry to $DSH_HOME/profiles/web/cordis.patch.yml:
|
|
113
|
+
|
|
114
|
+
~~~yaml
|
|
115
|
+
- insert:
|
|
116
|
+
- id: all-usage
|
|
117
|
+
name: dsh-all-usage
|
|
118
|
+
~~~
|
|
119
|
+
|
|
120
|
+
The profile patch layer hot-reloads; save the file and refresh the page.
|
|
121
|
+
|
|
122
|
+
### Architecture
|
|
123
|
+
|
|
124
|
+
- **Host** (`lib/index.js`): aggregates persisted session logs (`turn/end` and `assistant/message.usage`), folds live `session/event` updates, and exposes data routes through `webServer`:
|
|
125
|
+
- `GET /api/all-usage` — usage snapshot
|
|
126
|
+
- `GET /api/all-usage/balance?force=1` — account balance using the configured `llm-deepseek` API key
|
|
127
|
+
- `POST /api/all-usage/alias` — update workspace aliases
|
|
128
|
+
- **Client** (`lib/client.js`): a `window.__ModuleLoader__` browser bundle that registers the “Usage statistics” sidebar entry through the `sidebar.footer.action` slot. All API routes accept loopback requests and reject an explicit cross-origin Origin; balance reads and alias writes also require a process-scoped token generated when the plugin starts (the balance GET tolerates browsers omitting Origin).
|
|
129
|
+
|
|
130
|
+
### Data semantics
|
|
131
|
+
|
|
132
|
+
- All calls and tokens come from persisted DSH session logs; historical data is backfilled when the plugin activates and survives reloads or uninstall/reinstall cycles
|
|
133
|
+
- For each session and logical `turn / step`, only the final usage contribution is kept; retries or replaced messages do not double-count
|
|
134
|
+
- Processed tokens = input + output + cache read/write + reasoning; a cache hit means reused context, not newly generated tokens or actual cost
|
|
135
|
+
- Balance data comes from DeepSeek’s official `/user/balance` endpoint; the card shows guidance when no API key is configured
|
|
136
|
+
- English mode uses UTC for date buckets, range filters, streaks, heatmap dates, and export timestamps; Chinese mode uses local time
|
|
137
|
+
- Only sessions that can be mapped to a registered workspace by their working directory are included
|
|
138
|
+
|
|
139
|
+
### Development
|
|
140
|
+
|
|
141
|
+
- After editing `lib/client.js`, refresh the page. After editing `lib/index.js`, reload the package through DSH or restart the process; a page refresh alone cannot replace running host code
|
|
142
|
+
- The plugin has no third-party package dependencies: the Host uses Cordis services and the Client uses the runtime-provided React module
|
|
143
|
+
|
|
144
|
+
## License / 许可证
|
|
145
|
+
|
|
146
|
+
MIT
|
|
Binary file
|
|
Binary file
|