create-ailk 0.46.6 → 0.48.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 (144) hide show
  1. package/README.md +180 -43
  2. package/component-catalog.json +223 -285
  3. package/component-catalog.md +1 -1
  4. package/dist/apply-design.d.ts +26 -68
  5. package/dist/apply-design.js +150 -322
  6. package/dist/cli.js +152 -17
  7. package/dist/compare-chrome.d.ts +108 -0
  8. package/dist/compare-chrome.js +481 -0
  9. package/dist/compare-look.d.ts +94 -0
  10. package/dist/compare-look.js +378 -0
  11. package/dist/copy.js +1 -1
  12. package/dist/design-compile.d.ts +17 -21
  13. package/dist/design-compile.js +32 -56
  14. package/dist/design-files.d.ts +93 -0
  15. package/dist/design-files.js +312 -0
  16. package/dist/design-home.d.ts +4 -2
  17. package/dist/design-home.js +88 -6
  18. package/dist/design-names.d.ts +13 -0
  19. package/dist/design-names.js +76 -0
  20. package/dist/design-package.d.ts +46 -56
  21. package/dist/design-package.js +285 -288
  22. package/dist/design-presets.d.ts +41 -0
  23. package/dist/design-presets.js +83 -4
  24. package/dist/design-scaffold.d.ts +12 -2
  25. package/dist/design-scaffold.js +72 -34
  26. package/dist/generated/design-settings.d.ts +56 -0
  27. package/dist/generated/design-settings.js +237 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +2 -2
  30. package/dist/inventory.d.ts +3 -2
  31. package/dist/inventory.js +10 -4
  32. package/dist/lib/design-checks.d.ts +46 -0
  33. package/dist/lib/design-checks.js +79 -1
  34. package/dist/lib/env-catalog.js +5 -1
  35. package/dist/lib/module-license-gate.d.ts +1 -1
  36. package/dist/lib/module-license-gate.js +1 -1
  37. package/dist/lib/render-verdict.d.ts +13 -1
  38. package/dist/lib/render-verdict.js +41 -1
  39. package/dist/look-hub.d.ts +44 -0
  40. package/dist/look-hub.js +130 -0
  41. package/dist/look-record.d.ts +35 -0
  42. package/dist/look-record.js +85 -0
  43. package/dist/look-samples.d.ts +66 -0
  44. package/dist/look-samples.js +456 -0
  45. package/dist/look-settings.d.ts +53 -0
  46. package/dist/look-settings.js +363 -0
  47. package/dist/module-architecture.js +12 -0
  48. package/dist/parse-args.d.ts +10 -6
  49. package/dist/parse-args.js +26 -13
  50. package/dist/programmatic.d.ts +1 -19
  51. package/dist/programmatic.js +65 -103
  52. package/dist/retired-design-bodies.d.ts +29 -0
  53. package/dist/retired-design-bodies.js +51 -0
  54. package/dist/seed-flows.d.ts +1 -1
  55. package/dist/seed-flows.js +12 -14
  56. package/dist/seed-workspace.d.ts +4 -1
  57. package/dist/seed-workspace.js +139 -17
  58. package/dist/site-chrome.d.ts +41 -41
  59. package/dist/site-chrome.js +50 -70
  60. package/dist/site-fonts.d.ts +10 -14
  61. package/dist/site-fonts.js +5 -1
  62. package/dist/starter-grid.d.ts +2 -2
  63. package/dist/strip-look-copies.d.ts +67 -0
  64. package/dist/strip-look-copies.js +591 -0
  65. package/dist/template-manifest.d.ts +6 -14
  66. package/dist/template-manifest.js +0 -9
  67. package/dist/template-record.d.ts +3 -1
  68. package/dist/template-record.js +3 -1
  69. package/dist/topology.d.ts +15 -0
  70. package/dist/topology.js +60 -0
  71. package/dist/update.d.ts +57 -1
  72. package/dist/update.js +742 -13
  73. package/package.json +3 -4
  74. package/site-templates/aliases/hub.TEMPLATE-MANIFEST.json +2 -31
  75. package/site-templates/designs/minimalism/DESIGN.md +163 -297
  76. package/site-templates/designs/minimalism/LOOK.md +42 -0
  77. package/site-templates/designs/minimalism/design.yaml +167 -0
  78. package/site-templates/designs/standard/DESIGN.md +145 -149
  79. package/site-templates/designs/standard/LOOK.md +42 -0
  80. package/site-templates/designs/standard/design.yaml +72 -0
  81. package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +2 -31
  82. package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +1 -25
  83. package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +2 -31
  84. package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +1 -25
  85. package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +2 -31
  86. package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +1 -25
  87. package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +2 -31
  88. package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +1 -25
  89. package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +2 -31
  90. package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +1 -25
  91. package/site-templates/shapes/person-service/content/_site.mdx +0 -26
  92. package/templates/.claude/rules/extending.md +3 -2
  93. package/templates/.env.example +11 -4
  94. package/templates/CLAUDE.md +1 -1
  95. package/templates/DESIGN.md +145 -149
  96. package/templates/README.md +15 -16
  97. package/templates/apps/api/.env.example +29 -4
  98. package/templates/apps/api/CLAUDE.md +7 -4
  99. package/templates/apps/api/src/__tests__/vercel-handler.test.ts +176 -2
  100. package/templates/apps/api/src/lib/__mocks__/prisma.ts +30 -4
  101. package/templates/apps/api/src/vercel-handler.ts +32 -2
  102. package/templates/apps/mcp/.env.example +8 -0
  103. package/templates/apps/mcp/CLAUDE.md +5 -3
  104. package/templates/apps/web/.env.example +10 -3
  105. package/templates/apps/web/CLAUDE.md +31 -4
  106. package/templates/apps/web/app/[locale]/layout.tsx +141 -77
  107. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +13 -3
  108. package/templates/apps/web/app/not-found.tsx +11 -11
  109. package/templates/apps/web/auth.ts +48 -35
  110. package/templates/apps/web/jest.config.cjs +5 -0
  111. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +542 -10
  112. package/templates/apps/web/lib/__tests__/library-fonts.test.ts +35 -0
  113. package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +233 -0
  114. package/templates/apps/web/lib/__tests__/page-chrome.test.ts +123 -26
  115. package/templates/apps/web/lib/__tests__/section-look.test.ts +150 -0
  116. package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +19 -1
  117. package/templates/apps/web/lib/__tests__/site-navigation.test.ts +288 -0
  118. package/templates/apps/web/lib/__tests__/site-theme.test.ts +81 -289
  119. package/templates/apps/web/lib/deck-page.ts +3 -10
  120. package/templates/apps/web/lib/deploy-fonts.ts +12 -0
  121. package/templates/apps/web/lib/hub-site-config.ts +237 -29
  122. package/templates/apps/web/lib/library-fonts.ts +41 -0
  123. package/templates/apps/web/lib/mcp-oauth.ts +11 -4
  124. package/templates/apps/web/lib/page-chrome.ts +105 -20
  125. package/templates/apps/web/lib/section-look.ts +28 -0
  126. package/templates/apps/web/lib/site-design.ts +205 -0
  127. package/templates/apps/web/lib/site-navigation.ts +208 -0
  128. package/templates/apps/web/lib/site-theme-head.ts +98 -13
  129. package/templates/apps/web/lib/site-theme.ts +40 -62
  130. package/templates/apps/web/messages/en.json +0 -6
  131. package/templates/apps/web/next.config.mjs +213 -11
  132. package/templates/apps/web/package.json +2 -0
  133. package/templates/apps/web/site-pages.config.tsx +4 -2
  134. package/templates/content/_site.mdx +0 -26
  135. package/templates/design.yaml +75 -0
  136. package/templates/project.yaml +14 -0
  137. package/versions.json +52 -51
  138. package/site-templates/marketing-site/DESIGN.md +0 -259
  139. package/site-templates/marketing-site-free/DESIGN.md +0 -259
  140. package/site-templates/saas-product/DESIGN.md +0 -259
  141. package/templates/apps/web/lib/__tests__/deck-page.test.ts +0 -288
  142. package/templates/apps/web/lib/__tests__/site-theme-head.test.ts +0 -70
  143. package/templates/apps/web/lib/site-chrome.ts +0 -46
  144. package/templates/apps/web/lib/site-fonts.ts +0 -15
