opencastle 1.3.1 → 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 (486) hide show
  1. package/README.md +16 -10
  2. package/bin/cli.mjs +8 -9
  3. package/dist/cli/agent-roster.test.js +0 -48
  4. package/dist/cli/agent-roster.test.js.map +1 -1
  5. package/dist/cli/boundary.test.js +9 -7
  6. package/dist/cli/boundary.test.js.map +1 -1
  7. package/dist/cli/convoy/artifacts.d.ts +9 -2
  8. package/dist/cli/convoy/artifacts.d.ts.map +1 -1
  9. package/dist/cli/convoy/artifacts.js +13 -10
  10. package/dist/cli/convoy/artifacts.js.map +1 -1
  11. package/dist/cli/convoy/artifacts.test.js +4 -2
  12. package/dist/cli/convoy/artifacts.test.js.map +1 -1
  13. package/dist/cli/convoy/engine.d.ts +53 -23
  14. package/dist/cli/convoy/engine.d.ts.map +1 -1
  15. package/dist/cli/convoy/engine.git.test.d.ts +2 -0
  16. package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
  17. package/dist/cli/convoy/engine.git.test.js +435 -0
  18. package/dist/cli/convoy/engine.git.test.js.map +1 -0
  19. package/dist/cli/convoy/engine.js +1746 -2305
  20. package/dist/cli/convoy/engine.js.map +1 -1
  21. package/dist/cli/convoy/engine.test.js +698 -678
  22. package/dist/cli/convoy/engine.test.js.map +1 -1
  23. package/dist/cli/convoy/event-schemas.d.ts +2 -0
  24. package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
  25. package/dist/cli/convoy/event-schemas.js +59 -57
  26. package/dist/cli/convoy/event-schemas.js.map +1 -1
  27. package/dist/cli/convoy/events.d.ts +4 -1
  28. package/dist/cli/convoy/events.d.ts.map +1 -1
  29. package/dist/cli/convoy/events.js +69 -84
  30. package/dist/cli/convoy/events.js.map +1 -1
  31. package/dist/cli/convoy/events.test.js +50 -9
  32. package/dist/cli/convoy/events.test.js.map +1 -1
  33. package/dist/cli/convoy/gates.d.ts +9 -4
  34. package/dist/cli/convoy/gates.d.ts.map +1 -1
  35. package/dist/cli/convoy/gates.js +29 -14
  36. package/dist/cli/convoy/gates.js.map +1 -1
  37. package/dist/cli/convoy/isolation.d.ts +32 -6
  38. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  39. package/dist/cli/convoy/isolation.js +72 -34
  40. package/dist/cli/convoy/isolation.js.map +1 -1
  41. package/dist/cli/convoy/isolation.test.js +66 -42
  42. package/dist/cli/convoy/isolation.test.js.map +1 -1
  43. package/dist/cli/convoy/lock.d.ts.map +1 -1
  44. package/dist/cli/convoy/lock.js +25 -10
  45. package/dist/cli/convoy/lock.js.map +1 -1
  46. package/dist/cli/convoy/lock.test.js +12 -0
  47. package/dist/cli/convoy/lock.test.js.map +1 -1
  48. package/dist/cli/convoy/merge.d.ts +21 -4
  49. package/dist/cli/convoy/merge.d.ts.map +1 -1
  50. package/dist/cli/convoy/merge.js +69 -53
  51. package/dist/cli/convoy/merge.js.map +1 -1
  52. package/dist/cli/convoy/merge.test.js +23 -1
  53. package/dist/cli/convoy/merge.test.js.map +1 -1
  54. package/dist/cli/convoy/progress.d.ts +35 -0
  55. package/dist/cli/convoy/progress.d.ts.map +1 -0
  56. package/dist/cli/convoy/progress.js +103 -0
  57. package/dist/cli/convoy/progress.js.map +1 -0
  58. package/dist/cli/convoy/progress.test.d.ts +2 -0
  59. package/dist/cli/convoy/progress.test.d.ts.map +1 -0
  60. package/dist/cli/convoy/progress.test.js +53 -0
  61. package/dist/cli/convoy/progress.test.js.map +1 -0
  62. package/dist/cli/convoy/read-model.d.ts +468 -0
  63. package/dist/cli/convoy/read-model.d.ts.map +1 -0
  64. package/dist/cli/convoy/read-model.js +1132 -0
  65. package/dist/cli/convoy/read-model.js.map +1 -0
  66. package/dist/cli/convoy/read-model.test.d.ts +2 -0
  67. package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
  68. package/dist/cli/convoy/read-model.test.js +609 -0
  69. package/dist/cli/convoy/read-model.test.js.map +1 -0
  70. package/dist/cli/convoy/redact.d.ts +34 -0
  71. package/dist/cli/convoy/redact.d.ts.map +1 -0
  72. package/dist/cli/convoy/redact.js +66 -0
  73. package/dist/cli/convoy/redact.js.map +1 -0
  74. package/dist/cli/convoy/redact.test.d.ts +2 -0
  75. package/dist/cli/convoy/redact.test.d.ts.map +1 -0
  76. package/dist/cli/convoy/redact.test.js +43 -0
  77. package/dist/cli/convoy/redact.test.js.map +1 -0
  78. package/dist/cli/convoy/reviewer.d.ts +65 -0
  79. package/dist/cli/convoy/reviewer.d.ts.map +1 -0
  80. package/dist/cli/convoy/reviewer.js +141 -0
  81. package/dist/cli/convoy/reviewer.js.map +1 -0
  82. package/dist/cli/convoy/reviewer.test.d.ts +2 -0
  83. package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
  84. package/dist/cli/convoy/reviewer.test.js +96 -0
  85. package/dist/cli/convoy/reviewer.test.js.map +1 -0
  86. package/dist/cli/convoy/schedule.d.ts +30 -0
  87. package/dist/cli/convoy/schedule.d.ts.map +1 -0
  88. package/dist/cli/convoy/schedule.js +111 -0
  89. package/dist/cli/convoy/schedule.js.map +1 -0
  90. package/dist/cli/convoy/schedule.test.d.ts +2 -0
  91. package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
  92. package/dist/cli/convoy/schedule.test.js +45 -0
  93. package/dist/cli/convoy/schedule.test.js.map +1 -0
  94. package/dist/cli/convoy/spec-builder.d.ts +120 -30
  95. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  96. package/dist/cli/convoy/spec-builder.js +438 -114
  97. package/dist/cli/convoy/spec-builder.js.map +1 -1
  98. package/dist/cli/convoy/spec-builder.test.js +419 -435
  99. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  100. package/dist/cli/convoy/spec-types.d.ts +46 -92
  101. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  102. package/dist/cli/convoy/store.d.ts +6 -1
  103. package/dist/cli/convoy/store.d.ts.map +1 -1
  104. package/dist/cli/convoy/store.js +111 -15
  105. package/dist/cli/convoy/store.js.map +1 -1
  106. package/dist/cli/convoy/store.test.js +59 -13
  107. package/dist/cli/convoy/store.test.js.map +1 -1
  108. package/dist/cli/convoy/types.d.ts +76 -113
  109. package/dist/cli/convoy/types.d.ts.map +1 -1
  110. package/dist/cli/convoy/types.js +6 -13
  111. package/dist/cli/convoy/types.js.map +1 -1
  112. package/dist/cli/convoy/worktree.d.ts +88 -3
  113. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  114. package/dist/cli/convoy/worktree.js +282 -56
  115. package/dist/cli/convoy/worktree.js.map +1 -1
  116. package/dist/cli/convoy/worktree.test.js +132 -1
  117. package/dist/cli/convoy/worktree.test.js.map +1 -1
  118. package/dist/cli/convoy-args.test.js +9 -27
  119. package/dist/cli/convoy-args.test.js.map +1 -1
  120. package/dist/cli/convoy-cmd.d.ts +31 -6
  121. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  122. package/dist/cli/convoy-cmd.js +150 -201
  123. package/dist/cli/convoy-cmd.js.map +1 -1
  124. package/dist/cli/convoy-cmd.test.d.ts +2 -0
  125. package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
  126. package/dist/cli/convoy-cmd.test.js +144 -0
  127. package/dist/cli/convoy-cmd.test.js.map +1 -0
  128. package/dist/cli/dashboard.d.ts +24 -11
  129. package/dist/cli/dashboard.d.ts.map +1 -1
  130. package/dist/cli/dashboard.js +241 -303
  131. package/dist/cli/dashboard.js.map +1 -1
  132. package/dist/cli/dashboard.test.d.ts +2 -0
  133. package/dist/cli/dashboard.test.d.ts.map +1 -0
  134. package/dist/cli/dashboard.test.js +340 -0
  135. package/dist/cli/dashboard.test.js.map +1 -0
  136. package/dist/cli/dispatcher.test.js +35 -2
  137. package/dist/cli/dispatcher.test.js.map +1 -1
  138. package/dist/cli/docs-accuracy.test.js +3 -3
  139. package/dist/cli/docs-accuracy.test.js.map +1 -1
  140. package/dist/cli/log.d.ts +39 -0
  141. package/dist/cli/log.d.ts.map +1 -1
  142. package/dist/cli/log.js +267 -93
  143. package/dist/cli/log.js.map +1 -1
  144. package/dist/cli/log.test.d.ts +2 -0
  145. package/dist/cli/log.test.d.ts.map +1 -0
  146. package/dist/cli/log.test.js +208 -0
  147. package/dist/cli/log.test.js.map +1 -0
  148. package/dist/cli/nearest.d.ts +18 -0
  149. package/dist/cli/nearest.d.ts.map +1 -0
  150. package/dist/cli/nearest.js +38 -0
  151. package/dist/cli/nearest.js.map +1 -0
  152. package/dist/cli/nearest.test.d.ts +2 -0
  153. package/dist/cli/nearest.test.d.ts.map +1 -0
  154. package/dist/cli/nearest.test.js +24 -0
  155. package/dist/cli/nearest.test.js.map +1 -0
  156. package/dist/cli/pipeline.d.ts +61 -0
  157. package/dist/cli/pipeline.d.ts.map +1 -1
  158. package/dist/cli/pipeline.flow.test.d.ts +2 -0
  159. package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
  160. package/dist/cli/pipeline.flow.test.js +524 -0
  161. package/dist/cli/pipeline.flow.test.js.map +1 -0
  162. package/dist/cli/pipeline.js +471 -690
  163. package/dist/cli/pipeline.js.map +1 -1
  164. package/dist/cli/plan.d.ts +82 -31
  165. package/dist/cli/plan.d.ts.map +1 -1
  166. package/dist/cli/plan.js +167 -507
  167. package/dist/cli/plan.js.map +1 -1
  168. package/dist/cli/plan.test.d.ts +2 -0
  169. package/dist/cli/plan.test.d.ts.map +1 -0
  170. package/dist/cli/plan.test.js +158 -0
  171. package/dist/cli/plan.test.js.map +1 -0
  172. package/dist/cli/run/adapters/agent-process.d.ts +82 -0
  173. package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
  174. package/dist/cli/run/adapters/agent-process.js +224 -0
  175. package/dist/cli/run/adapters/agent-process.js.map +1 -0
  176. package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
  177. package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
  178. package/dist/cli/run/adapters/agent-process.test.js +159 -0
  179. package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
  180. package/dist/cli/run/adapters/claude.d.ts +53 -2
  181. package/dist/cli/run/adapters/claude.d.ts.map +1 -1
  182. package/dist/cli/run/adapters/claude.js +147 -171
  183. package/dist/cli/run/adapters/claude.js.map +1 -1
  184. package/dist/cli/run/adapters/claude.test.js +197 -254
  185. package/dist/cli/run/adapters/claude.test.js.map +1 -1
  186. package/dist/cli/run/adapters/codex.d.ts +25 -2
  187. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  188. package/dist/cli/run/adapters/codex.js +113 -81
  189. package/dist/cli/run/adapters/codex.js.map +1 -1
  190. package/dist/cli/run/adapters/codex.test.js +116 -95
  191. package/dist/cli/run/adapters/codex.test.js.map +1 -1
  192. package/dist/cli/run/adapters/copilot.d.ts +35 -1
  193. package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
  194. package/dist/cli/run/adapters/copilot.js +104 -287
  195. package/dist/cli/run/adapters/copilot.js.map +1 -1
  196. package/dist/cli/run/adapters/copilot.test.js +122 -282
  197. package/dist/cli/run/adapters/copilot.test.js.map +1 -1
  198. package/dist/cli/run/adapters/cursor.d.ts +25 -7
  199. package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
  200. package/dist/cli/run/adapters/cursor.js +103 -156
  201. package/dist/cli/run/adapters/cursor.js.map +1 -1
  202. package/dist/cli/run/adapters/cursor.test.js +106 -218
  203. package/dist/cli/run/adapters/cursor.test.js.map +1 -1
  204. package/dist/cli/run/adapters/index.d.ts +34 -5
  205. package/dist/cli/run/adapters/index.d.ts.map +1 -1
  206. package/dist/cli/run/adapters/index.js +147 -21
  207. package/dist/cli/run/adapters/index.js.map +1 -1
  208. package/dist/cli/run/adapters/index.test.d.ts +2 -0
  209. package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
  210. package/dist/cli/run/adapters/index.test.js +129 -0
  211. package/dist/cli/run/adapters/index.test.js.map +1 -0
  212. package/dist/cli/run/adapters/opencode.d.ts +25 -9
  213. package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
  214. package/dist/cli/run/adapters/opencode.js +136 -152
  215. package/dist/cli/run/adapters/opencode.js.map +1 -1
  216. package/dist/cli/run/adapters/opencode.test.js +99 -218
  217. package/dist/cli/run/adapters/opencode.test.js.map +1 -1
  218. package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
  219. package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
  220. package/dist/cli/run/adapters/permission-modes.js +113 -37
  221. package/dist/cli/run/adapters/permission-modes.js.map +1 -1
  222. package/dist/cli/run/adapters/permission-modes.test.js +55 -40
  223. package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
  224. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
  225. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
  226. package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
  227. package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
  228. package/dist/cli/run/platform.d.ts +52 -0
  229. package/dist/cli/run/platform.d.ts.map +1 -0
  230. package/dist/cli/run/platform.js +207 -0
  231. package/dist/cli/run/platform.js.map +1 -0
  232. package/dist/cli/run/platform.test.d.ts +2 -0
  233. package/dist/cli/run/platform.test.d.ts.map +1 -0
  234. package/dist/cli/run/platform.test.js +119 -0
  235. package/dist/cli/run/platform.test.js.map +1 -0
  236. package/dist/cli/run/schema.d.ts +6 -8
  237. package/dist/cli/run/schema.d.ts.map +1 -1
  238. package/dist/cli/run/schema.js +44 -68
  239. package/dist/cli/run/schema.js.map +1 -1
  240. package/dist/cli/run/schema.test.js +59 -279
  241. package/dist/cli/run/schema.test.js.map +1 -1
  242. package/dist/cli/run.d.ts +34 -56
  243. package/dist/cli/run.d.ts.map +1 -1
  244. package/dist/cli/run.js +379 -1132
  245. package/dist/cli/run.js.map +1 -1
  246. package/dist/cli/run.test.d.ts +2 -0
  247. package/dist/cli/run.test.d.ts.map +1 -0
  248. package/dist/cli/run.test.js +318 -0
  249. package/dist/cli/run.test.js.map +1 -0
  250. package/dist/cli/team-config.d.ts.map +1 -1
  251. package/dist/cli/team-config.js +2 -21
  252. package/dist/cli/team-config.js.map +1 -1
  253. package/dist/cli/tiers.test.js +4 -13
  254. package/dist/cli/tiers.test.js.map +1 -1
  255. package/package.json +3 -10
  256. package/src/cli/agent-roster.test.ts +0 -55
  257. package/src/cli/boundary.test.ts +9 -7
  258. package/src/cli/convoy/TELEMETRY.md +131 -125
  259. package/src/cli/convoy/artifacts.test.ts +4 -2
  260. package/src/cli/convoy/artifacts.ts +13 -12
  261. package/src/cli/convoy/engine.git.test.ts +462 -0
  262. package/src/cli/convoy/engine.test.ts +817 -850
  263. package/src/cli/convoy/engine.ts +1864 -2596
  264. package/src/cli/convoy/event-schemas.ts +63 -59
  265. package/src/cli/convoy/events.test.ts +58 -9
  266. package/src/cli/convoy/events.ts +69 -91
  267. package/src/cli/convoy/gates.ts +31 -12
  268. package/src/cli/convoy/isolation.test.ts +76 -43
  269. package/src/cli/convoy/isolation.ts +100 -38
  270. package/src/cli/convoy/lock.test.ts +16 -0
  271. package/src/cli/convoy/lock.ts +25 -8
  272. package/src/cli/convoy/merge.test.ts +25 -1
  273. package/src/cli/convoy/merge.ts +74 -61
  274. package/src/cli/convoy/progress.test.ts +59 -0
  275. package/src/cli/convoy/progress.ts +121 -0
  276. package/src/cli/convoy/read-model.test.ts +685 -0
  277. package/src/cli/convoy/read-model.ts +1469 -0
  278. package/src/cli/convoy/redact.test.ts +49 -0
  279. package/src/cli/convoy/redact.ts +73 -0
  280. package/src/cli/convoy/reviewer.test.ts +112 -0
  281. package/src/cli/convoy/reviewer.ts +196 -0
  282. package/src/cli/convoy/schedule.test.ts +56 -0
  283. package/src/cli/convoy/schedule.ts +109 -0
  284. package/src/cli/convoy/spec-builder.test.ts +460 -464
  285. package/src/cli/convoy/spec-builder.ts +460 -129
  286. package/src/cli/convoy/spec-types.ts +46 -108
  287. package/src/cli/convoy/store.test.ts +64 -13
  288. package/src/cli/convoy/store.ts +143 -33
  289. package/src/cli/convoy/types.ts +59 -71
  290. package/src/cli/convoy/worktree.test.ts +140 -1
  291. package/src/cli/convoy/worktree.ts +311 -61
  292. package/src/cli/convoy-args.test.ts +10 -30
  293. package/src/cli/convoy-cmd.test.ts +163 -0
  294. package/src/cli/convoy-cmd.ts +173 -216
  295. package/src/cli/dashboard/dashboard.css +2086 -0
  296. package/src/cli/dashboard/dashboard.js +1687 -0
  297. package/src/cli/dashboard/index.html +307 -0
  298. package/src/cli/dashboard.test.ts +382 -0
  299. package/src/cli/dashboard.ts +243 -339
  300. package/src/cli/dispatcher.test.ts +36 -2
  301. package/src/cli/docs-accuracy.test.ts +3 -3
  302. package/src/cli/log.test.ts +228 -0
  303. package/src/cli/log.ts +302 -83
  304. package/src/cli/nearest.test.ts +27 -0
  305. package/src/cli/nearest.ts +38 -0
  306. package/src/cli/pipeline.flow.test.ts +607 -0
  307. package/src/cli/pipeline.ts +544 -759
  308. package/src/cli/plan.test.ts +193 -0
  309. package/src/cli/plan.ts +209 -545
  310. package/src/cli/run/adapters/agent-process.test.ts +175 -0
  311. package/src/cli/run/adapters/agent-process.ts +252 -0
  312. package/src/cli/run/adapters/claude.test.ts +205 -260
  313. package/src/cli/run/adapters/claude.ts +151 -162
  314. package/src/cli/run/adapters/codex.test.ts +120 -100
  315. package/src/cli/run/adapters/codex.ts +115 -91
  316. package/src/cli/run/adapters/copilot.test.ts +135 -306
  317. package/src/cli/run/adapters/copilot.ts +105 -274
  318. package/src/cli/run/adapters/cursor.test.ts +111 -220
  319. package/src/cli/run/adapters/cursor.ts +105 -156
  320. package/src/cli/run/adapters/index.test.ts +148 -0
  321. package/src/cli/run/adapters/index.ts +168 -20
  322. package/src/cli/run/adapters/opencode.test.ts +106 -227
  323. package/src/cli/run/adapters/opencode.ts +139 -151
  324. package/src/cli/run/adapters/permission-modes.test.ts +63 -41
  325. package/src/cli/run/adapters/permission-modes.ts +118 -37
  326. package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
  327. package/src/cli/run/platform.test.ts +128 -0
  328. package/src/cli/run/platform.ts +213 -0
  329. package/src/cli/run/schema.test.ts +62 -344
  330. package/src/cli/run/schema.ts +48 -78
  331. package/src/cli/run.test.ts +351 -0
  332. package/src/cli/run.ts +366 -1151
  333. package/src/cli/team-config.ts +2 -21
  334. package/src/cli/tiers.test.ts +4 -17
  335. package/src/orchestrator/agents/team-lead.agent.md +1 -1
  336. package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
  337. package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
  338. package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
  339. package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
  340. package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
  341. package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
  342. package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
  343. package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
  344. package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
  345. package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
  346. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
  347. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  348. package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
  349. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
  350. package/dist/cli/convoy/dag-analysis.d.ts +0 -39
  351. package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
  352. package/dist/cli/convoy/dag-analysis.js +0 -279
  353. package/dist/cli/convoy/dag-analysis.js.map +0 -1
  354. package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
  355. package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
  356. package/dist/cli/convoy/dag-analysis.test.js +0 -289
  357. package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
  358. package/dist/cli/convoy/formula.d.ts +0 -19
  359. package/dist/cli/convoy/formula.d.ts.map +0 -1
  360. package/dist/cli/convoy/formula.js +0 -142
  361. package/dist/cli/convoy/formula.js.map +0 -1
  362. package/dist/cli/convoy/formula.test.d.ts +0 -2
  363. package/dist/cli/convoy/formula.test.d.ts.map +0 -1
  364. package/dist/cli/convoy/formula.test.js +0 -342
  365. package/dist/cli/convoy/formula.test.js.map +0 -1
  366. package/dist/cli/convoy/health.d.ts +0 -34
  367. package/dist/cli/convoy/health.d.ts.map +0 -1
  368. package/dist/cli/convoy/health.js +0 -123
  369. package/dist/cli/convoy/health.js.map +0 -1
  370. package/dist/cli/convoy/health.test.d.ts +0 -2
  371. package/dist/cli/convoy/health.test.d.ts.map +0 -1
  372. package/dist/cli/convoy/health.test.js +0 -448
  373. package/dist/cli/convoy/health.test.js.map +0 -1
  374. package/dist/cli/convoy/last-run.d.ts +0 -53
  375. package/dist/cli/convoy/last-run.d.ts.map +0 -1
  376. package/dist/cli/convoy/last-run.js +0 -54
  377. package/dist/cli/convoy/last-run.js.map +0 -1
  378. package/dist/cli/convoy/last-run.test.d.ts +0 -2
  379. package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
  380. package/dist/cli/convoy/last-run.test.js +0 -110
  381. package/dist/cli/convoy/last-run.test.js.map +0 -1
  382. package/dist/cli/convoy/pipeline.d.ts +0 -41
  383. package/dist/cli/convoy/pipeline.d.ts.map +0 -1
  384. package/dist/cli/convoy/pipeline.js +0 -414
  385. package/dist/cli/convoy/pipeline.js.map +0 -1
  386. package/dist/cli/convoy/pipeline.test.d.ts +0 -2
  387. package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
  388. package/dist/cli/convoy/pipeline.test.js +0 -837
  389. package/dist/cli/convoy/pipeline.test.js.map +0 -1
  390. package/dist/cli/convoy/review-stages.d.ts +0 -9
  391. package/dist/cli/convoy/review-stages.d.ts.map +0 -1
  392. package/dist/cli/convoy/review-stages.js +0 -134
  393. package/dist/cli/convoy/review-stages.js.map +0 -1
  394. package/dist/cli/convoy/review-stages.test.d.ts +0 -2
  395. package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
  396. package/dist/cli/convoy/review-stages.test.js +0 -197
  397. package/dist/cli/convoy/review-stages.test.js.map +0 -1
  398. package/dist/cli/run/executor.d.ts +0 -15
  399. package/dist/cli/run/executor.d.ts.map +0 -1
  400. package/dist/cli/run/executor.js +0 -249
  401. package/dist/cli/run/executor.js.map +0 -1
  402. package/dist/cli/run/executor.test.d.ts +0 -2
  403. package/dist/cli/run/executor.test.d.ts.map +0 -1
  404. package/dist/cli/run/executor.test.js +0 -297
  405. package/dist/cli/run/executor.test.js.map +0 -1
  406. package/dist/cli/run/reporter.d.ts +0 -10
  407. package/dist/cli/run/reporter.d.ts.map +0 -1
  408. package/dist/cli/run/reporter.js +0 -142
  409. package/dist/cli/run/reporter.js.map +0 -1
  410. package/dist/cli/run-dry-run.test.d.ts +0 -2
  411. package/dist/cli/run-dry-run.test.d.ts.map +0 -1
  412. package/dist/cli/run-dry-run.test.js +0 -83
  413. package/dist/cli/run-dry-run.test.js.map +0 -1
  414. package/dist/cli/run-executor-flags.test.d.ts +0 -2
  415. package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
  416. package/dist/cli/run-executor-flags.test.js +0 -31
  417. package/dist/cli/run-executor-flags.test.js.map +0 -1
  418. package/dist/cli/run-finish.test.d.ts +0 -2
  419. package/dist/cli/run-finish.test.d.ts.map +0 -1
  420. package/dist/cli/run-finish.test.js +0 -77
  421. package/dist/cli/run-finish.test.js.map +0 -1
  422. package/dist/cli/watch.d.ts +0 -15
  423. package/dist/cli/watch.d.ts.map +0 -1
  424. package/dist/cli/watch.js +0 -277
  425. package/dist/cli/watch.js.map +0 -1
  426. package/dist/dashboard/scripts/etl.d.ts +0 -10
  427. package/dist/dashboard/scripts/etl.d.ts.map +0 -1
  428. package/dist/dashboard/scripts/etl.js +0 -141
  429. package/dist/dashboard/scripts/etl.js.map +0 -1
  430. package/src/cli/convoy/dag-analysis.test.ts +0 -349
  431. package/src/cli/convoy/dag-analysis.ts +0 -367
  432. package/src/cli/convoy/formula.test.ts +0 -404
  433. package/src/cli/convoy/formula.ts +0 -174
  434. package/src/cli/convoy/health.test.ts +0 -519
  435. package/src/cli/convoy/health.ts +0 -189
  436. package/src/cli/convoy/last-run.test.ts +0 -130
  437. package/src/cli/convoy/last-run.ts +0 -87
  438. package/src/cli/convoy/pipeline.test.ts +0 -999
  439. package/src/cli/convoy/pipeline.ts +0 -492
  440. package/src/cli/convoy/review-stages.test.ts +0 -235
  441. package/src/cli/convoy/review-stages.ts +0 -166
  442. package/src/cli/run/executor.test.ts +0 -338
  443. package/src/cli/run/executor.ts +0 -292
  444. package/src/cli/run/reporter.ts +0 -160
  445. package/src/cli/run-dry-run.test.ts +0 -97
  446. package/src/cli/run-executor-flags.test.ts +0 -38
  447. package/src/cli/run-finish.test.ts +0 -91
  448. package/src/cli/watch.ts +0 -295
  449. package/src/dashboard/astro.config.mjs +0 -6
  450. package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
  451. package/src/dashboard/dist/data/.gitkeep +0 -0
  452. package/src/dashboard/dist/data/convoy-list.json +0 -1
  453. package/src/dashboard/dist/data/overall-stats.json +0 -29
  454. package/src/dashboard/dist/index.html +0 -1963
  455. package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
  456. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
  457. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
  458. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
  459. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
  460. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
  461. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
  462. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
  463. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
  464. package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
  465. package/src/dashboard/package-lock.json +0 -6
  466. package/src/dashboard/public/data/.gitkeep +0 -0
  467. package/src/dashboard/public/data/convoy-list.json +0 -1
  468. package/src/dashboard/public/data/overall-stats.json +0 -29
  469. package/src/dashboard/public/icon-192.png +0 -0
  470. package/src/dashboard/scripts/etl.test.ts +0 -166
  471. package/src/dashboard/scripts/etl.ts +0 -170
  472. package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
  473. package/src/dashboard/scripts/generate-demo-db.ts +0 -529
  474. package/src/dashboard/scripts/integration-test.ts +0 -504
  475. package/src/dashboard/scripts/verify-demo-data.sh +0 -51
  476. package/src/dashboard/seed-data/delegations.ndjson +0 -35
  477. package/src/dashboard/seed-data/events.ndjson +0 -104
  478. package/src/dashboard/seed-data/panels.ndjson +0 -13
  479. package/src/dashboard/seed-data/reviews.ndjson +0 -6
  480. package/src/dashboard/seed-data/sessions.ndjson +0 -50
  481. package/src/dashboard/src/env.d.ts +0 -1
  482. package/src/dashboard/src/layouts/Layout.astro +0 -25
  483. package/src/dashboard/src/pages/index.astro +0 -2313
  484. package/src/dashboard/src/styles/dashboard.css +0 -2943
  485. package/src/dashboard/tsconfig.json +0 -6
  486. /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
