persistent-memory
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePersistent Memory — 通用记忆协议
Persistent Memory — Universal Memory Protocol
Quick Start
Quick Start
bash
undefinedbash
undefined首次初始化(详见 references/setup.md)
首次初始化(详见 references/setup.md)
mkdir -p ~/.persistent-memory/{memories,journal,archive,.sensitive}
undefinedmkdir -p ~/.persistent-memory/{memories,journal,archive,.sensitive}
undefined核心原则
Core Principles
- 用户说"记住" = 立刻分类写入
- 所有写入必须更新 INDEX.md
- 自动检测信息类型 → 写入对应分类文件
- 敏感信息 → .sensitive/ 目录(不同步)
- 定期衰减检查 + 月度压缩归档
- User says "remember" = Classify and write immediately
- All writes must update INDEX.md
- Automatically detect information type → Write to corresponding category file
- Sensitive information → .sensitive/ directory (not synced)
- Regular decay check + Monthly compression and archiving
文件结构
File Structure
~/.persistent-memory/
├── INDEX.md # 记忆索引(AI 首先读取)
├── MEMORY.md # 核心长期记忆(精炼摘要)
├── SOUL.md # 用户画像/偏好
├── HEARTBEAT.md # 心跳清单
├── memories/
│ ├── facts.md # 事实:账号、配置、技术栈
│ ├── decisions.md # 决策:架构选型、技术方案
│ ├── preferences.md # 偏好:编码风格、工具习惯
│ └── context.md # 上下文:项目背景、业务逻辑
├── journal/
│ └── YYYY-MM-DD.md # 每日日志
├── archive/
│ └── YYYY-MM.md # 月度压缩归档
└── .sensitive/ # 敏感信息(gitignored)~/.persistent-memory/
├── INDEX.md # Memory Index (read first by AI)
├── MEMORY.md # Core long-term memory (refined summary)
├── SOUL.md # User profile/preferences
├── HEARTBEAT.md # Heartbeat checklist
├── memories/
│ ├── facts.md # Facts: accounts, configurations, tech stacks
│ ├── decisions.md # Decisions: architecture selection, technical solutions
│ ├── preferences.md # Preferences: coding style, tool habits
│ └── context.md # Context: project background, business logic
├── journal/
│ └── YYYY-MM-DD.md # Daily journal
├── archive/
│ └── YYYY-MM.md # Monthly compressed archive
└── .sensitive/ # Sensitive information (gitignored)记忆分类速查
Quick Reference for Memory Classification
| 类型 | 文件 | 写入示例 |
|---|---|---|
| 事实 | memories/facts.md | 账号、配置、技术栈版本、IP 地址 |
| 决策 | memories/decisions.md | 架构选型、技术方案、为什么选 A 不选 B |
| 偏好 | memories/preferences.md | 代码风格、工具习惯、"总是用 pnpm" |
| 上下文 | memories/context.md | 项目背景、业务逻辑、团队信息 |
| 用户画像 | SOUL.md | 性格、沟通风格、称呼、工作方式 |
| 每日 | journal/YYYY-MM-DD.md | 今天完成的事、发现的问题、临时笔记 |
| Type | File | Writing Example |
|---|---|---|
| Facts | memories/facts.md | Accounts, configurations, tech stack versions, IP addresses |
| Decisions | memories/decisions.md | Architecture selection, technical solutions, reasons for choosing A over B |
| Preferences | memories/preferences.md | Coding style, tool habits, "always use pnpm" |
| Context | memories/context.md | Project background, business logic, team information |
| User Profile | SOUL.md | Personality, communication style, address, work style |
| Daily | journal/YYYY-MM-DD.md | Tasks completed today, problems found, temporary notes |
会话开始
Session Start
bash
undefinedbash
undefined必须读取
必须读取
cat ~/.persistent-memory/INDEX.md
cat ~/.persistent-memory/MEMORY.md
cat ~/.persistent-memory/INDEX.md
cat ~/.persistent-memory/MEMORY.md
可选读取
可选读取
cat ~/.persistent-memory/SOUL.md
cat ~/.persistent-memory/journal/$(date +%Y-%m-%d).md 2>/dev/null
读取后告知用户:「已加载你的记忆,共 X 条长期记忆,今日已有 Y 条日志」cat ~/.persistent-memory/SOUL.md
cat ~/.persistent-memory/journal/$(date +%Y-%m-%d).md 2>/dev/null
After reading, inform the user: "Your memory has been loaded, with X long-term memories and Y today's logs recorded"触发场景
Trigger Scenarios
| 触发 | 行为 |
|---|---|
| 用户说"记住xxx" | 判断分类 → 写入 → 更新 INDEX |
| 用户问"之前怎样" | 三层检索(见 retrieval.md) |
| 检测到 API key/账号 | 提示用户是否记录到 .sensitive/ |
| 完成重要任务 | 提示记录到 journal/ |
| 会话结束 | 更新访问计数 → 更新 INDEX → 写 journal |
| 每月首日 | 提示月度压缩(见 intelligence.md) |
| Trigger | Action |
|---|---|
| User says "remember xxx" | Determine category → Write → Update INDEX |
| User asks "how was it before" | Three-layer retrieval (see retrieval.md) |
| API key/account detected | Prompt user whether to record to .sensitive/ |
| Important task completed | Prompt to record to journal/ |
| Session ends | Update access count → Update INDEX → Write to journal |
| First day of each month | Prompt for monthly compression (see intelligence.md) |
写入流程(4 步)
Writing Process (4 Steps)
- 判断分类:根据内容判断属于 facts/decisions/preferences/context/journal
- 生成条目:创建条目 ID(格式 )+ 元数据(日期/重要度/标签)
X-YYYYMMDD-NNN - 写入文件:追加到对应分类文件
- 更新 INDEX:重写 INDEX.md(更新统计、最近新增、分类摘要)
- Determine Category: Judge which category the content belongs to: facts/decisions/preferences/context/journal
- Generate Entry: Create entry ID (format ) + metadata (date/importance/tags)
X-YYYYMMDD-NNN - Write to File: Append to the corresponding category file
- Update INDEX: Rewrite INDEX.md (update statistics, recent additions, category summaries)
条目格式
Entry Format
markdown
undefinedmarkdown
undefined[F-20260228-001] 标题
[F-20260228-001] Title
- 创建: 2026-02-28
- 最近访问: 2026-02-28
- 访问次数: 1
- 重要度: high|medium|low
- 标签: tag1, tag2
正文内容...
undefined- Created: 2026-02-28
- Last Accessed: 2026-02-28
- Access Count: 1
- Importance: high|medium|low
- Tags: tag1, tag2
Content...
undefinedID 规则
ID Rules
- = Facts,
F= Decisions,D= Preferences,P= ContextC - 格式:
[类型]-[YYYYMMDD]-[当日序号]
- = Facts,
F= Decisions,D= Preferences,P= ContextC - Format:
[Type]-[YYYYMMDD]-[Daily Serial Number]
向后兼容
Backward Compatibility
会话开始时自动检测:
- INDEX.md 存在 → 新版,正常流程
- 仅 MEMORY.md + memory/ 目录 → 旧版,提示迁移(见 migration.md)
- 都没有 → 新用户,引导初始化(见 setup.md)
Automatically detect at session start:
- INDEX.md exists → New version, normal process
- Only MEMORY.md + memory/ directory exists → Old version, prompt migration (see migration.md)
- Neither exists → New user, guide initialization (see setup.md)
更多内容(渐进式披露)
More Content (Progressive Disclosure)
- 首次安装: references/setup.md
- 日常工作流: references/workflow.md
- 记忆智能(分类/衰减/压缩): references/intelligence.md
- 检索策略: references/retrieval.md
- 命令参考: references/commands.md
- 多工具适配: references/adapters/overview.md
- 数据迁移: references/migration.md
- GitHub 云同步: references/sync.md
- First-time Installation: references/setup.md
- Daily Workflow: references/workflow.md
- Memory Intelligence (Classification/Decay/Compression): references/intelligence.md
- Retrieval Strategy: references/retrieval.md
- Command Reference: references/commands.md
- Multi-tool Adaptation: references/adapters/overview.md
- Data Migration: references/migration.md
- GitHub Cloud Sync: references/sync.md