create-ailk 0.47.0 → 0.48.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.
Files changed (137) hide show
  1. package/README.md +192 -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 +1 -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 +807 -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 +42 -41
  59. package/dist/site-chrome.js +51 -70
  60. package/dist/site-fonts.d.ts +14 -14
  61. package/dist/site-fonts.js +9 -4
  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 +11 -4
  98. package/templates/apps/api/CLAUDE.md +6 -4
  99. package/templates/apps/api/src/lib/__mocks__/prisma.ts +15 -5
  100. package/templates/apps/mcp/CLAUDE.md +4 -2
  101. package/templates/apps/web/.env.example +10 -3
  102. package/templates/apps/web/CLAUDE.md +14 -3
  103. package/templates/apps/web/app/[locale]/layout.tsx +53 -50
  104. package/templates/apps/web/app/not-found.tsx +11 -11
  105. package/templates/apps/web/auth.ts +48 -35
  106. package/templates/apps/web/jest.config.cjs +5 -0
  107. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +179 -31
  108. package/templates/apps/web/lib/__tests__/library-fonts.test.ts +35 -0
  109. package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +71 -32
  110. package/templates/apps/web/lib/__tests__/page-chrome.test.ts +123 -26
  111. package/templates/apps/web/lib/__tests__/section-look.test.ts +150 -0
  112. package/templates/apps/web/lib/__tests__/site-theme.test.ts +81 -289
  113. package/templates/apps/web/lib/deck-page.ts +3 -10
  114. package/templates/apps/web/lib/deploy-fonts.ts +12 -0
  115. package/templates/apps/web/lib/hub-site-config.ts +97 -14
  116. package/templates/apps/web/lib/library-fonts.ts +41 -0
  117. package/templates/apps/web/lib/mcp-oauth.ts +11 -4
  118. package/templates/apps/web/lib/page-chrome.ts +52 -34
  119. package/templates/apps/web/lib/section-look.ts +28 -0
  120. package/templates/apps/web/lib/site-design.ts +205 -0
  121. package/templates/apps/web/lib/site-theme-head.ts +98 -13
  122. package/templates/apps/web/lib/site-theme.ts +40 -62
  123. package/templates/apps/web/messages/en.json +0 -6
  124. package/templates/apps/web/next.config.mjs +195 -6
  125. package/templates/apps/web/package.json +2 -0
  126. package/templates/apps/web/site-pages.config.tsx +4 -2
  127. package/templates/content/_site.mdx +0 -26
  128. package/templates/design.yaml +75 -0
  129. package/templates/project.yaml +14 -0
  130. package/versions.json +52 -51
  131. package/site-templates/marketing-site/DESIGN.md +0 -259
  132. package/site-templates/marketing-site-free/DESIGN.md +0 -259
  133. package/site-templates/saas-product/DESIGN.md +0 -259
  134. package/templates/apps/web/lib/__tests__/deck-page.test.ts +0 -288
  135. package/templates/apps/web/lib/__tests__/site-theme-head.test.ts +0 -70
  136. package/templates/apps/web/lib/site-chrome.ts +0 -46
  137. package/templates/apps/web/lib/site-fonts.ts +0 -15
@@ -1,42 +1,28 @@
1
1
  /**
2
- * Round trip: the real `content/_site.mdx` → the emitted CSS custom properties.
2
+ * `lib/site-theme.ts` reads the brand triad (`brand:`) of `content/_site.mdx`
3
+ * and nothing else: `theme:` is not read since #12477 (D1, D2) — a site's look
4
+ * is its hub design record's, and with none the page renders the base look,
5
+ * `@working-theory/theme`'s defaults under this triad.
3
6
  *
4
- * This is the end-to-end claim the wiring makes — a site declares a theme and
5
- * the built page renders in those colours — asserted on the actual repo file
6
- * rather than a fixture, so deleting the `theme:` block would fail here.
7
- *
8
- * Every expectation is DERIVED from whichever `_site.mdx` the test reads, never
9
- * hard-coded (#6460). This file is snapshotted into `create-ailk`'s
10
- * `templates/`, so it runs against TWO different `_site.mdx` files: this
11
- * monorepo's, and the scaffold's own. Hard-coded values made it a snapshot of
12
- * one tree's palette masquerading as a round-trip test — green here, red in a
13
- * scaffold whose theme differs, which is exactly what happened when the base
14
- * scaffold moved to the black-on-white foundation. It also meant a CUSTOMER who
15
- * took the file's own invitation to "declare only what you change" got a red
16
- * suite for editing their own colours.
17
- *
18
- * Deriving keeps every claim the hard-coded form made — the mapping is applied,
19
- * the values reach the CSS, and nothing else moves — while making all three
20
- * true of any declared palette. Deleting the `theme:` block still fails, on the
21
- * `toBeDefined()` below.
7
+ * Every expectation about the real file is DERIVED from whichever `_site.mdx`
8
+ * the test reads, never hard-coded (#6460): this file is snapshotted into
9
+ * `create-ailk`'s `templates/`, so it runs against this monorepo's
10
+ * `_site.mdx` and against a scaffold's own.
22
11
  */
