rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:skyzhao1223/dsh-agent-token-stats
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
一个 DSH 原生侧栏看板,把多个本地 Agent 的用量放到一起看。
Local-first, cross-agent usage analytics inside DeepSeek Harness: model totals, cache-hit analysis, reported/estimated costs, trends and data-quality diagnostics — without a separate dashboard service or author-side runtime telemetry.
不是账单核对工具。 Assistant 消息不等于 API 请求;本地日志没上报 token 时显示未知;参考价格不代表订阅实际扣费。统计边界 · 贡献指南 · 路线图 · 版本记录
No billed-request or complete-coverage claim is made. Source formats vary; capabilities are listed below. For other approaches, see the neutral community alternatives comparison.
v1.3.0 verification status: local regression suites passed on macOS. GitHub-hosted runners could not start during release preparation, so cross-platform CI is pending and the formal Release remains a draft. See release notes.
dsh plugin --profile web add github:skyzhao1223/dsh-agent-token-stats
# npm publishing planned: dsh plugin --profile web add dsh-agent-token-stats
# then restart: dsh web
Requires system sqlite3, jq, and zstd (macOS: brew install zstd). Host: DSH >= 0.2.2-rc.3 (verified owner-admission API). Older hosts are not given an authentication bypass.
The screenshots below use synthetic demonstration data rendered by the actual v1.3 client. They are not the author's private usage, real costs, or live-GUI acceptance evidence.
以下截图使用真实组件与虚构演示数据,不包含私人会话、项目路径或密钥,不代表真实账单。



