mcpField
P
patch-codex-fast

patch-codex-fast

github.com/yangchuansheng开发33239 次安装24 周前更新
代码仓库

关于 patch-codex-fast

用于修改本地 Codex 桌面应用的技能,面向使用 API key 登录并需要启用 Fast 模式、Plugins 或 Zed 远程打开的用户。它通过脚本执行补丁,并包含检查、验证与回滚流程。

主要功能

  1. 01为 API key 模式启用 Fast 与 Plugins
  2. 02为远程会话添加 Zed 打开支持
  3. 03提供环境检查与补丁脚本
  4. 04提供补丁回滚流程
  5. 05更新后可重新检查并应用补丁

适用场景

  1. 01在 API key 模式下使用 Fast 模式
  2. 02在 API key 模式下使用 Plugins
  3. 03从 Codex 远程会话用 Zed 打开文件
  4. 04补丁失败或应用异常时回滚

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/yangchuansheng/patch-codex-fast --skill patch-codex-fast

安装后在 Claude Code 中输入/patch-codex-fast确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
README.md
SECURITY.md
scripts/
macos-patch.sh
macos-rollback.sh
patch_codex_fast.py
windows-patch.ps1
windows-rollback.ps1
scripts/codex_fast_patch/
__init__.py
app.py
bundle.py
chrome.py
cli.py
patterns.py
zed_remote.py

详细介绍

Patch Codex Fast

当用户希望在使用 API 密钥而非 ChatGPT OAuth 登录运行 Codex 时启用 Codex 桌面版的 Fast/Speed 模式或插件,请使用此技能。当用户询问 Codex 远程 SSH 会话能否在 Zed 中打开文件,或希望修补 Codex 以便用 Zed 打开远程文件时,也请使用此技能。

通过 npx skills 安装或手动创建符号链接后,此技能是主要接口。不要让用户从 README 复制冗长的 shell 代码片段。请将此仓库中的脚本用作执行工具,根据当前操作系统运行正确的命令,然后报告结果和验证步骤。

这是一个非官方的本地补丁。在修改应用前,请确保用户了解此操作会修改已安装的 Codex 桌面版程序包、禁用选定的 Electron 完整性熔断器,并且在 Codex 更新后可能需要重新应用。

意图

用户应该可以这样说:

[$patch-codex-fast] Patch my local Codex app so Fast mode and Plugins work in API key mode.

然后 Agent 应端到端执行工作流,而不是回复手动操作步骤。以下脚本命令供 Agent 运行,不应让用户将其作为主要操作方式复制执行。

工作流

  1. 确定包含此 SKILL.md 的仓库根目录。
  2. 使用仓库脚本运行 doctor 检查。
  3. 如果环境有效,运行适用于当前操作系统的补丁脚本。
  4. 阅读完整命令输出并报告:
    • 是否已应用补丁操作;
    • 任何警告;
    • 准确的回滚命令。
  5. 请用户完全退出并重新打开 Codex,然后验证:
    • API 密钥模式下是否显示 Fast/Speed 模式;
    • API 密钥模式下是否显示 Plugins 侧边栏;
    • 插件安装流程是否不再将所有连接器标记为不可用;
    • Computer Use 设置中是否仍显示 Google Chrome 插件行。
  6. 如果 Codex 无法启动,或用户报告状态异常,请立即运行回滚。

仅针对 Zed 远程打开补丁:

  1. 运行 doctor 或 zed-remote-status。
  2. 如果环境有效,运行 patch-zed-remote。
  3. 阅读完整输出,并报告 Zed 目标是否标记为 supportsSsh,以及是否已插入远程 URL 辅助程序。
  4. 请用户完全退出并重新打开 Codex,然后验证远程 Codex 文件的“打开方式”中是否显示 Zed,以及能否在 Zed Remote Development 中打开。
  5. 如果 Codex 无法启动,或用户报告状态异常,请立即运行回滚。

命令

优先使用跨平台的 Python 入口点:

python3 scripts/patch_codex_fast.py doctor
python3 scripts/patch_codex_fast.py patch
python3 scripts/patch_codex_fast.py patch-zed-remote
python3 scripts/patch_codex_fast.py zed-remote-status
python3 scripts/patch_codex_fast.py rollback

