@intentius/chant 0.124.76 → 0.124.78

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 (212) hide show
  1. package/dist/__fixtures__/agent-guard/plywood.d.ts +8 -0
  2. package/dist/__fixtures__/agent-guard/plywood.d.ts.map +1 -0
  3. package/dist/__fixtures__/agent-guard/plywood.js +19 -0
  4. package/dist/__fixtures__/agent-guard/terragucci.d.ts +8 -0
  5. package/dist/__fixtures__/agent-guard/terragucci.d.ts.map +1 -0
  6. package/dist/__fixtures__/agent-guard/terragucci.js +30 -0
  7. package/dist/__fixtures__/gated-ledger.d.ts +10 -0
  8. package/dist/__fixtures__/gated-ledger.d.ts.map +1 -0
  9. package/dist/__fixtures__/gated-ledger.js +51 -0
  10. package/dist/__fixtures__/notify-messages/events.d.ts +9 -0
  11. package/dist/__fixtures__/notify-messages/events.d.ts.map +1 -0
  12. package/dist/__fixtures__/notify-messages/events.js +21 -0
  13. package/dist/__fixtures__/product-words.d.ts +14 -0
  14. package/dist/__fixtures__/product-words.d.ts.map +1 -1
  15. package/dist/__fixtures__/product-words.js +11 -0
  16. package/dist/__fixtures__/terragucci-notify.d.ts +66 -0
  17. package/dist/__fixtures__/terragucci-notify.d.ts.map +1 -0
  18. package/dist/__fixtures__/terragucci-notify.js +133 -0
  19. package/dist/action-pins.d.ts +8 -0
  20. package/dist/action-pins.d.ts.map +1 -1
  21. package/dist/action-pins.js +9 -0
  22. package/dist/agent-guard.d.ts +143 -0
  23. package/dist/agent-guard.d.ts.map +1 -0
  24. package/dist/agent-guard.js +455 -0
  25. package/dist/ci-commit.d.ts +120 -5
  26. package/dist/ci-commit.d.ts.map +1 -1
  27. package/dist/ci-commit.js +214 -23
  28. package/dist/ci-own-jobs.d.ts +81 -0
  29. package/dist/ci-own-jobs.d.ts.map +1 -0
  30. package/dist/ci-own-jobs.js +233 -0
  31. package/dist/ci-product-words.d.ts +18 -4
  32. package/dist/ci-product-words.d.ts.map +1 -1
  33. package/dist/ci-product-words.js +26 -6
  34. package/dist/ci-product.d.ts +40 -1
  35. package/dist/ci-product.d.ts.map +1 -1
  36. package/dist/ci-product.js +40 -1
  37. package/dist/cli/handlers/approve.d.ts +5 -1
  38. package/dist/cli/handlers/approve.d.ts.map +1 -1
  39. package/dist/cli/handlers/approve.js +17 -11
  40. package/dist/cli/handlers/build.d.ts +1 -1
  41. package/dist/cli/handlers/build.d.ts.map +1 -1
  42. package/dist/cli/handlers/build.js +88 -2
  43. package/dist/cli/handlers/commit.d.ts.map +1 -1
  44. package/dist/cli/handlers/commit.js +3 -1
  45. package/dist/cli/handlers/notify-relay.d.ts +18 -1
  46. package/dist/cli/handlers/notify-relay.d.ts.map +1 -1
  47. package/dist/cli/handlers/notify-relay.js +90 -14
  48. package/dist/cli/handlers/pr.d.ts.map +1 -1
  49. package/dist/cli/handlers/pr.js +3 -1
  50. package/dist/cli/handlers/release.d.ts +5 -1
  51. package/dist/cli/handlers/release.d.ts.map +1 -1
  52. package/dist/cli/handlers/release.js +21 -9
  53. package/dist/cli/handlers/run-generate.d.ts.map +1 -1
  54. package/dist/cli/handlers/run-generate.js +2 -1
  55. package/dist/cli/main.d.ts.map +1 -1
  56. package/dist/cli/main.js +21 -1
  57. package/dist/cli/parse-args.d.ts.map +1 -1
  58. package/dist/cli/parse-args.js +60 -4
  59. package/dist/cli/registry.d.ts +16 -0
  60. package/dist/cli/registry.d.ts.map +1 -1
  61. package/dist/components/pr-env-components.d.ts +65 -0
  62. package/dist/components/pr-env-components.d.ts.map +1 -0
  63. package/dist/components/pr-env-components.js +162 -0
  64. package/dist/components/pr-policy.d.ts +15 -0
  65. package/dist/components/pr-policy.d.ts.map +1 -1
  66. package/dist/components/pr-policy.js +24 -1
  67. package/dist/components/release-compile.d.ts +15 -3
  68. package/dist/components/release-compile.d.ts.map +1 -1
  69. package/dist/components/release-compile.js +66 -15
  70. package/dist/config.d.ts +14 -8
  71. package/dist/config.d.ts.map +1 -1
  72. package/dist/config.js +16 -1
  73. package/dist/gate-policy.d.ts +14 -1
  74. package/dist/gate-policy.d.ts.map +1 -1
  75. package/dist/gate-policy.js +16 -6
  76. package/dist/lexicon.d.ts +25 -1
  77. package/dist/lexicon.d.ts.map +1 -1
  78. package/dist/lexicon.js +10 -0
  79. package/dist/lifecycle/gated-op.d.ts +95 -0
  80. package/dist/lifecycle/gated-op.d.ts.map +1 -0
  81. package/dist/lifecycle/gated-op.js +96 -0
  82. package/dist/lifecycle/git.d.ts.map +1 -1
  83. package/dist/lifecycle/git.js +83 -2
  84. package/dist/lifecycle/release-images.d.ts +77 -3
  85. package/dist/lifecycle/release-images.d.ts.map +1 -1
  86. package/dist/lifecycle/release-images.js +132 -6
  87. package/dist/notify-product.d.ts +11 -2
  88. package/dist/notify-product.d.ts.map +1 -1
  89. package/dist/notify-product.js +16 -4
  90. package/dist/notify-relay-repo.d.ts +131 -0
  91. package/dist/notify-relay-repo.d.ts.map +1 -0
  92. package/dist/notify-relay-repo.js +202 -0
  93. package/dist/notify-relay.d.ts +25 -1
  94. package/dist/notify-relay.d.ts.map +1 -1
  95. package/dist/notify-relay.js +27 -2
  96. package/dist/notify.d.ts +36 -4
  97. package/dist/notify.d.ts.map +1 -1
  98. package/dist/notify.js +31 -21
  99. package/dist/notify.schema.json +1 -0
  100. package/dist/op/activities/review-product.d.ts +111 -0
  101. package/dist/op/activities/review-product.d.ts.map +1 -0
  102. package/dist/op/activities/review-product.js +116 -0
  103. package/dist/op/op-waves-capability.js +2 -2
  104. package/dist/policy-engine.d.ts +95 -0
  105. package/dist/policy-engine.d.ts.map +1 -0
  106. package/dist/policy-engine.js +157 -0
  107. package/dist/pr-forge-reads.d.ts +124 -0
  108. package/dist/pr-forge-reads.d.ts.map +1 -0
  109. package/dist/pr-forge-reads.js +322 -0
  110. package/dist/pr-forge.d.ts +14 -0
  111. package/dist/pr-forge.d.ts.map +1 -1
  112. package/dist/pr-forge.js +21 -13
  113. package/dist/pr-plan-note.d.ts +293 -0
  114. package/dist/pr-plan-note.d.ts.map +1 -0
  115. package/dist/pr-plan-note.js +362 -0
  116. package/dist/release-floors.d.ts +9 -1
  117. package/dist/release-floors.d.ts.map +1 -1
  118. package/dist/release-floors.js +9 -1
  119. package/dist/state-export.d.ts +126 -0
  120. package/dist/state-export.d.ts.map +1 -0
  121. package/dist/state-export.js +156 -0
  122. package/dist/state-migration.d.ts +148 -0
  123. package/dist/state-migration.d.ts.map +1 -0
  124. package/dist/state-migration.js +146 -0
  125. package/dist/state-unlock.d.ts +167 -0
  126. package/dist/state-unlock.d.ts.map +1 -0
  127. package/dist/state-unlock.js +196 -0
  128. package/dist/wave-runtime.mjs +332 -332
  129. package/dist/workspace/declaration.schema.json +1 -1
  130. package/dist/workspace/release-workflow.d.ts +10 -0
  131. package/dist/workspace/release-workflow.d.ts.map +1 -1
  132. package/dist/workspace/release-workflow.js +10 -4
  133. package/package.json +1 -1
  134. package/src/__fixtures__/agent-guard/plywood.ts +27 -0
  135. package/src/__fixtures__/agent-guard/terragucci.ts +39 -0
  136. package/src/__fixtures__/gated-ledger.ts +58 -0
  137. package/src/__fixtures__/notify-messages/events.ts +23 -0
  138. package/src/__fixtures__/notify-messages/messages.json +50 -0
  139. package/src/__fixtures__/pr-loop/terragucci-plan.note.golden.md +53 -0
  140. package/src/__fixtures__/pr-loop/terragucci-plan.note.json +83 -0
  141. package/src/__fixtures__/product-words.ts +12 -0
  142. package/src/__fixtures__/review-agent/terragucci-review.json +94 -0
  143. package/src/__fixtures__/terragucci-notify.ts +170 -0
  144. package/src/action-pins.test.ts +12 -1
  145. package/src/action-pins.ts +11 -0
  146. package/src/agent-guard.test.ts +319 -0
  147. package/src/agent-guard.ts +547 -0
  148. package/src/ci-commit.test.ts +213 -2
  149. package/src/ci-commit.ts +258 -27
  150. package/src/ci-own-jobs.test.ts +108 -0
  151. package/src/ci-own-jobs.ts +252 -0
  152. package/src/ci-product-words.ts +35 -7
  153. package/src/ci-product.ts +81 -1
  154. package/src/cli/handlers/approve-cwd.test.ts +112 -0
  155. package/src/cli/handlers/approve.ts +22 -11
  156. package/src/cli/handlers/build-own-jobs.test.ts +80 -0
  157. package/src/cli/handlers/build-pr-loop-control.test.ts +87 -0
  158. package/src/cli/handlers/build-run-group.test.ts +59 -0
  159. package/src/cli/handlers/build.ts +83 -3
  160. package/src/cli/handlers/commit.ts +3 -0
  161. package/src/cli/handlers/notify-relay.ts +99 -17
  162. package/src/cli/handlers/pr.ts +3 -1
  163. package/src/cli/handlers/release.ts +20 -10
  164. package/src/cli/handlers/run-generate.ts +2 -1
  165. package/src/cli/main.ts +21 -1
  166. package/src/cli/parse-args.ts +45 -3
  167. package/src/cli/registry.ts +16 -0
  168. package/src/components/pr-env-components.test.ts +137 -0
  169. package/src/components/pr-env-components.ts +213 -0
  170. package/src/components/pr-policy.test.ts +41 -1
  171. package/src/components/pr-policy.ts +25 -1
  172. package/src/components/release-compile.test.ts +47 -0
  173. package/src/components/release-compile.ts +70 -13
  174. package/src/config.ts +23 -3
  175. package/src/gate-policy-bundle.test.ts +14 -0
  176. package/src/gate-policy.test.ts +7 -0
  177. package/src/gate-policy.ts +22 -7
  178. package/src/lexicon.ts +28 -1
  179. package/src/lifecycle/gated-op.ts +158 -0
  180. package/src/lifecycle/git.test.ts +92 -0
  181. package/src/lifecycle/git.ts +71 -2
  182. package/src/lifecycle/release-images-dockerfile.test.ts +221 -0
  183. package/src/lifecycle/release-images.ts +167 -8
  184. package/src/notify-message-words.test.ts +186 -0
  185. package/src/notify-product.ts +17 -4
  186. package/src/notify-relay-repo.test.ts +284 -0
  187. package/src/notify-relay-repo.ts +234 -0
  188. package/src/notify-relay.test.ts +12 -0
  189. package/src/notify-relay.ts +29 -3
  190. package/src/notify.schema.json +1 -0
  191. package/src/notify.ts +59 -19
  192. package/src/op/activities/review-product.test.ts +116 -0
  193. package/src/op/activities/review-product.ts +200 -0
  194. package/src/op/op-waves-capability.ts +2 -2
  195. package/src/op/schedule-overdue.test.ts +26 -0
  196. package/src/policy-engine.test.ts +162 -0
  197. package/src/policy-engine.ts +200 -0
  198. package/src/pr-forge-reads.test.ts +285 -0
  199. package/src/pr-forge-reads.ts +424 -0
  200. package/src/pr-forge.ts +30 -16
  201. package/src/pr-plan-note.test.ts +105 -0
  202. package/src/pr-plan-note.ts +521 -0
  203. package/src/release-floors.ts +13 -1
  204. package/src/state-export.test.ts +124 -0
  205. package/src/state-export.ts +227 -0
  206. package/src/state-migration.test.ts +133 -0
  207. package/src/state-migration.ts +236 -0
  208. package/src/state-unlock.test.ts +165 -0
  209. package/src/state-unlock.ts +293 -0
  210. package/src/workspace/declaration.schema.json +1 -1
  211. package/src/workspace/release-workflow.test.ts +34 -0
  212. package/src/workspace/release-workflow.ts +19 -4
