OpenClaw Cost Analyzer
v1.0.0分析 OpenClaw 的 token 使用和成本,识别高消耗场景(长对话、频繁 cron、大 context),给出具体优化建议(模型降级、context 压缩、cron 频率调整)。纯 Node.js,无外部依赖。输出清晰的成本报告。
⭐ 0· 335·0 current·0 all-time
MIT-0
Download zip
LicenseMIT-0 · Free to use, modify, and redistribute. No attribution required.
Security Scan
OpenClaw
Suspicious
medium confidencePurpose & Capability
The name/description (cost analysis & optimization) matches the provided script: the Node.js script reads local logs, computes token/cost stats, and writes a report. No unrelated credentials or network access are requested. However, the SKILL.md and Security.md claim a different session-log path (~/.openclaw/agents/main/agent/sessions/*.jsonl) while the script's CONFIG.logsDir points to ~/.openclaw/workspace/memory/conversations — this mismatch will likely make the tool miss real logs unless paths are reconciled.
Instruction Scope
SKILL.md instructs reading session logs and only local operations, which the script follows, but there are several scope issues: the logs path in docs differs from the script's path; the script marks cron detection as TODO (session.isCron stays false), so cron analysis is incomplete; SKILL.md suggests shell commands (find -delete) and other openclaw/ollama CLI commands as manual actions — those are user actions but could be destructive if copy-pasted without caution. The instructions also reference other skills (openclaw-token-optimizer) without guaranteeing their presence.
Install Mechanism
No install spec; this is effectively an instruction-only skill with a script file. That minimizes installer risk. The script uses only Node built-ins (fs, path, os) and there's no install-step downloading external code.
Credentials
No environment variables, no credentials, and no external endpoints are requested. The script only reads local files and writes a report to the user's workspace directory.
Persistence & Privilege
always:false and no attempt to modify other skills or global config. The script writes a report into the user's memory workspace only. It does not persist credentials or alter agent configuration.
What to consider before installing
This skill appears to be a local cost-analysis tool and does not contain network calls, external installs, or credential requests — but review before use:
- Verify which session-log path your OpenClaw actually uses. The documentation claims ~/.openclaw/agents/main/agent/sessions/*.jsonl, but the script reads ~/.openclaw/workspace/memory/conversations. If these don't match, the script will find no logs. Update CONFIG.logsDir in scripts/cost_analyzer.js or adjust where your logs are stored.
- Inspect the full script yourself (scripts/cost_analyzer.js) and run it in a non-production environment first. It appears to only use fs/path/os, but confirm there are truly no network calls in the rest of the file (the provided snippet is truncated).
- Be cautious when copying suggested shell commands from SKILL.md (e.g., find ... -delete or cron add entries). Those are manual operations and can delete files or schedule jobs if executed.
- Note incomplete behavior: cron detection is unimplemented (session.isCron is hardcoded false), and some cost/threshold heuristics (modelCosts values and savings math) look approximate — validate the pricing data for your models before acting on savings recommendations.
- If you plan to automate daily/weekly runs, ensure the script is placed where SKILL.md assumes (or update the cron commands) and consider running it under a user with limited permissions. If you want higher assurance, run the script on a copy of your logs and confirm outputs before making configuration changes.
If you want, I can: (1) point out the exact lines in scripts/cost_analyzer.js to change to match your real log location, (2) search the full file for any network/subprocess patterns, or (3) suggest a small dry-run mode to print filenames found without writing reports.Like a lobster shell, security has layers — review code before you run it.
latestvk972trbbywt9vagxjtw2e9f46s81x4g9
License
MIT-0
Free to use, modify, and redistribute. No attribution required.
