memory-manager

star 0

分层记忆管理工具。支持 P0/P1/P2 生命周期、shared-memory 共享层、.abstract 索引、自动清理。基于 OpenViking 记忆思想。

AI-Scarlett By AI-Scarlett schedule Updated 3/1/2026

name: memory-manager description: 分层记忆管理工具。支持 P0/P1/P2 生命周期、shared-memory 共享层、.abstract 索引、自动清理。基于 OpenViking 记忆思想。

Memory Manager - 分层记忆管理工具

核心理念

基于 OpenViking 分层记忆思想,实现:

  • 记忆分级: P0/P1/P2 生命周期管理
  • 索引检索: .abstract 快速索引
  • 共享记忆: shared-memory 跨 Agent 同步
  • 自动清理: 定时清理过期记忆

记忆层级

层级 位置 保留期 用途
L0 瞬时 会话上下文 会话期间 临时对话
L1 短期 memory/YYYY-MM-DD.md 7-30 天 每日日志
L2 长期 MEMORY.md 90 天 + 核心记忆
L3 共享 shared-memory/ 永久 跨 Agent 共享

生命周期标签

标签 保留期 自动操作
P0-活跃 7 天 降级为 P1
P1-近期 30 天 降级为 P2
P2-归档 90 天 压缩归档

文件结构

memory-manager/
├── SKILL.md
├── README.md
├── scripts/
│   ├── memory_manager.py      # 核心管理
│   ├── abstract_index.py      # 索引管理
│   └── cleanup.py             # 清理脚本
├── references/
│   └── memory-system.md       # 记忆系统文档
└── templates/
    ├── .abstract              # 索引模板
    └── shared-memory/         # 共享记忆模板

使用方法

Python 调用

from memory_manager import MemoryManager

mm = MemoryManager(workspace="/home/admin/.openclaw/workspace")

# 创建记忆
mm.create_memory("今天完成了 model-router skill", level="P0", tags=["工作", "技能"])

# 检索记忆
results = mm.search("skill", level="P0")

# 更新索引
mm.update_abstract()

# 清理过期记忆
mm.cleanup()

命令行

# 查看记忆状态
python scripts/memory_manager.py status

# 创建记忆
python scripts/memory_manager.py add "记忆内容" --level P0 --tags 工作 技能

# 搜索记忆
python scripts/memory_manager.py search "关键词"

# 清理过期记忆
python scripts/cleanup.py

shared-memory 共享层

文件 用途 权限
global-context.md 系统状态/今日重点 所有 Agent 可读
user-profile.md 用户画像/偏好 所有 Agent 可读
project-state.md 项目状态/待办 所有 Agent 可读写
sync-log.md 同步日志 系统自动写入

自动清理

Cron 配置: 每日 04:00 执行

0 4 * * * cd /home/admin/.openclaw/workspace && python scripts/cleanup.py

索引文件 .abstract

格式:

# Memory Abstract Index

| File | Level | Size | Tags | Created |
|------|-------|------|------|---------|
| 2026-03-01.md | P0 | 2KB | 工作,技能 | 2026-03-01 |

相关技能

  • model-router - 模型路由
  • github-publisher - GitHub 发布
Install via CLI
npx skills add https://github.com/AI-Scarlett/memory-manager --skill memory-manager
Repository Details
star Stars 0
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator