codex-supervisor-mcp 0.5.6 → 0.5.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 CHANGED
@@ -182,11 +182,11 @@ Auto-install only happens on a **global install**. `npx`, `--ignore-scripts`, an
182
182
 
183
183
  ## Tools
184
184
 
185
- Fourteen of them.
185
+ Sixteen of them.
186
186
 
187
187
  | Tool | Arguments | What it does |
188
188
  |---|---|---|
189
- | `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Start a worker. `baseRef` picks the commit the worktree is cut from (default: the repository's `HEAD`); pass another worker's `codex/<id>` branch to build on work that isn't on the main line yet |
189
+ | `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Start a worker. `session_title` / `session_note` record what the batch is for, so the board and `get_session_works` show that instead of a bare id. `baseRef` picks the commit the worktree is cut from (default: the repository's `HEAD`); pass another worker's `codex/<id>` branch to build on work that isn't on the main line yet |
190
190
  | `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, plus the same arguments | Start a **new session**, seeded with the old worker's prompt, status, and recent events |
191
191
  | `resume_codex_worker` | `task_id`, `prompt` | Continue the **same** Codex session |
192
192
  | `list_codex_workers` | `status`, `includeHistory`, `includeDetails` | List workers; running ones only by default |
@@ -199,6 +199,8 @@ Fourteen of them.
199
199
  | `get_worker_result` | `task_id`, `limit`, `maxChars` | A worker's own final report, in full. The overview and `wait_codex_workers` clip the last message to 400 characters and keep only the head; read this for the conclusion |
200
200
  | `get_session_works` | `session_id` | Every worker dispatched under one session, oldest first. This is how a dead main thread finds its batch again |
201
201
  | `search_works` | `query`, `limit` | Substring match over title / goal / prompt / last_message, newest first |
202
+ | `describe_session` | `session_id`, `title`, `note` | Record a title and a note for a session; fields you leave out keep their value. For when the first dispatch forgot |
203
+ | `check_for_update` | `force` | Ask the npm registry whether a newer version is published and whether the installed files match the published tarball. The same check runs at startup; this forces a fresh one |
202
204
  | `cancel_codex_worker` | `task_id` | Stop a worker; falls back to the pid when the process handle isn't in this process |
203
205
 
204
206
  ### Why `ownedPaths` and `goal` are required
@@ -279,6 +281,30 @@ A database from 0.1.x migrates automatically the first time it's opened. Process
279
281
 
280
282
  `changed_files` has three sources: Codex's `file_change` events, `git status --porcelain` in the worker's own worktree (the uncommitted part), and `git diff --name-only <base_commit> HEAD` (the committed part). The last two exist because a worker that edits files through a shell command (`printf > file`) never emits a `file_change` event, and once it commits on its branch `git status` is clean again - a real batch of five workers did exactly that and every read came back empty. `base_commit` is recorded on the row at dispatch; rows older than that column fall back to the oldest reflog entry of the `codex/<taskId>` branch, which is where the branch was created.
281
283
 
284
+ ## The board
285
+
286
+ The package ships a read-only web view over the same SQLite file:
287
+
288
+ ```bash
289
+ codex-supervisor-web # after a global install
290
+ npx -p codex-supervisor-mcp codex-supervisor-web # without installing
291
+ ```
292
+
293
+ It listens on `http://127.0.0.1:7877`; `SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` move it, `SUPERVISOR_HOME` points it at another state directory.
294
+
295
+ The left column lists sessions by the `session_title` recorded at dispatch (or, failing that, a line built from the workers' goals) and how many of their workers are still running. A session opens into its worker ledger: status, title, the command being run or the last line reported, time taken, files changed (the worktree's real diff, committed work included), commands run. A worker opens a drawer with the full report rendered from markdown, the change list, commands, the raw event stream, the task text, token usage and the native Codex goal. It refreshes every 2.5 seconds while something is running, every 8 seconds otherwise.
296
+
297
+ It reads. It does not dispatch or cancel; that stays with the MCP.
298
+
299
+ ## Update check
300
+
301
+ 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:
302
+
303
+ - The installed version. If it is behind `latest`, `get_orchestration_overview`, the dispatch receipt and the `wait_codex_workers` response gain an `update` field with `latest_version` and the command to run (`npm i -g codex-supervisor-mcp@latest`). The skill tells the main thread to pass that on to the user.
304
+ - The installed files. A global install records the integrity of the unpacked tarball in `node_modules/.package-lock.json`; if it differs from what the registry publishes 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 instead.
305
+
306
+ The answer is cached for an hour and refreshed every six hours while the process runs. An unreachable registry is not an error: the result says `source: "offline"` and nothing nags. `CODEX_SUPERVISOR_NO_UPDATE_CHECK=1` turns the check off; `CODEX_SUPERVISOR_REGISTRY` points it at a private registry. The board shows the same result in its lower left corner.
307
+
282
308
  ## Environment variables
283
309
 
284
310
  | Variable | Default | Effect |
@@ -287,6 +313,10 @@ A database from 0.1.x migrates automatically the first time it's opened. Process
287
313
  | `CODEX_HOME` | `~/.codex` | Read-only. Used to read Codex's own `goals_1.sqlite` |
288
314
  | `CODEX_BIN` | `codex` (via `PATH`) | Path to the Codex CLI. On Windows a bare name is expanded through `PATHEXT` and the `.cmd` shim is stepped over automatically; a `.js` / `.cjs` / `.mjs` target is started with `node` |
289
315
  | `GIT_BIN` | `git` (via `PATH`) | Path to the Git executable |
316
+ | `SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` | `7877` / `127.0.0.1` | Where the board listens |
317
+ | `CODEX_SUPERVISOR_NO_UPDATE_CHECK` | unset | Set to `1` to disable the update check |
318
+ | `CODEX_SUPERVISOR_REGISTRY` | `https://registry.npmjs.org` | Registry the update check asks |
319
+ | `CODEX_SUPERVISOR_UPDATE_TIMEOUT_MS` | `4000` | How long the update check waits for the registry |
290
320
 
291
321
  When the MCP client starts without `codex` on `PATH`, which is common for GUI-launched apps, set `CODEX_BIN` explicitly:
292
322
 
@@ -331,7 +361,8 @@ When the MCP client starts without `codex` on `PATH`, which is common for GUI-la
331
361
  8. ~~Worker-native goals: inject a `create_goal` instruction at dispatch~~
332
362
  9. ~~Windows support: `.cmd` shim bypass, `taskkill` process tree, cross-platform `PATH` / `PATHEXT`~~ ✅
333
363
  10. Resident daemon: move dispatch and process lifetime out of the MCP process
334
- 11. A live React board
364
+ 11. ~~A live React board~~ ✅
365
+ 12. ~~Session titles and notes, update check~~ ✅
335
366
 
336
367
  Rejected, with the reasoning, so nobody brings them up again:
337
368
 
@@ -362,11 +393,15 @@ The skill covers the dispatch flow, the order to read results in, how to tell `f
362
393
 
363
394
  ```bash
364
395
  npm install
365
- npm test # deterministic: truncation, state machine, v1→v2 migration, setup, Windows routing, 17 end-to-end regression cases
396
+ npm test # deterministic: truncation, state machine, v1→v2 migration, setup, Windows routing, 23 regression cases, 40 edge cases
397
+ npm run test:edge # test/edge only: update check against a fake registry, session titles, baseRef, non-ASCII paths, ghost rows, board API
366
398
  npm run test:real # end-to-end against the real codex CLI (includes cross-process resume and worktree isolation)
367
399
  npm run smoke # basic smoke test (real codex)
368
400
  npm run smoke:mcp # MCP protocol smoke test
369
401
  npm run monitor # Ink terminal board
402
+ npm run web:install # board dependencies (web/)
403
+ npm run web:build # bundle the board into web/dist; runs before publish
404
+ npm run web:dev # board with hot reload, /api proxied to 7877
370
405
  ```
371
406
 
372
407
  `npm test` replays a fixed Codex event stream through `src/test-fixtures/fake-codex.js`, so it's fast and deterministic. `npm run test:real` actually invokes `codex exec`. It's slower, but it's the evidence that this still works against the current Codex.
package/README.md CHANGED
@@ -182,11 +182,11 @@ rm -rf ~/.codex-supervisor # 状态目录:sqlite、事件流、worktree
182
182
 
183
183
  ## 工具
184
184
 
185
- 14 个工具。
185
+ 16 个工具。
186
186
 
187
187
  | 工具 | 入参 | 作用 |
188
188
  |---|---|---|
189
- | `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | 起一个 worker。`baseRef` 指定 worktree 从哪个提交切(默认仓库 `HEAD`),要接着另一路还没合进主线的 `codex/<id>` 分支干就传它 |
189
+ | `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | 起一个 worker。`session_title` / `session_note` 记下这一批活是干什么的,看板和 `get_session_works` 显示它们而不是光秃秃的 id;`baseRef` 指定 worktree 从哪个提交切(默认仓库 `HEAD`),要接着另一路还没合进主线的 `codex/<id>` 分支干就传它 |
190
190
  | `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, + 同上 | 起一个**新会话**,把老 worker 的 prompt、状态、近期事件拼进去 |
191
191
  | `resume_codex_worker` | `task_id`, `prompt` | 接**同一个** Codex 会话继续跑 |
192
192
  | `list_codex_workers` | `status`, `includeHistory`, `includeDetails` | 列出 worker,默认只看在跑的 |
@@ -199,6 +199,8 @@ rm -rf ~/.codex-supervisor # 状态目录:sqlite、事件流、worktree
199
199
  | `get_worker_result` | `task_id`, `limit`, `maxChars` | 读 worker 自己的完整收尾汇报。总览和 `wait_codex_workers` 把最后一条消息截到 400 字只留开头,要结论读这个 |
200
200
  | `get_session_works` | `session_id` | 一个 session 派出去的全部 worker,按时间升序。主线程挂了之后靠它找回那批活 |
201
201
  | `search_works` | `query`, `limit` | 在 title / goal / prompt / last_message 里做子串匹配,从新到旧 |
202
+ | `describe_session` | `session_id`, `title`, `note` | 给一个 session 记标题和说明,没传的字段保留原值。派单时漏了可以事后补 |
203
+ | `check_for_update` | `force` | 问 npm registry 有没有更新的版本、本机装的文件和发布的 tarball 是否一致。启动时会自动查一次,这个工具用来强制再查 |
202
204
  | `cancel_codex_worker` | `task_id` | 终止 worker,进程句柄不在本进程时按 pid 兜底 |
203
205
 
204
206
  ### 为什么 `ownedPaths` 和 `goal` 是必填
@@ -277,7 +279,31 @@ Codex 原生 goal 有六个状态,映射到 work 状态:
277
279
 
278
280
  老版本(0.1.x)的库会在第一次打开时自动迁移:`editing` / `command` / `command_completed` / `reporting` 这些原本塞在 `status` 里的过程值会被拆到 `phase`,`status` 归到 `running`,一行不丢。迁移在一个 `BEGIN IMMEDIATE` 事务里做,多个进程同时启动也只会有一个真的迁移。
279
281
 
280
- `changed_files` 有三个来源:Codex 的 `file_change` 事件、worker 自己 worktree 里的 `git status --porcelain`(未提交的部分)、以及 `git diff --name-only <base_commit> HEAD`(已提交的部分)。后两个是兜底——worker 用 shell 命令(`printf > file`)改文件时不会产生 `file_change` 事件;它自己在分支上 commit 之后 `git status` 又是干净的,一批五路 worker 全这么干过,读回来全是空数组。`base_commit` 在派单时记在行上;更早的行没有这列,就退回去读 `codex/<taskId>` 分支 reflog 里最老的那条,那是分支建出来的位置。
282
+ `changed_files` 有三个来源:Codex 的 `file_change` 事件、worker 自己 worktree 里的 `git status --porcelain`(未提交的部分)、以及 `git diff --name-only <base_commit> HEAD`(已提交的部分)。后两个是兜底:worker 用 shell 命令(`printf > file`)改文件时不会产生 `file_change` 事件;它自己在分支上 commit 之后 `git status` 又是干净的,一批五路 worker 全这么干过,读回来全是空数组。`base_commit` 在派单时记在行上;更早的行没有这列,就退回去读 `codex/<taskId>` 分支 reflog 里最老的那条,那是分支建出来的位置。
283
+
284
+ ## 看板
285
+
286
+ 包里带一个只读的网页看板,读的是同一个 sqlite:
287
+
288
+ ```bash
289
+ codex-supervisor-web # 全局装过之后
290
+ npx -p codex-supervisor-mcp codex-supervisor-web # 没装也能起
291
+ ```
292
+
293
+ 默认开在 `http://127.0.0.1:7877`,`SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` 改端口和地址,`SUPERVISOR_HOME` 指向别的状态目录。
294
+
295
+ 左栏是 session,显示派单时记的 `session_title`(没记就用各路 worker 的 goal 拼一句)和这批活还有几路在跑。点进去是这个 session 的 worker 台账:状态、标题、正在执行的命令或最后一句汇报、耗时、改了几个文件(按 worktree 真实 diff 算,含已 commit 的)、跑了几条命令。再点一路,右侧抽屉给完整汇报(markdown 渲染)、改动清单、命令、原始事件流、任务书,还有 token 消耗和 Codex 原生 goal。有 worker 在跑时每 2.5 秒刷新,静止时 8 秒。
296
+
297
+ 它只读,不派单,不取消。派单的事归 MCP。
298
+
299
+ ## 更新检查
300
+
301
+ MCP 进程启动时会问一次 npm registry:`latest` 是哪个版本,它的 tarball integrity 是多少。然后和本机比两件事:
302
+
303
+ - 装的版本号。比 `latest` 低,就在 `get_orchestration_overview`、派单回执、`wait_codex_workers` 的返回里多一个 `update` 字段,带 `latest_version` 和要跑的命令(`npm i -g codex-supervisor-mcp@latest`)。skill 让主线程看到这个字段就转告用户。
304
+ - 装的文件。全局安装时 npm 把解出来的 tarball integrity 记在 `node_modules/.package-lock.json` 里,和 registry 上这个版本的 integrity 不一样,说明本机的文件不是发布的那份,同样提示重装。git checkout 没有这个值,只记 commit。
305
+
306
+ 结果缓存一小时,运行中每六小时再查一次。registry 连不上就算了,不报错也不提示,本次结果标 `source: "offline"`。不想联网就设 `CODEX_SUPERVISOR_NO_UPDATE_CHECK=1`;私有 registry 用 `CODEX_SUPERVISOR_REGISTRY`。看板左下角也会显示同一个结果。
281
307
 
282
308
  ## 环境变量
283
309
 
@@ -287,6 +313,10 @@ Codex 原生 goal 有六个状态,映射到 work 状态:
287
313
  | `CODEX_HOME` | `~/.codex` | 只读,用来读 Codex 原生的 `goals_1.sqlite` |
288
314
  | `CODEX_BIN` | `codex`(走 `PATH`) | Codex CLI 可执行文件路径。Windows 上给裸名字时会按 `PATHEXT` 展开,`.cmd` shim 会被自动绕开;指向 `.js` / `.cjs` / `.mjs` 时自动用 `node` 起它 |
289
315
  | `GIT_BIN` | `git`(走 `PATH`) | Git 可执行文件路径 |
316
+ | `SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` | `7877` / `127.0.0.1` | 看板监听的端口和地址 |
317
+ | `CODEX_SUPERVISOR_NO_UPDATE_CHECK` | 未设 | 设成 `1` 关闭更新检查 |
318
+ | `CODEX_SUPERVISOR_REGISTRY` | `https://registry.npmjs.org` | 更新检查用的 registry |
319
+ | `CODEX_SUPERVISOR_UPDATE_TIMEOUT_MS` | `4000` | 更新检查等 registry 的上限 |
290
320
 
291
321
  如果 MCP 客户端启动时 `PATH` 里没有 `codex`(GUI 启动的应用常见),显式设置 `CODEX_BIN`:
292
322
 
@@ -331,7 +361,8 @@ Codex 原生 goal 有六个状态,映射到 work 状态:
331
361
  8. ~~worker 原生 goal:派单时注入 `create_goal` 指令~~
332
362
  9. ~~Windows 支持:`.cmd` shim 绕行、`taskkill` 进程树、跨平台 PATH / `PATHEXT`~~ ✅
333
363
  10. 常驻 daemon:派单和进程生命周期从 MCP 进程里拿出来
334
- 11. React 实时看板
364
+ 11. ~~React 实时看板~~ ✅
365
+ 12. ~~session 标题和说明、更新检查~~ ✅
335
366
 
336
367
  砍掉不做的(说明理由,免得以后又想起来):
337
368
 
@@ -362,11 +393,15 @@ skill 里写了派单流程、读结果该按什么顺序、`failed` 和 `lost`
362
393
 
363
394
  ```bash
364
395
  npm install
365
- npm test # 确定性测试:截断、状态机、v1→v2 迁移、setup、Windows 路由、17 项端到端回归
396
+ npm test # 确定性测试:截断、状态机、v1→v2 迁移、setup、Windows 路由、23 项端到端回归、40 项边界
397
+ npm run test:edge # 只跑 test/edge:更新检查(假 registry)、session 标题、baseRef、中文路径、僵尸行、看板 API
366
398
  npm run test:real # 用真 codex CLI 跑端到端(含跨进程 resume、worktree 隔离)
367
399
  npm run smoke # 基础冒烟(真 codex)
368
400
  npm run smoke:mcp # MCP 协议冒烟
369
401
  npm run monitor # Ink 终端看板
402
+ npm run web:install # 看板前端依赖(web/)
403
+ npm run web:build # 打包看板到 web/dist,发 npm 前自动跑
404
+ npm run web:dev # 看板热更新开发,/api 代理到 7877
370
405
  ```
371
406
 
372
407
  `npm test` 用 `src/test-fixtures/fake-codex.js` 回放固定的 Codex 事件流,跑得快且确定。`npm run test:real` 会真的调 `codex exec`,慢一些,但它才是「跟最新 Codex 兼容」的证据。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-supervisor-mcp",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
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",
@@ -24,7 +24,8 @@
24
24
  ],
