Memory Architect
Split a monolithic MEMORY.md into three tiers plus a structured entity graph.
Architecture
CODEBLOCK0
Process
1. Analyze the existing MEMORY.md
Read the full file. Classify each section:
| Content type | Tier | Examples |
|---|
| Stable workflow / procedure | protocols | Emoji shortcuts, deploy steps, tool usage rules |
| Active project / waiting-on |
active | Current builds, pending replies, live URLs |
| Completed work / reference data | archive | Done tasks, contact lists, account tables, old decisions |
| Named entity with properties | ontology | People, orgs, projects, properties, locations |
2. Create the tier files
Write each tier file with a header comment explaining its purpose and update frequency.
protocols.md rules:
- - Only procedures that rarely change
- Include the exact commands (copy-pasteable)
- No project-specific state
active.md rules:
- - Only things with a next action or pending status
- Include "Waiting On" section at bottom
- Prune completed items to archive on each update
archive.md rules:
- - Completed work grouped by date or category
- Reference data (contacts, accounts, chat IDs)
- Keep searchable — use headers and tables
3. Extract entities to ontology
For each named person, organization, project, property, or location, create a JSONL entry:
CODEBLOCK1
ID conventions:
- - People: INLINECODE0
- Organizations:
grp_name or INLINECODE2 - Projects: INLINECODE3
- Properties/locations:
prop_name or INLINECODE5
Relation types: member_of, owns, collaborates_on, interested_in, guides, uses, listed_by, INLINECODE13
4. Rewrite MEMORY.md as router
Replace MEMORY.md with a ~25-line index that:
- - Lists the three tiers with one-line descriptions
- Notes the ontology location
- Preserves any system directives (NO_REPLY rules, heartbeat instructions)
- Contains zero project-specific content
5. Verify
CODEBLOCK2
Targets: MEMORY.md under 30, protocols under 100, active under 80, graph = 1 line per entity/relation.
Maintenance
On each session
- - Read
memory/protocols.md (always) - Scan
memory/active.md (always) - INLINECODE16 — only on
memory_search or explicit request
When adding new information
- - New procedure → protocols.md
- New project/active item → active.md
- Completed item → move active → archive
- New person/org/project → append to graph.jsonl
Entity queries
CODEBLOCK3
记忆架构师
将单一的MEMORY.md拆分为三个层级加上结构化实体图。
架构
MEMORY.md → 路由器(最多30行)。指向各层级。
memory/protocols.md → 热数据:稳定工作流、快捷方式、流程。会话启动时读取。
memory/active.md → 温数据:当前项目、待办事项、实时上下文。操作前检查。
memory/archive.md → 冷数据:已完成工作、历史参考。需要时搜索。
memory/ontology/graph.jsonl → 结构化实体+关系(仅追加JSONL格式)
流程
1. 分析现有MEMORY.md
读取完整文件。对每个部分进行分类:
| 内容类型 | 层级 | 示例 |
|---|
| 稳定工作流/流程 | protocols | 表情符号快捷方式、部署步骤、工具使用规则 |
| 活跃项目/待办事项 |
active | 当前构建、待回复消息、实时URL |
| 已完成工作/参考数据 | archive | 已完成任务、联系人列表、账户表格、旧决策 |
| 命名实体及其属性 | ontology | 人员、组织、项目、属性、位置 |
2. 创建层级文件
为每个层级文件添加头部注释,说明其用途和更新频率。
protocols.md规则:
- - 仅包含很少变更的流程
- 包含精确命令(可复制粘贴)
- 不包含项目特定状态
active.md规则:
- - 仅包含有下一步操作或待处理状态的内容
- 底部包含待办事项部分
- 每次更新时将已完成项目移至archive
archive.md规则:
- - 按日期或类别分组的已完成工作
- 参考数据(联系人、账户、聊天ID)
- 保持可搜索性——使用标题和表格
3. 提取实体到本体
对每个命名的人员、组织、项目、属性或位置,创建JSONL条目:
jsonl
{op:create,entity:{id:p_alice,type:Person,properties:{name:Alice,email:alice@example.com,role:工程师}},timestamp:2026-01-01T00:00:00Z}
{op:relate,from:palice,rel:memberof,to:org_acme,timestamp:2026-01-01T00:00:00Z}
ID命名规范:
- - 人员:p简称
- 组织:grp名称 或 org名称
- 项目:proj名称
- 属性/位置:prop名称 或 loc名称
关系类型: memberof(成员)、owns(拥有)、collaborateson(协作)、interestedin(感兴趣)、guides(指导)、uses(使用)、listedby(列出)、located_at(位于)
4. 重写MEMORY.md为路由器
将MEMORY.md替换为约25行的索引,包含:
- - 列出三个层级及一行描述
- 注明本体位置
- 保留任何系统指令(NO_REPLY规则、心跳指令)
- 不包含任何项目特定内容
5. 验证
bash
wc -l MEMORY.md memory/protocols.md memory/active.md memory/archive.md memory/ontology/graph.jsonl
目标:MEMORY.md不超过30行,protocols不超过100行,active不超过80行,graph每个实体/关系一行。
维护
每次会话
- - 读取 memory/protocols.md(始终)
- 扫描 memory/active.md(始终)
- memory/archive.md — 仅在 memory_search 或明确请求时
添加新信息时
- - 新流程 → protocols.md
- 新项目/活跃项 → active.md
- 已完成项 → 从active移至archive
- 新人/组织/项目 → 追加到graph.jsonl
实体查询
bash
grep p_forrest memory/ontology/graph.jsonl
grep type:Project memory/ontology/graph.jsonl
cat memory/ontology/graph.jsonl | jq -r select(.entity?.type==Person) | .entity.properties.name