Introduction

When using DeepSeek Harness (DSH) for model inference, tracking token consumption and cost is key to controlling spending. This plugin provides a localized usage statistics solution by reading local session logs, without relying on any online service, and displays data directly within the DSH environment.

Positioning

dsh-token is a local token usage statistics dashboard plugin maintained by fufuf-c, belonging to the model inference category. It addresses the narrow question of “how much did it cost and how many tokens were used,” while further providing a detailed perspective of “where tokens come from, how much was saved through caching, and which sessions consume tokens heavily.”

Core Capabilities

1. Four-Part Token Composition and Cache Savings

The plugin splits token consumption into four dimensions: miss, cache hit, cache write, and output. By distinguishing these four parts, it not only shows the total usage but also makes the cost savings from cache hits visible at a glance.

2. Global Filtering and Session Drill-Down

  • Global Filtering: Supports filtering by time (today/3 days/7 days/30 days/custom), model, session, and working directory. Supports sharing filter conditions via URL.
  • Session Drill-Down: The session details provide four-part statistics, per-model composition, per-request breakdown, and context growth curves. The interface marks requests with abnormal surges and supports direct navigation via ?session= deep links.

3. Cost and Budget Control

  • Built-in Pricing: Built-in DeepSeek official pricing table, supports peak/off-peak tiers and time-period modification.
  • Budget Monitoring: Provides a monthly budget ring progress bar, supports setting threshold alerts at 80% and 100%, and supports attributing costs by model or session.

4. Data Security and Interface

  • Zero Upload, No Online Dependencies: All data comes from local $DSH_HOME/sessions, decoded by the DSH official sessionPersistence service, without any data upload.
  • Interface Design: Uses an Apple-style four-tab interface, including multi-model stacked trend charts, day/week/month granularity switching, a 24-bucket hourly histogram, and an activity monthly calendar heatmap.

Installation and Usage

Install it via the plugin directory or the GitHub repository. After installation, the plugin provides three independent entry points in the sidebar, above the conversation area, and on the settings page, corresponding to the global dashboard, the session dashboard, and the settings information, respectively.

Typical usage:
1. Open the dashboard; by default, it displays the global token usage trend.
2. Use global filters (such as time or model) to quickly locate high-consumption sessions.
3. Click a session to enter details, and view the context growth curve and cache hit status.
4. Configure the monthly budget on the settings page and monitor cost thresholds.

Notes

  • Cost Calculation Logic: For models without built-in prices or custom prices, their cost is counted as 0. In this case, the estimated cost is displayed as “cost of priced portions + number of unpriced tokens” rather than a complete bill.
  • Data Persistence: Persistent storage is located under $DSH_HOME/dsh-token/, including the metadata file store.json and the shard record files under shards/. If store.json is corrupted, the plugin does not silently clear it; instead, it renames it to store.json.corrupt-<timestamp> and creates a backup.
  • Compatibility and Fault Tolerance: The plugin supports adaptive behavior across DSH versions, uses a failed session isolation mechanism, skips old logs within a cooling period, and ensures stable scanning.
  • Runtime Permissions: The plugin runs with DSH process permissions. Before installation, please check the source code and license (MIT).

Summary

dsh-token focuses on providing localized, fine-grained token cost analysis capabilities. With its four-part composition breakdown and budget management features, it helps developers more clearly manage inference costs and is suitable for DSH users who need fine-grained control of token consumption.