@@ -0,0 +1,233 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
5
+ /**
6
+ * The hub design record's `chrome` over `_site.mdx`'s styles (#12470 D7,
7
+ * AC-7; after #12401 D4, AC-6): style is the design record's, and applies
8
+ * whenever the hub read carries one, whether or not a navigation record
9
+ * renders.
10
+ *
11
+ * `withDesignChrome` is pure; `resolveHomeChrome` reads the records
12
+ * through the hub read, so `@working-theory/api-client`'s `siteConfig.get`
13
+ * (the HTTP call to the hub) is doubled and `next/cache` runs the read
14
+ * uncached. `_site.mdx` is a scratch content root (`AILK_CONTENT_ROOT`).
15
+ */
16
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
17
+ import { tmpdir } from "node:os";
18
+ import { join } from "node:path";
19
+
20
+ const mockGet = jest.fn();
21
+ jest.mock("@working-theory/api-client", () => ({
22
+ ...jest.requireActual("@working-theory/api-client"),
23
+ siteConfig: { get: (...args: unknown[]) => mockGet(...args) },
24
+ }));
25
+ jest.mock("next/cache", () => ({
26
+ unstable_cache: (fn: () => Promise<unknown>) => fn,
27
+ }));
28
+ let mockPagePathThrows = false;
29
+ jest.mock("@working-theory/templates/routes", () => {
30
+ const actual = jest.requireActual("@working-theory/templates/routes");
31
+ return {
32
+ ...actual,
33
+ pagePath: (...args: Parameters<typeof actual.pagePath>) => {
34
+ if (mockPagePathThrows) throw new RangeError("forced");
35
+ return actual.pagePath(...args);
36
+ },
37
+ };
38
+ });
39
+
40
+ import { siteDesignSchema, siteNavigationSchema } from "@working-theory/validation";
41
+
42
+ import { __resetHubSiteForTests } from "../hub-site-config";
43
+ import {
44
+ resolveHomeChrome,
45
+ resolvePageChrome,
46
+ withDesignChrome,
47
+ type SiteChromeSettings,
48
+ } from "../page-chrome";
49
+
50
+ // #10704 — a fixture suite: its content is shaped for the mdx source.
51
+ process.env.CONTENT_ADAPTER = "mdx";
52
+
53
+ const FILE: SiteChromeSettings = {
54
+ headerStyle: "full",
55
+ footerStyle: "columns",
56
+ // A renamed family's `path` rides beside its styles at runtime (#11385).
57
+ families: { portfolio: { footer: "none", path: "/writing-samples" } } as SiteChromeSettings["families"],
58
+ };
59
+
60
+ /** A design record of its chrome alone. */
61
+ const designWith = (chrome: object) => siteDesignSchema.parse({ version: "1", from: null, chrome });
62
+ const STYLED = designWith({ header: "bare", families: { portfolio: { header: "none" } } });
63
+ const NAVIGATION = siteNavigationSchema.parse({ version: "1", header: { items: [] }, footer: { columns: [] } });
64
+ const KNOBS = { nav: "full" as const, home: "default" as const, footer: "columns" as const };
65
+
66
+ describe("withDesignChrome (#12470 D7, AC-7)", () => {
67
+ it("lays the record's set styles over the file's, keeping the family's own path", () => {
68
+ const before = structuredClone(FILE);
69
+ expect(withDesignChrome(FILE, STYLED.chrome)).toEqual({
70
+ headerStyle: "bare",
71
+ footerStyle: "columns",
72
+ families: { portfolio: { header: "none", footer: "none", path: "/writing-samples" } },
73
+ });
74
+ expect(FILE).toEqual(before);
75
+ });
76
+
77
+ it("a chrome setting no style answers the file settings unchanged", () => {
78
+ const before = structuredClone(FILE);
79
+ expect(withDesignChrome(FILE, {})).toEqual(FILE);
80
+ expect(FILE).toEqual(before);
81
+ });
82
+
83
+ it("a record style the file does not set is added; a style neither sets stays unset", () => {
84
+ const result = withDesignChrome({ families: {} }, designWith({ families: { blog: { footer: "closing" } } }).chrome);
85
+ expect(result).toEqual({ families: { blog: { footer: "closing" } } });
86
+ expect(result).not.toHaveProperty("headerStyle");
87
+ });
88
+
89
+ it("the footer style alone is laid over the file's", () => {
90
+ expect(withDesignChrome(FILE, { footer: "closing" })).toEqual({ ...FILE, footerStyle: "closing" });
91
+ });
92
+
93
+ it("chrome absent answers the file settings", () => {
94
+ expect(withDesignChrome(FILE, undefined)).toEqual(FILE);
95
+ });
96
+ });
97
+
98
+ describe("resolveHomeChrome with a hub-connected read (#12470 D7, AC-7)", () => {
99
+ const ENV = ["AILK_SPOKE_KEY", "AILK_API_URL", "AILK_CONTENT_ROOT"] as const;
100
+ const saved = new Map(ENV.map((k) => [k, process.env[k]]));
101
+ let root: string;
102
+
103
+ beforeEach(() => {
104
+ __resetHubSiteForTests();
105
+ mockGet.mockReset();
106
+ mockPagePathThrows = false;
107
+ root = mkdtempSync(join(tmpdir(), "page-chrome-nav-"));
108
+ writeFileSync(
109
+ join(root, "_site.mdx"),
110
+ "---\nsiteName: Acme\nheader:\n style: full\nfooter:\n style: columns\nportfolio:\n footer: none\n path: /writing-samples\n---\n",
111
+ );
112
+ process.env.AILK_CONTENT_ROOT = root;
113
+ jest.spyOn(console, "warn").mockImplementation(() => undefined);
114
+ });
115
+
116
+ afterEach(() => {
117
+ jest.restoreAllMocks();
118
+ rmSync(root, { recursive: true, force: true });
119
+ for (const [k, v] of saved) {
120
+ if (v === undefined) delete process.env[k];
121
+ else process.env[k] = v;
122
+ }
123
+ });
124
+
125
+ it("resolves the home's header from the design record, and a page's own frontmatter still wins", async () => {
126
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
127
+ process.env.AILK_API_URL = "https://hub.example";
128
+ mockGet.mockResolvedValue({
129
+ ok: true,
130
+ body: { identity: null, seo: null, navigation: { version: 2, record: NAVIGATION }, design: { version: 1, record: STYLED, settings: null, look: null } },
131
+ });
132
+
133
+ const home = await resolveHomeChrome("en", KNOBS);
134
+ expect(home.chrome.header).toBe("bare");
135
+ expect(home.site.families.portfolio).toEqual({ header: "none", footer: "none", path: "/writing-samples" });
136
+
137
+ const page = (header?: "full") =>
138
+ resolvePageChrome({
139
+ isHome: false,
140
+ homeIsDeck: false,
141
+ family: "portfolio",
142
+ page: header ? { header } : {},
143
+ site: home.site,
144
+ chrome: KNOBS,
145
+ closingListed: false,
146
+ });
147
+ expect(page("full").header).toBe("full");
148
+ expect(page().header).toBe("none");
149
+ expect(page().footer).toBe("none");
150
+ });
151
+
152
+ it("with no hub read, the home resolves from the file", async () => {
153
+ const home = await resolveHomeChrome("en", KNOBS);
154
+ expect(home.chrome.header).toBe("full");
155
+ expect(home.navigation).toBeNull();
156
+ expect(mockGet).not.toHaveBeenCalled();
157
+ });
158
+
159
+ it("applies the design record's styles when the hub read carries a design record and no navigation record", async () => {
160
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
161
+ process.env.AILK_API_URL = "https://hub.example";
162
+ mockGet.mockResolvedValue({
163
+ ok: true,
164
+ body: { identity: null, seo: null, navigation: null, design: { version: 1, record: STYLED, settings: null, look: null } },
165
+ });
166
+ const home = await resolveHomeChrome("en", KNOBS);
167
+ expect(home.navigation).toBeNull();
168
+ expect(home.chrome.header).toBe("bare");
169
+ expect(home.site.families.portfolio).toEqual({ header: "none", footer: "none", path: "/writing-samples" });
170
+ });
171
+
172
+ it("a design record's mark-only header resolves the home's header mark-only (AC-14)", async () => {
173
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
174
+ process.env.AILK_API_URL = "https://hub.example";
175
+ mockGet.mockResolvedValue({
176
+ ok: true,
177
+ body: {
178
+ identity: null,
179
+ seo: null,
180
+ navigation: null,
181
+ design: { version: 1, record: designWith({ header: "mark-only" }), settings: null, look: null },
182
+ },
183
+ });
184
+ const home = await resolveHomeChrome("en", KNOBS);
185
+ expect(home.chrome.header).toBe("mark-only");
186
+ expect(home.site.headerStyle).toBe("mark-only");
187
+ });
188
+
189
+ it("an older hub's navigation still carrying styles lays none: style is the design record's", async () => {
190
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
191
+ process.env.AILK_API_URL = "https://hub.example";
192
+ const legacy = { version: "1", header: { items: [], style: "bare" }, footer: { columns: [], style: "none" } };
193
+ mockGet.mockResolvedValue({ ok: true, body: { identity: null, seo: null, navigation: { version: 2, record: legacy } } });
194
+ const home = await resolveHomeChrome("en", KNOBS);
195
+ expect(home.navigation?.version).toBe(2);
196
+ expect(home.chrome.header).toBe("full");
197
+ });
198
+
199
+ it("answers the rendered record with its version and translation", async () => {
200
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
201
+ process.env.AILK_API_URL = "https://hub.example";
202
+ mockGet.mockResolvedValue({
203
+ ok: true,
204
+ body: { identity: null, seo: null, navigation: { version: 2, record: NAVIGATION } },
205
+ });
206
+ const home = await resolveHomeChrome("en", KNOBS);
207
+ expect(home.navigation?.version).toBe(2);
208
+ expect(home.navigation?.chrome.navItems).toEqual([]);
209
+ });
210
+
211
+ it("a navigation record the translator refuses renders the files' links, and the design record's styles still apply", async () => {
212
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
213
+ process.env.AILK_API_URL = "https://hub.example";
214
+ // A record the schema takes cannot fail the translator, so the refusal is
215
+ // forced through `pagePath`, the one call inside it a mock can reach.
216
+ mockPagePathThrows = true;
217
+ const refused = siteNavigationSchema.parse({
218
+ version: "1",
219
+ header: {
220
+ items: [{ kind: "link", label: { text: "Audit" }, target: { kind: "page", address: { type: "Service", slug: "audit" } } }],
221
+ },
222
+ footer: { columns: [] },
223
+ });
224
+ mockGet.mockResolvedValue({
225
+ ok: true,
226
+ body: { identity: null, seo: null, navigation: { version: 2, record: refused }, design: { version: 1, record: STYLED, settings: null, look: null } },
227
+ });
228
+ const home = await resolveHomeChrome("en", KNOBS);
229
+ expect(home.navigation).toBeNull();
230
+ expect(home.chrome.header).toBe("bare");
231
+ expect(home.site.families.portfolio).toEqual({ header: "none", footer: "none", path: "/writing-samples" });
232
+ });
233
+ });
@@ -5,30 +5,44 @@
5
5
  * (AC-4). The reads run over a scratch content root (`AILK_CONTENT_ROOT`),
