create-ailk 0.40.0 → 0.40.1

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.
@@ -369,7 +369,7 @@
369
369
  "tier": "sections",
370
370
  "sourcePath": "packages/ui/src/sections/DocumentViewerClient.tsx",
371
371
  "importPath": "@working-theory/ui/sections",
372
- "exported": false,
372
+ "exported": true,
373
373
  "description": "The interactive shell for DocumentViewer. Split out of DocumentViewer.tsx (which stays RSC) for the same reason AlertSection composes AlertSectionDismissIsland: interactivity is contained to one client island.",
374
374
  "descriptionSource": "doc-comment",
375
375
  "descriptionGrade": "weak",
@@ -82,7 +82,7 @@ Import: `import { X } from "@working-theory/ui/sections";` (or from the `@workin
82
82
  | `DocumentChassis` | A long-read document page (privacy policy, terms, DPA, working agreement) — chrome-free header + optional stat strip + a sticky numbered section nav beside continuous prose; one document per page/route. The authored `sections` list drives both the nav and the body. | MDX `type: document-chassis` |
83
83
  | `DocumentViewer` | A paginated document embedded in a page (a report, a client deliverable) — use for a 10-50 page PDF at a closed 16:9 (deck) or letter (portrait) geometry, rendered by a dynamically-imported PDF.js so it never enters the main bundle. `src` accepts a public path or the authenticated `/v1/deliverables/:grantId` route. Not for long-read prose — that is `document-chassis`. | MDX `type: document-viewer` |
84
84
  | `DocumentViewerCanvas` | The PDF.js renderer for DocumentViewer. This file is reached ONLY via the dynamic import in DocumentViewerClient.tsx — that is deliberate: the static `import "pdfjs-dist"` below is what lands in this file's own route-split chunk instead of the main bundle (a static import of the renderer is a spec violation, not a style preference). | internal — compose from `packages/ui/src/sections/DocumentViewerCanvas.tsx` |
85
- | `DocumentViewerClient` | The interactive shell for DocumentViewer. Split out of DocumentViewer.tsx (which stays RSC) for the same reason AlertSection composes AlertSectionDismissIsland: interactivity is contained to one client island. *(weak)* | internal — compose from `packages/ui/src/sections/DocumentViewerClient.tsx` |
85
+ | `DocumentViewerClient` | The interactive shell for DocumentViewer. Split out of DocumentViewer.tsx (which stays RSC) for the same reason AlertSection composes AlertSectionDismissIsland: interactivity is contained to one client island. *(weak)* | `import { DocumentViewerClient } from "@working-theory/ui/sections"` |
86
86
  | `FAQ` | Question-and-answer pairs — use to pre-empt buyer objections that are naturally phrased as questions. | MDX `type: faq` · `import { FAQ } from "@working-theory/ui/sections"` |
87
87
  | `Feature` | A multi-item benefit/feature highlight grid — use to walk through several product capabilities. | MDX `type: feature` |
88
88
  | `FormLightbox` | The VideoLightbox dialog shell hosting a StepFlow instead of a video: a trigger (e.g. a "Let's Start" Button — any focusable element the caller supplies) opens the SAME StepFlow inside a Radix Dialog on the dimmed/blurred backdrop shared with VideoLightbox/SpotlightPanel. | `import { FormLightbox } from "@working-theory/ui/sections"` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ailk",
3
- "version": "0.40.0",
3
+ "version": "0.40.1",
4
4
  "description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "tar": "^7.5.21"
29
29
  },
30
30
  "devDependencies": {
31
- "@working-theory/schema": "0.64.0",
32
- "@working-theory/templates": "0.64.0"
31
+ "@working-theory/schema": "0.65.0",
32
+ "@working-theory/templates": "0.65.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
@@ -753,7 +753,16 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
753
753
  - **The seven handlers.** `robots.txt`, `sitemap.xml`, `llms.txt` (both copies — the docs + blog module's `lib/slices/docs-blog/llms-route.ts` too), `.well-known/mcp.json`, `.well-known/ai-plugin.json` and `openapi.json` are `force-dynamic` and read it once per request, after the checks each already makes and before any other work. `createSitemapHandler` and `createLlmsHandler` take a `discoverable` dep (default `siteDiscoverable`); every test caller passes one, so no suite reads a hub.
754
754
  - **On** is today, byte for byte. **Off**: robots.txt answers STEALTH's `User-agent: *` / `Disallow: /` with no Sitemap line; the other five answer 404 with no body (mcp.json keeps its CORS headers; its `OPTIONS` is unchanged). Every off answer is `cache-control: no-store`, so a crawler asks again.
755
755
  - **Hidden wins.** With `STEALTH` on, or no public page (`PUBLIC_PAGES` false), robots.txt answers as before and makes no read; sitemap.xml and llms.txt 404 before it.
756
- - **Pages are never hidden.** No page, layout or `middleware.ts` reads the switch, and `<meta robots>` and `X-Robots-Tag` stay `STEALTH`'s alone: off is a preference about discovery, not access control. `STEALTH` remains the hard, deploy-time hide.
756
+ - **Pages are never hidden.** No page, layout or `middleware.ts` reads the switch, and only `STEALTH` sets `X-Robots-Tag`: off is a preference about discovery, not access control. `<meta robots>` has two writers: `STEALTH` (`noindex, nofollow`, which always wins), and on a hub-connected site the workspace's Allow search indexing (`seo.robots.index: false` → the layout's `noindex, follow`, § A hub-connected site's identity). `STEALTH` remains the hard, deploy-time hide.
757
+
758
+ ## A hub-connected site's identity
759
+
760
+ **A site connected to its hub reads its name, description, legal name, contact, sameAs and indexing switch from the hub (#11456).** Hub-connected means `CONTENT_ADAPTER=database` (the switch `resolveBlogSource` uses) and a spoke key on the wire (`sendsSpokeKey()`); `lib/hub-site-config.ts`'s `readHubSite()` then reads `GET /v1/content/site-config` through `siteConfig.get()` — the key's own workspace's identity and seo rows, 401 to any other caller — cached by `unstable_cache` under `siteConfigTag()` for at most 300 s. Any other site makes no call and renders from `_site.mdx` exactly as before.
761
+
762
+ - **Who reads it.** `resolveSiteBrand()` (`lib/site-brand.tsx`) gives the locale layout's title, description, og/twitter copy, Nav/Footer `siteName` and copyright holder, and both llms.txt headings; `lib/site-identity.ts` registers a JSON-LD reader (`setSiteIdentityReader`) whose registration keeps the file's `baseUrl`, so no hub value moves an `@id`; the contact email and the closing footer's contact lines read the value the last read resolved (`heldHubSite()`), because their seam is synchronous. `SITE_NAME`'s other readers (og image, icons, auth, mcp.json, ai-plugin.json) keep the file value.
763
+ - **A hub row is the whole identity.** A field the operator cleared is absent, never refilled from the file; only a missing row, an unreadable one or a failed read falls back to `_site.mdx`. The file's top-level `contactEmail` stays the contact email's fallback. Hub values are collapsed to one line.
764
+ - **A save shows without a redeploy.** A 200 PUT of `identity` or `seo` sends the signed `site-config` revalidate event (`notifySiteConfigRevalidate`) to the site and its spokes; `app/api/revalidate/route.ts` answers it by purging `siteConfigTag()`. The 300 s expiry is the net for a spoke with no `revalidateUrl`.
765
+ - **A hub outage never breaks a page**: a failed read writes no cache entry and serves the instance's last good value, else the file. The indexing switch fails open.
757
766
 
758
767
  ## AEO & performance
759
768
 
@@ -771,7 +780,9 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
771
780
  - Don't reach into `apps/api` or `apps/mcp` from `apps/web`. They're peer apps — talk via HTTP/MCP.
772
781
  - Don't commit images to `screenshots/` — only the `.gitkeep` is tracked.
773
782
 
774
- Last updated: 2026-11-11 — § Where the base pages live: the 63 base pages, their actions, loaders and libs ship in `@working-theory/site-pages`, this app holds their generated route files and `site-pages.config.tsx`, and the ten namespaces ship in the package (#11259) — verified against `packages/site-pages/{routes.json,src/site.ts,src/index.ts}`, `site-pages.config.tsx` and `i18n/request.ts`.
783
+ Last updated: 2026-11-11 — § A hub-connected site's identity: the hub read, the brand, JSON-LD reader and contact readers that take it, the `site-config` revalidate event, and `<meta robots>`'s second writer (#11456) — verified against `lib/{hub-site-config.ts,site-brand.tsx,site-identity.ts,site-contact-email.ts,site-contact-lines.ts}`, `app/[locale]/layout.tsx`, `app/llms.txt/route.ts` and `app/api/revalidate/route.ts`.
784
+
785
+ Prior: 2026-11-11 — § Where the base pages live: the 63 base pages, their actions, loaders and libs ship in `@working-theory/site-pages`, this app holds their generated route files and `site-pages.config.tsx`, and the ten namespaces ship in the package (#11259) — verified against `packages/site-pages/{routes.json,src/site.ts,src/index.ts}`, `site-pages.config.tsx` and `i18n/request.ts`.
775
786
 
776
787
  Prior: 2026-11-10 — § The `(auth)` route group: sign-in, the hub session and the auth routes ship in `@working-theory/auth`, this app holds their 25 generated route files and `auth.config.tsx`, Better Auth reaches the package through `loadAuth()`, and the middleware's auth half is the package's edge entry (#11257) — verified against `packages/auth/{routes.json,src/site.ts,src/edge.ts}`, `auth.config.tsx`, `middleware.ts`, `lib/topology.generated.ts` and `i18n/request.ts`.
777
788
 
@@ -99,6 +99,7 @@ import {
99
99
  routeFamilyOf,
100
100
  } from "../../lib/page-chrome";
101
101
  import {
102
+ ancestorPaths,
102
103
  backLinkName,
103
104
  navLabelsByPath,
104
105
  parentHref,
@@ -109,12 +110,7 @@ import {
109
110
  withPublicServicesColumns,
110
111
  withPublicServicesPaths,
111
112
  } from "../../lib/services-path";
112
- import {
113
- COPYRIGHT_HOLDER,
114
- SITE_DESCRIPTION,
115
- SITE_NAME,
116
- resolveContentRoot,
117
- } from "../../lib/site-brand";
113
+ import { resolveContentRoot, resolveSiteBrand } from "../../lib/site-brand";
118
114
  import { siteChrome, type SiteChrome } from "../../lib/site-chrome";
119
115
  import {
120
116
  ACCOUNT_LABEL_KEY,
@@ -141,6 +137,7 @@ import {
141
137
  import { pagePathFor, resolveBaseUrl } from "../../src/lib/routes";
142
138
 
143
139
  import { ConsentBanner } from "./consent-banner";
140
+
144
141
  import { readSiteContactLines } from "../../lib/site-contact-lines";
145
142
 
146
143
  /**
@@ -279,6 +276,8 @@ const FLASH_PREVENTION_SCRIPT = `(function(){
279
276
  // ── Metadata ─────────────────────────────────────────────────────────────────
280
277
 
281
278
  export async function generateMetadata(): Promise<Metadata> {
279
+ // #11456 D4 — the hub's brand on a hub-connected site, else `_site.mdx`'s.
280
+ const brand = await resolveSiteBrand();
282
281
  const headerStore = await headers();
283
282
  const pathname = headerStore.get("x-pathname") ?? "/";
284
283
 
@@ -286,7 +285,7 @@ export async function generateMetadata(): Promise<Metadata> {
286
285
  const baseUrl = resolveBaseUrl();
287
286
  // #11244 — absolute: no layout sets `metadataBase`, so a relative og:image
288
287
  // reached crawlers as a path they could not fetch.
289
- const ogImageUrl = `${baseUrl.replace(/\/+$/, "")}${getOgImageUrl({ title: SITE_NAME, schemaType: "WebSite" })}`;
288
+ const ogImageUrl = `${baseUrl.replace(/\/+$/, "")}${getOgImageUrl({ title: brand.siteName, schemaType: "WebSite" })}`;
290
289
  const languages = buildHreflangAlternates(
291
290
  pathname,
292
291
  locales,
@@ -297,23 +296,31 @@ export async function generateMetadata(): Promise<Metadata> {
297
296
  // none of its own: the request's own URL, never the home page's.
298
297
  const requestUrl = pathname === "/" ? baseUrl : `${baseUrl}${pathname}`;
299
298
 
299
+ // #11456 D6 — `STEALTH` wins; otherwise the hub's Allow search indexing
300
+ // off answers `noindex, follow` on every page that sets no robots of its own.
301
+ const stealthRobots = getStealthRobots();
302
+
300
303
  return {
301
- title: SITE_NAME,
302
- description: SITE_DESCRIPTION,
304
+ title: brand.siteName,
305
+ description: brand.description,
303
306
  openGraph: {
304
- title: SITE_NAME,
305
- description: SITE_DESCRIPTION,
307
+ title: brand.siteName,
308
+ description: brand.description,
306
309
  type: "website",
307
310
  url: requestUrl,
308
311
  images: [ogImageUrl],
309
312
  },
310
313
  twitter: {
311
314
  card: "summary_large_image",
312
- title: SITE_NAME,
313
- description: SITE_DESCRIPTION,
315
+ title: brand.siteName,
316
+ description: brand.description,
314
317
  images: [ogImageUrl],
315
318
  },
316
- ...getStealthRobots(),
319
+ ...("robots" in stealthRobots
320
+ ? stealthRobots
321
+ : brand.indexable
322
+ ? {}
323
+ : { robots: { index: false, follow: true } }),
317
324
  alternates: {
318
325
  canonical: requestUrl,
319
326
  languages,
@@ -376,6 +383,9 @@ export default async function LocaleLayout({
376
383
  if (moved !== null)
377
384
  permanentRedirect(localeHref(locale, moved, DEFAULT_LOCALE));
378
385
  const messages = await getMessages();
386
+ // #11456 D4 — awaited before `readSiteContactLines`, so the held hub value
387
+ // the contact lines read is this render's.
388
+ const brand = await resolveSiteBrand();
379
389
  // #7742 D2 — `colorMode: "light"` pins the mode: a saved dark cookie is
380
390
  // ignored, no flash script runs and no theme switch renders.
381
391
  const pinLight = chrome.colorMode === "light";
@@ -584,7 +594,7 @@ export default async function LocaleLayout({
584
594
  const brandWordmark = {
585
595
  src: "/wordmark.svg",
586
596
  darkSrc: "/wordmark-light.svg",
587
- alt: SITE_NAME,
597
+ alt: brand.siteName,
588
598
  width: 140,
589
599
  height: 16,
590
600
  };
@@ -676,7 +686,7 @@ export default async function LocaleLayout({
676
686
  // snap an unpinned bar scrolls away with slide 1 (#5697). It keeps its
677
687
  // own actions, mark and bar style — only `sticky` is added.
678
688
  ...(isDeckPage ? { sticky: true } : {}),
679
- siteName: SITE_NAME,
689
+ siteName: brand.siteName,
680
690
  frame: "contained",
681
691
  navAlignment: "right",
682
692
  showThemeToggle: false,
@@ -717,7 +727,7 @@ export default async function LocaleLayout({
717
727
  }));
718
728
 
719
729
  // The bare header's back arrow (operator handoff 2026-11-09): the page's
720
- // served parent — a content page, a code-rendered route or a nav entry —
730
+ // served parent — a content page, a page route the app builds or a nav entry —
721
731
  // named in its label; home when no ancestor is served. Read only where
722
732
  // the arrow renders. A slide-left arrival is rewritten client-side by
723
733
  // NavBackLink (#8644).
@@ -725,7 +735,7 @@ export default async function LocaleLayout({
725
735
  // name follows the href NavBackLink resolves to.
726
736
  let bareBackLink: { href: string; label: string; returnLabel: string } | undefined;
727
737
  if (!isHome && pageChrome.header === "bare") {
728
- const titles = await servedPages(locale);
738
+ const titles = await servedPages(locale, ancestorPaths(pathname, enabledLocales));
729
739
  const navPathLabels = navLabelsByPath([publicNavItems, footerColumnDefs], labelFor);
730
740
  const served = (path: string): boolean => titles.has(path) || navPathLabels.has(path);
731
741
  const parent = servedParent({ pathname, locales: enabledLocales, served });
@@ -734,15 +744,22 @@ export default async function LocaleLayout({
734
744
  label:
735
745
  parent === null
736
746
  ? tNav("home")
737
- : tNav("backTo", { name: backLinkName(parent, { navLabels: navPathLabels, titles }) }),
747
+ : tNav("backTo", {
748
+ name: backLinkName(parent, {
749
+ navLabels: navPathLabels,
750
+ titles,
751
+ siteName: brand.siteName,
752
+ }),
753
+ }),
738
754
  returnLabel: tNav("home"),
739
755
  };
740
756
  }
741
757
 
742
- // The site's own name (#6942) — `SITE_NAME` resolves from `_site.mdx`'s
743
- // `siteName:`, so a customer's footer never carries the kit vendor's name.
744
- // The holder is `siteIdentity.legalName` when declared (#7796), else the name.
745
- const copyrightText = `© ${new Date().getFullYear()} ${COPYRIGHT_HOLDER}. All rights reserved.`;
758
+ // The site's own name (#6942) — the brand's name resolves from `_site.mdx`'s
759
+ // `siteName:` (or the hub's identity, #11456), so a customer's footer never
760
+ // carries the kit vendor's name. The holder is the identity's `legalName`
761
+ // when declared (#7796), else the name.
762
+ const copyrightText = `© ${new Date().getFullYear()} ${brand.copyrightHolder}. All rights reserved.`;
746
763
 
747
764
  // Footer legal links (#5612 D3). The centered variant folds in FAQ — the
748
765
  // roster's third always-scaffolded core route (`/faq`, alongside `/privacy`
@@ -974,7 +991,7 @@ export default async function LocaleLayout({
974
991
  itemLabels={navLabels.items}
975
992
  navItems={publicNavItems}
976
993
  columns={footerColumnDefs}
977
- siteName={SITE_NAME}
994
+ siteName={brand.siteName}
978
995
  logo={brandLogo}
979
996
  wordmark={brandWordmark}
980
997
  social={[...socialLinks]}
@@ -50,7 +50,11 @@ import { createHmac } from "node:crypto";
50
50
  import { readFileSync } from "node:fs";
51
51
  import { join } from "node:path";
52
52
 
53
- import { contentListTag, contentPageTag } from "@working-theory/page-renderer";
53
+ import {
54
+ contentListTag,
55
+ contentPageTag,
56
+ siteConfigTag,
57
+ } from "@working-theory/page-renderer";
54
58
  import { revalidateTag } from "next/cache";
55
59
  import * as ts from "typescript";
56
60
 
@@ -538,6 +542,57 @@ describe("POST /api/revalidate", () => {
538
542
 
539
543
  // --- #5902: replay window, signed event, bounded fields ------------------
540
544
 
545
+ describe("#11456 D5, AC-3 — the site-config event purges the hub-read tag", () => {
546
+ const SITE_CONFIG_BODY = { workspaceId: "wksp_fixture" };
547
+
548
+ it("a correctly signed site-config delivery purges siteConfigTag() with { expire: 0 } and no content tag", async () => {
549
+ const response = await POST(signedRequest(SITE_CONFIG_BODY, SECRET, "site-config"));
550
+
551
+ expect(response.status).toBe(200);
552
+ await expect(response.json()).resolves.toEqual({ revalidated: true });
553
+ expect(mockRevalidateTag).toHaveBeenCalledTimes(1);
554
+ expect(mockRevalidateTag).toHaveBeenCalledWith(siteConfigTag(), { expire: 0 });
555
+ expect(siteConfigTag()).toBe("site-config:default");
556
+ const info = (console.info as jest.Mock).mock.calls[0][0] as string;
557
+ expect(info).toContain('"event":"site-config"');
558
+ expect(info).toContain('"workspaceId":"wksp_fixture"');
559
+ });
560
+
561
+ it.each([
562
+ ["a type key", { workspaceId: "wksp_fixture", type: "Service" }],
563
+ ["the publish body", VALID_BODY],
564
+ ["no workspaceId", {}],
565
+ ["a non-string workspaceId", { workspaceId: 7 }],
566
+ ["a workspaceId over 64 characters", { workspaceId: "w".repeat(65) }],
567
+ ])("a correctly signed site-config body with %s is 400", async (_label, body) => {
568
+ const response = await POST(signedRequest(body, SECRET, "site-config"));
569
+ expect(response.status).toBe(400);
570
+ await expect(response.json()).resolves.toEqual({ error: "invalid_body" });
571
+ expect(mockRevalidateTag).not.toHaveBeenCalled();
572
+ });
573
+
574
+ it("a site-config delivery with a bad signature is 401", async () => {
575
+ const response = await POST(signedRequest(SITE_CONFIG_BODY, WRONG_SECRET, "site-config"));
576
+ expect(response.status).toBe(401);
577
+ expect(mockRevalidateTag).not.toHaveBeenCalled();
578
+ });
579
+
580
+ it("a site-config body signed as publish is not a site-config purge", async () => {
581
+ const rawBody = JSON.stringify(SITE_CONFIG_BODY);
582
+ const timestamp = String(nowSeconds());
583
+ const response = await POST(
584
+ makeRequest({
585
+ rawBody,
586
+ signature: sign(rawBody, SECRET, timestamp, "publish"),
587
+ event: "site-config",
588
+ timestamp,
589
+ }),
590
+ );
591
+ expect(response.status).toBe(401);
592
+ expect(mockRevalidateTag).not.toHaveBeenCalled();
593
+ });
594
+ });
595
+
541
596
  describe("#5902 — the timestamp and event are signed, and the fields are bounded", () => {
542
597
  it("accepts a timestamp just inside the 5-minute tolerance, either side", async () => {
543
598
  for (const offset of [-(TOLERANCE_SECONDS - 5), TOLERANCE_SECONDS - 5]) {
@@ -11,9 +11,10 @@
11
11
  * apps/api (ADR 0002, headless-first).
12
12
  *
13
13
  * The wire contract is #5851's as amended by #5902 (its spec's D1/D2): POST;
14
- * body the four-key JSON { workspaceId, type, slug, locale }; headers
14
+ * body the four-key JSON { workspaceId, type, slug, locale } (the one-key
15
+ * { workspaceId } for `site-config`, below); headers
15
16
  * `x-ailk-revalidate-timestamp: <unix seconds>`,
16
- * `x-ailk-revalidate-event: publish | unpublish` and
17
+ * `x-ailk-revalidate-event: publish | unpublish | site-config` and
17
18
  * `x-ailk-revalidate-signature: sha256=<lowercase hex>` — HMAC-SHA256 over
18
19
  * `v0:{timestamp}:{event}:{rawBody}`.
19
20
  *
@@ -40,6 +41,15 @@
40
41
  * can forge another page's tag. A page tag over Next's 256-character limit is
41
42
  * a 400 too — the read path cannot cache under such a tag either.
42
43
  *
44
+ * THE SITE-CONFIG EVENT (#11456, spec
45
+ * docs/specs/11456-a-hub-connected-site-reads-spec.md D5) — a third signed
46
+ * event, sent after the workspace's identity or seo is saved. Same headers
47
+ * and base string; the body is exactly `{ workspaceId }` (a string of at most
48
+ * 64 characters, no other key — else 400). It purges `siteConfigTag()`, the
49
+ * tag `lib/hub-site-config.ts` caches the hub read under, and no content tag.
50
+ * `workspaceId` is logged, never compared or tagged: the signing secret
51
+ * already names the site.
52
+ *
43
53
  * PII / secret boundary (FR9): no log line carries the secret, the signature
44
54
  * header value, the request body, or page content.
45
55
  */
@@ -49,7 +59,11 @@ import {
49
59
  SCHEMA_ORG_TYPES,
50
60
  SLUG_PATTERN,
51
61
  } from "@working-theory/content-adapters";
52
- import { contentListTag, contentPageTag } from "@working-theory/page-renderer";
62
+ import {
63
+ contentListTag,
64
+ contentPageTag,
65
+ siteConfigTag,
66
+ } from "@working-theory/page-renderer";
53
67
  import { localeSchema } from "@working-theory/validation";
54
68
  import { revalidateTag } from "next/cache";
55
69
  import { z } from "zod";
@@ -77,6 +91,11 @@ const bodySchema = z.object({
77
91
  locale: localeSchema,
78
92
  });
79
93
 
94
+ /** The `site-config` event's body (#11456 D5): its one key, bounded, nothing else. */
95
+ const siteConfigBodySchema = z
96
+ .object({ workspaceId: z.string().max(64) })
97
+ .strict();
98
+
80
99
  /** next@16.3.3 `NEXT_CACHE_TAG_MAX_LENGTH` (dist/lib/constants.js). */
81
100
  const CACHE_TAG_MAX_LENGTH = 256;
82
101
 
@@ -148,7 +167,11 @@ export async function POST(request: Request): Promise<Response> {
148
167
 
149
168
  const rawEvent = request.headers.get(EVENT_HEADER);
150
169
  const event =
151
- rawEvent === "publish" || rawEvent === "unpublish" ? rawEvent : "unknown";
170
+ rawEvent === "publish" ||
171
+ rawEvent === "unpublish" ||
172
+ rawEvent === "site-config"
173
+ ? rawEvent
174
+ : "unknown";
152
175
 
153
176
  /**
154
177
  * The one place a line is emitted (FR8), so the `[revalidate]` prefix, the
@@ -197,6 +220,24 @@ export async function POST(request: Request): Promise<Response> {
197
220
  return Response.json({ error: "invalid_signature" }, { status: 401 });
198
221
  }
199
222
 
223
+ if (event === "site-config") {
224
+ let parsed: unknown;
225
+ try {
226
+ parsed = JSON.parse(rawBody);
227
+ } catch {
228
+ parsed = undefined;
229
+ }
230
+ const siteConfig = siteConfigBodySchema.safeParse(parsed);
231
+ if (!siteConfig.success) {
232
+ log("warn", { status: 400 });
233
+ return Response.json({ error: "invalid_body" }, { status: 400 });
234
+ }
235
+ // The tag `lib/hub-site-config.ts` reads under — one builder, one process.
236
+ revalidateTag(siteConfigTag(), { expire: 0 });
237
+ log("info", { status: 200, workspaceId: siteConfig.data.workspaceId });
238
+ return Response.json({ revalidated: true }, { status: 200 });
239
+ }
240
+
200
241
  const body = parseBody(rawBody);
201
242
  if (body === null) {
202
243
  log("warn", { status: 400 });
@@ -33,6 +33,17 @@ jest.mock("../../../lib/modules.generated", () => ({
33
33
  // eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
34
34
  jest.mock("../../../lib/site-listing", () => ({ __esModule: true, SITE_LISTING: {} }));
35
35
 
36
+ // #11456 — the hub read's HTTP call; the rest of the client stays real, so
37
+ // `sendsSpokeKey` reads the env. `next/cache` runs the read uncached.
38
+ const mockSiteConfigGet = jest.fn();
39
+ jest.mock("@working-theory/api-client", () => ({
40
+ ...jest.requireActual("@working-theory/api-client"),
41
+ siteConfig: { get: (...args: unknown[]) => mockSiteConfigGet(...args) },
42
+ }));
43
+ jest.mock("next/cache", () => ({
44
+ unstable_cache: (fn: () => Promise<unknown>) => fn,
45
+ }));
46
+
36
47
  type Route = typeof import("../route");
37
48
 
38
49
  const BASE = "https://example.com";
@@ -130,3 +141,45 @@ describe.each(ROUTES)("GET /llms.txt (%s) — the site listing (#10940)", (path)
130
141
  expect(text).not.toContain("/thanks/projects-approved");
131
142
  });
132
143
  });
144
+
145
+ describe("the llms.txt heading — a hub-connected site's name (#11456 D4, AC-2)", () => {
146
+ const KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
147
+ const identity = (name: string) => ({
148
+ ok: true,
149
+ body: { identity: { kind: "Organization", name, url: "https://elsewhere.example" }, seo: null },
150
+ });
151
+
152
+ beforeEach(() => {
153
+ process.env.CONTENT_ADAPTER = "database";
154
+ process.env.NEXT_PUBLIC_BASE_URL = BASE;
155
+ process.env.AILK_API_URL = "https://hub.example";
156
+ mockSiteConfigGet.mockReset();
157
+ });
158
+ afterEach(() => {
159
+ delete process.env.CONTENT_ADAPTER;
160
+ delete process.env.NEXT_PUBLIC_BASE_URL;
161
+ delete process.env.AILK_API_URL;
162
+ delete process.env.AILK_SPOKE_KEY;
163
+ });
164
+
165
+ it("carries the hub name on a hub-connected site", async () => {
166
+ process.env.AILK_SPOKE_KEY = KEY;
167
+ mockSiteConfigGet.mockResolvedValue(identity("Hub Co"));
168
+ expect((await llms("../route", PUBLIC_ROWS)).split("\n")[0]).toBe("# Hub Co — content index");
169
+ });
170
+
171
+ it("a hub name holding a newline heads llms.txt on one line", async () => {
172
+ process.env.AILK_SPOKE_KEY = KEY;
173
+ mockSiteConfigGet.mockResolvedValue(identity("A\nB"));
174
+ const text = await llms("../route", PUBLIC_ROWS);
175
+ expect(text.split("\n")[0]).toBe("# A B — content index");
176
+ expect(text.split("\n")[1]).toBe("");
177
+ });
178
+
179
+ it("carries SITE_NAME on a site that is not hub-connected, and never calls the hub", async () => {
180
+ mockSiteConfigGet.mockResolvedValue(identity("Hub Co"));
181
+ const { SITE_NAME } = jest.requireActual<typeof import("../../../lib/site-brand")>("../../../lib/site-brand");
182
+ expect((await llms("../route", PUBLIC_ROWS)).split("\n")[0]).toBe(`# ${SITE_NAME} — content index`);
183
+ expect(mockSiteConfigGet).not.toHaveBeenCalled();
184
+ });
185
+ });
@@ -49,7 +49,7 @@ import {
49
49
  type DocsIndexPage,
50
50
  } from "../../lib/docs-index";
51
51
  import { PUBLIC_PAGES } from "../../lib/modules.generated";
52
- import { SITE_NAME } from "../../lib/site-brand";
52
+ import { resolveSiteBrand } from "../../lib/site-brand";
53
53
  import { SITE_LISTING } from "../../lib/site-listing";
54
54
  import { pagePathFor, resolveBaseUrl } from "../../src/lib/routes";
55
55
 
@@ -97,7 +97,10 @@ export function createLlmsHandler(deps: LlmsHandlerDeps = {}) {
97
97
  if (!(await isDiscoverable())) return new Response(null, { status: 404, headers: { "cache-control": "no-store" } });
98
98
  const adapter = resolveAdapter();
99
99
  const baseUrl = resolveBaseUrl();
100
- const lines: string[] = [`# ${SITE_NAME} — content index`, ""];
100
+ const lines: string[] = [
101
+ `# ${(await resolveSiteBrand()).siteName} — content index`,
102
+ "",
103
+ ];
101
104
 
102
105
  // llms.txt is default-locale-only per Phase 3 roadmap §3 (AEO MVP is
103
106
  // default-locale; per-locale AEO grading is deferred). Pass the default