opencastle 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (486) hide show
  1. package/README.md +16 -10
  2. package/bin/cli.mjs +8 -9
  3. package/dist/cli/agent-roster.test.js +0 -48
  4. package/dist/cli/agent-roster.test.js.map +1 -1
  5. package/dist/cli/boundary.test.js +9 -7
  6. package/dist/cli/boundary.test.js.map +1 -1
  7. package/dist/cli/convoy/artifacts.d.ts +9 -2
  8. package/dist/cli/convoy/artifacts.d.ts.map +1 -1
  9. package/dist/cli/convoy/artifacts.js +13 -10
  10. package/dist/cli/convoy/artifacts.js.map +1 -1
  11. package/dist/cli/convoy/artifacts.test.js +4 -2
  12. package/dist/cli/convoy/artifacts.test.js.map +1 -1
  13. package/dist/cli/convoy/engine.d.ts +53 -23
  14. package/dist/cli/convoy/engine.d.ts.map +1 -1
  15. package/dist/cli/convoy/engine.git.test.d.ts +2 -0
  16. package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
  17. package/dist/cli/convoy/engine.git.test.js +435 -0
  18. package/dist/cli/convoy/engine.git.test.js.map +1 -0
  19. package/dist/cli/convoy/engine.js +1746 -2305
  20. package/dist/cli/convoy/engine.js.map +1 -1
  21. package/dist/cli/convoy/engine.test.js +698 -678
  22. package/dist/cli/convoy/engine.test.js.map +1 -1
  23. package/dist/cli/convoy/event-schemas.d.ts +2 -0
  24. package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
  25. package/dist/cli/convoy/event-schemas.js +59 -57
  26. package/dist/cli/convoy/event-schemas.js.map +1 -1
  27. package/dist/cli/convoy/events.d.ts +4 -1
  28. package/dist/cli/convoy/events.d.ts.map +1 -1
  29. package/dist/cli/convoy/events.js +69 -84
  30. package/dist/cli/convoy/events.js.map +1 -1
  31. package/dist/cli/convoy/events.test.js +50 -9
  32. package/dist/cli/convoy/events.test.js.map +1 -1
  33. package/dist/cli/convoy/gates.d.ts +9 -4
  34. package/dist/cli/convoy/gates.d.ts.map +1 -1
  35. package/dist/cli/convoy/gates.js +29 -14
  36. package/dist/cli/convoy/gates.js.map +1 -1
  37. package/dist/cli/convoy/isolation.d.ts +32 -6
  38. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  39. package/dist/cli/convoy/isolation.js +72 -34
  40. package/dist/cli/convoy/isolation.js.map +1 -1
  41. package/dist/cli/convoy/isolation.test.js +66 -42
  42. package/dist/cli/convoy/isolation.test.js.map +1 -1
  43. package/dist/cli/convoy/lock.d.ts.map +1 -1
  44. package/dist/cli/convoy/lock.js +25 -10
  45. package/dist/cli/convoy/lock.js.map +1 -1
  46. package/dist/cli/convoy/lock.test.js +12 -0
  47. package/dist/cli/convoy/lock.test.js.map +1 -1
  48. package/dist/cli/convoy/merge.d.ts +21 -4
  49. package/dist/cli/convoy/merge.d.ts.map +1 -1
  50. package/dist/cli/convoy/merge.js +69 -53
  51. package/dist/cli/convoy/merge.js.map +1 -1
  52. package/dist/cli/convoy/merge.test.js +23 -1
  53. package/dist/cli/convoy/merge.test.js.map +1 -1
  54. package/dist/cli/convoy/progress.d.ts +35 -0
  55. package/dist/cli/convoy/progress.d.ts.map +1 -0
  56. package/dist/cli/convoy/progress.js +103 -0
  57. package/dist/cli/convoy/progress.js.map +1 -0
  58. package/dist/cli/convoy/progress.test.d.ts +2 -0
  59. package/dist/cli/convoy/progress.test.d.ts.map +1 -0
  60. package/dist/cli/convoy/progress.test.js +53 -0
  61. package/dist/cli/convoy/progress.test.js.map +1 -0
  62. package/dist/cli/convoy/read-model.d.ts +468 -0
  63. package/dist/cli/convoy/read-model.d.ts.map +1 -0
  64. package/dist/cli/convoy/read-model.js +1132 -0
  65. package/dist/cli/convoy/read-model.js.map +1 -0
  66. package/dist/cli/convoy/read-model.test.d.ts +2 -0
  67. package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
  68. package/dist/cli/convoy/read-model.test.js +609 -0
  69. package/dist/cli/convoy/read-model.test.js.map +1 -0
  70. package/dist/cli/convoy/redact.d.ts +34 -0
  71. package/dist/cli/convoy/redact.d.ts.map +1 -0
  72. package/dist/cli/convoy/redact.js +66 -0
  73. package/dist/cli/convoy/redact.js.map +1 -0
  74. package/dist/cli/convoy/redact.test.d.ts +2 -0
  75. package/dist/cli/convoy/redact.test.d.ts.map +1 -0
  76. package/dist/cli/convoy/redact.test.js +43 -0
  77. package/dist/cli/convoy/redact.test.js.map +1 -0
  78. package/dist/cli/convoy/reviewer.d.ts +65 -0
  79. package/dist/cli/convoy/reviewer.d.ts.map +1 -0
  80. package/dist/cli/convoy/reviewer.js +141 -0
  81. package/dist/cli/convoy/reviewer.js.map +1 -0
  82. package/dist/cli/convoy/reviewer.test.d.ts +2 -0
  83. package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
  84. package/dist/cli/convoy/reviewer.test.js +96 -0
  85. package/dist/cli/convoy/reviewer.test.js.map +1 -0
  86. package/dist/cli/convoy/schedule.d.ts +30 -0
  87. package/dist/cli/convoy/schedule.d.ts.map +1 -0
  88. package/dist/cli/convoy/schedule.js +111 -0
  89. package/dist/cli/convoy/schedule.js.map +1 -0
  90. package/dist/cli/convoy/schedule.test.d.ts +2 -0
  91. package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
  92. package/dist/cli/convoy/schedule.test.js +45 -0
  93. package/dist/cli/convoy/schedule.test.js.map +1 -0
  94. package/dist/cli/convoy/spec-builder.d.ts +120 -30
  95. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  96. package/dist/cli/convoy/spec-builder.js +438 -114
  97. package/dist/cli/convoy/spec-builder.js.map +1 -1
  98. package/dist/cli/convoy/spec-builder.test.js +419 -435
  99. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  100. package/dist/cli/convoy/spec-types.d.ts +46 -92
  101. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  102. package/dist/cli/convoy/store.d.ts +6 -1
  103. package/dist/cli/convoy/store.d.ts.map +1 -1
  104. package/dist/cli/convoy/store.js +111 -15
  105. package/dist/cli/convoy/store.js.map +1 -1
  106. package/dist/cli/convoy/store.test.js +59 -13
  107. package/dist/cli/convoy/store.test.js.map +1 -1
  108. package/dist/cli/convoy/types.d.ts +76 -113
  109. package/dist/cli/convoy/types.d.ts.map +1 -1
  110. package/dist/cli/convoy/types.js +6 -13
  111. package/dist/cli/convoy/types.js.map +1 -1
  112. package/dist/cli/convoy/worktree.d.ts +88 -3
  113. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  114. package/dist/cli/convoy/worktree.js +282 -56
  115. package/dist/cli/convoy/worktree.js.map +1 -1
  116. package/dist/cli/convoy/worktree.test.js +132 -1
  117. package/dist/cli/convoy/worktree.test.js.map +1 -1
  118. package/dist/cli/convoy-args.test.js +9 -27
  119. package/dist/cli/convoy-args.test.js.map +1 -1
  120. package/dist/cli/convoy-cmd.d.ts +31 -6
  121. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  122. package/dist/cli/convoy-cmd.js +150 -201
  123. package/dist/cli/convoy-cmd.js.map +1 -1
  124. package/dist/cli/convoy-cmd.test.d.ts +2 -0
  125. package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
  126. package/dist/cli/convoy-cmd.test.js +144 -0
  127. package/dist/cli/convoy-cmd.test.js.map +1 -0
  128. package/dist/cli/dashboard.d.ts +24 -11
  129. package/dist/cli/dashboard.d.ts.map +1 -1
  130. package/dist/cli/dashboard.js +241 -303
  131. package/dist/cli/dashboard.js.map +1 -1
  132. package/dist/cli/dashboard.test.d.ts +2 -0
  133. package/dist/cli/dashboard.test.d.ts.map +1 -0
  134. package/dist/cli/dashboard.test.js +340 -0
  135. package/dist/cli/dashboard.test.js.map +1 -0
  136. package/dist/cli/dispatcher.test.js +35 -2
  137. package/dist/cli/dispatcher.test.js.map +1 -1
  138. package/dist/cli/docs-accuracy.test.js +3 -3
  139. package/dist/cli/docs-accuracy.test.js.map +1 -1
  140. package/dist/cli/log.d.ts +39 -0
  141. package/dist/cli/log.d.ts.map +1 -1
  142. package/dist/cli/log.js +267 -93
  143. package/dist/cli/log.js.map +1 -1
  144. package/dist/cli/log.test.d.ts +2 -0
  145. package/dist/cli/log.test.d.ts.map +1 -0
  146. package/dist/cli/log.test.js +208 -0
  147. package/dist/cli/log.test.js.map +1 -0
  148. package/dist/cli/nearest.d.ts +18 -0
  149. package/dist/cli/nearest.d.ts.map +1 -0
  150. package/dist/cli/nearest.js +38 -0
  151. package/dist/cli/nearest.js.map +1 -0
  152. package/dist/cli/nearest.test.d.ts +2 -0
  153. package/dist/cli/nearest.test.d.ts.map +1 -0
  154. package/dist/cli/nearest.test.js +24 -0
  155. package/dist/cli/nearest.test.js.map +1 -0
  156. package/dist/cli/pipeline.d.ts +61 -0
  157. package/dist/cli/pipeline.d.ts.map +1 -1
  158. package/dist/cli/pipeline.flow.test.d.ts +2 -0
  159. package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
  160. package/dist/cli/pipeline.flow.test.js +524 -0
  161. package/dist/cli/pipeline.flow.test.js.map +1 -0
  162. package/dist/cli/pipeline.js +471 -690
  163. package/dist/cli/pipeline.js.map +1 -1
  164. package/dist/cli/plan.d.ts +82 -31
  165. package/dist/cli/plan.d.ts.map +1 -1
  166. package/dist/cli/plan.js +167 -507
  167. package/dist/cli/plan.js.map +1 -1
  168. package/dist/cli/plan.test.d.ts +2 -0
  169. package/dist/cli/plan.test.d.ts.map +1 -0
  170. package/dist/cli/plan.test.js +158 -0
  171. package/dist/cli/plan.test.js.map +1 -0
  172. package/dist/cli/run/adapters/agent-process.d.ts +82 -0
  173. package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
  174. package/dist/cli/run/adapters/agent-process.js +224 -0
  175. package/dist/cli/run/adapters/agent-process.js.map +1 -0
  176. package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
  177. package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
  178. package/dist/cli/run/adapters/agent-process.test.js +159 -0
  179. package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
  180. package/dist/cli/run/adapters/claude.d.ts +53 -2
  181. package/dist/cli/run/adapters/claude.d.ts.map +1 -1
  182. package/dist/cli/run/adapters/claude.js +147 -171
  183. package/dist/cli/run/adapters/claude.js.map +1 -1
  184. package/dist/cli/run/adapters/claude.test.js +197 -254
  185. package/dist/cli/run/adapters/claude.test.js.map +1 -1
  186. package/dist/cli/run/adapters/codex.d.ts +25 -2
  187. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  188. package/dist/cli/run/adapters/codex.js +113 -81
  189. package/dist/cli/run/adapters/codex.js.map +1 -1
  190. package/dist/cli/run/adapters/codex.test.js +116 -95
  191. package/dist/cli/run/adapters/codex.test.js.map +1 -1
  192. package/dist/cli/run/adapters/copilot.d.ts +35 -1
  193. package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
  194. package/dist/cli/run/adapters/copilot.js +104 -287
  195. package/dist/cli/run/adapters/copilot.js.map +1 -1
  196. package/dist/cli/run/adapters/copilot.test.js +122 -282
  197. package/dist/cli/run/adapters/copilot.test.js.map +1 -1
  198. package/dist/cli/run/adapters/cursor.d.ts +25 -7
  199. package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
  200. package/dist/cli/run/adapters/cursor.js +103 -156
  201. package/dist/cli/run/adapters/cursor.js.map +1 -1
  202. package/dist/cli/run/adapters/cursor.test.js +106 -218
  203. package/dist/cli/run/adapters/cursor.test.js.map +1 -1
  204. package/dist/cli/run/adapters/index.d.ts +34 -5
  205. package/dist/cli/run/adapters/index.d.ts.map +1 -1
  206. package/dist/cli/run/adapters/index.js +147 -21
  207. package/dist/cli/run/adapters/index.js.map +1 -1
  208. package/dist/cli/run/adapters/index.test.d.ts +2 -0
  209. package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
  210. package/dist/cli/run/adapters/index.test.js +129 -0
  211. package/dist/cli/run/adapters/index.test.js.map +1 -0
  212. package/dist/cli/run/adapters/opencode.d.ts +25 -9
  213. package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
  214. package/dist/cli/run/adapters/opencode.js +136 -152
  215. package/dist/cli/run/adapters/opencode.js.map +1 -1
  216. package/dist/cli/run/adapters/opencode.test.js +99 -218
  217. package/dist/cli/run/adapters/opencode.test.js.map +1 -1
  218. package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
  219. package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
  220. package/dist/cli/run/adapters/permission-modes.js +113 -37
  221. package/dist/cli/run/adapters/permission-modes.js.map +1 -1
  222. package/dist/cli/run/adapters/permission-modes.test.js +55 -40
  223. package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
  224. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
  225. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
  226. package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
  227. package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
  228. package/dist/cli/run/platform.d.ts +52 -0
  229. package/dist/cli/run/platform.d.ts.map +1 -0
  230. package/dist/cli/run/platform.js +207 -0
  231. package/dist/cli/run/platform.js.map +1 -0
  232. package/dist/cli/run/platform.test.d.ts +2 -0
  233. package/dist/cli/run/platform.test.d.ts.map +1 -0
  234. package/dist/cli/run/platform.test.js +119 -0
  235. package/dist/cli/run/platform.test.js.map +1 -0
  236. package/dist/cli/run/schema.d.ts +6 -8
  237. package/dist/cli/run/schema.d.ts.map +1 -1
  238. package/dist/cli/run/schema.js +44 -68
  239. package/dist/cli/run/schema.js.map +1 -1
  240. package/dist/cli/run/schema.test.js +59 -279
  241. package/dist/cli/run/schema.test.js.map +1 -1
  242. package/dist/cli/run.d.ts +34 -56
  243. package/dist/cli/run.d.ts.map +1 -1
  244. package/dist/cli/run.js +379 -1132
  245. package/dist/cli/run.js.map +1 -1
  246. package/dist/cli/run.test.d.ts +2 -0
  247. package/dist/cli/run.test.d.ts.map +1 -0
  248. package/dist/cli/run.test.js +318 -0
  249. package/dist/cli/run.test.js.map +1 -0
  250. package/dist/cli/team-config.d.ts.map +1 -1
  251. package/dist/cli/team-config.js +2 -21
  252. package/dist/cli/team-config.js.map +1 -1
  253. package/dist/cli/tiers.test.js +4 -13
  254. package/dist/cli/tiers.test.js.map +1 -1
  255. package/package.json +3 -10
  256. package/src/cli/agent-roster.test.ts +0 -55
  257. package/src/cli/boundary.test.ts +9 -7
  258. package/src/cli/convoy/TELEMETRY.md +131 -125
  259. package/src/cli/convoy/artifacts.test.ts +4 -2
  260. package/src/cli/convoy/artifacts.ts +13 -12
  261. package/src/cli/convoy/engine.git.test.ts +462 -0
  262. package/src/cli/convoy/engine.test.ts +817 -850
  263. package/src/cli/convoy/engine.ts +1864 -2596
  264. package/src/cli/convoy/event-schemas.ts +63 -59
  265. package/src/cli/convoy/events.test.ts +58 -9
  266. package/src/cli/convoy/events.ts +69 -91
  267. package/src/cli/convoy/gates.ts +31 -12
  268. package/src/cli/convoy/isolation.test.ts +76 -43
  269. package/src/cli/convoy/isolation.ts +100 -38
  270. package/src/cli/convoy/lock.test.ts +16 -0
  271. package/src/cli/convoy/lock.ts +25 -8
  272. package/src/cli/convoy/merge.test.ts +25 -1
  273. package/src/cli/convoy/merge.ts +74 -61
  274. package/src/cli/convoy/progress.test.ts +59 -0
  275. package/src/cli/convoy/progress.ts +121 -0
  276. package/src/cli/convoy/read-model.test.ts +685 -0
  277. package/src/cli/convoy/read-model.ts +1469 -0
  278. package/src/cli/convoy/redact.test.ts +49 -0
  279. package/src/cli/convoy/redact.ts +73 -0
  280. package/src/cli/convoy/reviewer.test.ts +112 -0
  281. package/src/cli/convoy/reviewer.ts +196 -0
  282. package/src/cli/convoy/schedule.test.ts +56 -0
  283. package/src/cli/convoy/schedule.ts +109 -0
  284. package/src/cli/convoy/spec-builder.test.ts +460 -464
  285. package/src/cli/convoy/spec-builder.ts +460 -129
  286. package/src/cli/convoy/spec-types.ts +46 -108
  287. package/src/cli/convoy/store.test.ts +64 -13
  288. package/src/cli/convoy/store.ts +143 -33
  289. package/src/cli/convoy/types.ts +59 -71
  290. package/src/cli/convoy/worktree.test.ts +140 -1
  291. package/src/cli/convoy/worktree.ts +311 -61
  292. package/src/cli/convoy-args.test.ts +10 -30
  293. package/src/cli/convoy-cmd.test.ts +163 -0
  294. package/src/cli/convoy-cmd.ts +173 -216
  295. package/src/cli/dashboard/dashboard.css +2086 -0
  296. package/src/cli/dashboard/dashboard.js +1687 -0
  297. package/src/cli/dashboard/index.html +307 -0
  298. package/src/cli/dashboard.test.ts +382 -0
  299. package/src/cli/dashboard.ts +243 -339
  300. package/src/cli/dispatcher.test.ts +36 -2
  301. package/src/cli/docs-accuracy.test.ts +3 -3
  302. package/src/cli/log.test.ts +228 -0
  303. package/src/cli/log.ts +302 -83
  304. package/src/cli/nearest.test.ts +27 -0
  305. package/src/cli/nearest.ts +38 -0
  306. package/src/cli/pipeline.flow.test.ts +607 -0
  307. package/src/cli/pipeline.ts +544 -759
  308. package/src/cli/plan.test.ts +193 -0
  309. package/src/cli/plan.ts +209 -545
  310. package/src/cli/run/adapters/agent-process.test.ts +175 -0
  311. package/src/cli/run/adapters/agent-process.ts +252 -0
  312. package/src/cli/run/adapters/claude.test.ts +205 -260
  313. package/src/cli/run/adapters/claude.ts +151 -162
  314. package/src/cli/run/adapters/codex.test.ts +120 -100
  315. package/src/cli/run/adapters/codex.ts +115 -91
  316. package/src/cli/run/adapters/copilot.test.ts +135 -306
  317. package/src/cli/run/adapters/copilot.ts +105 -274
  318. package/src/cli/run/adapters/cursor.test.ts +111 -220
  319. package/src/cli/run/adapters/cursor.ts +105 -156
  320. package/src/cli/run/adapters/index.test.ts +148 -0
  321. package/src/cli/run/adapters/index.ts +168 -20
  322. package/src/cli/run/adapters/opencode.test.ts +106 -227
  323. package/src/cli/run/adapters/opencode.ts +139 -151
  324. package/src/cli/run/adapters/permission-modes.test.ts +63 -41
  325. package/src/cli/run/adapters/permission-modes.ts +118 -37
  326. package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
  327. package/src/cli/run/platform.test.ts +128 -0
  328. package/src/cli/run/platform.ts +213 -0
  329. package/src/cli/run/schema.test.ts +62 -344
  330. package/src/cli/run/schema.ts +48 -78
  331. package/src/cli/run.test.ts +351 -0
  332. package/src/cli/run.ts +366 -1151
  333. package/src/cli/team-config.ts +2 -21
  334. package/src/cli/tiers.test.ts +4 -17
  335. package/src/orchestrator/agents/team-lead.agent.md +1 -1
  336. package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
  337. package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
  338. package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
  339. package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
  340. package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
  341. package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
  342. package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
  343. package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
  344. package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
  345. package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
  346. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
  347. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  348. package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
  349. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
  350. package/dist/cli/convoy/dag-analysis.d.ts +0 -39
  351. package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
  352. package/dist/cli/convoy/dag-analysis.js +0 -279
  353. package/dist/cli/convoy/dag-analysis.js.map +0 -1
  354. package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
  355. package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
  356. package/dist/cli/convoy/dag-analysis.test.js +0 -289
  357. package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
  358. package/dist/cli/convoy/formula.d.ts +0 -19
  359. package/dist/cli/convoy/formula.d.ts.map +0 -1
  360. package/dist/cli/convoy/formula.js +0 -142
  361. package/dist/cli/convoy/formula.js.map +0 -1
  362. package/dist/cli/convoy/formula.test.d.ts +0 -2
  363. package/dist/cli/convoy/formula.test.d.ts.map +0 -1
  364. package/dist/cli/convoy/formula.test.js +0 -342
  365. package/dist/cli/convoy/formula.test.js.map +0 -1
  366. package/dist/cli/convoy/health.d.ts +0 -34
  367. package/dist/cli/convoy/health.d.ts.map +0 -1
  368. package/dist/cli/convoy/health.js +0 -123
  369. package/dist/cli/convoy/health.js.map +0 -1
  370. package/dist/cli/convoy/health.test.d.ts +0 -2
  371. package/dist/cli/convoy/health.test.d.ts.map +0 -1
  372. package/dist/cli/convoy/health.test.js +0 -448
  373. package/dist/cli/convoy/health.test.js.map +0 -1
  374. package/dist/cli/convoy/last-run.d.ts +0 -53
  375. package/dist/cli/convoy/last-run.d.ts.map +0 -1
  376. package/dist/cli/convoy/last-run.js +0 -54
  377. package/dist/cli/convoy/last-run.js.map +0 -1
  378. package/dist/cli/convoy/last-run.test.d.ts +0 -2
  379. package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
  380. package/dist/cli/convoy/last-run.test.js +0 -110
  381. package/dist/cli/convoy/last-run.test.js.map +0 -1
  382. package/dist/cli/convoy/pipeline.d.ts +0 -41
  383. package/dist/cli/convoy/pipeline.d.ts.map +0 -1
  384. package/dist/cli/convoy/pipeline.js +0 -414
  385. package/dist/cli/convoy/pipeline.js.map +0 -1
  386. package/dist/cli/convoy/pipeline.test.d.ts +0 -2
  387. package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
  388. package/dist/cli/convoy/pipeline.test.js +0 -837
  389. package/dist/cli/convoy/pipeline.test.js.map +0 -1
  390. package/dist/cli/convoy/review-stages.d.ts +0 -9
  391. package/dist/cli/convoy/review-stages.d.ts.map +0 -1
  392. package/dist/cli/convoy/review-stages.js +0 -134
  393. package/dist/cli/convoy/review-stages.js.map +0 -1
  394. package/dist/cli/convoy/review-stages.test.d.ts +0 -2
  395. package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
  396. package/dist/cli/convoy/review-stages.test.js +0 -197
  397. package/dist/cli/convoy/review-stages.test.js.map +0 -1
  398. package/dist/cli/run/executor.d.ts +0 -15
  399. package/dist/cli/run/executor.d.ts.map +0 -1
  400. package/dist/cli/run/executor.js +0 -249
  401. package/dist/cli/run/executor.js.map +0 -1
  402. package/dist/cli/run/executor.test.d.ts +0 -2
  403. package/dist/cli/run/executor.test.d.ts.map +0 -1
  404. package/dist/cli/run/executor.test.js +0 -297
  405. package/dist/cli/run/executor.test.js.map +0 -1
  406. package/dist/cli/run/reporter.d.ts +0 -10
  407. package/dist/cli/run/reporter.d.ts.map +0 -1
  408. package/dist/cli/run/reporter.js +0 -142
  409. package/dist/cli/run/reporter.js.map +0 -1
  410. package/dist/cli/run-dry-run.test.d.ts +0 -2
  411. package/dist/cli/run-dry-run.test.d.ts.map +0 -1
  412. package/dist/cli/run-dry-run.test.js +0 -83
  413. package/dist/cli/run-dry-run.test.js.map +0 -1
  414. package/dist/cli/run-executor-flags.test.d.ts +0 -2
  415. package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
  416. package/dist/cli/run-executor-flags.test.js +0 -31
  417. package/dist/cli/run-executor-flags.test.js.map +0 -1
  418. package/dist/cli/run-finish.test.d.ts +0 -2
  419. package/dist/cli/run-finish.test.d.ts.map +0 -1
  420. package/dist/cli/run-finish.test.js +0 -77
  421. package/dist/cli/run-finish.test.js.map +0 -1
  422. package/dist/cli/watch.d.ts +0 -15
  423. package/dist/cli/watch.d.ts.map +0 -1
  424. package/dist/cli/watch.js +0 -277
  425. package/dist/cli/watch.js.map +0 -1
  426. package/dist/dashboard/scripts/etl.d.ts +0 -10
  427. package/dist/dashboard/scripts/etl.d.ts.map +0 -1
  428. package/dist/dashboard/scripts/etl.js +0 -141
  429. package/dist/dashboard/scripts/etl.js.map +0 -1
  430. package/src/cli/convoy/dag-analysis.test.ts +0 -349
  431. package/src/cli/convoy/dag-analysis.ts +0 -367
  432. package/src/cli/convoy/formula.test.ts +0 -404
  433. package/src/cli/convoy/formula.ts +0 -174
  434. package/src/cli/convoy/health.test.ts +0 -519
  435. package/src/cli/convoy/health.ts +0 -189
  436. package/src/cli/convoy/last-run.test.ts +0 -130
  437. package/src/cli/convoy/last-run.ts +0 -87
  438. package/src/cli/convoy/pipeline.test.ts +0 -999
  439. package/src/cli/convoy/pipeline.ts +0 -492
  440. package/src/cli/convoy/review-stages.test.ts +0 -235
  441. package/src/cli/convoy/review-stages.ts +0 -166
  442. package/src/cli/run/executor.test.ts +0 -338
  443. package/src/cli/run/executor.ts +0 -292
  444. package/src/cli/run/reporter.ts +0 -160
  445. package/src/cli/run-dry-run.test.ts +0 -97
  446. package/src/cli/run-executor-flags.test.ts +0 -38
  447. package/src/cli/run-finish.test.ts +0 -91
  448. package/src/cli/watch.ts +0 -295
  449. package/src/dashboard/astro.config.mjs +0 -6
  450. package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
  451. package/src/dashboard/dist/data/.gitkeep +0 -0
  452. package/src/dashboard/dist/data/convoy-list.json +0 -1
  453. package/src/dashboard/dist/data/overall-stats.json +0 -29
  454. package/src/dashboard/dist/index.html +0 -1963
  455. package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
  456. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
  457. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
  458. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
  459. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
  460. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
  461. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
  462. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
  463. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
  464. package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
  465. package/src/dashboard/package-lock.json +0 -6
  466. package/src/dashboard/public/data/.gitkeep +0 -0
  467. package/src/dashboard/public/data/convoy-list.json +0 -1
  468. package/src/dashboard/public/data/overall-stats.json +0 -29
  469. package/src/dashboard/public/icon-192.png +0 -0
  470. package/src/dashboard/scripts/etl.test.ts +0 -166
  471. package/src/dashboard/scripts/etl.ts +0 -170
  472. package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
  473. package/src/dashboard/scripts/generate-demo-db.ts +0 -529
  474. package/src/dashboard/scripts/integration-test.ts +0 -504
  475. package/src/dashboard/scripts/verify-demo-data.sh +0 -51
  476. package/src/dashboard/seed-data/delegations.ndjson +0 -35
  477. package/src/dashboard/seed-data/events.ndjson +0 -104
  478. package/src/dashboard/seed-data/panels.ndjson +0 -13
  479. package/src/dashboard/seed-data/reviews.ndjson +0 -6
  480. package/src/dashboard/seed-data/sessions.ndjson +0 -50
  481. package/src/dashboard/src/env.d.ts +0 -1
  482. package/src/dashboard/src/layouts/Layout.astro +0 -25
  483. package/src/dashboard/src/pages/index.astro +0 -2313
  484. package/src/dashboard/src/styles/dashboard.css +0 -2943
  485. package/src/dashboard/tsconfig.json +0 -6
  486. /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