在 Windows 上,如果没有 python3,请使用 python:

python .\scripts\patch_codex_fast.py doctor
python .\scripts\patch_codex_fast.py patch
python .\scripts\patch_codex_fast.py patch-zed-remote
python .\scripts\patch_codex_fast.py zed-remote-status
python .\scripts\patch_codex_fast.py rollback

也提供了包装脚本:

./scripts/macos-patch.sh
./scripts/macos-rollback.sh
.\scripts\windows-patch.ps1
.\scripts\windows-rollback.ps1

默认路径

macOS:

  • 资源目录:/Applications/Codex.app/Contents/Resources
  • 应用路径:/Applications/Codex.app

Windows:

  • 资源目录:%LOCALAPPDATA%\Programs\Codex\resources
  • 应用路径:%LOCALAPPDATA%\Programs\Codex\Codex.exe

如果 Codex 安装在其他位置,请将 --resources-dir 和 --app-path 传递给 Python 命令。

回滚策略

回滚是此技能的一部分,不可事后再考虑。如果补丁操作在更改文件后失败,或应用无法启动,请运行:

python3 scripts/patch_codex_fast.py rollback

在 Windows 上:

python .\scripts\patch_codex_fast.py rollback

回滚脚本必须先恢复 app.asar,再删除 app/,随后恢复 Electron 原始熔断器,并在 macOS 上重新签名。如果 macOS 因 Operation not permitted 而阻止在 /Applications/Codex.app 内写入,请先停止,不要删除 app/;授予“应用程序管理”权限,或将应用程序包移至其他位置再复制回来,然后恢复 app.asar 并重新签名。

Bundle 更新处理

Codex 更新时,bundle 哈希和压缩后的变量名可能会发生变化。先正常重新运行此 skill。如果脚本报告 No patches were applied,请使用以下搜索命令检查提取出的 app/webview/assets 目录:

grep -rl "authMethod" *.js | xargs grep -l "fast_mode"
grep -rl "pluginsDisabledTooltip" *.js
# Gate exported from gradient-*.js. Two known variants live in the wild:
#   older builds: function e(e){return e===`apikey`}
#   newer builds: function e(e){return e!==`chatgpt`}
# Both should be rewritten to `return false`.
grep -rlE 'return [A-Za-z_$]+(===|!==)`(apikey|chatgpt)`' *.js | grep -v locale
grep -rl "connector-unavailable" *.js | grep plugin

如果自动模式不再匹配,请按照 README 中描述的相同逻辑门进行修补。同时检查以下应用 bundle 位置,确保 Chrome 不受影响:

grep -rl "chrome-internal" app/.vite/build
grep -rl "externalBrowserUseAllowed" app/.vite/build
grep -rl "isExternalBrowserUseAvailable" app/webview/assets

当前修复会将 Dev runtime 的 Chrome 插件名称从 chrome-internal 映射为 chrome,避免外部浏览器功能门丢弃 Chrome 市场描述符,并防止渲染器插件列表在 isExternalBrowserUseAvailable 为 false 时隐藏 Chrome。

如需支持 Zed 远程打开,请检查主进程的打开目标 bundle:

grep -rl "id:\`zed\`" app/.vite/build
grep -rl "supportsSsh" app/.vite/build
grep -rl "vscode-remote://" app/.vite/build

Zed 补丁会保持 Zed 的本地行为不变,将 Zed 标记为支持 Codex 远程会话的 SSH,并将 Codex 传入的远程路径转换为 Zed 远程开发 URL,例如 ssh://user@host[:port]/path。优先使用 Codex 结构化的 SSH 配置字段,而不是显示别名,以免 Zed 回退到错误的本地 macOS 用户名。

成功标准

任务只有在 Agent 提供了修补或回滚路径的命令证据,并准确告知用户需要在 Codex UI 中验证哪些内容后才算完成:Fast/Plugins 补丁需验证 Computer Use 下的 Google Chrome 行,Zed 远程补丁需验证远程 Open With → Zed 流程。

评论

支持 Markdown