create-ailk 0.42.1 → 0.43.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.
package/README.md CHANGED
@@ -990,6 +990,28 @@ reads it from, with its words moved back into its sections, so a re-run of
990
990
  `migrate-content` reports every page `unchanged`. The full sequence, the
991
991
  evidence each step leaves and each step's rollback are in the cutover runbook.
992
992
 
993
+ ### Comparing pages before and after the heading-form conversion
994
+
995
+ The hub's heading-form conversion (#11794) writes each page still in the
996
+ heading form a new draft in the section form, and its plan lists the
997
+ converted Live pages. No URL serves a draft, so `compare-renders` takes the
998
+ "before" over time: capture the live pages before their drafts are published,
999
+ then compare the same URLs after, with the cutover's own comparison (text,
1000
+ JSON-LD and a full-page screenshot at 1440 and 390 wide) and a sweep of every
1001
+ path for a direct 200.
1002
+
1003
+ ```bash
1004
+ create-ailk compare-renders . --origin https://example.com --plan ~/.ailk-heading-form/plan.json --workspace <wksp_id> --capture .heading-form/example/before
1005
+ # … the drafts are written and published (docs/internal/runbooks/heading-form-conversion.md) …
1006
+ create-ailk compare-renders . --origin https://example.com --plan ~/.ailk-heading-form/plan.json --workspace <wksp_id> --against .heading-form/example/before
1007
+ # → .heading-form/example/before/comparison/{comparison.json,comparison.md,shots/}
1008
+ ```
1009
+
1010
+ It compares the workspace's live, converted rows in `--locale` (default `en`)
1011
+ that have a path, and lists every other live row as not compared. It needs
1012
+ Playwright's Chromium in the site, as `cutover` does. It exits 1 when a page
1013
+ differs or a URL is not 200, and 2 on a refusal.
1014
+
993
1015
  ### A spoke's declared environment
994
1016
 