package/dist/ci-commit.js CHANGED
@@ -28,14 +28,26 @@ import { spawn } from "node:child_process";
28
28
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
29
29
  import { join } from "node:path";
30
30
  import { CHANT_EXIT } from "./exit-codes.js";
31
+ import { FORGE_TOKEN_VARS } from "./ci-handover.js";
31
32
  import { agentForbiddenPaths, AgentError, branchOk, errText, LOGIN, readSmall, SHA } from "./ci-agent.js";
32
- import { parseProductComment } from "./ci-product-words.js";
33
+ import { COMMIT_COMMENT_ARG, parseProductComment } from "./ci-product-words.js";
34
+ import { NEXT_RELEASE } from "./release-floors.js";
33
35
  /** The first chant with the commit job and the scheduled Op spec's `commit` (#4722). Products feature-detect on it. */
34
36
  export const CI_COMMIT_FLOOR = "0.124.71";
35
37
  /** The first chant with a commit job after a check that runs on push, `jobToken` and `after` (#4749). Products feature-detect on it. */
36
38
  export const CI_COMMIT_PUSH_FLOOR = "0.124.72";
37
39
  /** The first chant whose commit job takes `allowedFiles` (#4758). */
38
40
  export const CI_COMMIT_FILES_FLOOR = "0.124.73";
