catherd-cli 1.4.0 → 2.0.0-beta.20261022113309

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.
Files changed (320) hide show
  1. package/README.md +188 -169
  2. package/THIRD_PARTY_NOTICES.md +217 -35
  3. package/catalog/jev.json +27 -1
  4. package/catalog/models.json +56 -239
  5. package/package.json +6 -8
  6. package/plugin/.claude-plugin/plugin.json +1 -1
  7. package/plugin/.codex-plugin/plugin.json +1 -1
  8. package/plugin/bin/catherd-mcp +1 -1
  9. package/plugin/commands/catherd.md +2 -2
  10. package/plugin/skills/catherd/SKILL.md +97 -356
  11. package/plugin/skills/catherd-setup/SKILL.md +21 -20
  12. package/src/adapters/all.ts +0 -4
  13. package/src/adapters/backend.ts +19 -4
  14. package/src/adapters/claude-code/index.ts +126 -14
  15. package/src/adapters/codex/events.ts +10 -0
  16. package/src/adapters/codex/index.ts +17 -5
  17. package/src/adapters/cursor/home.ts +1 -1
  18. package/src/adapters/cursor/index.ts +10 -4
  19. package/src/adapters/opencode/index.ts +38 -1
  20. package/src/cli.ts +27 -27
  21. package/src/domain/agents.ts +3 -1
  22. package/src/domain/bars.ts +33 -107
  23. package/src/domain/blocked.ts +72 -0
  24. package/src/domain/branch.ts +51 -0
  25. package/src/domain/brief.ts +106 -0
  26. package/src/domain/catalog.ts +69 -313
  27. package/src/domain/changes.ts +23 -1
  28. package/src/domain/cost.ts +19 -29
  29. package/src/domain/errors.ts +6 -2
  30. package/src/domain/fail-lines.ts +26 -0
  31. package/src/domain/failover.ts +37 -75
  32. package/src/domain/findings.ts +47 -0
  33. package/src/domain/gate-brief.ts +53 -0
  34. package/src/domain/hints.ts +13 -2
  35. package/src/domain/ids.ts +13 -2
  36. package/src/domain/jev.ts +47 -2
  37. package/src/domain/judge.ts +124 -0
  38. package/src/domain/lane.ts +118 -3
  39. package/src/domain/milestone-memory.ts +53 -0
  40. package/src/domain/notice.ts +32 -8
  41. package/src/domain/notify.ts +32 -0
  42. package/src/domain/plan-doc.ts +198 -0
  43. package/src/domain/plan-lint.ts +141 -0
  44. package/src/domain/profile-rules.ts +175 -138
  45. package/src/domain/profile.ts +140 -63
  46. package/src/domain/record.ts +68 -3
  47. package/src/domain/reply.ts +29 -0
  48. package/src/domain/role-prompts.ts +182 -56
  49. package/src/domain/role-scope.ts +76 -0
  50. package/src/domain/role-tools.ts +34 -0
  51. package/src/domain/roles.ts +2 -0
  52. package/src/domain/route.ts +90 -0
  53. package/src/domain/rules.ts +33 -0
  54. package/src/domain/run-events.ts +298 -0
  55. package/src/domain/run-machine.ts +668 -0
  56. package/src/domain/run-state.ts +1310 -0
  57. package/src/domain/scorecard.ts +197 -0
  58. package/src/domain/select.ts +229 -72
  59. package/src/domain/slopalytics.ts +72 -0
  60. package/src/domain/state.ts +5 -0
  61. package/src/domain/util.ts +22 -0
  62. package/src/domain/workspace.ts +130 -0
  63. package/src/entry/answer-command.ts +39 -0
  64. package/src/entry/catalog-command.ts +24 -165
  65. package/src/entry/check-bin.ts +17 -0
  66. package/src/entry/cli-kit.ts +18 -2
  67. package/src/entry/daemon-bin.ts +22 -0
  68. package/src/entry/deps.ts +2 -0
  69. package/src/entry/doctor-command.ts +20 -2
  70. package/src/entry/glyphs.ts +15 -2
  71. package/src/entry/host-arg.ts +28 -0
  72. package/src/entry/init-command.ts +20 -69
  73. package/src/entry/knowledge-command.ts +121 -5
  74. package/src/entry/lock-command.ts +103 -8
  75. package/src/entry/mcp/handshake.ts +6 -2
  76. package/src/entry/mcp/role-bin.ts +20 -0
  77. package/src/entry/mcp/role-server.ts +134 -0
  78. package/src/entry/mcp/server.ts +85 -21
  79. package/src/entry/mcp/session-tools.ts +149 -0
  80. package/src/entry/panel/openapi.ts +189 -0
  81. package/src/entry/panel/server.ts +410 -0
  82. package/src/entry/panel-command.ts +68 -0
  83. package/src/entry/pause-command.ts +67 -0
  84. package/src/entry/profile-command.ts +33 -18
  85. package/src/entry/role-cli-command.ts +159 -0
  86. package/src/entry/runs-command.ts +81 -27
  87. package/src/entry/scorecard-command.ts +187 -0
  88. package/src/entry/supervise-bin.ts +1 -1
  89. package/src/entry/supervise-command.ts +30 -3
  90. package/src/entry/workspace-command.ts +44 -0
  91. package/src/infra/boot-lock.ts +25 -0
  92. package/src/infra/delivery.ts +3 -0
  93. package/src/infra/dispatch-dir.ts +2 -0
  94. package/src/infra/env.ts +11 -3
  95. package/src/infra/git.ts +70 -0
  96. package/src/infra/heavy-lock.ts +133 -6
  97. package/src/infra/host-probe.ts +16 -0
  98. package/src/infra/launch.ts +63 -7
  99. package/src/infra/lock-activity.ts +88 -0
  100. package/src/infra/login-env.ts +48 -0
  101. package/src/infra/memory.ts +45 -0
  102. package/src/infra/ntfy.ts +40 -0
  103. package/src/infra/open-url.ts +42 -0
  104. package/src/infra/paths.ts +37 -2
  105. package/src/infra/role-mcp.ts +69 -0
  106. package/src/infra/slopalytics.ts +30 -0
  107. package/src/infra/store.ts +6 -1
  108. package/src/infra/supervisor.ts +107 -16
  109. package/src/services/admission.ts +133 -31
  110. package/src/services/backends.ts +4 -6
  111. package/src/services/budget.ts +26 -6
  112. package/src/services/capture.ts +1 -22
  113. package/src/services/catalog-service.ts +155 -254
  114. package/src/services/credentials.ts +15 -26
  115. package/src/services/daemon.ts +181 -0
  116. package/src/services/dispatch-service.ts +209 -17
  117. package/src/services/dispatches.ts +30 -2
  118. package/src/services/doctor-access.ts +8 -3
  119. package/src/services/doctor-backends.ts +1 -1
  120. package/src/services/doctor-checks.ts +47 -0
  121. package/src/services/doctor-docker.ts +221 -0
  122. package/src/services/doctor-role-mcp.ts +65 -0
  123. package/src/services/doctor.ts +72 -15
  124. package/src/services/end-push.ts +157 -0
  125. package/src/services/failover-rungs.ts +109 -0
  126. package/src/services/finalize.ts +24 -2
  127. package/src/services/gate-env.ts +217 -0
  128. package/src/services/gate-service.ts +231 -45
  129. package/src/services/global-install.ts +46 -13
  130. package/src/services/jev-service.ts +2 -4
  131. package/src/services/lane-edit.ts +154 -0
  132. package/src/services/lane-service.ts +291 -55
  133. package/src/services/milestone-check.ts +433 -0
  134. package/src/services/milestone-tree.ts +170 -0
  135. package/src/services/milestones.ts +167 -29
  136. package/src/services/notifier.ts +124 -4
  137. package/src/services/notify-service.ts +26 -0
  138. package/src/services/orchestrator-wait.ts +82 -0
  139. package/src/services/panel-setup.ts +116 -0
  140. package/src/services/pause.ts +161 -0
  141. package/src/services/peek.ts +79 -17
  142. package/src/services/plan-input.ts +151 -0
  143. package/src/services/ports.ts +60 -5
  144. package/src/services/preflight.ts +232 -24
  145. package/src/services/profile-service.ts +31 -3
  146. package/src/services/profile-store.ts +18 -6
  147. package/src/services/protocol.ts +123 -25
  148. package/src/services/provenance.ts +34 -89
  149. package/src/services/questions.ts +24 -0
  150. package/src/services/reconcile.ts +33 -1
  151. package/src/services/reentry.ts +7 -6
  152. package/src/services/role-access.ts +27 -0
  153. package/src/services/routing-service.ts +161 -42
  154. package/src/services/run-briefs.ts +477 -0
  155. package/src/services/run-client.ts +217 -0
  156. package/src/services/run-effects.ts +837 -0
  157. package/src/services/run-events-store.ts +174 -0
  158. package/src/services/run-evidence.ts +1 -1
  159. package/src/services/run-pin.ts +125 -0
  160. package/src/services/run-read.ts +221 -0
  161. package/src/services/run-report.ts +176 -0
  162. package/src/services/run-service.ts +204 -23
  163. package/src/services/run-store.ts +159 -18
  164. package/src/services/scorecard-metrics.ts +86 -0
  165. package/src/services/scorecard.ts +382 -0
  166. package/src/services/scratch.ts +60 -0
  167. package/src/services/sessions.ts +3 -1
  168. package/src/services/state.ts +21 -0
  169. package/src/services/summary.ts +76 -12
  170. package/src/services/tree-path.ts +27 -0
  171. package/src/services/verifier-brief.ts +23 -0
  172. package/src/services/verifier-step.ts +48 -0
  173. package/src/services/workspace-admission.ts +259 -0
  174. package/src/services/workspace-service.ts +259 -0
  175. package/src/services/workspace-store.ts +95 -0
  176. package/web/dist/assets/Brand-PKlUX5TE.js +1 -0
  177. package/web/dist/assets/Brand-PKlUX5TE.js.br +0 -0
  178. package/web/dist/assets/Brand-PKlUX5TE.js.gz +0 -0
  179. package/web/dist/assets/Modal-Dxc5so53.js +1 -0
  180. package/web/dist/assets/Modal-Dxc5so53.js.br +0 -0
  181. package/web/dist/assets/Modal-Dxc5so53.js.gz +0 -0
  182. package/web/dist/assets/Pressable-C8-T6Ed_.js +1 -0
  183. package/web/dist/assets/StatusChip-B5xfI_Mn.js +153 -0
  184. package/web/dist/assets/StatusChip-B5xfI_Mn.js.br +0 -0
  185. package/web/dist/assets/StatusChip-B5xfI_Mn.js.gz +0 -0
  186. package/web/dist/assets/_app-Ea5cpyKe.js +1 -0
  187. package/web/dist/assets/_app-Ea5cpyKe.js.br +0 -0
  188. package/web/dist/assets/_app-Ea5cpyKe.js.gz +0 -0
  189. package/web/dist/assets/_runId-pTG0fXVo.js +1 -0
  190. package/web/dist/assets/_runId-pTG0fXVo.js.br +0 -0
  191. package/web/dist/assets/_runId-pTG0fXVo.js.gz +0 -0
  192. package/web/dist/assets/drawer-Du3cdlok.js +1 -0
  193. package/web/dist/assets/drawer-Du3cdlok.js.br +0 -0
  194. package/web/dist/assets/drawer-Du3cdlok.js.gz +0 -0
  195. package/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  196. package/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  197. package/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  198. package/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  199. package/web/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  200. package/web/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  201. package/web/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  202. package/web/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  203. package/web/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  204. package/web/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  205. package/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  206. package/web/dist/assets/index-B6GiwDkh.js +11 -0
  207. package/web/dist/assets/index-B6GiwDkh.js.br +0 -0
  208. package/web/dist/assets/index-B6GiwDkh.js.gz +0 -0
  209. package/web/dist/assets/index-C5IbylvM.css +2 -0
  210. package/web/dist/assets/index-C5IbylvM.css.br +0 -0
  211. package/web/dist/assets/index-C5IbylvM.css.gz +0 -0
  212. package/web/dist/assets/label-DFSYBc62.js +1 -0
  213. package/web/dist/assets/label-DFSYBc62.js.br +0 -0
  214. package/web/dist/assets/label-DFSYBc62.js.gz +0 -0
  215. package/web/dist/assets/link-D8EcKZUt.js +1 -0
  216. package/web/dist/assets/link-D8EcKZUt.js.br +0 -0
  217. package/web/dist/assets/link-D8EcKZUt.js.gz +0 -0
  218. package/web/dist/assets/login-DaN5HPPW.js +1 -0
  219. package/web/dist/assets/login-DaN5HPPW.js.br +0 -0
  220. package/web/dist/assets/login-DaN5HPPW.js.gz +0 -0
  221. package/web/dist/assets/query-Cu--ccT3.js +1 -0
  222. package/web/dist/assets/questions-shoO9OVj.js +1 -0
  223. package/web/dist/assets/questions-shoO9OVj.js.br +0 -0
  224. package/web/dist/assets/questions-shoO9OVj.js.gz +0 -0
  225. package/web/dist/assets/react-query.gen-Bu2yV-qJ.js +12 -0
  226. package/web/dist/assets/react-query.gen-Bu2yV-qJ.js.br +0 -0
  227. package/web/dist/assets/react-query.gen-Bu2yV-qJ.js.gz +0 -0
  228. package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  229. package/web/dist/assets/run-status-C0DRuV7U.js +1 -0
  230. package/web/dist/assets/runs-C3rg2zZc.js +1 -0
  231. package/web/dist/assets/runs-C3rg2zZc.js.br +0 -0
  232. package/web/dist/assets/runs-C3rg2zZc.js.gz +0 -0
  233. package/web/dist/assets/setup-5I4Vl9fR.js +1 -0
  234. package/web/dist/assets/setup-5I4Vl9fR.js.br +0 -0
  235. package/web/dist/assets/setup-5I4Vl9fR.js.gz +0 -0
  236. package/web/dist/assets/table-BOxXhqS4.js +1 -0
  237. package/web/dist/assets/table-BOxXhqS4.js.br +0 -0
  238. package/web/dist/assets/table-BOxXhqS4.js.gz +0 -0
  239. package/web/dist/assets/textfield-BzRFkxBF.js +1 -0
  240. package/web/dist/assets/textfield-BzRFkxBF.js.br +0 -0
  241. package/web/dist/assets/textfield-BzRFkxBF.js.gz +0 -0
  242. package/web/dist/assets/time--9kSQbbp.js +1 -0
  243. package/web/dist/assets/use-css-variable-CpnN9WtA.js +5 -0
  244. package/web/dist/assets/use-css-variable-CpnN9WtA.js.br +0 -0
  245. package/web/dist/assets/use-css-variable-CpnN9WtA.js.gz +0 -0
  246. package/web/dist/assets/useMutation-CVPKlR34.js +1 -0
  247. package/web/dist/assets/useMutation-CVPKlR34.js.br +0 -0
  248. package/web/dist/assets/useMutation-CVPKlR34.js.gz +0 -0
  249. package/web/dist/index.html +15 -0
  250. package/catalog/ATTRIBUTION.md +0 -36
  251. package/catalog/scores.json +0 -3202
  252. package/catalog/sources.json +0 -97
  253. package/src/adapters/antigravity/events.ts +0 -131
  254. package/src/adapters/antigravity/home.ts +0 -46
  255. package/src/adapters/antigravity/index.ts +0 -320
  256. package/src/adapters/antigravity/models.ts +0 -37
  257. package/src/adapters/grok/events.ts +0 -112
  258. package/src/adapters/grok/home.ts +0 -132
  259. package/src/adapters/grok/index.ts +0 -339
  260. package/src/adapters/grok/models.ts +0 -48
  261. package/src/domain/calibration.ts +0 -125
  262. package/src/domain/sources.ts +0 -144
  263. package/src/entry/mcp/dispatch-tools.ts +0 -52
  264. package/src/entry/mcp/lane-tools.ts +0 -84
  265. package/src/entry/mcp/protocol-tools.ts +0 -57
  266. package/src/entry/mcp/run-tools.ts +0 -148
  267. package/src/entry/mcp/setup-tools.ts +0 -108
  268. package/src/entry/tui/commands.ts +0 -563
  269. package/src/entry/tui/effects.ts +0 -381
  270. package/src/entry/tui/fixtures.ts +0 -637
  271. package/src/entry/tui/profile-edits.ts +0 -146
  272. package/src/entry/tui/profile-tree.ts +0 -429
  273. package/src/entry/tui/providers/app.tsx +0 -162
  274. package/src/entry/tui/providers/boundary.tsx +0 -57
  275. package/src/entry/tui/providers/data.tsx +0 -160
  276. package/src/entry/tui/providers/keymap.tsx +0 -166
  277. package/src/entry/tui/providers/root.tsx +0 -45
  278. package/src/entry/tui/providers/theme.tsx +0 -17
  279. package/src/entry/tui/providers/toast.tsx +0 -77
  280. package/src/entry/tui/run.tsx +0 -114
  281. package/src/entry/tui/state.ts +0 -373
  282. package/src/entry/tui/stories.ts +0 -114
  283. package/src/entry/tui/text.ts +0 -130
  284. package/src/entry/tui/theme.ts +0 -140
  285. package/src/entry/tui/views/app.tsx +0 -208
  286. package/src/entry/tui/views/dialogs.tsx +0 -41
  287. package/src/entry/tui/views/profile-actions.ts +0 -331
  288. package/src/entry/tui/views/profiles.tsx +0 -520
  289. package/src/entry/tui/views/runs.tsx +0 -573
  290. package/src/entry/tui/views/save-dialog.tsx +0 -340
  291. package/src/entry/tui/views/status.tsx +0 -209
  292. package/src/entry/tui/widgets/chrome.tsx +0 -114
  293. package/src/entry/tui/widgets/dialog-confirm.tsx +0 -58
  294. package/src/entry/tui/widgets/dialog-prompt.tsx +0 -52
  295. package/src/entry/tui/widgets/dialog-select.tsx +0 -212
  296. package/src/entry/tui/widgets/dialog.tsx +0 -68
  297. package/src/entry/tui/widgets/line.tsx +0 -92
  298. package/src/entry/tui/widgets/list.tsx +0 -197
  299. package/src/entry/tui/widgets/spinner.tsx +0 -49
  300. package/src/entry/tui/widgets/toast.tsx +0 -62
  301. package/src/infra/sources/arena.ts +0 -87
  302. package/src/infra/sources/artificial-analysis.ts +0 -112
  303. package/src/infra/sources/cache.ts +0 -124
  304. package/src/infra/sources/csv.ts +0 -38
  305. package/src/infra/sources/epoch.ts +0 -82
  306. package/src/infra/sources/http.ts +0 -75
  307. package/src/infra/sources/litellm.ts +0 -58
  308. package/src/infra/sources/models-dev.ts +0 -59
  309. package/src/infra/sources/openrouter-endpoints.ts +0 -52
  310. package/src/infra/sources/openrouter-models.ts +0 -60
  311. package/src/infra/sources/rows.ts +0 -38
  312. package/src/infra/sources/vectara.ts +0 -69
  313. package/src/infra/sources/zip.ts +0 -48
  314. package/src/services/catalog-refresh.ts +0 -201
  315. package/src/services/doctor-sources.ts +0 -76
  316. package/src/services/runs-page.ts +0 -255
  317. package/src/services/source-derive.ts +0 -374
  318. package/src/services/source-sync.ts +0 -305
  319. package/src/services/standins.ts +0 -204
  320. package/src/services/treat-likes.ts +0 -97
