create-ailk 0.42.1 → 0.44.0

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 (25) hide show
  1. package/README.md +33 -10
  2. package/component-catalog.json +23 -0
  3. package/dist/cli.js +34 -0
  4. package/dist/compare-renders.d.ts +67 -0
  5. package/dist/compare-renders.js +274 -0
  6. package/dist/lib/import-mdx.d.ts +32 -15
  7. package/dist/lib/import-mdx.js +197 -188
  8. package/dist/lib/render-capture.d.ts +22 -0
  9. package/dist/lib/render-capture.js +125 -0
  10. package/dist/migrate-content.d.ts +9 -16
  11. package/dist/migrate-content.js +46 -82
  12. package/package.json +3 -3
  13. package/site-templates/shapes/local-business-service/content/en/Service/first-job.mdx +49 -26
  14. package/site-templates/shapes/local-business-service/content/en/Service/second-job.mdx +49 -26
  15. package/site-templates/shapes/local-business-service/content/en/Service/third-job.mdx +49 -26
  16. package/site-templates/shapes/organization-service/content/en/Service/first-engagement.mdx +49 -26
  17. package/site-templates/shapes/organization-service/content/en/Service/second-engagement.mdx +49 -26
  18. package/site-templates/shapes/organization-service/content/en/Service/third-engagement.mdx +49 -26
  19. package/site-templates/shapes/person-service/content/en/Service/first-engagement.mdx +49 -26
  20. package/site-templates/shapes/person-service/content/en/Service/second-engagement.mdx +49 -26
  21. package/site-templates/shapes/person-service/content/en/Service/third-engagement.mdx +49 -26
  22. package/templates/apps/api/CLAUDE.md +23 -5
  23. package/templates/apps/mcp/CLAUDE.md +32 -3
  24. package/templates/apps/web/package.json +1 -1
  25. package/versions.json +50 -50
package/README.md CHANGED
@@ -898,23 +898,24 @@ AILK_AGENT_KEY=<agent key> create-ailk migrate-content ./my-site --apply --api-u
898
898
  - Pages land as drafts and nothing is published, so the live site keeps
899
899
  serving its MDX files and does not change.