| Source | Adapter | What can be observed locally |
|---|---|---|
| DSH / OpenCode | Parsed | Model/provider and available token splits; cache usage and reported cost when recorded |
| Claude Code / WPS Claude | Parsed | Log usage fields; local gateways may omit token usage |
| Cursor IDE | Parsed, partial | Reported usageData when available; assistant-message counts and recorded token fields; unattributed tokens stay unattributed |
| OpenClaw / QClaw | Parsed | Available response usage in session logs |
| CodeWhale / WorkBuddy / Hermes | Parsed | Available session/response counters, with source-specific limitations |
| Codex CLI / Gemini CLI / Cline-Roo / Pi | Parsers included | Enabled when corresponding local logs exist; not all formats/platforms have been live-tested |
| Trae / Lingma / CodeGeeX / Comate / Ollama / AionUi / Copilot | Detection/probes | Not equivalent to token support; presence or limited counts only |
Coverage describes parsed observations, not completeness of the original logs. Primary development/testing platform: macOS. Linux source compatibility is partial and unverified; Windows scanning is not supported.
~/.agent-token-stats/ledger.json — ratchet-merged per source × model × day; identical rescans do not double-count and historical aggregates survive source-log deletion. This is not a per-message event ledger: after source log rotation, new usage below the old aggregate high-water mark may not be recognized until that mark is exceeded./ focuses model search (Cmd/Ctrl/Alt + / stays with the browser), Esc dismisses the toast → clears search → closes the day drill-down, and it only touches the model filter when this plugin's own search box has focus; tabs are a real tablist/tabpanel pair with ←/→/Home/End and :focus-visible rings; prefers-reduced-motion is honoured. Heatmap cells, bar rows, legend entries and table rows/headers stay mouse-only by design — making ~180 heat cells tabbable would be worse than leaving them out.~/.agent-token-stats/)| File | Purpose |
|---|---|
config.json |
{"budgets":{"dailyTokens":0,"monthlyTokens":0,"dailyCost":0,"monthlyCost":0}} — budget alert thresholds;cost 阈值按展示币种解读(即 pricing.json 的 display) |
pricing.json |
价目与展示币种,见下方「Pricing & currency」 |
quota.json |
{"deepseek":{"apiKey":"sk-..."},"kimi":{"apiKey":"..."}} — balance queries (env DEEPSEEK_API_KEY / MOONSHOT_API_KEY also work) |
export-*.csv |
CSV exports land here |
~/.agent-token-stats/pricing.json(全部可选):
{
"display": "CNY", // 面板/报告/CSV 的展示币种;省略 = 跟 unit
"unit": "USD", // 你写的 rules 数字用的币种;省略 = USD
"fx": 7.2, // 1 USD = 7.2 display,仅在两者不同时用于换算;缺 fx 时原样展示并在面板提示
"rules": [ // 可选:优先于内置表匹配,细分 pattern 要先写
{ "pat": "deepseek-v4.1-flash", "i": 0.28, "o": 0.42, "cr": 0.028, "cw": 0.28, "rt": 0.42 },
{ "pat": "wps-gateway/model", "i": 2, "o": 8, "cr": 0.2, "unit": "CNY" } // 单条规则可自带币种
]
}
i 输入(缓存未命中)、o 输出、cr 缓存读(命中)、cw 缓存写、rt 推理(省略或 ≤0 时按输出价)。(输入×i + 输出×o + 缓存读×cr + 缓存写×cw + 推理×rt) / 1e6,再按需要换算到 display。claude-opus 必须写在 claude 之前、细分模型行写在兜底行之前。*_usd、Cursor 的 API 价折算)按定义是美元,展示时同样按 fx 换算;上报与估算永远分列、不混算。deepseek-v4.1-flash / deepseek-v4-flash / deepseek-reasoner / 兜底 deepseek),网关转售价请用上面的 rules 覆盖。One bundle row, two halves:
lib/index.js, injects shell, webServer and connection): signature-based incremental scanners with bounded concurrency, locked ledger, pricing, and owner-authenticated routes GET /agent-token-stats/{data,sessions,report,quota} and POST /agent-token-stats/export. Same-origin checks supplement, rather than replace, DSH credential admission.lib/client.js, dsh.client web bundle): sidebar panel + main-slot dashboard, plain React.createElement, no build step needed for editsnode --check lib/index.js && node --check lib/client.js
npm ci --ignore-scripts
npm test # isolated regressions, no operator HOME mutation
node scripts/verify-host-regression.mjs # real SQLite + multi-process locking + full-route auth
node scripts/verify-client-react.mjs # actual ReactDOM/jsdom, six tabs + recovery boundary
python3 scripts/verify-traffic.py # isolated raw archive/upsert/failure tests
node scripts/verify-host-ledger-diff.mjs --ledger /path/ledger.json # read-only audit
node scripts/smoke.mjs
node scripts/verify-cold-snapshot.mjs # 秒级:冷启动首屏必须来自磁盘台账且字段同构
node scripts/verify-instant-open.mjs # isolated fixture HOME: cold/hot/forced refresh regression
node scripts/verify-cooldown.mjs # fixture HOME:冷却期内不重扫、冷却后补扫不丢数(~90s)
node scripts/verify-pricing.mjs # 秒级:币种/fx 换算、规则币种、细分优先、推理计费、缺 fx 告警
node scripts/verify-ux.mjs # 秒级:客户端结构级回归(骨架/筛选器适用范围/下钻/toast/键盘/a11y/token 白名单)
verify-ux.mjs用自带的最小 React 垫片把 Dashboard 真渲染一遍再断言结构,所以它验证的是结构与交互,不是视觉效果——配色、间距、真实对比度仍需在浏览器里人工确认。可用LTS_CLIENT=./some-copy.js node scripts/verify-ux.mjs指向变异副本,确认「把功能删掉断言真的会挂」。
scripts/traffic-snapshot.py archives three validated GitHub responses (repository, clones, views), their daily series and UTC timestamps. Same-day samples replace rather than duplicate CSV rows; failed responses append nothing. Rolling windows overlap and must never be added together or divided into daily installation counts. This script is not executed by the plugin and introduces no runtime telemetry..ledger.lock and reload disk state before merging. Backups rotate by the backup timestamp, not the frequently updated primary file. Invalid primaries fall back to a validated backup and preserve corruption evidence. Dead/orphan locks are not automatically stolen (to avoid deleting another writer's newly acquired lock); a lock timeout requires checking the recorded owner/PID and confirming no writer is alive before manual recovery. Failure to recover a ledger is reported rather than replacing it with an empty one.The npm package has not yet been published. Use the GitHub installation above until availability is verified. Downloads on npm, when available, count download events, not installed users.
The manual publish.yml workflow is designed for npm Trusted Publishing: bind the exact GitHub owner/repository/workflow and npm-release environment in npm, and protect that GitHub environment with approval. First publication/package provisioning may still need the owner's local interactive npm publish browser/passkey authentication. No reusable publish token is stored in this project. Revoke any token previously pasted into chat; do not share passkeys, tokens, OTPs or recovery codes with an agent. Workflow dispatch alone does not make a package available until npm trust is configured and publication succeeds.
Use the running Harness plugin manager to update an installed bundle. Whether a change is applied live is determined by its installation result; do not assume a watcher is active. UI updates need a browser refresh unless an active rebuild/HMR chain is verified. Host updates must be reloaded through the supported manager path or, when it reports restart required, on the next restart. Editing a link: source file alone does not prove running Host code changed.
MIT © skyzhao1223
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm-cost、deepseek-harness。