@@ -7,7 +7,7 @@ description: Use when the user wants to tune catherd — which models and effort
7
7
 
8
8
  You tune the user's catherd profile in conversation. A profile says, per role, which rungs it may run on (`backend:model#effort`, in ladder order) and what it may touch (its access mode); whether routing favours cost or speed; how each backend is billed; whether Jev picks the rung; which rung stands in when a backend hits its usage limit; the run budget and timeouts; whether each vendor harness runs with the user's customizations or isolated; how many heavy commands run at once; and when to push.
9
9
 
10
- **You never edit a file by hand.** Use `profile_set` for patches and the existing reviewed CLI reset below; both go through ProfileService, as do the `catherd profile` commands and the TUI.
10
+ **You never edit a file by hand.** Use `profile({ action: "set" })` for patches and the existing reviewed CLI reset below; both go through ProfileService, as do the `catherd profile` commands and the panel.
11
11
 
12
12
  **Discover the host first with `status()`.** Use the host's available MCP discovery facility; names and deferred tools differ. Claude Code may use `ToolSearch`; Codex never needs invented Claude tools or native Claude agents. Pass the actual project `repo` explicitly to profile, setup and catalog calls that accept it: native Codex starts the MCP server in the installed plugin root, not the project. An unknown terminal can use `catherd init --host codex` or `--host claude-code` for setup; this does not create a conversation owner. Conflicting identity must be resolved before ownership or push.
