Preface

DeepSeek Harness (DSH) maintains session logs. Ensuring the accuracy and traceability of token counts after a restart or long-running session is a concrete technical problem. Existing solutions may only provide visualization, but in scenarios that require defending numerical accuracy, looking at charts alone is not enough.

The dsh-token-ledger plugin folds DSH’s persistent session logs into total token counts and lets you recalculate those numbers from raw logs, then compare them against the runtime-recorded values.

What Is This

This is a ledger, not a dashboard. It folds persistent DSH session logs into total token counts, stays restart-safe, and lets you recalculate the same numbers from raw logs and diff them against the host-recorded results.

Core Features

  1. Restart-safe ledger: Persists logs into total token counts; state is preserved after restart.
  2. Audit command: The CLI (dsh-token-ledger audit) reads raw logs and diffs the results to verify data consistency.
  3. Billing generation: Generates bills on the settings page, with support for exporting to CSV or JSON.
  4. Settings page: Contains three tabs: Overview, Rates, and Bills.
  5. Lightweight: No runtime dependencies, no install scripts, and uses only node: imports.

Installation and Activation

Add the plugin using the official installation command:

dsh plugin --profile web add @chenmiao8563/dsh-token-ledger

After restarting DSH, check whether the configuration has taken effect:

dsh --profile web --dump-config | grep token-ledger

Typical Usage

The plugin provides a command-line interface and internal DSH commands:

# 在 DSH 会话中查询
/tokens
/tokens export     # 导出 CSV + JSON 到 <DSH_HOME>/token-ledger/exports/
/tokens json       # 查看原始快照
/tokens path       # 查看账本文件路径

# 命令行审计
dsh-token-ledger audit

The ledger file is located by default at <DSH_HOME>/token-ledger/ledger.json.

Applicable Scenarios and Notes

This plugin is suitable for scenarios that require verifying token counts, auditing logs, and generating exportable bills.

Notes:
* Zero dependencies: No runtime dependencies; all peer dependencies are optional.
* No model interface: Does not register prompt sections, messages, or tools, and does not interfere with requests or caching.
* Soft failure: Hooks are protected; ledger failures only log warnings and do not interrupt the session.
* License: MIT.

Conclusion

When you need to verify the accuracy of token statistics, this plugin is more useful than simple charts. It verifies results by recalculating from raw logs, ensuring that the ledger data is authentic and reliable.

  • Plugin catalog: https://www.skillhub.cn/plugins/chenmiao8563/dsh-token-ledger
  • Source code: https://github.com/chenmiao8563/dsh-token-ledger