opencastle 1.3.0 → 1.4.0

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 (577) hide show
  1. package/README.md +102 -131
  2. package/bin/cli.mjs +20 -10
  3. package/dist/cli/adapters/claude-code.d.ts +5 -3
  4. package/dist/cli/adapters/claude-code.d.ts.map +1 -1
  5. package/dist/cli/adapters/claude-code.js +7 -3
  6. package/dist/cli/adapters/claude-code.js.map +1 -1
  7. package/dist/cli/adapters/single-file-base.d.ts +18 -0
  8. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  9. package/dist/cli/adapters/single-file-base.js +29 -4
  10. package/dist/cli/adapters/single-file-base.js.map +1 -1
  11. package/dist/cli/agent-plugin.test.js +12 -0
  12. package/dist/cli/agent-plugin.test.js.map +1 -1
  13. package/dist/cli/agent-roster.test.js +0 -48
  14. package/dist/cli/agent-roster.test.js.map +1 -1
  15. package/dist/cli/bootstrap.d.ts.map +1 -1
  16. package/dist/cli/bootstrap.js +20 -0
  17. package/dist/cli/bootstrap.js.map +1 -1
  18. package/dist/cli/boundary.test.js +9 -7
  19. package/dist/cli/boundary.test.js.map +1 -1
  20. package/dist/cli/ci.d.ts.map +1 -1
  21. package/dist/cli/ci.js +6 -4
  22. package/dist/cli/ci.js.map +1 -1
  23. package/dist/cli/command-namespace.test.js +33 -0
  24. package/dist/cli/command-namespace.test.js.map +1 -1
  25. package/dist/cli/convoy/artifacts.d.ts +9 -2
  26. package/dist/cli/convoy/artifacts.d.ts.map +1 -1
  27. package/dist/cli/convoy/artifacts.js +13 -10
  28. package/dist/cli/convoy/artifacts.js.map +1 -1
  29. package/dist/cli/convoy/artifacts.test.js +4 -2
  30. package/dist/cli/convoy/artifacts.test.js.map +1 -1
  31. package/dist/cli/convoy/engine.d.ts +53 -23
  32. package/dist/cli/convoy/engine.d.ts.map +1 -1
  33. package/dist/cli/convoy/engine.git.test.d.ts +2 -0
  34. package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
  35. package/dist/cli/convoy/engine.git.test.js +435 -0
  36. package/dist/cli/convoy/engine.git.test.js.map +1 -0
  37. package/dist/cli/convoy/engine.js +1746 -2305
  38. package/dist/cli/convoy/engine.js.map +1 -1
  39. package/dist/cli/convoy/engine.test.js +698 -678
  40. package/dist/cli/convoy/engine.test.js.map +1 -1
  41. package/dist/cli/convoy/event-schemas.d.ts +2 -0
  42. package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
  43. package/dist/cli/convoy/event-schemas.js +59 -57
  44. package/dist/cli/convoy/event-schemas.js.map +1 -1
  45. package/dist/cli/convoy/events.d.ts +4 -1
  46. package/dist/cli/convoy/events.d.ts.map +1 -1
  47. package/dist/cli/convoy/events.js +69 -84
  48. package/dist/cli/convoy/events.js.map +1 -1
  49. package/dist/cli/convoy/events.test.js +50 -9
  50. package/dist/cli/convoy/events.test.js.map +1 -1
  51. package/dist/cli/convoy/gates.d.ts +9 -4
  52. package/dist/cli/convoy/gates.d.ts.map +1 -1
  53. package/dist/cli/convoy/gates.js +29 -14
  54. package/dist/cli/convoy/gates.js.map +1 -1
  55. package/dist/cli/convoy/isolation.d.ts +32 -6
  56. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  57. package/dist/cli/convoy/isolation.js +72 -34
  58. package/dist/cli/convoy/isolation.js.map +1 -1
  59. package/dist/cli/convoy/isolation.test.js +66 -42
  60. package/dist/cli/convoy/isolation.test.js.map +1 -1
  61. package/dist/cli/convoy/lock.d.ts.map +1 -1
  62. package/dist/cli/convoy/lock.js +25 -10
  63. package/dist/cli/convoy/lock.js.map +1 -1
  64. package/dist/cli/convoy/lock.test.js +12 -0
  65. package/dist/cli/convoy/lock.test.js.map +1 -1
  66. package/dist/cli/convoy/merge.d.ts +21 -4
  67. package/dist/cli/convoy/merge.d.ts.map +1 -1
  68. package/dist/cli/convoy/merge.js +69 -53
  69. package/dist/cli/convoy/merge.js.map +1 -1
  70. package/dist/cli/convoy/merge.test.js +23 -1
  71. package/dist/cli/convoy/merge.test.js.map +1 -1
  72. package/dist/cli/convoy/progress.d.ts +35 -0
  73. package/dist/cli/convoy/progress.d.ts.map +1 -0
  74. package/dist/cli/convoy/progress.js +103 -0
  75. package/dist/cli/convoy/progress.js.map +1 -0
  76. package/dist/cli/convoy/progress.test.d.ts +2 -0
  77. package/dist/cli/convoy/progress.test.d.ts.map +1 -0
  78. package/dist/cli/convoy/progress.test.js +53 -0
  79. package/dist/cli/convoy/progress.test.js.map +1 -0
  80. package/dist/cli/convoy/read-model.d.ts +468 -0
  81. package/dist/cli/convoy/read-model.d.ts.map +1 -0
  82. package/dist/cli/convoy/read-model.js +1132 -0
  83. package/dist/cli/convoy/read-model.js.map +1 -0
  84. package/dist/cli/convoy/read-model.test.d.ts +2 -0
  85. package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
  86. package/dist/cli/convoy/read-model.test.js +609 -0
  87. package/dist/cli/convoy/read-model.test.js.map +1 -0
  88. package/dist/cli/convoy/redact.d.ts +34 -0
  89. package/dist/cli/convoy/redact.d.ts.map +1 -0
  90. package/dist/cli/convoy/redact.js +66 -0
  91. package/dist/cli/convoy/redact.js.map +1 -0
  92. package/dist/cli/convoy/redact.test.d.ts +2 -0
  93. package/dist/cli/convoy/redact.test.d.ts.map +1 -0
  94. package/dist/cli/convoy/redact.test.js +43 -0
  95. package/dist/cli/convoy/redact.test.js.map +1 -0
  96. package/dist/cli/convoy/reviewer.d.ts +65 -0
  97. package/dist/cli/convoy/reviewer.d.ts.map +1 -0
  98. package/dist/cli/convoy/reviewer.js +141 -0
  99. package/dist/cli/convoy/reviewer.js.map +1 -0
  100. package/dist/cli/convoy/reviewer.test.d.ts +2 -0
  101. package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
  102. package/dist/cli/convoy/reviewer.test.js +96 -0
  103. package/dist/cli/convoy/reviewer.test.js.map +1 -0
  104. package/dist/cli/convoy/schedule.d.ts +30 -0
  105. package/dist/cli/convoy/schedule.d.ts.map +1 -0
  106. package/dist/cli/convoy/schedule.js +111 -0
  107. package/dist/cli/convoy/schedule.js.map +1 -0
  108. package/dist/cli/convoy/schedule.test.d.ts +2 -0
  109. package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
  110. package/dist/cli/convoy/schedule.test.js +45 -0
  111. package/dist/cli/convoy/schedule.test.js.map +1 -0
  112. package/dist/cli/convoy/spec-builder.d.ts +120 -30
  113. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  114. package/dist/cli/convoy/spec-builder.js +438 -114
  115. package/dist/cli/convoy/spec-builder.js.map +1 -1
  116. package/dist/cli/convoy/spec-builder.test.js +419 -435
  117. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  118. package/dist/cli/convoy/spec-types.d.ts +46 -92
  119. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  120. package/dist/cli/convoy/store.d.ts +6 -1
  121. package/dist/cli/convoy/store.d.ts.map +1 -1
  122. package/dist/cli/convoy/store.js +111 -15
  123. package/dist/cli/convoy/store.js.map +1 -1
  124. package/dist/cli/convoy/store.test.js +59 -13
  125. package/dist/cli/convoy/store.test.js.map +1 -1
  126. package/dist/cli/convoy/types.d.ts +76 -113
  127. package/dist/cli/convoy/types.d.ts.map +1 -1
  128. package/dist/cli/convoy/types.js +6 -13
  129. package/dist/cli/convoy/types.js.map +1 -1
  130. package/dist/cli/convoy/worktree.d.ts +88 -3
  131. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  132. package/dist/cli/convoy/worktree.js +282 -56
  133. package/dist/cli/convoy/worktree.js.map +1 -1
  134. package/dist/cli/convoy/worktree.test.js +132 -1
  135. package/dist/cli/convoy/worktree.test.js.map +1 -1
  136. package/dist/cli/convoy-args.test.js +9 -27
  137. package/dist/cli/convoy-args.test.js.map +1 -1
  138. package/dist/cli/convoy-cmd.d.ts +31 -6
  139. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  140. package/dist/cli/convoy-cmd.js +150 -200
  141. package/dist/cli/convoy-cmd.js.map +1 -1
  142. package/dist/cli/convoy-cmd.test.d.ts +2 -0
  143. package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
  144. package/dist/cli/convoy-cmd.test.js +144 -0
  145. package/dist/cli/convoy-cmd.test.js.map +1 -0
  146. package/dist/cli/dashboard.d.ts +24 -11
  147. package/dist/cli/dashboard.d.ts.map +1 -1
  148. package/dist/cli/dashboard.js +241 -303
  149. package/dist/cli/dashboard.js.map +1 -1
  150. package/dist/cli/dashboard.test.d.ts +2 -0
  151. package/dist/cli/dashboard.test.d.ts.map +1 -0
  152. package/dist/cli/dashboard.test.js +340 -0
  153. package/dist/cli/dashboard.test.js.map +1 -0
  154. package/dist/cli/dispatcher.test.js +41 -2
  155. package/dist/cli/dispatcher.test.js.map +1 -1
  156. package/dist/cli/docs-accuracy.test.js +36 -11
  157. package/dist/cli/docs-accuracy.test.js.map +1 -1
  158. package/dist/cli/doctor.d.ts.map +1 -1
  159. package/dist/cli/doctor.js +9 -6
  160. package/dist/cli/doctor.js.map +1 -1
  161. package/dist/cli/init-own-files.test.d.ts +2 -0
  162. package/dist/cli/init-own-files.test.d.ts.map +1 -0
  163. package/dist/cli/init-own-files.test.js +133 -0
  164. package/dist/cli/init-own-files.test.js.map +1 -0
  165. package/dist/cli/init.d.ts.map +1 -1
  166. package/dist/cli/init.js +106 -7
  167. package/dist/cli/init.js.map +1 -1
  168. package/dist/cli/init.test.js +5 -4
  169. package/dist/cli/init.test.js.map +1 -1
  170. package/dist/cli/layers.d.ts.map +1 -1
  171. package/dist/cli/layers.js +13 -4
  172. package/dist/cli/layers.js.map +1 -1
  173. package/dist/cli/lesson.d.ts.map +1 -1
  174. package/dist/cli/lesson.js +6 -5
  175. package/dist/cli/lesson.js.map +1 -1
  176. package/dist/cli/log.d.ts +39 -0
  177. package/dist/cli/log.d.ts.map +1 -1
  178. package/dist/cli/log.js +267 -93
  179. package/dist/cli/log.js.map +1 -1
  180. package/dist/cli/log.test.d.ts +2 -0
  181. package/dist/cli/log.test.d.ts.map +1 -0
  182. package/dist/cli/log.test.js +208 -0
  183. package/dist/cli/log.test.js.map +1 -0
  184. package/dist/cli/nearest.d.ts +18 -0
  185. package/dist/cli/nearest.d.ts.map +1 -0
  186. package/dist/cli/nearest.js +38 -0
  187. package/dist/cli/nearest.js.map +1 -0
  188. package/dist/cli/nearest.test.d.ts +2 -0
  189. package/dist/cli/nearest.test.d.ts.map +1 -0
  190. package/dist/cli/nearest.test.js +24 -0
  191. package/dist/cli/nearest.test.js.map +1 -0
  192. package/dist/cli/pipeline.d.ts +61 -0
  193. package/dist/cli/pipeline.d.ts.map +1 -1
  194. package/dist/cli/pipeline.flow.test.d.ts +2 -0
  195. package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
  196. package/dist/cli/pipeline.flow.test.js +524 -0
  197. package/dist/cli/pipeline.flow.test.js.map +1 -0
  198. package/dist/cli/pipeline.js +471 -690
  199. package/dist/cli/pipeline.js.map +1 -1
  200. package/dist/cli/plan.d.ts +82 -31
  201. package/dist/cli/plan.d.ts.map +1 -1
  202. package/dist/cli/plan.js +167 -507
  203. package/dist/cli/plan.js.map +1 -1
  204. package/dist/cli/plan.test.d.ts +2 -0
  205. package/dist/cli/plan.test.d.ts.map +1 -0
  206. package/dist/cli/plan.test.js +158 -0
  207. package/dist/cli/plan.test.js.map +1 -0
  208. package/dist/cli/prompt.d.ts.map +1 -1
  209. package/dist/cli/prompt.js +9 -7
  210. package/dist/cli/prompt.js.map +1 -1
  211. package/dist/cli/prompt.test.js +20 -2
  212. package/dist/cli/prompt.test.js.map +1 -1
  213. package/dist/cli/remove.d.ts.map +1 -1
  214. package/dist/cli/remove.js +3 -1
  215. package/dist/cli/remove.js.map +1 -1
  216. package/dist/cli/review.d.ts.map +1 -1
  217. package/dist/cli/review.js +7 -1
  218. package/dist/cli/review.js.map +1 -1
  219. package/dist/cli/run/adapters/agent-process.d.ts +82 -0
  220. package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
  221. package/dist/cli/run/adapters/agent-process.js +224 -0
  222. package/dist/cli/run/adapters/agent-process.js.map +1 -0
  223. package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
  224. package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
  225. package/dist/cli/run/adapters/agent-process.test.js +159 -0
  226. package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
  227. package/dist/cli/run/adapters/claude.d.ts +53 -2
  228. package/dist/cli/run/adapters/claude.d.ts.map +1 -1
  229. package/dist/cli/run/adapters/claude.js +147 -171
  230. package/dist/cli/run/adapters/claude.js.map +1 -1
  231. package/dist/cli/run/adapters/claude.test.js +197 -254
  232. package/dist/cli/run/adapters/claude.test.js.map +1 -1
  233. package/dist/cli/run/adapters/codex.d.ts +25 -2
  234. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  235. package/dist/cli/run/adapters/codex.js +113 -81
  236. package/dist/cli/run/adapters/codex.js.map +1 -1
  237. package/dist/cli/run/adapters/codex.test.js +116 -95
  238. package/dist/cli/run/adapters/codex.test.js.map +1 -1
  239. package/dist/cli/run/adapters/copilot.d.ts +35 -1
  240. package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
  241. package/dist/cli/run/adapters/copilot.js +104 -287
  242. package/dist/cli/run/adapters/copilot.js.map +1 -1
  243. package/dist/cli/run/adapters/copilot.test.js +122 -282
  244. package/dist/cli/run/adapters/copilot.test.js.map +1 -1
  245. package/dist/cli/run/adapters/cursor.d.ts +25 -7
  246. package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
  247. package/dist/cli/run/adapters/cursor.js +103 -156
  248. package/dist/cli/run/adapters/cursor.js.map +1 -1
  249. package/dist/cli/run/adapters/cursor.test.js +106 -218
  250. package/dist/cli/run/adapters/cursor.test.js.map +1 -1
  251. package/dist/cli/run/adapters/index.d.ts +34 -5
  252. package/dist/cli/run/adapters/index.d.ts.map +1 -1
  253. package/dist/cli/run/adapters/index.js +147 -21
  254. package/dist/cli/run/adapters/index.js.map +1 -1
  255. package/dist/cli/run/adapters/index.test.d.ts +2 -0
  256. package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
  257. package/dist/cli/run/adapters/index.test.js +129 -0
  258. package/dist/cli/run/adapters/index.test.js.map +1 -0
  259. package/dist/cli/run/adapters/opencode.d.ts +25 -9
  260. package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
  261. package/dist/cli/run/adapters/opencode.js +136 -152
  262. package/dist/cli/run/adapters/opencode.js.map +1 -1
  263. package/dist/cli/run/adapters/opencode.test.js +99 -218
  264. package/dist/cli/run/adapters/opencode.test.js.map +1 -1
  265. package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
  266. package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
  267. package/dist/cli/run/adapters/permission-modes.js +113 -37
  268. package/dist/cli/run/adapters/permission-modes.js.map +1 -1
  269. package/dist/cli/run/adapters/permission-modes.test.js +55 -40
  270. package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
  271. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
  272. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
  273. package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
  274. package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
  275. package/dist/cli/run/platform.d.ts +52 -0
  276. package/dist/cli/run/platform.d.ts.map +1 -0
  277. package/dist/cli/run/platform.js +207 -0
  278. package/dist/cli/run/platform.js.map +1 -0
  279. package/dist/cli/run/platform.test.d.ts +2 -0
  280. package/dist/cli/run/platform.test.d.ts.map +1 -0
  281. package/dist/cli/run/platform.test.js +119 -0
  282. package/dist/cli/run/platform.test.js.map +1 -0
  283. package/dist/cli/run/schema.d.ts +6 -8
  284. package/dist/cli/run/schema.d.ts.map +1 -1
  285. package/dist/cli/run/schema.js +44 -68
  286. package/dist/cli/run/schema.js.map +1 -1
  287. package/dist/cli/run/schema.test.js +59 -279
  288. package/dist/cli/run/schema.test.js.map +1 -1
  289. package/dist/cli/run.d.ts +34 -56
  290. package/dist/cli/run.d.ts.map +1 -1
  291. package/dist/cli/run.js +379 -1132
  292. package/dist/cli/run.js.map +1 -1
  293. package/dist/cli/run.test.d.ts +2 -0
  294. package/dist/cli/run.test.d.ts.map +1 -0
  295. package/dist/cli/run.test.js +318 -0
  296. package/dist/cli/run.test.js.map +1 -0
  297. package/dist/cli/sync-check.d.ts.map +1 -1
  298. package/dist/cli/sync-check.js +12 -3
  299. package/dist/cli/sync-check.js.map +1 -1
  300. package/dist/cli/sync.d.ts.map +1 -1
  301. package/dist/cli/sync.js +3 -2
  302. package/dist/cli/sync.js.map +1 -1
  303. package/dist/cli/team-config.d.ts.map +1 -1
  304. package/dist/cli/team-config.js +2 -21
  305. package/dist/cli/team-config.js.map +1 -1
  306. package/dist/cli/tiers.test.js +4 -13
  307. package/dist/cli/tiers.test.js.map +1 -1
  308. package/dist/cli/update.d.ts.map +1 -1
  309. package/dist/cli/update.js +4 -3
  310. package/dist/cli/update.js.map +1 -1
  311. package/dist/cli/website-plugins.test.js +51 -2
  312. package/dist/cli/website-plugins.test.js.map +1 -1
  313. package/dist/orchestrator/plugins/coolify/config.d.ts.map +1 -1
  314. package/dist/orchestrator/plugins/coolify/config.js +13 -0
  315. package/dist/orchestrator/plugins/coolify/config.js.map +1 -1
  316. package/dist/orchestrator/plugins/sentry/config.d.ts.map +1 -1
  317. package/dist/orchestrator/plugins/sentry/config.js +13 -0
  318. package/dist/orchestrator/plugins/sentry/config.js.map +1 -1
  319. package/package.json +3 -10
  320. package/src/cli/adapters/claude-code.ts +7 -3
  321. package/src/cli/adapters/single-file-base.ts +47 -4
  322. package/src/cli/agent-plugin.test.ts +14 -0
  323. package/src/cli/agent-roster.test.ts +0 -55
  324. package/src/cli/bootstrap.ts +23 -0
  325. package/src/cli/boundary.test.ts +9 -7
  326. package/src/cli/ci.ts +6 -4
  327. package/src/cli/command-namespace.test.ts +35 -0
  328. package/src/cli/convoy/TELEMETRY.md +138 -130
  329. package/src/cli/convoy/artifacts.test.ts +4 -2
  330. package/src/cli/convoy/artifacts.ts +13 -12
  331. package/src/cli/convoy/engine.git.test.ts +462 -0
  332. package/src/cli/convoy/engine.test.ts +817 -850
  333. package/src/cli/convoy/engine.ts +1864 -2596
  334. package/src/cli/convoy/event-schemas.ts +63 -59
  335. package/src/cli/convoy/events.test.ts +58 -9
  336. package/src/cli/convoy/events.ts +69 -91
  337. package/src/cli/convoy/gates.ts +31 -12
  338. package/src/cli/convoy/isolation.test.ts +76 -43
  339. package/src/cli/convoy/isolation.ts +100 -38
  340. package/src/cli/convoy/lock.test.ts +16 -0
  341. package/src/cli/convoy/lock.ts +25 -8
  342. package/src/cli/convoy/merge.test.ts +25 -1
  343. package/src/cli/convoy/merge.ts +74 -61
  344. package/src/cli/convoy/progress.test.ts +59 -0
  345. package/src/cli/convoy/progress.ts +121 -0
  346. package/src/cli/convoy/read-model.test.ts +685 -0
  347. package/src/cli/convoy/read-model.ts +1469 -0
  348. package/src/cli/convoy/redact.test.ts +49 -0
  349. package/src/cli/convoy/redact.ts +73 -0
  350. package/src/cli/convoy/reviewer.test.ts +112 -0
  351. package/src/cli/convoy/reviewer.ts +196 -0
  352. package/src/cli/convoy/schedule.test.ts +56 -0
  353. package/src/cli/convoy/schedule.ts +109 -0
  354. package/src/cli/convoy/spec-builder.test.ts +460 -464
  355. package/src/cli/convoy/spec-builder.ts +460 -129
  356. package/src/cli/convoy/spec-types.ts +46 -108
  357. package/src/cli/convoy/store.test.ts +64 -13
  358. package/src/cli/convoy/store.ts +143 -33
  359. package/src/cli/convoy/types.ts +59 -71
  360. package/src/cli/convoy/worktree.test.ts +140 -1
  361. package/src/cli/convoy/worktree.ts +311 -61
  362. package/src/cli/convoy-args.test.ts +10 -30
  363. package/src/cli/convoy-cmd.test.ts +163 -0
  364. package/src/cli/convoy-cmd.ts +173 -215
  365. package/src/cli/dashboard/dashboard.css +2086 -0
  366. package/src/cli/dashboard/dashboard.js +1687 -0
  367. package/src/cli/dashboard/index.html +307 -0
  368. package/src/cli/dashboard.test.ts +382 -0
  369. package/src/cli/dashboard.ts +243 -339
  370. package/src/cli/dispatcher.test.ts +43 -2
  371. package/src/cli/docs-accuracy.test.ts +37 -10
  372. package/src/cli/doctor.ts +9 -6
  373. package/src/cli/init-own-files.test.ts +156 -0
  374. package/src/cli/init.test.ts +5 -4
  375. package/src/cli/init.ts +104 -7
  376. package/src/cli/layers.ts +13 -4
  377. package/src/cli/lesson.ts +6 -5
  378. package/src/cli/log.test.ts +228 -0
  379. package/src/cli/log.ts +302 -83
  380. package/src/cli/nearest.test.ts +27 -0
  381. package/src/cli/nearest.ts +38 -0
  382. package/src/cli/pipeline.flow.test.ts +607 -0
  383. package/src/cli/pipeline.ts +544 -759
  384. package/src/cli/plan.test.ts +193 -0
  385. package/src/cli/plan.ts +209 -545
  386. package/src/cli/prompt.test.ts +21 -2
  387. package/src/cli/prompt.ts +11 -7
  388. package/src/cli/remove.ts +3 -0
  389. package/src/cli/review.ts +7 -1
  390. package/src/cli/run/adapters/agent-process.test.ts +175 -0
  391. package/src/cli/run/adapters/agent-process.ts +252 -0
  392. package/src/cli/run/adapters/claude.test.ts +205 -260
  393. package/src/cli/run/adapters/claude.ts +151 -162
  394. package/src/cli/run/adapters/codex.test.ts +120 -100
  395. package/src/cli/run/adapters/codex.ts +115 -91
  396. package/src/cli/run/adapters/copilot.test.ts +135 -306
  397. package/src/cli/run/adapters/copilot.ts +105 -274
  398. package/src/cli/run/adapters/cursor.test.ts +111 -220
  399. package/src/cli/run/adapters/cursor.ts +105 -156
  400. package/src/cli/run/adapters/index.test.ts +148 -0
  401. package/src/cli/run/adapters/index.ts +168 -20
  402. package/src/cli/run/adapters/opencode.test.ts +106 -227
  403. package/src/cli/run/adapters/opencode.ts +139 -151
  404. package/src/cli/run/adapters/permission-modes.test.ts +63 -41
  405. package/src/cli/run/adapters/permission-modes.ts +118 -37
  406. package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
  407. package/src/cli/run/platform.test.ts +128 -0
  408. package/src/cli/run/platform.ts +213 -0
  409. package/src/cli/run/schema.test.ts +62 -344
  410. package/src/cli/run/schema.ts +48 -78
  411. package/src/cli/run.test.ts +351 -0
  412. package/src/cli/run.ts +366 -1151
  413. package/src/cli/sync-check.ts +12 -3
  414. package/src/cli/sync.ts +3 -2
  415. package/src/cli/team-config.ts +2 -21
  416. package/src/cli/tiers.test.ts +4 -17
  417. package/src/cli/update.ts +4 -3
  418. package/src/cli/website-plugins.test.ts +55 -5
  419. package/src/orchestrator/agents/team-lead.agent.md +2 -2
  420. package/src/orchestrator/customizations/README.md +58 -13
  421. package/src/orchestrator/customizations/logs/README.md +23 -18
  422. package/src/orchestrator/instructions/general.instructions.md +1 -1
  423. package/src/orchestrator/plugins/coolify/config.ts +13 -0
  424. package/src/orchestrator/plugins/sentry/config.ts +13 -0
  425. package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
  426. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +44 -49
  427. package/src/orchestrator/prompts/brainstorm.prompt.md +2 -2
  428. package/src/orchestrator/prompts/bug-fix.prompt.md +5 -4
  429. package/src/orchestrator/prompts/create-skill.prompt.md +29 -39
  430. package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
  431. package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
  432. package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
  433. package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
  434. package/src/orchestrator/prompts/implement-feature.prompt.md +7 -6
  435. package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
  436. package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
  437. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
  438. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  439. package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
  440. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
  441. package/dist/cli/convoy/dag-analysis.d.ts +0 -39
  442. package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
  443. package/dist/cli/convoy/dag-analysis.js +0 -279
  444. package/dist/cli/convoy/dag-analysis.js.map +0 -1
  445. package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
  446. package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
  447. package/dist/cli/convoy/dag-analysis.test.js +0 -289
  448. package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
  449. package/dist/cli/convoy/formula.d.ts +0 -19
  450. package/dist/cli/convoy/formula.d.ts.map +0 -1
  451. package/dist/cli/convoy/formula.js +0 -142
  452. package/dist/cli/convoy/formula.js.map +0 -1
  453. package/dist/cli/convoy/formula.test.d.ts +0 -2
  454. package/dist/cli/convoy/formula.test.d.ts.map +0 -1
  455. package/dist/cli/convoy/formula.test.js +0 -342
  456. package/dist/cli/convoy/formula.test.js.map +0 -1
  457. package/dist/cli/convoy/health.d.ts +0 -34
  458. package/dist/cli/convoy/health.d.ts.map +0 -1
  459. package/dist/cli/convoy/health.js +0 -123
  460. package/dist/cli/convoy/health.js.map +0 -1
  461. package/dist/cli/convoy/health.test.d.ts +0 -2
  462. package/dist/cli/convoy/health.test.d.ts.map +0 -1
  463. package/dist/cli/convoy/health.test.js +0 -448
  464. package/dist/cli/convoy/health.test.js.map +0 -1
  465. package/dist/cli/convoy/last-run.d.ts +0 -53
  466. package/dist/cli/convoy/last-run.d.ts.map +0 -1
  467. package/dist/cli/convoy/last-run.js +0 -54
  468. package/dist/cli/convoy/last-run.js.map +0 -1
  469. package/dist/cli/convoy/last-run.test.d.ts +0 -2
  470. package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
  471. package/dist/cli/convoy/last-run.test.js +0 -110
  472. package/dist/cli/convoy/last-run.test.js.map +0 -1
  473. package/dist/cli/convoy/pipeline.d.ts +0 -41
  474. package/dist/cli/convoy/pipeline.d.ts.map +0 -1
  475. package/dist/cli/convoy/pipeline.js +0 -414
  476. package/dist/cli/convoy/pipeline.js.map +0 -1
  477. package/dist/cli/convoy/pipeline.test.d.ts +0 -2
  478. package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
  479. package/dist/cli/convoy/pipeline.test.js +0 -837
  480. package/dist/cli/convoy/pipeline.test.js.map +0 -1
  481. package/dist/cli/convoy/review-stages.d.ts +0 -9
  482. package/dist/cli/convoy/review-stages.d.ts.map +0 -1
  483. package/dist/cli/convoy/review-stages.js +0 -134
  484. package/dist/cli/convoy/review-stages.js.map +0 -1
  485. package/dist/cli/convoy/review-stages.test.d.ts +0 -2
  486. package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
  487. package/dist/cli/convoy/review-stages.test.js +0 -197
  488. package/dist/cli/convoy/review-stages.test.js.map +0 -1
  489. package/dist/cli/run/executor.d.ts +0 -15
  490. package/dist/cli/run/executor.d.ts.map +0 -1
  491. package/dist/cli/run/executor.js +0 -249
  492. package/dist/cli/run/executor.js.map +0 -1
  493. package/dist/cli/run/executor.test.d.ts +0 -2
  494. package/dist/cli/run/executor.test.d.ts.map +0 -1
  495. package/dist/cli/run/executor.test.js +0 -297
  496. package/dist/cli/run/executor.test.js.map +0 -1
  497. package/dist/cli/run/reporter.d.ts +0 -10
  498. package/dist/cli/run/reporter.d.ts.map +0 -1
  499. package/dist/cli/run/reporter.js +0 -142
  500. package/dist/cli/run/reporter.js.map +0 -1
  501. package/dist/cli/run-dry-run.test.d.ts +0 -2
  502. package/dist/cli/run-dry-run.test.d.ts.map +0 -1
  503. package/dist/cli/run-dry-run.test.js +0 -83
  504. package/dist/cli/run-dry-run.test.js.map +0 -1
  505. package/dist/cli/run-executor-flags.test.d.ts +0 -2
  506. package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
  507. package/dist/cli/run-executor-flags.test.js +0 -31
  508. package/dist/cli/run-executor-flags.test.js.map +0 -1
  509. package/dist/cli/run-finish.test.d.ts +0 -2
  510. package/dist/cli/run-finish.test.d.ts.map +0 -1
  511. package/dist/cli/run-finish.test.js +0 -77
  512. package/dist/cli/run-finish.test.js.map +0 -1
  513. package/dist/cli/watch.d.ts +0 -15
  514. package/dist/cli/watch.d.ts.map +0 -1
  515. package/dist/cli/watch.js +0 -277
  516. package/dist/cli/watch.js.map +0 -1
  517. package/dist/dashboard/scripts/etl.d.ts +0 -10
  518. package/dist/dashboard/scripts/etl.d.ts.map +0 -1
  519. package/dist/dashboard/scripts/etl.js +0 -141
  520. package/dist/dashboard/scripts/etl.js.map +0 -1
  521. package/src/cli/convoy/dag-analysis.test.ts +0 -349
  522. package/src/cli/convoy/dag-analysis.ts +0 -367
  523. package/src/cli/convoy/formula.test.ts +0 -404
  524. package/src/cli/convoy/formula.ts +0 -174
  525. package/src/cli/convoy/health.test.ts +0 -519
  526. package/src/cli/convoy/health.ts +0 -189
  527. package/src/cli/convoy/last-run.test.ts +0 -130
  528. package/src/cli/convoy/last-run.ts +0 -87
  529. package/src/cli/convoy/pipeline.test.ts +0 -999
  530. package/src/cli/convoy/pipeline.ts +0 -492
  531. package/src/cli/convoy/review-stages.test.ts +0 -235
  532. package/src/cli/convoy/review-stages.ts +0 -166
  533. package/src/cli/run/executor.test.ts +0 -338
  534. package/src/cli/run/executor.ts +0 -292
  535. package/src/cli/run/reporter.ts +0 -160
  536. package/src/cli/run-dry-run.test.ts +0 -97
  537. package/src/cli/run-executor-flags.test.ts +0 -38
  538. package/src/cli/run-finish.test.ts +0 -91
  539. package/src/cli/watch.ts +0 -295
  540. package/src/dashboard/astro.config.mjs +0 -6
  541. package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
  542. package/src/dashboard/dist/data/.gitkeep +0 -0
  543. package/src/dashboard/dist/data/convoy-list.json +0 -1
  544. package/src/dashboard/dist/data/overall-stats.json +0 -29
  545. package/src/dashboard/dist/index.html +0 -1963
  546. package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
  547. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
  548. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
  549. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
  550. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
  551. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
  552. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
  553. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
  554. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
  555. package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
  556. package/src/dashboard/package-lock.json +0 -6
  557. package/src/dashboard/public/data/.gitkeep +0 -0
  558. package/src/dashboard/public/data/convoy-list.json +0 -1
  559. package/src/dashboard/public/data/overall-stats.json +0 -29
  560. package/src/dashboard/public/icon-192.png +0 -0
  561. package/src/dashboard/scripts/etl.test.ts +0 -166
  562. package/src/dashboard/scripts/etl.ts +0 -170
  563. package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
  564. package/src/dashboard/scripts/generate-demo-db.ts +0 -529
  565. package/src/dashboard/scripts/integration-test.ts +0 -504
  566. package/src/dashboard/scripts/verify-demo-data.sh +0 -51
  567. package/src/dashboard/seed-data/delegations.ndjson +0 -35
  568. package/src/dashboard/seed-data/events.ndjson +0 -104
  569. package/src/dashboard/seed-data/panels.ndjson +0 -13
  570. package/src/dashboard/seed-data/reviews.ndjson +0 -6
  571. package/src/dashboard/seed-data/sessions.ndjson +0 -50
  572. package/src/dashboard/src/env.d.ts +0 -1
  573. package/src/dashboard/src/layouts/Layout.astro +0 -25
  574. package/src/dashboard/src/pages/index.astro +0 -2313
  575. package/src/dashboard/src/styles/dashboard.css +0 -2943
  576. package/src/dashboard/tsconfig.json +0 -6
  577. /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
