dojo.md
University for AI agents. 92 courses, 4400+ scenarios, any model via OpenRouter. Auto-training loops generate per-model SKILL.md documents. Works with Claude Code, OpenClaw, Cursor, Windsurf. No fine-tuning req...
分析 OpenClaw 的 token 使用和成本,识别高消耗场景(长对话、频繁 cron、大 context),给出具体优化建议(模型降级、context 压缩、cron 频率调整)。纯 Node.js,无外部依赖。输出清晰的成本报告。
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
SkillHub CLI
skillhub install dagangtj/oc-cost-analyzerInspect the source and compatibility requirements, then follow its installation steps.
Give your agent the source link and ask it to inspect instructions and dependencies before explaining the installation steps.
专为 OpenClaw 用户设计的成本分析和优化工具。通过分析 session logs,识别高消耗场景,给出可执行的优化建议。
node scripts/cost_analyzer.js analyze
默认分析最近 7 天,生成详细报告保存到 ~/.openclaw/workspace/memory/cost-analysis-report.md
指定天数:
node scripts/cost_analyzer.js analyze 30 # 分析最近 30 天
node scripts/cost_analyzer.js quick
输出示例:
📊 今日成本快览:
总成本: $2.45
会话数: 12
平均: $0.204/会话
# OpenClaw 成本分析报告
生成时间: 2026-02-26 15:30:00
## 📊 总览
- 总会话数: 45
- 总输入 tokens: 1,234,567
- 总输出 tokens: 456,789
- 总成本: $15.67
- 平均每会话: $0.348
## 🤖 模型使用统计
### claude-opus-4-6
- 会话数: 30
- 输入: 890,123 tokens
- 输出: 345,678 tokens
- 成本: $12.34
### claude-sonnet-4-20250514
- 会话数: 15
- 输入: 344,444 tokens
- 输出: 111,111 tokens
- 成本: $3.33
## 💰 高成本会话 (Top 5)
- Session: a1b2c3d4...
- 模型: claude-opus-4-6
- Tokens: 125,000
- 成本: $3.45
- 消息数: 25
## 💡 优化建议
### 1. 🔴 模型降级:yunyi-claude/claude-opus-4-6
**问题**: 该模型成本较高 ($45/M tokens),已使用 30 次会话
**建议**: 对于简单任务使用 Sonnet 或 DeepSeek,复杂任务才用 Opus
**预计节省**: $9.87
**操作**: `openclaw models set yunyi-claude/claude-sonnet-4-20250514`
### 2. 🟡 长对话检测
**问题**: 发现 3 个长对话,最长 125,000 tokens
**建议**: 超过 50k tokens 时开启新会话,避免 context 累积
**预计节省**: $1.04
**操作**: 手动开...
These signals come from indexed source analysis and may lag behind changes. Check the current source files.
专为 OpenClaw 用户设计的成本分析和优化工具。
# 生成完整分析报告(默认最近 7 天)
node scripts/cost_analyzer.js analyze
# 分析最近 30 天
node scripts/cost_analyzer.js analyze 30
# 快速查看今日成本
node scripts/cost_analyzer.js quick
| 使用模式 | 每日会话数 | 每日成本 | 每月成本 |
|---|---|---|---|
| 轻度使用 | 5-10 | $0.50-1.00 | $15-30 |
| 中度使用 | 20-30 | $2.00-4.00 | $60-120 |
| 重度使用 | 50+ | $8.00-15.00 | $240-450 |
| 优化后 | 50+ | $3.00-6.00 | $90-180 |
优化目标:节省 50-60% 成本
# 每日成本检查
openclaw cron add "0 9 * * *" "node ~/.openclaw/workspace/skills/openclaw-cost-optimizer/scripts/cost_analyzer.js quick"
# 每周深度分析
openclaw cron add "0 10 * * 1" "node ~/.openclaw/workspace/skills/openclaw-cost-optimizer/scripts/cost_analyzer.js analyze 7"
✅ 纯本地运行,无网络请求
✅ 无外部依赖
✅ 只读分析,不修改配置
✅ 数据不离开本机
MIT License
# OpenClaw Cost Optimizer 专为 OpenClaw 用户设计的成本分析和优化工具。通过分析 session logs,识别高消耗场景,给出可执行的优化建议。 ## 核心功能 ### 1. 成本分析 - 读取 session logs,统计 token 使用和成本 - 按模型、会话、时间维度分析 - 识别高成本会话和异常消耗 ### 2. 场景识别 - **长对话检测**: 超过 50k tokens 的会话 - **频繁 Cron**: 每天超过 10 次的定时任务 - **大 Context**: 平均输入超过 30k tokens - **昂贵模型**: 使用高成本模型处理简单任务 ### 3. 优化建议 - 模型降级策略(Opus → Sonnet → DeepSeek) - Context 压缩方案 - Cron 频率调整 - 本地模型使用建议 - 预计节省金额 ## 快速开始 ### 生成完整分析报告(推荐) ```bash node scripts/cost_analyzer.js analyze ``` 默认分析最近 7 天,生成详细报告保存到 `~/.openclaw/workspace/memory/cost-analysis-report.md` **指定天数**: ```bash node scripts/cost_analyzer.js analyze 30 # 分析最近 30 天 ``` ### 快速查看今日成本 ```bash node scripts/cost_analyzer.js quick ``` 输出示例: ``` 📊 今日成本快览: 总成本: $2.45 会话数: 12 平均: $0.204/会话 ``` ## 报告示例 ```markdown # OpenClaw 成本分析报告 生成时间: 2026-02-26 15:30:00 ## 📊 总览 - 总会话数: 45 - 总输入 tokens: 1,234,567 - 总输出 tokens: 456,789 - 总成本: $15.67 - 平均每会话: $0.348 ## 🤖 模型使用统计 ### claude-opus-4-6 - 会话数: 30 - 输入: 890,123 tokens - 输出: 345,678 tokens - 成本: $12.34 ### claude-sonnet-4-20250514 - 会话数: 15 - 输入: 344,444 tokens - 输出: 111,111 tokens - 成本: $3.33 ## 💰 高成本会话 (Top 5) - Session: a1b2c3d4... - 模型: claude-opus-4-6 - Tokens: 125,000 - 成本: $3.45 - 消息数: 25 ## 💡 优化建议 ### 1. 🔴 模型降级:yunyi-claude/claude-opus-4-6 **问题**: 该模型成本较高 ($45/M tokens),已使用 30 次会话 **建议**: 对于简单任务使用 Sonnet 或 DeepSeek,复杂任务才用 Opus **预计节省**: $9.87 **操作**: `openclaw models set yunyi-claude/claude-sonnet-4-20250514` ### 2. 🟡 长对话检测 **问题**: 发现 3 个长对话,最长 125,000 tokens **建议**: 超过 50k tokens 时开启新会话,避免 context 累积 **预计节省**: $1.04 **操作**: 手动开...
# OpenClaw Cost Optimizer 专为 OpenClaw 用户设计的成本分析和优化工具。 ## 功能 - 📊 分析 session logs,统计 token 使用和成本 - 🔍 识别高消耗场景(长对话、频繁 cron、大 context) - 💡 给出具体优化建议(模型降级、context 压缩、cron 频率调整) - 📈 生成清晰的成本报告 - 🚀 纯 Node.js,无外部依赖 ## 快速开始 ```bash # 生成完整分析报告(默认最近 7 天) node scripts/cost_analyzer.js analyze # 分析最近 30 天 node scripts/cost_analyzer.js analyze 30 # 快速查看今日成本 node scripts/cost_analyzer.js quick ``` ## 报告内容 - 总览:会话数、token 使用、总成本 - 模型统计:各模型的使用情况和成本 - 高成本会话:Top 5 最贵的会话 - 优化建议:可执行的优化方案和预计节省 ## 优化策略 1. **模型分级使用**:简单任务用 Sonnet/本地模型,复杂任务才用 Opus 2. **Context 优化**:精简 AGENTS.md,使用 lazy loading 3. **Cron 优化**:降低非关键任务频率 4. **会话管理**:超过 50k tokens 开启新会话 5. **本地模型**:文件读取等简单任务使用 Ollama ## 成本基准 | 使用模式 | 每日会话数 | 每日成本 | 每月成本 | |---------|-----------|---------|---------| | 轻度使用 | 5-10 | $0.50-1.00 | $15-30 | | 中度使用 | 20-30 | $2.00-4.00 | $60-120 | | 重度使用 | 50+ | $8.00-15.00 | $240-450 | | 优化后 | 50+ | $3.00-6.00 | $90-180 | **优化目标**:节省 50-60% 成本 ## 集成到工作流 ```bash # 每日成本检查 openclaw cron add "0 9 * * *" "node ~/.openclaw/workspace/skills/openclaw-cost-optimizer/scripts/cost_analyzer.js quick" # 每周深度分析 openclaw cron add "0 10 * * 1" "node ~/.openclaw/workspace/skills/openclaw-cost-optimizer/scripts/cost_analyzer.js analyze 7" ``` ## 安全性 ✅ 纯本地运行,无网络请求 ✅ 无外部依赖 ✅ 只读分析,不修改配置 ✅ 数据不离开本机 ## 许可 MIT License
University for AI agents. 92 courses, 4400+ scenarios, any model via OpenRouter. Auto-training loops generate per-model SKILL.md documents. Works with Claude Code, OpenClaw, Cursor, Windsurf. No fine-tuning req...
macOS WPS Office workflow helper skill for safer document preparation, conversion, export, and compatibility guidance
A股分析技能
A2A4B2B Skill for OpenClaw