Introduction¶
When running agents in DeepSeek Harness (DSH), model calls continuously consume tokens. While usage can occasionally be seen in the panel, preserving “which model was used each time and how much it cost,” aggregating by time period, and reconciling with platform invoices often requires manually stitching together scripts or spreadsheets.
The community already has plugins focused on balance monitoring and visualization (e.g., dsh-damage-pulse). dsh-cost-ledger takes a different path: recording each call, estimating costs via a local price table, manually entering official invoices and displaying discrepancies side-by-side, with JSON/CSV export and dry-run support. Below we describe what it is, how to install it, how to use it, and the boundaries you should accept when using it.
What is this¶
dsh-cost-ledger is published by maintainer dingchenhui0618-arch and categorized as admin-security in the SkillHub directory. Current GitHub stars: 0; License: MIT; package.json declares a dependency on DSH version >=0.2.1-rc.2 <0.3.0.
In one sentence: it’s a reconcilable token cost ledger for DSH—each model call records the provider, model, token types, and CNY calculated per a local price table; aggregates by hour, day, and session; supports export and dry-run; and places manually entered platform invoices alongside local estimates to directly show the difference.
It does not check balances, send notifications, or provide role animations; it is inspired by the “costs should be visible” awareness from wssfk12138/dsh-damage-pulse, but is an independent implementation—not a fork. Both can be installed independently and don’t depend on each other.
Core Features¶
Capture and Bookkeeping¶
The plugin wraps each streaming call on the host side using an llm/stream waterfall, reads usage from the adapter’s usage chunk, and writes a line to an append-only JSONL ledger when the stream ends.
Each record contains: timestamp, hour / day (Beijing time by default), session (recorded as purpose:<purpose> or unattributed when there is no session), provider, model, purpose, various token fields, usageSource (adapter / estimated / missing), price table hit, peak/off-peak tier, itemized and total costs (integer nano-CNY, 1 CNY = 10⁹ nano-CNY), status / finish / ms / error.
Does not record prompts, response content, tool parameters, or credentials—the ledger contains only billing metadata.
Two Kinds of Numbers, Never Mixed¶
- Local estimate: tokens reported by the adapter × rates from
$DSH_HOME/cost-ledger-prices.json(or built-in table); when usage is missing, estimates are made based on character ratios from official documentation and marked asestimated. - Actual invoice: platform amounts entered manually in the panel or CLI, which only go into
actual_cnyand do not overwrite estimates. - Difference:
diff = actual − estimated; periods without manual entry remain empty, not filled with zero.
Price Table and Unpriced Items¶
Reads $DSH_HOME/cost-ledger-prices.json by default; uses the built-in table if it doesn’t exist. The built-in table covers only public prices for DeepSeek official providers (deepseek-official, deepseek-account) (README notes it was scraped from official docs on 2026-10-19), and includes Beijing time peak/off-peak tiers and 2026 statutory holidays.
Relay providers won’t automatically use official prices: if there’s no explicit provider + model entry, the record is marked unpriced with cost 0, avoiding “looks correct but is actually wrong.” See the repo’s examples/prices.example.json for the custom price table structure.
Panel¶
After installation and profile restart, a “Cost Ledger” tab appears in the conversation view: totals and tier aggregation, invoice entry/editing, recent call details, JSON/CSV export, dry-run, price table reload, etc. The table shows only metadata.
Export and CLI¶
Panel operations and command-line are equivalent. Examples from the repo:
node bin/cost-ledger.mjs export --json --scope day
node bin/cost-ledger.mjs export --csv --scope session --out ledger.csv
node bin/cost-ledger.mjs export --json --detail
node bin/cost-ledger.mjs export --dry-run --scope hour
node bin/cost-ledger.mjs export --json --since 2026-10-18 --until 2026-10-19
After installation as an npm bin, the command name is dsh-cost-ledger.
Manual invoice entry example:
node bin/cost-ledger.mjs bill set --scope day --key 2026-10-19 --amount 12.34 --note "Platform invoice page"
node bin/cost-ledger.mjs bill list
node bin/cost-ledger.mjs bill delete --scope day --key 2026-10-19
The key convention: hour is YYYY-MM-DDTHH (Beijing time), day is YYYY-MM-DD, session is the session id.
Data Files (Local Machine)¶
| File | Default Path | Description |
|---|---|---|
| Call ledger | $DSH_HOME/cost-ledger.jsonl |
One line per call |
| Manual invoices | $DSH_HOME/cost-ledger-bills.json |
Official amounts and notes |
| Price table | $DSH_HOME/cost-ledger-prices.json |
Optional |
The plugin does not connect to the network; the ledger does not auto-rotate—archiving must be done manually. The README notes that ledger files are in the user directory, can be modified by processes with the same permissions, and are intended for reconciliation rather than tamper-proofing.
Installation and Activation¶
Install from GitHub (README states there is currently no npm release):
dsh plugin --profile <your-profile> add github:dingchenhui0618-arch/dsh-cost-ledger
Install from a local development directory:
dsh plugin --profile <your-profile> add D:\Projects\dsh-cost-ledger
Restart the corresponding profile after installation. The README notes: new plugins have mainly been tested and built on dev machines, with no claim of verification across every DSH version; the panel may degrade or disappear if slot contracts change, but host-side recording will continue.
The DSH ecosystem is “everything is a plugin”; the SkillHub directory page is a community site with no official affiliation with DeepSeek / High-Flyer.
Typical Usage¶
- Install and restart the profile per the commands above; normal conversations will generate
llm/streamcalls. - Open the “Cost Ledger” in the conversation view to view local estimate totals by hour/day/session; after platform invoices are released, use “Enter Invoice” or
bill setto enter actual amounts and compare the difference column. - When using relay or self-hosted providers, add entries for the corresponding
provider+modelincost-ledger-prices.jsonto avoid large numbers ofunpricedrecords. - For reports or external analysis, use
export --json|--csvor--detail; use--dry-runto preview aggregation results before changing the price table.
Use Cases and Caveats¶
Suitable for: DSH users who need local traceability, want to reconcile tokens and CNY by session/day, and want to compare local estimates with platform invoices side-by-side; who need exportable, scriptable cost metadata rather than balance animations or WeChat reminders.
Notes:
- Local estimates are not official settlement proof; discounts, gifted balances, cache billing differences, etc. will all show up in the
diff. - When usage is missing, records can only be
estimated—don’t confuse this with adapter facts. - The built-in price table and 2026 holidays will become outdated; after price changes, update
prices.jsonor customizeholidays. - The plugin runs with the permissions of the current DSH process. Before installing, review the GitHub source and MIT license to confirm it meets your security and compliance requirements.
Conclusion¶
dsh-cost-ledger writes “how much each call cost” into a local ledger that can be exported and reconciled, and lists estimates and manually entered invoices separately. For installation or full parameter details, visit the directory page skillhub.cn/plugins/dingchenhui0618-arch/dsh-cost-ledger and the repo github.com/dingchenhui0618-arch/dsh-cost-ledger.