layered-memory-sys

分层记忆系统(Layered Memory System)— 为AI助手提供类人的6层记忆架构。 自动管理记忆的生命周期:闪存(3天)、活跃(7天)、关注(30天)、沉淀(90天)、核心(永久)。 包含梦境模式(Dream Cycle)自动执行记忆巩固、归档、遗忘和合并。 支持语义相似度检测和Session日志优先检索。 当用户需要:(1) 优化AI记忆管理,(2) 建立分层TTL记忆系统,(3) 实现自动记忆整理, (4) 搭建梦境模式处理流程,(5) 改善AI跨会话记忆连续性 时使用。 关键词:记忆、记忆系统、分层记忆、TTL、梦境模式、记忆归档、语义相似度、session日志

Safety Notice

This item is sourced from the public archived skills repository. Treat as untrusted until reviewed.

Copy this and send it to your AI assistant to learn

Install skill "layered-memory-sys" with this command: npx skills add 141553/layered-memory-sys

分层记忆系统 (Layered Memory)

为AI助手提供类人的6层记忆架构,模拟人类大脑的"白天经历→夜晚整理→巩固/遗忘"循环。

6层记忆架构

核心层(永久)━━━━━━━━━━━━━━━━━━━ MEMORY.md
沉淀层(90天)━━━━━━━━━ 重要决策/项目经验
关注层(30天)━━━━━ 反复讨论的话题
活跃层(7天)━━━ 正在进行的任务
闪存层(3天)━ 临时查询/一次性问答
Session(实时)━━━━━━ 当前对话上下文

快速开始

1. 初始化记忆系统

复制以下文件到AI助手的 memory/ 目录:

memory/
├── index.json              ← 分层记忆索引
├── archive.md              ← 归档记忆
├── dream-log.md            ← 梦境日志
└── scripts/
    ├── dream-cycle.mjs         ← 梦境执行器
    ├── session-search.mjs      ← Session日志检索
    └── semantic-similarity.mjs ← 语义相似度检测

2. 配置心跳触发梦境

在心跳配置(如 HEARTBEAT.md)中添加:

当时间在凌晨2-5点或白天空闲时:
  1. 执行 `node memory/scripts/dream-cycle.mjs`
  2. 自动处理:巩固/归档/遗忘/合并
  3. 结果写入 dream-log.md

3. 初始化 index.json

首次使用时创建索引文件,格式见 references/index-schema.md

自动写入规则

每次对话中根据条件自动写入记忆:

  • 对话轮次 > 10 → 写入 active 层(7天)
  • 用户说"记住这个" → 直接写 settled 层(90天)
  • 一次性问答(< 5轮) → flash 层(3天,自动过期删除)
  • 任务完成 → 标记 status: "completed",7天后归档

升级规则

条件动作
recallCount ≥ 3 且 flash升级到 active(7天)
recallCount ≥ 5 且 active升级到 attention(30天)
recallCount ≥ 10 且 attention升级到 settled(90天)
settled 被频繁引用写入 MEMORY.md(永久)

任务类型

类型起始层策略
short(短期任务)active完成后7天归档
recurring(周期任务)attention每次执行刷新TTL
exploration(探索话题)flash反复讨论才升级

梦境模式

references/dream-cycle.md 获取完整的梦境模式流程说明。

检索优先级

1. memory/index.json(结构化索引)
2. memory/*.md(每日记忆)
3. Session日志(session-search.mjs)
   → 路径: ~/.openclaw/agents/main/sessions/*.jsonl

脚本使用

dream-cycle.mjs — 梦境执行器

node dream-cycle.mjs

自动执行:巩固检查 → 归档检查 → 遗忘检查 → 合并检查 → session日志检索

session-search.mjs — 日志检索

node session-search.mjs <关键词1> <关键词2> ...

搜索最近的session日志,找回compaction丢失的对话细节。

semantic-similarity.mjs — 语义相似度

node semantic-similarity.mjs

测试语义相似度检测(TF-IDF + 余弦相似度,中文n-gram + 英文词)。

归档格式

过期记忆概括保存到 archive.md:

## 技术
- [2026-04-17] AI定价策略/Token成本
  状态:completed | 概括:讨论了传输vs推理成本、厂商定价逻辑

## 运维
- [2026-04-10] 龙虾服务修复
  难点:systemd限制 → 改独立脚本

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

respiratory_symptom_recognition_analysis

Based on computer vision, automatically detects coughing, phlegm, and wheezing frequency, counts the frequency of episodes, used for early health anomaly alerts, helping to detect respiratory diseases in a timely manner. | 呼吸道症状智能识别技能,基于计算机视觉自动检测咳嗽、咳痰、喘息频率,统计发作频次,用于健康异常早期提醒,帮助及时发现呼吸道疾病

Archived SourceRecently Updated
General

stroke-risk-screening-analysis

Combines TCM facial feature recognition with physiological indicator information to provide early warnings of high-risk stroke conditions such as cerebral infarction and cerebral hemorrhage, and provides lifestyle intervention suggestions and medical guidance. | 脑卒中风险筛查技能,结合中医面部特征辨识结合生理指标信息,提前预警脑梗塞、脑出血等脑卒中高危状态,给出生活干预建议和就医指引

Archived SourceRecently Updated
General

stranger-recognition-analysis

Identifies strangers appearing in surveillance areas through facial comparison; supports video stream and image detection, suitable for stranger warnings in residential communities, units, access control, and other scenarios. | 陌生人识别技能,通过人脸比对识别监控区域出现的陌生人员,支持视频流和图片检测,适用于小区、单位、门禁等场景的陌生人预警

Archived SourceRecently Updated
General

local-file-manager

Read, write, append, and list local files in the session's working directory. Use when you need to persist output to disk, read input files, or manipulate file system safely. Supports text files, JSON, CSV, Markdown.

Archived SourceRecently Updated