MetaClaw Skill - Memory Management & Skill Evolution
Use when: Memory-Suche mit Hybrid Retrieval (LanceDB + FTS), automatische Memory-Extraktion, PluginEval Quality Checks, oder Skill Evolution. Dieser Skill bündelt die besten MetaClaw-Konzepte für generische Memory-Systeme.
Overview
MetaClaw ist ein generischer Skill für fortgeschrittene Memory-Management-Lösungen mit:
- - Hybrid Retrieval - Kombiniert semantische Suche (LanceDB) mit FTS/Keyword-Suche
- Memory Extraction - Automatische Extraktion aus Sessions in preferences.md, project-state.md
- Session Counter - Tracking für konsolidierte Memory-Konsolidation (Trigger: N Sessions)
- PluginEval Integration - Auto-Fix für Quality Badge ≥ Gold (≥85)
- Auto-Dream Consolidation - Automatische Memory-Konsolidierung basierend auf Session-Zähler
Installation
CODEBLOCK0
Usage
CLI Interface
CODEBLOCK1
Output
Memory Vector Search (JSON)
CODEBLOCK2
Memory Extraction (JSON)
CODEBLOCK3
Session Counter
$ ./scripts/session-counter.sh --check
# exit 0: consolidation ready
# exit 1: not ready yet
Config
memory/config.yaml
CODEBLOCK5
Auto-Dream Consolidation
Trigger-Logik
- - Session Counter: Zählt Sessions (default: 10)
- Mindestintervall: 6 Stunden zwischen Consolidations
- Auto-Detect: In INLINECODE1
Cron-Job (Optional)
CODEBLOCK6
PluginEval Integration
Quality Check (Layer 1)
CODEBLOCK7
Quality Targets
- - Gold Badge: ≥85 Punkte (Ziel)
- Silver Badge: ≥70 Punkte
- Bronze Badge: ≥60 Punkte
Implementation Details
Hybrid Retrieval Algorithm
CODEBLOCK8
Mode Selection
| Mode | Algorithmus | Use Case |
|---|
| INLINECODE2 | Vector-Suche | Semantische Ähnlichkeit |
| INLINECODE3 |
File-Inhalts-Suche | Exakte Begriffe |
|
fts | LanceDB FTS | Schnelle Keyword-Suche |
|
hybrid | Kombiniert | Standard (empfohlen) |
Session Counter
scripts/session-counter.sh
Trackt Sessions für konsolidierte Consolidation:
CODEBLOCK9
Memory Digest
scripts/memory-digest-enhanced.sh
Konsolidiert Memory-Files mit Session-basierter Logik:
CODEBLOCK10
Integration in OpenClaw
Heartbeat Integration
Füge folgenden Task zur Heartbeat-Logik hinzu:
CODEBLOCK11
Cron Integration
CODEBLOCK12
Troubleshooting
Problem: "Dependencies nicht verfügbar"
Lösung:
CODEBLOCK13
Problem: "Tabelle nicht gefunden"
Lösung:
CODEBLOCK14
Problem: Session-Counter füllt sich nicht auf
Lösung:
./scripts/session-counter.sh --status
# Prüfe ob --increment in Heartbeat aufgerufen wird
Changelog
Version 1.0.0 (2026-04-01)
Added:
- - Generischer MetaClaw Skill für ClawHub
- Hybrid Retrieval (semantic + FTS)
- Memory Extraction Pipeline
- PluginEval Integration
- Session Counter für konsolidierte Consolidation
- Memory Digest mit Session-basierter Logik
Changed:
- - Default Mode:
hybrid (statt semantic) - Score-Kombination: INLINECODE10
Removed:
- - Keine Breaking Changes (Backwards compatible)
Referenzen
- -
~/.openclaw/workspace/skills/memory-vector/ - Original Hybrid Retrieval - INLINECODE12 - Memory Extraction
- INLINECODE13 - PluginEval
- INLINECODE14 - Integration Plan
Last updated: 2026-04-01
Category: automation, memory
Tags: #hybrid-retrieval #memory #skill-evolution #plugineval
技能名称: MetaClaw
详细描述:
MetaClaw 技能 - 内存管理与技能进化
使用场景: 混合检索(LanceDB + FTS)的内存搜索、自动内存提取、PluginEval 质量检查或技能进化。该技能整合了通用内存系统的最佳 MetaClaw 概念。
概述
MetaClaw 是一个用于高级内存管理解决方案的通用技能,具备以下功能:
- - 混合检索 - 结合语义搜索(LanceDB)与 FTS/关键词搜索
- 内存提取 - 从会话中自动提取内容至 preferences.md、project-state.md
- 会话计数器 - 跟踪用于整合内存合并(触发条件:N 次会话)
- PluginEval 集成 - 质量徽章 ≥ 黄金(≥85)时自动修复
- 自动梦境合并 - 基于会话计数器的自动内存合并
安装
bash
创建依赖虚拟环境(自动使用)
cd ~/.openclaw/workspace/skills/metaclaw
python3 -m venv .venv-metaclaw
source .venv-metaclaw/bin/activate
pip install lancedb sentence-transformers
使用方法
CLI 接口
bash
混合检索(默认:0.6 语义 + 0.4 关键词)
python3 scripts/memory-vector-wrapper.py 查询内容 --mode hybrid
语义搜索
python3 scripts/memory-vector-wrapper.py 查询内容 --mode semantic
关键词搜索(FTS)
python3 scripts/memory-vector-wrapper.py 查询内容 --mode keyword
内存提取
python3 scripts/memory-extract.py [--date YYYY-MM-DD] [--dry-run]
会话计数器
./scripts/session-counter.sh --increment
./scripts/session-counter.sh --check # exit 0 = 可合并
PluginEval 质量检查
python3 scripts/skill-eval.py --layer1 skills/metaclaw/
自动修复(使用 --allow-write 进行写入)
python3 scripts/skill-eval.py --auto-fix --allow-write skills/metaclaw/
输出
内存向量搜索(JSON)
json
{
id: memory/2026-04-01.md,
path: /Users/donmeusi/.openclaw/workspace/memory/2026-04-01.md,
snippet: 提取的内容...,
date: 2026-04-01,
type: daily,
tags: [],
score: 0.0,
relevance: 0.0,
method: hybrid,
combined_score: 0.0
}
内存提取(JSON)
json
{
extracted: 2026-04-01,
type: project_state,
confidence: 0.85,
items: [
{
category: Project,
content: MetaClaw 集成阶段 1,
type: update,
source: session
}
],
preferences: [],
project_state: []
}
会话计数器
bash
$ ./scripts/session-counter.sh --check
exit 0: 可合并
exit 1: 尚未就绪
配置
memory/config.yaml
yaml
混合检索设置
retrieval:
default_mode: hybrid # semantic, keyword, fts, hybrid
semantic_weight: 0.6 # 0.6 语义 + 0.4 关键词/FTS
default_limit: 5
合并设置
consolidation:
interval_sessions: 10 # 每 N 次会话
min
intervalhours: 6 # 合并间至少间隔 6 小时
max
memorylines: 200 # MEMORY.md 最大行数
日志
logging:
level: INFO # DEBUG, INFO, WARNING, ERROR
file: ~/.openclaw/workspace/memory/.log
自动梦境合并
触发逻辑
- - 会话计数器:统计会话次数(默认:10)
- 最小间隔:合并间至少间隔 6 小时
- 自动检测:位于 memory-digest-enhanced.sh
定时任务(可选)
bash
crontab -e
每日自动梦境合并(03:00)
0 3
* $HOME/.openclaw/workspace/scripts/memory-digest-enhanced.sh --auto-dream
PluginEval 集成
质量检查(第 1 层)
bash
只读检查
python3 scripts/skill-eval.py --layer1 skills/metaclaw/
反模式检测
python3 scripts/skill-eval.py --anti-patterns skills/metaclaw/
自动修复预览(只读)
python3 scripts/skill-eval.py --auto-fix skills/metaclaw/
自动修复(写入)
python3 scripts/skill-eval.py --auto-fix --allow-write skills/metaclaw/
质量目标
- - 黄金徽章:≥85 分(目标)
- 白银徽章:≥70 分
- 青铜徽章:≥60 分
实现细节
混合检索算法
python
综合得分 = 0.6 语义 + 0.4 FTS
combined
score = semanticweight
semanticrelevance + (1 - semanticweight) fts_score
模式选择
| 模式 | 算法 | 使用场景 |
|---|
| semantic | 向量搜索 | 语义相似度 |
| keyword |
文件内容搜索 | 精确术语 |
| fts | LanceDB FTS | 快速关键词搜索 |
| hybrid | 组合模式 | 默认(推荐) |
会话计数器
scripts/session-counter.sh
跟踪会话次数以实现整合合并:
bash
心跳时递增
scripts/session-counter.sh --increment
获取当前计数
scripts/session-counter.sh --get
合并后重置
scripts/session-counter.sh --reset
检查是否应执行合并
scripts/session-counter.sh --check # exit 0 = 是,exit 1 = 否
内存摘要
scripts/memory-digest-enhanced.sh
使用基于会话的逻辑合并内存文件:
bash
正常运行(检查是否需要合并)
scripts/memory-digest-enhanced.sh
强制运行(覆盖检查)
scripts/memory-digest-enhanced.sh --force
试运行(显示将要执行的操作)
scripts/memory-digest-enhanced.sh --dry-run
自动梦境模式(带合并)
scripts/memory-digest-enhanced.sh --auto-dream
集成到 OpenClaw
心跳集成
将以下任务添加到心跳逻辑中:
bash
scripts/heartbeat.sh
$HOME/.openclaw/workspace/scripts/session-counter.sh --increment
定时任务集成
bash
crontab -e
自动梦境每日合并(可选)
0 3
* $HOME/.openclaw/workspace/scripts/memory-digest-enhanced.sh --auto-dream
故障排除
问题:依赖项不可用
解决方案:
bash
source .venv-metaclaw/bin/activate
pip install lancedb sentence-transformers numpy
问题:未找到表
解决方案:
bash
python3 skills/metaclaw/scripts/memoryvectorinit.py
问题:会话计数器未递增
解决方案:
bash
./scripts/session-counter.sh --status
检查心跳中是否调用了 --increment
更新日志
版本 1.0.0(2026-04-01)
新增:
- - 为 ClawHub 提供的通用 MetaClaw 技能
- 混合检索(语义 + FTS)
- 内存提取管道
- PluginEval 集成
- 用于整合合并的会话计数器
- 基于会话逻辑的内存摘要
变更:
- - 默认模式:hybrid(替代 semantic)
- 得分组合:0.6 语义 + 0.4 关键词
移除:
参考
- - ~/.openclaw/workspace/skills/memory-vector/ - 原始混合检索
- ~/.openclaw/workspace/scripts/memory-extract.py - 内存提取
- ~/.openclaw/workspace/scripts/skill-eval.py - PluginEval
- ~