create-ailk 0.41.0 → 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 (35) 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 +4 -0
  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/routes.d.ts +38 -2
  12. package/dist/routes.js +586 -27
  13. package/dist/surfaces.d.ts +16 -0
  14. package/dist/surfaces.js +36 -0
  15. package/dist/update.d.ts +1 -1
  16. package/dist/update.js +24 -2
  17. package/package.json +3 -3
  18. package/templates/.claude/hooks/template-guard.sh +145 -36
  19. package/templates/CLAUDE.md +1 -1
  20. package/templates/apps/api/CLAUDE.md +1 -0
  21. package/templates/apps/mcp/CLAUDE.md +5 -3
  22. package/templates/apps/web/CLAUDE.md +13 -1
  23. package/templates/apps/web/app/[locale]/layout.tsx +6 -3
  24. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +28 -0
  25. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +28 -0
  26. package/templates/apps/web/lib/__tests__/page-chrome.test.ts +24 -0
  27. package/templates/apps/web/lib/__tests__/route-paths.test.ts +57 -0
  28. package/templates/apps/web/lib/mcp-oauth.ts +14 -10
  29. package/templates/apps/web/lib/page-chrome.ts +8 -5
  30. package/templates/apps/web/lib/route-paths.ts +22 -0
  31. package/templates/apps/web/lib/services-path.ts +27 -18
  32. package/templates/apps/web/middleware.ts +2 -1
  33. package/templates/apps/web/next.config.mjs +123 -2
  34. package/templates/apps/web/src/lib/routes.ts +4 -2
  35. package/versions.json +50 -50
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,
@@ -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
+ }
package/dist/routes.d.ts CHANGED
@@ -87,6 +87,22 @@ export declare function isGenerated(text: string): boolean;
87
87
  export declare function customizationsRecord(siteDir: string): (sitePath: string) => string | undefined;
88
88
  /** Whether `<siteDir>/customizations.yaml` records `sitePath` — any entry, any path form or glob (the generator's own reading). */
89
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[];
90
106
  export interface RecordedRoute {
91
107
  path: string;
92
108
  state: "replaced" | "removed";
@@ -107,6 +123,17 @@ export interface RoutesDrift {
107
123
  seamAliasMissing: string[];
108
124
  /** A roster page route the site carries that no page file serves: `<route> → <expected page path>` (#11511). */
109
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;
110
137
  /** The manifest entries in force — recorded ones included, not-carried ones not. */
111
138
  generated: number;
112
139
  }
@@ -117,7 +144,7 @@ export interface RoutesDrift {
117
144
  * site with no readable header carries every surface.
118
145
  */
119
146
  export declare function siteGate(siteDir: string): (sitePath: string) => boolean;
120
- /** The count check mode fails on: missing, stale and stray route files, orphaned overrides, missing seam aliases and unserved roster routes. */
147
+ /** The count check mode fails on: missing, stale and stray route files, orphaned overrides, missing seam aliases, unserved roster routes and undecided pages. */
121
148
  export declare function routesFailing(drift: RoutesDrift): number;
122
149
  /** How the site's route files and message overrides differ from the installed page packages. `routesFailing` zero means in sync. */
123
150
  export declare function checkRoutes(siteDir: string): RoutesDrift;
@@ -127,6 +154,8 @@ export interface WriteRoutesResult {
127
154
  recorded: RecordedRoute[];
128
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). */
129
156
  kept: string[];
157
+ /** Generated files deleted from a renamed family's old directory (#11385 D5). */
158
+ removed: string[];
130
159
  }
131
160
  /** Write every generated file that is missing or stale; a recorded route is left exactly as it is. */
132
161
  export declare function writeRoutes(siteDir: string): WriteRoutesResult;
@@ -136,7 +165,14 @@ export interface RoutesArgs {
136
165
  check: boolean;
137
166
  help: boolean;
138
167
  }
139
- 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.\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";
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";
140
176
  /** Parse the argv AFTER the `routes` word. Strict `node:util` parseArgs, like `parseSyncRoutesArgs`. */
141
177
  export declare function parseRoutesArgs(argv: string[]): RoutesArgs;
142
178
  /** The printed report: one line per file, grouped by state; the recorded routes last, under their decision. */