900
900
  - The plan cannot see a write the API would refuse at `--apply` (a conflict
901
- with an edit made in between, or a server error): such a page is planned
902
- `create` or `update`. A page whose content fails its page type is planned
903
- and then saved with the errors the editor shows, not `failed`.
901
+ with an edit made in between, a server error, or a page whose content fails
902
+ its page type): such a page is planned `create` or `update`. At `--apply`
903
+ the save refuses a page that fails its page type with `422 invalid` and
904
+ stores nothing (#11843); fix its file and re-run.
904
905
  - The site's dependencies must be installed (`pnpm install`): the pages are
905
906
  read through the site's own `@working-theory/content-adapters`.
906
- - Every page is written with a live-source mark (#10898): its words already
907
- ship on the live site, so a heading its page type's template asks for and
908
- the page lacks is listed as advisory, and publish takes the page. Editing
909
- the page's words in the hub drops the mark, and the page is then gated as
910
- any other. A dry run prints a line after each page —
907
+ - Each page is saved in one write (#11843): `save_page` for a page — its
908
+ sections as its words when its frontmatter carries them, else its body —
909
+ and `save_document` for a document. No page carries a live-source mark, so
910
+ a heading its page type's template asks for and the page lacks stops its
911
+ publish, as on any page. A dry run prints a line after each page —
911
912
  `<path>: publish — publishable`, `publishable · advisory: missing "<heading>", …`
912
913
  or `not publishable · <status> · <code>:<where> "<what>"` — and then
913
914
  `publish: publishable <N> (<K> with advisory headings) · not publishable <M>`.
914
915
  The verdict is the site's installed `@working-theory/validation`'s, not the
915
916
  hub's: it sees no library-file finding, and no layout the hub repairs
916
- differently. A site whose validation package predates the live-source
917
- report prints one `publish: not checked` line instead.
917
+ differently. A site whose validation package has no content check prints
918
+ one `publish: not checked` line instead.
918
919
  - Exit 0 when no page failed, 1 when any did (in a dry run, when any would), 2
919
920
  on a refusal (a missing key, workspace id or origin, no `content/`, the
920
921
  adapter not installed), which sends nothing.
@@ -990,6 +991,28 @@ reads it from, with its words moved back into its sections, so a re-run of
990
991
  `migrate-content` reports every page `unchanged`. The full sequence, the
991
992
  evidence each step leaves and each step's rollback are in the cutover runbook.
992
993
 
994
+ ### Comparing pages before and after the heading-form conversion
995
+
996
+ The hub's heading-form conversion (#11794) writes each page still in the
997
+ heading form a new draft in the section form, and its plan lists the
998
+ converted Live pages. No URL serves a draft, so `compare-renders` takes the
999
+ "before" over time: capture the live pages before their drafts are published,
1000
+ then compare the same URLs after, with the cutover's own comparison (text,
1001
+ JSON-LD and a full-page screenshot at 1440 and 390 wide) and a sweep of every
1002
+ path for a direct 200.
1003
+
1004
+ ```bash
1005
+ create-ailk compare-renders . --origin https://example.com --plan ~/.ailk-heading-form/plan.json --workspace <wksp_id> --capture .heading-form/example/before
1006
+ # … the drafts are written and published (docs/internal/runbooks/heading-form-conversion.md) …
1007
+ create-ailk compare-renders . --origin https://example.com --plan ~/.ailk-heading-form/plan.json --workspace <wksp_id> --against .heading-form/example/before
1008
+ # → .heading-form/example/before/comparison/{comparison.json,comparison.md,shots/}
1009
+ ```
1010
+
1011
+ It compares the workspace's live, converted rows in `--locale` (default `en`)
1012
+ that have a path, and lists every other live row as not compared. It needs
1013
+ Playwright's Chromium in the site, as `cutover` does. It exits 1 when a page
1014
+ differs or a URL is not 200, and 2 on a refusal.
1015
+
993
1016
  ### A spoke's declared environment
994
1017
 
995
1018
  A spoke scaffold's `pnpm preflight` and CI run `pnpm env:declared`: every
@@ -4766,6 +4766,29 @@
4766
4766
  "kind",
4767
4767
  "flow"
4768
4768
  ]
4769
+ },
4770
+ {
4771
+ "type": "object",
4772
+ "properties": {
4773
+ "kind": {
4774
+ "type": "string",
4775
+ "const": "magnet"
4776
+ },
4777
+ "slug": {
4778
+ "type": "string",
4779
+ "minLength": 1,
4780
+ "maxLength": 59,
4781
+ "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
4782
+ },
4783
+ "href": {
4784
+ "type": "string",
4785
+ "minLength": 1
4786
+ }
4787
+ },
4788
+ "required": [
4789
+ "kind",
4790
+ "slug"
4791
+ ]
4769
4792
  }
4770
4793
  ]
4771
4794
  },
package/dist/cli.js CHANGED
@@ -81,6 +81,7 @@ import { ADD_ROUTE_HELP, AddRouteRefusedError, MAGNET_ROUTE, addMagnetToScaffold
81
81
  import { ADOPT_HELP, AdoptRefusedError, adoptSite, formatAdoptReport, parseAdoptArgs, } from "./adopt.js";
82
82
  import { APPLY_DESIGN_HELP, applyDesign, formatApplyDesignReport, parseApplyDesignArgs, } from "./apply-design.js";
83
83
  import { CLAUDE_MD_CHECK_PATH } from "./claude-md.js";
84
+ import { COMPARE_RENDERS_HELP, CompareRendersRefusedError, compareRenders, parseCompareRendersArgs, } from "./compare-renders.js";
84
85
  import { buildScaffoldMarkers } from "./copy.js";
85
86
  import { CUTOVER_HELP, CutoverRefusedError, cutover, parseCutoverArgs, } from "./cutover.js";
86
87
  import { EXPORT_CONTENT_HELP, ExportContentRefusedError, exportContent, parseExportContentArgs, } from "./export-content.js";
@@ -89,6 +90,7 @@ import { ImportMdxRefusedError } from "./lib/import-mdx.js";
89
90
  import { assertKeyedOrFreeReleased, assertReleased } from "./lib/module-license-gate.js";
90
91
  import { withNpmTokenUserConfig } from "./lib/npm-auth.js";
91
92
  import { FREE_PREREQUISITES_NOTE, LICENSED_PREREQUISITES_NOTE, isLicensedInstall, proCallout, } from "./lib/pro-callout.js";
93
+ import { loadChromium } from "./lib/render-comparison.js";
92
94
  import { LICENSE_SET_HELP, runLicenseSet } from "./license-set.js";
93
95
  import { MIGRATE_CONTENT_HELP, MigrateContentRefusedError, migrateContent, parseMigrateContentArgs, } from "./migrate-content.js";
94
96
  import { PLUGIN_INSTALL_LINES, ParseError, helpText, parseCliArgs, parseModules, resolveCliShape, toScaffoldOptions, } from "./parse-args.js";
@@ -456,6 +458,38 @@ async function main() {
456
458
  process.exit(2);
457
459
  }
458
460
  }
