oh-my-copilot 5.18.2 → 5.19.2

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 (326) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +206 -104
  4. package/bridge/__pycache__/gyoshu_bridge.cpython-314.pyc +0 -0
  5. package/bridge/claude-md-coordinator.cjs +2 -2
  6. package/bridge/cli.cjs +7155 -4471
  7. package/bridge/mcp-server.cjs +2470 -1027
  8. package/bridge/runtime-cli.cjs +102 -12
  9. package/bridge/team-mcp.cjs +100 -11
  10. package/bridge/team.js +100 -11
  11. package/dist/budget/ledger.d.ts +5 -0
  12. package/dist/budget/ledger.d.ts.map +1 -1
  13. package/dist/budget/ledger.js +2 -1
  14. package/dist/budget/ledger.js.map +1 -1
  15. package/dist/cli/commands/__tests__/factory-forge-cli.test.js +3 -3
  16. package/dist/cli/commands/__tests__/factory-forge-cli.test.js.map +1 -1
  17. package/dist/cli/commands/__tests__/factory-init.test.js +239 -17
  18. package/dist/cli/commands/__tests__/factory-init.test.js.map +1 -1
  19. package/dist/cli/commands/__tests__/factory-run-cli.test.js +103 -2
  20. package/dist/cli/commands/__tests__/factory-run-cli.test.js.map +1 -1
  21. package/dist/cli/commands/factory-board.d.ts +9 -0
  22. package/dist/cli/commands/factory-board.d.ts.map +1 -0
  23. package/dist/cli/commands/factory-board.js +34 -0
  24. package/dist/cli/commands/factory-board.js.map +1 -0
  25. package/dist/cli/commands/factory-check.d.ts +1 -0
  26. package/dist/cli/commands/factory-check.d.ts.map +1 -1
  27. package/dist/cli/commands/factory-check.js +2 -1
  28. package/dist/cli/commands/factory-check.js.map +1 -1
  29. package/dist/cli/commands/factory-poll.d.ts +9 -0
  30. package/dist/cli/commands/factory-poll.d.ts.map +1 -0
  31. package/dist/cli/commands/factory-poll.js +34 -0
  32. package/dist/cli/commands/factory-poll.js.map +1 -0
  33. package/dist/cli/commands/factory-setup.d.ts +2 -0
  34. package/dist/cli/commands/factory-setup.d.ts.map +1 -1
  35. package/dist/cli/commands/factory-setup.js +9 -3
  36. package/dist/cli/commands/factory-setup.js.map +1 -1
  37. package/dist/cli/commands/factory.d.ts +61 -18
  38. package/dist/cli/commands/factory.d.ts.map +1 -1
  39. package/dist/cli/commands/factory.js +325 -53
  40. package/dist/cli/commands/factory.js.map +1 -1
  41. package/dist/factory/__tests__/check-run.test.js +37 -96
  42. package/dist/factory/__tests__/check-run.test.js.map +1 -1
  43. package/dist/factory/__tests__/enqueue-ado.test.d.ts +2 -0
  44. package/dist/factory/__tests__/enqueue-ado.test.d.ts.map +1 -0
  45. package/dist/factory/__tests__/enqueue-ado.test.js +375 -0
  46. package/dist/factory/__tests__/enqueue-ado.test.js.map +1 -0
  47. package/dist/factory/__tests__/enqueue.test.d.ts +2 -0
  48. package/dist/factory/__tests__/enqueue.test.d.ts.map +1 -0
  49. package/dist/factory/__tests__/enqueue.test.js +470 -0
  50. package/dist/factory/__tests__/enqueue.test.js.map +1 -0
  51. package/dist/factory/__tests__/heal-ado.test.d.ts +2 -0
  52. package/dist/factory/__tests__/heal-ado.test.d.ts.map +1 -0
  53. package/dist/factory/__tests__/heal-ado.test.js +237 -0
  54. package/dist/factory/__tests__/heal-ado.test.js.map +1 -0
  55. package/dist/factory/__tests__/listener.test.js +27 -9
  56. package/dist/factory/__tests__/listener.test.js.map +1 -1
  57. package/dist/factory/__tests__/map-frontier.test.js +68 -0
  58. package/dist/factory/__tests__/map-frontier.test.js.map +1 -1
  59. package/dist/factory/__tests__/map-ingest.test.js +4 -3
  60. package/dist/factory/__tests__/map-ingest.test.js.map +1 -1
  61. package/dist/factory/__tests__/poll-ado.test.d.ts +2 -0
  62. package/dist/factory/__tests__/poll-ado.test.d.ts.map +1 -0
  63. package/dist/factory/__tests__/poll-ado.test.js +263 -0
  64. package/dist/factory/__tests__/poll-ado.test.js.map +1 -0
  65. package/dist/factory/__tests__/poll.test.d.ts +2 -0
  66. package/dist/factory/__tests__/poll.test.d.ts.map +1 -0
  67. package/dist/factory/__tests__/poll.test.js +748 -0
  68. package/dist/factory/__tests__/poll.test.js.map +1 -0
  69. package/dist/factory/board/__tests__/board-ado.test.d.ts +2 -0
  70. package/dist/factory/board/__tests__/board-ado.test.d.ts.map +1 -0
  71. package/dist/factory/board/__tests__/board-ado.test.js +194 -0
  72. package/dist/factory/board/__tests__/board-ado.test.js.map +1 -0
  73. package/dist/factory/board/__tests__/board.test.d.ts +2 -0
  74. package/dist/factory/board/__tests__/board.test.d.ts.map +1 -0
  75. package/dist/factory/board/__tests__/board.test.js +287 -0
  76. package/dist/factory/board/__tests__/board.test.js.map +1 -0
  77. package/dist/factory/board/collect.d.ts +145 -0
  78. package/dist/factory/board/collect.d.ts.map +1 -0
  79. package/dist/factory/board/collect.js +330 -0
  80. package/dist/factory/board/collect.js.map +1 -0
  81. package/dist/factory/board/render.d.ts +12 -0
  82. package/dist/factory/board/render.d.ts.map +1 -0
  83. package/dist/factory/board/render.js +93 -0
  84. package/dist/factory/board/render.js.map +1 -0
  85. package/dist/factory/check/__tests__/ado.test.js +14 -1
  86. package/dist/factory/check/__tests__/ado.test.js.map +1 -1
  87. package/dist/factory/check/__tests__/cli.test.js +38 -0
  88. package/dist/factory/check/__tests__/cli.test.js.map +1 -1
  89. package/dist/factory/check/__tests__/rules.test.js +72 -2
  90. package/dist/factory/check/__tests__/rules.test.js.map +1 -1
  91. package/dist/factory/check/cli.d.ts +34 -6
  92. package/dist/factory/check/cli.d.ts.map +1 -1
  93. package/dist/factory/check/cli.js +56 -34
  94. package/dist/factory/check/cli.js.map +1 -1
  95. package/dist/factory/check/rules.d.ts +11 -3
  96. package/dist/factory/check/rules.d.ts.map +1 -1
  97. package/dist/factory/check/rules.js +18 -5
  98. package/dist/factory/check/rules.js.map +1 -1
  99. package/dist/factory/check/score.d.ts +22 -2
  100. package/dist/factory/check/score.d.ts.map +1 -1
  101. package/dist/factory/check/score.js +55 -1
  102. package/dist/factory/check/score.js.map +1 -1
  103. package/dist/factory/enqueue.d.ts +195 -0
  104. package/dist/factory/enqueue.d.ts.map +1 -0
  105. package/dist/factory/enqueue.js +788 -0
  106. package/dist/factory/enqueue.js.map +1 -0
  107. package/dist/factory/heal/cli.d.ts +34 -2
  108. package/dist/factory/heal/cli.d.ts.map +1 -1
  109. package/dist/factory/heal/cli.js +88 -19
  110. package/dist/factory/heal/cli.js.map +1 -1
  111. package/dist/factory/heal/history.d.ts +12 -6
  112. package/dist/factory/heal/history.d.ts.map +1 -1
  113. package/dist/factory/heal/history.js +16 -6
  114. package/dist/factory/heal/history.js.map +1 -1
  115. package/dist/factory/heal/implement.d.ts +3 -1
  116. package/dist/factory/heal/implement.d.ts.map +1 -1
  117. package/dist/factory/heal/implement.js +1 -0
  118. package/dist/factory/heal/implement.js.map +1 -1
  119. package/dist/factory/heal/run.d.ts +3 -0
  120. package/dist/factory/heal/run.d.ts.map +1 -1
  121. package/dist/factory/heal/run.js +1 -1
  122. package/dist/factory/heal/run.js.map +1 -1
  123. package/dist/factory/listener.d.ts +13 -17
  124. package/dist/factory/listener.d.ts.map +1 -1
  125. package/dist/factory/listener.js +37 -63
  126. package/dist/factory/listener.js.map +1 -1
  127. package/dist/factory/map-frontier.d.ts +8 -1
  128. package/dist/factory/map-frontier.d.ts.map +1 -1
  129. package/dist/factory/map-frontier.js +65 -5
  130. package/dist/factory/map-frontier.js.map +1 -1
  131. package/dist/factory/map-ingest.d.ts.map +1 -1
  132. package/dist/factory/map-ingest.js +12 -1
  133. package/dist/factory/map-ingest.js.map +1 -1
  134. package/dist/factory/poll.d.ts +308 -0
  135. package/dist/factory/poll.d.ts.map +1 -0
  136. package/dist/factory/poll.js +677 -0
  137. package/dist/factory/poll.js.map +1 -0
  138. package/dist/factory/run/__tests__/engine.ado.test.js +157 -8
  139. package/dist/factory/run/__tests__/engine.ado.test.js.map +1 -1
  140. package/dist/factory/run/__tests__/engine.outcome.test.d.ts +2 -0
  141. package/dist/factory/run/__tests__/engine.outcome.test.d.ts.map +1 -0
  142. package/dist/factory/run/__tests__/engine.outcome.test.js +223 -0
  143. package/dist/factory/run/__tests__/engine.outcome.test.js.map +1 -0
  144. package/dist/factory/run/__tests__/engine.test.js +91 -0
  145. package/dist/factory/run/__tests__/engine.test.js.map +1 -1
  146. package/dist/factory/run/__tests__/units.test.js +299 -2
  147. package/dist/factory/run/__tests__/units.test.js.map +1 -1
  148. package/dist/factory/run/engine.d.ts +11 -3
  149. package/dist/factory/run/engine.d.ts.map +1 -1
  150. package/dist/factory/run/engine.js +145 -22
  151. package/dist/factory/run/engine.js.map +1 -1
  152. package/dist/factory/run/exec.d.ts +32 -4
  153. package/dist/factory/run/exec.d.ts.map +1 -1
  154. package/dist/factory/run/exec.js +120 -15
  155. package/dist/factory/run/exec.js.map +1 -1
  156. package/dist/factory/run/outcome.d.ts +31 -0
  157. package/dist/factory/run/outcome.d.ts.map +1 -0
  158. package/dist/factory/run/outcome.js +70 -0
  159. package/dist/factory/run/outcome.js.map +1 -0
  160. package/dist/factory/run/review-output.d.ts +6 -1
  161. package/dist/factory/run/review-output.d.ts.map +1 -1
  162. package/dist/factory/run/review-output.js +13 -3
  163. package/dist/factory/run/review-output.js.map +1 -1
  164. package/dist/factory/run/state.d.ts +2 -0
  165. package/dist/factory/run/state.d.ts.map +1 -1
  166. package/dist/factory/run/state.js.map +1 -1
  167. package/dist/factory/setup/__tests__/pipeline-pick.test.d.ts +2 -0
  168. package/dist/factory/setup/__tests__/pipeline-pick.test.d.ts.map +1 -0
  169. package/dist/factory/setup/__tests__/pipeline-pick.test.js +84 -0
  170. package/dist/factory/setup/__tests__/pipeline-pick.test.js.map +1 -0
  171. package/dist/factory/setup/__tests__/setup.test.js +1 -0
  172. package/dist/factory/setup/__tests__/setup.test.js.map +1 -1
  173. package/dist/factory/setup/detect.js +1 -1
  174. package/dist/factory/setup/detect.js.map +1 -1
  175. package/dist/factory/setup/pipeline-pick.d.ts +25 -0
  176. package/dist/factory/setup/pipeline-pick.d.ts.map +1 -0
  177. package/dist/factory/setup/pipeline-pick.js +55 -0
  178. package/dist/factory/setup/pipeline-pick.js.map +1 -0
  179. package/dist/factory/setup/write.d.ts +6 -0
  180. package/dist/factory/setup/write.d.ts.map +1 -1
  181. package/dist/factory/setup/write.js +3 -1
  182. package/dist/factory/setup/write.js.map +1 -1
  183. package/dist/factory/watchdog.d.ts +3 -2
  184. package/dist/factory/watchdog.d.ts.map +1 -1
  185. package/dist/factory/watchdog.js +5 -4
  186. package/dist/factory/watchdog.js.map +1 -1
  187. package/dist/factory/watchdog.test.js +19 -4
  188. package/dist/factory/watchdog.test.js.map +1 -1
  189. package/dist/forge/__tests__/config.test.js +51 -0
  190. package/dist/forge/__tests__/config.test.js.map +1 -1
  191. package/dist/forge/__tests__/gh-argv-baseline.chain.test.js +2 -2
  192. package/dist/forge/__tests__/gh-argv-baseline.chain.test.js.map +1 -1
  193. package/dist/forge/__tests__/gh-argv-baseline.factory.test.js +6 -4
  194. package/dist/forge/__tests__/gh-argv-baseline.factory.test.js.map +1 -1
  195. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.d.ts +2 -0
  196. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.d.ts.map +1 -0
  197. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.js +100 -0
  198. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.js.map +1 -0
  199. package/dist/forge/ado/__tests__/acceptance-scripts.test.js +360 -30
  200. package/dist/forge/ado/__tests__/acceptance-scripts.test.js.map +1 -1
  201. package/dist/forge/ado/__tests__/adapter.test.js +18 -3
  202. package/dist/forge/ado/__tests__/adapter.test.js.map +1 -1
  203. package/dist/forge/ado/__tests__/ci.test.d.ts +2 -0
  204. package/dist/forge/ado/__tests__/ci.test.d.ts.map +1 -0
  205. package/dist/forge/ado/__tests__/ci.test.js +271 -0
  206. package/dist/forge/ado/__tests__/ci.test.js.map +1 -0
  207. package/dist/forge/ado/__tests__/routes.test.js +24 -5
  208. package/dist/forge/ado/__tests__/routes.test.js.map +1 -1
  209. package/dist/forge/ado/__tests__/tracker-writes.test.d.ts +8 -0
  210. package/dist/forge/ado/__tests__/tracker-writes.test.d.ts.map +1 -0
  211. package/dist/forge/ado/__tests__/tracker-writes.test.js +377 -0
  212. package/dist/forge/ado/__tests__/tracker-writes.test.js.map +1 -0
  213. package/dist/forge/ado/__tests__/world.d.ts +4 -0
  214. package/dist/forge/ado/__tests__/world.d.ts.map +1 -1
  215. package/dist/forge/ado/__tests__/world.js +3 -2
  216. package/dist/forge/ado/__tests__/world.js.map +1 -1
  217. package/dist/forge/ado/checks.d.ts +25 -2
  218. package/dist/forge/ado/checks.d.ts.map +1 -1
  219. package/dist/forge/ado/checks.js +47 -23
  220. package/dist/forge/ado/checks.js.map +1 -1
  221. package/dist/forge/ado/ci.d.ts +13 -0
  222. package/dist/forge/ado/ci.d.ts.map +1 -0
  223. package/dist/forge/ado/ci.js +134 -0
  224. package/dist/forge/ado/ci.js.map +1 -0
  225. package/dist/forge/ado/guard.d.ts +19 -6
  226. package/dist/forge/ado/guard.d.ts.map +1 -1
  227. package/dist/forge/ado/guard.js +52 -11
  228. package/dist/forge/ado/guard.js.map +1 -1
  229. package/dist/forge/ado/index.d.ts +7 -1
  230. package/dist/forge/ado/index.d.ts.map +1 -1
  231. package/dist/forge/ado/index.js +16 -3
  232. package/dist/forge/ado/index.js.map +1 -1
  233. package/dist/forge/ado/reviews.d.ts +9 -1
  234. package/dist/forge/ado/reviews.d.ts.map +1 -1
  235. package/dist/forge/ado/reviews.js +45 -1
  236. package/dist/forge/ado/reviews.js.map +1 -1
  237. package/dist/forge/ado/routes.d.ts +35 -5
  238. package/dist/forge/ado/routes.d.ts.map +1 -1
  239. package/dist/forge/ado/routes.js +181 -9
  240. package/dist/forge/ado/routes.js.map +1 -1
  241. package/dist/forge/ado/tracker.d.ts +13 -2
  242. package/dist/forge/ado/tracker.d.ts.map +1 -1
  243. package/dist/forge/ado/tracker.js +139 -3
  244. package/dist/forge/ado/tracker.js.map +1 -1
  245. package/dist/forge/ado/wiql.d.ts +2 -0
  246. package/dist/forge/ado/wiql.d.ts.map +1 -1
  247. package/dist/forge/ado/wiql.js +6 -0
  248. package/dist/forge/ado/wiql.js.map +1 -1
  249. package/dist/forge/body-file.d.ts +17 -0
  250. package/dist/forge/body-file.d.ts.map +1 -0
  251. package/dist/forge/body-file.js +59 -0
  252. package/dist/forge/body-file.js.map +1 -0
  253. package/dist/forge/config.d.ts +3 -1
  254. package/dist/forge/config.d.ts.map +1 -1
  255. package/dist/forge/config.js +37 -2
  256. package/dist/forge/config.js.map +1 -1
  257. package/dist/forge/github/__tests__/argv-parity.test.js +17 -1
  258. package/dist/forge/github/__tests__/argv-parity.test.js.map +1 -1
  259. package/dist/forge/github/gh.d.ts +6 -0
  260. package/dist/forge/github/gh.d.ts.map +1 -1
  261. package/dist/forge/github/gh.js +2 -0
  262. package/dist/forge/github/gh.js.map +1 -1
  263. package/dist/forge/github/reviews.d.ts +2 -0
  264. package/dist/forge/github/reviews.d.ts.map +1 -1
  265. package/dist/forge/github/reviews.js +6 -0
  266. package/dist/forge/github/reviews.js.map +1 -1
  267. package/dist/forge/github/tracker.d.ts +20 -4
  268. package/dist/forge/github/tracker.d.ts.map +1 -1
  269. package/dist/forge/github/tracker.js +59 -5
  270. package/dist/forge/github/tracker.js.map +1 -1
  271. package/dist/forge/types.d.ts +108 -2
  272. package/dist/forge/types.d.ts.map +1 -1
  273. package/dist/forge/types.js +8 -0
  274. package/dist/forge/types.js.map +1 -1
  275. package/dist/graph/schema.d.ts +10 -10
  276. package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js +156 -35
  277. package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js.map +1 -1
  278. package/dist/hooks/session-end/__tests__/check-evidence.test.js +4 -4
  279. package/dist/hooks/session-end/__tests__/check-evidence.test.js.map +1 -1
  280. package/dist/hooks/session-end/__tests__/copilot-liveness.test.js +3 -3
  281. package/dist/hooks/session-end/__tests__/copilot-liveness.test.js.map +1 -1
  282. package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js +3 -3
  283. package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js.map +1 -1
  284. package/dist/hooks/session-end/__tests__/routing.test.js +36 -1
  285. package/dist/hooks/session-end/__tests__/routing.test.js.map +1 -1
  286. package/dist/hooks/session-end/__tests__/spawn-next.test.js +96 -5
  287. package/dist/hooks/session-end/__tests__/spawn-next.test.js.map +1 -1
  288. package/dist/hooks/session-end/__tests__/worker.test.js +38 -2
  289. package/dist/hooks/session-end/__tests__/worker.test.js.map +1 -1
  290. package/dist/hooks/session-end/chain-enqueuer.d.ts.map +1 -1
  291. package/dist/hooks/session-end/chain-enqueuer.js +22 -2
  292. package/dist/hooks/session-end/chain-enqueuer.js.map +1 -1
  293. package/dist/hooks/session-end/routing.d.ts +14 -0
  294. package/dist/hooks/session-end/routing.d.ts.map +1 -1
  295. package/dist/hooks/session-end/routing.js +25 -0
  296. package/dist/hooks/session-end/routing.js.map +1 -1
  297. package/dist/hooks/session-end/spawn-next.d.ts +20 -2
  298. package/dist/hooks/session-end/spawn-next.d.ts.map +1 -1
  299. package/dist/hooks/session-end/spawn-next.js +72 -5
  300. package/dist/hooks/session-end/spawn-next.js.map +1 -1
  301. package/dist/smoke/__tests__/copilot-chain-scenario.test.js +2 -1
  302. package/dist/smoke/__tests__/copilot-chain-scenario.test.js.map +1 -1
  303. package/dist/smoke/copilot-chain-scenario.d.ts.map +1 -1
  304. package/dist/smoke/copilot-chain-scenario.js +5 -1
  305. package/dist/smoke/copilot-chain-scenario.js.map +1 -1
  306. package/dist/team/__tests__/worker-launch-ack.test.js +134 -5
  307. package/dist/team/__tests__/worker-launch-ack.test.js.map +1 -1
  308. package/dist/team/worker-launch-ack.d.ts.map +1 -1
  309. package/dist/team/worker-launch-ack.js +19 -4
  310. package/dist/team/worker-launch-ack.js.map +1 -1
  311. package/docs/CLAUDE.md +1 -1
  312. package/docs/MIGRATION.md +26 -0
  313. package/docs/REFERENCE.md +187 -20
  314. package/docs/design/FACTORY-FINAL-DESIGN.md +1 -1
  315. package/docs/shipyard.md +17 -1
  316. package/package.json +2 -2
  317. package/plugin.json +1 -1
  318. package/scripts/ado-acceptance.mjs +309 -70
  319. package/scripts/lib/backlog-to-workitems.mjs +24 -21
  320. package/skills/ask-navigator/SKILL.md +5 -2
  321. package/skills/drydock/SKILL.md +2 -1
  322. package/skills/harbor/SKILL.md +17 -2
  323. package/skills/intent/SKILL.md +4 -0
  324. package/skills/launch/SKILL.md +35 -2
  325. package/skills/map/SKILL.md +2 -1
  326. package/skills/refit/SKILL.md +1 -0
