opencastle 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (486) hide show
  1. package/README.md +16 -10
  2. package/bin/cli.mjs +8 -9
  3. package/dist/cli/agent-roster.test.js +0 -48
  4. package/dist/cli/agent-roster.test.js.map +1 -1
  5. package/dist/cli/boundary.test.js +9 -7
  6. package/dist/cli/boundary.test.js.map +1 -1
  7. package/dist/cli/convoy/artifacts.d.ts +9 -2
  8. package/dist/cli/convoy/artifacts.d.ts.map +1 -1
  9. package/dist/cli/convoy/artifacts.js +13 -10
  10. package/dist/cli/convoy/artifacts.js.map +1 -1
  11. package/dist/cli/convoy/artifacts.test.js +4 -2
  12. package/dist/cli/convoy/artifacts.test.js.map +1 -1
  13. package/dist/cli/convoy/engine.d.ts +53 -23
  14. package/dist/cli/convoy/engine.d.ts.map +1 -1
  15. package/dist/cli/convoy/engine.git.test.d.ts +2 -0
  16. package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
  17. package/dist/cli/convoy/engine.git.test.js +435 -0
  18. package/dist/cli/convoy/engine.git.test.js.map +1 -0
  19. package/dist/cli/convoy/engine.js +1746 -2305
  20. package/dist/cli/convoy/engine.js.map +1 -1
  21. package/dist/cli/convoy/engine.test.js +698 -678
  22. package/dist/cli/convoy/engine.test.js.map +1 -1
  23. package/dist/cli/convoy/event-schemas.d.ts +2 -0
  24. package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
  25. package/dist/cli/convoy/event-schemas.js +59 -57
  26. package/dist/cli/convoy/event-schemas.js.map +1 -1
  27. package/dist/cli/convoy/events.d.ts +4 -1
  28. package/dist/cli/convoy/events.d.ts.map +1 -1
  29. package/dist/cli/convoy/events.js +69 -84
  30. package/dist/cli/convoy/events.js.map +1 -1
  31. package/dist/cli/convoy/events.test.js +50 -9
  32. package/dist/cli/convoy/events.test.js.map +1 -1
  33. package/dist/cli/convoy/gates.d.ts +9 -4
  34. package/dist/cli/convoy/gates.d.ts.map +1 -1
  35. package/dist/cli/convoy/gates.js +29 -14
  36. package/dist/cli/convoy/gates.js.map +1 -1
  37. package/dist/cli/convoy/isolation.d.ts +32 -6
  38. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  39. package/dist/cli/convoy/isolation.js +72 -34
  40. package/dist/cli/convoy/isolation.js.map +1 -1
  41. package/dist/cli/convoy/isolation.test.js +66 -42
  42. package/dist/cli/convoy/isolation.test.js.map +1 -1
  43. package/dist/cli/convoy/lock.d.ts.map +1 -1
  44. package/dist/cli/convoy/lock.js +25 -10
  45. package/dist/cli/convoy/lock.js.map +1 -1
  46. package/dist/cli/convoy/lock.test.js +12 -0
  47. package/dist/cli/convoy/lock.test.js.map +1 -1
  48. package/dist/cli/convoy/merge.d.ts +21 -4
  49. package/dist/cli/convoy/merge.d.ts.map +1 -1
  50. package/dist/cli/convoy/merge.js +69 -53
  51. package/dist/cli/convoy/merge.js.map +1 -1
  52. package/dist/cli/convoy/merge.test.js +23 -1
  53. package/dist/cli/convoy/merge.test.js.map +1 -1
  54. package/dist/cli/convoy/progress.d.ts +35 -0
  55. package/dist/cli/convoy/progress.d.ts.map +1 -0
  56. package/dist/cli/convoy/progress.js +103 -0
  57. package/dist/cli/convoy/progress.js.map +1 -0
  58. package/dist/cli/convoy/progress.test.d.ts +2 -0
  59. package/dist/cli/convoy/progress.test.d.ts.map +1 -0
  60. package/dist/cli/convoy/progress.test.js +53 -0
  61. package/dist/cli/convoy/progress.test.js.map +1 -0
  62. package/dist/cli/convoy/read-model.d.ts +468 -0
  63. package/dist/cli/convoy/read-model.d.ts.map +1 -0
  64. package/dist/cli/convoy/read-model.js +1132 -0
  65. package/dist/cli/convoy/read-model.js.map +1 -0
  66. package/dist/cli/convoy/read-model.test.d.ts +2 -0
  67. package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
  68. package/dist/cli/convoy/read-model.test.js +609 -0
  69. package/dist/cli/convoy/read-model.test.js.map +1 -0
  70. package/dist/cli/convoy/redact.d.ts +34 -0
  71. package/dist/cli/convoy/redact.d.ts.map +1 -0
  72. package/dist/cli/convoy/redact.js +66 -0
  73. package/dist/cli/convoy/redact.js.map +1 -0
  74. package/dist/cli/convoy/redact.test.d.ts +2 -0
  75. package/dist/cli/convoy/redact.test.d.ts.map +1 -0
  76. package/dist/cli/convoy/redact.test.js +43 -0
  77. package/dist/cli/convoy/redact.test.js.map +1 -0
  78. package/dist/cli/convoy/reviewer.d.ts +65 -0
  79. package/dist/cli/convoy/reviewer.d.ts.map +1 -0
  80. package/dist/cli/convoy/reviewer.js +141 -0
  81. package/dist/cli/convoy/reviewer.js.map +1 -0
  82. package/dist/cli/convoy/reviewer.test.d.ts +2 -0
  83. package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
  84. package/dist/cli/convoy/reviewer.test.js +96 -0
  85. package/dist/cli/convoy/reviewer.test.js.map +1 -0
  86. package/dist/cli/convoy/schedule.d.ts +30 -0
  87. package/dist/cli/convoy/schedule.d.ts.map +1 -0
  88. package/dist/cli/convoy/schedule.js +111 -0
  89. package/dist/cli/convoy/schedule.js.map +1 -0
  90. package/dist/cli/convoy/schedule.test.d.ts +2 -0
  91. package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
  92. package/dist/cli/convoy/schedule.test.js +45 -0
  93. package/dist/cli/convoy/schedule.test.js.map +1 -0
  94. package/dist/cli/convoy/spec-builder.d.ts +120 -30
  95. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  96. package/dist/cli/convoy/spec-builder.js +438 -114
  97. package/dist/cli/convoy/spec-builder.js.map +1 -1
  98. package/dist/cli/convoy/spec-builder.test.js +419 -435
  99. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  100. package/dist/cli/convoy/spec-types.d.ts +46 -92
  101. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  102. package/dist/cli/convoy/store.d.ts +6 -1
  103. package/dist/cli/convoy/store.d.ts.map +1 -1
  104. package/dist/cli/convoy/store.js +111 -15
  105. package/dist/cli/convoy/store.js.map +1 -1
  106. package/dist/cli/convoy/store.test.js +59 -13
  107. package/dist/cli/convoy/store.test.js.map +1 -1
  108. package/dist/cli/convoy/types.d.ts +76 -113
  109. package/dist/cli/convoy/types.d.ts.map +1 -1
  110. package/dist/cli/convoy/types.js +6 -13
  111. package/dist/cli/convoy/types.js.map +1 -1
  112. package/dist/cli/convoy/worktree.d.ts +88 -3
  113. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  114. package/dist/cli/convoy/worktree.js +282 -56
  115. package/dist/cli/convoy/worktree.js.map +1 -1
  116. package/dist/cli/convoy/worktree.test.js +132 -1
  117. package/dist/cli/convoy/worktree.test.js.map +1 -1
  118. package/dist/cli/convoy-args.test.js +9 -27
  119. package/dist/cli/convoy-args.test.js.map +1 -1
  120. package/dist/cli/convoy-cmd.d.ts +31 -6
  121. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  122. package/dist/cli/convoy-cmd.js +150 -201
  123. package/dist/cli/convoy-cmd.js.map +1 -1
  124. package/dist/cli/convoy-cmd.test.d.ts +2 -0
  125. package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
  126. package/dist/cli/convoy-cmd.test.js +144 -0
  127. package/dist/cli/convoy-cmd.test.js.map +1 -0
  128. package/dist/cli/dashboard.d.ts +24 -11
  129. package/dist/cli/dashboard.d.ts.map +1 -1
  130. package/dist/cli/dashboard.js +241 -303
  131. package/dist/cli/dashboard.js.map +1 -1
  132. package/dist/cli/dashboard.test.d.ts +2 -0
  133. package/dist/cli/dashboard.test.d.ts.map +1 -0
  134. package/dist/cli/dashboard.test.js +340 -0
  135. package/dist/cli/dashboard.test.js.map +1 -0
  136. package/dist/cli/dispatcher.test.js +35 -2
  137. package/dist/cli/dispatcher.test.js.map +1 -1
  138. package/dist/cli/docs-accuracy.test.js +3 -3
  139. package/dist/cli/docs-accuracy.test.js.map +1 -1
  140. package/dist/cli/log.d.ts +39 -0
  141. package/dist/cli/log.d.ts.map +1 -1
  142. package/dist/cli/log.js +267 -93
  143. package/dist/cli/log.js.map +1 -1
  144. package/dist/cli/log.test.d.ts +2 -0
  145. package/dist/cli/log.test.d.ts.map +1 -0
  146. package/dist/cli/log.test.js +208 -0
  147. package/dist/cli/log.test.js.map +1 -0
  148. package/dist/cli/nearest.d.ts +18 -0
  149. package/dist/cli/nearest.d.ts.map +1 -0
  150. package/dist/cli/nearest.js +38 -0
  151. package/dist/cli/nearest.js.map +1 -0
  152. package/dist/cli/nearest.test.d.ts +2 -0
  153. package/dist/cli/nearest.test.d.ts.map +1 -0
  154. package/dist/cli/nearest.test.js +24 -0
  155. package/dist/cli/nearest.test.js.map +1 -0
  156. package/dist/cli/pipeline.d.ts +61 -0
  157. package/dist/cli/pipeline.d.ts.map +1 -1
  158. package/dist/cli/pipeline.flow.test.d.ts +2 -0
  159. package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
  160. package/dist/cli/pipeline.flow.test.js +524 -0
  161. package/dist/cli/pipeline.flow.test.js.map +1 -0
  162. package/dist/cli/pipeline.js +471 -690
  163. package/dist/cli/pipeline.js.map +1 -1
  164. package/dist/cli/plan.d.ts +82 -31
  165. package/dist/cli/plan.d.ts.map +1 -1
  166. package/dist/cli/plan.js +167 -507
  167. package/dist/cli/plan.js.map +1 -1
  168. package/dist/cli/plan.test.d.ts +2 -0
  169. package/dist/cli/plan.test.d.ts.map +1 -0
  170. package/dist/cli/plan.test.js +158 -0
  171. package/dist/cli/plan.test.js.map +1 -0
  172. package/dist/cli/run/adapters/agent-process.d.ts +82 -0
  173. package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
  174. package/dist/cli/run/adapters/agent-process.js +224 -0
  175. package/dist/cli/run/adapters/agent-process.js.map +1 -0
  176. package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
  177. package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
  178. package/dist/cli/run/adapters/agent-process.test.js +159 -0
  179. package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
  180. package/dist/cli/run/adapters/claude.d.ts +53 -2
  181. package/dist/cli/run/adapters/claude.d.ts.map +1 -1
  182. package/dist/cli/run/adapters/claude.js +147 -171
  183. package/dist/cli/run/adapters/claude.js.map +1 -1
  184. package/dist/cli/run/adapters/claude.test.js +197 -254
  185. package/dist/cli/run/adapters/claude.test.js.map +1 -1
  186. package/dist/cli/run/adapters/codex.d.ts +25 -2
  187. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  188. package/dist/cli/run/adapters/codex.js +113 -81
  189. package/dist/cli/run/adapters/codex.js.map +1 -1
  190. package/dist/cli/run/adapters/codex.test.js +116 -95
  191. package/dist/cli/run/adapters/codex.test.js.map +1 -1
  192. package/dist/cli/run/adapters/copilot.d.ts +35 -1
  193. package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
  194. package/dist/cli/run/adapters/copilot.js +104 -287
  195. package/dist/cli/run/adapters/copilot.js.map +1 -1
  196. package/dist/cli/run/adapters/copilot.test.js +122 -282
  197. package/dist/cli/run/adapters/copilot.test.js.map +1 -1
  198. package/dist/cli/run/adapters/cursor.d.ts +25 -7
  199. package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
  200. package/dist/cli/run/adapters/cursor.js +103 -156
  201. package/dist/cli/run/adapters/cursor.js.map +1 -1
  202. package/dist/cli/run/adapters/cursor.test.js +106 -218
  203. package/dist/cli/run/adapters/cursor.test.js.map +1 -1
  204. package/dist/cli/run/adapters/index.d.ts +34 -5
  205. package/dist/cli/run/adapters/index.d.ts.map +1 -1
  206. package/dist/cli/run/adapters/index.js +147 -21
  207. package/dist/cli/run/adapters/index.js.map +1 -1
  208. package/dist/cli/run/adapters/index.test.d.ts +2 -0
  209. package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
  210. package/dist/cli/run/adapters/index.test.js +129 -0
  211. package/dist/cli/run/adapters/index.test.js.map +1 -0
  212. package/dist/cli/run/adapters/opencode.d.ts +25 -9
  213. package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
  214. package/dist/cli/run/adapters/opencode.js +136 -152
  215. package/dist/cli/run/adapters/opencode.js.map +1 -1
  216. package/dist/cli/run/adapters/opencode.test.js +99 -218
  217. package/dist/cli/run/adapters/opencode.test.js.map +1 -1
  218. package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
  219. package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
  220. package/dist/cli/run/adapters/permission-modes.js +113 -37
  221. package/dist/cli/run/adapters/permission-modes.js.map +1 -1
  222. package/dist/cli/run/adapters/permission-modes.test.js +55 -40
  223. package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
  224. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
  225. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
  226. package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
  227. package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
  228. package/dist/cli/run/platform.d.ts +52 -0
  229. package/dist/cli/run/platform.d.ts.map +1 -0
  230. package/dist/cli/run/platform.js +207 -0
  231. package/dist/cli/run/platform.js.map +1 -0
  232. package/dist/cli/run/platform.test.d.ts +2 -0
  233. package/dist/cli/run/platform.test.d.ts.map +1 -0
  234. package/dist/cli/run/platform.test.js +119 -0
  235. package/dist/cli/run/platform.test.js.map +1 -0
  236. package/dist/cli/run/schema.d.ts +6 -8
  237. package/dist/cli/run/schema.d.ts.map +1 -1
  238. package/dist/cli/run/schema.js +44 -68
  239. package/dist/cli/run/schema.js.map +1 -1
  240. package/dist/cli/run/schema.test.js +59 -279
  241. package/dist/cli/run/schema.test.js.map +1 -1
  242. package/dist/cli/run.d.ts +34 -56
  243. package/dist/cli/run.d.ts.map +1 -1
  244. package/dist/cli/run.js +379 -1132
  245. package/dist/cli/run.js.map +1 -1
  246. package/dist/cli/run.test.d.ts +2 -0
  247. package/dist/cli/run.test.d.ts.map +1 -0
  248. package/dist/cli/run.test.js +318 -0
  249. package/dist/cli/run.test.js.map +1 -0
  250. package/dist/cli/team-config.d.ts.map +1 -1
  251. package/dist/cli/team-config.js +2 -21
  252. package/dist/cli/team-config.js.map +1 -1
  253. package/dist/cli/tiers.test.js +4 -13
  254. package/dist/cli/tiers.test.js.map +1 -1
  255. package/package.json +3 -10
  256. package/src/cli/agent-roster.test.ts +0 -55
  257. package/src/cli/boundary.test.ts +9 -7
  258. package/src/cli/convoy/TELEMETRY.md +131 -125
  259. package/src/cli/convoy/artifacts.test.ts +4 -2
  260. package/src/cli/convoy/artifacts.ts +13 -12
  261. package/src/cli/convoy/engine.git.test.ts +462 -0
  262. package/src/cli/convoy/engine.test.ts +817 -850
  263. package/src/cli/convoy/engine.ts +1864 -2596
  264. package/src/cli/convoy/event-schemas.ts +63 -59
  265. package/src/cli/convoy/events.test.ts +58 -9
  266. package/src/cli/convoy/events.ts +69 -91
  267. package/src/cli/convoy/gates.ts +31 -12
  268. package/src/cli/convoy/isolation.test.ts +76 -43
  269. package/src/cli/convoy/isolation.ts +100 -38
  270. package/src/cli/convoy/lock.test.ts +16 -0
  271. package/src/cli/convoy/lock.ts +25 -8
  272. package/src/cli/convoy/merge.test.ts +25 -1
  273. package/src/cli/convoy/merge.ts +74 -61
  274. package/src/cli/convoy/progress.test.ts +59 -0
  275. package/src/cli/convoy/progress.ts +121 -0
  276. package/src/cli/convoy/read-model.test.ts +685 -0
  277. package/src/cli/convoy/read-model.ts +1469 -0
  278. package/src/cli/convoy/redact.test.ts +49 -0
  279. package/src/cli/convoy/redact.ts +73 -0
  280. package/src/cli/convoy/reviewer.test.ts +112 -0
  281. package/src/cli/convoy/reviewer.ts +196 -0
  282. package/src/cli/convoy/schedule.test.ts +56 -0
  283. package/src/cli/convoy/schedule.ts +109 -0
  284. package/src/cli/convoy/spec-builder.test.ts +460 -464
  285. package/src/cli/convoy/spec-builder.ts +460 -129
  286. package/src/cli/convoy/spec-types.ts +46 -108
  287. package/src/cli/convoy/store.test.ts +64 -13
  288. package/src/cli/convoy/store.ts +143 -33
  289. package/src/cli/convoy/types.ts +59 -71
  290. package/src/cli/convoy/worktree.test.ts +140 -1
  291. package/src/cli/convoy/worktree.ts +311 -61
  292. package/src/cli/convoy-args.test.ts +10 -30
  293. package/src/cli/convoy-cmd.test.ts +163 -0
  294. package/src/cli/convoy-cmd.ts +173 -216
  295. package/src/cli/dashboard/dashboard.css +2086 -0
  296. package/src/cli/dashboard/dashboard.js +1687 -0
  297. package/src/cli/dashboard/index.html +307 -0
  298. package/src/cli/dashboard.test.ts +382 -0
  299. package/src/cli/dashboard.ts +243 -339
  300. package/src/cli/dispatcher.test.ts +36 -2
  301. package/src/cli/docs-accuracy.test.ts +3 -3
  302. package/src/cli/log.test.ts +228 -0
  303. package/src/cli/log.ts +302 -83
  304. package/src/cli/nearest.test.ts +27 -0
  305. package/src/cli/nearest.ts +38 -0
  306. package/src/cli/pipeline.flow.test.ts +607 -0
  307. package/src/cli/pipeline.ts +544 -759
  308. package/src/cli/plan.test.ts +193 -0
  309. package/src/cli/plan.ts +209 -545
  310. package/src/cli/run/adapters/agent-process.test.ts +175 -0
  311. package/src/cli/run/adapters/agent-process.ts +252 -0
  312. package/src/cli/run/adapters/claude.test.ts +205 -260
  313. package/src/cli/run/adapters/claude.ts +151 -162
  314. package/src/cli/run/adapters/codex.test.ts +120 -100
  315. package/src/cli/run/adapters/codex.ts +115 -91
  316. package/src/cli/run/adapters/copilot.test.ts +135 -306
  317. package/src/cli/run/adapters/copilot.ts +105 -274
  318. package/src/cli/run/adapters/cursor.test.ts +111 -220
  319. package/src/cli/run/adapters/cursor.ts +105 -156
  320. package/src/cli/run/adapters/index.test.ts +148 -0
  321. package/src/cli/run/adapters/index.ts +168 -20
  322. package/src/cli/run/adapters/opencode.test.ts +106 -227
  323. package/src/cli/run/adapters/opencode.ts +139 -151
  324. package/src/cli/run/adapters/permission-modes.test.ts +63 -41
  325. package/src/cli/run/adapters/permission-modes.ts +118 -37
  326. package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
  327. package/src/cli/run/platform.test.ts +128 -0
  328. package/src/cli/run/platform.ts +213 -0
  329. package/src/cli/run/schema.test.ts +62 -344
  330. package/src/cli/run/schema.ts +48 -78
  331. package/src/cli/run.test.ts +351 -0
  332. package/src/cli/run.ts +366 -1151
  333. package/src/cli/team-config.ts +2 -21
  334. package/src/cli/tiers.test.ts +4 -17
  335. package/src/orchestrator/agents/team-lead.agent.md +1 -1
  336. package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
  337. package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
  338. package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
  339. package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
  340. package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
  341. package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
  342. package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
  343. package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
  344. package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
  345. package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
  346. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
  347. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  348. package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
  349. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
  350. package/dist/cli/convoy/dag-analysis.d.ts +0 -39
  351. package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
  352. package/dist/cli/convoy/dag-analysis.js +0 -279
  353. package/dist/cli/convoy/dag-analysis.js.map +0 -1
  354. package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
  355. package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
  356. package/dist/cli/convoy/dag-analysis.test.js +0 -289
  357. package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
  358. package/dist/cli/convoy/formula.d.ts +0 -19
  359. package/dist/cli/convoy/formula.d.ts.map +0 -1
  360. package/dist/cli/convoy/formula.js +0 -142
  361. package/dist/cli/convoy/formula.js.map +0 -1
  362. package/dist/cli/convoy/formula.test.d.ts +0 -2
  363. package/dist/cli/convoy/formula.test.d.ts.map +0 -1
  364. package/dist/cli/convoy/formula.test.js +0 -342
  365. package/dist/cli/convoy/formula.test.js.map +0 -1
  366. package/dist/cli/convoy/health.d.ts +0 -34
  367. package/dist/cli/convoy/health.d.ts.map +0 -1
  368. package/dist/cli/convoy/health.js +0 -123
  369. package/dist/cli/convoy/health.js.map +0 -1
  370. package/dist/cli/convoy/health.test.d.ts +0 -2
  371. package/dist/cli/convoy/health.test.d.ts.map +0 -1
  372. package/dist/cli/convoy/health.test.js +0 -448
  373. package/dist/cli/convoy/health.test.js.map +0 -1
  374. package/dist/cli/convoy/last-run.d.ts +0 -53
  375. package/dist/cli/convoy/last-run.d.ts.map +0 -1
  376. package/dist/cli/convoy/last-run.js +0 -54
  377. package/dist/cli/convoy/last-run.js.map +0 -1
  378. package/dist/cli/convoy/last-run.test.d.ts +0 -2
  379. package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
  380. package/dist/cli/convoy/last-run.test.js +0 -110
  381. package/dist/cli/convoy/last-run.test.js.map +0 -1
  382. package/dist/cli/convoy/pipeline.d.ts +0 -41
  383. package/dist/cli/convoy/pipeline.d.ts.map +0 -1
  384. package/dist/cli/convoy/pipeline.js +0 -414
  385. package/dist/cli/convoy/pipeline.js.map +0 -1
  386. package/dist/cli/convoy/pipeline.test.d.ts +0 -2
  387. package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
  388. package/dist/cli/convoy/pipeline.test.js +0 -837
  389. package/dist/cli/convoy/pipeline.test.js.map +0 -1
  390. package/dist/cli/convoy/review-stages.d.ts +0 -9
  391. package/dist/cli/convoy/review-stages.d.ts.map +0 -1
  392. package/dist/cli/convoy/review-stages.js +0 -134
  393. package/dist/cli/convoy/review-stages.js.map +0 -1
  394. package/dist/cli/convoy/review-stages.test.d.ts +0 -2
  395. package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
  396. package/dist/cli/convoy/review-stages.test.js +0 -197
  397. package/dist/cli/convoy/review-stages.test.js.map +0 -1
  398. package/dist/cli/run/executor.d.ts +0 -15
  399. package/dist/cli/run/executor.d.ts.map +0 -1
  400. package/dist/cli/run/executor.js +0 -249
  401. package/dist/cli/run/executor.js.map +0 -1
  402. package/dist/cli/run/executor.test.d.ts +0 -2
  403. package/dist/cli/run/executor.test.d.ts.map +0 -1
  404. package/dist/cli/run/executor.test.js +0 -297
  405. package/dist/cli/run/executor.test.js.map +0 -1
  406. package/dist/cli/run/reporter.d.ts +0 -10
  407. package/dist/cli/run/reporter.d.ts.map +0 -1
  408. package/dist/cli/run/reporter.js +0 -142
  409. package/dist/cli/run/reporter.js.map +0 -1
  410. package/dist/cli/run-dry-run.test.d.ts +0 -2
  411. package/dist/cli/run-dry-run.test.d.ts.map +0 -1
  412. package/dist/cli/run-dry-run.test.js +0 -83
  413. package/dist/cli/run-dry-run.test.js.map +0 -1
  414. package/dist/cli/run-executor-flags.test.d.ts +0 -2
  415. package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
  416. package/dist/cli/run-executor-flags.test.js +0 -31
  417. package/dist/cli/run-executor-flags.test.js.map +0 -1
  418. package/dist/cli/run-finish.test.d.ts +0 -2
  419. package/dist/cli/run-finish.test.d.ts.map +0 -1
  420. package/dist/cli/run-finish.test.js +0 -77
  421. package/dist/cli/run-finish.test.js.map +0 -1
  422. package/dist/cli/watch.d.ts +0 -15
  423. package/dist/cli/watch.d.ts.map +0 -1
  424. package/dist/cli/watch.js +0 -277
  425. package/dist/cli/watch.js.map +0 -1
  426. package/dist/dashboard/scripts/etl.d.ts +0 -10
  427. package/dist/dashboard/scripts/etl.d.ts.map +0 -1
  428. package/dist/dashboard/scripts/etl.js +0 -141
  429. package/dist/dashboard/scripts/etl.js.map +0 -1
  430. package/src/cli/convoy/dag-analysis.test.ts +0 -349
  431. package/src/cli/convoy/dag-analysis.ts +0 -367
  432. package/src/cli/convoy/formula.test.ts +0 -404
  433. package/src/cli/convoy/formula.ts +0 -174
  434. package/src/cli/convoy/health.test.ts +0 -519
  435. package/src/cli/convoy/health.ts +0 -189
  436. package/src/cli/convoy/last-run.test.ts +0 -130
  437. package/src/cli/convoy/last-run.ts +0 -87
  438. package/src/cli/convoy/pipeline.test.ts +0 -999
  439. package/src/cli/convoy/pipeline.ts +0 -492
  440. package/src/cli/convoy/review-stages.test.ts +0 -235
  441. package/src/cli/convoy/review-stages.ts +0 -166
  442. package/src/cli/run/executor.test.ts +0 -338
  443. package/src/cli/run/executor.ts +0 -292
  444. package/src/cli/run/reporter.ts +0 -160
  445. package/src/cli/run-dry-run.test.ts +0 -97
  446. package/src/cli/run-executor-flags.test.ts +0 -38
  447. package/src/cli/run-finish.test.ts +0 -91
  448. package/src/cli/watch.ts +0 -295
  449. package/src/dashboard/astro.config.mjs +0 -6
  450. package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
  451. package/src/dashboard/dist/data/.gitkeep +0 -0
  452. package/src/dashboard/dist/data/convoy-list.json +0 -1
  453. package/src/dashboard/dist/data/overall-stats.json +0 -29
  454. package/src/dashboard/dist/index.html +0 -1963
  455. package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
  456. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
  457. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
  458. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
  459. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
  460. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
  461. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
  462. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
  463. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
  464. package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
  465. package/src/dashboard/package-lock.json +0 -6
  466. package/src/dashboard/public/data/.gitkeep +0 -0
  467. package/src/dashboard/public/data/convoy-list.json +0 -1
  468. package/src/dashboard/public/data/overall-stats.json +0 -29
  469. package/src/dashboard/public/icon-192.png +0 -0
  470. package/src/dashboard/scripts/etl.test.ts +0 -166
  471. package/src/dashboard/scripts/etl.ts +0 -170
  472. package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
  473. package/src/dashboard/scripts/generate-demo-db.ts +0 -529
  474. package/src/dashboard/scripts/integration-test.ts +0 -504
  475. package/src/dashboard/scripts/verify-demo-data.sh +0 -51
  476. package/src/dashboard/seed-data/delegations.ndjson +0 -35
  477. package/src/dashboard/seed-data/events.ndjson +0 -104
  478. package/src/dashboard/seed-data/panels.ndjson +0 -13
  479. package/src/dashboard/seed-data/reviews.ndjson +0 -6
  480. package/src/dashboard/seed-data/sessions.ndjson +0 -50
  481. package/src/dashboard/src/env.d.ts +0 -1
  482. package/src/dashboard/src/layouts/Layout.astro +0 -25
  483. package/src/dashboard/src/pages/index.astro +0 -2313
  484. package/src/dashboard/src/styles/dashboard.css +0 -2943
  485. package/src/dashboard/tsconfig.json +0 -6
  486. /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
