SuperAPI AI Directory

persistent-memory

Coding & development

View repository

Updated 10-16 01:33

About this skill

Persistent Memory — Universal Memory Protocol

Quick Start

# 首次初始化(详见 references/setup.md)
mkdir -p ~/.persistent-memory/{memories,journal,archive,.sensitive}

Core Principles

  1. User says "remember" = immediately classify and write
  2. All writes must update INDEX.md
  3. Automatically detect information type → write to the corresponding category file
  4. Sensitive information → .sensitive/ directory (not synced)
  5. Periodic 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)

Memory Category Quick Reference

Type File Write Example
Facts memories/facts.md Accounts, configurations, tech stack versions, IP addresses
Decisions memories/decisions.md Architecture choices, technical solutions, why A was chosen over B
Preferences memories/preferences.md Code style, tool habits, "always use pnpm"
Context memories/context.md Project background, business logic, team information
User Profile SOUL.md Personality, communication style, form of address, working style
Daily journal/YYYY-MM-DD.md What was completed today, problems found, temporary notes

Session Start

# 必须读取
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

After reading, inform the user: "Your memory has been loaded, X long-term memories in total, Y log entries today"

Trigger Scenarios

Trigger Behavior
User says "remember xxx" Determine category → write → update INDEX
User asks "what was it like before" Three-layer retrieval (see retrieval.md)
API key/account detected Prompt the user whether to record to .sensitive/
Important task completed Prompt to record to journal/
Session end Update access count → update INDEX → write journal
First day of each month Prompt monthly compression (see intelligence.md)

Write Process (4 Steps)

  1. Determine category: Determine from the content whether it belongs to facts/decisions/preferences/context/journal
  2. Generate entry: Create entry ID (format X-YYYYMMDD-NNN) + metadata (date/importance/tags)
  3. Write to file: Append to the corresponding category file
  4. Update INDEX: Rewrite INDEX.md (update statistics, recent additions, category summaries)

Entry Format

### [F-20260228-001] 标题
- **创建**: 2026-02-28
- **最近访问**: 2026-02-28
- **访问次数**: 1
- **重要度**: high|medium|low
- **标签**: tag1, tag2

正文内容...

ID Rules

  • F = Facts, D = Decisions, P = Preferences, C = Context
  • Format:[类型]-[YYYYMMDD]-[当日序号]

Backward Compatibility

Automatically detect at session start:

  • INDEX.md exists → new version, normal process
  • Only MEMORY.md + memory/ directory → old version, prompt migration (see migration.md)
  • Neither exists → new user, guide initialization (see setup.md)

More Content (Progressive Disclosure)