25
25
  "bin": {
26
26
  "codex-supervisor-mcp": "./src/mcp-server.js",
27
- "codex-supervisor-setup": "./src/setup.js"
27
+ "codex-supervisor-setup": "./src/setup.js",
28
+ "codex-supervisor-web": "./src/web-server.js"
28
29
  },
29
30
  "files": [
30
31
  "src/mcp-server.js",
@@ -41,6 +42,9 @@
41
42
  "src/prompt.js",
42
43
  "src/cleanup.js",
43
44
  "src/monitor.jsx",
45
+ "src/web-server.js",
46
+ "src/update-check.js",
47
+ "web/dist/",
44
48
  "skills/",
45
49
  "README.md",
46
50
  "LICENSE"
@@ -51,12 +55,18 @@
51
55
  "start": "node ./src/mcp-server.js",
52
56
  "monitor": "tsx ./src/monitor.jsx",
53
57
  "cleanup": "node ./src/cleanup.js",
54
- "test": "node ./src/bin-resolver-test.js && node ./src/truncate-test.js && node ./src/status-test.js && node ./src/migration-test.js && node ./src/setup-test.js && node ./src/setup-windows-test.js && node ./src/regression-test.js",
58
+ "test": "node ./src/bin-resolver-test.js && node ./src/truncate-test.js && node ./src/status-test.js && node ./src/migration-test.js && node ./src/setup-test.js && node ./src/setup-windows-test.js && node ./src/regression-test.js && node --test test/edge/*.test.js",
55
59
  "test:real": "node ./src/real-codex-test.js",
56
60
  "smoke": "node ./src/smoke-test.js",
57
61
  "smoke:followup": "node ./src/followup-smoke-test.js",
58
62
  "smoke:mcp": "node ./src/mcp-smoke-test.js",
59
- "smoke:mcp-wait": "node ./src/mcp-wait-smoke-test.js"
63
+ "smoke:mcp-wait": "node ./src/mcp-wait-smoke-test.js",
64
+ "web": "node ./src/web-server.js",
65
+ "web:install": "npm --prefix web install",
66
+ "web:build": "npm --prefix web run build",
67
+ "web:dev": "npm --prefix web run dev",
68
+ "test:edge": "node --test test/edge/*.test.js",
69
+ "prepublishOnly": "npm run web:build && npm test"
60
70
  },
