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,45 +1,43 @@
1
- import { resolve } from 'node:path'
2
- import { existsSync } from 'node:fs'
3
- import { createConvoyStore } from './convoy/store.js'
4
- import { selectLastRun } from './convoy/last-run.js'
1
+ import { findProjectRoot, readRun, readRuns, type RunSummary } from './convoy/read-model.js'
2
+ import { nearest } from './nearest.js'
5
3
  import { c } from './prompt.js'
6
4
  import type { CliContext } from './types.js'
7
5
 
8
6
  /**
9
7
  * The experimental `convoy` namespace.
10
8
  *
11
- * Convoy execution used to occupy four top-level commands (start, plan,
12
- * validate, run) plus a 20-flag arg parser inside `run` that bundled status
13
- * reporting, resume, retry, and three DLQ verbs. All of that is state the tool
14
- * can read for itself, so the surface here is: name a task to start one, or run
15
- * it bare to see where the last one stands and what to do about it.
9
+ * Name a task to plan and run it, run a spec you wrote, continue what is not
10
+ * done, or watch it live. Run it bare to see where the last run stands and the
11
+ * one thing to do next. Everything else that used to live here — a status
12
+ * flag, retry and dead-letter verbs, watch mode, formulas — is state the tool
13
+ * can read for itself, so it is gone.
16
14
  */
17
15
 
18
16
  const CONVOY_HELP = `
19
17
  opencastle convoy [task] [options]
20
18
 
21
- Experimental: run multi-step work through the convoy engine.
19
+ Experimental: plan multi-step work and run it with agents in parallel.
22
20
 
23
21
  Usage:
24
- opencastle convoy Show the last run and what to do next
25
- opencastle convoy "<task>" Plan and execute a task
26
- opencastle convoy plan --prd <path> Resume from a PRD written earlier
27
- opencastle convoy resume Continue the last interrupted run
28
- opencastle convoy retry Re-run the failed tasks of the last run
29
- opencastle convoy dashboard Open the run viewer
30
- opencastle convoy run -f <spec> Execute a spec you wrote by hand
22
+ opencastle convoy The last run and the one next step
23
+ opencastle convoy "<task>" Plan it, show the plan, ask, then run it
24
+ opencastle convoy run <spec.yml> Run a spec you wrote
25
+ opencastle convoy resume Continue whatever is not done
26
+ opencastle convoy dashboard The Observability dashboard, live
27
+ opencastle convoy plan --prd <file> Plan again from a PRD you edited
31
28
 
32
29
  Options:
33
- --dry-run Plan only; do not execute
34
- --verbose Stream agent output
35
- --adapter, -a <name> Agent runtime to plan and run with
36
- --skip-validation Skip PRD and spec validation passes
37
- --json Machine-readable status
38
- --help, -h Show this help
39
-
40
- run and plan take their own options — try: opencastle convoy run --help
41
-
42
- This namespace is experimental and may change or be removed.
30
+ --yes, -y With a task: run the plan without asking
31
+ --dry-run With a task: plan and write the spec, but do not run it.
32
+ With run or resume: show what would run
33
+ --adapter, -a <name> Agent runtime (default: the one opencastle init set up)
34
+ --concurrency, -c <n> Tasks at once
35
+ --verbose Stream agent output
36
+ --json With no task: the last run, as JSON
37
+ --help, -h Show this help
38
+
39
+ Every subcommand has its own --help. This namespace is experimental and may
40
+ change.
43
41
  `
44
42
 
45
43
  /**
@@ -52,62 +50,21 @@ const CONVOY_HELP = `
52
50
  * `bin/cli.mjs` has already split any `--flag=value` form before this runs, so
53
51
  * only the space form reaches here.
54
52
  */
55
- const FLAGS_WITH_VALUES = new Set([
56
- '--adapter',
57
- '-a',
58
- '--file',
59
- '-f',
60
- '--prd',
61
- '--complexity',
62
- '--output-prd',
63
- '--output-spec',
64
- '--concurrency',
65
- '-c',
66
- '--permission-mode',
67
- '--report-dir',
68
- '--formula',
69
- '--set',
70
- '--watch-config',
71
- '--convoy',
72
- '--resolution',
73
- ])
53
+ const FLAGS_WITH_VALUES = new Set(['--adapter', '-a', '--concurrency', '-c', '--file', '-f', '--prd'])
74
54
 
