zh667/TokenLedger
DeepSeek Harness 的中继站点基于令牌的使用统计 — 零配置,无需凭据
Project Overview项目介绍
TokenLedger is a native DSH plugin built exclusively for DeepSeek Harness, designed to track and aggregate token usage for all API requests routed through DSH. It works with DSH versions 0.1.0-rc.6 and above, and requires the DSH web profile to function. It automatically pulls usage data from DSH's internal request logs to generate accurate aggregates. To install, run the command dsh plugin --profile web add "github:zh667/TokenLedger" in your terminal, then restart the running DSH web instance and hard refresh your browser. Once installed, you will find the "Token Ledger" entry at the bottom of your DSH sidebar.
TokenLedger automatically discovers and pulls relay site information from your existing DSH provider configuration, so you do not need to re-enter any details. It only reads the baseURL of each provider and never accesses or exposes your stored API credentials. It groups usage data by relay origin and project working directory, and supports tracking balances, rolling subscription quotas, and usage across multiple popular LLM providers including DeepSeek, Moonshot, Z.ai, OpenRouter, and more. It is ideal for DSH users who manage multiple API relays and accounts to keep track of their spending.
TokenLedger is released under the open source MIT license, free for anyone to use and modify. All usage data is processed and stored locally, and the plugin never sends your API keys, request prompts, or response content to external servers. If you need to pin the plugin to a specific version, you must use the full 40-character commit SHA, as short SHA values cannot be resolved by the DSH package manager. To troubleshoot issues with missing relays, run the /tokenledger diagnostics command to check index health.
TokenLedger 是专为 DeepSeek Harness (DSH) 开发的原生用量统计插件,用于清晰统计 DSH 中所有 API 请求的 Token 用量,并将用量归属到实际处理请求的 API 中转站点。它支持按中转站点、项目目录分组统计,兼容 DeepSeek 官方、New API、Sub2API 等多种主流账户类型,开箱即用无需额外配置。它要求 DSH 版本不低于 0.1.0-rc.6,且启用 web 配置文件,可通过一行命令完成安装。
安装完成重启 DSH web 后,硬刷新浏览器就能在侧边栏底部找到「用量账本」入口。它会自动从 DSH 的 provider 配置中读取中转站点信息,不需要用户重复填写,仅读取 baseURL 绝不触碰用户的 API 凭据信息。普通 DSH 用户、使用多个 API 中转和账户的开发者都可以使用它,方便掌握各个站点的 Token 消耗、余额和订阅配额情况。
TokenLedger 遵循 MIT 开源许可协议,完全免费使用。它同时支持 DSH 的原生 Web UI 和 Blue UI,所有数据都存储在本地,不会向外发送任何用户凭据或请求内容。如需排查中转站点不显示的问题,可以执行 /tokenledger diagnostics 命令查看路由归属和索引健康度。若需要固定版本,安装时必须填写完整的 40 位 commit SHA,短 SHA 无法被正确解析。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:TokenLedger(zh667/TokenLedger)
仓库:https://github.com/zh667/TokenLedger
本站详情页:https://www.yhbd.top/plugins/zh667-tokenledger/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证 MIT · ⭐ 202 · 最近提交 2026-09-15 · 主语言 JavaScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【1 兼容性检查】
① 我这边:DSH 版本、Node 版本、操作系统、当前 profile(web / desktop)。
② 读它的 README、package.json、插件 manifest,列出它要求的 DSH 版本 / Node 版本 / 操作系统 / 外部依赖 / 需要另外先装的运行时。
③ 逐条比对,结论只写「满足 / 不满足 / 未知」三种;不满足的给出可行替代方案。
④ 检查是否和我已装的插件冲突:命令名重复、skill / tool 重名、端口占用、重复注册的 MCP server。
【2 安全性检查】
① 仓库可信度:和上面「本站登记」是否一致;star / fork 数、创建时间、最近提交,是否归档或长期停更。
② 安装脚本:逐行看 package.json 的 preinstall / install / postinstall,以及 install.sh、setup.ps1 之类脚本。出现 curl|bash、下载后直接执行、混淆代码、访问与插件功能无关的域名,立刻停下来告诉我,不要继续装。
③ 依赖:列出新增依赖,标出无人维护、或与知名包拼写近似的可疑包(typosquatting)。
④ 权限与副作用:它会读写哪些目录、访问哪些域名、需要哪些 DSH 权限(filesystem / network / shell / clipboard 等),以及怎么卸载和回滚。
⑤ 如果它要求 sudo / 管理员权限,或权限明显超出功能所需,先停下来问我。
【3 安装】
上面两步没有「不满足」和「高危项」时才执行;用官方推荐方式安装,不要自行提权。
【4 汇报】
用表格输出:检查项 / 结论 / 依据 / 是否需要我决策。拿不准的一律写「未知」并说明要我怎么确认——不要猜,也不要替我决定。
Send this message to DSH in your current session: it verifies compatibility and security first (answering met / not met / unknown item by item) and only installs once everything checks out — it will stop and ask you if it finds a high-risk item. The box scrolls; the copy is the full prompt. CLI install commands may not be accurate across systems, so DSH is the safer route.把上面这条消息直接发给当前会话里的 DSH:它会先核对兼容性与安全性(逐条给「满足 / 不满足 / 未知」),确认没问题再安装,有高危项会停下来问你。框内可滚动,复制到的是完整提示词;安装命令不一定准确,发给 DSH 更稳。
- This site's static screen found no obvious risk signal (stars, license, activity, manifest)本站静态筛查没发现明显风险信号(星标、许可证、更新活跃度、清单完整度)
DSH walks through these 9 checksDSH 会逐条核对这 9 项
Compatibility兼容性
- DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
- External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
- Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册
Security安全性
- Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
- Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
- curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
- Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
- Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
- Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式
Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add "github:zh667/TokenLedger"
把 zh667/TokenLedger 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
TokenLedger
把 DeepSeek Harness 的 Token 用量算清楚,并归属到实际服务这次请求的中转站——不用配置,不用凭据。
Token-usage accounting for DeepSeek Harness, attributed to the relay site that
served each request. The existing Web GUI (dsh web) and renderer-neutral
consumers share the same host-owned aggregation. Zero configuration.

