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
@@ -15,7 +15,8 @@
15
15
  * variable, else (for `--dry-run` only) the `AILK_API_URL=` line of
16
16
  * `apps/web/.env.local`, and must be `https:` (or `http:` on a loopback
17
17
  * host); a send whose origin only that file names is refused, because a
18
- * repo file never decides where the key goes (#9969 D8); the key comes from the
18
+ * repo file never decides where the key goes (#9969 D8), and so is a send to
19
+ * an origin other than the one that file names (#12477); the key comes from the
19
20
  * `AILK_SPOKE_KEY` environment variable and nowhere else. Every refusal is
20
21
  * thrown before the first request. The hub origin and its source are printed
21
22
  * before any request, so where the key goes is visible before it is sent.
@@ -32,7 +33,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync, } from
32
33
  import { join, resolve } from "node:path";
33
34
  import { parseArgs } from "node:util";
34
35
  import { ParseError } from "./parse-args.js";
35
- import { HUB_ORIGIN_ENV_VAR, TopologyError, normalizeHubUrl, readSiteTopology, } from "./topology.js";
36
+ import { HUB_ORIGIN_ENV_VAR, TopologyError, normalizeHubUrl, readSiteTopology, readWebEnvValue, spokeOriginMismatch, } from "./topology.js";
36
37
  /** The environment variable the spoke key is read from — and nowhere else. */
37
38
  export const SPOKE_KEY_ENV_VAR = "AILK_SPOKE_KEY";
38
39
  /** The header the key travels in (`packages/api-client`'s spoke header). */
@@ -107,16 +108,7 @@ function readDeclaredFlows(flowsDir) {
107
108
  // ── The hub origin ──────────────────────────────────────────────────────────
108
109
  /** The `AILK_API_URL=` value in `apps/web/.env.local`, if one is assigned. */
109
110
  function readEnvLocalHubUrl(targetDir) {
110
- const path = join(targetDir, "apps", "web", ".env.local");
111
- if (!existsSync(path))
112
- return undefined;
113
- const line = readFileSync(path, "utf8")
114
- .split(/\r?\n/)
115
- .map((l) => /^\s*(?:export\s+)?AILK_API_URL\s*=\s*(.*)$/.exec(l))
116
- .filter((m) => m !== null)
117
- .pop(); // dotenv: the last assignment wins
118
- const value = line?.[1]?.trim().replace(/^(["'])(.*)\1$/, "$2");
119
- return value !== undefined && value !== "" ? value : undefined;
111
+ return readWebEnvValue(targetDir, ".env.local", HUB_ORIGIN_ENV_VAR);
120
112
  }
121
113
  const HUB_SOURCES_HINT = `The hub origin comes from --hub-url, else the ${HUB_ORIGIN_ENV_VAR} environment variable, else the ${HUB_ORIGIN_ENV_VAR}= line of apps/web/.env.local.`;
122
114
  function resolveHub(targetDir, hubUrl, env) {
@@ -261,6 +253,11 @@ export async function seedFlows(opts) {
261
253
  if (hub.source === "apps/web/.env.local") {
262
254
  throw new SeedFlowsRefusedError(`seed-flows: the hub origin ${hub.origin} was read from apps/web/.env.local. Confirm it with --hub-url ${hub.origin} (or set ${HUB_ORIGIN_ENV_VAR}) — the spoke key is sent only to an origin you name. Nothing was sent.`);
263
255
  }
256
+ // …and only to the hub the spoke's own apps/web/.env.local names (#12477).
257
+ const mismatch = spokeOriginMismatch(targetDir, hub.origin);
258
+ if (mismatch !== undefined) {
259
+ throw new SeedFlowsRefusedError(`seed-flows: ${mismatch}. Nothing was sent.`);
260
+ }
264
261
  const key = env[SPOKE_KEY_ENV_VAR]?.trim() ?? "";
265
262
  if (key === "") {
266
263
  throw new SeedFlowsRefusedError(`seed-flows: set ${SPOKE_KEY_ENV_VAR} to the spoke key your hub issued. It is read from the environment only — never a flag or a file. Nothing was sent.`);
@@ -371,8 +368,9 @@ Arguments:
371
368
  <dir> The spoke site. Defaults to the current dir.
372
369
 
373
370
  Options:
374
- --hub-url <origin> The hub's origin. Else AILK_API_URL. The
375
- AILK_API_URL= line of apps/web/.env.local is read
371
+ --hub-url <origin> The hub's origin. Else AILK_API_URL. It must be
372
+ the origin the AILK_API_URL= line of
373
+ apps/web/.env.local names; that line alone is read
376
374
  for --dry-run only. https: only (http: on
377
375
  localhost or 127.0.0.1).
378
376
  --dry-run Check every flows/*.json and print what would be sent.
@@ -28,6 +28,8 @@ export interface SeedWorkspaceOptions {
28
28
  sleep?: (ms: number) => Promise<void>;
29
29
  /** Each report line as it happens; defaults to nothing. */
30
30
  onLine?: (line: string) => void;
31
+ /** The shipped designs a site's recorded look resolves from; defaults to this installer's own. */
32
+ designsDir?: string;
31
33
  }
32
34
  export declare function seedWorkspace(opts: SeedWorkspaceOptions): Promise<{
33
35
  result: ImportMdxResult;
@@ -54,6 +56,7 @@ export declare function scaffoldSeedPlan(input: ScaffoldSeedPlanInput): Scaffold
54
56
  export interface RunScaffoldSeedOptions extends ScaffoldSeedPlanInput {
55
57
  targetDir: string;
56
58
  onLine: (line: string) => void;
59
+ designsDir?: string;
57
60
  adapters?: MdxAdapterModule;
58
61
  fetch?: typeof globalThis.fetch;
59
62
  sleep?: (ms: number) => Promise<void>;
@@ -69,5 +72,5 @@ export interface SeedWorkspaceArgs {
69
72
  workspaceId: string | undefined;
70
73
  help: boolean;
71
74
  }
72
- export declare const SEED_WORKSPACE_HELP = "create-ailk seed-workspace \u2014 import a starter's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk seed-workspace [<dir>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --api-url <origin> The site's API origin. Else AILK_API_URL. https:\n only (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page is written to the workspace, and set\nLive when it has no Live version, through the API's content routes, with the\nagent key, which is read from AILK_AGENT_KEY only and needs the content-edit\nand content-publish grants, at Autonomous. Each page prints created, updated,\nunchanged, skipped or failed, so a re-run is safe. When every page is Live, the site\nswitches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value\neither already sets. The site's dependencies must be installed. Exit 0 when\nevery page was seeded, 1 when any failed, 2 on a refusal (nothing is sent).\n";
75
+ export declare const SEED_WORKSPACE_HELP = "create-ailk seed-workspace \u2014 import a starter's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk seed-workspace [<dir>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --api-url <origin> The site's API origin. Else AILK_API_URL. https:\n only (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page is written to the workspace, and set\nLive when it has no Live version, through the API's content routes, with the\nagent key, which is read from AILK_AGENT_KEY only and needs the content-edit\nand content-publish grants, at Autonomous. Each page prints created, updated,\nunchanged, skipped or failed, so a re-run is safe. When every page is Live, the site\nswitches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value\neither already sets. The site's dependencies must be installed.\n\nThen the look: the site's first design record, from the design and starter it\nwas scaffolded with, is written to the workspace \u2014 only where the workspace\nholds none, and never for a site that still carries its look files or a\nworkspace already in use. This step alone needs the key's site-design grant;\nwithout it the step is skipped and named. On a spoke, whose pages are its own\nfiles, only the look is seeded, into the workspace and at the hub its\napps/web env files name. Exit 0 when every page was seeded and the look written, kept or\nskipped, 1 when any failed, 2 on a refusal (nothing is sent).\n";
73
76
  export declare function parseSeedWorkspaceArgs(argv: string[]): SeedWorkspaceArgs;
@@ -19,12 +19,21 @@
19
19
  * source are printed before the first one. The importer owns the transport
20
20
  * (#10203 D5): bearer header only, no redirect, the key never printed.
21
21
  *
22
- * The scaffold-time step (D3, D6) runs only on a hub with an Admin
23
- * (`workspace` or `multi-tenant`), after `--install`, with all three
22
+ * The scaffold-time step (D3, D6) runs on a hub with an Admin (`workspace`
23
+ * or `multi-tenant`), and on a spoke, after `--install`, with all three
24
24
  * variables set; otherwise it prints why and the command that seeds and
25
- * switches later, or nothing on a site with no Admin. It never fails the
25
+ * switches later, or nothing on a site with neither. It never fails the
26
26
  * scaffold.
27
27
  *
28
+ * Then the look (#12477 D4, spec
29
+ * docs/specs/12477-retire-the-generated-look-files-spec.md): a new site's
30
+ * first hub design record, built from the design and starter it was
31
+ * scaffolded with (`look-record.ts`), written only where the workspace holds
32
+ * none and the site carries no look of its own — never over a stored record,
33
+ * never into a workspace already in use. A spoke's pages are its own files,
34
+ * so on a spoke only the look is seeded, and only into the workspace its own
35
+ * env files name.
36
+ *
28
37
  * Pure module: no `import.meta.url`, so jest can import it directly. `fetch`,
29
38
  * `sleep`, `env` and the adapter are injectable. Spec:
30
39
  * docs/specs/10204-seed-the-starter-s-roster-spec.md; the publish and the
@@ -33,10 +42,13 @@
33
42
  import { join, resolve } from "node:path";
34
43
  import { parseArgs } from "node:util";
35
44
  import { AddModuleRefusedError } from "./add-module-core.js";
45
+ import { shippedDesignsDir } from "./design-names.js";
36
46
  import { ImportMdxRefusedError, formatImportMdxReport, importMdx, loadSiteMdxAdapter, } from "./lib/import-mdx.js";
47
+ import { describeAnswer, designUrl, hubRequest, retiredLookSources, storedVersion, } from "./look-hub.js";
48
+ import { lookRecordFor, readLookInputs } from "./look-record.js";
37
49
  import { ParseError } from "./parse-args.js";
38
50
  import { readSiteRoster } from "./site-roster.js";
39
- import { HUB_ORIGIN_ENV_VAR, TopologyError, normalizeHubUrl, readSiteTopology, writeApiEnv, writeWebEnv, } from "./topology.js";
51
+ import { HUB_ORIGIN_ENV_VAR, TopologyError, normalizeHubUrl, readSiteTopology, spokeOriginMismatch, spokeWorkspaceMismatch, writeApiEnv, writeWebEnv, } from "./topology.js";
40
52
  /** The environment variable the agent key is read from — and nowhere else. */
41
53
  export const AGENT_KEY_ENV_VAR = "AILK_AGENT_KEY";
42
54
  /** The environment variable the workspace id is read from when no flag names one. */
@@ -87,12 +99,9 @@ export async function seedWorkspace(opts) {
87
99
  throw err;
88
100
  refuse(`${err.message}.`);
89
101
  }
90
- if (topology === "spoke") {
91
- refuse(`${opts.targetDir} is a spoke: its pages are its own MDX files, and its hub owns the workspace.`);
92
- }
93
102
  const apiKey = given(env[AGENT_KEY_ENV_VAR]);
94
103
  if (apiKey === undefined) {
95
- refuse(`set ${AGENT_KEY_ENV_VAR} to an agent key with the content-edit and content-publish grants, at Autonomous. It is read from the environment only — never a flag or a file.`);
104
+ refuse(`set ${AGENT_KEY_ENV_VAR} to an agent key with the content-edit and content-publish grants, at Autonomous (and the site-design grant, for the look). It is read from the environment only — never a flag or a file.`);
96
105
  }
97
106
  const workspaceId = given(opts.workspaceId) ?? given(env[WORKSPACE_ID_ENV_VAR]);
98
107
  if (workspaceId === undefined) {
@@ -113,6 +122,23 @@ export async function seedWorkspace(opts) {
113
122
  throw err;
114
123
  refuse(`the API origin must be an https: origin (http: only on a loopback host) with no path, query, fragment or credentials (from ${source}).`);
115
124
  }
125
+ const fetchImpl = opts.fetch ?? globalThis.fetch;
126
+ const designsDir = opts.designsDir ?? shippedDesignsDir();
127
+ const look = { targetDir, designsDir, origin, workspaceId, apiKey, fetchImpl, onLine };
128
+ // #12477 D4 — a spoke's pages are its own files: only its look is seeded,
129
+ // and only into the workspace and hub its own env files name.
130
+ if (topology === "spoke") {
131
+ const mismatch = spokeWorkspaceMismatch(targetDir, workspaceId) ?? spokeOriginMismatch(targetDir, origin);
132
+ if (mismatch !== undefined)
133
+ refuse(`${mismatch}.`);
134
+ onLine(`Seeding ${opts.targetDir}'s look into workspace ${workspaceId} at ${origin} (from ${source}) — a spoke's pages are its own files.`);
135
+ const result = {
136
+ pages: [],
137
+ counts: { created: 0, updated: 0, unchanged: 0, skipped: 0, failed: 0 },
138
+ };
139
+ const lookOk = await seedLook({ ...look, topology, workspaceHeldPages: false });
140
+ return { result, exitCode: lookOk ? 0 : 1 };
141
+ }
116
142
  onLine(`Seeding ${opts.targetDir} into workspace ${workspaceId} at ${origin} (from ${source}).`);
117
143
  const adapters = opts.adapters ?? (await loadSiteMdxAdapter(targetDir));
118
144
  const result = await importMdx({
@@ -154,7 +180,91 @@ export async function seedWorkspace(opts) {
154
180
  }
155
181
  onLine("Content source: content/ (unchanged) until every page is seeded and Live.");
156
182
  }
157
- return { result, exitCode: failed > 0 ? 1 : 0 };
183
+ const lookOk = await seedLook({ ...look, topology, workspaceHeldPages: updated + unchanged > 0 });
184
+ return { result, exitCode: failed > 0 || !lookOk ? 1 : 0 };
185
+ }
186
+ const IN_USE = "Look: not written — the workspace is already in use; import its look (#12476's runbook) or choose it on the Admin's Look page.";
187
+ /**
188
+ * Write the site's first hub design record (D4 steps 0–3). `false` only when
189
+ * the look was not written for a reason that fails the run: a hub answer
190
+ * that is neither the record nor a named skip.
191
+ */
192
+ async function seedLook(input) {
193
+ const { onLine } = input;
194
+ // Step 0 — not a new site: no design request.
195
+ if (retiredLookSources(input.targetDir).length > 0) {
196
+ onLine("Look: not written — this site still carries its look files; import it (#12476's runbook) instead.");
197
+ return true;
198
+ }
199
+ if (input.topology === "hub" && input.workspaceHeldPages) {
200
+ onLine("Look: not written — the workspace already held pages; import its look (#12476's runbook) or choose it on the Admin's Look page.");
201
+ return true;
202
+ }
203
+ let inputs;
204
+ try {
205
+ inputs = readLookInputs(input.targetDir, input.designsDir);
206
+ }
207
+ catch (err) {
208
+ // The site's design.yaml or manifest does not read: no record from it.
209
+ onLine(`Look: not written (the site's design does not read: ${err.message}).`);
210
+ return false;
211
+ }
212
+ if (inputs === undefined) {
213
+ onLine("Look: not written — the site records no design; choose one on the Admin's Look page.");
214
+ return true;
215
+ }
216
+ const base = `${input.origin}/v1/workspaces/${encodeURIComponent(input.workspaceId)}`;
217
+ if (input.topology === "spoke") {
218
+ // A spoke's identity and navigation show use: the imports write them for a live spoke.
219
+ const identity = await hubRequest(input.fetchImpl, `${base}/identity`, input.apiKey);
220
+ if (!identity.ok) {
221
+ onLine(`Look: not written (${describeAnswer(identity)}).`);
222
+ return false;
223
+ }
224
+ const navigation = await hubRequest(input.fetchImpl, `${base}/navigation`, input.apiKey);
225
+ const navigationVersion = storedVersion(navigation);
226
+ if (navigationVersion === undefined) {
227
+ onLine(`Look: not written (${describeAnswer(navigation)}).`);
228
+ return false;
229
+ }
230
+ if (identity.data !== null || navigationVersion !== null) {
231
+ onLine(IN_USE);
232
+ return true;
233
+ }
234
+ }
235
+ // Step 1 — never written over a stored record.
236
+ const url = designUrl(input.origin, input.workspaceId);
237
+ const read = await hubRequest(input.fetchImpl, url, input.apiKey);
238
+ const stored = storedVersion(read);
239
+ if (stored === undefined) {
240
+ onLine(`Look: not written (${describeAnswer(read)}).`);
241
+ return false;
242
+ }
243
+ if (stored !== null) {
244
+ onLine(`Look: kept — the workspace holds version ${stored}.`);
245
+ return true;
246
+ }
247
+ // Step 2 — the first record.
248
+ const design = lookRecordFor(inputs);
249
+ const written = await hubRequest(input.fetchImpl, url, input.apiKey, {
250
+ method: "PUT",
251
+ body: { version: null, design },
252
+ });
253
+ const version = storedVersion(written);
254
+ if (typeof version === "number") {
255
+ onLine(`Look: written version ${version} · ${design.from?.look ?? "its own look"}.`);
256
+ return true;
257
+ }
258
+ if (written.status === 409) {
259
+ onLine("Look: kept — a record was saved meanwhile.");
260
+ return true;
261
+ }
262
+ if (written.status === 403) {
263
+ onLine(`Look: skipped — the agent key has no site-design grant (403 ${written.code ?? "<unexpected>"}); tick Site design on the agent's key, or choose the look on the Admin's Look page.`);
264
+ return true;
265
+ }
266
+ onLine(`Look: not written (${describeAnswer(written)}).`);
267
+ return false;
158
268
  }
159
269
  const SEED_CREDENTIALS = [
160
270
  HUB_ORIGIN_ENV_VAR,
@@ -169,9 +279,9 @@ function joinNames(names) {
169
279
  }
170
280
  /** What the scaffold does about seeding, decided in D3's order. */
171
281
  export function scaffoldSeedPlan(input) {
172
- if (input.topology === "spoke")
173
- return { kind: "not-applicable" };
174
- if (!input.modules.includes("workspace") &&
282
+ // #12477 D4 — a spoke seeds its look; a hub needs an Admin to seed at all.
283
+ if (input.topology !== "spoke" &&
284
+ !input.modules.includes("workspace") &&
175
285
  !input.modules.includes("multi-tenant")) {
176
286
  return { kind: "not-applicable" };
177
287
  }
@@ -198,10 +308,13 @@ export async function runScaffoldSeed(opts) {
198
308
  const plan = scaffoldSeedPlan(opts);
199
309
  if (plan.kind === "not-applicable")
200
310
  return;
201
- const later = ` To seed it and switch to the database later: ${AGENT_KEY_ENV_VAR}=<key> create-ailk seed-workspace ${opts.targetDir} --api-url <origin> --workspace <wksp_id>`;
311
+ const later = () => {
312
+ opts.onLine(` To seed it and switch to the database later: ${AGENT_KEY_ENV_VAR}=<key> create-ailk seed-workspace ${opts.targetDir} --api-url <origin> --workspace <wksp_id>`);
313
+ opts.onLine(" Its look step needs the key's site-design grant; until the look is written the site renders the base look.");
314
+ };
202
315
  if (plan.kind === "skip") {
203
316
  opts.onLine(plan.reason);
204
- opts.onLine(later);
317
+ later();
205
318
  return;
206
319
  }
207
320
  opts.onLine("Seeding the workspace:");
@@ -210,6 +323,7 @@ export async function runScaffoldSeed(opts) {
210
323
  targetDir: opts.targetDir,
211
324
  env: opts.env,
212
325
  onLine: opts.onLine,
326
+ ...(opts.designsDir !== undefined && { designsDir: opts.designsDir }),
213
327
  ...(opts.adapters !== undefined && { adapters: opts.adapters }),
214
328
  ...(opts.fetch !== undefined && { fetch: opts.fetch }),
215
329
  ...(opts.sleep !== undefined && { sleep: opts.sleep }),
@@ -221,7 +335,7 @@ export async function runScaffoldSeed(opts) {
221
335
  throw err;
222
336
  }
223
337
  opts.onLine(err.message);
224
- opts.onLine(later);
338
+ later();
225
339
  }
226
340
  }
227
341
  export const SEED_WORKSPACE_HELP = `create-ailk seed-workspace — import a starter's pages into its workspace.
@@ -245,8 +359,16 @@ agent key, which is read from AILK_AGENT_KEY only and needs the content-edit
245
359
  and content-publish grants, at Autonomous. Each page prints created, updated,
246
360
  unchanged, skipped or failed, so a re-run is safe. When every page is Live, the site
247
361
  switches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value
248
- either already sets. The site's dependencies must be installed. Exit 0 when
249
- every page was seeded, 1 when any failed, 2 on a refusal (nothing is sent).
362
+ either already sets. The site's dependencies must be installed.
363
+
364
+ Then the look: the site's first design record, from the design and starter it
365
+ was scaffolded with, is written to the workspace — only where the workspace
366
+ holds none, and never for a site that still carries its look files or a
367
+ workspace already in use. This step alone needs the key's site-design grant;
368
+ without it the step is skipped and named. On a spoke, whose pages are its own
369
+ files, only the look is seeded, into the workspace and at the hub its
370
+ apps/web env files name. Exit 0 when every page was seeded and the look written, kept or
371
+ skipped, 1 when any failed, 2 on a refusal (nothing is sent).
250
372
  `;
251
373
  export function parseSeedWorkspaceArgs(argv) {
252
374
  let parsed;
@@ -10,16 +10,18 @@
10
10
  * file (spec 5462 D9/D16) — these are SITE-LEVEL facts a template DECLARES
11
11
  * (on `TemplateManifest.layout` in the code registry, or on a bundle's
12
12
  * `ailk-template.json` `layout` field), never a file it ships. This module is
13
- * the single place that declares the vocabulary, fills defaults, validates an
14
- * untrusted (bundle-sourced) value, and renders the generated
15
- * `apps/web/lib/site-chrome.ts` every scaffold gets — beside `nav-config.ts`,
16
- * the same GENERATED-header idiom (`surfaces.ts` `renderNavConfig`).
13
+ * the single place that declares the vocabulary, fills defaults and validates
14
+ * an untrusted (bundle-sourced) value. The resolved knobs reach a site as its
15
+ * hub design record's layout (`look-record.ts`, #12477): no scaffold or
16
+ * `apply-design` writes `apps/web/lib/site-chrome.ts` any more.
17
+ * `renderSiteChrome` stays as the record of what create-ailk wrote there;
18
+ * `look-settings` (#12476, #12635) reads the values a live site's retired
19
+ * file declares, takes its layout from them and refuses one the layout does
20
+ * not take, before the look is imported.
17
21
  *
18
22
  * Every field is optional and DEFAULTS to `full` / `columns` / `false` /
19
23
  * `default` — the announcement banner is off unless a template turns it on
20
- * (#6469). A scaffold naming no template, or a template naming no `layout`
21
- * block, gets these defaults written, byte-identical to the monorepo's own
22
- * committed `apps/web/lib/site-chrome.ts`.
24
+ * (#6469).
23
25
  *
24
26
  * A design supplies layout knobs too (#6638, widened #6813 D4): its OWN
25
27
  * `layout` (a `DesignPackage`'s, read by `design-scaffold.ts`'s
@@ -29,36 +31,31 @@
29
31
  * close): an unrecognized design NAME now fails in `resolveDesign`, before
30
32
  * this function ever sees one.
31
33
  */
32
- /** The `nav` knob's vocabulary. `mark-only` → the layout passes Nav an empty
33
- * `navItems` (brand mark + the existing actions/theme/locale controls only). */
34
- export type SiteChromeNav = "full" | "mark-only";
35
- /** The `footer` knob's vocabulary. `centered` → `Footer layout="centered"`
36
- * (the existing third variant: nav row + social row + FooterBottomBar). */
37
- export type SiteChromeFooter = "columns" | "centered";
34
+ import { CHROME_STYLE_VALUES, DECK_ANCHORS_VALUES, DECK_GROUND_VALUES, FOOTER_STYLES, HEADER_STYLES, HOME_VALUES, INNER_PAGES_VALUES } from "./generated/design-settings.js";
35
+ /**
36
+ * The `nav` knob's vocabulary: the one header style list (#12470 D7) —
37
+ * `mark-only` → the layout passes Nav an empty `navItems` (brand mark + the
38
+ * existing actions/theme/locale controls only); `bare` and `none` as a page's
39
+ * own header.
40
+ */
41
+ export type SiteChromeHeader = (typeof HEADER_STYLES)[number];
42
+ /** The `footer` knob's vocabulary: the one footer style list (#12470 D7). */
43
+ export type SiteChromeFooterStyle = (typeof FOOTER_STYLES)[number];
38
44
  /** The `home` knob's vocabulary. `deck` → the locale-root route mounts
39
45
  * MarketingShell with `snap="mandatory"` + `deckHero` (spec 5426 D7). */
40
- export type SiteChromeHome = "default" | "deck";
46
+ export type SiteChromeHome = (typeof HOME_VALUES)[number];
41
47
  /** The `innerPages` knob's vocabulary (#7721). `bare` → every non-home page
42
48
  * gets the bare header and the one-bar footer. */
43
- export type SiteChromeInnerPages = "default" | "bare";
49
+ export type SiteChromeInnerPages = (typeof INNER_PAGES_VALUES)[number];
44
50
  /** The `deckAnchors` knob's vocabulary (#8773). `bare` → the deck home names
45
51
  * its slides `#<id>` instead of `#slide-<id>`, keeping the `slide-` name only
46
52
  * where the bare id would collide (the page renderer's `deckSlideAnchors`). */
47
- export type SiteChromeDeckAnchors = "prefixed" | "bare";
48
- /** The `colorMode` knob's vocabulary (#7742). `light` pins the site to light
49
- * and removes every theme switch; dark then appears only as a deck ground. */
50
- export type SiteChromeColorMode = "user" | "light";
53
+ export type SiteChromeDeckAnchors = (typeof DECK_ANCHORS_VALUES)[number];
51
54
  /** The `chromeStyle` knob's vocabulary (#7742). `minimal` → the deck's closing
52
55
  * slide is the wordmark + contact lines + one legal line, and the consent bar
53
56
  * is a ground-coloured hairline bar that never covers the down cue. */
54
- export type SiteChromeChromeStyle = "default" | "minimal";
55
- /**
56
- * The `deckGrounds` knob's vocabulary (#7719 D3) — the shared section surface
57
- * enum, duplicated from `@working-theory/validation`'s `SectionSurfaceSchema`
58
- * because `create-ailk` cannot import it (one runtime dependency, § 1.5);
59
- * `site-chrome.test.ts` proves the two lists equal.
60
- */
61
- export declare const DECK_GROUND_VALUES: readonly ["none", "gray-100", "wash", "wash-secondary", "gradient-brand", "gradient-dark", "solid-dark"];
57
+ export type SiteChromeChromeStyle = (typeof CHROME_STYLE_VALUES)[number];
58
+ /** The `deckGrounds` knob's vocabulary (#7719 D3): the shared section surface list. */
62
59
  export type DeckGround = (typeof DECK_GROUND_VALUES)[number];
63
60
  /**
64
61
  * A template's declared layout block — every field optional. Lives on
@@ -66,8 +63,8 @@ export type DeckGround = (typeof DECK_GROUND_VALUES)[number];
66
63
  * on a template bundle's `ailk-template.json` `layout` field, same shape.
67
64
  */
68
65
  export interface TemplateLayout {
69
- nav?: SiteChromeNav;
70
- footer?: SiteChromeFooter;
66
+ nav?: SiteChromeHeader;
67
+ footer?: SiteChromeFooterStyle;
71
68
  announcementBanner?: boolean;
72
69
  home?: SiteChromeHome;
73
70
  /** #7719 D3 — the surfaces a deck home cycles, slide by slide, onto slides that author none. */
@@ -78,8 +75,6 @@ export interface TemplateLayout {
78
75
  deckPresentation?: boolean;
79
76
  /** #8773 — `bare`: a presenting deck names its slides `#<id>` (a presenting deck home only). */
80
77
  deckAnchors?: SiteChromeDeckAnchors;
81
- /** #7742 D1 — `light`: the site is pinned to light, with no theme switch. */
82
- colorMode?: SiteChromeColorMode;
83
78
  /** #7742 D1 — `minimal`: the minimal closing slide, consent bar and themed 404. */
84
79
  chromeStyle?: SiteChromeChromeStyle;
85
80
  /** #7797 D1 — route paths whose page ends on the closing footer (wordmark, contact lines, legal line). */
@@ -87,8 +82,8 @@ export interface TemplateLayout {
87
82
  }
88
83
  /** `TemplateLayout` with every field resolved — what `site-chrome.ts` exports. */
89
84
  export interface ResolvedSiteChrome {
90
- nav: SiteChromeNav;
91
- footer: SiteChromeFooter;
85
+ nav: SiteChromeHeader;
86
+ footer: SiteChromeFooterStyle;
92
87
  announcementBanner: boolean;
93
88
  home: SiteChromeHome;
94
89
  /** Present only when a list resolves AND `home` is `deck` (#7719 D3) — never an `undefined` key. */
@@ -99,8 +94,6 @@ export interface ResolvedSiteChrome {
99
94
  deckPresentation?: true;
100
95
  /** Present only when it resolves to "bare" on a presenting deck home (#8773) — never "prefixed". */
101
96
  deckAnchors?: "bare";
102
- /** Present only when it resolves to "light" — never "user" (#7742 D1). */
103
- colorMode?: "light";
104
97
  /** Present only when it resolves to "minimal" — never "default" (#7742 D1). */
105
98
  chromeStyle?: "minimal";
106
99
  /** Present only when a non-empty list resolves — never `[]` (#7797 D1). */
@@ -108,8 +101,17 @@ export interface ResolvedSiteChrome {
108
101
  }
109
102
  /** Defaults (#5612 D1; banner off since #6469). */
110
103
  export declare const DEFAULT_SITE_CHROME: ResolvedSiteChrome;
111
- /** Template-relative path of the generated site-chrome registry — beside `NAV_CONFIG_PATH`. */
104
+ /**
105
+ * Site-relative path of the retired layout file (#12477): no generator writes
106
+ * it. `update` never records it (`REGENERATED_APP_PATHS`) and removes it only
107
+ * once the hub's read for the site carries its look (D6).
108
+ */
112
109
  export declare const SITE_CHROME_PATH = "apps/web/lib/site-chrome.ts";
110
+ /**
111
+ * Layout keys that are no longer settings, each with the reason a layout that
112
+ * carries one is refused (#12500 D3) — refused by name, never silently dropped.
113
+ */
114
+ export declare const RETIRED_LAYOUT_KEYS: Readonly<Record<string, string>>;
113
115
  /** Thrown by `validateTemplateLayout` on an unrecognized value, naming the field. */
114
116
  export declare class TemplateLayoutError extends Error {
115
117
  constructor(message: string);
@@ -142,10 +144,9 @@ export declare function validateTemplateLayout(value: unknown, subject: string):
142
144
  */
143
145
  export declare function resolveSiteChrome(layout?: TemplateLayout, designLayout?: TemplateLayout): ResolvedSiteChrome;
144
146
  /**
145
- * Render `apps/web/lib/site-chrome.ts` for a resolved layout — the same
146
- * GENERATED-header idiom `renderNavConfig` uses. `layout.tsx` imports
147
- * `siteChrome` to decide Nav's `navItems`, Footer's `layout` prop, whether
148
- * the announcement Banner mounts, and whether the locale-root route passes
149
- * `snap="mandatory"` + `deckHero` to MarketingShell.
147
+ * The text create-ailk wrote to `apps/web/lib/site-chrome.ts` for a resolved
148
+ * layout, before #12477 retired the file; nothing writes it. `look-settings`
149
+ * compares the values a site's file declares, never its text (#12635): each
150
+ * release changed the `SiteChrome` type header above them.
150
151
  */
151
152
  export declare function renderSiteChrome(resolved: ResolvedSiteChrome): string;