41
+ /**
42
+ * The first chant whose commit job takes `commandEnv`, gives the command
43
+ * `CHANT_COMMIT_PR`, keeps the tail of its standard error and replies with a
44
+ * product's refusal text ({@link setCommitRefusalReply}) (#4724).
45
+ */
46
+ export const CI_COMMIT_REPLY_FLOOR = "0.124.77";
47
+ /** The first chant whose commit job takes `commentArg`, one argument after the comment's word passed into the argv (#4820). */
48
+ export const CI_COMMIT_ARG_FLOOR = NEXT_RELEASE;
49
+ /** The first chant whose `commit land` reads {@link COMMIT_HARNESS_BREAK_ENV} in a BREAK arm of chant's e2e harness (#4836). */
50
+ export const CI_COMMIT_HARNESS_BREAK_FLOOR = NEXT_RELEASE;
39
51
  export const COMMIT_TRIGGERS = ["comment", "check"];
40
52
  export const COMMIT_MAX_RUNS = 3;
41
53
  export const COMMIT_TIMEOUT_MINUTES = 10;
@@ -57,10 +69,16 @@ export const COMMIT_ENV = {
57
69
  timeout: "CHANT_COMMIT_TIMEOUT",
58
70
  env: "CHANT_COMMIT_ENV",
59
71
  mergeBase: "CHANT_COMMIT_MERGE_BASE",
72
+ commandEnv: "CHANT_COMMIT_COMMAND_ENV",
73
+ commentArg: "CHANT_COMMIT_COMMENT_ARG",
60
74
  };
75
+ /** The variable the command reads the pull request's number from (#4724), such as for a default name. */
76
+ export const COMMIT_PR_ENV = "CHANT_COMMIT_PR";
61
77
  /** GitLab starts no pipeline on a note: a pipeline of the default branch started with these runs a comment commit job. */
62
78
  export const GITLAB_COMMIT_PR_VAR = "CHANT_COMMIT_PR";
63
79
  export const GITLAB_COMMIT_WORD_VAR = "CHANT_COMMIT";
80
+ /** With `commentArg` (#4820): the argument, as the comment would give it after the word. */
81
+ export const GITLAB_COMMIT_ARG_VAR = "CHANT_COMMIT_ARG";
64
82
  /** Where the jobs keep the decision, the exit code and the patch, from the job's directory. */
65
83
  export const COMMIT_DIR = ".chant/commit";
66
84
  /** The local ref the checkout fetches a pull request's head into. */
@@ -70,6 +88,10 @@ export const COMMIT_BASE_REF = "refs/chant/commit-base";
70
88
  export const COMMIT_DECISION_FILE = "decision.json";
71
89
  export const COMMIT_PATCH_FILE = "change.patch";
72
90
  export const COMMIT_RC_FILE = "rc";
91
+ /** The tail of the command's standard error (#4724), which a product's refusal reply reads. */
92
+ export const COMMIT_OUTPUT_FILE = "output";
93
+ /** How much of the command's standard error {@link COMMIT_OUTPUT_FILE} keeps, from the end. */
94
+ export const COMMIT_OUTPUT_LIMIT = 8192;
73
95
  /** What `chant commit land` leaves when it pushed (#4749): the pushed commit, which the push job's `after` lines read. */
74
96
  export const COMMIT_PUSHED_FILE = "pushed";
