create-ailk 0.42.0 → 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.
Files changed (26) hide show
  1. package/README.md +22 -0
  2. package/dist/cli.js +34 -0
  3. package/dist/compare-renders.d.ts +67 -0
  4. package/dist/compare-renders.js +274 -0
  5. package/dist/export-content.d.ts +10 -3
  6. package/dist/export-content.js +52 -8
  7. package/dist/lib/import-mdx.d.ts +22 -0
  8. package/dist/lib/import-mdx.js +73 -18
  9. package/dist/lib/render-capture.d.ts +22 -0
  10. package/dist/lib/render-capture.js +125 -0
  11. package/dist/migrate-content.d.ts +12 -3
  12. package/dist/migrate-content.js +65 -12
  13. package/package.json +3 -3
  14. package/site-templates/shapes/local-business-service/content/en/Service/first-job.mdx +49 -26
  15. package/site-templates/shapes/local-business-service/content/en/Service/second-job.mdx +49 -26
  16. package/site-templates/shapes/local-business-service/content/en/Service/third-job.mdx +49 -26
  17. package/site-templates/shapes/organization-service/content/en/Service/first-engagement.mdx +49 -26
  18. package/site-templates/shapes/organization-service/content/en/Service/second-engagement.mdx +49 -26
  19. package/site-templates/shapes/organization-service/content/en/Service/third-engagement.mdx +49 -26
  20. package/site-templates/shapes/person-service/content/en/Service/first-engagement.mdx +49 -26
  21. package/site-templates/shapes/person-service/content/en/Service/second-engagement.mdx +49 -26
  22. package/site-templates/shapes/person-service/content/en/Service/third-engagement.mdx +49 -26
  23. package/templates/apps/api/CLAUDE.md +18 -4
  24. package/templates/apps/mcp/CLAUDE.md +31 -4
  25. package/templates/apps/web/CLAUDE.md +3 -1
  26. package/versions.json +51 -51
@@ -16,8 +16,11 @@
16
16
  * sections — layout and data — go to the structure layer through
17
17
  * `PUT …/structure` under the draft's structure token (#10643), never into the
18
18
  * stored content. An unchanged layout writes nothing, so a re-run still