@@ -1,160 +0,0 @@
1
- import { mkdir, writeFile } from 'node:fs/promises'
2
- import { resolve } from 'node:path'
3
- import { formatDuration } from './executor.js'
4
- import { c } from '../prompt.js'
5
- import { appendEvent } from '../log.js'
6
- import type {
7
- TaskSpec,
8
- Task,
9
- TaskResult,
10
- RunReport,
11
- Reporter,
12
- ReporterOptions,
13
- } from '../convoy/spec-types.js'
14
-
15
- /**
16
- * Status icons for terminal output.
17
- */
18
- const ICONS: Record<string, string> = {
19
- start: '▶',
20
- done: '✓',
21
- failed: '✗',
22
- skipped: '⊘',
23
- 'timed-out': '⏱',
24
- }
25
-
26
- /**
27
- * Create a reporter that prints progress to the terminal and writes a JSON report.
28
- */
29
- export function createReporter(spec: TaskSpec, options: ReporterOptions = {}): Reporter {
30
- const reportDir = options.reportDir || resolve(process.cwd(), '.opencastle', 'runs')
31
- const verbose = options.verbose || false
32
-
33
- return {
34
- onTaskStart(task: Task): void {
35
- console.log(` ${ICONS.start} [${task.id}] ${task.description}`)
36
- },
37
-
38
- onTaskDone(task: Task, result: TaskResult): void {
39
- const dur = formatDuration(result.duration)
40
- if (result.status === 'done') {
41
- console.log(` ${ICONS.done} [${task.id}] completed (${dur})`)
42
- } else if (result.status === 'timed-out') {
43
- console.log(` ${ICONS['timed-out']} [${task.id}] timed out after ${task.timeout}`)
44
- } else {
45
- console.log(` ${ICONS.failed} [${task.id}] failed (${dur})`)
46
- if (result.output) {
47
- const lines = result.output.split('\n').slice(0, 5)
48
- for (const line of lines) {
49
- console.log(` ${line}`)
50
- }
51
- if (result.output.split('\n').length > 5) {
52
- console.log(` ... (truncated)`)
53
- }
54
- }
55
- }
56
-
57
- if (verbose && result.output && result.status === 'done') {
58
- console.log(` Output: ${result.output.slice(0, 500)}`)
59
- }
60
-
61
- appendEvent({
62
- type: 'delegation',
63
- timestamp: new Date().toISOString(),
64
- session_id: spec.name,
65
- agent: task.agent,
66
- task: `${task.id}: ${task.description}`,
67
- mechanism: 'run-task',
68
- outcome: result.status === 'done' ? 'success' : result.status,
69
- duration_sec: Math.round(result.duration / 1000),
70
- }).catch(() => {})
71
- },
72
-
73
- onTaskSkipped(task: Task, reason: string): void {
74
- console.log(` ${ICONS.skipped} [${task.id}] skipped — ${reason}`)
75
- },
76
-
77
- onPhaseStart(phase: number, tasks: Task[]): void {
78
- const ids = tasks.map((t) => t.id).join(', ')
79
- console.log(`\n Phase ${phase}: ${ids}`)
80
- },
81
-
82
- async onComplete(report: RunReport): Promise<void> {
83
- console.log(`\n ──────────────────────────────────`)
84
- console.log(` Run complete: ${report.name}`)
85
- console.log(` Duration: ${report.duration}`)
86
- console.log()
87
-
88
- const s = report.summary
89
- const parts: string[] = []
90
- if (s.done > 0) parts.push(`${s.done} done`)
91
- if (s.failed > 0) parts.push(`${s.failed} failed`)
92
- if (s.skipped > 0) parts.push(`${s.skipped} skipped`)
93
- if (s['timed-out'] > 0) parts.push(`${s['timed-out']} timed out`)
94
- console.log(` Tasks: ${s.total} total — ${parts.join(', ')}`)
95
-
96
- // Write JSON report
97
- try {
98
- await mkdir(reportDir, { recursive: true })
99
- const timestamp = new Date()
100
- .toISOString()
101
- .replace(/[:.]/g, '-')
102
- .slice(0, 19)
103
- const reportPath = resolve(reportDir, `${timestamp}.json`)
104
- await writeFile(reportPath, JSON.stringify(report, null, 2), 'utf8')
105
- console.log(` Report: ${reportPath}`)
106
- } catch (err: unknown) {
107
- console.log(` ${ICONS.failed} Could not write report: ${(err as Error).message}`)
108
- }
109
-
110
- await appendEvent({
111
- type: 'session',
112
- timestamp: new Date().toISOString(),
113
- agent: 'opencastle-run',
114
- model: spec.adapter,
115
- task: `Run: ${report.name}`,
116
- outcome: report.summary.failed > 0 || report.summary['timed-out'] > 0 ? 'failure' : 'success',
117
- duration_min: Math.round((new Date(report.completedAt).getTime() - new Date(report.startedAt).getTime()) / 60000),
118
- files_changed: 0,
119
- retries: 0,
120
- mode: 'tasks',
121
- tasks_total: report.summary.total,
122
- tasks_done: report.summary.done,
123
- tasks_failed: report.summary.failed,
124
- tasks_skipped: report.summary.skipped,
125
- }).catch(() => {})
126
-
127
- console.log()
128
- },
129
- }
130
- }
131
-
132
- /**
133
- * Print the execution plan (dry-run mode).
134
- */
135
- export function printExecutionPlan(spec: TaskSpec, phases: Task[][]): void {
136
- console.log(`\n ${c.bold(c.cyan(`🏰 Execution Plan: ${spec.name}`))}`)
137
- console.log(` ${c.dim('Adapter:')} ${c.cyan(spec.adapter)}`)
138
- console.log(` ${c.dim('Concurrency:')} ${c.yellow(String(spec.concurrency))}`)
139
- console.log(` ${c.dim('On failure:')} ${c.yellow(spec.on_failure)}`)
140
- console.log(` ${c.dim('Tasks:')} ${c.yellow(String(spec.tasks?.length ?? 0))}`)
141
- console.log(` ${c.dim('──────────────────────────────────')}`)
142
-
143
- for (let i = 0; i < phases.length; i++) {
144
- const phase = phases[i]
145
- if (i > 0) console.log()
146
- console.log(` ${c.bold(`Phase ${i + 1}:`)}`)
147
- for (const task of phase) {
148
- const deps =
149
- task.depends_on.length > 0
150
- ? c.yellow(` (after: ${task.depends_on.join(', ')})`)
151
- : ''
152
- const files =
153
- task.files.length > 0 ? c.dim(` [${task.files.join(', ')}]`) : ''
154
- console.log(
155
- ` ${c.green(task.id)} — ${task.description} ${c.dim(`[${task.agent}, ${task.timeout}]`)}${deps}${files}`
156
- )
157
- }
158
- }
159
- console.log()
160
- }
@@ -1,97 +0,0 @@
1
- /**
2
- * `--dry-run` on the paths that already had state to act on.
3
- *
4
- * The defect: `opts.dryRun` was read only on the fresh-run path, so
5
- * `convoy run --retry-failed --dry-run` and `--resume --dry-run` accepted the
6
- * flag and then executed agents against the user's repository for real. The one
7
- * flag people reach for to find out what will happen was the one that changed
8
- * nothing.
9
- */
10
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
11
- import {
12
- printRunDryRun,
13
- RETRYABLE_TASK_STATUSES,
14
- RESUMABLE_TASK_STATUSES,
15
- } from './run.js'
16
-
17
- function task(id: string, status: string, agent = 'developer') {
18
- return { id, agent, status }
19
- }
20
-
21
- let out: string[]
22
- beforeEach(() => {
23
- out = []
24
- vi.spyOn(console, 'log').mockImplementation((...a: unknown[]) => {
25
- out.push(a.join(' '))
26
- })
27
- })
28
- afterEach(() => {
29
- vi.restoreAllMocks()
30
- })
31
-
32
- const text = (): string => out.join('\n')
33
-
34
- describe('retryable and resumable status sets', () => {
35
- it('reopens exactly the statuses the engine reopens', () => {
36
- // engine.retryFailed's own list — kept here so a change to one is a change
37
- // to a shared constant rather than a silent divergence.
38
- expect([...RETRYABLE_TASK_STATUSES]).toEqual([
39
- 'failed',
40
- 'gate-failed',
41
- 'timed-out',
42
- 'review-blocked',
43
- 'disputed',
44
- ])
45
- })
46
-
47
- it('resumes the unfinished statuses, and never a done one', () => {
48
- expect([...RESUMABLE_TASK_STATUSES]).toEqual(['pending', 'assigned', 'running'])
49
- expect(RESUMABLE_TASK_STATUSES).not.toContain('done')
50
- })
51
- })
52
-
53
- describe('printRunDryRun', () => {
54
- it('says plainly that nothing will be executed', () => {
55
- printRunDryRun('retry', 'Convoy (Retry Failed)', 'My Run', [task('a', 'failed')], RETRYABLE_TASK_STATUSES)
56
- expect(text()).toContain('[dry-run] Nothing will be executed.')
57
- })
58
-
59
- it('lists only the tasks the verb would touch', () => {
60
- const tasks = [
61
- task('build', 'done'),
62
- task('test', 'failed'),
63
- task('docs', 'gate-failed', 'writer'),
64
- task('ship', 'pending'),
65
- ]
66
- printRunDryRun('retry', 'Convoy (Retry Failed)', 'My Run', tasks, RETRYABLE_TASK_STATUSES)
67
- const s = text()
68
- expect(s).toContain('Would re-run 2 of 4 task(s)')
69
- expect(s).toContain('test')
70
- expect(s).toContain('docs')
71
- // A finished task and a not-yet-started one are not retries.
72
- expect(s).not.toMatch(/^\s+build/m)
73
- expect(s).not.toMatch(/^\s+ship/m)
74
- })
75
-
76
- it('shows each task with its agent and status, so the plan can be checked', () => {
77
- printRunDryRun('resume', 'Convoy (Resume)', 'My Run', [task('api', 'pending', 'architect')], RESUMABLE_TASK_STATUSES)
78
- expect(text()).toMatch(/api.*architect.*pending/)
79
- })
80
-
81
- it('reports an empty work set rather than printing an empty list', () => {
82
- printRunDryRun('resume', 'Convoy (Resume)', 'My Run', [task('a', 'done')], RESUMABLE_TASK_STATUSES)
83
- const s = text()
84
- expect(s).toContain('No unfinished tasks')
85
- expect(s).toContain('pending, assigned, running')
86
- })
87
-
88
- it('uses the verb the user typed when there is nothing to retry', () => {
89
- printRunDryRun('retry', 'Convoy (Retry Failed)', 'My Run', [task('a', 'done')], RETRYABLE_TASK_STATUSES)
90
- expect(text()).toContain('No failed tasks to retry.')
91
- })
92
-
93
- it('names the run, so a preview cannot be mistaken for another one', () => {
94
- printRunDryRun('resume', 'Pipeline (Resume)', 'Checkout Rework', [], RESUMABLE_TASK_STATUSES)
95
- expect(text()).toContain('Pipeline (Resume): Checkout Rework')
96
- })
97
- })
@@ -1,38 +0,0 @@
1
- /**
2
- * A flag is refused when the spec's executor will never read it.
3
- *
4
- * The defect: `--report-dir` is consumed where `createReporter` is called, which
5
- * is the legacy path alone. For a `version: 1` spec — what every generated spec
6
- * is — it was parsed, resolved against cwd, and never handed to the engine,
7
- * which has no report directory at all. `convoy run -f spec.yml --report-dir
8
- * ./out` exited 0 with ./out empty. `--watch` and its companions had the mirror
9
- * problem: they live inside the engine branch, so a legacy or pipeline spec
10
- * accepted them and ran once.
11
- */
12
- import { describe, it, expect } from 'vitest'
13
- import { specExecutor } from './run.js'
14
- import type { TaskSpec } from './convoy/spec-types.js'
15
-
16
- const base = { name: 'S', concurrency: 1, tasks: [{ id: 't', agent: 'developer' }] }
17
-
18
- const spec = (over: Record<string, unknown> = {}): TaskSpec =>
19
- ({ ...base, ...over }) as unknown as TaskSpec
20
-
21
- describe('specExecutor', () => {
22
- it('sends a version 2 spec with a convoy chain to the pipeline orchestrator', () => {
23
- expect(specExecutor(spec({ version: 2, depends_on_convoy: ['a.yml'] }))).toBe('pipeline')
24
- })
25
-
26
- it('sends a version 1 spec to the convoy engine', () => {
27
- expect(specExecutor(spec({ version: 1 }))).toBe('engine')
28
- })
29
-
30
- it('sends a spec with no version to the legacy executor', () => {
31
- expect(specExecutor(spec())).toBe('legacy')
32
- })
33
-
34
- it('puts a generated spec on the engine, which is why --report-dir mattered', () => {
35
- // buildConvoyYaml always writes `version: 1`.
36
- expect(specExecutor(spec({ version: 1, defaults: { timeout: '30m' } }))).toBe('engine')
37
- })
38
- })
@@ -1,91 +0,0 @@
1
- import { readFileSync } from 'node:fs'
2
- import { join } from 'node:path'
3
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
4
- import { finishRun } from './run.js'
5
-
6
- /**
7
- * A run has to stop when it is over.
8
- *
9
- * Five paths finish one — a fresh convoy, a fresh pipeline, a retry, a convoy
10
- * resume and a pipeline resume — and each spelled the ending out by hand. The
11
- * no-dashboard half ended in `process.exit`, which stops whether or not anyone
12
- * remembered to say so. The dashboard half only registered a SIGINT handler, and
13
- * four of the five then fell into the next block: `convoy run` executed the whole
14
- * spec on the engine and then a second time on the legacy executor, and
15
- * `--retry-failed` followed its retry with a full fresh run. Every task twice,
16
- * paid for twice, and only when a dashboard was up — which is why no test saw it.
17
- */
18
-
19
- const repoRoot = join(import.meta.dirname, '..', '..')
20
-
21
- function makeDashboard(): { server: { close: ReturnType<typeof vi.fn<() => void>> }; url: string } {
22
- return { server: { close: vi.fn<() => void>() }, url: 'http://localhost:4300' }
23
- }
24
-
25
- describe('finishRun', () => {
26
- let exit: ReturnType<typeof vi.spyOn>
27
- let log: ReturnType<typeof vi.spyOn>
28
-
29
- beforeEach(() => {
30
- exit = vi.spyOn(process, 'exit').mockImplementation((() => undefined) as never)
31
- log = vi.spyOn(console, 'log').mockImplementation(() => undefined)
32
- })
33
-
34
- afterEach(() => {
35
- vi.restoreAllMocks()
36
- process.removeAllListeners('SIGINT')
37
- })
38
-
39
- it('exits when there is no dashboard to keep alive', () => {
40
- finishRun(null, false)
41
- expect(exit).toHaveBeenCalledWith(0)
42
- })
43
-
44
- it('exits non-zero when the run failed', () => {
45
- finishRun(null, true)
46
- expect(exit).toHaveBeenCalledWith(1)
47
- })
48
-
49
- it('stays up for the dashboard instead of exiting', () => {
50
- const dashboard = makeDashboard()
51
- finishRun(dashboard, false)
52
- expect(exit).not.toHaveBeenCalled()
53
- expect(log.mock.calls.flat().join('\n')).toContain('Press Ctrl+C to stop')
54
- })
55
-
56
- it('carries the run exit code into Ctrl+C', () => {
57
- const dashboard = makeDashboard()
58
- finishRun(dashboard, true)
59
- process.emit('SIGINT')
60
- expect(dashboard.server.close).toHaveBeenCalled()
61
- expect(exit).toHaveBeenCalledWith(1)
62
- })
63
-
64
- it('offers the retry hint only when the run failed', () => {
65
- finishRun(null, false, 'run it again')
66
- expect(log.mock.calls.flat().join('\n')).not.toContain('run it again')
67
-
68
- log.mockClear()
69
- finishRun(null, true, 'run it again')
70
- expect(log.mock.calls.flat().join('\n')).toContain('run it again')
71
- })
72
-
73
- it('offers the retry hint with a dashboard up too', () => {
74
- finishRun(makeDashboard(), true, 'run it again')
75
- expect(log.mock.calls.flat().join('\n')).toContain('run it again')
76
- })
77
- })
78
-
79
- describe('every path that finishes a run hands control back', () => {
80
- it('returns from each finishRun call rather than carrying on', () => {
81
- const src = readFileSync(join(repoRoot, 'src', 'cli', 'run.ts'), 'utf8')
82
- const calls = [...src.matchAll(/(\w+\s+)?finishRun\(/g)]
83
- .filter(m => m[1]?.trim() !== 'function')
84
- expect(calls.length, 'no call sites found — has the helper been renamed?').toBeGreaterThanOrEqual(5)
85
-
86
- const unreturned = calls
87
- .filter(m => m[1]?.trim() !== 'return')
88
- .map(m => src.slice(0, m.index).split('\n').length)
89
- expect(unreturned, `finishRun called without return at line(s): ${unreturned.join(', ')}`).toEqual([])
90
- })
91
- })
package/src/cli/watch.ts DELETED
@@ -1,295 +0,0 @@
1
- import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs'
2
- import { dirname, resolve } from 'node:path'
3
- import type { TaskSpec, AgentAdapter } from './convoy/spec-types.js'
4
- import type { ConvoyResult } from './convoy/engine.js'
5
- import type { WatchConfig } from './convoy/types.js'
6
- import { parseTaskSpecText, parseYaml } from './run/schema.js'
7
- import { c } from './prompt.js'
8
-
9
- export interface WatchLoopOptions {
10
- spec: TaskSpec
11
- specText: string
12
- specPath: string
13
- adapter: AgentAdapter
14
- verbose: boolean
15
- pidPath: string
16
- clearScratchpad: boolean
17
- watchConfigPath: string | null
18
- printResult: (result: ConvoyResult) => void
19
- }
20
-
21
- function parseCronField(field: string, min: number, max: number): number[] {
22
- if (field === '*') {
23
- const all: number[] = []
24
- for (let i = min; i <= max; i++) all.push(i)
25
- return all
26
- }
27
- const values: number[] = []
28
- for (const part of field.split(',')) {
29
- if (part.includes('/')) {
30
- const [rangeStr, stepStr] = part.split('/')
31
- const step = parseInt(stepStr, 10)
32
- if (!Number.isFinite(step) || step < 1) continue
33
- let start = min
34
- let end = max
35
- if (rangeStr !== '*') {
36
- const [s, e] = rangeStr.split('-').map(Number)
37
- start = s
38
- end = e ?? s
39
- }
40
- for (let i = start; i <= end; i += step) values.push(i)
41
- } else if (part.includes('-')) {
42
- const [s, e] = part.split('-').map(Number)
43
- for (let i = s; i <= e; i++) values.push(i)
44
- } else {
45
- const n = parseInt(part, 10)
46
- if (Number.isFinite(n)) values.push(n)
47
- }
48
- }
49
- return values
50
- }
51
-
52
- function cronMatches(schedule: string, date: Date): boolean {
53
- const parts = schedule.trim().split(/\s+/)
54
- if (parts.length !== 5) return false
55
- const [minF, hourF, domF, monF, dowF] = parts
56
- const minute = parseCronField(minF, 0, 59)
57
- const hour = parseCronField(hourF, 0, 23)
58
- const dom = parseCronField(domF, 1, 31)
59
- const mon = parseCronField(monF, 1, 12)
60
- const dow = parseCronField(dowF, 0, 6)
61
- return (
62
- minute.includes(date.getMinutes()) &&
63
- hour.includes(date.getHours()) &&
64
- dom.includes(date.getDate()) &&
65
- mon.includes(date.getMonth() + 1) &&
66
- dow.includes(date.getDay())
67
- )
68
- }
69
-
70
- function sleep(ms: number): Promise<void> {
71
- return new Promise(resolve => setTimeout(resolve, ms))
72
- }
73
-
74
- export async function watchLoop(options: WatchLoopOptions): Promise<void> {
75
- const {
76
- spec,
77
- specPath,
78
- adapter,
79
- verbose,
80
- pidPath,
81
- clearScratchpad,
82
- watchConfigPath,
83
- printResult,
84
- } = options
85
-
86
- // Resolve watch config — from --watch-config file, spec.watch, or default file-change
87
- let watchConfig: WatchConfig
88
- if (watchConfigPath) {
89
- const raw = readFileSync(watchConfigPath, 'utf8')
90
- const parsed = parseYaml(raw) as Record<string, unknown>
91
- watchConfig = parsed as unknown as WatchConfig
92
- } else if (spec.watch) {
93
- watchConfig = spec.watch
94
- } else {
95
- // Default: file-change trigger on the spec file itself
96
- watchConfig = {
97
- triggers: [{ type: 'file-change', glob: specPath, debounce_ms: 500 }],
98
- }
99
- }
100
-
101
- // Write PID file
102
- mkdirSync(dirname(pidPath), { recursive: true })
103
- writeFileSync(pidPath, String(process.pid), 'utf8')
104
-
105
- let shuttingDown = false
106
- let currentRun: Promise<ConvoyResult> | null = null
107
- let cycleNumber = 0
108
-
109
- // Graceful shutdown handlers
110
- function onShutdownSignal(): void {
111
- if (shuttingDown) return
112
- shuttingDown = true
113
- console.log(`\n ${c.yellow('\u26a0')} Watch mode shutting down...`)
114
- // If a run is in progress, we let it finish
115
- if (!currentRun) {
116
- cleanup()
117
- process.exit(0)
118
- }
119
- }
120
-
121
- process.on('SIGTERM', onShutdownSignal)
122
- process.on('SIGINT', onShutdownSignal)
123
-
124
- function cleanup(): void {
125
- try { unlinkSync(pidPath) } catch { /* ignore */ }
126
- process.removeListener('SIGTERM', onShutdownSignal)
127
- process.removeListener('SIGINT', onShutdownSignal)
128
- }
129
-
130
- // Emit watch_started
131
- const { createConvoyStore } = await import('./convoy/store.js')
132
- const { createEventEmitter } = await import('./convoy/events.js')
133
- const dbPath = resolve(process.cwd(), '.opencastle', 'convoy.db')
134
- mkdirSync(dirname(dbPath), { recursive: true })
135
- const evtStore = createConvoyStore(dbPath)
136
- const watchEvents = createEventEmitter(evtStore)
137
-
138
- const triggerTypes = watchConfig.triggers.map(t => t.type).join(',')
139
- watchEvents.emit('watch_started', { trigger_type: triggerTypes, pid: process.pid })
140
-
141
- // Clear scratchpad if requested
142
- if (clearScratchpad || watchConfig.clear_scratchpad) {
143
- evtStore.clearScratchpad()
144
- }
145
-
146
- console.log(`\n ${c.cyan('\ud83d\udc41')} Watch mode active (PID: ${process.pid})`)
147
- console.log(` Triggers: ${watchConfig.triggers.map(t => t.type).join(', ')}`)
148
-
149
- // Set up trigger watchers
150
- let triggerFired = false
151
- let triggerSource = ''
152
- const triggerCleanups: Array<() => void> = []
153
-
154
- for (const trigger of watchConfig.triggers) {
155
- if (trigger.type === 'file-change') {
156
- const { watch } = await import('node:fs')
157
- const debounceMs = trigger.debounce_ms ?? 500
158
- let debounceTimer: ReturnType<typeof setTimeout> | undefined
159
- const globPattern = trigger.glob ?? '**/*'
160
- const watcher = watch(resolve(process.cwd()), { recursive: true }, (_event, filename) => {
161
- if (!filename) return
162
- const globStr = globPattern
163
- let matches = false
164
- if (globStr.includes('*')) {
165
- // Convert simple glob to regex
166
- const re = new RegExp('^' + globStr.replace(/\./g, '\\.').replace(/\*\*/g, '\u29bf').replace(/\*/g, '[^/]*').replace(/\u29bf/g, '.*') + '$')
167
- matches = re.test(filename)
168
- } else {
169
- matches = filename === globStr || filename.endsWith('/' + globStr)
170
- }
171
- if (matches) {
172
- if (debounceTimer) clearTimeout(debounceTimer)
173
- debounceTimer = setTimeout(() => {
174
- triggerFired = true
175
- triggerSource = `file-change:${filename}`
176
- }, debounceMs)
177
- }
178
- })
179
- triggerCleanups.push(() => { watcher.close(); if (debounceTimer) clearTimeout(debounceTimer) })
180
- } else if (trigger.type === 'cron') {
181
- // Poll every 30s to check if cron matches
182
- let lastFired = -1
183
- const interval = setInterval(() => {
184
- const now = new Date()
185
- const minuteKey = now.getFullYear() * 525600 + now.getMonth() * 43800 + now.getDate() * 1440 + now.getHours() * 60 + now.getMinutes()
186
- if (minuteKey !== lastFired && cronMatches(trigger.schedule!, now)) {
187
- lastFired = minuteKey
188
- triggerFired = true
189
- triggerSource = `cron:${trigger.schedule}`
190
- }
191
- }, 30_000)
192
- triggerCleanups.push(() => clearInterval(interval))
193
- } else if (trigger.type === 'git-push') {
194
- // Poll git remote every 60s
195
- let lastRef = ''
196
- const { execFile: execFileCb } = await import('node:child_process')
197
- const { promisify } = await import('node:util')
198
- const execFileAsync = promisify(execFileCb)
199
- const interval = setInterval(async () => {
200
- try {
201
- await execFileAsync('git', ['fetch', '--quiet'], { cwd: process.cwd() })
202
- const { stdout } = await execFileAsync('git', ['rev-parse', 'FETCH_HEAD'], { cwd: process.cwd() })
203
- const ref = stdout.trim()
204
- if (lastRef && ref !== lastRef) {
205
- triggerFired = true
206
- triggerSource = `git-push:${ref.slice(0, 8)}`
207
- }
208
- lastRef = ref
209
- } catch { /* ignore fetch errors */ }
210
- }, 60_000)
211
- triggerCleanups.push(() => clearInterval(interval))
212
- }
213
- }
214
-
215
- // Main watch loop
216
- try {
217
- while (!shuttingDown) {
218
- // Wait for a trigger
219
- while (!triggerFired && !shuttingDown) {
220
- await sleep(500)
221
- }
222
-
223
- if (shuttingDown) break
224
- triggerFired = false
225
-
226
- cycleNumber++
227
- console.log(`\n ${c.cyan('\u27f3')} Watch cycle ${cycleNumber} triggered by: ${triggerSource}`)
228
-
229
- // Retention cleanup of agent identities
230
- try {
231
- evtStore.deleteAgentIdentitiesOlderThan(90)
232
- } catch { /* non-critical */ }
233
-
234
- // Scratchpad retention cleanup
235
- if (watchConfig.scratchpad_retention_days) {
236
- try {
237
- evtStore.clearScratchpadOlderThan(watchConfig.scratchpad_retention_days)
238
- } catch { /* non-critical */ }
239
- }
240
-
241
- watchEvents.emit('watch_cycle_start', { cycle_number: cycleNumber, triggered_by: triggerSource })
242
-
243
- // Re-read spec from disk (may have changed since last cycle)
244
- let cycleSpec: TaskSpec
245
- let cycleSpecText: string
246
- try {
247
- cycleSpecText = readFileSync(specPath, 'utf8')
248
- cycleSpec = parseTaskSpecText(cycleSpecText)
249
- // Apply overrides from original spec
250
- if (spec.concurrency !== 1) cycleSpec.concurrency = spec.concurrency
251
- if (spec.adapter) cycleSpec.adapter = spec.adapter
252
- if (verbose) cycleSpec._verbose = true
253
- } catch (err) {
254
- console.error(` ${c.red('\u2717')} Failed to re-read spec: ${(err as Error).message}`)
255
- watchEvents.emit('watch_cycle_end', { cycle_number: cycleNumber, status: 'error' })
256
- continue
257
- }
258
-
259
- // Run convoy
260
- const { createConvoyEngine } = await import('./convoy/engine.js')
261
- const cycleEngine = createConvoyEngine({
262
- spec: cycleSpec,
263
- specYaml: cycleSpecText,
264
- adapter,
265
- verbose,
266
- })
267
-
268
- let cycleResult: ConvoyResult
269
- try {
270
- currentRun = cycleEngine.run()
271
- cycleResult = await currentRun
272
- currentRun = null
273
- } catch (err) {
274
- currentRun = null
275
- console.error(` ${c.red('\u2717')} Cycle ${cycleNumber} failed: ${(err as Error).message}`)
276
- watchEvents.emit('watch_cycle_end', { cycle_number: cycleNumber, status: 'error' })
277
- continue
278
- }
279
-
280
- printResult(cycleResult)
281
- watchEvents.emit('watch_cycle_end', { cycle_number: cycleNumber, status: cycleResult.status })
282
-
283
- if (shuttingDown) break
284
- }
285
- } finally {
286
- // Clean up
287
- watchEvents.emit('watch_stopped', { reason: shuttingDown ? 'signal' : 'exit' })
288
- watchEvents.close()
289
- evtStore.close()
290
- for (const fn of triggerCleanups) {
291
- try { fn() } catch { /* ignore */ }
292
- }
293
- cleanup()
294
- }
295
- }
@@ -1,6 +0,0 @@
1
- import { defineConfig } from 'astro/config';
2
-
3
- export default defineConfig({
4
- site: 'https://www.opencastle.dev',
5
- base: process.env.DASHBOARD_BASE || '/',
6
- });