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
@@ -108,3 +108,31 @@ describe("GET /sitemap.xml — the site listing (#10940)", () => {
108
108
  expect(xml).not.toContain("evil.example");
109
109
  });
110
110
  });
111
+
112
+ // #11385 D3, AC-1, AC-3 — one site-config entry renames the portfolio's
113
+ // segment: every PortfolioItem is listed at /writing-samples with no listing
114
+ // row, and no URL keeps the old segment.
115
+ describe("GET /sitemap.xml — a renamed route family (#11385)", () => {
116
+ const saved = process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
117
+ beforeEach(() => {
118
+ process.env.CONTENT_ADAPTER = "database";
119
+ process.env.NEXT_PUBLIC_ENABLED_LOCALES = "en";
120
+ process.env.NEXT_PUBLIC_BASE_URL = BASE;
121
+ process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = '{"portfolio":"writing-samples"}';
122
+ ROWS.PortfolioItem = [{ type: "PortfolioItem", slug: "acme", title: "Acme" }];
123
+ });
124
+ afterEach(() => {
125
+ delete process.env.CONTENT_ADAPTER;
126
+ delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
127
+ delete process.env.NEXT_PUBLIC_BASE_URL;
128
+ delete ROWS.PortfolioItem;
129
+ if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
130
+ else process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = saved;
131
+ });
132
+
133
+ it("lists the PortfolioItem at /writing-samples/acme and nothing under /portfolio", async () => {
134
+ const all = locs(await sitemap({}));
135
+ expect(all.some((loc) => loc.endsWith("/writing-samples/acme"))).toBe(true);
136
+ expect(all.filter((loc) => loc.includes("/portfolio"))).toEqual([]);
137
+ });
138
+ });
@@ -521,3 +521,27 @@ describe("private pages (#11659)", () => {
521
521
  ]);
522
522
  });
523
523
  });
524
+
525
+ // #11385 D8, AC-9 — a renamed family keeps its chrome at its served segment.
526
+ describe("a renamed route family (#11385 AC-9)", () => {
527
+ const saved = process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
528
+ beforeEach(() => {
529
+ process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = '{"portfolio":"writing-samples"}';
530
+ });
531
+ afterEach(() => {
532
+ if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
533
+ else process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = saved;
534
+ });
535
+
536
+ it("finds the portfolio family at /writing-samples", () => {
537
+ expect(routeFamilyOf("/writing-samples/acme", ["en"])).toBe("portfolio");
538
+ expect(routeFamilyOf("/writing-samples", ["en"])).toBe("portfolio");
539
+ });
540
+
541
+ it("names the PortfolioItem and the PortfolioList as the chrome pages, never a LandingPage writing-samples", () => {
542
+ expect(chromePageCandidates("/writing-samples/acme", ["en"])[0]).toEqual({ type: "PortfolioItem", slug: "acme" });
543
+ const list = chromePageCandidates("/writing-samples", ["en"]);
544
+ expect(list[0]).toMatchObject({ type: "PortfolioList" });
545
+ expect(list).not.toContainEqual({ type: "LandingPage", slug: "writing-samples" });
546
+ });
547
+ });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The nav and footer follow a site's route-family renames (#11385 D8, AC-1, AC-9).
3
+ */
4
+ import type { NavItem } from "@working-theory/ui";
5
+ import { ArrowRight } from "lucide-react";
6
+
7
+ import { withRenamedColumns, withRenamedNavPaths } from "../route-paths";
8
+
9
+ const saved = process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
10
+ beforeEach(() => {
11
+ process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = '{"portfolio":"writing-samples"}';
12
+ });
13
+ afterEach(() => {
14
+ if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
15
+ else process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = saved;
16
+ });
17
+
18
+ describe("withRenamedNavPaths", () => {
19
+ it("maps a renamed family's item path", () => {
20
+ expect(withRenamedNavPaths([{ labelKey: "work", path: "/portfolio" }])[0]?.path).toBe(
21
+ "/writing-samples",
22
+ );
23
+ });
24
+
25
+ it("maps a flyout feature, a group item and an action, and leaves /about alone", () => {
26
+ const items: NavItem[] = [
27
+ {
28
+ labelKey: "work",
29
+ path: "/about",
30
+ flyout: {
31
+ features: [{ labelKey: "acme", path: "/portfolio/acme" }],
32
+ groups: [{ headingKey: "more", items: [{ labelKey: "beta", path: "/portfolio/beta" }] }],
33
+ actions: [{ labelKey: "all", icon: ArrowRight, path: "/portfolio" }],
34
+ },
35
+ },
36
+ ];
37
+ const [item] = withRenamedNavPaths(items);
38
+ expect(item?.path).toBe("/about");
39
+ expect(item?.flyout?.features[0]?.path).toBe("/writing-samples/acme");
40
+ expect(item?.flyout?.groups?.[0]?.items[0]?.path).toBe("/writing-samples/beta");
41
+ expect(item?.flyout?.actions?.[0]?.path).toBe("/writing-samples");
42
+ });
43
+
44
+ it("is the identity with no rename", () => {
45
+ delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
46
+ expect(withRenamedNavPaths([{ labelKey: "work", path: "/portfolio" }])[0]?.path).toBe("/portfolio");
47
+ });
48
+ });
49
+
50
+ describe("withRenamedColumns", () => {
51
+ it("maps a column item", () => {
52
+ expect(
53
+ withRenamedColumns([{ heading: "Work", items: [{ label: "Acme", path: "/portfolio/acme" }] }])[0]?.items[0]
54
+ ?.path,
55
+ ).toBe("/writing-samples/acme");
56
+ });
57
+ });
@@ -23,10 +23,10 @@
23
23
  * for a server with no tag, as a site's apps/web has;
