@intentius/chant 0.124.87 → 0.124.89

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 (483) hide show
  1. package/dist/action-pins.d.ts +1 -0
  2. package/dist/action-pins.d.ts.map +1 -1
  3. package/dist/action-pins.js +2 -0
  4. package/dist/actor.d.ts +47 -0
  5. package/dist/actor.d.ts.map +1 -0
  6. package/dist/actor.js +56 -0
  7. package/dist/bundle-check.d.ts +20 -5
  8. package/dist/bundle-check.d.ts.map +1 -1
  9. package/dist/bundle-check.js +20 -5
  10. package/dist/chant-install.d.ts +98 -0
  11. package/dist/chant-install.d.ts.map +1 -1
  12. package/dist/chant-install.js +203 -2
  13. package/dist/ci-base.d.ts +30 -0
  14. package/dist/ci-base.d.ts.map +1 -0
  15. package/dist/ci-base.js +33 -0
  16. package/dist/ci-comment-commands.d.ts +177 -0
  17. package/dist/ci-comment-commands.d.ts.map +1 -0
  18. package/dist/ci-comment-commands.js +325 -0
  19. package/dist/ci-comment-replies.d.ts +40 -0
  20. package/dist/ci-comment-replies.d.ts.map +1 -0
  21. package/dist/ci-comment-replies.js +59 -0
  22. package/dist/ci-commit.d.ts +1 -1
  23. package/dist/ci-commit.d.ts.map +1 -1
  24. package/dist/ci-commit.js +1 -2
  25. package/dist/ci-control.d.ts +1 -1
  26. package/dist/ci-control.d.ts.map +1 -1
  27. package/dist/ci-control.js +1 -1
  28. package/dist/ci-evidence-claims.d.ts +59 -0
  29. package/dist/ci-evidence-claims.d.ts.map +1 -0
  30. package/dist/ci-evidence-claims.js +87 -0
  31. package/dist/ci-evidence-from-job.d.ts +128 -0
  32. package/dist/ci-evidence-from-job.d.ts.map +1 -0
  33. package/dist/ci-evidence-from-job.js +203 -0
  34. package/dist/ci-evidence-jobs.d.ts +68 -4
  35. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  36. package/dist/ci-evidence-jobs.js +82 -5
  37. package/dist/ci-handover.d.ts +12 -0
  38. package/dist/ci-handover.d.ts.map +1 -1
  39. package/dist/ci-handover.js +15 -3
  40. package/dist/ci-identity.d.ts +32 -6
  41. package/dist/ci-identity.d.ts.map +1 -1
  42. package/dist/ci-identity.js +40 -8
  43. package/dist/ci-image.d.ts +65 -10
  44. package/dist/ci-image.d.ts.map +1 -1
  45. package/dist/ci-image.js +101 -22
  46. package/dist/ci-jobs.d.ts +1 -1
  47. package/dist/ci-jobs.d.ts.map +1 -1
  48. package/dist/ci-jobs.js +7 -2
  49. package/dist/ci-login.d.ts +75 -13
  50. package/dist/ci-login.d.ts.map +1 -1
  51. package/dist/ci-login.js +89 -37
  52. package/dist/ci-note-commands.d.ts +63 -3
  53. package/dist/ci-note-commands.d.ts.map +1 -1
  54. package/dist/ci-note-commands.js +69 -35
  55. package/dist/ci-product-words.d.ts +62 -1
  56. package/dist/ci-product-words.d.ts.map +1 -1
  57. package/dist/ci-product-words.js +52 -1
  58. package/dist/ci-product.d.ts +52 -2
  59. package/dist/ci-product.d.ts.map +1 -1
  60. package/dist/ci-product.js +51 -2
  61. package/dist/cli/commands/build.d.ts.map +1 -1
  62. package/dist/cli/commands/build.js +29 -2
  63. package/dist/cli/handlers/approve-confirm.d.ts +14 -0
  64. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
  65. package/dist/cli/handlers/approve-confirm.js +46 -0
  66. package/dist/cli/handlers/approve.d.ts.map +1 -1
  67. package/dist/cli/handlers/approve.js +2 -1
  68. package/dist/cli/handlers/build.d.ts +1 -1
  69. package/dist/cli/handlers/build.d.ts.map +1 -1
  70. package/dist/cli/handlers/build.js +22 -1
  71. package/dist/cli/handlers/ci-check.d.ts +1 -1
  72. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  73. package/dist/cli/handlers/ci-check.js +37 -7
  74. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  75. package/dist/cli/handlers/ci-evidence.js +255 -20
  76. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
  77. package/dist/cli/handlers/ci-forge-check.js +34 -17
  78. package/dist/cli/handlers/components.d.ts.map +1 -1
  79. package/dist/cli/handlers/components.js +3 -1
  80. package/dist/cli/handlers/generated-check.d.ts +11 -0
  81. package/dist/cli/handlers/generated-check.d.ts.map +1 -0
  82. package/dist/cli/handlers/generated-check.js +71 -0
  83. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  84. package/dist/cli/handlers/lifecycle.js +3 -0
  85. package/dist/cli/handlers/local-chant.d.ts +13 -0
  86. package/dist/cli/handlers/local-chant.d.ts.map +1 -1
  87. package/dist/cli/handlers/local-chant.js +42 -1
  88. package/dist/cli/handlers/lock.d.ts.map +1 -1
  89. package/dist/cli/handlers/lock.js +121 -4
  90. package/dist/cli/handlers/pr-comment.d.ts +21 -0
  91. package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
  92. package/dist/cli/handlers/pr-comment.js +112 -0
  93. package/dist/cli/handlers/pr-env.d.ts.map +1 -1
  94. package/dist/cli/handlers/pr-env.js +6 -3
  95. package/dist/cli/handlers/pr.d.ts +23 -1
  96. package/dist/cli/handlers/pr.d.ts.map +1 -1
  97. package/dist/cli/handlers/pr.js +97 -14
  98. package/dist/cli/handlers/promote.d.ts.map +1 -1
  99. package/dist/cli/handlers/promote.js +2 -1
  100. package/dist/cli/handlers/release.d.ts.map +1 -1
  101. package/dist/cli/handlers/release.js +11 -2
  102. package/dist/cli/handlers/run-wave.d.ts.map +1 -1
  103. package/dist/cli/handlers/run-wave.js +36 -2
  104. package/dist/cli/handlers/run.d.ts.map +1 -1
  105. package/dist/cli/handlers/run.js +2 -1
  106. package/dist/cli/main.d.ts.map +1 -1
  107. package/dist/cli/main.js +60 -4
  108. package/dist/cli/parse-args.d.ts.map +1 -1
  109. package/dist/cli/parse-args.js +82 -0
  110. package/dist/cli/registry.d.ts +35 -0
  111. package/dist/cli/registry.d.ts.map +1 -1
  112. package/dist/components/auto-release.d.ts.map +1 -1
  113. package/dist/components/auto-release.js +2 -1
  114. package/dist/components/check-hooks.d.ts +10 -0
  115. package/dist/components/check-hooks.d.ts.map +1 -1
  116. package/dist/components/check-hooks.js +18 -0
  117. package/dist/components/pr-checks.d.ts +169 -0
  118. package/dist/components/pr-checks.d.ts.map +1 -0
  119. package/dist/components/pr-checks.js +180 -0
  120. package/dist/components/pr-pipeline.d.ts +38 -0
  121. package/dist/components/pr-pipeline.d.ts.map +1 -1
  122. package/dist/components/pr-pipeline.js +6 -1
  123. package/dist/components/product-pipeline.d.ts +58 -2
  124. package/dist/components/product-pipeline.d.ts.map +1 -1
  125. package/dist/components/product-pipeline.js +76 -9
  126. package/dist/components/product-plan.d.ts +445 -7
  127. package/dist/components/product-plan.d.ts.map +1 -1
  128. package/dist/components/product-plan.js +426 -15
  129. package/dist/config.d.ts +10 -6
  130. package/dist/config.d.ts.map +1 -1
  131. package/dist/config.js +11 -6
  132. package/dist/control/consumers.d.ts +6 -0
  133. package/dist/control/consumers.d.ts.map +1 -1
  134. package/dist/control/consumers.js +6 -0
  135. package/dist/dead-guards.d.ts.map +1 -1
  136. package/dist/dead-guards.js +9 -6
  137. package/dist/discovery/files.d.ts +1 -1
  138. package/dist/discovery/files.js +1 -1
  139. package/dist/drift-issue.d.ts +20 -3
  140. package/dist/drift-issue.d.ts.map +1 -1
  141. package/dist/drift-issue.js +16 -0
  142. package/dist/drift-record.d.ts +52 -5
  143. package/dist/drift-record.d.ts.map +1 -1
  144. package/dist/drift-record.js +46 -6
  145. package/dist/floor-table.d.ts +6 -6
  146. package/dist/floor-table.d.ts.map +1 -1
  147. package/dist/floor-table.data.d.ts.map +1 -1
  148. package/dist/floor-table.data.js +81 -21
  149. package/dist/floor-table.js +10 -7
  150. package/dist/forge-check/contract.d.ts +19 -1
  151. package/dist/forge-check/contract.d.ts.map +1 -1
  152. package/dist/forge-check/contract.js +8 -2
  153. package/dist/forge-check/index.d.ts +4 -0
  154. package/dist/forge-check/index.d.ts.map +1 -1
  155. package/dist/forge-check/index.js +4 -0
  156. package/dist/forge-flags.d.ts +10 -0
  157. package/dist/forge-flags.d.ts.map +1 -1
  158. package/dist/forge-flags.js +31 -0
  159. package/dist/forge-remote.d.ts +47 -0
  160. package/dist/forge-remote.d.ts.map +1 -0
  161. package/dist/forge-remote.js +69 -0
  162. package/dist/gate-resume-run.d.ts +9 -1
  163. package/dist/gate-resume-run.d.ts.map +1 -1
  164. package/dist/gate-resume-run.js +26 -3
  165. package/dist/generated-check.d.ts +88 -0
  166. package/dist/generated-check.d.ts.map +1 -0
  167. package/dist/generated-check.js +248 -0
  168. package/dist/image-pins.d.ts +26 -0
  169. package/dist/image-pins.d.ts.map +1 -0
  170. package/dist/image-pins.js +19 -0
  171. package/dist/lexicon.d.ts +27 -0
  172. package/dist/lexicon.d.ts.map +1 -1
  173. package/dist/lifecycle/git.d.ts +11 -0
  174. package/dist/lifecycle/git.d.ts.map +1 -1
  175. package/dist/lifecycle/git.js +30 -3
  176. package/dist/lifecycle/publish-npm.d.ts +26 -0
  177. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  178. package/dist/lifecycle/publish-npm.js +76 -4
  179. package/dist/lifecycle/reach-locks.d.ts +131 -0
  180. package/dist/lifecycle/reach-locks.d.ts.map +1 -0
  181. package/dist/lifecycle/reach-locks.js +118 -0
  182. package/dist/lifecycle/release-cut.d.ts +3 -1
  183. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  184. package/dist/lifecycle/release-cut.js +15 -0
  185. package/dist/lifecycle/release-images.d.ts +22 -1
  186. package/dist/lifecycle/release-images.d.ts.map +1 -1
  187. package/dist/lifecycle/release-images.js +26 -3
  188. package/dist/lifecycle/release-ledger.d.ts +4 -3
  189. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  190. package/dist/lifecycle/release-ledger.js +3 -2
  191. package/dist/local-chant.d.ts +57 -3
  192. package/dist/local-chant.d.ts.map +1 -1
  193. package/dist/local-chant.js +122 -13
  194. package/dist/notify-product.d.ts +12 -3
  195. package/dist/notify-product.d.ts.map +1 -1
  196. package/dist/notify-product.js +10 -6
  197. package/dist/op/activities/source-release.d.ts.map +1 -1
  198. package/dist/op/activities/source-release.js +2 -1
  199. package/dist/op/activities/source-rollback.d.ts.map +1 -1
  200. package/dist/op/activities/source-rollback.js +2 -1
  201. package/dist/op/index.d.ts +2 -0
  202. package/dist/op/index.d.ts.map +1 -1
  203. package/dist/op/index.js +1 -0
  204. package/dist/op/op-waves-evidence-jobs.d.ts +97 -0
  205. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
  206. package/dist/op/op-waves-evidence-jobs.js +118 -0
  207. package/dist/op/op-waves-evidence.d.ts +12 -1
  208. package/dist/op/op-waves-evidence.d.ts.map +1 -1
  209. package/dist/op/op-waves-evidence.js +23 -2
  210. package/dist/op/op-waves-render-spec.d.ts +100 -0
  211. package/dist/op/op-waves-render-spec.d.ts.map +1 -0
  212. package/dist/op/op-waves-render-spec.js +162 -0
  213. package/dist/op/op-waves-run.d.ts +14 -1
  214. package/dist/op/op-waves-run.d.ts.map +1 -1
  215. package/dist/op/op-waves-run.js +56 -4
  216. package/dist/op/op-waves.d.ts +12 -0
  217. package/dist/op/op-waves.d.ts.map +1 -1
  218. package/dist/op/op-waves.js +14 -1
  219. package/dist/op/schedule-overdue.d.ts +39 -2
  220. package/dist/op/schedule-overdue.d.ts.map +1 -1
  221. package/dist/op/schedule-overdue.js +148 -10
  222. package/dist/op/wave-stop.d.ts +64 -0
  223. package/dist/op/wave-stop.d.ts.map +1 -0
  224. package/dist/op/wave-stop.js +127 -0
  225. package/dist/planned-files.d.ts +76 -0
  226. package/dist/planned-files.d.ts.map +1 -0
  227. package/dist/planned-files.js +108 -0
  228. package/dist/pr-forge-job.d.ts +22 -0
  229. package/dist/pr-forge-job.d.ts.map +1 -0
  230. package/dist/pr-forge-job.js +46 -0
  231. package/dist/pr-forge-reads.d.ts +21 -1
  232. package/dist/pr-forge-reads.d.ts.map +1 -1
  233. package/dist/pr-forge-reads.js +19 -1
  234. package/dist/pr-forge.d.ts +7 -1
  235. package/dist/pr-forge.d.ts.map +1 -1
  236. package/dist/pr-forge.js +7 -2
  237. package/dist/pr-loop.d.ts +3 -6
  238. package/dist/pr-loop.d.ts.map +1 -1
  239. package/dist/pr-loop.js +4 -81
  240. package/dist/pr-plan-note.d.ts +121 -0
  241. package/dist/pr-plan-note.d.ts.map +1 -1
  242. package/dist/pr-plan-note.js +104 -1
  243. package/dist/pr-plan-record.d.ts +47 -0
  244. package/dist/pr-plan-record.d.ts.map +1 -0
  245. package/dist/pr-plan-record.js +89 -0
  246. package/dist/pr-post.d.ts +68 -3
  247. package/dist/pr-post.d.ts.map +1 -1
  248. package/dist/pr-post.js +218 -13
  249. package/dist/pr-requires.d.ts +8 -0
  250. package/dist/pr-requires.d.ts.map +1 -1
  251. package/dist/pr-requires.js +3 -1
  252. package/dist/pr-status.d.ts +16 -0
  253. package/dist/pr-status.d.ts.map +1 -0
  254. package/dist/pr-status.js +90 -0
  255. package/dist/ref-gate-init.d.ts +90 -0
  256. package/dist/ref-gate-init.d.ts.map +1 -0
  257. package/dist/ref-gate-init.js +155 -0
  258. package/dist/ref-gate-rules.d.ts +19 -0
  259. package/dist/ref-gate-rules.d.ts.map +1 -0
  260. package/dist/ref-gate-rules.js +17 -0
  261. package/dist/release-floors.d.ts +100 -16
  262. package/dist/release-floors.d.ts.map +1 -1
  263. package/dist/release-floors.js +101 -17
  264. package/dist/render-module.d.ts +15 -0
  265. package/dist/render-module.d.ts.map +1 -0
  266. package/dist/render-module.js +73 -0
  267. package/dist/state-migration.d.ts +24 -1
  268. package/dist/state-migration.d.ts.map +1 -1
  269. package/dist/state-migration.js +39 -4
  270. package/dist/state-unlock.d.ts +32 -1
  271. package/dist/state-unlock.d.ts.map +1 -1
  272. package/dist/state-unlock.js +31 -0
  273. package/dist/wave-runtime.mjs +307 -297
  274. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  275. package/dist/workspace/ci-green-cli.js +15 -8
  276. package/dist/workspace/drift-cli.d.ts +1 -1
  277. package/dist/workspace/drift-cli.d.ts.map +1 -1
  278. package/dist/workspace/drift-cli.js +5 -12
  279. package/dist/workspace/forge-work.d.ts +3 -2
  280. package/dist/workspace/forge-work.d.ts.map +1 -1
  281. package/dist/workspace/forge-work.js +7 -17
  282. package/dist/workspace/lexicon-outputs.js +2 -2
  283. package/dist/workspace/release-train.d.ts.map +1 -1
  284. package/dist/workspace/release-train.js +2 -1
  285. package/dist/workspace/release-workflow.d.ts +27 -3
  286. package/dist/workspace/release-workflow.d.ts.map +1 -1
  287. package/dist/workspace/release-workflow.js +52 -7
  288. package/dist/workspace/trust/check-evidence-report.d.ts +25 -2
  289. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  290. package/dist/workspace/trust/check-evidence-report.js +28 -8
  291. package/dist/workspace/trust/check-evidence.d.ts +13 -1
  292. package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
  293. package/dist/workspace/trust/check-evidence.js +8 -3
  294. package/dist/workspace/trust/evidence.d.ts +5 -0
  295. package/dist/workspace/trust/evidence.d.ts.map +1 -1
  296. package/dist/workspace/trust/evidence.js +5 -0
  297. package/dist/workspace/trust/open-evidence.d.ts +67 -0
  298. package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
  299. package/dist/workspace/trust/open-evidence.js +92 -0
  300. package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
  301. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  302. package/dist/workspace/trust/ref-gate-cli.js +93 -11
  303. package/dist/workspace/trust/ref-gate.d.ts +61 -2
  304. package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
  305. package/dist/workspace/trust/ref-gate.js +72 -7
  306. package/dist/workspace/workspace-run.d.ts.map +1 -1
  307. package/dist/workspace/workspace-run.js +2 -1
  308. package/package.json +1 -1
  309. package/src/action-pins.ts +2 -0
  310. package/src/actor.test.ts +78 -0
  311. package/src/actor.ts +79 -0
  312. package/src/bundle-check.test.ts +22 -0
  313. package/src/bundle-check.ts +33 -5
  314. package/src/chant-install.test.ts +108 -1
  315. package/src/chant-install.ts +242 -2
  316. package/src/ci-base.test.ts +41 -0
  317. package/src/ci-base.ts +43 -0
  318. package/src/ci-comment-commands.test.ts +376 -0
  319. package/src/ci-comment-commands.ts +389 -0
  320. package/src/ci-comment-replies.ts +78 -0
  321. package/src/ci-commit.test.ts +51 -6
  322. package/src/ci-commit.ts +1 -2
  323. package/src/ci-control.ts +1 -0
  324. package/src/ci-evidence-claims.ts +102 -0
  325. package/src/ci-evidence-from-job.test.ts +165 -0
  326. package/src/ci-evidence-from-job.ts +251 -0
  327. package/src/ci-evidence-jobs.ts +88 -6
  328. package/src/ci-handover.ts +16 -3
  329. package/src/ci-identity.test.ts +3 -3
  330. package/src/ci-identity.ts +51 -11
  331. package/src/ci-image.test.ts +187 -16
  332. package/src/ci-image.ts +157 -25
  333. package/src/ci-jobs.ts +7 -2
  334. package/src/ci-login.test.ts +131 -3
  335. package/src/ci-login.token-drop.test.ts +204 -0
  336. package/src/ci-login.ts +137 -39
  337. package/src/ci-note-commands.ts +104 -41
  338. package/src/ci-product-words.ts +89 -0
  339. package/src/ci-product.ts +62 -1
  340. package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
  341. package/src/cli/commands/build.test.ts +41 -0
  342. package/src/cli/commands/build.ts +27 -2
  343. package/src/cli/handlers/approve-confirm.test.ts +35 -0
  344. package/src/cli/handlers/approve-confirm.ts +44 -0
  345. package/src/cli/handlers/approve.ts +2 -1
  346. package/src/cli/handlers/build-source-dir.test.ts +4 -0
  347. package/src/cli/handlers/build.ts +20 -2
  348. package/src/cli/handlers/ci-check.ts +37 -7
  349. package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
  350. package/src/cli/handlers/ci-evidence.ts +233 -18
  351. package/src/cli/handlers/ci-forge-check.ts +22 -9
  352. package/src/cli/handlers/components.ts +3 -1
  353. package/src/cli/handlers/generated-check.ts +69 -0
  354. package/src/cli/handlers/lifecycle.test.ts +20 -0
  355. package/src/cli/handlers/lifecycle.ts +4 -0
  356. package/src/cli/handlers/local-chant.ts +39 -1
  357. package/src/cli/handlers/lock-reach.test.ts +103 -0
  358. package/src/cli/handlers/lock.ts +100 -4
  359. package/src/cli/handlers/pr-comment.ts +104 -0
  360. package/src/cli/handlers/pr-env.ts +6 -3
  361. package/src/cli/handlers/pr-record.test.ts +1 -1
  362. package/src/cli/handlers/pr.ts +93 -15
  363. package/src/cli/handlers/promote.ts +2 -1
  364. package/src/cli/handlers/release.e2e.test.ts +35 -0
  365. package/src/cli/handlers/release.ts +14 -2
  366. package/src/cli/handlers/run-wave.ts +35 -2
  367. package/src/cli/handlers/run.ts +2 -1
  368. package/src/cli/main.ts +60 -4
  369. package/src/cli/parse-args.ts +58 -0
  370. package/src/cli/registry.ts +35 -0
  371. package/src/components/auto-release.ts +2 -1
  372. package/src/components/check-hooks.ts +22 -0
  373. package/src/components/check-report-summary.test.ts +78 -0
  374. package/src/components/pr-checks.ts +254 -0
  375. package/src/components/pr-pipeline.ts +43 -1
  376. package/src/components/product-pipeline.ts +113 -9
  377. package/src/components/product-plan.test.ts +140 -1
  378. package/src/components/product-plan.ts +707 -20
  379. package/src/config.ts +13 -8
  380. package/src/control/consumers.ts +7 -0
  381. package/src/dead-guards.test.ts +27 -5
  382. package/src/dead-guards.ts +9 -6
  383. package/src/discovery/files.ts +1 -1
  384. package/src/drift-issue.test.ts +29 -1
  385. package/src/drift-issue.ts +28 -3
  386. package/src/drift-record.test.ts +45 -0
  387. package/src/drift-record.ts +71 -6
  388. package/src/floor-table.data.ts +81 -21
  389. package/src/floor-table.ts +12 -9
  390. package/src/forge-check/contract.ts +23 -2
  391. package/src/forge-check/forge-check.test.ts +25 -0
  392. package/src/forge-check/index.ts +4 -0
  393. package/src/forge-flags.test.ts +25 -1
  394. package/src/forge-flags.ts +34 -0
  395. package/src/forge-remote.test.ts +37 -0
  396. package/src/forge-remote.ts +79 -0
  397. package/src/gate-resume-run.ts +27 -3
  398. package/src/generated-check.e2e.test.ts +118 -0
  399. package/src/generated-check.test.ts +170 -0
  400. package/src/generated-check.ts +310 -0
  401. package/src/image-pins.ts +31 -0
  402. package/src/lexicon.ts +28 -0
  403. package/src/lifecycle/git.test.ts +48 -0
  404. package/src/lifecycle/git.ts +27 -4
  405. package/src/lifecycle/publish-npm.ts +87 -4
  406. package/src/lifecycle/reach-locks.test.ts +87 -0
  407. package/src/lifecycle/reach-locks.ts +169 -0
  408. package/src/lifecycle/release-catalog.test.ts +2 -2
  409. package/src/lifecycle/release-cut.ts +17 -1
  410. package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
  411. package/src/lifecycle/release-images.test.ts +100 -0
  412. package/src/lifecycle/release-images.ts +38 -3
  413. package/src/lifecycle/release-ledger.ts +4 -3
  414. package/src/local-chant.e2e.test.ts +81 -6
  415. package/src/local-chant.test.ts +22 -3
  416. package/src/local-chant.ts +130 -13
  417. package/src/notify-product.ts +19 -8
  418. package/src/op/activities/source-release.ts +2 -1
  419. package/src/op/activities/source-rollback.ts +2 -1
  420. package/src/op/gate-resume.test.ts +27 -0
  421. package/src/op/index.ts +10 -0
  422. package/src/op/op-waves-evidence-jobs.ts +140 -0
  423. package/src/op/op-waves-evidence.test.ts +36 -3
  424. package/src/op/op-waves-evidence.ts +23 -3
  425. package/src/op/op-waves-notify-words.test.ts +18 -0
  426. package/src/op/op-waves-render-spec.test.ts +160 -0
  427. package/src/op/op-waves-render-spec.ts +171 -0
  428. package/src/op/op-waves-run.ts +59 -3
  429. package/src/op/op-waves.ts +16 -2
  430. package/src/op/schedule-overdue.test.ts +126 -1
  431. package/src/op/schedule-overdue.ts +164 -12
  432. package/src/op/wave-stop.test.ts +72 -0
  433. package/src/op/wave-stop.ts +137 -0
  434. package/src/planned-files.test.ts +80 -0
  435. package/src/planned-files.ts +134 -0
  436. package/src/pr-forge-job.test.ts +53 -0
  437. package/src/pr-forge-job.ts +46 -0
  438. package/src/pr-forge-reads-compare.test.ts +2 -1
  439. package/src/pr-forge-reads.ts +37 -1
  440. package/src/pr-forge.ts +14 -3
  441. package/src/pr-loop-narrowed.test.ts +2 -1
  442. package/src/pr-loop-words.test.ts +2 -1
  443. package/src/pr-loop.test.ts +1 -2
  444. package/src/pr-loop.ts +4 -80
  445. package/src/pr-plan-note.ts +184 -3
  446. package/src/pr-plan-record.test.ts +75 -0
  447. package/src/pr-plan-record.ts +101 -0
  448. package/src/pr-post-plan-note.test.ts +60 -0
  449. package/src/pr-post-replan.test.ts +144 -0
  450. package/src/pr-post-subject.test.ts +230 -0
  451. package/src/pr-post.test.ts +32 -1
  452. package/src/pr-post.ts +254 -15
  453. package/src/pr-requires.test.ts +20 -0
  454. package/src/pr-requires.ts +10 -1
  455. package/src/pr-status.ts +91 -0
  456. package/src/ref-gate-init.ts +208 -0
  457. package/src/ref-gate-rules.ts +26 -0
  458. package/src/release-floors.ts +139 -17
  459. package/src/render-module.ts +73 -0
  460. package/src/state-migration-record.test.ts +89 -0
  461. package/src/state-migration.test.ts +1 -1
  462. package/src/state-migration.ts +52 -4
  463. package/src/state-unlock.test.ts +33 -1
  464. package/src/state-unlock.ts +49 -1
  465. package/src/workspace/ci-green-cli.ts +14 -7
  466. package/src/workspace/ci-green-workflow.test.ts +32 -1
  467. package/src/workspace/drift-cli.ts +6 -18
  468. package/src/workspace/forge-work.ts +7 -14
  469. package/src/workspace/lexicon-outputs.ts +2 -2
  470. package/src/workspace/release-train.ts +2 -1
  471. package/src/workspace/release-workflow.test.ts +104 -3
  472. package/src/workspace/release-workflow.ts +60 -9
  473. package/src/workspace/trust/check-evidence-report.ts +39 -8
  474. package/src/workspace/trust/check-evidence.test.ts +5 -0
  475. package/src/workspace/trust/check-evidence.ts +17 -5
  476. package/src/workspace/trust/evidence.ts +5 -0
  477. package/src/workspace/trust/open-evidence.ts +129 -0
  478. package/src/workspace/trust/ref-gate-cli.ts +88 -10
  479. package/src/workspace/trust/ref-gate-pieces.test.ts +220 -0
  480. package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
  481. package/src/workspace/trust/ref-gate.test.ts +10 -0
  482. package/src/workspace/trust/ref-gate.ts +87 -6
  483. package/src/workspace/workspace-run.ts +2 -1