展示图使用演示数据与本机模拟中转站;面板上的每个数字都由真实代码路径算出,只是数据是造的。插件不会把 API Key 或上游原始响应发送到浏览器。
一眼看懂 / At a glance
| 能力 | 说明 | |
|---|---|---|
| 🎯 | 中转站归属 | 按 provider 的 baseURL 归一化 origin 分组——同一站的多把 key 合成一行,站名就是域名,不是你自己起的路由别名 |
| 📁 | 按项目归属 | 用量按会话启动时所在的目录分组——工作区注册过的用它的标题,没注册过的用目录名,子目录里起的会话照样算进去 |
| 🔍 | 零配置发现 | 从宿主的 provider 配置里读出中转站,不用你再填一遍。只读 baseURL,绝不碰旁边的凭据 |
| 💳 | 余额 | DeepSeek 官方、New API、Sub2API,每个账户一把普通 key 即可;不限额度的 key 报"已用"而不是假余额 |
| ⏳ | 订阅配额 | 卖套餐不卖余额的家数越来越多——5 小时 / 每周 / 每月各自滚动、各自重置,每个窗口一条进度条和一个重置时刻 |
| 📊 | 用量分析 | 今日/本月/累计三窗口、按站点/模型下钻、缓存命中率、一年活跃度热力图(悬停看当天模型构成) |
| 🧮 | 费用估算 | 生效日期分段的费率表、分桶计价、峰谷时段;未定价的模型显示破折号而不是 0 |
| 🗂 | 导出与诊断 | CSV / JSON 导出,索引健康度,归因不上的行数单独列出 |
| 🔒 | 只读回环 | 两个端点仅接受回环 GET,且在 peer socket 地址上设防;从不读取提示词、工具参数或响应内容 |
快速安装 / Quick start
需要 DeepSeek Harness web profile(@deepseek-ai/dsh >= 0.1.0-rc.6)。
dsh plugin --profile web add "github:zh667/TokenLedger"
重启已经在跑的 dsh web,浏览器硬刷新。侧边栏底部会出现「用量账本」入口。
升级或卸载:
dsh plugin --profile web update dsh-tokenledger
dsh plugin --profile web remove dsh-tokenledger
重装同一个 spec 会重新解析,所以 add 一遍就能拿到最新的 main(实测过,不是推测)。
要钉某个版本,必须用完整的 40 位 commit SHA。 包管理器把 ref 拿去和 git ls-remote 广播的引用列表比对,而那份列表里只有完整 SHA 和分支/标签名——短 SHA 匹配不到任何东西,会直接报 Could not resolve:
| spec | |
|---|---|
github:zh667/TokenLedger |
✅ |
github:zh667/TokenLedger#main |
✅ |
github:zh667/TokenLedger#947247a |
❌ 短 SHA 解析不了 |
github:zh667/TokenLedger#947247a86f0835f0e746695538569b1a76356dd1 |
✅ |
如果 package.json 里已经被写进了一个解析不了的 spec,add 也会失败——它会先解析整份清单。改掉那一行再 install 即可。
Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →
MeteorNOX/DeepSeek-Balance-Whale-Widget
edison7009/EchoBird
Han-1413141/dsh-cost-meter
wssfk12138/dsh-damage-pulse
edonadei/caliper
Ychris12138/dsh-usage-stats
Aisland-SJL/dsh-usage
wink-run/tokenbank