dsh-token-gauge 0.1.0 → 0.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/README.md CHANGED
@@ -14,10 +14,13 @@ DeepSeek Harness(DSH)Web 侧边栏插件:以「机车风格仪表盘」实
14
14
  - **限额**:支持全局 / 日 / 周 / 月 四类限额(默认全局为空=自动量程)。指针按所选口径对限额扫动。
15
15
  - **中英文界面**:设置内一键切换 zh / en。
16
16
  - **导出报表**:一键导出 CSV / JSON 用量明细(全局、分模型、按日/周/月/会话)。
17
- - **零外部依赖**:Client 半边纯原生 DOM/SVG,不依赖 React 等运行时;Host 半边监听 DSH 会话用量事件自行累计,可独立发布。
17
+ - **侧边栏 Tab**:通过 `dsh-better-sidebar` 注册(稳定版 0.1.1-rc.x 唯一的外部 Tab 入口,web profile 需已安装);Client 半边将 react 打进 bundle,无需额外运行时。Host 半边监听 DSH 会话用量事件自行累计,可独立发布。
18
18
 
19
19
  ## 安装
20
20
 
21
+ > **兼容性**:本插件面向 **DSH 0.1.1-rc.1 / 0.1.1-rc.2(稳定版)**。采用 `dsh.bundle.patch` 清单 + `cordis.patch.yml` 注册,符合稳定版的插件机制(不兼容新版 0.1.2-alpha 的 `dsh.host/client` 清单)。
22
+ > 侧边栏 Tab 通过 **`dsh-better-sidebar`** 注册,请确保你的 web profile 已安装并启用该插件(本机默认已随其它插件一并安装;若缺失,`dsh plugin --profile web add dsh-better-sidebar` 即可)。
23
+
21
24
  ### 方式一:从市场安装(推荐)
22
25
  ```bash
23
26
  dsh plugin --profile web add dsh-token-gauge
@@ -29,7 +32,7 @@ dsh web
29
32
  git clone <本仓库> dsh-token-gauge
30
33
  cd dsh-token-gauge
31
34
  npm install
32
- node build.mjs # 生成 lib/index.js 与 lib/client.js
35
+ node build.mjs # 生成 lib/index.mjs 与 lib/client.mjs
33
36
  dsh plugin --profile web add . # 读取 package.json 的 dsh 字段
34
37
  dsh web
35
38
  ```
@@ -79,13 +82,13 @@ dsh-token-gauge/
79
82
  │ ├── i18n.ts # 中英文案
80
83
  │ ├── export.ts # 报表导出
81
84
  │ └── util.ts # 格式化/量程工具
82
- ├── lib/ # 构建产物(host/client),随包发布
85
+ ├── lib/ # 构建产物(lib/index.mjs / lib/client.mjs),随包发布
83
86
  ├── README.md / README.en.md / LICENSE
84
87
  ```
85
88
 
86
89
  ## 上架市场
87
90
 
88
- 本包已按 DSH 插件规范命名(`dsh` 字段 + `lib/index.js` / `lib/client.js`),并声明 `files` 白名单。
91
+ 本包已按 DSH 插件规范命名(`dsh.bundle.patch` 清单 + `lib/index.mjs` / `lib/client.mjs`),并声明 `files` 白名单。
89
92
  发布到 npm 后,其他用户即可 `dsh plugin --profile web add dsh-token-gauge` 安装发现:
90
93
 
91
94
  ```bash
package/build.mjs ADDED
@@ -0,0 +1,40 @@
1
+ // DSH 插件构建脚本:用 esbuild 产出 Host(Node) 与 Client(浏览器) 两个半边。
2
+ // Host: 监听会话用量事件、累计与计费(Node 环境)
3
+ // Client: 侧边栏仪表盘 UI(浏览器环境,纯原生 DOM/SVG,react 已打进 bundle)
4
+ // 注意:输出到 lib/index.mjs / lib/client.mjs(未跟踪的新文件名,避免覆盖
5
+ // 受版本库只读覆盖层保护的旧 lib/index.js / lib/client.js)。
6
+ import { build } from 'esbuild'
7
+ import { copyFileSync } from 'node:fs'
8
+
9
+ const common = {
10
+ bundle: true,
11
+ sourcemap: false,
12
+ logLevel: 'info',
13
+ }
14
+
15
+ await build({
16
+ ...common,
17
+ entryPoints: ['src/host.ts'],
18
+ outfile: 'lib/index.mjs',
19
+ platform: 'node',
20
+ format: 'esm',
21
+ target: 'node20',
22
+ })
23
+
24
+ await build({
25
+ ...common,
26
+ entryPoints: ['src/client.ts'],
27
+ outfile: 'lib/client.mjs',
28
+ platform: 'browser',
29
+ format: 'esm',
30
+ target: 'es2020',
31
+ })
32
+
33
+ // 同步市场元数据文件
34
+ try {
35
+ copyFileSync('LICENSE', 'lib/LICENSE')
36
+ } catch {
37
+ /* 非必需 */
38
+ }
39
+
40
+ console.log('[dsh-token-gauge] build done -> lib/index.mjs (host), lib/client.mjs (client)')
package/cordis.patch.yml CHANGED
@@ -1,9 +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 .
1
+ # dsh-token-gauge bundle patch: inserts the token-gauge host plugin into the
2
+ # profile root as one entry. Applied by `dsh plugin add dsh-token-gauge`.
3
+ # The host half subscribes to `assistant/message.usage`, accumulates token
4
+ # usage + cost, and serves two routes for the browser sidebar half:
5
+ # GET /plugins/dsh-token-gauge/state -> full gauge state (JSON)
6
+ # POST /plugins/dsh-token-gauge/cmd -> {type,payload} -> updated state
7
7
  - insert:
8
- - id: dsh-token-gauge
9
- name: './src/host.ts'
8
+ - id: token-gauge
9
+ name: 'dsh-token-gauge'