create-ailk 0.40.3 → 0.42.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 (45) hide show
  1. package/README.md +31 -1
  2. package/component-catalog.json +6 -0
  3. package/dist/add-route.d.ts +2 -6
  4. package/dist/add-route.js +2 -43
  5. package/dist/export-content.js +11 -3
  6. package/dist/language-import.js +5 -2
  7. package/dist/lib/env-catalog.js +5 -1
  8. package/dist/lib/import-mdx.js +10 -7
  9. package/dist/magnet-page.d.ts +36 -0
  10. package/dist/magnet-page.js +70 -0
  11. package/dist/module-architecture.js +14 -48
  12. package/dist/routes.d.ts +44 -2
  13. package/dist/routes.js +766 -33
  14. package/dist/surfaces.d.ts +18 -2
  15. package/dist/surfaces.js +85 -21
  16. package/dist/topology.js +0 -1
  17. package/dist/update.d.ts +16 -1
  18. package/dist/update.js +273 -7
  19. package/package.json +3 -3
  20. package/templates/.claude/hooks/template-guard.sh +145 -36
  21. package/templates/CLAUDE.md +1 -1
  22. package/templates/apps/api/.env.example +2 -1
  23. package/templates/apps/api/CLAUDE.md +1 -0
  24. package/templates/apps/mcp/CLAUDE.md +5 -3
  25. package/templates/apps/web/.env.example +5 -6
  26. package/templates/apps/web/CLAUDE.md +41 -7
  27. package/templates/apps/web/app/[locale]/layout.tsx +6 -3
  28. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +37 -1
  29. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +28 -0
  30. package/templates/apps/web/lib/__tests__/deck-page.test.ts +17 -0
  31. package/templates/apps/web/lib/__tests__/magnet-routes.test.ts +1 -0
  32. package/templates/apps/web/lib/__tests__/page-chrome.test.ts +42 -0
  33. package/templates/apps/web/lib/__tests__/route-paths.test.ts +57 -0
  34. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +22 -7
  35. package/templates/apps/web/lib/deck-page.ts +20 -1
  36. package/templates/apps/web/lib/mcp-oauth.ts +14 -10
  37. package/templates/apps/web/lib/page-chrome.ts +11 -5
  38. package/templates/apps/web/lib/route-paths.ts +22 -0
  39. package/templates/apps/web/lib/services-path.ts +27 -18
  40. package/templates/apps/web/messages/en.json +0 -9
  41. package/templates/apps/web/middleware.ts +2 -1
  42. package/templates/apps/web/next.config.mjs +123 -2
  43. package/templates/apps/web/src/lib/routes.ts +4 -2
  44. package/versions.json +50 -50
  45. package/templates/apps/web/lib/deliverable-grant.ts +0 -18
package/README.md CHANGED
@@ -398,7 +398,7 @@ every such package:
398
398
  ```bash
399
399
  # write the generated files (run after `pnpm install` — the manifests are read from the installed packages)
400
400
  create-ailk routes --write ./my-site
401
- # check them — exit 1 naming each missing, stale or stray file; the scaffold's preflight runs this as `pnpm routes:check`
401
+ # check them — exit 1 naming each missing, stale, stray or undecided file; the scaffold's preflight runs this as `pnpm routes:check`
402
402
  create-ailk routes --check ./my-site
403
403
  ```
404
404
 
@@ -484,6 +484,36 @@ re-creates it. A replaced page stops receiving upgrades, visibly, as one
484
484
  recorded file. There is no command that copies a shipped page's source into
485
485
  a site.
486
486
 
487
+ **Every other page is a decided one.** A routing file under
488
+ `app/[locale]/` that no installed page package generated is a **site page**
489
+ unless the template shipped it (a `.ailk-template-files.json` key or an
490
+ `architecture.yaml` `customizations.scaffold_paths` match) or
491
+ `add-route magnet` wrote it byte for byte. A site page, and a replaced or
492
+ removed package route, needs a **decided** `customizations.yaml` entry —
493
+ `build-in: site — <decider>, <YYYY-MM-DD>, <reason>` or `build-in: ailk#<N>`.
494
+ `--check` fails each one with no entry, or whose entry is `undecided`
495
+ (`undecided_ok_until` does not apply to a page), and lists a decided one as
496
+ `kept by the site (decided)`:
497
+
498
+ ```text
499
+ undecided: apps/web/app/[locale]/talk-to-sam/page.tsx — no customizations.yaml entry → regenerate it: `create-ailk add-route magnet --path /talk-to-sam --flow talk-to-sam`
500
+ stray: apps/web/app/[locale]/meet/intro/page.tsx → @working-theory/ui-scheduling's meet/[slug]/page.tsx serves this address (from a content file) — delete this file, then run `create-ailk routes --write`
501
+ ```
502
+
503
+ Each reported `page.tsx` names what already serves its address: the
504
+ `add-route magnet` command for a magnet page (one whose renderer is a
505
+ site-local copy, or that was edited, included), else the installed package
506
+ page whose route matches it — a static match before a dynamic one. Before you
507
+ add a page, look up its page type and the package route that serves it, and
508
+ use that package page when it exists. Otherwise record the decision in
509
+ customizations.yaml (build-in: site — <decider>, <YYYY-MM-DD>, <reason>)
510
+ before you write the file. The scaffold's `template-guard.sh` hook refuses a
511
+ new routing file with no decided entry. A site with no
512
+ `.ailk-template-files.json` cannot tell a template page from a site page, so
513
+ pages outside every prefix are not checked and the report prints
514
+ `site pages not checked`. `create-ailk update` lists each page the check
515
+ fails on under **Needs review**, so a consumer's bump PR carries the list.
516
+
487
517
  **Where it runs.** At scaffold time after `--install` (a scaffold without
488
518
  `--install` names the command in its next steps), and inside `create-ailk
489
519
  update` after the pins move (below). The scaffold's `preflight` script runs
