Autodream — Memory Consolidation
Consolidates scattered daily memory files into a clean, organized MEMORY.md.
When to Use
- - Manually: User says "consolidate memory", "dream", "clean up memory", "organize my memories"
- Via heartbeat: Periodically check if consolidation is needed (24h+ since last run AND 5+ new files)
- After major events: Big refactor, project changes, many new daily files
Quick Start
CODEBLOCK0
Replace {{workspace}} with your actual workspace path (e.g., ~/.openclaw/workspace).
If Installed Globally
CODEBLOCK1
What It Does (4 Phases)
Phase 1: Orientation
- - Reads existing
MEMORY.md (if any) - Scans
memory/ for daily files - Identifies files changed since last consolidation
Phase 2: Gather Signal
- - Extracts structured entries from each daily file
- Classifies into categories: People, Projects, Preferences, Technical Decisions, Events, Lessons
- Scores importance of each entry
Phase 3: Consolidation
- - Removes exact duplicates (hash-based)
- Removes fuzzy duplicates (similarity > 75%)
- Prunes stale entries (completed tasks, old debugging notes)
- Normalizes relative dates ("yesterday" → "2026-03-24")
Phase 4: Prune & Index
- - Enforces max line limit (default: 200 lines)
- Prioritizes by importance × recency
- Writes clean
MEMORY.md with category sections - Backs up previous
MEMORY.md to INLINECODE7
Heartbeat Integration
Add to your HEARTBEAT.md:
CODEBLOCK2
Configuration
Create .autodream.json in workspace root to customize:
CODEBLOCK3
Safety
- - Non-destructive: Always backs up existing
MEMORY.md before modifying - Backups: Stored in INLINECODE11
- Reports: Consolidation reports in INLINECODE12
- Dry run: Always available with INLINECODE13
- Protected entries: Entries with ⚠️, IMPORTANT, NEVER, ALWAYS are never pruned
Output Format
CODEBLOCK4
Autodream — 记忆整合
将分散的日常记忆文件整合为一份清晰有序的 MEMORY.md。
使用时机
- - 手动触发:用户说“整合记忆”、“做梦”、“清理记忆”、“整理我的记忆”
- 通过心跳检测:定期检查是否需要整合(距离上次运行超过24小时且新增5个以上文件)
- 重大事件后:大型重构、项目变更、大量新增日常文件
快速开始
bash
检查是否需要整合
node /path/to/openclaw-autodream/bin/autodream.js {{workspace}} --stats
运行整合(先试运行!)
node /path/to/openclaw-autodream/bin/autodream.js {{workspace}} --dry-run --verbose
正式运行
node /path/to/openclaw-autodream/bin/autodream.js {{workspace}} --verbose
强制完全重新整合
node /path/to/openclaw-autodream/bin/autodream.js {{workspace}} --force --verbose
将 {{workspace}} 替换为你的实际工作区路径(例如 ~/.openclaw/workspace)。
如果已全局安装
bash
npm install -g openclaw-autodream
autodream ~/.openclaw/workspace --stats
autodream ~/.openclaw/workspace --verbose
autodream ~/.openclaw/workspace --dry-run
功能说明(4个阶段)
阶段1:定向
- - 读取现有的 MEMORY.md(如果有)
- 扫描 memory/ 目录下的日常文件
- 识别自上次整合以来发生变更的文件
阶段2:信号收集
- - 从每个日常文件中提取结构化条目
- 分类为:人物、项目、偏好、技术决策、事件、经验教训
- 对每个条目进行重要性评分
阶段3:整合
- - 移除完全重复项(基于哈希值)
- 移除模糊重复项(相似度 > 75%)
- 修剪过时条目(已完成的任务、旧的调试笔记)
- 规范化相对日期(“昨天” → “2026-03-24”)
阶段4:修剪与索引
- - 强制最大行数限制(默认:200行)
- 按重要性 × 时效性排序
- 写入带有分类章节的整洁 MEMORY.md
- 将之前的 MEMORY.md 备份到 memory/.autodream-backups/
心跳集成
添加到你的 HEARTBEAT.md:
markdown
记忆整合检查
- - 运行 autodream --stats 检查是否需要整合
- 如果显示“将触发:✅ 是”,则运行 autodream --verbose
- 仅在安静时段运行整合(不在用户活跃聊天时)
配置
在工作区根目录创建 .autodream.json 进行自定义:
json
{
maxLines: 200,
lookbackDays: 30,
categories: [
人物与关系,
项目与工作,
偏好与风格,
技术决策,
重要事件,
经验教训
],
preservePatterns: [⚠️, 重要, 绝不, 始终],
triggerThreshold: {
minHoursSinceLastRun: 24,
minNewFiles: 5
}
}
安全保障
- - 非破坏性:修改前始终备份现有 MEMORY.md
- 备份:存储在 memory/.autodream-backups/
- 报告:整合报告存储在 memory/.autodream-reports/
- 试运行:始终可通过 --dry-run 使用
- 受保护条目:带有 ⚠️、重要、绝不、始终 的条目永远不会被修剪
输出格式
markdown
长期记忆
人物与关系
- - 张三 — 团队负责人测试运行通过(2026-03-25)
项目与工作
- - Acme公司 — 第一季度回顾:利润率30.1%,目标40%(2026-03-25)
偏好与风格
- - 重视精确性和事实准确性(2026-02-01)
技术决策
- - Alpha项目使用Supabase + Vercel(2026-03-18)
经验教训
- - 修改生产数据前务必备份(2026-02-15)