461
+ // `compare-renders [dir]` (#11794): capture the heading-form conversion's
462
+ // converted Live pages before their publish, and compare them after.
463
+ if (argv[0] === "compare-renders") {
464
+ try {
465
+ const args = parseCompareRendersArgs(argv.slice(1));
466
+ if (args.help) {
467
+ process.stdout.write(COMPARE_RENDERS_HELP);
468
+ process.exit(0);
469
+ }
470
+ const { exitCode } = await compareRenders({
471
+ origin: args.origin,
472
+ plan: args.plan,
473
+ workspaceId: args.workspaceId,
474
+ ...(args.locale !== undefined && { locale: args.locale }),
475
+ ...(args.capture !== undefined && { capture: args.capture }),
476
+ ...(args.against !== undefined && { against: args.against }),
477
+ ...(args.out !== undefined && { out: args.out }),
478
+ ...(args.tolerance !== undefined && { tolerance: args.tolerance }),
479
+ chromium: loadChromium([resolve(args.target ?? process.cwd())]),
480
+ fetch: globalThis.fetch,
481
+ onLine: (line) => process.stdout.write(`${line}\n`),
482
+ });
483
+ process.exit(exitCode);
484
+ }
485
+ catch (err) {
486
+ if (!(err instanceof ParseError) && !(err instanceof CompareRendersRefusedError)) {
487
+ throw err;
488
+ }
489
+ process.stderr.write(`[create-ailk] ${err.message}\n`);
490
+ process.exit(2);
491
+ }
492
+ }
459
493
  // `routes --write | --check [dir]` (#11219, ADR 0040 rule 3): the one
460
494
  // route-file generator, over the manifests of the site's installed page
461
495
  // packages. Check mode exits 1 iff a generated file is missing, stale or
