create-ailk 0.40.1 → 0.40.2

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 (57) hide show
  1. package/README.md +26 -4
  2. package/dist/add-module.d.ts +2 -1
  3. package/dist/add-module.js +17 -1
  4. package/dist/cutover.d.ts +7 -3
  5. package/dist/cutover.js +8 -3
  6. package/dist/lib/declared-env.d.ts +5 -1
  7. package/dist/lib/declared-env.js +6 -1
  8. package/dist/lib/env-catalog.d.ts +3 -2
  9. package/dist/lib/env-catalog.js +4 -8
  10. package/dist/module-architecture.js +0 -1
  11. package/dist/programmatic.js +18 -9
  12. package/dist/remove-module.js +1 -1
  13. package/dist/seam-refresh.d.ts +60 -0
  14. package/dist/seam-refresh.js +214 -0
  15. package/dist/spoke-checkout.d.ts +12 -3
  16. package/dist/spoke-checkout.js +14 -5
  17. package/dist/sync-routes.d.ts +10 -1
  18. package/dist/sync-routes.js +61 -6
  19. package/dist/template-record.d.ts +14 -2
  20. package/dist/template-record.js +60 -22
  21. package/dist/topology.js +3 -4
  22. package/dist/update.d.ts +13 -1
  23. package/dist/update.js +100 -8
  24. package/package.json +3 -3
  25. package/templates/.env.example +6 -0
  26. package/templates/.github/workflows/ci.yml +3 -0
  27. package/templates/apps/api/.env.example +12 -0
  28. package/templates/apps/api/CLAUDE.md +10 -7
  29. package/templates/apps/mcp/CLAUDE.md +25 -5
  30. package/templates/apps/web/.env.example +7 -1
  31. package/templates/apps/web/CLAUDE.md +29 -13
  32. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  33. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +10 -3
  34. package/templates/apps/web/app/llms.txt/route.ts +13 -3
  35. package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +15 -7
  36. package/templates/apps/web/auth.config.tsx +2 -0
  37. package/templates/apps/web/auth.ts +28 -4
  38. package/templates/apps/web/jest.config.cjs +1 -1
  39. package/templates/apps/web/lib/__tests__/auth-email.test.ts +21 -0
  40. package/templates/apps/web/lib/__tests__/docs-path.test.ts +20 -2
  41. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +17 -10
  42. package/templates/apps/web/lib/__tests__/relay.test.ts +127 -12
  43. package/templates/apps/web/lib/__tests__/server-api.test.ts +72 -7
  44. package/templates/apps/web/lib/__tests__/services-path.test.ts +22 -1
  45. package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +33 -5
  46. package/templates/apps/web/lib/auth-email.ts +19 -0
  47. package/templates/apps/web/lib/docs-path.ts +1 -1
  48. package/templates/apps/web/lib/hub-site-config.ts +11 -8
  49. package/templates/apps/web/lib/mcp-oauth.ts +123 -17
  50. package/templates/apps/web/lib/relay.ts +48 -9
  51. package/templates/apps/web/lib/server-api.ts +37 -4
  52. package/templates/apps/web/lib/services-path.ts +1 -1
  53. package/templates/apps/web/messages/en.json +10 -8
  54. package/templates/apps/web/middleware.ts +4 -2
  55. package/templates/apps/web/src/lib/routes.ts +13 -0
  56. package/templates/tools/declared-env.ts +6 -1
  57. package/versions.json +51 -51
@@ -1,3 +1,4 @@
1
+ import { type SeamRefreshPlan } from "./seam-refresh.js";
1
2
  import type { WorkspaceVersionMap } from "./substitute.js";
2
3
  /** The site test that fails a route neither rendered through `renderPage` nor in its `NO_STRUCTURED_DATA_ROUTES` (#8704). */
3
4
  export declare const STRUCTURED_DATA_TEST_PATH = "apps/web/lib/__tests__/structured-data.test.tsx";