6
6
  * so the real readers parse real files.
7
7
  */
8
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
8
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { tmpdir } from "node:os";
10
10
  import { join } from "node:path";
11
11
 
12
12
  import { FrontmatterSchema } from "@working-theory/content-adapters";
13
- import {
14
- FOOTER_STYLES,
15
- HEADER_STYLES,
16
- ROUTE_FAMILY_KEYS,
17
- } from "@working-theory/site-config/schema";
13
+ import { ROUTE_FAMILY_KEYS } from "@working-theory/site-config/schema";
14
+ import { compileDesignLayout } from "@working-theory/theme";
15
+ import { designSettingsSchema, FOOTER_STYLES, HEADER_STYLES } from "@working-theory/validation";
18
16
  import { ROUTES } from "@working-theory/templates/routes";
17
+ import { parse as parseYaml } from "yaml";
18
+
19
+ // #12473 — the hub read behind the design record: `siteConfig.get` is the
20
+ // HTTP call to the hub, and the data cache runs the read uncached.
21
+ const mockSiteConfigGet = jest.fn();
22
+ jest.mock("@working-theory/api-client", () => ({
23
+ ...jest.requireActual("@working-theory/api-client"),
24
+ sendsSpokeKey: () => (process.env.AILK_SPOKE_KEY ?? "") !== "",
25
+ siteConfig: { get: (...args: unknown[]) => mockSiteConfigGet(...args) },
26
+ }));
27
+ jest.mock("next/cache", () => ({
28
+ unstable_cache: (fn: () => Promise<unknown>) => fn,
29
+ }));
30
+
31
+ import { __resetHubSiteForTests } from "../hub-site-config";
19
32
 