13
13
 
@@ -15,7 +15,7 @@ You tune the user's catherd profile in conversation. A profile says, per role, w
15
15
 
16
16
  - **One question at a time.** Each question carries your recommended answer and one line on why, so the user can simply say yes.
17
17
  - **The user steers.** When they reverse a proposal, take the reversal and never re-argue it.
18
- - **Talk in their terms:** minutes, their subscriptions, how often a rung climbed on their own runs, tokens per run. Benchmark names only when they ask.
18
+ - **Talk in their terms:** minutes, their subscriptions, how often a rung climbed on their own runs, tokens per run. Name the Slopalytics intelligence index only when they ask.
19
19
  - **Every number you quote comes from a tool result in this conversation.** When there is no data yet, say so instead of estimating.
20
20
 
21
21
  ## 1. Learn the goals
@@ -23,16 +23,17 @@ You tune the user's catherd profile in conversation. A profile says, per role, w
23
23
  Ask these, one at a time, each with its recommended answer:
24
24
 
25
25
  1. **Their order of speed, cost and quality.** Recommend cost first, the default `objective`: catherd climbs a rung when a cheap one cannot do the work, so the lanes that need speed get it anyway, and the reviewer and the verifier hold quality either way.
26
- 2. **The subscriptions they hold:** a ChatGPT plan (Codex), a Claude plan, OpenCode Go, Zen credit or API keys. They set `billing` per key (`codex`, `claude`, `claude-code`, `opencode-go`, `opencode`, `cursor`, `grok`, `antigravity`): `chatgpt-plan`, `claude-plan`, `subscription` or `metered`. Recommend leaning on subscriptions before metered spend. Explain which workers share this conversation's quota from the actual host and billing facts.
27
- 3. **The kind of work they orchestrate:** front-end screens, back-end services, terminal and ops work, docs. Recommend from their own runs when `runs_summary` has any.
26
+ 2. **The subscriptions they hold:** a ChatGPT plan (Codex), a Claude plan, OpenCode Go, Zen credit or API keys. They set `billing` per key (`codex`, `claude`, `claude-code`, `opencode-go`, `opencode`, `cursor`): `chatgpt-plan`, `claude-plan`, `subscription` or `metered`. Recommend leaning on subscriptions before metered spend. Explain which workers share this conversation's quota from the actual host and billing facts.
27
+ 3. **The kind of work they orchestrate:** front-end screens, back-end services, terminal and ops work, docs. Recommend from their own runs when the catalog's `runs:` evidence has any.
28
28
 
29
29
  ## 2. Read the facts before proposing
30
30
 
31
31
  In one message, call:
32
32
 
33
- - `catalog_query({ repo, role: "<role>" })` for each role you will discuss: the models that can fill it, their scored rungs, any "treat like", each rung's cost under their billing, and whether their backend's last listing offers it (`listed: false` means their account does not);
34
- - `runs_summary({})`: how each rung has done on their own runs (runs, refusals, climbs, time) and the harness cost line, for claude-code and opencode only: Codex reports no per-request input, so it has no harness figure;
35
- - `profile_get({ repo })`: where they stand now, with each role's `access` and `enforcement`. Pass the user's repo: without a name, the profile tools act on the profile this repo runs on (the one bound to it, else the active one), which `here` names; `active` is the global active profile.
33
+ - `catherd catalog list --role <role> --json` (in a shell, from their repo) for each role you will discuss: the models that can fill it, their indexed rungs (each with its `intelligence`, the one number catherd ranks on), each rung's cost under their billing, whether their backend's last listing offers it (`listed: false` means their account does not), and the `runs:` evidence of how each rung has done on their own runs (runs, refusals, climbs, time). The session has no catalog tool;
34
+ - `profile({ action: "get", repo })`: where they stand now, with each role's `access` and `enforcement`. Pass the user's repo: without a name, the profile tools act on the profile this repo runs on (the one bound to it, else the active one), which `here` names; `active` is the global active profile.
35
+
36
+ There is no per-run harness figure in the session: say so when isolation comes up.
36
37
 
