codex-supervisor-mcp 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +43 -21
- package/README.md +33 -17
- package/package.json +1 -1
- package/skills/codex-supervisor/SKILL.md +97 -160
package/README.en.md
CHANGED
|
@@ -64,12 +64,15 @@ Say it in plain words in Claude Code; the skill makes it follow the right steps:
|
|
|
64
64
|
What the main thread does underneath (you can call the tools yourself):
|
|
65
65
|
|
|
66
66
|
```
|
|
67
|
-
|
|
67
|
+
preflight_codex_worker run required probes with the target workspace/base/sandbox/guard
|
|
68
|
+
get_worker_preflight require passed; rerun when the contract changes
|
|
69
|
+
create_codex_worker ×3 each with preflight_id, session_id, ownedPaths, goal
|
|
68
70
|
wait_codex_workers 60 seconds by default, then a snapshot, call again until done
|
|
69
71
|
get_worker_result ×3 each worker's report, with the commands it really ran
|
|
72
|
+
get_worker_diff ×3 inspect the real change before deciding to land
|
|
70
73
|
```
|
|
71
74
|
|
|
72
|
-
Each worker's changes sit on its own `codex/<taskId>` branch
|
|
75
|
+
Each worker's changes sit on its own `codex/<taskId>` branch. After acceptance and diff review, the main thread lands them with `land_codex_worker` and `commitMessage`; the worker does not commit.
|
|
73
76
|
|
|
74
77
|
### 3. Open the board
|
|
75
78
|
|
|
@@ -90,7 +93,7 @@ Anything that speaks MCP can be the main thread; this is just my way. I run two
|
|
|
90
93
|
| Me | | Decide what to build, make the calls, read the reports |
|
|
91
94
|
| Planning session | The requirements and docs repository | Talk through the requirement, write the design, write one brief per block of work with a paragraph for the main brain at the end |
|
|
92
95
|
| Main-brain session | A worktree of the code repository | Read the brief, dispatch Codex workers, check every worker's diff, write results back into the brief, report to me. Writes no business code |
|
|
93
|
-
| Codex workers | Their own worktrees | One worker per
|
|
96
|
+
| Codex workers | Their own worktrees | One worker per independently verifiable feature package. It edits and runs acceptance. It does not commit, push or merge |
|
|
94
97
|
|
|
95
98
|
One block of text passes between the two sessions, pasted into the main-brain session and handed over with `/goal`. Its shape is fixed:
|
|
96
99
|
|
|
@@ -100,12 +103,14 @@ One block of text passes between the two sessions, pasted into the main-brain se
|
|
|
100
103
|
[Background] Why this block exists, what the previous one left behind
|
|
101
104
|
[Read first] Which sections of which documents. Which one wins when they disagree
|
|
102
105
|
[Repos] Where the worktrees are, which commit each branch is on, which branches are read-only
|
|
103
|
-
[Do] Follow the table in section N of the brief.
|
|
106
|
+
[Do] Follow the table in section N of the brief. Split by independently verifiable feature packages. Nothing outside the table. Workers do not commit
|
|
104
107
|
[Dispatch] search_works first, do not dispatch twice
|
|
105
108
|
One session_id for the whole batch
|
|
106
|
-
Serial when
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
Serial when writes overlap, parallel only with disjoint write sets
|
|
110
|
+
ownedPaths covers implementation, tests, routing, DI, configuration and migrations
|
|
111
|
+
Prepare dependencies with workspaceSetup; every writer passes preflight with the same contract
|
|
112
|
+
Write the task in full: background, where in the docs, complete write set, verify command, output format
|
|
113
|
+
Put the verify command in acceptance too; the worker self-checks through CODEX_SUPERVISOR_ACCEPTANCE_CLI
|
|
109
114
|
Read the diff when a worker returns. Its word is not enough; what you see is
|
|
110
115
|
[Build/test] Everything on the remote machine, nothing locally
|
|
111
116
|
[Red lines] What not to change, push or read
|
|
@@ -117,18 +122,16 @@ What the main brain calls in one round:
|
|
|
117
122
|
|
|
118
123
|
```
|
|
119
124
|
search_works has this batch been dispatched before
|
|
120
|
-
create_codex_worker one worker per
|
|
125
|
+
create_codex_worker one worker per feature package, same session_id, ownedPaths disjoint
|
|
121
126
|
wait_codex_workers 60 seconds a round, compact: true, call again until done
|
|
122
127
|
get_worker_result what it says it did; verification is what it really ran
|
|
123
128
|
get_worker_diff what it actually did
|
|
124
129
|
ask_codex_worker when the two differ, ask why; read-only, its thread untouched
|
|
125
|
-
resume_codex_worker when it must change something
|
|
126
|
-
land_codex_worker
|
|
130
|
+
resume_codex_worker continue the same thread when it must change something; rebaseOnto when main has moved
|
|
131
|
+
land_codex_worker reviewed; commit with commitMessage and land on the integration branch
|
|
127
132
|
```
|
|
128
133
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Why one worker does one step: when step 5 is wrong, the worker that did step 5 gets one `resume_codex_worker`, amends its own commit, the main brain checks again, and only then lands it. A worker that did steps 5, 6 and 7 cannot be fixed that way: 6 and 7 already sit on top of 5, so fixing 5 means redoing them too.
|
|
134
|
+
A feature package can still be resumed before landing. Split it when writes conflict, dependencies need sequencing, or the work has separate acceptance, not because every step needs a new model thread.
|
|
132
135
|
|
|
133
136
|
## What the board shows
|
|
134
137
|
|
|
@@ -148,18 +151,18 @@ Thirty-nine.
|
|
|
148
151
|
|
|
149
152
|
| Tool | Arguments | What it does |
|
|
150
153
|
|---|---|---|
|
|
151
|
-
| `check_workers` | none | Report newly settled runs and actionable changes; recover a new-format first lost
|
|
154
|
+
| `check_workers` | none | Report newly settled runs and actionable changes; recover a new-format first `lost`, `no_work` or `invalid_report` run once. Unchanged state is quiet. Call from a host-scheduled loop and use a distinct CODEX_SUPERVISOR_OBSERVER_ID for each reconnecting main thread |
|
|
152
155
|
| `overview_delta` | `cursor` | Main-thread incremental view: counters, changed summaries, short attention reason / next action and next_cursor; no prompt, diff, event or capsule history |
|
|
153
156
|
| `check_acceptance` | `cwd`, `acceptance`, `baseRef`, `timeoutMs` | Execute supplied checks before dispatch, without creating a worker or proving completion; warns that failure-count greps do not establish an approved failure list or required execution |
|
|
154
|
-
| `preflight_codex_worker` | `cwd`, `workspaceKind`, `inPlaceAuthorization`, `ownedPaths`, `probeCommands`, `baseRef`, `sandbox`, `allowedCommands`, `context`, `contracts`, `networkAccess`, `writableRoots` | Run a short probe worker under the exact workspace/base/sandbox/guard contract intended for the later worker; wait for `get_worker_preflight` to report passed before dispatch |
|
|
157
|
+
| `preflight_codex_worker` | `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, `ownedPaths`, `probeCommands`, `baseRef`, `sandbox`, `allowedCommands`, `context`, `contracts`, `networkAccess`, `writableRoots` | Run a short probe worker under the exact workspace/base/sandbox/guard contract intended for the later worker; wait for `get_worker_preflight` to report passed before dispatch |
|
|
155
158
|
| `get_worker_preflight` | `task_id` | Read probe command evidence and the immutable runtime contract hash |
|
|
156
|
-
| `create_codex_worker` | `task`, `cwd`, `workspaceKind`, `inPlaceAuthorization`, **`ownedPaths`**, **`goal`**, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `maxRunMs`, `maxTotalMs`, `acceptance`, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Git defaults to an isolated worktree. A non-Git write must choose `scratch`, or an authorized `in_place_write` with paths and acceptance. |
|
|
157
|
-
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`,
|
|
159
|
+
| `create_codex_worker` | `task`, `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, **`ownedPaths`**, **`goal`**, `preflight_id`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `maxRunMs`, `maxTotalMs`, `acceptance`, `acceptanceTimeoutMs`, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Git defaults to an isolated worktree. A non-Git write must choose `scratch`, or an authorized `in_place_write` with paths and acceptance. `workspaceSetup` prepares dependencies before the worker starts; when `preflight_id` is present its complete runtime contract must match. |
|
|
160
|
+
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, `session_title`, `title`, `cwd`, `sandbox`, `model`, `ownedPaths`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `workspaceKind`, `workspaceSetup`, `goal`, `baseRef`, `acceptance` | A new session seeded with the old worker's prompt, status and recent events. It does not accept `preflight_id`, `dependsOn` or `skipGitRepoCheck`. |
|
|
158
161
|
| `resume_codex_worker` | `task_id`, `prompt`, `rebaseOnto`, `acceptance`, `context` | Continue the same Codex conversation; `thread_id` stays. `rebaseOnto` first moves the worktree onto the project's newer commit (stash, skip integrated patches, replay new commits, unstash); a conflict puts it back and does not start the worker |
|
|
159
|
-
| `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states. 60 seconds by default
|
|
162
|
+
| `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `pollMs`, `compact`, `emitProgress`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states. 60 seconds by default. `termination_reason` distinguishes settled, exhausted budget and client cancellation. `emitProgress: true` emits progress every 30 seconds when the client supplies a progress token. `compact` returns one row per worker |
|
|
160
163
|
| `get_orchestration_overview` | `status`, `limit` | Every worker in one table, capped at 7000 bytes. Carries `version` and `update` |
|
|
161
164
|
| `get_worker_result` | `task_id`, `limit`, `maxChars`, `includeFiles` | The worker's own report, clipped past 6000 bytes with `truncated` and the size to ask for. `acceptance` is whether the supervisor's own checks passed, `verification` the commands the worker ran with exit codes, `base_behind` how far main has moved (`behind` is `null` with a note when `contains_base` is false, meaning the directory switched lines) |
|
|
162
|
-
| `get_worker_diff` | `task_id`, `maxChars`, `paths` | What the worker actually changed
|
|
165
|
+
| `get_worker_diff` | `task_id`, `file`, `hunk`, `pageSize`, `cursor`, `maxChars`, `paths` | What the worker actually changed. The default response is a complete file/hunk index. Select one file and page hunks with `hunk` or `cursor`; `maxChars` without `file` keeps the legacy bounded full-diff mode |
|
|
163
166
|
| `ask_codex_worker` | `task_id`, `question`, `timeoutMs`, `maxChars`, `fresh`, `end` | Ask the worker on the side. Its thread is forked into a read-only session with no network and no MCP tools; the worker itself is untouched. A resumed worker gets a new fork by itself, `fresh` forces one, `end` deletes it |
|
|
164
167
|
| `land_codex_worker` | `task_id`, `onto`, `commitMessage`, `ignoreAcceptance`, `allowOutsideOwned` | Cherry-pick the worker's `codex/<id>` commits onto the current branch of the dispatch directory: clean target only, a conflict rolls back, a failed acceptance is refused. A malformed report summary no longer blocks an explicit landing when acceptance and the reviewed diff are sound. `commitMessage` first commits its uncommitted edits as one commit; `ignoreAcceptance` lands anyway |
|
|
165
168
|
| `verify_delivery_push` | `task_id`, `remote`, `branch` | Fetch a remote branch and prove landed_head is reachable; records push_verified and creates a cleanup plan without pushing or deploying |
|
|
@@ -188,12 +191,28 @@ Thirty-nine.
|
|
|
188
191
|
| `check_for_update` | `force` | Ask the registry for a newer version |
|
|
189
192
|
| `cancel_codex_worker` | `task_id` | Stop a worker. Falls back to the pid across processes, after confirming that pid runs codex |
|
|
190
193
|
|
|
191
|
-
Two are required: `ownedPaths`
|
|
194
|
+
Two fields are required by the MCP schema: `ownedPaths` and `goal.objective`. A writer must also pass the workflow preflight gate described above; the schema keeps `preflight_id` optional for old clients, which is a compatibility escape hatch, not the normal path. `ownedPaths` overlap is reserved at dispatch, the runtime guard checks direct file writes, and landing checks the complete diff.
|
|
192
195
|
|
|
193
196
|
`acceptance` runs in Bash with `errexit` and `pipefail`: an unhandled failure stops the check, including a failing test in `npm test | tail`. Workers run `node "$CODEX_SUPERVISOR_ACCEPTANCE_CLI"` for the exact supervisor contract instead of retyping checks in an interactive zsh. Handle expected failures explicitly with `if` or `||`; a timeout always fails, even when the command exits 0 after termination. Windows requires Git for Windows Bash and reports an error when it is missing. Displayed output is clipped without changing the exit code.
|
|
194
197
|
|
|
195
198
|
In a repository with `package.json`, acceptance that uses local JavaScript tooling such as `npm`, `pnpm`, `vitest`, `vue-tsc`, `eslint` or `nuxi` is rejected with `workspace_setup_required` unless `workspaceSetup` was provided. Dependency preparation is now a runtime gate, not a reminder for the model.
|
|
196
199
|
|
|
200
|
+
The standard frontend worktree setup is:
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"workspaceSetup": {
|
|
205
|
+
"links": [{ "path": "node_modules", "source": "node_modules" }],
|
|
206
|
+
"submodules": true,
|
|
207
|
+
"commands": ["npx nuxi prepare"]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Pass the same setup to `preflight_codex_worker` and the target `create_codex_worker`; otherwise the runtime contracts do not match.
|
|
213
|
+
|
|
214
|
+
When dispatch omits `goal.tokenBudget`, the worker must omit `token_budget` entirely. The runtime guard rejects `0`, `1`, `null` and any invented value. If a budget is supplied explicitly, the worker must use that exact positive integer.
|
|
215
|
+
|
|
197
216
|
Acceptance commands receive `CODEX_SUPERVISOR_TASK_ID`, `CODEX_SUPERVISOR_BASE_COMMIT` and `CODEX_SUPERVISOR_RUN`: the current task, run base and run number, refreshed after rebase/resume.
|
|
198
217
|
|
|
199
218
|
Structured acceptance entries use `{command, reportPath, baseline}`. The baseline contains `identity.base_commit`, `failures` (test_id/kind/signature), and `required`; the report contains complete, identity, failures, executed, skipped, and the current `CODEX_SUPERVISOR_CHECK_ID`. Missing/skipped required tests, reused evidence, and changed failures reject acceptance while preserving the shell exit code. reportPath must remain inside the working directory; write reports to an ignored temporary directory so they are not landed.
|
|
@@ -206,6 +225,8 @@ Wait defaults to 60 seconds and compact rows; includeEvents selects details unle
|
|
|
206
225
|
|
|
207
226
|
Each run injects the shipped PreToolUse guard: apply_patch checks every target including renames and symlinks; forbid rejects red lines. Shell allows simple reads and explicitly declared allowedCommands/acceptance. Declared validation scripts run with dispatcher privileges and may have side effects; this is not a filesystem sandbox for arbitrary programs. Resume/follow-up inherit the policy without changing global hooks. Empty write runs use current output and command evidence and surface no_work; read-only tasks are not empty merely for having no diff.
|
|
208
227
|
|
|
228
|
+
Workers are not dispatchers. A worker starts with the codex-supervisor MCP server disabled, so it cannot dispatch, resume, cancel or edit another session. Business MCP servers remain available. Side-chat forks disable every MCP server.
|
|
229
|
+
|
|
209
230
|
A model with no separate `apply_patch` tool (measured with Codex 0.162 + DeepSeek/cc-switch) sends the patch as a shell call: `apply_patch <<'EOF' ... EOF`. The guard accepts that shape and judges every target path with the same ownedPaths rule, so such a model can still edit; an unquoted heredoc, or one followed by `&&`/`;`, is refused.
|
|
210
231
|
|
|
211
232
|
An `allowedCommands` entry ending in `*` is a prefix match (so `go test ./internal/*` covers `go test ./internal/service -run TestX`), valid only for a single command without shell metacharacters. An editor worker may also read with grep/sed (without `-i`)/find (without `-exec`/`-delete`)/jq (without `-i`)/awk, the git read subcommands and pure read pipes such as `cmd | head|tail|wc|sort|uniq`; `tee`, redirects and `env` stay refused. The guard is not a filesystem sandbox: a miss only writes inside the worker's own worktree, and land refuses it.
|
|
@@ -283,6 +304,7 @@ A terminal state lands in two steps: `turn.completed` sets `completed`, the proc
|
|
|
283
304
|
| `CODEX_SUPERVISOR_SKIP_SKILL_SYNC` | unset | `1` turns the skill sync at server start off |
|
|
284
305
|
| `CODEX_SUPERVISOR_SKIP_SETUP` | unset | `1` skips the `postinstall` setup |
|
|
285
306
|
| `CODEX_SUPERVISOR_NPM` | unset | npm for the auto-update; default is the one shipped with the running node |
|
|
307
|
+
| `CODEX_SUPERVISOR_HANDOFF_TOKEN_THRESHOLD` | `300000` | Native-goal token count that marks a worker `handoff_recommended`; `0` disables the warning |
|
|
286
308
|
|
|
287
309
|
GUI clients (Claude Desktop, Cursor, Windsurf) are not automatic registration targets of this installer: add this to their MCP config file, and since their `PATH` often lacks `codex`, give `CODEX_BIN` explicitly:
|
|
288
310
|
|
|
@@ -339,7 +361,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
339
361
|
- In the default `workspace-write` sandbox a worker cannot commit (Codex keeps `.git` read-only). Use `land_codex_worker` with `commitMessage`; do not switch to `danger-full-access` just to commit.
|
|
340
362
|
- The worktree is cut from a commit; uncommitted work in your checkout is not in it.
|
|
341
363
|
- Only the working directory is isolated. Temp directories, databases and ports are shared.
|
|
342
|
-
- `ownedPaths` is
|
|
364
|
+
- `ownedPaths` overlap is reserved at dispatch. The runtime guard checks direct file edits and landing checks the complete diff. Declared scripts can still produce side effects outside the list, so this is not a complete filesystem sandbox.
|
|
343
365
|
- Acceptance checks exactly what `acceptance` says. Anything not written there is not checked; `verification` is only what the worker ran itself, and the rest is the main thread reading the diff.
|
|
344
366
|
- One `wait_codex_workers` cannot wait to the end; the client's MCP tool timeout is a hard wall. Call it again.
|
|
345
367
|
- `search_works` is substring matching, fine for hundreds of works.
|
package/README.md
CHANGED
|
@@ -65,12 +65,15 @@ codex mcp add codex-supervisor -- npx -y codex-supervisor-mcp
|
|
|
65
65
|
主线程背后做的事(你也可以自己调工具):
|
|
66
66
|
|
|
67
67
|
```
|
|
68
|
-
|
|
68
|
+
preflight_codex_worker 同 workspace/base/sandbox/guard 先跑必要 probe
|
|
69
|
+
get_worker_preflight 确认 passed;contract 变化就重跑
|
|
70
|
+
create_codex_worker ×3 每路带 preflight_id、session_id、ownedPaths、goal
|
|
69
71
|
wait_codex_workers 默认等 60 秒,到点返回快照,没完就接着等
|
|
70
72
|
get_worker_result ×3 收每路的汇报,带它真跑过的命令和退出码
|
|
73
|
+
get_worker_diff ×3 看实际改动;证据对得上再决定是否 land
|
|
71
74
|
```
|
|
72
75
|
|
|
73
|
-
每路的改动在各自的 `codex/<taskId>`
|
|
76
|
+
每路的改动在各自的 `codex/<taskId>` 分支上。验收和 diff 都过了,主线程用 `land_codex_worker` 带 `commitMessage` 合入;worker 不自行提交。
|
|
74
77
|
|
|
75
78
|
### 3. 开看板
|
|
76
79
|
|
|
@@ -99,7 +102,7 @@ node "$CODEX_SUPERVISOR_STAGE_CLI" "gate:s3" --detail "integration queue"
|
|
|
99
102
|
| 我 | | 定需求,拍板,看汇报 |
|
|
100
103
|
| 规划会话 | 需求和文档仓 | 聊需求,写详设,每一块活写一份任务书,末尾附一段发给主脑的话 |
|
|
101
104
|
| 主脑会话 | 代码仓的一个 worktree | 读任务书,派 Codex worker,核每路的 diff,把结果填回任务书,向我汇报。不写业务代码 |
|
|
102
|
-
| Codex worker | 各自的 worktree | 一个 worker
|
|
105
|
+
| Codex worker | 各自的 worktree | 一个 worker 做一个能独立验收的功能包,在远端机器上修改、运行验收。不 commit、不 push、不合并 |
|
|
103
106
|
|
|
104
107
|
两个会话之间只传一段文字,粘进主脑会话用 `/goal` 接上。结构固定:
|
|
105
108
|
|
|
@@ -109,12 +112,13 @@ node "$CODEX_SUPERVISOR_STAGE_CLI" "gate:s3" --detail "integration queue"
|
|
|
109
112
|
【背景】 这一块为什么做,上一块留下了什么
|
|
110
113
|
【先读】 哪几份文档的哪几节。几份说法不一样时以哪份为准
|
|
111
114
|
【仓和分支】工作目录在哪,各分支现在在哪个提交,哪些分支只读
|
|
112
|
-
【做什么】
|
|
115
|
+
【做什么】 照任务书第几节那张表做。按能独立验收的功能包拆,表里没有的不做。worker 不自行 commit
|
|
113
116
|
【派活】 先 search_works 看有没有派过,别重复
|
|
114
117
|
整批用同一个 session_id
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
改同一批文件就串行,写入范围不重叠才并行。ownedPaths 覆盖实现、测试、路由、DI、配置和迁移
|
|
119
|
+
依赖先写 workspaceSetup;写 worker 先过同 contract 的 preflight
|
|
120
|
+
task 写全:背景、文档出处、完整写集、验证命令、输出格式
|
|
121
|
+
验证命令同时填 acceptance;worker 用 CODEX_SUPERVISOR_ACCEPTANCE_CLI 自查
|
|
118
122
|
worker 交回来先看 diff。它说过了不算,你看到才算
|
|
119
123
|
【构建和测试】全走远端机器,本机不跑
|
|
120
124
|
【红线】 不改什么,不推什么,不读什么
|
|
@@ -128,18 +132,16 @@ node "$CODEX_SUPERVISOR_STAGE_CLI" "gate:s3" --detail "integration queue"
|
|
|
128
132
|
search_works 查这批活派过没有
|
|
129
133
|
preflight_codex_worker 同环境跑 probe,确认 sandbox / guard / base / cache 真可用
|
|
130
134
|
get_worker_preflight 核 probe 的实际 command evidence;passed 才能派目标 worker
|
|
131
|
-
create_codex_worker
|
|
135
|
+
create_codex_worker 一个功能包一个 worker,同一个 session_id,ownedPaths 不重叠
|
|
132
136
|
wait_codex_workers 60 秒一轮,compact: true,没完接着调
|
|
133
137
|
get_worker_result 它说自己做了什么,verification 里是它真跑过的命令
|
|
134
138
|
get_worker_diff 它实际做了什么
|
|
135
139
|
ask_codex_worker 对不上就问它为什么,只读,不动它的线程
|
|
136
|
-
resume_codex_worker
|
|
137
|
-
land_codex_worker
|
|
140
|
+
resume_codex_worker 要改就继续同一线程;主线走远了带 rebaseOnto
|
|
141
|
+
land_codex_worker 核过了,带 commitMessage 代提交并落进集成分支
|
|
138
142
|
```
|
|
139
143
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
为什么一个 worker 只做一步:第 5 步做错了,让做第 5 步的那个 worker `resume_codex_worker` 一下,改完 `--amend` 并回它自己那个提交,主脑再核一次,过了才落进集成分支。要是一个 worker 连做了 5、6、7 三步,第 5 步错了就没法这样改,6 和 7 的提交已经叠在 5 上面,改 5 得连 6、7 一起重做。
|
|
144
|
+
功能包在 land 前仍可 `resume_codex_worker` 继续修改。真正需要拆开的原因是写集冲突、依赖顺序或独立验收,不是“每一步都必须换一个模型线程”。
|
|
143
145
|
|
|
144
146
|
## 看板里有什么
|
|
145
147
|
|
|
@@ -159,13 +161,13 @@ land_codex_worker 核过了,落进集成分支
|
|
|
159
161
|
|
|
160
162
|
| 工具 | 入参 | 作用 |
|
|
161
163
|
|---|---|---|
|
|
162
|
-
| `check_workers` | 无参 | 交付新终态、验收失败和需处理goal;新格式第1轮lost/no_work自动恢复一次,未变返回quiet;用宿主定时唤醒调用,每个主线程设独立CODEX_SUPERVISOR_OBSERVER_ID可在重启后接回 |
|
|
164
|
+
| `check_workers` | 无参 | 交付新终态、验收失败和需处理goal;新格式第1轮 `lost` / `no_work` / `invalid_report` 自动恢复一次,未变返回quiet;用宿主定时唤醒调用,每个主线程设独立CODEX_SUPERVISOR_OBSERVER_ID可在重启后接回 |
|
|
163
165
|
| `overview_delta` | `cursor` | 主线程默认轮询入口:只返回 active / needs_attention / ready_to_land / ready_to_clean、cursor 后变化、短版 attention_reason / next_action 和 next_cursor;不返回全量历史、prompt、diff、event 或 worker capsule |
|
|
164
166
|
| `check_acceptance` | `cwd`, `acceptance`, `baseRef`, `timeoutMs` | 派单前实际运行给定验收命令,不建 worker,不证明 worker 完成;数量 grep 会提示不能证明失败名单和必跑执行 |
|
|
165
167
|
| `preflight_codex_worker` | `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, `ownedPaths`, `probeCommands`, `baseRef`, `sandbox`, `allowedCommands`, `context`, `contracts`, `networkAccess`, `writableRoots` | 用与目标 worker 相同的 workspace/base/sandbox/guard 起短 probe worker;它必须实际跑完每条 probe command。probe 自动获得本次 guard-only 允许,但不进入目标 worker contract;联网和凭据目录仍须显式授权 |
|
|
166
168
|
| `get_worker_preflight` | `task_id` | 返回 probe 的实际 command evidence、运行环境 contract hash、worker outcome 和 `running/passed/failed`;probe 全部执行通过时,报告 JSON 错误或已 exit 0 的 close-handler 缺失只留诊断,不误判环境失败 |
|
|
167
169
|
| `create_codex_worker` | `task`, `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, **`ownedPaths`**, **`goal`**, `preflight_id`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `maxRunMs`, `maxTotalMs`, `acceptance`, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Git 默认隔离 worktree;非 Git 写入必须选 `scratch` 或有授权、paths、acceptance 的 `in_place_write`。`workspaceSetup` 在起 worker 前链接依赖、初始化子模块、跑 prepare;`preflight_id` 给了就必须是通过的同环境 probe |
|
|
168
|
-
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`,
|
|
170
|
+
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, `session_title`, `title`, `cwd`, `sandbox`, `model`, `ownedPaths`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `workspaceKind`, `workspaceSetup`, `goal`, `baseRef`, `acceptance` | 开一个新会话,把老 worker 的 prompt、状态、近期事件拼进去;不支持 `preflight_id`、`dependsOn`、`skipGitRepoCheck` |
|
|
169
171
|
| `resume_codex_worker` | `task_id`, `prompt`, `rebaseOnto`, `acceptance`, `context` | 接同一个 Codex 会话继续跑,`thread_id` 不变。`rebaseOnto` 先把 worktree 挪到主线新头(stash、跳过已合入补丁、重放新增提交、放回),冲突原样退回不起 worker |
|
|
170
172
|
| `wait_codex_workers` | `task_ids`, `mode`(any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `emitProgress`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | 等终态。默认 60 秒且不推周期 heartbeat;显式 `emitProgress: true` 才每 30 秒通知。`termination_reason` 区分 settled / budget_exhausted / client_cancelled;`compact` 每路一行 |
|
|
171
173
|
| `get_orchestration_overview` | `status`, `limit` | 全部 worker 的状态表,封顶 7000 字节。带 `version` 和 `update` |
|
|
@@ -199,12 +201,26 @@ land_codex_worker 核过了,落进集成分支
|
|
|
199
201
|
| `check_for_update` | `force` | 问 registry 有没有新版本 |
|
|
200
202
|
| `cancel_codex_worker` | `task_id` | 终止 worker。跨进程按 pid 兜底,先确认那个 pid 跑的是 codex |
|
|
201
203
|
|
|
202
|
-
|
|
204
|
+
MCP schema 必填两个:`ownedPaths` 和 `goal.objective`。写 worker 还必须通过上面的 preflight 工作流门禁;`preflight_id` 暂时保留为 optional 只为兼容旧客户端,不是正常流程可以跳过。`ownedPaths` 的写冲突在派单时预留,运行时 guard 会查直接写入,land 会再查完整 diff。
|
|
203
205
|
|
|
204
206
|
`acceptance` 在 Bash 中启用 `errexit` 和 `pipefail`:未处理的失败会停止检查,`npm test | tail` 中的测试失败也会保留。worker 自查必须运行 `node "$CODEX_SUPERVISOR_ACCEPTANCE_CLI"`,它执行同一份 supervisor 验收契约;不要手抄到 zsh,变量拆词等交互壳差异不会污染证据。写 worker 不能只用 `test -s`、`test -f` 或 `[ -e ]` 这类文件存在性命令交付;要加真实 test、endpoint probe 或结构化执行证据。识别到的 test runner 输出 `no tests to run` / `[no test files]` 时,即使退出码是 0 也判失败。预期失败用 `if` 或 `||` 显式处理;超时始终判失败,即使命令收到终止信号后退出 0。Windows 需要 Git for Windows 的 Bash;找不到会报错。显示的输出会裁剪,退出码不会因此改变。
|
|
205
207
|
|
|
206
208
|
`package.json` 仓库里,如果 `acceptance` 使用 `npm`、`pnpm`、`vitest`、`vue-tsc`、`eslint`、`nuxi` 等本地 JavaScript 工具,而派单没有 `workspaceSetup`,会直接拒绝为 `workspace_setup_required`。这条是 runtime 硬门禁,不再靠模型记得手工链接依赖。
|
|
207
209
|
|
|
210
|
+
前端 worktree 的标准配置:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"workspaceSetup": {
|
|
215
|
+
"links": [{ "path": "node_modules", "source": "node_modules" }],
|
|
216
|
+
"submodules": true,
|
|
217
|
+
"commands": ["npx nuxi prepare"]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
同一份配置要同时传给 `preflight_codex_worker` 和目标 `create_codex_worker`,否则 runtime contract 不匹配。
|
|
223
|
+
|
|
208
224
|
普通 worker 启动时会关闭它继承到的 `codex-supervisor` MCP,不能再派 worker、resume、cancel 或改编排状态;主线程是唯一编排者。其他业务 MCP 不受影响;旁问 fork 仍关闭全部 MCP,因为它只允许只读回答。
|
|
209
225
|
|
|
210
226
|
`session_id` 只负责批次、默认门禁和审批,不再把同批 worker 的标题、汇报或 session objective 自动塞进新 worker。worker 只收到内部编译的 context capsule:L0 只标明 branch 与 acceptance 来源(不塞命令正文)、自身身份/任务、显式依赖的最小交付摘要和路径/SHA 命中的 verified facts;raw event、完整 diff、历史报告、candidate facts 都只可按需读取。repo fact 只有两个 checkout 的 canonical `origin`、repo-relative watched path 和 base SHA 同时匹配时才跨 checkout 可见;无可识别 origin 就保持 work-scoped。事实的 base SHA 不再覆盖、watched path 发生 Git diff、context 输入内容 hash 或非 Git in-place manifest 漂移时会自动追加 `expired` 版本并从 capsule 排除。主线程只看 `get_context_snapshot_meta`,需要证据时再显式 `get_fact` / `get_worker_result` / `get_worker_diff`。
|
|
@@ -361,7 +377,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
361
377
|
- 默认 `workspace-write` 沙箱里 worker 提交不了(Codex 把 `.git` 设成只读)。收活时 `land_codex_worker` 带 `commitMessage` 替它提交;不要为了提交改用 `danger-full-access`。
|
|
362
378
|
- worktree 从一个提交切,你工作区里没 commit 的东西不在里面。
|
|
363
379
|
- 只隔离工作目录。临时目录、数据库、端口是共用的。
|
|
364
|
-
- `ownedPaths`
|
|
380
|
+
- `ownedPaths` 的冲突预留只在派单时计算;运行时 guard 会拦直接文件写入,land 会再查完整 diff。声明脚本仍可能产生清单外副作用,不能把它当完整文件系统沙箱。
|
|
365
381
|
- 验收是 `acceptance` 里写了什么就查什么。没写的事它不会替你查,`verification` 只是 worker 自己跑过的命令,剩下的靠主线程看 diff。
|
|
366
382
|
- 一次 `wait_codex_workers` 等不到底,客户端的 MCP 工具超时是硬墙,靠反复调。
|
|
367
383
|
- `search_works` 是子串匹配,几百条够用。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-supervisor-mcp",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"mcpName": "io.github.zriyox/codex-supervisor-mcp",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "MCP server that dispatches and supervises parallel Codex CLI workers, one isolated Git worktree each, with a persisted work state machine.",
|
|
@@ -1,196 +1,133 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: codex-supervisor
|
|
3
|
-
description:
|
|
3
|
+
description: 用 Codex CLI 并行做可独立验收的功能包,每路一个 Git worktree,能派单、等待、验收、恢复、合入和清理。用户说“派 codex”“并行跑”“多 agent”“接回旧 worker”时使用。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# codex-supervisor
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
主线程负责拆包、定写集、准备环境、验收和合入。worker 只在自己的 worktree 里完成一个功能包,不负责编排,也不负责交付到远端。
|
|
9
9
|
|
|
10
10
|
## 什么时候用
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
适合能拆成几路、每路能单独验收的活,也适合耗时长、中途可能断、需要保留证据的工作。纯问答、单文件小改、需要频繁来回确认的活,主线程自己做更快。
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## 派单前必须确认
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
1. 先 `search_works`,确认没有重复派工。
|
|
17
|
+
2. 按功能闭环拆包,不按 DTO、方法或单个测试拆。每路要有清楚的输入、产出和 acceptance。
|
|
18
|
+
3. `ownedPaths` 要覆盖完整写集:实现、测试、路由、注册表、DI、配置、迁移、i18n、模板接线都算。拿不准就给唯一模块目录。
|
|
19
|
+
4. 依赖必须提前放进 worktree。前端链接 `node_modules` 并执行 `nuxi prepare`;后端初始化 submodule。不要 sleep 抢时间,也不要等主线程事后补。
|
|
20
|
+
5. 写 worker 先跑同 contract 的 `preflight_codex_worker`。`get_worker_preflight` 必须是 `passed`,再把 preflight task id 填进 `preflight_id`。`check_acceptance` 不能代替 worker 环境预检。
|
|
21
|
+
6. 只要 worker 会 land,就必须有能证明结果的 acceptance。文件存在检查只能当附加条件,不能单独当完成证据。
|
|
22
|
+
7. `workspace-write` worker 不执行 `git add`、`git commit` 或 `amend`。验收通过后由主线程 `land_codex_worker(commitMessage)` 代提交并落地。
|
|
23
|
+
8. worker 不 push、不合并、不再派生 worker。临时 `codex/<id>` 分支不是交付物。
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
`preflight_id` 是 AI 派单硬规则。MCP schema 为了兼容旧客户端仍允许省略,但不能把“没被 schema 拒绝”当成可以跳过预检。
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
2. 拆功能包。每路写清楚:干什么、完整写集和 `ownedPaths`、依赖谁、怎么算做完和谁负责集成。改同一批文件就串行;文件不重叠只是并行前提,不等于依赖已满足。
|
|
27
|
-
3. 写 worker 先 `preflight_codex_worker`:用目标同一份 `workspaceKind` / `baseRef` / `ownedPaths` / `sandbox` / `allowedCommands` / `context` / `networkAccess` / `writableRoots` 跑必要命令。等它终态后 `get_worker_preflight` 必须 `passed`,再把它的 `task_id` 填进 `create_codex_worker.preflight_id`。contract 变了重跑,不能拿宿主 `check_acceptance` 冒充 worker 环境成功。
|
|
28
|
-
4. `create_codex_worker` 派出去。回执只有 `id`、`worktree_path`、`branch`、`owned_paths`、`status`,不回传任务原文。
|
|
29
|
-
5. 长任务配宿主 `/loop 5m check_workers` 定时收活,没变化 quiet,有新结果按 next_step 收。工具会按规则恢复一次,但不会唤醒关闭的主窗口;每个主线程设独立 `CODEX_SUPERVISOR_OBSERVER_ID` 可重启接回。短等用 `wait_codex_workers` 的 `timeoutMs: 60000`、`compact: true`,到点继续同批 task_ids。
|
|
27
|
+
## 标准派单
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
前端示例,preflight 和目标 worker 必须使用同一份 contract:
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
| `writableRoots` | 只有需要凭据目录时才传(绝对路径、已存在、自动解析软链、只对 workspace-write 生效):ssh/远程测试 → `["~/.ssh"]`;kubectl → `["~/.kube"]`;推私有镜像 → `["~/.docker"]`;aws cli → `["~/.aws"]`;签名提交 → `["~/.gnupg"]`。缓存目录不用写,已经自动加 |
|
|
43
|
-
| `ownedPaths` | 必填。这路允许写的路径,和在跑的 worker 重叠会被拒(**读不排他**,多路读同一份共享文件合法)。冲突是好事,说明该改拆法。传 `[]` 表示这路不落地:只读验证或研究 |
|
|
44
|
-
| `goal.objective` | 必填。一句话说目标,worker 会建成 Codex 原生 goal;不传 `goal.tokenBudget` 就是不限预算,runtime guard 会拒绝 worker 自填 `token_budget` |
|
|
45
|
-
| `session_id` | 同一批传同一个值。只管批次、默认验收和审批,不是上下文继承边界;第一路顺手带 `session_title`(30 字内,看板和 `get_session_works` 显示它),漏了用 `describe_session` 补 |
|
|
46
|
-
| `dependsOn` | 有先后依赖填上游的 `task_id`,它是硬门禁:上游必须同 `project_root`、成功结算、配置了 acceptance 就已通过、已 `land_codex_worker`,并且本路实际 `baseRef` 包含上游 `landed_head`。没满足先集成/修验收,不会启动下游 |
|
|
47
|
-
| `baseRef` | worktree 从哪个提交切,默认 `HEAD`。第 N+1 步要建立在第 N 步上,填 `codex/<第 N 步 task_id>` |
|
|
48
|
-
| `preflight_id` | 写 worker 必填。先跑 `preflight_codex_worker`,它实际在目标 sandbox/guard 里执行 `probeCommands`;`get_worker_preflight.status` 必须是 `passed`。base、ownedPaths、命令、context、contracts、network、可写根有变化就重跑 |
|
|
49
|
-
|
|
50
|
-
`probeCommands` 会自动加入这次 probe worker 的 guard-only allowlist,不会进入目标 worker 的 runtime contract;目标 worker 仍只声明自己真正需要的 `allowedCommands`。ssh 等联网探针仍要显式 `networkAccess: true`,需要写 `known_hosts` 时同时声明 `writableRoots: ["~/.ssh"]`。
|
|
51
|
-
|
|
52
|
-
预检结论以 probe command evidence 为准,不把模型最终 JSON 或进程 close handler 当环境事实:所有探针都实际执行且通过、没有失败命令时,最终报告格式错误不会让预检失败;probe-only worker 即使最终变 `lost` 且退出码未记录,也只记诊断,不重跑。命令未执行、非零或取消仍失败。
|
|
53
|
-
| `sandbox` | 默认 `workspace-write`,worker 提交不了(Codex 把 `.git` 设成只读)。这是正常形状:worker 只改和验收,收活时 `land_codex_worker(commitMessage)` 由 supervisor 代提交;不要为提交改用 `danger-full-access` |
|
|
54
|
-
|
|
55
|
-
验收用 Bash 的 `errexit` + `pipefail`:`npm test | tail` 不能吞失败;文件存在只可做附加门禁,不能单独证明业务完成。预期失败用 `if` / `||` 显式判。超时、`no tests to run`、`[no test files]` 都失败,别只看退出码 0。Windows 要有 Git for Windows Bash;缺失先修工具,别换回 cmd。
|
|
56
|
-
|
|
57
|
-
验收取当前身份用 `CODEX_SUPERVISOR_TASK_ID` / `CODEX_SUPERVISOR_BASE_COMMIT` / `CODEX_SUPERVISOR_RUN`;worker 进程和 supervisor 验收子进程都会注入同一组当前值,rebase/resume 后一起更新。不要在命令里写死旧 base。
|
|
58
|
-
|
|
59
|
-
`check_acceptance` 只是在宿主权限跑验收命令,预检通过不代表 worker sandbox/guard/PATH/cache/network 可用;写 worker 的实际环境预检必须走上面的 `preflight_codex_worker`。已知失败必须按结构化 baseline 的用例名/类型/签名比,必跑项写 required;报告必须标本次 `CODEX_SUPERVISOR_CHECK_ID`,给 complete/identity/failures/executed/skipped,缺失、跳过和旧报告都不算过。reportPath 用工作区内忽略的临时目录,验收报告别混进业务提交。
|
|
60
|
-
|
|
61
|
-
同批公共门禁用 `describe_session.default_acceptance`,自动追加本路验收;更新目标/门禁传 `expected_revision`,避免旧窗口覆盖。需要用户拍板时设 `approval_state: waiting_user`,不得自动resume;获批改approved并同步宿主goal。回执host_goal_sync给当前策略的/goal命令;宿主已有原生goal时,用/goal替换条件,支持ProposeGoal时提议同一condition并走宿主批准。这个条件要求读取最新session revision,批准旧失败或waiting_user后不再追旧目标;工具不偷偷改/禁用Stop hook。
|
|
62
|
-
|
|
63
|
-
wait默认60秒和compact,带includeEvents则详细返回;默认不推周期 heartbeat,只有显式 `emitProgress: true` 才在客户端带 progress token 时每30秒通知。需要一条长 wait 被宿主转后台后只收终态,就保持默认;需要桌面进度才 opt-in。返回的 `termination_reason` 区分 `settled` / `budget_exhausted` / `client_cancelled`,通知不能唤醒关闭的宿主。/loop实测可定时调用,主窗口须保持运行。
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"workspaceSetup": {
|
|
34
|
+
"links": [{ "path": "node_modules", "source": "node_modules" }],
|
|
35
|
+
"submodules": true,
|
|
36
|
+
"commands": ["npx nuxi prepare"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
64
40
|
|
|
65
|
-
|
|
41
|
+
`package.json` 项目如果用 `npm`、`pnpm`、`vitest`、`vue-tsc`、`eslint`、`nuxi` 等本地工具做验收,却没传 `workspaceSetup`,supervisor 会直接返回 `workspace_setup_required`。
|
|
66
42
|
|
|
67
|
-
|
|
43
|
+
## 关键参数
|
|
68
44
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
|
45
|
+
| 参数 | 怎么填 |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `task` | 写清目标、背景、要改的交付面、边界和验收。不要写“优化一下”。最终报告格式由 supervisor 追加,不在这里重复 |
|
|
48
|
+
| `cwd` | Git 项目根,或非 Git 输入目录;实际执行目录由 `workspaceKind` 决定 |
|
|
49
|
+
| `workspaceKind` | Git 代码默认 `git_worktree`;非 Git 只读用 `read_only_in_place`;联网研究用 `scratch`;明确授权修改非 Git 目录才用 `in_place_write` |
|
|
50
|
+
| `workspaceSetup` | Git worktree 启动前准备依赖。支持 `links`、`submodules`、`commands`。链接 `node_modules` 时会给 `.vite`、`.vite-temp`、`.cache` 可写缓存根 |
|
|
51
|
+
| `ownedPaths` | 必填。完整写入范围;不同 worker 的写入范围不能重叠。读取不排他。`[]` 只用于不 land 的只读或研究 worker |
|
|
52
|
+
| `sandbox` | 默认 `workspace-write`。这个沙箱不能 commit,这是正常边界;不要为了提交改用 `danger-full-access` |
|
|
53
|
+
| `preflight_id` | 写 worker 必填。preflight 的 base、`workspaceKind`、`sandbox`、`workspaceSetup`、`ownedPaths`、命令、context、contracts、network、可写根有任何变化都要重跑 |
|
|
54
|
+
| `acceptance` | worker 退出后由 supervisor 在 worktree 里执行。worker 自查统一运行 `node "$CODEX_SUPERVISOR_ACCEPTANCE_CLI"`,不要手抄到 zsh。每个检查必须真实证明功能 |
|
|
55
|
+
| `allowedCommands` | 声明会执行、会写入或有副作用的验证命令。read 命令有安全白名单;命令末尾 `*` 表示只匹配单条命令的前缀 |
|
|
56
|
+
| `forbid` | 明确禁止的命令片段。forbid 优先于 allowedCommands 和 acceptance |
|
|
57
|
+
| `goal.objective` | 必填。worker 会创建 Codex 原生 goal |
|
|
58
|
+
| `goal.tokenBudget` | 可选。不传就是不限预算,worker 必须完全省略 `token_budget`;传 `0`、`1` 或 `null` 会被 runtime guard 拒绝 |
|
|
59
|
+
| `session_id` | 同一批使用同一个值。它只负责分组、默认验收和审批,不会把同批 worker 的上下文互相注入 |
|
|
60
|
+
| `session_title` | 建议 30 字内,schema 上限 120 字;漏了可用 `describe_session` 补 |
|
|
61
|
+
| `dependsOn` | 填上游 task id。上游必须成功结算、acceptance 通过并 `land_codex_worker`,且本路 base 包含上游 landed head |
|
|
62
|
+
| `baseRef` | worktree 从哪个提交切。下一步要包含上一步时,填 `codex/<task_id>` 或已集成分支 |
|
|
63
|
+
|
|
64
|
+
派 `create_codex_worker` 后,回执不回传 task 原文。回执至少带 `id`、`worktree_path`、`branch`、`owned_paths`、`status`;有 base、session、failure 或 run log 时也会返回。
|
|
65
|
+
|
|
66
|
+
## worker 形状
|
|
67
|
+
|
|
68
|
+
| 形状 | 参数 | 用途 |
|
|
74
69
|
|---|---|---|
|
|
75
|
-
| Git 编辑
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
| 非 Git 写入
|
|
79
|
-
|
|
80
|
-
read-only 下 `networkAccess: true` 会被拒(实测该沙箱连 DNS 都不通,配了也没用);要联网就按 `scratch` 研究 worker 派。非 Git `workspace-write` 不写 `workspaceKind` 会拒绝,绝不偷偷落到用户目录。研究 worker 的 shell 不受 allowedCommands 限制,forbid 红线照旧。读共享文件永远不排他,只有写按 ownedPaths 排他。
|
|
81
|
-
|
|
82
|
-
check_workers可对已死的第1轮lost/no_work/invalid_report自动resume一次,recoveries记动作;invalid_report只让它重发裸JSON、不重做活,审批/认证/权限/quota不盲重试。连续两轮同 fingerprint 的无输出/无命令会变 `two_stall` + `needs_attention`,禁止再自动 resume;看 evidence 决定主线程接管、修工具或重派。最终报告强制JSON,但报告只是摘要:常见安全修复包括把单个字符串归一成 string[]、补上唯一缺失的 `]`/`}`;invalid_report 保留 `completed` 生命周期和 attention,不否定同 run 的 acceptance/diff。先自动重发一次,仍失败可审过 diff 后显式 land。
|
|
83
|
-
|
|
84
|
-
未提交材料用context:[{path:绝对路径,sha256:可选}];首次记哈希,resume材料变了要显式换context。context/contracts总6000字、最多20份文件,每份≤5 MB;handoff1800字/16行可裁,完整约束和refs另传。输入路径不等于写授权。
|
|
85
|
-
|
|
86
|
-
共享写入必须externalOutputs:[{path,sha256?}]+acceptance;绝对文件每份≤1 MB,参与归属冲突/hook。看external_outputs的前后内容、哈希与验收;外部文件已经写在共享目录,不用land,不能拿空worktree diff否认成果。
|
|
70
|
+
| Git 编辑 | `workspaceKind: "git_worktree"`、非空 `ownedPaths` | 改代码、跑 acceptance、等待主线程 land |
|
|
71
|
+
| 只读验收 | `workspaceKind: "read_only_in_place"`、`sandbox: "read-only"`、`ownedPaths: []` | 无写入、无网络,只给结论 |
|
|
72
|
+
| 联网研究 | `workspaceKind: "scratch"`、`workspace-write`、`networkAccess: true`、`ownedPaths: []` | 可以 curl/gh,只写 supervisor 管理的 scratch,永不 land |
|
|
73
|
+
| 非 Git 写入 | `workspaceKind: "in_place_write"`、授权、完整 `ownedPaths`、acceptance | 只改明确授权的非 Git 目录,不能 land |
|
|
87
74
|
|
|
88
|
-
|
|
75
|
+
## 等待与状态
|
|
89
76
|
|
|
90
|
-
|
|
77
|
+
- 日常增量看 `overview_delta`,保存 `next_cursor`。需要全量状态时才用 `get_orchestration_overview`。
|
|
78
|
+
- 短等用 `wait_codex_workers`,建议 `timeoutMs: 60000`、`compact: true`。`still_running: true` 只表示这次等待预算用完。
|
|
79
|
+
- 长任务用宿主 `/loop 5m check_workers`。不同主线程设置不同的 `CODEX_SUPERVISOR_OBSERVER_ID`。
|
|
80
|
+
- `idle_seconds` 是距上一条 Codex 事件的时间。`command_running: true` 时长命令可能仍在跑;没有命令且长时间无事件,再查 `get_codex_worker_events`。
|
|
81
|
+
- 不要用 shell 循环 grep `data/runs/*.jsonl` 判断状态。`failed`、`lost`、退出码和恢复状态以 supervisor 状态机为准。
|
|
91
82
|
|
|
92
|
-
|
|
83
|
+
## 收活顺序
|
|
93
84
|
|
|
94
|
-
|
|
85
|
+
1. 先看 `acceptance`。失败时把 `checks[].output_tail` 原样带回 resume,不改验收标准。
|
|
86
|
+
2. 读 `get_worker_result`。注意 `commands_run`、命令退出码和 `last_command_failed`,不要只听结论。
|
|
87
|
+
3. 读 `get_worker_diff`。默认先看文件和 hunk 索引,再按 `file` + `hunk`/`cursor` 分页读 patch。
|
|
88
|
+
4. 对不上就问 `ask_codex_worker`。旁路只读,不改 worker 线程。
|
|
89
|
+
5. 要改就 `resume_codex_worker`。不要要求 worker commit 或 amend;主线前进时按需带 `rebaseOnto: "HEAD"`。
|
|
90
|
+
6. 验收和 diff 都过了,用 `land_codex_worker({commitMessage})` 把未提交改动提交到 worker 分支并 cherry-pick 到当前集成分支。
|
|
95
91
|
|
|
96
|
-
|
|
92
|
+
`invalid_report` 不是业务失败。常见情况是单个字符串字段、缺一个 `]`/`}`,或内容完整但 schema 不合规。先让 `check_workers` 做一次 report-only 修复;仍失败时,acceptance 通过且 diff 审过,可以显式 land。报告只是摘要,不是交付证据。
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
- 快照里 `idle_seconds` 是距上一条 Codex 事件多久,命令跑着和模型思考时 Codex 都不发事件。`command_running: true` 是长命令(`current_command` 是哪条),接着等;`command_running: false` 且 idle 超过 10 分钟,`get_codex_worker_events` 看最后几条,进程没了状态机会自己标 `lost`。
|
|
100
|
-
- `timeoutMinutes` 别超过客户端的 MCP 工具超时,否则被掐的是这次调用。
|
|
101
|
-
- **不要自己写 shell 循环 grep `data/runs/*.jsonl`**。进程被杀、`failed`、`lost`、`exit_code` 只有状态机知道,文件里没有;resume 过的 worker 文件里有多条 `turn.completed`;用户在终端里看到的是一行黑盒。
|
|
102
|
-
- 想省上下文改调 `get_orchestration_overview`,封顶 7000 字节。
|
|
94
|
+
## 上下文与事实
|
|
103
95
|
|
|
104
|
-
|
|
96
|
+
- worker capsule 只在新派单或 resume 时生成。默认注入 L0 身份、当前任务、依赖摘要和路径/SHA 命中的 verified facts。
|
|
97
|
+
- `session_id` peers、完整事件、完整 diff、历史报告和 candidate facts 不会自动注入。
|
|
98
|
+
- 主线程看事实摘要用 `search_worker_facts`;追溯来源用 `get_fact`;看证据索引用 `get_worker_evidence` / `get_artifact`。
|
|
99
|
+
- worker 的报告先记为 candidate。只有 supervisor acceptance 通过后,才有资格成为当前 work 的 verified outcome。
|
|
100
|
+
- base SHA、watched path、context hash 或 in-place manifest 变化后,旧 fact 会过期并从后续 capsule 排除。
|
|
105
101
|
|
|
106
|
-
|
|
107
|
-
1. `get_worker_result`:它说自己做了什么。默认截到 6000 字节,`truncated: true` 就按 `next_step` 带 `maxChars` 读全。`verification` 是它真跑过的命令和退出码:说"测过了"但 `commands_run: 0`、说"没建成"但那条命令退出码是 0、`last_command_failed: true` 却说完成、说"环境问题"但 `failed[].output_tail` 里是代码报错,都打回(走第 4 步),别替它圆。`base_behind.behind > 0` 说明派单后主线往前走了,改之前先 rebase(第 4 步);`contains_base: false` 时 `behind` 是 `null` 并带 `note`,那是派单目录换了线,不是落后。
|
|
108
|
-
2. `get_worker_diff`:它实际做了什么。默认只回完整文件/hunk 索引;再传 `file` + `hunk` 或 `cursor` 分页读 patch,避免 500 行测试文件一次灌满上下文。显式传 `maxChars` 且不传 `file` 才走旧的整份 bounded diff。它说过了不算,diff 对得上才算。
|
|
109
|
-
3. 对不上、看不懂为什么:`ask_codex_worker` 带 `question` 问它。fork 出一个只读旁路,worker 自己的线程不动;fork 没网络没 MCP 工具,问"改了什么、为什么、在哪",别问要联网才能答的事。超时回 `running`,只带 `task_id` 再调拿答案。worker 被 resume 过后下一问自动换新 fork,`fresh: true` 强制换,问完 `end: true` 删。
|
|
110
|
-
4. 要它改:`resume_codex_worker`,写清问题在哪;不要要求 `workspace-write` worker 自己 commit 或 amend。旁路只读,改东西永远走 resume。主线往前走过(`base_behind.behind > 0`)就带 `rebaseOnto: "HEAD"`(在派单目录里解析):未提交的改动先 stash,跳过已合入的补丁,只把新增提交重放到新头,stash 放回,`base_commit` 跟着动。冲突(`rebase_conflict` / `stash_conflict`)会原样退回、不起 worker、`files` 列冲突文件;这时先 `land_codex_worker` 带 `commitMessage` 让 supervisor 提交成一笔再 rebase,或者重派一路 `baseRef` 填新头。
|
|
111
|
-
5. 过了:`land_codex_worker` 把 `codex/<id>` 上的提交 cherry-pick 到派单目录当前分支。目标脏了、分支不对、冲突都拒绝并原样退回。worker 没提交(默认沙箱提交不了)就带 `commitMessage`,supervisor 在它分支上替它提交一笔再落。验收 `failed` 它会拒,修完再落;`ignoreAcceptance` 只在用户说了"就这样落"时用。
|
|
102
|
+
## 中断与恢复
|
|
112
103
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
高风险的步(迁移、改公共接口、"做完了"写不成命令的)用 `create_independent_verifier(task_id)`:它建独立 thread、`read_only_in_place`、无网络、无原 report/candidate facts,只给目标和当前 worktree。verifier 结算后主线程调用 `record_independent_finding` 记 passes/fails/inconclusive,必要时 `resolve_independent_finding` 收口;两路说法对不上,两边都别信,自己看 diff。
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
## 收工口径:活儿必须落地
|
|
119
|
-
|
|
120
|
-
**"文件写好了"不等于交付。** 本地 worktree / 未提交改动 / 未 push 的 commit,线上都看不到 —— 部署会因为缺类、缺文件、缺 bean 直接挂。派单和主线程自己的改动都按这四条走:
|
|
121
|
-
|
|
122
|
-
1. **worker 的产出默认要合并**:每个终态 worker 走 `get_worker_result` → `get_worker_diff`,过了就 `land_codex_worker`(sandbox 是 workspace-write 的 worker 没提交,带 `commitMessage` 一起提交再落)。不合并必须在报告里写清原因(验收失败 / 越界 / 等审批),不能默认留在 codex/<id> 分支上。
|
|
123
|
-
2. **主线程自己的改动必须 add + commit + push**:`git add <paths> && git commit -m ... && git push`。跳过任何一步都要显式说明,不允许说"改好了"然后留在工作区。
|
|
124
|
-
3. **上线前核对远端,不认本地**:部署或重启服务前先 `git fetch`,再确认目标提交里真有那些改动 —— `git log --oneline origin/<branch> -1`、`git ls-tree -r --name-only origin/<branch> | rg <新文件>`、必要时 `git show origin/<branch>:<path>`。线上报 `NoSuchBeanDefinition`、找不到类/模块、404,先查这一条,再查代码逻辑。
|
|
125
|
-
4. **交付报告三件套**:本地改动 → commit SHA → push 后的远端 SHA(以及部署状态)。缺远端 SHA 就不算完成。
|
|
126
|
-
5. **push 后计划清理**:`land_codex_worker` 只到本地集成;用户 push 后先 `verify_delivery_push`,它会生成 15 分钟有效的 `cleanup_plan`。SAFE 必须是「acceptance 明确 passed + push_verified + worktree 干净 + 无活跃进程/依赖 + Git 注册/归属可证明」;主线程复核 item 后才 `apply_cleanup(plan_id,item_ids)`。apply 前会重验 fingerprint,并重新 fetch remote 确认 landed SHA 仍可达;只执行 `git worktree remove/prune`。**branch、task、event、JSONL、artifact 永远保留**。脏、未验收、未合、未 push、force-push 回退、lost、failed、证明不足一律不删。`check_workers` 只提醒,不执行删除。
|
|
127
|
-
|
|
128
|
-
`land_codex_worker` 只到本地集成 `landed`,不是远端交付。用户已经 push 后,主线程调 `verify_delivery_push({task_id,remote:"origin"})`,它只 fetch + 祖先校验、不替你 push/部署;通过才记 `push_verified`,后续才可进入安全 cleanup 候选。
|
|
129
|
-
|
|
130
|
-
典型事故:两个实现类只存在于主线程的 worktree 里,没 add / 没 commit / 没 push,线上跑的还是上一个提交,Spring 找不到 bean 启动失败 —— 不是代码错,是没上线。
|
|
131
|
-
|
|
132
|
-
多 worktree 场景同理:worker 的分支、主线程的改动、集成 worktree 的合并,三者都要各自 push 到远端;只在自己 worktree 里"跑通了"不算。
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
## 读结果别把上下文撑爆
|
|
136
|
-
|
|
137
|
-
| 想干什么 | 用哪个 |
|
|
138
|
-
|---|---|
|
|
139
|
-
| 主线程日常增量 | `overview_delta`,保存 `next_cursor`;只看计数、变化 task 摘要、短版阻塞原因和下一步 |
|
|
140
|
-
| 全部 worker 的状态 | `get_orchestration_overview`,只在需要全量状态时用 |
|
|
141
|
-
| 一路的完整结论 | `get_worker_result` |
|
|
142
|
-
| 一路改了什么 | `get_worker_diff` 默认拿文件/hunk 索引;选一个 `file` 后用 `hunk` 或 `cursor` 分页。只要文件名用 `get_worker_result` 带 `includeFiles: true` |
|
|
143
|
-
| 活着还是完了 | `get_worker_summary` |
|
|
144
|
-
| 过程 | `get_codex_worker_events`,`kinds` 先滤、`limit` 限条数、`maxChars` 截长串,先看 `available_kinds` |
|
|
145
|
-
| 门禁内部阶段 | worker 脚本调用 `node "$CODEX_SUPERVISOR_STAGE_CLI" "gate:s3" --detail "..."`;status/overview/wait 显示 `current_stage`,终态保留 `last_stage`。不要写 secret |
|
|
146
|
-
| 一路的状态细节 | `get_codex_worker_status`,`current_action` 是它正在跑的命令 |
|
|
147
|
-
| 验收过没过 | 每个读都带 `acceptance`;命令和每条的输出在 `get_worker_result.acceptance.checks` |
|
|
148
|
-
| worker 吃了哪些上下文 | `get_context_snapshot_meta`,只看 fact IDs/token/排除项,不会回 capsule 正文 |
|
|
149
|
-
| 线程是否太长 | `thread_health`:`ok` / `getting_long` / `handoff_recommended`;达到阈值时用 `create_codex_followup_worker` 起新线程,原线程留作证据 |
|
|
150
|
-
| 一条共享事实的来源 | `get_fact`,按 ID 精确读;不要把一批 facts 全拉进主线程 |
|
|
151
|
-
| 找当前任务的已验证事实 | `search_worker_facts`,传 task_id/query/cursor;只回 scope 内 verified summary + coverage,绝不拉 raw history |
|
|
152
|
-
| 找某路的证据索引 | `get_worker_evidence`,再按需 `get_artifact` 或 `get_codex_worker_events` |
|
|
153
|
-
| 主线程确认候选事实 | `promote_worker_fact`;只有主线程审过才会追加 verified,repo scope 必须给 watchedPaths |
|
|
154
|
-
| 主线程推翻事实 | `revoke_worker_fact`;写明 reason,追加撤销版本保留原始 fact;`get_fact.effective_state` 显示撤销状态,不进入 search 或后续 capsule |
|
|
155
|
-
|
|
156
|
-
默认读回来的长文本都是裁过的(`current_action` 300 字、`prompt` 300 字、`last_message` 400 字),别把裁剪当成活没干。全量在库里。别一次 `limit: 200` 拉全量事件。
|
|
157
|
-
|
|
158
|
-
worker 的 capsule 只在内部 create/resume 时生成:L0 身份会标 branch 与 acceptance 来源但不放 acceptance 命令正文、当前 work 的 verified facts、显式 `dependsOn` 的最小交付摘要、路径命中且 SHA 有效的 repo facts。repo fact 跨 checkout 必须 canonical `origin`、repo-relative watched path 与 SHA 同时命中;没有可识别 origin 就不共享。`session_id` peers、raw event、完整 diff/报告、candidate facts 一律不自动注入。base SHA 不再覆盖、watched path 有 Git diff、context 输入 content hash 或 in_place_write manifest 漂移时,旧 fact 自动 append-only `expired` 并排除,保留原始版本。主线程只能看 snapshot 元数据;要查事实用 `search_worker_facts` / `get_fact`,查证据用 `get_worker_evidence` / `get_artifact`,不能把自己变成 worker。
|
|
159
|
-
|
|
160
|
-
`thread_health` 依据 native goal 的累计 tokens;默认 30 万建议 handoff,可用 `CODEX_SUPERVISOR_HANDOFF_TOKEN_THRESHOLD` 调整,设 0 关闭。它只提醒,不自动结束线程。
|
|
161
|
-
|
|
162
|
-
worker 最终 JSON 只是 `candidate`:先留在本 run 做审计,绝不因为它自己说“完成”就变共享事实。supervisor acceptance 通过才会派生当前 work 的 `verified` outcome;验收失败/未配置、脏 diff、未 land/push 都不是 verified 交付证据。
|
|
163
|
-
|
|
164
|
-
## 断了怎么接
|
|
165
|
-
|
|
166
|
-
| 情况 | 用什么 |
|
|
104
|
+
| 情况 | 处理 |
|
|
167
105
|
|---|---|
|
|
168
|
-
|
|
|
169
|
-
| worker 变 `lost
|
|
170
|
-
| worktree
|
|
171
|
-
| worker
|
|
172
|
-
|
|
|
106
|
+
| 主线程挂了 | worker 的独立 run host 会继续记录日志、状态和验收。新窗口用 `get_session_works` 接回 |
|
|
107
|
+
| worker 变 `lost` | `resume_codex_worker`,worktree、改动和 thread id 都保留 |
|
|
108
|
+
| worktree 落后主线 | `resume_codex_worker` 带 `rebaseOnto: "HEAD"` |
|
|
109
|
+
| worker 失败 | 先看 `failure.source` 和 `error`,区分 provider、supervisor、workspace setup、model output、acceptance、worker process |
|
|
110
|
+
| 没有 thread id 的旧行 | 用 `create_codex_followup_worker`,通过文本重述上下文 |
|
|
173
111
|
|
|
174
|
-
`
|
|
112
|
+
`check_workers` 会自动恢复一次已死的第一轮 `lost`、`no_work` 或 `invalid_report`,不会盲重试审批、认证、权限、quota 或时间限制。`completed` 但 `exit_code: null` 是中间态;验收已跑完的 durable 事件会优先于 PID 推断。
|
|
175
113
|
|
|
176
|
-
|
|
114
|
+
## 落地、push 和清理
|
|
177
115
|
|
|
178
|
-
|
|
116
|
+
`land_codex_worker` 只完成本地集成,不等于远端交付。
|
|
179
117
|
|
|
180
|
-
|
|
118
|
+
1. 主线程自己的改动要 commit 并 push。用户批准的集成分支也要在 push 后核对远端 SHA。
|
|
119
|
+
2. worker 分支通常不 push。只有用户明确要求保留远端 worker 分支时再推。
|
|
120
|
+
3. push 后用 `verify_delivery_push` 证明 landed head 已到远端,并生成 cleanup plan。
|
|
121
|
+
4. `check_workers` 只提示清理,不执行删除。
|
|
122
|
+
5. 只有 `acceptance passed`、`push_verified`、worktree 干净、没有活跃进程/依赖、fingerprint 未变化的 SAFE item,才可用 `apply_cleanup(plan_id, item_ids)` 删除。
|
|
123
|
+
6. cleanup 只执行 `git worktree remove/prune`。task、run event、JSONL、artifact 和 branch 都保留。
|
|
181
124
|
|
|
182
125
|
## 常见坑
|
|
183
126
|
|
|
184
|
-
- worktree
|
|
185
|
-
- `exit_code: 0`
|
|
186
|
-
- `ownedPaths`
|
|
187
|
-
- worktree
|
|
188
|
-
- `resume_codex_worker`
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
## 看板
|
|
193
|
-
|
|
194
|
-
用户想用眼睛看就让他起 `codex-supervisor-web`(或 `npx -p codex-supervisor-mcp codex-supervisor-web`),开 `http://127.0.0.1:7877`。按 session 分组,每路有「旁问」tab,用户可以自己问 worker。
|
|
195
|
-
|
|
196
|
-
安装后没工具:先查Claude/Codex的mcp get codex-supervisor;运行codex-supervisor-setup修复本包旧入口,手动失败非0,skill写入失败仍尝试注册。CLI不在PATH设CLAUDE_BIN/CODEX_BIN;skill跟随CLAUDE_CONFIG_DIR/CODEX_HOME。禁用安装脚本时不会自动注册,自定义/disabled/project配置保留并提示处理;重开会话加载新工具和skill。
|
|
127
|
+
- worktree 从提交创建。主工作区未提交的依赖不会被 worker 看到,先 commit 或用受控 context。
|
|
128
|
+
- `exit_code: 0` 不等于业务完成;acceptance 和 diff 才是证据。
|
|
129
|
+
- `ownedPaths` 的写冲突在派单时预留。运行时 guard 会拦直接文件写入,land 会再查完整 diff;声明脚本仍可能有清单外副作用,不能把它当完整文件系统沙箱。
|
|
130
|
+
- worktree 只隔离工作目录。端口、数据库、临时目录和其它外部资源仍可能共享。
|
|
131
|
+
- `resume_codex_worker` 不会再次创建 goal。
|
|
132
|
+
- 看板用 `codex-supervisor-web` 打开 `http://127.0.0.1:7877`。看板只观察,不派单、不取消。
|
|
133
|
+
- 安装或升级后要重开会话,MCP 和 skill 才会加载新版本。
|