24
24
  * - one sign-in for every workspace (#11607 D1a): a server given
25
25
  * `allWorkspaces` (the Admin) binds `ailk:all-workspaces` in place of the
26
- * one workspace, after a confirmation naming every workspace it reaches,
27
- * and its token-info answers the person's live memberships at each call
28
- * (D2). A server without it never binds one and treats such a token as
29
- * another server's.
26
+ * one workspace, and its token-info answers the person's live memberships
27
+ * at each call (D2). Its consent offers no choice (#11672 D1): the server
28
+ * binds every requested scope the person's roles hold. A server without
29
+ * it never binds one and treats such a token as another server's.
30
30
  *
31
31
  * Every refusal is code-shaped: no English string reaches a client. No answer
32
32
  * or log line carries a token, code, verifier or client secret.
@@ -648,18 +648,22 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
648
648
  return ctx.json({ redirectURI: redirect.toString() });
649
649
  }
650
650
 
651
- const chosen = ctx.body.scopes ?? [];
651
+ let chosen: readonly string[];
652
652
  let binding: string;
653
653
  if (allWorkspaces) {
654
654
  // The reach is every workspace, so naming one is a client of the
655
- // single-workspace consent (#11607 D1a).
656
- if (ctx.body.workspace_id !== undefined) throw refuse("BAD_REQUEST", "invalid_request");
657
- const reach = await offeredReach(userId, value.scope);
658
- if (reach.workspaces.length === 0 || chosen.some((s) => !(reach.offered as string[]).includes(s))) {
659
- throw refuse("BAD_REQUEST", "invalid_scope");
655
+ // single-workspace consent (#11607 D1a). The server decides the
656
+ // grant (#11672 D1): a body naming scopes is refused, never
657
+ // ignored — a client posting a subset believes it is narrowing.
658
+ if (ctx.body.workspace_id !== undefined || ctx.body.scopes !== undefined) {
659
+ throw refuse("BAD_REQUEST", "invalid_request");
660
660
  }
661
+ const reach = await offeredReach(userId, value.scope);
662
+ if (reach.workspaces.length === 0) throw refuse("BAD_REQUEST", "invalid_scope");
663
+ chosen = reach.offered;
661
664
  binding = ALL_WORKSPACES_SCOPE;
662
665
  } else {
666
+ chosen = ctx.body.scopes ?? [];
663
667
  const workspace = (await offeredWorkspaces(userId, value.scope)).find(
664
668
  (w) => w.id === ctx.body.workspace_id,
665
669
  );
@@ -37,7 +37,7 @@ import {
37
37
  type RouteFamilyKey,
38
38
  type SiteLayout,
39
39
  } from "@working-theory/site-config/schema";
40
- import { ROUTES } from "@working-theory/templates/routes";
40
+ import { conventionPath, ROUTES } from "@working-theory/templates/routes";
41
41
  import { readLocales } from "@working-theory/web-i18n";
42
42
  import { cache } from "react";
43
43
  import { parse as parseYaml } from "yaml";
@@ -240,14 +240,16 @@ function matchesPattern(pattern: string, segments: readonly string[]): boolean {
240
240
  * The route family a pathname belongs to, else `null`: the first routes-map
241
241
  * hub whose prefix is the path, prefixes it, or whose detail pattern matches
242
242
  * it. A site's moved docs are mapped back onto `/docs` first, and its moved
243
- * services onto `/services` (#10043 D9).
243
+ * services onto `/services` (#10043 D9), then a renamed family's served
244
+ * segment onto its own (#11385 D8).
244
245
  */
245
246
  export function routeFamilyOf(
246
247
  pathname: string,
247
248
  locales: readonly string[],
248
249
  ): RouteFamilyKey | null {
249
250
  const bare = normalizeRoutePath(pathname, locales);
250
- const path = toInternalDocsPath(bare) ?? toInternalServicesPath(bare) ?? bare;
251
+ // #11385 D8 — a renamed family's served segment maps back onto its own.
252
+ const path = conventionPath(toInternalDocsPath(bare) ?? toInternalServicesPath(bare) ?? bare);
251
253
  const segments = path.split("/").filter((segment) => segment.length > 0);
252
254
  for (const row of ROUTES) {
253
255
  if (!row.hub) continue;
@@ -277,8 +279,9 @@ export function chromePageCandidates(
277
279
  locales: readonly string[],
278
280
  ): Array<{ type: SchemaOrgType; slug: string }> {
279
281
  const normalized = normalizeRoutePath(pathname, locales);
280
- // #10043 D9 — a site's moved services are mapped back onto `/services`.
281
- const path = toInternalServicesPath(normalized) ?? normalized;
282
+ // #10043 D9 — a site's moved services are mapped back onto `/services`,
283
+ // and #11385 D8 a renamed family's served segment onto its own.
284
+ const path = conventionPath(toInternalServicesPath(normalized) ?? normalized);
282
285
  if (path === "/") return [{ type: "HomePage", slug: "home" }];
283
286
  const segments = path.split("/").filter((segment) => segment.length > 0);
284
287
  // A service under its category (`/services/<category>/<slug>`): the nested
@@ -0,0 +1,22 @@
1
+ // route-paths.ts — the nav and footer follow a site's route-family renames
2
+ // (#11385 D8).
3
+ //
4
+ // A site writes `<family>: { path: /<segment> }` in `content/_site.mdx`;
5
+ // `next.config.mjs` bakes the renames into `NEXT_PUBLIC_AILK_ROUTE_PATHS`, and
6
+ // `renamedPath` reads them. The generated nav (`lib/nav-config.ts`) names the
7
+ // convention paths (`/portfolio`), so the layout maps them here at render, as
8
+ // it maps the docs and services paths.
9
+ import { renamedPath } from "@working-theory/templates/routes";
10
+ import type { NavItem } from "@working-theory/ui";
11
+
12
+ import { mapColumnPaths, mapNavItemPaths } from "./services-path";
13
+
14
+ /** Copies of the nav items with every renamed family's path at its served segment. */
15
+ export function withRenamedNavPaths(items: NavItem[]): NavItem[] {
16
+ return mapNavItemPaths(items, (path) => renamedPath(path));
17
+ }
18
+
19
+ /** Copies of the footer columns with every renamed family's path at its served segment. */
20
+ export function withRenamedColumns<C extends { items: { path: string }[] }>(columns: C[]): C[] {
21
+ return mapColumnPaths(columns, (path) => renamedPath(path));
22
+ }
@@ -51,12 +51,14 @@ export function toInternalServicesPath(bare: string): string | null {
51
51
 
52
52
  type NavFlyout = NonNullable<NavItem["flyout"]>;
53
53
 
54
- function mapPath<T extends { path: string }>(entry: T): T {
55
- return { ...entry, path: toPublicServicesHref(entry.path) };
56
- }
57
-
58
- function mapFlyout(flyout: NavFlyout): NavFlyout {
59
- return {
54
+ /**
55
+ * Copies of the nav items with every path mapped through `toPublic` — the
56
+ * item's own `path` and each flyout feature, group item and action. Every
57
+ * other field is carried by reference. Shared with `route-paths.ts` (#11385 D8).
58
+ */
59
+ export function mapNavItemPaths(items: NavItem[], toPublic: (path: string) => string): NavItem[] {
60
+ const mapPath = <T extends { path: string }>(entry: T): T => ({ ...entry, path: toPublic(entry.path) });
61
+ const mapFlyout = (flyout: NavFlyout): NavFlyout => ({
60
62
  ...flyout,
61
63
  features: flyout.features.map(mapPath),
62
64
  ...(flyout.groups
@@ -68,7 +70,23 @@ function mapFlyout(flyout: NavFlyout): NavFlyout {
68
70
  }
69
71
  : {}),
70
72
  ...(flyout.actions ? { actions: flyout.actions.map(mapPath) } : {}),
71
- };
73
+ });
74
+ return items.map((item) => ({
75
+ ...item,
76
+ ...(item.path !== undefined ? { path: toPublic(item.path) } : {}),
77
+ ...(item.flyout ? { flyout: mapFlyout(item.flyout) } : {}),
78
+ }));
79
+ }
80
+
81
+ /** Copies of the footer columns with every item's path mapped through `toPublic`. */
82
+ export function mapColumnPaths<C extends { items: { path: string }[] }>(
83
+ columns: C[],
84
+ toPublic: (path: string) => string,
85
+ ): C[] {
86
+ return columns.map((column) => ({
87
+ ...column,
88
+ items: column.items.map((item) => ({ ...item, path: toPublic(item.path) })),
89
+ }));
72
90
  }
73
91
 
74
92
  /**
@@ -77,21 +95,12 @@ function mapFlyout(flyout: NavFlyout): NavFlyout {
77
95
  * and action. Every other field is carried by reference.
78
96
  */
79
97
  export function withPublicServicesPaths(items: NavItem[]): NavItem[] {
80
- return items.map((item) => ({
81
- ...item,
82
- ...(item.path !== undefined
83
- ? { path: toPublicServicesHref(item.path) }
84
- : {}),
85
- ...(item.flyout ? { flyout: mapFlyout(item.flyout) } : {}),
86
- }));
98
+ return mapNavItemPaths(items, toPublicServicesHref);
87
99
  }
88
100
 
89
101
  /** Copies of the footer columns with every item's services path mapped onto `SERVICES_PATH`. */
90
102
  export function withPublicServicesColumns<
91
103
  C extends { items: { path: string }[] },
92
104
  >(columns: C[]): C[] {
93
- return columns.map((column) => ({
94
- ...column,
95
- items: column.items.map(mapPath),
96
- }));
105
+ return mapColumnPaths(columns, toPublicServicesHref);
97
106
  }
@@ -52,6 +52,7 @@ import {
52
52
  isBookingPath,
53
53
  setAuthRequestHeaders,
54
54
  } from "@working-theory/auth/edge";
55
+ import { routeSegment } from "@working-theory/templates/routes";
55
56
  import { NextRequest, NextResponse } from "next/server";
56
57
  import createMiddleware from "next-intl/middleware";
57
58
 
@@ -272,7 +273,7 @@ export function middleware(request: NextRequest): NextResponse {
272
273
  isFileRoutePath(request.nextUrl.pathname)
273
274
  ? FILE_ROUTE_SECURITY_HEADERS
274
275
  : SCHEDULING_PAGES &&
275
- isBookingPath(request.nextUrl.pathname, enabledLocales)
276
+ isBookingPath(request.nextUrl.pathname, enabledLocales, routeSegment("meet"))
276
277
  ? SCHEDULING_SECURITY_HEADERS
277
278
  : auth.oneTap
278
279
  ? ONE_TAP_SECURITY_HEADERS
@@ -4,8 +4,13 @@ import { parse as parseYaml } from "yaml";
4
4
  import bundleAnalyzer from "@next/bundle-analyzer";
5
5
  import { withSentryConfig } from "@sentry/nextjs";
6
6
  import createNextIntlPlugin from "next-intl/plugin";
7
- import { DocsPathSchema, ServicesPathSchema } from "@working-theory/site-config/schema";
8
- import { legacyRedirects, ROUTES, SERVICES_ROUTE } from "@working-theory/templates/routes";
7
+ import { DocsPathSchema, ServicesPathSchema, SiteConfigSchema } from "@working-theory/site-config/schema";
8
+ import {
9
+ legacyRedirects,
10
+ routeRenameRefusals,
11
+ ROUTES,
12
+ SERVICES_ROUTE,
13
+ } from "@working-theory/templates/routes";
9
14
  import { assetRemotePattern } from "@working-theory/validation";
10
15
  import { parseStealth } from "@working-theory/web-i18n/stealth";
11
16
  import { withBotId } from "botid/next/config";
@@ -280,6 +285,118 @@ function readServiceParents() {
280
285
  const servicesPathAtBuild = readServicesPathFromSiteMdx();
281
286
  readServiceParents();
282
287
 
288
+ // #11385 D4 — a renamed route family. A site sets `portfolio: { path:
289
+ // /writing-samples }` in content/_site.mdx on one of the renamable families
290
+ // (the `_site.mdx` keys other than `services` whose schema takes a `path`);
291
+ // it is read here, refused by name when it cannot be served or when its route
292
+ // files were not regenerated, and baked into NEXT_PUBLIC_AILK_ROUTE_PATHS,
293
+ // keyed by convention segment, for @working-theory/templates/route-paths.
294
+ // `redirects()` reads the same value through `legacyRedirects()`.
295
+ const ROUTE_PATH_SCHEMAS = Object.fromEntries(
296
+ Object.entries(SiteConfigSchema.shape)
297
+ .filter(([key, schema]) => key !== "services" && schema.unwrap?.()?.shape?.path !== undefined)
298
+ .map(([key, schema]) => [key, schema.unwrap().shape.path.unwrap()]),
299
+ );
300
+ /** Family → convention segment: the key's kebab form (`caseStudies` → `case-studies`). */
301
+ const ROUTE_CONVENTIONS = Object.fromEntries(
302
+ Object.keys(ROUTE_PATH_SCHEMAS).map((family) => [
303
+ family,
304
+ family.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`),
305
+ ]),
306
+ );
307
+ // middleware.ts's NON_LOCALE_ROUTE_PREFIXES, without their slash.
308
+ const NON_LOCALE_SEGMENTS = ["api", "apple-icon", "og", "v1"];
309
+ const ROUTE_ROOT = join(process.cwd(), "app/[locale]");
310
+ const GENERATED_ROUTE_HEADER = /^(?:\/\/ oss: false\r?\n)?\/\/ Generated by create-ailk routes from /;
311
+
312
+ function refuseRouteRename(family, value, reason) {
313
+ throw new Error(`content/_site.mdx ${family}.path ${value}: ${reason}`);
314
+ }
315
+
316
+ /** A route file's text when create-ailk generated it; `undefined` otherwise. */
317
+ function readGeneratedRoute(path) {
318
+ let text;
319
+ try {
320
+ text = readFileSync(path, "utf8");
321
+ } catch {
322
+ return undefined;
323
+ }
324
+ return GENERATED_ROUTE_HEADER.test(text) ? text : undefined;
325
+ }
326
+
327
+ function readRouteRenamesFromSiteMdx() {
328
+ const renames = {};
329
+ for (const [family, schema] of Object.entries(ROUTE_PATH_SCHEMAS)) {
330
+ const value = siteFrontmatterAtBuild?.[family]?.path;
331
+ if (value === undefined || value === null) continue;
332
+ const parsed = schema.safeParse(value);
333
+ if (!parsed.success) refuseRouteRename(family, value, parsed.error.issues[0].message);
334
+ renames[family] = parsed.data.slice(1);
335
+ }
336
+
337
+ const [refusal] = routeRenameRefusals(renames, ROUTE_CONVENTIONS, NON_LOCALE_SEGMENTS, [
338
+ ...enabledLocalesAtBuild.split(",").map((l) => l.toLowerCase()),
339
+ docsPathAtBuild.split("/")[1],
340
+ servicesPathAtBuild.split("/")[1],
341
+ ...NON_LOCALE_SEGMENTS,
342
+ ]);
343
+ if (refusal !== undefined) {
344
+ const family = refusal.split(" → ")[0];
345
+ const value = `/${renames[family]}`;
346
+ refuseRouteRename(family, value, refusal.slice(`${family} → ${value}: `.length));
347
+ }
348
+
349
+ // A renamed family's route files must be generated under its new segment,
350
+ // and that page must be the family's own (`…/pages/<convention>/…`).
351
+ for (const [family, segment] of Object.entries(renames)) {
352
+ const text = readGeneratedRoute(join(ROUTE_ROOT, segment, "page.tsx"));
353
+ const module = text && /\bfrom "(@working-theory\/[^"]+)"/.exec(text)?.[1];
354
+ if (!module?.includes(`/pages/${ROUTE_CONVENTIONS[family]}/`)) {
355
+ refuseRouteRename(
356
+ family,
357
+ `/${segment}`,
358
+ `app/[locale]/${segment}/page.tsx is not the ${family} family's generated route file; run create-ailk routes --write`,
359
+ );
360
+ }
361
+ }
362
+
363
+ // And no generated route file may serve a family away from its segment:
364
+ // the package page it re-exports (`…/pages/<segment>/…`) names its family.
365
+ const familyOfSegment = Object.fromEntries(
366
+ Object.entries(ROUTE_CONVENTIONS).map(([family, segment]) => [segment, family]),
367
+ );
368
+ let dirs = [];
369
+ try {
370
+ dirs = readdirSync(ROUTE_ROOT, { withFileTypes: true }).filter((e) => e.isDirectory());
371
+ } catch {
372
+ // No app/[locale]/ — nothing generated to check.
373
+ }
374
+ for (const { name: dir } of dirs) {
375
+ const text = readGeneratedRoute(join(ROUTE_ROOT, dir, "page.tsx"));
376
+ const module = text && /\bfrom "(@working-theory\/[^"]+)"/.exec(text)?.[1];
377
+ const family = module && familyOfSegment[/\/pages\/([^/]+)\//.exec(module)?.[1]];
378
+ if (!family) continue;
379
+ const served = renames[family] ?? ROUTE_CONVENTIONS[family];
380
+ if (dir !== served) {
381
+ throw new Error(
382
+ `app/[locale]/${dir}/page.tsx re-exports ${module}, the ${family} family's page, which this site serves at /${served}; run create-ailk routes --write`,
383
+ );
384
+ }
385
+ }
386
+ return renames;
387
+ }
388
+
389
+ const routePathsAtBuild = JSON.stringify(
390
+ Object.fromEntries(
391
+ Object.entries(readRouteRenamesFromSiteMdx()).map(([family, segment]) => [
392
+ ROUTE_CONVENTIONS[family],
393
+ segment,
394
+ ]),
395
+ ),
396
+ );
397
+ // Before the config is built, so `legacyRedirects()` in `redirects()` reads it.
398
+ process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = routePathsAtBuild;
399
+
283
400
  // #10647 D6 — a database spoke's pages name library images as `asset:<key>`,
284
401
  // which the hub resolves to its own `/v1/assets/:id` URLs. `next/image` admits
285
402
  // that path on the hub's origin, and nothing else, when `AILK_API_URL` (the
@@ -426,6 +543,10 @@ const nextConfig = {
426
543
  // services.path, or `/services`. Read by middleware.ts,
427
544
  // lib/services-path.ts and @working-theory/page-renderer.
428
545
  NEXT_PUBLIC_AILK_SERVICES_PATH: servicesPathAtBuild,
546
+ // The route-family renames (#11385), from content/_site.mdx's
547
+ // `<family>.path` keys, as `{ <convention segment>: <served segment> }`,
548
+ // or `{}`. Read by @working-theory/templates/route-paths.
549
+ NEXT_PUBLIC_AILK_ROUTE_PATHS: routePathsAtBuild,
429
550
  },
430
551
  async headers() {
431
552
  if (!STEALTH) return [];
@@ -5,7 +5,7 @@
5
5
  * handlers to avoid copy-paste duplication.
6
6
  */
7
7
 
8
- import { pagePath, routeFor } from "@working-theory/templates/routes";
8
+ import { pagePath, renamedPath, routeFor } from "@working-theory/templates/routes";
9
9
 
10
10
  import { SERVICES_PATH } from "../../lib/services-path";
11
11
  import { SITE_BASE_URL } from "../../lib/site-brand";
@@ -44,8 +44,10 @@ export function resolveBaseUrl(): string {
44
44
  * optional. `sitemap.xml`, `llms.txt` and, since #10775, the docs-blog
45
45
  * module's `docs-blog/llms-route.ts` call `pagePathFor` instead; the export
46
46
  * stays for a docs-blog site that installed the older copy of that route.
47
+ * It answers the public path, so a renamed route family's segment applies
48
+ * (#11385 D3); `routeFor` stays the hub's path key.
47
49
  */
48
- export const slugToPath: (type: string, slug: string) => string = routeFor;
50
+ export const slugToPath = (type: string, slug: string): string => renamedPath(routeFor(type, slug));
49
51
 
50
52
  /**
51
53
  * One listed page's public path (#10043 D9): `slugToPath`, except that the
package/versions.json CHANGED
@@ -1,69 +1,69 @@
1
1
  {
2
- "@working-theory/account": "0.68.0",
3
- "@working-theory/admin-ui": "0.68.0",
4
- "@working-theory/aeo": "0.68.0",
5
- "@working-theory/agent-context": "0.68.0",
2
+ "@working-theory/account": "0.69.0",
3
+ "@working-theory/admin-ui": "0.69.0",
4
+ "@working-theory/aeo": "0.69.0",
5
+ "@working-theory/agent-context": "0.69.0",
6
6
  "@working-theory/agent-contract": "0.1.0",
7
7
  "@working-theory/agent-memory": "0.0.0",
8
8
  "@working-theory/ai": "0.1.0",
9
- "@working-theory/analytics": "0.68.0",
10
- "@working-theory/api": "0.68.0",
11
- "@working-theory/api-client": "0.68.0",
12
- "@working-theory/auth": "0.68.0",
9
+ "@working-theory/analytics": "0.69.0",
10
+ "@working-theory/api": "0.69.0",
11
+ "@working-theory/api-client": "0.69.0",
12
+ "@working-theory/auth": "0.69.0",
13
13
  "@working-theory/cda-filesystem": "0.0.0",
14
- "@working-theory/cli": "0.68.0",
15
- "@working-theory/common": "0.68.0",
14
+ "@working-theory/cli": "0.69.0",
15
+ "@working-theory/common": "0.69.0",
16
16
  "@working-theory/consent": "0.1.0",
17
- "@working-theory/content-adapters": "0.68.0",
18
- "@working-theory/content-projection": "0.68.0",
19
- "@working-theory/email": "0.68.0",
17
+ "@working-theory/content-adapters": "0.69.0",
18
+ "@working-theory/content-projection": "0.69.0",
19
+ "@working-theory/email": "0.69.0",
20
20
  "@working-theory/env": "0.0.0",
21
- "@working-theory/eslint-config": "0.68.0",
22
- "@working-theory/fumadocs-schema": "0.68.0",
21
+ "@working-theory/eslint-config": "0.69.0",
22
+ "@working-theory/fumadocs-schema": "0.69.0",
23
23
  "@working-theory/ids": "0.21.0",
24
- "@working-theory/jsonld": "0.68.0",
25
- "@working-theory/license": "0.68.0",
26
- "@working-theory/mcp-server": "0.68.0",
27
- "@working-theory/metadata": "0.68.0",
28
- "@working-theory/observability": "0.68.0",
29
- "@working-theory/page-renderer": "0.68.0",
24
+ "@working-theory/jsonld": "0.69.0",
25
+ "@working-theory/license": "0.69.0",
26
+ "@working-theory/mcp-server": "0.69.0",
27
+ "@working-theory/metadata": "0.69.0",
28
+ "@working-theory/observability": "0.69.0",
29
+ "@working-theory/page-renderer": "0.69.0",
30
30
  "@working-theory/plugin-mcp": "0.1.3",
31
- "@working-theory/schema": "0.68.0",
32
- "@working-theory/schema-pack-registry": "0.68.0",
33
- "@working-theory/schema-validator": "0.68.0",
34
- "@working-theory/sections-registry": "0.68.0",
35
- "@working-theory/site-config": "0.68.0",
36
- "@working-theory/site-pages": "0.68.0",
37
- "@working-theory/spoke-checkout": "0.7.24",
38
- "@working-theory/stripe-client": "0.68.0",
39
- "@working-theory/templates": "0.68.0",
40
- "@working-theory/theme": "0.68.0",
41
- "@working-theory/ui": "0.68.0",
42
- "@working-theory/validation": "0.68.0",
43
- "@working-theory/web-i18n": "0.68.0",
44
- "@working-theory/admin": "0.19.0",
45
- "@working-theory/api-commerce": "0.2.2",
46
- "@working-theory/api-content-write": "0.12.0",
47
- "@working-theory/api-hub": "0.7.2",
48
- "@working-theory/api-multi-tenant": "0.4.2",
49
- "@working-theory/api-scheduling": "0.6.7",
50
- "@working-theory/api-signal-collectors": "0.6.8",
51
- "@working-theory/api-workspace": "0.12.2",
31
+ "@working-theory/schema": "0.69.0",
32
+ "@working-theory/schema-pack-registry": "0.69.0",
33
+ "@working-theory/schema-validator": "0.69.0",
34
+ "@working-theory/sections-registry": "0.69.0",
35
+ "@working-theory/site-config": "0.69.0",
36
+ "@working-theory/site-pages": "0.69.0",
37
+ "@working-theory/spoke-checkout": "0.7.25",
38
+ "@working-theory/stripe-client": "0.69.0",
39
+ "@working-theory/templates": "0.69.0",
40
+ "@working-theory/theme": "0.69.0",
41
+ "@working-theory/ui": "0.69.0",
42
+ "@working-theory/validation": "0.69.0",
43
+ "@working-theory/web-i18n": "0.69.0",
44
+ "@working-theory/admin": "0.20.0",
45
+ "@working-theory/api-commerce": "0.2.3",
46
+ "@working-theory/api-content-write": "0.13.0",
47
+ "@working-theory/api-hub": "0.7.3",
48
+ "@working-theory/api-multi-tenant": "0.4.3",
49
+ "@working-theory/api-scheduling": "0.6.8",
50
+ "@working-theory/api-signal-collectors": "0.6.9",
51
+ "@working-theory/api-workspace": "0.13.0",
52
52
  "@working-theory/billing-client": "0.0.0",
53
53
  "@working-theory/branding": "0.0.0",
54
54
  "@working-theory/license-client": "0.0.0",
55
55
  "@working-theory/license-manifest": "0.0.0",
56
- "@working-theory/mcp-scheduling": "0.4.9",
57
- "@working-theory/mcp-signal-collectors": "0.2.22",
58
- "@working-theory/mcp-workspace": "0.11.0",
56
+ "@working-theory/mcp-scheduling": "0.4.10",
57
+ "@working-theory/mcp-signal-collectors": "0.2.23",
58
+ "@working-theory/mcp-workspace": "0.12.0",
59
59
  "@working-theory/partner-session": "0.0.0",
60
60
  "@working-theory/preview-protocol": "0.0.0",
61
- "@working-theory/ui-commerce": "0.68.0",
62
- "@working-theory/ui-docs-blog": "0.68.0",
63
- "@working-theory/ui-scheduling": "0.68.0",
64
- "@working-theory/ui-signal-collectors": "0.68.0",
61
+ "@working-theory/ui-commerce": "0.69.0",
62
+ "@working-theory/ui-docs-blog": "0.69.0",
63
+ "@working-theory/ui-scheduling": "0.69.0",
64
+ "@working-theory/ui-signal-collectors": "0.69.0",
65
65
  "@working-theory/web": "0.0.0",
66
66
  "@working-theory/app-api": "1.0.0",
67
67
  "@working-theory/mcp": "0.0.0",
68
- "@working-theory/database": "0.68.0"
68
+ "@working-theory/database": "0.69.0"
69
69
  }