Introducing the DeepSeek Harness Plugin: dsh-usage-lite

The core philosophy of DSH (DeepSeek Harness) is “Everything is a Plugin.” In the process of agent development and debugging, tracking token consumption across sessions is a frequent requirement. dsh-usage-lite is a plugin maintained by developer ChrisLou-bioinfo. It requires no build step, aggregates token data from all local sessions directly, and adds a “Usage Statistics” page to the settings panel for visualization.

Core Features

The plugin provides the following statistical and visualization capabilities:

  • Summary Cards: Displays Total Tokens, Input (uncached), Cache Read (with hit rate), Cache Write, and Output (including reasoning).
  • Time Range Switching: Supports viewing data for the last 7 days, 30 days, or all history.
  • Multi-dimensional Rankings & Charts: Provides daily usage bar charts, rankings by model, and rankings by workspace.
  • Incremental Indexing & Persistence: After the initial full scan, it only re-reads added or modified sessions and persists the index snapshot to ~/.dsh/usage-lite/index.json, avoiding redundant calculations.

Installation & Activation

Install via the official plugin command. This plugin is compatible with DSH 0.2.0-rc.2+ (supports both Desktop and Web Profile).

dsh plugin add github:ChrisLou-bioinfo/dsh-usage-lite

Once installation is complete, open the Settings → Usage Statistics page to view the data.

Statistical Criteria & Data Flow

The plugin’s data source is local session logs, with the following specific rules:

  • Data Source: Prioritizes reading ctx.sessionQuery (Live data), with a fallback to readSession(id) to read persisted events.
  • Filtering Rules: Only counts samples in assistant/message events where data.usage exists and data.message.source.kind === "model"; ignores process values in streaming assistant/attempt.
  • De-duplication: Skips events preceding inheritedEventCount to avoid double-counting tokens from parent sessions when forking or resuming.
  • Calculation Formula: total = input + output + cacheRead + cacheWrite; reasoning is listed separately.
  • Cache Hit Rate: cacheRead / (cacheRead + input). If the provider does not report caching, it displays “—”.

Technical Maintenance Notes

  • Client Constraints: The client bundle (client.js) must only depend on platform seed modules (e.g., react, dsh-client-store); importing external dependencies is prohibited.
  • Inject Service Name: The exports.inject in client.js must be the service name ["slots"] (not the package name). Incorrect configuration will cause Web startup to fail with “entry did not activate”, and the desktop app may trigger a recovery flow after consecutive failures.
  • Upgrade Troubleshooting: If the settings page appears blank after a DSH version upgrade, please check the loading audit information in Settings → Plugins → Plugin list.
  • Plugin Removal:
    • Command Line: dsh plugin remove dsh-usage-lite
    • Manual: Delete the insertion entry for the corresponding profile in cordis.patch.yml.
    • Index Cleanup: The ~/.dsh/usage-lite/ directory can be deleted (Recommended).

Summary

dsh-usage-lite is a lightweight token statistics tool that achieves cross-session data aggregation without network requests through incremental indexing and local snapshot technology. For developers who need granular cost control and monitoring of model calls, this is a ready-to-use tool.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye