feat(plugins): add Codex and Claude Code memory integrations#453
Open
soongao wants to merge 2 commits into
Open
feat(plugins): add Codex and Claude Code memory integrations#453soongao wants to merge 2 commits into
soongao wants to merge 2 commits into
Conversation
Collaborator
|
Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
本 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,因此不作为默认单元自测的一部分。