20
33
  import {
21
34
  chromePageCandidates,
22
35
  readClosingFooterSettings,
23
36
  readSiteChromeSettings,
24
37
  resolveChromePage,
38
+ resolveHomeChrome,
25
39
  resolveHomeLayout,
26
40
  resolvePageChrome,
27
41
  routeFamilyOf,
28
42
  type PageChromeInput,
29
43
  type SiteChromeSettings,
30
44
  } from "../page-chrome";
31
- import type { SiteChrome } from "../site-chrome";
45
+ import { BASE_SITE_LAYOUT, type SiteChrome } from "../site-design";
32
46
 
33
47
  // #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
34
48
  process.env.CONTENT_ADAPTER = "mdx";
@@ -49,7 +63,7 @@ describe("route families (#10049 AC-2)", () => {
49
63
  expect([...ROUTE_FAMILY_KEYS]).toEqual(hubs);
50
64
  });
51
65
 
52
- it("the page frontmatter's header and footer enums equal the site's style lists", () => {
66
+ it("the page frontmatter's header and footer enums equal the one style lists (#12470 AC-14)", () => {
53
67
  const shape = FrontmatterSchema.shape;
54
68
  expect(shape.header.unwrap().options).toEqual([...HEADER_STYLES]);
55
69
  expect(shape.footer.unwrap().options).toEqual([...FOOTER_STYLES]);
@@ -104,7 +118,6 @@ const MINIMALISM: SiteChrome = {
104
118
  home: "deck",
105
119
  deckPresentation: true,
106
120
  innerPages: "bare",
107
- colorMode: "light",
108
121
  chromeStyle: "minimal",
109
122
  };
110
123
  const NOTHING: SiteChromeSettings = { families: {} };
@@ -151,29 +164,21 @@ describe("resolvePageChrome — the template level (#10049 AC-3)", () => {
151
164
  ["inner, bare inner pages", { chrome: MINIMALISM }, "bare", "line"],
152
165
  ["inner, otherwise", {}, "full", "columns"],
153
166
  ])("%s → (%j) %s / %s", (_name, over, header, footer) => {
154
- expect(resolvePageChrome(input(over))).toEqual({
155
- header,
156
- footer,
157
- headerFromTemplate: true,
158
- });
167
+ expect(resolvePageChrome(input(over))).toEqual({ header, footer });
159
168
  });
160
169
 
161
170
  it("a standard design whose home resolves deck keeps the full header and its own footer", () => {
162
171
  expect(
163
172
  resolvePageChrome(input({ isHome: true, homeIsDeck: true })),
164
- ).toEqual({
165
- header: "full",
166
- footer: "columns",
167
- headerFromTemplate: true,
168
- });
173
+ ).toEqual({ header: "full", footer: "columns" });
169
174
  });
170
175
 
171
- it("a minimalism site that turns its deck home off gets the full bar", () => {
176
+ it("a minimalism site that turns its deck home off gets its look's bar, mark-only", () => {
172
177
  expect(
173
178
  resolvePageChrome(
174
179
  input({ isHome: true, homeIsDeck: false, chrome: MINIMALISM }),
175
180
  ),
176
- ).toEqual({ header: "full", footer: "centered", headerFromTemplate: true });
181
+ ).toEqual({ header: "mark-only", footer: "centered" });
177
182
  });
178
183
 
179
184
  it("a closing-listed page whose own footer is columns ends on columns", () => {
@@ -185,6 +190,43 @@ describe("resolvePageChrome — the template level (#10049 AC-3)", () => {
185
190
  });
186
191
  });
187
192
 
193
+ describe("resolvePageChrome — the look's nav and footer (#12470 D7, AC-14)", () => {
194
+ it.each<[string, Partial<PageChromeInput>]>([
195
+ ["a default home", { isHome: true }],
196
+ ["an inner page that is not bare", {}],
197
+ ["a closing-listed page that is not bare", { closingListed: true }],
198
+ ])("%s takes the look's nav, every value of the one list", (_name, over) => {
199
+ for (const nav of HEADER_STYLES) {
200
+ expect(resolvePageChrome(input({ ...over, chrome: { ...STANDARD, nav } })).header).toBe(nav);
201
+ }
202
+ });
203
+
204
+ it("a default home and an inner page take the look's footer, every value of the one list; a closing-listed page keeps closing", () => {
205
+ for (const footer of FOOTER_STYLES) {
206
+ const chrome = { ...STANDARD, footer };
207
+ expect(resolvePageChrome(input({ isHome: true, chrome })).footer).toBe(footer);
208
+ expect(resolvePageChrome(input({ chrome })).footer).toBe(footer);
209
+ expect(resolvePageChrome(input({ closingListed: true, chrome })).footer).toBe("closing");
210
+ }
211
+ });
212
+
213
+ it("a deck home and a bare inner page keep their bare header whatever the look's nav, and line stays a resolved value only", () => {
214
+ const chrome = { ...MINIMALISM, nav: "none" as const };
215
+ expect(resolvePageChrome(input({ isHome: true, homeIsDeck: true, chrome })).header).toBe("bare");
216
+ expect(resolvePageChrome(input({ chrome }))).toEqual({ header: "bare", footer: "line" });
217
+ });
218
+
219
+ it("mark-only set by a site, a family or a page resolves the same mark-only a look's nav does", () => {
220
+ const fromLook = resolvePageChrome(input({ chrome: { ...STANDARD, nav: "mark-only" } })).header;
221
+ expect(fromLook).toBe("mark-only");
222
+ expect(resolvePageChrome(input({ site: { headerStyle: "mark-only", families: {} } })).header).toBe(fromLook);
223
+ expect(
224
+ resolvePageChrome(input({ family: "blog", site: { families: { blog: { header: "mark-only" } } } })).header,
225
+ ).toBe(fromLook);
226
+ expect(resolvePageChrome(input({ page: { header: "mark-only" } })).header).toBe(fromLook);
227
+ });
228
+ });
229
+
188
230
  describe("resolvePageChrome — most specific wins (#10049 AC-3)", () => {
189
231
  const site: SiteChromeSettings = {
190
232
  headerStyle: "none",
@@ -196,7 +238,6 @@ describe("resolvePageChrome — most specific wins (#10049 AC-3)", () => {
196
238
  expect(resolvePageChrome(input({ site }))).toEqual({
197
239
  header: "none",
198
240
  footer: "none",
199
- headerFromTemplate: false,
200
241
  });
201
242
  });
202
243
 
@@ -204,7 +245,6 @@ describe("resolvePageChrome — most specific wins (#10049 AC-3)", () => {
204
245
  expect(resolvePageChrome(input({ site, family: "blog" }))).toEqual({
205
246
  header: "bare",
206
247
  footer: "centered",
207
- headerFromTemplate: false,
208
248
  });
209
249
  });
210
250
 
@@ -217,7 +257,7 @@ describe("resolvePageChrome — most specific wins (#10049 AC-3)", () => {
217
257
  page: { header: "full", footer: "closing" },
218
258
  }),
219
259
  ),
220
- ).toEqual({ header: "full", footer: "closing", headerFromTemplate: false });
260
+ ).toEqual({ header: "full", footer: "closing" });
221
261
  });
222
262
 
223
263
  it("the axes resolve independently", () => {
@@ -232,10 +272,10 @@ describe("resolvePageChrome — most specific wins (#10049 AC-3)", () => {
232
272
  page: { footer: "none" },
233
273
  }),
234
274
  ),
235
- ).toEqual({ header: "none", footer: "none", headerFromTemplate: false });
275
+ ).toEqual({ header: "none", footer: "none" });
236
276
  expect(
237
277
  resolvePageChrome(input({ site: { headerStyle: "bare", families: {} } })),
238
- ).toEqual({ header: "bare", footer: "columns", headerFromTemplate: false });
278
+ ).toEqual({ header: "bare", footer: "columns" });
239
279
  });
