Agent Skills
› rcarmo/piclaw
› token-chart
token-chart
GitHub生成Token使用量图表,支持按天、模型或成本统计,可从数据库或会话文件读取数据,并通过IPC推送到Web UI时间线展示。
Trigger Scenarios
需要可视化Token消耗趋势
分析不同Provider或Model的使用分布
估算API调用成本
Install
npx skills add rcarmo/piclaw --skill token-chart -g -y
SKILL.md
Frontmatter
{
"name": "token-chart",
"description": "Generate a 7-day token usage chart (all chats) and post it to the web UI timeline.",
"distribution": "public"
}
Token chart
Generate token-usage charts from the database or from session files.
Modes
default— daily stacked token-usage bars across the last N daysprovider-model— stacked usage grouped by provider + model for attribution by model familyprovider-model-cost— estimated cost grouped by provider + model using the pricing reference bundled with the script
Examples
Default chart:
bun /workspace/piclaw/runtime/skills/operator/token-chart/token-chart.ts
Provider + model chart:
bun /workspace/piclaw/runtime/skills/operator/token-chart/token-chart.ts --mode provider-model
Estimated provider + model cost chart:
bun /workspace/piclaw/runtime/skills/operator/token-chart/token-chart.ts --mode provider-model-cost
Post to the web chat via IPC:
bun /workspace/piclaw/runtime/skills/operator/token-chart/token-chart.ts --ipc
Post via IPC and allow a Pushover nudge:
bun /workspace/piclaw/runtime/skills/operator/token-chart/token-chart.ts --ipc --nudge
Data sources
- default source:
token_usagerows in${PICLAW_STORE}/messages.db --source sessions: read usage from session files under${PICLAW_DATA}/sessionsinstead of SQLite--sessions-dir <dir>: override the session-file location explicitly
Use --source sessions when DB-backed token usage is unavailable or when you want to inspect raw session-file history directly.
Output behaviour
--ipcwrites an IPC message JSON file and, if needed, an SVG media file so piclaw posts the chart to the web timeline.- without
--ipc, the script writes markdown to stdout with an embedded SVG data URL plus summary text. --output-svg <path>writes the SVG to a file in either mode.
Notes
- Numbers are formatted with compact
K/Mlabels. - The estimated cost mode uses
provider-model-pricing-reference.ts, the route-specificpricing-2026-09-05.jsonsnapshot, and the human-readable noteprovider-model-pricing-reference.md. - This chart resolver estimates base-tier API value. Request-level long-context tiers, subscription allowances and actual invoices require separate analysis.
- Use this on demand unless you intentionally wire it into a scheduled task.
Version History
- d818352 Current 2026-09-09 11:39
- 5fa0ce5 2026-07-25 10:25


