DeepSHPlugins
token-usage-counter 项目预览
GITHUB / COMMUNITY PROJECT

token-usage-counter

安全与运维TypeScriptMIT

持久化 provider 上报的 Token 用量统计,支持按会话、按模型和按日活跃度查看。

1 StarsMu-scorpio 更新时间 2026-09-09
访问 GitHub 仓库
token-usage-counter 项目预览

项目介绍

中文

持久化 provider 上报的 Token 用量统计,支持按会话、按模型和按日活跃度查看。

English

Persistent provider-reported token usage totals with per-session, per-model, and daily activity statistics.

项目信息与收录信号

快照 2026-09-11
作者 / 组织
Mu-scorpio
仓库
Mu-scorpio/token-usage-counter
GitHub Stars
1
Forks
0
开发语言
TypeScript
许可证
MIT
最近推送
2026-09-09
Manifest
数据中检测到声明

公开仓库不自动等于可商用;许可证与当前兼容性以原项目文档为准。Manifest 和数据评分不构成安装安全认证。

数据评分

54/ 100
维护活跃
99
文档与实用信息
85
生态关注度
9
安装便捷信号
100
项目声明信号
100

近 2 天仍在更新;README 含完整安装与使用说明;关注度尚低(1)。

评分来自已有数据快照的五维模型,仅作浏览参考,不是实际使用评测或安全检测结论。

安装与使用

所有项目资料与许可均以对应 GitHub 仓库为准。

dsh plugin --profile web add dsh-token-usage-counter

复制命令不会自动执行。请先阅读仓库文档,确认环境要求与许可证。

项目截图

仓库 README

GitHub 原文

已保存的仓库文档快照;文档抓取时间未记录,可能与上方目录介绍处于不同版本。安装前请核对当前仓库说明。

Token Usage Counter for DeepSeek Harness

Persistent provider-reported token usage statistics for DeepSeek Harness. The plugin keeps uncached input, cache read, cache write, and output usage in separate buckets, and exposes cumulative, daily, per-session, and per-model views.

Features

CapabilityDescription
Accurate bucketsKeeps the four provider-reported usage buckets separate.
Persistent totalsStores data in the plugin-owned dsh-token-usage-counter settings namespace.
Multiple viewsProvides global, session, and provider/model summaries.
Daily activityTracks local-day token totals and call counts.
Built-in settings pageShips its own Web settings view and heatmap.
Safe commitsCounts usage only after a successful completion anchor.
Interactive commandRegisters /tokens when the commands service is mounted.

Install

Install the published DSH Bundle into the web profile:

dsh plugin --profile web add -w --config.auto-install-peers=false dsh-token-usage-counter dsh web

The Bundle is additive: it mounts only the plugin-owned token-usage-counter entry and leaves the built-in usage accumulator and page enabled.

Version 0.4.0 moves persistence from the shared usage-stats namespace to the plugin-owned dsh-token-usage-counter namespace. Existing 0.3.x totals are not silently migrated because the shared namespace belongs to the built-in plugin; the new counter starts with an independent snapshot after the upgrade.

Local development

From this checkout:

dsh web --patch ./cordis.yml

The local overlay mounts src/index.ts without replacing built-in components. For a manual composition, add only the plugin-owned entry:

  • insert:
  • id: token-usage-counter

name: './src/index.ts'

Compatibility

  • Node.js: 22.13.0 or newer.
  • DSH: 0.1.2-alpha.3–0.1.2-alpha.5 and 0.1.5-alpha.2 have profile smoke checks; intervening releases are explicitly unknown.
  • Profile: web.
  • Exact per-release results and disposable-profile evidence are recorded in

docs/VERIFICATION.md.

Store listing migration details: docs/STORE-REMEDIATION.md.

Build

npm install --ignore-scripts --legacy-peer-deps --no-package-lock npm run build npm run verify

The generated host and client bundles are committed under lib.

Counting rules

The plugin listens to the durable session event stream:

  • assistant/message.usage is counted once.
  • compaction/summary.usage is counted as one provider call.
  • A usage-only assistant/chunk is held until its matching assistant/message.
  • When a chunk and final message describe the same turn and step, the final

value replaces the early sample.

  • Failed requests, retries, and fork seed history are not counted twice.

API

The plugin provides ctx.tokenUsageCounter:

ctx.tokenUsageCounter.getSummary() ctx.tokenUsageCounter.getSession(sessionId) ctx.tokenUsageCounter.getModel(provider, model) ctx.tokenUsageCounter.formatSummary()

Links

  • npm: https://www.npmjs.com/package/dsh-token-usage-counter
  • GitHub: https://github.com/Mu-scorpio/token-usage-counter
  • DSH Bundle documentation: https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/user/develop/basic/publish.md

License

MIT

使用前核对

安装步骤、兼容版本与授权范围以原项目当前文档为准。Stars 和评分是快照中的导航信号。

安装与排错 · 项目问题反馈

同类项目