@@ -6412,6 +6412,9 @@
6412
6412
  "items": {
6413
6413
  "type": "string"
6414
6414
  }
6415
+ },
6416
+ "namedOnly": {
6417
+ "type": "boolean"
6415
6418
  }
6416
6419
  }
6417
6420
  },
@@ -10336,6 +10339,9 @@
10336
10339
  "items": {
10337
10340
  "type": "string"
10338
10341
  }
10342
+ },
10343
+ "namedOnly": {
10344
+ "type": "boolean"
10339
10345
  }
10340
10346
  },
10341
10347
  "required": [
@@ -1,4 +1,5 @@
1
1
  import { type InstallReportRow } from "./lib/extract-module-bundle.js";
2
+ import { MAGNET_PAGE_MARKER } from "./magnet-page.js";
2
3
  import type { MarkerMap, WorkspaceVersionMap } from "./substitute.js";
3
4
  import { type SyncRoutesResult } from "./sync-routes.js";
4
5
  /** A refusal the CLI exits 2 on, thrown before anything is written. */
@@ -47,12 +48,7 @@ export declare function addRouteToScaffold(opts: AddRouteOptions): AddRouteResul
47
48
  export declare function formatAddRouteReport(result: AddRouteResult): string;
48
49
  /** The route word that selects the magnet mode. */
49
50
  export declare const MAGNET_ROUTE = "magnet";
50
- /**
51
- * The header-comment marker every standard magnet page carries — the same
52
- * string the package's `flows/[slug]/magnet-page.tsx` exports, which the site's
53
- * `structured-data.test.tsx` reads to exempt the pair (#8840 D13).
54
- */
55
- export declare const MAGNET_PAGE_MARKER = "Standard magnet page (#8840)";
51
+ export { MAGNET_PAGE_MARKER };
56
52
  /** Whether `slug` passes `flowSlugSchema`'s rule. */
57
53
  export declare function isMagnetFlowSlug(slug: string): boolean;
58
54
  export interface AddMagnetOptions {
package/dist/add-route.js CHANGED
@@ -47,6 +47,7 @@ import { deriveArchitecture } from "./derive-architecture.js";
47
47
  import { appendEnvRows } from "./lib/declared-env.js";
48
48
  import { ENV_CATALOG } from "./lib/env-catalog.js";
49
49
  import { diffTwoStrings, } from "./lib/extract-module-bundle.js";
50
+ import { MAGNET_PAGE_MARKER, renderMagnetPage } from "./magnet-page.js";
50
51
  import { ParseError } from "./parse-args.js";
51
52
  import { RoutesRefusedError, writeRoutes } from "./routes.js";
52
53
  import { substituteMarkers } from "./substitute.js";
@@ -325,12 +326,7 @@ export function formatAddRouteReport(result) {
325
326
  // ── add-route magnet (#8840 D12) ───────────────────────────────────────────
326
327
  /** The route word that selects the magnet mode. */
327
328
  export const MAGNET_ROUTE = "magnet";
328
- /**
329
- * The header-comment marker every standard magnet page carries — the same
330
- * string the package's `flows/[slug]/magnet-page.tsx` exports, which the site's
331
- * `structured-data.test.tsx` reads to exempt the pair (#8840 D13).
332
- */
333
- export const MAGNET_PAGE_MARKER = "Standard magnet page (#8840)";
329
+ export { MAGNET_PAGE_MARKER };
334
330
  /** The module whose renderers and flow routes a magnet pair mounts. */
335
331
  const MAGNET_MODULE = "signal-collectors";
336
332
  /**
@@ -539,43 +535,6 @@ function staticPageServing(targetAbs, dirs, { ownPages }) {
539
535
  };
540
536
  return walk(root);
541
537
  }
542
- /**
543
- * The renderer's package subpath (#11251 D7), interpolated into the emitted
544
- * import so create-ailk's own dist carries no `@working-theory/*` import
545
- * statement (#8412).
546
- */
547
- const MAGNET_RENDERER = "@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page";
548
- /**
549
- * One page of the pair, importing the renderer from its package subpath,
550
- * `@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page`
551
- * (#11251 D7). Every interpolated value has passed `MAGNET_PATH_RE` or
552
- * `FLOW_SLUG_RE`, so none can leave its string literal (SEC-8840-V5).
553
- */
554
- function renderMagnetPage(kind, path, flow) {
555
- const [page, metadata, role] = kind === "landing"
556
- ? [
557
- "magnetLanding",
558
- "magnetLandingMetadata",
559
- `the landing of the ${path} magnet pair, its copy from the ${flow} flow's record`,
560
- ]
561
- : [
562
- "magnetStart",
563
- "magnetStartMetadata",
564
- `the walk of the ${path} magnet pair, its back arrow to ${path}`,
565
- ];
566
- return [
567
- `// Generated by \`create-ailk add-route magnet --path ${path} --flow ${flow}\`.`,
568
- `// ${MAGNET_PAGE_MARKER} — ${role}.`,
569
- `import { ${page}, ${metadata} } from "${MAGNET_RENDERER}";`,
570
- "",
571
- `const MAGNET = { slug: "${flow}", path: "${path}" } as const;`,
572
- "",
573
- 'export const dynamic = "force-dynamic";',
574
- `export const generateMetadata = ${metadata}(MAGNET);`,
575
- `export default ${page}(MAGNET);`,
576
- "",
577
- ].join("\n");
578
- }
579
538
  /** The report `add-route magnet` prints. */
580
539
  export function formatAddMagnetReport(result) {
581
540
  const written = result.report.filter((row) => row.action === "written");
@@ -54,11 +54,19 @@ const EDITORIAL_RENAMES = { publishedAt: "date", updatedAt: "updated" };
54
54
  const EDITORIAL_DROPPED = new Set(["type", "slug"]);
55
55
  /** The hub's live-source mark (#10898 D7): evidence about the draft's words, never a file's key. */
56
56
  const LIVE_SOURCE_KEY = "liveSource";
57
+ /**
58
+ * The hub's written-from record (#11707 D9, `WRITTEN_FROM_KEY` in
59
+ * api-content-write `content.ts`, restated: no runtime dep): what the words
60
+ * were written from, never a file's key — dropped here too, for a hub that
61
+ * still answers it in the draft's content.
62
+ */
63
+ const WRITTEN_FROM_KEY = "writtenFrom";
57
64
  /**
58
65
  * Never written from `siteFields` (#10806 D6): a mapped fumadocs key, an
59
- * address key, the strip marker, the live-source mark, or a prototype name.
66
+ * address key, the strip marker, the live-source mark, the written-from
67
+ * record, or a prototype name.
60
68
  */
61
- const NOT_SITE_FIELDS = new Set(["date", "updated", "type", "slug", "oss", "siteFields", LIVE_SOURCE_KEY, "__proto__"]);
69
+ const NOT_SITE_FIELDS = new Set(["date", "updated", "type", "slug", "oss", "siteFields", LIVE_SOURCE_KEY, WRITTEN_FROM_KEY, "__proto__"]);
62
70
  const INDEX_SLUG = "index";
63
71
  /** The store's address shapes, restated (create-ailk has no runtime dep): a path built from them stays in the site. */
64
72
  const TYPE_SHAPE = /^[A-Z][A-Za-z]*$/;
@@ -103,7 +111,7 @@ export function recombine(content, sections, codec, editorial, pinned) {
103
111
  const frontmatter = {};
104
112
  const { siteFields, ...stored } = rest;
105
113
  for (const [key, value] of Object.entries(editorial ? stored : rest)) {
106
- if (key === LIVE_SOURCE_KEY || (editorial && EDITORIAL_DROPPED.has(key)))
114
+ if (key === LIVE_SOURCE_KEY || key === WRITTEN_FROM_KEY || (editorial && EDITORIAL_DROPPED.has(key)))
107
115
  continue;
108
116
  frontmatter[editorial ? (EDITORIAL_RENAMES[key] ?? key) : key] = value;
109
117
  }
@@ -319,16 +319,19 @@ export function withLanguage(adapters, options) {
319
319
  // `GlossaryIndexDataSchema` requires `terms`, so a pinned glossary-index carries `[]`.
320
320
  rewritten.push({ ...rest, data: { ...kept, ...(kind === "term" && { terms: [] }), pinned: pins } });
321
321
  }
322
+ const dataOf = (s) => s.data ?? {};
322
323
  for (const kind of ["faq", "term"]) {
323
324
  if (type !== HOME_TYPE[kind])
324
325
  continue;
325
326
  const own = rewritten.filter((s) => s.type === SECTION_TYPE[kind]);
326
327
  if (own.length === 0)
327
328
  continue;
329
+ // An opted-out page takes no other Live item, so it has no top-ups (#11738 D4).
330
+ if (own.some((s) => dataOf(s)["namedOnly"] === true))
331
+ continue;
328
332
  const shown = new Set();
329
333
  for (const s of own) {
330
- const data = s.data ?? {};
331
- for (const pin of data["pinned"] ?? [])
334
+ for (const pin of dataOf(s)["pinned"] ?? [])
332
335
  shown.add(pin);
333
336
  }
334
337
  homes.push({ kind, slug, shown });
@@ -195,6 +195,10 @@ export const ENV_CATALOG = {
195
195
  description: "The services' public base, baked at build from content/_site.mdx's services.path; do not set by hand.",
196
196
  secret: false,
197
197
  },
198
+ NEXT_PUBLIC_AILK_ROUTE_PATHS: {
199
+ description: "The route family renames, baked at build from content/_site.mdx's route family paths; do not set by hand.",
200
+ secret: false,
201
+ },
198
202
  NEXT_PUBLIC_AILK_LISTING_SITE_KEY: {
199
203
  description: "The site's public listing key, inlined at build; it switches the listicle directory on. Public by design.",
200
204
  secret: false,
@@ -232,7 +236,7 @@ export const ENV_CATALOG = {
232
236
  secret: false,
233
237
  },
234
238
  OSS_API_INTERNAL_SECRET: {
235
- description: "Shared secret the /dev/purchase action sends to the API's checkout route; must equal the API's value. Server-only.",
239
+ description: "Shared secret the Offerings buy route (/api/offerings/checkout/<lookupKey>) sends to the API's checkout route; must equal the API's value. Server-only.",
236
240
  secret: true,
237
241
  },
238
242
  SENTRY_AUTH_TOKEN: {
@@ -79,6 +79,8 @@ const FRONTMATTER_PACKAGE = "gray-matter";
79
79
  const PAGE_TYPES_PACKAGE = "@working-theory/schema/page-types";
80
80
  /** The hub's live-source content key (`LIVE_SOURCE_KEY`, api-content-write `content.ts`), restated: no runtime dep. */
81
81
  const LIVE_SOURCE_KEY = "liveSource";
82
+ /** The hub's written-from record (`WRITTEN_FROM_KEY`, same file), restated: never taken from a file (#11707 D9). */
83
+ const WRITTEN_FROM_KEY = "writtenFrom";
82
84
  /** `EDITORIAL_FIELDS` (api-content-write `derive-publish.ts`): the editorial structure publish's repair builds. */
83
85
  const EDITORIAL_STRUCTURE_FIELDS = ["author", "tags", "order", "parent"];
84
86
  /** The adapter's locale shape (`BCP47_RE` in its `mdx/adapter.ts`). */
@@ -117,7 +119,7 @@ const EDITORIAL_FIELDS = {
117
119
  sections: "sections",
118
120
  };
119
121
  /** Keys not sent and not reported: the path decides both, and a strip marker. */
120
- const EDITORIAL_IGNORED = new Set(["type", "slug", "oss", LIVE_SOURCE_KEY]);
122
+ const EDITORIAL_IGNORED = new Set(["type", "slug", "oss", LIVE_SOURCE_KEY, WRITTEN_FROM_KEY]);
121
123
  /** Why a key is not sent (#10806 D4); `siteFieldRefusal`'s own reasons are the rest. */
122
124
  const NOT_SENT = {
123
125
  parent: "the path decides a blog post's parent",
@@ -601,11 +603,11 @@ function wrongLocale(at, answer, locale) {
601
603
  }
602
604
  return failed(at, `the API does not serve locale ${locale}`, `not sent: the API does not serve locale ${locale}`);
603
605
  }
604
- /** `value` without the live-source mark. */
605
- function withoutLiveSource(value) {
606
+ /** `value` without the hub's own records: the live-source mark and the written-from record. */
607
+ function withoutHubRecords(value) {
606
608
  if (value === null || typeof value !== "object" || Array.isArray(value))
607
609
  return value;
608
- const { [LIVE_SOURCE_KEY]: _mark, ...rest } = value;
610
+ const { [LIVE_SOURCE_KEY]: _mark, [WRITTEN_FROM_KEY]: _record, ...rest } = value;
609
611
  return rest;
610
612
  }
611
613
  async function writePage(t, page, locale, content, layout, publicTags) {
@@ -660,8 +662,8 @@ async function writePage(t, page, locale, content, layout, publicTags) {
660
662
  stored = read.data["content"];
661
663
  // #10898 D5 — a live tip is never re-drafted for the mark alone.
662
664
  const liveTip = read.data["status"] === "published";
663
- if (canonical(compared(liveTip ? withoutLiveSource(stored) : stored, content, publicTags)) ===
664
- canonical(compared(liveTip ? withoutLiveSource(content) : content, content, publicTags))) {
665
+ if (canonical(compared(liveTip ? withoutHubRecords(stored) : stored, content, publicTags)) ===
666
+ canonical(compared(liveTip ? withoutHubRecords(content) : content, content, publicTags))) {
665
667
  return done("unchanged", structureToken);
666
668
  }
667
669
  // The token is the version just compared against, so a draft saved
@@ -1187,7 +1189,8 @@ export async function importMdx(opts) {
1187
1189
  continue;
1188
1190
  }
1189
1191
  // #10898 D5 — a file never supplies the mark; the importer computes it.
1190
- const { [LIVE_SOURCE_KEY]: _fileMark, ...words } = converted.content;
1192
+ // #11707 D9 — nor the written-from record: a file is never its source.
1193
+ const { [LIVE_SOURCE_KEY]: _fileMark, [WRITTEN_FROM_KEY]: _fileRecord, ...words } = converted.content;
1191
1194
  const body = words["body"];
1192
1195
  converted.content =
1193
1196
  opts.liveSource === true && typeof body === "string"
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The magnet page pair `create-ailk add-route magnet` writes (#8840 D12,
3
+ * #11251 D7), and how `routes --check` recognises one it wrote (#11700 D5).
4
+ *
5
+ * No imports: `add-route.ts` imports `routes.ts`, so the renderer lives here,
6
+ * where both can read it without a cycle.
7
+ */
8
+ /**
9
+ * The header-comment marker every standard magnet page carries — the same
10
+ * string the package's `flows/[slug]/magnet-page.tsx` exports, which the site's
11
+ * `structured-data.test.tsx` reads to exempt the pair (#8840 D13).
12
+ */
13
+ export declare const MAGNET_PAGE_MARKER = "Standard magnet page (#8840)";
14
+ /**
15
+ * The renderer's package subpath (#11251 D7), interpolated into the emitted
16
+ * import so create-ailk's own dist carries no `@working-theory/*` import
17
+ * statement (#8412).
18
+ */
19
+ export declare const MAGNET_RENDERER = "@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page";
20
+ /**
21
+ * One page of the pair, importing the renderer from its package subpath,
22
+ * `@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page`
23
+ * (#11251 D7). Every interpolated value has passed `MAGNET_PATH_RE` or
24
+ * `FLOW_SLUG_RE`, so none can leave its string literal (SEC-8840-V5).
25
+ */
26
+ export declare function renderMagnetPage(kind: "landing" | "walk", path: string, flow: string): string;
27
+ /** Line 1 of a generated magnet page: the exact command that wrote it. */
28
+ export declare const MAGNET_COMMAND_RE: RegExp;
29
+ /**
30
+ * Whether `text`, at `sitePath`, is a page `add-route magnet` wrote and the
31
+ * site has not touched: line 1 names the command, the file sits at that
32
+ * command's landing (`<path>/page.tsx`) or walk (`<path>/start/page.tsx`)
33
+ * under `apps/web/app/[locale]/`, and its bytes are exactly what the command
34
+ * renders. An edited pair, or one importing a site-local renderer, is not.
35
+ */
36
+ export declare function isGeneratedMagnetPage(sitePath: string, text: string): boolean;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The magnet page pair `create-ailk add-route magnet` writes (#8840 D12,
3
+ * #11251 D7), and how `routes --check` recognises one it wrote (#11700 D5).
4
+ *
5
+ * No imports: `add-route.ts` imports `routes.ts`, so the renderer lives here,
6
+ * where both can read it without a cycle.
7
+ */
8
+ /**
9
+ * The header-comment marker every standard magnet page carries — the same
10
+ * string the package's `flows/[slug]/magnet-page.tsx` exports, which the site's
11
+ * `structured-data.test.tsx` reads to exempt the pair (#8840 D13).
12
+ */
13
+ export const MAGNET_PAGE_MARKER = "Standard magnet page (#8840)";
14
+ /**
15
+ * The renderer's package subpath (#11251 D7), interpolated into the emitted
16
+ * import so create-ailk's own dist carries no `@working-theory/*` import
17
+ * statement (#8412).
18
+ */
19
+ export const MAGNET_RENDERER = "@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page";
20
+ /**
21
+ * One page of the pair, importing the renderer from its package subpath,
22
+ * `@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page`
23
+ * (#11251 D7). Every interpolated value has passed `MAGNET_PATH_RE` or
24
+ * `FLOW_SLUG_RE`, so none can leave its string literal (SEC-8840-V5).
25
+ */
26
+ export function renderMagnetPage(kind, path, flow) {
27
+ const [page, metadata, role] = kind === "landing"
28
+ ? [
29
+ "magnetLanding",
30
+ "magnetLandingMetadata",
31
+ `the landing of the ${path} magnet pair, its copy from the ${flow} flow's record`,
32
+ ]
33
+ : [
34
+ "magnetStart",
35
+ "magnetStartMetadata",
36
+ `the walk of the ${path} magnet pair, its back arrow to ${path}`,
37
+ ];
38
+ return [
39
+ `// Generated by \`create-ailk add-route magnet --path ${path} --flow ${flow}\`.`,
40
+ `// ${MAGNET_PAGE_MARKER} — ${role}.`,
41
+ `import { ${page}, ${metadata} } from "${MAGNET_RENDERER}";`,
42
+ "",
43
+ `const MAGNET = { slug: "${flow}", path: "${path}" } as const;`,
44
+ "",
45
+ 'export const dynamic = "force-dynamic";',
46
+ `export const generateMetadata = ${metadata}(MAGNET);`,
47
+ `export default ${page}(MAGNET);`,
48
+ "",
49
+ ].join("\n");
50
+ }
51
+ /** Line 1 of a generated magnet page: the exact command that wrote it. */
52
+ export const MAGNET_COMMAND_RE = /^\/\/ Generated by `create-ailk add-route magnet --path (\S+) --flow (\S+)`\.$/;
53
+ /**
54
+ * Whether `text`, at `sitePath`, is a page `add-route magnet` wrote and the
55
+ * site has not touched: line 1 names the command, the file sits at that
56
+ * command's landing (`<path>/page.tsx`) or walk (`<path>/start/page.tsx`)
57
+ * under `apps/web/app/[locale]/`, and its bytes are exactly what the command
58
+ * renders. An edited pair, or one importing a site-local renderer, is not.
59
+ */
60
+ export function isGeneratedMagnetPage(sitePath, text) {
61
+ const command = MAGNET_COMMAND_RE.exec(text.split("\n", 1)[0] ?? "");
62
+ if (command === null)
63
+ return false;
64
+ const path = command[1];
65
+ const flow = command[2];
66
+ const landing = `apps/web/app/[locale]${path}/page.tsx`;
67
+ const walk = `apps/web/app/[locale]${path}/start/page.tsx`;
68
+ const kind = sitePath === landing ? "landing" : sitePath === walk ? "walk" : undefined;
69
+ return kind !== undefined && text === renderMagnetPage(kind, path, flow);
70
+ }
@@ -1231,7 +1231,8 @@ export const MODULE_SLICES = {
1231
1231
  //
1232
1232
  // the flows route files (generated, #11251) written by `routes --write`;
1233
1233
  // the spoke's `results` entries not carried
1234
- // apps/web/app/[locale]/reports/**, the ReportPage + ReportsList seeds
1234
+ // the package's `reports` route files (generated, #11657), the ReportPage
1235
+ // + ReportsList seeds
1235
1236
  // dropped (`SPOKE_EXCLUDED_MODULE_PATHS`,
1236
1237
  // 2026-10-09): the reader links a report's
1237
1238
  // bytes on the hub through
@@ -1294,49 +1295,18 @@ export const MODULE_SLICES = {
1294
1295
  // `sync-routes.ts`'s `NESTED_FOREIGN_MODULE_ENTRIES` for the companion
1295
1296
  // fix that keeps its presence from falsely reading as "projects carried".
1296
1297
  "apps/web/app/[locale]/projects/apply/ListingApplicationClient.tsx",
1297
- // #8840 D11/D13 — the Job application magnet's two walks. Same kind as
1298
- // `projects/apply` above: they sit under the UNRELATED "careers"
1299
- // surface's URL segment, which `excludedRoutePaths` does not gate on
1300
- // signal-collectors, so `ownedFiles` keeps them out of a keyless
1301
- // scaffold, and `NESTED_FOREIGN_MODULE_ENTRIES` keeps their presence
1302
- // from reading as "careers carried". The renderer they mount is the
1303
- // package's `@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page`
1304
- // (#11251 D7).
1305
- "apps/web/app/[locale]/careers/apply/page.tsx",
1306
- "apps/web/app/[locale]/careers/[slug]/apply/page.tsx",
1307
- // #9287 DD10 — the trial magnet pair. Its own `trial` route segment,
1308
- // which no surface gates, so `ownedFiles` keeps both pages out of a
1309
- // keyless scaffold, beside the careers walks.
1310
- "apps/web/app/[locale]/trial/page.tsx",
1311
- "apps/web/app/[locale]/trial/request/page.tsx",
1298
+ // #11657 — the magnet pages (the Job application walks, the trial
1299
+ // pair, the reports hub, the report reader, its walk and file proxy and
1300
+ // the deliverable renderer) ship in `@working-theory/ui-signal-collectors`;
1301
+ // a site holds only the route files `routes --write` generates from its
1302
+ // manifest, so none is an `ownedFiles` entry. `/downloads` is retired
1303
+ // into routes-map `legacyRoutes` redirects.
1312
1304
  // #5581 U4 — the eleven signal-collectors components + the slice's own
1313
1305
  // re-export entry point moved to packages-paid/ui-signal-collectors;
1314
1306
  // the package is delivered to a keyed scaffold via `patches` below,
1315
1307
  // not via `ownedFiles`/`installMap` (D5).
1316
- // #5562 — the report reader at `/reports/<slug>`. UNLIKE the flow routes
1317
- // above, this one DOES belong in `ownedFiles`, and for the same reason
1318
- // `projects/apply/ListingApplicationClient.tsx` does: `/reports` is a URL
1319
- // segment `MODULE_SURFACES["signal-collectors"] = ["flows"]` does not gate,
1320
- // so `excludedRoutePaths()` would leave it in a keyless scaffold. It has no
1321
- // upgrade-path fixture to protect either — it is net-new here, so nothing
1322
- // in `templates/` can regress by its absence.
1323
- "apps/web/app/[locale]/reports/[slug]/page.tsx",
1324
- // spec 6892 D2 — the /reports hub, alongside its reader above: also a
1325
- // URL segment MODULE_SURFACES["signal-collectors"] does not gate.
1326
- "apps/web/app/[locale]/reports/page.tsx",
1327
- // #8848 D6, D7 — the hub deliverable at `/reports/<slug>`: its renderer,
1328
- // the gated walk and the ungated file's byte proxy. Same segment, same
1329
- // reason as the reader above.
1330
- "apps/web/app/[locale]/reports/deliverable-page.tsx",
1331
- "apps/web/app/[locale]/reports/[slug]/start/page.tsx",
1332
- "apps/web/app/[locale]/reports/[slug]/file/route.ts",
1333
- // #8848 D12 — `/downloads` redirects into `/reports`, so a scaffold
1334
- // without this module ships no `/downloads` at all (the redirect target
1335
- // is this module's) rather than the old broken list.
1336
- "apps/web/app/[locale]/downloads/page.tsx",
1337
- "apps/web/app/[locale]/downloads/[slug]/page.tsx",
1338
1308
  //
1339
- // The two sections that route composes — `report-header` and
1309
+ // The two sections the reports route composes — `report-header` and
1340
1310
  // `reports-list` — are deliberately NOT owned here. They are
1341
1311
  // `SectionRenderer` DISPATCH entries with static imports, so stripping
1342
1312
  // them would leave the renderer with dangling imports in a keyless
@@ -1358,9 +1328,8 @@ export const MODULE_SLICES = {
1358
1328
  { route: "/flows/[slug]" },
1359
1329
  { route: "/flows/[slug]/start" },
1360
1330
  { route: "/flows/[slug]/results/[payload]" },
1361
- // #5562 — the report reader. Unlike the three rows above, this row's
1362
- // code IS this module's own `ownedFiles` (see the note beside it), so
1363
- // the contribution and the delivery shape carrying it agree here. Its
1331
+ // #5562 — the report reader. Like the three rows above, its code ships
1332
+ // in the package and its route file is generated (#11657). Its
1364
1333
  // seeds are SELF-SEEDING (spec 6892 D3): this module's own `installMap`
1365
1334
  // lands the four `ReportPage` samples below, so every template taking
1366
1335
  // the module gets them — `moduleRosterRows` derives the code-route form
@@ -1368,7 +1337,7 @@ export const MODULE_SLICES = {
1368
1337
  { route: "/reports/[slug]", contentDir: "content/en/ReportPage" },
1369
1338
  // #8848 D7's walk (`/reports/[slug]/start`) is NOT a contribution: a
1370
1339
  // contribution needs a shipped template manifest to carry its row, and
1371
- // none does yet. Its code ships through `ownedFiles` above.
1340
+ // none does yet. Its code ships in the package (#11657).
1372
1341
  ],
1373
1342
  // installMap (#5618 D6.3) — the module's sample files, moved here out
1374
1343
  // of `site-templates/marketing-site/` so the module OWNS its samples
@@ -1499,8 +1468,8 @@ export const MODULE_SLICES = {
1499
1468
  // filter (`isSpokeExcluded`), which drops every destination under
1500
1469
  // apps/api or database and the web files that call the hub's own
1501
1470
  // checkout (`SPOKE_HUB_CHECKOUT_SEEDS`: flows/[slug]/checkout.actions.ts,
1502
- // the flow results directory — the results layout among it — and
1503
- // dev/purchase, spoke-intake Rule 3). What lands
1471
+ // the flow results directory — the results layout among it — spoke-intake
1472
+ // Rule 3; `/dev/purchase` is retired, #11657). What lands
1504
1473
  // is the scaffold-commerce skill, the commerce-boundary rule and the
1505
1474
  // @working-theory/ui-commerce dependency (`patches` below). A spoke sells
1506
1475
  // through its hub's Offerings buy route (#9142). The checkout and
@@ -1592,9 +1561,6 @@ export const MODULE_SLICES = {
1592
1561
  // `FlowResultsPriceCard` in `@working-theory/ui-commerce`, which the
1593
1562
  // slot loads through the paid-sections registry. Without commerce the
1594
1563
  // page renders, offering Book a Call for every fit.
1595
- "apps/web/app/[locale]/dev/purchase/page.tsx",
1596
- "apps/web/app/[locale]/dev/purchase/error.tsx",
1597
- "apps/web/app/[locale]/dev/purchase/purchase.actions.ts",
1598
1564
  // #11253 D3, D6 — the checkout and purchase pages' typed config
1599
1565
  // (`defineCommerceConfig`), the host seam the generated route files pass
1600
1566
  // in, and the checkout stamp it reads, which every commerce site now
package/dist/routes.d.ts CHANGED
@@ -46,6 +46,8 @@ export interface RouteManifest {
46
46
  config: string | undefined;
47
47
  /** Routing files under the prefix that stay the site's own pages, never generated. */
48
48
  siteOwned: string[];
49
+ /** Entry paths outside the prefixes that another installed manifest's `siteOwned` names (#11657 D2). */
50
+ adopts: string[];
49
51
  /** The package's message catalog, when it ships one. */
50
52
  messages: ManifestMessages | undefined;
51
53
  /** `false` when each generated file carries the `// oss: false` marker; unset otherwise. */
@@ -81,8 +83,26 @@ export declare const OSS_FALSE_MARKER = "// oss: false";
81
83
  export declare function renderRouteFile(manifest: RouteManifest, entry: RouteEntry): string;
82
84
  /** Whether `text` is a file this generator wrote: its first line (after an `oss: false` marker) is the header. */
83
85
  export declare function isGenerated(text: string): boolean;
86
+ /** The id of the first `customizations:` entry whose paths match, per path; reads the file once (#11511). */
87
+ export declare function customizationsRecord(siteDir: string): (sitePath: string) => string | undefined;
84
88
  /** Whether `<siteDir>/customizations.yaml` records `sitePath` — any entry, any path form or glob (the generator's own reading). */
85
89
  export declare function isRecordedRoute(siteDir: string, sitePath: string): boolean;
90
+ /**
91
+ * The site's route renames (#11385 D6): `content/_site.mdx`'s renamable
92
+ * family paths as `{ <convention segment>: <served segment> }` —
93
+ * `{ meet: "meetings" }`, `{ "case-studies": "work" }`. Throws
94
+ * `RoutesRefusedError`, naming the key and the line, for frontmatter it
95
+ * cannot read with certainty; no file is `{}`.
96
+ */
97
+ export declare function readSiteRouteRenames(siteDir: string): Record<string, string>;
98
+ /**
99
+ * A copy of `@working-theory/templates`' `routeRenameRefusals` (#11385 D7),
100
+ * message for message — `tests/routes/route-renames-parity.test.ts` runs both
101
+ * over one table. `renames` is family-keyed; the served set is
102
+ * `ROUTES_FIRST_SEGMENTS` (the routes map's first segments) plus
103
+ * `extraServed`.
104
+ */
105
+ export declare function routeRenameRefusals(renames: Readonly<Record<string, string>>, conventions: Readonly<Record<string, string>>, reserved: readonly string[], extraServed?: readonly string[]): string[];
86
106
  export interface RecordedRoute {
87
107
  path: string;
88
108
  state: "replaced" | "removed";
@@ -101,6 +121,19 @@ export interface RoutesDrift {
101
121
  orphanedOverrides: string[];
102
122
  /** A site file missing the alias line a `siteSeam` package needs: `<file>: <alias>` (#11257 D4). */
103
123
  seamAliasMissing: string[];
124
+ /** A roster page route the site carries that no page file serves: `<route> → <expected page path>` (#11511). */
125
+ unservedRoster: string[];
126
+ /** Site pages, and recorded package routes, with no decided customizations.yaml entry; `id` names an undecided one (#11700). */
127
+ undecidedPages: Array<{
128
+ path: string;
129
+ id?: string;
130
+ }>;
131
+ /** Site pages outside every prefix that a decided entry keeps (#11700). */
132
+ decidedPages: RecordedRoute[];
133
+ /** For a reported `page.tsx`: the package page or generator that already serves its address (#11700 D6). */
134
+ routeSuggestions: Record<string, string>;
135
+ /** No `.ailk-template-files.json`, so site pages outside every prefix were not checked (#11700 D4). */
136
+ sitePagesUnchecked: boolean;
104
137
  /** The manifest entries in force — recorded ones included, not-carried ones not. */
105
138
  generated: number;
106
139
  }
@@ -111,7 +144,7 @@ export interface RoutesDrift {
111
144
  * site with no readable header carries every surface.
112
145
  */
113
146
  export declare function siteGate(siteDir: string): (sitePath: string) => boolean;
114
- /** The count check mode fails on: missing, stale and stray route files, orphaned overrides and missing seam aliases. */
147
+ /** The count check mode fails on: missing, stale and stray route files, orphaned overrides, missing seam aliases, unserved roster routes and undecided pages. */
115
148
  export declare function routesFailing(drift: RoutesDrift): number;
116
149
  /** How the site's route files and message overrides differ from the installed page packages. `routesFailing` zero means in sync. */
117
150
  export declare function checkRoutes(siteDir: string): RoutesDrift;
@@ -121,6 +154,8 @@ export interface WriteRoutesResult {
121
154
  recorded: RecordedRoute[];
122
155
  /** Routing files at an entry's path that the generator did not write — a site's own handler — left as they are (#11257 D10). */
123
156
  kept: string[];
157
+ /** Generated files deleted from a renamed family's old directory (#11385 D5). */
158
+ removed: string[];
124
159
  }
125
160
  /** Write every generated file that is missing or stale; a recorded route is left exactly as it is. */
126
161
  export declare function writeRoutes(siteDir: string): WriteRoutesResult;
@@ -130,7 +165,14 @@ export interface RoutesArgs {
130
165
  check: boolean;
131
166
  help: boolean;
132
167
  }
133
- export declare const ROUTES_HELP = "create-ailk routes \u2014 generate the route files for the pages a site's packages ship.\n\nUsage:\n create-ailk routes --write [<target-dir>]\n create-ailk routes --check [<target-dir>]\n\nArguments:\n <target-dir> The site root (holds apps/web). Defaults to the\n current dir.\n\nOptions:\n --write Write one generated file per route the installed\n page packages declare, under apps/web/app/[locale]/.\n A file already current is left alone.\n --check Write nothing; exit 1 naming each generated file\n that is missing, stale (differs from what --write\n would write) or stray (a page.tsx, layout.tsx or\n route.ts under a package's route prefix that is\n neither generated, recorded, nor one the package\n leaves to the site). It also names each orphaned\n override: a key in apps/web/messages/<locale>.json\n under a namespace a package's catalog ships that\n the catalog no longer has.\n --help, -h Print this message.\n\nA page package is an installed @working-theory/* dependency of apps/web whose\npackage.json declares \"ailk\": { \"routes\": \"<manifest>\" }. A generated file\nre-exports the package's page and copies its route-segment config; when the\npage takes the site's config it imports the manifest's config file from the\napp root (apps/web/account.config.tsx, say) and passes it in. Replace or remove a shipped route by recording it in\ncustomizations.yaml (an entry whose paths match the route file): a recorded\nroute is reported as replaced or removed, never failed, and --write never\ntouches it. A manifest may list several prefixes, and one manifest with\n\"root\": true may ship the locale-root page.tsx. A manifest with\n\"siteGated\": true ships only the routes the site selected: its public pages\nare not carried when .ailk-site-manifest.json lists no marketing module, and\nneither is any page under a surface the architecture.yaml \"# Surfaces:\" header\nleaves out. Run --write after `pnpm install` (the manifests are read from the\ninstalled packages); the scaffold's preflight runs --check as `pnpm routes:check`.\n";
168
+ /**
169
+ * The order an agent or a person adds a page in (#11700 D8). The same
170
+ * sentence is in this help, the check's failure header, the scaffold
171
+ * CLAUDE.md, the `add-page` and `extend-site` skill text and
172
+ * `template-guard.sh`'s refusal; `routes.test.ts` reads all six.
173
+ */
174
+ export declare const PAGE_DECISION_GUIDANCE = "Before you add a page, look up its page type and the package route that serves it, and use that package page when it exists. Otherwise record the decision in customizations.yaml (build-in: site \u2014 <decider>, <YYYY-MM-DD>, <reason>) before you write the file.";
175
+ export declare const ROUTES_HELP = "create-ailk routes \u2014 generate the route files for the pages a site's packages ship.\n\nUsage:\n create-ailk routes --write [<target-dir>]\n create-ailk routes --check [<target-dir>]\n\nArguments:\n <target-dir> The site root (holds apps/web). Defaults to the\n current dir.\n\nOptions:\n --write Write one generated file per route the installed\n page packages declare, under apps/web/app/[locale]/.\n A file already current is left alone.\n --check Write nothing; exit 1 naming each generated file\n that is missing, stale (differs from what --write\n would write) or stray (a page.tsx, layout.tsx or\n route.ts under a package's route prefix that is\n neither generated, recorded, nor one the package\n leaves to the site). It also names each orphaned\n override: a key in apps/web/messages/<locale>.json\n under a namespace a package's catalog ships that\n the catalog no longer has. And it names each roster\n page route (.ailk-site-manifest.json) that no page\n file serves \u2014 neither a site page nor a generated\n re-export. And it names each undecided page: a\n routing file under app/[locale]/ that no package,\n generator or template wrote, or a recorded package\n route, with no decided customizations.yaml entry\n (an undecided entry fails too). A reported\n page.tsx names the package page or the add-route\n magnet command that already serves its address.\n --help, -h Print this message.\n\nA page package is an installed @working-theory/* dependency of apps/web whose\npackage.json declares \"ailk\": { \"routes\": \"<manifest>\" }. A generated file\nre-exports the package's page and copies its route-segment config; when the\npage takes the site's config it imports the manifest's config file from the\napp root (apps/web/account.config.tsx, say) and passes it in. Replace or remove a shipped route by recording it in\ncustomizations.yaml (an entry whose paths match the route file): a recorded\nroute is reported as replaced or removed, never failed, and --write never\ntouches it. A manifest may list several prefixes, and one manifest with\n\"root\": true may ship the locale-root page.tsx. No two manifests may claim the\nsame prefix; one may claim a prefix strictly inside another's, which then\nships no route under it. A manifest with\n\"siteGated\": true ships only the routes the site selected: its public pages\nare not carried when .ailk-site-manifest.json lists no marketing module, and\nneither is any page under a surface the architecture.yaml \"# Surfaces:\" header\nleaves out. Run --write after `pnpm install` (the manifests are read from the\ninstalled packages); the scaffold's preflight runs --check as `pnpm routes:check`.\n\nBefore you add a page, look up its page type and the package route that serves it, and use that package page when it exists. Otherwise record the decision in customizations.yaml (build-in: site \u2014 <decider>, <YYYY-MM-DD>, <reason>) before you write the file. A decided entry is\n\"build-in: site \u2014 <decider>, <YYYY-MM-DD>, <reason>\" or \"build-in: ailk#<N>\";\nundecided_ok_until does not apply to a page. With no .ailk-template-files.json\na page outside every package prefix is not checked, and the report says so.\n";
134
176
  /** Parse the argv AFTER the `routes` word. Strict `node:util` parseArgs, like `parseSyncRoutesArgs`. */
135
177
  export declare function parseRoutesArgs(argv: string[]): RoutesArgs;
136
178
  /** The printed report: one line per file, grouped by state; the recorded routes last, under their decision. */