dsh-token-gist: Cumulative Token Usage Statistics and GitHub Gist Backup

Introduction

In DeepSeek Harness (DSH), historical Token usage statistics are often lost after deleting, archiving, or cleaning up session logs. This causes gaps in cumulative usage tracking, impacting cost accounting and usage planning. While DSH provides Token metering natively, it lacks cross-session accumulation, persistent backup, and state management independent of session logs. The dsh-token-gist plugin addresses this by maintaining cumulative totals locally and periodically syncing them to a GitHub Gist.

What It Is

dsh-token-gist is a DeepSeek Harness plugin that accumulates Token usage across all sessions (including sub-agents) and syncs the totals (with daily breakdowns) to a private GitHub Gist. The cumulative totals are maintained independently of session logs—deleting or archiving sessions will not reduce the recorded totals.

Core Features

  • Cumulative total tracking: Accumulates Token consumption across four dimensions reported by the provider—input, output, cache read, and cache write.
  • Independent of session logs: Totals are maintained in a local state file; deleting, archiving, or cleaning session logs will not decrease the accumulated values.
  • Gist backup & sync: Pushes totals and daily breakdowns to a GitHub Gist, supporting both automatic scheduled sync and manual immediate sync.
  • Sidebar card: Displays the current cumulative total and last sync status in the DSH interface, with a sync button.
  • Slash commands: /token-usage prints the current total; /token-usage sync pushes to Gist immediately.
  • Local persistence: State is written atomically to $DSH_HOME/dsh-token-gist/state.json.

Installation & Enablement

Install from a local directory (the repository must be cloned first):

plugin_manager  action: install_bundle  target: <absolute path to the directory>

After installation, go to Settings → Plugins to enable the plugin.

Configuration Fields

Configure via the plugin settings page, or edit cordis.patch.yml:

Field Default Description
gistToken — GitHub personal access token with gist write permission. A fine-grained token scoped to “Gists → Read and write” is recommended.
gistId — An existing Gist ID for updating; leave empty to create a new Gist on first sync.
gistFilename dsh-token-usage.json Filename within the Gist.
autoSync true Whether to auto-sync at a set interval.
syncIntervalMinutes 30 Auto-sync interval (minutes), range 1–1440.
description DSH token usage total Gist description.

The token can also be set via the environment variable DSH_TOKEN_GIST_TOKEN.

Typical Usage

  • Check Token usage: Type /token-usage in the conversation to print the current cumulative total.
  • Manual sync to Gist: Type /token-usage sync to immediately push the current total to the specified Gist.
  • Sidebar action: Click the “sync” button in the DSH sidebar card for manual sync.

Use Cases & Notes

Suitable for administrators or developers who need long-term Token consumption tracking, cross-session cumulative statistics, backup, and independent state management. The plugin runs with the permissions of the current DSH process; review the source code and license before use.

Conclusion

With the dual safeguard of local state and Gist backup, this plugin makes Token usage tracking more reliable, ideal for DSH users who require continuous monitoring and cost accounting.

Directory page: https://www.skillhub.cn/plugins/xiaoniangaoh/dsh-token-gist
GitHub: https://github.com/xiaoniangaoh/dsh-token-gist

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

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

Xiaoye