@@ -0,0 +1,67 @@
1
+ import { type ChromiumLike } from "./lib/render-comparison.js";
2
+ /** A refusal before anything is rendered: exit 2. */
3
+ export declare class CompareRendersRefusedError extends Error {
4
+ name: string;
5
+ }
6
+ /** One plan row as this command reads it. */
7
+ interface PlanRow {
8
+ workspaceId: string;
9
+ path: string | null;
10
+ locale?: string;
11
+ live: boolean;
12
+ class: string | null;
13
+ outcome: string;
14
+ reason?: string;
15
+ }
16
+ export interface CompareRendersOptions {
17
+ origin: string;
18
+ /** The plan file `convert-heading-form --plan` wrote. */
19
+ plan: string;
20
+ workspaceId: string;
21
+ /** The locale the origin serves at its unprefixed paths. Default `en`. */
22
+ locale?: string;
23
+ /** `--capture <dir>`: record the before renders. */
24
+ capture?: string;
25
+ /** `--against <dir>`: compare the live renders with that capture. */
26
+ against?: string;
27
+ /** Where the comparison's evidence goes; default `<against>/comparison`. */
28
+ out?: string;
29
+ tolerance?: number;
30
+ /** Playwright's `chromium`, from the site's own install; `undefined` refuses. */
31
+ chromium: ChromiumLike | undefined;
32
+ fetch: typeof globalThis.fetch;
33
+ onLine?: (line: string) => void;
34
+ now?: () => Date;
35
+ }
36
+ /**
37
+ * The plan's pages to compare for `workspaceId` (D6): live, in `locale`, with
38
+ * a path, and converted — or held only as `draft-ahead`, compared after the
39
+ * operator's own publish. Every other live row of the workspace is listed as
40
+ * not compared, with why.
41
+ */
42
+ export declare function comparedPaths(rows: readonly PlanRow[], workspaceId: string, locale: string): {
43
+ paths: string[];
44
+ notCompared: {
45
+ path: string | null;
46
+ reason: string;
47
+ }[];
48
+ };
49
+ /** Captures or compares (D6); answers the exit code: 0 all pass, 1 a page or URL failed. */
50
+ export declare function compareRenders(o: CompareRendersOptions): Promise<{
51
+ exitCode: number;
52
+ }>;
53
+ export interface CompareRendersArgs {
54
+ target: string | undefined;
55
+ origin: string | undefined;
56
+ plan: string | undefined;
57
+ workspaceId: string | undefined;
58
+ locale: string | undefined;
59
+ capture: string | undefined;
60
+ against: string | undefined;
61
+ out: string | undefined;
62
+ tolerance: number | undefined;
63
+ help: boolean;
64
+ }
65
+ export declare const COMPARE_RENDERS_HELP = "create-ailk compare-renders \u2014 before-and-after renders of the pages the heading-form conversion changed.\n\nUsage:\n create-ailk compare-renders [<dir>] --origin <url> --plan <file> --workspace <wksp_id> --capture <dir>\n create-ailk compare-renders [<dir>] --origin <url> --plan <file> --workspace <wksp_id> --against <dir> [--out <dir>] [--tolerance <share>]\n\nArguments:\n <dir> The site, whose Playwright runs the browser. Defaults to the current dir.\n\nOptions:\n --origin <url> The live site.\n --plan <file> The plan convert-heading-form --plan wrote.\n --workspace <wksp_id> The site's workspace: only its rows are compared.\n --locale <locale> The locale the site serves at its unprefixed paths. Default en.\n --capture <dir> Record each converted Live page before its draft is published.\n --against <dir> Compare each page now with that capture, then sweep every path for a 200.\n --out <dir> Where comparison.json, comparison.md and shots/ go. Default <against>/comparison.\n --tolerance <share> The share of a screenshot's pixels that may differ. Default 0.\n -h, --help Show this help.\n\nText, JSON-LD and a full-page screenshot are compared at 1440 and 390 wide.\nNeeds Playwright's Chromium in the site: pnpm add -D @playwright/test && pnpm exec playwright install chromium.\nThe runbook is docs/internal/runbooks/heading-form-conversion.md.\nExit 0 when every page is the same and every URL answers 200, 1 when one is\nnot, 2 on a refusal.\n";
66
+ export declare function parseCompareRendersArgs(argv: string[]): CompareRendersArgs;
67
+ export {};
@@ -0,0 +1,274 @@
1
+ /**
2
+ * `create-ailk compare-renders` (#11794 D6, spec
3
+ * docs/specs/11794-convert-the-remaining-heading-form-spec.md): the
4
+ * before-and-after evidence for the heading-form conversion.
5
+ *
6
+ * No URL serves a draft, so "before" is taken over time: `--capture` records
7
+ * each converted Live page of the plan from the live site before its new
8
+ * draft is published, and `--against` replays that capture as the `before`
9
+ * side of the cutover kit's own `comparePage` (text, JSON-LD and pixels at
10
+ * 1440 and 390 wide), with the live site as `after`, then sweeps every path
11
+ * for a direct 200. `render-comparison.ts` is used as it is: the replay is
12
+ * the only new seam (`lib/render-capture.ts`).
13
+ *
14
+ * The plan is the one `convert-heading-form --plan` writes. Its rows hold no
15
+ * words; a row with no path is listed as not compared, never joined to the
16
+ * origin.
17
+ *
18
+ * Pure module: no `import.meta.url`, so jest imports it directly; the browser
19
+ * and `fetch` are injected.
20
+ */
21
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
22
+ import { join } from "node:path";
23
+ import { parseArgs } from "node:util";
24
+ import { recordingPage, replayPage } from "./lib/render-capture.js";
25
+ import { comparePage, comparisonMarkdown, PLAYWRIGHT_INSTALL_HINT, sweep, } from "./lib/render-comparison.js";
26
+ import { ParseError } from "./parse-args.js";
27
+ /** A refusal before anything is rendered: exit 2. */
28
+ export class CompareRendersRefusedError extends Error {
29
+ name = "CompareRendersRefusedError";
30
+ }
31
+ /**
32
+ * The plan's pages to compare for `workspaceId` (D6): live, in `locale`, with
33
+ * a path, and converted — or held only as `draft-ahead`, compared after the
34
+ * operator's own publish. Every other live row of the workspace is listed as
35
+ * not compared, with why.
36
+ */
37
+ export function comparedPaths(rows, workspaceId, locale) {
38
+ const paths = [];
39
+ const notCompared = [];
40
+ for (const row of rows) {
41
+ if (row.workspaceId !== workspaceId || !row.live)
42
+ continue;
43
+ const converted = row.class !== null &&
44
+ (row.outcome === "converted" ||
45
+ row.outcome === "would-convert" ||
46
+ (row.outcome === "held" && row.reason === "draft-ahead"));
47
+ if (!converted)
48
+ notCompared.push({ path: row.path, reason: `${row.outcome}${row.reason ? `: ${row.reason}` : ""}` });
49
+ else if (row.path === null)
50
+ notCompared.push({ path: null, reason: "no path" });
51
+ else if (!isSitePath(row.path))
52
+ notCompared.push({ path: row.path, reason: "not a site path" });
53
+ else if ((row.locale ?? locale) !== locale)
54
+ notCompared.push({ path: row.path, reason: `locale ${row.locale}` });
55
+ else if (!paths.includes(row.path))
56
+ paths.push(row.path);
57
+ }
58
+ return { paths, notCompared };
59
+ }
60
+ /**
61
+ * Whether `path` is a path on any origin it is joined to: `/`-rooted, not
62
+ * `//`, and resolving to itself. The plan is a file on disk, so its paths are
63
+ * checked again here, never joined to the origin as written.
64
+ */
65
+ function isSitePath(path) {
66
+ if (typeof path !== "string" || !/^\/(?!\/)/.test(path))
67
+ return false;
68
+ const probe = "https://origin.invalid";
69
+ try {
70
+ const url = new URL(path, probe);
71
+ return url.origin === probe && url.pathname === path;
72
+ }
73
+ catch {
74
+ return false;
75
+ }
76
+ }
77
+ function readPlan(file) {
78
+ if (!existsSync(file))
79
+ throw new CompareRendersRefusedError(`compare-renders: no plan at ${file}`);
80
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
81
+ if (!Array.isArray(parsed.pages))
82
+ throw new CompareRendersRefusedError(`compare-renders: ${file} is not a plan`);
83
+ return parsed.pages;
84
+ }
85
+ /** A page that never renders: the capture's `after` side, so `comparePage` drives only the recording. */
86
+ const NO_PAGE = {
87
+ async setViewportSize() { },
88
+ async goto() {
89
+ return null;
90
+ },
91
+ url: () => "about:blank",
92
+ async evaluate() {
93
+ return undefined;
94
+ },
95
+ async screenshot() {
96
+ return Buffer.alloc(0);
97
+ },
98
+ };
99
+ /** Captures or compares (D6); answers the exit code: 0 all pass, 1 a page or URL failed. */
100
+ export async function compareRenders(o) {
101
+ const line = o.onLine ?? (() => { });
102
+ if ((o.capture === undefined) === (o.against === undefined)) {
103
+ throw new CompareRendersRefusedError("compare-renders: pass exactly one of --capture <dir> and --against <dir>");
104
+ }
105
+ let origin;
106
+ try {
107
+ origin = new URL(o.origin).origin;
108
+ }
109
+ catch {
110
+ throw new CompareRendersRefusedError(`compare-renders: --origin ${o.origin} is not a URL`);
111
+ }
112
+ if (!/^https?:$/.test(new URL(origin).protocol)) {
113
+ throw new CompareRendersRefusedError("compare-renders: --origin must be an http(s) URL");
114
+ }
115
+ const rows = readPlan(o.plan);
116
+ if (!rows.some((row) => row.workspaceId === o.workspaceId)) {
117
+ throw new CompareRendersRefusedError(`compare-renders: the plan has no page of workspace ${o.workspaceId}`);
118
+ }
119
+ if (o.chromium === undefined) {
120
+ throw new CompareRendersRefusedError(`compare-renders: Playwright's Chromium was not found in the site; install it: ${PLAYWRIGHT_INSTALL_HINT}`);
121
+ }
122
+ const { paths, notCompared } = comparedPaths(rows, o.workspaceId, o.locale ?? "en");
123
+ for (const row of notCompared)
124
+ line(`not compared ${row.path ?? "(no path)"} — ${row.reason}`);
125
+ const browser = await o.chromium.launch();
126
+ try {
127
+ if (o.capture !== undefined) {
128
+ const dir = o.capture;
129
+ mkdirSync(dir, { recursive: true });
130
+ const live = await (await browser.newContext()).newPage();
131
+ const recording = recordingPage(live, { dir, origin, paths });
132
+ let failed = 0;
133
+ for (const [i, path] of paths.entries()) {
134
+ const result = await comparePage({
135
+ path,
136
+ n: i + 1,
137
+ before: { origin, page: recording },
138
+ after: { origin, page: NO_PAGE },
139
+ tolerance: 0,
140
+ screenshots: true,
141
+ writeShot: () => { },
142
+ });
143
+ const rendered = result.viewports.every((v) => v.render.before === "ok");
144
+ if (!rendered)
145
+ failed += 1;
146
+ line(`${rendered ? "captured" : "NOT CAPTURED"} ${path}`);
147
+ }
148
+ writeFileSync(join(dir, "capture.json"), `${JSON.stringify({ origin, paths, at: (o.now ?? (() => new Date()))().toISOString() }, null, 2)}\n`);
149
+ return { exitCode: failed === 0 ? 0 : 1 };
150
+ }
151
+ const dir = o.against;
152
+ const captureFile = join(dir, "capture.json");
153
+ if (!existsSync(captureFile))
154
+ throw new CompareRendersRefusedError(`compare-renders: no capture at ${dir}`);
155
+ const captured = JSON.parse(readFileSync(captureFile, "utf8"));
156
+ const capturedPaths = Array.isArray(captured.paths) ? captured.paths.map(String) : [];
157
+ const out = o.out ?? join(dir, "comparison");
158
+ const shots = join(out, "shots");
159
+ mkdirSync(shots, { recursive: true });
160
+ const before = replayPage({ dir, origin, paths: capturedPaths });
161
+ const after = await (await browser.newContext()).newPage();
162
+ const pages = [];
163
+ for (const [i, path] of paths.entries()) {
164
+ const result = await comparePage({
165
+ path,
166
+ n: i + 1,
167
+ before: { origin, page: before },
168
+ after: { origin, page: after },
169
+ tolerance: o.tolerance ?? 0,
170
+ screenshots: true,
171
+ writeShot: (name, png) => writeFileSync(join(shots, name), png),
172
+ });
173
+ line(`${result.pass ? "same" : "DIFFERS"} ${path}`);
174
+ pages.push(result);
175
+ }
176
+ const swept = await sweep({ origin, paths, fetch: o.fetch });
177
+ const report = { before: `${origin} (captured)`, after: origin, pages, sweep: swept };
178
+ writeFileSync(join(out, "comparison.json"), `${JSON.stringify({ ...report, notCompared }, null, 2)}\n`);
179
+ const unlisted = notCompared.length === 0
180
+ ? ""
181
+ : [
182
+ "",
183
+ `## Not compared: ${notCompared.length} live page(s)`,
184
+ "",
185
+ ...notCompared.map((row) => `- \`${row.path ?? "(no path)"}\` — ${row.reason}`),
186
+ "",
187
+ ].join("\n");
188
+ writeFileSync(join(out, "comparison.md"), comparisonMarkdown(report) + unlisted);
189
+ const pass = swept.pass && pages.every((p) => p.pass);
190
+ line(`${pass ? "PASS" : "FAIL"}: ${pages.filter((p) => p.pass).length}/${pages.length} page(s) the same; evidence in ${out}`);
191
+ return { exitCode: pass ? 0 : 1 };
192
+ }
193
+ finally {
194
+ await browser.close();
195
+ }
196
+ }
197
+ export const COMPARE_RENDERS_HELP = `create-ailk compare-renders — before-and-after renders of the pages the heading-form conversion changed.
198
+
199
+ Usage:
200
+ create-ailk compare-renders [<dir>] --origin <url> --plan <file> --workspace <wksp_id> --capture <dir>
201
+ create-ailk compare-renders [<dir>] --origin <url> --plan <file> --workspace <wksp_id> --against <dir> [--out <dir>] [--tolerance <share>]
202
+
203
+ Arguments:
204
+ <dir> The site, whose Playwright runs the browser. Defaults to the current dir.
205
+
206
+ Options:
207
+ --origin <url> The live site.
208
+ --plan <file> The plan convert-heading-form --plan wrote.
209
+ --workspace <wksp_id> The site's workspace: only its rows are compared.
210
+ --locale <locale> The locale the site serves at its unprefixed paths. Default en.
211
+ --capture <dir> Record each converted Live page before its draft is published.
212
+ --against <dir> Compare each page now with that capture, then sweep every path for a 200.
213
+ --out <dir> Where comparison.json, comparison.md and shots/ go. Default <against>/comparison.
214
+ --tolerance <share> The share of a screenshot's pixels that may differ. Default 0.
215
+ -h, --help Show this help.
216
+
217
+ Text, JSON-LD and a full-page screenshot are compared at 1440 and 390 wide.
218
+ Needs Playwright's Chromium in the site: ${PLAYWRIGHT_INSTALL_HINT}.
219
+ The runbook is docs/internal/runbooks/heading-form-conversion.md.
220
+ Exit 0 when every page is the same and every URL answers 200, 1 when one is
221
+ not, 2 on a refusal.
222
+ `;
223
+ export function parseCompareRendersArgs(argv) {
224
+ let parsed;
225
+ try {
226
+ parsed = parseArgs({
227
+ args: argv,
228
+ strict: true,
229
+ allowPositionals: true,
230
+ options: {
231
+ origin: { type: "string" },
232
+ plan: { type: "string" },
233
+ workspace: { type: "string" },
234
+ locale: { type: "string" },
235
+ capture: { type: "string" },
236
+ against: { type: "string" },
237
+ out: { type: "string" },
238
+ tolerance: { type: "string" },
239
+ help: { type: "boolean", default: false, short: "h" },
240
+ },
241
+ });
242
+ }
243
+ catch (err) {
244
+ throw new ParseError(`compare-renders: ${err.message}`);
245
+ }
246
+ const [target, ...rest] = parsed.positionals;
247
+ if (rest.length > 0) {
248
+ throw new ParseError(`compare-renders takes at most one site directory, got ${parsed.positionals.length} arguments`);
249
+ }
250
+ const raw = parsed.values.tolerance;
251
+ const tolerance = raw === undefined ? undefined : Number(raw);
252
+ if (tolerance !== undefined && (raw.trim() === "" || Number.isNaN(tolerance) || tolerance < 0 || tolerance > 1)) {
253
+ throw new ParseError("compare-renders: --tolerance must be a number from 0 to 1");
254
+ }
255
+ const help = parsed.values.help === true;
256
+ if (!help) {
257
+ for (const name of ["origin", "plan", "workspace"]) {
258
+ if (parsed.values[name] === undefined)
259
+ throw new ParseError(`compare-renders: --${name} is required`);
260
+ }
261
+ }
262
+ return {
263
+ target,
264
+ origin: parsed.values.origin,
265
+ plan: parsed.values.plan,
266
+ workspaceId: parsed.values.workspace,
267
+ locale: parsed.values.locale,
268
+ capture: parsed.values.capture,
269
+ against: parsed.values.against,
270
+ out: parsed.values.out,
271
+ tolerance,
272
+ help,
273
+ };
274
+ }
@@ -39,12 +39,19 @@ export interface MdxAdapterModule {
39
39
  */
40
40
  siteFields?: SiteFieldRules;
41
41
  /**
42
- * The verdict the hub's publish gate will give a live-source page (#10898
43
- * D6), from the site's own contract; `undefined` for a type with no
44
- * registry entry. Absent when the site's validation package predates the
45
- * live-source report.
42
+ * The verdict the hub's publish gate will give a page (#10898 D6, #11843
43
+ * D7), from the site's own contract; `undefined` for a type with no
44
+ * registry entry. Absent when the site's validation package has no content
45
+ * check.
46
46
  */
47
47
  publishCheck?: (type: string, content: Record<string, unknown>, layout: Layout | undefined) => PublishVerdict | undefined;
48
+ /**
49
+ * Whether a page type is laid out in sections (#11793 D7), from the site's
50
+ * own registry and templates (`sectionsRuleOf`); with it, a file of such a
51
+ * type the run would store with no layout fails, naming the reason. Absent
52
+ * when the site's packages cannot say, and the run says so.
53
+ */
54
+ laidOutInSections?: (type: string) => boolean;
48
55
  }
