每日記憶整理工作流
概覽
每日記憶整理工作流提供一套系統化的流程,讓您:
- 回顧當日的重點檔案與會話
- 添加 Reference 與 Observation Drawers
- 關聯相關 Drawers 以增強知識圖譜
- 清理失效連結與孤立記憶
預估時間:10-15 分鐘
第 1 步:識別今日重點 (2 分鐘)
檔案識別
# 列出今日修改的檔案
git log --since="1 day ago" --name-only --pretty=format: | sort | uniq
# 輸出示例:
# architecture-decision.md
# api-gateway-spec.md
# database-schema.md
# benchmark-report.md
會話識別
# 列出今日的會話檔案 (若您的會話有檔案記錄)
find . -name "session-$(date +%Y%m%d)*.md" -type f
# 輸出示例:
# vscode-workspace-1/session-20260717T143000.md
# codex-workspace-2/session-20260717T161500.md
第 2 步:添加 Reference Drawers (3 分鐘)
對於今日修改的重要檔案,添加 Reference Drawers:
# 引用架構決策文件
mempalace add --type reference \
--wing "d:/Repo/myproject" \
--room "architecture" \
--title "API 網關架構決策" \
--file "architecture-decision.md" \
--range "lines 1-80" \
--tags "architecture,design-decision"
# 引用效能分析報告
mempalace add --type reference \
--wing "d:/Repo/myproject" \
--room "performance" \
--title "API 網關效能分析報告" \
--file "benchmark-report.md" \
--range "lines 20-60" \
--tags "performance,benchmark"
第 3 步:添加 Observation Drawers (5 分鐘)
從今日會話中提取見解,添加 Observation Drawers:
# 提取架構設計見解
mempalace add --type observation \
--wing "d:/Repo/myproject" \
--room "architecture" \
--title "微服務邊界按業務能力拆分" \
--content "微服務應根據業務能力而非技術層次拆分,以提高團隊的自主性與互動需求。" \
--sources "vscode-workspace-1/session-20260717T143000.md:120-145" \
--tags "microservices,architecture,independence"
# 提取效能優化見解
mempalace add --type observation \
--wing "d:/Repo/myproject" \
--room "performance" \
--title "跨服務查詢導致效能下降 30%" \
--content "測試顯示,跨服務查詢(API 網關 → 微服務 A → 微服務 B)的延遲比直接查詢高 30%。需要考慮引進快取或數據複製。" \
--sources "codex-workspace-2/session-20260717T161500.md:45-89" \
--tags "performance,cross-service,latency"
第 4 步:關聯 Drawers (3 分鐘)
將今日添加的 Drawers 與現有記憶關聯:
# 關聯架構相關的 Drawers
mempalace link \
--source "d:/Repo/myproject/architecture/drawer-001" \
--target "d:/Repo/myproject/architecture/drawer-020" \
--type "relates_to" \
--reason "都涉及微服務設計" \
--bidirectional
# 關聯效能相關的 Drawers
mempalace link \
--source "d:/Repo/myproject/performance/drawer-002" \
--target "d:/Repo/myproject/architecture/drawer-015" \
--type "ext_ends_from" \
--reason "在 API 網關架議上測出的效能問題"
第 5 步:清理失效連結與孤立記憶 (2 分鐘)
# 列出失效連結是否需要清理
mempalace graph --broken
# 若有 broken links,執行清理
mempalace graph --cleanup-broken
# 列出孤立記憶
mempalace graph --orphan
# 對孤立記憶進行關聯 (選擇性)
mempalace link \
--source "d:/Repo/myproject/uncategorized/drawer-isolated" \
--target "d:/Repo/myproject/architecture/drawer-020" \
--type "relates_to" \
--reason "都涉及架構設計"
第 6 步:導出視覺化 (1 分鐘)
# 導出 Mermaid 視覺化
mempalace graph --export --format mermaid --output "graph-$(date +%Y%m%d).mmd"
# 或導出並可編輯的 Mermaid+YAML
mempalace graph --export --format mermaid+yaml --output "graph-full-$(date +%Y%m%d)/"
進階:自動化腳本
您可以建立一個 Shell 腳本來簡化流程:
# mempalace-daily.sh
#!/bin/bash
echo "🏰 每日記憶整理工作流"
# 識別今日修改的檔案
echo "\n📄 今日修改的檔案:"
git log --since="1 day ago" --name-only --pretty=format: | sort | uniq
# 識別今日會話
echo "\n💬 今日會話檔案:"
find . -name "session-$(date +%Y%m%d)*.md" -type f
echo "\n✅ 請在上述檔案中選擇要記錄的內容,並使用 mempalace add 添加 Drawers。"
# 清理失效連結
echo "\n🔧 清理失效連結..."
mempalace graph --broken
read -p "是否清理失效連結? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
mempalace graph --cleanup-broken
fi
# 列出孤立記憶
echo "\n🔍 列出孤立記憶..."
mempalace graph --orphan
# 導出視覺化
echo "\n📊 導出視覺化..."
mempalace graph --export --format mermaid --output "graph-$(date +%Y%m%d).mmd"
echo "\n✨ 每日整理完成!"
執行腳本:
chmod +x mempalace-daily.sh
./mempalace-daily.sh
頻率建議
| 頻率 | 工作流重點 |
|---|---|
| 每日 | 添加今日 Drawers,清理失效連結 |
| 每週 | 關聯本周 Drawers,導出 Mermaid 視覺化 |
| 每月 | 遷移舊 Drawers,檢視知識圖譜演變 |
驗指標
您的每日整理工作流是否完善?檢查以下指標:
| 指標 | 目標 | 測量方式 |
|---|---|---|
| 新增 Drawers 數量 | 3-7 個 | mempalace list --wing today |
| 清理失效連結 | 0 個 | mempalace graph --broken |
| 關聯密度 | 3-7 Links/Drawer | mempalace graph --stats |
| 導出頻率 | 每週一次 | 檢視 .mempalace/graph-*.mmd |
相關工作流
指令參考
| 指令 | 用途 |
|---|---|
mempalace add |
添加 Reference 或 Observation Drawer |
mempalace link |
關聯 Drawers |
mempalace graph --broken |
列出失效連結 |
mempalace graph --orphan |
列出孤立記憶 |
mempalace graph --export |
導出視覺化圖譜 |
v3.9.0:多代理團隊改用共享 Hub
如果同一個專案每天同時由 Claude Code、Codex CLI 或其他 MCP host 讀同一座 Palace,不建議每個 agent 都各自載入大型 index。v3.9.0 的做法是讓一個健康 Hub 常駐,所有 CLI search 優先共用它。
每日工作流可以因此調整為:
- Hub 常駐持有 Palace collection。
- 多個 agent 平行讀取。
- 寫入 / mutation 仍由 Hub 以 exclusive path 協調。
- 交接任務時記錄 immutable base commit 與 definition of done。
- 需要追協作事件時,用 logstream topic routing 聚焦特定主題。
這樣「每日整理」從單人知識維護,升級成可供 agent fleet 共用的 shared-brain 運作流程。