feat(integration): add Claude Code plugin - #1237
Conversation
|
cc @PsiACE, The content is essentially aligned with the Codex implementation, and evidence of the successful use of powercontext has been added. Pls review it when you have time. -w- )b |
Teingi
left a comment
There was a problem hiding this comment.
Requesting changes for three blocking integration issues: authenticated MCP cannot load its header helper from a normal project working directory; setup can silently ignore the requested marketplace source/ref; and failure rollback can remove a pre-existing disabled plugin. I reproduced the header-helper failure and the disabled-plugin reinstall behavior with a temporary local Claude Code plugin installation. The PR's declared 109-test selection passes, but it does not cover these runtime and state-transition paths. Concrete fixes and regression-test shapes are included inline.
|
Please resolve the merge conflicts with the latest master branch. Thanks! |
sure, i will fix them in midnight -w-)b |
|
Conflict files resolved, review fixed~ I will continue to follow up ( -w- ) b |
Which issue or RFC does this PR close?
Closes #1233.
Rationale for this change
PowerContext already provides automatic project-scoped recall for Codex, but Claude Code users cannot receive relevant context before each prompt through an official integration.
This change adds a native Claude Code plugin that reuses the existing HTTP and MCP interfaces. Runtime selection, ranking, citation, rendering, Memory, and Handoff logic remain owned by the PowerContext Server.
What changes are included in this PR?
UserPromptSubmitHook that:/v1/context/prepareat most once;additionalContext;powercontext setup claude-codeandpowercontext doctor claude-code.The v1 integration does not install a
StopHook, read Claude Code transcripts, capture assistant responses, or mark ordinary prompts astask-outcome.Are there any user-facing changes?
Yes.
Users can install and diagnose the Claude Code integration with:
After setup, Claude Code automatically recalls project context and captures user prompts as ordinary Source evidence by default. Prompt capture can be disabled with
--no-capture-promptsorPOWERCONTEXT_CLAUDE_CAPTURE_PROMPTS=false.Claude Code and Codex share Memory when they resolve the same Git project scope. Authentication is configured through
POWERCONTEXT_CLAUDE_AUTHORIZATION.There are no breaking HTTP API, MCP API, or persisted-format changes.
How was this change tested?
Evidence
Test the current branch:
uv tool install --force \ "powercontext[cli,server] @ git+https://github.com/XnLemon/powercontext.git@feat/claude-code-integration" powercontext setup claude-code \ --source XnLemon/powercontext \ --ref feat/claude-code-integrationThen start the Server:
In another terminal, run:
In Claude Code, check
/hooksand/mcpto confirm that the PowerContext Hook and MCP Server are active.Automated validation:
Result:
109 passed.Additional validation:
prek run -a ty check zensical build -s claude plugin validate --strict . claude plugin validate --strict integrations/claude-code/plugins/powercontextAll commands passed.
Manual validation covered:
setupand bothdoctorcommands;/hooksand/mcp;A full
python -m pytest --doctest-modulesrun reported508 passed, 7 skipped, 2 failed. One failure is an unchanged LoCoMo fixture hash mismatch. The other was a provider-readiness timeout that passed when rerun independently. Neither failure touches this integration.AI usage statement
OpenAI Codex 5.6 Sol xhigh was used for repository analysis, implementation support, test and documentation authoring, and validation. The resulting changes were reviewed, and the CLI integration was manually validated end to end by the author.
中文
该 PR 关闭哪个 Issue 或 RFC?
Closes #1233。
修改原因
PowerContext 已经为 Codex 提供项目级自动上下文召回,但 Claude Code 用户还无法通过官方集成,在处理每条 prompt 前获得相关上下文。
该修改增加原生 Claude Code 插件,并复用现有 HTTP 和 MCP 接口。选择、排序、引用、渲染、Memory 和 Handoff 逻辑仍由 PowerContext Server 负责。
该 PR 包含哪些修改?
UserPromptSubmitHook:/v1/context/prepare;additionalContext注入;powercontext setup claude-code和powercontext doctor claude-code。v1 不安装
StopHook,不读取 Claude Code transcript,不采集助手回复,也不把普通 prompt 标记为task-outcome。是否存在用户可见修改?
是。
用户可以通过以下命令安装和诊断 Claude Code 集成:
setup 完成后,Claude Code 默认自动召回项目上下文,并把用户 prompt 采集为普通 Source 证据。可以通过
--no-capture-prompts或POWERCONTEXT_CLAUDE_CAPTURE_PROMPTS=false禁用采集。Claude Code 和 Codex 解析到同一个 Git 项目 scope 时,会共享 Memory。认证通过
POWERCONTEXT_CLAUDE_AUTHORIZATION配置。该修改不包含破坏性的 HTTP API、MCP API 或持久化格式变更。
如何测试该修改?
证据
使用当前分支测试:
uv tool install --force \ "powercontext[cli,server] @ git+https://github.com/XnLemon/powercontext.git@feat/claude-code-integration" powercontext setup claude-code \ --source XnLemon/powercontext \ --ref feat/claude-code-integration然后启动并检查:
另一个终端:
在 Claude Code 中检查 /hooks 和 /mcp。
自动化验证:
结果:
109 passed。其他验证:
prek run -a ty check zensical build -s claude plugin validate --strict . claude plugin validate --strict integrations/claude-code/plugins/powercontext以上命令全部通过。
手动验证覆盖:
/hooks与/mcp中确认 PowerContext;完整执行
python -m pytest --doctest-modules时结果为508 passed, 7 skipped, 2 failed。一个失败来自未修改的 LoCoMo fixture 哈希不一致;另一个是 provider readiness timeout,单独重跑已通过。两者均不涉及本集成。AI 使用声明
使用了 OpenAI Codex 进行仓库分析、辅助实现、测试与文档编写以及验证。最终修改经过人工审阅,并由作者完成 CLI 集成的端到端手动验证。