codex-with-chatgpt
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodex with ChatGPT
Codex with ChatGPT
ChatGPT thinks. Codex works.
You (Codex) own execution: editing, shell, git, tests, recovery.
ChatGPT owns high-level reasoning: understanding, planning, review, debug strategy.
The C2C Bridge gives ChatGPT read-only MCP access to the current workspace, so
control messages between you and ChatGPT stay tiny (< 1 KB) — ChatGPT pulls
whatever data it needs by itself.
Golden rules
- NEVER paste file contents, diffs, or logs into ChatGPT. ChatGPT reads them through MCP.
- NEVER show the user technical internals (MCP, OAuth, PKCE, tunnel, ports, localhost). Speak in terms of "连接 ChatGPT / 安全连接 / 配对". The only exception is the guided manual ChatGPT setup below: expose only the exact settings field labels/values the user must enter, without explaining internals.
- The pairing code is the ONLY credential you may ever type into a browser. Never touch OAuth tokens, cookies, or session storage.
- If something fails, run and repair silently. Only involve the user for logins, CAPTCHA, 2FA, explicit consent screens, or guided manual ChatGPT setup below — and then give them ONE action. Before the first ChatGPT connection on this machine,
c2c doctor:c2c prefs --json- missing: tell the user exactly
setupMode, wait for 「1」or「2」, thensetupChoicePrompt. Do not start ChatGPT configuration until they answer. Do not guess.c2c prefs set --setup-mode auto|manual --json - is
setupMode: skip automatic ChatGPT settings. Use guided manual from the start (chosen, not a failure).manual - is
setupMode: automatic browser setup. Two explicit failures of the same configuration step after repair then enter guided manual. A browser/js timeout, a page still loading/generating, or waiting for user login/2FA does NOT count as a failure. Do not change the savedautowhen falling back.setupModemeans skipdeveloperModeEnabled: trueuntil a connector create fails because developer mode is required. Then open that page, enable it, and#settings/Security. These prefs are for this machine, not per workspace. Do not ask again on reconnect or a second repo. A new computer (empty prefs) asks/checks once.c2c prefs set --developer-mode --json
- ALWAYS use the built-in in-app browser (iab) for every ChatGPT step.
Follow In-app browser (ChatGPT) below. NEVER Computer Use (no
screenshot-click). NEVER launch or control a third-party/external browser
(Chrome, Safari, Edge…), and never use to hand off to one.
open <url>- The ONLY exception: the user explicitly says the Cloudflare login must use their own browser session — that single Cloudflare login step may go through their browser; everything else stays in the built-in browser.
- If the user asks to run ChatGPT in their own browser, refuse politely and explain: "Codex 需要持续调用 ChatGPT 和配置连接,这会频繁操作页面,可能影响 你浏览器的正常使用。ChatGPT 只能跑在内置浏览器里。" Only if the user replies with an explicit "我愿意承担影响" may you proceed in their browser; otherwise keep ChatGPT in the built-in browser, every time they ask.
- Conversation reuse depends on →
c2c session --json(see Conversation management). Do not invent a second mode.conversation.mode- long-chat (legacy session file, or the user opted out): ONE ChatGPT conversation per workspace. Never silently start a new chat.
- project (new workspaces, or an existing workspace that opted in):
ONE ChatGPT Project (collection) per workspace. Same Codex conversation
reuses the ChatGPT chat URL saved in THIS thread. A new Codex
conversation opens a new chat from the Project collection page — never
gototo create it, and never reuse another Codex conversation's chat URL just becausehttps://chatgpt.com/exists. Each workspace also has exactly ONE ChatGPT connector. Do not create a second connector for the same workspace. Other workspaces may have their own connectors — never edit those.session.url
- After first-time setup, never ask the user to approve writing C2C's local
settings directory. Run (idempotent). If it fails with EPERM / Operation not permitted, request elevated permissions and retry ONCE. After
c2c sandbox-allow --jsonor{ "alreadyAllowed": true }, stay silent.{ "added": true } - ChatGPT pages: only the URLs in In-app browser (ChatGPT). Never start from chatgpt.com and click through menus.
- Doctor gate. After , do not
c2c doctor --jsonChatGPT and do not sendgotountil local is green — except the reconnect settings pages when[C2C]is true. Not green:chatgptRepair.needed- is not true
report.bridge.ok - is not true (unauthenticated local
report.mcp.okmust be 401)/mcp - sandbox / state-dir write failed (EPERM)
- this workspace used to have a public URL and the tunnel is down
- is true (fix the connector first, then doctor again)
chatgptRepair.needed - is true (user must log in to Cloudflare, then doctor again. Do not Delete the ChatGPT connector — the address did not change)
namedRepair.needed - says 状态无法确认: the local bridge may still be running. Do not
report.bridge, do not Delete the connector, do not treat it asc2c start. Wait and run doctor again. A ChatGPT-side 401 after a sent message is different: repair then, do not treat it as permission to skip this gate next time.chatgptRepair
ChatGPT负责思考,Codex负责执行。
你(Codex)掌握执行权:负责编辑、shell操作、git、测试、故障恢复。
ChatGPT负责高层推理:需求理解、方案规划、代码评审、调试策略制定。
C2C桥接器为ChatGPT提供当前工作区的只读MCP访问权限,因此你和ChatGPT之间的控制消息非常小(小于1KB)——ChatGPT会自行拉取所需的所有数据。
黄金法则
- 绝对不要将文件内容、diff或日志粘贴到ChatGPT中。ChatGPT会通过MCP读取这些内容。
- 绝对不要向用户展示技术内部细节(MCP、OAuth、PKCE、tunnel、端口、localhost)。使用「连接 ChatGPT / 安全连接 / 配对」这类表述。唯一的例外是下方的ChatGPT手动引导配置:仅展示用户必须输入的准确设置字段标签/值,不要解释内部原理。
- 配对码是你唯一可以输入到浏览器中的凭证。绝对不要操作OAuth令牌、cookie或会话存储。
- 如果出现故障,运行并静默修复。仅在登录、CAPTCHA、2FA、明确的同意页面,或下方的ChatGPT手动引导配置时才需要用户参与——且每次只让用户执行一个操作。 在本机首次连接ChatGPT之前,执行
c2c doctor:c2c prefs --json- 若缺失:准确告知用户
setupMode的内容,等待用户输入「1」或「2」,然后执行setupChoicePrompt。在用户回复前不要启动ChatGPT配置,不要自行猜测。c2c prefs set --setup-mode auto|manual --json - 若为
setupMode:跳过自动ChatGPT设置,从一开始就使用手动引导配置(是用户主动选择的,而非故障降级)。manual - 若为
setupMode:使用自动浏览器配置。若同一配置步骤在修复后仍明确失败两次,则进入手动引导配置。浏览器/JS超时、页面仍在加载/生成中、或等待用户登录/2FA都不算失败。降级时不要修改已保存的auto。setupMode表示跳过developerModeEnabled: true页面,直到连接器创建因需要开发人员模式而失败时,再打开该页面启用开发人员模式,并执行#settings/Security。 这些偏好设置是本机级别的,不是按工作区划分的。重新连接或打开第二个仓库时不要再次询问。新电脑(偏好设置为空)只需询问/检查一次。c2c prefs set --developer-mode --json
- 若
- 所有ChatGPT相关步骤都必须使用内置应用内浏览器(iab)。遵循下方的**应用内浏览器(ChatGPT)**规范。绝对不要使用Computer Use(不得通过截图点击操作)。绝对不要启动或控制第三方/外部浏览器(Chrome、Safari、Edge等),也不要使用将操作转交外部浏览器。
open <url>- 唯一的例外:如果用户明确表示Cloudflare登录必须使用他们自己的浏览器会话——则仅这一步Cloudflare登录可以通过用户的浏览器完成,其余所有操作仍在内置浏览器中进行。
- 如果用户要求在他们自己的浏览器中运行ChatGPT,礼貌拒绝并解释:「Codex 需要持续调用 ChatGPT 和配置连接,这会频繁操作页面,可能影响你浏览器的正常使用。ChatGPT 只能跑在内置浏览器里。」只有当用户明确回复「我愿意承担影响」时,才可以在用户的浏览器中继续操作;否则每次用户提出要求时,都应坚持将ChatGPT保留在内置浏览器中。
- 会话复用取决于返回的
c2c session --json(参见「会话管理」)。不要自行发明第二种模式。conversation.mode- long-chat(旧版会话文件,或用户选择退出新模式):每个工作区对应一个ChatGPT对话。绝对不要静默开启新对话。
- project(新工作区,或已选择加入新模式的现有工作区):每个工作区对应一个ChatGPT Project(合集)。同一个Codex对话会复用保存在本线程中的ChatGPT对话URL。新的Codex对话会从Project合集页面打开新对话——绝对不要通过
goto来创建对话,也不要仅仅因为https://chatgpt.com/存在就复用其他Codex对话的对话URL。 每个工作区也只能有一个ChatGPT连接器。不要为同一个工作区创建第二个连接器。其他工作区可以有自己的连接器——绝对不要编辑它们。session.url
- 首次设置完成后,永远不要要求用户批准写入C2C的本地设置目录。运行(幂等操作)。如果因EPERM / 操作不允许失败,请求提升权限并重试一次。在返回
c2c sandbox-allow --json或{ "alreadyAllowed": true }后,保持静默即可。{ "added": true } - ChatGPT页面:仅使用**应用内浏览器(ChatGPT)**中列出的URL。永远不要从chatgpt.com开始并通过菜单点击导航。
- Doctor门禁。执行后,在本地状态变为绿色之前,不要
c2c doctor --jsonChatGPT,也不要发送goto消息——除非[C2C]为true时的重连设置页面。出现以下情况表示状态未达标(非绿色):chatgptRepair.needed- 不为true
report.bridge.ok - 不为true(未认证的本地
report.mcp.ok请求必须返回401)/mcp - 沙箱/状态目录写入失败(EPERM)
- 该工作区之前有公共URL但tunnel已断开
- 为true(先修复连接器,再重新执行doctor)
chatgptRepair.needed - 为true(用户必须登录Cloudflare,然后重新执行doctor。不要删除ChatGPT连接器——地址没有变化)
namedRepair.needed - 显示状态无法确认:本地桥接器可能仍在运行。不要执行
report.bridge,不要删除连接器,也不要将其视为c2c start。等待后重新运行doctor。 发送消息后ChatGPT端返回401的情况不同:此时需要修复,但不要将其视为下次可以跳过该门禁的许可。chatgptRepair
In-app browser (ChatGPT)
应用内浏览器(ChatGPT)
Official skill: . These C2C rules override defaults
that close the tab, hide the window, or stall on the settings page.
control-in-app-browser-
Surface. Once per Codex session:, then
setupBrowserRuntime(). Reuseconst iab = await agent.browsers.get("iab"). Do not re-readiabif it is already bound. Neverdocumentation(),getDefault(), or Computer Use.getForUrl() -
One tab. Create the ChatGPT tab once (). After that, only
tabs.new()to switch URLs. If the tab still exists, claim it — never open a second ChatGPT tab. Do nottab.goto(...)the URL you are already on.goto -
Foreground + keep (standby). Right after opening or claiming the tab:
- — first-time setup and ChatGPT chatting stay in front of the user so they can watch.
await (await iab.capabilities.get("visibility")).set(true) - immediately, then again at the start and end of every turn. After setup succeeds or the C2C chat is open, also
await tab.markHandoff(). Never close this tab. Finished, waiting for the user, or timed out: leave it marked (standby). Do not let default turn cleanup close it.await tab.markDeliverable()
-
URLs only (same tab,— never hunt menus):
goto- 开发人员模式: (skip when
https://chatgpt.com/#settings/Securityhasc2c prefs --json)developerModeEnabled: true - 插件总管:
https://chatgpt.com/plugins - 加插件:
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins - 新对话 (long-chat only, and only if no saved chat):
https://chatgpt.com/ - Saved C2C chat: /
conversation.chatUrl(long-chat, or the chat already bound in THIS Codex conversation)session.url - Saved Project collection: (
conversation.projectUrl) Never click Reconnect / Refresh on an existing connector. The old address is dead and that page hangs on "This site cannot be reached". When the address changed: Delete THIS workspace'shttps://chatgpt.com/g/g-p-…/projectonly, then create it again via the 加插件 URL (same name, new Server URL). Do not put that public address into Project instructions — write the connector name only.connectorName
- 开发人员模式:
-
Do not wait for 8 tools on the settings page. "Connected" / authorize success / pairing accepted is enough. Confirm tools in the conversation with.
workspace_info -
Batch. Fill a known form in one Playwright /script when you can. After an action, one cheap DOM check. Do not screenshot-poll.
js -
One conversation, Chat mode. The first ChatGPT chat is the C2C conversation. Chat and Work (聊天 / 工作) are separate: a Work conversation cannot become Chat. On every NEW conversation, if a Chat/Work switcher is visible (often top-left), confirm Chat is selected before the boot prompt. If it is Work, do not continue there — Switch to a new Chat conversation (HANDOFF). If no switcher is visible, do not hunt menus; continue. Send the boot prompt and the workspace_info check in that Chat conversation. Confirm the reply names the current workspace before saving or replacing the session URL. If validation fails, keep the old saved URL. Do not open a throwaway verify chat and later another C2C chat.
-
Wait for a ChatGPT reply (do not hold one long browser wait). After you send INIT, EXECUTED, boot, or the workspace_info check:, keep the tab foreground, and stay in this same task. Do not
markHandoff5 minutes and do not screenshot-poll. Every 20–30 seconds, one cheap DOM check:waitFor- still generating → wait again (do not type, do not resend);
- /
STATE: PLAN/DONE/ the verify workspace name → read it and continue the existing protocol;BLOCKED - visible error → repair; do not start a new chat. A browser/js timeout is not failure. Claim the same tab, read the page, keep standby. If ChatGPT is still thinking, keep polling. Never open a second tab and never resend INIT/EXECUTED just because a wait timed out.
官方技能:。以下C2C规则会覆盖默认行为(默认会关闭标签页、隐藏窗口,或在设置页面停滞)。
control-in-app-browser-
表层操作。每个Codex会话执行一次:,然后执行
setupBrowserRuntime()。复用const iab = await agent.browsers.get("iab")实例。如果iab已经绑定,不要重新读取。绝对不要使用documentation()、getDefault()或Computer Use。getForUrl() -
单标签页。仅创建一次ChatGPT标签页()。之后仅通过
tabs.new()切换URL。如果标签页仍存在,就复用它——绝对不要打开第二个ChatGPT标签页。不要tab.goto(...)当前已经在打开的URL。goto -
前台显示 + 保持(待机)。打开或复用标签页后立即执行:
- —— 首次设置和ChatGPT对话期间保持在用户前台,方便用户查看。
await (await iab.capabilities.get("visibility")).set(true) - 立即执行,之后在每一轮的开始和结束都执行一次。设置成功或C2C对话打开后,还要执行
await tab.markHandoff()。 绝对不要关闭这个标签页。任务完成、等待用户或超时的时候:保持标记状态(待机)。不要让默认的回合清理逻辑关闭它。await tab.markDeliverable()
-
仅使用指定URL(同一标签页,用跳转——绝对不要在菜单里找):
goto- 开发人员模式: (当
https://chatgpt.com/#settings/Security返回c2c prefs --json时跳过)developerModeEnabled: true - 插件总管:
https://chatgpt.com/plugins - 加插件:
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins - 新对话(仅long-chat模式,且没有保存的对话时使用):
https://chatgpt.com/ - 已保存的C2C对话: /
conversation.chatUrl(long-chat模式,或本Codex对话中已绑定的对话)session.url - 已保存的Project合集: (格式为
conversation.projectUrl) 绝对不要在现有连接器上点击重新连接/刷新。旧地址已经失效,页面会一直卡在「无法访问此网站」。当地址变更时:仅删除本工作区的https://chatgpt.com/g/g-p-…/project,然后通过加插件URL重新创建(同名,新的服务器URL)。不要将公共地址写入Project指令中——只写连接器的名称。connectorName
- 开发人员模式:
-
不要在设置页面等待8个工具加载完成。显示「已连接」/授权成功/配对接受就足够了。在对话中通过确认工具是否可用。
workspace_info -
批量操作。尽可能用一个Playwright /脚本填充已知表单。执行操作后,做一次轻量的DOM检查。不要通过截图轮询。
js -
单对话,Chat模式。第一个ChatGPT对话就是C2C对话。聊天和工作(聊天 / 工作)是分开的:工作对话不能转为聊天对话。每次新建对话时,如果能看到聊天/工作切换器(通常在左上角),在发送启动提示前确认已选中聊天模式。如果是工作模式,不要在那里继续——切换到新的聊天对话(HANDOFF)。如果看不到切换器,不要在菜单里找,直接继续。 在该聊天对话中发送启动提示和workspace_info检查。在保存或替换会话URL之前,确认回复中提到了当前工作区的名称。如果验证失败,保留旧的已保存URL。不要打开一个临时的验证对话,之后再开另一个C2C对话。
-
等待ChatGPT回复(不要长时间阻塞浏览器等待)。发送INIT、EXECUTED、启动提示或workspace_info检查后:执行,保持标签页在前台,继续在同一任务中运行。不要
markHandoff5分钟,也不要截图轮询。每20-30秒做一次轻量DOM检查:waitFor- 仍在生成中 → 继续等待(不要输入,不要重发);
- 出现/
STATE: PLAN/DONE/ 验证工作区名称的内容 → 读取内容并继续现有协议流程;BLOCKED - 出现可见错误 → 修复;不要开启新对话。 浏览器/JS超时不是失败。复用同一个标签页,读取页面内容,保持待机状态。如果ChatGPT仍在思考,继续轮询。绝对不要打开第二个标签页,也不要仅仅因为等待超时就重发INIT/EXECUTED。
Locations
位置说明
- The codex-with-chatgpt checkout lives at: (installer/update MUST replace this line in the installed Skill with the user's actual checkout path.)
<ACTUAL_CHECKOUT_PATH> - CLI: let mean the path on the previous line; run
<checkout>(ornode "<checkout>/bin/c2c.js" <command>if globally linked). All commands supportc2c <command>for parsing.--json - If the checkout has no or no
node_modules, first rundist/inside it.corepack pnpm install && corepack pnpm build - Always pass (the project the user is working on, NOT the c2c repo).
-w <workspace root>
- codex-with-chatgpt的检出路径为:(安装程序/更新程序必须将已安装技能中的这一行替换为用户的实际检出路径。)
<ACTUAL_CHECKOUT_PATH> - CLI:代表上一行的路径;运行
<checkout>(如果全局链接了的话可以直接用node "<checkout>/bin/c2c.js" <command>)。所有命令都支持c2c <command>参数以便解析。--json - 如果检出目录中没有或
node_modules,先在该目录内运行dist/。corepack pnpm install && corepack pnpm build - 始终传入(这是用户正在处理的项目,不是c2c仓库本身)。
-w <workspace root>
Daily update check
每日更新检查
At the START of every workflow below (before anything else), run these two
commands (both are cheap / cached; never mention them unless an update exists):
c2c update-check --json- — writes the C2C state directory into Codex's sandbox
c2c sandbox-allow --json(macOS:writable_roots; Windows:~/Library/Application Support/codex-with-chatgpt; config file is%LOCALAPPDATA%\codex-with-chatgpton both, or~/.codex/config.tomlon Windows). If already allowlisted, this is a no-op and does not trigger elevation.%USERPROFILE%\.codex\config.toml
- → continue silently. Never mention the check.
{ "updateAvailable": false } - → tell the user one line: "检测到 Codex with ChatGPT 有新版本,我先更新一下(约 1 分钟),随后继续你的任务。" Then run the update workflow below, and CONTINUE the original task afterwards.
{ "updateAvailable": true }
在以下每个工作流的开始阶段(在做任何其他事之前),运行这两个命令(两者都是轻量/缓存操作;除非有更新,否则绝对不要向用户提及):
c2c update-check --json- —— 将C2C状态目录写入Codex的沙箱
c2c sandbox-allow --json中(macOS路径:writable_roots;Windows路径:~/Library/Application Support/codex-with-chatgpt;两个系统的配置文件都在%LOCALAPPDATA%\codex-with-chatgpt,Windows下也可以是~/.codex/config.toml)。如果已经在白名单中,该操作是空操作,不会触发权限提升请求。%USERPROFILE%\.codex\config.toml
- → 静默继续,绝对不要提及检查操作。
{ "updateAvailable": false } - → 告知用户一行内容:「检测到 Codex with ChatGPT 有新版本,我先更新一下(约 1 分钟),随后继续你的任务。」然后运行下方的更新工作流,完成后继续执行原始任务。
{ "updateAvailable": true }
Workflow: update("更新 Codex with ChatGPT",or triggered by the daily check)
工作流:更新(「更新 Codex with ChatGPT」,或由每日检查触发)
Inside the checkout directory (see Locations):
- (if it fails due to local edits:
git pull --ff-only).git stash && git pull --ff-only - .
corepack pnpm install && corepack pnpm build - Re-install the Skill: copy to
skill/SKILL.md, then fix the "checkout lives at:" line in the copy to the actual checkout path.~/.codex/skills/codex-with-chatgpt/SKILL.md - (so existing installs pick up the sandbox allowlist), then
c2c sandbox-allow --jsonso the bridge runs the new code, thenc2c restart -w <workspace>to refresh the cache (should now report up to date).c2c update-check --force --json - Tell the user "✓ 已更新到最新版本" — then resume whatever task triggered this. (The updated SKILL.md takes effect from the next Codex session; that's expected.)
在检出目录内执行(参见「位置说明」):
- (如果因本地修改失败:执行
git pull --ff-only)。git stash && git pull --ff-only - 。
corepack pnpm install && corepack pnpm build - 重新安装技能:将复制到
skill/SKILL.md,然后修改副本中「checkout lives at:」那一行的内容为实际检出路径。~/.codex/skills/codex-with-chatgpt/SKILL.md - (让现有安装获取沙箱白名单),然后执行
c2c sandbox-allow --json让桥接器运行新代码,再执行c2c restart -w <workspace>刷新缓存(此时应该显示已是最新版本)。c2c update-check --force --json - 告知用户「✓ 已更新到最新版本」——然后继续执行触发更新的任务。 (更新后的SKILL.md将在下一个Codex会话中生效;这是预期行为。)
Connection choice (once per workspace)
连接方式选择(每个工作区一次)
Ask this before the public address exists ( / first
that starts a tunnel). Do not mention tunnels, wrangler, DNS, or hostnames.
Speak only of 临时地址 / 固定域名 / 登录 Cloudflare.
c2c setupdoctor --fixc2c tunnel status -w <workspace> --json- If is false: do not ask again.
needsChoice - If is true: tell the user exactly
needsChoiceand wait.userPrompt- 没有账号 / 没有域名 / 临时 / 不用 →
c2c tunnel choose -w <ws> --mode quick --json - 有域名(例如 example.com)→ first tell them , then
loginPrompt. This may open the user's own browser (the Cloudflare exception in Golden rule 5). Wait until the command finishes. If they said they have an account but gave no domain: ask once for the domain. If the command returnsc2c tunnel choose -w <ws> --mode named --zone <domain> --json, ask once and retry. Ifneed: "zone"is true: tell themfallbackand continue on the temporary address. Do not retry named unless they ask.userMessage
- 没有账号 / 没有域名 / 临时 / 不用 →
- Never put connection credentials in the project. The CLI stores them in the C2C state directory.
在公共地址存在之前询问用户( / 首次启动tunnel的之前)。不要提及tunnel、wrangler、DNS或主机名。只使用「临时地址 / 固定域名 / 登录 Cloudflare」这类表述。
c2c setupdoctor --fixc2c tunnel status -w <workspace> --json- 如果为false:不要再询问。
needsChoice - 如果为true:准确告知用户
needsChoice的内容并等待。userPrompt- 用户选择「没有账号 / 没有域名 / 临时 / 不用」→
c2c tunnel choose -w <ws> --mode quick --json - 用户选择「有域名(例如 example.com)」→ 先告知用户的内容,然后执行
loginPrompt。这可能会打开用户自己的浏览器(黄金法则5中的Cloudflare例外情况)。等待命令执行完成。 如果用户说有账号但没有提供域名:询问一次域名。如果命令返回c2c tunnel choose -w <ws> --mode named --zone <domain> --json,询问一次后重试。 如果need: "zone"为true:告知用户fallback的内容,然后继续使用临时地址。除非用户要求,否则不要重试named模式。userMessage
- 用户选择「没有账号 / 没有域名 / 临时 / 不用」→
- 绝对不要将连接凭证存入项目中。CLI会将其存储在C2C状态目录里。
Workflow: first-time setup("使用 Codex with ChatGPT 完成首次配置")
工作流:首次设置(「使用 Codex with ChatGPT 完成首次配置」)
- Detect prerequisites yourself: (>= 20), and check
node --version.cloudflared- If cloudflared is missing on macOS run ; on Windows use
brew install cloudflared. Do this yourself; don't ask.winget install Cloudflare.cloudflared
- If cloudflared is missing on macOS run
- If the c2c repo has no , run
node_modulesin it.pnpm install && pnpm build - Run , then Connection choice, then
c2c sandbox-allow --json.c2c setup -w <workspace> --jsonedits Codexsandbox-allowonly — it adds C2C's state directory toconfig.tomlso later chats can write logs without elevation. If the write is denied, request approval and retry once. → returns[sandbox_workspace_write].writable_roots.{ mcpUrl, pairingCode, workspaceName, connectorName, ... }is this workspace's plugin title (legacy installs stayconnectorName; additional workspaces getCodex with ChatGPT). Pairing codes expire in ~5 minutes: runCodex with ChatGPT · <name>for a fresh one if you're slow.c2c pair --json - (this machine, not this workspace).
c2c prefs --json- If is null: tell the user exactly
setupMode. Wait for「1」or「2」. ThensetupChoicePromptorc2c prefs set --setup-mode auto. Do not open ChatGPT settings and do not start automatic configuration until they answer. Do not default to auto.--setup-mode manual - If they later ask to switch: same command. Do not re-ask on a later workspace or on reconnect.
c2c prefs set --setup-mode - : skip step 5's automatic ChatGPT settings. Go to Guided manual ChatGPT setup (chosen). Opening line:
setupMode: "manual"Do not say 自动配置没有成功.接下来用手动教学配置。一次只需要做一个操作。 - : continue with step 5. Keep the two-failure fallback.
setupMode: "auto"
- If
- Open ChatGPT on the ONE iab tab (see In-app browser). Foreground +
markHandoff immediately. Same tab, only:
goto- 开发人员模式: skip when
https://chatgpt.com/#settings/Securityis true. Otherwise open it, enable 开发人员模式 ("Developer mode") if it is off, thendeveloperModeEnabled. Never record it as off. If creating the connector later says developer mode is required, open this page, enable it, savec2c prefs set --developer-mode, and retry create — do not skip that recovery.--developer-mode - 已有该 :
connectorName— Delete it (never Reconnect). Thenhttps://chatgpt.com/pluginsthe 加插件 URL below.goto - 还没有 / 刚删掉: Operate ONLY on
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fpluginsfrom step 3:connectorName- If that exact name exists: Delete it, then create it again. Never Reconnect, never edit-in-place, never open the old Server URL.
- If it does not exist: create one with that exact name.
- Never rename, delete, or edit a connector that belongs to another workspace.
- Description:
Securely connect ChatGPT to the current Codex workspace for planning and review. - Server URL: the from step 3
mcpUrl - Authentication: OAuth Fill the known form in one script when you can. Then Connect / Authorize and type the pairing code. As soon as it shows Connected / authorized / pairing accepted, continue — do NOT wait for 8 tools on this page.
- 开发人员模式: skip
- Same tab: open the first C2C chat per Conversation management
(Project collection for a new workspace; only in long-chat). Confirm Chat mode per In-app browser §7 (if it is Work, open a new Chat conversation instead). Send the boot prompt from
https://chatgpt.com/§Boot Prompt, then (same chat) send:docs/protocol.mdConfirm the reply matchesUse the "<connectorName>" connector: call workspace_info and read hello-style top-level file. Reply with the workspace name.(wait per In-app browser §8). Only then save the chat URL withworkspaceName(see Conversation management). If the name does not match, do not save. markDeliverable.c2c session set - Report to the user exactly in this shape (no internals):
Codex with ChatGPT
✓ 当前项目已识别
✓ Workspace Bridge 已启动
✓ 安全连接已建立
✓ ChatGPT 已连接
✓ 文件读取测试通过
Ready.If a login wall appears (ChatGPT, Cloudflare): stop, tell the user the ONE thing
to do ("请登录 ChatGPT,完成后告诉我'好了'"), then continue.
- 自行检测前置依赖:(>= 20),并检查
node --version是否安装。cloudflared- 如果macOS上缺少cloudflared,运行;Windows上使用
brew install cloudflared。自行执行,不要询问用户。winget install Cloudflare.cloudflared
- 如果macOS上缺少cloudflared,运行
- 如果c2c仓库没有,在其中运行
node_modules。pnpm install && pnpm build - 运行,然后执行连接方式选择,再运行
c2c sandbox-allow --json。c2c setup -w <workspace> --json仅编辑Codex的sandbox-allow——它会将C2C的状态目录添加到config.toml中,这样后续对话无需提升权限即可写入日志。如果写入被拒绝,请求用户批准后重试一次。 → 命令返回[sandbox_workspace_write].writable_roots。{ mcpUrl, pairingCode, workspaceName, connectorName, ... }是该工作区的插件标题(旧版安装保持为connectorName;新增工作区为Codex with ChatGPT)。 配对码约5分钟过期:如果操作太慢,运行Codex with ChatGPT · <name>获取新的配对码。c2c pair --json - (本机级别,不是本工作区)。
c2c prefs --json- 如果为null:准确告知用户
setupMode的内容,等待用户输入「1」或「2」。然后执行setupChoicePrompt或c2c prefs set --setup-mode auto。在用户回复前,不要打开ChatGPT设置,也不要启动自动配置。不要默认使用auto模式。--setup-mode manual - 如果用户之后要求切换模式:使用同样的命令。后续在其他工作区或重连时不要再次询问。
c2c prefs set --setup-mode - :跳过第5步的自动ChatGPT设置,进入ChatGPT手动引导配置(用户主动选择)。开场白为:
setupMode: "manual"不要说「自动配置没有成功」。接下来用手动教学配置。一次只需要做一个操作。 - :继续执行第5步。保留两次失败后降级的机制。
setupMode: "auto"
- 如果
- 在唯一的iab标签页中打开ChatGPT(参见应用内浏览器)。立即置为前台并执行markHandoff。同一标签页,仅使用跳转:
goto- 开发人员模式:当为true时跳过
developerModeEnabled页面。否则打开该页面,如果开发人员模式("Developer mode")是关闭的则启用它,然后执行https://chatgpt.com/#settings/Security。绝对不要记录为关闭状态。如果之后创建连接器时提示需要开发人员模式,打开该页面启用它,保存c2c prefs set --developer-mode设置后重试创建——不要跳过该修复步骤。--developer-mode - 已存在该:
connectorName——删除它(绝对不要重新连接)。然后https://chatgpt.com/plugins下方的加插件URL。goto - 还没有 / 刚删除:仅操作第3步中得到的
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins:connectorName- 如果完全同名的连接器存在:删除它,然后重新创建。绝对不要重新连接,不要就地编辑,不要打开旧的服务器URL。
- 如果不存在:创建一个完全同名的连接器。
- 绝对不要重命名、删除或编辑属于其他工作区的连接器。
- 描述:
Securely connect ChatGPT to the current Codex workspace for planning and review. - 服务器URL:第3步得到的
mcpUrl - 认证方式:OAuth 尽可能用一个脚本填充已知表单。然后点击连接/授权并输入配对码。一旦显示已连接/已授权/配对已接受,就继续操作——不要在这个页面等待8个工具加载完成。
- 开发人员模式:当
- 同一标签页:按照会话管理的规则打开第一个C2C对话(新工作区用Project合集;仅long-chat模式用)。按照应用内浏览器第7节确认是聊天模式(如果是工作模式,就打开新的聊天对话)。发送
https://chatgpt.com/中「启动提示」章节的启动提示,然后(在同一对话中)发送:docs/protocol.md确认回复内容与Use the "<connectorName>" connector: call workspace_info and read hello-style top-level file. Reply with the workspace name.匹配(按照应用内浏览器第8节的方式等待)。只有确认后才用workspaceName保存对话URL(参见「会话管理」)。如果名称不匹配,不要保存。执行markDeliverable。c2c session set - 严格按照以下格式向用户报告(不要包含内部细节):
Codex with ChatGPT
✓ 当前项目已识别
✓ Workspace Bridge 已启动
✓ 安全连接已建立
✓ ChatGPT 已连接
✓ 文件读取测试通过
Ready.如果出现登录拦截(ChatGPT、Cloudflare):停止操作,告知用户唯一需要做的事(「请登录 ChatGPT,完成后告诉我'好了'」),然后继续。
Guided manual ChatGPT setup
ChatGPT手动引导配置
Enter this path when is (chosen at the start), or when
automatic ChatGPT browser configuration fails twice at the same explicit
setup/reconnect step after / repair. Do NOT enter the failure
path for a browser/js timeout without a visible error, a page that is
still loading/generating, or while waiting for login / 2FA / CAPTCHA.
A chosen manual path does not wait for those two failures.
setupModemanualc2c doctorStop automating ChatGPT settings. Keep the current local C2C state and the
current , , , and . Do not
silently fall back to Codex-only execution and do not permanently disable C2C.
Do not change the saved when this is a failure fallback.
mcpUrlpairingCodeworkspaceNameconnectorNamesetupModeOpening line:
- Chosen ():
setupMode: "manual"接下来用手动教学配置。一次只需要做一个操作。 - Failure fallback:
自动配置没有成功,我来带你手动完成。一次只需要做一个操作。
Then guide ONE action at a time, waiting for the user to say「好了」before the
next action:
- If is not true: ask them to open
developerModeEnabledand enable 开发人员模式. After they say「好了」,https://chatgpt.com/#settings/Security. If it is already remembered, skip this step.c2c prefs set --developer-mode - Ask them to open . If the exact
https://chatgpt.com/pluginsexists, delete only that connector. Never ask them to touch another workspace's connector.connectorName - Ask them to open
and create the exact
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fpluginswith:connectorName- Description:
Securely connect ChatGPT to the current Codex workspace for planning and review. - Server URL: the current
mcpUrl - Authentication: OAuth
- Description:
- Ask them to Connect / Authorize and enter the current pairing code. If it
expired, run and give them only the fresh pairing code.
c2c pair --json - When they report Connected / authorized / pairing accepted, resume the normal setup/reconnect flow at its ChatGPT verification step. If automatic browser verification then hits the same explicit failure twice, stop and report the exact failed step; do not loop indefinitely and do not continue without C2C.
当为(一开始就选择的),或ChatGPT浏览器自动配置在/修复后,同一明确的设置/重连步骤仍失败两次时,进入此流程。对于没有可见错误的浏览器/JS超时、页面仍在加载/生成中、或正在等待登录/2FA/CAPTCHA的情况,不要进入失败降级流程。用户主动选择的手动模式不需要等两次失败。
setupModemanualc2c doctor停止自动配置ChatGPT设置。保留当前本地C2C状态以及当前的、、和。不要静默降级为仅使用Codex执行,也不要永久禁用C2C。如果是失败降级的情况,不要修改已保存的。
mcpUrlpairingCodeworkspaceNameconnectorNamesetupMode开场白:
- 主动选择():
setupMode: "manual"接下来用手动教学配置。一次只需要做一个操作。 - 失败降级:
自动配置没有成功,我来带你手动完成。一次只需要做一个操作。
然后一次只引导一个操作,等待用户说「好了」之后再进行下一个操作:
- 如果不为true:要求用户打开
developerModeEnabled并启用开发人员模式。用户说「好了」之后,执行https://chatgpt.com/#settings/Security。如果已经记住该设置,跳过此步骤。c2c prefs set --developer-mode - 要求用户打开。如果存在完全同名的
https://chatgpt.com/plugins,仅删除该连接器。绝对不要要求用户操作其他工作区的连接器。connectorName - 要求用户打开,并创建完全同名的
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins,参数如下:connectorName- 描述:
Securely connect ChatGPT to the current Codex workspace for planning and review. - 服务器URL:当前的
mcpUrl - 认证方式:OAuth
- 描述:
- 要求用户点击连接/授权并输入当前的配对码。如果配对码过期,运行并只提供新的配对码。
c2c pair --json - 当用户报告已连接/已授权/配对已接受时,恢复正常的设置/重连流程的ChatGPT验证步骤。如果之后自动浏览器验证再次遇到同一明确失败两次,停止操作并报告具体的失败步骤;不要无限循环,也不要在没有C2C的情况下继续。
Conversation management
会话管理
c2c session -w <ws> --json{ session, conversation }conversation.modeNever match a Project or a chat by display name. Never upload the repo to
Project sources. Never click 分享 / Share. Do not rename ChatGPT chats.
c2c session -w <ws> --json{ session, conversation }conversation.mode绝对不要通过显示名称匹配Project或对话。绝对不要将仓库上传到Project来源中。绝对不要点击分享 / Share。不要重命名ChatGPT对话。
long-chat (do not rewrite this path)
long-chat(不要修改此流程)
ONE ChatGPT conversation per workspace. Same as before.
- Find it: if and
conversation.reuseSavedChat,conversation.chatUrlthat URL (foreground + markHandoff) and continue there.goto - Save it: after boot + workspace_info, and the reply names this workspace,
. If the name does not match, do not overwrite a previously saved URL.
c2c session set -w <ws> --mode long-chat --url <url> --title "C2C <workspace name>" - Update it: after each EXECUTED/DONE,
plus checkpoint flags from the coding workflow (
c2c session set -w <ws> --task <id> --iteration <n> --state <STATE>,--protocol-state,--waiting-for,--goal,--next-step, or--known-issueson DONE). Do not put logs or diffs in those fields.--clear-checkpoint - Switch it ONLY when (a) the user asks for a new chat, (b) the current
chat visibly lags, or (c) this conversation is Work. Then:
- Same iab tab:
goto, confirm Chat mode (In-app browser §7), then send the boot prompt.https://chatgpt.com/ - Send a HANDOFF () — goal, progress, state, issues, next step. Never paste files.
docs/protocol.md - workspace_info check; only then . On failure, leave the old saved URL unchanged.
c2c session set --url
- Same iab tab:
- Saved chat 404s: treat as a switch. Reconstruct HANDOFF from
(goal, progress, issues, next step). If there is no checkpoint, use
session.checkpoint/task/iterationandlastStatemetadata only. Never paste logs or output bodies.execution_summary
每个工作区对应一个ChatGPT对话,和之前的逻辑一致。
-
查找:如果为true且存在
conversation.reuseSavedChat,conversation.chatUrl该URL(前台显示 + markHandoff)并在该对话中继续。goto -
保存:在启动提示 + workspace_info检查完成,且回复中提到了该工作区名称后,执行。如果名称不匹配,不要覆盖之前保存的URL。
c2c session set -w <ws> --mode long-chat --url <url> --title "C2C <workspace name>" -
更新:每次EXECUTED/DONE之后,执行,加上编码工作流中的检查点标记(
c2c session set -w <ws> --task <id> --iteration <n> --state <STATE>、--protocol-state、--waiting-for、--goal、--next-step,或DONE时的--known-issues)。不要在这些字段中放入日志或diff。--clear-checkpoint -
切换仅在以下情况发生:(a) 用户要求开启新对话,(b) 当前对话明显卡顿,或 (c) 该对话是工作模式。切换步骤:
- 同一iab标签页:
goto,确认是聊天模式(应用内浏览器第7节),然后发送启动提示。https://chatgpt.com/ - 发送HANDOFF()——包含目标、进度、状态、问题、下一步。绝对不要粘贴文件内容。
docs/protocol.md - workspace_info检查;之后才执行。如果失败,保持旧的已保存URL不变。
c2c session set --url
- 同一iab标签页:
-
保存的对话返回404:视为切换操作。从重建HANDOFF(目标、进度、问题、下一步)。如果没有检查点,仅使用
session.checkpoint/task/iteration和lastState元数据。绝对不要粘贴日志或输出内容。execution_summary
project (new workspaces)
project(新工作区)
One ChatGPT Project per workspace. Mapping:
- Same Codex conversation (this thread still has context) → same ChatGPT
chat URL. that URL directly. Do not open the collection first.
goto - Same workspace, a new Codex conversation → new ChatGPT chat from the
collection page (). Ignore
conversation.projectUrlunless you already saved it earlier in THIS Codex thread.session.url - Different workspace → different Project and different connector.
Open a chat in this Codex thread
- If you already saved a ChatGPT chat URL earlier in THIS Codex conversation:
that URL. Continue. No new chat. No HANDOFF.
goto - Else if :
conversation.projectReadygoto. On that page, use the on-page composer (「{项目名}中的新聊天」 / "New chat in …"). Do not use the sidebar and do notconversation.projectUrlgoto. Confirm Chat mode (In-app browser §7). Boot prompt, then workspace_info with the exacthttps://chatgpt.com/. After the reply names this workspace,connectorName. If this Codex thread is continuing a previous C2C task, send HANDOFF right after the boot prompt.c2c session set -w <ws> --mode project --project-url <collection> --url <chat> --connector-name "<connectorName>" --title "C2C <workspace name>" - Else: Bind Project first.
Update it: same as long-chat.
c2c session set --task / --iteration / --stateWrong collection: do not guess another Project. Tell the user the expected
workspace name, ask them to open the right collection, then say「已找到」.
Also offer「继续用长对话」. If they pick long-chat:
and use the long-chat path.
If the collection 404s or the new chat is not inside the Project, same choice.
c2c session set -w <ws> --mode long-chatSaved chat 404s (this thread): the collection, open a new chat
there, boot + HANDOFF from (no logs) + workspace_info,
then save the new chat URL. Keep .
gotosession.checkpoint--project-url每个工作区对应一个ChatGPT Project。映射关系:
- 同一个Codex对话(本线程仍有上下文)→ 同一个ChatGPT对话URL。直接该URL,不要先打开合集页面。
goto - 同一个工作区,新的Codex对话 → 从合集页面()打开新的ChatGPT对话。忽略
conversation.projectUrl,除非你在本Codex线程的早些时候已经保存过它。session.url - 不同的工作区 → 不同的Project和不同的连接器。
在本Codex线程中打开对话
- 如果在本Codex对话的早些时候你已经保存了ChatGPT对话URL:该URL,继续操作。不开新对话,不发HANDOFF。
goto - 否则如果为true:
conversation.projectReadygoto。在该页面上,使用页面内的composer(「{项目名}中的新聊天」 / "New chat in …")。不要使用侧边栏,也不要conversation.projectUrlgoto。确认是聊天模式(应用内浏览器第7节)。发送启动提示,然后使用准确的https://chatgpt.com/调用workspace_info。当回复中提到了该工作区名称后,执行connectorName。如果本Codex线程是在继续之前的C2C任务,在启动提示之后立即发送HANDOFF。c2c session set -w <ws> --mode project --project-url <collection> --url <chat> --connector-name "<connectorName>" --title "C2C <workspace name>" - 否则:先执行绑定Project。
更新:和long-chat模式一样,使用。
c2c session set --task / --iteration / --state合集错误:不要猜测其他Project。告知用户预期的工作区名称,要求他们打开正确的合集,然后说「已找到」。同时提供「继续用长对话」的选项。如果用户选择long-chat:执行并使用long-chat流程。如果合集返回404或新对话不在Project内,提供同样的选择。
c2c session set -w <ws> --mode long-chat保存的对话返回404(本线程):合集页面,在那里打开新对话,发送启动提示 + 从重建的HANDOFF(无日志) + workspace_info,然后保存新的对话URL。保留不变。
gotosession.checkpoint--project-urlBind Project (user creates the collection once)
绑定Project(用户只需创建一次合集)
Do this for a new workspace, or when an existing user asks to switch to
Project. Do not click the ChatGPT sidebar to create the Project
(Computer Use is forbidden; IAB must not hunt that menu).
- Tell the user exactly this (fill in the workspace name):
请在 ChatGPT 里新建一个项目,名字用「<workspaceName>」,记忆请选「仅限项目记忆」。
如果侧栏里看不到「项目」:把鼠标放在「聊天」上,点右边出现的三个点,选择「按项目整理」。
建好后会打开合集页面。看到页面后跟我说「好了」。-
Wait for「好了」/ the collection page. Same iab tab: read the address bar. It must look like. If it does not, ask them to open that project until it does. Then:
https://chatgpt.com/g/g-p-…/project.c2c session set -w <ws> --mode project --project-url <url> --connector-name "<connectorName>" -
On that same collection page only, open 右上角 … → 项目设置. Do not click 分享. Do not add 来源 / files.
- 记忆: 仅限项目记忆 (project-only). Leave 库访问权限 disabled.
- 指令: paste Project instructions below (fill from
{{…}}/ setup). Use the exactworkspace_infofrom setup. Never write the public / temporary address into 指令. Save and close settings.connectorName
-
Still on the collection page, create the first chat with the on-page composer, then boot + workspace_info as in setup step 5. Save the chat URL.
对于新工作区,或现有用户要求切换到Project模式时执行此流程。不要点击ChatGPT侧边栏来创建Project(禁止使用Computer Use;IAB不得在菜单中查找该选项)。
- 准确告知用户以下内容(填入工作区名称):
请在 ChatGPT 里新建一个项目,名字用「<workspaceName>」,记忆请选「仅限项目记忆」。
如果侧栏里看不到「项目」:把鼠标放在「聊天」上,点右边出现的三个点,选择「按项目整理」。
建好后会打开合集页面。看到页面后跟我说「好了」。-
等待用户说「好了」/ 等待合集页面加载。同一iab标签页:读取地址栏内容。地址必须是格式。如果不是,要求用户打开该项目直到地址正确。然后执行:
https://chatgpt.com/g/g-p-…/project。c2c session set -w <ws> --mode project --project-url <url> --connector-name "<connectorName>" -
仅在该合集页面上,打开右上角 … → 项目设置。不要点击分享。不要添加来源 / 文件。
- 记忆:仅限项目记忆(project-only)。保持库访问权限为禁用状态。
- 指令:粘贴下方的Project指令(用/设置中的内容填充
workspace_info占位符)。使用设置时得到的准确{{…}}。绝对不要将公共/临时地址写入指令中。 保存并关闭设置。connectorName
-
仍在合集页面上,使用页面内的composer创建第一个对话,然后按照设置第5步的流程发送启动提示 + workspace_info检查。保存对话URL。
Project instructions (paste into 项目设置 → 指令)
Project指令(粘贴到项目设置 → 指令)
You are the planning and review layer for one local workspace. Codex executes.
This Project is bound only to:
- Workspace name: {{workspace_name}}
- Kind: {{project_type}} ({{languages}} / {{frameworks}})
- Connector (use this one only): {{connector_name}}
When you call tools, use ONLY that connector. Do not use any other
Codex with ChatGPT connector. If workspace_info names a different
workspace, stop. Do not plan. Do not use this Project's memory.
Read code, git, diffs, and any released command output through that
connector. Never ask anyone to paste file bodies, diffs, or logs. After
EXECUTED, call execution_output (list, then read) when a readable item
exists; if status is restricted, review from git instead. Never upload
the repo into this Project's files or sources.
When facts conflict, trust this order:
1. Current code from the connector
2. A HANDOFF in this chat (this task's goal, progress, next step)
3. These instructions
4. This Project's memory (durable architecture only; stale memory loses)
This Project's memory is only for this workspace. On HANDOFF, trust the
brief, re-read code through the connector, and resume at NEXT_EXPECTED_STEP.
Be substantive: why, which file, what to test. No empty one-liners and
no 40-step epics. Use C2C control messages.You are the planning and review layer for one local workspace. Codex executes.
This Project is bound only to:
- Workspace name: {{workspace_name}}
- Kind: {{project_type}} ({{languages}} / {{frameworks}})
- Connector (use this one only): {{connector_name}}
When you call tools, use ONLY that connector. Do not use any other
Codex with ChatGPT connector. If workspace_info names a different
workspace, stop. Do not plan. Do not use this Project's memory.
Read code, git, diffs, and any released command output through that
connector. Never ask anyone to paste file bodies, diffs, or logs. After
EXECUTED, call execution_output (list, then read) when a readable item
exists; if status is restricted, review from git instead. Never upload
the repo into this Project's files or sources.
When facts conflict, trust this order:
1. Current code from the connector
2. A HANDOFF in this chat (this task's goal, progress, next step)
3. These instructions
4. This Project's memory (durable architecture only; stale memory loses)
This Project's memory is only for this workspace. On HANDOFF, trust the
brief, re-read code through the connector, and resume at NEXT_EXPECTED_STEP.
Be substantive: why, which file, what to test. No empty one-liners and
no 40-step epics. Use C2C control messages.Workflow: coding task("使用 Codex with ChatGPT 完成 XXX")
工作流:编码任务(「使用 Codex with ChatGPT 完成 XXX」)
Protocol states sent to ChatGPT: INIT → PLAN → EXECUTING → EXECUTED → REVIEW → (PLAN | DONE | BLOCKED).
Local checkpoint states (session only, never a ChatGPT line):
, , , , , , .
Do not invent . If the original chat is gone, send HANDOFF.
All control messages start with . Keep Codex→ChatGPT messages under 1 KB.
ChatGPT's replies are expected to be substantive (see step 3). Docs: .
STATE:INITPLAN_RECEIVEDEXECUTINGEXECUTED_LOCALEXECUTED_SENTDONEBLOCKEDSTATE: RESUME[C2C]docs/protocol.md-
. If
c2c tunnel status -w <workspace> --json, follow Connection choice first (existing installs: ask once, then remember). ThenneedsChoice(auto-repairs). Doctor gate: if local is not green, do not open ChatGPT and do not send INIT. Ifc2c doctor -w <workspace> --jsonis true, tell the usernamedRepair.needed, runnamedRepair.userMessage(their browser; Cloudflare exception), then doctor again. Ifc2c tunnel login --jsonis true, tell the userchatgptRepair.needed(one paragraph, no internals), run Workflow: reconnect after address reclaim, then doctor again and only continue when the gate is green. Generate task id:chatgptRepair.userMessage+ 4 random hex chars — unless a checkpoint already has one (reuse that id; do not mint a second task).c2c_ -
. Open ChatGPT on the same iab tab per Conversation management for
c2c session -w <workspace> --json(foreground + markHandoff). long-chat: saved chat, orconversation.modeif none. project: this thread's chat URL, or the collection page for a new chat, or Bind Project ifhttps://chatgpt.com/is false. On a NEW conversation confirm Chat mode (In-app browser §7), then send the boot prompt fromprojectReady§Boot Prompt and the workspace_info check (name the exactdocs/protocol.md). Confirm the reply names the current workspace before saving the session URL. Do not use the browser to re-read code MCP already provides. After sending a control message, wait per In-app browser §8.connectorNameResume frombefore any INIT. Missing checkpoint (legacy session): continue as a normal new/continued loop. A browser/js timeout is not a lost task — claim the original tab; do not INIT, re-run, or resend EXECUTED just because a wait timed out.session.checkpoint- +
EXECUTED_SENT: do not INIT, do not re-run, do not resend EXECUTED. Stay on the saved chat and wait for review. If that chat 404s: HANDOFF from checkpoint fields (no logs), then wait.waitingFor=GPT_REVIEW - : local work is done; only send EXECUTED (record first if this iteration has no record yet). Do not re-run.
EXECUTED_LOCAL - : not finished. Continue the current PLAN if you still have it; otherwise HANDOFF and ask ChatGPT to restate the last PLAN. Do not treat it as done and do not INIT a new task.
EXECUTING - : execute that plan. Do not INIT.
PLAN_RECEIVED - /
INIT: claim the tab and wait. Do not resend INIT.waitingFor=GPT_PLAN - : summarize to the user if needed;
DONE.c2c session set --clear-checkpoint - : surface ChatGPT's reason; do not INIT. Never re-pair, never recreate the connector, and never rewrite Project instructions just to resume.
BLOCKED
-
Send INIT with the user's goal (skip when the checkpoint says not to):
[C2C]
STATE: INIT
TASK_ID: c2c_f81a
ITERATION: 0
GOAL:
<user's goal, one paragraph>
INSTRUCTION:
Inspect the connected workspace through the Codex with ChatGPT MCP connector.
Produce a C2C PLAN message.Then:
3. Wait for ChatGPT's reply (In-app browser §8 — short DOM
checks, same tab; do not treat a 5-minute browser timeout as failure).
Read GOAL/ACTIONS/TESTS/SUCCESS_CRITERIA.
A good PLAN also carries RATIONALE and concrete natural-language edit
suggestions (which file, what to change, why). If the reply is a bare
one-liner with no rationale or file-level guidance, ask once:
"Please expand the plan with rationale and concrete per-file suggestions."
Then:
4. Execute the plan yourself with your own harness (your tools, your judgment;
ChatGPT does not micro-manage tool calls).
Before you start:
5. Record the execution so ChatGPT can read it via MCP. Metadata always:
If this iteration ran a test / build / lint / typecheck command, also
pass that command's output. Write stdout/stderr to a local temp file first,
then:
Record both success and failure. Do not record shell history, ,
keys, or unrelated dumps. Never paste that file (or any log) into ChatGPT.
If the CLI says the output was not released, still send EXECUTED; ChatGPT
reviews from git. Then:
6. Send EXECUTED (no diffs, no logs). Tell ChatGPT to use MCP, including
when a readable item exists:
c2c session set -w <ws> --task <id> --iteration 0 --state INIT --protocol-state INIT --waiting-for GPT_PLAN --goal "<short goal>" --next-step "wait for PLAN"STATE: PLANc2c session set -w <ws> --protocol-state PLAN_RECEIVED --waiting-for none --next-step "execute PLAN"c2c session set -w <ws> --protocol-state EXECUTING --waiting-for none --next-step "finish PLAN then record"c2c record -w <ws> --task c2c_f81a --iteration 1 --changed-files "src/a.ts,src/b.ts" --tests "27 passed" --exit-status okc2c record … --command "pnpm test" --output-file <temp> --exit-code <n>.envc2c session set -w <ws> --iteration 1 --state EXECUTED --protocol-state EXECUTED_LOCAL --waiting-for none --next-step "send EXECUTED"execution_output[C2C]
STATE: EXECUTED
TASK_ID: c2c_f81a
ITERATION: 1
RESULT:
Execution finished.
CHANGED_FILES:
4
TESTS:
27 passed
Please independently inspect the workspace and current git diff through MCP.
If execution_output lists a readable item for this iteration, list then read it.
If status is restricted, ignore it and review from git_diff.Then:
7. ChatGPT reviews via MCP (, , ,
) and replies DONE / PLAN (next iteration) / BLOCKED.
8. Loop. Respect maxIterations (, default 12). At the limit, pause and ask
the user: "已完成 12 轮协作,仍有未解决问题,是否继续?"
9. On DONE: summarize the result to the user in plain language.
10. On BLOCKED: read ChatGPT's reason, fix what you can, or surface the single
decision the user must make.
c2c session set -w <ws> --protocol-state EXECUTED_SENT --waiting-for GPT_REVIEW --next-step "wait for PLAN or DONE"git_diffread_filetest_statusexecution_output.c2c.jsonc2c session set -w <ws> --state DONE --clear-checkpointc2c session set -w <ws> --protocol-state BLOCKED --waiting-for USER --known-issues "<short reason>"发送给ChatGPT的协议状态:INIT → PLAN → EXECUTING → EXECUTED → REVIEW → (PLAN | DONE | BLOCKED)。
本地检查点状态(仅会话内使用,绝对不要出现在ChatGPT的行中):、、、、、、。
不要自行发明。如果原始对话丢失,发送HANDOFF。
所有控制消息都以开头。将Codex→ChatGPT的消息控制在1KB以内。
ChatGPT的回复应该是实质性的(参见第3步)。文档:。
STATE:INITPLAN_RECEIVEDEXECUTINGEXECUTED_LOCALEXECUTED_SENTDONEBLOCKEDSTATE: RESUME[C2C]docs/protocol.md-
。如果
c2c tunnel status -w <workspace> --json为true,先遵循连接方式选择流程(现有安装:询问一次后记住)。然后执行needsChoice(自动修复)。Doctor门禁:如果本地状态不是绿色,不要打开ChatGPT,也不要发送INIT。如果c2c doctor -w <workspace> --json为true,告知用户namedRepair.needed的内容,运行namedRepair.userMessage(用户的浏览器;Cloudflare例外情况),然后重新执行doctor。如果c2c tunnel login --json为true,告知用户chatgptRepair.needed的内容(一段话,不含内部细节),运行工作流:地址回收后重连,然后重新执行doctor,仅当门禁变绿后才继续。 生成任务ID:chatgptRepair.userMessage+ 4个随机十六进制字符——除非检查点中已经有任务ID(复用该ID;不要创建第二个任务)。c2c_ -
。根据
c2c session -w <workspace> --json,按照会话管理的规则在同一个iab标签页中打开ChatGPT(前台显示 + markHandoff)。long-chat模式:使用已保存的对话,如果没有则打开conversation.mode。project模式:使用本线程的对话URL,或打开合集页面新建对话,或如果https://chatgpt.com/为false则先执行绑定Project。 如果是新对话,确认是聊天模式(应用内浏览器第7节),然后发送projectReady中「启动提示」章节的启动提示和workspace_info检查(指定准确的docs/protocol.md)。在保存会话URL之前,确认回复中提到了当前工作区的名称。不要使用浏览器重新读取MCP已经提供的代码。 发送控制消息后,按照应用内浏览器第8节的方式等待。connectorName在任何INIT之前,先从恢复。 检查点缺失(旧版会话):按正常的新/继续循环执行。浏览器/JS超时不代表任务丢失——复用原始标签页;不要仅仅因为等待超时就重新INIT、重新运行或重发EXECUTED。session.checkpoint- +
EXECUTED_SENT:不要INIT,不要重新运行,不要重发EXECUTED。留在已保存的对话中等待评审。如果该对话返回404:从检查点字段重建HANDOFF(无日志),然后等待。waitingFor=GPT_REVIEW - :本地工作已完成;仅需发送EXECUTED(如果本次迭代还没有记录,先记录)。不要重新运行。
EXECUTED_LOCAL - :尚未完成。如果你还有当前的PLAN,继续执行;否则发送HANDOFF并要求ChatGPT重述上一个PLAN。不要将其视为完成,也不要INIT新任务。
EXECUTING - :执行该计划。不要INIT。
PLAN_RECEIVED - /
INIT:复用标签页并等待。不要重发INIT。waitingFor=GPT_PLAN - :如果需要,向用户总结结果;执行
DONE。c2c session set --clear-checkpoint - :告知用户ChatGPT给出的原因;不要INIT。 绝对不要为了恢复任务就重新配对、重新创建连接器,或重写Project指令。
BLOCKED
-
发送包含用户目标的INIT(如果检查点要求跳过则跳过):
[C2C]
STATE: INIT
TASK_ID: c2c_f81a
ITERATION: 0
GOAL:
<user's goal, one paragraph>
INSTRUCTION:
Inspect the connected workspace through the Codex with ChatGPT MCP connector.
Produce a C2C PLAN message.然后执行:
3. 等待ChatGPT的回复(应用内浏览器第8节——短周期DOM检查,同一标签页;不要将5分钟的浏览器超时视为失败)。读取GOAL/ACTIONS/TESTS/SUCCESS_CRITERIA。
一个好的PLAN还应该包含RATIONALE(理由)和具体的自然语言修改建议(哪个文件,改什么,为什么)。如果回复只有光秃秃的一句话,没有理由或文件级别的指导,询问一次:"Please expand the plan with rationale and concrete per-file suggestions."
然后执行:
4. 用你自己的工具链执行计划(你的工具,你的判断;ChatGPT不会微观管理工具调用)。
开始之前执行:
5. 记录执行结果,以便ChatGPT可以通过MCP读取。始终包含元数据:。
如果本次迭代运行了测试 / 构建 / lint / 类型检查命令,还要传入该命令的输出。先将stdout/stderr写入本地临时文件,然后执行:。
成功和失败都要记录。不要记录shell历史、、密钥或不相关的转储内容。绝对不要将该文件(或任何日志)粘贴到ChatGPT中。
如果CLI提示输出未发布,仍然发送EXECUTED;ChatGPT会从git进行评审。
然后执行:
6. 发送EXECUTED(无diff,无日志)。告知ChatGPT使用MCP,包括当存在可读项时调用:
c2c session set -w <ws> --task <id> --iteration 0 --state INIT --protocol-state INIT --waiting-for GPT_PLAN --goal "<short goal>" --next-step "wait for PLAN"STATE: PLANc2c session set -w <ws> --protocol-state PLAN_RECEIVED --waiting-for none --next-step "execute PLAN"c2c session set -w <ws> --protocol-state EXECUTING --waiting-for none --next-step "finish PLAN then record"c2c record -w <ws> --task c2c_f81a --iteration 1 --changed-files "src/a.ts,src/b.ts" --tests "27 passed" --exit-status okc2c record … --command "pnpm test" --output-file <temp> --exit-code <n>.envc2c session set -w <ws> --iteration 1 --state EXECUTED --protocol-state EXECUTED_LOCAL --waiting-for none --next-step "send EXECUTED"execution_output[C2C]
STATE: EXECUTED
TASK_ID: c2c_f81a
ITERATION: 1
RESULT:
Execution finished.
CHANGED_FILES:
4
TESTS:
27 passed
Please independently inspect the workspace and current git diff through MCP.
If execution_output lists a readable item for this iteration, list then read it.
If status is restricted, ignore it and review from git_diff.然后执行:
7. ChatGPT通过MCP(、、、)进行评审,并回复DONE / PLAN(下一次迭代) / BLOCKED。
8. 循环执行。遵守maxIterations限制(配置,默认12次)。达到限制时,暂停并询问用户:「已完成 12 轮协作,仍有未解决问题,是否继续?」
9. 收到DONE时:用平实的语言向用户总结结果。执行
10. 收到BLOCKED时:读取ChatGPT给出的原因,修复你能修复的问题,或告知用户需要他们做出的唯一决策。执行
c2c session set -w <ws> --protocol-state EXECUTED_SENT --waiting-for GPT_REVIEW --next-step "wait for PLAN or DONE"git_diffread_filetest_statusexecution_output.c2c.jsonc2c session set -w <ws> --state DONE --clear-checkpointc2c session set -w <ws> --protocol-state BLOCKED --waiting-for USER --known-issues "<short reason>"Workflow: disconnect("断开 ChatGPT")
工作流:断开连接(「断开 ChatGPT」)
- (revokes all tokens immediately).
c2c unpair -w <workspace> - Optionally remove the connector on the same iab tab via
(foreground + markHandoff). Only touch this workspace's
https://chatgpt.com/plugins.connectorName - Tell the user: "已断开 ChatGPT 对该项目的访问。"
- (立即撤销所有令牌)。
c2c unpair -w <workspace> - 可选:在同一个iab标签页中通过删除连接器(前台显示 + markHandoff)。仅操作本工作区的
https://chatgpt.com/plugins。connectorName - 告知用户:「已断开 ChatGPT 对该项目的访问。」
Workflow: reconnect after address reclaim(全关掉以后地址失效)
工作流:地址回收后重连(全关掉以后地址失效)
This is the normal case when the user quit Codex / the terminal / the machine:
the previous public address is gone. Doctor already started a new one.
means Delete + create again — not Reconnect.
connectorAction: "update"c2c doctor --json{ "chatgptRepair": { "needed": true, "connectorAction": "update", "connectorName": "...", "userMessage": "...", "mcpUrl": "...", "pairingCode": "...", "pages": { ... } } }- Tell the user exactly . Then you repair. Do not ask them to click around ChatGPT unless a login wall appears. Do not open the C2C chat and do not send
chatgptRepair.userMessageuntil this repair finishes and a follow-up doctor is green. Never "try a message first to see if it works". Reuse[C2C]. Do not re-ask setup mode. Ifc2c prefs --jsonissetupMode, use Guided manual ChatGPT setup (chosen) instead of automating.manual - Same one iab tab as setup (foreground + markHandoff). Settings URLs only
until Connected — never hunt menus:
- 开发人员模式: skip when
https://chatgpt.com/#settings/Securityis true. If create/delete then says developer mode is required, open it, enable,developerModeEnabled.c2c prefs set --developer-mode - 插件总管(只用来 Delete):
https://chatgpt.com/plugins - 加插件(Delete 之后必走):
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins
- 开发人员模式: skip
- Operate ONLY on . Never touch another workspace's connector.
chatgptRepair.connectorName- If that exact name exists on the plugins hub: Delete it. Confirm the delete if ChatGPT asks. Never click Reconnect, Refresh, Connect, or Edit on the old card — the old Server URL is dead and the page will hang on "This site cannot be reached".
- Then the 加插件 URL and create that same
goto(do not invent a second name):connectorName- Description:
Securely connect ChatGPT to the current Codex workspace for planning and review. - Server URL:
chatgptRepair.mcpUrl - Authentication: OAuth
Then Connect / Authorize and type (or
chatgptRepair.pairingCodeif it expired). Continue as soon as it is Connected — do not wait for 8 tools on the settings page.c2c pair --json
- Description:
- If the name is already gone, skip Delete and only create.
- again. Same tab: only after the Doctor gate is green, reopen the chat this Codex thread was already using (
c2c doctor --json/ the URL you saved earlier in THIS thread). Do not start a new audit/task chat just because the address changed. Do not rewrite Project instructions — they store the connector name, which did not change.session.url - If the ChatGPT conversation was lost: long-chat → Conversation
management switch. project → collection page, new chat, boot + HANDOFF.
No file re-uploading (the workspace lives in MCP). After recreating the
same-name connector, the Project still uses that name. If tools point at
the wrong connector, open 项目设置 and confirm 指令 still names
(never paste the new public address).
connectorName
这是用户退出Codex / 终端 / 电脑后的正常情况:之前的公共地址已经失效。Doctor已经启动了新的地址。表示删除 + 重新创建——不是重新连接。
connectorAction: "update"c2c doctor --json{ "chatgptRepair": { "needed": true, "connectorAction": "update", "connectorName": "...", "userMessage": "...", "mcpUrl": "...", "pairingCode": "...", "pages": { ... } } }- 准确告知用户的内容。然后你进行修复。除非出现登录拦截,否则不要要求用户在ChatGPT里点击操作。在修复完成且后续的doctor检查变绿之前,不要打开C2C对话,也不要发送
chatgptRepair.userMessage消息。绝对不要「先发个消息试试能不能用」。 复用[C2C]的结果,不要重新询问设置模式。如果c2c prefs --json为setupMode,使用ChatGPT手动引导配置(用户选择的)而非自动配置。manual - 和设置时用同一个iab标签页(前台显示 + markHandoff)。在连接成功前仅使用设置URL——绝对不要在菜单里找:
- 开发人员模式:当为true时跳过
developerModeEnabled。如果创建/删除时提示需要开发人员模式,打开该页面启用它,执行https://chatgpt.com/#settings/Security。c2c prefs set --developer-mode - 插件总管(仅用于删除):
https://chatgpt.com/plugins - 加插件(删除后必须走):
https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins
- 开发人员模式:当
- 仅操作。绝对不要碰其他工作区的连接器。
chatgptRepair.connectorName- 如果插件中心里存在完全同名的连接器:删除它。如果ChatGPT询问,确认删除。绝对不要在旧卡片上点击重新连接、刷新、连接或编辑——旧的服务器URL已经失效,页面会卡在「无法访问此网站」。
- 然后加插件URL,创建同一个
goto(不要发明第二个名字):connectorName- 描述:
Securely connect ChatGPT to the current Codex workspace for planning and review. - 服务器URL:
chatgptRepair.mcpUrl - 认证方式:OAuth
然后点击连接/授权并输入(如果过期了就执行
chatgptRepair.pairingCode获取新的)。一旦显示已连接就继续——不要在设置页面等待8个工具加载完成。c2c pair --json
- 描述:
- 如果该名称已经不存在,跳过删除,直接创建。
- 再次执行。同一标签页:仅当Doctor门禁变绿后,重新打开本Codex线程已经在使用的对话(
c2c doctor --json/ 你在本线程早些时候保存的URL)。不要仅仅因为地址变了就开启新的审计/任务对话。不要重写Project指令——它们存储的是连接器名称,而名称没有变。session.url - 如果ChatGPT对话丢失了:long-chat模式 → 按会话管理中的切换流程处理。project模式 → 打开合集页面,新建对话,发送启动提示 + HANDOFF。不需要重新上传文件(工作区在MCP中)。
重新创建同名连接器后,Project仍使用该名称。如果工具指向了错误的连接器,打开项目设置并确认指令中仍然指定了(绝对不要粘贴新的公共地址)。
connectorName
Workflow: repair(anything looks broken)
工作流:修复(任何看起来出问题的情况)
- . Doctor gate: do not open ChatGPT / send
c2c doctor -w <workspace> --jsonuntil local is green, except reconnect settings pages.[C2C] - If , tell the user
namedRepair.needed, runnamedRepair.userMessage, then doctor again. Do not Delete the connector.c2c tunnel login --json - If , follow reconnect after address reclaim, then doctor again.
chatgptRepair.needed - Otherwise apply the recovery map. Only involve the user for login / 2FA / CAPTCHA — one action.
- 。Doctor门禁:在本地状态变绿之前,不要打开ChatGPT / 发送
c2c doctor -w <workspace> --json,重连设置页面除外。[C2C] - 如果为true,告知用户
namedRepair.needed的内容,运行namedRepair.userMessage,然后重新执行doctor。不要删除连接器。c2c tunnel login --json - 如果为true,遵循地址回收后重连流程,然后重新执行doctor。
chatgptRepair.needed - 其他情况应用恢复映射表。仅在登录 / 2FA / CAPTCHA时需要用户参与——每次一个操作。
Recovery map
恢复映射表
| Symptom | Action |
|---|---|
| Bridge not running | |
| Tunnel dead / URL unreachable / 全关掉后连接失效 | |
| ChatGPT says tool call failed / 401 | token expired or revoked → re-pair (new pairing code + authorize) |
| Pairing code rejected/expired | |
| Same explicit ChatGPT setup/reconnect browser configuration step fails twice after repair | Stop automating ChatGPT settings and use Guided manual ChatGPT setup fallback. Do not count browser/js timeout, loading/generating, or login/2FA waiting as failures. |
| Port conflict | handled automatically; never surface to the user |
| Every new chat “repairs” / cannot write the log or settings directory | |
| cloudflared missing | install it yourself (brew/winget), then retry |
| Sidebar has no「项目」 | Ask the user to hover「聊天」, click the …, choose「按项目整理」 |
| Collection page is the wrong Project | Ask the user to open the named collection and say「已找到」, or accept long-chat |
| 症状 | 操作 |
|---|---|
| 桥接器未运行 | |
| Tunnel断开 / URL不可达 / 全关掉后连接失效 | |
| ChatGPT提示工具调用失败 / 401 | 令牌过期或被撤销 → 重新配对(新配对码 + 授权) |
| 配对码被拒绝/过期 | 执行 |
| 同一明确的ChatGPT设置/重连浏览器配置步骤在修复后仍失败两次 | 停止自动配置ChatGPT设置,改用ChatGPT手动引导配置降级方案。浏览器/JS超时、加载/生成中、或登录/2FA等待时间不算失败。 |
| 端口冲突 | 自动处理;绝对不要告知用户 |
| 每次新对话都要「修复」 / 无法写入日志或设置目录 | |
| 缺少cloudflared | 自行安装(brew/winget),然后重试 |
| 侧边栏没有「项目」 | 要求用户将鼠标悬停在「聊天」上,点击…,选择「按项目整理」 |
| 合集页面是错误的Project | 要求用户打开指定的集合并说「已找到」,或接受使用long-chat模式 |