dsh-continue-cost 0.0.0-stage → 1.2.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 +21 -0
- package/README.md +131 -2
- package/client.js +1549 -0
- package/cordis.patch.yml +9 -0
- package/host-1.2.0.js +512 -0
- package/host.js +6 -0
- package/icon.svg +8 -0
- package/index.js +4 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +62 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-continue-cost 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,132 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-continue-cost · 对话轮数与续聊差价
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> DeepSeek Harness(DSH)插件:在输入框右侧显示**已完成的对话轮数**,或者——**继续这次对话比新开一次要多花多少钱**。
|
|
4
|
+
|
|
5
|
+
大多数费用插件回答的是“已经花了多少”。这个插件回答的是“**下一步该不该开新对话**”:续聊会把历史上下文再传一遍,这笔钱是可以省下来的,省多少取决于历史 token、缓存命中率和当前峰谷价。
|
|
6
|
+
|
|
7
|
+
## 为什么是它,而不是又一个费用计
|
|
8
|
+
|
|
9
|
+
| | 常见费用插件 | 本插件 |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| 口径 | 已经发生的花费 | 下一轮**继续 vs 新开**的差额 |
|
|
12
|
+
| 用途 | 看账单 | 做决定(要不要开新对话) |
|
|
13
|
+
| 展示 | 金额、明细、余额 | 一个胶囊 + 三色阈值(轮数或金额) |
|
|
14
|
+
|
|
15
|
+
差额是纯增量信息,和已有的费用统计插件共存不冲突。
|
|
16
|
+
|
|
17
|
+
## 两个数字到底是什么
|
|
18
|
+
|
|
19
|
+
胶囊显示二选一,点开面板顶部可以切换。
|
|
20
|
+
|
|
21
|
+
**对话轮数**
|
|
22
|
+
|
|
23
|
+
`12 轮` —— 这个会话里**已经完成**的问答轮次。进行中的那一轮要等回答结束、日志落盘后才 +1,所以刚发问时数字不变是正常的。
|
|
24
|
+
|
|
25
|
+
**续聊差价**
|
|
26
|
+
|
|
27
|
+
`≈ ¥0.0076` —— **继续当前对话**,比**新开一个对话**,下一轮请求要多花多少钱。
|
|
28
|
+
|
|
29
|
+
### 为什么会有差价
|
|
30
|
+
|
|
31
|
+
每次对话,模型都要重新读一遍上下文:系统提示、工具 schema、以及之前所有对话消息。开新对话时系统提示和工具还在,**历史消息不再携带**;续聊则要为这些历史消息再付一次输入费(命中缓存的部分便宜很多)。
|
|
32
|
+
|
|
33
|
+
所以差价只跟历史消息有关:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
差价 ≈ 历史上下文 token × 每 token 平均单价
|
|
37
|
+
平均单价 = 缓存命中比例 × 命中价 + 未命中比例 × 未命中价(按当前峰谷价)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
回答本身的费用在两种做法下一样,所以不计入。举例:历史消息 6 万 token、本会话约 97% 命中缓存、谷时 `deepseek-flash` 输入价 0.02 / 1 元每百万,差价约 6 万 × 0.023 ≈ **¥0.0014**;峰时或缓存命中率低时会明显更高。实际以账户扣费为准。
|
|
41
|
+
|
|
42
|
+
### 面板里还有什么
|
|
43
|
+
|
|
44
|
+
悬停胶囊:
|
|
45
|
+
|
|
46
|
+
- 已完成轮数、差额(继续 − 新开)
|
|
47
|
+
- 继续当前对话(下一轮上下文)费用、新开对话(同一轮上下文)费用
|
|
48
|
+
- 历史上下文、下一轮上下文预计、本会话平均 token 单价、计价模型(含峰/谷标注)
|
|
49
|
+
- 价格表来源、节假日表来源(官方在线 / 本地缓存 / 内置)
|
|
50
|
+
|
|
51
|
+
点击胶囊固定面板:顶部切换「对话轮数 / 多花金额」,下方设置绿色上限、黄色上限;「恢复默认」回到 5 / 10 轮、¥0.05 / ¥0.15。阈值存在 `localStorage`。
|
|
52
|
+
|
|
53
|
+
圆点在数值前面,按当前显示值着色:不超过绿色上限为绿,不超过黄色上限为黄,超过为红。每 30 秒重算一次,跨过峰谷边界会自动变色。
|
|
54
|
+
|
|
55
|
+
## 估算口径
|
|
56
|
+
|
|
57
|
+
价格单位:CNY / 百万 token。
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
历史 token ≈ provider 锚定的下一轮上下文总量 × 历史消息占比
|
|
61
|
+
继续费用 ≈ 下一轮上下文 token / 1,000,000 × 平均 token 单价
|
|
62
|
+
新开费用 ≈ (下一轮上下文 token − 历史 token) / 1,000,000 × 平均 token 单价
|
|
63
|
+
差额 ≈ 历史 token / 1,000,000 × 平均 token 单价
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- 平均 token 单价按本会话累计 `tokenUsage` 的缓存命中/未命中比例,套用当前时段官方单价。
|
|
67
|
+
- 回答本身在两种做法下费用相同,不计入差额;只比较输入侧。
|
|
68
|
+
- 峰时:北京时间周一至周五(不含法定节假日)09:00–12:00、14:00–18:00;其余时段、周末、调休上班周末、法定节假日全天为谷时。
|
|
69
|
+
- 下一轮上下文取 `contextPressure.projectedTokens`(缺失时退回 `pressureTokens`),历史消息占比取 `contextBreakdown`;两者都没有时显示「上下文数据还没准备好」,而不是硬猜。
|
|
70
|
+
- 每 30 秒重算一次,跨过峰谷边界会自动更新。
|
|
71
|
+
|
|
72
|
+
## 安装
|
|
73
|
+
|
|
74
|
+
需要 DSH 桌面版 0.2.x(在 0.2.2-rc.3 上验证)。三种方式任选:
|
|
75
|
+
|
|
76
|
+
**1. 本地文件夹(推荐给朋友之间分享)**
|
|
77
|
+
|
|
78
|
+
1. 下载 `dsh-continue-cost-1.2.0.zip` 并解压,得到 `dsh-continue-cost` 文件夹,放到固定位置。
|
|
79
|
+
2. DSH:**设置 → 插件 → 添加插件**,选择这个包含 `package.json` 的文件夹。
|
|
80
|
+
3. **完全退出 DSH 再打开**(Host 端的价格/节假日路由要重启才挂载)。
|
|
81
|
+
|
|
82
|
+
**2. npm(发布后可用)**
|
|
83
|
+
|
|
84
|
+
在 DSH 里用插件管理器安装:`plugin_manager` 的 `install_bundle`,target 填 `dsh-continue-cost@1.2.0`;如果这台 DSH 自带 `dsh` 命令,也可以 `dsh plugin add dsh-continue-cost`(profile 名按你的安装,桌面版一般是 `desktop`)。
|
|
85
|
+
|
|
86
|
+
**3. GitHub Release**:从 Releases 下载 zip,按方式 1 安装。
|
|
87
|
+
|
|
88
|
+
更新:替换文件夹内容(保持路径不变)或在插件管理里升级,然后重启 DSH。
|
|
89
|
+
|
|
90
|
+
## 数据来源与网络行为
|
|
91
|
+
|
|
92
|
+
- 价格表:<https://api-docs.deepseek.com/zh-cn/quick_start/pricing.md>,Host 端解析模型列与峰谷价,缓存 6 小时;客户端启动时和每 24 小时刷新一次。
|
|
93
|
+
- 节假日:优先使用已知的国务院通知 URL(2026、2027),其次政府网“最新文件”页,最后 Bing RSS 的 `site:gov.cn` 结果;固定文本解析,不调用大模型;Host 缓存一天。
|
|
94
|
+
- 两个 Host 路由:`/plugins/dsh-continue-cost/prices`、`/plugins/dsh-continue-cost/holidays`。
|
|
95
|
+
- 网络失败回退到 `localStorage` 里的上次成功结果,再回退到内置表,估算照常可用。
|
|
96
|
+
|
|
97
|
+
## 隐私
|
|
98
|
+
|
|
99
|
+
- 不上传会话内容、token 用量、API Key。
|
|
100
|
+
- 只请求上面的公开页面和本机 DSH 路由。
|
|
101
|
+
- 阈值和缓存只存在本机浏览器的 `localStorage`(桌面版 origin 为 `dsh-app://app`,改端口不丢)。
|
|
102
|
+
|
|
103
|
+
## 兼容性
|
|
104
|
+
|
|
105
|
+
- DSH 桌面版 0.2.x(验证于 0.2.2-rc.3);Web 版同版本亦可。
|
|
106
|
+
- 无原生依赖、无构建步骤,纯 ES module + browser factory。
|
|
107
|
+
- 依赖的投影:`sessionStats`、`tokenUsage`、`contextPressure`、`contextBreakdown`、`modelSelection`;缺少某个时退化为可用字段或显示未知。
|
|
108
|
+
|
|
109
|
+
## 限制
|
|
110
|
+
|
|
111
|
+
- 历史 token 占比是按 `contextBreakdown` 缩放到 provider 锚定总量的启发式,不是精确分桶。
|
|
112
|
+
- 平均单价按整个会话累计缓存比例,下一轮缓存状态变化会让实际值偏离。
|
|
113
|
+
- 中途切换模型时累计用量按当前模型价格折算。
|
|
114
|
+
- 节假日解析依赖 gov.cn 通知的固定文本结构;结构变化时回退缓存/内置。
|
|
115
|
+
- 已内置 2026 年表;2027 年表来自官方通知;更久远年份依赖自动发现。
|
|
116
|
+
|
|
117
|
+
## 开发
|
|
118
|
+
|
|
119
|
+
- `client.js` 是浏览器端(module factory,无构建),`host-1.2.0.js` 是 Host 端。
|
|
120
|
+
- DSH 会缓存 Host 模块:改 Host 时复制成新版本文件(如 `host-1.3.0.js`),改 `package.json` 的 `main`/`exports`/`files`,重启 DSH。
|
|
121
|
+
- 改包名时要同步:`client.js` 的 `NAME`/`NS` 与两个路由常量、`host-1.2.0.js` 的 `BASE_PATH`、`cordis.patch.yml` 的 `id`/`name`。
|
|
122
|
+
- 自检:`node --check client.js`、`node -e "import('./host-1.2.0.js')"`、重启后两个路由返回 `ok:true`。
|
|
123
|
+
|
|
124
|
+
## English
|
|
125
|
+
|
|
126
|
+
**dsh-continue-cost** is a DeepSeek Harness plugin that shows the completed turn count and, more importantly, the extra context cost of **continuing this conversation instead of starting a fresh one** — priced from the official peak/off-peak CNY table and the session's cache-hit mix. Most cost plugins report money already spent; this one helps you decide whether to start over. Badge thresholds (green/yellow/red) apply to turns or to the delta.
|
|
127
|
+
|
|
128
|
+
Install: unzip into a folder and add it from **Settings → Plugins → Add plugin**, then fully restart DSH.
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT
|