49
56
  /** One issue of the hub's content report, typed structurally. */
50
57
  export interface ContentIssueLike {
@@ -57,7 +64,7 @@ export interface ContentIssueLike {
57
64
  };
58
65
  fixer: string;
59
66
  }
60
- /** Whether publish will take a live-source page, and what its report lists (#10898 D6). */
67
+ /** Whether publish will take a page, and what its report lists (#10898 D6). */
61
68
  export type PublishVerdict = {
62
69
  publishable: true;
63
70
  advisory: ContentIssueLike[];
@@ -94,8 +101,6 @@ export interface ImportMdxOptions {
94
101
  onLine?: (line: string) => void;
95
102
  /** Set Live each written page that has no Live version (#10659 D2); off by default. */
96
103
  publish?: boolean;
97
- /** Send the live-source mark on each page (#10898 D5): migrate-content's import only. */
98
- liveSource?: boolean;
99
104
  }
100
105
  /** The tree a page came from: `content/` or the site's `apps/web/content`. */
101
106
  export type ImportMdxRoot = "content" | "editorial";
@@ -105,7 +110,7 @@ export type ImportMdxOutcome = {
105
110
  result: "created" | "updated" | "unchanged";
106
111
  type: string;
107
112
  slug: string;
108
- /** With `liveSource` and `publishCheck`: what the hub's publish gate will answer (#10898 D6). */
113
+ /** With `publishCheck`: what the hub's publish gate will answer (#10898 D6, #11843 D7). */
109
114
  publishVerdict?: PublishVerdict;
110
115
  /** `updated` with the words already matching the hub: only the layout changed (#11749 D5). */
111
116
  layoutOnly?: true;
@@ -184,7 +189,6 @@ export interface PublishCheckMembers {
184
189
  slug: string;
185
190
  body: string;
186
191
  }, structure: unknown) => ContentReportLike;
187
- liveSourceReport: (report: ContentReportLike) => ContentReportLike;
188
192
  templates: Readonly<Record<string, {
189
193
  kind: string;
190
194
  }>>;
@@ -194,14 +198,27 @@ export interface PublishCheckMembers {
194
198
  }[];
195
199
  }
