feat(plugins): add Codex and Claude Code memory integrations#453
feat(plugins): add Codex and Claude Code memory integrations#453soongao wants to merge 2 commits into
Conversation
|
Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program! |
|
Duplicate/scope cleanup triage for #235: This PR currently depends on #451 and #452, both of which duplicate or extend the adapter foundation outside the approved #235 lanes. The current plugin layer also combines multiple concerns at once: MCP registration, CLI hook installation, Codex plugin metadata, Claude Code plugin metadata, marketplace writes, install scripts, and AGENTS/CLAUDE guidance updates. The existing canonical boundaries are:
Recommendation: close this as a stacked integration PR for now. After #316/#372 land, reopen smaller follow-ups per runtime if needed: one Codex plugin wrapper and one Claude Code plugin wrapper, each using the approved MCP/Gateway pieces and with install-script/config writes reviewed as their own risk surface. |
概述
本 PR 新增 TencentDB Agent Memory 的 Codex / Claude Code plugin 集成层。
它把已有的 MCP memory search 能力和 CLI hook adapter 能力接入到具体 agent runtime 中,让 Codex 和 Claude Code 可以通过 plugin 安装后获得:
关联 Issue
Part of #235
前置依赖
本 PR 是 Codex / Claude Code 的 plugin 集成层,依赖前置 PR 提供的两个底层 adapter:
tdai_memory_search/tdai_conversation_search两个 MCP 检索工具tdai-memory/tdai-memory-hook命令,用于 hook 预取、捕获和 session flush建议合并顺序:
本 PR 的安装脚本会安装并注册上述两个 adapter,然后把它们接入 Codex / Claude Code 的 MCP、hooks、skill 和静态指导文件。
提供的 Plugin 能力
plugins/tdai-memory/scripts/install-codex.shAGENTS.md记忆工具说明plugins/tdai-memory-claude-code/scripts/install-claude-code.shCLAUDE.md记忆工具说明MCP 能力接入
两个 plugin 都会注册同一个
tdai-memoryMCP server,并向 agent 暴露记忆检索工具:tdai_memory_searchtdai_conversation_searchCodex plugin 会在安装时配置
tdai-memoryMCP server 的 tool approval policy,默认允许这两个只读检索工具自动调用。Hooks 能力接入
两个 plugin 都提供 runtime 对应的 hook 配置,把 agent 生命周期事件接到
tdai-memory-hook命令:SessionStarttdai-memory-hook session-startUserPromptSubmittdai-memory-hook prefetchStoptdai-memory-hook sync-turnCodex 和 Claude Code 的 hook 注册格式不同,因此本 PR 分别提供对应 runtime 的 plugin 配置:
plugins/tdai-memory/hooks/hooks.jsonplugins/tdai-memory-claude-code/hooks/hooks.json两边 hook 最终调用的是同一组 CLI adapter 命令,行为保持一致。
静态指导说明
两个安装脚本都会在用户本地 agent 指导文件中写入一段带 marker 的 TencentDB Agent Memory 说明:
~/.codex/AGENTS.mdtdai_memory_search/tdai_conversation_search,并限制单轮最多 3 次检索~/.claude/CLAUDE.mdtdai_memory_search/tdai_conversation_search,并限制单轮最多 3 次检索写入逻辑是幂等的:如果目标文件已有 TDAI marker block,则替换该 block;如果没有,则追加一段新的 TDAI memory block。
安装时做了什么
本 PR 提供的安装脚本会完成本地 plugin 集成所需的配置写入。安装过程是幂等的,重复执行会更新已有的 TDAI 配置块,而不是重复追加。
scripts/install-codex.shtdai-memoryMCP server、写入 Codex hook 配置、更新~/.codex/AGENTS.md、配置 MCP tool approval policy、配置 hook diagnostic log 路径scripts/install-claude-code.sh~/.claude/CLAUDE.md、配置 hook diagnostic log 路径对
AGENTS.md/CLAUDE.md的修改只发生在安装阶段:~/.codex/AGENTS.md<!-- TDAI_MEMORY_START -->/<!-- TDAI_MEMORY_END -->marker block 幂等更新tdai_memory_search/tdai_conversation_search,并限制单轮最多 3 次检索~/.claude/CLAUDE.md<!-- TDAI_MEMORY_START -->/<!-- TDAI_MEMORY_END -->marker block 幂等更新tdai_memory_search/tdai_conversation_search,并限制单轮最多 3 次检索安装后的运行时 hook 命令不会动态创建、重写或注入
AGENTS.md/CLAUDE.md内容。安装入口
Codex
安装脚本会执行:
packages/tdai-memory-mcppackages/tdai-memory-clitdai-memory@tdai-memory-localtdai-memoryMCP server~/.codex/AGENTS.mdClaude Code
安装脚本会执行:
packages/tdai-memory-mcppackages/tdai-memory-clitdai-memory-claude-code@tdai-memory-local~/.claude/CLAUDE.md运行链路
MCP 检索链路:
Hook 捕获链路:
自测结果
bash -n scripts/install-codex.sh scripts/install-claude-code.shcd packages/tdai-memory-cli && python3 -m pytest tests/unit -q16 passedcd packages/tdai-memory-mcp && python3 -m pytest tests/unit -q16 passed端到端安装验证需要本机已有 Codex / Claude Code CLI、可写的用户配置目录,以及已经运行的 TDAI Gateway,因此不作为默认单元自测的一部分。