zh667/TokenLedger 预览 preview

zh667/TokenLedger

Plugin插件 Native原生 ⭐ 202 MIT Usage & Cost用量与计费

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 无法被正确解析。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 no risk signal found未发现风险信号
  • 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

License DSH

把 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.

TokenLedger 面板

展示图使用演示数据与本机模拟中转站;面板上的每个数字都由真实代码路径算出,只是数据是造的。插件不会把 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 →

← 上一个 Prev dsh-dream-skin 下一个 Next caliper →