memoryweave/docs/p3-creative-plan.md

45 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# P3: CREATIVE.md 隔离 — 防止双写入冲突
## 问题
MEMORY.md 同时被 `memory` 工具(写环境事实/约定)和织忆(写记忆/经验)写入,可能导致 `§` 分隔符污染和数据混乱。
## 方案(参考 Memory-OS: 把 Icarus 写目标从 MEMORY.md 拆到 CREATIVE.md
1.`~/.hermes/` 下创建 `CREATIVE.md` 文件(初始内容为空,带标记头)
2. 修改 Hermes 织忆插件的 `sync_turn` 方法:将记忆写出目标从 MEMORY.md 改为 CREATIVE.md
3. 确保 Hermes 的 `system_prompt_block()` 返回 `CREATIVE.md` 的内容(如果文件存在)
4. 当前 `sync_turn` 使用的是 Hermes 原生 memory 工具写入 → 需要确认是直接写文件还是通过工具
## 具体文件
### `~/.hermes/CREATIVE.md` — 创建
```markdown
# CREATIVE.md — 织忆(A06)工作记忆与学习状态
> 由 Hermes 织忆插件自动管理,`memory` 工具请写入 MEMORY.md
> 创建日期2026-07-02
<!-- 织忆自动写入区 — 请勿手动编辑 -->
```
### `~/.hermes/hermes-agent/plugins/memory/zhiyi/__init__.py` — 修改 sync_turn
当前 sync_turn~391行附近把对话写入织忆后端/commit API同时可能也写 MEMORY.md。
需要确认:插件代码是否直接写 MEMORY.md如果没写那 P3 的动作为:
1.`system_prompt_block()` 方法中:检测并返回 CREATIVE.md 内容
2. 织忆本身通过 /commit 存储到 LanceDB和 MEMORY.md 无关 → 没有直接冲突
3. 所以 P3 = 创建 CREATIVE.md + 让 system_prompt_block 使用它 + 说明织忆的专用存储不在 MEMORY.md
## 验证
```bash
# CREATIVE.md 文件存在
ls -la ~/.hermes/CREATIVE.md
# 插件 system_prompt_block 返回正确
cd ~/.hermes/hermes-agent && python3 -c "
from plugins.memory.zhiyi import HermesZhiYiMemoryProvider
p = HermesZhiYiMemoryProvider()
p.initialize(session_id='test')
block = p.system_prompt_block()
print('CREATIVE.md in prompt:', 'CREATIVE.md' in block or '工作记忆' in block)
print(f'block length: {len(block)}')
"
```