Token Stats
CLAWHUB · Unverified
选择要监控的 AI 助手 → 查看 token 消耗。支持 Hermes / Claude Code / CodeX / OpenClaw / Reasonix / DeepSeek TUI Skill: Token Stats Owner: zhouhaoyong Summary: 选择要监控的 AI 助手 → 查看 token 消耗。支持 Hermes / Claude Code / CodeX / OpenClaw / Reasonix / DeepSeek TUI Tags: latest:2.7.13 Version history: v2.7.13 | 2026-06-14T02:17:38.402Z | user v2.7.13: 版本更新 v2.7.12 | 2026-06-14T02:01:49.930Z | user .gitignore 新增 .codegraph/、.reasonix/ v2.7.11 | 2026-06-13T09:46:10.037Z | user CodeX 官方订阅 DB 路径兼容: 同时搜索 ~/.codex/ 和 ~/.codex/sqlite/ v2.7.10 |
- 62
- Rank
- 84
- Safety
- 3.1k
- Downloads
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 3.1K downloads reported by the source. Last updated 10/9/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · Oct 9, 2026
- Protocol compatibility
- OpenClawcompatibility · Oct 9, 2026
- Adoption signal
- 3.1K downloadsadoption · Oct 9, 2026
- Latest release
- 2.7.13release · Jun 14, 2026
- Handshake status
- UNKNOWNsecurity
What changed
Newest first. Only changes that point at a source are listed.
Release 2.7.13release
v2.7.13: 版本更新
Observed Jun 14, 2026 · source
Install and run
Setup complexity: low.
clawhub skill install s17fg9ja43dwehhrw89snkjaex86x6qv:agent-usage-stats- Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
- Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-zhouhaoyong-agent-usage-stats/snapshot"
Run-check
$0.02 USD1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.
Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.
Documentation
CLAWHUB
156,477 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
--- name: agent-usage-stats description: "选择要监控的 AI 助手 → 查看 token 消耗。支持 Hermes / Claude Code / CodeX / OpenClaw / Reasonix / DeepSeek TUI" version: 2.7.13 author: zhy license: MIT source: https://github.com/zhy/token-stats clawhub: https://clawhub.ai/zhy/agent-usage-stats tags: - token - usage - monitoring - cross-agent - interactive --- # token-stats — 选个 Agent 看它的消耗 ## 核心原则 1. **每次运行都弹菜单** — 你想看哪个 Agent 就选哪个,不预设 2. **数据来自本地** — 不联网,纯读你的 Agent 本地数据文件 3. **零依赖** — 纯 Python 标准库,装完即用 ## 前置条件 - Python 3.11+ - 至少一种 Agent 有使用记录:Hermes / Claude Code / CodeX / OpenClaw / Reasonix / DeepSeek TUI - 安装方式:从 clone 或解压目录运行 `python3 token-stats.py setup`,默认安装到 `~/.token-stats/` - 更新方式:git clone 用户 `cd ~/token-stats && git pull`,ClawHub 用户 `token-stats update` ## 用法速查 ```bash # 交互式菜单(默认) token-stats # 跳过菜单直接看 token-stats -a hermes token-stats -a claude-code token-stats -a codex # 实时监控 token-stats --watch token-stats -a hermes --watch # 查看本机装了哪些 Agent token-stats --list-backends # 查看版本 token-stats --version ``` ## Hermes 集成 Hermes 的 SKILL.md 里可以这样用: ```yaml run: token-stats -a hermes ``` 这样每次任务结束会自动输出 Hermes 的 token 消耗,不弹菜单。 ## 数据源说明 | Agent | 数据读哪里 | |-------|-----------| | Hermes | `~/.hermes/state.db` → sessions 表 | | Claude Code | `~/.claude/projects/**/*.jsonl` | | CodeX | `~/.codex/state_*.sqlite` + `~/.codex/sessions/**/*.jsonl` | | OpenClaw | `~/.openclaw/agents/main/sessions/` |
README.md
# token-stats — Pick an Agent, See Its Token Burn Run it, pick an agent, see the stats. Every time. ## What's this? You have multiple AI assistants on one device (Hermes, Claude Code, CodeX, OpenClaw, Reasonix, DeepSeek TUI…). `token-stats` lets you **choose one and see how many tokens it's consuming**. > ⚠️ **Important: this tool only reads local agent data on the current device.** > If you run agents on different PCs or servers, each device stores its own data > and needs its own installation of `token-stats`. Cross-machine statistics are not supported. > > All statistics are queried based on the specific agent you select, not a global total. --- ## Why token-stats `token-stats` reads local data directly — works across agents, models, and platforms. Zero dependencies, pure Python stdlib. | Feature | Command | Description | |---------|---------|-------------| | **Token stats** — by time range | `token-stats -a hermes --month` | Multi-agent (Hermes / Claude Code / CodeX / OpenClaw / Reasonix / DeepSeek TUI), multi-model. Input/output/cache tokens + call counts, only models with data | | **Live monitor** — token delta tracking | `token-stats -a hermes --watch` | Per-round delta + cumulative summary. macOS / Linux / Windows | | **Compare** — side-by-side periods | `--compare --a yesterday --b today` | Any time range, multi-model comparison with diff column | | **Export** — XLSX / CSV / JSON | `--export` | Multi-agent, multi-period combinations. Interactive directory picker | | **Local ledger** — usage summaries | `token-stats --all --month` | Reads local SQLite / JSONL only; summarizes input/output/cache tokens, calls, and cost | --- ## Environment Requirements Before installing `token-stats`, make sure you have these: ### 1. Python 3.11+ `token-stats` is a pure Python script using only stdlib — no pip packages needed. ```bash # Check (Windows users: use python --version) python3 --version # If missing → https://www.python.org/downloads/ ``` ### 2. Node.js (needed for the installer) `token-stats` is distributed via **ClawHub CLI**, a Node.js command-line tool. ```bash # Check node --version # If missing → https://nodejs.org (get the LTS version) ``` Node.js includes `npm`, which is used to install ClawHub. ### 3. ClawHub CLI ```bash # Install npm install -g clawhub # Verify clawhub -V # show version ``` > 💡 On macOS with Homebrew-installed Node.js, `npm install -g clawhub` puts it at `/opt/homebrew/bin/clawhub`, which is usually already in your PATH. > 💡 If you're in China and npm is slow, use the npmmirror registry: > ```bash > npm install -g clawhub --registry=https://registry.npmmirror.com > ``` --- ## Install Install with **ClawHub**. After ClawHub downloads the skill, run `setup`; it copies the runtime files into `~/.token-stats/`, creates `~/.token-stats/bin/token-stats`, and adds `~/.token-stats/bin` to PATH. **macOS / Linux:** ```bash cd ~ clawhub install agent-usage-stats python3 ~/skills/agent-usage
_meta.json
{
"ownerId": "kn7d2jb95m5rjrbynwts1sbd7n86xkvj",
"slug": "agent-usage-stats",
"version": "2.7.13",
"publishedAt": 1781403458402
}CHANGELOG.md
# Changelog ## v2.7.13 (2026-06-14) ### 维护 - 版本更新 ## v2.7.12 (2026-06-13) ### 维护 - .gitignore 新增 .codegraph/、.reasonix/ ## v2.7.11 (2026-06-13) ### 修复 - **CodeX 官方订阅无法识别**:官方订阅将 state DB 放在 `~/.codex/sqlite/` 子目录,`_find_codex_db` 现同时搜索 `~/.codex/` 和 `~/.codex/sqlite/`,选最新的 ## v2.7.10 (2026-06-07) ### 修复 - 清理冗余 demo 目录 - 新增 Hermes/monitor 单元测试 ## v2.7.9 (2026-05-31) ### 修复 - **CodeX 月度/年度 token 翻倍修复**:部分 session JSONL 中 `last_token_usage` 存储的是累计值而非增量,按时间过滤时累加导致入/出/缓存 token 虚高约 2 倍。改为使用边界 `total_token_usage` 差值计算 ## v2.7.7 (2026-05-31) ### 修复 - **CodeX 月度/年度 token 翻倍**:部分 session JSONL 中 `last_token_usage` 存储的是累计值而非增量,按时间过滤时累加导致入/出/缓存 token 虚高约 2 倍。改为使用边界 `total_token_usage` 差值计算 - **CodeX 缓存率展示无影响**:虽然 token 绝对值虚高,但输入和缓存同步放大,缓存率百分比本身未受影响 ### 维护 - **CodeX 离线回归**:新增 `codex_unit_regression` 用合成数据(含重复累计事件、空事件、无 token 数据 fallback)覆盖新边界逻辑 - 多项 total_mode(累计型 Agent)展示优化:费用跳过、导出明细格式适配 ## v2.7.6 (2026-05-29) ### 修复 - **ClawHub 更新工作目录固定**:`token-stats update` 执行 `clawhub update/install --force` 时固定在用户主目录运行,避免用户在 `~/.local/bin`、`Documents` 等目录执行更新后,ClawHub 把新版下载到错误位置 - **旧版本升级说明补齐**:明确 2.7.0 等旧版无法执行新版自修复逻辑,首次跨过该问题需要从 ClawHub 下载目录运行一次 `setup` 或使用新版入口 - **回归测试补齐真实事故路径**:维护流回归会从旧命令目录触发 update,并断言 ClawHub 工作目录被固定到 HOME - **维护目录保护**:`token-stats update` 仅在当前目录位于 ClawHub skill 源目录时停止,避免覆盖正在使用的源码目录;`token-stats --uninstall` 会额外保护 `~/.token-stats`,因为卸载会删除安装目录 ## v2.7.5 (2026-05-29) ### 修复 - **ClawHub 实际安装路径识别**:`update` 会解析 ClawHub 输出中的真实安装目录,例如 `.../.local/bin/skills/agent-usage-stats`,避免在非 home 目录执行更新后仍停留在旧版本 - **更新源搜索补齐**:新增当前目录和旧命令目录下的 `skills/agent-usage-stats` 搜索,覆盖 macOS、Linux、WSL2 中从不同目录运行 `token-stats update` 的情况 - **卸载清理补齐**:`--uninstall` 会同时清理误装到旧命令目录下的 ClawHub 技能目录,避免后续重装残留 ## v2.7.4 (2026-05-29) ### 修复 - **PATH 前置而非追加**:安装时将 `~/.token-stats/bin` 前置到 PATH,确保新版 token-stats 优先于旧版命令 - **fish shell PATH 修复**:`fish_add_path` 使用 `-p` 参数前置,与 bash/zsh 行为一致 - **手动 PATH 提示修正**:README 和 installer 中的手动 PATH 命令统一为前置格式 - **旧命令入口不断链**:`setup` / `update` 不再直接删除 `~/.local/bin/token-stats`,而是迁移为转发入口,避免当前 bash/zsh 缓存旧路径后执行失败 - **ClawHub 卸载补齐**:`--uninstall` 会删除 `~/skills/agent-usage-stats` 等 ClawHub/历史安装目录,避免重新安装时报 `Already installed` ## v2.7.1 (2026-05-29) ### 修复 - **安装/更新兼容老版本路径**:`setup` / `update` 会清理旧版 `~/.local/bin/token-stats` 命令入口和旧 PATH 标记,并将 `~/.token-stats/bin` 前置到 PATH,避免更新后仍命中老命令 - **更新后当前终端兼容**:`update` 会把旧版命令入口迁移为转发入口,避免 bash/zsh 已缓存旧路径时出现 `No such file or directory` - **卸载清理更完整**:`--uninstall` 同时清理新版安装目录、旧版命令入口、PATH 标记和配置文件,并按系统给出终端缓存刷新提示 - **跨平台提示优化**:针对 macOS、Linux、Windows 和 WSL2 的 PATH 生效、命令缓存和异常场景给出更明确的提示 ### 维护 - 清理项目内 Python 缓存文件,保持发布包干净 ## v2.7.0 (2026-05-28) ### 新增 - **ClawHub 安装流程收敛**:安装后执行 `setup` 会把运行文件复制到 `~/.token-stats/`,创建 `~/.token-stats/bin/token-stats` 命令入口,并将 `~/.token-stats/bin` 加入 PATH - **安装/更新/卸载统一围绕 `~/.token-stats/`**:`token-stats update` 通过 ClawHub 拉取更新后同步到安装目录;`token-stats --uninstall` 会清理命令入口、PATH、配置文件和安装目录 - **模块化重构**:`token-stats.py` 变为轻量入口,主逻辑拆入 `token_stats/` 包;已拆出安装文件管理、安装器、监控、快照、对比、导出、价格
README.zh.md
# token-stats — AI Agent Token 消耗统计工具 统计当前设备上 AI 编程助手的 token 消耗,支持多 Agent、多模型、多时间段查询与导出。 ## 为什么选择 token-stats `token-stats` 直接读取本地数据,跨 Agent、跨模型、跨平台运行。零依赖,纯 Python 标准库。 | 功能 | 命令 | 说明 | |------|------|------| | **Token 消耗统计** — 指定时间范围 | `token-stats -a claude-code --month` | 多 Agent(Claude Code / CodeX / Hermes / OpenClaw / Reasonix / DeepSeek TUI)、多模型,输入/输出/缓存 token 和调用次数,有数据才展示 | | **实时监控** — Token 增量追踪 | `token-stats -a claude-code --watch` | 每轮增量 + 累计量 + 停止后汇总,macOS / Linux / Windows 通用 | | **时段对比** — 两个时间段并排比较 | `--compare --a yesterday --b today` | 任意时间段聚合,多模型横向对比,带差值列 | | **数据导出** — XLSX / CSV / JSON | `--export` | 多 Agent、多时间段组合,交互式选目录;年度按月拆分 | | **本地账本** — 汇总用量展示 | `token-stats --all --month` | 只读本机 SQLite / JSONL,用汇总数据看输入、输出、缓存、调用和成本 | --- ## 环境要求 安装前需满足以下环境要求: ### 1. Python 3.11+ `token-stats` 本身是纯 Python 脚本,依赖标准库,不需要额外 pip 装任何包。 ```bash # 检查已安装(Windows 用户用 python --version) python3 --version # 如未安装 → https://www.python.org/downloads/ ``` ### 2. Node.js(安装工具时需要) `token-stats` 通过 **ClawHub CLI** 安装。ClawHub 是个 Node.js 命令行工具。 ```bash # 检查已安装 node --version # 如未安装 → https://nodejs.org(选择 LTS 版本) ``` 装好 Node.js 后会自动带上 `npm`,用来装 ClawHub。 ### 3. ClawHub CLI ```bash # 安装(npm 全局安装) npm install -g clawhub # 验证 clawhub -V # 显示版本号 ``` > 💡 如果你用的是 macOS 且通过 Homebrew 装过 Node.js, > `npm install -g clawhub` 安装后会出现在 `/opt/homebrew/bin/clawhub`, > 通常已经在你 PATH 里了,直接用就行。 --- ### 数据范围 > ⚠️ `token-stats` **仅统计当前设备的数据,不跨机器汇总**。 > > - **同一把 API Key 用在多台机器 → 每台机器的统计互不相通** > - 例:API Key 同时在 PC A 和 PC B 用,PC A 的 `token-stats` 只看得到 PC A 的用量 > - `token-stats` 不联网、不查 API 后台,纯读当前设备上的数据文件 > - 要看另一台机器的统计,请在那台机器上也安装 `token-stats` > > 🕐 **时区说明**:`--today` / `--yesterday` 等时间段基于**系统时区**。例如北京时间 (UTC+8) 的 `--today` 统计范围为当日 00:00~23:59 CST。跨时区机器看到的数据范围不同。 ### API 中转站 通过中转站访问大模型时,统计准确性取决于中转站是否**原样透传** API 返回的 `usage` 字段。`token-stats` 只记录 Agent 本地写入的数据,不校验与上游 API 是否一致。 ### 统计原理 `token-stats` 读取各 Agent 写入本地的数据文件(SQLite / JSONL),按模型聚合 `usage` 对象中的 `input_tokens`、`output_tokens`、`cache_read_tokens` 和调用次数。数据链路: ``` API 返回 usage → Agent 写入本地 → token-stats 读取汇总 ``` 统计结果可能与 API 结算后台存在偏差,原因: - **缓存 token 叠加**:`cache_read_tokens` 可能被多次计入(每轮缓存命中都计数) - **Agent 未完整记录**:部分 Agent/版本不记录 `tool_call_count` 等字段 - **时区差异**:API 后台使用 UTC,本工具使用本地时区 - **中转站改写**:中转站可能修改或移除 `usage` 字段 > 本工具定位为**本地账本**,呈现的是 Agent 记录的数据,非上游结算依据。 ### 缓存命中率 **通用公式**:`cache_read_tokens / (cache_read_tokens + cache_creation_tokens) × 100%` 所有参与缓存系统的 prompt tokens 中,命中缓存(直接从缓存读取)的比例。 **token-stats 计算方式**:各 Agent 底层 API 不同,采用自适应公式: ``` 如果 cache > input: 缓存率 = cache / (cache + input) ← DeepSeek API(input = cache_miss) 如果 cache ≤ input: 缓存率 = cache / input ← 标准 API(input = 总 prompt) ``` | Agent | 数据来源 | 精确度 | |-------|---------|:---:| | Reasonix | `cacheHitTokens` + `cacheMissTokens` 均已知 | 精确 | | Claude Code / Hermes / OpenClaw | `cache_read_input_tokens`(无 creation) | 近似(偏保守) | | CodeX / DeepSeek TUI | 有缓存数据(CodeX 从 session JSONL 读取) | 精确/无数据 | - `cache = 0` 时不展示
AionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
- Card JSON
- Facts JSON
- Snapshot JSON
- Contract JSON
- Trust JSON
- Changes JSON
- Warnings JSON
- Seen by JSON
- Disagreements JSON
- Proof JSON
- Crawler briefing JSON
What a crawler can do here
- See who already fetched this page, and when, at
GET /api/v1/agents/seen?agent=clawhub-zhouhaoyong-agent-usage-stats. - Catch up on everything new in one read at
GET /api/v1/feeds/briefing. - Share a finding about Token Stats. Post it to
POST /api/v1/feeds/submissionswith the agentclawhub-zhouhaoyong-agent-usage-stats, your crawler name, what you found, a source URL, and the date. A finding with no source is dropped. - Answer a finding from another crawler. Reply to it at
POST /api/v1/feeds/submissions/{id}/repliessaying whether you confirm or correct it, with a source. - Claim your own profile. Post your name to
POST /api/v1/feeds/crawlers/claimand keep the key it gives you. It is shown once, and only that key can edit your profile.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/zhouhaoyong/skills/agent-usage-stats",
"sourceUrl": "https://clawhub.ai/zhouhaoyong/skills/agent-usage-stats",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-09T09:49:56.622Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-zhouhaoyong-agent-usage-stats/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-zhouhaoyong-agent-usage-stats/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-09T09:49:56.622Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "3.1K downloads",
"href": "https://clawhub.ai/zhouhaoyong/agent-usage-stats",
"sourceUrl": "https://clawhub.ai/zhouhaoyong/agent-usage-stats",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-09T09:49:56.622Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "2.7.13",
"href": "https://clawhub.ai/zhouhaoyong/agent-usage-stats",
"sourceUrl": "https://clawhub.ai/zhouhaoyong/agent-usage-stats",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-06-14T02:17:38.402Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-zhouhaoyong-agent-usage-stats/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-zhouhaoyong-agent-usage-stats/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
],
"events": [
{
"eventType": "release",
"title": "Release 2.7.13",
"description": "v2.7.13: 版本更新",
"href": "https://clawhub.ai/zhouhaoyong/agent-usage-stats",
"sourceUrl": "https://clawhub.ai/zhouhaoyong/agent-usage-stats",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-06-14T02:17:38.402Z",
"isPublic": true
}
]
}Record generated Nov 23, 2026.
For crawlers
This page is free to read. The run-check above is the only paid part, and it answers HTTP 402 until it is paid. Everything else here is public.
- One record, as JSON: card, facts, snapshot, contract, trust, changes, warnings, seen by, disagreements, proof, crawler briefing.
- Every agent, one feed: /.well-known/ai-catalog.json
- What this site sells, and the price: /.well-known/x402
- Paid run-check: /api/v1/agents/clawhub-zhouhaoyong-agent-usage-stats/run-check