19
- * reports `unchanged`; a changed layout on a live draft is refused
20
- * `draft_is_live` and the page fails with that reason.
19
+ * reports `unchanged`. A changed layout on a page whose words did not change
20
+ * and whose draft is its live version is refused `draft_is_live`; the
21
+ * importer then saves a draft with the same words under the version it read
22
+ * and sends the layout once more (#11749 D2), so the live page does not change
23
+ * until it is published. A second refusal fails the page with that reason.
21
24
  *
22
25
  * A section string that holds inline HTML is converted first (#10804) — a
23
26
  * link to `[label](href)`, a line break to a newline, a block to a blank
@@ -619,31 +622,49 @@ async function writePage(t, page, locale, content, layout, publicTags) {
619
622
  let live = false;
620
623
  let stored;
621
624
  let sent = false;
622
- const outcome = (result) => ({
623
- outcome: { root, path, result, type, slug },
625
+ const outcome = (result, layoutOnly = false) => ({
626
+ outcome: { root, path, result, type, slug, ...(layoutOnly && { layoutOnly: true }) },
624
627
  live,
625
628
  stored,
626
629
  sent,
627
630
  });
628
631
  // The words are written; now the layout, under the token the draft holds
629
- // (`null` for a page that has none yet).
630
- const done = async (result, structureToken = null) => {
632
+ // (`null` for a page that has none yet). `version` is the read's, given
633
+ // only when the words compared equal and were not saved (#11749 D2).
634
+ const done = async (result, structureToken = null, version) => {
631
635
  if (layout === undefined)
632
636
  return outcome(result);
633
- const put = await call(t, "PUT", `${pagePath}/structure${query}`, {
637
+ const writeLayout = () => call(t, "PUT", `${pagePath}/structure${query}`, {
634
638
  structureToken,
635
639
  structure: layout,
636
640
  });
641
+ let put = await writeLayout();
642
+ // #11749 D2 — the hub refuses a layout on a live tip and names the remedy:
643
+ // save a draft (the same words, under the version read), then write the
644
+ // layout once more. A save carries the structure token forward (§1).
645
+ const redraft = version !== undefined &&
646
+ !("network" in put) &&
647
+ put.status === 409 &&
648
+ put.code === "draft_is_live";
649
+ if (redraft) {
650
+ const saved = await call(t, "PATCH", address, content, version);
651
+ if ("network" in saved || saved.status !== 200)
652
+ return refusedAnswer(page, saved);
653
+ stored = saved.data["content"];
654
+ sent = true;
655
+ const mismatch = wrongLocale(page, saved, locale);
656
+ if (mismatch !== undefined)
657
+ return mismatch;
658
+ put = await writeLayout();
659
+ }
637
660
  if ("network" in put || put.status !== 200)
638
661
  return refusedAnswer(page, put);
662
+ // #10804 D6 — with no token the hub writes the layout (or refuses a
663
+ // live tip), so a dry run's `written: false` never makes it unchanged.
664
+ const layoutOnly = result === "unchanged" &&
665
+ (redraft || structureToken === null || put.data["written"] === true);
639
666
  return (wrongLocale(page, put, locale) ??
640
- outcome(
641
- // #10804 D6 — with no token the hub writes the layout (or refuses a
642
- // live tip), so a dry run's `written: false` never makes it unchanged.
643
- result === "unchanged" &&
644
- (structureToken === null || put.data["written"] === true)
645
- ? "updated"
646
- : result));
667
+ outcome(layoutOnly ? "updated" : result, layoutOnly));
647
668
  };
648
669
  for (let reread = false;; reread = true) {
649
670
  const read = await call(t, "GET", address);
@@ -664,7 +685,7 @@ async function writePage(t, page, locale, content, layout, publicTags) {
664
685
  const liveTip = read.data["status"] === "published";
665
686
  if (canonical(compared(liveTip ? withoutHubRecords(stored) : stored, content, publicTags)) ===
666
687
  canonical(compared(liveTip ? withoutHubRecords(content) : content, content, publicTags))) {
667
- return done("unchanged", structureToken);
688
+ return done("unchanged", structureToken, version);
668
689
  }
669
690
  // The token is the version just compared against, so a draft saved
670
691
  // since the read is a 409, never a silent overwrite.
@@ -1128,6 +1149,11 @@ export async function importMdx(opts) {
1128
1149
  // first in processing order wins and the rest fail. Two pages of different
1129
1150
  // types may share a slug (#10268 D7): the store addresses by type too.
1130
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
+ }
1131
1157
  let halt;
1132
1158
  let publishRefused;
1133
1159
  let live = 0;
@@ -1188,6 +1214,17 @@ export async function importMdx(opts) {
1188
1214
  fail(converted.reason);
1189
1215
  continue;
1190
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
+ }
1191
1228
  // #10898 D5 — a file never supplies the mark; the importer computes it.
1192
1229
  // #11707 D9 — nor the written-from record: a file is never its source.
1193
1230
  const { [LIVE_SOURCE_KEY]: _fileMark, [WRITTEN_FROM_KEY]: _fileRecord, ...words } = converted.content;
@@ -1204,9 +1241,7 @@ export async function importMdx(opts) {
1204
1241
  if (converted.notCarried.length > 0) {
1205
1242
  onLine(`${outcomePath(page)}: inline HTML not carried — ${converted.notCarried.join(", ")} (the layout holds no HTML; their text is kept)`);
1206
1243
  }
1207
- if (converted.layout === undefined &&
1208
- Array.isArray(source.frontmatter["sections"]) &&
1209
- source.frontmatter["sections"].length > 0) {
1244
+ if (converted.layout === undefined && hasSections) {
1210
1245
  onLine(`${page.path}: keeps its words in sections — the site's ${VALIDATION_PACKAGE} has no words codec; update its dependencies and re-run`);
1211
1246
  }
1212
1247
  // #10804 D5 — a layout the hub would refuse fails here, in a dry run and
@@ -1329,6 +1364,21 @@ export function publishCheckOf(members) {
1329
1364
  : { publishable: false, status: report.status, blocking };
1330
1365
  };
1331
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
+ }
1332
1382
  // ── The site's own adapter (D1) ─────────────────────────────────────────────
1333
1383
  /** Whether a `node_modules` at or above `dir` holds the adapter package. */
1334
1384
  function installedAbove(dir) {
@@ -1436,6 +1486,11 @@ export async function loadSiteMdxAdapter(siteRoot) {
1436
1486
  registry: registry,
1437
1487
  }),
1438
1488
  }),
1489
+ ...(templates !== null &&
1490
+ typeof templates === "object" &&
1491
+ Array.isArray(registry) && {
1492
+ laidOutInSections: sectionsRuleOf(registry, templates),
1493
+ }),
1439
1494
  ...(typeof matter === "function" && {
1440
1495
  parseFrontmatter: (raw) => {
1441
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;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * A capture of a live page's render, and its replay (#11794 D6, spec
3
+ * docs/specs/11794-convert-the-remaining-heading-form-spec.md).
4
+ *
5
+ * No URL serves a draft, so a heading-form page's "before" is captured from
6
+ * the live site before its converted draft is published, and replayed as the
7
+ * `before` side of the cutover's own `comparePage` afterwards. Both are
8
+ * `ComparisonPage`s, so the comparison is unchanged: `recordingPage` passes
9
+ * every call through to a real page and stores what it answered, and
10
+ * `replayPage` answers from the stored files and never navigates.
11
+ *
12
+ * One capture is `<dir>/<n>-<viewport>/render.json` (the status, the settled
13
+ * URL, the text and the JSON-LD) beside `screenshot.png`, where `n` is the
14
+ * path's place in `<dir>/capture.json`'s `paths`.
15
+ */
16
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
17
+ import { join } from "node:path";
18
+ import { JSONLD_EXPRESSION, TEXT_EXPRESSION, VIEWPORTS } from "./render-comparison.js";
19
+ const RENDER_FILE = "render.json";
20
+ const SCREENSHOT_FILE = "screenshot.png";
21
+ /** The viewport whose width the page was last set to, by name. */
22
+ function viewportOf(width) {
23
+ return VIEWPORTS.find((viewport) => viewport.width === width)?.name ?? String(width);
24
+ }
25
+ /** Where path `path` at `viewport` is stored; `null` for a path the capture does not list. */
26
+ function slot(dir, paths, path, viewport) {
27
+ const n = paths.indexOf(path) + 1;
28
+ return n === 0 ? null : join(dir, `${n}-${viewport}`);
29
+ }
30
+ /** `url`'s path on `origin`, or `null` when it is on another origin. */
31
+ function pathOn(origin, url) {
32
+ const parsed = new URL(url);
33
+ return parsed.origin === new URL(origin).origin ? parsed.pathname : null;
34
+ }
35
+ /**
36
+ * A page that passes every call through to `page` and stores, for each of
37
+ * `paths` on `origin` at each viewport, what it answered. It writes nowhere
38
+ * but under `dir`, and renders nothing it is not asked to.
39
+ */
40
+ export function recordingPage(page, o) {
41
+ let viewport = VIEWPORTS[0].name;
42
+ let at = null;
43
+ let stored = null;
44
+ const save = () => {
45
+ if (at === null || stored === null)
46
+ return;
47
+ mkdirSync(at, { recursive: true });
48
+ writeFileSync(join(at, RENDER_FILE), `${JSON.stringify(stored, null, 2)}\n`);
49
+ };
50
+ return {
51
+ async setViewportSize(size) {
52
+ viewport = viewportOf(size.width);
53
+ await page.setViewportSize(size);
54
+ },
55
+ async goto(url, options) {
56
+ const path = pathOn(o.origin, url);
57
+ at = path === null ? null : slot(o.dir, o.paths, path, viewport);
58
+ // A re-capture never leaves an earlier run's files for the replay to read.
59
+ if (at !== null)
60
+ rmSync(at, { recursive: true, force: true });
61
+ const response = await page.goto(url, options);
62
+ stored = { status: response?.status() ?? null, url: page.url() };
63
+ save();
64
+ return response;
65
+ },
66
+ url: () => page.url(),
67
+ async evaluate(expression) {
68
+ const answer = await page.evaluate(expression);
69
+ if (stored !== null && expression === TEXT_EXPRESSION)
70
+ stored.text = answer;
71
+ if (stored !== null && expression === JSONLD_EXPRESSION)
72
+ stored.jsonLd = answer;
73
+ save();
74
+ return answer;
75
+ },
76
+ async screenshot(options) {
77
+ const png = await page.screenshot(options);
78
+ if (at !== null)
79
+ writeFileSync(join(at, SCREENSHOT_FILE), png);
80
+ return png;
81
+ },
82
+ };
83
+ }
84
+ /**
85
+ * A page that answers from a capture under `dir` and never navigates. A path
86
+ * the capture does not list, or a capture missing its render or its
87
+ * screenshot, fails that render, so the comparison fails rather than
88
+ * comparing against nothing.
89
+ */
90
+ export function replayPage(o) {
91
+ let viewport = VIEWPORTS[0].name;
92
+ let at = null;
93
+ let stored = null;
94
+ return {
95
+ async setViewportSize(size) {
96
+ viewport = viewportOf(size.width);
97
+ },
98
+ async goto(url) {
99
+ const path = pathOn(o.origin, url);
100
+ at = path === null ? null : slot(o.dir, o.paths, path, viewport);
101
+ stored = null;
102
+ if (at === null || !existsSync(join(at, RENDER_FILE))) {
103
+ throw new Error(`no capture of ${path ?? url} at ${viewport}`);
104
+ }
105
+ if (!existsSync(join(at, SCREENSHOT_FILE)))
106
+ throw new Error(`the capture of ${path} at ${viewport} has no screenshot`);
107
+ stored = JSON.parse(readFileSync(join(at, RENDER_FILE), "utf8"));
108
+ const status = stored.status;
109
+ return status === null ? null : { status: () => status };
110
+ },
111
+ url: () => stored?.url ?? "about:blank",
112
+ async evaluate(expression) {
113
+ if (expression === TEXT_EXPRESSION)
114
+ return stored?.text;
115
+ if (expression === JSONLD_EXPRESSION)
116
+ return stored?.jsonLd;
117
+ return undefined;
118
+ },
119
+ async screenshot() {
120
+ if (at === null)
121
+ throw new Error("replay: no page");
122
+ return readFileSync(join(at, SCREENSHOT_FILE));
123
+ },
124
+ };
125
+ }
@@ -31,8 +31,17 @@ export interface MigrateContentOptions {
31
31
  * A fetch that sends `GET`s through `inner` and never sends a write: a `POST`
32
32
  * is answered `201` and a `PATCH` `200` locally, with the one member of a
33
33
  * write's answer `importMdx` reads (`data.locale`), and the structure write's
34
- * `PUT` (#10534) `200` as a layout unchanged (`data.written: false`). Any
35
- * other method throws.
34
+ * `PUT` (#10534) `200`. Any other method throws.
35
+ *
36
+ * The `PUT` answers `data.written` from the layout the hub's draft read
37
+ * returned (#11749 D4): each 200 `GET`'s `data.structure` is kept per page
38
+ * address, and a `PUT` to that address's `/structure` URL answers
39
+ * `written: true` when its body's `structure` is not `isDeepStrictEqual` to
40
+ * it — the hub's own comparison. Any other `PUT` (an equal layout, an address
41
+ * never read, a read with no `structure` member, no string body, a `Request`
42
+ * input) answers `written: false`. It never answers 409: a live tip with a
43
+ * changed layout is planned `update`, what `--apply` reports after its
44
+ * re-draft. The memory lasts one run, as the transport does.
36
45
  */
37
46
  export declare function readOnlyFetch(inner: typeof globalThis.fetch, locale: string): typeof globalThis.fetch;
38
47
  /** What a dry run prints when the site's contract cannot give a verdict. */
@@ -51,5 +60,5 @@ export interface MigrateContentArgs {
51
60
  languageSeed: string | undefined;
52
61
  help: boolean;
53
62
  }
54
- export declare const MIGRATE_CONTENT_HELP = "create-ailk migrate-content \u2014 import an existing site's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk migrate-content [<dir>] [--apply] [--api-url <origin>] [--workspace <wksp_id>] [--language-seed <file>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --apply Write the pages. Without it the command reads the\n workspace, prints what it would do, and writes\n nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL. https: only\n (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n --language-seed <file> A Language seed file (language/<entity>.json).\n Each of its topics becomes one Topic holding all\n its keywords. Its items are not read.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page (and each legacy\ncontent/<Type>/<slug>.mdx) is written to the workspace as a draft through\nthe API's content routes, with the agent key, which is read from\nAILK_AGENT_KEY only and needs the content-edit grant. Nothing is published,\nso the live site does not change. The site needs no .ailk-site-manifest.json\nand may be a spoke; its dependencies must be installed. A page whose\nfrontmatter carries sections is converted: its words are written to the\npage's Markdown and its sections to its layout.\n\nEach FAQ item and glossary-index term becomes one Language item of its kind,\nset Live when the run creates it, and its section pins the items in the\norder the file lists them. A question on several pages is one item, with\nthe FAQ page's words (the glossary page's, for a term). Lines prefixed\nlanguage: report each item, and each page the database read will not show\nas its file does. An API with no Language collection leaves them inline.\n\nWith --language-seed, each topic in the seed file is written after the\npages as one Topic: its name, its pillar page, and every keyword with its\nmonthly searches and as-of date, its primary marked. A Topic the workspace\nalready holds keeps its spelling, notes and newer numbers, and gains what it\nlacks. Lines prefixed language: topic/ report each one; a second --apply\nreports every topic unchanged. A seed file that is not readable, or whose\ntopics the hub would refuse, is refused before anything is sent.\n\nWhen the site has apps/web/content, each blog post and docs page in it is\nwritten too: apps/web/content/en/blog/<slug>.mdx (or <slug>/index.mdx) as a\nBlogPosting, or one series down, blog/<series>/<post>.mdx, as a BlogPosting\nwhose parent is the series; the same under docs as a DocsDetail, and each\ndirectory's own index.mdx as its BlogList or DocsList index. A file the walk\nskips is listed with the rule it failed. Their lines are prefixed\neditorial: \u2014 each outcome's root is content or editorial.\n\nA dry run prints create, update, unchanged, skipped or failed per page. It\ncannot see a write the API would refuse at --apply (a conflict or a server\nerror), nor a layout change on a page whose words did not change, and a\npage whose content fails its page type is planned and saved\nwith errors the editor shows, not failed. --apply prints created, updated,\nunchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no\npage failed, 1 when any did, 2 on a refusal (nothing is sent).\n\nEvery page is written with a live-source mark: its words already ship on the\nlive site, so the hub lists a heading the page type's template asks for and\nthe page lacks as advisory, and publish takes the page. Editing the page's\nwords in the hub drops the mark. A dry run prints a publish line after each\npage: publishable, the advisory headings the hub will list, or the status and\nfindings that will stop the publish. The verdict is the site's installed\n@working-theory/validation's, not the hub's; it sees no library-file finding\nand no layout the hub repairs differently. A site whose validation predates\nthe live-source report prints one \"publish: not checked\" line instead.\n";
63
+ export declare const MIGRATE_CONTENT_HELP = "create-ailk migrate-content \u2014 import an existing site's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk migrate-content [<dir>] [--apply] [--api-url <origin>] [--workspace <wksp_id>] [--language-seed <file>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --apply Write the pages. Without it the command reads the\n workspace, prints what it would do, and writes\n nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL. https: only\n (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n --language-seed <file> A Language seed file (language/<entity>.json).\n Each of its topics becomes one Topic holding all\n its keywords. Its items are not read.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page (and each legacy\ncontent/<Type>/<slug>.mdx) is written to the workspace as a draft through\nthe API's content routes, with the agent key, which is read from\nAILK_AGENT_KEY only and needs the content-edit grant. Nothing is published,\nso the live site does not change. The site needs no .ailk-site-manifest.json\nand may be a spoke; its dependencies must be installed. A page whose\nfrontmatter carries sections is converted: its words are written to the\npage's Markdown and its sections to its layout.\n\nEach FAQ item and glossary-index term becomes one Language item of its kind,\nset Live when the run creates it, and its section pins the items in the\norder the file lists them. A question on several pages is one item, with\nthe FAQ page's words (the glossary page's, for a term). Lines prefixed\nlanguage: report each item, and each page the database read will not show\nas its file does. An API with no Language collection leaves them inline.\n\nWith --language-seed, each topic in the seed file is written after the\npages as one Topic: its name, its pillar page, and every keyword with its\nmonthly searches and as-of date, its primary marked. A Topic the workspace\nalready holds keeps its spelling, notes and newer numbers, and gains what it\nlacks. Lines prefixed language: topic/ report each one; a second --apply\nreports every topic unchanged. A seed file that is not readable, or whose\ntopics the hub would refuse, is refused before anything is sent.\n\nWhen the site has apps/web/content, each blog post and docs page in it is\nwritten too: apps/web/content/en/blog/<slug>.mdx (or <slug>/index.mdx) as a\nBlogPosting, or one series down, blog/<series>/<post>.mdx, as a BlogPosting\nwhose parent is the series; the same under docs as a DocsDetail, and each\ndirectory's own index.mdx as its BlogList or DocsList index. A file the walk\nskips is listed with the rule it failed. Their lines are prefixed\neditorial: \u2014 each outcome's root is content or editorial.\n\nA dry run prints create, update, unchanged, skipped or failed per page. It\ncannot see a write the API would refuse at --apply (a conflict or a server\nerror), and a page whose content fails its page type is planned and saved\nwith errors the editor shows, not failed. An update whose words already\nmatch the workspace prints \"update \u2014 layout only\". A layout change to a page\nwhose draft is its live version is saved as a new draft with the same words,\nso the live site does not change until the page is published. --apply prints created, updated,\nunchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no\npage failed, 1 when any did, 2 on a refusal (nothing is sent).\n\nEvery page is written with a live-source mark: its words already ship on the\nlive site, so the hub lists a heading the page type's template asks for and\nthe page lacks as advisory, and publish takes the page. Editing the page's\nwords in the hub drops the mark. A dry run prints a publish line after each\npage: publishable, the advisory headings the hub will list, or the status and\nfindings that will stop the publish. The verdict is the site's installed\n@working-theory/validation's, not the hub's; it sees no library-file finding\nand no layout the hub repairs differently. A site whose validation predates\nthe live-source report prints one \"publish: not checked\" line instead.\n";
55
64
  export declare function parseMigrateContentArgs(argv: string[]): MigrateContentArgs;
@@ -34,7 +34,7 @@
34
34
  */
35
35
  import { readFileSync } from "node:fs";
36
36
  import { join, resolve } from "node:path";
37
- import { parseArgs } from "node:util";
37
+ import { isDeepStrictEqual, parseArgs } from "node:util";
38
38
  import { languageLines, languageOffLine, seedTopics, seedTopicsOf, topicSeedLines, withLanguage, } from "./language-import.js";
39
39
  import { formatImportMdxReport, importMdx, isDirectory, loadSiteMdxAdapter, outcomePath, } from "./lib/import-mdx.js";
40
40
  import { ParseError } from "./parse-args.js";
@@ -63,18 +63,64 @@ function given(value) {
63
63
  * A fetch that sends `GET`s through `inner` and never sends a write: a `POST`
64
64
  * is answered `201` and a `PATCH` `200` locally, with the one member of a
65
65
  * write's answer `importMdx` reads (`data.locale`), and the structure write's
66
- * `PUT` (#10534) `200` as a layout unchanged (`data.written: false`). Any
67
- * other method throws.
66
+ * `PUT` (#10534) `200`. Any other method throws.
67
+ *
68
+ * The `PUT` answers `data.written` from the layout the hub's draft read
69
+ * returned (#11749 D4): each 200 `GET`'s `data.structure` is kept per page
70
+ * address, and a `PUT` to that address's `/structure` URL answers
71
+ * `written: true` when its body's `structure` is not `isDeepStrictEqual` to
72
+ * it — the hub's own comparison. Any other `PUT` (an equal layout, an address
73
+ * never read, a read with no `structure` member, no string body, a `Request`
74
+ * input) answers `written: false`. It never answers 409: a live tip with a
75
+ * changed layout is planned `update`, what `--apply` reports after its
76
+ * re-draft. The memory lasts one run, as the transport does.
68
77
  */
69
78
  export function readOnlyFetch(inner, locale) {
79
+ const layouts = new Map();
80
+ /** Whether the hub would write a dry run's layout `PUT` (#11749 D4). */
81
+ function layoutWritten(input, init) {
82
+ if (input instanceof Request || typeof init?.body !== "string")
83
+ return false;
84
+ const url = String(input);
85
+ const address = url.replace(/\/structure(?=\?|$)/, "");
86
+ if (address === url || !layouts.has(address))
87
+ return false;
88
+ let sent;
89
+ try {
90
+ sent = JSON.parse(init.body)?.structure;
91
+ }
92
+ catch {
93
+ return false;
94
+ }
95
+ return !isDeepStrictEqual(sent, layouts.get(address));
96
+ }
70
97
  return (async (input, init) => {
71
98
  const method = (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
72
- if (method === "GET")
73
- return inner(input, init);
99
+ if (method === "GET") {
100
+ const response = await inner(input, init);
101
+ if (response.status === 200) {
102
+ const url = input instanceof Request ? input.url : String(input);
103
+ try {
104
+ // Parsed here, never by `Response.json()`, so both sides of the
105
+ // comparison are this module's plain objects.
106
+ const data = JSON.parse(await response.clone().text())?.data;
107
+ if (data !== null && typeof data === "object" && "structure" in data) {
108
+ layouts.set(url, data.structure);
109
+ }
110
+ else {
111
+ layouts.delete(url);
112
+ }
113
+ }
114
+ catch {
115
+ // Not JSON: nothing is recorded; the response goes back as it came.
116
+ }
117
+ }
118
+ return response;
119
+ }
74
120
  if (method !== "POST" && method !== "PATCH" && method !== "PUT") {
75
121
  throw new Error(`a dry run sends no ${method} request`);
76
122
  }
77
- const data = method === "PUT" ? { locale, written: false } : { locale };
123
+ const data = method === "PUT" ? { locale, written: layoutWritten(input, init) } : { locale };
78
124
  return new Response(JSON.stringify({ ok: true, data }), {
79
125
  status: method === "POST" ? 201 : 200,
80
126
  headers: { "content-type": "application/json" },
@@ -92,8 +138,11 @@ const PLAN_VERB = {
92
138
  };
93
139
  function planLine(outcome) {
94
140
  const verb = PLAN_VERB[outcome.result];
95
- return "reason" in outcome
96
- ? `${outcomePath(outcome)}: ${verb} — ${outcome.reason}`
141
+ if ("reason" in outcome)
142
+ return `${outcomePath(outcome)}: ${verb} — ${outcome.reason}`;
143
+ // #11749 D5 — an update whose words already match says so.
144
+ return outcome.layoutOnly === true
145
+ ? `${outcomePath(outcome)}: ${verb} — layout only`
97
146
  : `${outcomePath(outcome)}: ${verb}`;
98
147
  }
99
148
  // ── The publish verdict (#10898 D6) ─────────────────────────────────────────
@@ -102,8 +151,10 @@ function issueText(issue, advisory) {
102
151
  const { heading, setting, key } = issue.location;
103
152
  const subject = heading ?? setting ?? key;
104
153
  const quoted = subject === undefined ? "" : ` "${subject}"`;
154
+ // #11792 D6 — a heading finding reads as a word; any other advisory code is named as it is.
155
+ const word = issue.code === "empty-section" ? "empty" : issue.code === "missing-heading" ? "missing" : issue.code;
105
156
  if (advisory)
106
- return `${issue.code === "empty-section" ? "empty" : "missing"}${quoted}`;
157
+ return `${word}${quoted}`;
107
158
  return `${issue.code}:${issue.location.kind}${quoted}`;
108
159
  }
109
160
  function verdictText(verdict) {
@@ -321,9 +372,11 @@ editorial: — each outcome's root is content or editorial.
321
372
 
322
373
  A dry run prints create, update, unchanged, skipped or failed per page. It
323
374
  cannot see a write the API would refuse at --apply (a conflict or a server
324
- error), nor a layout change on a page whose words did not change, and a
325
- page whose content fails its page type is planned and saved
326
- with errors the editor shows, not failed. --apply prints created, updated,
375
+ error), and a page whose content fails its page type is planned and saved
376
+ with errors the editor shows, not failed. An update whose words already
377
+ match the workspace prints "update — layout only". A layout change to a page
378
+ whose draft is its live version is saved as a new draft with the same words,
379
+ so the live site does not change until the page is published. --apply prints created, updated,
327
380
  unchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no
328
381
  page failed, 1 when any did, 2 on a refusal (nothing is sent).
329
382
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ailk",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "tar": "^7.5.21"
29
29
  },
30
30
  "devDependencies": {
31
- "@working-theory/schema": "0.69.0",
32
- "@working-theory/templates": "0.69.0"
31
+ "@working-theory/schema": "0.71.0",
32
+ "@working-theory/templates": "0.71.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
@@ -9,31 +9,54 @@ schema:
9
9
  provider:
10
10
  "@type": Organization
11
11
  name: "Your Company"
12
+ sections:
13
+ [
14
+ {
15
+ "id": "hero",
16
+ "type": "hero",
17
+ "data":
18
+ {
19
+ "headline": "{First job}",
20
+ "subheadline": "{Open with the situation a reader is in when they come looking for this. Two or three sentences, no more — the detail belongs under the headings below.}",
21
+ },
22
+ },
23
+ {
24
+ "id": "what-it-covers",
25
+ "type": "content-block",
26
+ "data":
27
+ {
28
+ "headline": "What it covers",
29
+ "body": "- {The first thing you actually do}\n- {The second thing you actually do}\n- {The third thing you actually do}",
30
+ },
31
+ },
32
+ {
33
+ "id": "how-it-runs",
34
+ "type": "content-block",
35
+ "data":
36
+ {
37
+ "headline": "How it runs",
38
+ "body": "{One paragraph on the shape of the visit: how it is scheduled, how long it takes, who turns up, and what you need from the customer beforehand.}",
39
+ },
40
+ },
41
+ {
42
+ "id": "what-you-end-up-with",
43
+ "type": "content-block",
44
+ "data":
45
+ {
46
+ "headline": "What you end up with",
47
+ "body": "{One paragraph on the result. Be concrete — describe the property when the crew drives away.}",
48
+ },
49
+ },
50
+ {
51
+ "id": "what-it-costs",
52
+ "type": "content-block",
53
+ "data":
54
+ {
55
+ "headline": "What it costs",
56
+ "body": "{One line on the pricing shape — flat rate, hourly, or by the job — and what it excludes. Replace with your real numbers, or delete this section and let a call do it.}",
57
+ },
58
+ },
59
+ ]
12
60
  ---
13
61
 
14
- # \{First job}
15
-
16
- \{Open with the situation a reader is in when they come looking for this. Two or
17
- three sentences, no more — the detail belongs under the headings below.}
18
-
19
- ## What it covers
20
-
21
- - \{The first thing you actually do}
22
- - \{The second thing you actually do}
23
- - \{The third thing you actually do}
24
-
25
- ## How it runs
26
-
27
- \{One paragraph on the shape of the visit: how it is scheduled, how long it
28
- takes, who turns up, and what you need from the customer beforehand.}
29
-
30
- ## What you end up with
31
-
32
- \{One paragraph on the result. Be concrete — describe the property when the
33
- crew drives away.}
34
-
35
- ## What it costs
36
-
37
- \{One line on the pricing shape — flat rate, hourly, or by the job — and what it
38
- excludes. Replace with your real numbers, or delete this section and let a
39
- call do it.}
62
+ {/* Rendered from frontmatter `sections[]`. Placeholder copy — replace every {brace} with your own words before you launch. */}
@@ -9,31 +9,54 @@ schema:
9
9
  provider:
10
10
  "@type": Organization
11
11
  name: "Your Company"
12
+ sections:
13
+ [
14
+ {
15
+ "id": "hero",
16
+ "type": "hero",
17
+ "data":
18
+ {
19
+ "headline": "{Second job}",
20
+ "subheadline": "{Open with the situation a reader is in when they come looking for this. Two or three sentences, no more — the detail belongs under the headings below.}",
21
+ },
22
+ },
23
+ {
24
+ "id": "what-it-covers",
25
+ "type": "content-block",
26
+ "data":
27
+ {
28
+ "headline": "What it covers",
29
+ "body": "- {The first thing you actually do}\n- {The second thing you actually do}\n- {The third thing you actually do}",
30
+ },
31
+ },
32
+ {
33
+ "id": "how-it-runs",
34
+ "type": "content-block",
35
+ "data":
36
+ {
37
+ "headline": "How it runs",
38
+ "body": "{One paragraph on the shape of the visit: how it is scheduled, how long it takes, who turns up, and what you need from the customer beforehand.}",
39
+ },
40
+ },
41
+ {
42
+ "id": "what-you-end-up-with",
43
+ "type": "content-block",
44
+ "data":
45
+ {
46
+ "headline": "What you end up with",
47
+ "body": "{One paragraph on the result. Be concrete — describe the property when the crew drives away.}",
48
+ },
49
+ },
50
+ {
51
+ "id": "what-it-costs",
52
+ "type": "content-block",
53
+ "data":
54
+ {
55
+ "headline": "What it costs",
56
+ "body": "{One line on the pricing shape — flat rate, hourly, or by the job — and what it excludes. Replace with your real numbers, or delete this section and let a call do it.}",
57
+ },
58
+ },
59
+ ]
12
60
  ---
13
61
 
14
- # \{Second job}
15
-
16
- \{Open with the situation a reader is in when they come looking for this. Two or
17
- three sentences, no more — the detail belongs under the headings below.}
18
-
19
- ## What it covers
20
-
21
- - \{The first thing you actually do}
22
- - \{The second thing you actually do}
23
- - \{The third thing you actually do}
24
-
25
- ## How it runs
26
-
27
- \{One paragraph on the shape of the visit: how it is scheduled, how long it
28
- takes, who turns up, and what you need from the customer beforehand.}
29
-
30
- ## What you end up with
31
-
32
- \{One paragraph on the result. Be concrete — describe the property when the
33
- crew drives away.}
34
-
35
- ## What it costs
36
-
37
- \{One line on the pricing shape — flat rate, hourly, or by the job — and what it
38
- excludes. Replace with your real numbers, or delete this section and let a
39
- call do it.}
62
+ {/* Rendered from frontmatter `sections[]`. Placeholder copy — replace every {brace} with your own words before you launch. */}