rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:kelaocai/dsh-token-spend
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
实时查看本会话消耗的 Token 与花费金额 · Live per-conversation token usage and cost in the DeepSeek Harness composer, priced with DeepSeek's official peak / off-peak rates.
在聊天输入框上方的统计行里,内置的「活动」「用量」旁边会多一个 (¥) 1.56 · 37M 形式的控件:实时显示当前会话消耗的 Token 和按官方价格估算的人民币花费。点击展开明细:缓存命中 / 未命中 / 输出的 Token 与金额、缓存命中率、高峰 / 空闲时段金额、按模型汇总。
tokenUsage 完全一致);金额按每条调用发生时刻所属时段计价。@deepseek-ai/dsh-experimental-plugin-market-bundle)。https://cdn.jsdelivr.net/gh/kelaocai/dsh-token-spend@main/market/index.json
(备用地址:https://raw.githubusercontent.com/kelaocai/dsh-token-spend/main/market/index.json)
dsh-token-spend,点击安装。dsh plugin add git+https://github.com/kelaocai/dsh-token-spend.git
dsh plugin add 只是把包装进 profile;随后在「插件」页启用 dsh-token-spend 这个 bundle 即可。
(也可以直接用上面市场索引里的「安装」,效果相同。)
dsh plugin add dsh-token-spend
npm 包地址:https://www.npmjs.com/package/dsh-token-spend
需要 DSH 0.2.2-rc.1 或更高版本(依赖会话投影与 composer dock 槽位)。本插件已提交 dsh.so 市场审核(Declared),并带有 GitHub
dsh-plugin话题。
安装后可直接使用内置的 DeepSeek 官方价格。需要改价时,在 profile 的 cordis.patch.yml
(~/.dsh/profiles/<profile>/cordis.patch.yml)追加:
- id: token-spend
config:
currency: '¥'
timeZone: Asia/Shanghai
peakWeekdays: [1, 2, 3, 4, 5]
peakWindows:
- [9, 12]
- [14, 18]
# 官方规则里法定节假日全天按空闲价,但插件不内置节假日日历;需要时逐日补充
holidays: ['2026-10-01', '2026-10-02']
models:
deepseek-flash:
peak: { cacheMiss: 2, cacheHit: 0.04, output: 8 }
offPeak: { cacheMiss: 1, cacheHit: 0.02, output: 4 }
deepseek-v4-pro:
peak: { cacheMiss: 9, cacheHit: 0.3, output: 27 }
offPeak: { cacheMiss: 4.5, cacheHit: 0.15, output: 13.5 }
# 未知模型的兜底价;不配置则该模型只显示 Token、不计金额
fallback:
peak: { cacheMiss: 1, cacheHit: 0.01, output: 2 }
offPeak: { cacheMiss: 0.5, cacheHit: 0.005, output: 1 }
| 字段 | 默认 | 说明 |
|---|---|---|
currency |
¥ |
金额前缀 |
timeZone |
Asia/Shanghai |
判定高峰/空闲所用时区 |
peakWeekdays |
[1,2,3,4,5] |
高峰星期(0=周日) |
peakWindows |
[[9,12],[14,18]] |
高峰小时区间,左闭右开 |
holidays |
[] |
YYYY-MM-DD,当日全天按空闲价 |
models |
内置 DeepSeek 价格 | 键为模型 id,或用 provider/model 精确覆盖 |
fallback |
null |
未知模型的兜底费率;null 表示不计金额 |
改价不需要迁移历史数据:投影状态只保存 Token 计数,金额在发布给客户端时计算。
来源:DeepSeek 模型 & 价格。
| 模型 | 输入(缓存命中)峰/闲 | 输入(缓存未命中)峰/闲 | 输出 峰/闲 |
|---|---|---|---|
deepseek-flash |
0.04 / 0.02 | 2 / 1 | 8 / 4 |
deepseek-v4-pro |
0.30 / 0.15 | 9 / 4.5 | 27 / 13.5 |
deepseek-v4-flash、deepseek-v4-flash-vision-exp 等历史别名按 flash 价格计费。DeepSeek 不单独收取缓存写入费用;若 provider 上报了 cacheWriteTokens,默认按缓存未命中价格计,可用 cacheWrite 覆盖。
tokenCost 会话投影,折叠 assistant/message、assistant/attempt、model/selection 事件,按「模型 × 高峰/空闲」累计 Token;投影状态随会话 checkpoint 持久化,可回放历史会话。conversation.composer.dock 注册一个控件,读取 useProjection('tokenCost') 渲染;没有 Host 半时退化为只显示 Token。tokenUsage 同理)。holidays,否则按「工作日 + 时段」规则计算。node --test "test/*.test.mjs" # 折叠、时段、计价、schema 的纯函数测试
文件结构:
| 文件 | 职责 |
|---|---|
pricing.js |
纯逻辑:配置归一化、高峰判定、事件折叠、价格视图、投影 schema(无依赖,可直接用 Node 测试)。 |
index.js |
Host 插件入口:向 ctx.sessionProjections 注册 tokenCost 投影。 |
client.js |
浏览器半:composer dock 控件 + 明细弹层,无需构建。 |
cordis.patch.yml |
Bundle patch:挂载 Host 行并给出默认定价。 |
market/index.json |
DSH 插件市场索引(format 1),可在「发现」页作为索引源添加。 |
test/ |
node:test 单元测试。 |
已发布到 npm:https://www.npmjs.com/package/dsh-token-spend 。后续发版:
npm version patch # 或 minor / major
npm publish --access public
git push --follow-tags
仓库也包含 .github/workflows/publish.yml:配置 NPM_TOKEN(带 Bypass 2FA 的 Granular Access Token)后,发布 GitHub Release 或手动运行 workflow 即可自动发布。npm 对首次发布的包会先进入 staged 队列,通常需要维护者在 npmjs.com 确认/等待处理完成后才对安装者可见。
欢迎 Issue / PR。
dsh-token-spend adds one control to the DeepSeek Harness composer dock that shows the current Session's token usage and an estimated CNY cost, computed from the official DeepSeek list prices with peak / off-peak tariffs. Click it for a breakdown (cache-hit / cache-miss input, output, cache hit rate, peak vs off-peak money, per-model rows).
tokenCost projection.tokenUsage control.Install from the market index URL above, from this Git repository (dsh plugin add git+https://github.com/kelaocai/dsh-token-spend.git), or from npm once published (dsh plugin add dsh-token-spend). Requires DSH 0.2.2-rc.1 or newer.
MIT licensed.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。