Usage statistics: a usage and reference-cost panel for DeepSeek Harness with today, 7-day, 30-day, all-time and custom ranges aggregated by hour or day; a model filter and a per-model breakdown of requests, input and output tokens, cache, reference cost and share; a model-share card showing the top four models by total tokens with the rest grouped as others; a reference price list generated from opencode Zen and DeepSeek's published rates, with DeepSeek models billed by Beijing weekday peak/off-peak windows and Chinese public holidays; a pricing-match dialog to point an unmatched model at a reference model or type per-million rates by hand; reference cost switchable between ¥ and $ at a fixed 1 USD = 7 CNY; and a yearly heatmap drawn only with theme variables, with no third-party chart library.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-plugin-usage
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:bennett-dsh/dsh-plugin-usage
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
dsh-plugin-usage is a Token usage statistics plugin for DeepSeek Harness. It folds the usage events already persisted in DSH session logs, prices them per model and per billed instant, renders a dashboard as a settings section, and keeps a "today's reference cost" pill beside the composer. It records nothing itself and changes no system source.
- Today / last 7 days / last 30 days / all / custom range (no span limit), bucketed by hour or day
- Per-model breakdown: requests, input/output, cache, cost, share; model filters apply instantly
- Reference cost: bundled opencode Zen + DeepSeek price lists, peak/off-peak billing per timestamp, ¥ / $ switch — and any user can pull the latest prices from the UI, without waiting for a release
- Price matching: a deterministic five-rung ladder; unmatched models can be pointed at a reference model or given hand-typed rates in the dialog
- Yearly heatmap, daily/hourly trend charts; light and dark follow the DSH theme variables
- Composer cost pill: "Today ¥x.xx" beside the composer (hidden when today has no calls); currency follows the setting
- Plugin detail star nudge: one line at the bottom of the plugin manager's detail page
Languages: the UI copy and plugin metadata follow the DSH language, with 8 official languages built in (zh / en / ja / de / es / fr / pt / ru). ja / de / es / fr / pt / ru are machine translations (lightly reviewed) — corrections are welcome in an issue; Chinese and English are maintained by the author. This README ships in 简体中文 and English.
Install
The plugin is published on npm as dsh-plugin-usage (see registry.npmjs.org).
DSH Desktop: sidebar → Plugins → Add plugin, then enter
dsh-plugin-usageWeb / CLI profile:
dsh plugin --profile <name> add dsh-plugin-usage, then restartFrom GitHub (equivalent; pin a tag or commit):
dsh plugin --profile web add github:bennett-dsh/dsh-plugin-usage#v0.6.0Local directory / tarball (development or offline):
dsh plugin --profile web add ./dsh-plugin-usage dsh plugin --profile web add ./dsh-plugin-usage-0.6.0.tgz
Upgrade the same way (the desktop plugin page offers Update; the CLI has update). Uninstall: dsh plugin --profile <name> remove dsh-plugin-usage.
The
desktopprofile is owned by the Electron app and cannot be driven withdsh plugin --profile desktop; use the plugin page instead. For artifact verification and restart rules see MAINTAINING.md.
Configuration
There are only three fields, stored in the current profile's Cordis patch through settings.update('usage', …). All are .volatile(): a runtime write applies immediately and survives a restart, while editing the profile patch by hand needs a restart.
| Field | Meaning |
|---|---|
currency |
Default display currency (fixed rate: 1 USD = 7 CNY) |
prices |
Custom reference prices: model id → input/output/cache-read/cache-write per million tokens, in USD |
matchMap |
Confirmed model matches: model id → reference model id (written when you press Apply in the price dialog) |
prices is empty by default and exists only for ids the reference table cannot answer (an odd relay id, a private id). A row for an id the table already carries overrides the reference price — exactly the problem the hand-copied default table had before 0.4.0 (one cache price was 13.3× the official list; seven rows named retired models). The default table therefore ships no rows.
Prices resolve through the following ladder, and no rung scores similarity:
- Custom (
prices; keys may beprovider/modelor a bare model id) - A match confirmed in the dashboard dialog (
matchMap) - Exact literal hit (case,
provider/modelprefix,_/./-separators and the router'sauto-prefix are normalized before comparing) - Aliases (where retired names such as
deepseek-chat,deepseek-reasoneranddeepseek-v4-flashpoint) - Variant suffixes (
-free/-exp/-fast/-latest/ a four-digit date such as-1017): only when the base model exists in the table; billed at the base row and reported as fuzzy
Exact beats inferred: a row the table really publishes is a fact and no inference may override it. Rung 5 is a closed rename rule, not similarity: the suffix list is fixed and the base model must exist.
Reference candidates are grouped by source: DeepSeek official and opencode Zen. The picker also offers a Custom option at the top: type three rates (input / output / cache read, in the dialog's display currency, per million tokens); they are written to prices and both tiers bill at the same rate.
DeepSeek's two models bill by peak/off-peak: Beijing time, Monday to Friday (excluding Chinese public holidays), 09:00–12:00 and 14:00–18:00 are peak; all other times, including weekends and public holidays all day, are off-peak.
The ¥ / $ switch on the reference-cost card only affects the current browser (
localStorage); it does not rewritecurrency. This kernel does not auto-generate a configuration page for this plugin: use the dashboard's Price matching dialog forprices/matchMap; to change the defaultcurrencyor hand-writeprices, edit theconfigof theusagerow in the profile'scordis.patch.yml(see Configuration). Editing a plugin title/description inlocale/*.jsonneeds an app restart (the host reads it at startup); editing the client UI dictionary only needs a page refresh. See Configuration.
Data source and accounting
The composer pill and the settings page share the same usage/query channel and the same scope (today 00:00 → now, priced per record's provider/model). It does not read the official tokenUsage projection: that projection only carries a per-session total and no model attribution, so pricing from it would merge different unit prices into one number. The scope is "today", not "this session" — the host renders conversation.composer.dock without props, so a dock entry cannot know the session id.
The plugin folds usage events already persisted in DSH session logs; it does not keep a log of its own:
- Reads go through the official interfaces: live sessions are driven by
session/eventpush (each committed event is folded once); persisted sessions go throughsessionPersistence.open/readand are skipped whenrevisionis unchanged; a 30 s persisted scan doubles as the repair path - Folded results are cached on disk (
~/.dsh/cache/dsh-plugin-usage/fold/<session>.json;DSH_HOMEmoves the root): one file per session, a hit requires the session'srevisionto match, and the signature carriesFOLD_CACHE_VERSIONplus the holiday calendar'scapturedAt - Billing matches the official
tokenUsageprojection: the same(turn, step)replaces in place; retries afterllm/retry-startedaccumulate;assistant/attemptstream usage is included - Forked sessions skip the inherited prefix by
inheritedEventCount, so the parent is never billed twice - Cost = Σ(token bucket × its rate) / 1e6; DeepSeek's buckets are split by the instant's tier while folding, and switching currency does not rewrite them
- The price table is denominated in USD per million tokens;
¥display converts at the fixed 7:1 rate - The price table has two sources that share one parser (
src/host/reference-parse.js, used by both the generator and the runtime):- Bundled:
scripts/gen-prices.mjs(npm run prices) at release time; CI runs it weekly and opens a PR only when the upstream data changed. Offline installs price from this table. - Pulled by the user: the cost card's "Pull the latest price matching" entry, or "Pull latest prices" in the dialog. The host fetches the opencode Zen catalogue, the DeepSeek pricing page and the public-holiday calendar, parses them, runs the same validation, swaps both and stores them at
<DSH_HOME>/cache/dsh-plugin-usage/reference/table.json, which the next start reuses. Prices and calendar are one click and one stored payload — no extra entry point. The dialog marks the table as built-in or updated and shows the capture date; "Restore the built-in table" undoes it - A pull happens only when someone clicks: no timer, and activation never fetches. Network failures, layout changes and a table that fails validation are reported separately and the bundled data stays in force. A holiday calendar that cannot be fetched does not fail the refresh — one extra sentence, and the peak rule keeps using the bundled calendar
- Bundled:
- Public holidays come from NateScarlet/holiday-cn; the year span follows the usage data's date range plus one year forward (the runtime pull uses the same rule)
Compatibility
- DSH
>=0.2.1-rc.3 <0.3.0(engines.dsh; verified against0.2.2-rc.3with both native contract gates and 250 unit tests), Node ≥ 22 - The settings nav icon uses the official
settings.section.icon(0.2.2-rc.1): the registration id must equal the section id (token-stats); earlier kernels lack the slot and fall back to the official gear, with everything else unchanged - The plugin-detail star nudge uses the official
plugins.detail.section(0.2.2-rc.1); earlier kernels simply omit that line - The composer cost pill needs the 0.2.1
conversation.composer.dock: 0.2.0 has no such slot; a failed injection logs a warning and leaves the settings page untouched - Earlier hosts keep the
Session.events/readFromfallback path
Documentation
The public documentation library lives in docs/: design trade-offs, assembly contracts, configuration, troubleshooting, compatibility and project experience. The maintainer handbook is MAINTAINING.md; private material (roadmap, decisions, research) lives in docs-private/ (only its entry README is tracked).
- Design · Architecture · Native alignment
- Configuration · Troubleshooting · Testing
- Changelog · Contributing · Security
Development
npm install
npm run build # tsc -> lib/, then emit lib/client/index.js
npm test # pretest builds, then unit tests + the documentation link gate
npm run verify:typert # validate the typert contribution with the official loader (SKIPPED without the asar)
npm run verify:remote # run the native channel with the real cordis + typert registry (same SKIPPED rule)
npm run check:docs # only the public docs' relative-link and anchor check
npm test has five layers, and each one catches a different class of problem:
| Layer | Covers | Failure looks like |
|---|---|---|
tests/*.test.js |
Pure functions and host behaviour (fold / pricing / rpc / typert / i18n …) | An assertion |
tests/*.test.cjs |
Built artifacts: the pricing dialog and the plugin detail entry with a real bundle + fake host, 75 checks | CHECK(S) FAILED with names |
tests/fold-parity.test.js |
Reconciliation of our event fold against the official tokenUsage projection |
The four counts differ |
npm run verify:remote |
Real cordis + real typert registry: face registration, receiver service, and the "one-shot probe during activation fails" regression | CHECK(S) FAILED |
node tools/check-docs.mjs |
Relative links and anchors in the public docs | The broken links are listed |
The parity fixture is recorded, not handwritten: scripts/fold-parity-fixture.mjs extracts the official @deepseek-ai/dsh-token-meter usage-projection.js from the local asar, runs it verbatim and writes the result to tests/fixtures/token-usage-parity.json. Re-run it after a DSH upgrade; never edit the numbers by hand.
CI runs install → build → test → bundle-id contract → tarball content checks; pushing a v* tag verifies the version, builds and tests, and creates a GitHub Release.
src/host/ host: scan / fold / fold-cache / query / state / aggregate / prices / pricing / peak / holidays / settings / rpc / typert
src/client/ the settings dashboard + the plugin-detail star nudge (plain JS, inline stylesheet)
scripts/ build entry + price/holiday generators + the fold-parity recorder + two native contract checks
docs/ public documentation library (navigation / design / reference / guide / experience / testing)
docs-private/ private documentation library (only its entry README is tracked)
tests/ unit tests, built-artifact gates, fold parity, i18n and documentation-link gates
Client → host channel: prefer the native typert Remote (src/host/typert.js registers the face; the client mounts it with remote.$mount), and fall back to connection.fetch /api/usage/* when it is unavailable. Both stay available; the dashboard response's channel field says which one answered.
Install and upgrade hard rules
Install with the official plugin manager (plugin_manager install_bundle + a file: tarball). pnpm has an awkward decision chain for a same version, same path file: dependency (measured 2026-10-31, pnpm 11.7/11.28):
| Attempt | Result |
|---|---|
Same version, replaced tarball content, then install_bundle |
ambiguous-install: only cleanup, nothing installed |
pnpm install --force |
Already up to date (or still the old content) — it fetches by the lockfile integrity, not the file |
Delete node_modules/<pkg> then pnpm install |
Still Already up to date; the directory is not restored |
There is no reliable same-version replacement. The only stable path is: bump the version → install_bundle → restart.
⚠️ Never overwrite
node_modules/<pkg>while DSH is running. Measured 2026-10-31 02:00: about 0.8 s after a tarball was laid into a running profile, the host exited with0xC0000005. Quit DSH before touching files, or use the manager + restart.With a development junction /
link:install,npm run buildrewriteslib/while the running host is reading it; avoid building during long tasks. Client changes need a page refresh; host changes need a restart.
Only bump the version when a release is warranted, and always verify the artifact (read package.json's version, grep for a marker added in this change) rather than trusting the manager's applied.
For development you can also load from source with
--patch:dsh web --patch cordis.yml(paths incordis.yml).
License
Links
More in this category
bowenliang123/dsh-context★ 5616
DeepSeek Harness officially recommended - a context insight plugin for context composition, evolution and Multi-Agent collaboration. It provides a cross-session Insights page (tokens, cost, cache hit, activity heatmap, skill and tool loads), a per-session Context tab (composition, token and timing stats, timeline, browser, events, file activity, command executions), a Fleet tab for the agent family (the current agent, its parents and every subagent), and a /context command.
Han-1413141/dsh-cost-meter★ 787
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★ 292
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 206
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★ 195
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.