create-ailk 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +149 -2
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +7 -2
  6. package/dist/add-route.js +28 -13
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +9 -15
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +67 -0
  26. package/dist/routes.d.ts +103 -0
  27. package/dist/routes.js +708 -0
  28. package/dist/site-manifest.js +1 -1
  29. package/dist/site-roster.d.ts +2 -1
  30. package/dist/site-roster.js +30 -8
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +18 -0
  34. package/dist/surfaces.js +47 -282
  35. package/dist/sync-routes.d.ts +28 -1
  36. package/dist/sync-routes.js +144 -11
  37. package/dist/template-record.d.ts +11 -0
  38. package/dist/template-record.js +18 -0
  39. package/dist/topology.d.ts +15 -1
  40. package/dist/topology.js +20 -4
  41. package/dist/update.d.ts +31 -2
  42. package/dist/update.js +627 -99
  43. package/package.json +3 -3
  44. package/templates/README.md +1 -1
  45. package/templates/apps/mcp/CLAUDE.md +5 -3
  46. package/templates/apps/web/CLAUDE.md +62 -20
  47. package/templates/apps/web/account.config.tsx +101 -0
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  51. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  53. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  54. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  55. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  57. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  58. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  59. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  60. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  61. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  62. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  63. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  64. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  65. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  66. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  67. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  68. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  69. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  70. package/templates/apps/web/app/apple-icon.tsx +72 -0
  71. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  72. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  73. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  74. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  75. package/templates/apps/web/app/og/route.tsx +155 -72
  76. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  77. package/templates/apps/web/i18n/request.ts +44 -1
  78. package/templates/apps/web/jest.config.cjs +13 -1
  79. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  80. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  81. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  82. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  83. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  84. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  85. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  86. package/templates/apps/web/lib/listings.tsx +2 -2
  87. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  88. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  89. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  90. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  91. package/templates/apps/web/lib/served-pages.ts +95 -0
  92. package/templates/apps/web/lib/site-brand.tsx +3 -5
  93. package/templates/apps/web/messages/en.json +8 -684
  94. package/templates/apps/web/middleware.ts +3 -1
  95. package/templates/apps/web/next.config.mjs +27 -0
  96. package/templates/apps/web/package.json +1 -0
  97. package/templates/customizations.yaml +9 -0
  98. package/templates/package.json +3 -1
  99. package/templates/tools/lint-architecture.ts +164 -11
  100. package/versions.json +48 -47
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  119. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  120. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  121. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  122. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  123. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  125. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  126. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  127. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  128. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  135. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  136. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  138. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  139. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  140. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  141. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  142. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  153. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  154. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  157. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  158. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  161. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  162. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  164. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  165. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  166. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  167. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  168. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  169. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  170. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  171. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  173. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  174. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  175. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  176. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  177. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  178. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  179. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  180. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  181. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  182. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  183. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  195. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  196. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  197. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  198. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  199. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  200. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  201. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  214. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  215. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  216. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  217. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  218. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  219. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  220. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  221. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  222. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  224. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  225. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  226. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  227. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  228. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  229. package/templates/apps/web/lib/account-config.ts +0 -678
  230. package/templates/apps/web/lib/checkout-config.ts +0 -16
  231. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  232. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
package/README.md CHANGED
@@ -296,6 +296,32 @@ scaffold's). It never rewrites or deletes an existing file, writes nothing
296
296
  outside `apps/web/app/[locale]/` except the local modules those routes import
297
297
  (below), runs no install, and a second run is a no-op. `--apply` exits 0 on success.
298
298
 
