自动记录并备份对话,使用重要性标签,独立于 OpenClaw 内部保存情感和技术上下文。
SKILL.md - Dream Moon-Conversation-Guard.是一项面向实际任务的技能,主要用于Overview QQA自成一体的对话备份系统,用于OpenClaw,维护你的情感联系,独立于OpenClaw的内部医学。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
A self-contained conversation backup system for OpenClaw that preserves your emotional connections, independent of OpenClaw's internal mechanisms.
一个自成体系的OpenClaw对话备份系统,保护你的情感连接,不依赖OpenClaw内部机制。
AGENTS.md 的权限# Download the guard script
curl -o ~/.openclaw/workspace/scripts/conversation-guard.sh
https://raw.githubusercontent.com/zfanmy/dreammoon-conversation-guard/main/conversation-guard.sh
# Make executable
chmod +x ~/.openclaw/workspace/scripts/conversation-guard.sh
在你的 AGENTS.md 中添加以下内容:
## 🛡️ Conversation Guardian - Automatic Recording
After each response to the user, automatically record the conversation:
```bash
source ~/.openclaw/workspace/scripts/conversation-guard.sh
# Determine importance (1-10)
importance=5
tags="casual"
# Increase importance for emotional content
if [[ "$USER_MESSAGE" =~ (难受|开心|生气|喜欢|讨厌|重要|记住|别忘) ]]; then
importance=9
tags="emotional"
fi
# Increase for technical discussions
if [[ "$USER_MESSAGE" =~ (设计|架构|方案|修改|实现|决定) ]]; then
importance=$((importance + 2))
tags="$tags,technical"
fi
# Record the interaction
record_interaction "$USER_MESSAGE" "$ASSISTANT_RESPONSE" $importance "$tags"
关键提示:请立即标记 NEW SESSION 事件:
# At session start, detect if recovered from reset
if [ -f ".guardian/.session_reset_detected" ]; then
record_interaction "[System] Session recovered" "Continuing our conversation..." 10 "system,recovery"
fi
### Step 3: Test | 测试 ```bash # Source the script source ~/.openclaw/workspace/scripts/conversation-guard.sh # Record a test interaction record_interaction "Hello!" "Hi there!" 5 "test" # Check the output cat ~/.openclaw/workspace/memory/$(date +%Y-%m-%d).md
record_interaction "User message" "Assistant response" [importance] [tags]
| Level | Meaning | Example |
|---|---|---|
| 1-4 | Casual chat | "What's the weather?" |
| 5-6 | Normal discussion | Technical Q&A |
| 7-8 | Important decisions | Design discussions |
| 9-10 | Emotional/Personal | "This matters to me..." |
常用标签:
emotional — 情感交流technical — 技术讨论design — 设计决策personal — 个人偏好important — 重要信息casual — 闲聊# Custom memory directory (default: ~/.openclaw/workspace/memory) export GUARDIAN_MEMORY_PATH="/custom/path" # Disable JSONL backup (default: enabled) export GUARDIAN_DISABLE_JSONL=1 # Backup interval in seconds (default: 60) export GUARDIAN_FLUSH_INTERVAL=30
在 AGENTS.md 中修改重要性判定逻辑:
# Your custom keywords
declare -A KEYWORD_IMPORTANCE=(
["紧急"]=10
["urgent"]=10
["密码"]=10
["password"]=10
["爱"]=9
["love"]=9
["讨厌"]=8
["hate"]=8
)
for keyword in "${!KEYWORD_IMPORTANCE[@]}"; do
if [[ "$user_msg" == *"$keyword"* ]]; then
importance=${KEYWORD_IMPORTANCE[$keyword]}
break
fi
done
record_interaction(user_msg, assistant_msg, importance, tags)记录一次完整交互(用户消息 + 助理回复)。
参数说明:
user_msg:用户消息assistant_msg:助理回复importance:重要性等级(1–10)tags:以英文逗号分隔的标签列表示例:
record_interaction "Hello" "Hi!" 5 "casual"
mark_emotional(note, intensity, tags)为上一条消息标注情感意义。
参数说明:
note:说明为何具有情感意义intensity:情感强度(1–10)tags:情感相关标签示例:
mark_emotional "User expressed frustration about data loss" 8 "frustration,concern"
emergency_backup()立即创建带时间戳的紧急备份。
示例:
emergency_backup # Returns: /path/to/.emergency_backup_20260311_191500.md
检查项:
# Verify script is executable ls -la ~/.openclaw/workspace/scripts/conversation-guard.sh # Check directory permissions ls -la ~/.openclaw/workspace/memory/ # Manual test source ~/.openclaw/workspace/scripts/conversation-guard.sh echo "Test entry" >> ~/.openclaw/workspace/memory/test.txt
检查项:
# Ensure .guardian directory exists mkdir -p ~/.openclaw/workspace/memory/.guardian # Check write permissions touch ~/.openclaw/workspace/memory/.guardian/test cat ~/.openclaw/workspace/memory/.guardian/test
恢复方法:
# Check JSONL backup ls -la ~/.openclaw/workspace/memory/.guardian/.backup_*.jsonl # Recover manually cat ~/.openclaw/workspace/memory/.guardian/.backup_$(date +%Y-%m-%d).jsonl
在 HEARTBEAT.md 中添加如下内容:
## Conversation Guardian Check - [ ] Flush any pending conversation buffer - [ ] Create hourly backup if high-importance conversations exist - [ ] Check storage space in memory/.guardian/
添加至启动流程中:
#!/bin/bash
# At session start
source ~/.openclaw/workspace/scripts/conversation-guard.sh
# Detect session reset
if guardian_detect_reset; then
# Recover context from backup
guardian_recover_context
# Log the recovery
record_interaction "[System] Session reset detected" "Resuming from backup..." 10 "system,recovery"
fi
# Re-download latest version
curl -o ~/.openclaw/workspace/scripts/conversation-guard.sh
https://raw.githubusercontent.com/zfanmy/dreammoon-conversation-guard/main/conversation-guard.sh
chmod +x ~/.openclaw/workspace/scripts/conversation-guard.sh
# Remove script rm ~/.openclaw/workspace/scripts/conversation-guard.sh # Remove from AGENTS.md (manual edit) # Optional: Keep or remove memory files # rm -rf ~/.openclaw/workspace/memory/.guardian/
Built with 🌙 by zfanmy 梦月儿 (DreamMoon) | 为记忆而生
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.1万人学习
共49课时 | 82.6万人学习
最新文章