23
12
  import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
24
13
  import { tmpdir } from "node:os";
25
14
  import { join } from "node:path";
26
15
 
27
- import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
16
+ import { parse as parseYaml } from "yaml";
28
17
 
29
- import { PartialColorPaletteSchema, SiteThemeSchema } from "@working-theory/site-config/schema";
30
18
  import {
19
+ siteBrandToBrandTokens,
31
20
  siteColorTokenMap,
32
- siteThemeScopedDarkCss,
33
- siteThemeShapeCss,
34
- siteThemeToBrandTokens,
35
21
  themeToCssVarsBothModes,
36
- themeToScopedDarkCss,
37
22
  } from "@working-theory/theme";
23
+ import { COMPILED_PALETTE_KEYS } from "@working-theory/validation";
38
24
 
39
- import { loadSiteBrandTokens, loadSiteShapeCss } from "../site-theme";
25
+ import { loadSiteBrandTokens, loadSiteThemeBlocks } from "../site-theme";
40
26
 
41
27
  const REPO_CONTENT_ROOT = join(__dirname, "..", "..", "..", "..", "content");
42
28
 
@@ -50,243 +36,106 @@ function darkBlock(css: string): string {
50
36
  return css.slice(css.indexOf(':root[data-theme="dark"]'));
51
37
  }
52
38
 
53
- /** The two modes, as the palette and the emitted CSS both name them. */
54
- const MODES = ["light", "dark"] as const;
55
-
56
- type ModeColors = Partial<Record<(typeof MODES)[number], Record<string, string>>>;
39
+ const originalRoot = process.env.AILK_CONTENT_ROOT;
40
+ const tempRoots: string[] = [];
57
41
 
58
- /**
59
- * The colours the `_site.mdx` under test declares — `theme.colors` with any
60
- * `brand.colors` (the brand triad, #6820) layered over it per mode — as raw
61
- * SLOT names (`text`, `primary`), not token keys. Read with the same
62
- * frontmatter parse `site-theme.ts` uses, so the test cannot pass against a
63
- * file the implementation reads differently, and derived from the layered
64
- * result so a scaffold whose owner sets a triad stays green.
65
- */
66
- function declaredColors(): ModeColors {
67
- const raw = readFileSync(join(REPO_CONTENT_ROOT, "_site.mdx"), "utf8");
68
- const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/.exec(raw);
69
- const parsed = parseYaml(frontmatter?.[1] ?? "") as
70
- | { theme?: { colors?: ModeColors }; brand?: { colors?: ModeColors } }
71
- | null;
72
- const out: ModeColors = {};
73
- for (const mode of MODES) {
74
- const layered = { ...parsed?.theme?.colors?.[mode], ...parsed?.brand?.colors?.[mode] };
75
- if (Object.keys(layered).length > 0) out[mode] = layered;
76
- }
77
- return out;
78
- }
42
+ afterEach(() => {
43
+ if (originalRoot === undefined) delete process.env.AILK_CONTENT_ROOT;
44
+ else process.env.AILK_CONTENT_ROOT = originalRoot;
45
+ for (const root of tempRoots.splice(0)) rmSync(root, { recursive: true, force: true });
46
+ });
79
47
 
