token-card
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseToken Card
Token Card
Produce an SVG card summarising this machine's AI coding agent usage — total tokens,
equivalent API cost, current streak, and the split across agents — and write it into the
working tree as a file the README can reference.
The card is a committed artifact rather than a hosted image, so it renders from the
repository itself and does not depend on a third-party endpoint staying up.
生成一张SVG卡片,汇总本机AI编码Agent的使用情况——总Token数、等效API成本、当前连续使用天数,以及各Agent的使用占比——并将其作为README可引用的文件写入工作区。
该卡片是提交到仓库的静态产物,而非托管图片,因此直接从仓库本身渲染,不依赖第三方端点的可用性。
When to Activate
何时使用
- Someone wants a usage figure visible in a README or docs page.
- Someone asks for a shareable summary of their agent activity across tools.
Use instead when the question is "what did I spend this week". The two read
different sources and produce different things:
/cost-report | Token Card | |
|---|---|---|
| Source | | The agents' own session logs |
| Agents | Claude Code | Claude Code, Codex, Gemini CLI, OpenCode |
| Output | Terminal summary, optional CSV | An SVG file committed to the repo |
- 有人希望在README或文档页面中展示使用数据。
- 有人需要一份可分享的、跨工具的Agent活动总结。
如果问题是「我这周花了多少钱」,请使用 。两者读取不同的数据源,产出也不同:
/cost-report | Token Card | |
|---|---|---|
| 数据源 | 由ECC的 | 各Agent自身的会话日志 |
| 支持的Agent | Claude Code | Claude Code、Codex、Gemini CLI、OpenCode |
| 输出形式 | 终端摘要,可选CSV输出 | 提交到仓库的SVG文件 |
The tool this runs
所用工具
@tokenchit/cliPinned to an exact version, deliberately. resolves to whatever the registry
currently serves, and this tool reads local session logs — so a compromised future release
would be executed with access to them before anyone had reviewed it. Pin, and raise the pin
knowingly:
@latestbash
TOKENCHIT_VERSION=0.10.0To check the pinned artifact before running it the first time:
bash
npm view @tokenchit/cli@0.10.0 dist.integrity dist.tarball@tokenchit/cli特意固定到精确版本。 会解析为npm注册表当前提供的任意版本,而该工具会读取本地会话日志——因此如果未来版本被攻破,在有人审核之前就会被执行,且能访问这些日志。请固定版本,并在明确知情的情况下升级版本:
@latestbash
TOKENCHIT_VERSION=0.10.0首次运行前,可通过以下命令校验固定版本的产物:
bash
npm view @tokenchit/cli@0.10.0 dist.integrity dist.tarballWorkflow
工作流程
-
Ask before the first download.fetches the package from the npm registry and executes it. That is a remote download of code that will read local logs, so get explicit confirmation from the user before the first run on a machine. If they decline, stop here and say what would have run.
npx -
Configure, unless this is a dry run. Ifis absent, run:
.tokenchit.jsonbashnpx -y @tokenchit/cli@0.10.0 initIt detects which agents have logs on this machine and records them. The file is meant to be committed and never contains a credential.Skip this entirely when the user passed, and report that--dry-runwould be created. A preview that writes a config file is not a preview..tokenchit.json -
Render the card. The bare command writes to the configured output —unless
tokenchit.svgnames another path:.tokenchit.jsonbashnpx -y @tokenchit/cli@0.10.0 syncAppend only the flags the user actually asked for, each spelled exactly as below. Do not copy a placeholder into the command —ignores an unrecognised positional argument rather than refusing it, so a bracketedsyncreaches the CLI as junk and the card is written anyway, which is the opposite of what was asked.[--dry-run]Flag Effect --out <path>Write somewhere other than the configured output |--theme auto|lightdarkCard theme; adapts to the reader's systemauto--dry-runPrint what would be written and touch nothing reads local files and sends nothing: no prompts, no code, no file contents leave the machine, and it transmits nothing to any server. The npx invocation around it is a registry download — that is the network access in this workflow, and step 1 is where it is agreed.sync -
Report and offer. Print the figures it produced — tokens, equivalent cost, streak, per-agent split — and the path written. If the repository has a README that does not yet reference the card, offer to add:markdown
prints the path relative to the repository root. A Markdown image resolves relative to the file it sits in, so rewrite it for the README being edited: a card atsyncisdocs/usage.svgfrom the root README but./docs/usage.svgfrom../usage.svg. Pasting the printed path into a nested README points atdocs/zh-CN/README.mdand renders broken.docs/zh-CN/docs/usage.svgDo not edit the README without being asked.
Stop after step 4. Publishing to the public leaderboard is a separate command that
requires explicit opt-in, and is not part of this workflow — run it only if the user asks for
it by name. removes the row and the account again.
publishunpublish-
首次下载前需询问用户。会从npm注册表获取包并执行。这是一次远程代码下载,且下载的代码会读取本地日志,因此在某台机器上首次运行前,必须获得用户的明确确认。如果用户拒绝,在此停止,并告知原本会执行的操作。
npx -
执行配置(试运行场景跳过)。 如果不存在,运行:
.tokenchit.jsonbashnpx -y @tokenchit/cli@0.10.0 init该命令会检测本机上哪些Agent存在日志,并记录下来。该文件需要提交到仓库,且绝不会包含凭证信息。如果用户传入了参数,完全跳过此步骤,并告知用户--dry-run本会被 创建。写入配置文件的预览不算真正的预览。.tokenchit.json -
生成卡片。 不带参数的命令会写入配置的输出路径——如果中没有指定其他路径,则默认为
.tokenchit.json:tokenchit.svgbashnpx -y @tokenchit/cli@0.10.0 sync仅添加用户明确要求的参数,每个参数的拼写必须与下方完全一致。不要在命令中复制占位符——命令会忽略无法识别的位置参数而非报错,因此带括号的sync会作为无效参数传入CLI,最终仍然会生成卡片,这与用户的需求完全相反。[--dry-run]参数 作用 --out <path>写入到配置的输出路径之外的其他位置 |--theme auto|lightdark卡片主题; 会适配读者的系统主题auto--dry-run仅打印本会写入的内容,不修改任何文件 命令仅读取本地文件,不发送任何数据:没有提示、没有代码、没有文件内容离开本机,也不会向任何服务器传输数据。包裹它的npx调用只是从注册表下载包——这是本工作流程中唯一的网络访问,且已在步骤1中获得用户同意。sync -
反馈结果并提供可选操作。 输出生成的统计数据——Token数、等效成本、连续使用天数、各Agent占比——以及写入的文件路径。如果仓库的README中尚未引用该卡片,可主动提议添加:markdown
命令输出的是相对于仓库根目录的路径。Markdown图片的路径是相对于其所在文件解析的,因此需要根据被编辑的README的位置调整路径:例如卡片位于sync时,根目录的README中应写docs/usage.svg,而./docs/usage.svg中应写docs/zh-CN/README.md。直接将输出的路径粘贴到嵌套的README中会指向../usage.svg,导致图片无法加载。docs/zh-CN/docs/usage.svg未经用户要求,请勿编辑README。
步骤4完成后即停止。发布到公共排行榜是独立的 命令,需要用户明确选择加入,不属于本工作流程——仅当用户明确要求执行该命令时才运行。 命令可移除排行榜中的记录和账户。
publishunpublishOutput
输出内容
The path of the SVG, the figures it contains, and the markdown snippet for referencing it.
On a dry run: what would have been written, and nothing on disk changed.
SVG文件的路径、其中包含的统计数据,以及引用该卡片的Markdown片段。试运行模式下:输出本会写入的内容,且不会修改磁盘上的任何文件。
Notes
注意事项
- Requires Node.js 22 or newer (the package declares ). Nothing is installed globally;
engines: { node: ">=22" }fetches the pinned version per run.npx - Reads token counts and timestamps only.
- 需要Node.js 22或更高版本(该包声明了 )。不会全局安装任何内容;
engines: { node: ">=22" }每次运行都会获取固定版本。npx - 仅读取Token数量和时间戳。