@intentius/chant 0.124.99 → 0.124.100

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 (40) hide show
  1. package/bin/chant +3 -3
  2. package/dist/cli/commands/carve-emit.js +2 -2
  3. package/dist/cli/commands/check-lexicon-plugin.d.ts +2 -2
  4. package/dist/cli/commands/check-lexicon-plugin.js +3 -3
  5. package/dist/cli/commands/check-lexicon.js +4 -4
  6. package/dist/cli/commands/init-lexicon/templates/project.d.ts +1 -1
  7. package/dist/cli/commands/init-lexicon/templates/project.js +4 -4
  8. package/dist/cli/commands/init.d.ts +13 -0
  9. package/dist/cli/commands/init.js +30 -2
  10. package/dist/cli/handlers/release.d.ts +8 -0
  11. package/dist/cli/handlers/release.js +34 -1
  12. package/dist/cli/main.js +5 -0
  13. package/dist/cli/parse-args.js +7 -0
  14. package/dist/cli/registry.d.ts +2 -0
  15. package/dist/codegen/pinned-upgrade.js +1 -1
  16. package/dist/components/capability-plugin.d.ts +1 -1
  17. package/dist/components/capability-plugin.js +1 -1
  18. package/dist/config.d.ts +8 -0
  19. package/dist/config.js +2 -0
  20. package/dist/dead-guards.d.ts +5 -1
  21. package/dist/dead-guards.js +34 -23
  22. package/dist/discovery/sandbox/driver.js +1 -1
  23. package/dist/discovery/specifier-resolve.js +1 -1
  24. package/dist/floor-table.d.ts +3 -1
  25. package/dist/floor-table.data.js +9 -3
  26. package/dist/floor-table.js +4 -3
  27. package/dist/module-source.d.ts +2 -2
  28. package/dist/module-source.js +8 -8
  29. package/dist/release-floors.d.ts +3 -1
  30. package/dist/release-floors.js +3 -1
  31. package/dist/ts-loader.d.ts +1 -1
  32. package/dist/ts-loader.js +6 -6
  33. package/dist/wave-runtime.mjs +8 -8
  34. package/dist/workspace/reason-codes.d.ts +4 -0
  35. package/dist/workspace/reason-codes.js +5 -0
  36. package/dist/workspace/release-changed.d.ts +108 -0
  37. package/dist/workspace/release-changed.js +454 -0
  38. package/dist/workspace/release-changed.schema.json +188 -0
  39. package/dist/workspace/search-contract.d.ts +1 -1
  40. package/package.json +26 -26
package/bin/chant CHANGED
@@ -54,13 +54,13 @@ function runFromSource() {
54
54
  ].find((candidate) => existsSync(candidate));
55
55
 
56
56
  if (loader) {
57
- relay(process.execPath, ["--conditions=development", "--import", pathToFileURL(loader).href, mainTs, ...args]);
57
+ relay(process.execPath, ["--conditions=@intentius/chant-source", "--import", pathToFileURL(loader).href, mainTs, ...args]);
58
58
  } else if (process.platform === "win32") {
59
59
  // npx is npx.cmd on Windows, which node starts only through a shell.
60
60
  const quote = (arg) => (/^[\w./:=@\\-]+$/.test(arg) ? arg : `"${arg.replace(/"/g, '""')}"`);
61
- relay("npx", ["tsx", "--conditions=development", mainTs, ...args].map(quote), { shell: true });
61
+ relay("npx", ["tsx", "--conditions=@intentius/chant-source", mainTs, ...args].map(quote), { shell: true });
62
62
  } else {
63
- relay("npx", ["tsx", "--conditions=development", mainTs, ...args]);
63
+ relay("npx", ["tsx", "--conditions=@intentius/chant-source", mainTs, ...args]);
64
64
  }
65
65
  }
66
66
 
@@ -21,7 +21,7 @@ import { resolveEmitProvider } from "../../terraform/carve-provider.js";
21
21
  import { readStateResource } from "../../terraform/state.js";
22
22
  import { writeCarveManifest } from "../../terraform/manifest.js";
23
23
  import { adoptFromState } from "../../terraform/adopt-state.js";
24
- import { generateTsConfig, getChantVersion, SCAFFOLD_DEV_DEPENDENCIES } from "./init.js";
24
+ import { generateTsConfig, getChantVersion, lexiconDependencyRange, SCAFFOLD_DEV_DEPENDENCIES } from "./init.js";
25
25
  export async function carveEmit(opts, deps) {
26
26
  if (!opts.from)
27
27
  return { ok: false, error: "chant carve emit requires --from <terraform-dir>" };
@@ -199,7 +199,7 @@ function scaffoldProject(outDir, lexicon, params = []) {
199
199
  },
200
200
  dependencies: {
201
201
  "@intentius/chant": `^${ver}`,
202
- [`@intentius/chant-lexicon-${lexicon}`]: `^${ver}`,
202
+ [`@intentius/chant-lexicon-${lexicon}`]: lexiconDependencyRange(lexicon),
203
203
  },
204
204
  devDependencies: { ...SCAFFOLD_DEV_DEPENDENCIES },
205
205
  };