@@ -1,7 +1,21 @@
1
1
  import { stringify } from 'yaml'
2
+ import { existsSync, readFileSync } from 'node:fs'
3
+ import { join } from 'node:path'
2
4
  import { getEffortProfile } from './effort-scaling.js'
5
+ import { normalizePath, pathsOverlap } from './partition.js'
6
+ import { parseYaml, validateSpec } from '../run/schema.js'
3
7
 
4
- /** The task plan generated by the LLM — just the creative decomposition, no YAML concerns */
8
+ /**
9
+ * The planner's task plan, and the spec built from it.
10
+ *
11
+ * The LLM decides only what it is good at: the tasks, their prompts, who does
12
+ * them, what they touch and what waits for what. Everything that decides how
13
+ * the run behaves — branch, runtime, concurrency, failure policy, the checks —
14
+ * is set here from facts the code can read, so a generated spec is safe and
15
+ * fast without anyone editing it.
16
+ */
17
+
18
+ /** One task as the planner writes it. */
5
19
  export interface TaskPlanTask {
6
20
  id: string
7
21
  agent?: string
@@ -13,18 +27,12 @@ export interface TaskPlanTask {
13
27
  review?: string
14
28
  complexity?: 1 | 2 | 3 | 5 | 8 | 13
15
29
  prompt: string
16
- gates?: string[]
17
- built_in_gates?: Record<string, boolean | string>
18
30
  }
19
31
 
32
+ /** The planner's whole answer. */
20
33
  export interface TaskPlan {
21
34
  name: string
22
- branch?: string
23
- concurrency?: number | 'auto'
24
- on_failure?: 'continue' | 'stop'
25
35
  tasks: TaskPlanTask[]
26
- gates?: string[]
27
- gate_retries?: number
28
36
  }
29
37
 
30
38
  /** A patch to apply to a task plan — output of the fix-convoy prompt */
@@ -34,79 +42,136 @@ export interface TaskPatch {
34
42
  value: unknown // new value for the field
35
43
  }
36
44
 
37
- function toKebabCase(name: string): string {
45
+ /** What the code, not the planner, decides about a run. */
46
+ export interface SpecSettings {
47
+ /** The runtime that planned it; run, resume and retry stay on it. */
48
+ adapter: string
49
+ /** Where the work lands. Never the user's checkout. */
50
+ branch: string
51
+ /** Project checks, run once after every task is merged. */
52
+ gates: string[]
53
+ }
54
+
55
+ /** More agents at once than this costs more in rate limits and machine load than it saves. */
56
+ export const MAX_PLANNED_CONCURRENCY = 4
57
+
58
+ export function slugify(name: string): string {
38
59
  return name
39
60
  .toLowerCase()
40
61
  .replace(/[^a-z0-9]+/g, '-')
41
62
  .replace(/^-+|-+$/g, '')
42
63
  }
43
64
 
44
- /** Advanced spec properties derived programmatically from complexity assessment */
45
- export interface SpecEnrichment {
46
- guard?: { enabled: boolean }
47
- circuit_breaker?: { threshold: number; cooldown_ms: number }
48
- detect_drift?: boolean
49
- built_in_gates?: Record<string, boolean | string>
50
- max_concurrent_reviews?: number
65
+ // ── Project checks ──────────────────────────────────────────────────────────
66
+
67
+ export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'
68
+
69
+ function readPackageJson(projectRoot: string): Record<string, unknown> | null {
70
+ const path = join(projectRoot, 'package.json')
71
+ if (!existsSync(path)) return null
72
+ try {
73
+ return JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>
74
+ } catch {
75
+ return null
76
+ }
51
77
  }
52
78
 
53
79
  /**
54
- * Derives advanced convoy spec properties from a complexity assessment.
55
- * These are infrastructure concerns the LLM shouldn't generate — they're computed from signals.
80
+ * The package manager a project uses: its `packageManager` field (what
81
+ * corepack honours), else its lockfile, else npm.
56
82
  */
57
- export function deriveSpecEnrichment(complexity: {
58
- complexity: 'low' | 'medium' | 'high'
59
- total_tasks: number
60
- domains: string[]
61
- }): SpecEnrichment {
62
- const enrichment: SpecEnrichment = {}
63
-
64
- // Circuit breaker: higher complexity → lower threshold (trip faster)
65
- if (complexity.complexity === 'high') {
66
- enrichment.circuit_breaker = { threshold: 2, cooldown_ms: 300_000 }
67
- } else if (complexity.complexity === 'medium') {
68
- enrichment.circuit_breaker = { threshold: 3, cooldown_ms: 300_000 }
83
+ export function detectPackageManager(projectRoot: string): PackageManager {
84
+ const declared = readPackageJson(projectRoot)?.packageManager
85
+ if (typeof declared === 'string') {
86
+ const name = declared.split('@')[0]
87
+ if (name === 'npm' || name === 'pnpm' || name === 'yarn' || name === 'bun') return name
69
88
  }
89
+ if (existsSync(join(projectRoot, 'pnpm-lock.yaml'))) return 'pnpm'
90
+ if (existsSync(join(projectRoot, 'yarn.lock'))) return 'yarn'
91
+ if (existsSync(join(projectRoot, 'bun.lockb')) || existsSync(join(projectRoot, 'bun.lock'))) return 'bun'
92
+ return 'npm'
93
+ }
70
94
 
71
- // Drift detection for medium/high
72
- if (complexity.complexity !== 'low') {
73
- enrichment.detect_drift = true
74
- }
95
+ /** Cheapest first, so a type error fails the run before the test suite starts. */
96
+ const GATE_SCRIPTS = [['typecheck', 'type-check'], ['lint'], ['test'], ['build']]
75
97
 
76
- // Guard: enabled for medium/high
77
- if (complexity.complexity !== 'low') {
78
- enrichment.guard = { enabled: true }
79
- }
80
-
81
- // Built-in gates based on domains
82
- const domains = new Set(complexity.domains.map(d => d.toLowerCase()))
83
- const gates: Record<string, boolean | string> = {
84
- secret_scan: true,
85
- blast_radius: true,
98
+ /**
99
+ * The project's own checks, from its package.json scripts.
100
+ *
101
+ * They run once, after every task has merged, which is the only point at which
102
+ * they test the combined result. The planner used to choose gates itself and
103
+ * the spec builder added a per-task `npm test` once a plan passed five tasks:
104
+ * the whole suite, once per task, mostly against the same code.
105
+ */
106
+ export function detectGates(projectRoot: string): string[] {
107
+ const scripts = readPackageJson(projectRoot)?.scripts
108
+ if (!scripts || typeof scripts !== 'object') return []
109
+ const pm = detectPackageManager(projectRoot)
110
+ const gates: string[] = []
111
+ for (const names of GATE_SCRIPTS) {
112
+ const name = names.find((n) => typeof (scripts as Record<string, unknown>)[n] === 'string')
113
+ if (!name) continue
114
+ const body = (scripts as Record<string, string>)[name]
115
+ // `npm init` writes a test script that always fails, and a watcher never
116
+ // exits; either would fail or hang every run.
117
+ if (/no test specified/.test(body) || /--watch\b/.test(body)) continue
118
+ gates.push(`${pm} run ${name}`)
86
119
  }
120
+ return gates
121
+ }
87
122
 
88
- if (domains.has('frontend') || domains.has('ui')) {
89
- gates.browser_test = 'auto'
123
+ // ── Building the spec ───────────────────────────────────────────────────────
124
+
125
+ /** Topological levels: a task's level is one more than its deepest dependency's. */
126
+ function levels(plan: TaskPlan): Map<string, number> {
127
+ const byId = new Map(plan.tasks.map((t) => [t.id, t]))
128
+ const memo = new Map<string, number>()
129
+ const visit = (id: string, seen: Set<string>): number => {
130
+ const known = memo.get(id)
131
+ if (known !== undefined) return known
132
+ if (seen.has(id)) return 0 // a cycle; checkPlan reports it
133
+ seen.add(id)
134
+ const deps = (byId.get(id)?.depends_on ?? []).filter((d) => byId.has(d))
135
+ const level = deps.length ? 1 + Math.max(...deps.map((d) => visit(d, seen))) : 0
136
+ memo.set(id, level)
137
+ return level
90
138
  }
91
- if (domains.has('testing') || complexity.total_tasks > 5) {
92
- gates.regression_test = 'auto'
93
- }
94
- if (domains.has('database') || domains.has('api') || domains.has('backend')) {
95
- gates.dependency_audit = 'auto'
96
- }
97
-
98
- enrichment.built_in_gates = gates
99
-
100
- // Review concurrency scales with task count
101
- enrichment.max_concurrent_reviews = complexity.total_tasks > 6 ? 3 : 2
139
+ for (const t of plan.tasks) visit(t.id, new Set())
140
+ return memo
141
+ }
102
142
 
103
- return enrichment
143
+ /**
144
+ * How many tasks to run at once: the widest level of the plan, capped.
145
+ *
146
+ * A fixed 2 left wide plans waiting and gave a straight chain a slot it could
147
+ * never use.
148
+ */
149
+ export function planConcurrency(plan: TaskPlan): number {
150
+ const width = new Map<number, number>()
151
+ for (const level of levels(plan).values()) width.set(level, (width.get(level) ?? 0) + 1)
152
+ const widest = Math.max(1, ...width.values())
153
+ return Math.min(widest, MAX_PLANNED_CONCURRENCY)
104
154
  }
105
155
 
106
156
  /**
107
- * Converts a TaskPlan into a valid convoy YAML string with a comment header.
157
+ * Converts a TaskPlan into convoy YAML.
158
+ *
159
+ * Defaults that changed, and why:
160
+ * - `branch: convoy/<slug>`. Without one the engine merged into whatever was
161
+ * checked out, and resume of a branchless run crashed.
162
+ * - `on_failure: continue`. `stop` switched off every per-task retry and still
163
+ * let the rest of the wave run; with `continue` a failure blocks only what
164
+ * depends on it, and resume picks it up.
165
+ * - `adapter`, so a resumed run cannot land on a different runtime.
166
+ * - No `detect_drift`, and no built-in gates: drift asked a fresh session with
167
+ * no memory to grade work it never saw and re-ran tasks on its guess, and the
168
+ * built-in gates either repeated the full suite per task or read a diff that
169
+ * was not committed yet.
170
+ * - `gate_retries: 1` when there are gates: one agent attempt to fix a failing
171
+ * check on the merged result, rather than a finished run reported red over a
172
+ * lint error.
108
173
  */
109
- export function buildConvoyYaml(plan: TaskPlan, enrichment?: SpecEnrichment): string {
174
+ export function buildConvoyYaml(plan: TaskPlan, settings: SpecSettings): string {
110
175
  const tasks = plan.tasks.map((task) => {
111
176
  const t: Record<string, unknown> = {}
112
177
  t.id = task.id
@@ -117,9 +182,7 @@ export function buildConvoyYaml(plan: TaskPlan, enrichment?: SpecEnrichment): st
117
182
  if (task.depends_on && task.depends_on.length > 0) t.depends_on = task.depends_on
118
183
  if (task.max_retries !== undefined) t.max_retries = task.max_retries
119
184
  if (task.review !== undefined) t.review = task.review
120
- if (task.gates !== undefined) t.gates = task.gates
121
- if (task.built_in_gates !== undefined) t.built_in_gates = task.built_in_gates
122
- // Auto-populate from effort table when complexity is set and fields are missing
185
+ // The effort table fills in what the planner left out, from its complexity score.
123
186
  if (task.complexity !== undefined) {
124
187
  const profile = getEffortProfile(task.complexity)
125
188
  if (t.timeout === undefined) t.timeout = profile.timeout
@@ -134,42 +197,319 @@ export function buildConvoyYaml(plan: TaskPlan, enrichment?: SpecEnrichment): st
134
197
  const spec: Record<string, unknown> = {
135
198
  name: plan.name,
136
199
  version: 1,
137
- concurrency: plan.concurrency ?? 2,
138
- on_failure: plan.on_failure ?? 'stop',
200
+ adapter: settings.adapter,
201
+ branch: settings.branch,
202
+ concurrency: planConcurrency(plan),
203
+ on_failure: 'continue',
139
204
  }
205
+ if (settings.gates.length > 0) {
206
+ spec.gates = settings.gates
207
+ spec.gate_retries = 1
208
+ }
209
+ spec.defaults = { timeout: '30m', max_retries: 1, review: 'fast' }
210
+ spec.tasks = tasks
211
+
212
+ const header =
213
+ '# Written by `opencastle convoy`. Edit it if you like, then run it with:\n' +
214
+ '# opencastle convoy run <this file>\n'
215
+ return header + stringify(spec, { lineWidth: 120, defaultKeyType: 'PLAIN', defaultStringType: 'PLAIN' })
216
+ }
217
+
218
+ // ── Files ───────────────────────────────────────────────────────────────────
140
219
 
141
- if (plan.branch !== undefined) spec.branch = plan.branch
220
+ function isGlob(path: string): boolean {
221
+ return path.includes('*') || path.includes('?')
222
+ }
142
223
 
143
- const defaults: Record<string, unknown> = {
144
- timeout: '30m',
145
- max_retries: 1,
146
- review: 'fast',
224
+ /**
225
+ * Every `files` entry as a concrete path or directory.
226
+ *
227
+ * The engine refuses a glob, and refused it only after the run had been
228
+ * recorded. A glob is reduced to the directory in front of its first wildcard
229
+ * (`src/**\/*.ts` → `src/`), which claims at least what the glob did. One with
230
+ * no directory in front (`*.md`) would claim the whole project, so it is
231
+ * dropped and reported instead.
232
+ */
233
+ export function normalizePlanFiles(plan: TaskPlan): { plan: TaskPlan; notes: string[] } {
234
+ const notes: string[] = []
235
+ const tasks = plan.tasks.map((task) => {
236
+ if (!task.files?.length) return task
237
+ const files: string[] = []
238
+ for (const raw of task.files) {
239
+ let path = raw.trim()
240
+ if (isGlob(path)) {
241
+ const segments = path.replace(/\\/g, '/').split('/')
242
+ const fixed = segments.slice(0, segments.findIndex(isGlob))
243
+ if (fixed.length === 0 || fixed.every((s) => s === '' || s === '.')) {
244
+ notes.push(`${task.id}: dropped "${raw}" — a pattern at the project root would claim everything`)
245
+ continue
246
+ }
247
+ path = fixed.join('/') + '/'
248
+ notes.push(`${task.id}: "${raw}" → "${path}"`)
249
+ }
250
+ if (path && !files.includes(path)) files.push(path)
251
+ }
252
+ return { ...task, files }
253
+ })
254
+ return { plan: { ...plan, tasks }, notes }
255
+ }
256
+
257
+ /** For each task, every task it waits for, directly or not. */
258
+ function ancestors(plan: TaskPlan): Map<string, Set<string>> {
259
+ const byId = new Map(plan.tasks.map((t) => [t.id, t]))
260
+ const memo = new Map<string, Set<string>>()
261
+ const visit = (id: string, path: Set<string>): Set<string> => {
262
+ const known = memo.get(id)
263
+ if (known) return known
264
+ const out = new Set<string>()
265
+ if (path.has(id)) return out // a cycle; checkPlan reports it
266
+ path.add(id)
267
+ for (const dep of byId.get(id)?.depends_on ?? []) {
268
+ if (!byId.has(dep)) continue
269
+ out.add(dep)
270
+ for (const a of visit(dep, path)) out.add(a)
271
+ }
272
+ path.delete(id)
273
+ memo.set(id, out)
274
+ return out
147
275
  }
276
+ for (const t of plan.tasks) visit(t.id, new Set())
277
+ return memo
278
+ }
148
279
 
149
- if (enrichment?.circuit_breaker) defaults.circuit_breaker = enrichment.circuit_breaker
150
- if (enrichment?.detect_drift) defaults.detect_drift = enrichment.detect_drift
151
- if (enrichment?.built_in_gates) defaults.built_in_gates = enrichment.built_in_gates
152
- if (enrichment?.max_concurrent_reviews) defaults.max_concurrent_reviews = enrichment.max_concurrent_reviews
280
+ interface Conflict {
281
+ first: string
282
+ second: string
283
+ paths: string[]
284
+ }
153
285
 
154
- spec.defaults = defaults
286
+ /**
287
+ * Pairs of tasks that may run at the same time and claim the same files.
288
+ *
289
+ * "At the same time" means neither waits for the other, directly or through
290
+ * others. That is stricter than the engine's check, which compares tasks
291
+ * phase by phase, and it is the right one for a scheduler that starts a task
292
+ * the moment its dependencies finish: two tasks in different phases can still
293
+ * overlap in time. Compared case-insensitively too, because the spec may run
294
+ * on macOS or Windows.
295
+ */
296
+ function conflicts(plan: TaskPlan): Conflict[] {
297
+ const before = ancestors(plan)
298
+ const normalized = new Map<string, string[]>()
299
+ for (const t of plan.tasks) {
300
+ const paths: string[] = []
301
+ for (const f of t.files ?? []) {
302
+ try {
303
+ paths.push(normalizePath(f))
304
+ } catch {
305
+ // Reported by checkPlan.
306
+ }
307
+ }
308
+ normalized.set(t.id, paths)
309
+ }
310
+ const found: Conflict[] = []
311
+ for (let i = 0; i < plan.tasks.length; i++) {
312
+ for (let j = i + 1; j < plan.tasks.length; j++) {
313
+ const a = plan.tasks[i]
314
+ const b = plan.tasks[j]
315
+ if (before.get(a.id)?.has(b.id) || before.get(b.id)?.has(a.id)) continue
316
+ const paths: string[] = []
317
+ for (const pa of normalized.get(a.id) ?? []) {
318
+ for (const pb of normalized.get(b.id) ?? []) {
319
+ if (pathsOverlap(pa, pb) || pathsOverlap(pa.toLowerCase(), pb.toLowerCase())) {
320
+ if (!paths.includes(pa)) paths.push(pa)
321
+ }
322
+ }
323
+ }
324
+ if (paths.length) found.push({ first: a.id, second: b.id, paths })
325
+ }
326
+ }
327
+ return found
328
+ }
155
329
 
156
- // guard is spec-level (not inside defaults)
157
- if (enrichment?.guard) spec.guard = enrichment.guard
330
+ /**
331
+ * Everything the code can check about a plan before an agent runs it.
332
+ *
333
+ * The schema the runner applies, plus the two rules the engine enforces only
334
+ * once the run has started: no globs, and no two concurrent tasks on the same
335
+ * files. An empty list means the engine will accept the spec.
336
+ */
337
+ const TEST_PATH = /(^|\/)(tests?|__tests__|spec)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py)$|(^|\/)test_[^/]+\.py$/
158
338
 
159
- spec.tasks = tasks
339
+ /**
340
+ * Fold a task that only writes tests for one other task into that task.
341
+ *
342
+ * Planners split work into "write the code" and "test the code" even when told
343
+ * not to: three real runs did it every time. Each split is another session,
344
+ * review and merge, and the agent that wrote the code never runs a test against
345
+ * it. A task folds in when every file it owns is a test file, it depends on
346
+ * exactly one task, nothing else claims its files, and that task is not itself
347
+ * test-only. Tasks that waited on it wait on the merged task instead.
348
+ */
349
+ export function foldTestOnlyTasks(plan: TaskPlan): { plan: TaskPlan; folded: Array<[string, string]> } {
350
+ const byId = new Map(plan.tasks.map((t) => [t.id, { ...t, files: [...(t.files ?? [])], depends_on: [...(t.depends_on ?? [])] }]))
351
+ const isTestOnly = (t: TaskPlanTask): boolean => (t.files ?? []).length > 0 && (t.files ?? []).every((f) => TEST_PATH.test(f))
352
+ const folded: Array<[string, string]> = []
353
+ // A dependency another dependency already waits on adds nothing: tests that
354
+ // list both a store change and the routes built on it test the routes.
355
+ const ancestors = (id: string, seen = new Set<string>()): Set<string> => {
356
+ for (const d of byId.get(id)?.depends_on ?? []) {
357
+ if (!seen.has(d)) {
358
+ seen.add(d)
359
+ ancestors(d, seen)
360
+ }
361
+ }
362
+ return seen
363
+ }
364
+ const direct = (deps: string[]): string[] => deps.filter((d) => !deps.some((o) => o !== d && ancestors(o).has(d)))
365
+ for (const task of plan.tasks) {
366
+ const t = byId.get(task.id)
367
+ if (!t || !isTestOnly(t)) continue
368
+ const deps = direct(t.depends_on)
369
+ if (deps.length !== 1) continue
370
+ const target = byId.get(deps[0])
371
+ if (!target || isTestOnly(target)) continue
372
+ const claimedElsewhere = [...byId.values()].some(
373
+ (o) => o.id !== t.id && o.id !== target.id && (o.files ?? []).some((f) => t.files.includes(f)),
374
+ )
375
+ if (claimedElsewhere) continue
376
+ target.files = [...new Set([...(target.files ?? []), ...t.files])]
377
+ target.prompt = `${target.prompt.trimEnd()}\n\nIn the same session, write the tests for this change:\n${t.prompt.trim()}`
378
+ byId.delete(t.id)
379
+ for (const other of byId.values()) {
380
+ if (other.depends_on.includes(t.id)) {
381
+ other.depends_on = [...new Set(other.depends_on.map((d) => (d === t.id ? target.id : d)))].filter((d) => d !== other.id)
382
+ }
383
+ }
384
+ folded.push([t.id, target.id])
385
+ }
386
+ return { plan: { ...plan, tasks: plan.tasks.filter((t) => byId.has(t.id)).map((t) => byId.get(t.id)!) }, folded }
387
+ }
160
388
 
161
- if (plan.gates !== undefined) spec.gates = plan.gates
162
- if (plan.gate_retries !== undefined) spec.gate_retries = plan.gate_retries
389
+ export function checkPlan(plan: TaskPlan, settings: SpecSettings): string[] {
390
+ const problems: string[] = []
391
+
392
+ const shape = planShapeProblem(plan as unknown as Record<string, unknown>)
393
+ if (shape) {
394
+ problems.push(`Plan: ${shape}`)
395
+ } else {
396
+ try {
397
+ const { valid, errors } = validateSpec(parseYaml(buildConvoyYaml(plan, settings)))
398
+ if (!valid) problems.push(...errors.map((e) => `Schema: ${e}`))
399
+ } catch (err) {
400
+ problems.push(`Schema: ${err instanceof Error ? err.message : String(err)}`)
401
+ }
402
+ }
163
403
 
164
- const header = `# .opencastle/convoys/${toKebabCase(plan.name)}.convoy.yml\n`
165
- const yaml = stringify(spec, {
166
- lineWidth: 120,
167
- defaultKeyType: 'PLAIN',
168
- defaultStringType: 'PLAIN',
169
- })
170
- return header + yaml
404
+ for (const task of plan.tasks) {
405
+ for (const f of task.files ?? []) {
406
+ if (isGlob(f)) {
407
+ problems.push(`Task "${task.id}": files entry "${f}" is a pattern — name a file or a directory`)
408
+ continue
409
+ }
410
+ if (/^([A-Za-z]:)?[\\/]/.test(f)) {
411
+ problems.push(`Task "${task.id}": files entry "${f}" must be relative to the project root`)
412
+ continue
413
+ }
414
+ try {
415
+ normalizePath(f)
416
+ } catch (err) {
417
+ problems.push(`Task "${task.id}": ${err instanceof Error ? err.message : String(err)}`)
418
+ }
419
+ }
420
+ }
421
+
422
+ for (const c of conflicts(plan)) {
423
+ problems.push(
424
+ `Tasks "${c.first}" and "${c.second}" can run at the same time but both claim ${c.paths.join(', ')}` +
425
+ ` — give each its own files, or make one depend on the other`,
426
+ )
427
+ }
428
+ return problems
429
+ }
430
+
431
+ /**
432
+ * Make the later of each conflicting pair wait for the earlier.
433
+ *
434
+ * The last resort, after fix-convoy has had its rounds: it costs parallelism,
435
+ * never correctness, and it cannot create a cycle — an edge is only added
436
+ * between two tasks that do not yet wait for each other in either direction.
437
+ */
438
+ export function sequenceConflicts(plan: TaskPlan): { plan: TaskPlan; added: Array<[string, string]> } {
439
+ let current: TaskPlan = structuredClone(plan)
440
+ const added: Array<[string, string]> = []
441
+ for (;;) {
442
+ const [next] = conflicts(current)
443
+ if (!next) break
444
+ current = {
445
+ ...current,
446
+ tasks: current.tasks.map((t) =>
447
+ t.id === next.second ? { ...t, depends_on: [...(t.depends_on ?? []), next.first] } : t,
448
+ ),
449
+ }
450
+ added.push([next.second, next.first])
451
+ }
452
+ return { plan: current, added }
453
+ }
454
+
455
+ // ── Joining group plans ─────────────────────────────────────────────────────
456
+
457
+ export interface GroupPlan {
458
+ name: string
459
+ depends_on: string[]
460
+ plan: TaskPlan
461
+ }
462
+
463
+ /**
464
+ * One plan from the plans written for each group of a large feature.
465
+ *
466
+ * Groups used to become a chain of separate specs run one after another, even
467
+ * when the assessment said two of them were independent. Here a group's first
468
+ * tasks wait for the last tasks of every group it depends on, and nothing else
469
+ * is added: independent groups run side by side under the normal scheduler,
470
+ * and the user gets one spec, one plan to read and one run to resume.
471
+ *
472
+ * Two groups can both name a task `setup`. The later one is renamed
473
+ * `<group>-setup`, with its group's references to it.
474
+ *
475
+ * `groups` must come in dependency order (topologicalSortGroups).
476
+ */
477
+ export function mergeGroupPlans(name: string, groups: GroupPlan[]): TaskPlan {
478
+ const taken = new Set<string>()
479
+ const sinks = new Map<string, string[]>()
480
+ const tasks: TaskPlanTask[] = []
481
+
482
+ for (const group of groups) {
483
+ const rename = new Map<string, string>()
484
+ for (const t of group.plan.tasks) {
485
+ let id = t.id
486
+ if (taken.has(id)) {
487
+ id = `${group.name}-${t.id}`
488
+ for (let n = 2; taken.has(id); n++) id = `${group.name}-${t.id}-${n}`
489
+ }
490
+ taken.add(id)
491
+ rename.set(t.id, id)
492
+ }
493
+
494
+ const upstream = group.depends_on.flatMap((g) => sinks.get(g) ?? [])
495
+ const dependedOn = new Set(group.plan.tasks.flatMap((t) => t.depends_on ?? []))
496
+ for (const t of group.plan.tasks) {
497
+ const own = (t.depends_on ?? []).map((d) => rename.get(d) ?? d)
498
+ // A copy each: a shared array would come out of the YAML writer as an anchor.
499
+ const depends_on = own.length > 0 ? own : [...upstream]
500
+ tasks.push({ ...t, id: rename.get(t.id)!, depends_on })
501
+ }
502
+ sinks.set(
503
+ group.name,
504
+ group.plan.tasks.filter((t) => !dependedOn.has(t.id)).map((t) => rename.get(t.id)!),
505
+ )
506
+ }
507
+
508
+ return { name, tasks }
171
509
  }
172
510
 
511
+ // ── Patches and parsing ─────────────────────────────────────────────────────
512
+
173
513
  /**
174
514
  * Applies an array of patches to a task plan. Returns a new TaskPlan (immutable).
175
515
  */
@@ -203,7 +543,6 @@ function detectJsonTruncation(jsonText: string): string | null {
203
543
  const trimmed = jsonText.trim()
204
544
  if (!trimmed) return 'empty output'
205
545
 
206
- // Count open/close braces and brackets
207
546
  let braces = 0
208
547
  let brackets = 0
209
548
  let inString = false
@@ -243,14 +582,12 @@ export function parseTaskPlan(jsonText: string): TaskPlan | null {
243
582
  }
244
583
 
245
584
  /**
246
- * Like parseTaskPlan but returns a diagnostic reason on failure.
585
+ * Like parseTaskPlan but returns a diagnostic reason on failure, for the caller
586
+ * to report.
247
587
  */
248
588
  export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
249
589
  const truncation = detectJsonTruncation(jsonText)
250
- if (truncation) {
251
- console.warn(` ⚠ parseTaskPlan: ${truncation}`)
252
- return { plan: null, reason: truncation }
253
- }
590
+ if (truncation) return { plan: null, reason: truncation }
254
591
 
255
592
  let parsed: Record<string, unknown>
256
593
  try {
@@ -259,27 +596,33 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
259
596
  return { plan: null, reason: `JSON.parse failed: ${err instanceof Error ? err.message : String(err)}` }
260
597
  }
261
598
 
599
+ const problem = planShapeProblem(parsed)
600
+ if (problem) return { plan: null, reason: problem }
601
+ return { plan: parsed as unknown as TaskPlan }
602
+ }
603
+
604
+ /**
605
+ * What makes an object not a task plan, or null: a name, a non-empty task list,
606
+ * unique ids, a prompt each, dependencies that exist, and no cycle.
607
+ */
608
+ function planShapeProblem(parsed: Record<string, unknown> | null): string | null {
262
609
  if (!parsed || typeof parsed.name !== 'string') {
263
- return { plan: null, reason: `missing or invalid top-level "name" field (got ${typeof parsed?.name})` }
610
+ return `missing or invalid top-level "name" field (got ${typeof parsed?.name})`
264
611
  }
265
612
  if (!Array.isArray(parsed.tasks) || (parsed.tasks as unknown[]).length === 0) {
266
- return { plan: null, reason: `missing or empty "tasks" array` }
613
+ return `missing or empty "tasks" array`
267
614
  }
268
- for (let i = 0; i < (parsed.tasks as unknown[]).length; i++) {
269
- const t = (parsed.tasks as unknown[])[i] as Record<string, unknown>
270
- if (typeof t.id !== 'string') {
271
- return { plan: null, reason: `task[${i}] missing "id" field` }
272
- }
615
+ const tasks = parsed.tasks as Array<Record<string, unknown>>
616
+ for (let i = 0; i < tasks.length; i++) {
617
+ const t = tasks[i]
618
+ if (!t || typeof t !== 'object') return `task[${i}] is not an object`
619
+ if (typeof t.id !== 'string') return `task[${i}] missing "id" field`
273
620
  if (typeof t.prompt !== 'string') {
274
- return { plan: null, reason: `task "${t.id ?? i}" missing "prompt" field (has keys: ${Object.keys(t).join(', ')})` }
275
- }
276
- if ((t.prompt as string).length === 0) {
277
- return { plan: null, reason: `task "${t.id}" has empty "prompt" field` }
621
+ return `task "${t.id}" missing "prompt" field (has keys: ${Object.keys(t).join(', ')})`
278
622
  }
623
+ if (t.prompt.length === 0) return `task "${t.id}" has empty "prompt" field`
279
624
  }
280
625
 
281
- // Validate unique task IDs
282
- const tasks = parsed.tasks as Array<Record<string, unknown>>
283
626
  const ids = new Set<string>()
284
627
  const duplicates: string[] = []
285
628
  for (const task of tasks) {
@@ -287,20 +630,14 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
287
630
  if (ids.has(id)) duplicates.push(id)
288
631
  ids.add(id)
289
632
  }
290
- if (duplicates.length > 0) {
291
- console.warn(` ⚠ parseTaskPlan: duplicate task IDs: ${duplicates.join(', ')}`)
292
- return { plan: null, reason: `duplicate task IDs: ${duplicates.join(', ')}` }
293
- }
633
+ if (duplicates.length > 0) return `duplicate task IDs: ${duplicates.join(', ')}`
294
634
 
295
- // Validate depends_on references
296
635
  for (const task of tasks) {
297
- if (Array.isArray(task.depends_on)) {
298
- for (const dep of task.depends_on as string[]) {
299
- if (!ids.has(dep)) {
300
- console.warn(` ⚠ parseTaskPlan: task "${task.id as string}" depends on unknown task "${dep}"`)
301
- return { plan: null, reason: `task "${task.id as string}" depends on unknown task "${dep}"` }
302
- }
303
- }
636
+ if (task.depends_on !== undefined && !Array.isArray(task.depends_on)) {
637
+ return `task "${task.id as string}" has a depends_on that is not a list`
638
+ }
639
+ for (const dep of (task.depends_on as string[] | undefined) ?? []) {
640
+ if (!ids.has(dep)) return `task "${task.id as string}" depends on unknown task "${dep}"`
304
641
  }
305
642
  }
306
643
 
@@ -312,11 +649,9 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
312
649
  adj.set(id, [])
313
650
  }
314
651
  for (const task of tasks) {
315
- if (Array.isArray(task.depends_on)) {
316
- for (const dep of task.depends_on as string[]) {
317
- adj.get(dep)!.push(task.id as string)
318
- inDegree.set(task.id as string, (inDegree.get(task.id as string) ?? 0) + 1)
319
- }
652
+ for (const dep of (task.depends_on as string[] | undefined) ?? []) {
653
+ adj.get(dep)!.push(task.id as string)
654
+ inDegree.set(task.id as string, (inDegree.get(task.id as string) ?? 0) + 1)
320
655
  }
321
656
  }
322
657
  const queue = [...ids].filter(id => inDegree.get(id) === 0)
@@ -330,12 +665,8 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
330
665
  if (deg === 0) queue.push(next)
331
666
  }
332
667
  }
333
- if (visited < ids.size) {
334
- console.warn(` ⚠ parseTaskPlan: dependency cycle detected`)
335
- return { plan: null, reason: 'dependency cycle detected' }
336
- }
337
-
338
- return { plan: parsed as unknown as TaskPlan }
668
+ if (visited < ids.size) return 'dependency cycle detected'
669
+ return null
339
670
  }
340
671
 
341
672
  /**