@@ -1,173 +1,161 @@
1
- import { spawn } from 'node:child_process'
2
- import { writeFileSync, unlinkSync } from 'node:fs'
3
- import { join } from 'node:path'
4
1
  import type { Task, ExecuteOptions, ExecuteResult, TokenUsage } from '../../convoy/spec-types.js'
2
+ import { commandExists } from '../platform.js'
3
+ import { opencodePermission } from './permission-modes.js'
4
+ import { runAgent, stopTask, promptOf, interruptedMessage, OUTPUT_LIMIT } from './agent-process.js'
5
+
6
+ /**
7
+ * OpenCode, run headless: `opencode run --format json`.
8
+ *
9
+ * With no message argument `opencode run` reads the message from stdin. That
10
+ * is also the only safe way to pass it: a message given as arguments is
11
+ * re-joined with quotes added around any that contain a space, so the agent
12
+ * received `"Fix the bug"`, quotes and all. Each `step_finish` event carries
13
+ * that step's tokens and cost, which are summed. OpenCode prices the step
14
+ * itself from its model table — that figure is what is recorded. The stream
15
+ * does not name the model.
16
+ */
5
17
 
6
- /** Adapter name */
7
18
  export const name = 'opencode'
8
19
 
9
20
  export function supportsSessionContinuity(): boolean { return false }