@@ -30,9 +30,9 @@ export interface LoadedLexicon {
30
30
  /**
31
31
  * The module a lexicon package presents to consumers, as its source.
32
32
  *
33
- * Tier 1 requires `exports["."].development` to be `./src/index.ts` and
33
+ * Tier 1 requires `exports["."]["@intentius/chant-source"]` to be `./src/index.ts` and
34
34
  * `default` to be its compiled `./dist/index.js` (#3981). The check reads the
35
- * lexicon's source, so `development` is the first choice: a `dist/` may be
35
+ * lexicon's source, so `@intentius/chant-source` is the first choice: a `dist/` may be
36
36
  * missing or older than the source. `default` and `main` come next, and the
37
37
  * conventional paths keep this usable on a lexicon that has not reached that
38
38
  * check yet.
@@ -27,9 +27,9 @@ import { esModuleNamespace } from "../../module-interop.js";
27
27
  /**
28
28
  * The module a lexicon package presents to consumers, as its source.
29
29
  *
30
- * Tier 1 requires `exports["."].development` to be `./src/index.ts` and
30
+ * Tier 1 requires `exports["."]["@intentius/chant-source"]` to be `./src/index.ts` and
31
31
  * `default` to be its compiled `./dist/index.js` (#3981). The check reads the
32
- * lexicon's source, so `development` is the first choice: a `dist/` may be
32
+ * lexicon's source, so `@intentius/chant-source` is the first choice: a `dist/` may be
33
33
  * missing or older than the source. `default` and `main` come next, and the
34
34
  * conventional paths keep this usable on a lexicon that has not reached that
35
35
  * check yet.
@@ -38,7 +38,7 @@ export function pluginEntryFor(dir) {
38
38
  const candidates = [];
39
39
  try {
40
40
  const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf-8"));
41
- for (const declared of [pkg.exports?.["."]?.development, pkg.exports?.["."]?.default, pkg.main]) {
41
+ for (const declared of [pkg.exports?.["."]?.["@intentius/chant-source"], pkg.exports?.["."]?.default, pkg.main]) {
42
42
  if (typeof declared === "string")
43
43
  candidates.push(declared);
44
44
  }
@@ -275,7 +275,7 @@ export async function checkLexicon(dir) {
275
275
  // chant #1067 — packaging shape, real but unenforced before: a lexicon
276
276
  // shipping differently would break consumers silently. Cheap structural
277
277
  // check on package.json, not a build execution. #3981 — lexicons ship
278
- // compiled JS: `default` is ./dist/index.js, `development` stays on
278
+ // compiled JS: `default` is ./dist/index.js, `@intentius/chant-source` stays on
279
279
  // ./src/index.ts for the repository's tools, and the build keeps the JS tsc
280
280
  // emits (it used to delete it).
281
281
  const packageJsonRaw = readOr(join(dir, "package.json"));
@@ -284,7 +284,7 @@ export async function checkLexicon(dir) {
284
284
  if (packageJsonRaw) {
285
285
  try {
286
286
  const pkg = JSON.parse(packageJsonRaw);
287
- const developmentExport = pkg.exports?.["."]?.development;
287
+ const developmentExport = pkg.exports?.["."]?.["@intentius/chant-source"];
288
288
  const defaultExport = pkg.exports?.["."]?.default;
289
289
  const buildScript = pkg.scripts?.build ?? "";
290
290
  const developmentOk = developmentExport === "./src/index.ts";
@@ -293,7 +293,7 @@ export async function checkLexicon(dir) {
293
293
  packagingOk = developmentOk && defaultOk && keepsEmittedJs;
294
294
  const problems = [];
295
295
  if (!developmentOk)
296
- problems.push(`exports["."].development is ${JSON.stringify(developmentExport)}, expected "./src/index.ts"`);
296
+ problems.push(`exports["."]["@intentius/chant-source"] is ${JSON.stringify(developmentExport)}, expected "./src/index.ts"`);
297
297
  if (!defaultOk)
298
298
  problems.push(`exports["."].default is ${JSON.stringify(defaultExport)}, expected "./dist/index.js"`);
299
299
  if (!keepsEmittedJs)
@@ -308,7 +308,7 @@ export async function checkLexicon(dir) {
308
308
  packagingDetail = "package.json missing or unreadable";
309
309
  }
310
310
  items.push({
311
- name: 'package.json routes exports["."] development at ./src/index.ts and default at ./dist/index.js, and build keeps emitted JS',
311
+ name: 'package.json routes exports["."] @intentius/chant-source at ./src/index.ts and default at ./dist/index.js, and build keeps emitted JS',
312
312
  tier: 1,
313
313
  pass: packagingOk,
314
314
  detail: packagingDetail,
@@ -7,7 +7,7 @@ export declare function generatePackageJson(name: string, names: {
7
7
  export declare function generateTsConfig(): string;
8
8
  /**
9
9
  * Build config used by `npm run build` (and CI's `tsc --noEmit`). Uses `bundler`
10
- * resolution + the `development` condition so `@intentius/chant/*` resolves to the
10
+ * resolution + the `@intentius/chant-source` condition so `@intentius/chant/*` resolves to the
11
11
  * workspace source, and excludes tests/docs — the same setup the shipped lexicons
12
12
  * use. (The plain `tsconfig.json` extends the monorepo root and can't be tsc'd on
13
13
  * its own.)
@@ -10,12 +10,12 @@ export function generatePackageJson(name, names) {
10
10
  files: ["src/", "dist/"],
11
11
  exports: {
12
12
  ".": {
13
- development: "./src/index.ts",
13
+ "@intentius/chant-source": "./src/index.ts",
14
14
  types: "./dist/index.d.ts",
15
15
  default: "./dist/index.js",
16
16
  },
17
17
  "./*": {
18
- development: "./src/*.ts",
18
+ "@intentius/chant-source": "./src/*.ts",
19
19
  types: "./dist/*.d.ts",
20
20
  default: "./dist/*.js",
21
21
  },
@@ -55,7 +55,7 @@ export function generateTsConfig() {
55
55
  }
56
56
  /**
57
57
  * Build config used by `npm run build` (and CI's `tsc --noEmit`). Uses `bundler`
58
- * resolution + the `development` condition so `@intentius/chant/*` resolves to the
58
+ * resolution + the `@intentius/chant-source` condition so `@intentius/chant/*` resolves to the
59
59
  * workspace source, and excludes tests/docs — the same setup the shipped lexicons
60
60
  * use. (The plain `tsconfig.json` extends the monorepo root and can't be tsc'd on
61
61
  * its own.)
@@ -71,7 +71,7 @@ export function generateTsConfigBuild() {
71
71
  rootDir: "src",
72
72
  paths: {},
73
73
  moduleResolution: "bundler",
74
- customConditions: ["development"],
74
+ customConditions: ["@intentius/chant-source"],
75
75
  },
76
76
  include: ["src/**/*"],
77
77
  exclude: ["**/*.test.ts", "node_modules", "dist", "docs"],
@@ -1,5 +1,18 @@
1
1
  /** Read the current chant package version from our own package.json. */
2
2
  export declare function getChantVersion(): string;
3
+ /** Where a lexicon's own version comes from: the installed package, then the registry. */
4
+ export interface LexiconVersionSources {
5
+ installed: (lexicon: string) => string | undefined;
6
+ published: (lexicon: string) => string | undefined;
7
+ }
8
+ /**
9
+ * The dependency range a scaffolded project writes for a lexicon package
10
+ * (#5138). Packages release on their own version lines, so the range is the
11
+ * lexicon's own version, never chant core's: the installed package's version
12
+ * when chant can resolve it, else the registry's latest, else the `latest`
13
+ * dist-tag, which installs whatever the registry has.
14
+ */
15
+ export declare function lexiconDependencyRange(lexicon: string, sources?: LexiconVersionSources): string;
3
16
  /**
4
17
  * Init command options
5
18
  */
@@ -2,8 +2,9 @@ import { existsSync, mkdirSync, writeFileSync, readdirSync, readFileSync } from
2
2
  import { join, resolve, dirname } from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  import { createInterface } from "readline";
5
+ import { execFileSync } from "child_process";
5
6
  import { formatSuccess, formatWarning } from "../format.js";
6
- import { loadPlugin, recordProjectLexicons, unknownPathLexiconsNotice } from "../plugins.js";
7
+ import { loadPlugin, recordProjectLexicons, resolveLexiconVersions, unknownPathLexiconsNotice } from "../plugins.js";
7
8
  import { lexiconModulePath, lexiconSourceLabel } from "../../lexicon-module.js";
8
9
  import { MCP_CONFIG_FILENAME, detectPackageManager, generateMcpConfig, mcpConfigPath } from "../mcp-config.js";
9
10
  /** Read the current chant package version from our own package.json. */
@@ -17,6 +18,33 @@ export function getChantVersion() {
17
18
  return "0.0.13";
18
19
  }
19
20
  }