240
280
 
241
281
  it("a family key for another family has no effect", () => {
@@ -545,3 +585,60 @@ describe("a renamed route family (#11385 AC-9)", () => {
545
585
  expect(list).not.toContainEqual({ type: "LandingPage", slug: "writing-samples" });
546
586
  });
547
587
  });
588
+
589
+ // ── #12473 AC-3 — the home's chrome from the hub design record's layout ─────
590
+
591
+ // The monorepo's design library; a scaffold ships this file (#10704) but not
592
+ // the library, so the block skips there (#12593).
593
+ const MINIMALISM_SETTINGS = join(__dirname, "../../../../packages/create-ailk/site-templates/designs/minimalism/design.yaml");
594
+
595
+ (existsSync(MINIMALISM_SETTINGS) ? describe : describe.skip)("resolveHomeChrome — the design record's layout knobs (#12473 AC-3)", () => {
596
+ /** Minimalism's settings with `deckAnchors: bare` added, parsed as the hub parses them. */
597
+ const settings = () => {
598
+ const parsed = parseYaml(readFileSync(MINIMALISM_SETTINGS, "utf8")) as { layout: Record<string, unknown> };
599
+ return designSettingsSchema.parse({ ...parsed, layout: { ...parsed.layout, deckAnchors: "bare" } });
600
+ };
601
+ const answer = (design: unknown) =>
602
+ mockSiteConfigGet.mockResolvedValue({ ok: true, body: { identity: null, seo: null, design } });
603
+ const ENV = ["AILK_SPOKE_KEY", "AILK_API_URL", "AILK_CONTENT_ROOT"] as const;
604
+ const saved = new Map(ENV.map((k) => [k, process.env[k]]));
605
+ let root: string;
606
+
607
+ beforeEach(() => {
608
+ __resetHubSiteForTests();
609
+ mockSiteConfigGet.mockReset();
610
+ root = mkdtempSync(join(tmpdir(), "home-knobs-"));
611
+ process.env.AILK_CONTENT_ROOT = root;
612
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
613
+ process.env.AILK_API_URL = "https://hub.example";
614
+ });
615
+
616
+ afterEach(() => {
617
+ rmSync(root, { recursive: true, force: true });
618
+ for (const [k, v] of saved) {
619
+ if (v === undefined) delete process.env[k];
620
+ else process.env[k] = v;
621
+ }
622
+ });
623
+
624
+ it("answers the record's deck home and its compiled knobs", async () => {
625
+ const worked = settings();
626
+ answer({ version: 2, record: { version: "1", from: { look: "minimalism", version: "1" } }, settings: worked, look: null });
627
+ const home = await resolveHomeChrome("en", BASE_SITE_LAYOUT);
628
+ expect(home.layout).toBe("deck");
629
+ expect(home.knobs).toStrictEqual(compileDesignLayout(worked.layout));
630
+ expect(home.chrome).toEqual({ header: "bare", footer: "closing" });
631
+ });
632
+
633
+ it.each<[string, () => void]>([
634
+ ["no record", () => answer(null)],
635
+ ["a record with settings: null and only a brand", () =>
636
+ answer({ version: 2, record: { version: "1", from: null, brand: { colors: { primary: "#1a7f37" } } }, settings: null, look: null })],
637
+ ])("with %s, answers the base look's values and no knobs", async (_label, arrange) => {
638
+ arrange();
639
+ const home = await resolveHomeChrome("en", BASE_SITE_LAYOUT);
640
+ expect(home.layout).toBe("default");
641
+ expect(home).not.toHaveProperty("knobs");
642
+ expect(home.chrome).toEqual({ header: "full", footer: "columns" });
643
+ });
644
+ });
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
5
+ /**
6
+ * The site registers its section look over its hub read (#12474 D3; AC-3):
7
+ * the reader answers the worked-out `settings.sections` of the hub read's
8
+ * `design`, never the record's own `settings`; nothing is registered, and no
9
+ * read made, on a site that is not hub-connected.
10
+ *
11
+ * External boundaries doubled: `@working-theory/api-client`'s
12
+ * `siteConfig.get` (the HTTP call to the hub) and `next/cache`'s
13
+ * `unstable_cache` (a pass-through, so each read reaches the double). The env
14
+ * decides `hubConnected()`; `@working-theory/page-renderer`'s registration is
15
+ * recorded.
16
+ */
17
+ import type { SectionLookReader } from "@working-theory/page-renderer";
18
+
19
+ const mockSetSectionLookReader = jest.fn<void, [SectionLookReader | undefined]>();
20
+ jest.mock("@working-theory/page-renderer", () => ({
21
+ ...jest.requireActual("@working-theory/page-renderer"),
22
+ setSectionLookReader: (reader: SectionLookReader | undefined) => mockSetSectionLookReader(reader),
23
+ }));
24
+
25
+ const mockGet = jest.fn();
26
+ jest.mock("@working-theory/api-client", () => ({
27
+ ...jest.requireActual("@working-theory/api-client"),
28
+ siteConfig: { get: (...args: unknown[]) => mockGet(...args) },
29
+ }));
30
+ jest.mock("next/cache", () => ({
31
+ unstable_cache: (fn: () => Promise<unknown>) => fn,
32
+ }));
33
+
34
+ const KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
35
+ const ENV_KEYS = ["AILK_SPOKE_KEY", "AILK_API_URL", "NEXT_PUBLIC_AILK_API_URL", "NEXT_PUBLIC_API_URL"] as const;
36
+ const savedEnv = new Map(ENV_KEYS.map((k) => [k, process.env[k]]));
37
+
38
+ const S = { HomePage: { hero: { variant: "centered", fill: "viewport" }, team: { variant: "with-portraits" } } };
39
+ const R = { HomePage: { hero: { variant: "split" } } };
40
+
41
+ /** A complete design's settings, as the hub works them out. */
42
+ function settings(sections?: unknown): Record<string, unknown> {
43
+ return {
44
+ name: "Minimalism",
45
+ version: 1,
46
+ description: "The minimalism design.",
47
+ colors: {
48
+ bg: "#ffffff",
49
+ fg: "#000000",
50
+ surface: "#ffffff",
51
+ "surface-secondary": "#ffffff",
52
+ border: "#000000",
53
+ "text-muted": "#333333",
54
+ brand: "#000000",
55
+ "fg-on-brand": "#ffffff",
56
+ accent: "#000000",
57
+ "bg-dark": "#000000",
58
+ "fg-dark": "#ffffff",
59
+ "surface-dark": "#000000",
60
+ "surface-secondary-dark": "#000000",
61
+ "border-dark": "#ffffff",
62
+ "text-muted-dark": "#cccccc",
63
+ "brand-dark": "#ffffff",
64
+ "fg-on-brand-dark": "#000000",
65
+ "accent-dark": "#ffffff",
66
+ },
67
+ typography: {
68
+ body: { fontFamily: "system-ui, sans-serif", fontSize: "1.125rem", fontWeight: 400, lineHeight: 1.5 },
69
+ },
70
+ rounded: { button: "0.5rem" },
71
+ spacing: { section: "7rem" },
72
+ layout: { nav: "full", footer: "columns", announcementBanner: false, home: "default" },
73
+ ...(sections === undefined ? {} : { sections }),
74
+ };
75
+ }
76
+
77
+ const LOOK = { name: "minimalism", version: "1", latest: "1", behind: false };
78
+
79
+ /** One site-config answer carrying `design`. */
80
+ function answer(design: unknown) {
81
+ return { ok: true, status: 200, body: { identity: null, seo: null, navigation: null, design } };
82
+ }
83
+
84
+ /** Load the module fresh and answer the reader it registered, if any. */
85
+ function load(): SectionLookReader | undefined {
86
+ mockSetSectionLookReader.mockClear();
87
+ jest.isolateModules(() => {
88
+ require("../section-look");
89
+ });
90
+ return mockSetSectionLookReader.mock.calls[0]?.[0];
91
+ }
92
+
93
+ beforeEach(() => {
94
+ mockGet.mockReset();
95
+ for (const k of ENV_KEYS) delete process.env[k];
96
+ process.env.AILK_SPOKE_KEY = KEY;
97
+ process.env.AILK_API_URL = "https://hub.example";
98
+ jest.spyOn(console, "warn").mockImplementation(() => undefined);
99
+ });
100
+
101
+ afterEach(() => {
102
+ jest.restoreAllMocks();
103
+ for (const [k, v] of savedEnv) {
104
+ if (v === undefined) delete process.env[k];
105
+ else process.env[k] = v;
106
+ }
107
+ });
108
+
109
+ describe("apps/web section look (#12474 AC-3)", () => {
110
+ it("answers the worked-out sections of a library-look record, which holds no settings of its own", async () => {
111
+ mockGet.mockResolvedValue(
112
+ answer({ version: 3, record: { version: "1", from: { look: "minimalism", version: "1" } }, settings: settings(S), look: LOOK }),
113
+ );
114
+ const reader = load();
115
+ expect(reader).toBeDefined();
116
+ expect(await reader!()).toEqual(S);
117
+ });
118
+
119
+ it("answers the worked-out sections, not the record's, for an own look", async () => {
120
+ mockGet.mockResolvedValue(
121
+ answer({ version: 1, record: { version: "1", from: null, settings: settings(R) }, settings: settings(S), look: null }),
122
+ );
123
+ expect(await load()!()).toEqual(S);
124
+ });
125
+
126
+ it.each([
127
+ ["no design", null],
128
+ ["worked-out settings of null", { version: 1, record: { version: "1", from: null }, settings: null, look: null }],
129
+ ["settings with no sections", { version: 1, record: { version: "1", from: null }, settings: settings(), look: null }],
130
+ ])("answers undefined with %s", async (_label, design) => {
131
+ mockGet.mockResolvedValue(answer(design));
132
+ expect(await load()!()).toBeUndefined();
133
+ });
134
+
135
+ it("registers nothing, and reads nothing, on a site that is not hub-connected", () => {
136
+ for (const k of ENV_KEYS) delete process.env[k];
137
+ expect(load()).toBeUndefined();
138
+ expect(mockSetSectionLookReader).not.toHaveBeenCalled();
139
+ expect(mockGet).not.toHaveBeenCalled();
140
+ });
141
+
142
+ it("reads the hub on each call, so a changed look reaches the next render", async () => {
143
+ const reader = load()!;
144
+ expect(mockGet).not.toHaveBeenCalled();
145
+ mockGet.mockResolvedValueOnce(answer({ version: 1, record: { version: "1", from: null }, settings: settings(S), look: null }));
146
+ mockGet.mockResolvedValueOnce(answer({ version: 2, record: { version: "1", from: null }, settings: settings(R), look: null }));
147
+ expect(await reader()).toEqual(S);
148
+ expect(await reader()).toEqual(R);
149
+ });
150
+ });
@@ -320,12 +320,30 @@ describe("the featureList registration with no content directory (#10644 AC-2)",
320
320
  expect(mockSiteConfigGet).toHaveBeenCalledTimes(1);
321
321
  });