299
+ **A route the site declined stays declined.** A site that drops one template
300
+ route on purpose records it in `customizations.yaml`:
301
+
302
+ ```yaml
303
+ declined_routes:
304
+ - route: "pricing/[slug]" # as it sits under apps/web/app/[locale]/
305
+ reason: "this site sells from /pricing alone"
306
+ decided: "Site Owner, 2026-11-02" # <decider>, <YYYY-MM-DD>
307
+ ```
308
+
309
+ `sync-routes` lists a declined route (and its sub-routes) under **Declined by
310
+ this site**, never as missing, so a check whose only gaps are declined routes
311
+ exits 0; `--apply` never copies it, not even inside an ancestor route's copy.
312
+ `create-ailk update` never writes a file under a declined route's directory and
313
+ lists each one it skips. The scaffold's `pnpm architecture` refuses an entry
314
+ with no `reason`, no `decided` line, or naming no route the template carries
315
+ (#11260).
316
+
317
+ **What `--apply` copies, it records.** Every file it writes gets a row in
318
+ `.ailk-template-files.json` — the sha256 of the bytes written and the
319
+ create-ailk version that copied it — so `create-ailk update` (below) reads it
320
+ as the untouched template copy it is and carries it forward, instead of
321
+ holding it as "exists, not in the record" on the next release. A site with no
322
+ record gets none; a malformed record refuses the run before anything is
323
+ copied. `add-route` runs the same sync, so it records what it copies too.
324
+
299
325
  **Scope.** Every core route (`about`, `contact`, `faq`, `thanks/[slug]`,
300
326
  `sign-in`) is always checked, and so is the `(authed)` route GROUP —
301
327
  `layout.tsx`, `account/`, and `waitlist/` — even though
@@ -361,6 +387,112 @@ the route-surface registry in the same file.
361
387
  `ROUTE_SINCE` entry — `__tests__/sync-routes.test.ts` fails otherwise (and it
362
388
  fails on a stale entry for a route the template no longer ships).
363
389
 
390
+ ### Generate the route files for the pages a site's packages ship
391
+
392
+ A website page ships in a package (ADR 0040): its implementation, data
393
+ loading and server actions live in a `@working-theory/*` package, and the
394
+ site's `apps/web/app/[locale]/` holds **one generated file per route** —
395
+ nothing of the page's implementation. `routes` is the one generator for
396
+ every such package:
397
+
398
+ ```bash
399
+ # write the generated files (run after `pnpm install` — the manifests are read from the installed packages)
400
+ create-ailk routes --write ./my-site
401
+ # check them — exit 1 naming each missing, stale or stray file; the scaffold's preflight runs this as `pnpm routes:check`
402
+ create-ailk routes --check ./my-site
403
+ ```
404
+
405
+ A **page package** is an installed dependency of `apps/web` whose
406
+ `package.json` declares `"ailk": { "routes": "<manifest path>" }`. Its
407
+ manifest names the package's route prefix under `app/[locale]/`, the site's
408
+ config file, and one entry per routing file:
409
+
410
+ ```json
411
+ {
412
+ "schema": 1,
413
+ "prefix": "(authed)/account",
414
+ "config": "account.config",
415
+ "routes": [
416
+ {
417
+ "path": "(authed)/account/general/page.tsx",
418
+ "kind": "page",
419
+ "module": "general/page",
420
+ "exports": ["default", "generateMetadata"],
421
+ "segmentConfig": ["export const dynamic = \"force-dynamic\";"],
422
+ "config": true
423
+ }
424
+ ]
425
+ }
426
+ ```
427
+
428
+ Each generated file carries a header naming the package and its version, one
429
+ re-export per listed export (`default`, `metadata` and `generateMetadata` on
430
+ a page or layout; the HTTP methods on a route handler), the route-segment
431
+ config lines copied literally — Next reads those from the file in `app/`, so
432
+ a re-export would not do — and, when the entry takes config, an import of
433
+ the site's `apps/web/<config>.tsx` passed to the page as its `config` prop
434
+ (the wrapper calls the page and returns its tree, so the route module keeps
435
+ the page's own contract):
436
+
437
+ ```tsx
438
+ // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
439
+ import Page from "@working-theory/account/general/page";
440
+
441
+ import config from "../../../../../account.config";
442
+
443
+ export { generateMetadata } from "@working-theory/account/general/page";
444
+ export const dynamic = "force-dynamic";
445
+
446
+ export default async function Route(
447
+ props: Omit<Parameters<typeof Page>[0], "config">,
448
+ ) {
449
+ return Page({ ...props, config });
450
+ }
451
+ ```
452
+
453
+ The config file is the **one typed file** through which a site customizes a
454
+ package's pages (options and slots, typed by the package — a misspelled
455
+ option fails `tsc`); there is no context provider, because most pages are
456
+ Server Components. The generated files are prettier-stable and never
457
+ hand-edited: `--check` reports a **stale** file (its content differs from
458
+ what `--write` would write — after a version bump, every header does, until
459
+ `--write` runs), a **missing** one (an entry with no file), and a **stray**
460
+ one (a `page.tsx`, `layout.tsx` or `route.ts` under a package's prefix that
461
+ is neither generated nor recorded; the other Next convention files —
462
+ `loading.tsx`, `error.tsx`, `not-found.tsx` — are the site's own and never
463
+ stray). The prefix is the subtree the package has taken over, and a
464
+ manifest shipping no route owns nothing yet.
465
+
466
+ **Replacing or removing a shipped page is recorded.** A site replaces a
467
+ shipped route by writing its own file at that route, and removes one by
468
+ deleting the generated file — and, either way, by adding an entry to
469
+ `customizations.yaml` whose `paths` match the route file, in the manifest's
470
+ own grammar:
471
+
472
+ ```yaml
473
+ customizations:
474
+ - id: own-security-page
475
+ paths:
476
+ - "apps/web/app/[locale]/(authed)/account/security/**"
477
+ request: "acme/acme-site#12"
478
+ decision: "build-in: site — Sam, 2026-11-09, the site keeps its own Security page"
479
+ ```
480
+
481
+ A recorded route is reported as `replaced` (its file exists) or `removed`
482
+ (it does not) and never fails the check; `--write` never overwrites or
483
+ re-creates it. A replaced page stops receiving upgrades, visibly, as one
484
+ recorded file. There is no command that copies a shipped page's source into
485
+ a site.
486
+
487
+ **Where it runs.** At scaffold time after `--install` (a scaffold without
488
+ `--install` names the command in its next steps), and inside `create-ailk
489
+ update` after the pins move (below). The scaffold's `preflight` script runs
490
+ `--check` as its `routes:check` step, through the `create-ailk` its root
491
+ `devDependencies` pin at the exact version that scaffolded the site — so the
492
+ check re-renders the files with the generator that wrote them; `update` moves
493
+ that pin to its own version along with the files. A bump for a moved slice is
494
+ a pin change plus regenerated route files.
495
+
364
496
  ### Update the copied app code
365
497
 
366
498
  A fresh scaffold records every `apps/web`, `apps/api` and `apps/mcp` file the
@@ -403,10 +535,20 @@ merge-file` against the recorded version's own copy as the base. A clean
403
535
  dropped from the roster after the writes, every other byte of the file
404
536
  kept. Reported as **Roster rows dropped, no route serves them**.
405
537
 
538
+ - A file at a template path that exists on disk but was never recorded —
539
+ one an earlier `sync-routes --apply` or `add-route` copied without
540
+ recording it — is **Adopted** when its bytes are that path's template
541
+ copy in any published create-ailk version from the site's
542
+ `patternVersion` up to the one being applied: its row is written and the
543
+ file moves forward as an untouched copy does, listed under **Adopted**
544
+ with the version it matched. One matching no published copy is the
545
+ site's own: skipped as a site edit, never overwritten, and counted under
546
+ **Held as site edits, not in the record**.
547
+
406
548
  A file outside the gated-off surfaces and spoke exclusions the site's scope
407
549
  no longer covers is **Skipped**, as is one that exists on disk but was never
408
- recorded (a module bundle's own file, say) when its bytes differ from the
409
- running copy. Nothing the base scaffold did not write is ever touched. No
550
+ recorded (a module bundle's own file, say) when its bytes match no template
551
+ copy. Nothing the base scaffold did not write is ever touched. No
410
552
  template change at all means `Already up to date` and zero files written.
411
553
 
412
554
  **Tests are held back with the file they test.** When a file is left under
@@ -681,6 +823,11 @@ AILK_AGENT_KEY=<agent key> create-ailk migrate-content ./my-site --api-url <api
681
823
  AILK_AGENT_KEY=<agent key> create-ailk migrate-content ./my-site --apply --api-url <api origin> --workspace <wksp_id>
682
824
  ```
683
825
 
826
+ - `--language-seed <file>` also writes a Language seed file's `topics[]`
827
+ (`language/<entity>.json`), each as one Topic holding all its keywords —
828
+ their monthly searches and as-of dates as the keywords' numbers, the
829
+ primary marked, the pillar set. A Topic the workspace already holds keeps
830
+ its spelling, notes and newer numbers. The file's `items[]` are not read.
684
831
  - It is a dry run by default and writes nothing: it reads the workspace,
685
832
  prints what `--apply` would do to each page — `create`, `update`,
686
833
  `unchanged`, `skipped` or `failed` — then a count line. A dry run never sends
@@ -121,7 +121,7 @@
121
121
  "importPath": "@working-theory/ui-commerce",
122
122
  "rootBarrel": "@working-theory/ui-commerce",
123
123
  "sourceRoot": "packages-paid/ui-commerce/src/blocks",
124
- "count": 12
124
+ "count": 13
125
125
  },
