🦐 Nightly Dream — Memory Consolidation System
"While you sleep, your memories consolidate. Now your AI does too."
A biologically-inspired memory consolidation system. Every night, fragments of your interactions are distilled into structured long-term knowledge — duplicates merged, insights captured, stale memories gracefully archived.
Features
- - 🌙 Four-Stage Dream Cycle: Orient → Gather → Consolidate → Prune
- 📊 5-Metric Health Score: Freshness, Coverage, Coherence, Efficiency, Reachability
- 🎯 Importance Scoring: Base weight × recency × reference boost
- 🗑️ Forgetting Curve: Automatic archival of stale, low-importance entries
- 🔗 Knowledge Graph: Related entries tracked via index.json
- 📈 Milestones: First dream, streaks, entry count milestones
- 🏥 Smart Skip: No new content? Still delivers value with memory recall
- 📊 Dashboard: Auto-generated HTML health dashboard
- 🔔 Rich Notifications: Growth metrics, highlights, insights, stale threads
Memory Architecture
CODEBLOCK0
Quick Start
Manual Trigger
CODEBLOCK1
Automatic (Cron)
Pre-configured cron job runs at 03:00 daily.
Dream Cycle Flow
Step 0: Smart Skip
Checks for unconsolidated logs. If none → still delivers value via memory recall.
Step 1: Collect
Reads unconsolidated daily logs. Extracts decisions, facts, lessons, todos.
Step 2: Consolidate
Compares with MEMORY.md. Semantic dedup. New → append, Updated → modify, Duplicate → skip.
Step 3: Score & Prune
Computes health score (5 metrics). Archives stale entries below importance threshold.
Step 4: Notify
Sends rich notification with growth metrics, highlights, insights, and suggestions.
Health Metrics
| Metric | Weight | Description |
|---|
| Freshness | 25% | Entries referenced in last 30 days |
| Coverage |
25% | Sections updated in last 14 days |
| Coherence | 20% | Entries with relation links |
| Efficiency | 15% | MEMORY.md line count (concise) |
| Reachability | 15% | Connected components in graph |
Importance Markers
| Marker | Effect |
|---|
| 🔥 HIGH | 2x importance weight |
| 📌 PIN |
Exempt from archival |
| ⚠️ PERMANENT | Never archive or modify |
Archival Rules
Entry archived when ALL true:
- - 90+ days since last referenced
- Importance < 0.3
- Not marked PIN or PERMANENT
- Not in episodes/
Manual Commands
| Command | Action |
|---|
| "Dream now" | Run full consolidation |
| "Memory status" |
Show health score + stats |
| "Memory dashboard" | Generate dashboard.html |
| "Memory export" | Export memories to JSON |
⚠️ Timeout Configuration (Critical!)
This skill requires a longer timeout to run properly. Add this to your openclaw.json under agents.defaults:
CODEBLOCK2
Without this, the dream consolidation will timeout and fail. The skill scans many files and needs time to read, analyze, and write memory.
Cron Configuration (macOS launchd)
Create ~/Library/LaunchAgents/com.openclaw.claws-dream.plist:
CODEBLOCK3
Load with:
CODEBLOCK4
Linux (systemd timer)
Create /etc/systemd/system/claws-dream.service:
CODEBLOCK5
Create /etc/systemd/system/claws-dream.timer:
CODEBLOCK6
Enable with:
CODEBLOCK7
Linux (cron)
CODEBLOCK8
Windows (WSL)
CODEBLOCK9
Or create a .bat file:
CODEBLOCK10
Windows (PowerShell Task Scheduler)
CODEBLOCK11
Reference Files
- -
references/dream-prompt.md — Full consolidation prompt
- -
references/first-dream-prompt.md — First run initialization - INLINECODE8 — Health score algorithms
- INLINECODE9 — File templates
- INLINECODE10 — HTML dashboard template
Safety Rules
- 1. Never delete daily logs — only mark with INLINECODE11
- Never remove ⚠️ PERMANENT items — user-protected
- Safe changes — if MEMORY.md changes >30%, save .bak first
- Scope — only read/write memory/ directory and MEMORY.md
Version 2.2 — Built with 🦐 by Crayfish Liu
🦐 夜间梦境 — 记忆巩固系统
当你入睡时,你的记忆得到巩固。现在你的AI也是如此。
一个受生物学启发的记忆巩固系统。每晚,你的互动片段会被提炼成结构化的长期知识——重复内容被合并,洞察被捕获,过时记忆被优雅归档。
功能特性
- - 🌙 四阶段梦境循环:定向 → 收集 → 巩固 → 修剪
- 📊 五项健康指标:新鲜度、覆盖率、连贯性、效率、可达性
- 🎯 重要性评分:基础权重 × 近期性 × 引用加成
- 🗑️ 遗忘曲线:自动归档过时且低重要性的条目
- 🔗 知识图谱:通过index.json追踪相关条目
- 📈 里程碑:首次梦境、连续记录、条目数量里程碑
- 🏥 智能跳过:无新内容?通过记忆召回仍提供价值
- 📊 仪表盘:自动生成的HTML健康仪表盘
- 🔔 丰富通知:增长指标、亮点、洞察、过时线程
记忆架构
workspace/
├── MEMORY.md # 结构化长期知识
└── memory/
├── index.json # 条目元数据 + 健康统计
├── procedures.md # 工作流偏好
├── archive.md # 已归档条目(已淡化)
├── dream-log.md # 巩固报告
├── dashboard.html # 生成的健康仪表盘
├── YYYY-MM-DD.md # 每日互动日志
└── episodes/ # 项目叙事
快速开始
手动触发
运行梦境 / 巩固记忆 / 立即做梦
自动(Cron)
预配置的cron任务每天03:00运行。
梦境循环流程
步骤0:智能跳过
检查未巩固的日志。如果没有 → 通过记忆召回仍提供价值。
步骤1:收集
读取未巩固的每日日志。提取决策、事实、经验教训、待办事项。
步骤2:巩固
与MEMORY.md比较。语义去重。新内容 → 追加,更新 → 修改,重复 → 跳过。
步骤3:评分与修剪
计算健康评分(5项指标)。归档低于重要性阈值的过时条目。
步骤4:通知
发送包含增长指标、亮点、洞察和建议的丰富通知。
健康指标
| 指标 | 权重 | 描述 |
|---|
| 新鲜度 | 25% | 最近30天内被引用的条目 |
| 覆盖率 |
25% | 最近14天内更新的章节 |
| 连贯性 | 20% | 具有关联链接的条目 |
| 效率 | 15% | MEMORY.md行数(简洁性) |
| 可达性 | 15% | 图中的连通分量 |
重要性标记
免于归档 |
| ⚠️ 永久 | 永不归档或修改 |
归档规则
当以下条件全部满足时条目被归档:
- - 自上次引用超过90天
- 重要性 < 0.3
- 未标记为固定或永久
- 不在episodes/目录中
手动命令
显示健康评分 + 统计 |
| 记忆仪表盘 | 生成dashboard.html |
| 记忆导出 | 将记忆导出为JSON |
⚠️ 超时配置(关键!)
此技能需要更长的超时时间才能正常运行。 将其添加到你的openclaw.json中的agents.defaults下:
json
agents: {
defaults: {
timeoutSeconds: 300
}
}
没有这个配置,梦境巩固将会超时并失败。该技能需要扫描许多文件,需要时间来读取、分析和写入记忆。
Cron配置(macOS launchd)
创建~/Library/LaunchAgents/com.openclaw.claws-dream.plist:
xml
Label
com.openclaw.claws-dream
ProgramArguments
/bin/bash
/Users/clawliu/.openclaw/workspace/skills/claws-dream/scripts/dream.sh
StartCalendarInterval
Hour
3
Minute
0
RunAtLoad
StandardOutPath
/Users/clawliu/.openclaw/workspace/logs/claws-dream.log
StandardErrorPath
/Users/clawliu/.openclaw/workspace/logs/claws-dream.err
加载方式:
bash
launchctl load ~/Library/LaunchAgents/com.openclaw.claws-dream.plist
Linux(systemd定时器)
创建/etc/systemd/system/claws-dream.service:
ini
[Unit]
Description=claws-dream 夜间记忆巩固
[Service]
Type=oneshot
ExecStart=/bin/bash /home/user/.openclaw/workspace/skills/claws-dream/scripts/dream.sh
User=user
创建/etc/systemd/system/claws-dream.timer:
ini
[Unit]
Description=每天凌晨3点运行claws-dream
[Timer]
OnCalendar=--* 03:00:00
Persistent=true
[Install]
WantedBy=timers.target
启用方式:
bash
sudo systemctl daemon-reload
sudo systemctl enable --now claws-dream.timer
Linux(cron)
bash
0 3 * /bin/bash /home/user/.openclaw/workspace/skills/claws-dream/scripts/dream.sh >> /home/user/.openclaw/workspace/logs/claws-dream.log 2>&1
Windows(WSL)
batch
:: 通过指向WSL的Windows任务计划程序运行
wsl bash -c bash /mnt/c/Users/you/.openclaw/workspace/skills/claws-dream/scripts/dream.sh
或者创建一个.bat文件:
batch
@echo off
wsl bash -c bash /home/you/.openclaw/workspace/skills/claws-dream/scripts/dream.sh
Windows(PowerShell任务计划程序)
powershell
$action = New-ScheduledTaskAction -Execute bash -Argument -c bash /home/you/.openclaw/workspace/skills/claws-dream/scripts/dream.sh
$trigger = New-ScheduledTaskTrigger -Daily -At 3am
Register-ScheduledTask -TaskName claws-dream -Action $action -Trigger $trigger -RunLevel Limited
参考文件
- - references/dream-prompt.md — 完整巩固提示
- - references/first-dream-prompt.md — 首次运行初始化
- references/scoring.md — 健康评分算法
- references/memory-template.md — 文件模板
- references/dashboard-template.md — HTML仪表盘模板
安全规则
- 1. 永不删除每日日志 — 仅用标记
- 永不移除⚠️ 永久项目 — 用户保护
- 安全变更 — 如果MEMORY.md变更超过30%,先保存.bak备份
- 范围限制 — 仅读写memory/目录和MEMORY.md
版本2.2 — 由🦐刘小龙制作