Introduction

The plugin ecosystem of DeepSeek Harness allows extending client capabilities. For developers, tracking token usage to evaluate cost or resource consumption is a common requirement. dsh-token-stat is a plugin for tracking cumulative token usage since first using DSH, with breakdowns by model and date. It provides a visual dashboard, and the data storage directory can be changed online from the settings page.

Core Features

This plugin provides the following core capabilities:

  • Cumulative statistics: Tracks cumulative token usage, including input, cache read, cache write, output, and total.
  • Breakdown queries: Provides detailed breakdowns by model and date.
  • Visual dashboard: Displays a dashboard with hand-written SVG charts on the settings page, including a donut chart, stacked column chart, and ranking view.
  • Data management: The data storage directory can be changed online from the settings page.
  • Zero dependencies: Zero runtime dependencies; no build step or authorization is required.

Installation

Install the plugin using a CLI command, with no additional build steps:

dsh plugin --profile <profile> add https://github.com/Anna-la/token-stat

After installation, the plugin automatically scans all historical sessions under <DSH_HOME>/sessions and begins accumulating usage data.

Usage

  1. View in the settings page: Open “Settings → Plugins → Configurable”, find the “Token Usage Statistics” card, and expand it. The card displays the cumulative total, breakdown tables by model/date, and metadata.
  2. View visual charts: After expanding the card, click “Visualization” to view hand-written SVG charts (model usage share donut chart, daily usage stacked column chart, and horizontal model usage ranking).
  3. Manage the data directory: Modify the “Data Save Directory” in the card and save to change the data storage location online.
  4. Rescan: Click the “Rescan” button inside the card to fully rebuild historical session aggregates from disk.
  5. Query via the dialog box: Ask “check the token usage statistics” in the dialog, and the model will call the plugin tool to return the report text.

Statistics Scope and Data Notes

  • Data source: Data comes from precise usage values reported by the provider in session logs.
  • Deduplication rule: Retries or duplicate reports within the same (turn, step) are counted only for the final sample.
  • Data isolation: Reports are written by default to ~/.dsh-token-stat, which is completely outside DSH_HOME. Official cleanup or reinstallation of directories such as profiles, storages, and sessions will not accidentally delete this plugin’s data.
  • Report files: Generates three files: report.md, report.json, and archive.json.
  • Tool calls: Supports tool-call based statistics queries.

Notes

  • Security: The API /api/token-stat/stats is accessible only from loopback addresses; external requests are rejected with 403.
  • Dependencies: Zero third-party dependencies; charts are hand-written SVG.
  • Retention after uninstallation: After uninstalling the plugin, historical report files remain in the default directory.
  • Read-only operation: The plugin only reads session logs and does not modify any session data.