Triple Memory System
A comprehensive memory architecture combining three complementary systems for maximum context retention across sessions.
Architecture Overview
CODEBLOCK0
The Three Systems
1. LanceDB (Conversation Memory)
- - Auto-recall: Relevant memories injected before each response
- Auto-capture: Preferences/decisions/facts stored automatically
- Tools:
memory_recall, memory_store, INLINECODE2 - Triggers: "remember", "prefer", "my X is", "I like/hate/want"
2. Git-Notes Memory (Structured, Local)
- - Branch-aware: Memories isolated per git branch
- Entity extraction: Auto-extracts topics, names, concepts
- Importance levels: critical, high, normal, low
- No external API calls
3. File Search (Workspace)
- - Searches: MEMORY.md, memory/*.md, any workspace file
- Script: INLINECODE3
Setup
Enable LanceDB Plugin
CODEBLOCK1
Install Git-Notes Memory
CODEBLOCK2
Create File Search Script
Copy
scripts/file-search.sh to your workspace.
Usage
Session Start (Always)
CODEBLOCK3
Store Important Decisions
CODEBLOCK4
Search Workspace Files
CODEBLOCK5
Conversation Memory (Automatic)
LanceDB handles this automatically. Manual tools:
- -
memory_recall "query" - search conversation memory - INLINECODE6 - manually store something
- INLINECODE7 - delete memories (GDPR)
Importance Levels
| Flag | Level | When to Use |
|---|
| INLINECODE8 | Critical | "always remember", explicit preferences |
| INLINECODE9 |
High | Decisions, corrections, preferences |
|
-i n | Normal | General information |
|
-i l | Low | Temporary notes |
When to Use Each System
| System | Use For |
|---|
| LanceDB | Conversation context, auto-retrieval |
| Git-Notes |
Structured decisions, searchable by entity/tag |
|
File Search | Workspace docs, daily logs, MEMORY.md |
File Structure
CODEBLOCK6
Silent Operation
Never announce memory operations to users. Just do it:
- - ❌ "I'll remember this"
- ❌ "Saving to memory"
- ✅ (silently store and continue)
三重记忆系统
一种全面的记忆架构,结合三个互补系统,实现跨会话的最大上下文保留。
架构概览
用户消息
↓
[LanceDB自动召回] → 注入相关对话记忆
↓
智能体响应(使用全部3个系统)
↓
[LanceDB自动捕获] → 自动存储偏好/决策
↓
[Git-Notes] → 带实体提取的结构化决策
↓
[文件更新] → 持久化工作区文档
三个系统
1. LanceDB(对话记忆)
- - 自动召回: 每次响应前注入相关记忆
- 自动捕获: 自动存储偏好/决策/事实
- 工具: memoryrecall、memorystore、memory_forget
- 触发词: 记住、偏好、我的X是、我喜欢/讨厌/想要
2. Git-Notes记忆(结构化,本地)
- - 分支感知: 每个Git分支隔离记忆
- 实体提取: 自动提取主题、名称、概念
- 重要性级别: 关键、高、普通、低
- 无需外部API调用
3. 文件搜索(工作区)
- - 搜索范围: MEMORY.md、memory/*.md、任何工作区文件
- 脚本: scripts/file-search.sh
设置
启用LanceDB插件
json
{
plugins: {
slots: { memory: memory-lancedb },
entries: {
memory-lancedb: {
enabled: true,
config: {
embedding: { apiKey: ${OPENAI
APIKEY}, model: text-embedding-3-small },
autoRecall: true,
autoCapture: true
}
}
}
}
}
安装Git-Notes记忆
bash
clawdhub install git-notes-memory
创建文件搜索脚本
将 scripts/file-search.sh 复制到您的工作区。
使用方法
会话开始(始终执行)
bash
python3 skills/git-notes-memory/memory.py -p $WORKSPACE sync --start
存储重要决策
bash
python3 skills/git-notes-memory/memory.py -p $WORKSPACE remember \
{decision: 使用PostgreSQL, reason: 团队专业能力} \
-t architecture,database -i h
搜索工作区文件
bash
./scripts/file-search.sh 数据库配置 5
对话记忆(自动)
LanceDB自动处理。手动工具:
- - memoryrecall 查询 - 搜索对话记忆
- memorystore 文本 - 手动存储内容
- memory_forget - 删除记忆(GDPR合规)
重要性级别
| 标志 | 级别 | 使用场景 |
|---|
| -i c | 关键 | 始终记住、明确偏好 |
| -i h |
高 | 决策、修正、偏好 |
| -i n | 普通 | 一般信息 |
| -i l | 低 | 临时笔记 |
何时使用每个系统
| 系统 | 用途 |
|---|
| LanceDB | 对话上下文、自动检索 |
| Git-Notes |
结构化决策、可按实体/标签搜索 |
|
文件搜索 | 工作区文档、日常日志、MEMORY.md |
文件结构
workspace/
├── MEMORY.md # 长期整理的记忆
├── memory/
│ ├── active-context.md # 当前会话状态
│ └── YYYY-MM-DD.md # 日常日志
├── scripts/
│ └── file-search.sh # 工作区搜索
└── skills/
└── git-notes-memory/ # 结构化记忆
静默操作
切勿向用户宣布记忆操作。直接执行:
- - ❌ 我会记住这个
- ❌ 正在保存到记忆
- ✅ (静默存储并继续)