@jerry_chzy/dsh-token-usage 0.1.0 → 0.1.2

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.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/client/ui-token-usage/README.md
5
- README.md: 03a27eeabcfbbffc9511811026ddc4f5e183697e
6
- README.zh.md: 17e3825cae5b4c0cfb299e6c0238936b2b851277
5
+ README.md: 8ca136d3209736e290e2ddfc90931660956c8060
6
+ README.zh.md: 7643a421d74e35b1264b1e8cb09bb1ed9bb26003
package/README.md CHANGED
@@ -11,6 +11,31 @@ English | [中文](README.zh.md)
11
11
 
12
12
  This package renders one composer-dock line under the Web GUI's composer: the current conversation's token usage split into its four disjoint billing buckets — uncached input, cache read, cache write, and output — plus an estimated cost. The counts come from the durable `tokenUsage` projection, so paging and compaction cannot change them; the slot's session scope makes the readout per-conversation. Cost comes from the plugin's `pricing` config, matched against the session's last-used model, and stays hidden when that model has no configured price. The host half also backfills the money Web never showed: one pass over the archived corpus writes a `TOKEN_COST.md` per session working directory, and the readout points at it when a route has no price.
13
13
 
14
+ ## `/usage` quick start
15
+
16
+ Send `/usage` in any conversation. Where the client executes commands (the `dsh` CLI, the Web composer) it runs as a registered command; where it can only send a message (a phone client, a remote page, an APP page) the node half answers at the model boundary. Either way the provider is never called, no usage is settled, and the context occupancy reading keeps its value.
17
+
18
+ ```text
19
+ 合计 264M · 输入 2.6M · 缓存读 261M · 输出 608K · ≈¥20.40 · 上下文 440K/1M
20
+ ```
21
+
22
+ Rename the command and localize its copy through the row config:
23
+
24
+ ```yaml
25
+ - id: ui-token-usage
26
+ name: '@deepseek-ai/dsh-client-ui-token-usage'
27
+ config:
28
+ command:
29
+ name: usage
30
+ labels:
31
+ total: 合计
32
+ input: 输入
33
+ cacheRead: 缓存读
34
+ cacheWrite: 缓存写
35
+ output: 输出
36
+ context: 上下文
37
+ ```
38
+
14
39
  ## Table of Contents
15
40
 
16
41
  - [Use this package](#use-this-package)
@@ -38,6 +63,12 @@ dsh plugin --profile <name> add <the .tgz path the script prints>
38
63
 
39
64
  The script stages a copy whose manifest rewrites every `workspace:` range to the workspace version and drops `devDependencies`, because a workspace `pnpm pack` leaves `workspace:` in `devDependencies` and a profile install then fails with `ERR_PNPM_CANNOT_RESOLVE_WORKSPACE_PROTOCOL`. The package declares `dsh.bundle.patch`, so the profile mounts the readout row from the package's own `cordis.patch.yml` without a manual insert. The `desktop` profile belongs to the Electron application and rejects `dsh plugin` by design; install there through the application's own plugin surface.
40
65
 
66
+ The published build installs from npm directly, without packing anything:
67
+
68
+ ```powershell
69
+ dsh plugin --profile web add @jerry_chzy/dsh-token-usage@0.1.1 --registry=https://registry.npmjs.org
70
+ ```
71
+
41
72
  Configure prices through this plugin's row config. `pricing` maps a model-id prefix to CNY per million tokens, and the longest matching prefix wins, so dated or vision routes can share or override a base model's price:
42
73
 
43
74
  ```yaml
package/README.zh.md CHANGED
@@ -11,6 +11,31 @@ kind: "package-reference"
11
11
 
12
12
  本包在 Web GUI 的 composer 下方渲染一行 token 用量读数:当前对话的用量拆成四个互不相交的计费桶——未缓存输入、缓存读、缓存写、输出——再加一个估算花费。计数来自持久的 `tokenUsage` 投影,因此分页与压缩都不会改变它;slot 的会话作用域让读数按对话独立。花费来自本插件的 `pricing` 配置,按会话最后使用的模型匹配;该模型没有配置价格时不显示金额。宿主半边还会把 Web 从未显示的金额补出来:对存档语料跑一趟,给每个会话工作目录写一个 `TOKEN_COST.md`;当某条路由没有价格时,读数会指向该文件。
13
13
 
14
+ ## `/usage` 速查
15
+
16
+ 在任意对话里发送 `/usage`。会执行命令的客户端(`dsh` CLI、Web composer)按注册命令执行;只能发消息的客户端(手机端、远端页面、APP 页面)由 node 半边在模型边界回答。两种方式都不调用提供方、不产生 usage 结算,上下文占用读数保持不变。
17
+
18
+ ```text
19
+ 合计 264M · 输入 2.6M · 缓存读 261M · 输出 608K · ≈¥20.40 · 上下文 440K/1M
20
+ ```
21
+
22
+ 通过行配置改命令名并汉化文案:
23
+
24
+ ```yaml
25
+ - id: ui-token-usage
26
+ name: '@deepseek-ai/dsh-client-ui-token-usage'
27
+ config:
28
+ command:
29
+ name: usage
30
+ labels:
31
+ total: 合计
32
+ input: 输入
33
+ cacheRead: 缓存读
34
+ cacheWrite: 缓存写
35
+ output: 输出
36
+ context: 上下文
37
+ ```
38
+
14
39
  ## 目录
15
40
 
16
41
  - [使用本包](#use-this-package)
@@ -38,6 +63,12 @@ dsh plugin --profile <名字> add <脚本打印出的 .tgz 路径>
38
63
 
39
64
  脚本会暂存一份副本,把清单里所有 `workspace:` 范围改写为工作区版本并删掉 `devDependencies`——因为工作区里直接 `pnpm pack` 会在 `devDependencies` 里留下 `workspace:`,profile 安装时就会报 `ERR_PNPM_CANNOT_RESOLVE_WORKSPACE_PROTOCOL`。包声明了 `dsh.bundle.patch`,因此 profile 会从包自带的 `cordis.patch.yml` 挂载读数行,不需要手工插入。`desktop` profile 归 Electron 应用所有,按设计拒绝 `dsh plugin`;在那里请走应用自己的插件界面。
40
65
 
66
+ 已发布版本可以直接从 npm 安装,不需要打包:
67
+
68
+ ```powershell
69
+ dsh plugin --profile web add @jerry_chzy/dsh-token-usage@0.1.1 --registry=https://registry.npmjs.org
70
+ ```
71
+
41
72
  通过本插件的行配置设置价格。`pricing` 把模型 id 前缀映射到「元/百万 tokens」,最长的匹配前缀胜出,因此带日期的快照或 vision 路由可以共用或覆盖基础模型的价目:
42
73
 
43
74
  ```yaml