codex-supervisor-mcp 0.9.5 → 0.9.7
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 +1 -0
- package/README.md +1 -0
- package/package.json +2 -1
- package/skills/codex-supervisor/SKILL.md +1 -0
- package/src/cleanup-hint.js +29 -0
- package/src/cleanup.js +12 -3
- package/src/mcp-server.js +5 -1
package/README.en.md
CHANGED
|
@@ -32,6 +32,7 @@ Point several agents at one repository and they overwrite each other, nobody can
|
|
|
32
32
|
| "Failed" and "process gone" look alike | The state machine keeps `failed` and `lost` apart |
|
|
33
33
|
| No view of where a batch is | `codex-supervisor-web`, a board that shows every worker by session |
|
|
34
34
|
| Work sits uncommitted or unpushed | Collecting a worker means `land_codex_worker` by default; the main thread commits and pushes its own edits; before deploying, check the remote SHA really contains the files |
|
|
35
|
+
| Worktrees and branches pile up | Clean up as you merge: `npm run cleanup -- --days 0 --dry-run` lists the candidates (merged and clean only), then `--apply`; `check_workers` returns a `cleanup` hint with both commands once the store passes the threshold |
|
|
35
36
|
|
|
36
37
|
Workers run `codex exec` with `model` passed through: the main thread stays on Claude, workers can run DeepSeek or any model Codex has a provider for, and the bills stay separate.
|
|
37
38
|
|
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
| worker 说做完了其实没有 | 派单给 `acceptance` 验收命令,worker 退出后 supervisor 在它的 worktree 里跑,失败 `land` 拒绝 |
|
|
33
33
|
| 看不见一批活现在到哪了 | `codex-supervisor-web` 开一个看板,按 session 看每路 worker 在干什么 |
|
|
34
34
|
| 改动留在本地没上线 | 收活默认 `land_codex_worker` 合回主分支;主线程自己的改动必须 commit + push;部署前用远端 SHA 核对文件真的在线上 |
|
|
35
|
+
| worktree / 分支越堆越多 | 合并即清理:`npm run cleanup -- --days 0 --dry-run` 看候选(只删已合并+干净的),确认后 `--apply`;`check_workers` 超过阈值会带回 `cleanup` 提示和命令 |
|
|
35
36
|
|
|
36
37
|
worker 跑的是 `codex exec`,`model` 透传:主线程留在 Claude,worker 可以挂 DeepSeek 或任何 Codex 配了 provider 的模型,账单分开算。
|
|
37
38
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-supervisor-mcp",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
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.",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"src/worker-report.js",
|
|
48
48
|
"src/worker-report.schema.json",
|
|
49
49
|
"src/sandbox-roots.js",
|
|
50
|
+
"src/cleanup-hint.js",
|
|
50
51
|
"src/handoff.js",
|
|
51
52
|
"src/external-output.js",
|
|
52
53
|
"src/truncate.js",
|
|
@@ -100,6 +100,7 @@ Codex需0.162+支持hooks/output-schema,能力不够派单start_failed先修CL
|
|
|
100
100
|
2. **主线程自己的改动必须 add + commit + push**:`git add <paths> && git commit -m ... && git push`。跳过任何一步都要显式说明,不允许说"改好了"然后留在工作区。
|
|
101
101
|
3. **上线前核对远端,不认本地**:部署或重启服务前先 `git fetch`,再确认目标提交里真有那些改动 —— `git log --oneline origin/<branch> -1`、`git ls-tree -r --name-only origin/<branch> | rg <新文件>`、必要时 `git show origin/<branch>:<path>`。线上报 `NoSuchBeanDefinition`、找不到类/模块、404,先查这一条,再查代码逻辑。
|
|
102
102
|
4. **交付报告三件套**:本地改动 → commit SHA → push 后的远端 SHA(以及部署状态)。缺远端 SHA 就不算完成。
|
|
103
|
+
5. **合并即清理**:`land_codex_worker` 落地后,那路 worker 的 worktree 和 `codex/<id>` 分支就没用了 —— 清掉,别攒着。先 `SUPERVISOR_HOME=<store> npm run cleanup -- --days 0 --dry-run` 看候选(默认 14 天窗口会把最近两周的全都漏掉,所以必须带 `--days 0`),确认只删「已合并 + 干净 + 无活跃依赖」的,再 `--apply`。脏、未合、lost、failed 一律保留,并在报告里写清还剩什么、为什么。`check_workers` 在 worktree 数超过阈值(默认 50,`SUPERVISOR_CLEANUP_HINT` 可调,0 关闭)时会带回 `cleanup` 字段和两条命令。
|
|
103
104
|
|
|
104
105
|
典型事故:两个实现类只存在于主线程的 worktree 里,没 add / 没 commit / 没 push,线上跑的还是上一个提交,Spring 找不到 bean 启动失败 —— 不是代码错,是没上线。
|
|
105
106
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import { supervisorRoot, worktreesDir } from "./paths.js";
|
|
3
|
+
|
|
4
|
+
const DEFAULT_THRESHOLD = 50;
|
|
5
|
+
|
|
6
|
+
export function cleanupThreshold(raw = process.env.SUPERVISOR_CLEANUP_HINT) {
|
|
7
|
+
if (raw === undefined || raw === "") return DEFAULT_THRESHOLD;
|
|
8
|
+
const value = Number(raw);
|
|
9
|
+
return Number.isFinite(value) && value >= 0 ? value : DEFAULT_THRESHOLD;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// A batch that never cleans up should say so instead of quietly growing to
|
|
13
|
+
// hundreds of worktrees. The hint only reports a count and the two commands;
|
|
14
|
+
// deletion stays a deliberate step, because cleanup only removes worktrees that
|
|
15
|
+
// are merged and clean and keeps dirty, unmerged, lost and failed work.
|
|
16
|
+
export async function cleanupHint({ list = readdir, root = supervisorRoot, dir = worktreesDir, threshold = cleanupThreshold() } = {}) {
|
|
17
|
+
if (!threshold) return null;
|
|
18
|
+
let entries;
|
|
19
|
+
try { entries = (await list(dir)).length; } catch { return null; }
|
|
20
|
+
if (entries < threshold) return null;
|
|
21
|
+
return {
|
|
22
|
+
worktrees: entries,
|
|
23
|
+
threshold,
|
|
24
|
+
command: `SUPERVISOR_HOME=${root} npm run cleanup -- --days 0 --dry-run`,
|
|
25
|
+
apply: `SUPERVISOR_HOME=${root} npm run cleanup -- --days 0 --apply`,
|
|
26
|
+
note: "merged and clean worktrees are removable; dirty, unmerged, lost and failed ones are kept on purpose"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
package/src/cleanup.js
CHANGED
|
@@ -11,6 +11,7 @@ function parseArgs(argv) {
|
|
|
11
11
|
days: 14,
|
|
12
12
|
dryRun: true,
|
|
13
13
|
includeFailed: true,
|
|
14
|
+
keepRecords: false,
|
|
14
15
|
vacuum: false
|
|
15
16
|
};
|
|
16
17
|
|
|
@@ -25,6 +26,10 @@ function parseArgs(argv) {
|
|
|
25
26
|
options.dryRun = true;
|
|
26
27
|
} else if (arg === "--keep-failed") {
|
|
27
28
|
options.includeFailed = false;
|
|
29
|
+
} else if (arg === "--keep-records") {
|
|
30
|
+
// Remove the directory and the branch, keep the task row and its run log:
|
|
31
|
+
// the work is merged, but the ledger of what ran stays.
|
|
32
|
+
options.keepRecords = true;
|
|
28
33
|
} else if (arg === "--vacuum") {
|
|
29
34
|
options.vacuum = true;
|
|
30
35
|
} else if (arg === "--help" || arg === "-h") {
|
|
@@ -48,6 +53,7 @@ Options:
|
|
|
48
53
|
--apply Actually delete matching rows, JSONL logs, and worktrees.
|
|
49
54
|
--days <n> Keep tasks newer than n days. Default: 14.
|
|
50
55
|
--keep-failed Preserve failed/cancelled tasks even when older than --days.
|
|
56
|
+
--keep-records Remove the worktree and branch but keep the task row and run log.
|
|
51
57
|
--vacuum Vacuum SQLite after deleting rows.
|
|
52
58
|
-h, --help Show help.
|
|
53
59
|
`);
|
|
@@ -152,11 +158,13 @@ for (const task of candidates) {
|
|
|
152
158
|
}
|
|
153
159
|
deleted.worktrees += 1;
|
|
154
160
|
const logPath = task.run_log ?? join(runsDir, `${task.id}.jsonl`);
|
|
155
|
-
if (
|
|
156
|
-
|
|
161
|
+
if (!options.keepRecords) {
|
|
162
|
+
if (await safeDeleteFile(logPath, options.dryRun)) deleted.jsonl += 1;
|
|
163
|
+
removedIds.push(task.id);
|
|
164
|
+
}
|
|
157
165
|
}
|
|
158
166
|
|
|
159
|
-
if (!options.dryRun &&
|
|
167
|
+
if (!options.dryRun && !options.keepRecords && removedIds.length > 0) {
|
|
160
168
|
await deleteTasks(removedIds);
|
|
161
169
|
}
|
|
162
170
|
deleted.tasks = removedIds.length;
|
|
@@ -168,6 +176,7 @@ if (!options.dryRun && options.vacuum) {
|
|
|
168
176
|
console.log(JSON.stringify({
|
|
169
177
|
dry_run: options.dryRun,
|
|
170
178
|
keep_days: options.days,
|
|
179
|
+
records_kept: options.keepRecords,
|
|
171
180
|
cutoff: new Date(cutoffMs).toISOString(),
|
|
172
181
|
candidates: taskIds,
|
|
173
182
|
skipped,
|
package/src/mcp-server.js
CHANGED
|
@@ -43,6 +43,7 @@ import { syncSkills } from "./skill-sync.js";
|
|
|
43
43
|
import { maybeAutoUpdate } from "./auto-update.js";
|
|
44
44
|
import { askWorker, endSideSession, latestSideTurn } from "./side-chat.js";
|
|
45
45
|
import { landWorker } from "./landing.js";
|
|
46
|
+
import { cleanupHint } from "./cleanup-hint.js";
|
|
46
47
|
|
|
47
48
|
// Report the real package version. This string had drifted to 0.4.0 while the
|
|
48
49
|
// package shipped 0.5.x, so the handshake named a version nobody was running.
|
|
@@ -538,7 +539,10 @@ server.registerTool("check_workers", {
|
|
|
538
539
|
const result = collectWorkerChanges(await readTasks(), await readObserverCursor(observerId));
|
|
539
540
|
await writeObserverCursor(observerId, result.cursor);
|
|
540
541
|
const { cursor, ...reply } = result;
|
|
541
|
-
|
|
542
|
+
// The cleanup hint rides along without touching quiet: it is a standing fact
|
|
543
|
+
// about the store, not a new worker event.
|
|
544
|
+
const cleanup = await cleanupHint();
|
|
545
|
+
return textResult({ ...reply, quiet: reply.quiet && recoveries.length === 0, recoveries, ...(cleanup ? { cleanup } : {}) });
|
|
542
546
|
});
|
|
543
547
|
observerRead = read.catch(() => {});
|
|
544
548
|
return read;
|