codex-plugin-cc

其他

openai/codex-plugin-cc

在 Claude Code 中使用 Codex 进行代码审查或任务委派的插件。

项目简介

为 Claude Code 提供的插件,集成 OpenAI 的 Codex,通过斜杠命令实现代码审查、任务委派和后台作业。支持审查、对抗性审查、传输和救援工作流。

README 预览

# Codex plugin for Claude Code\n\nUse Codex from inside Claude Code for code reviews or to delegate tasks to Codex.\n\nThis plugin is for Claude Code users who want an easy way to start using Codex from the workflow\nthey already have.\n\n\n\n## What You Get\n\n- `/codex:review` for a normal read-only Codex review\n- `/codex:adversarial-review` for a steerable challenge review\n- `/codex:rescue`, `/codex:transfer`, `/codex:status`, `/codex:result`, and `/codex:cancel` to delegate work, hand off sessions, and manage background jobs\n\n## Requirements\n\n- **ChatGPT subscription (incl. Free) or OpenAI API key.**\n  - Usage will contribute to your Codex usage limits. [Learn more](https://developers.openai.com/codex/pricing).\n- **Node.js 18.18 or later**\n\n## Install\n\nAdd the marketplace in Claude Code:\n\n```bash\n/plugin marketplace add openai/codex-plugin-cc\n```\n\nInstall the plugin:\n\n```bash\n/plugin install codex@openai-codex\n```\n\nReload plugins:\n\n```bash\n/reload-plugins\n```\n\nThen run:\n\n```bash\n/codex:setup\n```\n\n`/codex:setup` will tell you whether Codex is ready. If Codex is missing and npm is available, it can offer to install Codex for you.\n\nIf you prefer to install Codex yourself, use:\n\n```bash\nnpm install -g @openai/codex\n```\n\nIf Codex is installed but not logged in yet, run:\n\n```bash\n!codex login\n```\n\nAfter install, you should see:\n\n- the slash commands listed below\n- the `codex:codex-rescue` subagent in `/agents`\n\nOne simple first run is:\n\n```bash\n/codex:review --background\n/codex:status\n/codex:result\n```\n\n## Usage\n\n### `/codex:review`\n\nRuns a normal Codex review on your current work. It gives you the same quality of code review as running `/review` inside Codex directly.\n\n> [!NOTE]\n> Code review especially for multi-file changes might take a while. It's generally recommended to run it in the background.\n\nUse it when you want:\n\n- a review of your current uncommitted changes\n- a review of your bran

常见问题 (5)

故障排除
如何修复 Codex review/adversarial-review 的 HTTP 400 错误:“gpt-5.6-sol model requires a newer version of Codex”?

当 Codex 桌面应用将 model = "gpt-5.6-sol" 写入共享的 ~/.codex/config.toml,而 npm CLI(@openai/codex 截至 0.145.0)无法使用该模型时,就会发生这种情况。review 和 adversarial-review 路径会继承此默认值并失败,即使正常的 task 轮次可能正常工作。

解决方法:

1. 在 review 调用中使用 npm CLI 支持的模型,例如:

node scripts/codex-companion.mjs review --wait --scope working-tree --model gpt-5.5

2. 如果你正在编辑插件命令模板,请将 --model gpt-5.5 放在带引号的参数块内:

review "$ARGUMENTS --model gpt-5.5"

将其作为单独的参数传递可能会导致 normalizeArgv 将该参数块视为焦点文本。

3. 或者修改 ~/.codex/config.toml 中的共享默认值:

model = "gpt-5.5"

从 npm CLI 0.142.1 升级到 0.145.0 无法解决此问题,因为目前没有任何已发布的 npm CLI 接受 gpt-5.6-sol。

来源 Issue #561
故障排除
如何修复在 Git Bash 中运行 codex-companion cancel 时出现的 taskkill "Invalid argument/option - 'C:/Program Files/Git/PID'" 错误?