21
+ const defaultLexiconVersionSources = {
22
+ installed: (lexicon) => resolveLexiconVersions([lexicon])[lexicon],
23
+ published: (lexicon) => {
24
+ try {
25
+ const out = execFileSync("npm", ["view", `@intentius/chant-lexicon-${lexicon}`, "version"], {
26
+ encoding: "utf-8",
27
+ timeout: 20000,
28
+ stdio: ["ignore", "pipe", "ignore"],
29
+ }).trim();
30
+ return /^\d+\.\d+\.\d+/.test(out) ? out : undefined;
31
+ }
32
+ catch {
33
+ return undefined;
34
+ }
35
+ },
36
+ };
37
+ /**
38
+ * The dependency range a scaffolded project writes for a lexicon package
39
+ * (#5138). Packages release on their own version lines, so the range is the
40
+ * lexicon's own version, never chant core's: the installed package's version
41
+ * when chant can resolve it, else the registry's latest, else the `latest`
42
+ * dist-tag, which installs whatever the registry has.
43
+ */
44
+ export function lexiconDependencyRange(lexicon, sources = defaultLexiconVersionSources) {
45
+ const version = sources.installed(lexicon) ?? sources.published(lexicon);
46
+ return version ? `^${version}` : "latest";
47
+ }
20
48
  /**
21
49
  * The devDependencies a scaffolded project gets, from `chant init` and from
22
50
  * `chant carve` (#3233). The project's TypeScript is for its editor and `tsc`
@@ -37,7 +65,7 @@ function generatePackageJson(lexicon, extraScripts, lexiconIsPackage = true) {
37
65
  const dependencies = {
38
66
  "@intentius/chant": `^${ver}`,
39
67
  // chant#2578 — a lexicon declared by path is not a package to depend on.
40
- ...(lexiconIsPackage ? { [`@intentius/chant-lexicon-${lexicon}`]: `^${ver}` } : {}),
68
+ ...(lexiconIsPackage ? { [`@intentius/chant-lexicon-${lexicon}`]: lexiconDependencyRange(lexicon) } : {}),
41
69
  };
42
70
  const pkg = {
43
71
  name: "chant-project",
@@ -19,6 +19,8 @@
19
19
  * release verify <label|digest> [--json]
20
20
  * check the release's signature offline against .chant/allowed_signers
21
21
  * at the release's commit (#4049)
22
+ * release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]
23
+ * the members to release at a commit, with their dependency closure (#5134)
22
24
  * release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json]
23
25
  * the green commits of trunk a release can be cut from, each with what it
24
26
  * would ship, and what each environment runs (#4168 4.2)
@@ -121,6 +123,12 @@ export declare function runReleaseVerify(ctx: CommandContext): Promise<number>;
121
123
  * prints the read contract's `release-candidates` document.
122
124
  */