995
1017
  A spoke scaffold's `pnpm preflight` and CI run `pnpm env:declared`: every
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
+ }
@@ -45,6 +45,13 @@ export interface MdxAdapterModule {
45
45
  * live-source report.
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 {
@@ -202,6 +209,19 @@ export interface PublishCheckMembers {
202
209
  * so only the rest block.
203
210
  */
204
211
  export declare function publishCheckOf(members: PublishCheckMembers): NonNullable<MdxAdapterModule["publishCheck"]>;
212
+ /**
213
+ * #11793 D7 — the rule `laidOutInSections`: a type is laid out in sections
214
+ * when the site's registry names it and its template's kind is `sections`. A
215
+ * registry entry whose template the site's validation package lacks answers
216
+ * false, never throws, so mismatched site packages never stop the run
217
+ * (SEC-11793-06).
218
+ */
219
+ export declare function sectionsRuleOf(registry: readonly {
220
+ key: string;
221
+ template: string;
222
+ }[], templates: Readonly<Record<string, {
223
+ kind: string;
224
+ }>>): (type: string) => boolean;
205
225
  /**
206
226
  * The site's installed adapter package, resolved from its `apps/web` — never
207
227
  * create-ailk's own `node_modules`.
@@ -1149,6 +1149,11 @@ export async function importMdx(opts) {
1149
1149
  // first in processing order wins and the rest fail. Two pages of different
1150
1150
  // types may share a slug (#10268 D7): the store addresses by type too.
1151
1151
  const addresses = new Map();
1152
+ // #11793 D7 (Q7) — an older site's packages cannot say which types are laid
1153
+ // out in sections, so its pages without sections are written as read.
1154
+ if (opts.adapters.laidOutInSections === undefined) {
1155
+ onLine("import-mdx: the site's packages cannot say which page types are laid out in sections; pages without sections were written as read");
1156
+ }
1152
1157
  let halt;
1153
1158
  let publishRefused;
1154
1159
  let live = 0;
@@ -1209,6 +1214,17 @@ export async function importMdx(opts) {
1209
1214
  fail(converted.reason);
1210
1215
  continue;
1211
1216
  }
1217
+ const authored = source.frontmatter["sections"];
1218
+ const hasSections = Array.isArray(authored) && authored.length > 0;
1219
+ // #11793 D7 — a page laid out in sections is never stored with no layout:
1220
+ // it fails here, naming why, before anything is sent for it.
1221
+ if (converted.layout === undefined &&
1222
+ opts.adapters.laidOutInSections?.(page.type) === true) {
1223
+ fail(hasSections
1224
+ ? `sections: the site's ${VALIDATION_PACKAGE} has no words codec — update its dependencies and re-run`
1225
+ : `sections: a ${page.type} page is laid out in sections, and this file has none — move its words into frontmatter sections`);
1226
+ continue;
1227
+ }
1212
1228
  // #10898 D5 — a file never supplies the mark; the importer computes it.
1213
1229
  // #11707 D9 — nor the written-from record: a file is never its source.
1214
1230
  const { [LIVE_SOURCE_KEY]: _fileMark, [WRITTEN_FROM_KEY]: _fileRecord, ...words } = converted.content;
@@ -1225,9 +1241,7 @@ export async function importMdx(opts) {
1225
1241
  if (converted.notCarried.length > 0) {
1226
1242
  onLine(`${outcomePath(page)}: inline HTML not carried — ${converted.notCarried.join(", ")} (the layout holds no HTML; their text is kept)`);
1227
1243
  }
1228
- if (converted.layout === undefined &&
1229
- Array.isArray(source.frontmatter["sections"]) &&
1230
- source.frontmatter["sections"].length > 0) {
1244
+ if (converted.layout === undefined && hasSections) {
1231
1245
  onLine(`${page.path}: keeps its words in sections — the site's ${VALIDATION_PACKAGE} has no words codec; update its dependencies and re-run`);
1232
1246
  }
1233
1247
  // #10804 D5 — a layout the hub would refuse fails here, in a dry run and
@@ -1350,6 +1364,21 @@ export function publishCheckOf(members) {
1350
1364
  : { publishable: false, status: report.status, blocking };
1351
1365
  };
1352
1366
  }
1367
+ /**
1368
+ * #11793 D7 — the rule `laidOutInSections`: a type is laid out in sections
1369
+ * when the site's registry names it and its template's kind is `sections`. A
1370
+ * registry entry whose template the site's validation package lacks answers
1371
+ * false, never throws, so mismatched site packages never stop the run
1372
+ * (SEC-11793-06).
1373
+ */
1374
+ export function sectionsRuleOf(registry, templates) {
1375
+ return (type) => {
1376
+ const template = registry.find((entry) => entry?.key === type)?.template;
1377
+ return (typeof template === "string" &&
1378
+ Object.hasOwn(templates, template) &&
1379
+ templates[template]?.kind === "sections");
1380
+ };
1381
+ }
1353
1382
  // ── The site's own adapter (D1) ─────────────────────────────────────────────
1354
1383
  /** Whether a `node_modules` at or above `dir` holds the adapter package. */
1355
1384
  function installedAbove(dir) {
@@ -1457,6 +1486,11 @@ export async function loadSiteMdxAdapter(siteRoot) {
1457
1486
  registry: registry,
1458
1487
  }),
1459
1488
  }),
1489
+ ...(templates !== null &&
1490
+ typeof templates === "object" &&
1491
+ Array.isArray(registry) && {
1492
+ laidOutInSections: sectionsRuleOf(registry, templates),
1493
+ }),
1460
1494
  ...(typeof matter === "function" && {
1461
1495
  parseFrontmatter: (raw) => {
1462
1496
  const { data, content } = matter(raw);
@@ -0,0 +1,22 @@
1
+ import { type ComparisonPage } from "./render-comparison.js";
2
+ /**
3
+ * A page that passes every call through to `page` and stores, for each of
4
+ * `paths` on `origin` at each viewport, what it answered. It writes nowhere
5
+ * but under `dir`, and renders nothing it is not asked to.
6
+ */
7
+ export declare function recordingPage(page: ComparisonPage, o: {
8
+ dir: string;
9
+ origin: string;
10
+ paths: readonly string[];
11
+ }): ComparisonPage;
12
+ /**
13
+ * A page that answers from a capture under `dir` and never navigates. A path
14
+ * the capture does not list, or a capture missing its render or its
15
+ * screenshot, fails that render, so the comparison fails rather than
16
+ * comparing against nothing.
17
+ */
18
+ export declare function replayPage(o: {
19
+ dir: string;
20
+ origin: string;
21
+ paths: readonly string[];
22
+ }): ComparisonPage;