75
97
  /**
@@ -144,6 +166,28 @@ export function resolveCommitSpec(name, spec, product = "chant") {
144
166
  const after = spec.after ?? [];
145
167
  if (!Array.isArray(after) || !after.every((l) => typeof l === "string" && l.trim() !== "" && !l.includes("\n")))
146
168
  throw new AgentError(`${where}: after is a list of shell lines, one command each`);
169
+ const commandEnv = spec.commandEnv ?? [];
170
+ if (!Array.isArray(commandEnv) || !commandEnv.every((v) => typeof v === "string" && VAR.test(v)))
171
+ throw new AgentError(`${where}: commandEnv is a list of variable names`);
172
+ const tokens = commandEnv.filter((v) => FORGE_TOKEN_VARS.includes(v) || v === spec.tokenEnv || v.startsWith("CHANT_COMMIT_"));
173
+ if (tokens.length > 0)
174
+ throw new AgentError(`${where}: commandEnv may not pass ${tokens.join(", ")}: the command never sees a forge token or the job's own settings`);
175
+ let commentArg;
176
+ if (spec.commentArg !== undefined) {
177
+ const a = spec.commentArg;
178
+ if (spec.on !== "comment")
179
+ throw new AgentError(`${where}: commentArg is for the comment trigger, which has a comment to read it from`);
180
+ if (typeof a.pattern !== "string" || !a.pattern.startsWith("^") || !a.pattern.endsWith("$") || a.pattern.length > 200) {
181
+ throw new AgentError(`${where}: commentArg's pattern is a regular expression's source anchored with ^ and $, such as "^[a-z0-9]+(?:[-_][a-z0-9]+)*$"`);
182
+ }
183
+ try {
184
+ new RegExp(a.pattern);
185
+ }
186
+ catch (e) {
187
+ throw new AgentError(`${where}: commentArg's pattern is not a regular expression (${e.message})`);
188
+ }
189
+ commentArg = { pattern: a.pattern, position: intIn(`${where}: commentArg's position`, a.position, 1, spec.command.length) };
190
+ }
147
191
  return {
148
192
  name,
149
193
  on: spec.on,
@@ -159,8 +203,29 @@ export function resolveCommitSpec(name, spec, product = "chant") {
159
203
  mergeBase: spec.mergeBase === true,
160
204
  jobToken: spec.jobToken === true,
161
205
  after: [...after],
206
+ commandEnv: [...new Set(commandEnv)],
207
+ ...(commentArg ? { commentArg } : {}),
162
208
  };
163
209
  }
210
+ /** The words that take an argument, for {@link parseProductComment}: this job's word, when it has `commentArg`. */
211
+ function commentArgPatterns(s) {
212
+ const word = s.comment?.split(" ")[1];
213
+ return word && s.commentArg ? { [word]: new RegExp(s.commentArg.pattern) } : {};
214
+ }
215
+ /**
216
+ * The argv the command runs (#4820): `command`, with the comment's argument
217
+ * at `commentArg.position` when there is one. An argument the settings do
218
+ * not take, or one off its pattern, throws.
219
+ */
220
+ export function commitArgv(s, arg) {
221
+ if (arg === undefined)
222
+ return [...s.command];
223
+ if (!s.commentArg)
224
+ throw new AgentError("this commit job takes no argument after its word");
225
+ if (!COMMIT_COMMENT_ARG.test(arg) || !new RegExp(s.commentArg.pattern).test(arg))
226
+ throw new AgentError(`${JSON.stringify(arg)} is not a name this commit job takes`);
227
+ return [...s.command.slice(0, s.commentArg.position), arg, ...s.command.slice(s.commentArg.position)];
228
+ }
164
229
  /** The settings as the generated jobs' variables. */
