@intentius/chant 0.124.78 → 0.124.80
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.
- package/dist/action-pins.d.ts.map +1 -1
- package/dist/action-pins.js +1 -2
- package/dist/change-set.d.ts +10 -1
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +4 -1
- package/dist/ci-agent.d.ts +16 -2
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +6 -1
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +2 -3
- package/dist/ci-note-commands.d.ts +199 -0
- package/dist/ci-note-commands.d.ts.map +1 -0
- package/dist/ci-note-commands.js +372 -0
- package/dist/ci-product.d.ts +6 -2
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +5 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +7 -1
- package/dist/cli/handlers/pr-notes.d.ts +13 -0
- package/dist/cli/handlers/pr-notes.d.ts.map +1 -0
- package/dist/cli/handlers/pr-notes.js +73 -0
- package/dist/cli/handlers/release.d.ts +8 -0
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +64 -2
- package/dist/cli/handlers/run-wave.js +1 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +17 -1
- package/dist/cli/mcp/product-tools.d.ts +6 -0
- package/dist/cli/mcp/product-tools.d.ts.map +1 -1
- package/dist/cli/mcp/product-tools.js +6 -0
- package/dist/cli/mcp/read-only.d.ts +12 -0
- package/dist/cli/mcp/read-only.d.ts.map +1 -1
- package/dist/cli/mcp/read-only.js +16 -0
- package/dist/cli/mcp/server.d.ts +11 -0
- package/dist/cli/mcp/server.d.ts.map +1 -1
- package/dist/cli/mcp/server.js +26 -5
- package/dist/cli/mcp/types.d.ts +5 -1
- package/dist/cli/mcp/types.d.ts.map +1 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +10 -0
- package/dist/cli/registry.d.ts +4 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/capability.d.ts +53 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/group-digest.d.ts +17 -0
- package/dist/components/group-digest.d.ts.map +1 -0
- package/dist/components/group-digest.js +18 -0
- package/dist/components/groups.d.ts +2 -11
- package/dist/components/groups.d.ts.map +1 -1
- package/dist/components/groups.js +2 -12
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/pr-pipeline.d.ts +22 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +26 -0
- package/dist/components/product-pipeline.d.ts +12 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +5 -1
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lexicon.js +1 -2
- package/dist/lifecycle/release-cut.d.ts +7 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +1 -0
- package/dist/lifecycle/release-images.d.ts +12 -3
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +6 -7
- package/dist/lifecycle/release-publish.d.ts +8 -1
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.js +30 -3
- package/dist/lifecycle/release-version.d.ts +86 -0
- package/dist/lifecycle/release-version.d.ts.map +1 -0
- package/dist/lifecycle/release-version.js +208 -0
- package/dist/mcp/types.d.ts +26 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/notify-product.d.ts.map +1 -1
- package/dist/notify-product.js +1 -2
- package/dist/op/activities/review-product.d.ts.map +1 -1
- package/dist/op/activities/review-product.js +1 -2
- package/dist/op/gate.d.ts +17 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +36 -0
- package/dist/op/index.d.ts +8 -6
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +5 -4
- package/dist/op/op-waves-after-plan.d.ts +109 -1
- package/dist/op/op-waves-after-plan.d.ts.map +1 -1
- package/dist/op/op-waves-after-plan.js +180 -3
- package/dist/op/op-waves-capability-spec.js +1 -2
- package/dist/op/op-waves-capability.d.ts +93 -3
- package/dist/op/op-waves-capability.d.ts.map +1 -1
- package/dist/op/op-waves-capability.js +218 -10
- package/dist/op/op-waves-run-hooks.d.ts +104 -0
- package/dist/op/op-waves-run-hooks.d.ts.map +1 -0
- package/dist/op/op-waves-run-hooks.js +145 -0
- package/dist/op/op-waves-run.d.ts +21 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +307 -21
- package/dist/op/op-waves.d.ts +11 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +7 -1
- package/dist/op/runtime.d.ts +2 -0
- package/dist/op/runtime.d.ts.map +1 -1
- package/dist/pr-forge-reads.d.ts +151 -1
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +265 -1
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +1 -2
- package/dist/release-floors.d.ts +19 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +23 -5
- package/dist/wave-runtime.mjs +312 -312
- package/dist/workspace/change-set.schema.json +7 -0
- package/dist/workspace/release-workflow.d.ts +7 -0
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +11 -1
- package/package.json +1 -1
- package/src/action-pins.test.ts +1 -2
- package/src/action-pins.ts +1 -3
- package/src/change-set.test.ts +20 -0
- package/src/change-set.ts +11 -1
- package/src/ci-agent.test.ts +9 -0
- package/src/ci-agent.ts +15 -2
- package/src/ci-commit.test.ts +2 -3
- package/src/ci-commit.ts +2 -3
- package/src/ci-note-commands.test.ts +377 -0
- package/src/ci-note-commands.ts +479 -0
- package/src/ci-product.ts +6 -2
- package/src/cli/handlers/build.ts +7 -1
- package/src/cli/handlers/pr-notes.ts +70 -0
- package/src/cli/handlers/release.ts +55 -2
- package/src/cli/handlers/run-wave.ts +1 -0
- package/src/cli/main.ts +17 -1
- package/src/cli/mcp/product-tools.test.ts +49 -0
- package/src/cli/mcp/product-tools.ts +7 -0
- package/src/cli/mcp/read-only.ts +19 -0
- package/src/cli/mcp/server.test.ts +30 -0
- package/src/cli/mcp/server.ts +28 -5
- package/src/cli/mcp/types.ts +6 -1
- package/src/cli/parse-args.ts +8 -0
- package/src/cli/registry.ts +4 -0
- package/src/components/capability.ts +52 -0
- package/src/components/group-digest.ts +20 -0
- package/src/components/groups.ts +3 -13
- package/src/components/index.ts +2 -0
- package/src/components/pr-pipeline.ts +35 -0
- package/src/components/product-pipeline.test.ts +14 -0
- package/src/components/product-pipeline.ts +13 -1
- package/src/config.ts +15 -0
- package/src/lexicon.ts +1 -2
- package/src/lifecycle/release-cut.ts +11 -0
- package/src/lifecycle/release-images-dockerfile.test.ts +10 -2
- package/src/lifecycle/release-images.ts +12 -8
- package/src/lifecycle/release-publish.ts +34 -3
- package/src/lifecycle/release-version.test.ts +155 -0
- package/src/lifecycle/release-version.ts +226 -0
- package/src/mcp/types.ts +27 -0
- package/src/notify-message-words.test.ts +1 -2
- package/src/notify-product.ts +1 -2
- package/src/op/activities/review-product.ts +1 -2
- package/src/op/gate.ts +46 -0
- package/src/op/index.ts +10 -4
- package/src/op/op-waves-after-plan-wave.test.ts +225 -0
- package/src/op/op-waves-after-plan.ts +228 -5
- package/src/op/op-waves-capability-spec.ts +1 -1
- package/src/op/op-waves-capability.test.ts +9 -1
- package/src/op/op-waves-capability.ts +246 -13
- package/src/op/op-waves-gate-port.test.ts +232 -0
- package/src/op/op-waves-run-hooks.test.ts +183 -0
- package/src/op/op-waves-run-hooks.ts +194 -0
- package/src/op/op-waves-run.ts +313 -25
- package/src/op/op-waves-step-wave.test.ts +276 -0
- package/src/op/op-waves.ts +15 -2
- package/src/op/runtime.ts +2 -0
- package/src/pr-forge-reads-compare.test.ts +145 -0
- package/src/pr-forge-reads.test.ts +203 -0
- package/src/pr-forge-reads.ts +398 -1
- package/src/pr-plan-note.ts +1 -2
- package/src/release-floors.ts +32 -5
- package/src/workspace/change-set.schema.json +7 -0
- package/src/workspace/release-workflow.test.ts +18 -0
- package/src/workspace/release-workflow.ts +21 -1
|
@@ -120,6 +120,11 @@ async function releaseImagesOf(cwd: string): Promise<import("../../lifecycle/rel
|
|
|
120
120
|
return (await loadChantConfig(cwd)).config.release?.images ?? [];
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
async function releaseVersionOf(cwd: string): Promise<import("../../lifecycle/release-version").ReleaseVersionConfig | undefined> {
|
|
124
|
+
const { loadChantConfig } = await import("../../config");
|
|
125
|
+
return (await loadChantConfig(cwd)).config.release?.version;
|
|
126
|
+
}
|
|
127
|
+
|
|
123
128
|
/** Copy each `release.images` archive from the directory the cut built it in to the same path under `to`. */
|
|
124
129
|
export function copyImageArchives(images: ReadonlyArray<{ archive: string }>, from: string, to: string): void {
|
|
125
130
|
for (const i of images) {
|
|
@@ -176,7 +181,7 @@ export async function runReleaseImages(ctx: CommandContext): Promise<number> {
|
|
|
176
181
|
if (!existsSync(abs)) throw new ReleaseImageError("release-image-no-archive", `image "${d.name}" has no archive at ${d.archive}`, "Hand this job the archives the cut built, or run without --no-build to build them again.");
|
|
177
182
|
return { component: d.name, kind: "image" as const, path: d.archive, digest: ociArchiveDigest(abs) };
|
|
178
183
|
})
|
|
179
|
-
: buildReleaseImages({ images: declared, cwd, sourceDateEpoch: commitTime(cwd, release.commit), label, archiveDigest: ociArchiveDigest });
|
|
184
|
+
: buildReleaseImages({ images: declared, cwd, sourceDateEpoch: commitTime(cwd, release.commit), label, archiveDigest: ociArchiveDigest, ...((await releaseVersionOf(cwd)) ? { versionArg: true } : {}) });
|
|
180
185
|
} catch (err) {
|
|
181
186
|
if (err instanceof ReleaseImageError) return fail(err.code, err.message, err.fix);
|
|
182
187
|
throw err;
|
|
@@ -200,6 +205,38 @@ export async function runReleaseImages(ctx: CommandContext): Promise<number> {
|
|
|
200
205
|
return 0;
|
|
201
206
|
}
|
|
202
207
|
|
|
208
|
+
/**
|
|
209
|
+
* `release stamp <label> [--json]` (#4840): write the label into the files
|
|
210
|
+
* `release.version` names, as the cut does before its build, and leave them
|
|
211
|
+
* so. The publish job runs it before its build; `chant release publish`
|
|
212
|
+
* takes those files, stamped with the release's label, as the commit's.
|
|
213
|
+
* `git checkout -- <files>` puts them back.
|
|
214
|
+
*/
|
|
215
|
+
export async function runReleaseStamp(ctx: CommandContext): Promise<number> {
|
|
216
|
+
const { args } = ctx;
|
|
217
|
+
const label = args.extraPositional ?? null;
|
|
218
|
+
const fail = (code: string, message: string, fix?: string): number => {
|
|
219
|
+
if (args.json) console.log(JSON.stringify({ label, error: { code, message, ...(fix ? { fix } : {}) } }, null, 2));
|
|
220
|
+
else console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
|
|
221
|
+
return 1;
|
|
222
|
+
};
|
|
223
|
+
if (label === null) return fail("release-version-no-label", "release stamp needs the release's label", "chant release stamp <label> [--json]");
|
|
224
|
+
const cwd = resolve(".");
|
|
225
|
+
const config = await releaseVersionOf(cwd);
|
|
226
|
+
if (!config) return fail("release-version-not-declared", "this member's chant.config.ts has no release.version, so there is nothing to stamp", "Name the package directories: release: { version: { packages: [\"packages/cli\"] } }");
|
|
227
|
+
const { stampReleaseVersion, ReleaseVersionError } = await import("../../lifecycle/release-version");
|
|
228
|
+
let files: string[];
|
|
229
|
+
try {
|
|
230
|
+
files = stampReleaseVersion({ cwd, config, label }).files;
|
|
231
|
+
} catch (err) {
|
|
232
|
+
if (err instanceof ReleaseVersionError) return fail(err.code, err.message, err.fix);
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
235
|
+
if (args.json) console.log(JSON.stringify({ label, files }, null, 2));
|
|
236
|
+
else console.error(formatSuccess(`Stamped ${label} into ${files.join(", ")}`));
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
203
240
|
function describeActorSource(source: import("../../lifecycle/release-workstation").ActorSource): string {
|
|
204
241
|
switch (source) {
|
|
205
242
|
case "flag":
|
|
@@ -259,6 +296,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
259
296
|
};
|
|
260
297
|
const at = await import("../../lifecycle/release-at");
|
|
261
298
|
let checkout: import("../../lifecycle/release-at").CommitCheckout | null = null;
|
|
299
|
+
let stamped: import("../../lifecycle/release-version").Stamped | null = null;
|
|
262
300
|
|
|
263
301
|
try {
|
|
264
302
|
// The workstation checks come first, in the order #4027 lists them; the
|
|
@@ -352,6 +390,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
352
390
|
// --at: the cut reads, compiles and builds the commit's tree, not the checkout's.
|
|
353
391
|
if (args.at !== undefined && top && commit) checkout = at.checkoutCommit(top, cwd, commit);
|
|
354
392
|
const cutCwd = checkout?.memberDir ?? cwd;
|
|
393
|
+
const versionConfig = await releaseVersionOf(cutCwd);
|
|
355
394
|
// #4657: the images release.images declares are built first, and their digests handed to the build command.
|
|
356
395
|
const declaredImages = await releaseImagesOf(cutCwd);
|
|
357
396
|
const digestsFile = declaredImages.length > 0 ? join(tmpdir(), `chant-release-digests-${process.pid}.json`) : undefined;
|
|
@@ -361,7 +400,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
361
400
|
const { buildReleaseImages, writeReleaseDigests, ReleaseImageError } = await import("../../lifecycle/release-images");
|
|
362
401
|
const { ociArchiveDigest } = await import("../../lifecycle/publish-oci");
|
|
363
402
|
try {
|
|
364
|
-
const built = buildReleaseImages({ images: declaredImages, cwd: cutCwd, sourceDateEpoch: commitTime(cutCwd, at), label, archiveDigest: ociArchiveDigest });
|
|
403
|
+
const built = buildReleaseImages({ images: declaredImages, cwd: cutCwd, sourceDateEpoch: commitTime(cutCwd, at), label, archiveDigest: ociArchiveDigest, ...(versionConfig ? { versionArg: true } : {}) });
|
|
365
404
|
writeReleaseDigests(digestsFile, Object.fromEntries(built.map((a) => [a.component, a.digest])));
|
|
366
405
|
return built;
|
|
367
406
|
} catch (err) {
|
|
@@ -371,6 +410,18 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
371
410
|
}
|
|
372
411
|
}
|
|
373
412
|
: undefined;
|
|
413
|
+
// #4840: release.version stamps the label into package.json once the cut has found the tree clean.
|
|
414
|
+
const stamp = versionConfig
|
|
415
|
+
? async () => {
|
|
416
|
+
const { stampReleaseVersion, ReleaseVersionError } = await import("../../lifecycle/release-version");
|
|
417
|
+
try {
|
|
418
|
+
if (!stamped) stamped = stampReleaseVersion({ cwd: cutCwd, config: versionConfig, label });
|
|
419
|
+
} catch (err) {
|
|
420
|
+
if (err instanceof ReleaseVersionError) throw new ReleaseCutError(err.code as import("../../lifecycle/release-cut").ReleaseCutCode, `no release was cut: ${err.message}`, err.fix);
|
|
421
|
+
throw err;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
: undefined;
|
|
374
425
|
// #4692: the lane is the commit's own config's under --at.
|
|
375
426
|
const lane = await laneOf(ctx, cutCwd);
|
|
376
427
|
const request = {
|
|
@@ -385,6 +436,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
385
436
|
...(args.overrideGreen ? { overrideGreen: true } : {}),
|
|
386
437
|
...(Object.keys(images).length > 0 ? { images } : {}),
|
|
387
438
|
...(buildImages ? { buildImages } : {}),
|
|
439
|
+
...(stamp ? { stamp } : {}),
|
|
388
440
|
};
|
|
389
441
|
|
|
390
442
|
if (dryRun) {
|
|
@@ -540,6 +592,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
540
592
|
}
|
|
541
593
|
throw err;
|
|
542
594
|
} finally {
|
|
595
|
+
(stamped as import("../../lifecycle/release-version").Stamped | null)?.restore();
|
|
543
596
|
checkout?.remove();
|
|
544
597
|
}
|
|
545
598
|
}
|
|
@@ -108,6 +108,7 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
108
108
|
...(product?.afterPlan ? { afterPlan: product.afterPlan } : {}),
|
|
109
109
|
...(product?.capabilities ? { capabilities: product.capabilities } : {}),
|
|
110
110
|
...(product?.hookExec ? { hookExec: product.hookExec } : {}),
|
|
111
|
+
...(product?.runHooks ? { runHooks: product.runHooks } : {}),
|
|
111
112
|
spec,
|
|
112
113
|
specFile: relative(process.cwd(), path),
|
|
113
114
|
wave: args.wave,
|
package/src/cli/main.ts
CHANGED
|
@@ -531,6 +531,11 @@ Releases:
|
|
|
531
531
|
the release's commit, refuse one whose digest is not
|
|
532
532
|
the recorded one, and write the recorded digests to
|
|
533
533
|
the file CHANT_RELEASE_DIGESTS names for the build.
|
|
534
|
+
release stamp <label> [--json]
|
|
535
|
+
Write the label as the version of each package.json
|
|
536
|
+
release.version names, and the lockfile's entries for
|
|
537
|
+
them, as the cut does before its build. The publish
|
|
538
|
+
job runs it before its build.
|
|
534
539
|
release workflow [--forge github|gitlab|forgejo] [--install <command>]
|
|
535
540
|
[--build <command>] [--chant <command>] [--output <file>]
|
|
536
541
|
Write the publish workflow, run on a release/** tag.
|
|
@@ -1307,7 +1312,14 @@ Component release ledger + status:
|
|
|
1307
1312
|
--decide-model <id> asks whether the
|
|
1308
1313
|
description leaves out a destroy or a
|
|
1309
1314
|
replacement and posts the finding (#4629)
|
|
1310
|
-
components pr-
|
|
1315
|
+
components pr-notes GitLab (#4785): read the merge requests' notes,
|
|
1316
|
+
and for each new comment command from a
|
|
1317
|
+
Developer or above start the job that answers
|
|
1318
|
+
it (--forge gitlab [--branch <b>]
|
|
1319
|
+
[--preview-comment] [--apply-before-merge]
|
|
1320
|
+
[--apply-on-merge] [--locks]); each answered
|
|
1321
|
+
note is recorded on chant/lifecycle
|
|
1322
|
+
components pr-record On merge (#4168): plan the same members again,
|
|
1311
1323
|
store the change set and write the merge record
|
|
1312
1324
|
_merges/<commit>.json; applies and refuses
|
|
1313
1325
|
nothing, and a plan that differs from the
|
|
@@ -1910,6 +1922,8 @@ export const commandRegistry: CommandDef[] = [
|
|
|
1910
1922
|
{ name: "release verify", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseVerify(ctx) },
|
|
1911
1923
|
// #4657: build a release's images again in its publish job, checked against the digests it records.
|
|
1912
1924
|
{ name: "release images", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseImages(ctx) },
|
|
1925
|
+
// #4840: the label into the package.json files release.version names, in the publish job before its build.
|
|
1926
|
+
{ name: "release stamp", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseStamp(ctx) },
|
|
1913
1927
|
{ name: "release workflow", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/release-workflow")).runReleaseWorkflow(ctx) },
|
|
1914
1928
|
// #4168 4.3: mode (b), chosen changes composed onto a base on chant/compose/<name>.
|
|
1915
1929
|
{ name: "release compose", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseCompose(ctx) },
|
|
@@ -2068,6 +2082,8 @@ export const commandRegistry: CommandDef[] = [
|
|
|
2068
2082
|
{ name: "components apply-wave", requiresPlugins: true, handler: async (ctx) => (await import("./handlers/pr")).runComponentsApplyWave(ctx) },
|
|
2069
2083
|
// #4295: posts from the plan report in a job that runs none of the change's code, so it loads no plugins.
|
|
2070
2084
|
{ name: "components pr-post", handler: async (ctx) => (await import("./handlers/pr")).runComponentsPrPost(ctx) },
|
|
2085
|
+
// #4785: GitLab's comment commands, polled from the notes in a job that runs none of the change's code, so it loads no plugins.
|
|
2086
|
+
{ name: "components pr-notes", handler: async (ctx) => (await import("./handlers/pr-notes")).runComponentsPrNotes(ctx) },
|
|
2071
2087
|
{ name: "components pr-record", requiresPlugins: true, handler: async (ctx) => (await import("./handlers/pr")).runComponentsPrRecord(ctx) },
|
|
2072
2088
|
// #4616: the agent jobs' three steps. Imported on first use; none loads plugins.
|
|
2073
2089
|
{ name: "agent prepare", handler: async (ctx) => (await import("./handlers/agent")).runAgentCommandLine(ctx) },
|
|
@@ -176,3 +176,52 @@ describe("the report tool's keys (#4555)", () => {
|
|
|
176
176
|
expect(safeReportKey("/a/b/")).toBe("a/b");
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
|
+
|
|
180
|
+
describe("tool annotations in tools/list (#4823)", () => {
|
|
181
|
+
async function annotations(server: McpServer): Promise<Map<string, Record<string, unknown> | undefined>> {
|
|
182
|
+
const res = await server.handleRequest({ jsonrpc: "2.0", id: 1, method: "tools/list" });
|
|
183
|
+
return new Map((res.result as { tools: Array<ToolDefinition & { annotations?: Record<string, unknown> }> }).tools.map((t) => [t.name, t.annotations]));
|
|
184
|
+
}
|
|
185
|
+
const READ = { readOnlyHint: true, destructiveHint: false };
|
|
186
|
+
|
|
187
|
+
test("a product's readOnly tool reads as read-only, a forgeWrite tool as an additive write, and its own annotations pass through", async () => {
|
|
188
|
+
const hook: ProductMcpHook = {
|
|
189
|
+
product: "terragucci",
|
|
190
|
+
propose: true,
|
|
191
|
+
tools: () => [
|
|
192
|
+
{ ...tool("index", true), annotations: { idempotentHint: true, openWorldHint: false } },
|
|
193
|
+
{ ...tool("request_from_template"), forgeWrite: true },
|
|
194
|
+
],
|
|
195
|
+
};
|
|
196
|
+
const listedAnnotations = await annotations(new McpServer([], { product: hook }));
|
|
197
|
+
expect(listedAnnotations.get("terragucci:index")).toEqual({ ...READ, idempotentHint: true, openWorldHint: false });
|
|
198
|
+
expect(listedAnnotations.get("terragucci:request_from_template")).toEqual({ readOnlyHint: false, destructiveHint: false });
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("the declaration wins over an annotation that says otherwise", async () => {
|
|
202
|
+
const hook: ProductMcpHook = { product: "plywood", tools: () => [{ ...tool("stacks", true), annotations: { readOnlyHint: false, destructiveHint: true, title: "Stacks" } }] };
|
|
203
|
+
expect((await annotations(new McpServer([], { product: hook }))).get("plywood:stacks")).toEqual({ ...READ, title: "Stacks" });
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test("a plugin's readOnly tool is annotated, and a tool that declares nothing is not", async () => {
|
|
207
|
+
const plugin = { name: "lex", mcpTools: () => [tool("catalog", true), tool("generate")] } as unknown as import("../../lexicon").LexiconPlugin;
|
|
208
|
+
const listedAnnotations = await annotations(new McpServer([plugin]));
|
|
209
|
+
expect(listedAnnotations.get("lex:catalog")).toEqual(READ);
|
|
210
|
+
expect(listedAnnotations.get("lex:generate")).toBeUndefined();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("a read-only core tool is annotated, a mutating one is not, and lint is read-only only without fix", async () => {
|
|
214
|
+
const open = await annotations(new McpServer([]));
|
|
215
|
+
expect(open.get("search")).toEqual(READ);
|
|
216
|
+
expect(open.get("op-status")).toEqual(READ);
|
|
217
|
+
expect(open.get("op-run")).toBeUndefined();
|
|
218
|
+
expect(open.get("lint")).toBeUndefined();
|
|
219
|
+
const closed = await annotations(new McpServer([], { readOnly: true }));
|
|
220
|
+
expect(closed.get("lint")).toEqual(READ);
|
|
221
|
+
for (const [name, a] of closed) expect(a, name).toEqual(READ);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test("the floor names the next release", () => {
|
|
225
|
+
expect(ciProduct.MCP_TOOL_ANNOTATIONS_FLOOR).toBe("0.124.79");
|
|
226
|
+
});
|
|
227
|
+
});
|
|
@@ -78,6 +78,13 @@ export interface ProductMcpHook {
|
|
|
78
78
|
*/
|
|
79
79
|
export const PRODUCT_MCP_PROPOSE_FLOOR = "0.124.58";
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The first chant whose `tools/list` gives MCP tool annotations: a tool's
|
|
83
|
+
* `annotations`, and `readOnlyHint`/`destructiveHint` from `readOnly: true`
|
|
84
|
+
* or `forgeWrite: true` (chant#4823).
|
|
85
|
+
*/
|
|
86
|
+
export const MCP_TOOL_ANNOTATIONS_FLOOR = "0.124.79";
|
|
87
|
+
|
|
81
88
|
/** The words a `forgeWrite` tool's name may hold on the `--propose` tier, which the write-word check passes over (chant#4655). */
|
|
82
89
|
export const PRODUCT_TOOL_PROPOSE_WORDS = ["request", "propose"] as const;
|
|
83
90
|
|
package/src/cli/mcp/read-only.ts
CHANGED
|
@@ -17,6 +17,25 @@
|
|
|
17
17
|
import { workspaceReadTools, workspaceWriteTools } from "./workspace-tools";
|
|
18
18
|
import { ledgerReadTools } from "./ledger-tools";
|
|
19
19
|
import { reportReadTools } from "./report-tools";
|
|
20
|
+
import type { McpToolContribution, ToolAnnotations } from "../../mcp/types";
|
|
21
|
+
|
|
22
|
+
/** The annotations of a tool that changes nothing (chant#4823). */
|
|
23
|
+
export const READ_ONLY_ANNOTATIONS: Readonly<ToolAnnotations> = Object.freeze({ readOnlyHint: true, destructiveHint: false });
|
|
24
|
+
|
|
25
|
+
/** The annotations of a product's `forgeWrite` tool, which adds a pull request or a comment and deletes nothing (chant#4823). */
|
|
26
|
+
export const FORGE_WRITE_ANNOTATIONS: Readonly<ToolAnnotations> = Object.freeze({ readOnlyHint: false, destructiveHint: false });
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A contributed tool's annotations in `tools/list` (chant#4823): its own,
|
|
30
|
+
* with `readOnlyHint` and `destructiveHint` set from `readOnly: true` or
|
|
31
|
+
* `forgeWrite: true`, so a hint never says more than the rule the server
|
|
32
|
+
* serves the tool by. Undefined when the tool gives and declares nothing.
|
|
33
|
+
*/
|
|
34
|
+
export function contributedToolAnnotations(tool: Pick<McpToolContribution, "readOnly" | "forgeWrite" | "annotations">): ToolAnnotations | undefined {
|
|
35
|
+
const declared = tool.readOnly === true ? READ_ONLY_ANNOTATIONS : tool.forgeWrite === true ? FORGE_WRITE_ANNOTATIONS : undefined;
|
|
36
|
+
if (!declared && !tool.annotations) return undefined;
|
|
37
|
+
return { ...tool.annotations, ...declared };
|
|
38
|
+
}
|
|
20
39
|
|
|
21
40
|
/**
|
|
22
41
|
* Core tools that change nothing, served in both modes.
|
|
@@ -344,6 +344,36 @@ describe("McpServer", () => {
|
|
|
344
344
|
expect(result.structuredContent).toBeUndefined();
|
|
345
345
|
});
|
|
346
346
|
|
|
347
|
+
// MCP's CallToolResult.structuredContent is a JSON object (schema
|
|
348
|
+
// 2025-06-18: `structuredContent?: { [key: string]: unknown }`), and the
|
|
349
|
+
// MCP SDK's Client.callTool refuses anything else (#4822).
|
|
350
|
+
test("an array-returning handler gets its array as structuredContent.items, and the array as text", async () => {
|
|
351
|
+
const rows = [{ id: "a" }, { id: "b" }];
|
|
352
|
+
const plugin = createMockPlugin({
|
|
353
|
+
name: "test-lex",
|
|
354
|
+
mcpTools: () => [
|
|
355
|
+
{
|
|
356
|
+
name: "rows",
|
|
357
|
+
description: "Rows",
|
|
358
|
+
inputSchema: { type: "object", properties: {} },
|
|
359
|
+
handler: async () => rows,
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
});
|
|
363
|
+
const s = new McpServer([plugin]);
|
|
364
|
+
const response = await s.handleRequest({
|
|
365
|
+
jsonrpc: "2.0",
|
|
366
|
+
id: 1,
|
|
367
|
+
method: "tools/call",
|
|
368
|
+
params: { name: "test-lex:rows", arguments: {} },
|
|
369
|
+
});
|
|
370
|
+
const result = response!.result as { content: Array<{ type: string; text: string }>; structuredContent?: unknown };
|
|
371
|
+
const sc = result.structuredContent;
|
|
372
|
+
expect(typeof sc === "object" && sc !== null && !Array.isArray(sc)).toBe(true);
|
|
373
|
+
expect(sc).toEqual({ items: rows });
|
|
374
|
+
expect(result.content).toEqual([{ type: "text", text: JSON.stringify(rows, null, 2) }]);
|
|
375
|
+
});
|
|
376
|
+
|
|
347
377
|
test("an isError response has no structuredContent", async () => {
|
|
348
378
|
const response = await server.handleRequest({
|
|
349
379
|
jsonrpc: "2.0",
|
package/src/cli/mcp/server.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { buildResourcesList, handleResourcesRead } from "./resource-handlers";
|
|
|
19
19
|
import { createLedgerTools } from "./ledger-tools";
|
|
20
20
|
import { createReportTools } from "./report-tools";
|
|
21
21
|
import { activeProductMcpHook, productMcpContext, productToolsServed, type ProductMcpHook } from "./product-tools";
|
|
22
|
-
import { MUTATING_CORE_TOOLS, READ_ONLY_CORE_TOOLS, ReadOnlyRegistrationError, servesContributedTool } from "./read-only";
|
|
22
|
+
import { contributedToolAnnotations, MUTATING_CORE_TOOLS, READ_ONLY_ANNOTATIONS, READ_ONLY_CORE_TOOLS, ReadOnlyRegistrationError, servesContributedTool } from "./read-only";
|
|
23
23
|
import { CHANT_VERSION } from "../version";
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -220,7 +220,11 @@ export class McpServer {
|
|
|
220
220
|
// and its forgeWrite tools on the --propose tier (chant#4655).
|
|
221
221
|
if (product) {
|
|
222
222
|
for (const tool of productToolsServed(product, productMcpContext(product, cwd, this.readOnly, this.propose))) {
|
|
223
|
-
|
|
223
|
+
const annotations = contributedToolAnnotations(tool);
|
|
224
|
+
this.registerTool(
|
|
225
|
+
{ name: namespacedToolName(product.product, tool.name), description: tool.description, inputSchema: tool.inputSchema, ...(annotations ? { annotations } : {}) },
|
|
226
|
+
tool.handler,
|
|
227
|
+
);
|
|
224
228
|
}
|
|
225
229
|
}
|
|
226
230
|
}
|
|
@@ -241,11 +245,13 @@ export class McpServer {
|
|
|
241
245
|
for (const tool of tools) {
|
|
242
246
|
// A read-only server serves a plugin tool only when it says it changes nothing (chant#4543).
|
|
243
247
|
if (!servesContributedTool(tool, this.readOnly)) continue;
|
|
248
|
+
const annotations = contributedToolAnnotations(tool);
|
|
244
249
|
this.registerTool(
|
|
245
250
|
{
|
|
246
251
|
name: namespacedToolName(plugin.name, tool.name),
|
|
247
252
|
description: tool.description,
|
|
248
253
|
inputSchema: tool.inputSchema,
|
|
254
|
+
...(annotations ? { annotations } : {}),
|
|
249
255
|
},
|
|
250
256
|
tool.handler,
|
|
251
257
|
);
|
|
@@ -276,13 +282,17 @@ export class McpServer {
|
|
|
276
282
|
* Register a core tool. On a read-only server a mutating core tool is
|
|
277
283
|
* left out, and a core tool on neither list of ./read-only.ts is refused
|
|
278
284
|
* with an error, so a new tool cannot reach a read-only server unsorted.
|
|
285
|
+
*
|
|
286
|
+
* A tool on the read-only list is listed with {@link READ_ONLY_ANNOTATIONS}
|
|
287
|
+
* (chant#4823), except the ordinary server's `lint`, whose `fix` writes.
|
|
279
288
|
*/
|
|
280
289
|
private registerCoreTool(definition: ToolDefinition, handler: ToolHandler): void {
|
|
281
290
|
if (this.readOnly && !READ_ONLY_CORE_TOOLS.has(definition.name)) {
|
|
282
291
|
if (MUTATING_CORE_TOOLS.has(definition.name)) return;
|
|
283
292
|
throw new ReadOnlyRegistrationError(definition.name);
|
|
284
293
|
}
|
|
285
|
-
|
|
294
|
+
const reads = READ_ONLY_CORE_TOOLS.has(definition.name) && definition !== lintTool;
|
|
295
|
+
this.registerTool(reads ? { ...definition, annotations: { ...READ_ONLY_ANNOTATIONS } } : definition, handler);
|
|
286
296
|
}
|
|
287
297
|
|
|
288
298
|
/**
|
|
@@ -400,7 +410,7 @@ export class McpServer {
|
|
|
400
410
|
// The client, from this request's _meta (2026-07-28) or else from initialize.
|
|
401
411
|
const clientInfo = parseMeta(params).clientInfo ?? this.clientInfo;
|
|
402
412
|
const result = await handler(toolParams, clientInfo ? { clientInfo } : {});
|
|
403
|
-
const
|
|
413
|
+
const structured = structuredContentOf(result);
|
|
404
414
|
return {
|
|
405
415
|
content: [
|
|
406
416
|
{
|
|
@@ -412,7 +422,7 @@ export class McpServer {
|
|
|
412
422
|
// objects that get stringified above, so agents that want the
|
|
413
423
|
// parsed shape directly get it here too, alongside the text block
|
|
414
424
|
// kept for backward compatibility (#1194).
|
|
415
|
-
...(
|
|
425
|
+
...(structured ? { structuredContent: structured } : {}),
|
|
416
426
|
};
|
|
417
427
|
} catch (error) {
|
|
418
428
|
return {
|
|
@@ -470,6 +480,19 @@ export class McpServer {
|
|
|
470
480
|
}
|
|
471
481
|
}
|
|
472
482
|
|
|
483
|
+
/**
|
|
484
|
+
* A tool result's `structuredContent`, which MCP types as a JSON object
|
|
485
|
+
* (`{ [key: string]: unknown }`): a plain object as it is, an array as
|
|
486
|
+
* `{ items: [...] }` (#4822), and nothing for a string or other scalar. The
|
|
487
|
+
* text block still carries the result as the handler returned it, so a
|
|
488
|
+
* client that reads text sees the array.
|
|
489
|
+
*/
|
|
490
|
+
export function structuredContentOf(result: unknown): Record<string, unknown> | undefined {
|
|
491
|
+
if (Array.isArray(result)) return { items: result };
|
|
492
|
+
if (typeof result === "object" && result !== null) return result as Record<string, unknown>;
|
|
493
|
+
return undefined;
|
|
494
|
+
}
|
|
495
|
+
|
|
473
496
|
/**
|
|
474
497
|
* Start MCP server, loading plugins from the project
|
|
475
498
|
*/
|
package/src/cli/mcp/types.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface McpRequestMeta {
|
|
|
35
35
|
"io.modelcontextprotocol/clientInfo"?: McpClientInfo;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
import type { ToolAnnotations } from "../../mcp/types";
|
|
39
|
+
|
|
38
40
|
/**
|
|
39
41
|
* Tool definition for MCP
|
|
40
42
|
*/
|
|
@@ -49,13 +51,16 @@ export interface ToolDefinition {
|
|
|
49
51
|
/**
|
|
50
52
|
* JSON schema for `structuredContent` (2025-06-18+), when a tool's result
|
|
51
53
|
* shape is obvious and stable enough to declare. Optional and additive —
|
|
52
|
-
* most tools omit it (#1194).
|
|
54
|
+
* most tools omit it (#1194). A handler that returns an array has it
|
|
55
|
+
* sent as `{ items: [...] }` (#4822), so its schema describes that object.
|
|
53
56
|
*/
|
|
54
57
|
outputSchema?: {
|
|
55
58
|
type: "object";
|
|
56
59
|
properties: Record<string, unknown>;
|
|
57
60
|
required?: string[];
|
|
58
61
|
};
|
|
62
|
+
/** The tool's annotations in `tools/list` (chant#4823): the read-only core and contributed tools say so. */
|
|
63
|
+
annotations?: ToolAnnotations;
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
/**
|
package/src/cli/parse-args.ts
CHANGED
|
@@ -20,6 +20,8 @@ import type { ParsedArgs } from "./registry";
|
|
|
20
20
|
const BOOLEAN_FLAGS = new Set([
|
|
21
21
|
"--help",
|
|
22
22
|
"--open",
|
|
23
|
+
"--note-commands",
|
|
24
|
+
"--locks",
|
|
23
25
|
"--version",
|
|
24
26
|
"--agents",
|
|
25
27
|
"--agent",
|
|
@@ -906,6 +908,12 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
906
908
|
const m = /^(op|member|readTokenSecret|tokenSecret|forge|ref|apiBase|sentCheck|markSent)=(.+)$/s.exec(raw);
|
|
907
909
|
if (!m) throw new Error(`--control-setting needs <key>=<value>, the key one of op, member, readTokenSecret, tokenSecret, forge, ref, apiBase, sentCheck, markSent: got "${raw}"`);
|
|
908
910
|
(result.controlSettings ??= {})[m[1]!] = m[2]!;
|
|
911
|
+
} else if (arg === "--note-commands") {
|
|
912
|
+
// `chant build --pr-loop --note-commands` (#4785).
|
|
913
|
+
result.noteCommands = true;
|
|
914
|
+
} else if (arg === "--locks") {
|
|
915
|
+
// `chant components pr-notes --locks` (#4785).
|
|
916
|
+
result.locks = true;
|
|
909
917
|
} else if (arg === "--stale-notes") {
|
|
910
918
|
// `chant build --pr-loop --stale-notes` (#4628).
|
|
911
919
|
result.staleNotes = true;
|
package/src/cli/registry.ts
CHANGED
|
@@ -579,6 +579,10 @@ export interface ParsedArgs {
|
|
|
579
579
|
controlSettings?: Record<string, string>;
|
|
580
580
|
/** `chant build --pr-loop --stale-notes` (#4628): the note carries its target commit, and a push to the target branch marks open notes stale. */
|
|
581
581
|
staleNotes?: boolean;
|
|
582
|
+
/** `chant build --pr-loop --note-commands` (#4785): on GitLab, the scheduled job that answers the product's comment commands by polling merge request notes. */
|
|
583
|
+
noteCommands?: boolean;
|
|
584
|
+
/** `chant components pr-notes --locks` (#4785): the pipeline has the lock and unlock jobs, so a lock or unlock note starts them. */
|
|
585
|
+
locks?: boolean;
|
|
582
586
|
/** `chant components pr-post --stale` (#4628): mark the open pull requests' notes stale after the target branch moved. */
|
|
583
587
|
stale?: boolean;
|
|
584
588
|
/** `chant components pr-post --tip <sha>` (#4628): the target branch's commit, which the note carries, or with --stale its commit now. */
|
|
@@ -125,6 +125,29 @@ export interface DeployContext {
|
|
|
125
125
|
* its packs where they stand.
|
|
126
126
|
*/
|
|
127
127
|
policyBase?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Environment variables the run's engine runs with, over the job's
|
|
130
|
+
* (#4842): an op wave's run hook gives them per run, such as a role's
|
|
131
|
+
* credentials or values read from a secret store. A capability passes them
|
|
132
|
+
* to every command it runs for the plan and the apply. Absent: the job's
|
|
133
|
+
* environment as it is.
|
|
134
|
+
*/
|
|
135
|
+
processEnv?: Record<string, string>;
|
|
136
|
+
/**
|
|
137
|
+
* The directory the caller runs the step in (#4854): an op wave's `cwd`,
|
|
138
|
+
* absolute. A capability that looks for a project file, such as the
|
|
139
|
+
* nearest `chant.config.*`, starts there when its input names no directory
|
|
140
|
+
* of its own. Absent: `process.cwd()`, as before.
|
|
141
|
+
*/
|
|
142
|
+
cwd?: string;
|
|
143
|
+
/**
|
|
144
|
+
* A check to call once the engine has initialised the run and before its
|
|
145
|
+
* plan runs any of the run's code (#4842), such as a check of the module
|
|
146
|
+
* and provider sources the init fetched. It throws to stop the plan. A
|
|
147
|
+
* capability that has no separate init calls it before it plans. Absent:
|
|
148
|
+
* nothing to call.
|
|
149
|
+
*/
|
|
150
|
+
afterInit?: () => Promise<void>;
|
|
128
151
|
/**
|
|
129
152
|
* The run's row lease (#4594), set by an apply path that plans inside its
|
|
130
153
|
* steps (`run --components`, `components fan-out`, a promote). The driver
|
|
@@ -395,6 +418,33 @@ export interface Capability<In = unknown, Out = unknown> {
|
|
|
395
418
|
* error is a moved plan ({@link isPlanMovedError}).
|
|
396
419
|
*/
|
|
397
420
|
runGroup?(ctx: GroupContext, run: GroupRun, members: readonly GroupMember<In>[]): Promise<CapabilityGroupOutcome>;
|
|
421
|
+
/**
|
|
422
|
+
* Optional (#4842): the runs of an op wave whose runs are found at plan
|
|
423
|
+
* time (`discover`), such as a Terragrunt repo's units in one layer of
|
|
424
|
+
* `terragrunt find`'s graph. `input` is the step's input with `{op}` and
|
|
425
|
+
* `{wave}` filled and `{target}` left as written. Each run found then
|
|
426
|
+
* plans with `{target}` filled, one at a time, or with `planGroup` on a
|
|
427
|
+
* wave marked `together`. Throwing fails the wave before anything plans.
|
|
428
|
+
*/
|
|
429
|
+
discoverRuns?(ctx: RunDiscoveryContext, input: In): Promise<DiscoveredRuns>;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** What `discoverRuns` is asked with (#4842). */
|
|
433
|
+
export interface RunDiscoveryContext {
|
|
434
|
+
/** The environment the wave's runs plan in, as `DeployContext.env`. */
|
|
435
|
+
env: string;
|
|
436
|
+
/** The directory the wave runs in, as `DeployContext.cwd` (#4854). */
|
|
437
|
+
cwd?: string;
|
|
438
|
+
/** The wave: its name in the spec and its number from 1. A `rest` wave past the spec's asks with each number in turn. */
|
|
439
|
+
wave: { name: string; number: number };
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** What `discoverRuns` answers (#4842). */
|
|
443
|
+
export interface DiscoveredRuns {
|
|
444
|
+
/** The wave's runs, by target, in the order they apply. Empty: the wave has none, and applies nothing. */
|
|
445
|
+
targets: string[];
|
|
446
|
+
/** How many waves the discovery found, which a `rest` wave walks to. */
|
|
447
|
+
waves?: number;
|
|
398
448
|
}
|
|
399
449
|
|
|
400
450
|
/**
|
|
@@ -404,6 +454,8 @@ export interface Capability<In = unknown, Out = unknown> {
|
|
|
404
454
|
*/
|
|
405
455
|
export interface GroupContext {
|
|
406
456
|
env: string;
|
|
457
|
+
/** The directory the group runs in, as `DeployContext.cwd` (#4854). Absent outside an op wave. */
|
|
458
|
+
cwd?: string;
|
|
407
459
|
vars?: Record<string, unknown>;
|
|
408
460
|
/** The group's components, upstreams first. */
|
|
409
461
|
components: string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The group digest of a capability group (ws-107), in a module of its own
|
|
3
|
+
* so an op wave planned `together` (#4842) binds the same digest without
|
|
4
|
+
* the wave-job runtime bundle loading `./groups.ts`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { computePlanDigest } from "../lifecycle/plan-digest";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The group digest (ws-107): over the capability's kind, each member's
|
|
11
|
+
* component, change-set member and own plan digest, sorted, and the
|
|
12
|
+
* capability's digest of the composition. One member more, or the same
|
|
13
|
+
* members composed differently, moves it.
|
|
14
|
+
*/
|
|
15
|
+
export function groupDigest(kind: string, members: ReadonlyArray<{ component: string; member: string; planDigest: string }>, composition: string): string {
|
|
16
|
+
const sorted = [...members]
|
|
17
|
+
.map((m) => ({ component: m.component, member: m.member, planDigest: m.planDigest }))
|
|
18
|
+
.sort((a, b) => a.component.localeCompare(b.component) || a.member.localeCompare(b.member));
|
|
19
|
+
return computePlanDigest("capability-group", { kind, members: sorted, composition });
|
|
20
|
+
}
|
package/src/components/groups.ts
CHANGED
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
import { computePlanDigest } from "../lifecycle/plan-digest";
|
|
30
|
+
import { groupDigest } from "./group-digest";
|
|
31
|
+
|
|
32
|
+
export { groupDigest };
|
|
30
33
|
import type { ChangeSetPart } from "../change-set";
|
|
31
34
|
import type { PlanShape } from "./covered-round";
|
|
32
35
|
import {
|
|
@@ -575,19 +578,6 @@ export function groupsByComponent(plan: Pick<FanOutPlan, "groups">): Map<string,
|
|
|
575
578
|
return new Map((plan.groups ?? []).flatMap((g) => g.components.map((c) => [c, g] as const)));
|
|
576
579
|
}
|
|
577
580
|
|
|
578
|
-
/**
|
|
579
|
-
* The group digest (ws-107): over the capability's kind, each member's
|
|
580
|
-
* component, change-set member and own plan digest, sorted, and the
|
|
581
|
-
* capability's digest of the composition. One member more, or the same
|
|
582
|
-
* members composed differently, moves it.
|
|
583
|
-
*/
|
|
584
|
-
export function groupDigest(kind: string, members: ReadonlyArray<{ component: string; member: string; planDigest: string }>, composition: string): string {
|
|
585
|
-
const sorted = [...members]
|
|
586
|
-
.map((m) => ({ component: m.component, member: m.member, planDigest: m.planDigest }))
|
|
587
|
-
.sort((a, b) => a.component.localeCompare(b.component) || a.member.localeCompare(b.member));
|
|
588
|
-
return computePlanDigest("capability-group", { kind, members: sorted, composition });
|
|
589
|
-
}
|
|
590
|
-
|
|
591
581
|
/**
|
|
592
582
|
* A member's plan with its group folded in (ws-107), after `bindTargets`:
|
|
593
583
|
* its digest becomes the digest over its own and the group's, written into
|
package/src/components/index.ts
CHANGED
|
@@ -369,6 +369,15 @@ export interface PrLoopPipelineOptions {
|
|
|
369
369
|
* from `--stale-notes` beside `--pr-loop`. Default false.
|
|
370
370
|
*/
|
|
371
371
|
staleNotes?: boolean;
|
|
372
|
+
/**
|
|
373
|
+
* GitLab's comment commands (#4785): GitLab starts no pipeline on a note,
|
|
374
|
+
* so a job of the target branch's pipeline, started by a schedule with
|
|
375
|
+
* `CHANT_NOTE_COMMANDS=1`, polls the merge requests' notes and starts the
|
|
376
|
+
* jobs the commands ask for ({@link prNoteCommandsJob}). Refused on GitHub
|
|
377
|
+
* and Forgejo, which start a workflow on a comment. Set from
|
|
378
|
+
* `--note-commands` beside `--pr-loop`. Default off.
|
|
379
|
+
*/
|
|
380
|
+
noteCommands?: boolean;
|
|
372
381
|
/**
|
|
373
382
|
* The responses to pipeline events (#4629, ../ci-respond.ts), from
|
|
374
383
|
* `chant build --pr-loop --respond <list>`: the apply job and the
|
|
@@ -605,6 +614,32 @@ export function prActionJob(forge: ForgeKind, options: Pick<PrLoopPipelineOption
|
|
|
605
614
|
export const PR_COMMENT_PREVIEW_JOB = "comment-preview";
|
|
606
615
|
/** The job that posts the comment preview's note and status (#4620). */
|
|
607
616
|
export const PR_COMMENT_PREVIEW_NOTE_JOB = "comment-preview-note";
|
|
617
|
+
/** The job that polls GitLab's merge request notes for comment commands (#4785). */
|
|
618
|
+
export const PR_NOTE_COMMANDS_JOB = "note-commands";
|
|
619
|
+
/** The variable a schedule (or a person) starts a pipeline of the target branch with to run the note-commands job (#4785). */
|
|
620
|
+
export const GITLAB_NOTE_COMMANDS_VAR = "CHANT_NOTE_COMMANDS";
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* The note-commands job's command (#4785): `chant components pr-notes
|
|
624
|
+
* --forge gitlab`, with a flag for each job the pipeline has that a command
|
|
625
|
+
* starts. Undefined without `noteCommands`; refused on GitHub and Forgejo,
|
|
626
|
+
* which start a workflow on a comment.
|
|
627
|
+
*/
|
|
628
|
+
export function prNoteCommandsJob(forge: ForgeKind, options: Pick<PrLoopPipelineOptions, "noteCommands" | "previewComment" | "applyBeforeMerge" | "applyOnMerge" | "waveGate" | "locks" | "branch" | "words"> = {}): { command: string } | undefined {
|
|
629
|
+
if (!options.noteCommands) return undefined;
|
|
630
|
+
if (forge !== "gitlab") throw new Error(`--note-commands polls GitLab's merge request notes, and ${forge} starts a workflow on a comment; drop --note-commands`);
|
|
631
|
+
const words = resolveProductWords(options.words);
|
|
632
|
+
const command = [
|
|
633
|
+
"chant", "components", "pr-notes", "--forge", "gitlab",
|
|
634
|
+
...(options.branch ? ["--branch", JSON.stringify(options.branch)] : []),
|
|
635
|
+
...(options.previewComment ? ["--preview-comment"] : []),
|
|
636
|
+
...(options.applyBeforeMerge ? ["--apply-before-merge"] : []),
|
|
637
|
+
...(options.applyOnMerge || options.waveGate ? ["--apply-on-merge"] : []),
|
|
638
|
+
...(options.locks === "plan" ? ["--locks"] : []),
|
|
639
|
+
].join(" ");
|
|
640
|
+
return { command: withProductBin(command, words.bin) };
|
|
641
|
+
}
|
|
642
|
+
|
|
608
643
|
/** The GitLab variable a pipeline of the target branch is started with to preview a merge request again (#4620). */
|
|
609
644
|
export const GITLAB_PREVIEW_PR_VAR = "CHANT_PREVIEW_PR";
|
|
610
645
|
/** The variable the GitHub-shaped preview job's checkout script reads the pull request's head ref from (#4620). */
|