Claude Code、Cursor 和 OpenCode 的记忆 — 持久化 AI 代理记忆
为你喜爱的 AI 代理提供记忆
Section titled “为你喜爱的 AI 代理提供记忆”toon-memory 为你已经使用的 AI 编程代理提供持久化记忆。无论你偏好 Claude Code、Cursor 还是 OpenCode,你的代理都会在会话之间记住一切。
代理专属设置
Section titled “代理专属设置”Claude Code
Section titled “Claude Code”Claude Code 对 toon-memory 有完整的钩子支持:
{ "mcpServers": { "toon-memory": { "command": "npx", "args": ["-y", "toon-memory", "mcp"] } }}钩子: SessionStart、PostToolUse、Stop — 自动提醒和上下文加载。
Cursor
Section titled “Cursor”在 Cursor 中添加 MCP 配置:
{ "servers": { "toon-memory": { "command": "npx", "args": ["-y", "toon-memory", "mcp"] } }}OpenCode
Section titled “OpenCode”添加到 .opencode/opencode.json:
{ "mcp": { "toon-memory": { "type": "local", "command": ["npx", "-y", "toon-memory", "mcp"], "enabled": true } }}插件: .opencode/plugins/toon-memory.ts — 通过插件实现 SessionStart 钩子。
Windsurf
Section titled “Windsurf”{ "servers": { "toon-memory": { "command": "npx", "args": ["-y", "toon-memory", "mcp"] } }}VS Code / Copilot
Section titled “VS Code / Copilot”添加到 .vscode/mcp.json:
{ "servers": { "toon-memory": { "command": "npx", "args": ["-y", "toon-memory", "mcp"] } }}Codex CLI
Section titled “Codex CLI”添加到 .codex/config.toml:
[mcpServers.toon-memory]command = "npx"args = ["-y", "toon-memory", "mcp"]Gemini CLI
Section titled “Gemini CLI”添加到 .gemini/settings.json:
{ "mcpServers": { "toon-memory": { "command": "npx", "args": ["-y", "toon-memory", "mcp"] } }}添加到 ~/.config/zed/settings.json:
{ "mcp_servers": { "toon-memory": { "command": "npx", "args": ["-y", "toon-memory", "mcp"] } }}交互式安装器(最简单)
Section titled “交互式安装器(最简单)”npx toon-memory安装器将:
- 检测你安装了哪些代理
- 询问要配置哪些代理
- 自动添加 MCP 配置
各代理获得的功能
Section titled “各代理获得的功能”所有代理都获得相同的 35 个 MCP 工具和 4 个 MCP 资源:
memory_remember— 保存决策、模式、缺陷memory_recall— 搜索记忆(平铺或图模式)memory_smart_recall— 统一召回,结合 BM25 + 图 + 质量context_generate— 一次调用获取完整项目简报context_diff— 自上次会话以来的更改- 以及另外 15 个工具……
你可以同时为多个代理配置 toon-memory:
npx toon-memory# 选择:claude, cursor, opencode所有代理共享 .toon-memory/memory/data.toon 中的同一记忆文件。
并行运行多个代理时:
memory_sessions()// 🧭 Active sessions (2):// • claude @ feature/auth (you)// • opencode @ feature/db查看其他会话正在操作的文件以避免冲突。
支持的代理(15+)
Section titled “支持的代理(15+)”| 代理 | 配置位置 | 钩子 |
|---|---|---|
| OpenCode | .opencode/opencode.json |
基于插件 |
| Claude Code | .claude/settings.json |
SessionStart + PostToolUse + Stop |
| Cursor | .cursor/mcp.json |
— |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
— |
| VS Code | .vscode/mcp.json |
— |
| Codex CLI | .codex/config.toml |
SessionStart + PostToolUse + Stop |
| Gemini CLI | .gemini/settings.json |
SessionStart + PostToolUse + Stop |
| Zed | ~/.config/zed/settings.json |
— |
| Cline | .cline/mcp.json |
— |
| Continue | .continue/config.json |
— |
| Antigravity | .gemini/config/mcp_config.json |
PreInvocation + PostToolUse + Stop |
| Aider | — | 指令文件 |
| KiloCode | ~/.kilocode/mcp_settings.json |
— |
| OpenClaw | .openclaw.json |
— |
| Kiro | .kiro/settings/mcp.json |
— |
npm install -g toon-memorynpx toon-memory # 交互式安装器参见支持的代理页面获取详细配置。