{"skill":{"slug":"unified-self-improving","displayName":"Unified Self Improving","summary":"统一自我进化系统，整合 self-improving-agent、self-improving、mulch 三个技能的优势，提供结构化日志、三层存储、自动升级、模式检测、命名空间隔离和 token 高效的 JSONL 格式支持。","description":"---\nname: unified-self-improving\ndescription: 统一自我进化系统，整合 self-improving-agent、self-improving、mulch 三个技能的优势，提供结构化日志、三层存储、自动升级、模式检测、命名空间隔离和 token 高效的 JSONL 格式支持。\nversion: 1.0.3\ntags: [memory, self-improvement, learning, lifecycle]\ntrigger: session-end, error, correction, pattern-detected, manual-trigger, heartbeat\n---\n\n# 统一自我进化系统 (Unified Self-Improving)\n\n## 概述\n\n本技能整合了以下三个自我进化相关技能的核心功能：\n\n| 技能 | 核心优势 |\n|------|----------|\n| **self-improving-agent** | Markdown 格式、结构化日志（ID/优先级/状态）、promote 机制、重复模式检测 |\n| **self-improving** | 三层存储（HOT/WARM/COLD）、自动升级规则（3次）、命名空间隔离 |\n| **mulch** | JSONL 格式、token 效率高（-54%）、prime/query CLI |\n\n整合后的系统提供统一的 CLI 接口，所有命令统一为 `unified-self-improving <command>` 格式。\n\n---\n\n## 架构\n\n### 存储层级\n\n| 层级 | 位置 | 访问频率 | 格式 | 保留时间 |\n|------|------|----------|------|----------|\n| **HOT** | `memory/hot/` | 实时/每次会话 | Markdown + JSONL 双格式 | 最近 3 次会话 |\n| **WARM** | `memory/warm/learnings/` | 频繁查询 | JSONL | 3-10 次会话 |\n| **COLD** | `memory/cold/archive/` | 归档参考 | JSONL | 10+ 次会话 |\n\n---\n\n## CLI 命令\n\n```\nunified-self-improving <command> [options]\n```\n\n| 命令 | 功能 |\n|------|------|\n| `log` | 记录 correction/error/pattern |\n| `query` | 查询学习项 |\n| `move` | 移动层级（合并 promote/upgrade） |\n| `recall` | 从 COLD 召回 |\n| `namespace` | 命名空间管理 |\n| `index` | 索引管理（合并 mulch prime） |\n| `import` | 批量导入 |\n| `session` | 会话 start/end |\n| `detect-pattern` | 模式检测 |\n\n---\n\n### 记录学习项\n\n```bash\n# 记录用户纠正\nunified-self-improving log -t correction -c \"用户纠正了我\"\n\n# 记录错误\nunified-self-improving log -t error -c \"命令执行失败\" -p high\n\n# 指定命名空间\nunified-self-improving log -t pattern -c \"检测到重复行为\" -n myproject\n```\n\n### 查询\n\n```bash\n# 查询所有\nunified-self-improving query\n\n# 按关键词搜索\nunified-self-improving query --pattern \"correction\"\n\n# 按 ID 查询\nunified-self-improving query --id learn-20260315-001\n\n# 按优先级/层级过滤\nunified-self-improving query --priority high --level hot\n```\n\n### 层级移动\n\n```bash\n# 移动到指定层级 (合并 promote/upgrade)\nunified-self-improving move --id learn-xxx --to warm\n```\n\n### 命名空间\n\n```bash\n# 创建命名空间\nunified-self-improving namespace create myproject\n\n# 列出命名空间\nunified-self-improving namespace list\n\n# 删除命名空间\nunified-self-improving namespace delete myproject\n```\n\n### 索引\n\n```bash\n# 重建索引\nunified-self-improving index rebuild\n```\n\n### 导入导出\n\n```bash\n# 批量导入\nunified-self-improving import learnings.jsonl\n\n# 指定目标层级和命名空间\nunified-self-improving import -n myproject -l warm data.jsonl\n```\n\n### 会话管理\n\n```bash\n# 开始会话\nunified-self-improving session start\n\n# 结束会话 (自动执行升级和清理)\nunified-self-improving session end\n```\n\n### 模式检测\n\n```bash\n# 检测重复模式\nunified-self-improving detect-pattern\n\n# 指定最小出现次数\nunified-self-improving detect-pattern -m 3\n```\n\n---\n\n## 工作流\n\n### Session Start（会话开始）\n\n1. 加载 `memory/index.jsonl` 建立全局索引\n2. 检查 HOT 层是否有未处理的 `corrections` 或 `patterns`\n3. 如有需要，从 WARM/COLD 层召回相关历史学习\n4. 初始化会话日志文件\n\n```bash\n# 加载索引\ncat ~/.openclaw/workspace/memory/index.jsonl | jq -s 'from_entries'\n\n# 召回相关学习\nunified-self-improving recall --id learn-xxx\n```\n\n### Session End（会话结束）\n\n1. 合并会话日志到 HOT 层\n2. 执行自动升级检查（HOT → WARM）\n3. 更新全局索引\n4. 清理过期会话（超过 3 次会话的 HOT 内容）\n\n```bash\n# 会话结束处理\nunified-self-improving session end\n```\n\n---\n\n## 存储结构\n\n```\n~/.openclaw/workspace/memory/\n├── hot/\n│   ├── session-{YYYY-MM-DD}-{HHMMSS}.md\n│   ├── session-{YYYY-MM-DD}-{HHMMSS}.jsonl\n│   ├── corrections.md\n│   ├── errors.md\n│   └── patterns.md\n├── warm/learnings/{namespace}/\n├── cold/archive/{namespace}/\n├── namespace/{namespace}/hot|warm|cold/\n└── index.jsonl\n```\n\n### JSONL 记录格式\n\n```json\n{\"id\": \"learn-20260315-001\", \"namespace\": \"default\", \"content\": \"学习内容\", \"priority\": \"high\", \"status\": \"active\", \"access_count\": 0, \"created_at\": \"2026-03-15T04:00:00Z\", \"updated_at\": \"2026-03-15T04:00:00Z\"}\n```\n\n---\n\n## 配置\n\n可在 `scripts/lib/config.sh` 中修改：\n\n- `HOT_RETENTION`: HOT 层保留会话数 (默认 3)\n- `WARM_RETENTION`: WARM 层保留会话数 (默认 10)\n- `AUTO_UPGRADE_THRESHOLD`: 自动升级阈值 (默认 3)\n- `DEFAULT_NAMESPACE`: 默认命名空间 (default)\n\n---\n\n## 文件位置\n\n- 技能目录: `~/.openclaw/workspace/skills/unified-self-improving/`\n- 存储根目录: `~/.openclaw/workspace/memory/`\n- 脚本目录: `~/.openclaw/workspace/scripts/unified-self-improving/`\n","tags":{"latest":"1.0.4"},"stats":{"comments":0,"downloads":693,"installsAllTime":0,"installsCurrent":0,"stars":0,"versions":5},"createdAt":1773552957859,"updatedAt":1779078241355},"latestVersion":{"version":"1.0.4","createdAt":1773554793794,"changelog":"unified-self-improving 1.0.4\n\n- Migrated all CLI and workflow documentation to the new unified `unified-self-improving <command>` interface, deprecating legacy skill-specific commands for clarity and consistency.\n- Updated storage model to consolidate three learning layers, clarifying directory structures for HOT, WARM, and COLD.\n- Improved configuration documentation (in SKILL.md) to describe core tunable environment variables and simplified the configuration path.\n- Added unified multi-purpose commands (log, move, recall, namespace, index, import, session, detect-pattern), merging previously separate abilities and triggers into concise subcommands.\n- Streamlined workflow and session management instructions; clarified command usage examples for logging, querying, moving, and importing data.","license":"MIT-0"},"metadata":null,"owner":{"handle":"421zuoduan","userId":"s176bj2jj1gzfab6jqpmyfknt583gtdx","displayName":"Cui Ruochen","image":"https://avatars.githubusercontent.com/u/108874795?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1780089893626}}