196
200
  /**
197
- * The hub's publish gate over a live-source page, as the site's contract
198
- * reads it: the page's words checked against its type's template and the
199
- * structure publish's repair would build — the layout when the page converts,
200
- * an editorial template's frontmatter quartet, else none — with the
201
- * required-heading findings advisory. Publish repairs every `script` finding,
202
- * so only the rest block.
201
+ * The hub's publish gate over a page, as the site's contract reads it: the
202
+ * page's words checked against its type's template and the structure
203
+ * publish's repair would build — the layout when the page converts, an
204
+ * editorial template's frontmatter quartet, else none. No live-source split
205
+ * is applied: no save keeps the mark (#11843 D7). Publish repairs every
206
+ * `script` finding, so only the rest block.
203
207
  */
204
208
  export declare function publishCheckOf(members: PublishCheckMembers): NonNullable<MdxAdapterModule["publishCheck"]>;
209
+ /**
210
+ * #11793 D7 — the rule `laidOutInSections`: a type is laid out in sections
211
+ * when the site's registry names it and its template's kind is `sections`. A
212
+ * registry entry whose template the site's validation package lacks answers
213
+ * false, never throws, so mismatched site packages never stop the run
214
+ * (SEC-11793-06).
215
+ */
216
+ export declare function sectionsRuleOf(registry: readonly {
217
+ key: string;
218
+ template: string;
219
+ }[], templates: Readonly<Record<string, {
220
+ kind: string;
221
+ }>>): (type: string) => boolean;
205
222
  /**
206
223
  * The site's installed adapter package, resolved from its `apps/web` — never
207
224
  * create-ailk's own `node_modules`.