126
126
  {
127
127
  "name": "commerce-panels",
@@ -3642,6 +3642,17 @@
3642
3642
  "descriptionGrade": "strong",
3643
3643
  "sectionType": null
3644
3644
  },
3645
+ {
3646
+ "name": "FlowResultsPriceCard",
3647
+ "tier": "commerce-blocks",
3648
+ "sourcePath": "packages-paid/ui-commerce/src/blocks/FlowResultsPriceCard.tsx",
3649
+ "importPath": "@working-theory/ui-commerce",
3650
+ "exported": true,
3651
+ "description": "The flows results page's configurable checkout price card, with its own breakdown toggle and every label passed in.",
3652
+ "descriptionSource": "doc-comment",
3653
+ "descriptionGrade": "strong",
3654
+ "sectionType": null
3655
+ },
3645
3656
  {
3646
3657
  "name": "InvoiceForm",
3647
3658
  "tier": "commerce-blocks",
@@ -6790,6 +6801,21 @@
6790
6801
  "start",
6791
6802
  "center"
6792
6803
  ]
6804
+ },
6805
+ "tags": {
6806
+ "maxItems": 20,
6807
+ "type": "array",
6808
+ "items": {
6809
+ "type": "string",
6810
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
6811
+ }
6812
+ },
6813
+ "pinned": {
6814
+ "maxItems": 100,
6815
+ "type": "array",
6816
+ "items": {
6817
+ "type": "string"
6818
+ }
6793
6819
  }
6794
6820
  },
6795
6821
  "required": [
@@ -6915,8 +6941,7 @@
6915
6941
  }
6916
6942
  },
6917
6943
  "required": [
6918
- "quote",
6919
- "author"
6944
+ "quote"
6920
6945
  ]
6921
6946
  }
6922
6947
  },
@@ -6931,6 +6956,21 @@
6931
6956
  "gradient-dark",
6932
6957
  "solid-dark"
6933
6958
  ]
6959
+ },
6960
+ "tags": {
6961
+ "maxItems": 20,
6962
+ "type": "array",
6963
+ "items": {
6964
+ "type": "string",
6965
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
6966
+ }
6967
+ },
6968
+ "pinned": {
6969
+ "maxItems": 100,
6970
+ "type": "array",
6971
+ "items": {
6972
+ "type": "string"
6973
+ }
6934
6974
  }
6935
6975
  },
6936
6976
  "required": [
@@ -11976,7 +12016,6 @@
11976
12016
  "minLength": 1
11977
12017
  },