75
- /**
76
- * Flags the planner reads, forwarded from the task path.
77
- *
78
- * `opencastle convoy "add rate limiting" --adapter codex` used to run on the
79
- * auto-detected adapter and say nothing: the task path kept an allowlist of two
80
- * flags and silently discarded everything else. A flag that is accepted and
81
- * ignored is the defect `bin/cli.mjs` refuses unknown options to prevent, and
82
- * its comment exempts `convoy` on the grounds that this file validates its own
83
- * input — which, on this path, it did not.
84
- *
85
- * `--text` is not here because the task itself supplies it, and `--prd` is not
86
- * because `SUBCOMMAND_FLAGS` sends it to `convoy plan` with a pointer.
87
- */
88
- const TASK_FLAGS = new Set([
89
- '--adapter',
90
- '-a',
91
- '--verbose',
92
- '--dry-run',
93
- '--dryRun',
94
- '--skip-validation',
95
- '--complexity',
96
- '--output-prd',
97
- '--output-spec',
98
- ])
55
+ /** Flags the planner reads, forwarded from the task path. */
56
+ const TASK_FLAGS = new Set(['--yes', '-y', '--dry-run', '--adapter', '-a', '--concurrency', '-c', '--verbose'])
57
+
58
+ /** What a mistyped word is checked against. `retry` still works, but is not suggested. */
59
+ const SUBCOMMANDS = ['run', 'resume', 'dashboard', 'plan']
99
60
 
100
61
  /**
101
62
  * The words of the task, with the flags and their values taken out.
102
63
  *
103
64
  * A shell splits an unquoted task into one argument per word, and this command
104
65
  * used to read only the first of them: `opencastle convoy add rate limiting to
105
- * the API` planned a feature called "add". No error — it went on to spend a full
106
- * PRD round-trip on the wrong request, and the quoted form that works is the
107
- * only one our own "Start one:" hint shows.
108
- *
109
- * Flag values come out with their flag, so `--adapter codex` cannot contribute
110
- * the word "codex" to a task description.
66
+ * the API` planned a feature called "add". Flag values come out with their
67
+ * flag, so `--adapter codex` cannot add the word "codex" to a task.
111
68
  */
