Introduction¶
The DeepSeek Harness (DSH) plugin system allows for the extension of core functionalities. In agent development or daily usage, tracking Token consumption and monitoring model activity are common requirements. dsh-usage-stats is a “Usage Statistics” plugin designed for the official DSH desktop application. It adds a dedicated statistics section to the settings page, offering visualization features such as a five-grid lifetime summary, GitHub-style heatmaps, and trend lines. All data processed by this plugin is stored locally on disk, involves no network uploads, and introduces no additional runtime dependencies.
Core Features¶
The plugin primarily provides the following visualization and data functionalities:
- 5-Grid Lifetime Summary Bar: Displays cumulative Token count, single-day peak Token count, longest chat duration, current streak days, and longest streak days.
- Token Activity Heatmap: Presents Token activity over a 52-week period, supporting switches between daily, weekly, and cumulative views.
- Trend Lines: Provides trend line charts for three time dimensions: today, last 7 days, and last 30 days, with the ability to view data by specific model.
- Model Usage Donut Chart: Displays the Token usage proportion for each model within a selected time range.
- Historical Session Backfill: The plugin automatically scans and backfills historical session data upon startup; users can also manually trigger this by clicking the “Backfill History” button in the footer.
- Local JSONL Storage: Data is saved locally in JSONL format, serving as the single source of truth.
- Zero Upload & Zero Dependency: Sends no data to remote servers and requires no
npm install.
Installation & Activation¶
Installing this plugin requires the use of DSH’s plugin management command. Ensure the host environment meets the requirements: DSH version 0.2.0-rc.2 or higher, and host Node.js version >= 22.15.
Install via the GitHub tag tarball channel (Recommended):
dsh plugin --profile desktop add https://github.com/axuan-1314/dsh-usage-stats/archive/refs/tags/v0.2.0.tar.gz
After installation, the plugin takes effect automatically and adds a “Usage Stats” section to the settings page. If using the web or headless profile, replace --profile desktop in the command with the corresponding profile name.
Data & Configuration¶
Data Location¶
All statistics data is stored on the local filesystem and is not uploaded. The default path is ~/.dsh/usage-stats/. Data includes monthly rotating JSONL transaction files (records-YYYY-MM.jsonl) and daily aggregation cache files.
Configuration Keys¶
The plugin supports the following configuration keys (usually set in the config file):
enabled: Whether to enable the plugin, defaults totrue.storageRoot: Custom data storage root directory.sessionsRoot: Custom session file path.
Typical Usage¶
After installing and restarting DSH, you can view data in the “Usage Stats” section of the settings page. To fetch data directly via API, you can access the following endpoints:
- Get Summary:
GET /api/dsh-usage-stats/summary - View Heatmap:
GET /api/dsh-usage-stats/heatmap?days= - View Trend:
GET /api/dsh-usage-stats/trend?days=1|7|30 - View Model Usage:
GET /api/dsh-usage-stats/models?days=7|30
For historical data, if the plugin has not automatically completed the backfill, you can click the “Backfill History” button in the footer. This operation adopts a 202 Accepted mechanism and executes in background shards, ensuring the interface does not freeze.
Use Cases & Notes¶
Suitable Scenarios¶
This plugin is suitable for developers who need to monitor Token consumption costs in detail, analyze usage habits, and manage multi-model usage scenarios.
Notes¶
- Single-Writer Lock: If two DSH instances are launched simultaneously, the instance loaded later will degrade to a read-only mirror, displaying data without collecting or backfilling.
- Memory State: Live fold slot data is stored in memory and will be lost after a process restart.
- Version Requirements: Please ensure the DSH version is not lower than 0.2.0-rc.2 and the host Node.js version is not lower than 22.15; otherwise, it will not function correctly.
Summary¶
The dsh-usage-stats plugin provides a lightweight usage statistics solution for DSH through local collection and backfill mechanisms. It requires no complex dependency configuration, data is fully controllable, and it serves as a fundamental tool for developers to monitor and optimize agent costs.