@@ -0,0 +1,49 @@
1
+ import { describe, it, expect, beforeEach } from 'vitest'
2
+ import { maskSecretLine, redactSecrets, redactValue, REDACTED } from './redact.js'
3
+ import { _resetAllowlistCache, _setAllowlistConfigPath, scanForSecrets } from './gates.js'
4
+
5
+ const TOKEN = 'ghp_' + 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9'
6
+
7
+ beforeEach(() => {
8
+ _setAllowlistConfigPath('/nonexistent/secret-scan-config.yml')
9
+ _resetAllowlistCache()
10
+ })
11
+
12
+ describe('maskSecretLine', () => {
13
+ it('hides the value and keeps the words around it', () => {
14
+ const masked = maskSecretLine(`export GITHUB_TOKEN=${TOKEN} # ci`)
15
+ expect(masked).not.toContain(TOKEN)
16
+ expect(masked).toContain(REDACTED)
17
+ expect(masked).toContain('export')
18
+ expect(scanForSecrets(masked).clean).toBe(true)
19
+ })
20
+
21
+ it('drops the whole line when masking tokens is not enough', () => {
22
+ const masked = maskSecretLine('postgres://admin:hunter@db.local/app', 'Connection String')
23
+ expect(masked).toBe(`${REDACTED} (Connection String)`)
24
+ })
25
+ })
26
+
27
+ describe('redactSecrets', () => {
28
+ it('leaves clean text alone', () => {
29
+ expect(redactSecrets('nothing to see\nhere')).toEqual({ text: 'nothing to see\nhere', patterns: [] })
30
+ })
31
+
32
+ it('masks only the flagged lines', () => {
33
+ const r = redactSecrets(`line one\ntoken ${TOKEN}\nline three`)
34
+ expect(r.text.split('\n')[0]).toBe('line one')
35
+ expect(r.text.split('\n')[2]).toBe('line three')
36
+ expect(r.text).not.toContain(TOKEN)
37
+ expect(r.patterns).toEqual(['GitHub Token'])
38
+ })
39
+ })
40
+
41
+ describe('redactValue', () => {
42
+ it('masks strings anywhere in a structure and keeps its shape', () => {
43
+ const { value, patterns } = redactValue({ reason: `token ${TOKEN}`, n: 3, list: ['ok', `x ${TOKEN}`] })
44
+ expect(value.n).toBe(3)
45
+ expect(value.list[0]).toBe('ok')
46
+ expect(JSON.stringify(value)).not.toContain(TOKEN)
47
+ expect(patterns).toHaveLength(2)
48
+ })
49
+ })
@@ -0,0 +1,73 @@
1
+ import { scanForSecrets } from '../secret-scan.js'
2
+
3
+ /**
4
+ * Masking credentials before they are stored.
5
+ *
6
+ * The scanner only said *whether* a line held a secret, so every caller chose
7
+ * between writing the secret and dropping the record. Events were inserted into
8
+ * SQLite unscanned and only the NDJSON copy was blocked — the dashboard then
9
+ * served the SQLite copy, and a resume replayed it into the NDJSON file as well.
10
+ * Masking keeps the record and loses only the value.
11
+ */
12
+
13
+ export const REDACTED = '[REDACTED]'
14
+
15
+ export interface RedactResult {
16
+ text: string
17
+ /** Pattern names that matched, one per masked line. Empty when nothing was masked. */
18
+ patterns: string[]
19
+ }
20
+
21
+ /**
22
+ * Mask the likely value on a line the scanner flagged.
23
+ *
24
+ * Long or digit-bearing tokens are what credentials look like; ordinary words
25
+ * around them ("password", "token", "Bearer") stay, so the line still says what
26
+ * was there. If the line still matches afterwards, the whole line goes.
27
+ */
28
+ export function maskSecretLine(line: string, pattern = 'secret'): string {
29
+ const masked = line.replace(/[A-Za-z0-9_\-+/=.~]{8,}/g, (token) =>
30
+ token.length >= 16 || /\d/.test(token) ? REDACTED : token,
31
+ )
32
+ if (scanForSecrets(masked).clean) return masked
33
+ return `${REDACTED} (${pattern})`
34
+ }
35
+
36
+ /** Mask every line of `text` the scanner flags. */
37
+ export function redactSecrets(text: string): RedactResult {
38
+ const scan = scanForSecrets(text)
39
+ if (scan.clean) return { text, patterns: [] }
40
+ const lines = text.split('\n')
41
+ const patterns: string[] = []
42
+ for (const finding of scan.findings) {
43
+ const i = finding.line - 1
44
+ if (lines[i] === undefined) continue
45
+ lines[i] = maskSecretLine(lines[i], finding.pattern)
46
+ patterns.push(finding.pattern)
47
+ }
48
+ return { text: lines.join('\n'), patterns }
49
+ }
50
+
51
+ /**
52
+ * Mask every string inside a JSON-like value. Structure is kept, so an event's
53
+ * fields stay where readers look for them.
54
+ */
55
+ export function redactValue<T>(value: T): { value: T; patterns: string[] } {
56
+ const patterns: string[] = []
57
+ const walk = (v: unknown): unknown => {
58
+ if (typeof v === 'string') {
59
+ const r = redactSecrets(v)
60
+ patterns.push(...r.patterns)
61
+ return r.text
62
+ }
63
+ if (Array.isArray(v)) return v.map(walk)
64
+ if (v && typeof v === 'object') {
65
+ const out: Record<string, unknown> = {}
66
+ for (const [k, inner] of Object.entries(v as Record<string, unknown>)) out[k] = walk(inner)
67
+ return out
68
+ }
69
+ return v
70
+ }
71
+ const result = walk(value) as T
72
+ return { value: result, patterns }
73
+ }
@@ -0,0 +1,112 @@
1
+ import { describe, it, expect, vi } from 'vitest'
2
+ import { buildReviewPrompt, countChangedLines, defaultReviewer, parseReviewVerdict, type ReviewContext } from './reviewer.js'
3
+ import type { TaskRecord } from './types.js'
4
+
5
+ const task = { id: 'api', agent: 'developer' } as TaskRecord
6
+
7
+ function ctx(overrides: Partial<ReviewContext> = {}): ReviewContext {
8
+ return {
9
+ prompt: 'Build the API',
10
+ files: ['src/api.ts'],
11
+ diff: 'diff --git a/src/api.ts b/src/api.ts\n+export const x = 1\n',
12
+ cwd: '/work/tree',
13
+ adapterName: 'claude',
14
+ execute: vi.fn().mockResolvedValue({
15
+ success: true,
16
+ output: 'Fine.\n<!-- REVIEW_VERDICT { "verdict": "pass", "issues": [] } -->',
17
+ exitCode: 0,
18
+ usage: { prompt_tokens: 800, completion_tokens: 40 },
19
+ costUsd: 0.004,
20
+ model: 'claude-haiku-4-5',
21
+ }),
22
+ canRunReadOnly: true,
23
+ timeoutMs: 60_000,
24
+ ...overrides,
25
+ }
26
+ }
27
+
28
+ describe('parseReviewVerdict', () => {
29
+ it('reads the last verdict comment', () => {
30
+ const out = 'Example: <!-- REVIEW_VERDICT { "verdict": "pass", "issues": [] } -->\nActual:\n<!-- REVIEW_VERDICT { "verdict": "block", "issues": ["no tests"] } -->'
31
+ expect(parseReviewVerdict(out)).toEqual({ verdict: 'block', issues: ['no tests'] })
32
+ })
33
+
34
+ it('returns null for no verdict, bad JSON, or an unknown verdict', () => {
35
+ expect(parseReviewVerdict('looks good to me')).toBeNull()
36
+ expect(parseReviewVerdict('<!-- REVIEW_VERDICT { verdict: pass } -->')).toBeNull()
37
+ expect(parseReviewVerdict('<!-- REVIEW_VERDICT { "verdict": "maybe", "issues": [] } -->')).toBeNull()
38
+ })
39
+ })
40
+
41
+ describe('buildReviewPrompt', () => {
42
+ it('carries the task, its files and the diff, and asks for one verdict line', () => {
43
+ const prompt = buildReviewPrompt(task, ctx())
44
+ expect(prompt).toContain('Build the API')
45
+ expect(prompt).toContain('src/api.ts')
46
+ expect(prompt).toContain('+export const x = 1')
47
+ expect(prompt).toContain('REVIEW_VERDICT')
48
+ expect(prompt).toContain('Do not edit anything')
49
+ })
50
+
51
+ it('truncates a very large diff and says so', () => {
52
+ const prompt = buildReviewPrompt(task, ctx({ diff: 'x'.repeat(100_000) }))
53
+ expect(prompt.length).toBeLessThan(70_000)
54
+ expect(prompt).toContain('diff truncated')
55
+ })
56
+ })
57
+
58
+ describe('defaultReviewer', () => {
59
+ it('runs read-only in the task’s worktree and reports what it spent', async () => {
60
+ const c = ctx()
61
+ const result = await defaultReviewer(task, 'fast', 'claude-haiku-4-5', c)
62
+ expect(c.execute).toHaveBeenCalledWith(
63
+ expect.objectContaining({ id: 'api-review', agent: 'reviewer' }),
64
+ { cwd: '/work/tree', permissionMode: 'plan', model: 'claude-haiku-4-5' },
65
+ )
66
+ expect(result).toEqual({ verdict: 'pass', feedback: '', tokens: 840, model: 'claude-haiku-4-5', costUsd: 0.004 })
67
+ })
68
+
69
+ it('passes no model when neither the spec nor the runtime names one', async () => {
70
+ const c = ctx()
71
+ await defaultReviewer(task, 'fast', 'default', c)
72
+ expect(vi.mocked(c.execute).mock.calls[0][1]).toEqual({ cwd: '/work/tree', permissionMode: 'plan', model: undefined })
73
+ })
74
+
75
+ it('reviews on the runtime\'s economy model when the spec names none', async () => {
76
+ const c = ctx({ defaultModel: 'haiku' })
77
+ await defaultReviewer(task, 'fast', 'default', c)
78
+ expect(vi.mocked(c.execute).mock.calls[0][1]).toMatchObject({ model: 'haiku' })
79
+ // The spec's reviewer_model still wins.
80
+ const pinned = ctx({ defaultModel: 'haiku' })
81
+ await defaultReviewer(task, 'fast', 'sonnet', pinned)
82
+ expect(vi.mocked(pinned.execute).mock.calls[0][1]).toMatchObject({ model: 'sonnet' })
83
+ })
84
+
85
+ it('tells the reviewer the diff is the change, so it does not read the repository', () => {
86
+ expect(buildReviewPrompt(task, ctx())).toMatch(/The diff is the whole change/)
87
+ })
88
+
89
+ it('is skipped, never passed, when it cannot run read-only, fails, times out, or gives no verdict', async () => {
90
+ expect((await defaultReviewer(task, 'fast', 'default', ctx({ canRunReadOnly: false }))).verdict).toBe('skipped')
91
+ expect((await defaultReviewer(task, 'fast', 'default', undefined)).verdict).toBe('skipped')
92
+ const failing = ctx({ execute: vi.fn().mockResolvedValue({ success: false, output: 'boom', exitCode: 1 }) })
93
+ expect(await defaultReviewer(task, 'fast', 'default', failing)).toMatchObject({ verdict: 'skipped', feedback: 'the reviewer exited with code 1' })
94
+ const timedOut = ctx({ execute: vi.fn().mockResolvedValue({ success: false, output: '', exitCode: -1, _timedOut: true }) })
95
+ expect((await defaultReviewer(task, 'fast', 'default', timedOut)).feedback).toBe('the reviewer timed out')
96
+ const mute = ctx({ execute: vi.fn().mockResolvedValue({ success: true, output: 'LGTM', exitCode: 0 }) })
97
+ expect(await defaultReviewer(task, 'fast', 'default', mute)).toMatchObject({ verdict: 'skipped', feedback: 'the reviewer gave no verdict' })
98
+ const throws = ctx({ execute: vi.fn().mockRejectedValue(new Error('spawn ENOENT')) })
99
+ expect((await defaultReviewer(task, 'fast', 'default', throws)).feedback).toContain('spawn ENOENT')
100
+ })
101
+
102
+ it('returns the issues as feedback on a block', async () => {
103
+ const c = ctx({ execute: vi.fn().mockResolvedValue({ success: true, output: '<!-- REVIEW_VERDICT { "verdict": "block", "issues": ["a", "b"] } -->', exitCode: 0 }) })
104
+ expect(await defaultReviewer(task, 'fast', 'default', c)).toMatchObject({ verdict: 'block', feedback: 'a\nb' })
105
+ })
106
+ })
107
+
108
+ describe('countChangedLines', () => {
109
+ it('counts added and removed lines, not the file headers', () => {
110
+ expect(countChangedLines('--- a/x\n+++ b/x\n-old\n+new\n+more\n context')).toBe(3)
111
+ })
112
+ })
@@ -0,0 +1,196 @@
1
+ import type { ReviewHeuristics, Task, ExecuteOptions, ExecuteResult } from './spec-types.js'
2
+ import type { TaskRecord } from './types.js'
3
+
4
+ /**
5
+ * Reviewing a task's change before it is merged.
6
+ *
7
+ * No reviewer was ever wired into the CLI, so every `review: fast` was stored
8
+ * as a pass with 0 tokens and every panel as three passes — reviews counted on
9
+ * the dashboard that never ran. The default reviewer is now the task's own
10
+ * runtime, read-only, in the task's worktree. When it cannot run, or says
11
+ * nothing that parses, the review is recorded as skipped: never as a pass.
12
+ */
13
+
14
+ export interface DiffStats {
15
+ linesChanged: number
16
+ filesChanged: number
17
+ filePaths: string[]
18
+ }
19
+
20
+ export type ReviewLevel = 'auto-pass' | 'fast' | 'panel'
21
+
22
+ export interface ReviewResult {
23
+ /** `skipped` means no verdict was reached; the change is neither passed nor blocked by it. */
24
+ verdict: 'pass' | 'block' | 'skipped'
25
+ feedback: string
26
+ tokens: number
27
+ model: string | null
28
+ costUsd?: number
29
+ }
30
+
31
+ /** What the engine hands a reviewer besides the task. */
32
+ export interface ReviewContext {
33
+ /** The task's own prompt, without retry notes or the shared context. */
34
+ prompt: string
35
+ files: string[]
36
+ diff: string
37
+ cwd: string
38
+ adapterName: string
39
+ /** Runs one agent session; the engine tracks it so Ctrl+C can stop it. */
40
+ execute: (task: Task, options: ExecuteOptions) => Promise<ExecuteResult>
41
+ /** Whether the runtime can run without write access. */
42
+ canRunReadOnly: boolean
43
+ timeoutMs: number
44
+ /** The model to review with when the spec sets no `reviewer_model`: the runtime's economy tier. */
45
+ defaultModel?: string
46
+ }
47
+
48
+ export type ReviewRunner = (
49
+ task: TaskRecord,
50
+ level: ReviewLevel,
51
+ reviewerModel: string,
52
+ ctx?: ReviewContext,
53
+ ) => Promise<ReviewResult>
54
+
55
+ /**
56
+ * How much review a change gets.
57
+ *
58
+ * Small changes pass without a reviewer, everything else gets one fast review.
59
+ * A panel (three reviewers) is expensive, so `auto` never picks it: only a spec
60
+ * that asks for `review: panel` gets one. `panel_paths`/`panel_agents` used to
61
+ * escalate automatically.
62
+ */
63
+ export function evaluateReviewLevel(
64
+ task: Pick<TaskRecord, 'agent'>,
65
+ diff: DiffStats,
66
+ heuristics?: ReviewHeuristics,
67
+ allGatesPassed?: boolean,
68
+ ): ReviewLevel {
69
+ const autoPassAgents = heuristics?.auto_pass_agents ?? ['writer']
70
+ const autoPassMaxLines = heuristics?.auto_pass_max_lines ?? 10
71
+ const autoPassMaxFiles = heuristics?.auto_pass_max_files ?? 2
72
+ const panelPaths = heuristics?.panel_paths ?? ['auth/', 'security/', 'migrations/', 'rls/']
73
+ const panelAgents = heuristics?.panel_agents ?? ['security-expert', 'data-engineer']
74
+
75
+ // Sensitive work is never waved through on size alone.
76
+ const sensitive =
77
+ panelPaths.some((p) => diff.filePaths.some((fp) => fp.startsWith(p) || fp.includes('/' + p))) ||
78
+ panelAgents.includes(task.agent)
79
+ if (sensitive) return 'fast'
80
+
81
+ if (autoPassAgents.includes(task.agent)) return 'auto-pass'
82
+ if (diff.linesChanged <= autoPassMaxLines && diff.filesChanged <= autoPassMaxFiles && allGatesPassed !== false) {
83
+ return 'auto-pass'
84
+ }
85
+ return 'fast'
86
+ }
87
+
88
+ /** Lines added or removed in a unified diff. */
89
+ export function countChangedLines(diff: string): number {
90
+ let n = 0
91
+ for (const line of diff.split('\n')) {
92
+ if ((line.startsWith('+') && !line.startsWith('+++')) || (line.startsWith('-') && !line.startsWith('---'))) n++
93
+ }
94
+ return n
95
+ }
96
+
97
+ const DIFF_LIMIT = 60_000
98
+
99
+ export function buildReviewPrompt(task: Pick<TaskRecord, 'id' | 'agent'>, ctx: Pick<ReviewContext, 'prompt' | 'files' | 'diff'>): string {
100
+ const diff = ctx.diff.length > DIFF_LIMIT
101
+ ? ctx.diff.slice(0, DIFF_LIMIT) + `\n… (diff truncated; ${ctx.diff.length - DIFF_LIMIT} more characters — read the files in this worktree for the rest)`
102
+ : ctx.diff
103
+ return [
104
+ `You are a code reviewer. Another agent (${task.agent}) just finished task "${task.id}" in this git worktree. Review its change before it is merged. Do not edit anything.`,
105
+ '',
106
+ '## The task it was given',
107
+ ctx.prompt.trim(),
108
+ '',
109
+ ctx.files.length > 0 ? `## Files it was allowed to change\n${ctx.files.join(', ')}\n` : '',
110
+ '## The change',
111
+ '```diff',
112
+ diff || '(no changes)',
113
+ '```',
114
+ '',
115
+ 'The diff is the whole change. Open a file only when the diff cannot answer a question, and do not explore the rest of the repository or run the test suite: the convoy runs the project\'s checks after merging. A review that read the repository cost more than the task it reviewed.',
116
+ '',
117
+ '## What to check',
118
+ '1. Does the change do what the task asked, completely?',
119
+ '2. Are there bugs, missing error handling, or broken behaviour?',
120
+ '3. Does it stay within the files it was allowed to change?',
121
+ '',
122
+ 'Block only for problems that must be fixed before merging. End your answer with exactly one verdict line:',
123
+ '<!-- REVIEW_VERDICT { "verdict": "pass", "issues": [] } -->',
124
+ 'or',
125
+ '<!-- REVIEW_VERDICT { "verdict": "block", "issues": ["what must change, and where"] } -->',
126
+ ].filter((l) => l !== '').join('\n')
127
+ }
128
+
129
+ /** The reviewer's verdict, or null when its answer holds none. */
130
+ export function parseReviewVerdict(output: string): { verdict: 'pass' | 'block'; issues: string[] } | null {
131
+ const matches = [...output.matchAll(/<!--\s*REVIEW_VERDICT\s*(\{[\s\S]*?\})\s*-->/g)]
132
+ const last = matches[matches.length - 1]
133
+ if (!last) return null
134
+ let parsed: unknown
135
+ try {
136
+ parsed = JSON.parse(last[1])
137
+ } catch {
138
+ return null
139
+ }
140
+ if (!parsed || typeof parsed !== 'object') return null
141
+ const p = parsed as Record<string, unknown>
142
+ if (p.verdict !== 'pass' && p.verdict !== 'block') return null
143
+ const issues = Array.isArray(p.issues) ? p.issues.filter((i): i is string => typeof i === 'string') : []
144
+ return { verdict: p.verdict, issues }
145
+ }
146
+
147
+ const skipped = (feedback: string, extra: Partial<ReviewResult> = {}): ReviewResult => ({
148
+ verdict: 'skipped',
149
+ feedback,
150
+ tokens: 0,
151
+ model: null,
152
+ ...extra,
153
+ })
154
+
155
+ /**
156
+ * Review with the task's own runtime, read-only (`permissionMode: 'plan'`), in
157
+ * the task's worktree, where the reviewer can open the files it is judging.
158
+ */
159
+ export const defaultReviewer: ReviewRunner = async (task, _level, reviewerModel, ctx) => {
160
+ if (!ctx) return skipped('no reviewer context')
161
+ if (!ctx.canRunReadOnly) {
162
+ return skipped(`the ${ctx.adapterName} runtime cannot run a read-only reviewer`)
163
+ }
164
+ const reviewTask: Task = {
165
+ id: `${task.id}-review`,
166
+ prompt: buildReviewPrompt(task, ctx),
167
+ agent: 'reviewer',
168
+ timeout: `${Math.round(ctx.timeoutMs / 1000)}s`,
169
+ depends_on: [],
170
+ files: [],
171
+ description: `Review of ${task.id}`,
172
+ max_retries: 0,
173
+ }
174
+ let result: ExecuteResult
175
+ try {
176
+ result = await ctx.execute(reviewTask, {
177
+ cwd: ctx.cwd,
178
+ permissionMode: 'plan',
179
+ model: reviewerModel && reviewerModel !== 'default' ? reviewerModel : ctx.defaultModel,
180
+ })
181
+ } catch (err) {
182
+ return skipped(`the reviewer could not start: ${(err as Error).message}`)
183
+ }
184
+ const tokens = result.usage?.total_tokens
185
+ ?? ((result.usage?.prompt_tokens ?? 0) + (result.usage?.completion_tokens ?? 0))
186
+ const spent = { tokens, model: result.model ?? null, costUsd: result.costUsd }
187
+ if (result._timedOut) return skipped('the reviewer timed out', spent)
188
+ if (!result.success) return skipped(`the reviewer exited with code ${result.exitCode}`, spent)
189
+ const verdict = parseReviewVerdict(result.output)
190
+ if (!verdict) return skipped('the reviewer gave no verdict', spent)
191
+ return {
192
+ verdict: verdict.verdict,
193
+ feedback: verdict.issues.join('\n'),
194
+ ...spent,
195
+ }
196
+ }
@@ -0,0 +1,56 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { buildPhases, filesOverlap, formatDuration, pickStartable, taskFiles } from './schedule.js'
3
+ import type { Task } from './spec-types.js'
4
+ import type { TaskRecord } from './types.js'
5
+
6
+ const rec = (id: string, files: string[] = []) => ({ id, files: files.length ? JSON.stringify(files) : null }) as TaskRecord
7
+ const task = (id: string, depends_on: string[] = []) => ({ id, depends_on }) as Task
8
+
9
+ describe('buildPhases', () => {
10
+ it('groups tasks by dependency depth', () => {
11
+ const phases = buildPhases([task('a'), task('b', ['a']), task('c'), task('d', ['b', 'c'])])
12
+ expect(phases.map(p => p.map(t => t.id))).toEqual([['a', 'c'], ['b'], ['d']])
13
+ })
14
+
15
+ it('throws on a cycle', () => {
16
+ expect(() => buildPhases([task('a', ['b']), task('b', ['a'])])).toThrow(/circular/)
17
+ })
18
+ })
19
+
20
+ describe('pickStartable', () => {
21
+ it('fills the free slots in order', () => {
22
+ expect(pickStartable([rec('a'), rec('b'), rec('c')], [], 2).map(t => t.id)).toEqual(['a', 'b'])
23
+ })
24
+
25
+ it('holds back a task whose files overlap a running one, and lets the next one through', () => {
26
+ const picked = pickStartable([rec('b', ['src/api.ts']), rec('c', ['docs/'])], [rec('a', ['src/'])], 2)
27
+ expect(picked.map(t => t.id)).toEqual(['c'])
28
+ })
29
+
30
+ it('checks two picks against each other too', () => {
31
+ const picked = pickStartable([rec('a', ['x.ts']), rec('b', ['x.ts']), rec('c', ['y.ts'])], [], 3)
32
+ expect(picked.map(t => t.id)).toEqual(['a', 'c'])
33
+ })
34
+
35
+ it('never blocks tasks that declare no files', () => {
36
+ expect(pickStartable([rec('b')], [rec('a', ['src/'])], 1).map(t => t.id)).toEqual(['b'])
37
+ })
38
+ })
39
+
40
+ describe('helpers', () => {
41
+ it('normalises declared files', () => {
42
+ expect(taskFiles(rec('a', ['./src/a.ts', 'src\\b.ts']))).toEqual(['src/a.ts', 'src/b.ts'])
43
+ })
44
+
45
+ it('treats a directory as overlapping the files under it, in either case', () => {
46
+ expect(filesOverlap(['src/'], ['src/x.ts'])).toBe(true)
47
+ expect(filesOverlap(['README.md'], ['readme.md'])).toBe(true)
48
+ expect(filesOverlap(['a.ts'], ['b.ts'])).toBe(false)
49
+ })
50
+
51
+ it('formats durations', () => {
52
+ expect(formatDuration(850)).toBe('850ms')
53
+ expect(formatDuration(252_000)).toBe('4m 12s')
54
+ expect(formatDuration(3_780_000)).toBe('1h 3m')
55
+ })
56
+ })
@@ -0,0 +1,109 @@
1
+ import type { Task } from './spec-types.js'
2
+ import type { TaskRecord } from './types.js'
3
+ import { normalizePath, pathsOverlap } from './partition.js'
4
+
5
+ /**
6
+ * Pure scheduling helpers: the plan-time phase split, and which ready tasks may
7
+ * start next to the ones already running.
8
+ */
9
+
10
+ /**
11
+ * Group tasks into phases by dependency depth (Kahn's algorithm).
12
+ *
13
+ * Phases are no longer barriers — the engine starts a task the moment its
14
+ * dependencies are done. They remain the unit of the plan-time partition
15
+ * check and the `phase` column the viewer groups by.
16
+ */
17
+ export function buildPhases(tasks: Task[]): Task[][] {
18
+ const taskMap = new Map<string, Task>()
19
+ for (const t of tasks) taskMap.set(t.id, t)
20
+
21
+ const inDegree = new Map<string, number>()
22
+ const dependents = new Map<string, string[]>()
23
+ for (const t of tasks) {
24
+ inDegree.set(t.id, (t.depends_on || []).filter((d) => taskMap.has(d)).length)
25
+ dependents.set(t.id, [])
26
+ }
27
+ for (const t of tasks) {
28
+ for (const dep of t.depends_on || []) dependents.get(dep)?.push(t.id)
29
+ }
30
+
31
+ const phases: Task[][] = []
32
+ const remaining = new Set(tasks.map((t) => t.id))
33
+ while (remaining.size > 0) {
34
+ const phase: Task[] = []
35
+ for (const id of remaining) {
36
+ if (inDegree.get(id) === 0) phase.push(taskMap.get(id)!)
37
+ }
38
+ if (phase.length === 0) throw new Error('Cannot resolve task order — possible circular dependency')
39
+ phases.push(phase)
40
+ for (const t of phase) {
41
+ remaining.delete(t.id)
42
+ for (const depId of dependents.get(t.id)!) inDegree.set(depId, inDegree.get(depId)! - 1)
43
+ }
44
+ }
45
+ return phases
46
+ }
47
+
48
+ /** A duration for people: `850ms`, `12s`, `4m 12s`, `1h 3m`. */
49
+ export function formatDuration(ms: number): string {
50
+ if (ms < 1000) return `${Math.max(0, Math.round(ms))}ms`
51
+ const seconds = Math.floor(ms / 1000)
52
+ if (seconds < 60) return `${seconds}s`
53
+ const minutes = Math.floor(seconds / 60)
54
+ const remSec = seconds % 60
55
+ if (minutes < 60) return remSec > 0 ? `${minutes}m ${remSec}s` : `${minutes}m`
56
+ const hours = Math.floor(minutes / 60)
57
+ const remMin = minutes % 60
58
+ return remMin > 0 ? `${hours}h ${remMin}m` : `${hours}h`
59
+ }
60
+
61
+ /** The task's declared files, normalised; unparseable entries are kept verbatim. */
62
+ export function taskFiles(task: Pick<TaskRecord, 'files'>): string[] {
63
+ if (!task.files) return []
64
+ let raw: unknown
65
+ try {
66
+ raw = JSON.parse(task.files)
67
+ } catch {
68
+ return []
69
+ }
70
+ if (!Array.isArray(raw)) return []
71
+ return raw.filter((f): f is string => typeof f === 'string').map((f) => {
72
+ try {
73
+ return normalizePath(f)
74
+ } catch {
75
+ return f
76
+ }
77
+ })
78
+ }
79
+
80
+ /** True when two declared file lists share a path, or one contains the other. */
81
+ export function filesOverlap(a: string[], b: string[]): boolean {
82
+ if (a.length === 0 || b.length === 0) return false
83
+ return a.some((x) => b.some((y) => pathsOverlap(x, y) || pathsOverlap(x.toLowerCase(), y.toLowerCase())))
84
+ }
85
+
86
+ /**
87
+ * Which of the ready tasks may start now, in order, given what is running and
88
+ * how many slots are free.
89
+ *
90
+ * A task whose files overlap a running task's waits — the dynamic form of the
91
+ * per-phase partition check, which only ever compared tasks in the same phase.
92
+ * Two tasks picked in the same call are checked against each other too.
93
+ */
94
+ export function pickStartable(
95
+ ready: TaskRecord[],
96
+ running: TaskRecord[],
97
+ freeSlots: number,
98
+ ): TaskRecord[] {
99
+ const picked: TaskRecord[] = []
100
+ const busy = running.map(taskFiles)
101
+ for (const task of ready) {
102
+ if (picked.length >= freeSlots) break
103
+ const files = taskFiles(task)
104
+ if (busy.some((other) => filesOverlap(files, other))) continue
105
+ picked.push(task)
106
+ busy.push(files)
107
+ }
108
+ return picked
109
+ }