322
322
 
323
+ // #12390 D2 — a single-tenant site (its own API's address, no key) reads
324
+ // its one workspace's identity through the same reader.
325
+ it("keyless with an API address: registers a reader carrying the workspace identity on the file's baseUrl", async () => {
326
+ hubConnect();
327
+ delete process.env.AILK_SPOKE_KEY;
328
+ delete process.env.NEXT_PUBLIC_SITE_URL;
329
+ load();
330
+ expect(calls("setSiteIdentityReader")).toHaveLength(1);
331
+ const reader = calls("setSiteIdentityReader")[0]![0] as () => Promise<unknown>;
332
+ await expect(reader()).resolves.toEqual({
333
+ siteName: "Hub Co",
334
+ baseUrl: ORIGIN,
335
+ identity: HUB_IDENTITY,
336
+ });
337
+ expect(mockSiteConfigGet).toHaveBeenCalledTimes(1);
338
+ });
339
+
323
340
  it.each([
324
341
  ["CONTENT_ADAPTER unset", () => delete process.env.CONTENT_ADAPTER],
325
342
  ["CONTENT_ADAPTER=database", () => (process.env.CONTENT_ADAPTER = "database")],
326
- ])("not hub-connected (no AILK_SPOKE_KEY, %s): registers no reader, and setSiteIdentity receives the file registration", (_label, arrange) => {
343
+ ])("not hub-connected (no AILK_SPOKE_KEY, no API address, %s): registers no reader, and setSiteIdentity receives the file registration", (_label, arrange) => {
327
344
  hubConnect();
328
345
  delete process.env.AILK_SPOKE_KEY;
346
+ delete process.env.AILK_API_URL;
329
347
  arrange();
330
348
  load();
331
349
  expect(calls("setSiteIdentityReader")).toEqual([]);