import CodeBlock from ‘../../../components/CodeBlock.astro’; import CopyButton from ‘../../../components/CopyButton.tsx’;
Palace 架構
v3.6.0 更新重點
MemPalace v3.6.0 已不只面向單機 Palace:新增安全預設的 mempalace serve,支援 bearer token、TLS 與 --read-only 團隊部署;另加入可選的 Milvus backend、時間性事實的 supersede()、對話 authored_at 保留、挖掘 session 的 hallways 圖譜、exclude_patterns 專案排除,以及 .tex/.bib LaTeX 來源。MCP surface 目前包含 36 個工具。1
使用遠端服務時,請把它視為部署選項,不要把本機 mempalace init 與 mempalace serve 混成同一個流程。
MemPalace 使用「記憶宮殿 (Palace)」的概念來組織您的記憶。整個架構分為三個層級:翼 (Wing)、室 (Room)、抽屜 (Drawer)。
三層架構
Palace (記憶宮殿)
└── Wing (翼) # 語境切分(專案/使用者/工作區)
└── Room (室) # 主題分類(概念/專案/議題)
└── Drawer (抽屜) # 具體內容(核心觀點/引用實證)
Wing(翼)
Wing 是最高層級的語境切分,常用於:
| Wing 類型 | 範例 | 使用情境 |
|---|---|---|
| Repository(儲存庫) | d:/Repo/myproject |
專案相關記憶 |
| Workspace(工作區) | vscode-workspace-1 |
特定 IDE 工作物件 |
| User(使用者) | user-james |
個人或團隊檔案案 |
初始化 Palace 時,預設使用當前儲存庫作為第一個 Wing:
<CodeBlock code={‘mempalace init’} language=“bash”> <CopyButton code={‘mempalace init’} />
Room(室)
Room 是 Wing 下的主題分類,用於組織相關內容。常見類型:
| Room 類型 | 範例 |
|---|---|
| Concept(概念) | codebase-architecture、api-design-patterns |
| Project(專案) | q3-planning、migration-strategy |
| Topic(議題) | pricing-model、user-onboarding |
Drawer(抽屜)
Drawer 是最小儲存單位,包含具體內容。Drawer 有兩種類型:
# Reference Drawer:引用外部內容
mempalace add --type reference \
--title "Claude Anthropic 4.5 模型能力概覽" \
--source "https://docs.anthropic.com/claude-4-5" \
--wing "d:/Repo/myproject"
# Observation Drawer:直接記錄見解
mempalace add --type observation \
--title "Claude 4.5 在複雜推理任務上的表現優於 GPT-4o" \
--wing "d:/Repo/myproject"
資料存放位置
Palace 的資料存放在 <root>/.mempalace/palace/ 目錄下:
.mempalace/palace/
├── d:/Repo/myproject/ # Wing
│ ├── codebase-architecture/ # Room 1
│ │ ├── drawer-001.md # Drawer 1
│ │ └── drawer-002.md # Drawer 2
│ ├── q3-planning/ # Room 2
│ │ └── drawer-003.md # Drawer 3
│ └── wings.yaml # Wing 元數據
├── vscode-workspace-1/ # Wing 2
│ └── ...
└── palace.yaml # Palace 全局配置
建立最佳的 Palace 結構
按專案切分 Wing
# 當有多個專案時,使用對應的儲存庫路徑作為 Wing
mempalace add --wing "d:/Repo/api-gateway" --room "architecture"
mempalace add --wing "d:/Repo/frontend" --room "component-library"
按會話類型切分 Wing
如果您的 Palace 混合了不同類型的對話,可建立虛擬 Wing:
# 技術設計對話
mempalace add --wing "technical" --room "database-schema"
# 產品策略對話
mempalace add --wing "product" --room "pricing-strategy"
在 Room 內相關聯的 Drawers
將相關的 Drawers 放在同一個 Room,便於檢索:
# 在同一個 Room 中建立關聯的 Drawers
mempalace add --type observation \
--room "database-schema" \
--title "使用 PostgreSQL 處理關聯數據"
mempalace add --type reference \
--room "database-schema" \
--title "PostgreSQL 效能優化最佳實踐" \
--source "https://www.postgresql.org/docs/current/performance-tips.html"
檢視 Palace 結構
使用 mempalace list 指令檢視當前 Palace 的 Wing、Room、Drawer 結構:
<CodeBlock code={‘mempalace list –wing “d:/Repo/myproject”’} language=“bash” />
輸出示例:
Wing: d:/Repo/myproject
Rooms: 3, Drawers: 12
Room: codebase-architecture (3 Drawers)
[observation] 複雜架構與知識圖譜的映射
[reference] Clean Architecture 原則
[observation] 微服務邊界定義
Room: q3-planning (5 Drawers)
[observation] Q3 營收預測調整
[reference] H1 營收分析報告
...
Room: api-design-patterns (4 Drawers)
...
最佳實踐
✅ 使用清晰的 Wing/Room 命名:project-name 而非 proj-01
✅ 相關 Drawers 放同一個 Room:便於檢索時一次取得完整上下文
✅ 使用說明性標題:Drawer 標題應足以讓您在 3 秒內理解內容
✅ 定期整理 Room:將過時的 Drawers 移動或刪除
❌ 避免過細的 Room 切分:一個 Wing 下少於 5 個 Room 時考慮合併
❌ 避免混合類型:不要在技術設計 Room 中放入產品策略 Drawers
❌ 避免抽象 Wing 名稱:使用具體標識符(儲存庫路徑、使用者名稱)而非 wing-1
下一課
在熟悉 Palace 架構後,下一課將深入瞭解 MemPalace 的 Verbatim 儲存機制,以及它如何做到零失真記憶。