@@ -84,6 +85,14 @@ export interface SyncRoutesResult {
84
85
  * Sorted.
85
86
  */
86
87
  recorded: string[];
88
+ /**
89
+ * The seams the synced routes import — the `(authed)` gate and the web
90
+ * seam — that `--apply` on a spoke rewrote with this version's render, as
91
+ * `update` does (#11148). Empty without `apply`, and on a hub. Sorted.
92
+ */
93
+ regeneratedSeams: string[];
94
+ /** Those seams left as the site keeps them, with why (#11148). Sorted by path. */
95
+ heldSeams: SeamRefreshPlan["held"];
87
96
  /**
88
97
  * `ROUTE_MESSAGE_NAMESPACES` dot-paths, of any route in `missing`, absent
89
98
  * from the target's `messages/en.json`. CHECK-ONLY — never copied (see
@@ -217,7 +226,7 @@ export interface SyncRoutesArgs {
217
226
  apply: boolean;
218
227
  help: boolean;
219
228
  }
220
- export declare const SYNC_ROUTES_HELP = "create-ailk sync-routes \u2014 copy template routes an existing site is missing.\n\nUsage:\n create-ailk sync-routes [<target-dir>] [--apply]\n\nArguments:\n <target-dir> An already-scaffolded repo (contains\n architecture.yaml). Defaults to the current dir.\n\nOptions:\n --apply Copy the missing route directories into the target.\n Without it the command only reports: exit 1 when a\n route is missing, 0 when in sync.\n --help, -h Print this message.\n\nChecks every core route plus the routes of each surface the site carries; a\nsurface gated off at scaffold time is skipped, not drift. A route the site lists\nin customizations.yaml declined_routes is reported as declined and never copied\n(#11260). A route the site has changed locally is reported and never\noverwritten. Nothing is deleted except,\non a spoke, the retired legacy checkout's files that still match create-ailk's\ncopy: --apply removes them and rewrites the generated billing action (#9142).\nEvery file --apply copies is recorded in .ailk-template-files.json, when the\nsite has one, so `create-ailk update` carries it forward (#11213).\n";
229
+ export declare const SYNC_ROUTES_HELP = "create-ailk sync-routes \u2014 copy template routes an existing site is missing.\n\nUsage:\n create-ailk sync-routes [<target-dir>] [--apply]\n\nArguments:\n <target-dir> An already-scaffolded repo (contains\n architecture.yaml). Defaults to the current dir.\n\nOptions:\n --apply Copy the missing route directories into the target.\n Without it the command only reports: exit 1 when a\n route is missing, 0 when in sync.\n --help, -h Print this message.\n\nChecks every core route plus the routes of each surface the site carries; a\nsurface gated off at scaffold time is skipped, not drift. A route the site lists\nin customizations.yaml declined_routes is reported as declined and never copied\n(#11260). A route the site has changed locally is reported and never\noverwritten. Nothing is deleted except,\non a spoke, the retired legacy checkout's files that still match create-ailk's\ncopy: --apply removes them and rewrites the generated billing action (#9142).\nEvery file --apply copies is recorded in .ailk-template-files.json, when the\nsite has one, so `create-ailk update` carries it forward (#11213). On a\nspoke, --apply also renders the web seam and the (authed) gate again when\ntheir bytes are still the recorded render, as `create-ailk update` does; one\nedited by hand is reported and left (#11148).\n";
221
230
  /**
222
231
  * Parse the argv AFTER the `sync-routes` word. Strict `node:util` parseArgs,
223
232
  * like `parseCliArgs`; at most one positional.
@@ -57,12 +57,15 @@ import { appendEnvRows } from "./lib/declared-env.js";
57
57
  import { ENV_CATALOG } from "./lib/env-catalog.js";
58
58
  import { publicTreeRemoved } from "./lib/site-modules.js";
59
59
  import { readRouteManifests } from "./routes.js";
60
+ import { planSeamRefresh, readSeamInputs, seamRow } from "./seam-refresh.js";
60
61
  import { BILLING_ACTION, BILLING_ACTION_MARKER, RETIRED_CHECKOUT_E2E_MARKER, RETIRED_CHECKOUT_E2E_WORKFLOW_PATH, RETIRED_SPOKE_CHECKOUT_PATHS, } from "./spoke-checkout.js";
61
62
  import { GATEABLE_SURFACES, HUB_KEPT_ROUTE_DIRS, NON_ROUTE_DIRS, pagePackageOfRoute, ROUTE_DEPENDENCIES, ROUTE_MESSAGE_NAMESPACES, ROUTE_SINCE, surfaceForRouteDir, } from "./surfaces.js";
62
63
  import { TEMPLATE_RECORD_PATH, parseTemplateRecord, recordCopiedFiles, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
63
- import { SPOKE_SEAM_FILES, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
64
+ import { AUTHED_GATE_SEAM_PATH, SPOKE_SEAM_FILES, TopologyError, WEB_SEAM_PATH, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
64
65
  /** Template-relative prefix every `apps/web` route directory sits under. */
65
66
  const ROUTE_ROOT = "apps/web/app/[locale]";
67
+ /** The seams a synced route imports, which `--apply` regenerates on a spoke (#11148). */
68
+ const ROUTE_SEAM_FILES = [AUTHED_GATE_SEAM_PATH, WEB_SEAM_PATH];
66
69
  /** The site test that fails a route neither rendered through `renderPage` nor in its `NO_STRUCTURED_DATA_ROUTES` (#8704). */
67
70
  export const STRUCTURED_DATA_TEST_PATH = "apps/web/lib/__tests__/structured-data.test.tsx";
68
71
  /**
@@ -821,6 +824,8 @@ export function syncRoutes(opts) {
821
824
  const applied = [];
822
825
  const appliedDependencies = [];
823
826
  const recorded = [];
827
+ const regeneratedSeams = [];
828
+ let heldSeams = [];
824
829
  if (opts.apply === true) {
825
830
  // #11213 — the site's record, read before the first write: every
826
831
  // recordable file copied below is recorded at the create-ailk version
@@ -829,6 +834,7 @@ export function syncRoutes(opts) {
829
834
  // refuses the run. A row at a path no longer recorded is dropped, as
830
835
  // `update` drops it (#10173).
831
836
  const recordPath = join(targetAbs, TEMPLATE_RECORD_PATH);
837
+ const version = opts.version ?? buildScaffoldMarkers(markers.PROJECT_NAME)["CREATE_AILK_VERSION"];
832
838
  let recording;
833
839
  if (existsSync(recordPath)) {
834
840
  let record;
@@ -838,12 +844,27 @@ export function syncRoutes(opts) {
838
844
  catch (err) {
839
845
  throw new Error(`${err.message}; nothing copied`, { cause: err });
840
846
  }
841
- const version = opts.version ?? buildScaffoldMarkers(markers.PROJECT_NAME)["CREATE_AILK_VERSION"];
842
847
  if (version === undefined) {
843
848
  throw new Error(`cannot record the copied files in ${TEMPLATE_RECORD_PATH}: no create-ailk version; nothing copied`);
844
849
  }
845
850
  recording = { record, version };
846
851
  }
852
+ // #11148 — the seam renders' inputs, read before the first write: an
853
+ // apps/web/package.json they cannot parse refuses the run with nothing
854
+ // copied (the manifest was already parsed by `readSpokeShape` above). The
855
+ // plan itself runs after the copies, so its dropped-import scan reads the
856
+ // synced routes.
857
+ let seamInputs;
858
+ if (spoke !== undefined && version !== undefined) {
859
+ try {
860
+ seamInputs = readSeamInputs(targetAbs);
861
+ }
862
+ catch (err) {
863
+ if (err instanceof TopologyError)
864
+ throw new TopologyError(`${err.message}; nothing copied`);
865
+ throw err;
866
+ }
867
+ }
847
868
  /** Site-relative path → sha256 of the bytes written, for the record. */
848
869
  const copied = new Map();
849
870
  const writable = missingRoutes.filter((r) => !refusedSet.has(r));
@@ -896,12 +917,32 @@ export function syncRoutes(opts) {
896
917
  copied.set(dep, sha256Hex(bytes));
897
918
  appliedDependencies.push(dep);
898
919
  }
920
+ let nextRecord = recording?.record;
899
921
  if (recording !== undefined) {
900
922
  const next = recordCopiedFiles(recording.record, copied, recording.version);
901
- if (next.recorded.length > 0) {
902
- writeFileSync(recordPath, serializeTemplateRecord(next.record));
903
- recorded.push(...next.recorded);
923
+ nextRecord = next.record;
924
+ recorded.push(...next.recorded);
925
+ }
926
+ // #11148 — on a spoke, the seams a synced route imports are regenerated
927
+ // as `update` regenerates them, written before the record names them.
928
+ if (seamInputs !== undefined && version !== undefined) {
929
+ const plan = planSeamRefresh(targetAbs, nextRecord?.seams ?? {}, version, ROUTE_SEAM_FILES, seamInputs);
930
+ const seams = { ...plan.rows };
931
+ for (const [path, render] of plan.writes) {
932
+ const abs = join(targetAbs, ...path.split("/"));
933
+ mkdirSync(dirname(abs), { recursive: true });
934
+ writeFileSync(abs, render);
935
+ seams[path] = seamRow(render, version);
936
+ regeneratedSeams.push(path);
904
937
  }
938
+ heldSeams = plan.held;
939
+ if (nextRecord !== undefined)
940
+ nextRecord = { ...nextRecord, seams };
941
+ }
942
+ if (recording !== undefined && nextRecord !== undefined) {
943
+ const text = serializeTemplateRecord(nextRecord);
944
+ if (text !== serializeTemplateRecord(recording.record))
945
+ writeFileSync(recordPath, text);
905
946
  }
906
947
  // #7874 D9 — a spoke declares what the copied routes read, as the last
907
948
  // write. A malformed env_contract block throws EnvContractError naming
@@ -921,6 +962,8 @@ export function syncRoutes(opts) {
921
962
  missingDependencies,
922
963
  appliedDependencies,
923
964
  recorded,
965
+ regeneratedSeams: regeneratedSeams.sort(),
966
+ heldSeams,
924
967
  missingMessageNamespaces,
925
968
  skippedSurfaces,
926
969
  declined,
@@ -1065,6 +1108,15 @@ export function formatSyncRoutesReport(result, apply) {
1065
1108
  if (result.recorded.length > 0) {
1066
1109
  lines.push(`[create-ailk] Recorded ${result.recorded.length} copied file(s) in ${TEMPLATE_RECORD_PATH}, so \`create-ailk update\` carries them forward.`);
1067
1110
  }
1111
+ // #11148 — the seams the synced routes import.
1112
+ if (result.regeneratedSeams.length > 0) {
1113
+ lines.push(`[create-ailk] Regenerated ${result.regeneratedSeams.length} seam(s) the synced routes import:`);
1114
+ lines.push(...result.regeneratedSeams.map((path) => ` ${path}`));
1115
+ }
1116
+ if (result.heldSeams.length > 0) {
1117
+ lines.push(`[create-ailk] Held ${result.heldSeams.length} seam(s) the synced routes import:`);
1118
+ lines.push(...result.heldSeams.map(({ path, reason }) => ` ${path} — ${reason}`));
1119
+ }
1068
1120
  if (result.missingMessageNamespaces.length > 0) {
1069
1121
  lines.push(`[create-ailk] Also required — message namespace(s) not found in apps/web/messages/en.json (add manually, not auto-merged):`);
1070
1122
  lines.push(...result.missingMessageNamespaces.map((ns) => ` ${ns}`));
@@ -1123,7 +1175,10 @@ overwritten. Nothing is deleted except,
1123
1175
  on a spoke, the retired legacy checkout's files that still match create-ailk's
1124
1176
  copy: --apply removes them and rewrites the generated billing action (#9142).
1125
1177
  Every file --apply copies is recorded in .ailk-template-files.json, when the
1126
- site has one, so \`create-ailk update\` carries it forward (#11213).
1178
+ site has one, so \`create-ailk update\` carries it forward (#11213). On a
1179
+ spoke, --apply also renders the web seam and the (authed) gate again when
1180
+ their bytes are still the recorded render, as \`create-ailk update\` does; one
1181
+ edited by hand is reported and left (#11148).
1127
1182
  `;
1128
1183
  /**
1129
1184
  * Parse the argv AFTER the `sync-routes` word. Strict `node:util` parseArgs,
@@ -44,6 +44,13 @@ export interface TemplateRecord {
44
44
  schema: 1;
45
45
  projectName: string;
46
46
  files: Record<string, TemplateFileRow>;
47
+ /**
48
+ * The sha256 of each topology seam (`SPOKE_SEAM_FILES`) as create-ailk last
49
+ * rendered it, and that version (#11148): `update` and `sync-routes --apply`
50
+ * regenerate a seam still at its row and hold one the site edited. Absent
51
+ * from a record written before #11148, and when no seam was recorded.
52
+ */
53
+ seams?: Record<string, TemplateFileRow>;
47
54
  }
48
55
  /** Thrown by `parseTemplateRecord` on a malformed or unsafe record. */
49
56
  export declare class TemplateRecordError extends Error {
@@ -63,10 +70,15 @@ export interface ParseTemplateRecordOptions {
63
70
  * JSON that does not parse; `schema !== 1`; an unknown top-level key; an
64
71
  * empty `projectName`; a `files` key that is not a recordable path (unless
65
72
  * `onUnrecordable` takes it); a `sha256` that is not 64 lowercase hex; a
66
- * `version` that is not a semver string (#8522 D1).
73
+ * `version` that is not a semver string (#8522 D1). A record declaring
74
+ * `offTemplate` is refused by name whatever its value or rows (#9559 D2).
67
75
  */
68
76
  export declare function parseTemplateRecord(text: string, opts?: ParseTemplateRecordOptions): TemplateRecord;
69
- /** `record` as `scaffold()` and `update` write it: sorted keys, trailing newline. */
77
+ /**
78
+ * `record` as `scaffold()` and `update` write it: sorted keys, trailing
79
+ * newline; `seams` only when it holds a row, so a record without one is
80
+ * byte-identical to before #11148.
81
+ */
70
82
  export declare function serializeTemplateRecord(record: TemplateRecord): string;
71
83
  export interface PlanTemplateRecordOptions {
72
84
  /** The freshly scaffolded site. */
@@ -15,6 +15,11 @@
15
15
  * only READS the scaffold's own disk to confirm a copied path's final bytes
16
16
  * (a later layer may have rewritten it, D2); every write goes through the
17
17
  * caller.
18
+ *
19
+ * A record carrying `offTemplate` declares the site off-template (#9559):
20
+ * every app file is site-owned and upgrades are hand-ported, so
21
+ * `parseTemplateRecord` refuses it by name and no command that reads the
22
+ * record runs on that site.
18
23
  */
19
24
  import { createHash } from "node:crypto";
20
25
  import { existsSync, readFileSync } from "node:fs";
@@ -105,6 +110,7 @@ export function isRecordable(destRel) {
105
110
  export function sha256Hex(bytes) {
106
111
  return createHash("sha256").update(bytes).digest("hex");
107
112
  }
113
+ const SEAM_SET = new Set(SPOKE_SEAM_FILES);
108
114
  /** Thrown by `parseTemplateRecord` on a malformed or unsafe record. */
109
115
  export class TemplateRecordError extends Error {
110
116
  constructor(message) {
@@ -134,7 +140,8 @@ function isSafeRecordKey(key) {
134
140
  * JSON that does not parse; `schema !== 1`; an unknown top-level key; an
135
141
  * empty `projectName`; a `files` key that is not a recordable path (unless
136
142
  * `onUnrecordable` takes it); a `sha256` that is not 64 lowercase hex; a
137
- * `version` that is not a semver string (#8522 D1).
143
+ * `version` that is not a semver string (#8522 D1). A record declaring
144
+ * `offTemplate` is refused by name whatever its value or rows (#9559 D2).
138
145
  */
139
146
  export function parseTemplateRecord(text, opts = {}) {
140
147
  let doc;
@@ -148,7 +155,10 @@ export function parseTemplateRecord(text, opts = {}) {
148
155
  throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} is not a JSON object`);
149
156
  }
150
157
  const record = doc;
151
- const allowed = new Set(["schema", "projectName", "files"]);
158
+ if ("offTemplate" in record) {
159
+ throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} declares this site off-template (${JSON.stringify(record["offTemplate"])}): every file under apps/ is site-owned and upgrades are hand-ported, so this command does not run on it`);
160
+ }
161
+ const allowed = new Set(["schema", "projectName", "files", "seams"]);
152
162
  for (const key of Object.keys(record)) {
153
163
  if (!allowed.has(key)) {
154
164
  throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} has an unknown top-level key "${key}"`);
@@ -177,30 +187,58 @@ export function parseTemplateRecord(text, opts = {}) {
177
187
  }
178
188
  throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} "files" has a key "${key}" that is not a recordable path`);
179
189
  }
180
- if (typeof value !== "object" || value === null) {
181
- throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} "files"["${key}"] must be an object`);
182
- }
183
- const row = value;
184
- const sha = row["sha256"];
185
- if (typeof sha !== "string" || !SHA256_PATTERN.test(sha)) {
186
- throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} "files"["${key}"].sha256 must be 64 lowercase hex characters`);
187
- }
188
- const version = row["version"];
189
- if (typeof version !== "string" || !VERSION_PATTERN.test(version)) {
190
- throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} "files"["${key}"].version must be a semver string`);
190
+ files[key] = parseRow(`"files"["${key}"]`, value);
191
+ }
192
+ const seamsRaw = record["seams"];
193
+ if (seamsRaw === undefined)
194
+ return { schema: 1, projectName, files };
195
+ if (typeof seamsRaw !== "object" || seamsRaw === null || Array.isArray(seamsRaw)) {
196
+ throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} "seams" must be an object`);
197
+ }
198
+ const seams = {};
199
+ for (const [key, value] of Object.entries(seamsRaw)) {
200
+ if (!SEAM_SET.has(key)) {
201
+ throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} "seams" has a key "${key}" that is not a topology seam`);
191
202
  }
192
- files[key] = { sha256: sha, version };
203
+ seams[key] = parseRow(`"seams"["${key}"]`, value);
193
204
  }
194
- return { schema: 1, projectName, files };
205
+ return { schema: 1, projectName, files, seams };
195
206
  }
196
- /** `record` as `scaffold()` and `update` write it: sorted keys, trailing newline. */
197
- export function serializeTemplateRecord(record) {
198
- const files = {};
199
- for (const key of Object.keys(record.files).sort()) {
200
- files[key] = record.files[key];
207
+ /** One `{ sha256, version }` row, refusing — naming `label` — on either field malformed. */
208
+ function parseRow(label, value) {
209
+ if (typeof value !== "object" || value === null) {
210
+ throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} ${label} must be an object`);
211
+ }
212
+ const row = value;
213
+ const sha = row["sha256"];
214
+ if (typeof sha !== "string" || !SHA256_PATTERN.test(sha)) {
215
+ throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} ${label}.sha256 must be 64 lowercase hex characters`);
201
216
  }
202
- return (JSON.stringify({ schema: record.schema, projectName: record.projectName, files }, null, 2) +
203
- "\n");
217
+ const version = row["version"];
218
+ if (typeof version !== "string" || !VERSION_PATTERN.test(version)) {
219
+ throw new TemplateRecordError(`${TEMPLATE_RECORD_PATH} ${label}.version must be a semver string`);
220
+ }
221
+ return { sha256: sha, version };
222
+ }
223
+ /**
224
+ * `record` as `scaffold()` and `update` write it: sorted keys, trailing
225
+ * newline; `seams` only when it holds a row, so a record without one is
226
+ * byte-identical to before #11148.
227
+ */
228
+ export function serializeTemplateRecord(record) {
229
+ const sorted = (rows) => {
230
+ const out = {};
231
+ for (const key of Object.keys(rows).sort())
232
+ out[key] = rows[key];
233
+ return out;
234
+ };
235
+ const seams = record.seams !== undefined && Object.keys(record.seams).length > 0 ? sorted(record.seams) : undefined;
236
+ return (JSON.stringify({
237
+ schema: record.schema,
238
+ projectName: record.projectName,
239
+ files: sorted(record.files),
240
+ ...(seams !== undefined ? { seams } : {}),
241
+ }, null, 2) + "\n");
204
242
  }
205
243
  /**
206
244
  * The record a fresh scaffold writes (#8522 D2): one row per copied path
package/dist/topology.js CHANGED
@@ -1015,6 +1015,7 @@ const AUTH_CONFIG_HUB = [
1015
1015
  " confirmSignUpEmail,",
1016
1016
  " makeSendAccountOpen,",
1017
1017
  " purchaseCapture,",
1018
+ " senderWorkspace,",
1018
1019
  "} from \"./lib/auth-email\";",
1019
1020
  "import {",
1020
1021
  " getActiveProviderIds,",
@@ -1089,11 +1090,9 @@ const AUTH_CONFIG_HUB = [
1089
1090
  " confirmSignUpEmail: (nonce) => confirmSignUpEmail(nonce),",
1090
1091
  " makeSendAccountOpen: (deps) => makeSendAccountOpen(deps),",
1091
1092
  " buildAuthEmailRequest: (payload, secret) =>",
1092
- " buildAuthEmailRequest(",
1093
- " payload as Parameters<typeof buildAuthEmailRequest>[0],",
1094
- " secret,",
1095
- " ),",
1093
+ " buildAuthEmailRequest(payload, secret),",
1096
1094
  " purchaseCapture,",
1095
+ " senderWorkspace,",
1097
1096
  " },",
1098
1097
  " },",
1099
1098
  "} satisfies AuthSite;",
package/dist/update.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type MdxParse } from "./mdx-braces.js";
2
+ import { type ModuleName } from "./parse-args.js";
2
3
  import type { WorkspaceVersionMap } from "./substitute.js";
3
4
  /** A refusal the CLI exits 2 on, thrown before anything is written. */
4
5
  export declare class UpdateRefusedError extends Error {
@@ -112,6 +113,8 @@ export interface UpdateResult {
112
113
  headingsAdded: string[];
113
114
  /** The mdx-body pages under `content/` whose bare `{` were escaped this run (#10773). */
114
115
  bracesEscaped: string[];
116
+ /** The topology seams rewritten with this version's render for the site's topology and sign-in mode (#11148). */
117
+ regenerated?: string[];
115
118
  /** The generated route files written from the installed page packages' manifests after the pins moved (#11219). */
116
119
  routesWritten?: string[];
117
120
  /** The root `devDependencies["create-ailk"]` pin, moved to the running version so the scaffold's `routes:check` renders with the generator that wrote the files (#11219). */
@@ -124,6 +127,15 @@ export interface UpdateResult {
124
127
  files: number;
125
128
  };
126
129
  }
130
+ /**
131
+ * Whether `diskBytes` is `templateBytes` with the `jest-config` /
132
+ * `next-config` patches of the site's `modules` for `path` applied, in some
133
+ * order the modules could have been installed (#11591 D2): the copy a
134
+ * scaffold or `add-module` left, which `planTemplateRecord` keeps out of the
135
+ * record, never a site edit. `false` when no module patches `path`; an order
136
+ * whose patch no longer applies matches nothing.
137
+ */
138
+ export declare function isModulePatchedCopy(path: string, templateBytes: Uint8Array, diskBytes: Uint8Array, modules: readonly ModuleName[]): boolean;
127
139
  /**
128
140
  * The site's messages catalog with every key the template's copy has and it
129
141
  * lacks (#10173): the site's values always win, nothing is removed, and the
@@ -156,6 +168,6 @@ export interface UpdateArgs {
156
168
  target: string | undefined;
157
169
  help: boolean;
158
170
  }
159
- export declare const UPDATE_HELP = "create-ailk update \u2014 bring template fixes into a site's copied app code.\n\nUsage:\n create-ailk update [<target-dir>]\n\nArguments:\n <target-dir> The existing site. Defaults to the current dir.\n\nOptions:\n --help, -h Print this message.\n\nReads .ailk-template-files.json (written beside .ailk-site-manifest.json by\nevery template scaffold) to tell an untouched copy from an edit. An\nuntouched apps/web, apps/api or apps/mcp file, or a root tools/jest file the\napp jest configs require, whose template copy changed is overwritten. An\nedited file whose template copy also changed is three-way merged with\n`git` (git must be on PATH); a conflict leaves the file alone and is\nlisted under \"Needs review\"; an apps/web/messages catalog instead gains the\ntemplate's new keys and keeps every value it has \u2014 also when its recorded\nversion's copy cannot be read \u2014 and is reviewed only when a key is an object\non one side and a value on the other; a written apps/web file that uses\nthrough t(...) a key the catalog then lacks is held with it, listed under\n\"Held back with <catalog>\". Each @working-theory/* package a written apps/web\nfile imports that apps/web/package.json does not declare is added to its\ndependencies at this release's version. An edited file whose\nbytes are another published create-ailk version's copy is a stale copy, not\nan edit: it is overwritten or removed as an untouched file is, listed with\nthe version it matched. An edit that touches only comment lines is listed as\n\"comment-only edit\"; on a conflict the template's copy lands. A file at a\ntemplate path that is not in the record (one an earlier sync-routes --apply\nor add-route copied without recording it) whose bytes are a published\ncreate-ailk version's copy \u2014 from the version the site was scaffolded at to\nthis one \u2014 is adopted: recorded and moved forward as an untouched file is,\nlisted under \"Adopted\" with the version it matched. One whose bytes match no\npublished copy is a site edit: skipped, never overwritten, and counted under\n\"Held as site edits, not in the record\". No file under a route the site\nlists in customizations.yaml declined_routes is written: each is listed under\n\"Skipped\" naming the declined route. Every template\ntest, and every site-edited template file, that imports a file left under\n\"Needs review\" (by a relative or @/ import, transitively) is held\nat the site's version with it, its record entry is not advanced, and it is\nlisted under \"Held back with <file>\" \u2014 reconcile the file, then run update\nagain to bring it forward. A skipped file never holds another. A file whose\nown bytes are the record's is not held by what it imports: it moves, unless\nit names an export the held copy lacks, and the held file is listed as\n\"Held back: <file> \u2014 imported by N moved files; the site edit is <hunk\nsummary>\". A written file whose import names a file the site lacks gets it\nadded when this template supplies it; otherwise it is held the same way,\nunder \"Held back with <file> (not in this site)\", unless its own copy\nalready named the file \u2014 then it moves and the path is listed under \"Not in\nthis site or the template: <file>\". A file the template removed is kept\nwhile any file still in the site imports it. Every other file in the run\nstill updates. When project.yaml has an env_contract block, each\nenv var the written files read that has no row gains one; no row is edited.\nA record row at a path create-ailk no longer records is dropped and listed.\nA surface the site's .ailk-site-manifest.json names a page on but\narchitecture.yaml does not declare (one no module owns, such as projects)\ngets its route files added and is declared, listed under \"Surfaces declared\nfrom the roster\". A code-route row of that roster no page file serves is\ndropped, listed under \"Roster rows dropped, no route serves them\".\nA site with no record gets one on its first run, from the version its\n.ailk-site-manifest.json already records. A site scaffolded before\n@working-theory/mcp-server has its copied apps/mcp moved to the boot set:\nthe server and each module's paid MCP pack join apps/mcp/package.json, the\ncopied server files go, and apps/mcp/src/lib/paid-tools.generated.ts is\nrewritten on every run. A site scaffolded before @working-theory/api has its\ncopied apps/api moved to the boot file: the app becomes @working-theory/app-api,\nthe package and the six @working-theory/api-<module> packages join\napps/api/package.json, its bins and build:vercel delegate to the package, and\nthe copied server files go. Run `pnpm install` after either move, since the\napp's package.json gained dependencies. Each mdx-body page in content/ with no\n'# ' heading gets its title and description written into its body as its\nheading and intro, listed under \"Page heading added\"; a page with one heading\nis left as it is, and one with several, or one whose frontmatter it cannot\nread, is listed under \"Needs review\". Each bare { on an mdx-body page is\nescaped as \\{ when the site's own MDX parser then reads the page clean, listed\nunder \"Placeholder brace escaped\"; a page it cannot escape safely, or any page\nwith one while the site's dependencies are not installed, is listed under\n\"Needs review\". Last, the generated route files of every installed page\npackage (one whose package.json declares \"ailk\": { \"routes\" }) are rewritten\nfrom its manifest, listed under \"Route files regenerated\"; run\n`create-ailk routes --write` after the install when the packages were not\ninstalled yet. Commit before running, and review the diff after.\n";
171
+ export declare const UPDATE_HELP = "create-ailk update \u2014 bring template fixes into a site's copied app code.\n\nUsage:\n create-ailk update [<target-dir>]\n\nArguments:\n <target-dir> The existing site. Defaults to the current dir.\n\nOptions:\n --help, -h Print this message.\n\nReads .ailk-template-files.json (written beside .ailk-site-manifest.json by\nevery template scaffold) to tell an untouched copy from an edit. An\nuntouched apps/web, apps/api or apps/mcp file, or a root tools/jest file the\napp jest configs require, whose template copy changed is overwritten. An\nedited file whose template copy also changed is three-way merged with\n`git` (git must be on PATH); a conflict leaves the file alone and is\nlisted under \"Needs review\"; an apps/web/messages catalog instead gains the\ntemplate's new keys and keeps every value it has \u2014 also when its recorded\nversion's copy cannot be read \u2014 and is reviewed only when a key is an object\non one side and a value on the other; a written apps/web file that uses\nthrough t(...) a key the catalog then lacks is held with it, listed under\n\"Held back with <catalog>\". Each @working-theory/* package a written apps/web\nfile imports that apps/web/package.json does not declare is added to its\ndependencies at this release's version. An edited file whose\nbytes are another published create-ailk version's copy is a stale copy, not\nan edit: it is overwritten or removed as an untouched file is, listed with\nthe version it matched. An edit that touches only comment lines is listed as\n\"comment-only edit\"; on a conflict the template's copy lands. A file at a\ntemplate path that is not in the record (one an earlier sync-routes --apply\nor add-route copied without recording it) whose bytes are a published\ncreate-ailk version's copy \u2014 from the version the site was scaffolded at to\nthis one \u2014 is adopted: recorded and moved forward as an untouched file is,\nlisted under \"Adopted\" with the version it matched. One whose bytes are the\nrunning copy with this site's modules' patches applied (a module's\njest.config.cjs or next.config.mjs edit) is left as it is and not listed.\nOne whose bytes match no published copy is a site edit: skipped, never overwritten, and counted under\n\"Held as site edits, not in the record\". No file under a route the site\nlists in customizations.yaml declined_routes is written: each is listed under\n\"Skipped\" naming the declined route. Every template\ntest, and every site-edited template file, that imports a file left under\n\"Needs review\" (by a relative or @/ import, transitively) is held\nat the site's version with it, its record entry is not advanced, and it is\nlisted under \"Held back with <file>\" \u2014 reconcile the file, then run update\nagain to bring it forward. A skipped file never holds another. A file whose\nown bytes are the record's is not held by what it imports: it moves, unless\nit names an export the held copy lacks, and the held file is listed as\n\"Held back: <file> \u2014 imported by N moved files; the site edit is <hunk\nsummary>\". A written file whose import names a file the site lacks gets it\nadded when this template supplies it; otherwise it is held the same way,\nunder \"Held back with <file> (not in this site)\", unless its own copy\nalready named the file \u2014 then it moves and the path is listed under \"Not in\nthis site or the template: <file>\". A file the template removed is kept\nwhile any file still in the site imports it. Every other file in the run\nstill updates. When project.yaml has an env_contract block, each\nenv var the written files read that has no row gains one; no row is edited.\nA record row at a path create-ailk no longer records is dropped and listed.\nA surface the site's .ailk-site-manifest.json names a page on but\narchitecture.yaml does not declare (one no module owns, such as projects)\ngets its route files added and is declared, listed under \"Surfaces declared\nfrom the roster\". A code-route row of that roster no page file serves is\ndropped, listed under \"Roster rows dropped, no route serves them\".\nA site with no record gets one on its first run, from the version its\n.ailk-site-manifest.json already records. A site scaffolded before\n@working-theory/mcp-server has its copied apps/mcp moved to the boot set:\nthe server and each module's paid MCP pack join apps/mcp/package.json, the\ncopied server files go, and apps/mcp/src/lib/paid-tools.generated.ts is\nrewritten on every run. A site scaffolded before @working-theory/api has its\ncopied apps/api moved to the boot file: the app becomes @working-theory/app-api,\nthe package and the six @working-theory/api-<module> packages join\napps/api/package.json, its bins and build:vercel delegate to the package, and\nthe copied server files go. Run `pnpm install` after either move, since the\napp's package.json gained dependencies. Each mdx-body page in content/ with no\n'# ' heading gets its title and description written into its body as its\nheading and intro, listed under \"Page heading added\"; a page with one heading\nis left as it is, and one with several, or one whose frontmatter it cannot\nread, is listed under \"Needs review\". Each bare { on an mdx-body page is\nescaped as \\{ when the site's own MDX parser then reads the page clean, listed\nunder \"Placeholder brace escaped\"; a page it cannot escape safely, or any page\nwith one while the site's dependencies are not installed, is listed under\n\"Needs review\". Each topology seam (*.generated.* \u2014 the web seam, the\n(authed) gate, the API origin and the MCP seam) is rendered again for the\ntopology and sign-in mode .ailk-site-manifest.json records and listed under\n\"Regenerated\", when its bytes are still the render .ailk-template-files.json\nrecords; one edited by hand, or with no recorded render, is listed under\n\"Needs review\" and left as it is. Last, the generated route files of every installed page\npackage (one whose package.json declares \"ailk\": { \"routes\" }) are rewritten\nfrom its manifest, listed under \"Route files regenerated\"; run\n`create-ailk routes --write` after the install when the packages were not\ninstalled yet. Commit before running, and review the diff after.\n";
160
172
  /** Parse the argv AFTER the `update` word. Strict `node:util` parseArgs, like `parseAdoptArgs`. */
161
173
  export declare function parseUpdateArgs(argv: string[]): UpdateArgs;
package/dist/update.js CHANGED
@@ -57,8 +57,11 @@
57
57
  * its bytes are that path's template copy in any published version from
58
58
  * the record's oldest (the manifest's `patternVersion`) to the running one:
59
59
  * recorded, and moved forward as an untouched copy is, named with the
60
- * version it matched. One matching no published copy is the site's own:
61
- * held as a site edit, never overwritten, and counted in the report.
60
+ * version it matched. One whose bytes are the running copy with the site's
61
+ * own modules' patches applied (a module's `jest.config.cjs` or
62
+ * `next.config.mjs` edit, #11591) is left as it is and not listed. One
63
+ * matching no published copy is the site's own: held as a site edit, never
64
+ * overwritten, and counted in the report.
62
65
  *
63
66
  * A skipped file never holds another (#11216): the run has decided not to
64
67
  * manage it, so only a file under review, and what is held with it, holds.
@@ -102,6 +105,7 @@ import { headingViolations, mdxBodyPages, mdxBodyRule, migrateBodyHeadings } fro
102
105
  import { buildScaffoldMarkers, isExcluded, isTextFile, renderTemplateFile, templateDestination } from "./copy.js";
103
106
  import { declinedRouteOfPath, readDeclinedRoutes } from "./declined-routes.js";
104
107
  import { deriveArchitecture } from "./derive-architecture.js";
108
+ import { computeModulePatches } from "./lib/apply-module-patches.js";
105
109
  import { EnvContractError, planEnvRows, readEnvContract, readManifestTopology, } from "./lib/declared-env.js";
106
110
  import { ENV_CATALOG } from "./lib/env-catalog.js";
107
111
  import { assertContentLengthWithinLimit, assertHttpsRegistryUrl, fetchTimeoutSignal, } from "./lib/fetch-guard.js";
@@ -114,11 +118,12 @@ import { MODULE_SLICES } from "./module-architecture.js";
114
118
  import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH, renderSitePaidSections, writeModuleFlags, writePaidMcpTools, writePaidSectionsRegistry, } from "./paid-sections.js";
115
119
  import { ParseError } from "./parse-args.js";
116
120
  import { RoutesRefusedError, writeRoutes } from "./routes.js";
121
+ import { planSeamRefresh, seamRow, siteSeamRenders } from "./seam-refresh.js";
117
122
  import { SITE_LISTING_PATH } from "./site-listing-path.js";
118
123
  import { SITE_ROSTER_PATH, planServedRoster, readRosterPageRoutes } from "./site-roster.js";
119
124
  import { GATEABLE_SURFACES, excludedRoutePaths, isRemovedPublicRoutePath, resolveSurfaces, surfacesNamedByRoutes, } from "./surfaces.js";
120
125
  import { DATABASE_BOOT_FILES, ROOT_TOOL_FILES, TEMPLATE_RECORD_PATH, isRecordable, parseTemplateRecord, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
121
- import { MCP_SEAM_PATH, MCP_SERVER_HUB, TopologyError, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
126
+ import { MCP_SEAM_PATH, MCP_SERVER_HUB, SPOKE_SEAM_FILES, TopologyError, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
122
127
  /** A refusal the CLI exits 2 on, thrown before anything is written. */
123
128
  export class UpdateRefusedError extends Error {
124
129
  exitCode = 2;
@@ -127,6 +132,38 @@ export class UpdateRefusedError extends Error {
127
132
  this.name = "UpdateRefusedError";
128
133
  }
129
134
  }
135
+ /** Every order of `items` — only the given order past 4, where the count would grow past 24 (#11591 D2). */
136
+ function orders(items) {
137
+ if (items.length <= 1 || items.length > 4)
138
+ return [[...items]];
139
+ return items.flatMap((first, i) => orders([...items.slice(0, i), ...items.slice(i + 1)]).map((rest) => [first, ...rest]));
140
+ }
141
+ /**
142
+ * Whether `diskBytes` is `templateBytes` with the `jest-config` /
143
+ * `next-config` patches of the site's `modules` for `path` applied, in some
144
+ * order the modules could have been installed (#11591 D2): the copy a
145
+ * scaffold or `add-module` left, which `planTemplateRecord` keeps out of the
146
+ * record, never a site edit. `false` when no module patches `path`; an order
147
+ * whose patch no longer applies matches nothing.
148
+ */
149
+ export function isModulePatchedCopy(path, templateBytes, diskBytes, modules) {
150
+ const patching = modules
151
+ .map((name) => (MODULE_SLICES[name].patches ?? []).filter((p) => p.target === path && (p.kind === "jest-config" || p.kind === "next-config")))
152
+ .filter((patches) => patches.length > 0);
153
+ if (patching.length === 0)
154
+ return false;
155
+ const template = Buffer.from(templateBytes).toString("utf8");
156
+ const disk = Buffer.from(diskBytes).toString("utf8");
157
+ return orders(patching).some((order) => {
158
+ try {
159
+ const folded = order.reduce((text, patches) => computeModulePatches(patches, { versions: {}, readTarget: () => text })[0]?.content ?? text, template);
160
+ return folded === disk;
161
+ }
162
+ catch {
163
+ return false;
164
+ }
165
+ });
166
+ }
130
167
  /** `buildScaffoldMarkers`, with `CREATE_AILK_VERSION` set to the version being rendered (D3). */
131
168
  function markersForVersion(projectName, version) {
132
169
  return { ...buildScaffoldMarkers(projectName), CREATE_AILK_VERSION: version };
@@ -1604,6 +1641,9 @@ export async function updateSite(opts) {
1604
1641
  adopted.push({ path, version: stale });
1605
1642
  continue;
1606
1643
  }
1644
+ // #11591 — the copy the site's own module patches left: unrecorded and unreported.
1645
+ if (isModulePatchedCopy(path, newBytes, readFileSync(abs), header.modules))
1646
+ continue;
1607
1647
  skipped.push({ path, reason: UNRECORDED_SITE_EDIT });
1608
1648
  continue;
1609
1649
  }
@@ -1689,6 +1729,21 @@ export async function updateSite(opts) {
1689
1729
  if (listingRaw !== undefined && !existsSync(join(targetDir, ...SITE_LISTING_PATH.split("/")))) {
1690
1730
  renders.set(SITE_LISTING_PATH, Buffer.from(renderTemplateFile(listingRaw, SITE_LISTING_PATH, {}, markersForVersion(record.projectName, version))).toString("utf8"));
1691
1731
  }
1732
+ // #11148 — the topology seams still at their recorded render are rendered
1733
+ // again for the site's recorded topology and sign-in mode, so a written
1734
+ // file's import of one reads the new render. The MCP move rewrites a hub's
1735
+ // pre-move MCP seam itself, so that seam is left to it.
1736
+ let seamPlan;
1737
+ try {
1738
+ seamPlan = planSeamRefresh(targetDir, record.seams ?? {}, version, mcpMove?.seam !== undefined ? SPOKE_SEAM_FILES.filter((path) => path !== MCP_SEAM_PATH) : undefined);
1739
+ }
1740
+ catch (err) {
1741
+ if (err instanceof TopologyError)
1742
+ throw new UpdateRefusedError(err.message);
1743
+ throw err;
1744
+ }
1745
+ for (const [path, render] of seamPlan.writes)
1746
+ renders.set(path, render);
1692
1747
  // What the run rewrites after the record's writes, never from the template.
1693
1748
  const rewrittenLater = new Set([
1694
1749
  MODULE_FLAGS_PATH,
@@ -2157,6 +2212,29 @@ export async function updateSite(opts) {
2157
2212
  for (const path of deletes.filter(notHeld)) {
2158
2213
  rmSync(join(targetDir, ...path.split("/")));
2159
2214
  }
2215
+ // #11148 — each planned seam the import pass did not hold, written before
2216
+ // the record that names its render; a seam held there keeps its row.
2217
+ const regenerated = [];
2218
+ const nextSeams = { ...seamPlan.rows };
2219
+ // The MCP move's seam, when it lands as this version's render, is recorded
2220
+ // as one, so the run after the move changes no byte.
2221
+ if (mcpMove?.seam !== undefined && mcpMove.seam === siteSeamRenders(targetDir).get(MCP_SEAM_PATH)) {
2222
+ nextSeams[MCP_SEAM_PATH] = seamRow(mcpMove.seam, version);
2223
+ }
2224
+ for (const [path, render] of seamPlan.writes) {
2225
+ if (renders.get(path) !== render) {
2226
+ const row = record.seams?.[path];
2227
+ if (row !== undefined)
2228
+ nextSeams[path] = row;
2229
+ continue;
2230
+ }
2231
+ const abs = join(targetDir, ...path.split("/"));
2232
+ mkdirSync(dirname(abs), { recursive: true });
2233
+ writeFileSync(abs, render);
2234
+ nextSeams[path] = seamRow(render, version);
2235
+ regenerated.push(path);
2236
+ }
2237
+ const seamsChanged = serializeTemplateRecord({ ...record, seams: nextSeams }) !== serializeTemplateRecord(record);
2160
2238
  const backfilled = backfillPatternVersion !== undefined
2161
2239
  ? { version: backfillPatternVersion, files: Object.keys(record.files).length }
2162
2240
  : undefined;
@@ -2167,11 +2245,12 @@ export async function updateSite(opts) {
2167
2245
  removed: removed.filter(notHeld),
2168
2246
  current: current.filter(notHeld),
2169
2247
  };
2170
- const recordChanged = backfilled !== undefined ||
2248
+ const recordChanged = seamsChanged ||
2249
+ backfilled !== undefined ||
2171
2250
  droppedRows.length > 0 ||
2172
2251
  Object.values(moved).some((paths) => paths.length > 0);
2173
2252
  if (recordChanged) {
2174
- writeFileSync(recordPath, serializeTemplateRecord({ schema: 1, projectName: record.projectName, files: nextFiles }));
2253
+ writeFileSync(recordPath, serializeTemplateRecord({ schema: 1, projectName: record.projectName, files: nextFiles, seams: nextSeams }));
2175
2254
  }
2176
2255
  // #10774 D3 — the surfaces the roster named are declared, as add-route
2177
2256
  // declares one: the whole generated file, re-derived.
@@ -2287,6 +2366,9 @@ export async function updateSite(opts) {
2287
2366
  for (const { path, reason } of headings.refused) {
2288
2367
  review.push({ path: sitePath(path), reason: `no '# ' heading added: ${reason}` });
2289
2368
  }
2369
+ // #11148 — a seam left as the site keeps it, with why; joins `review` after
2370
+ // `heldFiles` was computed, as the heading rows do.
2371
+ review.push(...seamPlan.held);
2290
2372
  // #10773 D6 — a bare `{` on an mdx-body page is MDX code: the page fails or
2291
2373
  // drops it. Escape every one, after the heading pass so its writes are read
2292
2374
  // too, keeping a page's write only when the site's own parser reads it clean.
@@ -2352,6 +2434,7 @@ export async function updateSite(opts) {
2352
2434
  : {}),
2353
2435
  headingsAdded: headings.written.map(sitePath),
2354
2436
  bracesEscaped,
2437
+ ...(regenerated.length > 0 ? { regenerated: regenerated.sort() } : {}),
2355
2438
  ...(routesWritten.length > 0 ? { routesWritten } : {}),
2356
2439
  ...(cliPin !== undefined ? { cliPin } : {}),
2357
2440
  ...(backfilled !== undefined ? { backfilled } : {}),
@@ -2435,6 +2518,7 @@ export function formatUpdateReport(result) {
2435
2518
  ["Already current", result.current],
2436
2519
  ["Page heading added", result.headingsAdded],
2437
2520
  ["Placeholder brace escaped", result.bracesEscaped],
2521
+ ["Regenerated", result.regenerated ?? []],
2438
2522
  ["Route files regenerated", result.routesWritten ?? []],
2439
2523
  ];
2440
2524
  if (result.cliPin !== undefined) {
@@ -2516,6 +2600,7 @@ export function formatUpdateReport(result) {
2516
2600
  result.current.length === 0 &&
2517
2601
  result.headingsAdded.length === 0 &&
2518
2602
  result.bracesEscaped.length === 0 &&
2603
+ result.regenerated === undefined &&
2519
2604
  result.routesWritten === undefined &&
2520
2605
  result.cliPin === undefined &&
2521
2606
  result.review.length === 0 &&
@@ -2571,8 +2656,10 @@ template path that is not in the record (one an earlier sync-routes --apply
2571
2656
  or add-route copied without recording it) whose bytes are a published
2572
2657
  create-ailk version's copy — from the version the site was scaffolded at to
2573
2658
  this one — is adopted: recorded and moved forward as an untouched file is,
2574
- listed under "Adopted" with the version it matched. One whose bytes match no
2575
- published copy is a site edit: skipped, never overwritten, and counted under
2659
+ listed under "Adopted" with the version it matched. One whose bytes are the
2660
+ running copy with this site's modules' patches applied (a module's
2661
+ jest.config.cjs or next.config.mjs edit) is left as it is and not listed.
2662
+ One whose bytes match no published copy is a site edit: skipped, never overwritten, and counted under
2576
2663
  "Held as site edits, not in the record". No file under a route the site
2577
2664
  lists in customizations.yaml declined_routes is written: each is listed under
2578
2665
  "Skipped" naming the declined route. Every template
@@ -2616,7 +2703,12 @@ read, is listed under "Needs review". Each bare { on an mdx-body page is
2616
2703
  escaped as \\{ when the site's own MDX parser then reads the page clean, listed
2617
2704
  under "Placeholder brace escaped"; a page it cannot escape safely, or any page
2618
2705
  with one while the site's dependencies are not installed, is listed under
2619
- "Needs review". Last, the generated route files of every installed page
2706
+ "Needs review". Each topology seam (*.generated.* — the web seam, the
2707
+ (authed) gate, the API origin and the MCP seam) is rendered again for the
2708
+ topology and sign-in mode .ailk-site-manifest.json records and listed under
2709
+ "Regenerated", when its bytes are still the render .ailk-template-files.json
2710
+ records; one edited by hand, or with no recorded render, is listed under
2711
+ "Needs review" and left as it is. Last, the generated route files of every installed page
2620
2712
  package (one whose package.json declares "ailk": { "routes" }) are rewritten
2621
2713
  from its manifest, listed under "Route files regenerated"; run
2622
2714
  \`create-ailk routes --write\` after the install when the packages were not
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ailk",
3
- "version": "0.40.1",
3
+ "version": "0.40.2",
4
4
  "description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "tar": "^7.5.21"
29
29
  },
30
30
  "devDependencies": {
31
- "@working-theory/schema": "0.65.0",
32
- "@working-theory/templates": "0.65.0"
31
+ "@working-theory/schema": "0.66.0",
32
+ "@working-theory/templates": "0.66.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",