Install
openclaw skills install convert-memory-files-between-systems如何将 memory-lancedb-pro 的记忆文件转换为原版 markdown 格式,并导入到 memos-local-openclaw-plugin 系统中。TRIGGER 当用户提到记忆文件转换、markdown 文件导入、配置文件修改、数据库导入、记忆插件更换、或任何涉及将记忆数据从一个系统迁移到另一个系统的需求时。
openclaw skills install convert-memory-files-between-systems本技能帮助你将 memory-lancedb-pro 的记忆文件转换为原版 markdown 格式,并导入到 memos-local-openclaw-plugin 系统中,确保数据迁移的顺利进行。
确认 memory-lancedb-pro 的数据存储位置和格式
memory-md 目录检查 JSONL 备份文件的结构
{
"text": "记忆内容",
"timestamp": "时间戳",
"category": "类别(decision, fact 等)",
"metadata": {
"l0_abstract": "摘要",
"l1_overview": "概述",
"l2_content": "详细内容"
}
}
将记忆从 JSONL 备份文件转换为 markdown 文件
删除配置文件中关于 memory-lancedb-pro 的所有内容
确认当前记忆系统
slots.memory: memos-local-openclaw-plugin~/.openclaw/memory/ 目录将转换好的 markdown 记忆文件导入到 memos-local-openclaw-plugin 系统中
/home/hahaha1234/.openclaw/memos-local/memos.dbchunks 表的字段chunks 表中验证导入结果
❌ 使用 sed 和 grep 删除配置文件中的相关行 → 由于 sed 的转义问题和 grep 的逐行删除导致 JSON 无效 → ✅ 使用 Python 脚本精确删除相关配置,避免格式问题
import json
# 读取配置文件
with open('/path/to/config.json', 'r') as file:
config = json.load(file)
# 删除 memory-lancedb-pro 相关配置
if 'memory-lancedb-pro' in config['plugins']['entries']:
del config['plugins']['entries']['memory-lancedb-pro']
if 'memory-lancedb-pro' in config['plugins']['load']['paths']:
config['plugins']['load']['paths'].remove('memory-lancedb-pro')
if 'memory-lancedb-pro' in config['plugins']['allow']:
config['plugins']['allow'].remove('memory-lancedb-pro')
# 保存配置文件
with open('/path/to/config.json', 'w') as file:
json.dump(config, file, indent=2)
import sqlite3
import os
import re
# 连接数据库
conn = sqlite3.connect('/home/hahaha1234/.openclaw/memos-local/memos.db')
cursor = conn.cursor()
# 创建 chunks 表(如果不存在)
cursor.execute('''
CREATE TABLE IF NOT EXISTS chunks (
id INTEGER PRIMARY KEY,
session_key TEXT,
turn_id INTEGER,
content TEXT,
timestamp TEXT,
category TEXT,
importance REAL,
scope TEXT
)
''')
# 读取 markdown 文件
memory_dir = '/home/hahaha1234/.openclaw/memory/'
for filename in os.listdir(memory_dir):
if filename.endswith('.md'):
with open(os.path.join(memory_dir, filename), 'r') as file:
content = file.read()
# 解析 markdown 文件
date = re.search(r'# (\d{4}-\d{2}-\d{2}) 记忆', content).group(1)
memories = re.findall(r'## \[(\d{2}:\d{2}:\d{2})\] (DECISION|FACT) - 重要性:(\d+\.\d+)\n\n**范围**: (.+?)\n\n(.+?)\n\n---', content, re.DOTALL)
# 插入数据到数据库
for memory in memories:
timestamp, category, importance, scope, content = memory
cursor.execute('''
INSERT INTO chunks (session_key, turn_id, content, timestamp, category, importance, scope)
VALUES (?, ?, ?, ?, ?, ?, ?)
''', (date, 0, content, timestamp, category, float(importance), scope))
# 提交并关闭连接
conn.commit()
conn.close()
text、timestamp、category 和 metadata/home/hahaha1234/.openclaw/memos-local/memos.dbchunks 表的字段:session_key、turn_id、content 等chunks 表中,确保数据格式正确scripts/delete_memory_lancedb_pro_config.py — 删除配置文件中 memory-lancedb-pro 相关内容的 Python 脚本scripts/import_markdown_to_memos.py — 将 markdown 记忆文件导入到 memos 数据库的 Python 脚本scripts/remove_memory_lancedb_pro.py — automation scriptscripts/import_markdown_to_memos.py — automation script