dsh-spend-pill
A cost pill for the DeepSeek Harness composer status row — shows what your previous turn actually cost.
Tiny DSH plugin. The pill reads 上句结算 ¥0.062; click it for the breakdown: how many model calls that turn took, how much was re-reading history, how heavy the context is, and what the next message's fixed "starting price" will be.
Why
DSH's built-in stats row tells you 25 turns · 226 steps and 11.1M tok · 99% cache hit, but not money.
Two things about agent cost are counter-intuitive:
- You pay per model call, not per turn. One turn can trigger ~10 calls (read a file, run a command, edit code — each is a separate request), and every request re-bills the whole context.
- Re-reading history is often the biggest line item. At 390k tokens of context, each call re-reads 390k tokens — more than the model actually spends thinking and writing.
This plugin puts both on screen.
What it shows
Pill (collapsed)
上句结算 ¥0.062 (previous turn: ¥0.062)
Expanded
本会话已花 ¥2.12 session total
输出 18.3 万 token
缓存读 5888.3 万 token
未命中 20.7 万 token
────────────────────
上句结算(第 28 轮) ¥0.062 previous turn, settled
其中模型调用 6 次 model calls in that turn
本句进行中 ¥0.041 current turn so far
────────────────────
当前上下文 39.3 万(38%)
起步价(重读历史) ¥0.0079 next message's fixed input cost
按当前空闲·半价时段估算
- Settled value, not an estimate: the previous turn's cost is folded on the host from the full session log, so it survives restarts and compaction.
- Thresholds: context turns amber at 50%, red at 60% — DSH auto-compacts around 69%, so these leave headroom.
Install
From GitHub (recommended)
dsh plugin --profile desktop add "github:lalilulelo3/dsh-spend-pill"
Use desktop for the desktop app, web for the CLI web UI. Restart the host afterwards.
Local development (clone + link)
git clone https://github.com/lalilulelo3/dsh-spend-pill.git
dsh plugin --profile desktop add "link:C:/path/to/dsh-spend-pill"
⚠️ Do not install by npm package name yet. The npm entry is a
0.0.0-stageplaceholder left behind by npm's staged-publishing flow and contains nolib/, sodsh plugin add dsh-spend-pillwould install an empty, unloadable package. This notice will be removed once a real version ships.
How it works
- Host (
lib/index.js) registers aspendStatssession projection. It consumes the provider-reportedusageonassistant/message, splits turns onturn/end, and folds per-turn token totals. Because the projection replays the full persisted log, restarts / pagination / compaction do not change the result. - Client (
lib/client.js) registers into theconversation.composer.dockslot withorder: -1, and reads thetokenUsage,contextPressure, andspendStatsprojections. - Pricing is hardcoded to DeepSeek official rates (cache hit 0.02, miss 1, output 4 CNY per million tokens, off-peak; doubled at peak), with peak/off-peak detected from Beijing time.
- Not an invoice: the projection carries no per-call timestamps, so everything is converted at the current rate. Mixed peak/off-peak usage will drift.
Limitations
- Prices only make sense for DeepSeek; edit
PRICE_PEAK/PRICE_OFFfor other providers. - The settled value is empty on the very first turn (
¥—). - An interrupted turn with no model calls does not overwrite the last settled value.
License
MIT
No comments yet. Be the first to write one.