123
125
  export declare function runReleaseCandidates(ctx: CommandContext): Promise<number>;
126
+ /**
127
+ * `release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]`
128
+ * (#5134): the members a release at a commit has to cut, in publish order,
129
+ * each with why. `--json` prints the read contract's `release-changed` document.
130
+ */
131
+ export declare function runReleaseChanged(ctx: CommandContext): Promise<number>;
124
132
  export declare function runReleaseList(ctx: CommandContext): Promise<number>;
125
133
  /**
126
134
  * `release export <label|digest> --env <env> [-o <dir>]` (#4046): write each
@@ -19,6 +19,8 @@
19
19
  * release verify <label|digest> [--json]
20
20
  * check the release's signature offline against .chant/allowed_signers
21
21
  * at the release's commit (#4049)
22
+ * release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]
23
+ * the members to release at a commit, with their dependency closure (#5134)
22
24
  * release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json]
23
25
  * the green commits of trunk a release can be cut from, each with what it
24
26
  * would ship, and what each environment runs (#4168 4.2)
@@ -46,7 +48,7 @@ import { tmpdir } from "node:os";
46
48
  import { dirname, join, relative, resolve } from "node:path";
47
49
  import { formatBold, formatError, formatSuccess, formatWarning } from "../format.js";
48
50
  import { parseParamFlags } from "../build-params-cli.js";
49
- const USAGE = "chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release images <label|digest> [--no-build] [-o <file>] [--json] | release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
51
+ const USAGE = "chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release images <label|digest> [--no-build] [-o <file>] [--json] | release changed [--at <sha>] [--bump-member <member>=<level>]... [--json] | release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
50
52
  /** The build inputs `release cut` and `release compile` share. */