80
- /**
81
- * The CSS custom property a token key is emitted as — `fgOnBrand` →
82
- * `--color-fg-on-brand`. The colon in every call site anchors the match, so
83
- * `--color-surface` never collides with `--color-surface-secondary`.
84
- */
85
- function cssVar(tokenKey: string): string {
86
- return `--color-${tokenKey.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`;
48
+ function useSiteMdx(frontmatter: string): void {
49
+ const root = mkdtempSync(join(tmpdir(), "ailk-site-theme-"));
50
+ tempRoots.push(root);
51
+ writeFileSync(join(root, "_site.mdx"), `---\nsiteName: Test\n${frontmatter}---\n`, "utf8");
52
+ process.env.AILK_CONTENT_ROOT = root;
87
53
  }
88
54
 
89
- /** `{ [tokenKey]: value }` for one mode's declared slots, mapping applied. */
90
- function declaredTokens(mode: (typeof MODES)[number]): Record<string, string> {
91
- const out: Record<string, string> = {};
92
- for (const [slot, value] of Object.entries(declaredColors()[mode] ?? {})) {
93
- const tokenKey = siteColorTokenMap[slot as keyof typeof siteColorTokenMap];
94
- // A slot with no token counterpart cannot reach the CSS at all —
95
- // `siteThemeToBrandTokens` throws on it, which the schema's own tests
96
- // cover. Nothing to assert about it here.
97
- if (typeof tokenKey === "string") out[tokenKey] = value;
98
- }
99
- return out;
55
+ /** The layout's base-look emission (`lib/site-theme-head.ts`'s null branch). */
56
+ function layoutCss(): string {
57
+ const brand = loadSiteBrandTokens();
58
+ return themeToCssVarsBothModes(brand ? { brand } : {});
100
59
  }
101
60
 
102
61
  describe("loadSiteBrandTokens — the real content/_site.mdx", () => {
103
- const originalRoot = process.env.AILK_CONTENT_ROOT;
104
-
105
62
  beforeEach(() => {
106
63
  process.env.AILK_CONTENT_ROOT = REPO_CONTENT_ROOT;
107
64
  });
108
65
 
109
- afterEach(() => {
110
- if (originalRoot === undefined) delete process.env.AILK_CONTENT_ROOT;
111
- else process.env.AILK_CONTENT_ROOT = originalRoot;
66
+ it("is exactly the file's brand: triad, whatever its theme: says", () => {
67
+ const raw = readFileSync(join(REPO_CONTENT_ROOT, "_site.mdx"), "utf8");
68
+ const parsed = parseYaml(/^---\r?\n([\s\S]*?)\r?\n---/.exec(raw)?.[1] ?? "") as { brand?: object } | null;
69
+ const brand = parsed?.brand === undefined ? undefined : loadSiteThemeBlocks().brand;
70
+ expect(loadSiteBrandTokens()).toEqual(
71
+ brand === undefined ? undefined : siteBrandToBrandTokens(undefined, brand),
72
+ );
112
73
  });
74
+ });
113
75
 
114
- it("translates every colour the file declares into its mapped token", () => {
115
- const overlay = loadSiteBrandTokens();
116
- // The `theme:` block exists and produced an overlay — the claim the
117
- // hard-coded form made by naming values, kept without naming them.
118
- expect(overlay).toBeDefined();
119
-
120
- // `BrandTokenOverrides` is deliberately `Readonly<Record<string, unknown>>`
121
- // — `@working-theory/theme` cannot name the overlay's shape without
122
- // pinning it to one token set — so the test states the shape it asserts
123
- // about. The hard-coded form sidestepped this by comparing whole objects.
124
- const colors = (overlay?.["colors"] ?? {}) as Partial<
125
- Record<(typeof MODES)[number], Record<string, string>>
126
- >;
76
+ describe("loadSiteBrandTokens — theme: is not read (#12477 AC-4)", () => {
77
+ const THEME = [
78
+ "theme:",
79
+ " corners: square",
80
+ " darkBands: site",
81
+ " colors:",
82
+ " light:",
83
+ ' bg: "#123456"',
84
+ " dark:",
85
+ ' bg: "#1c1917"',
86
+ " band:",
87
+ ' bg: "#000001"',
88
+ "",
89
+ ].join("\n");
127
90
 
128
- let asserted = 0;
129
- for (const mode of MODES) {
130
- const expectedTokens = declaredTokens(mode);
131
- // Exactly the declared slots, nothing invented and nothing dropped.
132
- expect(colors[mode] ?? {}).toEqual(expectedTokens);
133
- asserted += Object.keys(expectedTokens).length;
134
- }
135
- // Non-vacuity: a file that declared nothing would satisfy the loop above.
136
- expect(asserted).toBeGreaterThan(0);
91
+ it("a theme: with no brand: emits the theme's defaults, byte for byte", () => {
92
+ useSiteMdx(THEME);
93
+ expect(loadSiteBrandTokens()).toBeUndefined();
94
+ expect(layoutCss()).toBe(themeToCssVarsBothModes({}));
137
95
  });
138
96
 
139
- it("reaches the emitted CSS custom properties", () => {
140
- const brand = loadSiteBrandTokens();
141
- const css = themeToCssVarsBothModes(brand ? { brand } : {});
142
- const blockFor = { light: lightBlock(css), dark: darkBlock(css) };
143
-
144
- let asserted = 0;
145
- for (const mode of MODES) {
146
- for (const [tokenKey, value] of Object.entries(declaredTokens(mode))) {
147
- expect(blockFor[mode]).toContain(`${cssVar(tokenKey)}: ${value};`);
148
- asserted += 1;
149
- }
97
+ it("a theme: beside a brand: leaks none of its colours, corners or band", () => {
98
+ useSiteMdx(`${THEME}brand:\n colors:\n light: { primary: "#0a3d62" }\n`);
99
+ const css = layoutCss();
100
+ expect(css).toContain("--color-brand: #0a3d62;");
101
+ for (const value of ["#123456", "#1c1917", "#000001", "--radius-control: 0;", ":not(:root)"]) {
102
+ expect(css).not.toContain(value);
150
103
  }
151
- expect(asserted).toBeGreaterThan(0);
104
+ expect(loadSiteThemeBlocks()).not.toHaveProperty("theme");
152
105
  });
153
106
 
154
- it("changes exactly the declared variables and nothing else", () => {
155
- const brand = loadSiteBrandTokens();
156
- const themed = themeToCssVarsBothModes(brand ? { brand } : {});
157
-
158
- // Rebuild the expectation from the DEFAULT CSS by overwriting, per mode
159
- // block, only the variables this site declares. Anything the overlay
160
- // touched beyond them makes the final equality fail — which is the whole
161
- // point of this case.
162
- const base = themeToCssVarsBothModes();
163
- const rewritten = { light: lightBlock(base), dark: darkBlock(base) };
164
- for (const mode of MODES) {
165
- for (const [tokenKey, value] of Object.entries(declaredTokens(mode))) {
166
- const pattern = new RegExp(`(${cssVar(tokenKey)}: )[^;]+;`);
167
- // The variable must exist in the default block for the overwrite to
168
- // mean anything — a replace with no target would weaken the equality
169
- // below into a tautology. Presence is the right check rather than
170
- // "the text changed": a site may legitimately declare a value that
171
- // already MATCHES the default (the black-on-white base declares
172
- // `bg: #ffffff`, which light mode already is), and that no-op is
173
- // correct, not vacuous.
174
- expect(rewritten[mode]).toMatch(pattern);
175
- rewritten[mode] = rewritten[mode].replace(pattern, `$1${value};`);
176
- }
177
-
178
- // `--color-surface-raised` is DERIVED, not independent: the emitter
179
- // resolves it from `surfaceSecondary` in light mode and from `surface`
180
- // in dark (`packages/theme/src/theme-to-css.ts`, and the rule is
181
- // documented at `site-theme.ts`'s header). So a site that declares
182
- // either of those moves it too, and the equality below has to account
183
- // for it — re-derived here from whatever the block now carries rather
184
- // than restated as a value, so the two cannot drift.
185
- //
186
- // Kept inside the total equality instead of excluded from it: this
187
- // variable is SUPPOSED to move, and excluding it would stop the test
188
- // noticing if it ever stopped moving.
189
- const derivedFrom = mode === "light" ? "surfaceSecondary" : "surface";
190
- const sourceValue = new RegExp(`${cssVar(derivedFrom)}: ([^;]+);`).exec(
191
- rewritten[mode],
192
- )?.[1];
193
- expect(sourceValue).toBeDefined();
194
- rewritten[mode] = rewritten[mode].replace(
195
- /(--color-surface-raised: )[^;]+;/,
196
- `$1${sourceValue};`,
197
- );
198
- }
199
-
200
- expect(themed).toBe(rewritten.light + rewritten.dark);
107
+ it("an invalid theme: no longer throws, since it is never parsed", () => {
108
+ useSiteMdx("theme:\n colors:\n light:\n nonsense: red\n");
109
+ expect(() => loadSiteBrandTokens()).not.toThrow();
110
+ expect(loadSiteBrandTokens()).toBeUndefined();
201
111
  });
202
112
 
203
- it("treats a bare `theme:` key as no theme, rather than throwing", () => {
204
- // YAML parses a dangling `theme:` to null. It is what commenting out the
205
- // block's children leaves behind, it means the same as an absent key, and
206
- // it must not escape as a ZodError out of an async Server Component.
207
- const root = mkdtempSync(join(tmpdir(), "ailk-site-theme-"));
208
- writeFileSync(
209
- join(root, "_site.mdx"),
210
- ["---", "siteName: Test", "theme:", "---", ""].join("\n"),
211
- "utf8",
212
- );
213
- process.env.AILK_CONTENT_ROOT = root;
214
-
113
+ it("treats a bare `brand:` key as no triad, rather than throwing", () => {
114
+ useSiteMdx("brand:\n");
215
115
  expect(loadSiteBrandTokens()).toBeUndefined();
216
116
  });
217
117
 
218
118
  it("returns undefined — and so emits the default CSS — when no config is readable", () => {
219
119
  process.env.AILK_CONTENT_ROOT = join(__dirname, "no-such-content-root");
220
-
221
- const brand = loadSiteBrandTokens();
222
- expect(brand).toBeUndefined();
223
- expect(themeToCssVarsBothModes(brand ? { brand } : {})).toBe(
224
- themeToCssVarsBothModes(),
225
- );
120
+ expect(loadSiteBrandTokens()).toBeUndefined();
121
+ expect(layoutCss()).toBe(themeToCssVarsBothModes());
226
122
  });
227
123
  });
228
124
 
229
125
  /**
230
- * The brand triad (#6820) — `brand.colors` / `brand.fonts` layered over the
231
- * theme. The golden: a site with a theme and no triad emits exactly the CSS
232
- * the pre-triad formula emitted; a site with a triad carries its fonts and
233
- * primary into both mode blocks.
126
+ * The brand triad (#6820) — `brand.colors` / `brand.fonts` over the theme's
127
+ * defaults: a site with a triad carries its fonts and primary into both mode
128
+ * blocks.
234
129
  */
235
130
  describe("loadSiteBrandTokens — the brand triad", () => {
236
- const originalRoot = process.env.AILK_CONTENT_ROOT;
237
- const tempRoots: string[] = [];
238
-
239
- afterEach(() => {
240
- if (originalRoot === undefined) delete process.env.AILK_CONTENT_ROOT;
241
- else process.env.AILK_CONTENT_ROOT = originalRoot;
242
- for (const root of tempRoots.splice(0)) rmSync(root, { recursive: true, force: true });
243
- });
244
-
245
- /** The repo's own `theme:` block, as YAML text and as parsed. */
246
- function repoTheme(): { yaml: string; parsed: unknown } {
247
- const raw = readFileSync(join(REPO_CONTENT_ROOT, "_site.mdx"), "utf8");
248
- const parsed = (
249
- parseYaml(/^---\r?\n([\s\S]*?)\r?\n---/.exec(raw)?.[1] ?? "") as { theme?: unknown }
250
- ).theme;
251
- return { yaml: stringifyYaml({ theme: parsed }), parsed };
252
- }
253
-
254
- function useSiteMdx(frontmatter: string): void {
255
- const root = mkdtempSync(join(tmpdir(), "ailk-site-triad-"));
256
- tempRoots.push(root);
257
- writeFileSync(join(root, "_site.mdx"), `---\nsiteName: Test\n${frontmatter}---\n`, "utf8");
258
- process.env.AILK_CONTENT_ROOT = root;
259
- }
260
-
261
- /** The layout's emission, verbatim (`app/[locale]/layout.tsx`). */
262
- function layoutCss(): string {
263
- const brand = loadSiteBrandTokens();
264
- return themeToCssVarsBothModes(brand ? { brand } : {}) + loadSiteShapeCss();
265
- }
266
-
267
- it("golden: the repo's theme with no triad emits the pre-triad CSS byte for byte", () => {
268
- const { yaml, parsed } = repoTheme();
269
- useSiteMdx(`${yaml}brand:\n logomark: { light: /logomark.svg, dark: /logomark.svg, alt: Test }\n`);
270
-
271
- const theme = SiteThemeSchema.parse(parsed);
272
- const before = siteThemeToBrandTokens(theme);
273
- // Mirrors loadSiteShapeCss: a `darkBands: site` theme (minimalism's, since #7739) also scopes
274
- // its dark ink; without it `scoped` is "" and the golden is the pre-triad CSS unchanged.
275
- const scoped = theme.darkBands === "site" && before ? siteThemeScopedDarkCss(theme, before) : "";
276
- expect(layoutCss()).toBe(
277
- themeToCssVarsBothModes(before ? { brand: before } : {}) + siteThemeShapeCss(theme) + scoped,
278
- );
279
- });
280
-
281
- it("golden: no _site.mdx emits the default CSS", () => {
282
- process.env.AILK_CONTENT_ROOT = join(__dirname, "no-such-content-root");
131
+ it("a logomark alone emits the default CSS", () => {
132
+ useSiteMdx("brand:\n logomark: { light: /logomark.svg, dark: /logomark.svg, alt: Test }\n");
283
133
  expect(layoutCss()).toBe(themeToCssVarsBothModes({}));
284
134
  });
285
135
 
286
136
  it("a declared triad reaches --font-display / --font-body and --color-brand in both blocks", () => {
287
- const { yaml } = repoTheme();
288
137
  useSiteMdx(
289
- `${yaml}brand:\n` +
138
+ "brand:\n" +
290
139
  ` colors:\n light: { primary: "#0a3d62" }\n dark: { primary: "#82ccdd" }\n` +
291
140
  ` fonts:\n display: "'Fraunces', Georgia, serif"\n body: "Inter, sans-serif"\n`,
292
141
  );
@@ -309,75 +158,18 @@ describe("loadSiteBrandTokens — the brand triad", () => {
309
158
  });
310
159
 
311
160
  /**
312
- * The twelve customer-facing colour slots live in `@working-theory/site-config`
313
- * and the map from them to token names lives in `@working-theory/theme`;
314
- * neither package may import the other, so nothing inside either can notice
315
- * the two lists drifting. `apps/web` imports both, so the cross-check lives
161
+ * The twelve customer-facing colour slots live in `@working-theory/validation`
162
+ * (`COMPILED_PALETTE_KEYS`) and the map from them to token names lives in
163
+ * `@working-theory/theme`, which takes only validation's types, so nothing
164
+ * inside either can notice the two lists drifting. `apps/web` imports both,
165
+ * so the cross-check lives
316
166
  * here — without it, a slot added to the palette schema would parse cleanly
317
167
  * and then throw "is not a theme colour" at render.
318
168
  */
319
169
  describe("the two vocabularies agree on which slots exist", () => {
320
170
  it("siteColorTokenMap covers exactly the schema's colour slots", () => {
321
171
  expect(Object.keys(siteColorTokenMap).sort()).toEqual(
322
- Object.keys(PartialColorPaletteSchema.shape).sort(),
172
+ [...COMPILED_PALETTE_KEYS].sort(),
323
173
  );
324
174
  });
325
175
  });
326
-
327
- // #7719 D6 — `darkBands: site` paints dark-scoped bands with the site's dark colours.
328
- describe("loadSiteShapeCss — darkBands", () => {
329
- const originalRoot = process.env.AILK_CONTENT_ROOT;
330
- const tempRoots: string[] = [];
331
-
332
- afterEach(() => {
333
- if (originalRoot === undefined) delete process.env.AILK_CONTENT_ROOT;
334
- else process.env.AILK_CONTENT_ROOT = originalRoot;
335
- for (const root of tempRoots.splice(0)) rmSync(root, { recursive: true, force: true });
336
- });
337
-
338
- function useSiteMdx(frontmatter: string): void {
339
- const root = mkdtempSync(join(tmpdir(), "ailk-site-dark-bands-"));
340
- tempRoots.push(root);
341
- writeFileSync(join(root, "_site.mdx"), `---\nsiteName: Test\n${frontmatter}---\n`, "utf8");
342
- process.env.AILK_CONTENT_ROOT = root;
343
- }
344
-
345
- const THEME = [
346
- "theme:",
347
- " corners: square",
348
- " colors:",
349
- " dark:",
350
- ' bg: "#1c1917"',
351
- ' text: "#fafaf9"',
352
- "",
353
- ].join("\n");
354
-
355
- it("without darkBands, the shape CSS is today's", () => {
356
- useSiteMdx(THEME);
357
- const theme = SiteThemeSchema.parse({ corners: "square", colors: { dark: { bg: "#1c1917", text: "#fafaf9" } } });
358
- expect(loadSiteShapeCss()).toBe(siteThemeShapeCss(theme));
359
- });
360
-
361
- it("with darkBands: site, ends with the scoped dark rule carrying the site's dark --color-bg", () => {
362
- useSiteMdx(`${THEME} darkBands: site\n`);
363
- const css = loadSiteShapeCss();
364
- const brand = loadSiteBrandTokens();
365
- expect(brand).toBeDefined();
366
- const scoped = themeToScopedDarkCss({ brand: brand! });
367
- expect(css.endsWith(scoped)).toBe(true);
368
- expect(scoped).toContain("--color-bg: #1c1917;");
369
- expect(css.startsWith(siteThemeShapeCss(SiteThemeSchema.parse({ corners: "square" })))).toBe(true);
370
- });
371
-
372
- it("with darkBands: site, the scoped rule leaves square corners to inherit from :root", () => {
373
- useSiteMdx(`${THEME} darkBands: site\n`);
374
- const scoped = loadSiteShapeCss().slice(loadSiteShapeCss().indexOf(":not(:root)"));
375
- expect(scoped).not.toMatch(/--radius-/);
376
- expect(scoped).not.toMatch(/--font-/);
377
- });
378
-
379
- it("darkBands: platform adds nothing", () => {
380
- useSiteMdx(`${THEME} darkBands: platform\n`);
381
- expect(loadSiteShapeCss()).not.toContain(':not(:root)');
382
- });
383
- });
@@ -24,7 +24,7 @@ import { headers } from "next/headers";
24
24
  import { cache } from "react";
25
25
 
26
26
  import { normalizeRoutePath } from "./closing-footer-path";
27
- import { siteChrome, type SiteChrome } from "./site-chrome";
27
+ import { BASE_SITE_LAYOUT, readSiteDesign, type SiteLayoutKnobs } from "./site-design";
28
28
 
29
29
  /**
30
30
  * The routes besides `[slug]` whose page can present as a deck: every
@@ -59,15 +59,6 @@ export const DECK_ROUTES = [
59
59
  "/working-agreement",
60
60
  ] as const;
61
61
 
62
- /** The widened type (#7719 D3, #7740 D8): present only when the design sets it. */
63
- type Chrome = SiteChrome & {
64
- deckGrounds?: DeckPageInputs["deckGrounds"];
65
- deckPresentation?: true;
66
- /** #8773 — present only when the design chooses bare slide anchors. */
67
- deckAnchors?: "bare";
68
- };
69
- const chrome: Chrome = siteChrome;
70
-
71
62
  function routeSegments(route: string): string[] {
72
63
  return route.split("/").filter((segment) => segment.length > 0);
73
64
  }
@@ -202,6 +193,8 @@ async function inputsFor(ctx: DeckPageContext): Promise<DeckPageInputs | null> {
202
193
  ) {
203
194
  return null;
204
195
  }
196
+ // #12473 D4 / #12477 D1 — the hub design record's layout, else the base look's.
197
+ const chrome: SiteLayoutKnobs = (await readSiteDesign())?.layout ?? BASE_SITE_LAYOUT;
205
198
  return {
206
199
  ...(chrome.deckGrounds !== undefined ? { deckGrounds: chrome.deckGrounds } : {}),
207
200
  deckPresentation: chrome.deckPresentation === true,
@@ -0,0 +1,12 @@
1
+ // deploy-fonts.ts — the faces outside the design library a hub design record
2
+ // names, built in at the site's next production build (#12473 D7, spec
3
+ // docs/specs/12473-a-site-renders-its-colours-spec.md).
4
+ //
5
+ // WRITTEN AT BUILD by `next.config.mjs` on a hub-connected production build:
6
+ // one `next/font/google` call per family the record's look or brand sources
7
+ // that `LIBRARY_FONTS` (@working-theory/theme) does not hold. Committed as the
8
+ // empty default, which every other build leaves untouched, so a local
9
+ // hub-connected `next build` can leave this file changed. Never hand-edit.
10
+
11
+ /** A built face: the CSS variable its family is read through, and the class that declares it. */
12
+ export const DEPLOY_FACES: ReadonlyMap<string, { variable: string; className: string }> = new Map();