@guojinpeng/dsh-cost-meter 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-cost-meter 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 CHANGED
@@ -1,3 +1,134 @@
1
- # Temporary Holding Version
1
+ # @guojinpeng/dsh-cost-meter
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [English](README.md) | [简体中文](README.zh-CN.md)
4
+
5
+ This plugin shows estimated session and turn costs in DSH.
6
+ Use DSH 0.2.0-rc.2 or later.
7
+ Tests use DSH 0.2.0-rc.2.
8
+
9
+ ## Install
10
+
11
+ 1. Install the npm package:
12
+
13
+ ```powershell
14
+ dsh plugin --profile web add -w @guojinpeng/dsh-cost-meter
15
+ ```
16
+
17
+ 2. Restart DSH.
18
+ 3. Open **Plugins**.
19
+ 4. Select **@guojinpeng/dsh-cost-meter** to change prices.
20
+
21
+ Replace `web` with your profile name.
22
+ If you used the old unscoped package, disable it before you install this package.
23
+
24
+ If the npm package is not available, download the scoped package from
25
+ [GitHub Releases](https://github.com/guojinpeng/dsh-cost-meter/releases).
26
+ Run this command in the download directory:
27
+
28
+ ```powershell
29
+ dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.2.tgz
30
+ ```
31
+
32
+ Restart DSH.
33
+ Keep the downloaded file at the installation path.
34
+
35
+ ## Features
36
+
37
+ - Shows session and completed-turn cost estimates.
38
+ - Shows a short initialization message while prices load.
39
+ - Shows input, output, cache-read and cache-write cost details.
40
+ - Groups used models by provider. The list comes from DSH session history.
41
+ - Supports separate prices for each full `provider/model` name.
42
+ - Gets initial prices from models.dev. Uses the local catalog cache first.
43
+ - Syncs only configured models. Asks for confirmation before prices are overwritten.
44
+ - Matches source prices by model ID. Prefers the manufacturer's usage-based price. Keeps existing prices if matching is unclear.
45
+ - Keeps existing prices when the source cannot supply a supported rate.
46
+ - Uses USD per million tokens for model prices. Supports USD and CNY cost display.
47
+ - Updates cost estimates after you save or sync prices.
48
+ - Supports price reset and separate session/turn visibility controls.
49
+ - Stores configuration at `~/.dsh/guojinpeng/dsh-cost-meter/config.json`. Uses `DSH_HOME` when set.
50
+ - Copies the old `~/.dsh/dsh-cost-meter/config.json` on first start if the new file does not exist. Keeps the old file.
51
+ - Uses isolated plugin, client, API, projection, style and configuration identifiers.
52
+
53
+ These screenshots use example model prices. They do not show a billing statement.
54
+
55
+ Session cost details:
56
+
57
+ ![Session cost card](docs/images/session-cost.png)
58
+
59
+ Turn cost details:
60
+
61
+ ![Turn cost card](docs/images/turn-cost.png)
62
+
63
+ Model price settings:
64
+
65
+ ![Model price settings on desktop](docs/images/model-prices-desktop.png)
66
+
67
+ ## Develop From Source
68
+
69
+ Install Node.js, pnpm 9 and Git. Install DSH globally before you run the tests:
70
+
71
+ ```powershell
72
+ npm install -g @deepseek-ai/dsh@0.2.0-rc.2
73
+ git clone https://github.com/guojinpeng/dsh-cost-meter.git
74
+ cd dsh-cost-meter
75
+ pnpm install --frozen-lockfile
76
+ ```
77
+
78
+ Edit files in `src/`. Run tests and create a package:
79
+
80
+ ```powershell
81
+ npm test
82
+ npm run build
83
+ npm pack
84
+ ```
85
+
86
+ `npm pack` also runs the build. It creates `guojinpeng-dsh-cost-meter-<version>.tgz`.
87
+ Install the generated file in your DSH profile. For version 0.1.2:
88
+
89
+ ```powershell
90
+ dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.2.tgz
91
+ ```
92
+
93
+ Restart DSH and check the plugin. Repeat the build, package and install steps after changes.
94
+ Tests use the global DSH installation. Set `DSH_RUNTIME_ROOT` to the DSH package directory if its location is different.
95
+ Commit source files and `pnpm-lock.yaml`. Do not commit generated files or local configuration.
96
+
97
+ ## Publish To npm
98
+
99
+ Use an npm account with publish access to `@guojinpeng/dsh-cost-meter`.
100
+ Run these commands in the project directory:
101
+
102
+ ```powershell
103
+ npm login --registry=https://registry.npmjs.org/
104
+ npm whoami --registry=https://registry.npmjs.org/
105
+ npm view @guojinpeng/dsh-cost-meter version --registry=https://registry.npmjs.org/
106
+ ```
107
+
108
+ An unpublished package can return `E404` from `npm view`.
109
+ For an update, choose a version that is newer than the published version.
110
+ Update `package.json`. You can use this command to increase the patch version without creating a Git tag:
111
+
112
+ ```powershell
113
+ npm version patch --no-git-tag-version
114
+ pnpm install --lockfile-only
115
+ npm test
116
+ npm pack --dry-run
117
+ ```
118
+
119
+ Check the file list from `npm pack --dry-run`. Then publish the public package:
120
+
121
+ ```powershell
122
+ npm publish --access public --registry=https://registry.npmjs.org/
123
+ npm view @guojinpeng/dsh-cost-meter version --registry=https://registry.npmjs.org/
124
+ ```
125
+
126
+ Complete npm's authentication steps when prompted.
127
+ Each package version can be published only once.
128
+ Commit and push the version change. Create the matching Git tag and GitHub Release.
129
+
130
+ Users can then install the package:
131
+
132
+ ```powershell
133
+ dsh plugin --profile web add -w @guojinpeng/dsh-cost-meter
134
+ ```
@@ -0,0 +1,134 @@
1
+ # @guojinpeng/dsh-cost-meter
2
+
3
+ [English](README.md) | [简体中文](README.zh-CN.md)
4
+
5
+ 此插件用于估算 DSH 的会话费用和每轮费用。
6
+ 需要 DSH 0.2.0-rc.2 或更高版本。
7
+ 已在 DSH 0.2.0-rc.2 上测试。
8
+
9
+ ## 安装
10
+
11
+ 1. 安装 npm 包:
12
+
13
+ ```powershell
14
+ dsh plugin --profile web add -w @guojinpeng/dsh-cost-meter
15
+ ```
16
+
17
+ 2. 重启 DSH。
18
+ 3. 打开**插件**页面。
19
+ 4. 选择 **@guojinpeng/dsh-cost-meter**,修改模型单价。
20
+
21
+ 将 `web` 替换为你使用的 profile 名称。
22
+ 如果已安装旧版无 scope 的插件,请先禁用旧版,再安装此插件。
23
+
24
+ 如果 npm 包尚不可用,请从
25
+ [GitHub Releases](https://github.com/guojinpeng/dsh-cost-meter/releases)
26
+ 下载 scoped 安装包。在下载目录执行:
27
+
28
+ ```powershell
29
+ dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.2.tgz
30
+ ```
31
+
32
+ 安装后重启 DSH。
33
+ 请保留下载的安装包,不要改变其安装路径。
34
+
35
+ ## 功能
36
+
37
+ - 显示会话费用和已完成轮次的费用估算。
38
+ - 加载价格时显示简短的“初始化中”提示。
39
+ - 显示输入、输出、缓存读取和缓存写入的费用明细。
40
+ - 按提供方分组显示模型。模型列表来自 DSH 调用历史。
41
+ - 按完整的 `provider/model` 名称分别设置单价。
42
+ - 从 models.dev 初始化价格。优先读取本地目录缓存。
43
+ - 仅同步当前配置中的模型。覆盖价格前要求确认。
44
+ - 按模型 ID 匹配第三方价格。优先使用原厂按量价格。匹配不明确时保留已有价格。
45
+ - 第三方数据无法提供受支持的单价时,保留已有价格。
46
+ - 模型单价使用 USD / 百万 token。费用支持 USD 和 CNY 显示。
47
+ - 保存或同步价格后,立即更新费用估算。
48
+ - 支持价格归零,以及分别控制会话和轮次费用标签的显示。
49
+ - 配置保存在 `~/.dsh/guojinpeng/dsh-cost-meter/config.json`。设置 `DSH_HOME` 后,使用该目录。
50
+ - 新配置不存在时,首次启动会复制旧的 `~/.dsh/dsh-cost-meter/config.json`。保留旧文件。
51
+ - 插件、客户端、接口、费用 projection、样式和配置使用独立命名空间。
52
+
53
+ 以下截图使用示例模型价格,不代表实际账单。
54
+
55
+ 会话费用明细:
56
+
57
+ ![会话费用卡片](docs/images/session-cost.png)
58
+
59
+ 本轮费用明细:
60
+
61
+ ![本轮费用卡片](docs/images/turn-cost.png)
62
+
63
+ 模型单价配置:
64
+
65
+ ![桌面端模型单价配置](docs/images/model-prices-desktop.png)
66
+
67
+ ## 从源码开发
68
+
69
+ 安装 Node.js、pnpm 9 和 Git。运行测试前,先全局安装 DSH:
70
+
71
+ ```powershell
72
+ npm install -g @deepseek-ai/dsh@0.2.0-rc.2
73
+ git clone https://github.com/guojinpeng/dsh-cost-meter.git
74
+ cd dsh-cost-meter
75
+ pnpm install --frozen-lockfile
76
+ ```
77
+
78
+ 修改 `src/` 中的代码。运行测试并生成安装包:
79
+
80
+ ```powershell
81
+ npm test
82
+ npm run build
83
+ npm pack
84
+ ```
85
+
86
+ `npm pack` 也会执行构建,生成 `guojinpeng-dsh-cost-meter-<版本号>.tgz`。
87
+ 将生成的文件安装到你的 DSH profile。以 0.1.2 为例:
88
+
89
+ ```powershell
90
+ dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.2.tgz
91
+ ```
92
+
93
+ 重启 DSH,检查插件。每次修改后,重新构建、打包并安装。
94
+ 测试使用全局安装的 DSH。如果安装位置不同,将 `DSH_RUNTIME_ROOT` 设置为 DSH 包目录。
95
+ 提交源码和 `pnpm-lock.yaml`。不要提交生成文件或本地配置。
96
+
97
+ ## 发布到 npm
98
+
99
+ 使用有权发布 `@guojinpeng/dsh-cost-meter` 的 npm 账号。
100
+ 在项目目录执行:
101
+
102
+ ```powershell
103
+ npm login --registry=https://registry.npmjs.org/
104
+ npm whoami --registry=https://registry.npmjs.org/
105
+ npm view @guojinpeng/dsh-cost-meter version --registry=https://registry.npmjs.org/
106
+ ```
107
+
108
+ 包尚未发布时,`npm view` 可能返回 `E404`。
109
+ 更新已发布的包时,新版本必须高于已发布版本。
110
+ 修改 `package.json`。也可以用以下命令递增补丁版本,不自动创建 Git 标签:
111
+
112
+ ```powershell
113
+ npm version patch --no-git-tag-version
114
+ pnpm install --lockfile-only
115
+ npm test
116
+ npm pack --dry-run
117
+ ```
118
+
119
+ 检查 `npm pack --dry-run` 列出的文件。然后发布公开包:
120
+
121
+ ```powershell
122
+ npm publish --access public --registry=https://registry.npmjs.org/
123
+ npm view @guojinpeng/dsh-cost-meter version --registry=https://registry.npmjs.org/
124
+ ```
125
+
126
+ 根据提示完成 npm 身份验证。
127
+ 同一包版本只能发布一次。
128
+ 提交并推送版本变更,创建对应的 Git 标签和 GitHub Release。
129
+
130
+ 发布后,用户可执行以下命令安装:
131
+
132
+ ```powershell
133
+ dsh plugin --profile web add -w @guojinpeng/dsh-cost-meter
134
+ ```
@@ -0,0 +1,13 @@
1
+ # dsh-cost-meter bundle patch: inserts the cost chip plugin into the profile
2
+ # root as a single entry. All runtime configuration (currency, exchange rate,
3
+ # chip visibility, model price table) lives in
4
+ # <DSH_HOME>/guojinpeng/dsh-cost-meter/config.json and is edited from the plugin's detail
5
+ # page in the DSH Plugins UI. Browser requests must be same-origin.
6
+ #
7
+ # `name` is the plugin's own package name, matching the fixture plugins under
8
+ # apps/web/tests/fixtures/plugins/. Use the scoped npm package
9
+ # name: the profile resolves it through the node_modules link `dsh plugin add`
10
+ # creates for the installed package directory.
11
+ - insert:
12
+ - id: guojinpeng/dsh-cost-meter
13
+ name: '@guojinpeng/dsh-cost-meter'