[good first issue-platform adapt-Claude Code] Add native Memory plugin for Claude Code (hooks + MCP, no proxy) - #1268
Open
plainwuatlig wants to merge 1 commit into
Conversation
… no proxy) Adds MemoryCore/claude-code-plugin, a pure v3 client for Claude Code in the shape of the OpenClaw client adapter: lifecycle hooks plus a stdio MCP server over @tencentdb-agent-memory/memory-sdk-ts-v2. Claude Code keeps talking to Anthropic directly; nothing is routed through the proxy. Hooks (one process per event, state shared via hashed files): - UserPromptSubmit: searchAtomic for the prompt every time; readCore and listScenarios once per session; injected as additionalContext with a short guide to the MCP tools. A total Gateway outage injects nothing. - Stop: the finished turn is read from the transcript named by transcript_path (fallback: the Claude Code projects directory) and sent as one addConversation: prompt, tool calls, tool results, intermediate and final text. Thinking and images dropped, tool traffic quoted with size caps, 8192-char chunks, 100 messages per batch. Credential-shaped substrings are redacted before sending. Falls back to prompt + reply when no transcript can be read. Skipped while background tasks or session crons are present. - SessionEnd: whatever transcript remains unsent. A failed batch leaves the marker at the last batch that landed and the turn unclaimed, so a later hook sends the rest. MCP server: tdai_memory_search, tdai_conversation_search, tdai_scenario_read, tdai_memory_capture (a milestone in the agent's own words), and, when TDAI_KNOWLEDGE_URL is set, tdai_wiki_list/search/pages/read/write against the Knowledge Service /v3/wiki API. Wiki ids are always parameters; identity comes from TDAI_* env; the plugin carries no organisation content. Verified against a running Gateway and Knowledge Service: first-prompt recall 178 ms, Stop turn capture 346 ms with the secret redacted, L0 read-back shows all four messages; MCP server lists 9 tools and returns real hits. 17 vitest tests. Bilingual README; rows added to INSTALL.md / INSTALL_CN.md. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EkVfNqVBnTAHnc62NUieKj Signed-off-by: Plain Wu <plain.wu@lig.com.tw>
This was referenced Sep 6, 2026
Closed
Collaborator
|
Thank you so much for your attention and contribution! We will arrange an internal review for this PR shortly, and all feedback will be shared right here in the discussion. |
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.
Description | 描述
Adds
MemoryCore/claude-code-plugin/: a native Claude Code client for Memory Gateway/v3/*, in the same shape as the OpenClaw client adapter (MemoryCore/openclaw-plugin/): a pure client over@tencentdb-agent-memory/memory-sdk-ts-v2, no extraction or storage, and no LLM-traffic proxy. Claude Code keeps talking to Anthropic directly; memory arrives through Claude Code's own lifecycle hooks and a stdio MCP server. It sits beside the existing proxy route (agents/claude-code/) as the choice for teams that do not want to move model traffic, keys, or billing to the proxy.新增
MemoryCore/claude-code-plugin/:Memory Gateway/v3/*的 原生 Claude Code 客户端,形态与 OpenClaw 客户端适配器一致——基于@tencentdb-agent-memory/memory-sdk-ts-v2的纯客户端,不做抽取和存储,不经过 LLM 流量代理。Claude Code 仍直连 Anthropic;记忆通过 Claude Code 自身的生命周期 Hook 与一个 stdio MCP server 接入。与现有代理路线(agents/claude-code/)并列,供不希望把模型流量、密钥与计费转到代理的团队选用。Hooks (one process per event; state shared via hashed files in a state dir)
UserPromptSubmit:searchAtomicfor the prompt on every turn;readCore+listScenariosonce per session; injected asadditionalContext(<user-persona>,<scene-navigation>,<relevant-memories>, tool guide). A total Gateway outage injects nothing.Stop: the finished turn is read from the transcript named bytranscript_path(fallback: the Claude Code projects directory) and sent as oneaddConversation: prompt, tool calls, tool results, intermediate and final text. Thinking/images dropped; tool traffic quoted with size caps; 8192-char chunks; 100 messages per batch. Credential-shaped substrings are redacted before sending (tool traffic carries env dumps and config files). Falls back to prompt + reply when no transcript can be read. Skipped whilebackground_tasks/session_cronsare present.SessionEnd: whatever transcript remains unsent. A failed batch leaves the marker at the last batch that landed and the turn unclaimed, so a later hook sends the rest.MCP server (stdio):
tdai_memory_search,tdai_conversation_search,tdai_scenario_read,tdai_memory_capture(a milestone in the agent's own words), and, whenTDAI_KNOWLEDGE_URLis set,tdai_wiki_list / search / pages / read / writeagainst the Knowledge Service/v3/wikiAPI. Wiki ids are always tool parameters; identity comes fromTDAI_*env; the plugin carries no organisation-specific content.Docs: bilingual
README.md/README_CN.md,integrations/hooks.json,integrations/mcp.json.example; one row added to the agent tables inINSTALL.md/INSTALL_CN.md.Related Issue | 关联 Issue
#926 (Adapters Wanted, Claude Code native route). Complements #1126's proxy route for Pi and
agents/claude-code/for Claude Code rather than replacing them.Change Type | 修改类型
Self-test Checklist | 自测清单
npm run typecheck,npm run build,npm test(17 vitest tests: transcript normalisation and redaction, hook flows incl. partial failure and retry, MCP round-trips, Knowledge client envelopes). Live against a running Gateway + Knowledge Service: first-prompt recall 178 ms with persona/guide/L1, second prompt L1 only;Stopsent the turn in 346 ms with the secret redacted;queryConversationread back all four messages; MCP server lists 9 tools and returns real wiki and memory hits.Additional Notes | 其他说明
Design choices worth a reviewer's eye: (1) per-turn capture at
Stoprather than only atSessionEnd, because a 100-message batch costs the Gateway a few seconds and a session'sSessionEndfires once, so end-only capture loses the tail of long sessions; (2) redaction on the client, because the Gateway records what it is sent; (3) the MCP wiki tools includewiki_write, whichMemoryKnowledge's own MCP server does not yet expose — happy to move that there instead if preferred.Commit is DCO signed-off.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EkVfNqVBnTAHnc62NUieKj