dsh-token-gauge 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-token-gauge 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.en.md ADDED
@@ -0,0 +1,54 @@
1
+ # dsh-token-gauge · Token Gauge Dashboard
2
+
3
+ A DeepSeek Harness (DSH) Web sidebar plugin that shows Token usage and cost on a **motorcycle-style dashboard**.
4
+ The needle rotates smoothly as usage grows; usage and cost figures sit below the needle. Click ⚙ to open a settings
5
+ popup to switch style, palette, displayed metrics, usage scope, limits (global/daily/weekly/monthly), language, and export reports.
6
+
7
+ > Default style: **Modern EV Tech** · Default palette: **Neon Blue** · Default metric: **global cumulative**.
8
+
9
+ ## Features
10
+
11
+ - **Live gauge**: SVG arc gauge; needle rotates with `usage / limit`; turns red when over limit.
12
+ - **6 styles**: Modern EV Tech (default), Raw Motorcycle, Luxury Sports, Cute Car, Cyberpunk, Retro Dial.
13
+ - **8 palettes**: Amber Gold, Neon Blue, Track Red, Aurora Green, Sakura Pink, Night Purple, Titanium Silver, Volcano Orange (freely combinable with styles).
14
+ - **Usage & cost**: total tokens, cost (¥), plus optional cards (input/output, cache hit, sessions, today, quota progress).
15
+ - **Limits**: global / daily / weekly / monthly (default global = empty → auto scale).
16
+ - **i18n**: one-click zh / en.
17
+ - **Export**: one-click CSV / JSON usage reports (global, per-model, per day/week/month/session).
18
+ - **Zero runtime deps**: Client is pure DOM/SVG (no React); Host listens to DSH usage events and aggregates on its own.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ # From marketplace
24
+ dsh plugin --profile web add dsh-token-gauge
25
+ dsh web
26
+
27
+ # From source
28
+ npm install
29
+ node build.mjs
30
+ dsh plugin --profile web add .
31
+ ```
32
+
33
+ ## Data & pricing
34
+
35
+ - **Source**: Host subscribes to `assistant/message.usage` in the DSH session event stream and aggregates it.
36
+ - **Views**: global / daily / weekly / monthly / session / model.
37
+ - **Cost**: `(missInput×inMiss + cacheHit×inHit + cacheWrite×write + output×out) / 1,000,000` (¥/M tokens).
38
+ Ships DeepSeek official CNY presets, editable per model in settings (advanced · pricing).
39
+
40
+ ## Settings (⚙ popup)
41
+
42
+ Language · Style · Palette · Metric (global/session/today/daily/weekly/monthly) · Display toggles ·
43
+ Limits (global/daily/weekly/monthly) · Advanced pricing · Export CSV/JSON · Clear / Reset.
44
+
45
+ ## Publish
46
+
47
+ ```bash
48
+ npm version patch
49
+ npm publish --registry=https://registry.npmjs.org
50
+ ```
51
+
52
+ ## License
53
+
54
+ MIT
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # dsh-token-gauge · Token 机车仪表盘
2
+
3
+ DeepSeek Harness(DSH)Web 侧边栏插件:以「机车风格仪表盘」实时展示 Token 用量与费用。
4
+ 指针随用量增长平滑转动,下方显示用量与费用数字;点击 ⚙ 打开设置弹窗,可切换风格、配色、显示内容、用量口径、限额(全局/日/周/月)、语言并导出用量报表。
5
+
6
+ > 默认风格:**现代电车科技**;默认配色:**霓虹蓝**;默认用量口径:**全局累计**。
7
+
8
+ ## 特性
9
+
10
+ - **实时仪表盘**:SVG 弧形表盘,指针随 `用量 / 限额` 比值转动;超限进入红色危险区并提示。
11
+ - **多风格(6 种)**:现代电车科技(默认)、原始机车、豪华跑车、可爱小车、赛博朋克、复古机械表盘。
12
+ - **多配色(8 种)**:琥珀金、霓虹蓝、赛道红、极光绿、樱粉、暗夜紫、钛银、火山橙。风格与配色可自由组合。
13
+ - **用量与费用**:显示总 Token、费用(¥),并可开启输入/输出、缓存命中、会话数、今日用量、限额进度等副卡片。
14
+ - **限额**:支持全局 / 日 / 周 / 月 四类限额(默认全局为空=自动量程)。指针按所选口径对限额扫动。
15
+ - **中英文界面**:设置内一键切换 zh / en。
16
+ - **导出报表**:一键导出 CSV / JSON 用量明细(全局、分模型、按日/周/月/会话)。
17
+ - **零外部依赖**:Client 半边纯原生 DOM/SVG,不依赖 React 等运行时;Host 半边监听 DSH 会话用量事件自行累计,可独立发布。
18
+
19
+ ## 安装
20
+
21
+ ### 方式一:从市场安装(推荐)
22
+ ```bash
23
+ dsh plugin --profile web add dsh-token-gauge
24
+ dsh web
25
+ ```
26
+
27
+ ### 方式二:本地源码安装
28
+ ```bash
29
+ git clone <本仓库> dsh-token-gauge
30
+ cd dsh-token-gauge
31
+ npm install
32
+ node build.mjs # 生成 lib/index.js 与 lib/client.js
33
+ dsh plugin --profile web add . # 读取 package.json 的 dsh 字段
34
+ dsh web
35
+ ```
36
+ 或在已运行 DSH 的情况下以本地 overlay 调试:
37
+ ```bash
38
+ node build.mjs
39
+ dsh web --patch ./cordis.patch.yml
40
+ ```
41
+
42
+ 安装后重启/硬刷新 DSH Web,侧边栏出现「Token 仪表盘」Tab。开始对话产生 Token 后,仪表盘即实时更新。
43
+
44
+ ## 数据来源与费用口径
45
+
46
+ - **数据源**:Host 半边订阅 DSH 会话事件流中的 `assistant/message.usage`(含输入/输出/缓存命中/缓存写入 token),自行累计,不依赖其他插件。
47
+ - **累计视图**:全局 / 当日 / 当周 / 当月 / 会话 / 模型 六套。
48
+ - **费用**:`费用 = (未命中输入×输入未命中单价 + 缓存命中×输入命中单价 + 缓存写入×写入单价 + 输出×输出单价) / 1,000,000`。
49
+ 内置 DeepSeek 官方 ¥ 预设(如 deepseek-chat:输入缓存命中 0.5 / 未命中 2、输出 8;deepseek-reasoner:1 / 4 / 16),可在设置「高级·定价」中按模型自定义(¥/百万 token)。
50
+
51
+ ## 设置项(⚙ 弹窗)
52
+
53
+ | 分组 | 说明 |
54
+ |---|---|
55
+ | 语言 | 中文 / English |
56
+ | 风格 | 6 种机车风格 |
57
+ | 配色 | 8 种调色板 |
58
+ | 用量口径 | 全局累计 / 当前会话 / 今日 / 每日 / 每周 / 每月 |
59
+ | 显示内容 | 用量、费用、输入/输出、缓存节省、会话数、今日用量、限额进度(可独立开关) |
60
+ | 限额 | 全局 / 日 / 周 / 月(留空为不限,仪表盘自动量程) |
61
+ | 高级·定价 | 按模型编辑输入命中/未命中、输出、缓存写入 单价(¥/百万 token) |
62
+ | 导出报表 | CSV / JSON |
63
+ | 其他 | 清空用量、恢复默认 |
64
+
65
+ ## 目录结构
66
+
67
+ ```
68
+ dsh-token-gauge/
69
+ ├── package.json # dsh 字段声明 host/client 半边(市场兼容)
70
+ ├── tsconfig.json
71
+ ├── build.mjs # esbuild 构建脚本
72
+ ├── cordis.patch.yml # 本地 overlay
73
+ ├── src/
74
+ │ ├── host.ts # Host 半边:用量监听/累计/计费/持久化
75
+ │ ├── client.ts # Client 半边:注册侧边栏 Tab + 装配
76
+ │ ├── gauge.ts # SVG 仪表盘(指针/读数)
77
+ │ ├── styles.ts # 风格+配色定义与全局 CSS
78
+ │ ├── settings.ts # 设置弹窗
79
+ │ ├── i18n.ts # 中英文案
80
+ │ ├── export.ts # 报表导出
81
+ │ └── util.ts # 格式化/量程工具
82
+ ├── lib/ # 构建产物(host/client),随包发布
83
+ ├── README.md / README.en.md / LICENSE
84
+ ```
85
+
86
+ ## 上架市场
87
+
88
+ 本包已按 DSH 插件规范命名(`dsh` 字段 + `lib/index.js` / `lib/client.js`),并声明 `files` 白名单。
89
+ 发布到 npm 后,其他用户即可 `dsh plugin --profile web add dsh-token-gauge` 安装发现:
90
+
91
+ ```bash
92
+ npm version patch # 或 minor/major
93
+ npm publish # 须使用官方源 registry.npmjs.org
94
+ ```
95
+
96
+ ## 许可
97
+
98
+ MIT
@@ -0,0 +1,9 @@
1
+ # 本地开发 overlay:将本插件注入 DSH web profile。
2
+ # 用法(先构建产物):
3
+ # node build.mjs
4
+ # dsh web --patch ./cordis.patch.yml
5
+ # 或在已装 dsh 的情况下直接以本地包安装(会读取 package.json 的 dsh 字段,推荐):
6
+ # dsh plugin --profile web add .
7
+ - insert:
8
+ - id: dsh-token-gauge
9
+ name: './src/host.ts'
package/lib/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-token-gauge 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.