11978
12018
  "blocks": {
11979
- "minItems": 1,
11980
12019
  "type": "array",
11981
12020
  "items": {
11982
12021
  "oneOf": [
@@ -12105,8 +12144,7 @@
12105
12144
  },
12106
12145
  "required": [
12107
12146
  "id",
12108
- "heading",
12109
- "blocks"
12147
+ "heading"
12110
12148
  ]
12111
12149
  }
12112
12150
  },
@@ -15,13 +15,13 @@ The component inventory of `@working-theory/ui` and the shells of `@working-theo
15
15
  3. Check the Primitives, Panels and Shells tables too — a low-level control, a collapsible layout container, or a route-level frame lives there, not under Sections or Blocks.
16
16
  4. Only then build. If you do build, you are declaring the capability is genuinely absent.
17
17
 
18
- Inventory: **330 component files** across 16 tiers — 60 sections, 110 blocks, 19 chrome, 82 primitives, 6 panels, 8 shells, 5 docs-blog-blocks, 1 docs-blog-chrome, 2 docs-blog-shells, 2 scheduling-sections, 6 scheduling-blocks, 5 signal-collectors-sections, 9 signal-collectors-blocks, 2 commerce-sections, 12 commerce-blocks, 1 commerce-panels. 327 distinct names: `SchedulerEmbed`, `Separator`, `Tabs` exist in more than one tier as genuinely different components, listed once per tier with its own source path.
18
+ Inventory: **331 component files** across 16 tiers — 60 sections, 110 blocks, 19 chrome, 82 primitives, 6 panels, 8 shells, 5 docs-blog-blocks, 1 docs-blog-chrome, 2 docs-blog-shells, 2 scheduling-sections, 6 scheduling-blocks, 5 signal-collectors-sections, 9 signal-collectors-blocks, 2 commerce-sections, 13 commerce-blocks, 1 commerce-panels. 328 distinct names: `SchedulerEmbed`, `Separator`, `Tabs` exist in more than one tier as genuinely different components, listed once per tier with its own source path.
19
19
 
20
- Description coverage: **326/330** components carry a capability description derived from source — 45 from the section registry's hand-authored when-to-use text, 246 from the component's own doc-comment header, 35 from its tier barrel's roster line. **4** have none; they are listed under [Undescribed components](#undescribed-components) rather than given a sentence invented from their name.
20
+ Description coverage: **327/331** components carry a capability description derived from source — 45 from the section registry's hand-authored when-to-use text, 247 from the component's own doc-comment header, 35 from its tier barrel's roster line. **4** have none; they are listed under [Undescribed components](#undescribed-components) rather than given a sentence invented from their name.
21
21
 
22
- Of those, **293** are *strong* — a capability sentence you could match a requirement against — and **33** are *weak*: either one short clause, or a long one that spends itself on wiring (client boundaries, class names, which primitives it composes) instead of on what the thing is for. Weak rows are marked `(weak)` and listed in full under [Weak descriptions](#weak-descriptions). Coverage is 99%, but **findable-without-luck coverage is 89%**.
22
+ Of those, **294** are *strong* — a capability sentence you could match a requirement against — and **33** are *weak*: either one short clause, or a long one that spends itself on wiring (client boundaries, class names, which primitives it composes) instead of on what the thing is for. Weak rows are marked `(weak)` and listed in full under [Weak descriptions](#weak-descriptions). Coverage is 99%, but **findable-without-luck coverage is 89%**.
23
23
 
24
- Per tier, strong out of total: **Sections** 59/60 · **Blocks** 102/110 · **Chrome** 10/19 · **Primitives** 67/82 (4 undescribed) · **Panels** 6/6 · **Shells** 7/8 · **Docs + Blog Blocks** 5/5 · **Docs + Blog Chrome** 1/1 · **Docs + Blog Shells** 0/2 · **Scheduling Sections** 2/2 · **Scheduling Blocks** 6/6 · **Signal-Collectors Sections** 5/5 · **Signal-Collectors Blocks** 8/9 · **Commerce Sections** 2/2 · **Commerce Blocks** 12/12 · **Commerce Panels** 1/1. A tier low on this line is a tier where a capability search is most likely to come up empty on something that exists.
24
+ Per tier, strong out of total: **Sections** 59/60 · **Blocks** 102/110 · **Chrome** 10/19 · **Primitives** 67/82 (4 undescribed) · **Panels** 6/6 · **Shells** 7/8 · **Docs + Blog Blocks** 5/5 · **Docs + Blog Chrome** 1/1 · **Docs + Blog Shells** 0/2 · **Scheduling Sections** 2/2 · **Scheduling Blocks** 6/6 · **Signal-Collectors Sections** 5/5 · **Signal-Collectors Blocks** 8/9 · **Commerce Sections** 2/2 · **Commerce Blocks** 13/13 · **Commerce Panels** 1/1. A tier low on this line is a tier where a capability search is most likely to come up empty on something that exists.
25
25
 
26
26
  That grade is **mechanical**. It counts what it can measure — how much a description adds beyond the component's own name, how much of it is spent on wiring, whether the extraction came out damaged — and it cannot tell a fluent paragraph about the wrong subject from a useful one. A person reading these tables will find more rows unusable than the weak count admits. Treat it as a floor on the problem, not a measurement of it, and read the source before concluding a capability is absent.
27
27
 
@@ -524,7 +524,7 @@ Import: `import { X } from "@working-theory/ui-commerce";` (or from the `@workin
524
524
 