Git Bash/MSYS 会将 /PID 参数转换为 Windows 路径。请将 Windows 回退方案替换为 PowerShell:powershell.exe -NoProfile -Command "Stop-Process -Id <pid> -Force"。作为临时手动解决方法,请在 PowerShell 中运行此命令。如果仍要使用 taskkill,可以在命令前添加 MSYS_NO_PATHCONV=1,或使用双斜杠对标志进行转义:MSYS_NO_PATHCONV=1 taskkill /PID <pid> /T /F 或 taskkill //PID <pid> //T //F。

来源 Issue #331
故障排除
如何修复在 Windows 上 '/codex:transfer' 报错 "did not record an imported thread",即使线程已创建的问题?

这是 Windows 上一个误报的导入后查找失败。导入本身成功,但插件无法匹配账本记录,因为账本存储的路径带有 \\?\ 扩展长度前缀,而 Node 的 realpathSync() 返回的路径不带该前缀,并且实时的 Claude 转录在导入后发生变化,导致内容哈希检查失败。临时解决方法:打开 %USERPROFILE%\.codex\external_agent_session_imports.json,找到最新的具有有效 imported_thread_id 的记录,然后运行 codex resume <imported_thread_id>。永久修复:在 scripts/lib/codex.mjs 中,更新 importedThreadIdForSource() 以规范化两个路径——去除 \\?\、将 / 转换为 \,并在 Windows 上转为小写——然后按规范化后的 source_path 和非空的 imported_thread_id 匹配记录。将 content_sha256 作为优先条件处理:如果存在最新的精确哈希匹配则使用该匹配,否则回退到该源路径的最新导入记录,而不是返回 null。已验证的受影响环境:codex@openai-codex v1.0.6、Codex CLI 0.144.2、Node v24.15.0、Windows 11。

来源 Issue #513
故障排除
在 Windows 上运行 Codex 后台任务时,如何修复 "EPERM: operation not permitted, unlink broker.pid" 错误?

将 codex-plugin-cc 升级到 v1.3.0 或更高版本。此版本将 broker 的 pid/log 文件删除改为尽力而为(best-effort),因此 Windows 上因文件被锁定或并发删除而引发的 EPERM 错误不会再中断 broker 的清理流程并导致任务失败。如果无法立即升级,请修补 plugins/codex/scripts/lib/broker-lifecycle.mjs:将两处未加保护的 fs.unlinkSync(pidFile) 和 fs.unlinkSync(logFile) 调用用 try/catch 包裹起来,忽略 EPERM 和 ENOENT(或忽略所有清理错误,与其他已加保护的清理步骤保持一致)。升级或修补后,重启 Codex 任务。

来源 Issue #633
故障排除
为什么在 Windows 的 Git Bash 中运行 `codex-companion cancel` 会失败并提示 `taskkill exit=1`?

当命令通过 $SHELL 启动时,Git Bash/MSYS 会将 /PID、/T 和 /F 等 taskkill 标志转换为 Windows 路径,导致 taskkill 收到无效参数。

**首选修复方案:**在终止进程树时,在 scripts/lib/process.mjs 中不通过 shell 直接调用 taskkill.exe:

spawnSync('taskkill.exe', ['/PID', String(pid), '/T', '/F'], {
  shell: false,
  windowsHide: true,
});

或者,将 Windows 上的 shell 选项改为始终使用 cmd.exe 而不是 process.env.SHELL:

shell: process.platform === 'win32' ? true : false

**临时解决方法:**在移除 SHELL 环境变量的情况下运行 cancel 命令:

env -u SHELL node codex-companion.mjs cancel <jobId> --json

如果是从另一个 Node 进程启动 codex-companion,请在 Windows 上从子进程环境中删除 SHELL:

const env = { ...process.env };
if (process.platform === 'win32') delete env.SHELL;

对于本地化版本的 Windows,还应将 taskkill 的退出代码 128 视为“进程未找到”来处理,而不要仅依赖英文错误消息的正则表达式。

来源 Issue #182