让 ClawHub Skill 自动进化为个性化专属技能
Skill Evolution Plugin 是一个 OpenClaw 插件,能够自动捕获 Skill 使用过程中的修正行为,通过模式识别生成优化建议,最终实现 Skill 的自进化。
核心价值:让从 ClawHub 下载的通用 Skill,通过你的使用习惯,自动进化为个性化专属技能。
- 🔍 隐式学习 - 无需手动反馈,自动捕获 AI 的修正行为
- 📝 补丁生成 - 直接生成可应用的 unified diff 补丁
- 🔒 本地优先 - 数据存储在本地,隐私安全
- 🚀 轻量级 - 独立插件,npm install 即可使用
- 🎯 OpenClaw 原生 - 深度集成 OpenClaw 生态
- Node.js >= 16.0.0
- OpenClaw >= 1.0.0
- npm >= 7.0.0
# 克隆项目
git clone https://github.com/YOUR_USERNAME/skill-evolution-plugin.git
cd skill-evolution-plugin
# 安装依赖
npm install
# (可选)全局安装 CLI
npm install -g# 使用快速启动脚本
./QUICKSTART.sh
# 或手动运行
node bin/cli.js demo输出示例:
═══════════════════════════════════════════════════════════
Skill Evolution Plugin - MVP 演示
═══════════════════════════════════════════════════════════
--- 第 1 次执行 ---
[SkillEvolution] 开始监控会话 exec_1774620809179_ws4q9w (skill: agent-browser)
[SkillEvolution] 会话 exec_1774620809179_ws4q9w 结束,已保存到 ...
✓ 会话 exec_1774620809179_ws4q9w 已保存
...
═══════════════════════════════════════════════════════════
生成进化报告
═══════════════════════════════════════════════════════════
╔══════════════════════════════════════════════════════════╗
║ 📊 Skill 进化报告 - agent-browser ║
╚══════════════════════════════════════════════════════════╝
📈 执行统计:
- 总执行次数:5
- 成功率:100.0%
🔍 发现 2 个优化机会:
1. 优化 agent-browser.snapshot 的重试策略
频率:60.0% (3/5)
2. 为 agent-browser.click 添加容错逻辑
频率:60.0% (3/5)
# 生成人类可读报告
node bin/cli.js report agent-browser
# 查看状态
node bin/cli.js status agent-browser
# JSON 格式分析
node bin/cli.js analyze agent-browsernode bin/cli.js list-patches agent-browserconst { SkillEvolutionPlugin } = require('skill-evolution-plugin');
// 创建插件实例
const plugin = new SkillEvolutionPlugin();
// 开始监控
const sessionId = plugin.startMonitoring('agent-browser', '帮我登录网站');
// 记录工具调用
plugin.recordToolCall(sessionId, 'agent-browser.open',
{ url: 'https://example.com' },
{ success: true }
);
// 记录修正(AI 自动调整参数)
plugin.recordToolCall(sessionId, 'agent-browser.click',
{ ref: '@e5' },
{ success: true },
{ correctedFrom: { ref: '@e3' }, correctionReason: 'Element not found' }
);
// 结束监控
plugin.stopMonitoring(sessionId, 'success');
// 生成报告
const report = plugin.generateReport('agent-browser');
console.log(report);// 自定义配置
const plugin = new SkillEvolutionPlugin({
threshold: 3, // 3 次相似修正后建议
logPath: '~/.openclaw/skills'
});
// 分析模式
const analysis = plugin.analyze('agent-browser');
console.log(JSON.stringify(analysis, null, 2));
// 创建补丁
const patchInfo = plugin.createPatch(
'agent-browser',
originalContent,
modifiedContent,
'Add retry logic'
);const { evolutionPlugin } = require('skill-evolution-plugin');
// 在 OpenClaw SkillExecutor 中
async executeTool(skillName, toolName, params) {
const sessionId = evolutionPlugin.startMonitoring(skillName, userRequest);
try {
const result = await originalExecute(toolName, params);
evolutionPlugin.recordToolCall(sessionId, toolName, params, result);
return result;
} catch (error) {
evolutionPlugin.recordToolCall(sessionId, toolName, params, { error });
throw error;
} finally {
evolutionPlugin.stopMonitoring(sessionId, 'success');
}
}更多示例:
- examples/basic-usage.js - 基础用法
- examples/advanced-usage.js - 进阶用法
- examples/openclaw-integration.js - OpenClaw 集成
skill-evolution demo # 运行演示
skill-evolution analyze <skill> # 分析模式(JSON 输出)
skill-evolution report <skill> # 生成人类可读报告
skill-evolution status <skill> # 查看状态
skill-evolution list-patches <skill> # 列出补丁
skill-evolution help # 显示帮助选项:
-t, --threshold <number> 建议阈值(默认:3)
-l, --limit <number> 日志数量限制(默认:100)
-h, --help 显示帮助
┌─────────────────────────────────────────────────────────┐
│ 用户 │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ Skill Evolution Plugin │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐│
│ │ Interceptor │→ │ Analyzer │→ │ Patch Manager ││
│ │ (拦截器) │ │ (分析器) │ │ (补丁管理) ││
│ └─────────────┘ └──────────────┘ └─────────────────┘│
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ ~/.openclaw/skills/<skill>/.evolution/ │
│ ├── execution-log.jsonl (执行日志) │
│ ├── patches/ (补丁文件) │
│ └── manifest.json (版本管理) │
└─────────────────────────────────────────────────────────┘
核心模块:
- Interceptor:拦截工具调用,记录修正行为
- Analyzer:分析日志,识别模式,生成建议
- PatchManager:管理补丁的生成和应用
{
"session_id": "exec_1774620809181_jf3oj0",
"skill": "agent-browser",
"timestamp": "2026-03-27T14:13:29.181Z",
"user_request": "帮我登录 example.com",
"actual_execution": [...],
"modifications": [
{
"type": "correction",
"tool": "agent-browser.click",
"original": "@e3",
"corrected": "@e5",
"reason": "Re-snapshot"
}
],
"outcome": "success"
}# 启用/禁用插件
export SKILL_EVOLUTION_ENABLED=true
# 自定义日志路径
export SKILL_EVOLUTION_LOG_PATH=~/.openclaw/skills
# 设置阈值
export SKILL_EVOLUTION_THRESHOLD=3# ~/.openclaw/config.yaml
plugins:
skill-evolution:
enabled: true
threshold: 3
logPath: ~/.openclaw/skills
autoReport: weekly# 运行演示
npm run demo
# 运行测试(计划中)
npm test
# 查看测试覆盖率
npm run coverageskill-evolution-plugin/
├── src/
│ ├── index.js # 主入口
│ ├── interceptor.js # 拦截器
│ ├── analyzer.js # 分析器
│ └── patch-manager.js # 补丁管理
├── bin/
│ └── cli.js # CLI 工具
├── examples/
│ ├── basic-usage.js # 基础用法
│ ├── advanced-usage.js # 进阶用法
│ └── openclaw-integration.js # OpenClaw 集成
├── test/
│ └── demo.js # 演示脚本
├── docs/
│ ├── ARCHITECTURE.md # 架构设计
│ ├── API.md # API 参考
│ └── INTEGRATION.md # 集成指南
├── integration/
│ ├── README.md # 集成指南
│ └── openclaw-hook-example.js # 示例代码
├── package.json
├── README.md
├── CHANGELOG.md
├── CONTRIBUTING.md
└── LICENSE
欢迎贡献!详见 CONTRIBUTING.md
- 🐛 报告 Bug
- 💡 提出新功能建议
- 📝 改进文档
- 🔧 提交代码
- 🌍 翻译文档
# 1. Fork 项目
# 2. 克隆到本地
git clone https://github.com/YOUR_USERNAME/skill-evolution-plugin.git
# 3. 创建分支
git checkout -b feature/your-feature-name
# 4. 开发并提交
npm install
# ... 开发 ...
git commit -m "feat: add new feature"
# 5. 创建 Pull Request- 拦截器
- 分析器
- 补丁管理
- CLI 工具
- 基础文档
- 补丁自动生成
- 补丁应用功能
- 回滚功能
- 单元测试
- OpenClaw 深度集成
- 改进模式识别算法
- 跨 Skill 学习
- 改进建议共享池
- 企业版功能
- 内存开销:~5MB(存储执行记录)
- CPU 开销:<1%(异步记录,不阻塞执行)
- 磁盘开销:~1KB/次执行(JSONL 格式)
- ✅ 本地存储:所有数据存储在
~/.openclaw/skills/<skill>/.evolution/ - ✅ 不上传云端:无网络请求,完全离线
- ✅ 用户控制:用户可随时删除
.evolution/目录 - ✅ 不记录敏感信息:仅记录工具调用,不记录用户数据
- PROJECT_SUMMARY.md - 项目总结
- DEV_PLAN.md - 开发计划
MIT License - 详见 LICENSE
感谢 OpenClaw 社区和所有贡献者!
- Email: 2739146558@qq.com
Made with ❤️ for OpenClaw Community