Prices each Session's provider-reported token usage in CNY and shows the running cost under the composer and beside every Session in the sidebar, with a token breakdown on hover.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:number-10/dsh-session-cost-fan
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
DeepSeek Harness 插件:读取每个会话累计的 token 用量,按单价折算成元,显示在输入框底部统计行与侧边栏对应会话上。
安装
dsh plugin add github:number-10/dsh-session-cost-fan
(也可以把本目录作为本地 bundle 装进 profile:Plugin Manager → 添加插件 → 选择目录。)
显示位置
- 输入框底部统计行:和「轮/步 · tok/s · tok · 缓存命中」并在同一行,右侧显示当前会话的实时花费(
¥3.79),随每条已落定的模型回复刷新;悬停可看完整一句话说明。 - 侧边栏每个会话行的时间右侧:
¥1.73这样的小字(悬停该行时这一条会隐藏,属于侧边栏行本身的行为)。金额固定两位小数;不足一分的会话显示<¥0.01,避免行宽忽长忽短。 - 悬停会话弹出的卡片里:精确到 6 位小数的花费 + 总 token,再下面是未命中输入 / 缓存命中 / 缓存写入 / 输出 四个非零桶,以及计价用的模型(跨模型会话写“按 A 等 N 个模型计价”,用了默认价的模型会单独点名)。
用量从哪来
把会话日志里 provider 上报的 usage 折叠进一个 Host 侧的 sessionCost 投影单元(ctx.sessionProjections):
assistant/message与assistant/attempt都算;同一步骤后一次上报替换前一次,llm/retry-started之后的重新尝试在失败尝试之上累加(与dsh-token-meter的tokenUsage口径一致)。- 缓存未命中输入、缓存命中输入、缓存写入、输出四个桶分别计价;缓存写没有单独官方价,按「缓存未命中输入价」计。
- 每条 usage 按它自己发生时刻的时段和它自己的模型计价,因此跨模型、跨高峰/空闲的会话不会被一个总价糊过去。
价格配置
单价是 元 / 百万 tokens。插件包自带的 cordis.patch.yml 里已写好默认价;要改价,请在 profile 的 cordis.patch.yml(%USERPROFILE%\.dsh\profiles\<profile>\cordis.patch.yml)里加同 id 的覆盖块——profile 层优先,且不会被重装插件覆盖:
- id: session-cost-fan
name: 'dsh-session-cost-fan'
config:
currency: CNY
symbol: '¥'
offPeakRatio: 0.5 # 空闲时段 = 高峰价 × 该系数
models:
deepseek-flash: { cacheHit: 0.04, cacheMiss: 2, cacheWrite: 2, output: 8 }
deepseek-v4-pro: { cacheHit: 0.3, cacheMiss: 9, cacheWrite: 9, output: 27 }
fallback: { cacheHit: 0.04, cacheMiss: 2, cacheWrite: 2, output: 8 }
覆盖块会整份替换 config,缺的键按内置默认值补齐,所以只写想改的部分即可。默认值取 DeepSeek 官方价目表的高峰时段价(2026-11 口径):deepseek-flash 缓存命中 0.04 / 未命中 2 / 输出 8,deepseek-v4-pro 0.30 / 9 / 27(元/百万 tokens)。改价后重启 DSH 生效。
高峰 / 空闲
按官方规则,北京时间周一至周五(不含法定节假日)9:00–12:00、14:00–18:00 为高峰,其余时段为空闲,空闲价是高峰价的一半。插件按事件发生时刻判断;中国法定节假日没有内置日历,节假日的工作日会按高峰计价(偏高)。
已知限制
- 金额只在 Host 侧计算并随投影缓存下发;安装前就存在的会话,其持久化投影缓存里还没有
sessionCost行,因此要等该会话被打开或再次产生事件后才显示金额。 - 单价是插件配置里的静态表,不随官方调价自动更新。
- 子代理会话同样是独立会话,各自计价。
Links
More in this category
bowenliang123/dsh-context★ 5656
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 781
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 291
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 207
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 194
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 114
Personal center for DeepSeek Harness: cross-session usage statistics with per-provider and per-model breakdown (auto-discovers configured models), per-model cost estimation, global custom instructions, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.