37
38
  Verify the exact omitted Codex model ID `gpt-6.1-sol` against native catalog discovery and validation. If its spelling differs, report the mismatch and resolve it explicitly with the owner; never silently normalize or substitute a model. Retain architect high and verifier low effort.
38
39
 
@@ -44,7 +45,7 @@ Go through these in order, and skip any the user does not care about:
44
45
  2. `billing`, from step 1;
45
46
  3. the worker's `rungs` and its `defaultRung`;
46
47
  4. the reviewer and the UI reviewer;
47
- 5. the architect and the verifier. Recommend omitted host defaults: on Codex, exactly `codex:gpt-6.1-sol#high` and `codex:gpt-6.1-sol#low`; on Claude Code, the existing native Claude defaults. A `claude:` rung requires a Claude Code host and its native `Agent`; `claude-code:` runs headless through `dispatch` on either host. Codex architect/verifier use process `dispatch`/`result`. Preserve explicit model IDs, efforts, ladder order and all other fields. Never silently convert `claude:` into `claude-code:`;
48
+ 5. the architect and the verifier. Recommend omitted host defaults: on Codex, exactly `codex:gpt-6.1-sol#high` and `codex:gpt-6.1-sol#low`; on Claude Code, the existing native Claude defaults. A `claude:` rung requires a Claude Code host; the daemon runs it as its headless `claude-code:` twin, and `claude-code:` is that headless rung on either host. Codex architect and verifier run as headless processes the daemon starts. Preserve explicit model IDs, efforts, ladder order and all other fields. Never silently convert `claude:` into `claude-code:` in the profile;
48
49
  6. the writer, the researcher and the artist;
49
50
  7. each role's `access` (below);
50
51
  8. `failover` (below);
@@ -52,7 +53,7 @@ Go through these in order, and skip any the user does not care about:
52
53
  10. harness isolation, per harness (below);
53
54
  11. `lock.heavy` and `notify`.
54
55
 
55
- Existing materialized profiles remain unchanged on read, init, upgrade or host switch. To deliberately opt into host defaults, use the existing CLI from the project directory, naming the profile returned by `profile_get`:
56
+ Existing materialized profiles remain unchanged on read, init, upgrade or host switch. To deliberately opt into host defaults, use the existing CLI from the project directory, naming the profile returned by `profile({ action: "get" })`:
56
57
 
57
58
  ```sh
58
59
  catherd profile reset-host-defaults <profile> --host codex --preview --json > /tmp/catherd-host-defaults-review.json
@@ -64,28 +65,28 @@ Use `--host claude-code` for that host. This reviewed reset removes only archite
64
65
 
65
66
  Each proposal has three parts: the change, a worked example from their facts, and the tradeoff in their terms. For instance: "Luna high on build lanes: about 5 min slower than Sol medium, no Claude quota, climbs on 1 in 5 of your runs so far."
66
67
 
67
- - Offer only the rungs `catalog_query` lists as capable for the role, written `backend:model#effort`.
68
- - An unscored model can be enabled only once it has a "treat like <scored rung>". There is no tool for that: give the user the command to run in a terminal, `catherd catalog treat-like <rung> <scored rung>`, then come back and propose again.
68
+ - Offer only the rungs `catherd catalog list` shows as capable for the role, written `backend:model#effort`.
69
+ - Offer only the indexed pairs `catherd catalog list` shows. A model or effort the Slopalytics index does not list is not offered, and a rung that names one is an error: if the user wants it, say it is not indexed yet and propose the nearest indexed pair. Never pick a worker rung below `#medium`. Use `maxEffort` to keep a model from its highest efforts, and `bars` to move a difficulty's bar for one role, rather than removing rungs.
69
70
 