51
53
  function compileInputs(ctx, params, projectDir = resolve("."), releaseLabel) {
52
54
  const { args } = ctx;
@@ -890,6 +892,37 @@ export async function runReleaseCandidates(ctx) {
890
892
  console.error(`Cut one: chant release cut <label> --at <sha>${doc.lane !== null && ctx.args.lane !== undefined ? ` --lane ${doc.lane}` : ""}`);
891
893
  return 0;
892
894
  }
895
+ /**
896
+ * `release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]`
897
+ * (#5134): the members a release at a commit has to cut, in publish order,
898
+ * each with why. `--json` prints the read contract's `release-changed` document.
899
+ */
900
+ export async function runReleaseChanged(ctx) {
901
+ const { releaseChangedDocument } = await import("../../workspace/release-changed.js");
902
+ const doc = await releaseChangedDocument({
903
+ cwd: resolve("."),
904
+ ...(ctx.args.at ? { at: ctx.args.at } : {}),
905
+ ...(ctx.args.bumpMember ? { bump: ctx.args.bumpMember } : {}),
906
+ });
907
+ if (ctx.args.json) {
908
+ console.log(JSON.stringify(doc, null, 2));
909
+ return "error" in doc ? 1 : 0;
910
+ }
911
+ if ("error" in doc) {
912
+ console.error(formatError({ message: `${doc.error.message} [${doc.error.code}]`, hint: USAGE }));
913
+ return 1;
914
+ }
915
+ if (doc.members.length === 0) {
916
+ console.log(`Nothing to release at ${doc.at.slice(0, 12)}.`);
917
+ return 0;
918
+ }
919
+ for (const m of doc.members) {
920
+ const why = m.reason.member !== null ? `${m.reason.code} ${m.reason.member}` : m.reason.code;
921
+ const label = m.next !== null ? `${m.last?.label ?? "?"} -> ${m.next}` : "no release yet";
922
+ console.log(`layer ${m.layer} ${m.member} ${label} (${why})`);
923
+ }
924
+ return 0;
925
+ }
893
926
  export async function runReleaseList(ctx) {
894
927
  const { releasesDocument } = await import("../../workspace/releases.js");
895
928
  const doc = await releasesDocument({ cwd: resolve(".") });
package/dist/cli/main.js CHANGED
@@ -555,6 +555,10 @@ Releases:
555
555
  Write the publish workflow, run on a release/** tag.
556
556
  Under supply-chain it passes --require-provenance, and
557
557
  under verified-releases it runs release verify first
558
+ release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]
559
+ The members to release at a commit, in publish order,
560
+ each with why: changed, needed-by <member>, or
561
+ range-broken-by <member>. Reads local refs only
558
562
  release list [--json] Every release of this member with its targets, its
559
563
  cuts and the environments that run it.
560
564
  release export <label|digest> --env <env> [-o <dir>] [--json]
@@ -2038,6 +2042,7 @@ export const commandRegistry = [
2038
2042
  // #4168 4.3: mode (b), chosen changes composed onto a base on chant/compose/<name>.
2039
2043
  { name: "release compose", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release.js")).runReleaseCompose(ctx) },
2040
2044
  { name: "release candidates", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release.js")).runReleaseCandidates(ctx) },
2045
+ { name: "release changed", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release.js")).runReleaseChanged(ctx) },
2041
2046
  { name: "release list", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release.js")).runReleaseList(ctx) },
2042
2047
  { name: "release export", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release.js")).runReleaseExport(ctx) },
2043
2048
  { name: "release compile", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release.js")).runReleaseCompile(ctx) },
@@ -1032,6 +1032,13 @@ export function parseArgs(args) {
1032
1032
  // `chant workspace graph --intent ... --follow-squash` and `chant workspace runs --follow-squash` (#3035)
1033
1033
  result.followSquash = true;
1034
1034
  }
1035
+ else if (arg === "--bump-member") {
1036
+ // `chant release changed --bump-member <member>=<level>` (#5134) is repeatable.
1037
+ const value = args[++i];
1038
+ if (!value || value.startsWith("-"))
1039
+ throw new Error("--bump-member needs a member and a level: --bump-member <member>=major|minor|patch");
1040
+ (result.bumpMember ?? (result.bumpMember = [])).push(value);
1041
+ }
1035
1042
  else if (arg === "--forge-issues") {
1036
1043
  // `chant release candidates --forge-issues` and `chant workspace graph --intent ... --forge-issues` (#4649)
1037
1044
  result.forgeIssues = true;
@@ -666,6 +666,8 @@ export interface ParsedArgs {
666
666
  intent?: string;
667
667
  /** `chant workspace graph --intent` and `chant workspace runs` (#3035): follow squash merges to their pull requests' original commits, fetching missing pull request refs. */
668
668
  followSquash?: boolean;
669
+ /** `chant release changed --bump-member <member>=<level>` (#5134) — repeatable. */
670
+ bumpMember?: string[];
669
671
  /** `chant release candidates --forge-issues` and `chant workspace graph --intent --forge-issues` (#4649): ask the forge which issues each squash-merged pull request closes, once per pull request. */
670
672
  forgeIssues?: boolean;
671
673
  /** `chant workspace graph --intent --record <id>`: walk one decision record over every entry its constrains lists. */
@@ -192,7 +192,7 @@ function lexiconEntry(lexiconDir) {
192
192
  rel = root;
193
193
  else if (root && typeof root === "object") {
194
194
  const conds = root;
195
- rel = conds.development ?? conds.default ?? conds.import ?? rel;
195
+ rel = conds["@intentius/chant-source"] ?? conds.default ?? conds.import ?? rel;
196
196
  }
197
197
  if (typeof rel !== "string")
198
198
  return null;
@@ -120,7 +120,7 @@ export declare function isCapabilityPlugin(value: unknown): value is CapabilityP
120
120
  * on every `just release` — the aws plugin shipped `"1.0.0"` from the day it
121
121
  * was extracted from the starter set (#681), and the k8s plugin's authoring-
122
122
  * time `"0.41.0"` was stale one release later. Walking up from the module's
123
- * own URL survives both the `src/` (development condition) and `dist/`
123
+ * own URL survives both the `src/` (@intentius/chant-source condition) and `dist/`
124
124
  * layouts, and an npm install, without any build-time stamping.
125
125
  *
126
126
  * Returns `"0.0.0"` when no versioned `package.json` is found — a visible
@@ -60,7 +60,7 @@ export function isCapabilityPlugin(value) {
60
60
  * on every `just release` — the aws plugin shipped `"1.0.0"` from the day it
61
61
  * was extracted from the starter set (#681), and the k8s plugin's authoring-
62
62
  * time `"0.41.0"` was stale one release later. Walking up from the module's
63
- * own URL survives both the `src/` (development condition) and `dist/`
63
+ * own URL survives both the `src/` (@intentius/chant-source condition) and `dist/`
64
64
  * layouts, and an npm install, without any build-time stamping.
65
65
  *
66
66
  * Returns `"0.0.0"` when no versioned `package.json` is found — a visible
package/dist/config.d.ts CHANGED
@@ -166,6 +166,7 @@ export declare const ChantConfigSchema: z.ZodObject<{
166
166
  args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
167
167
  }, z.core.$strict>]>>>;
168
168
  lane: z.ZodOptional<z.ZodString>;
169
+ legacyTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
169
170
  version: z.ZodOptional<z.ZodObject<{
170
171
  packages: z.ZodArray<z.ZodString>;
171
172
  lockfile: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
@@ -532,6 +533,13 @@ export interface ChantConfig {
532
533
  * rather than `ci/green/<sha>`.
533
534
  */
534
535
  lane?: string;
536
+ /**
537
+ * Tag prefixes of releases cut before members had ledgers (#5134), such as
538
+ * `release/npm/` and `chant-v`. `chant release changed` reads the newest
539
+ * `<prefix><version>` tag as a member's last release when its ledger has
540
+ * no cut.
541
+ */
542
+ legacyTags?: string[];
535
543
  /**
536
544
  * The package directories whose `package.json` the release stamps with
537
545
  * its label (#4840), so the version needs no commit: the cut stamps them
package/dist/config.js CHANGED
@@ -101,6 +101,8 @@ export const ChantConfigSchema = z.object({
101
101
  ]))
102
102
  .optional(),
103
103
  lane: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, "a ci.green lane name: lowercase letters, digits and dashes").optional(),
104
+ // #5134: tag prefixes of releases cut before members had ledgers, read as a last release by `chant release changed`.
105
+ legacyTags: z.array(z.string().min(1)).optional(),
104
106
  // #4840: the label stamped into these packages' package.json at the cut and the publish.
105
107
  version: z.object({
106
108
  packages: z.array(z.string().min(1)).min(1),
@@ -10,8 +10,10 @@ export interface DeadGuard {
10
10
  floor: string;
11
11
  /** The floor's version. */
12
12
  version: string;
13
- /** The chant pin that meets it. */
13
+ /** The pin that meets it: the product's range on `package`, or on `@intentius/chant` when there is none. */
14
14
  pin: string;
15
+ /** The lexicon package the floor's version belongs to, when it is not `@intentius/chant`. */
16
+ package?: string;
15
17
  /** The line's text, trimmed. */
16
18
  text: string;
17
19
  }
@@ -66,6 +68,8 @@ export interface Guard {
66
68
  kind: DeadGuard["kind"];
67
69
  floor: string;
68
70
  version: string;
71
+ /** The lexicon package the version belongs to; absent for chant core. */
72
+ package?: string;
69
73
  }
70
74
  /**
71
75
  * The feature-detects on a floor in one source file. `table` gives each
@@ -23,9 +23,10 @@
23
23
  * (`@intentius/chant-lexicon-terraform/registry`, #4916), loaded with
24
24
  * `import()` where a `catch` is near (`try { await import(specifier) }
25
25
  * catch { return undefined }`, or `.catch(`), the shape of a chant-next.ts
26
- * loader. Its floor is the lowest floor the subpath serves: a chant with
27
- * that floor has the subpath. Lexicons release with chant at the same
28
- * version, so a lexicon subpath is checked against the chant pin too.
26
+ * loader. Its floor is the lowest floor the subpath serves: a package at
27
+ * that floor has the subpath. Each package has its own version (#5138), so
28
+ * a lexicon subpath is checked against the pin on that lexicon's package,
29
+ * and a chant subpath against the `@intentius/chant` pin.
29
30
  * - `product-floor`: a product's own constant for the chant it needs,
30
31
  * `const CHANT_CI_FLOOR = "0.124.67"`, whose checks the pin meets.
31
32
  *
@@ -50,12 +51,12 @@ export function pinOf(range) {
50
51
  return undefined;
51
52
  return /(\d+\.\d+\.\d+)/.exec(r)?.[1];
52
53
  }
53
- /** The `@intentius/chant` range a package.json names, if any. */
54
- function chantRange(file) {
54
+ /** The range a package.json names for `name` (`@intentius/chant` by default), if any. */
55
+ function chantRange(file, name = "@intentius/chant") {
55
56
  try {
56
57
  const pkg = JSON.parse(readFileSync(file, "utf8"));
57
58
  for (const k of CHANT_DEPS) {
58
- const v = pkg[k]?.["@intentius/chant"];
59
+ const v = pkg[k]?.[name];
59
60
  if (typeof v === "string")
60
61
  return v;
61
62
  }
@@ -269,6 +270,10 @@ export function insideTry(code, offset) {
269
270
  }
270
271
  return false;
271
272
  }
273
+ /** The lexicon package a subpath belongs to (`@intentius/chant-lexicon-terraform/registry`), if it is one. */
274
+ function lexiconPackageOf(spec) {
275
+ return /^(@intentius\/chant-lexicon-[a-z0-9-]+)(?:\/|$)/.exec(spec)?.[1];
276
+ }
272
277
  /**
273
278
  * The feature-detects on a floor in one source file. `table` gives each
274
279
  * floor's version; a name two files declare takes the higher one.
@@ -277,8 +282,8 @@ export function guardsIn(src, table = FLOOR_TABLE) {
277
282
  const floors = new Map();
278
283
  for (const r of table) {
279
284
  const had = floors.get(r.name);
280
- if (had === undefined || compareChantVersions(r.version, had) > 0)
281
- floors.set(r.name, r.version);
285
+ if (had === undefined || compareChantVersions(r.version, had.version) > 0)
286
+ floors.set(r.name, { version: r.version, package: r.package });
282
287
  }
283
288
  // The lowest floor each subpath serves.
284
289
  const modules = new Map();
@@ -295,7 +300,7 @@ export function guardsIn(src, table = FLOOR_TABLE) {
295
300
  const lines = src.split("\n");
296
301
  const out = [];
297
302
  const seen = new Set();
298
- const push = (offset, kind, floor, version) => {
303
+ const push = (offset, kind, floor, version, pkg) => {
299
304
  const line = lineAt(starts, offset);
300
305
  const key = `${line}|${kind}|${floor}`;
301
306
  if (seen.has(key))
@@ -303,7 +308,7 @@ export function guardsIn(src, table = FLOOR_TABLE) {
303
308
  if (lines[line - 1]?.includes(KEEP) || /^\s*(?:\/\/|\/?\*).*chant-dead-guards: keep/.test(lines[line - 2] ?? ""))
304
309
  return;
305
310
  seen.add(key);
306
- out.push({ line, kind, floor, version });
311
+ out.push({ line, kind, floor, version, ...(pkg ? { package: pkg } : {}) });
307
312
  };
308
313
  // Names bound by a static import or re-export, from anywhere: using one is
309
314
  // using the part. And the spans of those statements, which hold no check.
@@ -327,26 +332,27 @@ export function guardsIn(src, table = FLOOR_TABLE) {
327
332
  for (const m of code.matchAll(/\b[A-Z][A-Z0-9_]*_FLOOR\b/g)) {
328
333
  const at = m.index;
329
334
  const name = m[0];
330
- const version = floors.get(name);
331
- if (version === undefined || inStatement(at))
335
+ const found = floors.get(name);
336
+ if (found === undefined || inStatement(at))
332
337
  continue;
338
+ const { version, package: pkg } = found;
333
339
  if (inString[at]) {
334
340
  // A name in a string is a check when the line asks a module for it:
335
341
  // names a chant subpath or an import(), `"X_FLOOR" in m`, `m["X_FLOOR"]`.
336
342
  const text = codeLines[lineAt(starts, at) - 1] ?? "";
337
343
  if (/@intentius\/chant|\bimport\(|["'`]\s+in\s+[A-Za-z_$]/.test(text) || /[\w$\])]\s*\[\s*$/.test(code.slice(Math.max(0, at - 24), at - 1)))
338
- push(at, "floor", name, version);
344
+ push(at, "floor", name, version, pkg);
339
345
  continue;
340
346
  }
341
347
  const owner = /([A-Za-z_$][\w$]*)\s*\??\.\s*$/.exec(code.slice(Math.max(0, at - 64), at));
342
348
  if (owner || /\.\s*$/.test(code.slice(Math.max(0, at - 2), at))) {
343
349
  if (!owner || !namespaces.has(owner[1]))
344
- push(at, "floor", name, version);
350
+ push(at, "floor", name, version, pkg);
345
351
  continue;
346
352
  }
347
353
  if (imported.has(name) || declared.has(name))
348
354
  continue;
349
- push(at, "floor", name, version);
355
+ push(at, "floor", name, version, pkg);
350
356
  }
351
357
  // module: a chant or lexicon subpath loaded with import() inside a try, or with .catch( on the load.
352
358
  for (const m of src.matchAll(/(["'`])(@intentius\/chant(?:-lexicon-[a-z0-9-]+)?(?:\/[A-Za-z0-9_./-]+)?)\1/g)) {
@@ -375,7 +381,7 @@ export function guardsIn(src, table = FLOOR_TABLE) {
375
381
  const after = code.slice(site, site + 400);
376
382
  const caught = /^[^;\n]*?\)\s*\.catch\(/.test(after) || insideTry(code, site);
377
383
  if (caught)
378
- push(at, "module", spec, version);
384
+ push(at, "module", spec, version, lexiconPackageOf(spec));
379
385
  }
380
386
  // product-floor: the product's own constant for the chant it needs.
381
387
  for (const m of code.matchAll(/\b(?:const|let|var)\s+([A-Z0-9_]*CHANT[A-Z0-9_]*_FLOOR)\s*(?::\s*string\s*)?=\s*/g)) {
@@ -387,13 +393,14 @@ export function guardsIn(src, table = FLOOR_TABLE) {
387
393
  return out.sort((a, b) => a.line - b.line || a.floor.localeCompare(b.floor));
388
394
  }
389
395
  /** The chant pin over `file` (relative to `productDir`): the nearest package.json with one, up to the product's root. */
390
- function pinFor(productDir, file, cache) {
396
+ function pinFor(productDir, file, cache, name = "@intentius/chant") {
391
397
  for (let dir = dirname(join(productDir, file));; dir = dirname(dir)) {
392
398
  const manifest = join(dir, "package.json");
393
- let range = cache.get(manifest);
399
+ const key = `${name}|${manifest}`;
400
+ let range = cache.get(key);
394
401
  if (range === undefined) {
395
- range = existsSync(manifest) ? (chantRange(manifest) ?? null) : null;
396
- cache.set(manifest, range);
402
+ range = existsSync(manifest) ? (chantRange(manifest, name) ?? null) : null;
403
+ cache.set(key, range);
397
404
  }
398
405
  if (range !== null)
399
406
  return { pin: pinOf(range), manifest };
@@ -426,8 +433,12 @@ export function findDeadGuards(options) {
426
433
  const src = readFileSync(join(productDir, file), "utf8");
427
434
  const lines = src.split("\n");
428
435
  for (const g of guardsIn(src, table)) {
429
- const row = { file, ...g, pin, text: (lines[g.line - 1] ?? "").trim() };
430
- (compareChantVersions(pin, g.version) >= 0 ? dead : live).push(row);
436
+ // #5138: a lexicon's floor is a version of that lexicon, so its pin is the product's range on it.
437
+ const own = g.package ? pinFor(productDir, file, cache, g.package).pin : pin;
438
+ if (own === undefined)
439
+ continue;
440
+ const row = { file, ...g, pin: own, text: (lines[g.line - 1] ?? "").trim() };
441
+ (compareChantVersions(own, g.version) >= 0 ? dead : live).push(row);
431
442
  }
432
443
  }
433
444
  return { ok: dead.length === 0, dead, live, pins: [...pins].map(([file, pin]) => ({ file, pin })).sort((a, b) => a.file.localeCompare(b.file)), files: files.length, unpinned };
@@ -435,5 +446,5 @@ export function findDeadGuards(options) {
435
446
  /** One dead guard as a line: `file:line: ...`. */
436
447
  export function deadGuardLine(g) {
437
448
  const what = g.kind === "module" ? `loads ${g.floor} behind a catch` : g.kind === "product-floor" ? `declares ${g.floor}` : `checks ${g.floor}`;
438
- return `${g.file}:${g.line}: ${what}, which chant ${g.version} has; the pin ${g.pin} meets it`;
449
+ return `${g.file}:${g.line}: ${what}, which ${g.package ?? "chant"} ${g.version} has; the pin ${g.pin} meets it`;
439
450
  }
@@ -32,7 +32,7 @@ import { chantModule, chantSourceDir } from "../../ts-loader.js";
32
32
  // #3878: the TypeScript source, also when this module runs compiled from dist/.
33
33
  const HERE = chantSourceDir(import.meta.url);
34
34
  const DISCOVERY_DIR = join(HERE, "..");
35
- /** Absolute paths to chant's OWN trusted modules the generated driver imports — always resolved relative to THIS file's own location on disk, so this works whether chant is running from the monorepo or from a consumer's `node_modules` (both route runtime resolution at `src/*.ts` — see `packages/core/package.json`'s `development`/`default` export conditions). */
35
+ /** Absolute paths to chant's OWN trusted modules the generated driver imports — always resolved relative to THIS file's own location on disk, so this works whether chant is running from the monorepo or from a consumer's `node_modules` (both route runtime resolution at `src/*.ts` — see `packages/core/package.json`'s `@intentius/chant-source`/`default` export conditions). */
36
36
  const COLLECT_MODULE = chantModule(join(DISCOVERY_DIR, "collect.ts"));
37
37
  const RESOLVE_MODULE = chantModule(join(DISCOVERY_DIR, "resolve.ts"));
38
38
  // The pure codec, NOT `entity-wire.ts` — that file also exports
@@ -90,7 +90,7 @@ export function splitBareSpecifier(specifier) {
90
90
  }
91
91
  /**
92
92
  * The conditions an ESM import in Node matches, which is what the run path
93
- * does. From source, `development` too (#3981): the run path there resolves a
93
+ * does. From source, `@intentius/chant-source` too (#3981): the run path there resolves a
94
94
  * chant package to its `src/*.ts`, not to the compiled `dist/*.js` its
95
95
  * `default` names.
96
96
  */
@@ -2,8 +2,10 @@
2
2
  export interface FloorRow {
3
3
  /** The constant's name, `CI_IMAGE_FLOOR`. */
4
4
  name: string;
5
- /** The first chant release with the part. A floor not yet released has the next release's number. */
5
+ /** The first release of `package` with the part. A floor not yet released has the next release's number. */
6
6
  version: string;
7
+ /** The npm package `version` belongs to. Absent for chant core, `@intentius/chant`. */
8
+ package?: string;
7
9
  /** What the floor gates: the first sentence of the constant's doc comment. */
8
10
  gates: string;
9
11
  /** The issue that added it, `#4784`, or a product's (`terragucci issue 1303`). */