Preface¶
In DeepSeek Harness (DSH), when running multiple sessions and workspaces, tokens are scattered across their respective session artifacts, making it hard to see at a glance how many were used today, how much cache read/write is involved, or which retry stacked another layer. Relying on scattered logs or manually digging through records is slow and not conducive to comparing against “official tokenUsage projection” numbers.
Below is the community plugin dsh-token-usage (maintainer 879745uhjun, category admin-security): It registers a global panel in the main interface with the same mechanism as the “Plugin Page”, uses a read-only route to incrementally scan persistent artifacts under ~/.dsh/sessions, and displays real-time and historical usage on a separate page, along with a sortable table and estimated cost. No prompt modification required, nor does it register Host tools.
What is this¶
dsh-token-usage targets DSH local users: aggregates the usage of each durable session onto one page, and supports grouping by time window, workspace, and export. Current package version is 1.3.0, license MIT, depends on DSH >=0.2.2-rc.1 and <0.3.0. Community directory see SkillHub entry, source code see GitHub: 879745uhjun/dsh-token-usage. SkillHub and DeepSeek / Huanfang have no official affiliation, just a community listing site.
The plugin defaults no Configuration required; spend numbers are reference estimates, not bills.
Core Features¶
Independent Page, Not an Overlay¶
The plugin registers a global panel in the center column: enter Token usage from the sidebar, it will replace the session view in the main slot (same mechanism as the Plugins page), use Back to chat or open any session to return. This is a “real page”, not an overlay covering the chat.
Real-time Scanning and Running Marker¶
The Host side performs incremental reads on ~/.dsh/sessions: only decoding Zstandard frames appended since the last poll. The browser polls the same-origin read-only route /token-usage every 2 seconds; sessions still running show a green dot with “running now” marker.
Aggregation, History Band, and Time Windows¶
The page header allows selecting today / last 7 days / last 30 days / all time, and both summary cards and tables are recalculated based on each session’s own “daily buckets”. There is also a history band for the last 14 local calendar days; each summary card has a trend badge (e.g., ▲56%, ▼12%) in the bottom right, hover to see detailed values of the comparison window.
Sortable Table and Search¶
Clicking table headers toggles ascending / descending, involving columns such as session, model, input, output, cache read, cache write, total, spend, cache hit rate, last active, etc. Search can filter by session, workspace, model, or id; sessions with no usage records are hidden by default, expand to show when needed.
Workspace Grouping and Sub-sessions¶
Rows can be grouped by workspace and show subtotals; sub-agent sessions can be collapsed into parent session chips (e.g., 1 sub-sessions · ¥1.22), click to inline expand. Groups can be closed.
Export¶
Three buttons above the table: CSV · sessions (current filtered/sorted result, raw integers, UTF-8 BOM), CSV · days (daily totals for the selected time range), Copy table (Markdown table, easy to paste into documents).
Number Meaning and Warm Start Cache¶
Usage folding logic is consistent with the built-in tokenUsage projection: the final assistant settlement of a single attempt replaces streaming sampling; retry attempts are billed separately. Incremental read results are cached in ~/.dsh/token-usage-cache.json (keyed by artifact size and modification time), the README states cold start is approx 2.3 s, warm start approx 7 ms; if the file changes, it falls back to incremental read.
Estimated Spend (Optional Override Unit Price)¶
Each attempt is priced based on the model and peak/valley window at the time of occurrence; the built-in table uses DeepSeek official CNY prices (Flash: cache-hit / miss / output per million tokens is 0.02 / 1 / 4; Pro: 0.15 / 4.5 / 13.5), rate within Beijing peak window multiplied by 2. Spend appears in summary bars, table columns, and default historical metrics.
When customization is needed, create ~/.dsh/token-usage-prices.json (all fields optional, default to built-in values if not written):
{
"currency": "CNY",
"symbol": "¥",
"peakMultiplier": 2,
"models": [
{ "match": "minimax", "cacheHit": 0.3, "cacheMiss": 3, "output": 9 },
{ "match": "deepseek-v4-pro", "cacheHit": 0.15, "cacheMiss": 4.5, "output": 13.5 }
],
"fallback": { "cacheHit": 0.02, "cacheMiss": 1, "output": 4 },
"holidays": ["2026-10-01", "2026-10-02"]
}
match is a case-insensitive substring of the model name, longest match takes precedence; holidays are statutory holiday dates billed at valley rate for the full day, need to be added manually by year.
Implementation Points and Boundaries¶
| File | Function |
|---|---|
index.js |
Host: Incremental Zstd read sessions, usage folding, read-only /token-usage |
client.js |
Browser: Panel, summary, 14-day history, sortable table and polling |
The Host does not register tools or inject prompts, only provides a read-only JSON route. The plugin will not read account balance; private rates not declared in the override file are also unknown. Pricing is based on uncached, cache-write, and cache-read prompt token usage reported by the provider.
Installation and Enablement¶
The README and package metadata do not provide a CLI command like dsh plugin add …. The community directory page provides a “Send to DeepSeek Harness to install” guide, with the plugin identified as 879745uhjun/dsh-token-usage. Before installing, it is recommended to check index.js, client.js, and the MIT license on GitHub to ensure it meets engines.dsh constraints with your current DSH version.
The plugin reads local ~/.dsh/sessions and session cache files with the current dsh process permissions; only install if you trust the source code and the maintainer.
Typical Usage¶
- After installing and restarting or refreshing the DSH client, open Token usage in the sidebar.
- Select a time window in the page header (e.g., last 7 days), view summary cards and the 14-day history band.
- Use the search box to locate a specific workspace or model, click column headers to sort by total or spend.
- For archiving, click CSV · sessions or Copy table; if reconciling custom model unit prices, first configure
~/.dsh/token-usage-prices.jsonthen refresh the page. - When there are many sub-agents, expand the sub-session chips under the workspace group to check for duplicate billing.
Maintainer local test commands (for development, not mandatory steps for end users):
node test/host.test.mjs
DOM-related tests require pnpm add -D jsdom react react-dom first, then execute node test/page.dom.test.mjs.
Suitable Scenarios and Notes¶
Suitable for: Developers who use DSH locally for a long time and need to compare input/output/cache by session, care about cache hit rate and reference spend; scenarios that require exporting usage tables to CSV or Markdown for weekly reports.
Notes:
- Data all comes from local session artifacts and plugin cache, not involving cloud billing API.
- Peak/Valley and holiday rules are based on built-in logic and your written
token-usage-prices.json, may deviate from actual billing. clientis configured withimmediately: trueand injects several@deepseek-ai/dsh-client-ui-*modules, needs to be compatible with the current DSH frontend bundle.
Conclusion¶
Following the steps above, you can converge the tokens and cache traffic scattered in various sessions onto one page: real-time polling, 14-day trends, sortable and exportable, and override unit prices with JSON when needed. Further details see GitHub README, installation entry see SkillHub: dsh-token-usage.