70
- **Access.** Each role runs `read-only`, `workspace-write` or `full`. The defaults: architect, reviewer and researcher `read-only`; worker, writer and artist `workspace-write`; verifier and UI reviewer `full`. `profile_get` says per role whether its backend holds it to that mode (`enforced`: Codex's sandbox) or only asks (`advisory`: claude-code, opencode and native subagents, where the model can still reach past it). Recommend the defaults; when the user wants a role tighter or looser, say what it can no longer do (a read-only reviewer on claude-code or opencode has no shell, so it cannot run `git diff`) and that `profile_validate` will warn about it. A `workspace-write` role also writes catherd's lock dir and the temp dir, reaches the network, binds loopback ports and talks to a local Docker socket, so it runs its own installs and tests; `roles.<role>.network: false` takes the network, loopback and Docker away from that role (Codex enforces it; claude-code drops its web tools; opencode has no sandbox to enforce it). `catherd doctor` probes each of these per backend.
71
+ **Access.** Each role runs `read-only`, `workspace-write` or `full`. The defaults: architect, reviewer and researcher `read-only`; worker, writer and artist `workspace-write`; verifier and UI reviewer `full`. `profile({ action: "get" })` says per role whether its backend holds it to that mode (`enforced`: Codex's sandbox) or only asks (`advisory`: claude-code, opencode and native subagents, where the model can still reach past it). Recommend the defaults; when the user wants a role tighter or looser, say what it can no longer do (a read-only reviewer on claude-code or opencode has no shell, so it cannot run `git diff`) and that `profile({ action: "validate" })` will warn about it. A `workspace-write` role also writes catherd's lock dir and the temp dir, reaches the network, binds loopback ports and talks to a local Docker socket, so it runs its own installs and tests; `roles.<role>.network: false` takes the network, loopback and Docker away from that role (Codex enforces it; claude-code drops its web tools; opencode has no sandbox to enforce it). `catherd doctor` probes each of these per backend.
71
72
 
72
- **Failover.** `failover` maps a rung to its stand-in when that rung's backend hits a usage limit. A stand-in must be scored and on another quota (Go and Zen bill apart; native `claude` and `claude-code` share the Claude plan). The default profile fails a Codex rung over only to a stand-in that clears the same bars at least as well: Go's GPT-6 Luna for Luna high, and Kimi K3 (its scores borrowed from Sol medium) for Sol medium. Sol high and xhigh have none, so a limit there pauses the lane rather than dropping it a tier. Say so, and offer to change it when they have no Go subscription. `null` removes an entry.
73
+ **Failover.** `failover` maps a rung to its stand-in when that rung's backend hits a usage limit. A stand-in must be indexed, on another quota and at least as intelligent as its rung (Go and Zen bill apart; native `claude` and `claude-code` share the Claude plan). The default profile fails a Codex rung over only to an indexed stand-in at least as intelligent: Go's GPT-6 Luna for Luna high, and Kimi K3 for Sol medium. Sol high and xhigh have none in the profile. Beyond the profile's stand-ins, the daemon moves a unit that hit a limit to the nearest indexed rung, on a free quota, of any backend they have configured that is not weaker (a Claude rung last); when none qualifies, the lane waits for the hold rather than dropping a tier. Say so, and offer to change the profile's stand-ins when they have no Go subscription. `null` removes an entry.
73
74
 
74
- **Budget and timeouts.** `budget` (`minutes`, `tokens`, `usd`) is a soft cap: from 80 % routing starts at the cheapest rung that clears the bar, and at 100 % no new role starts. `timeouts.idleMin` (15) stops a role that has gone quiet, `timeouts.wallMin` (90) one that runs too long. `preflight.confirm: true` makes `preflight` show its commands for the user to approve first.
75
+ **Budget and timeouts.** `budget` (`minutes`, `tokens`, `usd`) is a soft cap: from 80 % routing starts at the cheapest rung that clears the bar, and at 100 % no new role starts. `timeouts.idleMin` (15) stops a role that has gone quiet, `timeouts.wallMin` (90) one that runs too long; `roles.<role>.timeouts.idleMin` and `wallMin` override them for one role (a verifier with a long gate), and `null` removes the override. `preflight.confirm: true` makes `preflight` show its commands for the user to approve first.
75
76
 
76
- **Notifications and readiness.** `notify` controls milestone, finish and blocked moments through whatever notification facility the host actually exposes; Claude Code may have `PushNotification`. Do not invent a Codex tool or a scheduling promise. Completion uses Claude's peer inbox or Codex's existing native queue (`--remote unix://`); a Codex busy session receives ordered next input after its active turn, not urgent next-tool-round delivery. Queue acceptance proves neither processing nor `result` collection; unloaded/interrupted sessions may retain input. `catherd doctor --host codex` checks capability without sending; only explicit `--test-push` sends a labeled smoke input. Use the orchestration skill's `peek`/`result` recovery and current-owner, exact-event `runs retry-push` decision for ambiguity.
77
+ **Notifications.** `notify` controls the milestone, finish and blocked moments. Where a parked question reaches the owner is `notify.url`, an ntfy topic url: set it with `profile({ action: "set", notify_url })` (ask them for the url; never invent one). The daemon sends to it from the machine, so a question reaches the phone with no session open. `catherd doctor --test-push` sends a labeled test notice.
77
78
 
78
- **Harness isolation.** For each harness they use (`codex`, `claude-code`, `opencode`, `cursor`, `grok`, `antigravity`), offer `harness.<name>.isolated` with its harness line from `runs_summary` (Codex has none: it reports no per-request input, so say there is no figure for it instead of offering one) and this tradeoff: "native keeps your hooks, skills and AGENTS.md; isolated saves ~N tokens per run, but the role loses them." Recommend native. When they have no isolated runs yet, the number is the median first-turn input of their native runs: say that isolation would save some part of it, not all of it. When there are no runs at all, say there is no number yet, and recommend native until there is.
79
+ **Harness isolation.** For each harness they use (`codex`, `claude-code`, `opencode`, `cursor`), offer `harness.<name>.isolated` and this tradeoff: "native keeps your hooks, skills and AGENTS.md; isolated saves some tokens per run, but the role loses them." Recommend native. The session reads no harness line, so quote no number. Codex reports no per-request input, so it has no harness figure (Codex has none: it reports no per-request input).
79
80
 
80
81
  ## 4. Write it
81
82
 
82
- - Call `profile_set({ repo, patch })` with only what changed; pass `name` only to edit a profile other than the one this repo runs on (a name that does not exist yet starts a new profile from the default one). Lists (`rungs`, `notify`) replace, maps (`billing`, `failover`, `budget`) merge, and `null` removes a key. A key it does not know is refused with `E_INPUT_INVALID`. It validates before it writes:
83
+ - Call `profile({ action: "set", repo, patch })` with only what changed; pass `name` only to edit a profile other than the one this repo runs on (a name that does not exist yet starts a new profile from the default one). Lists (`rungs`, `notify`) replace, maps (`billing`, `failover`, `budget`) merge, and `null` removes a key. A key it does not know is refused with `E_INPUT_INVALID`. It validates before it writes:
83
84
  - `saved: false` comes with `errors`, each with a `path`, a `message` and often a `fix`. Explain each in their terms, fix the patch, and propose again.
84
85
  - `saved: true` comes with the `diff` (`path`, `before`, `after`) and any `warnings`. Read the diff back to the user, one line per change, and each warning with it.
85
- - Then call `profile_validate({ repo })`. `errors` block a save: the worker disabled, an enabled role with no usable rung, an unscored rung without a "treat like", a failover stand-in unscored or on the same quota, a backend catherd cannot run. `warnings` do not: an access mode other than the role's default, a model the backend's listing lacks, a stand-in that never runs, a stand-in that scores below its rung ("downgrade"), a Claude stand-in while another plan could stand in ("spends Claude quota"), a ladder whose rung scores below the one before it ("the ladder goes down"). Each has a `fix`; offer it.
86
+ - Then call `profile({ action: "validate", repo })`. `errors` block a save: the worker disabled, an enabled role with no usable rung, a rung or failover stand-in the index does not list ("has no Slopalytics intelligence index"), a failover stand-in on the same quota, a backend catherd cannot run. `warnings` do not: an access mode other than the role's default, a model the backend's listing lacks, a stand-in that never runs, a stand-in less intelligent than its rung ("downgrade"), a Claude stand-in while another plan could stand in ("spends Claude quota"), a ladder whose rung is less intelligent than the one before it ("the ladder goes down"). Each has a `fix`; offer it.
86
87
 
87
88
  ## 5. Say what applies when
88
89
 
89
- - Codex, claude-code, opencode, Cursor, grok and Antigravity changes, access and isolation included, apply at the next dispatch, even in a run already under way. Isolating Cursor needs `CURSOR_API_KEY` in the environment catherd runs in, isolating grok `XAI_API_KEY`, and isolating Antigravity `GEMINI_API_KEY`; `profile_validate` refuses each without. A read-only role (reviewer, architect, researcher) can run on Antigravity only isolated: agy has no read-only mode.
90
- - For native Claude roles, an agent listed in `newSessionNeededFor` applies from the next Claude Code session: Claude Code reads agent files when a session starts. Other Claude changes apply now. `record_agent_run` accounts only for native Claude Agent results on Claude Code; process records are automatic.
90
+ - Rung and ladder changes apply at the next dispatch, even in a run already under way. Access and isolation are pinned per run when it starts: a run under way keeps them until it is re-pinned (`catherd runs pin <run>`). Isolating Cursor needs `CURSOR_API_KEY` in the environment catherd runs in; `profile` validation refuses it without.
91
+ - Every role runs headless, so no agent file needs a new session: a change applies at the next dispatch. `newSessionNeededFor` stays empty unless a native Claude agent file is linked.
91
92
  - ProfileService manages Claude agent files/links only when native Claude roles are used. Codex-only setup and profile operations do not write under `~/.claude`; Claude CLI/login is needed only by an enabled selected role or reachable failover that uses it. Editing an inactive Claude-dependent profile writes its managed files but links none; they apply once active or repo-bound. Keep role-disabled, access, isolation, budget and failover choices intact.
@@ -1,8 +1,6 @@
1
- import { antigravityAdapter } from "./antigravity/index.ts";
2
1
  import { claudeCodeAdapter } from "./claude-code/index.ts";
3
2
  import { codexAdapter } from "./codex/index.ts";
4
3
  import { cursorAdapter } from "./cursor/index.ts";
5
- import { grokAdapter } from "./grok/index.ts";
6
4
  import { opencodeAdapter } from "./opencode/index.ts";
7
5
  import { registerAdapter } from "./registry.ts";
8
6
 
@@ -10,5 +8,3 @@ registerAdapter(codexAdapter);
10
8
  registerAdapter(claudeCodeAdapter);
11
9
  registerAdapter(opencodeAdapter);
12
10
  registerAdapter(cursorAdapter);
13
- registerAdapter(grokAdapter);
14
- registerAdapter(antigravityAdapter);
@@ -3,6 +3,7 @@ import type { ADAPTER_IDS, Rung } from "../domain/ids.ts";
3
3
  import type { BillingMode } from "../domain/cost.ts";
4
4
  import type { Access, ExitInfo, RunStatus, Tokens } from "../domain/record.ts";
5
5
  import type { CliResult } from "./cli.ts";
6
+ import type { RoleMcpContext } from "../domain/role-tools.ts";
6
7
  type AdapterId = (typeof ADAPTER_IDS)[number];
7
8
 
8
9
  export interface Probe {
@@ -43,6 +44,10 @@ export interface DiscoveredModel {
43
44
  export interface RunRequest {
44
45
  rung: Rung;
45
46
  access: Access;
47
+ /** Native catherd roles receive a dedicated, run-bound control-plane server. */
48
+ roleMcp?: RoleMcpContext;
49
+ /** spec 1.5 plan 21: the role's TMPDIR (`<run>/scratch/<name>`), a write root besides the repo */
50
+ scratch?: string;
46
51
  /** spec §5: a workspace-write role's network and loopback grants; false only when the profile says `network: false` */
47
52
  network?: boolean;
48
53
  thread: string | null;
@@ -82,6 +87,11 @@ export interface EventDelta {
82
87
  limit?: boolean;
83
88
  tooOld?: boolean;
84
89
  retrying?: boolean;
90
+ /**
91
+ * plan 23: a model step started (opencode's step_start). Two in a row with nothing between are a provider retry,
92
+ * which the supervisor never counts as progress
93
+ */
94
+ step?: boolean;
85
95
  /** the stream's terminal event: the supervisor may kill a CLI that lingers after it */
86
96
  final?: boolean;
87
97
  /** a tool call starting (`open`) or ending: while one is open the run is busy, however quiet */
@@ -147,14 +157,20 @@ export interface BackendAdapter {
147
157
  interrupt?(thread: string, cwd: string): Promise<void>;
148
158
  /** `sinceMs`: when this run started, so what an earlier run on the thread left behind does not count */
149
159
  isBusy?(thread: string, cwd: string, sinceMs?: number): Promise<boolean>;
160
+ /**
161
+ * Plan 23: the provider retry the session is waiting out, by its attempt number, when its newest message since
162
+ * `sinceMs` is retrying (a 503, an overloaded backend); null when it is not
163
+ */
164
+ providerRetry?(thread: string, cwd: string, sinceMs: number): Promise<number | null>;
150
165
  /** Spec §4.5: this backend's own stand-in for a rung on a usage limit, when the profile names none. */
151
166
  failoverFor?(rung: Rung, repo?: string): Rung | null;
152
167
  /**
153
168
  * Spec §5 and §12: a shell that runs a command the way this backend's workspace-write worker runs one,
154
169
  * with the grants the worker gets, for doctor's access probes; a string says why it cannot be tested here.
155
- * Absent: the CLI has no way to run a shell in its sandbox without a model turn (spec 1.3 §3.4).
170
+ * Absent: the CLI has no way to run a shell in its sandbox without a model turn (spec 1.3 §3.4). `repos`: the
171
+ * repositories workers run in (doctor's own and every bound one), for a backend whose sandbox is set per repo.
156
172
  */
157
- accessShell?(o: { network: boolean }): Promise<AccessShell | string>;
173
+ accessShell?(o: { network: boolean; repos?: string[] }): Promise<AccessShell | string>;
158
174
  /** Spec §10.3: why this backend's isolation is weak; doctor warns when a profile uses it. */
159
175
  isolationNote?: string;
160
176
  /**
@@ -163,8 +179,7 @@ export interface BackendAdapter {
163
179
  */
164
180
  isolationKey?: string;
165
181
  /**
166
- * Spec 1.3 §9 Q2: the access modes this backend holds a role to only when isolated (agy has no read-only flag;
167
- * its deny rules live in the settings catherd writes in its own home). A native role at one does not validate.
182
+ * Spec 1.3 §9 Q2: the access modes this backend holds a role to only when isolated (one with no read-only flag). A native role at one does not validate.
168
183
  */
169
184
  isolatedOnly?: Access[];
170
185
  /** Spec 1.3 §6.6: the plan quota left, in the CLI's words, read without spending a model turn (doctor's row). */
@@ -16,6 +16,8 @@ import {
16
16
  import { readFileSync } from "node:fs";
17
17
  import { join } from "node:path";
18
18
  import { claudeHome } from "../../infra/paths.ts";
19
+ import { ROLE_MCP_SERVER, roleMcpTools } from "../../domain/role-tools.ts";
20
+ import { roleMcpConfig } from "../../infra/role-mcp.ts";
19
21
  import { dockerSocket, scratchShell, writableRoots } from "../access.ts";
20
22
  import { jsonOf, runCli } from "../cli.ts";
21
23
  import {
@@ -74,15 +76,21 @@ export const CLAUDE_ACCESS: Record<Access, string[]> = {
74
76
  * them Docker: the socket and `docker *` are network grants) and sets `allowLocalBinding: false`, so the
75
77
  * user's own `true` does not carry over (their allowedDomains and other array grants merge in and stay;
76
78
  * doctor says `network: false` is not enforced by claude-code's shell). With the user's sandbox on, `enabled: true`
77
- * goes in too, so a merge that replaces the whole `sandbox` object cannot turn it off.
79
+ * goes in too, so a merge that replaces the whole `sandbox` object cannot turn it off. A `repo` of null reads the
80
+ * user's settings only: a run that drops the project's settings files (`--setting-sources ""`).
78
81
  */
79
- export function claudeAccessArgs(access: Access, network = true, repo?: string): string[] {
82
+ export function claudeAccessArgs(
83
+ access: Access,
84
+ network = true,
85
+ repo?: string | null,
86
+ extra: string[] = [],
87
+ ): string[] {
80
88
  const base = CLAUDE_ACCESS[access];
81
89
  if (access !== "workspace-write") return base;
82
90
  const sock = dockerSocket();
83
91
  const sandbox = {
84
92
  ...(claudeSandboxOn(repo) ? { enabled: true } : {}),
85
- filesystem: { allowWrite: writableRoots() },
93
+ filesystem: { allowWrite: [...new Set([...writableRoots(), ...extra])] },
86
94
  ...(network
87
95
  ? {
88
96
  network: { allowLocalBinding: true, ...(sock ? { allowUnixSockets: [sock] } : {}) },
@@ -113,12 +121,14 @@ function sandboxEnabledIn(file: string): boolean | undefined {
113
121
  * Whether Claude Code's Bash sandbox is on for a worker in `repo` (`sandbox.enabled`): the most specific
114
122
  * settings file that says wins, as Claude Code layers them: the user's settings.json, then the project's
115
123
  * .claude/settings.json and .claude/settings.local.json (Claude Code has no user-level settings.local.json).
124
+ * A `repo` of null reads the user's settings.json only.
116
125
  */
117
- export function claudeSandboxOn(repo: string = process.cwd()): boolean {
126
+ export function claudeSandboxOn(repo: string | null = process.cwd()): boolean {
118
127
  const files = [
119
128
  join(claudeHome(), "settings.json"),
120
- join(repo, ".claude", "settings.json"),
121
- join(repo, ".claude", "settings.local.json"),
129
+ ...(repo === null
130
+ ? []
131
+ : [join(repo, ".claude", "settings.json"), join(repo, ".claude", "settings.local.json")]),
122
132
  ];
123
133
  return files.map(sandboxEnabledIn).findLast((on) => on !== undefined) ?? false;
124
134
  }
@@ -128,17 +138,114 @@ export function claudeSandboxOn(repo: string = process.cwd()): boolean {
128
138
  * shell, which doctor probes as is. With it on, only a model turn runs inside it, so doctor says what to
129
139
  * check instead of spending one.
130
140
  */
131
- async function accessShell(): Promise<AccessShell | string> {
132
- if (claudeSandboxOn())
133
- return "Claude Code's own sandbox is on (sandbox.enabled): catherd passes the lock, temp, loopback and Docker grants in --settings; outbound HTTPS reaches only sandbox.network.allowedDomains, so add registry.npmjs.org and the hosts your checks need there";
141
+ async function accessShell(o: { repos?: string[] } = {}): Promise<AccessShell | string> {
142
+ // the setting is per repo (its .claude/settings*.json over the user's): each repo a worker runs in counts,
143
+ // not only the directory doctor runs in
144
+ const repos = o.repos?.length ? o.repos : [process.cwd()];
145
+ const on = repos.filter((r) => claudeSandboxOn(r));
146
+ if (on.length)
147
+ return `Claude Code's own sandbox is on (sandbox.enabled)${o.repos?.length ? ` in ${on.join(", ")}` : ""}: catherd passes the lock, temp, loopback and Docker grants in --settings; outbound HTTPS reaches only sandbox.network.allowedDomains, so add registry.npmjs.org and the hosts your checks need there`;
134
148
  return scratchShell("an unsandboxed shell (Claude Code's sandbox is off)", []);
135
149
  }
136
150
 
151
+ /**
152
+ * An isolated run without the user's customizations. --bare would also drop OAuth, so a Claude plan could not
153
+ * log in; --safe-mode keeps auth, but drops every --mcp-config server too (Claude Code 2.1.287: "--mcp-config:
154
+ * … ignored (safe mode)"). A run with the role server (spec 1.5 plan 21, #42 finding 1) gets the same isolation
155
+ * piece by piece instead: only the --mcp-config servers, no settings file (so no hooks, no enabled plugins), no
156
+ * skills, CLAUDE.md and auto-memory off through the env, and the user's auth, provider, model, deny rules and
157
+ * allowed domains carried into --settings (carriedUserSettings).
158
+ */
159
+ /** The user settings keys --setting-sources "" would drop that a run needs: auth, provider and model. */
160
+ const CARRIED_SETTINGS = [
161
+ "apiKeyHelper",
162
+ "env",
163
+ "awsAuthRefresh",
164
+ "awsCredentialExport",
165
+ "gcpAuthRefresh",
166
+ "model",
167
+ ] as const;
168
+
169
+ /**
170
+ * What an isolated run with the role server keeps of the user's settings.json (plan 21 review, finding 1):
171
+ * --safe-mode keeps the settings files and drops only customizations, while `--setting-sources ""` drops the
172
+ * files, so a Bedrock, Vertex, gateway or apiKeyHelper login would fail. Carried: the auth and provider keys,
173
+ * `model`, `permissions.deny` and `sandbox.network`; never hooks, plugins, allow rules or the rest.
174
+ */
175
+ function carriedUserSettings(): Record<string, unknown> {
176
+ let user: Record<string, any>;
177
+ try {
178
+ user = JSON.parse(readFileSync(join(claudeHome(), "settings.json"), "utf8"));
179
+ } catch {
180
+ return {};
181
+ }
182
+ if (!user || typeof user !== "object") return {};
183
+ const out: Record<string, unknown> = {};
184
+ for (const k of CARRIED_SETTINGS) if (user[k] !== undefined) out[k] = user[k];
185
+ const deny = user.permissions?.deny;
186
+ if (Array.isArray(deny) && deny.length) out.permissions = { deny };
187
+ const network = user.sandbox?.network;
188
+ if (network && typeof network === "object") out.sandbox = { network };
189
+ return out;
190
+ }
191
+
192
+ /** `--settings` with the user's carried keys merged under catherd's own: catherd's sandbox grants win. */
193
+ function withCarriedSettings(args: string[]): string[] {
194
+ const carried = carriedUserSettings();
195
+ if (!Object.keys(carried).length) return args;
196
+ const at = args.indexOf("--settings");
197
+ const own: Record<string, any> = at >= 0 ? JSON.parse(args[at + 1] as string) : {};
198
+ const userNet: Record<string, unknown> = (carried.sandbox as any)?.network ?? {};
199
+ const ownNet: Record<string, unknown> = own.sandbox?.network ?? {};
200
+ const sockets = [
201
+ ...((userNet.allowUnixSockets as string[] | undefined) ?? []),
202
+ ...((ownNet.allowUnixSockets as string[] | undefined) ?? []),
203
+ ];
204
+ const sandbox =
205
+ carried.sandbox || own.sandbox
206
+ ? {
207
+ sandbox: {
208
+ ...own.sandbox,
209
+ network: {
210
+ ...userNet,
211
+ ...ownNet,
212
+ ...(sockets.length ? { allowUnixSockets: [...new Set(sockets)] } : {}),
213
+ },
214
+ },
215
+ }
216
+ : {};
217
+ const json = JSON.stringify({ ...carried, ...own, ...sandbox });
218
+ if (at < 0) return [...args, "--settings", json];
219
+ const out = [...args];
220
+ out[at + 1] = json;
221
+ return out;
222
+ }
223
+
224
+ function isolationArgs(r: RunRequest): string[] {
225
+ if (!r.roleMcp) return ["--safe-mode"];
226
+ return ["--strict-mcp-config", "--setting-sources", "", "--disable-slash-commands"];
227
+ }
228
+
137
229
  function plan(r: RunRequest): SpawnPlan {
138
230
  if (r.thread !== null && !THREAD.test(r.thread))
139
231
  throw new CatherdError("E_ADMIT_THREAD", `"${r.thread}" is not a Claude Code session id`, {
140
232
  fix: "pass the thread from the earlier RunRecord",
141
233
  });
234
+ // isolated with the role server, `--setting-sources ""` drops the project's settings (its network grants too),
235
+ // so only the user's carried settings.json decides whether the sandbox is on (PR #46)
236
+ const carried = r.isolated && !!r.roleMcp;
237
+ const access = claudeAccessArgs(r.access, r.network, carried ? null : r.repo, r.scratch ? [r.scratch] : []);
238
+ const accessArgs = carried ? withCarriedSettings(access) : [...access];
239
+ if (r.roleMcp) {
240
+ const tools = roleMcpTools(r.roleMcp.role).map((tool) => `mcp__${ROLE_MCP_SERVER}__${tool}`);
241
+ const allowed = accessArgs.indexOf("--allowedTools");
242
+ if (allowed >= 0) accessArgs[allowed + 1] = [accessArgs[allowed + 1], ...tools].join(",");
243
+ else accessArgs.push("--allowedTools", tools.join(","));
244
+ accessArgs.push(
245
+ "--mcp-config",
246
+ JSON.stringify({ mcpServers: { [ROLE_MCP_SERVER]: roleMcpConfig(r.roleMcp) } }),
247
+ );
248
+ }
142
249
  return {
143
250
  cmd: "claude",
144
251
  args: [
@@ -154,11 +261,14 @@ function plan(r: RunRequest): SpawnPlan {
154
261
  ...(r.thread === null ? ["--session-id", crypto.randomUUID()] : ["--resume", r.thread]),
155
262
  "--permission-prompts",
156
263
  "none",
157
- ...claudeAccessArgs(r.access, r.network, r.repo),
158
- // --bare would also drop OAuth, so a Claude plan could not log in; --safe-mode keeps auth
159
- ...(r.isolated ? ["--safe-mode"] : []),
264
+ ...accessArgs,
265
+ ...(r.isolated ? isolationArgs(r) : []),
160
266
  ],
161
- env: {},
267
+ // CLAUDE.md and auto-memory off, as --safe-mode turns them off (spec 1.5 plan 21)
268
+ env:
269
+ r.isolated && r.roleMcp
270
+ ? { CLAUDE_CODE_DISABLE_CLAUDE_MDS: "1", CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" }
271
+ : {},
162
272
  cwd: r.repo,
163
273
  stdinPath: r.briefPath,
164
274
  };
@@ -232,7 +342,9 @@ function claudeActivity(e: Record<string, any>): string | undefined {
232
342
  if (typeof input.command === "string") return `$ ${input.command}`;
233
343
  if (typeof input.file_path === "string")
234
344
  return `${EDIT_TOOLS.has(c.name) ? "edit" : String(c.name)} ${input.file_path}`;
235
- return String(c.name ?? "tool");
345
+ // another tool shows its first string argument, as opencode's activity does
346
+ const first = Object.values(input).find((v) => typeof v === "string");
347
+ return `${String(c.name ?? "tool")}${typeof first === "string" ? ` ${first}` : ""}`;
236
348
  }
237
349
  if (c?.type === "text" && typeof c.text === "string") return c.text;
238
350
  return undefined;
@@ -8,6 +8,8 @@ export interface CodexFold {
8
8
  limit: boolean;
9
9
  tooOld: boolean;
10
10
  lastEvent: string | null;
11
+ /** plan 22: the agent message that ended each completed turn, in order */
12
+ finals: string[];
11
13
  }
12
14
 
13
15
  /**
@@ -43,10 +45,18 @@ export function foldCodexEvents(lines: string[]): CodexFold {
43
45
  limit: false,
44
46
  tooOld: false,
45
47
  lastEvent: null,
48
+ finals: [],
46
49
  };
50
+ let said: string | null = null;
47
51
  for (const line of lines) {
48
52
  const e = parseCodexLine(line);
49
53
  if (!e) continue;
54
+ if (e.type === "item.completed" && e.item?.type === "agent_message" && typeof e.item.text === "string")
55
+ said = e.item.text;
56
+ if (e.type === "turn.completed" && said !== null) {
57
+ f.finals.push(said);
58
+ said = null;
59
+ }
50
60
  f.lastEvent = e.item?.type ? `${e.type}/${e.item.type}` : e.type;
51
61
  const msg: string = e.message ?? e.error?.message ?? e.item?.message ?? "";
52
62
  if (CODEX_TOO_OLD.some((r) => r.test(msg))) f.tooOld = true;
@@ -1,7 +1,9 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
+ import { codexRoleMcpArgs } from "../../infra/role-mcp.ts";
3
4
  import { CatherdError } from "../../domain/errors.ts";
4
5
  import type { Access, RunStatus } from "../../domain/record.ts";
6
+ import { composeReply } from "../../domain/reply.ts";
5
7
  import {
6
8
  type AccessShell,
7
9
  type BackendAdapter,
@@ -57,9 +59,14 @@ export function userWritableRoots(): string[] {
57
59
  * The same `-c` overrides go to `codex sandbox` in doctor's probes, so doctor tests exactly what a worker gets. `-c …writable_roots=` replaces the
58
60
  * user's own roots, so theirs go in too; an isolated run ignores the user's config, so it has none.
59
61
  */
60
- export function codexGrants(access: Access, network = true, isolated = false): string[] {
62
+ export function codexGrants(
63
+ access: Access,
64
+ network = true,
65
+ isolated = false,
66
+ extra: string[] = [],
67
+ ): string[] {
61
68
  if (access !== "workspace-write") return [];
62
- const roots = [...new Set([...(isolated ? [] : userWritableRoots()), ...writableRoots()])];
69
+ const roots = [...new Set([...(isolated ? [] : userWritableRoots()), ...writableRoots(), ...extra])];
63
70
  return [
64
71
  "-c",
65
72
  `sandbox_workspace_write.network_access=${network}`,
@@ -89,7 +96,8 @@ function plan(r: RunRequest): SpawnPlan {
89
96
  "--json",
90
97
  "-o",
91
98
  r.replyPath,
92
- ...codexGrants(r.access, r.network, r.isolated),
99
+ ...codexGrants(r.access, r.network, r.isolated, r.scratch ? [r.scratch] : []),
100
+ ...(r.roleMcp ? codexRoleMcpArgs(r.roleMcp) : []),
93
101
  ];
94
102
  const sandbox = SANDBOX[r.access];
95
103
  const args =
@@ -125,6 +133,7 @@ function finalize(run: FinishedRun): Outcome {
125
133
  : "ok";
126
134
  const lastErr = run.stderr.trim().split("\n").at(-1) ?? "";
127
135
  const home = run.request.isolated ? isolatedCodexHomePath() : userCodexHome();
136
+ const reply = composeReply(f.finals, run.reply);
128
137
  return {
129
138
  status,
130
139
  thread: f.thread ?? run.request.thread,
@@ -138,6 +147,8 @@ function finalize(run: FinishedRun): Outcome {
138
147
  code: status,
139
148
  message: f.failure ?? (lastErr || `${stopped}, exit ${run.exit.code ?? run.exit.signal}`),
140
149
  },
150
+ // plan 22: -o keeps the last turn's message; a later turn never overwrites the report
151
+ ...(reply !== run.reply ? { reply } : {}),
141
152
  };
142
153
  }
143
154
 
@@ -243,7 +254,7 @@ function codexActivity(e: Record<string, any>): string | undefined {
243
254
  return `edit ${it.changes
244
255
  .map((c: { path?: unknown }) => c.path)
245
256
  .filter((p: unknown) => typeof p === "string")
246
- .join(", ")}`;
257
+ .join(", ")}`.trimEnd();
247
258
  if (it.type === "agent_message" && typeof it.text === "string") return it.text;
248
259
  return undefined;
249
260
  }
@@ -263,12 +274,13 @@ export const codexAdapter: BackendAdapter = {
263
274
  // Not a todo_list: update_plan opens one that only completes with the turn, and would mute the watchdog
264
275
  const id = typeof e.item?.id === "string" && CODEX_TOOL_ITEMS.has(e.item.type) ? e.item.id : null;
265
276
  const open = e.type === "item.started" ? true : e.type === "item.completed" ? false : null;
277
+ const activity = codexActivity(e);
266
278
  return {
267
279
  ...(f.thread ? { thread: f.thread } : {}),
268
280
  ...(id !== null && open !== null ? { item: { id, open } } : {}),
269
281
  ...(e.type === "turn.completed" ? { tokens: f.tokens } : {}),
270
282
  lastEvent: f.lastEvent ?? undefined,
271
- ...(codexActivity(e) ? { activity: codexActivity(e) } : {}),
283
+ ...(activity ? { activity } : {}),
272
284
  ...(f.turnFailed ? { failure: f.failure ?? "turn failed" } : {}),
273
285
  ...(f.limit ? { limit: true } : {}),
274
286
  ...(f.tooOld ? { tooOld: true } : {}),
@@ -18,7 +18,7 @@ export const isolatedCursorHome = (access: Access, network = true): string =>
18
18
 
19
19
  /**
20
20
  * The env of an isolated run: the moved HOME (the only thing that stops Cursor's hard-coded `~/.claude`,
21
- * `~/.codex`, `~/.grok` and `~/.agents` reads, research §2.8), and Cursor's config and data dirs inside it, so a
21
+ * `~/.codex` and `~/.agents` reads, research §2.8), and Cursor's config and data dirs inside it, so a
22
22
  * CURSOR_CONFIG_DIR or XDG_CONFIG_HOME of the user's cannot point it back. Its credentials stay in memory: on
23
23
  * macOS Cursor otherwise saves the CURSOR_API_KEY login to the moved HOME's keychain, which does not exist, and
24
24
  * the failed `security` call raises a "Keychain Not Found" dialog.
@@ -39,7 +39,7 @@ export { isolatedCursorHome, isolatedCursorRoot } from "./home.ts";
39
39
  export const CURSOR_MIN_VERSION = "2026.09.28";
40
40
  export const CURSOR_INSTALL = "curl https://cursor.com/install -fsS | bash";
41
41
  const THREAD = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
42
- /** Cursor's versions are a date and a hash (`2026.09.28-64d2043`); grok's `agent` prints `grok 1.0.44 (…)`. */
42
+ /** Cursor's versions are a date and a hash (`2026.09.28-64d2043`). */
43
43
  const CURSOR_VERSION = /^\s*\d{4}\.\d{1,2}\.\d{1,2}-[0-9a-f]+\b/;
44
44
  const DAY_MS = 24 * 60 * 60_000;
45
45
  const LOGIN_FIX = "cursor-agent login, or export CURSOR_API_KEY=<key>";
@@ -50,7 +50,7 @@ export const cursorShell = { timeoutMs: 15_000 };
50
50
  const which = (bin: string): string | null => Bun.which(bin, { PATH: process.env.PATH ?? "" });
51
51
 
52
52
  /**
53
- * Spec 1.3 §4.1: `cursor-agent` first. The installers of Cursor and grok both link `agent` (research §2.1,
53
+ * Spec 1.3 §4.1: `cursor-agent` first. Another CLI's installer may also link `agent` (research §2.1,
54
54
  * §3.1), so `agent` is taken only when `cursor-agent` is missing, and the probe checks what it is.
55
55
  */
56
56
  export function cursorBin(): "cursor-agent" | "agent" {
@@ -100,7 +100,13 @@ function plan(r: RunRequest): SpawnPlan {
100
100
  }
101
101
 
102
102
  async function listModels(): Promise<DiscoveredModel[]> {
103
- const r = await runCli(cursorBin(), ["models"], { ...cursorShell, env: { NO_OPEN_BROWSER: "1" } });
103
+ const bin = cursorBin();
104
+ // an `agent` that is not Cursor's (another CLI's) is never asked for models: nothing to list, as when absent
105
+ if (bin === "agent") {
106
+ const v = await runCli(bin, ["--version"], cursorShell).catch(() => null);
107
+ if (!v || !CURSOR_VERSION.test(v.out)) return [];
108
+ }
109
+ const r = await runCli(bin, ["models"], { ...cursorShell, env: { NO_OPEN_BROWSER: "1" } });
104
110
  return r?.ok ? parseCursorModels(r.out) : [];
105
111
  }
106
112
 
@@ -213,7 +219,7 @@ async function probe(): Promise<Probe> {
213
219
  try {
214
220
  v = await runCli(bin, ["--version"], cursorShell);
215
221
  } catch (e) {
216
- // an `agent` that is not Cursor's may not even run here (the owner's is a Linux grok, research §3.1)
222
+ // an `agent` that is not Cursor's may not even run here (a Linux build on macOS, research §3.1)
217
223
  if (bin === "agent") v = { ok: false, out: "", err: String(e) };
218
224
  else throw e;
219
225
  }