用途
Mnemonics 用于跨对话的持久记忆管理。它通过 @historian 子代理来存储、检索和管理记忆,使重要信息不会随着会话结束而丢失。
主要能力
记忆工具仅通过 @historian 子代理提供,不能直接调用:
- memory_remember:创建或更新记忆
- memory_recall:搜索并检索记忆
- memory_forget:删除记忆
- memory_list_types:列出可用的记忆类型
- memory_sync:重建搜索索引
必须始终委托给 historian,例如:
@historian remember that we decided on PostgreSQL for the database
@historian what did we decide about authentication?
记忆类型
| 类型 | 用途 | 示例 |
|---|---|---|
| architectural-decision | 系统架构选择 | "Using PostgreSQL with read replicas for scaling" |
| design-decision | UI/UX 决策 | "Card layout for dashboard, 3 columns on desktop" |
| learning | 经验与发现 | "Bun's native TS support removes build step need" |
| user-preference | 用户偏好 | "User prefers dark mode, tabs not spaces" |
| project-preference | 团队约定 | "We use conventional commits, PR reviews required" |
| issue | 已知问题 | "Rate limiting not implemented yet, tracking in #42" |
| context | 通用上下文(默认) | "Project started Feb 2026, MVP target Q2" |
| recurring-pattern | 可复用模式 | "Error handling: wrap in try/catch, return {error}" |
| conventions-pattern | 编码规范 | "Use named exports, avoid default exports" |
注意:项目可通过配置定义自定义记忆类型。应始终使用 @historian list all memory types available 查看当前项目的完整列表。
使用方式
何时委托给 Historian
记住(创建/更新):
- 做出重要的架构或设计决策之后
- 用户表达其工作方式偏好时
- 发现关于代码库或工具的重要信息时
- 学到应跨会话保留的经验时
回忆(搜索/检索):
- 开始新会话时 → 回忆相关上下文
- 用户询问"我们关于 X 决定了什么?"
- 需要检查某个决策是否已经做出
- 查找已知问题或模式
遗忘(删除):
- 用户想移除过时或错误的记忆
- 清理重复或无关的条目
同步(重建索引):
- 手动编辑 .mnemonics/ 中的记忆文件之后
- 搜索结果看起来过时时
示例提示
记住:
@historian remember that we decided on JWT auth with 15-min expiry
@historian save this learning: Bun handles TypeScript natively without compilation
@historian note that the user prefers minimal UI animations
@historian store this as an architectural-decision: we're using event sourcing for the audit log
回忆:
@historian what did we decide about authentication?
@historian recall any known issues with the API
@historian what are my preferences for this project?
@historian show all architectural decisions
@historian find memories about database choices
管理:
@historian list all memory types available
@historian forget the memory about the old API design
@historian sync the index to include recent memory files
工作原理
- 记忆以 Markdown 文件形式存储在 .mnemonics/{type}/{title}.md,带 YAML frontmatter
- 通过 qmd(BM25 与向量混合搜索)自动建立索引
- Historian 负责分类、去重和语义搜索
- 文件对 Git 友好,可提交以便团队共享
最佳实践
- 标题要具体——用 "qmd-cli-for-writes" 而非 "important decision"
- 让 historian 分类——它会先搜索以避免重复
- 决策前先回忆——检查是否已有相关决策
- 提交记忆文件——它们是项目知识的一部分
限制
记忆工具不能直接调用,必须通过 @historian 子代理。其他限制暂未提供。