61
71
  "dependencies": {
62
72
  "@modelcontextprotocol/sdk": "^1.21.0"
@@ -18,9 +18,10 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
18
18
  ## 一次派单
19
19
 
20
20
  1. 拆活。每路写清楚:干什么、能写哪些文件、怎么算做完。
21
- 2. `create_codex_worker` 派出去。返回的是一张精简回执(`id`、`worktree_path`、`branch`、`owned_paths`、`status`),任务原文不回传,派十一路也不会把你的提示词抄十一遍。
22
- 3. 派完就 `wait_codex_workers` 等。默认只等 2 分钟,到点返回进度快照,worker 照跑;拿同一批 `task_ids` 接着调,直到 `timed_out: false`。默认**不带**事件(`includeEvents: false`),返回只够看状态,要事件得自己开。
23
- 4. 收结果走 `get_worker_result`,拿完整汇报,别一上来读事件流。
21
+ 2. 第一路派单时带 `session_id` + `session_title`(一句话说这批活是干什么的,30 字以内,比如「给 12 个接口补单测」),要交代背景再加 `session_note`。看板左栏和 `get_session_works` 显示的是这个标题,不是 id。漏了就事后调 `describe_session` 补。
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`,拿完整汇报,别一上来读事件流。
24
25
 
25
26
  `ownedPaths` 和 `goal` 必填,不是可选项。
26
27
 
@@ -33,7 +34,9 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
33
34
  | `ownedPaths` | 这个 worker 允许写的路径。和正在跑的 worker 重叠会被拒,返回冲突的 `task_id` |
34
35
  | `goal.objective` | 一句话说清这路活的目标 |
35
36
  | `session_id` | 同一批派单传同一个值。断线重连靠它 |
37
+ | `session_title` / `session_note` | 这批活是干什么的,一句话 + 可选说明。第一路带上就行,后面几路不用重复 |
36
38
  | `dependsOn` | 有先后依赖时填上游的 `task_id` |
39
+ | `baseRef` | worktree 从哪个提交切。默认仓库 `HEAD`;要接着另一路还没合进主线的活干,填它的分支 `codex/<taskId>` |
37
40
 
38
41
  一次派一批:
39
42
 
@@ -42,6 +45,10 @@ create_codex_worker × N (同一个 session_id)
42
45
  wait_codex_workers (task_ids: [...], mode: "all")
43
46
  ```
44
47
 
48
+ ## 看到 `update` 字段就转告用户
49
+
50
+ `get_orchestration_overview`、派单回执、`wait_codex_workers` 的返回里出现 `update` 且 `update_available: true`(或 `integrity_matches: false`)时,当轮回复里告诉用户一句:现在装的是 `installed_version`,npm 上已经是 `latest_version`,跑 `install_command` 里那条命令,然后重启 Claude Code / Codex。只说一次,不要每轮重复。用户让你查时调 `check_for_update`。
51
+
45
52
  ## 读结果别把上下文撑爆
46
53
 
47
54
  按这个顺序读,能不动后面就别动:
@@ -115,6 +122,10 @@ wait_codex_workers (task_ids: [...], mode: "all")
115
122
  - **worktree 只隔离工作区,不隔离端口和数据库**。多路活要是都会连同一个 dev server 或同一个库,得自己错开。
116
123
  - **`cancel_codex_worker` 跨进程靠 pid**。要求那个 pid 的命令行里带 `codex`,防止误杀复用 pid 的进程。
117
124
 
125
+ ## 看板
126
+
127
+ 用户想用眼睛看这批活在干什么时,告诉他起 `codex-supervisor-web`(全局装过)或 `npx -p codex-supervisor-mcp codex-supervisor-web`,开 `http://127.0.0.1:7877`。看板按 session 分组,显示的就是派单时记的 `session_title`,所以标题要写得让人一眼看懂。
128
+
118
129
  ## 收尾
119
130
 
120
131
  一批活全部到终态后:
@@ -9,6 +9,7 @@ import {
9
9
  readActiveTasks,
10
10
  readTaskEvents,
11
11
  taskRunPath,
12
+ upsertSession,
12
13
  upsertTask
13
14
  } from "./task-store.js";
14
15
  import { applyCodexEvent } from "./event-parser.js";
@@ -386,6 +387,8 @@ export async function createCodexWorker({
386
387
  title,
387
388
  task,
388
389
  sessionId = null,
390
+ sessionTitle = null,
391
+ sessionNote = null,
389
392
  cwd,
390
393
  sandbox = "workspace-write",
391
394
  model = null,
@@ -413,6 +416,10 @@ export async function createCodexWorker({
413
416
  const conflicts = await findOwnershipConflicts(normalizedOwnedPaths);
414
417
  if (conflicts.length > 0) throw ownershipConflictError(conflicts);
415
418
 
419
+ if (sessionId && (sessionTitle || sessionNote)) {
420
+ await upsertSession({ id: sessionId, title: sessionTitle, note: sessionNote });
421
+ }
422
+
416
423
  const id = `codex-${Date.now()}-${randomUUID().slice(0, 8)}`;
417
424
  const worktree = useWorktree
418
425
  ? await ensureWorktree(projectRoot, id, baseRef)
@@ -627,6 +634,8 @@ export async function createFollowupWorker({
627
634
  taskId,
628
635
  followupPrompt,
629
636
  sessionId = null,
637
+ sessionTitle = null,
638
+ sessionNote = null,
630
639
  title,
631
640
  cwd,
632
641
  sandbox,
@@ -666,6 +675,8 @@ export async function createFollowupWorker({
666
675
  title: title ?? `Follow-up for ${parent.id}`,
667
676
  task: prompt,
668
677
  sessionId: sessionId ?? parent.session_id ?? null,
678
+ sessionTitle,
679
+ sessionNote,
669
680
  cwd: cwd ?? parent.project_root ?? parent.cwd,
670
681
  sandbox: sandbox ?? parent.sandbox,
671
682
  model: model ?? parent.model,
package/src/mcp-server.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  resumeCodexWorker
11
11
  } from "./codex-runner.js";
12
12
  import {
13
+ getSession,
13
14
  getTask,
14
15
  getTasks,
15
16
  isPidAlive,
@@ -20,12 +21,14 @@ import {
20
21
  readTasksBySession,
21
22
  reconcileDetachedActiveTasks,
22
23
  searchTasks,
24
+ upsertSession,
23
25
  upsertTask
24
26
  } from "./task-store.js";
25
27
  import { readNativeGoal } from "./goal-store.js";
26
28
  import { readTaskChanges } from "./worktree.js";
27
29
  import { ACTIVE_STATUSES, TERMINAL_STATUSES, TASK_STATUSES, isGoalNeedingAttention } from "./status.js";
28
30
  import { approxTokenCount, truncateEventStrings, truncateMiddleChars } from "./truncate.js";
31
+ import { checkForUpdate, updateNotice } from "./update-check.js";
29
32
 
30
33
  // Report the real package version. This string had drifted to 0.4.0 while the
31
34
  // package shipped 0.5.x, so the handshake named a version nobody was running.
@@ -38,6 +41,35 @@ const server = new McpServer({
38
41
  version: packageVersion
39
42
  });
40
43
 
44
+ // Nobody should keep running an old build without hearing about it. The
45
+ // registry is asked once at start and every six hours after; the answer
46
+ // rides along in the overview, the dispatch receipt and the wait response,
47
+ // which are the calls every orchestrating session makes.
48
+ const UPDATE_RECHECK_MS = 6 * 60 * 60 * 1000;
49
+ let updateState = null;
50
+ async function refreshUpdateState({ force = false } = {}) {
51
+ try {
52
+ updateState = await checkForUpdate({ force });
53
+ if (updateState.notice) process.stderr.write(`[codex-supervisor] ${updateState.notice}\n`);
54
+ } catch (error) {
55
+ process.stderr.write(`[codex-supervisor] update check failed: ${error.message}\n`);
56
+ }
57
+ return updateState;
58
+ }
59
+ refreshUpdateState();
60
+ setInterval(() => refreshUpdateState({ force: true }), UPDATE_RECHECK_MS).unref();
61
+
62
+ // The short form for tool results: null when the install is current.
63
+ function updateField() {
64
+ return updateNotice(updateState);
65
+ }
66
+
67
+ // Spread into a result: adds `update` only when there is something to say.
68
+ function withUpdate(payload) {
69
+ const update = updateField();
70
+ return update ? { ...payload, update } : payload;
71
+ }
72
+
41
73
  const OVERVIEW_BYTE_BUDGET = 7000;
42
74
  const OVERVIEW_CAP_LEVELS = [
43
75
  { title: 40, goal: 60, action: 60, path: 60 },
@@ -241,11 +273,12 @@ function settleTokenCount(payload) {
241
273
  return Buffer.byteLength(JSON.stringify(payload), "utf8");
242
274
  }
243
275
 
244
- function buildOverview(tasks) {
276
+ function buildOverview(tasks, extras = {}) {
245
277
  let payload;
246
278
  for (const [index, caps] of OVERVIEW_CAP_LEVELS.entries()) {
247
279
  payload = {
248
280
  generated_at: new Date().toISOString(),
281
+ ...extras,
249
282
  total: tasks.length,
250
283
  active: tasks.filter((task) => ACTIVE_STATUSES.has(task.status)).length,
251
284
  needs_attention: tasks
@@ -329,6 +362,11 @@ server.registerTool(
329
362
  task: z.string().min(1),
330
363
  cwd: z.string().min(1),
331
364
  session_id: z.string().min(1).optional(),
365
+ // What this batch is about, in one line, so a reader of the store sees
366
+ // "给 12 个接口补单测" instead of a bare session id. Set it on
367
+ // the first dispatch of a session; later dispatches may omit it.
368
+ session_title: z.string().min(1).max(120).optional(),
369
+ session_note: z.string().min(1).max(2000).optional(),
332
370
  sandbox: z.enum(["read-only", "workspace-write", "danger-full-access"]).default("workspace-write"),
333
371
  model: z.string().optional(),
334
372
  reasoningEffort: z.enum(["minimal", "low", "medium", "high"]).default("high"),
@@ -347,8 +385,13 @@ server.registerTool(
347
385
  },
348
386
  async (input) => {
349
387
  try {
350
- const record = await createCodexWorker({ ...input, sessionId: input.session_id ?? null });
351
- return textResult(receipt(record));
388
+ const record = await createCodexWorker({
389
+ ...input,
390
+ sessionId: input.session_id ?? null,
391
+ sessionTitle: input.session_title ?? null,
392
+ sessionNote: input.session_note ?? null
393
+ });
394
+ return textResult(withUpdate(receipt(record)));
352
395
  } catch (error) {
353
396
  return errorResult(error);
354
397
  }
@@ -365,6 +408,8 @@ server.registerTool(
365
408
  task_id: z.string().min(1),
366
409
  followup_prompt: z.string().min(1),
367
410
  session_id: z.string().min(1).optional(),
411
+ session_title: z.string().min(1).max(120).optional(),
412
+ session_note: z.string().min(1).max(2000).optional(),
368
413
  title: z.string().optional(),
369
414
  cwd: z.string().optional(),
370
415
  sandbox: z.enum(["read-only", "workspace-write", "danger-full-access"]).optional(),
@@ -380,12 +425,14 @@ server.registerTool(
380
425
  baseRef: z.string().min(1).optional()
381
426
  }
382
427
  },
383
- async ({ task_id, followup_prompt, session_id, ...options }) => {
428
+ async ({ task_id, followup_prompt, session_id, session_title, session_note, ...options }) => {
384
429
  try {
385
430
  const record = await createFollowupWorker({
386
431
  taskId: task_id,
387
432
  followupPrompt: followup_prompt,
388
433
  sessionId: session_id ?? null,
434
+ sessionTitle: session_title ?? null,
435
+ sessionNote: session_note ?? null,
389
436
  ...options
390
437
  });
391
438
  return textResult(receipt(record));
@@ -454,7 +501,14 @@ server.registerTool(
454
501
  await reconcileDetachedActiveTasks();
455
502
  const tasks = await readTasks();
456
503
  const filtered = (status ? tasks.filter((task) => task.status === status) : tasks).slice(-limit);
457
- return textResult(buildOverview(filtered));
504
+ // version and update ride inside the budgeted payload so approx_tokens
505
+ // still reports the real cost of the whole reply.
506
+ return textResult(
507
+ buildOverview(filtered, {
508
+ version: packageVersion,
509
+ update: updateField() ?? { update_available: false, installed_version: packageVersion, checked: updateState?.source ?? "pending" }
510
+ })
511
+ );
458
512
  }
459
513
  );
460
514
 
@@ -531,7 +585,7 @@ server.registerTool(
531
585
  ? `${Math.round(effectiveTimeoutMs / 60000)}-minute`
532
586
  : `${Math.round(effectiveTimeoutMs / 1000)}-second`;
533
587
 
534
- return textResult({
588
+ return textResult(withUpdate({
535
589
  mode,
536
590
  timed_out: timedOut,
537
591
  still_running: timedOut,
@@ -548,7 +602,7 @@ server.registerTool(
548
602
  lost_count: tasks.filter((task) => task.status === "lost").length,
549
603
  active_count: tasks.filter((task) => ACTIVE_STATUSES.has(task.status)).length,
550
604
  workers: summaries
551
- });
605
+ }));
552
606
  }
553
607
  );
554
608
 
@@ -564,8 +618,11 @@ server.registerTool(
564
618
  },
565
619
  async ({ session_id }) => {
566
620
  const tasks = await readTasksBySession(session_id);
621
+ const meta = await getSession(session_id);
567
622
  return textResult({
568
623
  session_id,
624
+ title: meta?.title ?? null,
625
+ note: meta?.note ?? null,
569
626
  count: tasks.length,
570
627
  active: tasks.filter((task) => ACTIVE_STATUSES.has(task.status)).length,
571
628
  works: tasks.map(workRow)
@@ -573,6 +630,40 @@ server.registerTool(
573
630
  }
574
631
  );
575
632
 
633
+ server.registerTool(
634
+ "check_for_update",
635
+ {
636
+ title: "Check for update",
637
+ description:
638
+ "Ask the npm registry whether a newer codex-supervisor-mcp is published, and whether the installed files match the published tarball. Returns installed and latest version, integrity check, and the install command. The same check runs on startup; call this to force a fresh one.",
639
+ inputSchema: {
640
+ force: z.boolean().default(true)
641
+ }
642
+ },
643
+ async ({ force }) => {
644
+ const result = await refreshUpdateState({ force });
645
+ return textResult(result ?? { error: "update_check_failed" });
646
+ }
647
+ );
648
+
649
+ server.registerTool(
650
+ "describe_session",
651
+ {
652
+ title: "Describe session",
653
+ description:
654
+ "Record what a session is about: a one-line title and an optional note. Readers of the store (the web view, get_session_works) show these instead of the bare session id. Fields you omit are kept.",
655
+ inputSchema: {
656
+ session_id: z.string().min(1),
657
+ title: z.string().min(1).max(120).optional(),
658
+ note: z.string().min(1).max(2000).optional()
659
+ }
660
+ },
661
+ async ({ session_id, title, note }) => {
662
+ const row = await upsertSession({ id: session_id, title: title ?? null, note: note ?? null });
663
+ return textResult({ session_id, title: row?.title ?? null, note: row?.note ?? null, updated_at: row?.updated_at ?? null });
664
+ }
665
+ );
666
+
576
667
  server.registerTool(
577
668
  "search_works",
578
669
  {
package/src/task-store.js CHANGED
@@ -158,6 +158,19 @@ const TASK_EVENTS_INDEX_DDL =
158
158
  const TASKS_SESSION_INDEX_DDL =
159
159
  "CREATE INDEX IF NOT EXISTS idx_tasks_session ON tasks(session_id);";
160
160
 
161
+ // A session is a string on each task row; this table is what a session is
162
+ // *about*. A main thread sets it once per batch, so a reader sees "给 12
163
+ // 个接口补单测" instead of a bare id.
164
+ const SESSIONS_DDL = `
165
+ CREATE TABLE IF NOT EXISTS sessions (
166
+ id TEXT PRIMARY KEY,
167
+ title TEXT,
168
+ note TEXT,
169
+ created_at TEXT NOT NULL,
170
+ updated_at TEXT NOT NULL
171
+ );
172
+ `;
173
+
161
174
  function sleepSync(ms) {
162
175
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
163
176
  }
@@ -191,6 +204,7 @@ function initializeSchema(dbInstance) {
191
204
  dbInstance.exec(TASK_EVENTS_DDL);
192
205
  dbInstance.exec(TASK_EVENTS_INDEX_DDL);
193
206
  dbInstance.exec(TASKS_SESSION_INDEX_DDL);
207
+ dbInstance.exec(SESSIONS_DDL);
194
208
  dbInstance.exec("COMMIT;");
195
209
  } catch (error) {
196
210
  try {
@@ -381,6 +395,34 @@ export async function readTasksBySession(sessionId) {
381
395
  return rows.map(rowToTask);
382
396
  }
383
397
 
398
+ export async function upsertSession({ id, title = null, note = null }) {
399
+ if (!id) throw new Error("session id is required");
400
+ await ensureFilesystem();
401
+ const now = new Date().toISOString();
402
+ // Only overwrite what the caller sent: a later dispatch that names the
403
+ // session without a title must not blank the title set earlier.
404
+ openDb()
405
+ .prepare(`
406
+ INSERT INTO sessions (id, title, note, created_at, updated_at) VALUES (@id, @title, @note, @now, @now)
407
+ ON CONFLICT(id) DO UPDATE SET
408
+ title = COALESCE(excluded.title, sessions.title),
409
+ note = COALESCE(excluded.note, sessions.note),
410
+ updated_at = excluded.updated_at
411
+ `)
412
+ .run({ id, title: title ?? null, note: note ?? null, now });
413
+ return getSession(id);
414
+ }
415
+
416
+ export async function getSession(sessionId) {
417
+ await ensureFilesystem();
418
+ return openDb().prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId) ?? null;
419
+ }
420
+
421
+ export async function readSessions() {
422
+ await ensureFilesystem();
423
+ return openDb().prepare("SELECT * FROM sessions").all();
424
+ }
425
+
384
426
  export async function getTasks(taskIds) {
385
427
  await ensureFilesystem();
386
428
  return taskIds.map((taskId) => {