codex-supervisor-mcp 0.8.0 → 0.9.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 +46 -16
- package/README.md +46 -16
- package/package.json +10 -1
- package/skills/codex-supervisor/SKILL.md +32 -5
- package/src/acceptance-baseline.js +64 -0
- package/src/acceptance.js +264 -0
- package/src/cleanup.js +66 -19
- package/src/codex-runner.js +287 -29
- package/src/event-parser.js +4 -1
- package/src/external-output.js +29 -0
- package/src/goal-store.js +10 -7
- package/src/handoff.js +31 -0
- package/src/landing.js +32 -8
- package/src/mcp-server.js +181 -28
- package/src/owned-changes.js +27 -0
- package/src/prompt.js +24 -4
- package/src/setup.js +60 -22
- package/src/skill-sync.js +2 -2
- package/src/status.js +1 -1
- package/src/task-store.js +156 -8
- package/src/tool-guard.js +66 -0
- package/src/web-app.js +2 -1
- package/src/worker-changes.js +38 -0
- package/src/worker-report.js +15 -0
- package/src/worker-report.schema.json +10 -0
- package/src/worktree.js +25 -1
package/README.en.md
CHANGED
|
@@ -43,7 +43,7 @@ Prerequisites: Node.js 22.13.0 or newer, `codex` on `PATH`. macOS, Linux and Win
|
|
|
43
43
|
npm install -g codex-supervisor-mcp
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
`postinstall`
|
|
46
|
+
A global npm install runs `postinstall` when lifecycle scripts are enabled, installing the skill and registering MCP with detected Claude Code/Codex clients. `--ignore-scripts`, disabled lifecycle scripts, and running through npx do not guarantee registration; run `codex-supervisor-setup` and inspect both clients with `mcp get`. Manual registration also works:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
claude mcp add -s user codex-supervisor -- npx -y codex-supervisor-mcp
|
|
@@ -62,7 +62,7 @@ What the main thread does underneath (you can call the tools yourself):
|
|
|
62
62
|
|
|
63
63
|
```
|
|
64
64
|
create_codex_worker ×3 each with session_id, session_title, ownedPaths, goal
|
|
65
|
-
wait_codex_workers
|
|
65
|
+
wait_codex_workers 60 seconds by default, then a snapshot, call again until done
|
|
66
66
|
get_worker_result ×3 each worker's report, with the commands it really ran
|
|
67
67
|
```
|
|
68
68
|
|
|
@@ -115,7 +115,7 @@ What the main brain calls in one round:
|
|
|
115
115
|
```
|
|
116
116
|
search_works has this batch been dispatched before
|
|
117
117
|
create_codex_worker one worker per step, same session_id, ownedPaths disjoint
|
|
118
|
-
wait_codex_workers
|
|
118
|
+
wait_codex_workers 60 seconds a round, compact: true, call again until done
|
|
119
119
|
get_worker_result what it says it did; verification is what it really ran
|
|
120
120
|
get_worker_diff what it actually did
|
|
121
121
|
ask_codex_worker when the two differ, ask why; read-only, its thread untouched
|
|
@@ -141,32 +141,62 @@ Light and dark follow the system. No external resources.
|
|
|
141
141
|
|
|
142
142
|
## Tools
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
Twenty-one.
|
|
145
145
|
|
|
146
146
|
| Tool | Arguments | What it does |
|
|
147
147
|
|---|---|---|
|
|
148
|
-
| `
|
|
148
|
+
| `check_workers` | none | Report newly settled runs and actionable changes; recover a new-format first lost/no_work 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 |
|
|
149
|
+
| `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 |
|
|
150
|
+
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `maxRunMs`, `maxTotalMs`, `acceptance`, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Start a worker. `acceptance` lists the commands the supervisor runs in the worktree once the worker exits; exit 0 on every one passes. `baseRef` picks the commit the worktree is cut from (default `HEAD`); pass another worker's `codex/<id>` to build on it |
|
|
149
151
|
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, plus the above | A new session seeded with the old worker's prompt, status and recent events |
|
|
150
|
-
| `resume_codex_worker` | `task_id`, `prompt`, `rebaseOnto`, `acceptance` | Continue the same Codex conversation; `thread_id` stays. `rebaseOnto` first moves the worktree onto the project's newer commit (stash, replay
|
|
151
|
-
| `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states.
|
|
152
|
+
| `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 |
|
|
153
|
+
| `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states. 60 seconds by default, then a snapshot while the workers keep running; `compact` returns one line per worker with `idle_seconds` / `command_running`, so a long command and a stuck worker look different |
|
|
152
154
|
| `get_orchestration_overview` | `status`, `limit` | Every worker in one table, capped at 7000 bytes. Carries `version` and `update` |
|
|
153
155
|
| `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 |
|
|
154
156
|
| `get_worker_diff` | `task_id`, `maxChars`, `paths` | What the worker actually changed: patches from the worktree's start to its working tree, committed or not. `maxChars` bounds the answer; files past it are listed without a patch |
|
|
155
157
|
| `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 |
|
|
156
|
-
| `land_codex_worker` | `task_id`, `onto`, `commitMessage`, `ignoreAcceptance` | 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. `commitMessage` first commits its uncommitted edits as one commit; `ignoreAcceptance` lands anyway |
|
|
158
|
+
| `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. `commitMessage` first commits its uncommitted edits as one commit; `ignoreAcceptance` lands anyway |
|
|
157
159
|
| `get_worker_summary` | `task_id` | One paragraph: goal, status, changes, last command and message |
|
|
158
160
|
| `get_codex_worker_status` | `task_id`, `includePrompt`, `promptMaxChars` | One worker in detail |
|
|
159
161
|
| `get_codex_worker_events` | `task_id`, `limit`, `maxChars`, `kinds` | The raw event stream |
|
|
160
162
|
| `get_worker_goal` | `task_id` | The goal recorded at dispatch plus the native Codex goal (tokens, time) |
|
|
161
163
|
| `list_codex_workers` | `status`, `includeHistory`, `includeDetails` | List workers, active ones by default |
|
|
162
164
|
| `get_session_works` | `session_id` | Every worker of one session. The way back after a main-thread restart |
|
|
163
|
-
| `describe_session` | `session_id`, `title`, `note` | Record a title and note for a session |
|
|
165
|
+
| `describe_session` | `session_id`, `title`, `note`, `objective`, `default_acceptance`, `approval_state`, `expected_revision` | Record a title and note for a session |
|
|
164
166
|
| `search_works` | `query`, `limit` | Substring search over title / goal / prompt / last_message, newest first |
|
|
165
167
|
| `check_for_update` | `force` | Ask the registry for a newer version |
|
|
166
168
|
| `cancel_codex_worker` | `task_id` | Stop a worker. Falls back to the pid across processes, after confirming that pid runs codex |
|
|
167
169
|
|
|
168
170
|
Two are required: `ownedPaths` (checked against every running worker before dispatch, overlap refuses the call, dispatch-time only) and `goal.objective` (the worker turns it into a native Codex goal). Without `session_id` nothing groups the batch; use one value for the whole batch.
|
|
169
171
|
|
|
172
|
+
`acceptance` runs in Bash with `errexit` and `pipefail`: an unhandled failure stops the check, including a failing test in `npm test | tail`. 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.
|
|
173
|
+
|
|
174
|
+
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.
|
|
175
|
+
|
|
176
|
+
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.
|
|
177
|
+
|
|
178
|
+
Landing checks the real diff against ownedPaths before committing drafts; only use allowOutsideOwned for an explicitly approved exception.
|
|
179
|
+
|
|
180
|
+
Session default_acceptance is prepended to local checks; resume uses the latest policy. describe_session returns policy_revision and expected_revision prevents stale edits. waiting_user blocks dispatch/resume until approved. host_goal_sync returns a current-policy /goal command. Replace an active native goal through /goal, or propose the same condition through ProposeGoal for host approval when available. The condition reads the latest session revision and approved scope; MCP does not silently modify or disable the host Stop hook.
|
|
181
|
+
|
|
182
|
+
Wait defaults to 60 seconds and compact rows; includeEvents selects details unless compact is explicit. Clients supplying a progress token receive notifications every 30 seconds. MCP SDK and real Claude 2.1.299 are verified: a 65-second wait succeeds with a 35-second idle timeout after three progress notifications. Native /loop scheduling is also verified.
|
|
183
|
+
|
|
184
|
+
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.
|
|
185
|
+
|
|
186
|
+
After reconciliation, check_workers atomically resumes a dead first lost/no_work run once and returns recovery receipts. A second failure remains actionable; approval, authentication, permission and quota waits are not retried. Final reports use JSON result/verification/not_done; structured_report exposes validation independently of command history and acceptance. Invalid JSON is failed/invalid_report and cannot land. Existing history is labelled legacy_text.
|
|
187
|
+
|
|
188
|
+
context declares up to 20 absolute file paths with optional sha256, within a combined 6000-character budget with contracts; each file is at most 5 MB. Dispatch pins actual hashes and resume refuses drift unless new context is explicitly supplied. Handoffs are limited to 1800 characters/16 lines with a truncation marker; complete contracts and refs remain separate, and inputs grant no write permission.
|
|
189
|
+
|
|
190
|
+
Declare externalOutputs:[{path,sha256?}] and acceptance for shared writes. Targets are absolute file paths, at most 1 MB each. Current-run before/after hashes and bounded content appear in result/diff as shared_file_already_written_not_cherry_pick; land cannot integrate external files. Targets participate in ownership conflict checks and hook policy; the dispatcher is responsible for validation script side effects.
|
|
191
|
+
|
|
192
|
+
workspace-write defaults to networkAccess:false; explicitly enable it for ssh/network checks. Resume/follow-up inherit the setting. maxRunMs bounds one run and maxTotalMs bounds wall time since dispatch; exceeding either stops the worker and preserves actionable partial results without automatic retry. A wait budget does not change these quotas.
|
|
193
|
+
|
|
194
|
+
Dispatch checks required hooks/output-schema support (Codex 0.162+); unsupported capability returns settled start_failed. get_worker_goal.native_goal_read distinguishes missing_goal, missing_database, locked and read_error; a read failure is not evidence that no goal exists. Native budget/usage limits need attention. Cleanup preserves ignored artifacts, shared evidence and unresolved attention.
|
|
195
|
+
|
|
196
|
+
Ownership reservation and task insertion are atomic across MCP dispatch/resume processes; ownership remains reserved during acceptance or exit settlement. Failure to create an isolated Git checkout is explicit and never falls back to executing in the project directory.
|
|
197
|
+
|
|
198
|
+
Cleanup previews by default: `npm run cleanup -- --dry-run`. `--apply` removes only integrated, clean completed worktrees with no active dependents and verified Git registration/ownership. Dirty, unlanded, lost/failed or unproven work is preserved with a reason.
|
|
199
|
+
|
|
170
200
|
## How this differs from Claude Code subagents
|
|
171
201
|
|
|
172
202
|
File isolation is not the difference: a subagent can open a worktree too. The difference is the model and the process.
|
|
@@ -176,7 +206,7 @@ File isolation is not the difference: a subagent can open a worktree too. The di
|
|
|
176
206
|
| Model | Claude only | `model` passed to the Codex CLI; DeepSeek works |
|
|
177
207
|
| Who does the work | Claude Code itself | A separate `codex exec` process |
|
|
178
208
|
| Two writers on one file | Worktrees keep them apart, no path declaration | `ownedPaths` overlap is refused before dispatch |
|
|
179
|
-
| Main-thread process dies |
|
|
209
|
+
| Main-thread process dies | The main window cannot collect results | An independent run process records worker output and acceptance; a new window reads the same session_id |
|
|
180
210
|
| Who can drive it | Claude Code only | Any MCP client |
|
|
181
211
|
| Seeing the process | Only the returned conclusion | Raw JSONL and the web board |
|
|
182
212
|
|
|
@@ -189,7 +219,7 @@ File isolation is not the difference: a subagent can open a worktree too. The di
|
|
|
189
219
|
| `completed` | Done |
|
|
190
220
|
| `failed` | Non-zero exit, `turn.failed`, spawn failure |
|
|
191
221
|
| `cancelled` | Stopped by `cancel_codex_worker` |
|
|
192
|
-
| `lost` |
|
|
222
|
+
| `lost` | Worker killed by an outside signal, run process disappeared, or a row whose process never started. `resume_codex_worker` picks it up |
|
|
193
223
|
|
|
194
224
|
A terminal state lands in two steps: `turn.completed` sets `completed`, the process exit writes `exit_code`; `wait_codex_workers` returns only after the exit code is in. Windows has no signals, so an outside kill reports as `failed` with an exit code. Native Codex goals: `paused` / `blocked` count as `running` and go to `needs_attention`, `usageLimited` / `budgetLimited` as `failed`.
|
|
195
225
|
|
|
@@ -223,7 +253,7 @@ A terminal state lands in two steps: `turn.completed` sets `completed`, the proc
|
|
|
223
253
|
| `CODEX_SUPERVISOR_SKIP_SETUP` | unset | `1` skips the `postinstall` setup |
|
|
224
254
|
| `CODEX_SUPERVISOR_NPM` | unset | npm for the auto-update; default is the one shipped with the running node |
|
|
225
255
|
|
|
226
|
-
GUI clients (Claude Desktop, Cursor, Windsurf)
|
|
256
|
+
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:
|
|
227
257
|
|
|
228
258
|
```json
|
|
229
259
|
{
|
|
@@ -241,7 +271,7 @@ GUI clients (Claude Desktop, Cursor, Windsurf) do not run `postinstall`: add thi
|
|
|
241
271
|
|
|
242
272
|
Nothing to do by hand. At start the server asks the registry in the background; a newer version is installed by a detached `npm i -g` into the same global path, the running session is untouched and the next session starts on it. Only a copy that `npm i -g` installed is touched; a git checkout or an `npx` copy is left alone. The skill does the same: every start copies it into the existing skill directories, backing up an edited file as `SKILL.md.bak-<timestamp>`.
|
|
243
273
|
|
|
244
|
-
When the install fails (a global directory that needs sudo) the `update` field says why and `npm install -g codex-supervisor-mcp@latest` by hand still works. Versions up to 0.6.1 only notify; upgrade by hand once and it is automatic from then on.
|
|
274
|
+
When the install fails (a global directory that needs sudo) the `update` field says why and `npm install -g codex-supervisor-mcp@latest` by hand still works. Versions up to 0.6.1 only notify; upgrade by hand once and it is automatic from then on. After changing Node versions/install prefixes, setup repairs old package-generated paths and verifies command/args through client read-back. Custom, disabled and project registrations are preserved with a repair warning. To run the setup again: `codex-supervisor-setup` (`--skill-only` / `--mcp-only` / `--dry-run`). Manual registration failures exit nonzero; automatic installs warn without failing npm. A skill write failure does not prevent MCP registration. Set `CLAUDE_BIN` / `CODEX_BIN` for off-PATH CLIs. Skill locations follow `CLAUDE_CONFIG_DIR` / `CODEX_HOME`.
|
|
245
275
|
|
|
246
276
|
Uninstall:
|
|
247
277
|
|
|
@@ -266,7 +296,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
266
296
|
| Dispatch says `codex only resolved to a shell shim` | Windows found only the `.cmd`; the package entry behind it is gone | Reinstall `@openai/codex`, or point `CODEX_BIN` at `codex.js` |
|
|
267
297
|
| Worker `failed` at once with `spawn codex ENOENT` | No codex on the process `PATH` | Set `CODEX_BIN` in the config |
|
|
268
298
|
| `Cannot find module 'node:sqlite'` | Node older than 22.13.0 | Upgrade Node |
|
|
269
|
-
| Worker `lost` | The
|
|
299
|
+
| Worker `lost` | The worker or independent run process was interrupted | Inspect events, then `resume_codex_worker` |
|
|
270
300
|
| Worker reports `git add` failing with `index.lock: Operation not permitted` | The default sandbox keeps `.git` read-only | `land_codex_worker` with `commitMessage`, or dispatch with `danger-full-access` |
|
|
271
301
|
| `ownedPaths overlap with active worker(s)` | Two workers claimed the same paths | Split differently, or cancel the one holding them |
|
|
272
302
|
| The board is empty | The board and the MCP use different `SUPERVISOR_HOME`s | Start it inside the project with the `.mcp.json`, or pass the same `SUPERVISOR_HOME` |
|
|
@@ -274,7 +304,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
274
304
|
|
|
275
305
|
## Known limitations
|
|
276
306
|
|
|
277
|
-
-
|
|
307
|
+
- Each run has an independent process that drains worker output, records its exit, and runs acceptance before exiting. These continue after the dispatching MCP is killed; a new window uses `get_session_works` to collect results. If the run process is also killed, inspect lost/interrupted evidence before resuming the preserved worktree and thread_id.
|
|
278
308
|
- In the default `workspace-write` sandbox a worker cannot commit (Codex keeps `.git` read-only). Either `land_codex_worker` with `commitMessage` commits for it, or dispatch with `danger-full-access`.
|
|
279
309
|
- The worktree is cut from a commit; uncommitted work in your checkout is not in it.
|
|
280
310
|
- Only the working directory is isolated. Temp directories, databases and ports are shared.
|
|
@@ -287,7 +317,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
287
317
|
|
|
288
318
|
Done: `CODEX_BIN` / `SUPERVISOR_HOME` / `GIT_BIN`; `status` and `phase` split; `ownedPaths` / `goal` / `dependsOn`; `thread_id` on disk + `resume_codex_worker`; concurrency and multi-process writes; `session_id`, `search_works`, native goals; Windows; the web board; `baseRef`; collecting work with `get_worker_diff` / `ask_codex_worker` / `land_codex_worker`; background auto-update.
|
|
289
319
|
|
|
290
|
-
|
|
320
|
+
Run lifetime is independent of MCP; each run process exits after settlement without a global resident daemon.
|
|
291
321
|
|
|
292
322
|
Not planned: vector search (substring matching is faster at this scale and costs nothing to maintain), `usage_count` ordering (2 of 80 real works were ever referenced again).
|
|
293
323
|
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ worker 跑的是 `codex exec`,`model` 透传:主线程留在 Claude,worker
|
|
|
43
43
|
npm install -g codex-supervisor-mcp
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
`postinstall
|
|
46
|
+
npm 全局安装在允许执行安装脚本时,会运行 `postinstall`,给检测到的 Claude Code/Codex 装 skill 并注册 MCP。`--ignore-scripts`、禁用安装脚本或只运行 npx 不保证自动注册;没看到时先运行 `codex-supervisor-setup`,再查两端 `mcp get`。手动注册也可以:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
claude mcp add -s user codex-supervisor -- npx -y codex-supervisor-mcp
|
|
@@ -62,7 +62,7 @@ codex mcp add codex-supervisor -- npx -y codex-supervisor-mcp
|
|
|
62
62
|
|
|
63
63
|
```
|
|
64
64
|
create_codex_worker ×3 每路带 session_id、session_title、ownedPaths、goal
|
|
65
|
-
wait_codex_workers 默认等
|
|
65
|
+
wait_codex_workers 默认等 60 秒,到点返回快照,没完就接着等
|
|
66
66
|
get_worker_result ×3 收每路的汇报,带它真跑过的命令和退出码
|
|
67
67
|
```
|
|
68
68
|
|
|
@@ -115,7 +115,7 @@ npx -p codex-supervisor-mcp codex-supervisor-web
|
|
|
115
115
|
```
|
|
116
116
|
search_works 查这批活派过没有
|
|
117
117
|
create_codex_worker 一步一个 worker,同一个 session_id,ownedPaths 不重叠
|
|
118
|
-
wait_codex_workers
|
|
118
|
+
wait_codex_workers 60 秒一轮,compact: true,没完接着调
|
|
119
119
|
get_worker_result 它说自己做了什么,verification 里是它真跑过的命令
|
|
120
120
|
get_worker_diff 它实际做了什么
|
|
121
121
|
ask_codex_worker 对不上就问它为什么,只读,不动它的线程
|
|
@@ -141,32 +141,62 @@ land_codex_worker 核过了,落进集成分支
|
|
|
141
141
|
|
|
142
142
|
## 工具
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
21 个。
|
|
145
145
|
|
|
146
146
|
| 工具 | 入参 | 作用 |
|
|
147
147
|
|---|---|---|
|
|
148
|
-
| `
|
|
148
|
+
| `check_workers` | 无参 | 交付新终态、验收失败和需处理goal;新格式第1轮lost/no_work自动恢复一次,未变返回quiet;用宿主定时唤醒调用,每个主线程设独立CODEX_SUPERVISOR_OBSERVER_ID可在重启后接回 |
|
|
149
|
+
| `check_acceptance` | `cwd`, `acceptance`, `baseRef`, `timeoutMs` | 派单前实际运行给定验收命令,不建 worker,不证明 worker 完成;数量 grep 会提示不能证明失败名单和必跑执行 |
|
|
150
|
+
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `maxRunMs`, `maxTotalMs`, `acceptance`, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | 起一个 worker。`acceptance` 是验收命令,worker 退出后 supervisor 在它的 worktree 里跑,退出码 0 算过。`baseRef` 指定 worktree 从哪个提交切,默认 `HEAD`,接另一路填它的 `codex/<id>` |
|
|
149
151
|
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, 其余同上 | 开一个新会话,把老 worker 的 prompt、状态、近期事件拼进去 |
|
|
150
|
-
| `resume_codex_worker` | `task_id`, `prompt`, `rebaseOnto`, `acceptance` | 接同一个 Codex 会话继续跑,`thread_id` 不变。`rebaseOnto` 先把 worktree 挪到主线新头(stash
|
|
151
|
-
| `wait_codex_workers` | `task_ids`, `mode`(any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | 等终态。默认
|
|
152
|
+
| `resume_codex_worker` | `task_id`, `prompt`, `rebaseOnto`, `acceptance`, `context` | 接同一个 Codex 会话继续跑,`thread_id` 不变。`rebaseOnto` 先把 worktree 挪到主线新头(stash、跳过已合入补丁、重放新增提交、放回),冲突原样退回不起 worker |
|
|
153
|
+
| `wait_codex_workers` | `task_ids`, `mode`(any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | 等终态。默认 60 秒,到点带快照返回,worker 照跑;`compact` 每路只回一行,带 `idle_seconds` / `command_running`,分得清长命令和卡住 |
|
|
152
154
|
| `get_orchestration_overview` | `status`, `limit` | 全部 worker 的状态表,封顶 7000 字节。带 `version` 和 `update` |
|
|
153
155
|
| `get_worker_result` | `task_id`, `limit`, `maxChars`, `includeFiles` | worker 自己的汇报,默认截 6000 字节、`truncated` 提示读全。`acceptance` 是 supervisor 替你跑的验收过没过,`verification` 是它自己跑过的命令和退出码,`base_behind` 是主线走了多远 |
|
|
154
156
|
| `get_worker_diff` | `task_id`, `maxChars`, `paths` | worker 实际改了什么:从 worktree 起点到工作区的 patch,提交没提交都算。`maxChars` 管总量,超了的文件只列名 |
|
|
155
157
|
| `ask_codex_worker` | `task_id`, `question`, `timeoutMs`, `maxChars`, `fresh`, `end` | 旁路问 worker 一句。线程 fork 成只读侧会话,没网络、没 MCP 工具,worker 本身不动。worker 被 resume 过会自动换新 fork,`fresh` 强制换,`end` 删 |
|
|
156
|
-
| `land_codex_worker` | `task_id`, `onto`, `commitMessage`, `ignoreAcceptance` | 把 worker 在 `codex/<id>` 上的提交 cherry-pick 到派单目录的当前分支。目标要干净,冲突回滚,验收 `failed` 拒绝。`commitMessage` 先替它把未提交的改动提交成一笔,`ignoreAcceptance` 放行 |
|
|
158
|
+
| `land_codex_worker` | `task_id`, `onto`, `commitMessage`, `ignoreAcceptance`, `allowOutsideOwned` | 把 worker 在 `codex/<id>` 上的提交 cherry-pick 到派单目录的当前分支。目标要干净,冲突回滚,验收 `failed` 拒绝。`commitMessage` 先替它把未提交的改动提交成一笔,`ignoreAcceptance` 放行 |
|
|
157
159
|
| `get_worker_summary` | `task_id` | 一段话:goal、状态、改动、最后一条命令和消息 |
|
|
158
160
|
| `get_codex_worker_status` | `task_id`, `includePrompt`, `promptMaxChars` | 单个 worker 的状态细节 |
|
|
159
161
|
| `get_codex_worker_events` | `task_id`, `limit`, `maxChars`, `kinds` | 原始事件流 |
|
|
160
162
|
| `get_worker_goal` | `task_id` | 派单时记的 goal + Codex 原生 goal(token、用时) |
|
|
161
163
|
| `list_codex_workers` | `status`, `includeHistory`, `includeDetails` | 列 worker,默认只看在跑的 |
|
|
162
164
|
| `get_session_works` | `session_id` | 一个 session 的全部 worker。主线程重启后靠它找回那批活 |
|
|
163
|
-
| `describe_session` | `session_id`, `title`, `note` | 给 session 记标题和说明 |
|
|
165
|
+
| `describe_session` | `session_id`, `title`, `note`, `objective`, `default_acceptance`, `approval_state`, `expected_revision` | 给 session 记标题和说明 |
|
|
164
166
|
| `search_works` | `query`, `limit` | 在 title / goal / prompt / last_message 里找子串,从新到旧 |
|
|
165
167
|
| `check_for_update` | `force` | 问 registry 有没有新版本 |
|
|
166
168
|
| `cancel_codex_worker` | `task_id` | 终止 worker。跨进程按 pid 兜底,先确认那个 pid 跑的是 codex |
|
|
167
169
|
|
|
168
170
|
必填的两个:`ownedPaths`(派单前和在跑的 worker 求交集,重叠就拒,只在派单时查)和 `goal.objective`(worker 会建成 Codex 原生 goal)。`session_id` 不传就归不了组,一批活传同一个值。
|
|
169
171
|
|
|
172
|
+
`acceptance` 在 Bash 中启用 `errexit` 和 `pipefail`:未处理的失败会停止检查,`npm test | tail` 中的测试失败也会保留。预期失败用 `if` 或 `||` 显式处理;超时始终判失败,即使命令收到终止信号后退出 0。Windows 需要 Git for Windows 的 Bash;找不到会报错。显示的输出会裁剪,退出码不会因此改变。
|
|
173
|
+
|
|
174
|
+
验收命令的环境包含 `CODEX_SUPERVISOR_TASK_ID`、`CODEX_SUPERVISOR_BASE_COMMIT` 和 `CODEX_SUPERVISOR_RUN`;分别是当前任务、当前运行基线和运行次数,rebase/resume 后会更新。
|
|
175
|
+
|
|
176
|
+
结构化验收项用 `{command, reportPath, baseline}`。baseline 包含 `identity.base_commit`、`failures`(test_id/kind/signature)和 `required`;报告包含 complete、identity、failures、executed、skipped,以及本次 `CODEX_SUPERVISOR_CHECK_ID`。必跑用例缺失/跳过、旧报告、失败名单变化都拒绝通过,原始退出码保留。reportPath 必须在工作目录内;测试报告可能写文件,要用忽略的临时目录,避免把报告合入。
|
|
177
|
+
|
|
178
|
+
落地前按真实 diff 核对 ownedPaths,越界拒绝且不提交草稿;只有用户明确授权时才用 allowOutsideOwned。
|
|
179
|
+
|
|
180
|
+
同 session 的 `default_acceptance` 自动加到每路本地检查前;resume 会取最新策略。`describe_session` 返回 policy_revision,改目标/门禁可传 expected_revision 防旧窗口覆盖;waiting_user 拒绝派单与恢复,approved 后再继续。回执host_goal_sync包含按当前策略生成的/goal命令;宿主已有原生goal时用/goal替换条件,支持ProposeGoal时可提议同一条件并走宿主批准。条件要求读取最新session revision及批准范围;MCP不会偷偷修改或禁用宿主Stop hook。
|
|
181
|
+
|
|
182
|
+
wait 默认预算60秒、默认compact;includeEvents会选择详细结果(显式compact优先)。带progress token的客户端每30秒收到通知;已验证MCP SDK及真实Claude2.1.299:idle35秒、wait65秒,三次progress后正常返回;原生/loop定时调用也已实测。
|
|
183
|
+
|
|
184
|
+
每路临时注入随包PreToolUse守卫:apply_patch核对全部目标路径(含rename和symlink),forbid拒绝红线;Shell仅允许简单读取和派单显式allowedCommands/acceptance。声明的验证脚本以派单者权限执行,可有副作用,不能当作任意程序的文件沙箱。guard策略随resume/followup继承,不写全局hooks。空跑write run按本轮输出前后内容和命令判断,no_work进入needs_attention;只读任务不因没改文件判空跑。
|
|
185
|
+
|
|
186
|
+
check_workers在状态协调后,对已结束的第1轮lost/no_work原子resume一次;第2轮仍有问题则保留证据等处理。审批、认证、权限和quota等待不重试,返回recoveries记录。worker最终输出强制JSON result/verification/not_done;get_worker_result的structured_report给格式校验,独立命令与acceptance仍为实际证据。非法JSON标failed/invalid_report并拒绝land;旧历史标legacy_text。
|
|
187
|
+
|
|
188
|
+
context用绝对文件路径与可选sha256声明材料,最多20份、与contracts合计6000字;文件不超过5 MB。首次派单记录实际哈希,resume校验原材料未变,需要新材料时显式传context。handoff最多1800字/16行,截断明确标记;完整约束和引用单独保留,材料不授予写权限。
|
|
189
|
+
|
|
190
|
+
确需共享写入时声明externalOutputs:[{path,sha256?}]并配置acceptance。目标必须是绝对文件路径、每份≤1 MB;记录本轮前后哈希和有界内容,result/diff标shared_file_already_written_not_cherry_pick,不能通过land合入外部文件。外部目标参与归属冲突与hook;验证脚本的共享副作用由派单者负责。
|
|
191
|
+
|
|
192
|
+
workspace-write默认networkAccess:false;需要ssh/联网验证显式true,随resume/followup继承,不以danger-full-access代替。maxRunMs限制单轮、maxTotalMs限制从派单开始的总时长;超限中止worker并保留needs_attention/partial work,不自动重试。wait预算不改变这些quota。
|
|
193
|
+
|
|
194
|
+
运行前核验Codex CLI是否具备hooks/output-schema(要求0.162+);能力不足返回start_failed,wait可正常结算。get_worker_goal.native_goal_read区分missing_goal、missing_database、locked和read_error,不能把读取失败当没建goal。原生budget/usage限制也进入needs_attention。cleanup保留ignored artifacts、共享证据和未解决attention。
|
|
195
|
+
|
|
196
|
+
ownedPaths预留和任务入库在同一事务内,跨MCP并发派单/恢复不能抢同一输出;验收或退出尚未结算时仍保留归属。Git工作区隔离创建失败明确报错,不退回主目录执行。
|
|
197
|
+
|
|
198
|
+
清理默认只预览:`npm run cleanup -- --dry-run`。`--apply` 只删除已合入、干净、无活跃依赖、Git注册与目录归属可证明的 completed worktree;脏、未合、lost/failed 及证据不足的目录保留并给出原因。
|
|
199
|
+
|
|
170
200
|
## 和 Claude Code 的 subagent 有什么区别
|
|
171
201
|
|
|
172
202
|
文件隔离不是差别:subagent 自己也能开 worktree。差别在模型和进程。
|
|
@@ -176,7 +206,7 @@ land_codex_worker 核过了,落进集成分支
|
|
|
176
206
|
| 能跑什么模型 | 只能选 Claude | `model` 透传给 Codex CLI,DeepSeek 也能挂 |
|
|
177
207
|
| 干活的是谁 | Claude Code 自己 | 独立的 `codex exec` 进程 |
|
|
178
208
|
| 两路写同一个文件 | 靠 worktree 隔开,没有路径声明 | 派单前查 `ownedPaths` 交集,重叠直接拒 |
|
|
179
|
-
| 主线程进程挂了 |
|
|
209
|
+
| 主线程进程挂了 | 主窗口无法收活 | 独立运行进程继续记录 worker 和验收;新窗口用 session_id 收回同批结果 |
|
|
180
210
|
| 谁能驱动 | 只有 Claude Code | 任何 MCP 客户端 |
|
|
181
211
|
| 看过程 | 只有它返回的结论 | 原始 JSONL 和网页看板 |
|
|
182
212
|
|
|
@@ -189,7 +219,7 @@ land_codex_worker 核过了,落进集成分支
|
|
|
189
219
|
| `completed` | 成功 |
|
|
190
220
|
| `failed` | 非零退出码、`turn.failed`、spawn 失败 |
|
|
191
221
|
| `cancelled` | 被 `cancel_codex_worker` 中断 |
|
|
192
|
-
| `lost` |
|
|
222
|
+
| `lost` | worker 被外部信号杀掉、运行进程失踪、或者行写了但进程从没起来。`resume_codex_worker` 接回 |
|
|
193
223
|
|
|
194
224
|
终态分两步落盘:`turn.completed` 先把 status 置成 completed,进程退出后才写 `exit_code`;`wait_codex_workers` 等到 `exit_code` 落了才返回。Windows 没有信号,外部 kill 只报 `failed` 加退出码。Codex 原生 goal 的 `paused` / `blocked` 算 `running` 并进 `needs_attention`,`usageLimited` / `budgetLimited` 算 `failed`。
|
|
195
225
|
|
|
@@ -223,7 +253,7 @@ land_codex_worker 核过了,落进集成分支
|
|
|
223
253
|
| `CODEX_SUPERVISOR_SKIP_SETUP` | 未设 | `1` 跳过 `postinstall` 的自动安装 |
|
|
224
254
|
| `CODEX_SUPERVISOR_NPM` | 未设 | 自动更新用的 npm,默认用当前 node 自带的 |
|
|
225
255
|
|
|
226
|
-
GUI 客户端(Claude Desktop、Cursor、Windsurf
|
|
256
|
+
GUI 客户端(Claude Desktop、Cursor、Windsurf)不在本安装器的自动注册目标中,自己把这段加进它的 MCP 配置文件,`PATH` 里常常没有 `codex`,显式给 `CODEX_BIN`:
|
|
227
257
|
|
|
228
258
|
```json
|
|
229
259
|
{
|
|
@@ -241,7 +271,7 @@ GUI 客户端(Claude Desktop、Cursor、Windsurf)不跑 `postinstall`,自
|
|
|
241
271
|
|
|
242
272
|
不用手动更。server 启动时后台查一次 registry,有新版就起独立进程 `npm i -g` 到同一个全局路径;正在跑的会话不受影响,下一个新会话就是新版。只对 `npm i -g` 装的那份生效,git 源码和 `npx` 起的不碰。skill 也一样,每次启动刷到已有的 skill 目录,改过的先备份成 `SKILL.md.bak-<时间戳>`。
|
|
243
273
|
|
|
244
|
-
装失败(全局目录要 sudo)时 `update` 字段带原因,手动 `npm install -g codex-supervisor-mcp@latest`。0.6.1
|
|
274
|
+
装失败(全局目录要 sudo)时 `update` 字段带原因,手动 `npm install -g codex-supervisor-mcp@latest`。0.6.1 及以前只提醒不自动装,手动升一次就进自动了。换 Node/安装前缀后,setup 会修复本包生成的旧入口,并读回核对 command/args;已有自定义、disabled、project配置保留并提示处理,不擅自覆盖。重跑安装:`codex-supervisor-setup`(`--skill-only` / `--mcp-only` / `--dry-run`)。手动注册失败返回非0,自动安装保持成功但打印warning;skill写入失败仍继续尝试MCP注册;没找到CLI时可设 `CLAUDE_BIN` / `CODEX_BIN`。skill路径跟随 `CLAUDE_CONFIG_DIR` / `CODEX_HOME`。
|
|
245
275
|
|
|
246
276
|
卸载:
|
|
247
277
|
|
|
@@ -266,7 +296,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
266
296
|
| 派单报 `codex only resolved to a shell shim` | Windows 只找到 `.cmd`,背后的包入口没了 | 重装 `@openai/codex`,或 `CODEX_BIN` 指到 `codex.js` |
|
|
267
297
|
| worker 一起来就 `failed`,`spawn codex ENOENT` | 进程 `PATH` 里没有 codex | 配置里设 `CODEX_BIN` |
|
|
268
298
|
| `Cannot find module 'node:sqlite'` | Node 低于 22.13.0 | 升 Node |
|
|
269
|
-
| worker `lost` |
|
|
299
|
+
| worker `lost` | worker 或独立运行进程中断 | 查事件后用 `resume_codex_worker` 接回 |
|
|
270
300
|
| worker 说 `git add` 报 `index.lock: Operation not permitted` | 默认沙箱把 `.git` 设成只读 | 收活时 `land_codex_worker` 带 `commitMessage`,或派单用 `danger-full-access` |
|
|
271
301
|
| `ownedPaths overlap with active worker(s)` | 两路认领了同一片路径 | 改拆法,或先取消占着的那路 |
|
|
272
302
|
| 看板打开是空的 | 看板和 MCP 的 `SUPERVISOR_HOME` 不是同一个 | 在配了 `.mcp.json` 的项目目录里起,或显式传同一个 `SUPERVISOR_HOME` |
|
|
@@ -274,7 +304,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
274
304
|
|
|
275
305
|
## 已知限制
|
|
276
306
|
|
|
277
|
-
- worker
|
|
307
|
+
- 每次运行由独立进程读取 worker 输出、落状态和执行验收,直到结算后退出。派单 MCP 被 kill 后这些工作继续;新窗口用 `get_session_works` 收结果。若运行进程也被杀,保留 worktree 和 thread_id,核对 lost/interrupted 后恢复。
|
|
278
308
|
- 默认 `workspace-write` 沙箱里 worker 提交不了(Codex 把 `.git` 设成只读)。要么收活时 `land_codex_worker` 带 `commitMessage` 替它提交,要么派单用 `danger-full-access`。
|
|
279
309
|
- worktree 从一个提交切,你工作区里没 commit 的东西不在里面。
|
|
280
310
|
- 只隔离工作目录。临时目录、数据库、端口是共用的。
|
|
@@ -287,7 +317,7 @@ rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.co
|
|
|
287
317
|
|
|
288
318
|
做完的:`CODEX_BIN` / `SUPERVISOR_HOME` / `GIT_BIN`;`status` 和 `phase` 拆开;`ownedPaths` / `goal` / `dependsOn`;`thread_id` 落库 + `resume_codex_worker`;并发和多进程写库;`session_id`、`search_works`、原生 goal;Windows;网页看板;`baseRef`;收活三件套 `get_worker_diff` / `ask_codex_worker` / `land_codex_worker`;后台自动更新。
|
|
289
319
|
|
|
290
|
-
|
|
320
|
+
运行生命周期已独立于 MCP;每路结算后退出,不需要常驻全局 daemon。
|
|
291
321
|
|
|
292
322
|
不做的:向量检索(子串匹配在这个规模更快、零维护)、`usage_count` 排序(实测 80 个 work 里只有 2 个被回头引用过)。
|
|
293
323
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-supervisor-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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.",
|
|
@@ -39,6 +39,15 @@
|
|
|
39
39
|
"src/event-parser.js",
|
|
40
40
|
"src/worktree.js",
|
|
41
41
|
"src/landing.js",
|
|
42
|
+
"src/acceptance.js",
|
|
43
|
+
"src/acceptance-baseline.js",
|
|
44
|
+
"src/worker-changes.js",
|
|
45
|
+
"src/owned-changes.js",
|
|
46
|
+
"src/tool-guard.js",
|
|
47
|
+
"src/worker-report.js",
|
|
48
|
+
"src/worker-report.schema.json",
|
|
49
|
+
"src/handoff.js",
|
|
50
|
+
"src/external-output.js",
|
|
42
51
|
"src/truncate.js",
|
|
43
52
|
"src/status.js",
|
|
44
53
|
"src/paths.js",
|
|
@@ -16,13 +16,14 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
|
|
|
16
16
|
1. 先 `search_works` 搜一下,别重复派。
|
|
17
17
|
2. 拆活。每路写清楚:干什么、能写哪些文件、怎么算做完。改同一批文件就串行,文件完全不重叠才并行。
|
|
18
18
|
3. `create_codex_worker` 派出去。回执只有 `id`、`worktree_path`、`branch`、`owned_paths`、`status`,不回传任务原文。
|
|
19
|
-
4. `
|
|
19
|
+
4. 长任务配宿主 `/loop 5m check_workers` 定时收活,没变化 quiet,有新结果按 next_step 收。工具会按规则恢复一次,但不会唤醒关闭的主窗口;每个主线程设独立 `CODEX_SUPERVISOR_OBSERVER_ID` 可重启接回。短等用 `wait_codex_workers` 的 `timeoutMs: 60000`、`compact: true`,到点继续同批 task_ids。
|
|
20
20
|
|
|
21
21
|
| 参数 | 怎么填 |
|
|
22
22
|
|---|---|
|
|
23
23
|
| `task` | 这一路具体干什么。要能直接开工,别写"优化一下"。汇报格式 supervisor 已经附在 task 后面(结论 / 验证 / 没做的),别再要它列改动文件,diff 自己看 |
|
|
24
24
|
| `cwd` | 项目根目录。worker 在自己的 worktree 里干活,不动你的工作区 |
|
|
25
25
|
| `acceptance` | 这一步"做完了"的判据,shell 命令列表,worker 退出后 supervisor 在它的 worktree 里逐条跑,退出码 0 算过,worker 在 prompt 里看得到。任务书里的验证命令原样抄:查那个文件在不在、那个接口通不通、那个测试文件过不过。写能判这一步的,不写全仓回归;远端机器的检查包进 `ssh`。命令用 supervisor 自己的权限跑,等于你自己跑 |
|
|
26
|
+
| `forbid` / `allowedCommands` | 原样声明红线与验证命令;守卫拒绝未声明Shell程序,编辑用apply_patch |
|
|
26
27
|
| `ownedPaths` | 必填。这路允许写的路径,和在跑的 worker 重叠会被拒。冲突是好事,说明该改拆法 |
|
|
27
28
|
| `goal.objective` | 必填。一句话说目标,worker 会建成 Codex 原生 goal |
|
|
28
29
|
| `session_id` | 同一批传同一个值。第一路顺手带 `session_title`(30 字内,看板和 `get_session_works` 显示它),漏了用 `describe_session` 补 |
|
|
@@ -30,6 +31,28 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
|
|
|
30
31
|
| `baseRef` | worktree 从哪个提交切,默认 `HEAD`。第 N+1 步要建立在第 N 步上,填 `codex/<第 N 步 task_id>` |
|
|
31
32
|
| `sandbox` | 默认 `workspace-write`,worker 提交不了(Codex 把 `.git` 设成只读)。要它自己提交就 `danger-full-access`,否则收活时让 supervisor 替它提交 |
|
|
32
33
|
|
|
34
|
+
验收用 Bash 的 `errexit` + `pipefail`:`npm test | tail` 不能吞失败;预期失败用 `if` / `||` 显式判。超时即失败,别只看退出码 0。Windows 要有 Git for Windows Bash;缺失先修工具,别换回 cmd。
|
|
35
|
+
|
|
36
|
+
验收取当前身份用 `CODEX_SUPERVISOR_TASK_ID` / `CODEX_SUPERVISOR_BASE_COMMIT` / `CODEX_SUPERVISOR_RUN`;不要在命令里写死旧 base,rebase/resume 后这些值会更新。
|
|
37
|
+
|
|
38
|
+
派单前可用 `check_acceptance` 实跑验收命令;预检通过不代表 worker 已完成。已知失败必须按结构化 baseline 的用例名/类型/签名比,必跑项写 required;报告必须标本次 `CODEX_SUPERVISOR_CHECK_ID`,给 complete/identity/failures/executed/skipped,缺失、跳过和旧报告都不算过。reportPath 用工作区内忽略的临时目录,验收报告别混进业务提交。
|
|
39
|
+
|
|
40
|
+
同批公共门禁用 `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。
|
|
41
|
+
|
|
42
|
+
wait默认60秒和compact,带includeEvents则详细返回;客户端带progress token时每30秒收到通知。已实测Claude2.1.299在35秒idle下收到三次progress,65秒wait正常返回;通知不能唤醒关闭的宿主。/loop实测可定时调用,主窗口须保持运行。
|
|
43
|
+
|
|
44
|
+
派单写forbid红线、allowedCommands验证命令;runtime守卫按次注入并随resume/followup继承。apply_patch核对ownedPaths,Shell仅放简单读取和显式声明的验证命令;声明脚本可以有副作用,须先核对,不能当万能文件沙箱。no_work表示本轮write无输出变化且没跑命令;先看run_evidence,不拿上轮提交/命令当本轮完成。
|
|
45
|
+
|
|
46
|
+
check_workers可对已死的第1轮lost/no_work自动resume一次,recoveries记动作;第2轮仍失败看证据处理,审批/认证/权限/quota不盲重试。最终报告强制JSON,structured_report仅验证格式;invalid_report拒land,resume让模型提交合法JSON,命令和acceptance另外核对。
|
|
47
|
+
|
|
48
|
+
未提交材料用context:[{path:绝对路径,sha256:可选}];首次记哈希,resume材料变了要显式换context。context/contracts总6000字、最多20份文件,每份≤5 MB;handoff1800字/16行可裁,完整约束和refs另传。输入路径不等于写授权。
|
|
49
|
+
|
|
50
|
+
共享写入必须externalOutputs:[{path,sha256?}]+acceptance;绝对文件每份≤1 MB,参与归属冲突/hook。看external_outputs的前后内容、哈希与验收;外部文件已经写在共享目录,不用land,不能拿空worktree diff否认成果。
|
|
51
|
+
|
|
52
|
+
远端编译/ssh在workspace-write显式networkAccess:true,默认false,resume/followup继承;不要用danger-full-access代替联网配置。需要时声明maxRunMs/maxTotalMs,超限保留partial work并提示处理,不自动恢复;wait预算与quota分开。
|
|
53
|
+
|
|
54
|
+
Codex需0.162+支持hooks/output-schema,能力不够派单start_failed先修CLI。goal查询看native_goal_read,missing与locked/read_error分开;budget/usage限制也要处理。cleanup保留ignored成果、共享证据及未解决attention。
|
|
55
|
+
|
|
33
56
|
等待的几条规矩:
|
|
34
57
|
|
|
35
58
|
- 等待预算管这次调用,不管 worker。`still_running: true` 是等满了不是挂了,按 `next_step` 再调。
|
|
@@ -44,7 +67,7 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
|
|
|
44
67
|
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 步)。
|
|
45
68
|
2. `get_worker_diff`:它实际做了什么。起点到工作区的全部改动,提交没提交都算;`maxChars` 管总量,`paths` 缩范围。它说过了不算,diff 对得上才算。
|
|
46
69
|
3. 对不上、看不懂为什么:`ask_codex_worker` 带 `question` 问它。fork 出一个只读旁路,worker 自己的线程不动;fork 没网络没 MCP 工具,问"改了什么、为什么、在哪",别问要联网才能答的事。超时回 `running`,只带 `task_id` 再调拿答案。worker 被 resume 过后下一问自动换新 fork,`fresh: true` 强制换,问完 `end: true` 删。
|
|
47
|
-
4. 要它改:`resume_codex_worker`,写清问题在哪,让它改完 `git commit --amend --no-edit` 并进原来那个提交。旁路只读,改东西永远走 resume。主线往前走过(`base_behind.behind > 0`)就带 `rebaseOnto: "HEAD"`(在派单目录里解析):未提交的改动先 stash
|
|
70
|
+
4. 要它改:`resume_codex_worker`,写清问题在哪,让它改完 `git commit --amend --no-edit` 并进原来那个提交。旁路只读,改东西永远走 resume。主线往前走过(`base_behind.behind > 0`)就带 `rebaseOnto: "HEAD"`(在派单目录里解析):未提交的改动先 stash,跳过已合入的补丁,只把新增提交重放到新头,stash 放回,`base_commit` 跟着动。冲突(`rebase_conflict` / `stash_conflict`)会原样退回、不起 worker、`files` 列冲突文件;这时让它先 `land_codex_worker` 带 `commitMessage` 提交成一笔再 rebase,或者重派一路 `baseRef` 填新头。
|
|
48
71
|
5. 过了:`land_codex_worker` 把 `codex/<id>` 上的提交 cherry-pick 到派单目录当前分支。目标脏了、分支不对、冲突都拒绝并原样退回。worker 没提交(默认沙箱提交不了)就带 `commitMessage`,supervisor 在它分支上替它提交一笔再落。验收 `failed` 它会拒,修完再落;`ignoreAcceptance` 只在用户说了"就这样落"时用。
|
|
49
72
|
|
|
50
73
|
一批活全部到终态后:`get_orchestration_overview` 确认没有 `needs_attention`、`acceptance_failed` 为空,再逐路走上面几步。合不合、怎么合由主线程定。
|
|
@@ -69,8 +92,8 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
|
|
|
69
92
|
|
|
70
93
|
| 情况 | 用什么 |
|
|
71
94
|
|---|---|
|
|
72
|
-
| 主线程自己挂了 |
|
|
73
|
-
| worker 变 `lost`(
|
|
95
|
+
| 主线程自己挂了 | 独立运行进程继续记日志、状态和验收;新窗口 `get_session_works({ session_id })` 收回同批活 |
|
|
96
|
+
| worker 变 `lost`(worker 或独立运行进程中断) | `resume_codex_worker`。worktree 里的改动和 `thread_id` 都在,同一线程接着干;被杀时正在做的那一步可能要重做 |
|
|
74
97
|
| worktree 落后主线(`base_behind.behind > 0`) | `resume_codex_worker` 带 `rebaseOnto: "HEAD"`,见收活第 4 步 |
|
|
75
98
|
| worker `failed` | 看 `error` 和日志,查完再 resume 或重派 |
|
|
76
99
|
| 没记到 `thread_id` 的老行 | `create_codex_followup_worker`,新线程靠文本重述 |
|
|
@@ -85,10 +108,14 @@ overview、派单回执、`wait` 返回里出现 `update` 且 `update_available:
|
|
|
85
108
|
|
|
86
109
|
- worktree 从一个提交切,你工作区里没 commit 的东西 worker 看不到。要让它读到就给绝对路径或先 commit。
|
|
87
110
|
- `exit_code: 0` 只说明没崩。`acceptance` 是 supervisor 替你跑的验收,`verification` 是它自己跑过的,两个都没有就只剩 diff。验收命令别往 worktree 写文件,会混进它的改动。
|
|
88
|
-
- `ownedPaths`
|
|
111
|
+
- `ownedPaths` 在跨MCP派单/恢复时原子预留,验收和退出结算前仍占用;Git隔离创建失败不退回主目录。land 按真实 diff 拒越界(提交草稿前就查)。仍不等于运行时沙箱,收活看 diff;`allowOutsideOwned` 只用于用户明确批准的例外。
|
|
89
112
|
- worktree 只隔离工作区,端口和数据库是共用的。
|
|
90
113
|
- `resume_codex_worker` 不会再建 goal。`cancel_codex_worker` 跨进程靠 pid,要求那个 pid 的命令行里带 `codex`。
|
|
91
114
|
|
|
115
|
+
收尾先 `npm run cleanup -- --dry-run` 看清理候选;只有已合入、干净、无活跃依赖的目录才可apply。脏、未合、lost/failed和证明不了的保留,禁止强删未知成果。
|
|
116
|
+
|
|
92
117
|
## 看板
|
|
93
118
|
|
|
94
119
|
用户想用眼睛看就让他起 `codex-supervisor-web`(或 `npx -p codex-supervisor-mcp codex-supervisor-web`),开 `http://127.0.0.1:7877`。按 session 分组,每路有「旁问」tab,用户可以自己问 worker。
|
|
120
|
+
|
|
121
|
+
安装后没工具:先查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。
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Compare complete test identities, never a grep of the total failure count.
|
|
2
|
+
// The caller supplies an approved baseline and the current runner's evidence.
|
|
3
|
+
export function compareFailureBaseline(expected, actual) {
|
|
4
|
+
const errors = [];
|
|
5
|
+
const result = { passed: false, added: [], removed: [], changed: [], missing_required: [], errors };
|
|
6
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
|
+
const text = (value) => typeof value === "string" && value.trim().length > 0;
|
|
8
|
+
if (!object(expected) || !object(actual)) {
|
|
9
|
+
errors.push("baseline and report must be objects");
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
if (!object(expected.identity) || !text(expected.identity.base_commit)) errors.push("baseline identity.base_commit is required");
|
|
13
|
+
if (!object(actual.identity) || !text(actual.identity.base_commit)) errors.push("report identity.base_commit is required");
|
|
14
|
+
if (expected.identity?.base_commit !== actual.identity?.base_commit) errors.push("base_commit mismatch");
|
|
15
|
+
if (actual.complete !== true) errors.push("report is not complete");
|
|
16
|
+
// Any explicitly approved identity component must match, including suite
|
|
17
|
+
// version, dataset hash or measured commit. Extra actual fields are allowed.
|
|
18
|
+
for (const [key, value] of Object.entries(expected.identity ?? {})) {
|
|
19
|
+
if (!text(value)) errors.push(`baseline identity.${key} must be a nonempty string`);
|
|
20
|
+
else if (actual.identity?.[key] !== value && key !== "base_commit") errors.push(`identity.${key} mismatch`);
|
|
21
|
+
}
|
|
22
|
+
const ids = (value, label) => {
|
|
23
|
+
if (!Array.isArray(value) || value.some((entry) => !text(entry))) {
|
|
24
|
+
errors.push(`${label} must be an array of nonempty test IDs`);
|
|
25
|
+
return new Set();
|
|
26
|
+
}
|
|
27
|
+
const unique = new Set(value);
|
|
28
|
+
if (unique.size !== value.length) errors.push(`${label} has duplicate test IDs`);
|
|
29
|
+
return unique;
|
|
30
|
+
};
|
|
31
|
+
const required = ids(expected.required, "required");
|
|
32
|
+
const executed = ids(actual.executed, "executed");
|
|
33
|
+
const skipped = ids(actual.skipped, "skipped");
|
|
34
|
+
for (const id of skipped) if (executed.has(id)) errors.push(`test ${id} is both executed and skipped`);
|
|
35
|
+
result.missing_required = [...required].filter((id) => !executed.has(id) || skipped.has(id)).sort();
|
|
36
|
+
const failures = (value, label) => {
|
|
37
|
+
const map = new Map();
|
|
38
|
+
if (!Array.isArray(value)) {
|
|
39
|
+
errors.push(`${label} failures must be an array`);
|
|
40
|
+
return map;
|
|
41
|
+
}
|
|
42
|
+
for (const item of value) {
|
|
43
|
+
if (!object(item) || !text(item.test_id) || !["failure", "error"].includes(item.kind) || !text(item.signature)) {
|
|
44
|
+
errors.push(`${label} has a malformed failure record`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (map.has(item.test_id)) errors.push(`${label} has duplicate failure ${item.test_id}`);
|
|
48
|
+
map.set(item.test_id, { test_id: item.test_id, kind: item.kind, signature: item.signature });
|
|
49
|
+
}
|
|
50
|
+
return map;
|
|
51
|
+
};
|
|
52
|
+
const baseline = failures(expected.failures, "baseline");
|
|
53
|
+
const observed = failures(actual.failures, "report");
|
|
54
|
+
for (const [id, item] of observed) {
|
|
55
|
+
if (!executed.has(id)) errors.push(`failure ${id} was not executed`);
|
|
56
|
+
const before = baseline.get(id);
|
|
57
|
+
if (!before) result.added.push(item);
|
|
58
|
+
else if (before.kind !== item.kind || before.signature !== item.signature) result.changed.push({ test_id: id, expected: before, actual: item });
|
|
59
|
+
}
|
|
60
|
+
for (const [id, item] of baseline) if (!observed.has(id)) result.removed.push(item);
|
|
61
|
+
for (const key of ["added", "removed", "changed"]) result[key].sort((a, b) => a.test_id.localeCompare(b.test_id));
|
|
62
|
+
result.passed = errors.length === 0 && result.added.length === 0 && result.removed.length === 0 && result.changed.length === 0 && result.missing_required.length === 0;
|
|
63
|
+
return result;
|
|
64
|
+
}
|