@@ -44,6 +44,7 @@ export declare const ACTION_PINS: {
44
44
  readonly setupBun2: ActionPin;
45
45
  readonly golangciLint9: ActionPin;
46
46
  readonly dockerLogin4: ActionPin;
47
+ readonly dockerSetupQemu4: ActionPin;
47
48
  readonly dockerSetupBuildx4: ActionPin;
48
49
  readonly dockerMetadata6: ActionPin;
49
50
  readonly dockerBuildPush7: ActionPin;
@@ -1 +1 @@
1
- {"version":3,"file":"action-pins.d.ts","sourceRoot":"","sources":["../src/action-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAID,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BsB,CAAC;AAE/C,6DAA6D;AAC7D,eAAO,MAAM,OAAO,MAAO,SAAS,KAAG,MAA8B,CAAC;AAKtE,8IAA8I;AAC9I,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED,sKAAsK;AACtK,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAQtD;AAED,8IAA8I;AAC9I,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAI5E;AAED,mFAAmF;AACnF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxD"}
1
+ {"version":3,"file":"action-pins.d.ts","sourceRoot":"","sources":["../src/action-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAID,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BsB,CAAC;AAE/C,6DAA6D;AAC7D,eAAO,MAAM,OAAO,MAAO,SAAS,KAAG,MAA8B,CAAC;AAKtE,8IAA8I;AAC9I,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED,sKAAsK;AACtK,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAQtD;AAED,8IAA8I;AAC9I,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAI5E;AAED,mFAAmF;AACnF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxD"}
@@ -36,6 +36,8 @@ export const ACTION_PINS = {
36
36
  setupBun2: pin("oven-sh/setup-bun", "v2", "0c5077e51419868618aeaa5fe8019c62421857d6", "v2.2.0"),
37
37
  golangciLint9: pin("golangci/golangci-lint-action", "v9", "ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a", "v9.3.0"),
38
38
  dockerLogin4: pin("docker/login-action", "v4", "81c6f93d4bc991e510b342a00b419b3bb4efc5c6", "v4.7.0"),
39
+ // #4876: the release workflow's QEMU binfmt setup for a `release.images` platform the runner can't run.
40
+ dockerSetupQemu4: pin("docker/setup-qemu-action", "v4", "99012661954931238ded8c8b007157a8430204e1", "v4.4.0"),
39
41
  dockerSetupBuildx4: pin("docker/setup-buildx-action", "v4", "f87e5991a6d7451dcb8d9637bfbc97413f497069", "v4.4.1"),
40
42
  dockerMetadata6: pin("docker/metadata-action", "v6", "dc802804100637a589fabce1cb79ff13a1411302", "v6.2.0"),
41
43
  dockerBuildPush7: pin("docker/build-push-action", "v7", "c3c9e263c25d99ce0380d002d59b67737d91b0dc", "v7.4.0"),
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Who runs a command, when the caller names nobody (#4911): the forge's
3
+ * actor in a job (`GITHUB_ACTOR`, which Forgejo sets too, then
4
+ * `GITLAB_USER_LOGIN`), else the login (`USER`, `USERNAME` on Windows).
5
+ * The terraform and pulumi lexicons' gated requests and the products'
6
+ * requesters read it here rather than each writing the order, and so do
7
+ * chant's own CLI handlers and the records they write (#4952). A caller
8
+ * that refuses when nobody is named passes `""` as the fallback.
9
+ *
10
+ * {@link actorOf} is the same order with the two places a product's
11
+ * requester also looks (#4966): `GITHUB_TRIGGERING_ACTOR` ahead of the
12
+ * forge's actor, which names who re-ran a job rather than who started its
13
+ * run, and git's `user.name` in the checkout between the forge's actor and
14
+ * the login, which names the person at a laptop better than `$USER`.
15
+ */
16
+ /** The actor fallback's variables, in the order {@link actorFromEnv} reads them. */
17
+ export declare const ACTOR_ENV_ORDER: readonly ["GITHUB_ACTOR", "GITLAB_USER_LOGIN", "USER", "USERNAME"];
18
+ /** The first of {@link ACTOR_ENV_ORDER} set to something other than blanks, else `fallback` (default `unknown`). */
19
+ export declare function actorFromEnv(env?: Record<string, string | undefined>, fallback?: string): string;
20
+ /** Which of the places {@link actorOf} reads, and the answer when none is set. */
21
+ export interface ActorOptions {
22
+ /** The variables. Default `process.env`. */
23
+ env?: Record<string, string | undefined>;
24
+ /** Read `GITHUB_TRIGGERING_ACTOR` first: who re-ran the job, ahead of who started the run. Default false. */
25
+ triggering?: boolean;
26
+ /** Read the forge's actor (`GITHUB_ACTOR`, `GITLAB_USER_LOGIN`). Default true. */
27
+ forge?: boolean;
28
+ /** A checkout whose git config is read after the forge's actor. Unset, git is not asked. */
29
+ repo?: string;
30
+ /** The git config keys read in `repo`, in order. Default `["user.name"]`. */
31
+ gitKeys?: readonly string[];
32
+ /** Read the login (`USER`, `USERNAME`) last. Default true. */
33
+ login?: boolean;
34
+ /** The answer when nothing is set. Default `unknown`; `""` for a caller that refuses. */
35
+ fallback?: string;
36
+ }
37
+ /** The places {@link actorOf} reads for `options`, in order: variable names, and `git:<key>` for a git config key. */
38
+ export declare function actorOrder(options?: Omit<ActorOptions, "env" | "fallback">): string[];
39
+ /**
40
+ * The first place of {@link actorOrder} set to something other than blanks,
41
+ * else `fallback` (#4966). With no options it answers as
42
+ * {@link actorFromEnv}. A git config key is read only when every place
43
+ * before it is empty, so a job with a forge actor runs no git.
44
+ */
45
+ export declare function actorOf(options?: ActorOptions): string;
46
+ export { ACTOR_ORDER_FLOOR } from "./release-floors.js";
47
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../src/actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,oFAAoF;AACpF,eAAO,MAAM,eAAe,YAAI,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,UAAU,CAAU,CAAC;AAElG,oHAAoH;AACpH,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EAAE,QAAQ,SAAY,GAAG,MAAM,CAMhH;AAED,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,6GAA6G;IAC7G,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4FAA4F;IAC5F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,sHAAsH;AACtH,wBAAgB,UAAU,CAAC,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,UAAU,CAAM,GAAG,MAAM,EAAE,CAOzF;AAOD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,YAAiB,GAAG,MAAM,CAO1D;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/actor.js ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Who runs a command, when the caller names nobody (#4911): the forge's
3
+ * actor in a job (`GITHUB_ACTOR`, which Forgejo sets too, then
4
+ * `GITLAB_USER_LOGIN`), else the login (`USER`, `USERNAME` on Windows).
5
+ * The terraform and pulumi lexicons' gated requests and the products'
6
+ * requesters read it here rather than each writing the order, and so do
7
+ * chant's own CLI handlers and the records they write (#4952). A caller
8
+ * that refuses when nobody is named passes `""` as the fallback.
9
+ *
10
+ * {@link actorOf} is the same order with the two places a product's
11
+ * requester also looks (#4966): `GITHUB_TRIGGERING_ACTOR` ahead of the
12
+ * forge's actor, which names who re-ran a job rather than who started its
13
+ * run, and git's `user.name` in the checkout between the forge's actor and
14
+ * the login, which names the person at a laptop better than `$USER`.
15
+ */
16
+ import { spawnSync } from "node:child_process";
17
+ /** The actor fallback's variables, in the order {@link actorFromEnv} reads them. */
18
+ export const ACTOR_ENV_ORDER = ["GITHUB_ACTOR", "GITLAB_USER_LOGIN", "USER", "USERNAME"];
19
+ /** The first of {@link ACTOR_ENV_ORDER} set to something other than blanks, else `fallback` (default `unknown`). */
20
+ export function actorFromEnv(env = process.env, fallback = "unknown") {
21
+ for (const name of ACTOR_ENV_ORDER) {
22
+ const v = env[name]?.trim();
23
+ if (v)
24
+ return v;
25
+ }
26
+ return fallback;
27
+ }
28
+ /** The places {@link actorOf} reads for `options`, in order: variable names, and `git:<key>` for a git config key. */
29
+ export function actorOrder(options = {}) {
30
+ return [
31
+ ...(options.triggering ? ["GITHUB_TRIGGERING_ACTOR"] : []),
32
+ ...(options.forge === false ? [] : ["GITHUB_ACTOR", "GITLAB_USER_LOGIN"]),
33
+ ...(options.repo !== undefined ? (options.gitKeys ?? ["user.name"]).map((k) => `git:${k}`) : []),
34
+ ...(options.login === false ? [] : ["USER", "USERNAME"]),
35
+ ];
36
+ }
37
+ function gitConfig(repo, key) {
38
+ const r = spawnSync("git", ["-C", repo, "config", key], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] });
39
+ return r.status === 0 ? r.stdout.trim() : undefined;
40
+ }
41
+ /**
42
+ * The first place of {@link actorOrder} set to something other than blanks,
43
+ * else `fallback` (#4966). With no options it answers as
44
+ * {@link actorFromEnv}. A git config key is read only when every place
45
+ * before it is empty, so a job with a forge actor runs no git.
46
+ */
47
+ export function actorOf(options = {}) {
48
+ const env = options.env ?? process.env;
49
+ for (const place of actorOrder(options)) {
50
+ const v = (place.startsWith("git:") ? gitConfig(options.repo, place.slice(4)) : env[place])?.trim();
51
+ if (v)
52
+ return v;
53
+ }
54
+ return options.fallback ?? "unknown";
55
+ }
56
+ export { ACTOR_ORDER_FLOOR } from "./release-floors.js";
@@ -25,14 +25,29 @@ export interface EsbuildPluginLike {
25
25
  } | undefined): void;
26
26
  }): void;
27
27
  }
28
+ /** What {@link chantExternalPlugin} keeps external, and where it records it. */
29
+ export interface ChantExternalOptions {
30
+ /**
31
+ * The chant packages whose imports may stay external (#4922). Default: the
32
+ * `@intentius/chant*` packages in the `dependencies` of `pkgDir`'s
33
+ * package.json, the ones an install of the published package brings. A
34
+ * product that bundles its lexicons (devDependencies) and depends only on
35
+ * `@intentius/chant` gets core external and the lexicons bundled.
36
+ */
37
+ packages?: Iterable<string>;
38
+ /** Collects the specifiers left external. */
39
+ external?: Set<string>;
40
+ }
28
41
  /**
29
42
  * An esbuild plugin that leaves an `@intentius/chant*` import external when
30
- * the chant installed for `pkgDir` (where the bin runs) serves it as compiled
31
- * JS, so the bundle runs the installed, pinned chant. Any other chant import
32
- * goes on to the next plugin and esbuild, which bundle it. `external`, when
33
- * given, collects the specifiers left external.
43
+ * its package is one of `options.packages` (by default the package's chant
44
+ * `dependencies`, #4922) and the chant installed for `pkgDir` (where the bin
45
+ * runs) serves it as compiled JS, so the bundle runs the installed, pinned
46
+ * chant. Any other chant import goes on to the next plugin and esbuild, which
47
+ * bundle it. A bundled lexicon's own imports of core come through here too.
48
+ * The second argument may still be the `external` set alone.
34
49
  */
35
- export declare function chantExternalPlugin(pkgDir: string, external?: Set<string>): EsbuildPluginLike;
50
+ export declare function chantExternalPlugin(pkgDir: string, options?: ChantExternalOptions | Set<string>): EsbuildPluginLike;
36
51
  /**
37
52
  * The bare specifiers a bundle imports: static `import` and `export ... from`,
38
53
  * `import()` and `require()` of a string. Relative imports are left out, and
@@ -1 +1 @@
1
- {"version":3,"file":"bundle-check.d.ts","sourceRoot":"","sources":["../src/bundle-check.ts"],"names":[],"mappings":"AA4EA,kHAAkH;AAClH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMrF;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOzF;AAED,gHAAgH;AAChH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,gHAAgH;AAChH,MAAM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AAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAC;CACf;AAcD,kIAAkI;AAClI,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,8FAA8F;AAC9F,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAInF;AASD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAwGxF"}
@@ -111,18 +111,33 @@ export function chantRuntimeTarget(specifier, fromDir) {
111
111
  export function chantServesCompiled(pkgDir) {
112
112
  return chantRuntimeTarget("@intentius/chant", pkgDir) !== undefined;
113
113
  }
114
+ /** The `@intentius/chant*` names in the `dependencies` of the package at `pkgDir`. */
115
+ function chantDependencies(pkgDir) {
116
+ const f = join(pkgDir, "package.json");
117
+ if (!existsSync(f))
118
+ return [];
119
+ const deps = JSON.parse(readFileSync(f, "utf8")).dependencies ?? {};
120
+ return Object.keys(deps).filter((n) => CHANT.test(n));
121
+ }
114
122
  /**
115
123
  * An esbuild plugin that leaves an `@intentius/chant*` import external when
116
- * the chant installed for `pkgDir` (where the bin runs) serves it as compiled
117
- * JS, so the bundle runs the installed, pinned chant. Any other chant import
118
- * goes on to the next plugin and esbuild, which bundle it. `external`, when
119
- * given, collects the specifiers left external.
124
+ * its package is one of `options.packages` (by default the package's chant
125
+ * `dependencies`, #4922) and the chant installed for `pkgDir` (where the bin
126
+ * runs) serves it as compiled JS, so the bundle runs the installed, pinned
127
+ * chant. Any other chant import goes on to the next plugin and esbuild, which
128
+ * bundle it. A bundled lexicon's own imports of core come through here too.
129
+ * The second argument may still be the `external` set alone.
120
130
  */
121
- export function chantExternalPlugin(pkgDir, external) {
131
+ export function chantExternalPlugin(pkgDir, options) {
132
+ const opts = options instanceof Set ? { external: options } : (options ?? {});
133
+ const external = opts.external;
134
+ const keep = new Set(opts.packages ?? chantDependencies(pkgDir));
122
135
  return {
123
136
  name: "chant-external",
124
137
  setup(b) {
125
138
  b.onResolve({ filter: CHANT }, (args) => {
139
+ if (!keep.has(CHANT.exec(args.path)[1]))
140
+ return undefined;
126
141
  if (chantRuntimeTarget(args.path, pkgDir) === undefined)
127
142
  return undefined;
128
143
  external?.add(args.path);
@@ -18,7 +18,17 @@
18
18
  * {@link chantArgv} runs the package's `bin/chant` with the node running
19
19
  * now: the bin picks the compiled CLI in an installed package and the source
20
20
  * in a checkout (#3878), so a product never chooses between them.
21
+ *
22
+ * #4889: {@link runChant} spawns that chant and returns its output and its
23
+ * last `--json` document ({@link lastJsonLine}), and
24
+ * {@link installResolveFallback} and {@link fallbackImportArgs} resolve any
25
+ * bare specifier a file with no `node_modules` above it imports, in the
26
+ * product's process and in chant's children, from the product's install
27
+ * (SQL Yodeler's `resolve-fallback.ts` and `process.ts`, terragucci's
28
+ * `runChant` in `resume.ts`).
21
29
  */
30
+ /** The first chant with `runChant`, `lastJsonLine`, `installResolveFallback` and `fallbackImportArgs` in `@intentius/chant/chant-install` (#4889): a product runs chant and reads its `--json` document, and a file with no `node_modules` above it imports the product's packages, with no code of the product's own. */
31
+ export declare const CHANT_RUN_FLOOR = "0.124.88";
22
32
  /** Where a chant package is installed. */
23
33
  export interface ChantInstall {
24
34
  /** The `@intentius/chant` package directory. */
@@ -96,5 +106,93 @@ export declare function chantResolveFallback(from: string): (specifier: string,
96
106
  * repository needs chant in its own `node_modules`.
97
107
  */
98
108
  export declare function installChantResolveFallback(from?: string): boolean;
109
+ /** A bare specifier: a package name, not a relative or absolute path, a URL, a `node:` builtin or a `#` import. */
110
+ export declare function isBareSpecifier(specifier: string): boolean;
111
+ /** Whether the file at `url` has a `node_modules` directory in its own directory or any above it. A URL that is not a file's counts as having one. */
112
+ export declare function hasNodeModulesAbove(url: unknown): boolean;
113
+ /**
114
+ * The file URL a bare specifier is retried from: a file beside the
115
+ * `node_modules` directory that holds `from` (by default this module, in
116
+ * the chant the product depends on), so the retry finds the product's own
117
+ * packages first; `from` itself when it is in no `node_modules`, as in a
118
+ * chant checkout. SQL Yodeler's `ownModules`.
119
+ */
120
+ export declare function fallbackParent(from?: string): string;
121
+ /**
122
+ * A resolve hook (SQL Yodeler's `resolve-fallback.ts`): a bare specifier
123
+ * Node could not find, imported by a file with no `node_modules` in its
124
+ * directory or any above it, resolves from `parent`. chant's commit job
125
+ * runs a product's command in a git worktree outside the checkout the job
126
+ * installed, so a `chant.config.ts` or an Op there imports chant, its
127
+ * lexicons and the product by name and finds none of them. A file that has
128
+ * an install of its own, and any other failure, is left as Node reports it.
129
+ */
130
+ export declare function bareResolveFallback(parent: string): (specifier: string, context: Record<string, unknown>, next: NextResolve) => ResolveResult;
131
+ /**
132
+ * Install {@link bareResolveFallback} once in this process, retrying from
133
+ * `parent` (default {@link fallbackParent}). A product's bin calls it before
134
+ * it loads a repository's `chant.config.ts` or Ops. Uses Node's
135
+ * `module.registerHooks` where it has one, else `module.register`. Returns
136
+ * whether it is installed: false on a Node with neither.
137
+ */
138
+ export declare function installResolveFallback(parent?: string): boolean;
139
+ /**
140
+ * The node arguments that install {@link bareResolveFallback} in a chant
141
+ * child (`chant build`, `chant run`), before its own imports of the
142
+ * repository's files: one `--import` of a `data:` module, so it loads the
143
+ * same from a product's `src/` under tsx and from its bundle. Pass them as
144
+ * {@link chantArgv}'s `nodeArgs`, or {@link runChant}'s `resolveFallback`.
145
+ */
146
+ export declare function fallbackImportArgs(parent?: string): string[];
147
+ /** What {@link runChant} returns once the child exits. */
148
+ export interface ChantRun {
149
+ /** The exit code; 128 when a signal ended it. */
150
+ code: number;
151
+ stdout: string;
152
+ stderr: string;
153
+ /** {@link lastJsonLine} of `stdout`: the `--json` document, when the command printed one. */
154
+ json?: unknown;
155
+ }
156
+ export interface RunChantOptions {
157
+ /** The directory chant runs in. Default the current one. */
158
+ cwd?: string;
159
+ /** The environment the child starts from, before {@link chantEnv}. Default `process.env`. */
160
+ env?: NodeJS.ProcessEnv;
161
+ /**
162
+ * A chant executable to run as it is (a product's `--chant` flag): no
163
+ * node in front of it, so `nodeArgs` and `resolveFallback` do not apply.
164
+ */
165
+ chant?: string;
166
+ /** The install to run. Default {@link bundledChant}, else the first of `from` that {@link installedChant} finds, else `chant` on PATH. */
167
+ install?: ChantInstall;
168
+ /** Directories to look for an install from when this module is in none (terragucci looks from the repository). */
169
+ from?: readonly string[];
170
+ /** Node arguments before the bin, such as a product's own `--import`. */
171
+ nodeArgs?: readonly string[];
172
+ /** Install {@link bareResolveFallback} in the child (`true` from {@link fallbackParent}, or a parent URL). */
173
+ resolveFallback?: boolean | string;
174
+ /** `FORCE_COLOR=0` and `NO_COLOR=1`, for output a product reads. */
175
+ noColor?: boolean;
176
+ /** `inherit` writes the child's output to this process's and captures none. Default `pipe`. */
177
+ stdio?: "pipe" | "inherit";
178
+ /** Each chunk as it arrives, for output a person watches. */
179
+ onStdout?: (text: string) => void;
180
+ onStderr?: (text: string) => void;
181
+ }
182
+ /**
183
+ * Run `chant <args>` and resolve with its exit code, its output and its
184
+ * `--json` document (#4889; SQL Yodeler's `runChant`, terragucci's in
185
+ * `resume.ts`). The chant is the product's own ({@link chantArgv}) with its
186
+ * bin first on PATH ({@link chantEnv}). Never rejects on a non-zero exit;
187
+ * rejects when the child cannot start.
188
+ */
189
+ export declare function runChant(args: readonly string[], options?: RunChantOptions): Promise<ChantRun>;
190
+ /**
191
+ * The last line of `stdout` that parses as a JSON object: chant prints its
192
+ * `--json` document as one line, after any log lines. A pretty-printed
193
+ * document is read from the first `{` to the end. Undefined when there is
194
+ * none.
195
+ */
196
+ export declare function lastJsonLine(stdout: string): unknown;
99
197
  export {};
100
198
  //# sourceMappingURL=chant-install.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chant-install.d.ts","sourceRoot":"","sources":["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I in an installed package and the source
20
20
  * in a checkout (#3878), so a product never chooses between them.
21
+ *
22
+ * #4889: {@link runChant} spawns that chant and returns its output and its
23
+ * last `--json` document ({@link lastJsonLine}), and
24
+ * {@link installResolveFallback} and {@link fallbackImportArgs} resolve any
25
+ * bare specifier a file with no `node_modules` above it imports, in the
26
+ * product's process and in chant's children, from the product's install
27
+ * (SQL Yodeler's `resolve-fallback.ts` and `process.ts`, terragucci's
28
+ * `runChant` in `resume.ts`).
21
29
  */
30
+ import { spawn } from "node:child_process";
22
31
  import { existsSync, readFileSync } from "node:fs";
23
32
  import * as nodeModule from "node:module";
24
- import { delimiter, dirname, join, resolve } from "node:path";
25
- import { fileURLToPath } from "node:url";
33
+ import { delimiter, dirname, join, resolve, sep } from "node:path";
34
+ import { fileURLToPath, pathToFileURL } from "node:url";
35
+ /** The first chant with `runChant`, `lastJsonLine`, `installResolveFallback` and `fallbackImportArgs` in `@intentius/chant/chant-install` (#4889): a product runs chant and reads its `--json` document, and a file with no `node_modules` above it imports the product's packages, with no code of the product's own. */
36
+ export const CHANT_RUN_FLOOR = "0.124.88";
26
37
  const PACKAGE = "@intentius/chant";
27
38
  /** The install whose manifest is `<root>/package.json`, when it is chant's and names a bin that is there. */
28
39
  function installAt(root) {
@@ -156,3 +167,193 @@ export function installChantResolveFallback(from = import.meta.url) {
156
167
  flags[FALLBACK] = true;
157
168
  return true;
158
169
  }
170
+ // ── #4889: any bare specifier, for a file with no node_modules above it ────
171
+ /** A bare specifier: a package name, not a relative or absolute path, a URL, a `node:` builtin or a `#` import. */
172
+ export function isBareSpecifier(specifier) {
173
+ return !/^(\.{0,2}\/|[a-zA-Z][a-zA-Z0-9+.-]*:)/.test(specifier) && !specifier.startsWith("#");
174
+ }
175
+ /** Whether the file at `url` has a `node_modules` directory in its own directory or any above it. A URL that is not a file's counts as having one. */
176
+ export function hasNodeModulesAbove(url) {
177
+ if (typeof url !== "string" || !url.startsWith("file:"))
178
+ return true;
179
+ for (let dir = dirname(fileURLToPath(url));;) {
180
+ if (existsSync(join(dir, "node_modules")))
181
+ return true;
182
+ const up = dirname(dir);
183
+ if (up === dir)
184
+ return false;
185
+ dir = up;
186
+ }
187
+ }
188
+ /**
189
+ * The file URL a bare specifier is retried from: a file beside the
190
+ * `node_modules` directory that holds `from` (by default this module, in
191
+ * the chant the product depends on), so the retry finds the product's own
192
+ * packages first; `from` itself when it is in no `node_modules`, as in a
193
+ * chant checkout. SQL Yodeler's `ownModules`.
194
+ */
195
+ export function fallbackParent(from = import.meta.url) {
196
+ const path = from.startsWith("file:") ? fileURLToPath(from) : from;
197
+ const marker = `${sep}node_modules${sep}`;
198
+ const at = path.lastIndexOf(marker);
199
+ if (at < 0)
200
+ return from.startsWith("file:") ? from : pathToFileURL(from).href;
201
+ return pathToFileURL(join(path.slice(0, at), "chant-resolve-fallback.js")).href;
202
+ }
203
+ /**
204
+ * A resolve hook (SQL Yodeler's `resolve-fallback.ts`): a bare specifier
205
+ * Node could not find, imported by a file with no `node_modules` in its
206
+ * directory or any above it, resolves from `parent`. chant's commit job
207
+ * runs a product's command in a git worktree outside the checkout the job
208
+ * installed, so a `chant.config.ts` or an Op there imports chant, its
209
+ * lexicons and the product by name and finds none of them. A file that has
210
+ * an install of its own, and any other failure, is left as Node reports it.
211
+ */
212
+ export function bareResolveFallback(parent) {
213
+ return (specifier, context, next) => {
214
+ try {
215
+ return next(specifier, context);
216
+ }
217
+ catch (err) {
218
+ const code = err.code;
219
+ if (code !== "ERR_MODULE_NOT_FOUND" && code !== "MODULE_NOT_FOUND")
220
+ throw err;
221
+ if (!isBareSpecifier(specifier) || context.parentURL === parent || hasNodeModulesAbove(context.parentURL))
222
+ throw err;
223
+ return next(specifier, { ...context, parentURL: parent });
224
+ }
225
+ };
226
+ }
227
+ /**
228
+ * {@link bareResolveFallback} as module source for a child's `--import`,
229
+ * with `PARENT` bound: the same checks, written for Node's synchronous
230
+ * `registerHooks` and, on a Node without it, the asynchronous `register`,
231
+ * whose `next` returns a promise.
232
+ */
233
+ function hooksSource(parent) {
234
+ return [
235
+ 'import { existsSync } from "node:fs";',
236
+ 'import { dirname, join } from "node:path";',
237
+ 'import { fileURLToPath } from "node:url";',
238
+ `const PARENT = ${JSON.stringify(parent)};`,
239
+ 'const bare = (s) => !/^(\\.{0,2}\\/|[a-zA-Z][a-zA-Z0-9+.-]*:)/.test(s) && !s.startsWith("#");',
240
+ "function installed(url) {",
241
+ ' if (typeof url !== "string" || !url.startsWith("file:")) return true;',
242
+ " for (let d = dirname(fileURLToPath(url)); ; ) {",
243
+ ' if (existsSync(join(d, "node_modules"))) return true;',
244
+ " const up = dirname(d);",
245
+ " if (up === d) return false;",
246
+ " d = up;",
247
+ " }",
248
+ "}",
249
+ "function retry(specifier, context, next, e) {",
250
+ ' if (!e || (e.code !== "ERR_MODULE_NOT_FOUND" && e.code !== "MODULE_NOT_FOUND") || !bare(specifier) || context.parentURL === PARENT || installed(context.parentURL)) throw e;',
251
+ " return next(specifier, { ...context, parentURL: PARENT });",
252
+ "}",
253
+ "export function resolve(specifier, context, next) {",
254
+ " let r;",
255
+ " try { r = next(specifier, context); } catch (e) { return retry(specifier, context, next, e); }",
256
+ ' return r && typeof r.then === "function" ? r.catch((e) => retry(specifier, context, next, e)) : r;',
257
+ "}",
258
+ ].join("\n");
259
+ }
260
+ const dataUrl = (source) => `data:text/javascript,${encodeURIComponent(source)}`;
261
+ const BARE_FALLBACK = Symbol.for("chant.bareResolveFallback");
262
+ /**
263
+ * Install {@link bareResolveFallback} once in this process, retrying from
264
+ * `parent` (default {@link fallbackParent}). A product's bin calls it before
265
+ * it loads a repository's `chant.config.ts` or Ops. Uses Node's
266
+ * `module.registerHooks` where it has one, else `module.register`. Returns
267
+ * whether it is installed: false on a Node with neither.
268
+ */
269
+ export function installResolveFallback(parent = fallbackParent()) {
270
+ const flags = globalThis;
271
+ if (flags[BARE_FALLBACK])
272
+ return true;
273
+ const m = nodeModule;
274
+ if (typeof m.registerHooks === "function")
275
+ m.registerHooks({ resolve: bareResolveFallback(parent) });
276
+ else if (typeof m.register === "function")
277
+ m.register(dataUrl(hooksSource(parent)));
278
+ else
279
+ return false;
280
+ flags[BARE_FALLBACK] = true;
281
+ return true;
282
+ }
283
+ /**
284
+ * The node arguments that install {@link bareResolveFallback} in a chant
285
+ * child (`chant build`, `chant run`), before its own imports of the
286
+ * repository's files: one `--import` of a `data:` module, so it loads the
287
+ * same from a product's `src/` under tsx and from its bundle. Pass them as
288
+ * {@link chantArgv}'s `nodeArgs`, or {@link runChant}'s `resolveFallback`.
289
+ */
290
+ export function fallbackImportArgs(parent = fallbackParent()) {
291
+ const hooks = dataUrl(hooksSource(parent));
292
+ const registrar = [
293
+ 'import * as m from "node:module";',
294
+ `import { resolve } from ${JSON.stringify(hooks)};`,
295
+ `if (typeof m.registerHooks === "function") m.registerHooks({ resolve }); else m.register(${JSON.stringify(hooks)});`,
296
+ ].join("\n");
297
+ return ["--import", dataUrl(registrar)];
298
+ }
299
+ /**
300
+ * Run `chant <args>` and resolve with its exit code, its output and its
301
+ * `--json` document (#4889; SQL Yodeler's `runChant`, terragucci's in
302
+ * `resume.ts`). The chant is the product's own ({@link chantArgv}) with its
303
+ * bin first on PATH ({@link chantEnv}). Never rejects on a non-zero exit;
304
+ * rejects when the child cannot start.
305
+ */
306
+ export function runChant(args, options = {}) {
307
+ const install = options.chant === undefined ? (options.install ?? bundledChant() ?? installedChant(options.from ?? [])) : undefined;
308
+ const fallback = options.resolveFallback === true ? fallbackImportArgs() : typeof options.resolveFallback === "string" ? fallbackImportArgs(options.resolveFallback) : [];
309
+ const [command, ...argv] = install ? chantArgv(args, { install, nodeArgs: [...fallback, ...(options.nodeArgs ?? [])] }) : [options.chant ?? "chant", ...args];
310
+ const env = { ...chantEnv(options.env ?? process.env, install), ...(options.noColor ? { FORCE_COLOR: "0", NO_COLOR: "1" } : {}) };
311
+ const piped = options.stdio !== "inherit";
312
+ return new Promise((done, reject) => {
313
+ const child = spawn(command, argv, { cwd: options.cwd ?? process.cwd(), env, stdio: ["ignore", piped ? "pipe" : "inherit", piped ? "pipe" : "inherit"] });
314
+ let stdout = "";
315
+ let stderr = "";
316
+ child.stdout?.setEncoding("utf8");
317
+ child.stderr?.setEncoding("utf8");
318
+ child.stdout?.on("data", (chunk) => {
319
+ stdout += chunk;
320
+ options.onStdout?.(chunk);
321
+ });
322
+ child.stderr?.on("data", (chunk) => {
323
+ stderr += chunk;
324
+ options.onStderr?.(chunk);
325
+ });
326
+ child.on("error", reject);
327
+ child.on("close", (code, signal) => {
328
+ const json = lastJsonLine(stdout);
329
+ done({ code: code ?? (signal ? 128 : 1), stdout, stderr, ...(json !== undefined ? { json } : {}) });
330
+ });
331
+ });
332
+ }
333
+ /**
334
+ * The last line of `stdout` that parses as a JSON object: chant prints its
335
+ * `--json` document as one line, after any log lines. A pretty-printed
336
+ * document is read from the first `{` to the end. Undefined when there is
337
+ * none.
338
+ */
339
+ export function lastJsonLine(stdout) {
340
+ const lines = stdout.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("{"));
341
+ for (const line of lines.reverse()) {
342
+ try {
343
+ return JSON.parse(line);
344
+ }
345
+ catch {
346
+ // A log line that starts with "{"; keep looking.
347
+ }
348
+ }
349
+ const at = stdout.indexOf("{");
350
+ if (at >= 0) {
351
+ try {
352
+ return JSON.parse(stdout.slice(at));
353
+ }
354
+ catch {
355
+ // Not JSON.
356
+ }
357
+ }
358
+ return undefined;
359
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `@intentius/chant/ci-base` (#4966): the base a CI job measures a change
3
+ * from, read off the job's own variables, so a product's check and policy
4
+ * steps need no rule of their own for it (terragucci's `policyBase`).
5
+ *
6
+ * - A pull request's job: its target branch, `origin/<target>`
7
+ * (`GITHUB_BASE_REF` on GitHub and Forgejo, GitLab's
8
+ * `CI_MERGE_REQUEST_TARGET_BRANCH_NAME`).
9
+ * - A push to a branch other than the default branch: `origin/<default>`,
10
+ * so a change that edits a check or a policy on a side branch is still
11
+ * judged by the default branch's.
12
+ * - A push to the default branch, or a job with no branch: no base, and
13
+ * the checkout's own files are the trusted ones.
14
+ *
15
+ * `chant ci check` takes it as its `--base` when none is given.
16
+ *
17
+ * This module imports nothing.
18
+ */
19
+ export interface CiBaseOptions {
20
+ /** A base the caller already has (a flag, a product's own variable); it wins over everything. */
21
+ base?: string;
22
+ /** The default branch. Default GitLab's `CI_DEFAULT_BRANCH`; GitHub and Forgejo jobs carry none, so a product passes its own. */
23
+ defaultBranch?: string;
24
+ /** The remote the branches are fetched from. Default `origin`. */
25
+ remote?: string;
26
+ }
27
+ /** The base ref for the job `env` describes, as the module comment says; undefined when there is none. */
28
+ export declare function ciBaseRef(env?: Record<string, string | undefined>, options?: CiBaseOptions): string | undefined;
29
+ export { CI_BASE_REF_FLOOR } from "./release-floors.js";
30
+ //# sourceMappingURL=ci-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci-base.d.ts","sourceRoot":"","sources":["../src/ci-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,aAAa;IAC5B,iGAAiG;IACjG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iIAAiI;IACjI,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,0GAA0G;AAC1G,wBAAgB,SAAS,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,GAAG,SAAS,CAShI;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * `@intentius/chant/ci-base` (#4966): the base a CI job measures a change
3
+ * from, read off the job's own variables, so a product's check and policy
4
+ * steps need no rule of their own for it (terragucci's `policyBase`).
5
+ *
6
+ * - A pull request's job: its target branch, `origin/<target>`
7
+ * (`GITHUB_BASE_REF` on GitHub and Forgejo, GitLab's
8
+ * `CI_MERGE_REQUEST_TARGET_BRANCH_NAME`).
9
+ * - A push to a branch other than the default branch: `origin/<default>`,
10
+ * so a change that edits a check or a policy on a side branch is still
11
+ * judged by the default branch's.
12
+ * - A push to the default branch, or a job with no branch: no base, and
13
+ * the checkout's own files are the trusted ones.
14
+ *
15
+ * `chant ci check` takes it as its `--base` when none is given.
16
+ *
17
+ * This module imports nothing.
18
+ */
19
+ const set = (v) => (v && v.trim() ? v.trim() : undefined);
20
+ /** The base ref for the job `env` describes, as the module comment says; undefined when there is none. */
21
+ export function ciBaseRef(env = process.env, options = {}) {
22
+ const given = set(options.base);
23
+ if (given)
24
+ return given;
25
+ const remote = options.remote ?? "origin";
26
+ const target = set(env.GITHUB_BASE_REF) ?? set(env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME);
27
+ if (target)
28
+ return `${remote}/${target}`;
29
+ const branch = set(env.GITHUB_REF_NAME) ?? set(env.CI_COMMIT_BRANCH);
30
+ const main = set(options.defaultBranch) ?? set(env.CI_DEFAULT_BRANCH);
31
+ return branch && main && branch !== main ? `${remote}/${main}` : undefined;
32
+ }
33
+ export { CI_BASE_REF_FLOOR } from "./release-floors.js";