DeepSeek Harness (DSH) uses a plugin-based architecture, allowing developers to enhance workflows through extended features. When using DSH over the long term for development or debugging, tracking Token consumption, estimating costs, and analyzing model performance are common needs. The dsh-token-usage plugin aims to address this issue by listening to DSH session logs and building a visualized statistics panel for users.
Core Features¶
The plugin mainly provides the following statistical dimensions:
- Real-time and Historical Replay: Monitors event streams of all sessions in real time and replays all historical session logs at startup. This means statistics include historical usage prior to plugin installation, and data is not lost after service restarts.
- Overview Panel: Displays total Tokens and estimated costs for today, this week, and this month, broken down into categories such as input, output, and cache hits.
- Task Statistics: Analyzes this week’s tasks, including thinking duration (calculated based on
reasoning-deltafragments), total task duration, number of tasks, and number of steps. - Leaderboards:
- Top 3 Tasks: The tasks with the highest Token consumption this week.
- Model Rankings: Token consumption share, progress bars, and costs for each model this week.
- Project Statistics: Usage grouped by workspace (session cwd), with support for switching between weekly and all-time views.
- Chart Display: A stacked bar chart for the last 14 days, with hover tooltips showing daily details.
- Pricing Settings: Supports DeepSeek’s official peak/off-peak pricing rules (peak-hour prices are doubled) and supports one-click fetching of the latest pricing from the official website.
Installation and Enablement¶
Before installing, ensure that DeepSeek Harness (DSH), git, and pnpm are installed.
One-Click Installation¶
Use the official installation script:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/KeFan-J/dsh-token-usage/main/install.sh)"
The script automatically clones the repository, installs dependencies, and mounts the plugin into the DSH web profile. After installation, perform the following steps to enable the plugin:
- Restart the DSH service:
npx @deepseek-ai/dsh web
- Force-refresh the browser page (
Cmd+Shift+R). - Open Settings (gear icon), find and click “Token Usage” in the settings list.
Manual Installation¶
If you need to customize the installation path, use the following commands:
git clone https://github.com/KeFan-J/dsh-token-usage.git
cd dsh-token-usage
pnpm install
dsh plugin --profile web add "link:$(pwd)"
# 重启 DSH + 强制刷新浏览器
Implementation Principles¶
- Host Side: Listens to the global
session/eventstream and replays logs at startup. Deduplicates usingsessionId:seqto prevent duplicate calculations. Calculates costs based on the effective pricing rules (including peak/off-peak) and provides JSON API routes. - Browser Side: Registers a page in the DSH settings slot, using
--dsw-*theme variables to adapt to light/dark modes. - Mounting Method: Mounts as a bare plugin line into the bundle layer of the DSH profile via
cordis.patch.yml, without modifying the DSH source code.
Data and Privacy¶
- Local Storage: All data is stored locally only. Usage comes from DSH’s own persisted session logs, costs are calculated locally, and no telemetry data is uploaded.
- Outbound Requests: The only external request is the “Fetch latest prices from the official website” button, which only reads the content of DeepSeek’s public pricing page.
License¶
MIT
Project Address: https://github.com/KeFan-J/dsh-token-usage