Introduction¶
Teams running agents with DeepSeek Harness (hereinafter referred to as DSH) face a common issue: every session produces token usage, but these numbers are scattered across individual sessions. To know how much was spent in total this month, which days were peak consumption, and how much deepseek-v4-flash and other providers/models account for, one often has to check session by session.
dsh-token-stats turns this into a settings panel: it aggregates token usage across sessions, splits it by provider and model, and plots a monthly stacked cost chart. It is also a typical example of the DSH “everything is a plugin” philosophy—the entire feature is provided as an independent bundle without needing to change a single line of code in the core repository.
Below is an introduction to the plugin’s positioning, how it works, and installation steps.
What is it¶
dsh-token-stats is a plugin for DeepSeek Harness, maintained by qiushui0901, and is MIT licensed. One-sentence positioning: it provides a cross-session token usage statistics panel for DSH, with the core being a monthly stacked cost chart (USD) split by provider and model.
The version is 0.1.0, depends on zod ^3.23.8, has an optional peerDependency react ^18.2.0, and devDependencies include esbuild ^0.24.0 and @types/react ^18.3.0.
Core Features¶
Overview. Displays the number of sessions with usage records, token buckets (uncached input, cache read, cache write, output) reported by four providers, totals, and a cost breakdown estimated by matching price tables.
Monthly Cost Chart. A stacked bar chart (USD) by day and by model, supporting < / > month navigation, provider and model filtering, grid line scales fixed to two decimal places, and accompanied by a color legend.
Pricing by Model. Usage is priced by matching exact provider/model price tables. It includes built-in lines for deepseek / deepseek-v4-flash, with others falling back to the default price table. In this version, prices are fixed constants.
Data Honesty. Sessions where cache projection precedes per-model units (or deployments that simply lack these units) are marked as “no model data”. They are priced according to the default price table and provide clear hints in the interface; they will not be silently mixed into model-based statistics.
How it Works¶
The bundle is split in two.
Host Half (src/host/) registers two session projection units: modelUsage (total session usage by provider/model) and modelDailyUsage (cells by provider/model/UTC day), following the pattern of @deepseek-ai/dsh-token-meter. The registration is idempotent—the registry shares keys with the same stateVersion, so it is safe for deployments that already have the same built-in units (release builds or source code checkouts).
Client Half (src/client/) contributes a “Token Usage” panel via settings.section. It reads the session.list projection column to display data (zero-log loading), and shifts daily cells from UTC to the local time zone for display.
Installation and Enablement¶
Prerequisites: DeepSeek Harness is installed (either the dsh CLI or a source code checkout).
Method 1: npm Installation. The README labels this method as “once published”. As of the time of writing, it is unclear if the package has been published to npm. If the command is unavailable, please use Method 2:
dsh plugin --profile <name> add dsh-token-stats
dsh --profile <name> web
Method 2: Installation from Repository. Clone, build, and then add the local directory to the corresponding profile:
git clone https://github.com/qiushui0901/dsh-token-stats.git
cd dsh-token-stats
npm install && npm run build
dsh plugin --profile <name> add ./dsh-token-stats
dsh --profile <name> web
Method 3: Use with DSH Source Code Checkout. Mount directly using a patch file:
pnpm dsh web --patch /path/to/dsh-token-stats/cordis.patch.yml
Before using this method, you need to link dsh-token-stats into the checkout’s node_modules or install it into the profile corresponding to the checkout startup.
The build artifacts are lib/host.js (self-contained Node entry) and lib/client.js (browser bundle registered via window.__ModuleLoader__.load).
After the above steps, start it and open http://127.0.0.1:3080 in your browser. Go to Settings → Token Usage to see the panel.
Applicable Scenarios and Notes¶
Suitable for developers and teams who use DSH long-term, need to review token costs by month, and care about the consumption share of each model.
A few limitations worth knowing before use:
- Model Data Forward Fill. Sessions run before the
modelUsage/modelDailyUsageprojections exist cannot be attributed to specific models until the projection cache rows are rewritten. This portion of usage is priced according to the default price table. - Daily Bucketing Based on UTC. The host assigns cells under UTC days, while the client shifts them for display based on the full-day time zone offset. Therefore, daily cells near time zone boundaries may fall into adjacent local days.
- Prices are Fixed Constants. Prices are compiled into the bundle, and there is no editor in the UI. If the built-in rates do not match your situation, you need to modify
DEFAULT_PRICES/DEFAULT_PRICE_TABLESinsrc/client/usage-aggregate.tsand rebuild.
Finally, a reminder: plugins run with the permissions of the current dsh process. Before installing any third-party plugins, you should check their source code and license. dsh-token-stats is MIT licensed; the repository address can be found at the end of the article for your review.
Conclusion¶
If your DSH deployment lacks an entry point to view token costs by month and by model, dsh-token-stats can fill this gap with an installation process of less than 100 lines, without intruding on the core repository.
- Community Directory Page: https://www.skillhub.cn/plugins/qiushui0901/dsh-token-stats
- GitHub Repository: https://github.com/qiushui0901/dsh-token-stats
The community directory is an independent site and has no official affiliation with DeepSeek or High-Flyer. The plugin itself is built on the DeepSeek Harness plugin system, which is based on the MIT license.