112
69
  export function positionalWords(args: string[]): string[] {
113
70
  const out: string[] = []
@@ -148,212 +105,213 @@ export function splitTaskFlags(args: string[]): { forward: string[]; unknown: st
148
105
  return { forward, unknown }
149
106
  }
150
107
 
151
- /** Delegate to an existing command module, passing through remaining args. */
152
- async function delegate(mod: string, ctx: CliContext, args: string[]): Promise<void> {
153
- const loaded = (await import(`./${mod}.js`)) as {
154
- default: (_ctx: CliContext) => Promise<void>
155
- }
156
- await loaded.default({ ...ctx, args })
157
- }
108
+ // ── Status ────────────────────────────────────────────────────────────────────
158
109
 
159
- interface LastRun {
110
+ const FAILED_STATUSES = new Set(['failed', 'gate-failed', 'timed-out', 'review-blocked', 'disputed', 'hook-failed'])
111
+
112
+ export interface LastRun {
160
113
  id: string
161
114
  name: string
162
115
  status: string
163
- /** Which orchestrator owns it — `resume` hands a pipeline to a different one. */
164
- kind: 'pipeline' | 'convoy'
116
+ branch: string | null
117
+ created_at: string
118
+ /** A process is working on it now. */
119
+ alive: boolean
165
120
  total: number
166
121
  done: number
122
+ /** Every failed status: failed, gate-failed, timed-out, review-blocked, disputed, hook-failed. */
167
123
  failed: number
124
+ running: number
125
+ skipped: number
168
126
  pending: number
127
+ /** The one command to run next. */
128
+ next: string
129
+ /** An older run with work left, when this one has none: what `resume` would continue. */
130
+ older_unfinished: { id: string; name: string } | null
131
+ }
132
+
133
+ function unfinished(run: RunSummary): boolean {
134
+ return run.status !== 'done' || run.tasks_done < run.tasks_total
169
135
  }
170
136
 
171
137
  /**
172
- * The same run `opencastle convoy resume` would continue.
173
- *
174
- * Read through `selectLastRun` rather than `getLatestConvoy`, which is what this
175
- * used to call. The two answers differed whenever a project had run a pipeline:
176
- * this screen named the newest convoy and advised `resume`, and `resume` then
177
- * reopened the pipeline instead. Advice that names a different run than the
178
- * command acts on is worse than no advice.
138
+ * The last run, from the read model: the database is opened read-only, never
139
+ * migrated, and closed again. The status screen used to open the read-write
140
+ * store, which migrated an older project's database just to look at it.
179
141
  */
180
- function readLastRun(projectRoot: string): LastRun | null {
181
- const dbPath = resolve(projectRoot, '.opencastle', 'convoy.db')
182
- if (!existsSync(dbPath)) return null
183
- let store
184
- try {
185
- store = createConvoyStore(dbPath)
186
- } catch {
187
- return null
188
- }
189
- try {
190
- const last = selectLastRun(store)
191
- if (!last) return null
192
-
193
- // A pipeline's progress is the progress of every convoy in it, so the counts
194
- // come from all of them rather than from a single spec's task list.
195
- const convoyIds =
196
- last.kind === 'pipeline'
197
- ? store.getConvoysByPipeline(last.record.id).map((c) => c.id)
198
- : [last.record.id]
199
- const tasks = convoyIds.flatMap((id) => store.getTasksByConvoy(id))
200
-
201
- return {
202
- id: last.record.id,
203
- name: last.record.name,
204
- status: last.record.status,
205
- kind: last.kind,
206
- total: tasks.length,
207
- done: tasks.filter((t) => t.status === 'done').length,
208
- failed: tasks.filter((t) => t.status === 'failed' || t.status === 'gate-failed').length,
209
- pending: tasks.filter((t) => t.status === 'pending' || t.status === 'assigned').length,
210
- }
211
- } catch {
212
- return null
213
- } finally {
214
- try { store.close() } catch { /* already closed */ }
142
+ export function readLastRun(projectRoot: string): LastRun | null {
143
+ const runs = readRuns(projectRoot, 200)
144
+ if (runs.length === 0) return null
145
+ const last = runs[0]
146
+ const tasks = readRun(projectRoot, last.id)?.tasks ?? []
147
+ const count = (pick: (s: string) => boolean): number => tasks.filter((t) => pick(t.status)).length
148
+ const done = count((s) => s === 'done')
149
+ // Not done is not done: skipped and running tasks count against "finished"
150
+ // as much as failed ones do, and the run's own status is not trusted to say so.
151
+ const notDone = last.status !== 'done' || done < tasks.length
152
+ const older = notDone ? undefined : runs.slice(1).find(unfinished)
153
+ return {
154
+ id: last.id,
155
+ name: last.name,
156
+ status: last.status,
157
+ branch: last.branch,
158
+ created_at: last.created_at,
159
+ alive: last.alive,
160
+ total: tasks.length,
161
+ done,
162
+ failed: count((s) => FAILED_STATUSES.has(s)),
163
+ running: count((s) => s === 'running' || s === 'assigned'),
164
+ skipped: count((s) => s === 'skipped'),
165
+ pending: count((s) => s === 'pending'),
166
+ next: last.alive ? 'opencastle convoy dashboard' : notDone ? 'opencastle convoy resume' : 'opencastle convoy "<task>"',
167
+ older_unfinished: older ? { id: older.id, name: older.name } : null,
215
168
  }
216
169
  }
217
170
 
218
- /** Bare `convoy`: report the last run and offer the verb that fits its state. */
171
+ /** Bare `convoy`: report the last run and the one verb that fits its state. */
219
172
  function renderStatus(last: LastRun | null, json: boolean): void {
220
173
  if (json) {
221
174
  console.log(JSON.stringify(last, null, 2))
222
175
  return
223
176
  }
224
177
 
178
+ console.log(`\n 🚚 ${c.bold('Convoy')} ${c.dim('(experimental)')}\n`)
225
179
  if (!last) {
226
- console.log(`\n 🚚 ${c.bold('Convoy')} ${c.dim('(experimental)')}\n`)
227
180
  console.log(' No runs yet.\n')
228
181
  console.log(` ${c.bold('Start one:')} ${c.cyan('opencastle convoy "add rate limiting to the API"')}\n`)
229
182
  return
230
183
  }
231
184
 
232
- const mark =
233
- last.status === 'done' ? c.green('✓') : last.status === 'running' ? c.cyan('▶') : c.yellow('!')
234
-
235
- console.log(`\n 🚚 ${c.bold('Convoy')} ${c.dim('(experimental)')}\n`)
236
- console.log(
237
- ` ${mark} ${c.bold(last.name)} ${c.dim(`— ${last.status}`)}` +
238
- (last.kind === 'pipeline' ? c.dim(' (pipeline)') : ''),
239
- )
240
- console.log(
241
- ` ${last.done}/${last.total} done` +
242
- (last.failed ? c.yellow(`, ${last.failed} failed`) : '') +
243
- (last.pending ? c.dim(`, ${last.pending} pending`) : ''),
244
- )
185
+ const resumable = last.next === 'opencastle convoy resume'
186
+ const mark = last.alive ? c.cyan('▶') : resumable ? c.yellow('!') : c.green('✓')
187
+ const state = last.alive ? 'running now' : last.status
188
+ console.log(` ${mark} ${c.bold(last.name)} ${c.dim(`— ${state}`)}`)
189
+ const parts = [`${last.done}/${last.total} done`]
190
+ if (last.failed) parts.push(c.yellow(`${last.failed} failed`))
191
+ if (last.skipped) parts.push(c.yellow(`${last.skipped} skipped`))
192
+ if (last.running) parts.push(`${last.running} running`)
193
+ if (last.pending) parts.push(c.dim(`${last.pending} pending`))
194
+ console.log(` ${parts.join(', ')}`)
195
+ if (last.branch) console.log(` ${c.dim('Branch')} ${last.branch}`)
245
196
  console.log('')
246
197
 
247
- // `retry` reopens the failed tasks of a single convoy. A pipeline is a chain
248
- // of them, and `resume` is what carries the chain on past a failed link — so
249
- // advising `retry` here named a verb that would have run one link in isolation.
250
- if (last.failed > 0 && last.kind === 'convoy') {
251
- console.log(` ${c.bold('Next:')} ${c.cyan('opencastle convoy retry')}`)
252
- console.log(` ${c.dim('re-runs only the failed tasks')}`)
253
- } else if (last.failed > 0 || last.pending > 0 || last.status === 'running') {
254
- console.log(` ${c.bold('Next:')} ${c.cyan('opencastle convoy resume')}`)
255
- console.log(` ${c.dim('continues from the last checkpoint')}`)
256
- } else {
257
- console.log(` ${c.dim('Nothing outstanding. Start another with')} ${c.cyan('opencastle convoy "<task>"')}`)
198
+ const why = last.alive
199
+ ? 'watch it live'
200
+ : resumable
201
+ ? 'runs what is not done — failed, interrupted and skipped tasks — and keeps the rest'
202
+ : 'every task is done; start another'
203
+ console.log(` ${c.bold('Next:')} ${c.cyan(last.next)}`)
204
+ console.log(` ${c.dim(why)}`)
205
+ if (last.older_unfinished) {
206
+ console.log(` ${c.dim(`An earlier run, ${last.older_unfinished.name}, has work left; opencastle convoy resume continues it.`)}`)
258
207
  }
259
208
  console.log('')
260
209
  }
261
210
 
262
- export default async function convoy(ctx: CliContext): Promise<void> {
263
- const { args } = ctx
211
+ // ── Dispatch ──────────────────────────────────────────────────────────────────
264
212
 
265
- const [sub, ...rest] = args
213
+ /** Hand the arguments to another command module. */
214
+ async function delegate(mod: string, ctx: CliContext, args: string[]): Promise<void> {
215
+ const loaded = (await import(`./${mod}.js`)) as { default: (_ctx: CliContext) => Promise<void> }
216
+ await loaded.default({ ...ctx, args })
217
+ }
266
218
 
267
- // `convoy --help` is ours; `convoy plan --help` belongs to the subcommand, which
268
- // is where its flags are actually documented.
269
- const wantsHelp = args.includes('--help') || args.includes('-h')
270
- if (wantsHelp && (sub === undefined || sub === '--help' || sub === '-h')) {
271
- console.log(CONVOY_HELP)
272
- return
273
- }
219
+ function refuse(message: string, hint?: string): never {
220
+ console.error(` ${c.red('✗')} ${message}`)
221
+ if (hint) console.error(` ${c.dim(hint)}`)
222
+ process.exit(1)
223
+ }
274
224
 
275
- const positionals = positionalWords(args)
225
+ /** An unknown flag, named with what replaced it when it is one we removed, or the nearest one we have. */
226
+ async function unknownFlag(flag: string, candidates: string[]): Promise<string> {
227
+ const { REMOVED_FLAGS } = await import('./run.js')
228
+ if (flag in REMOVED_FLAGS) return `${flag} was removed. ${REMOVED_FLAGS[flag]}.`
229
+ const near = nearest(flag, candidates)
230
+ return `Unknown option ${flag}.${near ? ` Did you mean ${near}?` : ''}`
231
+ }
232
+
233
+ export default async function convoy(ctx: CliContext): Promise<void> {
234
+ const { args } = ctx
235
+ const [sub, ...rest] = args
276
236
 
277
237
  switch (sub) {
278
- case undefined:
279
- renderStatus(readLastRun(process.cwd()), false)
238
+ case 'run':
239
+ await delegate('run', ctx, rest)
280
240
  return
281
-
282
241
  case 'resume':
283
- await delegate('run', ctx, ['--resume', ...rest])
284
- return
285
-
286
- case 'retry':
287
- await delegate('run', ctx, ['--retry-failed', ...rest])
242
+ // `retry` is what this was called before resume did everything it did.
243
+ case 'retry': {
244
+ const { resume } = await import('./run.js')
245
+ await resume({ ...ctx, args: rest })
288
246
  return
289
-
247
+ }
290
248
  case 'dashboard':
291
249
  await delegate('dashboard', ctx, rest)
292
250
  return
293
-
294
- case 'run':
295
- // Explicit spec execution, for a .convoy.yml written by hand or by the planner.
296
- await delegate('run', ctx, rest)
297
- return
298
-
299
251
  case 'plan':
300
- // The planner writes a PRD before it writes a spec, and tells you where. Without
301
- // this there was no command that would take that PRD back — the advice dead-ended.
252
+ // The only way to plan again from a PRD someone edited.
302
253
  await delegate('pipeline', ctx, rest)
303
254
  return
304
-
305
255
  default:
306
256
  break
307
257
  }
308
258
 
309
- // A bare flag set with no subcommand is a status query — but only for flags
310
- // this level actually reads. `--file` and `--prd` belong to `run` and `plan`,
311
- // and falling into the status screen meant `convoy --file spec.yml` printed
312
- // "No runs yet" and exited without reading the file, or looking for it: the
313
- // value was never touched, so a path that did not exist produced no error. Our
314
- // own shipped instructions named that form.
259
+ // `convoy --help` is ours; `convoy run --help` belongs to the subcommand.
260
+ if (args.includes('--help') || args.includes('-h')) {
261
+ console.log(CONVOY_HELP)
262
+ return
263
+ }
264
+
265
+ // A flag that belongs to a subcommand used at this level would otherwise
266
+ // be read as part of a task, or dropped.
315
267
  const SUBCOMMAND_FLAGS = new Map([
316
268
  ['--file', 'run'],
317
269
  ['-f', 'run'],
318
270
  ['--prd', 'plan'],
319
- ['--resume', 'resume'],
320
- ['--retry-failed', 'retry'],
321
271
  ])
322
272
  const misplaced = args.find((a) => SUBCOMMAND_FLAGS.has(a))
323
273
  if (misplaced) {
324
274
  const owner = SUBCOMMAND_FLAGS.get(misplaced)!
325
- console.error(` ${c.red('✗')} ${misplaced} belongs to \`opencastle convoy ${owner}\`.`)
326
- console.error(` ${c.dim('Try:')} opencastle convoy ${owner} ${args.slice(args.indexOf(misplaced)).join(' ')}`)
327
- process.exit(1)
275
+ refuse(
276
+ `${misplaced} belongs to \`opencastle convoy ${owner}\`.`,
277
+ `Try: opencastle convoy ${owner} ${args.slice(args.indexOf(misplaced)).join(' ')}`,
278
+ )
328
279
  }
329
280
 
330
- if (sub.startsWith('--')) {
331
- renderStatus(readLastRun(process.cwd()), args.includes('--json'))
281
+ const words = positionalWords(args)
282
+ if (words.length === 0) {
283
+ // Flags alone: the status screen, which reads only --json.
284
+ const stray = args.find((a) => a.startsWith('-') && a !== '--json')
285
+ if (stray) {
286
+ refuse(
287
+ TASK_FLAGS.has(stray) ? `${stray} goes with a task: opencastle convoy "<task>" ${stray}` : await unknownFlag(stray, ['--json', ...TASK_FLAGS]),
288
+ 'Run "opencastle convoy --help" for usage.',
289
+ )
290
+ }
291
+ renderStatus(readLastRun(findProjectRoot(process.cwd()) ?? process.cwd()), args.includes('--json'))
332
292
  return
333
293
  }
334
294
 
335
- // Words that plainly mean "tell me where things stand" are a status query, not
336
- // a feature request. `convoy status` used to spend 95 seconds generating a PRD
337
- // for a feature called "status" — and it is the obvious thing to type, since
338
- // the bare command prints a status report.
339
- if (['status', 'state', 'info', 'ls', 'list'].includes(sub) && positionals.length === 1) {
340
- renderStatus(readLastRun(process.cwd()), args.includes('--json'))
341
- return
295
+ // A single word is not something a planner can act on, and is far more
296
+ // often a mistyped subcommand: `convoy resum` used to start a planning
297
+ // session for a feature called "resum". Planning costs real sessions, so
298
+ // the word is checked before any start.
299
+ if (words.length === 1 && !words[0].includes(' ')) {
300
+ const near = nearest(words[0], SUBCOMMANDS)
301
+ refuse(
302
+ near ? `Unknown subcommand "${words[0]}". Did you mean opencastle convoy ${near}?` : `"${words[0]}" is one word; describe the task in a few.`,
303
+ near
304
+ ? 'To plan a task, describe it in a few words: opencastle convoy "add rate limiting to the API"'
305
+ : 'For example: opencastle convoy "add rate limiting to the API". For the last run: opencastle convoy',
306
+ )
342
307
  }
343
308
 
344
- // Anything else is a task description: plan it, then execute. `pipeline` takes
345
- // it as a flag value, so name it — passing it positionally made the one command
346
- // this tool prints under "Start one:" fail with "Unknown option".
347
- //
348
- // Every word, not just the first. An unquoted task arrives as one argument per
349
- // word, and taking `sub` alone silently planned the first of them.
309
+ // Everything else is a task: plan it, show the plan, ask, run. Every word,
310
+ // not just the first: an unquoted task arrives as one argument per word.
350
311
  const { forward, unknown } = splitTaskFlags(args)
351
312
  if (unknown.length > 0) {
352
- const accepted = [...TASK_FLAGS].sort().join(' ')
353
- console.error(` ${c.red('✗')} Unknown option for a convoy task: ${unknown[0]}`)
354
- console.error(` ${c.dim('Accepts:')} ${accepted} --help`)
355
- console.error(` ${c.dim('For run or plan options:')} opencastle convoy run --help`)
356
- process.exit(1)
313
+ refuse(await unknownFlag(unknown[0], [...TASK_FLAGS]), `A task accepts: ${[...TASK_FLAGS].join(' ')} --help`)
357
314
  }
358
- await delegate('pipeline', ctx, ['--text', positionals.join(' '), ...forward])
315
+ const { planTask } = await import('./pipeline.js')
316
+ await planTask({ ...ctx, args: forward }, words.join(' '))
359
317
  }