525
525
  ---
526
526
 
527
- ## Commerce Blocks (12)
527
+ ## Commerce Blocks (13)
528
528
 
529
529
  Paid — delivered by the `commerce` module bundle, not present in a Free scaffold. Checkout, payment, invoice, subscription and customer-portal tiles. Search here before hand-rolling any Stripe-facing UI.
530
530
 
@@ -534,6 +534,7 @@ Import: `import { X } from "@working-theory/ui-commerce";` (or from the `@workin
534
534
  | --- | --- | --- |
535
535
  | `CheckoutForm` | Product/amount selection + checkout submit for the one-time checkout surface. | internal — compose from `packages-paid/ui-commerce/src/blocks/CheckoutForm.tsx` |
536
536
  | `CheckoutPriceCard` | DESIGN 's checkout price card: the panel's fourth view once it flips to the right and becomes an order summary — eyebrow, offer name + description, seat/credit line items, an optional caller-supplied add-credits row, and the total + due-today. | `import { CheckoutPriceCard } from "@working-theory/ui-commerce"` |
537
+ | `FlowResultsPriceCard` | The flows results page's configurable checkout price card, with its own breakdown toggle and every label passed in. | `import { FlowResultsPriceCard } from "@working-theory/ui-commerce"` |
537
538
  | `InvoiceForm` | Creates a draft invoice (single line item), for the invoice surface (U4). | internal — compose from `packages-paid/ui-commerce/src/blocks/InvoiceForm.tsx` |
538
539
  | `InvoiceList` | A customer's invoice rows, shared by the invoice surface (U4). Capability-bearing: binds a schema.org `Invoice` resource-payload fragment per row (imported from `@working-theory/schema`) — so a co-located `.text.ts` + `.text.test.ts` renderer is required and gated by `scripts/check-ax-parity.sh`. | internal — compose from `packages-paid/ui-commerce/src/blocks/InvoiceList.tsx` |
539
540
  | `PaymentLinkCard` | A single shareable Stripe Payment Link (pay-by-link surface). Renders the link's offer name, active-status chip, optional amount, and the hosted URL with a one-click copy action. | internal — compose from `packages-paid/ui-commerce/src/blocks/PaymentLinkCard.tsx` |
@@ -38,6 +38,7 @@ import { publicTreeRemoved } from "./lib/site-modules.js";
38
38
  import { normalizeModules } from "./module-architecture.js";
39
39
  import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH, writePaidSections, } from "./paid-sections.js";
40
40
  import { ParseError, parseModules } from "./parse-args.js";
41
+ import { RoutesRefusedError, writeRoutes } from "./routes.js";
41
42
  import { writeSpokeFlowsReadme } from "./seed-flows.js";
42
43
  import { SITE_ROSTER_PATH, moduleRosterRows, planRosterAppend, readSiteRoster, siteRosterProblems, } from "./site-roster.js";
43
44
  import { spokeCheckoutSite, spokeEnvRowOptions, writeSpokeCheckoutSlice, } from "./spoke-checkout.js";
@@ -233,6 +234,20 @@ export async function applyModuleToScaffold(opts) {
233
234
  if (existsSync(abs) && readFileSync(abs, "utf8") !== before)
234
235
  rows.push({ path, action: "written" });
235
236
  }
237
+ // #11251 D8 — a page package's route files, generated from its installed
238
+ // manifest. `add-module` runs no package manager, so on a site that has not
239
+ // installed the module's package yet this writes nothing (the next-steps
240
+ // line names `routes --write`); on one that has, the files land now.
241
+ // A refusal (a malformed manifest, a missing config file) writes nothing
242
+ // here: the site's own `routes --check` names it, as after `update`.
243
+ try {
244
+ for (const path of writeRoutes(targetAbs).written)
245
+ rows.push({ path, action: "written" });
246
+ }
247
+ catch (err) {
248
+ if (!(err instanceof RoutesRefusedError))
249
+ throw err;
250
+ }
236
251
  const navRow = syncNavConfig(targetAbs, current.surfaces, surfaces);
237
252
  if (navRow !== undefined)
238
253
  rows.push(navRow);
@@ -411,7 +426,7 @@ export function formatAddModuleReport(result, moduleName) {
411
426
  lines.push(`architecture.yaml modules: ${result.modules.join(", ")}`);
412
427
  lines.push(...formatRoster(result.roster, moduleName));
413
428
  if (written.length > 0 || patched.length > 0 || routes.applied.length > 0) {
414
- lines.push("Next: pnpm install, then pnpm build.");
429
+ lines.push("Next: pnpm install, then pnpm create-ailk routes --write, then pnpm build.");
415
430
  }
416
431
  return lines.join("\n") + "\n";
417
432
  }
@@ -19,6 +19,11 @@ export interface AddRouteOptions {
19
19
  templatesDir: string;
20
20
  /** The package's `site-templates/` dir — the `_base` layer's seeds. */
21
21
  siteTemplatesDir: string;
22
+ /**
23
+ * The create-ailk version the copied route files are recorded at
24
+ * (#11213); defaults to the running package's own, as `syncRoutes` does.
25
+ */
26
+ version?: string;
22
27
  }
23
28
  export interface AddRouteResult {
24
29
  /** Resolved absolute path to the site. */
@@ -44,7 +49,7 @@ export declare function formatAddRouteReport(result: AddRouteResult): string;
44
49
  export declare const MAGNET_ROUTE = "magnet";
45
50
  /**
46
51
  * The header-comment marker every standard magnet page carries — the same
47
- * string `flows/[slug]/magnet-page.tsx` exports, which the site's
52
+ * string the package's `flows/[slug]/magnet-page.tsx` exports, which the site's
48
53
  * `structured-data.test.tsx` reads to exempt the pair (#8840 D13).
49
54
  */
50
55
  export declare const MAGNET_PAGE_MARKER = "Standard magnet page (#8840)";
@@ -81,7 +86,7 @@ export interface AddMagnetResult {
81
86
  /**
82
87
  * Write a magnet page pair — `apps/web/app/[locale]/<path>/page.tsx` (the
83
88
  * landing) and `<path>/start/page.tsx` (the walk) — bound to one flow slug.
84
- * Each page is a few lines over the factories in `flows/[slug]/magnet-page`;
89
+ * Each page is a few lines over the factories in the package's `flows/[slug]/magnet-page`;
85
90
  * the copy, consent and ending come from the flow's record.
86
91
  *
87
92
  * Every refusal throws `AddRouteRefusedError` before the first write. A page
package/dist/add-route.js CHANGED
@@ -12,8 +12,10 @@
12
12
  * against the site's module set — a route another module delivers is
13
13
  * refused, naming the module and `add-module`, before any write;
14
14
  * - the surface's route dirs are synced in (`syncRoutes` with it forced
15
- * carried), `architecture.yaml` is regenerated with it declared, and the
16
- * nav follows unless the site has edited it (`syncNavConfig`);
15
+ * carried, which records every file it copies in
16
+ * `.ailk-template-files.json`, #11213), `architecture.yaml` is
17
+ * regenerated with it declared, and the nav follows unless the site has
18
+ * edited it (`syncNavConfig`);
17
19
  * - the surface's seed content is written from the two shared layers a
18
20
  * fresh scaffold keeps it from (the `templates/` overlay, then `_base`),
19
21
  * never over a file the site already has.
@@ -30,7 +32,8 @@
30
32
  * `create-ailk add-route magnet --path <path> --flow <slug>` (#8840 D12) is
31
33
  * the second mode: it writes a site's own magnet page pair at `<path>` and
32
34
  * `<path>/start`, bound to one flow slug, over the standard renderers in
33
- * `flows/[slug]/magnet-page.tsx` — see `addMagnetToScaffold`.
35
+ * `@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page` —
36
+ * see `addMagnetToScaffold`.
34
37
  *
35
38
  * Pure module: no `import.meta.url`, so jest can import it directly — the
36
39
  * package-rooted inputs are supplied by the CLI, the `add-module.ts` split.
@@ -50,6 +53,7 @@ import { GATEABLE_SURFACES, MODULE_SURFACES, parseSurfaces, resolveSurfaces, } f
50
53
  import { syncRoutes } from "./sync-routes.js";
51
54
  import { BASE_LAYER_DIR } from "./template-manifest.js";
52
55
  import { templatePageSeeds } from "./template-pages.js";
56
+ import { TEMPLATE_RECORD_PATH } from "./template-record.js";
53
57
  import { TopologyError, readSiteTopology } from "./topology.js";
54
58
  /** A refusal the CLI exits 2 on, thrown before anything is written. */
55
59
  export class AddRouteRefusedError extends Error {
@@ -117,6 +121,7 @@ export function addRouteToScaffold(opts) {
117
121
  versions: opts.versions,
118
122
  apply: true,
119
123
  forceSurfaces: [route],
124
+ ...(opts.version !== undefined ? { version: opts.version } : {}),
120
125
  });
121
126
  const report = seedSurfaceContent(targetAbs, route, opts);
122
127
  seedGeneratedContent(targetAbs, route, report);
@@ -255,6 +260,7 @@ export function formatAddRouteReport(result) {
255
260
  applied: [],
256
261
  refused: [],
257
262
  appliedDependencies: [],
263
+ recorded: [],
258
264
  missingMessageNamespaces: [],
259
265
  };
260
266
  const lines = [
@@ -273,6 +279,9 @@ export function formatAddRouteReport(result) {
273
279
  lines.push(`Also copied ${routes.appliedDependencies.length} file(s) those routes import:`);
274
280
  lines.push(...routes.appliedDependencies.map((dep) => ` ${dep}`));
275
281
  }
282
+ if (routes.recorded.length > 0) {
283
+ lines.push(`Recorded ${routes.recorded.length} copied file(s) in ${TEMPLATE_RECORD_PATH}, so create-ailk update carries them forward.`);
284
+ }
276
285
  if (routes.refused.length > 0) {
277
286
  lines.push(`Routes not copied (${routes.refused.length}) — an import does not resolve (run create-ailk sync-routes for the paths): ${routes.refused.join(", ")}`);
278
287
  }
@@ -303,7 +312,7 @@ export function formatAddRouteReport(result) {
303
312
  export const MAGNET_ROUTE = "magnet";
304
313
  /**
305
314
  * The header-comment marker every standard magnet page carries — the same
306
- * string `flows/[slug]/magnet-page.tsx` exports, which the site's
315
+ * string the package's `flows/[slug]/magnet-page.tsx` exports, which the site's
307
316
  * `structured-data.test.tsx` reads to exempt the pair (#8840 D13).
308
317
  */
309
318
  export const MAGNET_PAGE_MARKER = "Standard magnet page (#8840)";
@@ -354,7 +363,7 @@ export function isMagnetFlowSlug(slug) {
354
363
  /**
355
364
  * Write a magnet page pair — `apps/web/app/[locale]/<path>/page.tsx` (the
356
365
  * landing) and `<path>/start/page.tsx` (the walk) — bound to one flow slug.
357
- * Each page is a few lines over the factories in `flows/[slug]/magnet-page`;
366
+ * Each page is a few lines over the factories in the package's `flows/[slug]/magnet-page`;
358
367
  * the copy, consent and ending come from the flow's record.
359
368
  *
360
369
  * Every refusal throws `AddRouteRefusedError` before the first write. A page
@@ -406,9 +415,9 @@ export function addMagnetToScaffold(opts) {
406
415
  const pages = [
407
416
  [
408
417
  landing,
409
- renderMagnetPage("landing", opts.path, opts.flow, segments.length),
418
+ renderMagnetPage("landing", opts.path, opts.flow),
410
419
  ],
411
- [walk, renderMagnetPage("walk", opts.path, opts.flow, segments.length + 1)],
420
+ [walk, renderMagnetPage("walk", opts.path, opts.flow)],
412
421
  ];
413
422
  const report = [];
414
423
  for (const [path, text] of pages) {
@@ -516,12 +525,18 @@ function staticPageServing(targetAbs, dirs, { ownPages }) {
516
525
  return walk(root);
517
526
  }
518
527
  /**
519
- * One page of the pair. `depth` is the page directory's segment count under
520
- * `[locale]`, so the import climbs back to `flows/[slug]/magnet-page`. Every
521
- * interpolated value has passed `MAGNET_PATH_RE` or `FLOW_SLUG_RE`, so none
522
- * can leave its string literal (SEC-8840-V5).
528
+ * The renderer's package subpath (#11251 D7), interpolated into the emitted
529
+ * import so create-ailk's own dist carries no `@working-theory/*` import
530
+ * statement (#8412).
531
+ */
532
+ const MAGNET_RENDERER = "@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page";
533
+ /**
534
+ * One page of the pair, importing the renderer from its package subpath,
535
+ * `@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page`
536
+ * (#11251 D7). Every interpolated value has passed `MAGNET_PATH_RE` or
537
+ * `FLOW_SLUG_RE`, so none can leave its string literal (SEC-8840-V5).
523
538
  */
524
- function renderMagnetPage(kind, path, flow, depth) {
539
+ function renderMagnetPage(kind, path, flow) {
525
540
  const [page, metadata, role] = kind === "landing"
526
541
  ? [
527
542
  "magnetLanding",
@@ -536,7 +551,7 @@ function renderMagnetPage(kind, path, flow, depth) {
536
551
  return [
537
552
  `// Generated by \`create-ailk add-route magnet --path ${path} --flow ${flow}\`.`,
538
553
  `// ${MAGNET_PAGE_MARKER} — ${role}.`,
539
- `import { ${page}, ${metadata} } from "${"../".repeat(depth)}flows/[slug]/magnet-page";`,
554
+ `import { ${page}, ${metadata} } from "${MAGNET_RENDERER}";`,
540
555
  "",
541
556
  `const MAGNET = { slug: "${flow}", path: "${path}" } as const;`,
542
557
  "",
package/dist/cli.js CHANGED
@@ -33,6 +33,10 @@
33
33
  * (#10648)
34
34
  * on a `sync-routes` subcommand: parse its own argv, run syncRoutesSync(),
35
35
  * print the report, exit (1 iff routes are missing in check mode)
36
+ * on a `routes` subcommand: write the generated route files the site's
37
+ * installed page packages declare (--write), or check them (--check:
38
+ * exit 1 naming each missing, stale or stray file; 2 on a refusal)
39
+ * (#11219, ADR 0040)
36
40
  * on a `license set` subcommand: write the key into the scaffold, push it
37
41
  * to a linked Vercel project and redeploy, exit (#6683 D9)
38
42
  * on a `provision-env` subcommand: set MCP_PUBLIC_HTTP_URL (and apps/mcp's
@@ -91,6 +95,7 @@ import { PLUGIN_INSTALL_LINES, ParseError, helpText, parseCliArgs, parseModules,
91
95
  import { addModule, removeModule, formatSurfaceDrift, scaffold, syncArchitectureSync, syncCatalogSync, syncClaudeMdSync, syncRoutesSync, } from "./programmatic.js";
92
96
  import { PROVISION_ENV_HELP, runProvisionEnv } from "./provision-env.js";
93
97
  import { REMOVE_MODULE_HELP, RemoveModuleRefusedError, formatRemoveModuleReport, parseRemoveModuleArgs, } from "./remove-module.js";
98
+ import { ROUTES_HELP, RoutesRefusedError, checkRoutes, formatRoutesReport, parseRoutesArgs, routesFailing, writeRoutes, } from "./routes.js";
94
99
  import { SEED_FLOWS_HELP, SeedFlowsRefusedError, parseSeedFlowsArgs, seedFlows, } from "./seed-flows.js";
95
100
  import { SEED_WORKSPACE_HELP, SeedWorkspaceRefusedError, parseSeedWorkspaceArgs, runScaffoldSeed, seedWorkspace, } from "./seed-workspace.js";
96
101
  import { CORE_SURFACE_PATHS, SURFACE_ALIASES } from "./surfaces.js";
@@ -348,6 +353,7 @@ async function main() {
348
353
  apply: args.apply,
349
354
  apiUrl: args.apiUrl,
350
355
  workspaceId: args.workspaceId,
356
+ languageSeed: args.languageSeed,
351
357
  onLine: (line) => process.stdout.write(`${line}\n`),
352
358
  });
353
359
  process.exit(exitCode);
@@ -450,6 +456,37 @@ async function main() {
450
456
  process.exit(2);
451
457
  }
452
458
  }
459
+ // `routes --write | --check [dir]` (#11219, ADR 0040 rule 3): the one
460
+ // route-file generator, over the manifests of the site's installed page
461
+ // packages. Check mode exits 1 iff a generated file is missing, stale or
462
+ // stray; a recorded replacement or removal is reported, never failed. A
463
+ // refusal it names (a malformed manifest, no config file, neither flag)
464
+ // exits 2 before anything is written.
465
+ if (argv[0] === "routes") {
466
+ try {
467
+ const args = parseRoutesArgs(argv.slice(1));
468
+ if (args.help) {
469
+ process.stdout.write(ROUTES_HELP);
470
+ process.exit(0);
471
+ }
472
+ const targetDir = resolve(args.target ?? process.cwd());
473
+ if (args.write) {
474
+ process.stdout.write(formatRoutesReport(writeRoutes(targetDir), "write"));
475
+ process.exit(0);
476
+ }
477
+ const drift = checkRoutes(targetDir);
478
+ const failing = routesFailing(drift);
479
+ (failing > 0 ? process.stderr : process.stdout).write(formatRoutesReport(drift, "check"));
480
+ process.exit(failing > 0 ? 1 : 0);
481
+ }
482
+ catch (err) {
483
+ const parseError = err.code?.startsWith("ERR_PARSE_ARGS") === true;
484
+ if (!(err instanceof RoutesRefusedError) && !parseError)
485
+ throw err;
486
+ process.stderr.write(`[create-ailk] ${err.message}\n`);
487
+ process.exit(2);
488
+ }
489
+ }
453
490
  // Subcommand dispatch, ahead of the flag parser: `sync-routes` has its own
454
491
  // argv shape (#4986). Check mode exits 1 iff a template route is missing;
455
492
  // locally modified routes are reported but do not fail; --apply exits 0.
@@ -677,6 +714,20 @@ async function main() {
677
714
  if (result.status !== 0) {
678
715
  throw new Error(`pnpm install failed in ${targetAbs} (exit ${result.status}). Run it manually after fixing the issue.`);
679
716
  }
717
+ // #11219 — with the packages installed, the generated route files of
718
+ // every page package are written (ADR 0040 rule 3: the generator runs at
719
+ // scaffold time). Without --install there is nothing to read them from;
720
+ // the next-steps message names the command to run after the install. A
721
+ // refusal is printed, never thrown: the tree is written and valid, and
722
+ // the site's own `routes --check` names what is left (the update idiom).
723
+ try {
724
+ process.stdout.write(formatRoutesReport(writeRoutes(targetAbs), "write"));
725
+ }
726
+ catch (err) {
727
+ if (!(err instanceof RoutesRefusedError))
728
+ throw err;
729
+ process.stderr.write(`[create-ailk] route files not generated: ${err.message}\n`);
730
+ }
680
731
  }
681
732
  // #10204 — on a hub with an Admin, seed the starter's pages into the
682
733
  // workspace, or say why not and how to later. A refusal is printed, never
@@ -760,6 +811,7 @@ async function main() {
760
811
  lines.push(` cd ${targetAbs}`);
761
812
  if (!opts.install) {
762
813
  lines.push(isSpoke ? " pnpm install" : " pnpm install # also generates the Prisma client");
814
+ lines.push(" pnpm create ailk@latest routes --write # the route files of the pages your packages ship");
763
815
  }
764
816
  lines.push(" pnpm dev # http://localhost:3000");
765
817
  lines.push(" pnpm build # production build, when you are ready to deploy");
@@ -0,0 +1,13 @@
1
+ /** The site file the list lives in. */
2
+ export declare const DECLINED_ROUTES_FILE = "customizations.yaml";
3
+ /**
4
+ * The `route` of every `declined_routes` entry in `<siteDir>/customizations.yaml`,
5
+ * sorted and deduplicated, each without a leading or trailing `/`. Empty when
6
+ * the file or the key is absent. Block (`- route: …`) and flow
7
+ * (`declined_routes: []`) forms; quoted or bare values.
8
+ */
9
+ export declare function readDeclinedRoutes(siteDir: string): string[];
10
+ /** The declined entry covering `route` (ROUTE_ROOT-relative) — itself or an ancestor — or undefined. */
11
+ export declare function declinedRouteFor(route: string, declined: readonly string[]): string | undefined;
12
+ /** The declined entry whose directory holds site-relative `path`, or undefined. */
13
+ export declare function declinedRouteOfPath(path: string, declined: readonly string[]): string | undefined;