165
230
  export function commitSettingsEnv(s) {
166
231
  return {
@@ -176,6 +241,8 @@ export function commitSettingsEnv(s) {
176
241
  [COMMIT_ENV.timeout]: String(s.timeout),
177
242
  [COMMIT_ENV.env]: s.env,
178
243
  ...(s.mergeBase ? { [COMMIT_ENV.mergeBase]: "1" } : {}),
244
+ ...(s.commandEnv.length > 0 ? { [COMMIT_ENV.commandEnv]: JSON.stringify(s.commandEnv) } : {}),
245
+ ...(s.commentArg ? { [COMMIT_ENV.commentArg]: JSON.stringify(s.commentArg) } : {}),
179
246
  };
180
247
  }
181
248
  /** The settings back from the job's variables, checked as {@link resolveCommitSpec} checks a spec. */
@@ -211,6 +278,19 @@ export function commitSettingsFromEnv(env, product = "chant") {
211
278
  const maxRuns = num(COMMIT_ENV.maxRuns);
212
279
  const timeout = num(COMMIT_ENV.timeout);
213
280
  const guarded = list(COMMIT_ENV.guarded);
281
+ let commentArg;
282
+ const argText = env[COMMIT_ENV.commentArg];
283
+ if (argText) {
284
+ try {
285
+ const parsed = JSON.parse(argText);
286
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
287
+ throw new Error("not an object");
288
+ commentArg = parsed;
289
+ }
290
+ catch (e) {
291
+ throw new AgentError(`${COMMIT_ENV.commentArg} is a JSON object with pattern and position (${e.message})`);
292
+ }
293
+ }
214
294
  const spec = {
215
295
  on: env[COMMIT_ENV.on],
216
296
  ...(env[COMMIT_ENV.comment] ? { comment: env[COMMIT_ENV.comment] } : {}),
@@ -223,6 +303,8 @@ export function commitSettingsFromEnv(env, product = "chant") {
223
303
  ...(guarded ? { guarded } : {}),
224
304
  ...(env[COMMIT_ENV.env] ? { env: env[COMMIT_ENV.env] } : {}),
225
305
  ...(env[COMMIT_ENV.mergeBase] === "1" ? { mergeBase: true } : {}),
306
+ ...(list(COMMIT_ENV.commandEnv) ? { commandEnv: list(COMMIT_ENV.commandEnv) } : {}),
307
+ ...(commentArg ? { commentArg } : {}),
226
308
  };
227
309
  return resolveCommitSpec(name, spec, product);
228
310
  }
@@ -264,7 +346,8 @@ export function commitRequestFromRun(words, s, env, event) {
264
346
  const word = s.comment?.split(" ")[1];
265
347
  if (gitlab) {
266
348
  pr = Number(env[GITLAB_COMMIT_PR_VAR]);
267
- body = env[GITLAB_COMMIT_WORD_VAR] === word ? s.comment : `/${words.product} ${env[GITLAB_COMMIT_WORD_VAR] ?? ""}`;
349
+ const arg = env[GITLAB_COMMIT_ARG_VAR];
350
+ body = env[GITLAB_COMMIT_WORD_VAR] === word ? `${s.comment}${arg ? ` ${arg}` : ""}` : `/${words.product} ${env[GITLAB_COMMIT_WORD_VAR] ?? ""}`;
268
351
  user = env.GITLAB_USER_LOGIN;
269
352
  }
270
353
  else {
@@ -277,12 +360,12 @@ export function commitRequestFromRun(words, s, env, event) {
277
360
  return { refused: "the run names no pull request" };
278
361
  if (typeof user !== "string" || !LOGIN.test(user))
279
362
  return { refused: "the run names nobody who asked" };
280
- const parsed = parseProductComment(words, body, env);
363
+ const parsed = parseProductComment(words, body, env, commentArgPatterns(s));
281
364
  if (parsed?.kind === "refused")
282
365
  return { refused: parsed.reason };
283
366
  if (parsed?.kind !== "commit" || parsed.word !== word)
284
367
  return { refused: `the comment is not ${s.comment}` };
285
- return { pr, user };
368
+ return { pr, user, ...(parsed.arg !== undefined ? { arg: parsed.arg } : {}) };
286
369
  }
287
370
  /**
288
371
  * GitLab, a branch pipeline (a check that runs on push): the merge request
@@ -342,6 +425,8 @@ export function readCommitDecision(dir) {
342
425
  return undefined;
343
426
  if (d.baseSha !== undefined && !SHA.test(d.baseSha))
344
427
  return undefined;
428
+ if (d.arg !== undefined && !(typeof d.arg === "string" && COMMIT_COMMENT_ARG.test(d.arg)))
429
+ return undefined;
345
430
  return d;
346
431
  }
347
432
  catch {
@@ -432,7 +517,7 @@ export async function prepareCommitRun(i) {
432
517
  const req = await resolveCommitRequest(i.words, s, i.env, i.event, i.forge);
433
518
  if ("refused" in req)
434
519
  return no(req.refused, s.on === "check" ? "skipped" : "refused");
435
- const who = { pr: req.pr, ...(req.user ? { user: req.user } : {}) };
520
+ const who = { pr: req.pr, ...(req.user ? { user: req.user } : {}), ...(req.arg !== undefined ? { arg: req.arg } : {}) };
436
521
  if (req.user && i.forge?.userCanWrite && !(await i.forge.userCanWrite(req.user)))
437
522
  return no(`${req.user} cannot write to the repository, so ${s.name} does not run for them`, "refused", who);
438
523
  let sha;
@@ -499,7 +584,16 @@ export async function prepareCommitRun(i) {
499
584
  }
500
585
  export const runCommitArgv = (argv, o) => new Promise((done) => {
501
586
  let timedOut = false;
502
- const child = spawn(argv[0], argv.slice(1), { cwd: o.cwd, env: o.env, stdio: ["ignore", "inherit", "inherit"] });
587
+ let tail = Buffer.alloc(0);
588
+ const child = spawn(argv[0], argv.slice(1), { cwd: o.cwd, env: o.env, stdio: ["ignore", "inherit", "pipe"] });
589
+ // The job's log still gets all of it; the tail is kept for the reply.
590
+ child.stderr?.on("data", (chunk) => {
591
+ process.stderr.write(chunk);
592
+ tail = Buffer.concat([tail, chunk]);
593
+ if (tail.length > COMMIT_OUTPUT_LIMIT)
594
+ tail = tail.subarray(tail.length - COMMIT_OUTPUT_LIMIT);
595
+ });
596
+ const output = () => tail.toString("utf8");
503
597
  const timer = setTimeout(() => {
504
598
  timedOut = true;
505
599
  child.kill("SIGTERM");
@@ -507,25 +601,29 @@ export const runCommitArgv = (argv, o) => new Promise((done) => {
507
601
  }, o.timeoutMs);
508
602
  child.on("error", () => {
509
603
  clearTimeout(timer);
510
- done({ exitCode: null, timedOut });
604
+ done({ exitCode: null, timedOut, output: output() });
511
605
  });
512
606
  child.on("close", (code) => {
513
607
  clearTimeout(timer);
514
- done({ exitCode: code, timedOut });
608
+ done({ exitCode: code, timedOut, output: output() });
515
609
  });
516
610
  });
517
611
  /**
518
612
  * The variables the command sees: process basics, with the checkout's
519
613
  * `node_modules/.bin` first on `PATH` so a product's bin installed on the
520
- * target branch runs on the head's files. Never a forge or cloud token.
614
+ * target branch runs on the head's files. Never a forge or cloud token. Also
615
+ * the variables the spec's `commandEnv` names, and {@link COMMIT_PR_ENV}, the
616
+ * pull request's number (#4724).
521
617
  */
522
- export function commitCommandEnv(env, checkout) {
618
+ export function commitCommandEnv(env, checkout, o = {}) {
523
619
  const out = {};
524
- for (const name of ["PATH", "HOME", "TMPDIR", "LANG", "LC_ALL", "TERM", "SystemRoot", "npm_config_cache"]) {
620
+ for (const name of ["PATH", "HOME", "TMPDIR", "LANG", "LC_ALL", "TERM", "SystemRoot", "npm_config_cache", ...(o.names ?? [])]) {
525
621
  const v = env[name];
526
622
  if (v !== undefined)
527
623
  out[name] = v;
528
624
  }
625
+ if (o.pr !== undefined)
626
+ out[COMMIT_PR_ENV] = String(o.pr);
529
627
  const bin = join(checkout, "node_modules", ".bin");
530
628
  if (existsSync(bin))
531
629
  out.PATH = out.PATH ? `${bin}:${out.PATH}` : bin;
@@ -539,6 +637,14 @@ export async function runCommit(i) {
539
637
  writeFileSync(rcFile, "refused\n");
540
638
  return { rc: "refused", changed: false };
541
639
  }
640
+ let argv;
641
+ try {
642
+ argv = commitArgv(i.settings, decision.arg);
643
+ }
644
+ catch {
645
+ writeFileSync(rcFile, "refused\n");
646
+ return { rc: "refused", changed: false };
647
+ }
542
648
  i.git(["worktree", "add", "--detach", "--force", i.workDir, decision.sha]);
543
649
  if (i.settings.mergeBase) {
544
650
  if (!decision.baseSha) {
@@ -554,14 +660,68 @@ export async function runCommit(i) {
554
660
  return { rc: "conflict", changed: false };
555
661
  }
556
662
  }
557
- const out = await i.runCommand(i.settings.command, { cwd: i.workDir, env: commitCommandEnv(i.env, i.checkout), timeoutMs: i.settings.timeout * 60000 });
663
+ const env = commitCommandEnv(i.env, i.checkout, { names: i.settings.commandEnv, ...(decision.pr !== undefined ? { pr: decision.pr } : {}) });
664
+ const out = await i.runCommand(argv, { cwd: i.workDir, env, timeoutMs: i.settings.timeout * 60000 });
558
665
  const rc = out.timedOut ? "timeout" : out.exitCode === null ? "no-exit" : String(out.exitCode);
559
666
  writeFileSync(rcFile, `${rc}\n`);
667
+ if (out.output)
668
+ writeFileSync(join(i.dir, COMMIT_OUTPUT_FILE), out.output.slice(-COMMIT_OUTPUT_LIMIT));
560
669
  i.git(["add", "-A"], { cwd: i.workDir });
561
670
  const patch = i.git(["diff", "--cached", "--binary", "--no-renames", "HEAD"], { cwd: i.workDir });
562
671
  writeFileSync(join(i.dir, COMMIT_PATCH_FILE), patch);
563
672
  return { rc, changed: patch.length > 0 };
564
673
  }
674
+ // ── the harness's BREAK switch (#4836) ─────────────────────────────────────
675
+ /**
676
+ * The push job's variable that turns one of land's checks off, for a BREAK
677
+ * arm of a product's e2e harness scenario: a comma list of
678
+ * {@link COMMIT_HARNESS_CHECKS}. It proves the check matters: with it off,
679
+ * the scenario's expectations must fail. Read only by `chant commit land`,
680
+ * and refused anywhere but chant's harness ({@link commitHarnessBreaks}).
681
+ * The command never sees it: `commandEnv` refuses every `CHANT_COMMIT_*`.
682
+ */
683
+ export const COMMIT_HARNESS_BREAK_ENV = "CHANT_COMMIT_HARNESS_BREAK";
684
+ /**
685
+ * The checks the switch may turn off. `paths`: a change outside `allowed`
686
+ * and `allowedFiles` lands (a guarded path is still refused). `moved-base`:
687
+ * with `mergeBase`, a base that moved while the command ran lands the merge
688
+ * of the tip the command ran on.
689
+ */
690
+ export const COMMIT_HARNESS_CHECKS = ["paths", "moved-base"];
691
+ /** The forge a job of chant's e2e harness reaches, `HARNESS_HOSTS.forgejo` (./e2e-harness/stack.ts). */
692
+ export const COMMIT_HARNESS_FORGE = "http://forgejo:3000";
693
+ const HARNESS_WORDS = { paths: "the path check", "moved-base": "the moved-base check" };
694
+ /**
695
+ * The checks {@link COMMIT_HARNESS_BREAK_ENV} turns off, or why it is
696
+ * refused. It is read only in a BREAK arm of chant's e2e harness: `BREAK=1`,
697
+ * not GitLab, and a job whose `GITHUB_SERVER_URL` is the harness's Forgejo,
698
+ * {@link COMMIT_HARNESS_FORGE}. Unset or empty, no check is off.
699
+ */
700
+ export function commitHarnessBreaks(env) {
701
+ const raw = env[COMMIT_HARNESS_BREAK_ENV]?.trim() ?? "";
702
+ if (raw === "")
703
+ return { checks: [] };
704
+ const server = env.GITHUB_SERVER_URL?.replace(/\/+$/, "");
705
+ if (env.BREAK !== "1" || env.GITLAB_CI === "true" || server !== COMMIT_HARNESS_FORGE) {
706
+ return { refused: `${COMMIT_HARNESS_BREAK_ENV} is read only in a BREAK arm of chant's e2e harness (BREAK=1 on the harness's Forgejo, ${COMMIT_HARNESS_FORGE}), and this job is not one` };
707
+ }
708
+ const named = raw.split(",").map((c) => c.trim()).filter((c) => c !== "");
709
+ const bad = named.filter((c) => !COMMIT_HARNESS_CHECKS.includes(c));
710
+ if (bad.length > 0)
711
+ return { refused: `${COMMIT_HARNESS_BREAK_ENV} names ${bad.join(", ")}; the checks it turns off are ${COMMIT_HARNESS_CHECKS.join(" and ")}` };
712
+ return { checks: [...new Set(named)] };
713
+ }
714
+ let activeRefusalReply;
715
+ /** Set the refusal reply for this process (a product's bin, once, as it sets its words). Returns the one it replaced. */
716
+ export function setCommitRefusalReply(reply) {
717
+ const was = activeRefusalReply;
718
+ activeRefusalReply = reply;
719
+ return was;
720
+ }
721
+ /** The refusal reply {@link setCommitRefusalReply} set, if any. */
722
+ export function activeCommitRefusalReply() {
723
+ return activeRefusalReply;
724
+ }
565
725
  const code = (s) => "`" + s.replaceAll("`", "'") + "`";
566
726
  /**
567
727
  * `chant commit land`: from the commit job's patch to a pushed commit, or a
@@ -621,20 +781,44 @@ export async function landCommitChange(i) {
621
781
  if ("refused" in req)
622
782
  return finish({ result: s.on === "check" ? "skipped" : "refused", reason: req.refused });
623
783
  ({ pr, user } = req);
784
+ // #4836: a BREAK arm of the harness may turn a check off; anywhere else the switch fails the land.
785
+ const harness = commitHarnessBreaks(i.env);
786
+ if ("refused" in harness)
787
+ return finish({ result: "failed", reason: harness.refused }, `${harness.refused}, so nothing was pushed.`);
788
+ const off = new Set(harness.checks);
624
789
  const decision = readCommitDecision(i.dir);
625
- if (!decision || decision.name !== s.name || decision.on !== s.on || (decision.pr !== undefined && decision.pr !== pr)) {
790
+ if (!decision || decision.name !== s.name || decision.on !== s.on || (decision.pr !== undefined && decision.pr !== pr) || (decision.go && decision.arg !== req.arg)) {
626
791
  return finish({ result: "failed", reason: "the commit job left no decision this job can read" }, "the commit job left nothing to land, so nothing was pushed.");
627
792
  }
628
793
  if (!decision.go)
629
794
  return finish({ result: decision.stop ?? "refused", reason: decision.reason ?? "refused" }, `${decision.reason ?? `${s.name} did not run`}, so nothing was pushed.`);
795
+ // What ran, as the replies and the commit name it: the command with the comment's argument (#4820).
796
+ let ranArgv;
797
+ try {
798
+ ranArgv = commitArgv(s, req.arg).join(" ");
799
+ }
800
+ catch (e) {
801
+ return finish({ result: "refused", reason: errText(e) }, `${errText(e)}, so nothing was pushed.`);
802
+ }
630
803
  const rc = readSmall(join(i.dir, COMMIT_RC_FILE))?.trim() ?? "";
631
804
  if (rc === "conflict") {
632
805
  return finish({ result: "refused", reason: `merging ${decision.base ?? "the base"} into the head conflicts` }, `merging ${code(decision.base ?? "the base")} into the ${what} conflicts, so ${s.name} did not run and nothing was pushed. Resolve the conflict on the branch.`);
633
806
  }
634
807
  if (rc === "timeout")
635
- return finish({ result: "stopped", reason: `the command passed its ${s.timeout} minute limit` }, `${code(s.command.join(" "))} was stopped at its ${s.timeout} minute limit, so nothing was pushed.`);
808
+ return finish({ result: "stopped", reason: `the command passed its ${s.timeout} minute limit` }, `${code(ranArgv)} was stopped at its ${s.timeout} minute limit, so nothing was pushed.`);
809
+ if (rc !== "0" && /^[0-9]+$/.test(rc) && i.refusalReply) {
810
+ let said;
811
+ try {
812
+ said = i.refusalReply({ settings: s, rc, output: readSmall(join(i.dir, COMMIT_OUTPUT_FILE), COMMIT_OUTPUT_LIMIT * 2) ?? "" });
813
+ }
814
+ catch {
815
+ said = undefined;
816
+ }
817
+ if (said)
818
+ return finish({ result: "refused", reason: `the command refused, exiting ${rc}` }, `${said.trim()} Nothing was pushed.`);
819
+ }
636
820
  if (rc !== "0")
637
- return finish({ result: "failed", reason: `the command exited ${rc || "with no code"}` }, `${code(s.command.join(" "))} stopped with ${rc ? `exit code ${rc}` : "no exit code"}, so nothing was pushed. The commit job's log has its output.`);
821
+ return finish({ result: "failed", reason: `the command exited ${rc || "with no code"}` }, `${code(ranArgv)} stopped with ${rc ? `exit code ${rc}` : "no exit code"}, so nothing was pushed. The commit job's log has its output.`);
638
822
  const head = await i.forge.pullRequestHead?.(pr).catch(() => undefined);
639
823
  if (!head || !head.open || !head.sameRepo || !branchOk(head.branch))
640
824
  return finish({ result: "refused", reason: `#${pr} is not an open ${what} from this repository` }, `#${pr} is not an open ${what} from this repository, so nothing was pushed.`);
@@ -659,8 +843,12 @@ export async function landCommitChange(i) {
659
843
  catch (e) {
660
844
  return finish({ result: "failed", reason: `could not fetch ${target} (${errText(e)})` });
661
845
  }
662
- if (baseSha !== decision.baseSha)
663
- return finish({ result: s.on === "check" ? "skipped" : "refused", reason: "the base moved" }, `${code(target)} moved while ${s.name} ran, so nothing was pushed. Ask again.`);
846
+ if (baseSha !== decision.baseSha) {
847
+ if (!off.has("moved-base"))
848
+ return finish({ result: s.on === "check" ? "skipped" : "refused", reason: "the base moved" }, `${code(target)} moved while ${s.name} ran, so nothing was pushed. Ask again.`);
849
+ // BREAK: land the merge of the tip the command ran on, which the check exists to stop.
850
+ baseSha = decision.baseSha;
851
+ }
664
852
  }
665
853
  // The limit and the approval again, on this job's own read.
666
854
  const earlier = (await i.readRuns().catch(() => [])).filter((r) => Date.parse(r.started) < Date.parse(started));
@@ -677,7 +865,7 @@ export async function landCommitChange(i) {
677
865
  if (approved && s.on === "check")
678
866
  return finish({ result: "refused", reason: `the plan of ${sha.slice(0, 8)} is approved by ${approved}, and a commit would void that approval` });
679
867
  const patch = join(i.dir, COMMIT_PATCH_FILE);
680
- const nothing = () => finish({ result: s.on === "check" ? "skipped" : "refused", reason: "the command changed nothing" }, `${code(s.command.join(" "))} changed nothing, so nothing was pushed.`);
868
+ const nothing = () => finish({ result: s.on === "check" ? "skipped" : "refused", reason: "the command changed nothing" }, `${code(ranArgv)} changed nothing, so nothing was pushed.`);
681
869
  if (!existsSync(patch) || statSync(patch).size === 0)
682
870
  return nothing();
683
871
  let paths;
@@ -702,13 +890,15 @@ export async function landCommitChange(i) {
702
890
  }
703
891
  if (paths.length === 0)
704
892
  return nothing();
705
- const { forbidden, outside } = commitRefusedPaths(paths, s);
893
+ const refusedPaths = commitRefusedPaths(paths, s);
894
+ const forbidden = refusedPaths.forbidden;
895
+ const outside = off.has("paths") ? [] : refusedPaths.outside;
706
896
  if (forbidden.length > 0 || outside.length > 0) {
707
897
  const bad = [...new Set([...forbidden, ...outside])];
708
- return finish({ result: "refused", reason: `the change touches ${bad.join(", ")}`, paths }, `${code(s.command.join(" "))} changed ${bad.map(code).join(", ")}, which ${s.name} may not change (it may change ${[...s.allowed, ...s.allowedFiles].map(code).join(", ")}, and never CI, chant's settings and state, code owners, agent instructions or git settings), so nothing was pushed.`);
898
+ return finish({ result: "refused", reason: `the change touches ${bad.join(", ")}`, paths }, `${code(ranArgv)} changed ${bad.map(code).join(", ")}, which ${s.name} may not change (it may change ${[...s.allowed, ...s.allowedFiles].map(code).join(", ")}, and never CI, chant's settings and state, code owners, agent instructions or git settings), so nothing was pushed.`);
709
899
  }
710
- const title = s.on === "comment" ? `${s.comment} asked for by ${user} on ${what} #${pr}` : `${s.name} after the check found something at ${sha.slice(0, 8)}`;
711
- const ran = baseSha ? `Merged ${decision.base} at ${baseSha.slice(0, 12)} into ${sha.slice(0, 12)}, then ran ${s.command.join(" ")}.` : `Ran ${s.command.join(" ")} on ${sha.slice(0, 12)}.`;
900
+ const title = s.on === "comment" ? `${s.comment}${req.arg !== undefined ? ` ${req.arg}` : ""} asked for by ${user} on ${what} #${pr}` : `${s.name} after the check found something at ${sha.slice(0, 8)}`;
901
+ const ran = baseSha ? `Merged ${decision.base} at ${baseSha.slice(0, 12)} into ${sha.slice(0, 12)}, then ran ${ranArgv}.` : `Ran ${ranArgv} on ${sha.slice(0, 12)}.`;
712
902
  const message = [title, "", ran, "", ...(user ? [`Requested-by: ${user}`] : []), `${COMMIT_TRAILER}: ${s.name}`, ""].join("\n");
713
903
  let commitSha;
714
904
  try {
@@ -725,8 +915,9 @@ export async function landCommitChange(i) {
725
915
  catch (e) {
726
916
  return finish({ result: "failed", reason: `could not push to ${head.branch} (${errText(e)})`, commit: commitSha }, `could not push to ${code(head.branch)} (${errText(e)}), so nothing was pushed.`);
727
917
  }
918
+ const breakNote = off.size > 0 ? ` (BREAK: ${[...off].map((c) => HARNESS_WORDS[c]).join(" and ")} ${off.size === 1 ? "was" : "were"} off)` : "";
728
919
  const voided = approved ? ` The plan of ${code(sha.slice(0, 8))} was approved by ${approved}; the new commit is planned again and needs approval again.` : "";
729
- return finish({ result: "pushed", reason: `pushed ${commitSha} to ${head.branch}`, commit: commitSha, paths, ...(approved ? { approvalVoided: approved } : {}) }, `pushed ${code(commitSha.slice(0, 8))} to ${code(head.branch)}${user ? ` for ${user}` : ""}, from ${baseSha ? `a merge of ${code(decision.base)} and ` : ""}${code(s.command.join(" "))}, changing ${paths.map(code).join(", ")}.${voided} Nothing was applied, approved or merged.`);
920
+ return finish({ result: "pushed", reason: `pushed ${commitSha} to ${head.branch}${breakNote}`, commit: commitSha, paths, ...(approved ? { approvalVoided: approved } : {}) }, `pushed ${code(commitSha.slice(0, 8))} to ${code(head.branch)}${user ? ` for ${user}` : ""}, from ${baseSha ? `a merge of ${code(decision.base)} and ` : ""}${code(ranArgv)}, changing ${paths.map(code).join(", ")}.${voided} Nothing was applied, approved or merged.${breakNote}`);
730
921
  }
731
922
  // ── what the generated jobs run ────────────────────────────────────────────
732
923
  /** The three commands of the commit jobs, through the product's bin. */
@@ -0,0 +1,81 @@
1
+ /**
2
+ * A repository's own jobs in a pipeline file chant generates (#4769).
3
+ *
4
+ * chant's generators write the whole file, so a job a repository adds by
5
+ * hand is gone at the next `chant build`. Two ways keep it:
6
+ *
7
+ * - a jobs file, or a map of jobs, merged after chant's jobs
8
+ * ({@link mergeOwnJobs}, `chant build --own-jobs <file>`). The file is in
9
+ * the forge's own syntax: a map of job name to job. A name chant's file
10
+ * already gives a job is refused, and on GitLab a top-level keyword too.
11
+ * terragucci's `own_jobs` works this way.
12
+ * - the jobs of the old file that the new one lacks, put back as they were
13
+ * written, comments and all ({@link keepOwnJobs}, `chant build
14
+ * --keep-own-jobs`). A job that runs `chant` or the product's bin counts as
15
+ * generated and is not kept. plywood's `init` and `ci` work this way.
16
+ *
17
+ * Either way the jobs go after chant's, under one comment line: inside
18
+ * `jobs:` at two spaces on GitHub and Forgejo, and at the top level on
19
+ * GitLab. The blocks are read as text by their indentation, so a kept job
20
+ * keeps its formatting. A file with no own jobs is returned unchanged.
21
+ */
22
+ /** The first chant with `mergeOwnJobs`, `keepOwnJobs` and `chant build --own-jobs` / `--keep-own-jobs` (#4769). Products feature-detect on it. */
23
+ export declare const OWN_JOBS_FLOOR = "0.124.77";
24
+ /** The forges whose pipeline files take own jobs. */
25
+ export type OwnJobsForge = "github" | "gitlab" | "forgejo";
26
+ export declare const OWN_JOBS_FORGES: readonly OwnJobsForge[];
27
+ /** The default line above the own jobs. A product passes its own as `line`. */
28
+ export declare const OWN_JOBS_LINE = "# Your own jobs, kept as they are when chant writes this file again.";
29
+ /** GitLab's top-level keys that are not jobs: never read as a job, never kept. */
30
+ export declare const GITLAB_TOP_KEYWORDS: readonly string[];
31
+ /** The names an own job may not take on GitLab: the keywords, and `pages`, which GitLab reads as its Pages job. */
32
+ export declare const GITLAB_RESERVED_JOB_NAMES: readonly string[];
33
+ /** A job name every forge's YAML reads as a plain key. */
34
+ export declare const OWN_JOB_NAME: RegExp;
35
+ /** An own job refused: a collision, a reserved name, or a file that is not a map of jobs. */
36
+ export declare class OwnJobsError extends Error {
37
+ constructor(message: string);
38
+ }
39
+ /** Each job's block of lines in `text`, by name, in file order. */
40
+ export declare function jobBlocks(text: string, forge: OwnJobsForge): Map<string, string>;
41
+ /** The job names of a pipeline file. */
42
+ export declare function jobNames(text: string, forge: OwnJobsForge): string[];
43
+ /** The problems with `own` as a map of job name to job; `where` names it in each. */
44
+ export declare function ownJobsProblems(own: unknown, where: string): string[];
45
+ /** The map of jobs a YAML file holds. Throws {@link OwnJobsError} when it is missing, not YAML, or not a map of jobs. */
46
+ export declare function readOwnJobsFile(path: string, where?: string): Record<string, Record<string, unknown>>;
47
+ export interface MergeOwnJobsOptions {
48
+ /** The line above the jobs. Default {@link OWN_JOBS_LINE}. */
49
+ line?: string;
50
+ /** What the jobs are called in a refusal, such as `own_jobs` or the file's path. Default `own jobs`. */
51
+ where?: string;
52
+ /** Names the generated file's jobs take, when the caller knows them; default: read from `generated`. */
53
+ generatedJobs?: readonly string[];
54
+ }
55
+ /**
56
+ * The YAML of `own`, as it goes after chant's jobs: {@link OWN_JOBS_LINE} (or
57
+ * `line`), then each job as it is. Empty for no jobs. Throws
58
+ * {@link OwnJobsError} on a name in `ours` or, on GitLab, a reserved one.
59
+ */
60
+ export declare function ownJobsYAML(own: Record<string, unknown> | undefined, ours: readonly string[], forge: OwnJobsForge, options?: Omit<MergeOwnJobsOptions, "generatedJobs">): string;
61
+ /** `generated` with `own` after chant's jobs (terragucci's `own_jobs` model). Unchanged for no jobs. */
62
+ export declare function mergeOwnJobs(generated: string, forge: OwnJobsForge, own: Record<string, unknown> | undefined, options?: MergeOwnJobsOptions): string;
63
+ /** Whether a job's block runs `chant` or one of `bins`: a job chant's generator wrote. */
64
+ export declare function isGeneratedJob(block: string, bins?: readonly string[]): boolean;
65
+ export interface KeepOwnJobsOptions {
66
+ /** The product's bin, such as `npx --no-install plywood`: a job that runs it is generated. `chant` always counts. */
67
+ bins?: readonly string[];
68
+ /** The line above the kept jobs. Default {@link OWN_JOBS_LINE}. */
69
+ line?: string;
70
+ }
71
+ /** The jobs of `previous` that `generated` lacks and that run neither `chant` nor a bin of `bins`. */
72
+ export declare function ownJobsOf(previous: string, generated: string, forge: OwnJobsForge, bins?: readonly string[]): Map<string, string>;
73
+ /**
74
+ * The old file's own jobs carried into the new one (plywood's model):
75
+ * `previous` undefined means there was no file. `kept` names them.
76
+ */
77
+ export declare function keepOwnJobs(previous: string | undefined, generated: string, forge: OwnJobsForge, options?: KeepOwnJobsOptions): {
78
+ text: string;
79
+ kept: string[];
80
+ };
81
+ //# sourceMappingURL=ci-own-jobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci-own-jobs.d.ts","sourceRoot":"","sources":["../src/ci-own-jobs.ts"],"names":[],"mappings":"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"}