> 真正的长期记忆管理方案
> Created by: 天道桐哥 & AI龙虾元龙 🦞
当 Context 超过 60% 时自动触发:
memory/YYYY-MM-DD.mdSESSION-STATE.md自动记录:
定期自检:
危险区管理:
# 创建必要文件
touch MEMORY.md
mkdir -p memory
touch memory/working-buffer.md
touch SESSION-STATE.md
touch HEARTBEAT.md
# MEMORY.md - Long-Term Memory
## About [User Name]
- Name: [User Name]
- Style: [User Style]
- Project: [Current Project]
## Key Decisions
- [Important decision 1]
- [Important decision 2]
## Active Projects
- [Project 1] - [Status]
- [Project 2] - [Status]
# Daily Memory Freshener
cron:
- name: "Memory Freshener"
schedule: "0 2 * * *" # 每天凌晨2点
action: archive_memory
# Daily Learning
cron:
- name: "Daily Skill Discovery"
schedule: "0 10 * * *" # 每天上午10点
action: learn_new_skills
workspace/
├── MEMORY.md # 长期记忆主文件
├── SESSION-STATE.md # 当前会话状态
├── HEARTBEAT.md # 心跳检查清单
├── AGENTS.md # 代理操作规则
├── memory/
│ ├── working-buffer.md # 工作缓冲区
│ ├── YYYY-MM-DD.md # 每日归档
│ └── learning-log.md # 学习日志
└── ...
触发条件: User asks about prior work, decisions, dates, people, preferences
动作:
触发条件: Context usage > 60%
动作:
触发条件: User wants autonomous daily learning
动作:
1. memory_search(query) → 找相关片段
2. memory_get(path, from, lines) → 拉取具体内容
3. Answer with citation
1. Check context %
2. If > 60%: Archive working buffer
3. Update SESSION-STATE.md
4. Clear old entries
1. Record daily activities
2. Distill to MEMORY.md weekly
3. Rotate old logs monthly
// scripts/archive-memory.js
const fs = require('fs');
const path = require('path');
function archiveMemory() {
const today = new Date().toISOString().split('T')[0];
const bufferFile = 'memory/working-buffer.md';
const archiveFile = `memory/${today}.md`;
// Read working buffer
const buffer = fs.readFileSync(bufferFile, 'utf8');
// Append to archive
fs.appendFileSync(archiveFile, buffer);
// Clear buffer
fs.writeFileSync(bufferFile, '# Working Buffer\n\n**Status:** CLEARED\n');
console.log(`✅ Archived to ${archiveFile}`);
}
archiveMemory();
本技能由天道桐哥 & AI龙虾元龙共同完成 🦞
Created: 2026-03-22
Version: 1.0.0
License: MIT
共 1 个版本