codex-supervisor-mcp 0.7.1 → 0.7.2
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 +98 -195
- package/README.md +71 -168
- package/package.json +1 -1
- package/skills/codex-supervisor/SKILL.md +53 -131
- package/src/landing.js +33 -1
package/README.en.md
CHANGED
|
@@ -16,23 +16,23 @@ English | [中文](README.md)
|
|
|
16
16
|
|
|
17
17
|
## What it is
|
|
18
18
|
|
|
19
|
-
Point several agents at one repository and they overwrite each other, and nobody can say
|
|
19
|
+
Point several agents at one repository and they overwrite each other, and nobody can say who changed what. This MCP takes dispatch and bookkeeping out of the model's context and puts them on disk:
|
|
20
20
|
|
|
21
|
-
| Problem | What
|
|
21
|
+
| Problem | What it does |
|
|
22
22
|
|---|---|
|
|
23
|
-
| Workers
|
|
24
|
-
|
|
|
23
|
+
| Workers trample each other's files | One Git worktree per worker, `ownedPaths` checked for overlap before dispatch |
|
|
24
|
+
| Worker output floods the main thread | Events go to `data/runs/<taskId>.jsonl`; reads are gated by `limit` / `maxChars` / `kinds` |
|
|
25
25
|
| One status read fills the context | `get_orchestration_overview` fits every worker into 7000 bytes |
|
|
26
|
-
| Nobody knows who is still running after a restart | `supervisor.sqlite
|
|
27
|
-
| A new session cannot pick up an old worker | `resume_codex_worker` runs `codex exec resume <thread_id
|
|
28
|
-
| "
|
|
29
|
-
|
|
|
26
|
+
| Nobody knows who is still running after a restart | `supervisor.sqlite`, one row per work, with `thread_id` |
|
|
27
|
+
| A new session cannot pick up an old worker | `resume_codex_worker` runs `codex exec resume <thread_id>`: the same Codex conversation |
|
|
28
|
+
| "Failed" and "process gone" look alike | The state machine keeps `failed` and `lost` apart |
|
|
29
|
+
| No view of where a batch is | `codex-supervisor-web`, a board that shows every worker by session |
|
|
30
30
|
|
|
31
|
-
Workers
|
|
31
|
+
Workers run `codex exec`; `model` is passed through. The main thread stays on Claude for judgement, workers can run DeepSeek or any model Codex has a provider for, and the bills stay separate.
|
|
32
32
|
|
|
33
33
|
## Five minutes to a running batch
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Prerequisites: Node.js 22.13.0 or newer, `codex` on `PATH`. macOS, Linux and Windows.
|
|
36
36
|
|
|
37
37
|
### 1. Install
|
|
38
38
|
|
|
@@ -40,37 +40,30 @@ Requirements: Node.js 22.13.0 or newer, and the `codex` CLI on `PATH`. macOS, Li
|
|
|
40
40
|
npm install -g codex-supervisor-mcp
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
claude mcp list | grep codex-supervisor
|
|
47
|
-
codex mcp list | grep codex-supervisor
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
If it is missing (`npx`, `--ignore-scripts` and pnpm installs skip `postinstall`), add it by hand:
|
|
43
|
+
`postinstall` copies the skill into `~/.claude/skills/`, `~/.agents/skills/` and `~/.codex/skills/` and registers the MCP with `claude mcp add -s user` and `codex mcp add`. If `claude mcp list` does not show it (`npx`, `--ignore-scripts` and pnpm skip `postinstall`), add it by hand:
|
|
51
44
|
|
|
52
45
|
```bash
|
|
53
46
|
claude mcp add -s user codex-supervisor -- npx -y codex-supervisor-mcp
|
|
54
47
|
codex mcp add codex-supervisor -- npx -y codex-supervisor-mcp
|
|
55
48
|
```
|
|
56
49
|
|
|
57
|
-
Restart Claude Code / Codex
|
|
50
|
+
Restart Claude Code / Codex. Updates take care of themselves from here; see "Updating".
|
|
58
51
|
|
|
59
52
|
### 2. Dispatch a batch
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
Say it in plain words in Claude Code; the skill makes it follow the right steps:
|
|
62
55
|
|
|
63
|
-
> Fill in the unit tests for these three modules
|
|
56
|
+
> Fill in the unit tests for these three modules, three codex-supervisor workers in parallel, session "unit tests".
|
|
64
57
|
|
|
65
58
|
What the main thread does underneath (you can call the tools yourself):
|
|
66
59
|
|
|
67
60
|
```
|
|
68
61
|
create_codex_worker ×3 each with session_id, session_title, ownedPaths, goal
|
|
69
|
-
wait_codex_workers two
|
|
70
|
-
get_worker_result ×3
|
|
62
|
+
wait_codex_workers two minutes by default, then a snapshot, call again until done
|
|
63
|
+
get_worker_result ×3 each worker's full report and changed files
|
|
71
64
|
```
|
|
72
65
|
|
|
73
|
-
Each worker's changes sit on its own `codex/<taskId>` branch
|
|
66
|
+
Each worker's changes sit on its own `codex/<taskId>` branch; whether and how to merge is the main thread's call.
|
|
74
67
|
|
|
75
68
|
### 3. Open the board
|
|
76
69
|
|
|
@@ -80,17 +73,13 @@ codex-supervisor-web
|
|
|
80
73
|
npx -p codex-supervisor-mcp codex-supervisor-web
|
|
81
74
|
```
|
|
82
75
|
|
|
83
|
-
Open `http://127.0.0.1:7877`.
|
|
84
|
-
|
|
85
|
-
Which store it opens: `SUPERVISOR_HOME` from the environment if set; otherwise the nearest `.mcp.json` above the current directory, if its `codex-supervisor` entry sets `SUPERVISOR_HOME`; otherwise the default `~/.codex-supervisor`. The startup line says which one and where it came from, so running it inside the project directory is enough.
|
|
86
|
-
|
|
87
|
-
`SUPERVISOR_WEB_PORT` changes the port. A taken port (usually a board that is already running) is reported in one line and the process exits. The board does not dispatch or cancel; the ask tab starts a read-only Codex side session, described below.
|
|
76
|
+
Open `http://127.0.0.1:7877`. State directory: `SUPERVISOR_HOME` if set, else the one configured in the nearest `.mcp.json` above the current directory, else `~/.codex-supervisor`. `SUPERVISOR_WEB_PORT` changes the port; a taken port is reported. The board never dispatches or cancels.
|
|
88
77
|
|
|
89
78
|
## How I use it
|
|
90
79
|
|
|
91
|
-
|
|
80
|
+
This MCP does not care who the main thread is: Claude Code, Codex, Cursor, anything that speaks MCP can dispatch, and workers use whatever model Codex has a provider for. What follows is my way, not the only way.
|
|
92
81
|
|
|
93
|
-
I run two Claude Code sessions
|
|
82
|
+
I run two Claude Code sessions, one for documents and one for dispatch. A session that writes the design and watches the workers fills its context in two hours.
|
|
94
83
|
|
|
95
84
|
| Who | Where | Does what |
|
|
96
85
|
|---|---|---|
|
|
@@ -99,7 +88,7 @@ I run two Claude Code sessions. One writes documents, the other dispatches. A se
|
|
|
99
88
|
| 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 |
|
|
100
89
|
| Codex workers | Their own worktrees | One worker per step, one commit per step, build and verify on a remote machine. No push, no merge |
|
|
101
90
|
|
|
102
|
-
|
|
91
|
+
One block of text passes between the two sessions: the planning session writes it, I paste it into the main-brain session and hand it over with `/goal`. Its shape is fixed:
|
|
103
92
|
|
|
104
93
|
```text
|
|
105
94
|
[Role] You are the main brain: read docs and code, dispatch workers, check results, update docs, report to me. You write no business code.
|
|
@@ -134,19 +123,19 @@ land_codex_worker checked, then landed on the integration branch
|
|
|
134
123
|
|
|
135
124
|
The last block was 25 steps. The main-brain session ran it end to end with nothing in its context but the brief and each worker's report. The tokens the workers burn are not on the main brain's bill.
|
|
136
125
|
|
|
137
|
-
"One worker per step, one commit per step, checked before the next" came from trying it the other way.
|
|
126
|
+
"One worker per step, one commit per step, checked before the next" came from trying it the other way. When a step is wrong, one `resume_codex_worker` asks for `--amend` into the same commit, the main brain checks again, then lands. A worker that did three steps cannot be fixed this way: when step 5 is wrong, steps 6 and 7 are already on top.
|
|
138
127
|
|
|
139
128
|
## What the board shows
|
|
140
129
|
|
|
141
130
|
| Where | What |
|
|
142
131
|
|---|---|
|
|
143
|
-
| Left column | One
|
|
144
|
-
| Session page |
|
|
145
|
-
| Worker
|
|
146
|
-
| Worker drawer |
|
|
147
|
-
|
|
|
132
|
+
| Left column | One row per session: title, worker count, how many running, last activity. Version and update notice at the bottom |
|
|
133
|
+
| Session page | Counts (total / running / done / failed / lost); while workers run, the command each one is on |
|
|
134
|
+
| Worker table | One row per worker: status, title, current command or last report line, duration, files changed, commands run |
|
|
135
|
+
| Worker drawer | Seven tabs: overview, report, changes, commands, events, task, side chat |
|
|
136
|
+
| Side chat | Ask the worker a question, the way Codex's `/btw` works: its thread is forked into a read-only side session, the running work is untouched. Multi-turn, stoppable, and a page that leaves picks up where it was |
|
|
148
137
|
|
|
149
|
-
|
|
138
|
+
Light and dark follow the system. No external resources.
|
|
150
139
|
|
|
151
140
|
## Tools
|
|
152
141
|
|
|
@@ -154,78 +143,53 @@ Nineteen.
|
|
|
154
143
|
|
|
155
144
|
| Tool | Arguments | What it does |
|
|
156
145
|
|---|---|---|
|
|
157
|
-
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Start a worker. `
|
|
146
|
+
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Start a worker. `baseRef` picks the commit the worktree is cut from (default `HEAD`); pass another worker's `codex/<id>` to build on it |
|
|
158
147
|
| `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 |
|
|
159
148
|
| `resume_codex_worker` | `task_id`, `prompt` | Continue the same Codex conversation; `thread_id` stays |
|
|
160
|
-
| `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states. Two minutes by default, then a snapshot
|
|
149
|
+
| `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states. Two minutes by default, then a snapshot while the workers keep running; `compact` returns one line per worker |
|
|
161
150
|
| `get_orchestration_overview` | `status`, `limit` | Every worker in one table, capped at 7000 bytes. Carries `version` and `update` |
|
|
162
|
-
| `get_worker_result` | `task_id`, `limit`, `maxChars` | The worker's own full report plus `status` / `exit_code` / `changed_files
|
|
163
|
-
| `get_worker_diff` | `task_id`, `maxChars`, `paths` | What the worker actually changed: patches from the worktree's
|
|
151
|
+
| `get_worker_result` | `task_id`, `limit`, `maxChars` | The worker's own full report plus `status` / `exit_code` / `changed_files` |
|
|
152
|
+
| `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 |
|
|
164
153
|
| `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 |
|
|
165
|
-
| `land_codex_worker` | `task_id`, `onto`, `commitMessage` | Cherry-pick the worker's
|
|
154
|
+
| `land_codex_worker` | `task_id`, `onto`, `commitMessage` | Cherry-pick the worker's `codex/<id>` commits onto the current branch of the directory it was dispatched from. Clean target only, a conflict rolls back. `commitMessage` first commits the worker's uncommitted edits as one commit |
|
|
166
155
|
| `get_worker_summary` | `task_id` | One paragraph: goal, status, changes, last command and message |
|
|
167
|
-
| `get_codex_worker_status` | `task_id`, `includePrompt`, `promptMaxChars` | One worker in detail
|
|
156
|
+
| `get_codex_worker_status` | `task_id`, `includePrompt`, `promptMaxChars` | One worker in detail |
|
|
168
157
|
| `get_codex_worker_events` | `task_id`, `limit`, `maxChars`, `kinds` | The raw event stream |
|
|
169
158
|
| `get_worker_goal` | `task_id` | The goal recorded at dispatch plus the native Codex goal (tokens, time) |
|
|
170
159
|
| `list_codex_workers` | `status`, `includeHistory`, `includeDetails` | List workers, active ones by default |
|
|
171
|
-
| `get_session_works` | `session_id` | Every worker of one session
|
|
172
|
-
| `describe_session` | `session_id`, `title`, `note` | Record a title and note
|
|
160
|
+
| `get_session_works` | `session_id` | Every worker of one session. The way back after a main-thread restart |
|
|
161
|
+
| `describe_session` | `session_id`, `title`, `note` | Record a title and note for a session |
|
|
173
162
|
| `search_works` | `query`, `limit` | Substring search over title / goal / prompt / last_message, newest first |
|
|
174
|
-
| `check_for_update` | `force` | Ask the registry for a newer version
|
|
175
|
-
| `cancel_codex_worker` | `task_id` | Stop a worker. Falls back to the pid
|
|
176
|
-
|
|
177
|
-
### The three things to always pass
|
|
178
|
-
|
|
179
|
-
- `ownedPaths`: the paths this worker may write. Checked against every running worker before dispatch; an overlap refuses the call with the conflicting `task_id` and no worktree is created. It is a dispatch-time check, not a runtime sandbox.
|
|
180
|
-
- `goal.objective`: one line on what the worker is for. The worker creates a native Codex goal from it and marks it complete when done.
|
|
181
|
-
- `session_id`: not required by the schema, but without it nothing groups the batch and neither the board nor `get_session_works` can find it again. Same value for the whole batch, and `session_title` on the first dispatch.
|
|
182
|
-
|
|
183
|
-
### Reading results without filling the context
|
|
184
|
-
|
|
185
|
-
| Want | Use | Cost |
|
|
186
|
-
|---|---|---|
|
|
187
|
-
| Status of every worker | `get_orchestration_overview` | 7000 bytes, hard cap |
|
|
188
|
-
| One worker's conclusion | `get_worker_result` | The full report, tens of thousands of characters for a big job |
|
|
189
|
-
| Alive or finished | `get_worker_summary` | A paragraph |
|
|
190
|
-
| What it did | `get_codex_worker_events` | Filter with `kinds`, bound with `limit`, clip with `maxChars` |
|
|
191
|
-
| What it actually changed | `get_worker_diff` | Capped by `maxChars`; the file list is always complete |
|
|
192
|
-
| Why it did that | `ask_codex_worker` | One answer; the fork carries the worker's whole context |
|
|
163
|
+
| `check_for_update` | `force` | Ask the registry for a newer version |
|
|
164
|
+
| `cancel_codex_worker` | `task_id` | Stop a worker. Falls back to the pid across processes, after confirming that pid runs codex |
|
|
193
165
|
|
|
194
|
-
|
|
166
|
+
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.
|
|
195
167
|
|
|
196
168
|
## How this differs from Claude Code subagents
|
|
197
169
|
|
|
198
|
-
File isolation is not the difference:
|
|
170
|
+
File isolation is not the difference: a subagent can open a worktree too. The difference is the model and the process.
|
|
199
171
|
|
|
200
172
|
| | Claude Code subagent | codex-supervisor worker |
|
|
201
173
|
|---|---|---|
|
|
202
|
-
|
|
|
174
|
+
| Model | Claude only | `model` passed to the Codex CLI; DeepSeek works |
|
|
203
175
|
| Who does the work | Claude Code itself | A separate `codex exec` process |
|
|
204
|
-
| Two
|
|
205
|
-
| Main
|
|
176
|
+
| Two writers on one file | Worktrees keep them apart, no path declaration | `ownedPaths` overlap is refused before dispatch |
|
|
177
|
+
| Main-thread process dies | Workers die with it | `thread_id` is in sqlite; `resume_codex_worker` picks the same conversation up |
|
|
206
178
|
| Who can drive it | Claude Code only | Any MCP client |
|
|
207
|
-
|
|
|
179
|
+
| Seeing the process | Only the returned conclusion | Raw JSONL and the web board |
|
|
208
180
|
|
|
209
181
|
## The state machine
|
|
210
182
|
|
|
211
|
-
`status`
|
|
212
|
-
|
|
213
|
-
| Value | Meaning |
|
|
183
|
+
| `status` | Meaning |
|
|
214
184
|
|---|---|
|
|
215
185
|
| `queued` | Dispatched, not started |
|
|
216
|
-
| `running` | Running |
|
|
217
|
-
| `completed` |
|
|
218
|
-
| `failed` | Non-zero exit, `turn.failed`,
|
|
186
|
+
| `running` | Running. `phase`: `starting → thinking → command → editing → reporting` |
|
|
187
|
+
| `completed` | Done |
|
|
188
|
+
| `failed` | Non-zero exit, `turn.failed`, spawn failure |
|
|
219
189
|
| `cancelled` | Stopped by `cancel_codex_worker` |
|
|
220
|
-
| `lost` | Killed by an outside signal,
|
|
221
|
-
|
|
222
|
-
`phase` has a value only while `running`: `starting → thinking → command → editing → reporting`.
|
|
223
|
-
|
|
224
|
-
`failed` sends you to the logs; `lost` means run it again. A terminal state lands in two steps: `turn.completed` sets `completed`, the process exit writes `exit_code`. `wait_codex_workers` waits for the second step; a direct status read that sees `completed` with `exit_code: null` is in the gap, read again.
|
|
225
|
-
|
|
226
|
-
Windows has no signals. An outside kill and the process calling `exit(1)` look the same to the parent, so there it reports `failed` with the exit code.
|
|
190
|
+
| `lost` | Killed by an outside signal, MCP process gone, or a row whose process never started. `resume_codex_worker` picks it up |
|
|
227
191
|
|
|
228
|
-
|
|
192
|
+
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`.
|
|
229
193
|
|
|
230
194
|
## Where state lives
|
|
231
195
|
|
|
@@ -233,42 +197,31 @@ Native Codex goal states map like this: `active` / `paused` / `blocked` are `run
|
|
|
233
197
|
|
|
234
198
|
| File | Content |
|
|
235
199
|
|---|---|
|
|
236
|
-
| `data/supervisor.sqlite` | `tasks` (one row per work), `task_events`
|
|
237
|
-
| `data/runs/<taskId>.jsonl` |
|
|
238
|
-
| `data/update-check.json` |
|
|
239
|
-
| `worktrees/<taskId>/` |
|
|
240
|
-
|
|
241
|
-
`changed_files` has three sources: Codex's `file_change` events; `git status --porcelain` in the worktree (uncommitted); `git diff --name-only <base_commit> HEAD` (committed). The last two exist because a worker editing through the shell emits no `file_change` event, and once it commits `git status` is clean again. A real batch of five did exactly that and every read came back empty. `base_commit` is recorded at dispatch; older rows fall back to the oldest reflog entry of the branch. Every git read passes `core.quotePath=false`, so non-ASCII file names come back as written instead of octal-escaped.
|
|
242
|
-
|
|
243
|
-
A 0.1.x database migrates itself the first time it is opened, without losing a row.
|
|
244
|
-
|
|
245
|
-
## Update check
|
|
246
|
-
|
|
247
|
-
When the MCP process starts it asks the npm registry which version is `latest` and what that tarball's integrity is, then compares two things with the install:
|
|
248
|
-
|
|
249
|
-
- The version. If it is behind, `get_orchestration_overview`, the dispatch receipt and the `wait_codex_workers` response gain an `update` field with `latest_version` and `npm i -g codex-supervisor-mcp@latest`. The skill tells the main thread to pass that on.
|
|
250
|
-
- The files. A global install records the unpacked tarball's integrity in `node_modules/.package-lock.json`; if it differs from the registry's value for that version, the files on disk are not the published build and the notice says to reinstall. A git checkout has no such value and reports its commit.
|
|
200
|
+
| `data/supervisor.sqlite` | `tasks` (one row per work), `task_events`, `sessions`, `side_sessions` / `side_turns` (side chat) |
|
|
201
|
+
| `data/runs/<taskId>.jsonl` | Raw `codex --json` output |
|
|
202
|
+
| `data/update-check.json`, `auto-update.json` | Update check and background update records |
|
|
203
|
+
| `worktrees/<taskId>/` | The worker's Git worktree |
|
|
251
204
|
|
|
252
|
-
|
|
205
|
+
`changed_files` is the worktree's real diff (`git status` plus `git diff <base_commit> HEAD`), so edits made through the shell and commits the worker made itself are both visible. Git reads run with `core.quotePath=false`, so non-ASCII file names come back as written. Databases from older versions migrate on first open.
|
|
253
206
|
|
|
254
207
|
## Environment variables
|
|
255
208
|
|
|
256
209
|
| Variable | Default | Effect |
|
|
257
210
|
|---|---|---|
|
|
258
|
-
| `SUPERVISOR_HOME` | `~/.codex-supervisor` | State root. The MCP and the board must
|
|
259
|
-
| `CODEX_HOME` | `~/.codex` | Read-only
|
|
260
|
-
| `CODEX_BIN` | `codex` | Path to the Codex CLI. The Windows `.cmd` shim is bypassed
|
|
211
|
+
| `SUPERVISOR_HOME` | `~/.codex-supervisor` | State root. The MCP and the board must point at the same one |
|
|
212
|
+
| `CODEX_HOME` | `~/.codex` | Read-only: the native `goals_1.sqlite` and the MCP config |
|
|
213
|
+
| `CODEX_BIN` | `codex` | Path to the Codex CLI. The Windows `.cmd` shim is bypassed |
|
|
261
214
|
| `GIT_BIN` | `git` | Path to git |
|
|
262
|
-
| `SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` | `7877` / `127.0.0.1` |
|
|
215
|
+
| `SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` | `7877` / `127.0.0.1` | Board address |
|
|
263
216
|
| `CODEX_SUPERVISOR_NO_UPDATE_CHECK` | unset | `1` disables the update check |
|
|
264
|
-
| `CODEX_SUPERVISOR_REGISTRY` | `https://registry.npmjs.org` | Registry for the update check |
|
|
217
|
+
| `CODEX_SUPERVISOR_REGISTRY` | `https://registry.npmjs.org` | Registry for the update check and the auto-update |
|
|
265
218
|
| `CODEX_SUPERVISOR_UPDATE_TIMEOUT_MS` | `4000` | How long to wait for the registry |
|
|
266
|
-
| `CODEX_SUPERVISOR_SKIP_SETUP` | unset | `1` skips the `postinstall` setup |
|
|
267
219
|
| `CODEX_SUPERVISOR_NO_AUTO_UPDATE` | unset | `1` turns the background auto-update off (notify only) |
|
|
268
220
|
| `CODEX_SUPERVISOR_SKIP_SKILL_SYNC` | unset | `1` turns the skill sync at server start off |
|
|
269
|
-
| `
|
|
221
|
+
| `CODEX_SUPERVISOR_SKIP_SETUP` | unset | `1` skips the `postinstall` setup |
|
|
222
|
+
| `CODEX_SUPERVISOR_NPM` | unset | npm for the auto-update; default is the one shipped with the running node |
|
|
270
223
|
|
|
271
|
-
|
|
224
|
+
GUI clients (Claude Desktop, Cursor, Windsurf) do not run `postinstall`: add this to their MCP config file, and since their `PATH` often lacks `codex`, give `CODEX_BIN` explicitly:
|
|
272
225
|
|
|
273
226
|
```json
|
|
274
227
|
{
|
|
@@ -282,124 +235,74 @@ A process started by a GUI client often has no `codex` on `PATH`; set `CODEX_BIN
|
|
|
282
235
|
}
|
|
283
236
|
```
|
|
284
237
|
|
|
285
|
-
##
|
|
286
|
-
|
|
287
|
-
### GUI clients
|
|
288
|
-
|
|
289
|
-
GUI clients do not run `postinstall`; add the JSON above to the config file:
|
|
290
|
-
|
|
291
|
-
| Client | macOS | Windows | Linux |
|
|
292
|
-
|---|---|---|---|
|
|
293
|
-
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | `%APPDATA%\Claude\claude_desktop_config.json` | `~/.config/Claude/claude_desktop_config.json` |
|
|
294
|
-
| Cursor | `~/.cursor/mcp.json` | `%APPDATA%\Cursor\mcp.json` | `~/.config/cursor/mcp.json` |
|
|
295
|
-
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | `%APPDATA%\Codeium\windsurf\mcp_config.json` | `~/.config/.codeium/windsurf/mcp_config.json` |
|
|
296
|
-
|
|
297
|
-
### Running the setup again
|
|
298
|
-
|
|
299
|
-
```bash
|
|
300
|
-
codex-supervisor-setup # detect clients, install the skill, register the MCP
|
|
301
|
-
codex-supervisor-setup --target claude,codex
|
|
302
|
-
codex-supervisor-setup --skill-only
|
|
303
|
-
codex-supervisor-setup --mcp-only
|
|
304
|
-
codex-supervisor-setup --dry-run # print the plan only
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
An existing skill with different content is backed up to `SKILL.md.bak-<timestamp>` before it is overwritten.
|
|
238
|
+
## Updating
|
|
308
239
|
|
|
309
|
-
|
|
240
|
+
Nothing to do by hand. The server asks the registry in the background at start (then every six hours); when a newer version is published it starts a detached process that runs `npm i -g` into the same global path. The running session is untouched; the next session starts on the new version. Progress lands in `data/auto-update.json` and in `update.auto_update` on tool results. Only a copy that `npm i -g` installed is touched; a git checkout, an `npm link` or an `npx` copy is left alone, and each version is attempted once.
|
|
310
241
|
|
|
311
|
-
|
|
242
|
+
The skill takes care of itself too: every server start copies the bundled skill into whichever skill directories exist, backing up a differing file as `SKILL.md.bak-<timestamp>`. A session that already loaded the skill sees the new text after loading it again.
|
|
312
243
|
|
|
313
|
-
|
|
244
|
+
Where the global directory needs sudo the install fails, 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. Switching Node versions breaks the registered absolute path: `claude mcp remove -s user codex-supervisor` and `codex mcp remove codex-supervisor` first, then install. To run the setup again: `codex-supervisor-setup` (`--skill-only` / `--mcp-only` / `--dry-run`).
|
|
314
245
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
```bash
|
|
318
|
-
npm install -g codex-supervisor-mcp@latest
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
Versions up to 0.6.1 only notify and never install. Coming from one of those, upgrade by hand once; after that it is automatic. No re-registration needed.
|
|
322
|
-
|
|
323
|
-
Manual-update pitfalls:
|
|
324
|
-
|
|
325
|
-
- The registry takes a few minutes to move `latest` after a publish. If the version did not change, wait, or pin the version.
|
|
326
|
-
- Switching Node versions breaks the registered absolute path. Run `claude mcp remove -s user codex-supervisor` and `codex mcp remove codex-supervisor` first, then install.
|
|
327
|
-
- The skill takes care of itself: every server start copies the bundled skill into whichever of `~/.claude/skills/`, `~/.agents/skills/` and `~/.codex/skills/` already exist, backing up a differing file as `SKILL.md.bak-<timestamp>`. A session that already loaded the skill sees the new text only after loading it again. `CODEX_SUPERVISOR_SKIP_SKILL_SYNC=1` turns the sync off.
|
|
328
|
-
|
|
329
|
-
### Uninstall
|
|
246
|
+
Uninstall:
|
|
330
247
|
|
|
331
248
|
```bash
|
|
332
249
|
npm uninstall -g codex-supervisor-mcp
|
|
333
250
|
claude mcp remove -s user codex-supervisor
|
|
334
251
|
codex mcp remove codex-supervisor
|
|
335
|
-
rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.codex/skills/codex-supervisor
|
|
336
|
-
rm -rf ~/.codex-supervisor
|
|
252
|
+
rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.codex/skills/codex-supervisor ~/.codex-supervisor
|
|
337
253
|
```
|
|
338
254
|
|
|
339
|
-
|
|
255
|
+
## Windows
|
|
340
256
|
|
|
341
|
-
- The npm-installed CLI is `codex.cmd`,
|
|
342
|
-
- Cross-process cancel
|
|
343
|
-
-
|
|
257
|
+
- The npm-installed CLI is `codex.cmd`, which Node refuses to spawn directly. The runner steps over it to `node_modules/@openai/codex/bin/codex.js` and runs that with `node`; no `shell: true`, which would leave only the shell killable on cancel.
|
|
258
|
+
- Cross-process cancel uses `taskkill /PID <pid> /T /F` for the whole tree, after confirming that pid runs codex.
|
|
259
|
+
- Besides `PATH`, `%APPDATA%\npm`, `%LOCALAPPDATA%\pnpm`, `%LOCALAPPDATA%\Volta\bin` and `%ProgramFiles%\nodejs` are probed.
|
|
344
260
|
|
|
345
|
-
|
|
261
|
+
## Troubleshooting
|
|
346
262
|
|
|
347
263
|
| Symptom | Cause | Fix |
|
|
348
264
|
|---|---|---|
|
|
349
265
|
| Not in `claude mcp list` | The install method skipped `postinstall` | `codex-supervisor-setup`, or `claude mcp add` by hand |
|
|
350
266
|
| 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` |
|
|
351
|
-
| Worker
|
|
267
|
+
| Worker `failed` at once with `spawn codex ENOENT` | No codex on the process `PATH` | Set `CODEX_BIN` in the config |
|
|
352
268
|
| `Cannot find module 'node:sqlite'` | Node older than 22.13.0 | Upgrade Node |
|
|
353
|
-
| Worker
|
|
269
|
+
| Worker `lost` | The MCP process was killed and took the worker with it | `resume_codex_worker` |
|
|
270
|
+
| 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` |
|
|
354
271
|
| `ownedPaths overlap with active worker(s)` | Two workers claimed the same paths | Split differently, or cancel the one holding them |
|
|
355
|
-
| The board is empty | The board and the MCP use different `SUPERVISOR_HOME`s | Start it inside
|
|
356
|
-
| `port 7877 ... is already in use` | A board is already running | Open
|
|
272
|
+
| 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` |
|
|
273
|
+
| `port 7877 ... is already in use` | A board is already running | Open it, or start another with `SUPERVISOR_WEB_PORT=8080` |
|
|
357
274
|
|
|
358
275
|
## Known limitations
|
|
359
276
|
|
|
360
|
-
- A worker is a child of the MCP process. Kill the MCP and the worker goes with it, settled as `lost
|
|
361
|
-
- In the default `workspace-write` sandbox a worker cannot commit
|
|
362
|
-
- The worktree is cut from a commit
|
|
363
|
-
- Only the working directory is isolated. Temp directories, databases and ports are shared
|
|
364
|
-
- `ownedPaths` is checked at dispatch only; it does not stop a worker from creating
|
|
365
|
-
- It
|
|
366
|
-
-
|
|
367
|
-
-
|
|
368
|
-
- `search_works` is substring matching. Fine at hundreds of rows; revisit at tens of thousands.
|
|
277
|
+
- A worker is a child of the MCP process. Kill the MCP and the worker goes with it, settled as `lost`; its worktree and `thread_id` survive and `resume_codex_worker` picks it up. Keeping it alive across that takes a resident daemon; see the Roadmap.
|
|
278
|
+
- 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
|
+
- The worktree is cut from a commit; uncommitted work in your checkout is not in it.
|
|
280
|
+
- Only the working directory is isolated. Temp directories, databases and ports are shared.
|
|
281
|
+
- `ownedPaths` is checked at dispatch only; it does not stop a worker from creating files outside its list. Read the diff.
|
|
282
|
+
- It knows "finished", not "correct". Acceptance is the main thread's job.
|
|
283
|
+
- One `wait_codex_workers` cannot wait to the end; the client's MCP tool timeout is a hard wall. Call it again.
|
|
284
|
+
- `search_works` is substring matching, fine for hundreds of works.
|
|
369
285
|
|
|
370
286
|
## Roadmap
|
|
371
287
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
6. ~~`session_id` + `get_session_works`~~ ✅
|
|
378
|
-
7. ~~`search_works`~~ ✅
|
|
379
|
-
8. ~~Native worker goals~~ ✅
|
|
380
|
-
9. ~~Windows~~ ✅
|
|
381
|
-
10. ~~Web board~~ ✅
|
|
382
|
-
11. ~~Session titles, update check, `baseRef`, committed changes visible~~ ✅
|
|
383
|
-
12. ~~Collecting work: `get_worker_diff` / `ask_codex_worker` / `land_codex_worker`; background auto-update~~ ✅
|
|
384
|
-
13. Resident daemon: move dispatch and process lifetime out of the MCP process
|
|
385
|
-
|
|
386
|
-
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), a layered memory index (not enough data to need one).
|
|
288
|
+
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
|
+
|
|
290
|
+
Next: a resident daemon, moving dispatch and process lifetime out of the MCP process.
|
|
291
|
+
|
|
292
|
+
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).
|
|
387
293
|
|
|
388
294
|
## Development
|
|
389
295
|
|
|
390
296
|
```bash
|
|
391
297
|
npm install
|
|
392
|
-
npm test #
|
|
393
|
-
npm run test:edge # test/edge only
|
|
394
|
-
npm run test:real # end to end
|
|
395
|
-
npm run
|
|
396
|
-
npm run
|
|
397
|
-
npm run web:install # board dependencies
|
|
398
|
-
npm run web:dev # board with hot reload, /api proxied to 7877
|
|
399
|
-
npm run web:build # bundle into web/dist; runs before publish
|
|
298
|
+
npm test # fake-codex replay, fast and deterministic
|
|
299
|
+
npm run test:edge # test/edge only
|
|
300
|
+
npm run test:real # end to end against the real codex CLI
|
|
301
|
+
npm run web:dev # board development, /api proxied to 7877
|
|
302
|
+
npm run web:build # bundle to web/dist, runs before npm publish
|
|
400
303
|
```
|
|
401
304
|
|
|
402
|
-
|
|
305
|
+
CI runs Ubuntu / macOS / Windows, plus a Node 22.13.0 job that pins the `engines` floor.
|
|
403
306
|
|
|
404
307
|
## License
|
|
405
308
|
|
package/README.md
CHANGED
|
@@ -40,21 +40,14 @@ worker 跑的是 `codex exec`,`model` 参数原样透传。主线程留在 Cla
|
|
|
40
40
|
npm install -g codex-supervisor-mcp
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
claude mcp list | grep codex-supervisor
|
|
47
|
-
codex mcp list | grep codex-supervisor
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
没看到就手动补(`npx`、`--ignore-scripts`、pnpm 这些装法不跑 `postinstall`):
|
|
43
|
+
`postinstall` 会把 skill 装进 `~/.claude/skills/`、`~/.agents/skills/`、`~/.codex/skills/`,并用 `claude mcp add -s user` 和 `codex mcp add` 注册 MCP。`claude mcp list` 里没看到(`npx`、`--ignore-scripts`、pnpm 不跑 `postinstall`)就手动补:
|
|
51
44
|
|
|
52
45
|
```bash
|
|
53
46
|
claude mcp add -s user codex-supervisor -- npx -y codex-supervisor-mcp
|
|
54
47
|
codex mcp add codex-supervisor -- npx -y codex-supervisor-mcp
|
|
55
48
|
```
|
|
56
49
|
|
|
57
|
-
重启 Claude Code / Codex
|
|
50
|
+
重启 Claude Code / Codex。以后不用再手动更,见「更新」。
|
|
58
51
|
|
|
59
52
|
### 2. 派第一批活
|
|
60
53
|
|
|
@@ -62,7 +55,7 @@ codex mcp add codex-supervisor -- npx -y codex-supervisor-mcp
|
|
|
62
55
|
|
|
63
56
|
> 把这三个模块的单测补齐,用 codex-supervisor 分三路并行跑,session 叫「补单测」。
|
|
64
57
|
|
|
65
|
-
|
|
58
|
+
主线程背后做的事(你也可以自己调工具):
|
|
66
59
|
|
|
67
60
|
```
|
|
68
61
|
create_codex_worker ×3 每路带 session_id、session_title、ownedPaths、goal
|
|
@@ -80,17 +73,13 @@ codex-supervisor-web
|
|
|
80
73
|
npx -p codex-supervisor-mcp codex-supervisor-web
|
|
81
74
|
```
|
|
82
75
|
|
|
83
|
-
打开 `http://127.0.0.1:7877
|
|
84
|
-
|
|
85
|
-
它读哪个状态目录:环境里有 `SUPERVISOR_HOME` 就用它;没有就从当前目录往上找 `.mcp.json`,里面 `codex-supervisor` 配了 `SUPERVISOR_HOME` 就用那个;都没有才用默认的 `~/.codex-supervisor`。启动时会打印用的是哪个、从哪来的。在项目目录里敲一下就对上了,不用再传路径。
|
|
86
|
-
|
|
87
|
-
端口用 `SUPERVISOR_WEB_PORT` 改。端口被占(多半是已经有一个看板在跑)会直接说明并退出。看板不派单也不取消;「旁问」会起一个只读的 Codex 旁路会话,见下面。
|
|
76
|
+
打开 `http://127.0.0.1:7877`。状态目录:有 `SUPERVISOR_HOME` 用它,没有就从当前目录往上找 `.mcp.json` 里的配置,再没有用 `~/.codex-supervisor`。端口用 `SUPERVISOR_WEB_PORT` 改,被占了会直接说。看板不派单也不取消。
|
|
88
77
|
|
|
89
78
|
## 我自己怎么用
|
|
90
79
|
|
|
91
|
-
|
|
80
|
+
这个 MCP 不挑主线程:Claude Code、Codex、Cursor,能连 MCP 的都能派活;worker 用什么模型看你给 Codex 配了哪个 provider。下面是我的用法,不是唯一用法。
|
|
92
81
|
|
|
93
|
-
我开两个 Claude Code
|
|
82
|
+
我开两个 Claude Code 会话,一个只管文档,一个只管派活。一个会话又写详设又盯 worker,上下文两小时就满。
|
|
94
83
|
|
|
95
84
|
| 谁 | 开在哪 | 管什么 |
|
|
96
85
|
|---|---|---|
|
|
@@ -99,7 +88,7 @@ npx -p codex-supervisor-mcp codex-supervisor-web
|
|
|
99
88
|
| 主脑会话 | 代码仓的一个 worktree | 读任务书,派 Codex worker,核每路的 diff,把结果填回任务书,向我汇报。不写业务代码 |
|
|
100
89
|
| Codex worker | 各自的 worktree | 一个 worker 做一步,一个提交,在远端机器上编译和验证。不 push,不合并 |
|
|
101
90
|
|
|
102
|
-
|
|
91
|
+
两个会话之间只传一段文字:规划会话写好,我粘进主脑会话,用 `/goal` 接上。结构固定:
|
|
103
92
|
|
|
104
93
|
```text
|
|
105
94
|
【角色】 你是主脑:读文档和代码,派 worker,核结果,更新文档,向我汇报。不写业务代码。
|
|
@@ -119,7 +108,7 @@ npx -p codex-supervisor-mcp codex-supervisor-web
|
|
|
119
108
|
【汇报】 中文,表格优先,报哪几项,然后停下来等我
|
|
120
109
|
```
|
|
121
110
|
|
|
122
|
-
|
|
111
|
+
主脑一轮下来调的工具:
|
|
123
112
|
|
|
124
113
|
```
|
|
125
114
|
search_works 查这批活派过没有
|
|
@@ -132,21 +121,21 @@ resume_codex_worker 要改就追一条,让它 amend 进原来那个提交
|
|
|
132
121
|
land_codex_worker 核过了,落进集成分支
|
|
133
122
|
```
|
|
134
123
|
|
|
135
|
-
上一块活 25 步,主脑会话从头跑到尾,上下文里只有任务书和每路的汇报。worker
|
|
124
|
+
上一块活 25 步,主脑会话从头跑到尾,上下文里只有任务书和每路的汇报。worker 烧的 token 不进主脑的账。
|
|
136
125
|
|
|
137
|
-
「一个 worker
|
|
126
|
+
「一个 worker 一步、一步一个提交、核过才进下一步」是试出来的。某一步不对,`resume_codex_worker` 追一条让它 `--amend` 进原来那个提交,主脑再核一次,过了才落。一个 worker 做三步就没法这么修:第 5 步错了,第 6、7 步已经叠在上面。
|
|
138
127
|
|
|
139
128
|
## 看板里有什么
|
|
140
129
|
|
|
141
130
|
| 位置 | 内容 |
|
|
142
131
|
|---|---|
|
|
143
|
-
| 左栏 | 每个 session
|
|
144
|
-
| session 页 |
|
|
145
|
-
| worker 台账 |
|
|
146
|
-
| worker 抽屉 |
|
|
147
|
-
| 旁问 | 对这路 worker 提问,就是 Codex
|
|
132
|
+
| 左栏 | 每个 session 一行:标题、worker 数、几路在跑、最近活动。左下角是版本和更新提示 |
|
|
133
|
+
| session 页 | 统计(总数 / 运行中 / 完成 / 失败 / 丢失),有 worker 在跑时列每路正在执行的命令 |
|
|
134
|
+
| worker 台账 | 一行一路:状态、标题、正在跑的命令或最后一句汇报、耗时、改了几个文件、跑了几条命令 |
|
|
135
|
+
| worker 抽屉 | 七个 tab:概览、汇报、改动、命令、事件、任务书、旁问 |
|
|
136
|
+
| 旁问 | 对这路 worker 提问,就是 Codex 的 `/btw`:从它的线程 fork 出只读旁路会话来答,不碰它正在跑的活。多轮、可中断、换标签页回来自动接上 |
|
|
148
137
|
|
|
149
|
-
|
|
138
|
+
浅色深色跟系统走,没有外网资源。
|
|
150
139
|
|
|
151
140
|
## 工具
|
|
152
141
|
|
|
@@ -154,48 +143,31 @@ land_codex_worker 核过了,落进集成分支
|
|
|
154
143
|
|
|
155
144
|
| 工具 | 入参 | 作用 |
|
|
156
145
|
|---|---|---|
|
|
157
|
-
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | 起一个 worker。`
|
|
146
|
+
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | 起一个 worker。`baseRef` 指定 worktree 从哪个提交切,默认 `HEAD`,接着另一路干就填它的 `codex/<id>` |
|
|
158
147
|
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, 其余同上 | 开一个新会话,把老 worker 的 prompt、状态、近期事件拼进去 |
|
|
159
148
|
| `resume_codex_worker` | `task_id`, `prompt` | 接同一个 Codex 会话继续跑,`thread_id` 不变 |
|
|
160
|
-
| `wait_codex_workers` | `task_ids`, `mode`(any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | 等终态。默认 2 分钟,到点带快照返回,worker 照跑;`
|
|
149
|
+
| `wait_codex_workers` | `task_ids`, `mode`(any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | 等终态。默认 2 分钟,到点带快照返回,worker 照跑;`compact` 每路只回一行 |
|
|
161
150
|
| `get_orchestration_overview` | `status`, `limit` | 全部 worker 的状态表,封顶 7000 字节。带 `version` 和 `update` |
|
|
162
|
-
| `get_worker_result` | `task_id`, `limit`, `maxChars` | worker 自己的完整汇报,外加 `status` / `exit_code` / `changed_files
|
|
163
|
-
| `get_worker_diff` | `task_id`, `maxChars`, `paths` | worker 实际改了什么:从 worktree 起点到工作区的 patch
|
|
151
|
+
| `get_worker_result` | `task_id`, `limit`, `maxChars` | worker 自己的完整汇报,外加 `status` / `exit_code` / `changed_files` |
|
|
152
|
+
| `get_worker_diff` | `task_id`, `maxChars`, `paths` | worker 实际改了什么:从 worktree 起点到工作区的 patch,提交没提交都算。`maxChars` 管总量,超了的文件只列名 |
|
|
164
153
|
| `ask_codex_worker` | `task_id`, `question`, `timeoutMs`, `maxChars`, `fresh`, `end` | 旁路问 worker 一句。线程 fork 成只读侧会话,没网络、没 MCP 工具,worker 本身不动。worker 被 resume 过会自动换新 fork,`fresh` 强制换,`end` 删 |
|
|
165
|
-
| `land_codex_worker` | `task_id`, `onto`, `commitMessage` | 把 worker 在 `codex/<id>` 上的提交 cherry-pick
|
|
154
|
+
| `land_codex_worker` | `task_id`, `onto`, `commitMessage` | 把 worker 在 `codex/<id>` 上的提交 cherry-pick 到派单目录的当前分支。目标必须干净,冲突就回滚。`commitMessage` 先替它把未提交的改动提交成一笔 |
|
|
166
155
|
| `get_worker_summary` | `task_id` | 一段话:goal、状态、改动、最后一条命令和消息 |
|
|
167
|
-
| `get_codex_worker_status` | `task_id`, `includePrompt`, `promptMaxChars` | 单个 worker
|
|
156
|
+
| `get_codex_worker_status` | `task_id`, `includePrompt`, `promptMaxChars` | 单个 worker 的状态细节 |
|
|
168
157
|
| `get_codex_worker_events` | `task_id`, `limit`, `maxChars`, `kinds` | 原始事件流 |
|
|
169
158
|
| `get_worker_goal` | `task_id` | 派单时记的 goal + Codex 原生 goal(token、用时) |
|
|
170
159
|
| `list_codex_workers` | `status`, `includeHistory`, `includeDetails` | 列 worker,默认只看在跑的 |
|
|
171
|
-
| `get_session_works` | `session_id` | 一个 session 的全部 worker
|
|
172
|
-
| `describe_session` | `session_id`, `title`, `note` | 给 session
|
|
160
|
+
| `get_session_works` | `session_id` | 一个 session 的全部 worker。主线程重启后靠它找回那批活 |
|
|
161
|
+
| `describe_session` | `session_id`, `title`, `note` | 给 session 记标题和说明 |
|
|
173
162
|
| `search_works` | `query`, `limit` | 在 title / goal / prompt / last_message 里找子串,从新到旧 |
|
|
174
|
-
| `check_for_update` | `force` | 问 registry
|
|
175
|
-
| `cancel_codex_worker` | `task_id` | 终止 worker
|
|
176
|
-
|
|
177
|
-
### 三个必填项
|
|
178
|
-
|
|
179
|
-
- `ownedPaths`:这路 worker 允许写的路径。派单前和所有在跑的 worker 求交集,重叠就拒,返回冲突的 `task_id`,worktree 都不会建。它只在派单时查,不是运行时沙箱。
|
|
180
|
-
- `goal.objective`:一句话说这路活的目标。worker 起手会用它建 Codex 原生 goal,干完标 complete。
|
|
181
|
-
- `session_id`:严格说不是必填,但不传就归不了组,看板和 `get_session_works` 都找不回来。一批活传同一个值,第一路顺手带上 `session_title`。
|
|
182
|
-
|
|
183
|
-
### 读结果别撑爆上下文
|
|
184
|
-
|
|
185
|
-
| 想干什么 | 用哪个 | 代价 |
|
|
186
|
-
|---|---|---|
|
|
187
|
-
| 看全部 worker 状态 | `get_orchestration_overview` | 7000 字节封顶 |
|
|
188
|
-
| 收一路的结论 | `get_worker_result` | 汇报全文,大活上万字 |
|
|
189
|
-
| 只看活着还是完了 | `get_worker_summary` | 一段话 |
|
|
190
|
-
| 看过程 | `get_codex_worker_events` | 用 `kinds` 先滤、`limit` 限条数、`maxChars` 截长串 |
|
|
191
|
-
| 看它实际改了什么 | `get_worker_diff` | `maxChars` 封顶,文件清单永远全 |
|
|
192
|
-
| 问它为什么 | `ask_codex_worker` | 一段回答,fork 带着它的全部上下文 |
|
|
163
|
+
| `check_for_update` | `force` | 问 registry 有没有新版本 |
|
|
164
|
+
| `cancel_codex_worker` | `task_id` | 终止 worker。跨进程按 pid 兜底,先确认那个 pid 跑的是 codex |
|
|
193
165
|
|
|
194
|
-
|
|
166
|
+
必填的两个:`ownedPaths`(派单前和在跑的 worker 求交集,重叠就拒,只在派单时查)和 `goal.objective`(worker 会建成 Codex 原生 goal)。`session_id` 不传就归不了组,一批活传同一个值。
|
|
195
167
|
|
|
196
168
|
## 和 Claude Code 的 subagent 有什么区别
|
|
197
169
|
|
|
198
|
-
文件隔离不是差别:subagent 自己也能开 worktree
|
|
170
|
+
文件隔离不是差别:subagent 自己也能开 worktree。差别在模型和进程。
|
|
199
171
|
|
|
200
172
|
| | Claude Code subagent | codex-supervisor worker |
|
|
201
173
|
|---|---|---|
|
|
@@ -208,24 +180,16 @@ land_codex_worker 核过了,落进集成分支
|
|
|
208
180
|
|
|
209
181
|
## 状态机
|
|
210
182
|
|
|
211
|
-
`status`
|
|
212
|
-
|
|
213
|
-
| 值 | 含义 |
|
|
183
|
+
| `status` | 含义 |
|
|
214
184
|
|---|---|
|
|
215
185
|
| `queued` | 已派单,未启动 |
|
|
216
|
-
| `running` |
|
|
186
|
+
| `running` | 运行中。`phase`:`starting → thinking → command → editing → reporting` |
|
|
217
187
|
| `completed` | 成功 |
|
|
218
188
|
| `failed` | 非零退出码、`turn.failed`、spawn 失败 |
|
|
219
189
|
| `cancelled` | 被 `cancel_codex_worker` 中断 |
|
|
220
|
-
| `lost` | 被外部信号杀掉、MCP
|
|
221
|
-
|
|
222
|
-
`phase` 只在 `running` 时有值:`starting → thinking → command → editing → reporting`。
|
|
223
|
-
|
|
224
|
-
`failed` 要看日志,`lost` 直接重跑。终态分两步落盘:`turn.completed` 先把 status 置成 completed,进程退出后才写 `exit_code`;`wait_codex_workers` 等到 `exit_code` 落了才返回,直接读 status 撞上 `completed` 配 `exit_code: null` 就过一会再读。
|
|
225
|
-
|
|
226
|
-
Windows 没有信号,外部 kill 和进程自己 `exit(1)` 在父进程看来一样,所以那里只报 `failed` 加退出码。
|
|
190
|
+
| `lost` | 被外部信号杀掉、MCP 进程消失、或者行写了但进程从没起来。`resume_codex_worker` 接回 |
|
|
227
191
|
|
|
228
|
-
Codex 原生 goal
|
|
192
|
+
终态分两步落盘:`turn.completed` 先把 status 置成 completed,进程退出后才写 `exit_code`;`wait_codex_workers` 等到 `exit_code` 落了才返回。Windows 没有信号,外部 kill 只报 `failed` 加退出码。Codex 原生 goal 的 `paused` / `blocked` 算 `running` 并进 `needs_attention`,`usageLimited` / `budgetLimited` 算 `failed`。
|
|
229
193
|
|
|
230
194
|
## 状态存储
|
|
231
195
|
|
|
@@ -233,42 +197,31 @@ Codex 原生 goal 的六个状态映射:`active` / `paused` / `blocked` 都算
|
|
|
233
197
|
|
|
234
198
|
| 文件 | 内容 |
|
|
235
199
|
|---|---|
|
|
236
|
-
| `data/supervisor.sqlite` | `tasks`(一行一个 work)、`task_events
|
|
200
|
+
| `data/supervisor.sqlite` | `tasks`(一行一个 work)、`task_events`、`sessions`、`side_sessions` / `side_turns`(旁问) |
|
|
237
201
|
| `data/runs/<taskId>.jsonl` | Codex `--json` 的原始输出 |
|
|
238
|
-
| `data/update-check.json` |
|
|
202
|
+
| `data/update-check.json`、`auto-update.json` | 更新检查和后台更新的记录 |
|
|
239
203
|
| `worktrees/<taskId>/` | 该 worker 的 Git worktree |
|
|
240
204
|
|
|
241
|
-
`changed_files`
|
|
242
|
-
|
|
243
|
-
老版本(0.1.x)的库第一次打开时自动迁移,一行不丢。
|
|
244
|
-
|
|
245
|
-
## 更新检查
|
|
246
|
-
|
|
247
|
-
MCP 启动时问一次 npm registry:`latest` 是哪个版本,tarball integrity 是多少。和本机比两样:
|
|
248
|
-
|
|
249
|
-
- 版本号。比 `latest` 低,`get_orchestration_overview`、派单回执、`wait_codex_workers` 的返回里多一个 `update` 字段,带 `latest_version` 和 `npm i -g codex-supervisor-mcp@latest`。skill 让主线程看到就转告你。
|
|
250
|
-
- 文件。全局安装时 npm 把解出来的 integrity 记在 `node_modules/.package-lock.json`,和 registry 上这个版本的不一样就说明本机文件不是发布的那份,同样提示重装。git checkout 没这个值,只记 commit。
|
|
251
|
-
|
|
252
|
-
缓存一小时,跑着的时候每六小时再查。registry 连不上不报错,结果标 `source: "offline"`。看板左下角显示同一个结果。`CODEX_SUPERVISOR_NO_UPDATE_CHECK=1` 关掉,`CODEX_SUPERVISOR_REGISTRY` 指到私有源。
|
|
205
|
+
`changed_files` 按 worktree 的真实 diff 算(`git status` 加 `git diff <base_commit> HEAD`),worker 用 shell 改文件、自己 commit 过都能看到。git 读操作都带 `core.quotePath=false`,中文文件名不会变成八进制转义。老版本的库第一次打开时自动迁移。
|
|
253
206
|
|
|
254
207
|
## 环境变量
|
|
255
208
|
|
|
256
209
|
| 变量 | 默认 | 作用 |
|
|
257
210
|
|---|---|---|
|
|
258
211
|
| `SUPERVISOR_HOME` | `~/.codex-supervisor` | 状态根目录。MCP 和看板要指同一个 |
|
|
259
|
-
| `CODEX_HOME` | `~/.codex` | 只读,读 Codex 原生的 `goals_1.sqlite` |
|
|
260
|
-
| `CODEX_BIN` | `codex` | Codex CLI 路径。Windows 上 `.cmd` shim
|
|
212
|
+
| `CODEX_HOME` | `~/.codex` | 只读,读 Codex 原生的 `goals_1.sqlite` 和 MCP 配置 |
|
|
213
|
+
| `CODEX_BIN` | `codex` | Codex CLI 路径。Windows 上 `.cmd` shim 自动绕开 |
|
|
261
214
|
| `GIT_BIN` | `git` | Git 路径 |
|
|
262
215
|
| `SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` | `7877` / `127.0.0.1` | 看板监听地址 |
|
|
263
216
|
| `CODEX_SUPERVISOR_NO_UPDATE_CHECK` | 未设 | `1` 关闭更新检查 |
|
|
264
|
-
| `CODEX_SUPERVISOR_REGISTRY` | `https://registry.npmjs.org` |
|
|
217
|
+
| `CODEX_SUPERVISOR_REGISTRY` | `https://registry.npmjs.org` | 更新检查和自动更新用的 registry |
|
|
265
218
|
| `CODEX_SUPERVISOR_UPDATE_TIMEOUT_MS` | `4000` | 等 registry 的上限 |
|
|
266
|
-
| `CODEX_SUPERVISOR_SKIP_SETUP` | 未设 | `1` 跳过 `postinstall` 的自动安装 |
|
|
267
219
|
| `CODEX_SUPERVISOR_NO_AUTO_UPDATE` | 未设 | `1` 关闭后台自动更新(只提醒) |
|
|
268
220
|
| `CODEX_SUPERVISOR_SKIP_SKILL_SYNC` | 未设 | `1` 关闭 server 启动时的 skill 同步 |
|
|
269
|
-
| `
|
|
221
|
+
| `CODEX_SUPERVISOR_SKIP_SETUP` | 未设 | `1` 跳过 `postinstall` 的自动安装 |
|
|
222
|
+
| `CODEX_SUPERVISOR_NPM` | 未设 | 自动更新用的 npm,默认用当前 node 自带的 |
|
|
270
223
|
|
|
271
|
-
GUI
|
|
224
|
+
GUI 客户端(Claude Desktop、Cursor、Windsurf)不跑 `postinstall`,自己把这段加进它的 MCP 配置文件,`PATH` 里常常没有 `codex`,显式给 `CODEX_BIN`:
|
|
272
225
|
|
|
273
226
|
```json
|
|
274
227
|
{
|
|
@@ -282,67 +235,30 @@ GUI 客户端起的进程 `PATH` 里常常没有 `codex`,在配置里显式给
|
|
|
282
235
|
}
|
|
283
236
|
```
|
|
284
237
|
|
|
285
|
-
##
|
|
286
|
-
|
|
287
|
-
### GUI 客户端
|
|
288
|
-
|
|
289
|
-
GUI 不跑 `postinstall`,自己把上面那段 JSON 加进配置文件:
|
|
290
|
-
|
|
291
|
-
| 客户端 | macOS | Windows | Linux |
|
|
292
|
-
|---|---|---|---|
|
|
293
|
-
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | `%APPDATA%\Claude\claude_desktop_config.json` | `~/.config/Claude/claude_desktop_config.json` |
|
|
294
|
-
| Cursor | `~/.cursor/mcp.json` | `%APPDATA%\Cursor\mcp.json` | `~/.config/cursor/mcp.json` |
|
|
295
|
-
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | `%APPDATA%\Codeium\windsurf\mcp_config.json` | `~/.config/.codeium/windsurf/mcp_config.json` |
|
|
296
|
-
|
|
297
|
-
### 重跑安装
|
|
298
|
-
|
|
299
|
-
```bash
|
|
300
|
-
codex-supervisor-setup # 自动检测客户端,补 skill + 注册 MCP
|
|
301
|
-
codex-supervisor-setup --target claude,codex
|
|
302
|
-
codex-supervisor-setup --skill-only
|
|
303
|
-
codex-supervisor-setup --mcp-only
|
|
304
|
-
codex-supervisor-setup --dry-run # 只打印计划
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
skill 已存在且内容不同时先备份成 `SKILL.md.bak-<时间戳>` 再覆盖。
|
|
238
|
+
## 更新
|
|
308
239
|
|
|
309
|
-
|
|
240
|
+
不用手动更。server 启动时在后台问一次 registry(之后每 6 小时一次),有新版就起一个独立进程 `npm i -g` 到同一个全局路径。正在跑的会话不受影响,下一个新会话就是新版。过程记在 `data/auto-update.json`,工具返回的 `update.auto_update` 里也能看到。只对 `npm i -g` 装的那份生效,git 源码、`npm link`、`npx` 起的都不碰;同一个版本只试一次。
|
|
310
241
|
|
|
311
|
-
|
|
242
|
+
skill 同样不用管:server 每次启动把自带的 skill 刷到已存在的那几个 skill 目录,内容不同先备份成 `SKILL.md.bak-<时间戳>`。已经加载了 skill 的会话要重新加载才看到新文本。
|
|
312
243
|
|
|
313
|
-
|
|
244
|
+
全局目录要 sudo 才能写的机器会装失败,`update` 字段里带原因,这时手动 `npm install -g codex-supervisor-mcp@latest`。0.6.1 及以前只提醒不自己装,手动升一次就进自动了。换了 Node 版本,注册的绝对路径失效,先 `claude mcp remove -s user codex-supervisor` 和 `codex mcp remove codex-supervisor` 再装。重跑安装:`codex-supervisor-setup`(`--skill-only` / `--mcp-only` / `--dry-run`)。
|
|
314
245
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
```bash
|
|
318
|
-
npm install -g codex-supervisor-mcp@latest
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
0.6.1 及以前的版本只提醒、不自己装。从那些版本上来,手动升一次,之后就自动了。注册不用重做。
|
|
322
|
-
|
|
323
|
-
手动更的坑:
|
|
324
|
-
|
|
325
|
-
- 刚发布的版本 registry 要几分钟才切 `latest`,装完版本没变就等一会,或者写死版本号。
|
|
326
|
-
- 换了 Node 版本,注册的绝对路径就失效了。先 `claude mcp remove -s user codex-supervisor` 和 `codex mcp remove codex-supervisor`,再装。
|
|
327
|
-
- skill 不用单独管:server 每次启动会把自带的 skill 刷到 `~/.claude/skills/`、`~/.agents/skills/`、`~/.codex/skills/` 里已经存在的那几个目录,内容不同先备份成 `SKILL.md.bak-<时间戳>`。已经加载了 skill 的会话要重新加载才看到新文本。`CODEX_SUPERVISOR_SKIP_SKILL_SYNC=1` 关掉。
|
|
328
|
-
|
|
329
|
-
### 卸载
|
|
246
|
+
卸载:
|
|
330
247
|
|
|
331
248
|
```bash
|
|
332
249
|
npm uninstall -g codex-supervisor-mcp
|
|
333
250
|
claude mcp remove -s user codex-supervisor
|
|
334
251
|
codex mcp remove codex-supervisor
|
|
335
|
-
rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.codex/skills/codex-supervisor
|
|
336
|
-
rm -rf ~/.codex-supervisor
|
|
252
|
+
rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.codex/skills/codex-supervisor ~/.codex-supervisor
|
|
337
253
|
```
|
|
338
254
|
|
|
339
|
-
|
|
255
|
+
## Windows
|
|
340
256
|
|
|
341
|
-
- npm 装的 CLI 是 `codex.cmd`,Node
|
|
342
|
-
- 跨进程取消用 `taskkill /PID <pid> /T /F`
|
|
257
|
+
- npm 装的 CLI 是 `codex.cmd`,Node 拒绝直接 spawn 它。这里绕到 `node_modules/@openai/codex/bin/codex.js` 用 `node` 起,不用 `shell: true`,那样取消时只杀得掉 shell。
|
|
258
|
+
- 跨进程取消用 `taskkill /PID <pid> /T /F` 杀整棵树,先确认那个 pid 跑的是 codex。
|
|
343
259
|
- 除 `PATH` 外还探 `%APPDATA%\npm`、`%LOCALAPPDATA%\pnpm`、`%LOCALAPPDATA%\Volta\bin`、`%ProgramFiles%\nodejs`。
|
|
344
260
|
|
|
345
|
-
|
|
261
|
+
## 排查
|
|
346
262
|
|
|
347
263
|
| 症状 | 原因 | 处理 |
|
|
348
264
|
|---|---|---|
|
|
@@ -350,56 +266,43 @@ rm -rf ~/.codex-supervisor
|
|
|
350
266
|
| 派单报 `codex only resolved to a shell shim` | Windows 只找到 `.cmd`,背后的包入口没了 | 重装 `@openai/codex`,或 `CODEX_BIN` 指到 `codex.js` |
|
|
351
267
|
| worker 一起来就 `failed`,`spawn codex ENOENT` | 进程 `PATH` 里没有 codex | 配置里设 `CODEX_BIN` |
|
|
352
268
|
| `Cannot find module 'node:sqlite'` | Node 低于 22.13.0 | 升 Node |
|
|
353
|
-
| worker
|
|
269
|
+
| worker `lost` | MCP 进程被杀,worker 跟着没了 | `resume_codex_worker` 接回 |
|
|
270
|
+
| worker 说 `git add` 报 `index.lock: Operation not permitted` | 默认沙箱把 `.git` 设成只读 | 收活时 `land_codex_worker` 带 `commitMessage`,或派单用 `danger-full-access` |
|
|
354
271
|
| `ownedPaths overlap with active worker(s)` | 两路认领了同一片路径 | 改拆法,或先取消占着的那路 |
|
|
355
|
-
| 看板打开是空的 | 看板和 MCP 的 `SUPERVISOR_HOME` 不是同一个 | 在配了 `.mcp.json`
|
|
356
|
-
| `port 7877 ... is already in use` | 已经有一个看板在跑 |
|
|
272
|
+
| 看板打开是空的 | 看板和 MCP 的 `SUPERVISOR_HOME` 不是同一个 | 在配了 `.mcp.json` 的项目目录里起,或显式传同一个 `SUPERVISOR_HOME` |
|
|
273
|
+
| `port 7877 ... is already in use` | 已经有一个看板在跑 | 直接开它,或 `SUPERVISOR_WEB_PORT=8080` 再起一个 |
|
|
357
274
|
|
|
358
275
|
## 已知限制
|
|
359
276
|
|
|
360
|
-
- worker 是 MCP 进程的子进程。MCP 被 kill,worker
|
|
361
|
-
-
|
|
362
|
-
- worktree 从一个提交切,你工作区里没 commit
|
|
363
|
-
-
|
|
364
|
-
- `ownedPaths` 只在派单时查,拦不住 worker
|
|
365
|
-
-
|
|
366
|
-
- 一次 `wait_codex_workers`
|
|
367
|
-
-
|
|
368
|
-
- `search_works` 是子串匹配,几百条够用,几万条再说。
|
|
277
|
+
- worker 是 MCP 进程的子进程。MCP 被 kill,worker 跟着没了,结算成 `lost`;worktree 和 `thread_id` 都在,`resume_codex_worker` 接回。让它不跟着死要常驻 daemon,在 Roadmap 里。
|
|
278
|
+
- 默认 `workspace-write` 沙箱里 worker 提交不了(Codex 把 `.git` 设成只读)。要么收活时 `land_codex_worker` 带 `commitMessage` 替它提交,要么派单用 `danger-full-access`。
|
|
279
|
+
- worktree 从一个提交切,你工作区里没 commit 的东西不在里面。
|
|
280
|
+
- 只隔离工作目录。临时目录、数据库、端口是共用的。
|
|
281
|
+
- `ownedPaths` 只在派单时查,拦不住 worker 新建清单外的文件。收活看 diff。
|
|
282
|
+
- 只管「跑完了」不管「对不对」,验收得主线程自己做。
|
|
283
|
+
- 一次 `wait_codex_workers` 等不到底,客户端的 MCP 工具超时是硬墙,靠反复调。
|
|
284
|
+
- `search_works` 是子串匹配,几百条够用。
|
|
369
285
|
|
|
370
286
|
## Roadmap
|
|
371
287
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
6. ~~`session_id` + `get_session_works`~~ ✅
|
|
378
|
-
7. ~~`search_works`~~ ✅
|
|
379
|
-
8. ~~worker 原生 goal~~ ✅
|
|
380
|
-
9. ~~Windows~~ ✅
|
|
381
|
-
10. ~~网页看板~~ ✅
|
|
382
|
-
11. ~~session 标题、更新检查、`baseRef`、已 commit 的改动可见~~ ✅
|
|
383
|
-
12. ~~收活三件套:`get_worker_diff` / `ask_codex_worker` / `land_codex_worker`;后台自动更新~~ ✅
|
|
384
|
-
13. 常驻 daemon:派单和进程生命周期从 MCP 进程里拿出来
|
|
385
|
-
|
|
386
|
-
不做的:向量检索(子串匹配在这个规模更快、零维护)、`usage_count` 排序(实测 80 个 work 里只有 2 个被回头引用过)、三层记忆索引(数据量撑不起)。
|
|
288
|
+
做完的:`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
|
+
|
|
290
|
+
下一个:常驻 daemon,派单和进程生命周期从 MCP 进程里拿出来。
|
|
291
|
+
|
|
292
|
+
不做的:向量检索(子串匹配在这个规模更快、零维护)、`usage_count` 排序(实测 80 个 work 里只有 2 个被回头引用过)。
|
|
387
293
|
|
|
388
294
|
## 开发
|
|
389
295
|
|
|
390
296
|
```bash
|
|
391
297
|
npm install
|
|
392
|
-
npm test #
|
|
393
|
-
npm run test:edge # 只跑 test/edge
|
|
298
|
+
npm test # fake-codex 回放,快且确定
|
|
299
|
+
npm run test:edge # 只跑 test/edge
|
|
394
300
|
npm run test:real # 真 codex CLI 端到端
|
|
395
|
-
npm run smoke:mcp # MCP 协议冒烟
|
|
396
|
-
npm run monitor # Ink 终端看板
|
|
397
|
-
npm run web:install # 看板依赖
|
|
398
301
|
npm run web:dev # 看板开发,/api 代理到 7877
|
|
399
302
|
npm run web:build # 打包到 web/dist,发 npm 前自动跑
|
|
400
303
|
```
|
|
401
304
|
|
|
402
|
-
|
|
305
|
+
CI 跑 Ubuntu / macOS / Windows,另加一个 Node 22.13.0 的 job 卡 `engines` 下界。
|
|
403
306
|
|
|
404
307
|
## License
|
|
405
308
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-supervisor-mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP server that dispatches and supervises parallel Codex CLI workers, one isolated Git worktree each, with a persisted work state machine.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,157 +9,79 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
|
|
|
9
9
|
|
|
10
10
|
## 什么时候用
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
- 活偏大,不想让它占自己的上下文
|
|
14
|
-
- 跑到一半可能断,需要能接回来
|
|
12
|
+
一批能拆开的活、活偏大不想占自己的上下文、跑到一半可能断要能接回来。一个文件的小改、纯问答、要来回确认的活,自己干更快。
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
## 派单
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
3. `create_codex_worker` 派出去。返回的是一张精简回执(`id`、`worktree_path`、`branch`、`owned_paths`、`status`),任务原文不回传,派十一路也不会把你的提示词抄十一遍。
|
|
23
|
-
4. 派完就 `wait_codex_workers` 等。默认只等 2 分钟,到点返回进度快照,worker 照跑;拿同一批 `task_ids` 接着调,直到 `timed_out: false`。默认**不带**事件(`includeEvents: false`),返回只够看状态,要事件得自己开。
|
|
24
|
-
5. 收结果走 `get_worker_result`,拿完整汇报,别一上来读事件流。
|
|
25
|
-
|
|
26
|
-
`ownedPaths` 和 `goal` 必填,不是可选项。
|
|
27
|
-
|
|
28
|
-
`wait_codex_workers` 的等待预算管的是这一次调用,不是 worker。返回里 `still_running: true` 是等满了,不是活挂了,按 `next_step` 接着调就行。别把 `timeoutMinutes` 开到超过客户端的 MCP 工具超时——那样被掐掉的是这次调用,丢的是这次的结果。
|
|
29
|
-
|
|
30
|
-
## 长任务怎么等
|
|
31
|
-
|
|
32
|
-
一路活要跑二十分钟、一小时,正确的等法只有一种:**反复调 `wait_codex_workers`**,每次默认 2 分钟,回来看一眼 `still_running`,没完就再调。只想知道完没完,带 `compact: true`,每路一行。中间想省一点上下文就改调 `get_orchestration_overview`。
|
|
33
|
-
|
|
34
|
-
**不要自己写 shell 循环去 `grep` / `tail` `data/runs/<taskId>.jsonl`**,哪怕看起来更省事。原因:
|
|
35
|
-
|
|
36
|
-
- 那个文件只是 Codex 的原始输出。进程被杀、`failed`、`lost`、`exit_code` 这些只有状态机知道,文件里没有。你的循环会在一个已经死掉的 worker 上一直 `sleep`。
|
|
37
|
-
- `turn.completed` 出现不等于活完成:进程退出后 `exit_code` 才落,`wait` 等的是这个;resume 过的 worker 文件里有多条 `turn.completed`,按条数判断会误判。
|
|
38
|
-
- 用户在终端里看到的是一行 `until grep ... sleep 15` 的黑盒,不知道你在等什么、等了多久;`wait` 的返回有每路的状态和进度。
|
|
39
|
-
|
|
40
|
-
要盯某一路的具体动作,用 `get_codex_worker_status`(`current_action` 是它正在跑的命令);要看它说了什么,用 `get_worker_result`。
|
|
16
|
+
1. 先 `search_works` 搜一下,别重复派。
|
|
17
|
+
2. 拆活。每路写清楚:干什么、能写哪些文件、怎么算做完。改同一批文件就串行,文件完全不重叠才并行。
|
|
18
|
+
3. `create_codex_worker` 派出去。回执只有 `id`、`worktree_path`、`branch`、`owned_paths`、`status`,不回传任务原文。
|
|
19
|
+
4. `wait_codex_workers` 等。默认 2 分钟,到点返回快照,worker 照跑;拿同一批 `task_ids` 接着调到 `timed_out: false`。只想知道完没完带 `compact: true`。
|
|
41
20
|
|
|
42
21
|
| 参数 | 怎么填 |
|
|
43
22
|
|---|---|
|
|
44
|
-
| `task` |
|
|
45
|
-
| `cwd` | 项目根目录。worker
|
|
46
|
-
| `ownedPaths` |
|
|
47
|
-
| `goal.objective` |
|
|
48
|
-
| `session_id` |
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
## 看到 `update` 字段就转告用户
|
|
61
|
-
|
|
62
|
-
`get_orchestration_overview`、派单回执、`wait_codex_workers` 的返回里出现 `update` 且 `update_available: true`(或 `integrity_matches: false`)时,当轮回复里告诉用户一句,内容照 `notice` 说。`auto_update.state` 是 `started`、`running` 或 `done` 时,新版已经在后台装或装好了,用户只需要重开会话;`install_command` 有值才让用户自己跑它再重启 Claude Code / Codex。只说一次,不要每轮重复。用户让你查时调 `check_for_update`。
|
|
63
|
-
|
|
64
|
-
## 读结果别把上下文撑爆
|
|
65
|
-
|
|
66
|
-
按这个顺序读,能不动后面就别动:
|
|
67
|
-
|
|
68
|
-
| 想干什么 | 用哪个 | 代价 |
|
|
69
|
-
|---|---|---|
|
|
70
|
-
| 看全部 worker 现在什么状态 | `get_orchestration_overview` | ~1750 token,封顶 |
|
|
71
|
-
| 收一路活的完整结论 | `get_worker_result` | 汇报全文,大活可能上万字 |
|
|
72
|
-
| 只想知道活着还是完了 | `get_worker_summary` | 一段话 |
|
|
73
|
-
| 看某个 worker 干了什么 | `get_codex_worker_events` | 用 `limit` / `kinds` / `maxChars` 压 |
|
|
74
|
-
| 看某个 worker 的状态 | `get_codex_worker_status` | 比 overview 一行细,命令和 prompt 都裁过 |
|
|
75
|
-
| 看 goal 和 token 消耗 | `get_worker_goal` | 很小 |
|
|
76
|
-
|
|
77
|
-
**收结论必须走 `get_worker_result`。** `wait_codex_workers` 返回里的 `last_message` 会被截到 400 字只留开头,`get_orchestration_overview` 干脆不给这一列。拿截断版当结论,后面的证据、数字和结论全会漏掉。`get_worker_result` 还会带回 `status`、`exit_code`、`changed_files`,顺便就能判断是真跑完还是崩了。
|
|
78
|
-
|
|
79
|
-
**默认读回来的长文本都是裁过的**,别把裁剪当成"活没干":`current_action` 截 300 字(一条 heredoc 命令能写一整个文件,原样回传一次就是几万字)、`get_codex_worker_status` 的 `prompt` 截 300 字(要全文传 `includePrompt: true`)、`last_message` 在 overview 和 wait 里截 400 字、在 status 里截 4000 字。全量在库里:命令流看 `get_codex_worker_events`,结论看 `get_worker_result`。
|
|
80
|
-
|
|
81
|
-
`get_codex_worker_events` 的三个闸门:`kinds` 先过滤再取 `limit`;`maxChars` 把超长字符串中间截断;不知道有哪些 `kinds` 时先看返回里的 `available_kinds`。
|
|
82
|
-
|
|
83
|
-
**别做**:一次 `limit: 200` 拉全量事件。那是几万 token。
|
|
23
|
+
| `task` | 这一路具体干什么。要能直接开工,别写"优化一下" |
|
|
24
|
+
| `cwd` | 项目根目录。worker 在自己的 worktree 里干活,不动你的工作区 |
|
|
25
|
+
| `ownedPaths` | 必填。这路允许写的路径,和在跑的 worker 重叠会被拒。冲突是好事,说明该改拆法 |
|
|
26
|
+
| `goal.objective` | 必填。一句话说目标,worker 会建成 Codex 原生 goal |
|
|
27
|
+
| `session_id` | 同一批传同一个值。第一路顺手带 `session_title`(30 字内,看板和 `get_session_works` 显示它),漏了用 `describe_session` 补 |
|
|
28
|
+
| `dependsOn` | 有先后依赖填上游的 `task_id` |
|
|
29
|
+
| `baseRef` | worktree 从哪个提交切,默认 `HEAD`。第 N+1 步要建立在第 N 步上,填 `codex/<第 N 步 task_id>` |
|
|
30
|
+
| `sandbox` | 默认 `workspace-write`,worker 提交不了(Codex 把 `.git` 设成只读)。要它自己提交就 `danger-full-access`,否则收活时让 supervisor 替它提交 |
|
|
31
|
+
|
|
32
|
+
等待的几条规矩:
|
|
33
|
+
|
|
34
|
+
- 等待预算管这次调用,不管 worker。`still_running: true` 是等满了不是挂了,按 `next_step` 再调。
|
|
35
|
+
- `timeoutMinutes` 别超过客户端的 MCP 工具超时,否则被掐的是这次调用。
|
|
36
|
+
- **不要自己写 shell 循环 grep `data/runs/*.jsonl`**。进程被杀、`failed`、`lost`、`exit_code` 只有状态机知道,文件里没有;resume 过的 worker 文件里有多条 `turn.completed`;用户在终端里看到的是一行黑盒。
|
|
37
|
+
- 想省上下文改调 `get_orchestration_overview`,封顶 7000 字节。
|
|
84
38
|
|
|
85
39
|
## 收活:先看证据,再问,再改,再落
|
|
86
40
|
|
|
87
|
-
|
|
41
|
+
1. `get_worker_result`:它说自己做了什么。`wait` 和 overview 里的 `last_message` 是截过的,结论必须走这里。
|
|
42
|
+
2. `get_worker_diff`:它实际做了什么。起点到工作区的全部改动,提交没提交都算;`maxChars` 管总量,`paths` 缩范围。它说过了不算,diff 对得上才算。
|
|
43
|
+
3. 对不上、看不懂为什么:`ask_codex_worker` 带 `question` 问它。fork 出一个只读旁路,worker 自己的线程不动;fork 没网络没 MCP 工具,问"改了什么、为什么、在哪",别问要联网才能答的事。超时回 `running`,只带 `task_id` 再调拿答案。worker 被 resume 过后下一问自动换新 fork,`fresh: true` 强制换,问完 `end: true` 删。
|
|
44
|
+
4. 要它改:`resume_codex_worker`,写清问题在哪,让它改完 `git commit --amend --no-edit` 并进原来那个提交。旁路只读,改东西永远走 resume。
|
|
45
|
+
5. 过了:`land_codex_worker` 把 `codex/<id>` 上的提交 cherry-pick 到派单目录当前分支。目标脏了、分支不对、冲突都拒绝并原样退回。worker 没提交(默认沙箱提交不了)就带 `commitMessage`,supervisor 在它分支上替它提交一笔再落。
|
|
88
46
|
|
|
89
|
-
|
|
90
|
-
2. `get_worker_diff`:它实际做了什么。从 worktree 起点到工作区的全部改动,提交没提交都算,按文件给 patch;`maxChars` 管总量,`paths` 缩范围。它说过了不算,diff 对得上才算。
|
|
91
|
-
3. 对不上、看不懂为什么这么改:`ask_codex_worker` 带 `question` 问它。走的是 fork 出来的只读旁路,worker 自己的线程不动;fork 带着它的全部上下文,一句话能答。fork 没网络、没 MCP 工具,它自己知道,所以别问它"远端跑通了没"这类要联网才能答的事,问"你改了什么、为什么、在哪"。超过 `timeoutMs` 回 `running`,之后只带 `task_id` 再调一次拿答案。worker 被 `resume` 过以后,下一问自动换一个新 fork(返回 `refreshed: "worker_resumed"`);想强制换就 `fresh: true`。问完 `end: true` 删 fork。
|
|
92
|
-
4. 要它改:`resume_codex_worker`,提示词里写清问题在哪,让它改完 `git commit --amend --no-edit` 并进原来那个提交,保持一步一个提交。旁路只读,改东西永远走 resume。
|
|
93
|
-
5. 过了:`land_codex_worker` 把 `codex/<id>` 上的提交 cherry-pick 到派单目录的当前分支。目标脏了、分支不对、冲突,都会拒绝并原样退回,不留半截。
|
|
47
|
+
一批活全部到终态后:`get_orchestration_overview` 确认没有 `needs_attention`,再逐路走上面五步。合不合、怎么合由主线程定。
|
|
94
48
|
|
|
95
|
-
|
|
96
|
-
- 让它只改文件不提交,收活时 `land_codex_worker` 带 `commitMessage`,由 supervisor 在它的分支上替它提交一笔再落。一步一个提交照样成立。
|
|
97
|
-
- 要它自己提交(比如要 `--amend`),派单 `sandbox: "danger-full-access"`。
|
|
98
|
-
|
|
99
|
-
串行做活(第 N+1 步建立在第 N 步上)两种走法:落完第 N 步再派第 N+1 步;或者第 N+1 步派单时 `baseRef: "codex/<第 N 步的 task_id>"`,直接从它的分支开,最后只落最后一路。
|
|
100
|
-
|
|
101
|
-
## 中断了怎么接
|
|
102
|
-
|
|
103
|
-
先分清是哪种断:
|
|
104
|
-
|
|
105
|
-
| 情况 | 用什么 | 效果 |
|
|
106
|
-
|---|---|---|
|
|
107
|
-
| 想接着**同一个** Codex 会话干 | `resume_codex_worker` | 上下文不丢,`thread_id` 不变 |
|
|
108
|
-
| 想开**新会话**,带着老活的摘要干 | `create_codex_followup_worker` | 新线程,靠文本重述 |
|
|
109
|
-
| 主线程自己挂了,要找回那批活 | `get_session_works` | 按 `session_id` 列全部 |
|
|
110
|
-
| worker 变 `lost`(MCP 进程没了把它带走了) | `resume_codex_worker` | 同一线程接着干,worktree 里的改动都在 |
|
|
111
|
-
|
|
112
|
-
主线程重启后第一件事:`get_session_works({ session_id })`。一次拿到那批活的清单和状态,不用凭记忆猜。
|
|
113
|
-
|
|
114
|
-
`resume_codex_worker` 只有在原任务记了 `thread_id` 时能用。没记过就用 `create_codex_followup_worker`。
|
|
115
|
-
|
|
116
|
-
## 找以前的活
|
|
117
|
-
|
|
118
|
-
`search_works({ query })` 在 title、goal、prompt、last_message 里做子串匹配,从新到旧返回。
|
|
119
|
-
|
|
120
|
-
想按状态筛就用 `list_codex_workers({ status, includeHistory: true })`。
|
|
121
|
-
|
|
122
|
-
## 状态怎么读
|
|
123
|
-
|
|
124
|
-
`status` 是生命周期,一个 work 一个值:`queued` / `running` / `completed` / `failed` / `cancelled` / `lost`。
|
|
49
|
+
## 读结果别把上下文撑爆
|
|
125
50
|
|
|
126
|
-
|
|
51
|
+
| 想干什么 | 用哪个 |
|
|
52
|
+
|---|---|
|
|
53
|
+
| 全部 worker 的状态 | `get_orchestration_overview` |
|
|
54
|
+
| 一路的完整结论 | `get_worker_result` |
|
|
55
|
+
| 一路改了什么 | `get_worker_diff` |
|
|
56
|
+
| 活着还是完了 | `get_worker_summary` |
|
|
57
|
+
| 过程 | `get_codex_worker_events`,`kinds` 先滤、`limit` 限条数、`maxChars` 截长串,先看 `available_kinds` |
|
|
58
|
+
| 一路的状态细节 | `get_codex_worker_status`,`current_action` 是它正在跑的命令 |
|
|
127
59
|
|
|
128
|
-
|
|
60
|
+
默认读回来的长文本都是裁过的(`current_action` 300 字、`prompt` 300 字、`last_message` 400 字),别把裁剪当成活没干。全量在库里。别一次 `limit: 200` 拉全量事件。
|
|
129
61
|
|
|
130
|
-
|
|
131
|
-
- `lost`:进程被外部信号杀了,或者 MCP 进程自己没了(worker 是它的子进程)。worktree 里的改动都还在,`thread_id` 也在库里。**用 `resume_codex_worker` 接回同一个线程**,提示词里说"接着上次的做,先看工作区现状";它被杀时正在做的那一步可能要重做。只有没记到 `thread_id` 的老行才走 `create_codex_followup_worker` 重派。
|
|
62
|
+
## 断了怎么接
|
|
132
63
|
|
|
133
|
-
|
|
64
|
+
| 情况 | 用什么 |
|
|
65
|
+
|---|---|
|
|
66
|
+
| 主线程自己挂了 | 先 `get_session_works({ session_id })`,一次拿回那批活 |
|
|
67
|
+
| worker 变 `lost`(MCP 进程没了把它带走了,或被信号杀了) | `resume_codex_worker`。worktree 里的改动和 `thread_id` 都在,同一线程接着干;被杀时正在做的那一步可能要重做 |
|
|
68
|
+
| worker `failed` | 看 `error` 和日志,查完再 resume 或重派 |
|
|
69
|
+
| 没记到 `thread_id` 的老行 | `create_codex_followup_worker`,新线程靠文本重述 |
|
|
134
70
|
|
|
135
|
-
|
|
71
|
+
`status` 是生命周期:`queued` / `running` / `completed` / `failed` / `cancelled` / `lost`。`phase` 只在跑着时有值:`starting` → `thinking` → `command` → `editing` → `reporting`。`completed` 配 `exit_code: null` 是中间态,`wait` 会等到退出码落了再返回。goal 的 `paused` / `blocked` 不是结束,是等人管,overview 会列进 `needs_attention`。
|
|
136
72
|
|
|
137
|
-
|
|
73
|
+
## 看到 `update` 字段就转告用户
|
|
138
74
|
|
|
139
|
-
|
|
140
|
-
- Go 到 Codex 界面上能直接看到这个 goal
|
|
141
|
-
- `resume_codex_worker` **不会**再建 goal(有未完成 goal 时 `create_goal` 会失败)
|
|
75
|
+
overview、派单回执、`wait` 返回里出现 `update` 且 `update_available: true` 时,当轮回复里照 `notice` 告诉用户一句。`auto_update.state` 是 `started` / `running` / `done` 时新版已在后台装,重开会话即可;`install_command` 有值才让用户自己跑。只说一次。
|
|
142
76
|
|
|
143
77
|
## 常见坑
|
|
144
78
|
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
- **`ownedPaths` 是派单前的冲突检测,不是运行时的沙箱**。它只挡「两路活登记写同一个文件」,拦不住 worker 在自己 worktree 里新建清单外的文件——sandbox 是 `workspace-write`,写自己 worktree 里的任何路径都合法。收活时该看 diff 还得看:`get_worker_result` / `get_worker_summary` 里的 `changed_files` 已经包含 worker 在自己分支上 commit 过的文件(按 `base_commit` 和 `HEAD` 比),不用再去 worktree 里跑 `git show --stat`。
|
|
151
|
-
- **worktree 只隔离工作区,不隔离端口和数据库**。多路活要是都会连同一个 dev server 或同一个库,得自己错开。
|
|
152
|
-
- **`cancel_codex_worker` 跨进程靠 pid**。要求那个 pid 的命令行里带 `codex`,防止误杀复用 pid 的进程。
|
|
79
|
+
- worktree 从一个提交切,你工作区里没 commit 的东西 worker 看不到。要让它读到就给绝对路径或先 commit。
|
|
80
|
+
- 它只管"跑完了"不管"对不对",`exit_code: 0` 只说明没崩,验收自己做。
|
|
81
|
+
- `ownedPaths` 是派单前的冲突检测,不是运行时沙箱,拦不住 worker 新建清单外的文件。收活看 diff。
|
|
82
|
+
- worktree 只隔离工作区,端口和数据库是共用的。
|
|
83
|
+
- `resume_codex_worker` 不会再建 goal。`cancel_codex_worker` 跨进程靠 pid,要求那个 pid 的命令行里带 `codex`。
|
|
153
84
|
|
|
154
85
|
## 看板
|
|
155
86
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
## 收尾
|
|
159
|
-
|
|
160
|
-
一批活全部到终态后:
|
|
161
|
-
|
|
162
|
-
1. `get_orchestration_overview` 确认没有 `needs_attention`
|
|
163
|
-
2. 逐路 `get_worker_result` 拿完整汇报,对着验收标准核内容
|
|
164
|
-
3. 失败的区分 `failed`(查原因)和 `lost`(重跑)
|
|
165
|
-
4. 改动在各自 worktree 的 `codex/<taskId>` 分支上,合并由主线程决定
|
|
87
|
+
用户想用眼睛看就让他起 `codex-supervisor-web`(或 `npx -p codex-supervisor-mcp codex-supervisor-web`),开 `http://127.0.0.1:7877`。按 session 分组,每路有「旁问」tab,用户可以自己问 worker。
|
package/src/landing.js
CHANGED
|
@@ -12,12 +12,44 @@ import { parsePorcelainLine, resolveWorktreeBase, worktreeRef } from "./worktree
|
|
|
12
12
|
|
|
13
13
|
const defaultGitBin = process.env.GIT_BIN?.trim() || "git";
|
|
14
14
|
|
|
15
|
+
// A commit needs a committer. On a machine where git has no user.name or
|
|
16
|
+
// user.email (CI runners, a fresh box, a GUI-launched MCP with no HOME
|
|
17
|
+
// config), cherry-pick and commit both die with "empty ident name", so a
|
|
18
|
+
// stand-in identity is supplied through the environment for that one
|
|
19
|
+
// directory. An identity git already has is used untouched.
|
|
20
|
+
const FALLBACK_IDENTITY = { name: "codex-supervisor", email: "codex-supervisor@localhost" };
|
|
21
|
+
const identityCache = new Map();
|
|
22
|
+
function identityEnv(cwd) {
|
|
23
|
+
if (identityCache.has(cwd)) return identityCache.get(cwd);
|
|
24
|
+
let name = "";
|
|
25
|
+
let email = "";
|
|
26
|
+
try {
|
|
27
|
+
name = execFileSync(defaultGitBin, ["-C", cwd, "config", "user.name"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 10000 }).trim();
|
|
28
|
+
} catch {
|
|
29
|
+
// unset
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
email = execFileSync(defaultGitBin, ["-C", cwd, "config", "user.email"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 10000 }).trim();
|
|
33
|
+
} catch {
|
|
34
|
+
// unset
|
|
35
|
+
}
|
|
36
|
+
const env = {};
|
|
37
|
+
if (!name || !email) {
|
|
38
|
+
env.GIT_AUTHOR_NAME = name || FALLBACK_IDENTITY.name;
|
|
39
|
+
env.GIT_AUTHOR_EMAIL = email || FALLBACK_IDENTITY.email;
|
|
40
|
+
env.GIT_COMMITTER_NAME = name || FALLBACK_IDENTITY.name;
|
|
41
|
+
env.GIT_COMMITTER_EMAIL = email || FALLBACK_IDENTITY.email;
|
|
42
|
+
}
|
|
43
|
+
identityCache.set(cwd, env);
|
|
44
|
+
return env;
|
|
45
|
+
}
|
|
46
|
+
|
|
15
47
|
function git(cwd, args, { timeout = 60000 } = {}) {
|
|
16
48
|
return execFileSync(defaultGitBin, ["-C", cwd, "-c", "core.quotePath=false", ...args], {
|
|
17
49
|
encoding: "utf8",
|
|
18
50
|
timeout,
|
|
19
51
|
stdio: ["ignore", "pipe", "pipe"],
|
|
20
|
-
env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GIT_EDITOR: "true" }
|
|
52
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GIT_EDITOR: "true", ...identityEnv(cwd) }
|
|
21
53
|
});
|
|
22
54
|
}
|
|
23
55
|
|