10
- /**
11
- * Check if the `opencode` CLI is available on the system PATH.
12
- */
21
+
13
22
  export async function isAvailable(): Promise<boolean> {
14
- return new Promise((resolve) => {
15
- const proc = spawn('which', ['opencode'], { stdio: 'pipe' })
16
- proc.on('close', (code) => resolve(code === 0))
17
- proc.on('error', () => resolve(false))
18
- })
23
+ return commandExists('opencode')
19
24
  }
20
25
 
21
- /**
22
- * Execute a task by invoking the OpenCode CLI in headless mode.
23
- */
24
- export async function execute(task: Task, options: ExecuteOptions = {}): Promise<ExecuteResult> {
25
- let prompt = `You are a ${task.agent}. ${task.prompt}`
26
-
27
- if (task.files && task.files.length > 0) {
28
- prompt += `\n\nOnly modify files under: ${task.files.join(', ')}`
29
- }
30
-
31
- const args = ['run', prompt, '--format', 'json']
26
+ export interface ParsedOpenCode {
27
+ /** The text of the last step that produced any: the agent's final answer. */
28
+ text?: string
29
+ usage?: TokenUsage
30
+ costUsd?: number
31
+ errors: string[]
32
+ }
32
33
 
33
- const cwd = options?.cwd ?? process.cwd()
34
- const mcpJsonPath = join(cwd, 'mcp.json')
35
- let wroteJson = false
34
+ const num = (v: unknown): number | undefined => (typeof v === 'number' && Number.isFinite(v) ? v : undefined)
36
35
 
37
- if (options.mcpServers?.length) {
38
- const mcpJson: Record<string, Record<string, unknown>> = {}
39
- for (const server of options.mcpServers) {
40
- const entry: Record<string, unknown> = {}
41
- if (server.command) entry.command = server.command
42
- if (server.args) entry.args = server.args
43
- if (server.url) entry.url = server.url
44
- if (server.config) Object.assign(entry, server.config)
45
- mcpJson[server.name] = entry
36
+ /**
37
+ * Read `opencode run --format json` output.
38
+ *
39
+ * Step tokens are per step, so they add up. OpenCode's `input` excludes the
40
+ * cache reads and writes, and its `output` excludes reasoning; both are added
41
+ * back so `prompt_tokens` and `completion_tokens` count everything.
42
+ */
43
+ export function parseOpenCodeOutput(stdout: string): ParsedOpenCode {
44
+ const parsed: ParsedOpenCode = { errors: [] }
45
+ let stepText: string[] = []
46
+ let lastText: string[] = []
47
+ let prompt = 0
48
+ let completion = 0
49
+ let cacheRead = 0
50
+ let cacheWrite = 0
51
+ let cost = 0
52
+ let sawTokens = false
53
+ let sawCost = false
54
+
55
+ for (const raw of stdout.split('\n')) {
56
+ const line = raw.trim()
57
+ if (!line.startsWith('{')) continue
58
+ let ev: Record<string, unknown>
59
+ try {
60
+ ev = JSON.parse(line) as Record<string, unknown>
61
+ } catch {
62
+ continue
46
63
  }
47
- writeFileSync(mcpJsonPath, JSON.stringify({ mcpServers: mcpJson }, null, 2), 'utf8')
48
- args.push('--mcp-config', mcpJsonPath)
49
- wroteJson = true
50
- }
51
-
52
- if (options.mcp_approve_all) {
53
- args.push('--approve-mcps')
54
- }
55
-
56
- try {
57
- return await new Promise<ExecuteResult>((resolve) => {
58
- const proc = spawn('opencode', args, {
59
- stdio: ['ignore', 'pipe', 'pipe'],
60
- env: { ...process.env },
61
- cwd,
62
- })
63
-
64
- let stdout = ''
65
- let stderr = ''
66
-
67
- proc.stdout.on('data', (chunk: Buffer) => {
68
- stdout += chunk.toString()
69
- if (options.verbose) {
70
- process.stdout.write(chunk)
71
- }
72
- })
73
-
74
- proc.stderr.on('data', (chunk: Buffer) => {
75
- stderr += chunk.toString()
76
- if (options.verbose) {
77
- process.stderr.write(chunk)
78
- }
79
- })
80
-
81
- proc.on('close', (code) => {
82
- let textOutput = [stdout, stderr].filter(Boolean).join('\n')
83
- let usage: TokenUsage | undefined
84
- try {
85
- // Try single JSON object first (claude CLI)
86
- const parsed = JSON.parse(stdout) as Record<string, unknown>
87
- if (typeof parsed.result === 'string') {
88
- textOutput = parsed.result
89
- }
90
- const u = parsed?.usage as Record<string, number> | undefined
91
- if (u) {
92
- const promptTokens = (u.input_tokens ?? u.prompt_tokens) as number | undefined
93
- const completionTokens = (u.output_tokens ?? u.completion_tokens) as number | undefined
94
- const total = ((promptTokens ?? 0) + (completionTokens ?? 0)) || undefined
95
- usage = { prompt_tokens: promptTokens, completion_tokens: completionTokens, total_tokens: total }
64
+ const part = ev.part as Record<string, unknown> | undefined
65
+ switch (ev.type) {
66
+ case 'step_start':
67
+ stepText = []
68
+ break
69
+ case 'text':
70
+ if (typeof part?.text === 'string' && part.text) stepText.push(part.text)
71
+ break
72
+ case 'step_finish': {
73
+ if (stepText.length) lastText = stepText
74
+ stepText = []
75
+ const tokens = part?.tokens as Record<string, unknown> | undefined
76
+ if (tokens) {
77
+ const cache = (tokens.cache ?? {}) as Record<string, unknown>
78
+ const read = num(cache.read) ?? 0
79
+ const write = num(cache.write) ?? 0
80
+ prompt += (num(tokens.input) ?? 0) + read + write
81
+ completion += (num(tokens.output) ?? 0) + (num(tokens.reasoning) ?? 0)
82
+ cacheRead += read
83
+ cacheWrite += write
84
+ sawTokens = true
96
85
  }
97
- } catch {
98
- // Fallback: parse JSONL (one JSON object per line)
99
- // Claude CLI uses {"result": "text"}, Copilot CLI uses
100
- // {"type":"assistant.message","data":{"content":"text"}} for the AI
101
- // response and a separate {"type":"result"} line for session metadata.
102
- const lines = stdout.split('\n')
103
- let lastAssistantContent: string | undefined
104
- for (const rawLine of lines) {
105
- const line = rawLine.trim()
106
- if (!line) continue
107
- try {
108
- const parsed = JSON.parse(line) as Record<string, unknown>
109
- // Claude-style: result text in the result line
110
- if (typeof parsed.result === 'string' && parsed.result) {
111
- textOutput = parsed.result
112
- const u = parsed?.usage as Record<string, number> | undefined
113
- if (u) {
114
- const promptTokens = (u.input_tokens ?? u.prompt_tokens) as number | undefined
115
- const completionTokens = (u.output_tokens ?? u.completion_tokens) as number | undefined
116
- const total = ((promptTokens ?? 0) + (completionTokens ?? 0)) || undefined
117
- usage = { prompt_tokens: promptTokens, completion_tokens: completionTokens, total_tokens: total }
118
- }
119
- lastAssistantContent = undefined // prefer explicit result field
120
- break
121
- }
122
- // Copilot-style: AI response in assistant.message events
123
- if (parsed.type === 'assistant.message') {
124
- const data = parsed.data as Record<string, unknown> | undefined
125
- if (data && typeof data.content === 'string') {
126
- lastAssistantContent = data.content
127
- }
128
- }
129
- } catch { /* skip non-JSON lines */ }
130
- }
131
- if (lastAssistantContent !== undefined) {
132
- textOutput = lastAssistantContent
86
+ const c = num(part?.cost)
87
+ if (c !== undefined) {
88
+ cost += c
89
+ sawCost = true
133
90
  }
91
+ break
92
+ }
93
+ case 'error': {
94
+ const err = ev.error as Record<string, unknown> | undefined
95
+ const data = err?.data as Record<string, unknown> | undefined
96
+ const message = data?.message ?? err?.message ?? err?.name
97
+ if (typeof message === 'string') parsed.errors.push(message)
98
+ break
134
99
  }
135
- resolve({
136
- success: code === 0,
137
- output: textOutput.slice(0, 500_000),
138
- exitCode: code ?? -1,
139
- usage,
140
- })
141
- })
100
+ }
101
+ }
102
+ if (stepText.length) lastText = stepText
103
+ if (lastText.length) parsed.text = lastText.join('\n')
104
+ if (sawTokens) {
105
+ parsed.usage = {
106
+ prompt_tokens: prompt,
107
+ completion_tokens: completion,
108
+ total_tokens: prompt + completion,
109
+ cache_read_tokens: cacheRead,
110
+ cache_write_tokens: cacheWrite,
111
+ }
112
+ }
113
+ // OpenCode reports 0 when it has no price for the model; that is "unknown", not free.
114
+ if (sawCost && cost > 0) parsed.costUsd = cost
115
+ return parsed
116
+ }
142
117
 
143
- proc.on('error', (err) => {
144
- resolve({
145
- success: false,
146
- output: `Failed to spawn opencode: ${err.message}`,
147
- exitCode: -1,
148
- })
149
- })
118
+ /** OpenCode's permission JSON, merged over any the user already set in the environment. */
119
+ function permissionEnv(permission: Record<string, string>): Record<string, string> {
120
+ let existing: Record<string, unknown> = {}
121
+ try {
122
+ const parsed = JSON.parse(process.env.OPENCODE_PERMISSION ?? '{}') as unknown
123
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) existing = parsed as Record<string, unknown>
124
+ } catch { /* not JSON: OpenCode ignores it too */ }
125
+ return { OPENCODE_PERMISSION: JSON.stringify({ ...existing, ...permission }) }
126
+ }
150
127
 
151
- // Store process ref for potential timeout kill
152
- task._process = proc
128
+ export async function execute(task: Task, options: ExecuteOptions = {}): Promise<ExecuteResult> {
129
+ const permission = opencodePermission(options.permissionMode)
130
+ const args = ['run', '--format', 'json', ...permission.args]
131
+ if (options.model) args.push('--model', options.model) // provider/model
132
+
133
+ const exit = await runAgent(task, {
134
+ command: 'opencode',
135
+ args,
136
+ input: promptOf(task),
137
+ cwd: options.cwd ?? process.cwd(),
138
+ ...(permission.permission ? { env: permissionEnv(permission.permission) } : {}),
139
+ verbose: options.verbose,
153
140
  })
154
- } finally {
155
- if (wroteJson) {
156
- try { unlinkSync(mcpJsonPath) } catch { /* ignore */ }
157
- }
141
+
142
+ const parsed = parseOpenCodeOutput(exit.stdout)
143
+ const interrupted = interruptedMessage('opencode', task, exit)
144
+ // An `error` event is a session error or a rejected prompt: the run failed, whatever the exit code says.
145
+ const success = !interrupted && exit.code === 0 && parsed.errors.length === 0
146
+ const output = success
147
+ ? parsed.text ?? exit.stdout
148
+ : [interrupted, parsed.text, ...parsed.errors, exit.stderr.trim()].filter(Boolean).join('\n')
149
+ return {
150
+ success,
151
+ output: output.slice(0, OUTPUT_LIMIT),
152
+ exitCode: exit.code,
153
+ ...(exit.timedOut ? { _timedOut: true } : {}),
154
+ ...(parsed.usage ? { usage: parsed.usage } : {}),
155
+ ...(parsed.costUsd !== undefined ? { costUsd: parsed.costUsd } : {}),
158
156
  }
159
157
  }
160
158
 
161
- /**
162
- * Kill the process associated with a task (used by timeout enforcement).
163
- */
164
159
  export function kill(task: Task): void {
165
- if (task._process && !task._process.killed) {
166
- task._process.kill('SIGTERM')
167
- setTimeout(() => {
168
- if (task._process && !task._process.killed) {
169
- task._process.kill('SIGKILL')
170
- }
171
- }, 5000)
172
- }
160
+ stopTask(task)
173
161
  }
@@ -4,12 +4,17 @@
4
4
  * The defect: `--permission-mode` was validated against the enum, stored on the
5
5
  * spec, threaded through four call sites in the engine, handed to the adapter —
6
6
  * and read by one of the five. A run told to hold its workers to `plan` wrote
7
- * files anyway, on `codex`, `cursor`, `opencode` and `copilot` alike.
7
+ * files anyway, on `codex`, `cursor`, `opencode` and `copilot` alike. Each CLI
8
+ * now has a mapping; these tests pin what each mode becomes.
8
9
  */
9
10
  import { describe, it, expect } from 'vitest'
10
11
  import {
11
12
  ADAPTER_PERMISSION_MODES,
13
+ meaningOf,
12
14
  codexSandboxFor,
15
+ copilotPermissionArgs,
16
+ opencodePermission,
17
+ cursorPermissionArgs,
13
18
  supportsPermissionMode,
14
19
  permissionModeError,
15
20
  } from './permission-modes.js'
@@ -30,24 +35,28 @@ describe('the capability table', () => {
30
35
  }
31
36
  })
32
37
 
33
- it('lets claude and codex carry the whole enum', () => {
34
- expect([...ADAPTER_PERMISSION_MODES.claude].sort()).toEqual([...PERMISSION_MODES].sort())
35
- expect([...ADAPTER_PERMISSION_MODES.codex].sort()).toEqual([...PERMISSION_MODES].sort())
38
+ it('lets every runtime run read-only, so the planner can use any of them', () => {
39
+ for (const name of ['claude', 'codex', 'cursor', 'opencode', 'copilot']) {
40
+ expect(supportsPermissionMode(name, 'plan'), name).toBe(true)
41
+ }
36
42
  })
43
+ })
37
44
 
38
- it('does not claim read-only or bypass for the runtimes that have no such flag', () => {
39
- for (const name of ['cursor', 'opencode', 'copilot']) {
40
- expect(ADAPTER_PERMISSION_MODES[name]).not.toContain('plan')
41
- expect(ADAPTER_PERMISSION_MODES[name]).not.toContain('default')
42
- expect(ADAPTER_PERMISSION_MODES[name]).not.toContain('bypassPermissions')
43
- }
45
+ describe('meaningOf', () => {
46
+ it('reduces the modes to read-only, edits and everything', () => {
47
+ expect(meaningOf('plan')).toBe('read-only')
48
+ // In a headless run `default` can only refuse what it would have asked about.
49
+ expect(meaningOf('default')).toBe('read-only')
50
+ expect(meaningOf(undefined)).toBe('edits')
51
+ expect(meaningOf('acceptEdits')).toBe('edits')
52
+ expect(meaningOf('auto')).toBe('edits')
53
+ expect(meaningOf('dontAsk')).toBe('edits')
54
+ expect(meaningOf('bypassPermissions')).toBe('everything')
44
55
  })
45
56
  })
46
57
 
47
58
  describe('codexSandboxFor', () => {
48
59
  it('leaves the default run exactly as it was', () => {
49
- // acceptEdits is the default mode, and workspace-write is what the adapter
50
- // has always passed. This fix must not change an unconfigured run.
51
60
  expect(codexSandboxFor(undefined)).toBe('workspace-write')
52
61
  expect(codexSandboxFor('acceptEdits')).toBe('workspace-write')
53
62
  })
@@ -60,36 +69,57 @@ describe('codexSandboxFor', () => {
60
69
  it('widens the sandbox only when explicitly asked', () => {
61
70
  expect(codexSandboxFor('bypassPermissions')).toBe('danger-full-access')
62
71
  })
72
+ })
73
+
74
+ describe('copilotPermissionArgs', () => {
75
+ it('denies writes and commands for read-only — denials beat any allow, even COPILOT_ALLOW_ALL', () => {
76
+ expect(copilotPermissionArgs('plan')).toEqual(['--deny-tool=write', '--deny-tool=shell'])
77
+ })
63
78
 
64
- it('treats the do-not-ask modes as ordinary edit access', () => {
65
- expect(codexSandboxFor('auto')).toBe('workspace-write')
66
- expect(codexSandboxFor('dontAsk')).toBe('workspace-write')
79
+ it('allows file edits by default, and no longer approves everything', () => {
80
+ expect(copilotPermissionArgs(undefined)).toEqual(['--allow-tool=write'])
81
+ expect(copilotPermissionArgs('acceptEdits')).not.toContain('--allow-all')
67
82
  })
68
83
 
69
- it('never returns the same sandbox for plan and bypassPermissions', () => {
70
- // The shipped behaviour: both were workspace-write, because the value was
71
- // hardcoded and the mode never read.
72
- expect(codexSandboxFor('plan')).not.toBe(codexSandboxFor('bypassPermissions'))
84
+ it('allows everything only for bypassPermissions', () => {
85
+ expect(copilotPermissionArgs('bypassPermissions')).toEqual(['--allow-all'])
73
86
  })
74
87
  })
75
88
 
76
- describe('supportsPermissionMode', () => {
77
- it('accepts every mode on the adapters that map them all', () => {
78
- for (const mode of PERMISSION_MODES) {
79
- expect(supportsPermissionMode('claude', mode)).toBe(true)
80
- expect(supportsPermissionMode('codex', mode)).toBe(true)
81
- }
89
+ describe('opencodePermission', () => {
90
+ it('denies the edit and bash tools for read-only', () => {
91
+ expect(opencodePermission('plan')).toEqual({ args: [], permission: { edit: 'deny', bash: 'deny' } })
92
+ })
93
+
94
+ it('keeps `opencode run` as it is for edits, and approves questions only for everything', () => {
95
+ expect(opencodePermission('acceptEdits')).toEqual({ args: [] })
96
+ expect(opencodePermission('bypassPermissions')).toEqual({ args: ['--auto'] })
97
+ })
98
+ })
99
+
100
+ describe('cursorPermissionArgs', () => {
101
+ it('applies edits only with --force', () => {
102
+ expect(cursorPermissionArgs('acceptEdits')).toEqual(['--force'])
103
+ expect(cursorPermissionArgs('plan')).not.toContain('--force')
82
104
  })
83
105
 
84
- it('refuses a mode the runtime cannot express', () => {
85
- expect(supportsPermissionMode('cursor', 'plan')).toBe(false)
86
- expect(supportsPermissionMode('opencode', 'default')).toBe(false)
87
- expect(supportsPermissionMode('copilot', 'bypassPermissions')).toBe(false)
106
+ it('trusts the worktree and asks only questions for read-only', () => {
107
+ expect(cursorPermissionArgs('plan')).toEqual(['--trust', '--mode', 'ask'])
88
108
  })
89
109
 
90
- it('accepts what those runtimes actually do', () => {
91
- expect(supportsPermissionMode('cursor', 'acceptEdits')).toBe(true)
92
- expect(supportsPermissionMode('opencode', 'dontAsk')).toBe(true)
110
+ it('turns the sandbox off only for bypassPermissions', () => {
111
+ expect(cursorPermissionArgs('bypassPermissions')).toEqual(['--force', '--sandbox', 'disabled', '--approve-mcps'])
112
+ expect(cursorPermissionArgs('acceptEdits')).not.toContain('--sandbox')
113
+ })
114
+ })
115
+
116
+ describe('supportsPermissionMode', () => {
117
+ it('accepts every mode on every adapter that maps them all', () => {
118
+ for (const mode of PERMISSION_MODES) {
119
+ for (const name of ['claude', 'codex', 'cursor', 'opencode', 'copilot']) {
120
+ expect(supportsPermissionMode(name, mode)).toBe(true)
121
+ }
122
+ }
93
123
  })
94
124
 
95
125
  it('does not second-guess an adapter it has never heard of', () => {
@@ -100,15 +130,7 @@ describe('supportsPermissionMode', () => {
100
130
  describe('permissionModeError', () => {
101
131
  it('is null when the mode can be honoured', () => {
102
132
  expect(permissionModeError('claude', 'plan')).toBeNull()
133
+ expect(permissionModeError('cursor', 'plan')).toBeNull()
103
134
  expect(permissionModeError('codex', 'bypassPermissions')).toBeNull()
104
135
  })
105
-
106
- it('names the adapter, the mode, and a way forward', () => {
107
- const msg = permissionModeError('cursor', 'plan')!
108
- expect(msg).toContain('cursor')
109
- expect(msg).toContain('plan')
110
- expect(msg).toContain('acceptEdits')
111
- // A refusal with no alternative is just a wall.
112
- expect(msg).toMatch(/claude|codex/)
113
- })
114
136
  })
@@ -2,68 +2,149 @@ import { PERMISSION_MODES } from '../../convoy/spec-types.js'
2
2
  import type { PermissionMode } from '../../convoy/spec-types.js'
3
3
 
4
4
  /**
5
- * Which permission modes each adapter can actually honour.
5
+ * What each permission mode means on each agent CLI.
6
6
  *
7
- * `--permission-mode` was validated against the enum, stored on the spec,
8
- * threaded through four call sites in the engine, handed to the adapter — and
9
- * then read by exactly one of the five. On `codex`, `cursor`, `opencode` and
10
- * `copilot` it was accepted in full and dropped, so a run asked to hold a worker
11
- * to `plan` went ahead and wrote files, saying nothing.
7
+ * The modes are Claude Code's. Every other CLI spells authority differently,
8
+ * and this file is the one place that translates. Three meanings matter:
12
9
  *
13
- * Silently ignoring an authority setting is the worst of the three options. The
14
- * other two are honouring it and refusing it, and this table is what decides
15
- * which of those happens: a mode listed here is honoured by that adapter, and a
16
- * mode absent from it is refused before the run starts, naming the alternatives.
10
+ * - **read-only** (`plan`, and `default`, which in a headless run can only
11
+ * refuse what it would have asked about): the agent reads and answers. It
12
+ * edits no file, and runs no command beyond what the CLI itself treats as
13
+ * read-only. The planner runs its agents this way.
14
+ * - **edits** (`acceptEdits` — the default — and `auto`, `dontAsk`): the agent
15
+ * edits files in its working directory without asking. Whether it may also
16
+ * run commands is each CLI's own rule, noted per CLI below.
17
+ * - **everything** (`bypassPermissions`): no prompts and no sandbox.
17
18
  *
18
- * `ExecuteOptions.permissionMode` used to carry a note saying adapters that
19
- * cannot express a mode ignore it. They no longer may.
19
+ * A mode an adapter cannot express is refused before the run starts, never
20
+ * dropped: a run told to stay read-only that writes anyway is the worst
21
+ * outcome there is.
20
22
  */
21
23
 
22
24
  /** Every mode, for an adapter that maps the whole enum. */
23
25
  const ALL: readonly PermissionMode[] = PERMISSION_MODES
24
26
 
25
- /**
26
- * The modes that all mean "do the work without asking".
27
- *
28
- * `cursor --force`, `opencode`'s unattended run, and the Copilot SDK session
29
- * with `onPermissionRequest` approving everything are each exactly this and
30
- * nothing else: there is no flag on any of them for read-only or for a wider
31
- * grant. They accept the modes that describe what they already do, and refuse
32
- * the ones that would be a lie.
33
- */
34
- const EDITS_ONLY: readonly PermissionMode[] = ['acceptEdits', 'auto', 'dontAsk']
27
+ type Meaning = 'read-only' | 'edits' | 'everything'
28
+
29
+ /** The three meanings the modes reduce to on a CLI that is not Claude Code. */
30
+ export function meaningOf(mode: PermissionMode | undefined): Meaning {
31
+ switch (mode) {
32
+ case 'plan':
33
+ case 'default':
34
+ return 'read-only'
35
+ case 'bypassPermissions':
36
+ return 'everything'
37
+ // acceptEdits, auto, dontAsk, and no mode at all.
38
+ default:
39
+ return 'edits'
40
+ }
41
+ }
35
42
 
36
43
  export const ADAPTER_PERMISSION_MODES: Record<string, readonly PermissionMode[]> = {
37
- // Passed straight through as `--permission-mode`.
44
+ // Passed through as `claude -p --permission-mode <mode>`, except read-only
45
+ // (`plan`), which is default mode with Edit, Write and NotebookEdit denied —
46
+ // see `claudePermissionArgs`. A headless run refuses whatever it would have
47
+ // asked about. `acceptEdits` allows edits and simple filesystem commands
48
+ // (mkdir, mv, cp …) in the working directory.
38
49
  claude: ALL,
39
- // Mapped onto the sandbox setting — see `codexSandboxFor`.
50
+ // `codex exec` never asks for approval; the sandbox is the whole policy.
51
+ // See `codexSandboxFor`. Edits mode can run commands, inside the sandbox.
40
52
  codex: ALL,
41
- cursor: EDITS_ONLY,
42
- opencode: EDITS_ONLY,
43
- copilot: EDITS_ONLY,
53
+ // `copilot` tool rules. See `copilotPermissionArgs`. Edits mode runs only
54
+ // read-only commands.
55
+ copilot: ALL,
56
+ // `opencode run` allows edits and commands by default and rejects what it
57
+ // would ask about. See `opencodePermission`.
58
+ opencode: ALL,
59
+ // `cursor-agent -p` applies edits only with `--force`, which also allows
60
+ // commands. See `cursorPermissionArgs`.
61
+ cursor: ALL,
44
62
  }
45
63
 
46
64
  /**
47
- * The sandbox `codex exec -s` should run under for a given mode.
65
+ * The sandbox `codex exec -s` runs under.
48
66
  *
49
- * `acceptEdits` keeps `workspace-write`, which is what the adapter has always
50
- * passed, so the default run is byte-for-byte what it was. The other modes stop
51
- * being silently equal to it.
67
+ * `codex exec` always runs with approval policy "never" — it has no `-a` of
68
+ * its own, and the `-a never` this adapter used to pass before `exec` was
69
+ * parsed as an option of the interactive CLI and ignored — so the sandbox is
70
+ * all there is. `read-only` writes nothing and runs commands read-only;
71
+ * `workspace-write` writes inside the working directory, with no network;
72
+ * `danger-full-access` is unrestricted.
52
73
  */
53
74
  export function codexSandboxFor(mode: PermissionMode | undefined): string {
54
- switch (mode) {
55
- // "writes nothing unattended" and "plan only" are both read-only to codex.
56
- case 'default':
57
- case 'plan':
75
+ switch (meaningOf(mode)) {
76
+ case 'read-only':
58
77
  return 'read-only'
59
- case 'bypassPermissions':
78
+ case 'everything':
60
79
  return 'danger-full-access'
61
- // acceptEdits, auto, dontAsk, and no mode at all.
62
80
  default:
63
81
  return 'workspace-write'
64
82
  }
65
83
  }
66
84
 
85
+ /**
86
+ * Copilot CLI tool rules for a headless run.
87
+ *
88
+ * In prompt mode Copilot cannot ask, so whatever no rule allows is refused;
89
+ * reads inside the working directory, and read-only shell commands, need no
90
+ * rule. `write` is every file-editing tool and `shell` every command. Deny
91
+ * rules beat allow rules — even `--allow-all` and `COPILOT_ALLOW_ALL` in the
92
+ * environment — so read-only is stated as denials rather than left to the
93
+ * absence of an allow. Edits mode allows `write` and leaves commands to that
94
+ * default, which is close to Claude Code's `acceptEdits`.
95
+ */
96
+ export function copilotPermissionArgs(mode: PermissionMode | undefined): string[] {
97
+ switch (meaningOf(mode)) {
98
+ case 'read-only':
99
+ return ['--deny-tool=write', '--deny-tool=shell']
100
+ case 'everything':
101
+ return ['--allow-all']
102
+ default:
103
+ return ['--allow-tool=write']
104
+ }
105
+ }
106
+
107
+ /**
108
+ * OpenCode's permission settings for a headless `opencode run`.
109
+ *
110
+ * `run` already allows edits and commands, and rejects whatever would need a
111
+ * question (paths outside the project, a detected loop). Read-only denies the
112
+ * edit and bash tools through `OPENCODE_PERMISSION` — the built-in `plan`
113
+ * agent alone still runs shell commands. `--auto` approves the questions too.
114
+ */
115
+ export function opencodePermission(mode: PermissionMode | undefined): { args: string[]; permission?: Record<string, string> } {
116
+ switch (meaningOf(mode)) {
117
+ case 'read-only':
118
+ return { args: [], permission: { edit: 'deny', bash: 'deny' } }
119
+ case 'everything':
120
+ return { args: ['--auto'] }
121
+ default:
122
+ return { args: [] }
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Cursor Agent flags for a headless `cursor-agent -p`.
128
+ *
129
+ * In print mode the agent proposes changes and applies none unless `--force`
130
+ * is given, and `--mode ask` keeps it to read-only questions and answers. A
131
+ * headless run in a workspace Cursor has not been told to trust — every new
132
+ * worktree — exits at once, so read-only passes `--trust`; `--force` implies
133
+ * it. Cursor has no grant narrower than `--force`, which also lets it run
134
+ * commands. Everything also turns Cursor's sandbox off and approves the
135
+ * project's MCP servers.
136
+ */
137
+ export function cursorPermissionArgs(mode: PermissionMode | undefined): string[] {
138
+ switch (meaningOf(mode)) {
139
+ case 'read-only':
140
+ return ['--trust', '--mode', 'ask']
141
+ case 'everything':
142
+ return ['--force', '--sandbox', 'disabled', '--approve-mcps']
143
+ default:
144
+ return ['--force']
145
+ }
146
+ }
147
+
67
148
  /** True when `adapter` can honour `mode`. Unknown adapters are not second-guessed. */
68
149
  export function supportsPermissionMode(adapter: string, mode: PermissionMode): boolean {
69
150
  const supported = ADAPTER_PERMISSION_MODES[adapter]