@@ -0,0 +1,788 @@
1
+ /**
2
+ * `omg factory enqueue --spec <id> --file <tickets.json> [--dry-run] [--json]`
3
+ * (shipyard ↔ factory design §3.2-§3.4, PR 8; Azure DevOps PR 9): push
4
+ * launch's C3-approved tickets to the tracker as child items of the spec,
5
+ * idempotently.
6
+ *
7
+ * - The ticket file is validated strictly (unknown fields, duplicate keys,
8
+ * `blockedBy` cycles, unknown references, AC count, rendered body length,
9
+ * all-vague AC); any refusal exits 2 before anything is written.
10
+ * - The spec's author must be trusted (OWNER, MEMBER or COLLABORATOR), else
11
+ * exit 2: enqueue writes into its body and marks its children.
12
+ * - Every item carries a `shipyard-key: <spec>/<key>` footer. A key counts
13
+ * only on an issue of the configured repository whose author is trusted and
14
+ * whose `Part of #<spec>` line names the spec; any other holder is ignored
15
+ * and reported, so an external issue cannot claim a key. Holders come from
16
+ * the key search and from the spec's task-list children: GitHub search is
17
+ * eventually consistent, so the task list is rewritten right after each
18
+ * create and a re-run after a partial failure finds what it created. An
19
+ * immediate re-run may still need a short wait when a create landed but
20
+ * its task-list write did not.
21
+ * - Per key: missing → created; present and equal → unchanged (no write);
22
+ * present, changed and unclaimed → updated; claimed (closed, a factory run
23
+ * state, an open or merged `factory/issue-<n>` PR, or the branch on origin)
24
+ * → kept-claimed, never edited. A key in the tracker but not in the file is
25
+ * reported `orphaned` and never closed.
26
+ * - `Blocked by #n` lines are written in a second pass, once every id is
27
+ * known; the spec body's `<!-- shipyard:tickets -->` task list is rewritten
28
+ * as one section.
29
+ * - Model-written text is neutralized before it is posted from the user's
30
+ * account: @-mentions, `#n`, `GH-n` and `owner/repo#n` references and issue
31
+ * or PR urls go into code spans (nobody is notified, no backlink appears),
32
+ * `<!--` is escaped (no comment hides the rest of the body from a reader),
33
+ * and `omg-plan:`, `shipyard-key:`, `Acceptance criteria` headings, edge,
34
+ * parent and task-list lines are escaped so they cannot become trusted
35
+ * plan, key or edge input.
36
+ * - The mark step is `omg factory check <ids> --mark --yes` over this file's
37
+ * created, updated and unchanged items only (never an orphan or any other
38
+ * task-list line of the spec); the dry run lists exactly those mark
39
+ * candidates, so the C3 signature covers them (design Q11), and with the intake label enqueue adds
40
+ * at create it is what makes the runnable children factory work.
41
+ *
42
+ * Writes go through the factory guard with a TrackerWriteContext (the 7a
43
+ * shapes: `gh issue create|edit --repo … --body-file`, the key search); body
44
+ * files sit in a fresh temporary directory outside the worktree. Every other
45
+ * gh and git call is one of `omg factory check`'s read shapes. `--dry-run`
46
+ * never sets the write mode, so the guard refuses any write it might reach.
47
+ *
48
+ * Azure DevOps (design §3.3): a work item of `factory.intake.itemTypes[0]`;
49
+ * the description is the ticket body plus the key footer (the adapter
50
+ * escapes it into HTML), the AC go to Microsoft.VSTS.Common.AcceptanceCriteria
51
+ * and the priority to Microsoft.VSTS.Common.Priority; the parent is a
52
+ * Hierarchy-Reverse link and each edge a Dependency-Reverse link (added once
53
+ * every id is known; a link is never removed, a dropped edge is a warning),
54
+ * and the spec is never edited. Trust is `System.CreatedBy.uniqueName` in
55
+ * `factory.forge.azureDevOps.trustedAuthors` (user config only); spec, `#n` edges
56
+ * and key holders must be items of the forge project. An area-tag intake
57
+ * source gives a new item its tag and area path; a board-column or saved
58
+ * query source is warned about, since enqueue never sets a column or state.
59
+ * Model text loses its `@`/`#n`/`!n` signs to fullwidth look-alikes, so no
60
+ * mention or work item link forms. The az calls are the read guard's, and
61
+ * while writing the work item create and PATCH go through the factory guard
62
+ * with the TrackerWriteContext (PR 7b's routes).
63
+ *
64
+ * Exit codes: 0 enqueued (or planned), 1 a tracker read or write failed, or
65
+ * the mark step did, 2 usage or a refused ticket file (nothing written), 5
66
+ * incompatible (no forge, or an unsupported one).
67
+ */
68
+ import chalk from 'chalk';
69
+ import { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
70
+ import { tmpdir } from 'os';
71
+ import { isAbsolute, join, relative } from 'path';
72
+ import { isAdoCommand } from '../forge/ado/guard.js';
73
+ import { adoHtmlToText } from '../forge/ado/html.js';
74
+ import { adoGuardContext } from '../forge/ado/index.js';
75
+ import { adoListHtml, adoTextHtml } from '../forge/ado/tracker.js';
76
+ import { ForgeConfigError, resolveForgeConfig } from '../forge/config.js';
77
+ import { ghRepoArg } from '../forge/github/gh.js';
78
+ import { shipyardKeyLine, shipyardKeys } from '../forge/types.js';
79
+ import { isPlainBranchName } from '../ship/config.js';
80
+ import { TRUSTED_READ_ENV } from '../ship/exec.js';
81
+ import { baseLayer, CheckIncompatibleError, CheckUsageError, checkGuardExec, defaultResolveAz, EXIT_CHECK_FAILED, fetchBase, parseItemId, runFactoryCheck, } from './check/cli.js';
82
+ import { isVague } from './check/rules.js';
83
+ import { plainText } from './check/score.js';
84
+ import { factoryForgeOptions } from './run/forge-roots.js';
85
+ import { factoryGuardExec, FactorySafetyError, MAX_TRACKER_BODY_CHARS } from './run/exec.js';
86
+ import { factoryBranch, readFactoryState, TERMINAL_FACTORY_PHASES } from './run/state.js';
87
+ export const ENQUEUE_SCHEMA_VERSION = 1;
88
+ /** The most tickets one file may carry (one launch effort; each is a few gh calls). */
89
+ export const MAX_TICKETS = 100;
90
+ const MAX_FILE_BYTES = 1024 * 1024;
91
+ const KEY = /^[a-z0-9-]{3,60}$/;
92
+ const TICKET_FIELDS = ['key', 'title', 'body', 'acceptance', 'blockedBy', 'priority'];
93
+ const PRIORITY_LABELS = ['priority:p0', 'priority:p1', 'priority:p2', 'priority:p3'];
94
+ export const EDGES_OPEN = '<!-- shipyard:edges -->';
95
+ export const EDGES_CLOSE = '<!-- /shipyard:edges -->';
96
+ export const TICKETS_OPEN = '<!-- shipyard:tickets -->';
97
+ export const TICKETS_CLOSE = '<!-- /shipyard:tickets -->';
98
+ // ---------------------------------------------------------------- the file
99
+ /** Control characters other than tab and line breaks, and format characters (bidi overrides, zero-width). */
100
+ const BODY_CONTROL = /[\p{Cf}]|[^\P{Cc}\t\n\r]/u;
101
+ const LINE_CONTROL = /[\p{Cc}\p{Cf}]/u;
102
+ function fail(message) {
103
+ throw new CheckUsageError(`ticket file: ${message}`);
104
+ }
105
+ function line(v, where, max) {
106
+ if (typeof v !== 'string' || !v.trim())
107
+ fail(`${where} must be a non-empty string`);
108
+ if (LINE_CONTROL.test(v))
109
+ fail(`${where} must be one line without control or format characters`);
110
+ if (v.trim().length > max)
111
+ fail(`${where} is longer than ${max} characters`);
112
+ return v.trim();
113
+ }
114
+ /** Parse and validate a ticket file; CheckUsageError (exit 2) on the first problem. */
115
+ export function parseTicketFile(raw, maxAcceptanceItems) {
116
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw))
117
+ fail('must be a JSON object');
118
+ const top = raw;
119
+ const extra = Object.keys(top).filter((k) => !['schemaVersion', 'spec', 'tickets'].includes(k));
120
+ if (extra.length > 0)
121
+ fail(`unknown field ${JSON.stringify(extra[0])}`);
122
+ if (top.schemaVersion !== 1)
123
+ fail('schemaVersion must be 1');
124
+ if (typeof top.spec !== 'number' || !Number.isInteger(top.spec) || top.spec <= 0)
125
+ fail('spec must be a positive integer');
126
+ if (!Array.isArray(top.tickets) || top.tickets.length === 0)
127
+ fail('tickets must be a non-empty array');
128
+ if (top.tickets.length > MAX_TICKETS)
129
+ fail(`at most ${MAX_TICKETS} tickets`);
130
+ const tickets = top.tickets.map((t, i) => {
131
+ const at = `tickets[${i}]`;
132
+ if (!t || typeof t !== 'object' || Array.isArray(t))
133
+ fail(`${at} must be an object`);
134
+ const o = t;
135
+ const unknown = Object.keys(o).find((k) => !TICKET_FIELDS.includes(k));
136
+ if (unknown !== undefined)
137
+ fail(`${at} has unknown field ${JSON.stringify(unknown)}`);
138
+ if (typeof o.key !== 'string' || !KEY.test(o.key))
139
+ fail(`${at}.key must match [a-z0-9-]{3,60}`);
140
+ const title = line(o.title, `${at}.title`, 200);
141
+ if (title.startsWith('-'))
142
+ fail(`${at}.title must not start with "-"`);
143
+ if (typeof o.body !== 'string')
144
+ fail(`${at}.body must be a string`);
145
+ if (BODY_CONTROL.test(o.body))
146
+ fail(`${at}.body has control or format characters`);
147
+ if (!Array.isArray(o.acceptance) || o.acceptance.length === 0)
148
+ fail(`${at}.acceptance must be a non-empty array`);
149
+ if (o.acceptance.length > maxAcceptanceItems)
150
+ fail(`${at}.acceptance has ${o.acceptance.length} items (factory.check.maxAcceptanceItems is ${maxAcceptanceItems})`);
151
+ const acceptance = o.acceptance.map((a, j) => line(a, `${at}.acceptance[${j}]`, 500));
152
+ if (acceptance.every(isVague))
153
+ fail(`${at}.acceptance: every item is vague and names nothing concrete (name the contract in backticks)`);
154
+ const blockedBy = o.blockedBy === undefined ? [] : o.blockedBy;
155
+ if (!Array.isArray(blockedBy) || blockedBy.some((b) => typeof b !== 'string'))
156
+ fail(`${at}.blockedBy must be an array of strings`);
157
+ if (new Set(blockedBy).size !== blockedBy.length)
158
+ fail(`${at}.blockedBy lists an edge twice`);
159
+ if (o.priority !== undefined && (typeof o.priority !== 'number' || !Number.isInteger(o.priority) || o.priority < 1 || o.priority > 4)) {
160
+ fail(`${at}.priority must be an integer 1..4`);
161
+ }
162
+ return { key: o.key, title, body: o.body, acceptance, blockedBy: blockedBy, ...(o.priority !== undefined ? { priority: o.priority } : {}) };
163
+ });
164
+ const keys = new Set();
165
+ for (const t of tickets) {
166
+ if (keys.has(t.key))
167
+ fail(`duplicate key ${t.key}`);
168
+ keys.add(t.key);
169
+ }
170
+ for (const t of tickets) {
171
+ for (const b of t.blockedBy) {
172
+ if (keys.has(b))
173
+ continue;
174
+ if (!/^#\d+$/.test(b) || Number(b.slice(1)) <= 0)
175
+ fail(`${t.key}.blockedBy ${JSON.stringify(b)} is neither a key in this file nor #<n>`);
176
+ if (Number(b.slice(1)) === top.spec)
177
+ fail(`${t.key} cannot be blocked by its spec #${top.spec}`);
178
+ }
179
+ }
180
+ const cycle = findCycle(tickets);
181
+ if (cycle)
182
+ fail(`blockedBy cycle: ${cycle.join(' -> ')}`);
183
+ return { schemaVersion: 1, spec: top.spec, tickets };
184
+ }
185
+ /** A `blockedBy` cycle among the file's keys as the path that closes it, or null. */
186
+ export function findCycle(tickets) {
187
+ const edges = new Map(tickets.map((t) => [t.key, t.blockedBy.filter((b) => !b.startsWith('#'))]));
188
+ const state = new Map();
189
+ const path = [];
190
+ const visit = (key) => {
191
+ if (state.get(key) === 'done')
192
+ return null;
193
+ if (state.get(key) === 'open')
194
+ return [...path.slice(path.indexOf(key)), key];
195
+ state.set(key, 'open');
196
+ path.push(key);
197
+ for (const next of edges.get(key) ?? []) {
198
+ const found = visit(next);
199
+ if (found)
200
+ return found;
201
+ }
202
+ path.pop();
203
+ state.set(key, 'done');
204
+ return null;
205
+ };
206
+ for (const t of tickets) {
207
+ const found = visit(t.key);
208
+ if (found)
209
+ return found;
210
+ }
211
+ return null;
212
+ }
213
+ // ---------------------------------------------------------------- rendering
214
+ /**
215
+ * Escape what the factory reads as trusted input when an item's author is
216
+ * trusted, as enqueue's items are: the `omg-plan:` link, the `shipyard-key:`
217
+ * footer, an `Acceptance criteria` heading, `Depends on|Blocked by|Part of
218
+ * #n` lines and task-list `- [ ] #n` children (src/forge/github/tracker.ts,
219
+ * src/factory/run/plan-rules.ts). The backslashes render as nothing. `<!--`
220
+ * becomes `&lt;!--`, so an unclosed comment cannot hide the AC, edges and key
221
+ * from a human reader.
222
+ */
223
+ export function neutralizeTrusted(text) {
224
+ return escapeTrustedLines(text.replace(/<!--/g, '&lt;!--'));
225
+ }
226
+ /** neutralizeTrusted without the comment rule (Azure DevOps: the adapter escapes every `<`). */
227
+ function escapeTrustedLines(text) {
228
+ return text
229
+ .replace(/(omg-plan|shipyard-key):/gi, '$1\\:')
230
+ .replace(/^([^\S\r\n]*)(#{1,6}[^\S\r\n]*acceptance criteria)/gim, '$1\\$2')
231
+ .replace(/^([^\S\r\n]*(?:depends on|blocked by|part of)[^\S\r\n]+)#(?=\d)/gim, '$1\\#')
232
+ .replace(/^([^\S\r\n]*[-*][^\S\r\n]+\[[ xX]\][^\S\r\n]+)#(?=\d)/gm, '$1\\#');
233
+ }
234
+ /** An issue/PR/discussion url (also a bare `www.` one), an @-mention (user or org/team), or an `owner/repo#n`, `#n` or `GH-n` reference. */
235
+ const NOTIFYING = /(?:https?:\/\/|(?<![\w./-])www\.)[^\s/<>()`]+\/[^\s/<>()`]+\/[^\s/<>()`]+\/(?:issues|pull|discussions)\/\d+|(?<![A-Za-z0-9_])@[A-Za-z0-9][A-Za-z0-9-]*(?:\/[A-Za-z0-9][A-Za-z0-9_.-]*)?|(?<![\w./-])[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9_.-]+#\d+|(?<![\w&])#\d+\b|(?<![\w-])GH-\d+\b/gi;
236
+ /**
237
+ * Put every mention and cross-reference in a code span, so posting the text
238
+ * notifies nobody and leaves no backlink. The span's backtick run is one
239
+ * longer than any run in the text, so it pairs only with itself (CommonMark
240
+ * code spans close on a run of the same length); a backtick right next to it
241
+ * gets a space so the runs never merge, and so does a backslash before it
242
+ * (it would escape the first backtick and no span would form). Inside an existing code span or
243
+ * block it shows as literal backticks, which is harmless.
244
+ */
245
+ export function neutralizeNotifying(text) {
246
+ const longest = Math.max(0, ...[...text.matchAll(/`+/g)].map((m) => m[0].length));
247
+ const tick = '`'.repeat(longest + 1);
248
+ // GitHub decodes entities before it detects mentions and references (`&#64;x`, `&commat;x`, `o/r&#35;5`).
249
+ return text
250
+ .replace(NOTIFYING, (m, at, s) => `${s[at - 1] === '`' || s[at - 1] === '\\' ? ' ' : ''}${tick}${m}${tick}${s[at + m.length] === '`' ? ' ' : ''}`)
251
+ .replace(/&(?=#|[a-z]+;)/gi, '&amp;');
252
+ }
253
+ const modelText = (s) => neutralizeTrusted(neutralizeNotifying(s));
254
+ /**
255
+ * Azure DevOps: an `@` that could start a mention (`@<GUID>`, `@name`; not an
256
+ * email's), and a `#n` work item or `!n` pull request link. Markup mentions
257
+ * (`<a data-vss-mention>`) cannot form at all: the adapter escapes every `<`
258
+ * and the guard passes no attribute.
259
+ */
260
+ const ADO_NOTIFYING = /(?<![\w.+-])@(?=[<{\w])|(?<!\w)[#!](?=\d)/g;
261
+ const FULLWIDTH = { '@': '@', '#': '#', '!': '!' };
262
+ /** Each mention or link sign becomes its fullwidth look-alike (@ # !), so the text reads the same and links nothing. */
263
+ export const neutralizeAdoNotifying = (text) => text.replace(ADO_NOTIFYING, (m) => FULLWIDTH[m]);
264
+ /** Model text as an Azure DevOps field gets it (the adapter HTML-escapes it). */
265
+ export const adoModelText = (s) => escapeTrustedLines(neutralizeAdoNotifying(s));
266
+ /** The work item description (design §3.3): the ticket body and the key footer; AC, parent and edges have their own fields and links. */
267
+ export function renderAdoDescription(spec, t) {
268
+ const body = adoModelText(t.body).trim();
269
+ return [...(body ? [body, ''] : []), shipyardKeyLine(spec, t.key), ''].join('\n');
270
+ }
271
+ /** The item title as posted. */
272
+ export const renderTitle = (t) => neutralizeNotifying(t.title);
273
+ /** The item body (design §3.3): the ticket body, the AC list, the edges section, the key footer. `edges` are `#<n>` refs. */
274
+ export function renderTicketBody(spec, t, edges) {
275
+ const body = modelText(t.body).trim();
276
+ return [
277
+ ...(body ? [body, ''] : []),
278
+ '## Acceptance criteria',
279
+ '',
280
+ ...t.acceptance.map((a) => neutralizeTrusted(`- [ ] ${neutralizeNotifying(a)}`)),
281
+ '',
282
+ EDGES_OPEN,
283
+ `Part of #${spec}`,
284
+ ...edges.map((e) => `Blocked by ${e}`),
285
+ EDGES_CLOSE,
286
+ '',
287
+ shipyardKeyLine(spec, t.key),
288
+ '',
289
+ ].join('\n');
290
+ }
291
+ const normalized = (s) => s.replace(/\r\n/g, '\n').trimEnd();
292
+ /**
293
+ * The spec body with its `<!-- shipyard:tickets -->` task list set to
294
+ * `children` (appended when absent); a box already ticked stays ticked.
295
+ * Throws CheckUsageError when the section markers are not one ordered pair.
296
+ */
297
+ export function specBodyWithTickets(body, children) {
298
+ const opens = body.split(TICKETS_OPEN).length - 1;
299
+ const closes = body.split(TICKETS_CLOSE).length - 1;
300
+ const start = body.indexOf(TICKETS_OPEN);
301
+ const end = body.indexOf(TICKETS_CLOSE);
302
+ if (opens !== closes || opens > 1 || (opens === 1 && end < start)) {
303
+ throw new CheckUsageError(`the spec body's ${TICKETS_OPEN} section is malformed; fix it by hand`);
304
+ }
305
+ const old = opens === 1 ? body.slice(start + TICKETS_OPEN.length, end) : '';
306
+ const ticked = new Set([...old.matchAll(/^- \[[xX]\] #(\d+)\r?$/gm)].map((m) => Number(m[1])));
307
+ const section = [TICKETS_OPEN, ...children.map((id) => `- [${ticked.has(id) ? 'x' : ' '}] #${id}`), TICKETS_CLOSE].join('\n');
308
+ if (opens === 1)
309
+ return body.slice(0, start) + section + body.slice(end + TICKETS_CLOSE.length);
310
+ return `${body.trimEnd()}${body.trim() ? '\n\n' : ''}${section}\n`;
311
+ }
312
+ // ---------------------------------------------------------------- the guard
313
+ /**
314
+ * enqueue's Exec: the key search, and while `writing()` the issue create and
315
+ * edit, go through the factory guard with the TrackerWriteContext (PR 7a's
316
+ * exact shapes); every other gh and git call through `omg factory check`'s
317
+ * read-only guard. On Azure DevOps (`ado` names the forge and az entry),
318
+ * while `writing()` the work item create and PATCH go through the factory
319
+ * guard with the TrackerWriteContext (PR 7b's routes); every other az call,
320
+ * the key WIQL included, is a check read. Nothing else runs.
321
+ */
322
+ export function enqueueGuardExec(exec, writes, writing, ado = () => undefined) {
323
+ const reads = checkGuardExec(exec, undefined, ado);
324
+ const tracker = factoryGuardExec(exec, () => [], ado, writes);
325
+ return (cmd, args, opts) => {
326
+ if (isAdoCommand(cmd)) {
327
+ const flag = (f) => { const at = args.indexOf(f); return at >= 0 ? args[at + 1]?.toLowerCase() : undefined; };
328
+ const itemWrite = flag('--area') === 'wit' && flag('--resource') === 'workitems' && (flag('--http-method') === 'post' || flag('--http-method') === 'patch');
329
+ return writing() && itemWrite ? tracker(cmd, args, opts) : reads(cmd, args, opts);
330
+ }
331
+ const file = cmd.replace(/\\/g, '/').split('/').pop().toLowerCase().replace(/\.exe$/, '');
332
+ if (file === 'gh' && args[0] === 'issue') {
333
+ if (args[1] === 'list' && args[2] === '--repo')
334
+ return tracker(cmd, args, opts);
335
+ if (writing() && (args[1] === 'create' || (args[1] === 'edit' && args[3] === '--repo')))
336
+ return tracker(cmd, args, opts);
337
+ }
338
+ if (file === 'gh' || file === 'git')
339
+ return reads(cmd, args, opts);
340
+ throw new FactorySafetyError(`omg factory enqueue refuses \`${file} ${args.join(' ')}\`: not a command omg factory enqueue runs`);
341
+ };
342
+ }
343
+ /** Why an existing item must not be edited: closed, or what `omg factory check` reads as an active or finished run. */
344
+ function claimOf(forge, root, base, item, remoteBranch) {
345
+ if (!item.open)
346
+ return 'closed';
347
+ try {
348
+ const run = readFactoryState(root, item.id);
349
+ if (run)
350
+ return TERMINAL_FACTORY_PHASES.includes(run.phase) ? `run-finished:${run.phase}` : `run-active:${run.phase}`;
351
+ const branch = factoryBranch(item.id);
352
+ if (forge.reviews.findOpenPrForBranch(branch) !== undefined)
353
+ return 'pr-exists';
354
+ if (forge.reviews.findMergedPrForBranch(branch, base) !== undefined)
355
+ return 'merged';
356
+ return remoteBranch(branch) ? 'branch-exists' : undefined;
357
+ }
358
+ catch (error) {
359
+ // An unreadable claim is a claim: never edit an item that may be under a running engine.
360
+ return `claim-unknown: ${error instanceof Error ? error.message : String(error)}`;
361
+ }
362
+ }
363
+ function git(exec, root, args) {
364
+ const r = exec('git', args, { cwd: root, env: TRUSTED_READ_ENV });
365
+ return { ok: r.status === 0, out: r.stdout.trim(), err: r.stderr.trim().split('\n')[0] ?? '' };
366
+ }
367
+ function readTicketFile(path, maxAcceptanceItems) {
368
+ if (!existsSync(path) || !statSync(path).isFile())
369
+ throw new CheckUsageError(`--file ${path} is not a file`);
370
+ if (statSync(path).size > MAX_FILE_BYTES)
371
+ throw new CheckUsageError(`--file ${path} is larger than ${MAX_FILE_BYTES} bytes`);
372
+ let raw;
373
+ try {
374
+ raw = JSON.parse(readFileSync(path, 'utf8'));
375
+ }
376
+ catch (error) {
377
+ throw new CheckUsageError(`--file ${path} is not JSON: ${error instanceof Error ? error.message : String(error)}`);
378
+ }
379
+ return parseTicketFile(raw, maxAcceptanceItems);
380
+ }
381
+ /** Run one enqueue; returns the exit code. Usage and incompatible errors propagate (exit 2 / 5 at the CLI). */
382
+ export async function runFactoryEnqueue(o, deps) {
383
+ const specId = parseItemId(o.spec);
384
+ const warnings = [];
385
+ let ctx;
386
+ let writing = false;
387
+ let adoGuard;
388
+ const exec = enqueueGuardExec(deps.exec, () => ctx, () => writing, () => adoGuard);
389
+ const top = git(exec, process.cwd(), ['rev-parse', '--show-toplevel']);
390
+ if (!top.ok)
391
+ throw new CheckUsageError('omg factory enqueue must run inside a git repository');
392
+ const root = top.out;
393
+ const origin = git(exec, root, ['remote', 'get-url', 'origin']);
394
+ if (!origin.ok)
395
+ throw new CheckIncompatibleError(`git remote get-url origin failed: ${origin.err}`);
396
+ const base = deps.base(root);
397
+ if (!isPlainBranchName(base))
398
+ throw new CheckUsageError(`base ${JSON.stringify(base)} is not a branch name`);
399
+ const baseSha = fetchBase(exec, root, base, warnings);
400
+ const trustedUser = deps.trustedUser();
401
+ let config;
402
+ try {
403
+ const loaded = resolveForgeConfig(trustedUser, baseLayer(exec, root, base, baseSha, trustedUser, warnings), deps.projectConfig(root), origin.out);
404
+ config = loaded.config;
405
+ warnings.push(...loaded.warnings);
406
+ }
407
+ catch (error) {
408
+ if (!(error instanceof ForgeConfigError))
409
+ throw error;
410
+ throw error.code === 'invalid' ? new CheckUsageError(error.message) : new CheckIncompatibleError(`${error.code}: ${error.message}`);
411
+ }
412
+ if (config.kind !== 'github' && config.kind !== 'azure-devops')
413
+ throw new CheckIncompatibleError(`omg factory enqueue does not support the ${String(config.kind)} forge`);
414
+ const ado = config.kind === 'azure-devops';
415
+ const file = readTicketFile(o.file, config.check.maxAcceptanceItems);
416
+ if (file.spec !== specId)
417
+ throw new CheckUsageError(`--spec ${specId} does not match the ticket file's spec ${file.spec}`);
418
+ const source = config.intake.source;
419
+ const intakeLabel = source?.type === 'label' ? source.label : undefined;
420
+ // Azure DevOps membership: an area-tag source's tag and area path (the adapter sets the path on create).
421
+ const intakeTag = source?.type === 'area-tag' ? source.tag : undefined;
422
+ if (ado) {
423
+ const itemType = config.intake.itemTypes[0];
424
+ if (!itemType)
425
+ throw new CheckUsageError('factory.intake.itemTypes names no work item type to create');
426
+ // Enqueue never sets a board column or state, so these sources cannot be honoured at create.
427
+ if (source?.type === 'board-column')
428
+ warnings.push(`factory.intake.source is the board column ${source.column}: enqueue never sets a column or state, so the work items join the intake only once they are moved there (omg factory check --parent still lists them)`);
429
+ else if (source?.type === 'wiql-query')
430
+ warnings.push('factory.intake.source is a saved query: membership is the query\'s job, enqueue does not make the work items match it (omg factory check --parent still lists them)');
431
+ else if (!intakeTag)
432
+ warnings.push('factory.intake.source is not an area-tag source: the work items are not added to the intake source (omg factory check --parent still lists them)');
433
+ ctx = { repo: config.repo.url, bodyDir: '', labels: intakeTag ? [intakeTag] : [], itemTypes: [itemType] };
434
+ }
435
+ else {
436
+ if (!intakeLabel)
437
+ warnings.push('factory.intake.source is not a label: the items are not added to the intake source (omg factory check --parent still lists them)');
438
+ ctx = { repo: ghRepoArg(config.repo), bodyDir: '', labels: [...(intakeLabel ? [intakeLabel] : []), ...PRIORITY_LABELS] };
439
+ }
440
+ let forge;
441
+ let forgeOptions;
442
+ try {
443
+ // Azure DevOps: the az entry is resolved once; the guard and the adapter use the same one.
444
+ const entry = ado ? (deps.resolveAz ?? defaultResolveAz)(root) : undefined;
445
+ if (entry)
446
+ adoGuard = adoGuardContext(config, entry);
447
+ forgeOptions = { ...factoryForgeOptions(root), ...(entry ? { entry } : {}) };
448
+ forge = deps.createForge(exec, root, config, forgeOptions);
449
+ }
450
+ catch (error) {
451
+ throw new CheckIncompatibleError(error instanceof Error ? error.message : String(error));
452
+ }
453
+ const tracker = forge.tracker;
454
+ if (!tracker.findByKey || !tracker.createItem || !tracker.updateItem || (ado && !tracker.addRelation))
455
+ throw new CheckIncompatibleError(`the ${config.kind} tracker cannot write items`);
456
+ // Work item ids are org-wide: an Azure DevOps item counts only in the forge project.
457
+ const inForge = (item) => (ado
458
+ ? item.project !== undefined && item.project.toLowerCase() === (config.repo.project ?? '').toLowerCase()
459
+ : item.repoUrl.toLowerCase() === config.repo.url.toLowerCase());
460
+ const itemOf = ado ? `a work item of project ${config.repo.project}` : `an issue of ${config.repo.url}`;
461
+ const remoteBranch = (branch) => {
462
+ const res = git(exec, root, ['ls-remote', 'origin', `refs/heads/${branch}`]);
463
+ if (!res.ok)
464
+ throw new Error(`git ls-remote origin refs/heads/${branch} failed: ${res.err}`);
465
+ return res.out.length > 0;
466
+ };
467
+ // The spec: an open issue of this repository (a work item of the forge project).
468
+ let spec;
469
+ try {
470
+ spec = tracker.viewItem(specId);
471
+ }
472
+ catch (error) {
473
+ throw new CheckUsageError(`spec #${specId} cannot be read as ${itemOf}: ${error instanceof Error ? error.message : String(error)}`);
474
+ }
475
+ if (!inForge(spec))
476
+ throw new CheckUsageError(`spec #${specId} is not ${itemOf}`);
477
+ if (!spec.open)
478
+ throw new CheckUsageError(`spec #${specId} is closed`);
479
+ if (!spec.authorTrusted) {
480
+ // Azure DevOps has no author association: trust is the creator's uniqueName in the user config's trustedAuthors; none listed trusts nobody.
481
+ const trusted = config.azureDevOps?.trustedAuthors ?? [];
482
+ throw new CheckUsageError(!ado
483
+ ? `spec #${specId}'s author is not an OWNER, MEMBER or COLLABORATOR of ${config.repo.url}`
484
+ : trusted.length === 0
485
+ ? `factory.forge.azureDevOps.trustedAuthors is empty in the user config, so no Azure DevOps author is trusted: add the uniqueName that created spec #${specId} there`
486
+ : `spec #${specId}'s creator is not in factory.forge.azureDevOps.trustedAuthors (user config)`);
487
+ }
488
+ // Key holders: trusted children of the spec only, from the key search and the spec's task list (search lags behind creates).
489
+ const holders = new Map();
490
+ const ignored = [];
491
+ const found = tracker.findByKey(specId);
492
+ const seen = new Set(found.map((f) => f.item.id));
493
+ for (const child of spec.children) {
494
+ if (seen.has(child))
495
+ continue;
496
+ let item;
497
+ try {
498
+ item = tracker.viewItem(child);
499
+ }
500
+ catch (error) {
501
+ warnings.push(`task-list child #${child} of spec #${specId} cannot be read: ${error instanceof Error ? error.message : String(error)}`);
502
+ continue;
503
+ }
504
+ const keys = shipyardKeys(item.body).filter(([s]) => s === specId);
505
+ if (keys.length === 1 && inForge(item))
506
+ found.push({ key: keys[0][1], item });
507
+ }
508
+ for (const { key, item } of found) {
509
+ if (!inForge(item))
510
+ ignored.push({ id: item.id, key, reason: 'not in the forge project' });
511
+ else if (!item.authorTrusted)
512
+ ignored.push({ id: item.id, key, reason: 'author is not trusted' });
513
+ // Azure DevOps links the parent right after the create: a trusted holder with no parent is one whose link failed, and enqueue links it.
514
+ else if (item.parent !== specId && !(ado && item.parent === undefined))
515
+ ignored.push({ id: item.id, key, reason: `not a child of #${specId}` });
516
+ else if (holders.has(key))
517
+ throw new CheckUsageError(`key ${key} is held by #${holders.get(key).id} and #${item.id}; close one by hand`);
518
+ else
519
+ holders.set(key, item);
520
+ }
521
+ // `#n` edges must name existing items (on Azure DevOps, of the forge project).
522
+ for (const ref of new Set(file.tickets.flatMap((t) => t.blockedBy.filter((b) => b.startsWith('#'))))) {
523
+ let item;
524
+ try {
525
+ item = tracker.viewItem(Number(ref.slice(1)));
526
+ }
527
+ catch {
528
+ item = undefined;
529
+ }
530
+ if (!item || (ado && !inForge(item)))
531
+ throw new CheckUsageError(`blockedBy ${ref} is not ${itemOf}`);
532
+ }
533
+ const ids = new Map([...holders].map(([k, item]) => [k, item.id]));
534
+ const ref = (b, known) => (b.startsWith('#') ? b : known.has(b) ? `#${known.get(b)}` : undefined);
535
+ /** The full edge list; a key without an id yet shows as `#<key>` (dry run only). */
536
+ const edgesOf = (t, known) => t.blockedBy.map((b) => ref(b, known) ?? `#${b}`);
537
+ /** Azure DevOps: the links an item still lacks, as `[kind, #n]` (a key without an id yet shows as `#<key>`, dry run only). */
538
+ const adoLinks = (p, known) => [
539
+ ...(p.item?.parent === specId ? [] : [['parent', `#${specId}`]]),
540
+ ...edgesOf(p.ticket, known).filter((e) => !p.item?.dependsOn.includes(Number(e.slice(1)))).map((e) => ['depends-on', e]),
541
+ ];
542
+ const planned = file.tickets.map((t) => {
543
+ const item = holders.get(t.key);
544
+ const title = ado ? neutralizeAdoNotifying(t.title) : renderTitle(t);
545
+ const maxTitle = ado ? 255 : 256;
546
+ if (title.length > maxTitle)
547
+ throw new CheckUsageError(`${t.key}: the title is longer than ${maxTitle} characters once mentions are neutralized`);
548
+ const body = ado ? renderAdoDescription(specId, t) : renderTicketBody(specId, t, edgesOf(t, ids));
549
+ if (body.length > config.check.maxBodyChars)
550
+ throw new CheckUsageError(`${t.key}: the rendered body is ${body.length} characters (factory.check.maxBodyChars is ${config.check.maxBodyChars})`);
551
+ if (ado) {
552
+ const acceptance = t.acceptance.map(adoModelText);
553
+ const labels = intakeTag ? [intakeTag] : [];
554
+ if (!item)
555
+ return { ticket: t, action: 'created', reasons: [], title, labels, addLabels: labels, removeLabels: [], acceptance };
556
+ const addLabels = labels.filter((l) => !item.labels.some((x) => x.toLowerCase() === l.toLowerCase()));
557
+ const claim = claimOf(forge, root, base, item, remoteBranch);
558
+ if (claim)
559
+ return { ticket: t, item, action: 'kept-claimed', reasons: [claim], title, labels, addLabels: [], removeLabels: [], acceptance };
560
+ // Compared as the adapter writes and viewItem reads them back (the HTML round trip folds whitespace).
561
+ const fieldsSame = item.title === title && normalized(item.body) === normalized(adoHtmlToText(adoTextHtml(body)))
562
+ && (item.acceptance ?? '') === adoHtmlToText(adoListHtml(acceptance)) && (t.priority === undefined || item.priority === t.priority) && addLabels.length === 0;
563
+ // A link is never removed (the guard passes adds only): an edge the file dropped is the captain's to unlink.
564
+ const wanted = new Set(t.blockedBy.map((b) => ref(b, ids)).filter((r) => r !== undefined).map((r) => Number(r.slice(1))));
565
+ for (const dep of item.dependsOn.filter((d) => !wanted.has(d)))
566
+ warnings.push(`#${item.id} (${t.key}) keeps its predecessor link to #${dep}: enqueue never removes a link; remove it by hand if that edge is gone`);
567
+ const p = { ticket: t, item, action: 'updated', reasons: [], title, labels, addLabels, removeLabels: [], acceptance, fieldsSame };
568
+ const pending = t.blockedBy.some((b) => ref(b, ids) === undefined);
569
+ return fieldsSame && !pending && adoLinks(p, ids).length === 0 ? { ...p, action: 'unchanged' } : p;
570
+ }
571
+ const labels = [...(intakeLabel ? [intakeLabel] : []), ...(t.priority ? [PRIORITY_LABELS[t.priority - 1]] : [])];
572
+ if (!item)
573
+ return { ticket: t, action: 'created', reasons: [], title, labels, addLabels: labels, removeLabels: [] };
574
+ const has = (l) => item.labels.some((x) => x.toLowerCase() === l.toLowerCase());
575
+ const addLabels = labels.filter((l) => !has(l));
576
+ const removeLabels = PRIORITY_LABELS.filter((l) => !labels.includes(l) && item.labels.includes(l)).slice(0, Math.max(0, 4 - addLabels.length));
577
+ const claim = claimOf(forge, root, base, item, remoteBranch);
578
+ if (claim)
579
+ return { ticket: t, item, action: 'kept-claimed', reasons: [claim], title, labels, addLabels: [], removeLabels: [] };
580
+ const pending = t.blockedBy.some((b) => ref(b, ids) === undefined);
581
+ const same = !pending && item.title === title && normalized(item.body) === normalized(body) && addLabels.length === 0 && removeLabels.length === 0;
582
+ return { ticket: t, item, action: same ? 'unchanged' : 'updated', reasons: [], title, labels, addLabels, removeLabels };
583
+ });
584
+ const fileKeys = new Set(file.tickets.map((t) => t.key));
585
+ const orphans = [...holders].filter(([k]) => !fileKeys.has(k)).map(([, item]) => item).sort((a, b) => a.id - b.id);
586
+ const specBody = (known) => specBodyWithTickets(spec.body, [
587
+ ...file.tickets.map((t) => known.get(t.key)).filter((id) => id !== undefined),
588
+ ...orphans.map((i) => i.id),
589
+ ]);
590
+ const orphanRows = orphans.map((item) => ({ key: [...holders].find(([, i]) => i === item)[0], id: item.id, action: 'orphaned', bucket: null, reasons: [], markCandidate: false }));
591
+ const markCandidate = (a) => a === 'created' || a === 'updated' || a === 'unchanged';
592
+ const newKeys = planned.filter((p) => p.action === 'created').map((p) => p.ticket.key);
593
+ // Each new child adds one `- [ ] #<id>` line; refuse now rather than after the creates. (Azure DevOps: the spec is never edited.)
594
+ if (!ado && specBody(ids).length + newKeys.length * 20 > MAX_TRACKER_BODY_CHARS)
595
+ throw new CheckUsageError(`spec #${specId}'s body would exceed ${MAX_TRACKER_BODY_CHARS} characters with the task list`);
596
+ if (o.dryRun) {
597
+ // Ids a create would assign are unknown: the planned spec body lists the known ones and names the new keys.
598
+ const taskList = !ado && (newKeys.length > 0 || normalized(specBody(ids)) !== normalized(spec.body)) ? 'updated' : 'unchanged';
599
+ const specPlanned = () => `${specBody(ids)}${newKeys.length > 0 ? `\n(plus the new ${newKeys.join(', ')} once created)` : ''}`;
600
+ const rows = [
601
+ ...planned.map((p) => ({
602
+ key: p.ticket.key,
603
+ id: p.item?.id ?? null,
604
+ action: p.action,
605
+ bucket: null,
606
+ reasons: p.reasons,
607
+ markCandidate: markCandidate(p.action),
608
+ ...(p.action === 'created' || p.action === 'updated'
609
+ ? {
610
+ planned: ado
611
+ ? {
612
+ title: p.title, body: renderAdoDescription(specId, p.ticket), addLabels: p.addLabels, removeLabels: [], acceptance: p.acceptance,
613
+ ...(p.ticket.priority !== undefined ? { priority: p.ticket.priority } : {}), links: adoLinks(p, ids).map(([kind, target]) => `${kind} ${target}`),
614
+ }
615
+ : { title: p.title, body: renderTicketBody(specId, p.ticket, edgesOf(p.ticket, ids)), addLabels: p.addLabels, removeLabels: p.removeLabels },
616
+ }
617
+ : {}),
618
+ })),
619
+ ...orphanRows,
620
+ ];
621
+ report(o, deps, { schemaVersion: ENQUEUE_SCHEMA_VERSION, ok: true, dryRun: true, spec: { id: specId, taskList, ...(taskList === 'updated' ? { planned: specPlanned() } : {}) }, items: rows, ignored, mark: null, warnings });
622
+ return 0;
623
+ }
624
+ // The writes: body files in a fresh directory outside the worktree (the guard reads its own copy of each).
625
+ const bodyDir = mkdtempSync(join(tmpdir(), 'omg-enqueue-'));
626
+ const rel = relative(root, bodyDir);
627
+ const rows = [];
628
+ let taskList = 'unchanged';
629
+ let failed = false;
630
+ try {
631
+ if (!rel.startsWith('..') && !isAbsolute(rel))
632
+ throw new CheckIncompatibleError(`the temporary directory ${bodyDir} is inside the worktree ${root}; set TMPDIR elsewhere`);
633
+ ctx = { ...ctx, bodyDir };
634
+ writing = true;
635
+ let n = 0;
636
+ const bodyFile = (name, text) => {
637
+ const path = join(bodyDir, `${++n}-${name}.md`);
638
+ writeFileSync(path, text, { mode: 0o600, flag: 'wx' });
639
+ return path;
640
+ };
641
+ const written = new Map();
642
+ let specNow = spec.body;
643
+ // GitHub only: on Azure DevOps the spec's children are its Hierarchy-Forward links and its description is never edited.
644
+ const writeSpec = () => {
645
+ const next = specBody(ids);
646
+ if (normalized(next) === normalized(specNow))
647
+ return;
648
+ tracker.updateItem(specId, { title: spec.title, bodyFile: bodyFile(`spec-${specId}`, next), addLabels: [], removeLabels: [] });
649
+ specNow = next;
650
+ taskList = 'updated';
651
+ };
652
+ try {
653
+ if (ado) {
654
+ // The adapter reads a body file only from the directory it was built with.
655
+ const writer = deps.createForge(exec, root, config, { ...forgeOptions, trackerBodyDir: bodyDir }).tracker;
656
+ const priority = (t) => (t.priority !== undefined ? { priority: t.priority } : {});
657
+ // Pass 1: create the missing work items and link each to the spec at once, so a re-run finds it as a child.
658
+ for (const p of planned.filter((x) => x.action === 'created')) {
659
+ const id = writer.createItem({ title: p.title, bodyFile: bodyFile(p.ticket.key, renderAdoDescription(specId, p.ticket)), labels: p.labels, acceptance: p.acceptance, ...priority(p.ticket) });
660
+ ids.set(p.ticket.key, id);
661
+ writer.addRelation(id, 'parent', specId);
662
+ }
663
+ // Pass 2: every id is known now; update the changed fields, then add the missing predecessor (and, for a holder, parent) links.
664
+ for (const p of planned) {
665
+ if (p.action !== 'created' && p.action !== 'updated')
666
+ continue;
667
+ const id = ids.get(p.ticket.key);
668
+ if (p.action === 'updated' && !p.fieldsSame) {
669
+ writer.updateItem(id, { title: p.title, bodyFile: bodyFile(p.ticket.key, renderAdoDescription(specId, p.ticket)), addLabels: p.addLabels, removeLabels: [], acceptance: p.acceptance, ...priority(p.ticket) });
670
+ }
671
+ // A created item got its parent link in pass 1.
672
+ for (const [kind, target] of adoLinks(p, ids))
673
+ if (p.action === 'updated' || kind !== 'parent')
674
+ writer.addRelation(id, kind, Number(target.slice(1)));
675
+ }
676
+ }
677
+ else {
678
+ // Pass 1: create the missing items with the edges already known; list each on the spec at once, so a re-run finds it without search.
679
+ for (const p of planned.filter((x) => x.action === 'created')) {
680
+ const body = renderTicketBody(specId, p.ticket, p.ticket.blockedBy.map((b) => ref(b, ids)).filter((r) => r !== undefined));
681
+ ids.set(p.ticket.key, tracker.createItem({ title: p.title, bodyFile: bodyFile(p.ticket.key, body), labels: p.labels }));
682
+ written.set(p.ticket.key, body);
683
+ writeSpec();
684
+ }
685
+ // Pass 2: every edge is known now; rewrite the created items that missed one, and update the changed ones.
686
+ for (const p of planned) {
687
+ if (p.action !== 'created' && p.action !== 'updated')
688
+ continue;
689
+ const body = renderTicketBody(specId, p.ticket, edgesOf(p.ticket, ids));
690
+ if (p.action === 'created' && written.get(p.ticket.key) === body)
691
+ continue;
692
+ tracker.updateItem(ids.get(p.ticket.key), {
693
+ title: p.title,
694
+ bodyFile: bodyFile(p.ticket.key, body),
695
+ // A created item got its labels at create.
696
+ addLabels: p.action === 'updated' ? p.addLabels : [],
697
+ removeLabels: p.removeLabels,
698
+ });
699
+ }
700
+ // The spec's task list, which `omg factory check --parent` reads (already current unless nothing was created).
701
+ writeSpec();
702
+ }
703
+ }
704
+ catch (error) {
705
+ failed = true;
706
+ warnings.push(`write failed (re-run enqueue to finish; it is idempotent): ${error instanceof Error ? error.message : String(error)}`);
707
+ }
708
+ finally {
709
+ writing = false;
710
+ }
711
+ }
712
+ finally {
713
+ rmSync(bodyDir, { recursive: true, force: true });
714
+ }
715
+ for (const p of planned)
716
+ rows.push({ key: p.ticket.key, id: ids.get(p.ticket.key) ?? null, action: p.action, bucket: null, reasons: p.reasons, markCandidate: markCandidate(p.action) });
717
+ rows.push(...orphanRows);
718
+ // The mark step: `omg factory check <ids> --mark --yes` over this file's candidates only (the C3 signature covers them).
719
+ let mark = null;
720
+ const candidates = rows.filter((r) => r.markCandidate && r.id !== null).map((r) => String(r.id));
721
+ if (!failed && candidates.length > 0) {
722
+ const captured = [];
723
+ try {
724
+ const code = await runFactoryCheck({ ids: candidates, mark: true, yes: true, json: true }, { ...deps, out: (l) => captured.push(l), err: (l) => captured.push(l) });
725
+ const json = JSON.parse(captured.join('\n'));
726
+ mark = json.mark;
727
+ for (const r of rows) {
728
+ const hit = json.items.find((i) => i.id === r.id);
729
+ if (!hit)
730
+ continue;
731
+ r.bucket = hit.bucket;
732
+ if (r.action !== 'kept-claimed')
733
+ r.reasons = hit.reasons;
734
+ }
735
+ if (code !== 0) {
736
+ failed = true;
737
+ warnings.push(`mark step: omg factory check --parent ${specId} --mark exited ${code}`);
738
+ }
739
+ }
740
+ catch (error) {
741
+ failed = true;
742
+ warnings.push(`mark step failed: ${error instanceof Error ? error.message : String(error)}`);
743
+ }
744
+ }
745
+ report(o, deps, { schemaVersion: ENQUEUE_SCHEMA_VERSION, ok: !failed, dryRun: false, spec: { id: specId, taskList }, items: rows, ignored, mark, warnings });
746
+ return failed ? EXIT_CHECK_FAILED : 0;
747
+ }
748
+ function report(o, deps, json) {
749
+ if (o.json) {
750
+ deps.out(JSON.stringify({ ...json, warnings: json.warnings.map(plainText) }, null, 2));
751
+ return;
752
+ }
753
+ for (const w of json.warnings)
754
+ deps.err(chalk.yellow(plainText(w)));
755
+ const rows = json.items.map((r) => [r.key, r.id === null ? '(new)' : `#${r.id}`, r.action, r.bucket ?? '-', r.reasons[0] ?? '']);
756
+ const widths = [0, 1, 2, 3].map((i) => Math.max(...rows.map((row) => row[i].length), ['KEY', 'ID', 'ACTION', 'BUCKET'][i].length));
757
+ const pad = (row) => row.slice(0, 4).map((c, i) => c.padEnd(widths[i])).join(' ');
758
+ deps.out(chalk.bold(`${pad(['KEY', 'ID', 'ACTION', 'BUCKET'])} REASON`));
759
+ for (const row of rows)
760
+ deps.out(`${pad(row)} ${plainText(row[4])}`);
761
+ for (const i of json.ignored)
762
+ deps.err(chalk.yellow(`ignored #${i.id} (key ${i.key}): ${i.reason}`));
763
+ deps.out(`spec #${json.spec.id} task list: ${json.spec.taskList}`);
764
+ if (json.dryRun) {
765
+ deps.out(chalk.bold('dry run: nothing was written. The writes:'));
766
+ for (const r of json.items.filter((x) => x.planned)) {
767
+ const p = r.planned;
768
+ const labels = [...p.addLabels.map((l) => `+${l}`), ...p.removeLabels.map((l) => `-${l}`)].join(' ');
769
+ deps.out(`\n== ${r.action === 'created' ? 'create' : `edit #${r.id}`} ${r.key}: ${JSON.stringify(p.title)}${labels ? ` [${labels}]` : ''}`);
770
+ deps.out(p.body);
771
+ if (p.acceptance)
772
+ deps.out(`acceptance criteria:\n${p.acceptance.map((a) => `- ${a}`).join('\n')}`);
773
+ if (p.priority !== undefined)
774
+ deps.out(`priority: ${p.priority}`);
775
+ if (p.links?.length)
776
+ deps.out(`links: ${p.links.join(', ')}`);
777
+ }
778
+ if (json.spec.planned)
779
+ deps.out(`\n== edit spec #${json.spec.id} body:\n${json.spec.planned}`);
780
+ const candidates = json.items.filter((r) => r.markCandidate).map((r) => (r.id === null ? `(new) ${r.key}` : `#${r.id}`));
781
+ deps.out(`\n== mark step: omg factory check --mark --yes over ${candidates.length > 0 ? candidates.join(', ') : 'nothing'}; the runnable ones get the marker`);
782
+ }
783
+ else if (json.mark) {
784
+ if (json.mark.marked.length > 0)
785
+ deps.out(chalk.green(`marked ${json.mark.marker}: ${json.mark.marked.map((id) => `#${id}`).join(', ')}`));
786
+ }
787
+ }
788
+ //# sourceMappingURL=enqueue.js.map