create-ailk 0.38.0 → 0.40.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 (304) hide show
  1. package/dist/add-route.js +16 -1
  2. package/dist/body-heading.d.ts +2 -1
  3. package/dist/body-heading.js +31 -3
  4. package/dist/derive-architecture.js +3 -1
  5. package/dist/module-architecture.js +0 -3
  6. package/dist/remove-module.js +27 -14
  7. package/dist/routes.d.ts +36 -2
  8. package/dist/routes.js +269 -23
  9. package/dist/site-manifest.js +6 -4
  10. package/dist/site-roster.d.ts +11 -3
  11. package/dist/site-roster.js +48 -22
  12. package/dist/surfaces.d.ts +13 -3
  13. package/dist/surfaces.js +128 -194
  14. package/dist/sync-routes.js +22 -5
  15. package/dist/template-record.js +3 -1
  16. package/dist/topology.d.ts +11 -0
  17. package/dist/topology.js +253 -3
  18. package/package.json +3 -3
  19. package/templates/apps/web/CLAUDE.md +32 -4
  20. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +6 -1
  21. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +6 -1
  22. package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
  23. package/templates/apps/web/account.config.tsx +2 -3
  24. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  25. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  26. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
  27. package/templates/apps/web/app/[locale]/layout.tsx +2 -2
  28. package/templates/apps/web/auth.config.tsx +107 -0
  29. package/templates/apps/web/auth.ts +2 -1
  30. package/templates/apps/web/i18n/request.ts +13 -2
  31. package/templates/apps/web/jest.config.cjs +10 -0
  32. package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
  33. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +3 -0
  34. package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
  35. package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
  36. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
  37. package/templates/apps/web/lib/__tests__/server-api.test.ts +1 -1
  38. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
  39. package/templates/apps/web/lib/in-page-magnet.ts +2 -2
  40. package/templates/apps/web/lib/pricing-page.ts +3 -3
  41. package/templates/apps/web/lib/server-api.ts +1 -1
  42. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
  43. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
  44. package/templates/apps/web/lib/site-header.ts +1 -1
  45. package/templates/apps/web/lib/topology.generated.ts +5 -0
  46. package/templates/apps/web/messages/en.json +0 -271
  47. package/templates/apps/web/middleware.ts +12 -25
  48. package/templates/apps/web/next.config.mjs +15 -0
  49. package/templates/apps/web/package.json +2 -0
  50. package/templates/apps/web/site-pages.config.tsx +85 -0
  51. package/templates/apps/web/types/messages.d.ts +6 -1
  52. package/templates/tools/body-heading.ts +30 -3
  53. package/versions.json +50 -48
  54. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
  55. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
  56. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
  57. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
  58. package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
  59. package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
  60. package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
  61. package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
  62. package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
  63. package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
  64. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
  65. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
  66. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
  67. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
  68. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
  69. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
  70. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
  71. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
  72. package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
  73. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
  74. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
  75. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
  76. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
  77. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
  78. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
  79. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
  80. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
  81. package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
  82. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
  83. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
  84. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
  85. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -3
  86. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -3
  87. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -3
  88. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -2
  89. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -3
  90. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -12
  91. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -12
  92. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -12
  93. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -2
  94. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -12
  95. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -3
  96. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -10
  97. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -3
  98. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -3
  99. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -12
  100. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -2
  101. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -3
  102. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -3
  103. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  104. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -3
  105. package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
  106. package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
  107. package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
  108. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
  109. package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
  110. package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
  111. package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
  112. package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
  113. package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
  114. package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
  115. package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
  116. package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
  117. package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
  118. package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
  119. package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
  120. package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
  121. package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
  122. package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
  123. package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
  124. package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
  125. package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
  126. package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
  127. package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
  128. package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
  129. package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
  130. package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
  131. package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
  132. package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
  133. package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
  134. package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
  135. package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
  136. package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
  137. package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
  138. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
  139. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
  140. package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
  141. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
  142. package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
  143. package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
  144. package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
  145. package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
  146. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
  147. package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
  148. package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
  149. package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
  150. package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
  151. package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
  152. package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
  153. package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
  154. package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
  155. package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
  156. package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
  157. package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
  158. package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
  159. package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
  160. package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
  161. package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
  162. package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
  163. package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
  164. package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
  165. package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
  166. package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
  167. package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
  168. package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
  169. package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
  170. package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
  171. package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
  172. package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
  173. package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
  174. package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
  175. package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
  176. package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
  177. package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
  178. package/templates/apps/web/app/[locale]/page.tsx +0 -147
  179. package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
  180. package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
  181. package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
  182. package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
  183. package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
  184. package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
  185. package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
  186. package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
  187. package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
  188. package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
  189. package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
  190. package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
  191. package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
  192. package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
  193. package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
  194. package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
  195. package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
  196. package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
  197. package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
  198. package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
  199. package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
  200. package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
  201. package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
  202. package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
  203. package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
  204. package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
  205. package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
  206. package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
  207. package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
  208. package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
  209. package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
  210. package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
  211. package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
  212. package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
  213. package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
  214. package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
  215. package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
  216. package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
  217. package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
  218. package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
  219. package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
  220. package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
  221. package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
  222. package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
  223. package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
  224. package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
  225. package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
  226. package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
  227. package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
  228. package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
  229. package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
  230. package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
  231. package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
  232. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
  233. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
  234. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
  235. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
  236. package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
  237. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
  238. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
  239. package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
  240. package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
  241. package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
  242. package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
  243. package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
  244. package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
  245. package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
  246. package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
  247. package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
  248. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
  249. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
  250. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
  251. package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
  252. package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
  253. package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
  254. package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
  255. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
  256. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
  257. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
  258. package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
  259. package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
  260. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
  261. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
  262. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
  263. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
  264. package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
  265. package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
  266. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
  267. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
  268. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
  269. package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
  270. package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
  271. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
  272. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
  273. package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
  274. package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
  275. package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
  276. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
  277. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
  278. package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
  279. package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
  280. package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
  281. package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
  282. package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
  283. package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
  284. package/templates/apps/web/lib/auth-routes.ts +0 -125
  285. package/templates/apps/web/lib/hub-children.tsx +0 -351
  286. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
  287. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
  288. package/templates/apps/web/lib/hub-session/config.ts +0 -110
  289. package/templates/apps/web/lib/hub-session/entry.ts +0 -238
  290. package/templates/apps/web/lib/hub-session/index.ts +0 -21
  291. package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
  292. package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
  293. package/templates/apps/web/lib/hub-session/seal.ts +0 -86
  294. package/templates/apps/web/lib/hub-session/session.ts +0 -298
  295. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
  296. package/templates/apps/web/lib/meet-placeholder.ts +0 -5
  297. package/templates/apps/web/lib/next-path.ts +0 -35
  298. package/templates/apps/web/lib/posting-title.ts +0 -39
  299. package/templates/apps/web/lib/route-family.ts +0 -69
  300. package/templates/apps/web/lib/service-listing.ts +0 -89
  301. package/templates/apps/web/lib/template-listing.ts +0 -169
  302. package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
  303. package/templates/apps/web/src/lib/lead-write.ts +0 -90
  304. /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
package/dist/routes.js CHANGED
@@ -63,20 +63,91 @@
63
63
  * that site: neither written, nor missing, nor stray; the check names it as
64
64
  * not carried.
65
65
  *
66
+ * The app mount (#11257 D10). A route handler a page package ships outside
67
+ * the locale segment — `/api/auth/**`, `/api/hub-session/**` — is an entry
68
+ * with `"mount": "app"`, its `path` relative to `apps/web/app/`, under one of
69
+ * the manifest's `appPrefixes`. The trust model is the same in both mounts: an
70
+ * installed `@working-theory/*` page package authors the routing files under
71
+ * the prefixes it declares, and nothing else. So an app prefix must start
72
+ * `api/`, may not be `api` itself or one of the site's own handler trees
73
+ * (`SITE_HANDLER_PREFIXES`), and may not equal, contain or sit under another
74
+ * installed manifest's; an app entry never takes the config (a route handler
75
+ * cannot). In both mounts `--write` never overwrites a routing file whose
76
+ * first line is not the generator header — a site's own handler, or a
77
+ * recorded replacement — it reports it as `kept`. An entry's `waiver` (one
78
+ * line — no newline or control character; non-ASCII text such as an em
79
+ * dash is allowed) is written as the ADR 0020 marker on the line
80
+ * after the header, and every `module` is held to a fixed character set, so
81
+ * no manifest text can inject source into a generated file.
82
+ *
83
+ * A manifest that sets `"siteSeam": true` names a package whose modules read
84
+ * the site through `<package>/site`, which the site aliases to its config
85
+ * file in `next.config.mjs` and `jest.config.cjs`; check mode names either
86
+ * file when its alias line is missing, so a build bound to the package's
87
+ * stub fails before any request (SEC-11257-1).
88
+ *
89
+ * The locale root (#11259 D5). A manifest that sets `"root": true` may list
90
+ * the entry `page.tsx` — the home page at `app/[locale]/page.tsx`; its stray
91
+ * scope there is that one file, never the tree beneath it. One installed
92
+ * manifest at most may claim the root, and no two may claim overlapping
93
+ * prefixes: each refusal names both packages.
94
+ *
95
+ * The site's surfaces (#11259 D5). A manifest that sets `"siteGated": true`
96
+ * ships routes a site carries only when it selected them. On a site whose
97
+ * `.ailk-site-manifest.json` lists no `marketing` module, an entry inside the
98
+ * public route tree (`isRemovedPublicRoutePath`) is not carried; and an entry
99
+ * whose top directory is a `GATEABLE_SURFACES` route of a surface the site's
100
+ * `architecture.yaml` `# Surfaces:` header does not list (aliases
101
+ * canonicalized) is not carried either. A site with no readable header
102
+ * carries every entry. A manifest without the flag is never gated.
103
+ *
66
104
  * Pure module: no `import.meta.url`, so jest imports it directly.
67
105
  */
68
106
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
69
107
  import { dirname, join, posix, relative, resolve, sep } from "node:path";
70
108
  import { parseArgs } from "node:util";
109
+ import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
110
+ import { publicTreeRemoved } from "./lib/site-modules.js";
111
+ import { GATEABLE_SURFACES, ROUTE_ROOT, canonicalizeSurface, isRemovedPublicRoutePath } from "./surfaces.js";
71
112
  import { isSpokeExcluded, readSpokeShape } from "./topology.js";
72
113
  /** The app a page package's routes mount in, relative to the site root. */
73
114
  export const ROUTES_APP_DIR = "apps/web";
74
115
  /** The locale segment every shipped route sits under. */
75
116
  const LOCALE_DIR = "app/[locale]";
117
+ /** The locale-root page, the one entry a `"root": true` manifest may list outside its prefixes (#11259 D5). */
118
+ const ROOT_PAGE = "page.tsx";
119
+ /** The app root an `app`-mounted entry's path is relative to (#11257 D10). */
120
+ const APP_DIR = "app";
121
+ /**
122
+ * The site's own handler trees under `app/api/`, which no page package may
123
+ * declare as an app prefix (#11257 D10, SEC-11257-3): the Offerings buy route,
124
+ * the revalidate hook, the webhook routes and the legacy checkout.
125
+ */
126
+ export const SITE_HANDLER_PREFIXES = ["api/offerings", "api/revalidate", "api/webhooks", "api/checkout"];
127
+ /** A `module` value: the characters both shipped manifests use, so no quote or backtick reaches generated source. */
128
+ const MODULE_RE = /^[A-Za-z0-9_\-./()[\]]+$/;
129
+ /**
130
+ * A `waiver`: one line of text — no control character (C0, DEL or C1) and no
131
+ * Unicode line or paragraph separator, so nothing can end the comment line it
132
+ * is written into. Not ASCII-only: the shipped waivers carry an em dash, the
133
+ * ADR 0020 marker's own form.
134
+ */
135
+ function isOneLineText(value) {
136
+ if (value === "")
137
+ return false;
138
+ for (const char of value) {
139
+ const code = char.codePointAt(0) ?? 0;
140
+ if (code < 0x20 || (code >= 0x7f && code <= 0x9f) || code === 0x2028 || code === 0x2029)
141
+ return false;
142
+ }
143
+ return true;
144
+ }
76
145
  /** The `package.json` key a page package declares its manifest under. */
77
146
  const MANIFEST_KEY = "ailk";
78
147
  const PACKAGE_SCOPE = "@working-theory/";
79
148
  const ROUTING_FILES = new Set(["page.tsx", "layout.tsx", "route.ts"]);
149
+ /** The routing file names the generator writes (`ROUTING_FILES`), for the snapshot build (#11259 D6). */
150
+ export const ROUTING_FILE_NAMES = ROUTING_FILES;
80
151
  const SKIPPED_DIRS = new Set(["__tests__", "node_modules"]);
81
152
  const HTTP_METHODS = new Set(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]);
82
153
  const KIND_OF_FILE = { "page.tsx": "page", "layout.tsx": "layout", "route.ts": "route" };
@@ -108,6 +179,10 @@ function stringList(value, where) {
108
179
  }
109
180
  return value;
110
181
  }
182
+ /** Whether one of two plain paths equals the other or sits under it. */
183
+ function overlaps(a, b) {
184
+ return a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
185
+ }
111
186
  /** Parse and validate one manifest; every refusal names the package and the entry. */
112
187
  export function parseRouteManifest(pkg, version, raw) {
113
188
  const at = `${pkg}'s route manifest`;
@@ -129,6 +204,25 @@ export function parseRouteManifest(pkg, version, raw) {
129
204
  }
130
205
  if (!Array.isArray(raw.routes))
131
206
  throw new RoutesRefusedError(`${at}: routes must be a list`);
207
+ for (const key of ["siteSeam", "root", "siteGated"]) {
208
+ if (raw[key] !== undefined && typeof raw[key] !== "boolean") {
209
+ throw new RoutesRefusedError(`${at}: ${key} must be a boolean when set`);
210
+ }
211
+ }
212
+ const root = raw.root === true;
213
+ const appPrefixes = stringList(raw.appPrefixes, `${at}: appPrefixes`);
214
+ if (new Set(appPrefixes).size !== appPrefixes.length) {
215
+ throw new RoutesRefusedError(`${at}: appPrefixes must be distinct`);
216
+ }
217
+ for (const appPrefix of appPrefixes) {
218
+ if (!isPlainPath(appPrefix) || !appPrefix.startsWith("api/")) {
219
+ throw new RoutesRefusedError(`${at}: appPrefixes ${JSON.stringify(appPrefix)} must be a plain path under app/api/ (no leading or trailing slash, no . or .. segment)`);
220
+ }
221
+ const site = SITE_HANDLER_PREFIXES.find((own) => overlaps(own, appPrefix));
222
+ if (site !== undefined) {
223
+ throw new RoutesRefusedError(`${at}: appPrefixes ${JSON.stringify(appPrefix)} overlaps the site's own ${site}/ handlers`);
224
+ }
225
+ }
132
226
  const prefix = prefixes;
133
227
  const underPrefix = (path) => prefix.some((p) => path.startsWith(`${p}/`));
134
228
  const prefixNamed = prefix.length === 1 ? `prefix ${prefix[0]}/` : `prefixes ${prefix.join(", ")}`;
@@ -160,7 +254,26 @@ export function parseRouteManifest(pkg, version, raw) {
160
254
  if (!isPlainPath(path) || !ROUTING_FILES.has(posix.basename(path))) {
161
255
  throw new RoutesRefusedError(`${where}: path must be a plain path ending in page.tsx, layout.tsx or route.ts`);
162
256
  }
163
- if (!underPrefix(path)) {
257
+ if (entry.mount !== undefined && entry.mount !== "locale" && entry.mount !== "app") {
258
+ throw new RoutesRefusedError(`${where}: mount must be "locale" or "app"`);
259
+ }
260
+ const mount = entry.mount === "app" ? "app" : "locale";
261
+ if (mount === "app") {
262
+ if (appPrefixes.length === 0) {
263
+ throw new RoutesRefusedError(`${where}: ${path} is mounted under app/, but the manifest names no appPrefixes`);
264
+ }
265
+ if (!appPrefixes.some((p) => path.startsWith(`${p}/`))) {
266
+ throw new RoutesRefusedError(`${where}: ${path} is outside the manifest's appPrefixes ${appPrefixes.join(", ")}`);
267
+ }
268
+ if (entry.config === true) {
269
+ throw new RoutesRefusedError(`${where}: an app-mounted entry (${path}) cannot take the site config`);
270
+ }
271
+ }
272
+ else if (path === ROOT_PAGE) {
273
+ if (!root)
274
+ throw new RoutesRefusedError(`${where}: ${path} is the locale root, which only a manifest with "root": true ships`);
275
+ }
276
+ else if (!underPrefix(path)) {
164
277
  throw new RoutesRefusedError(`${where}: ${path} is outside the manifest's ${prefixNamed}`);
165
278
  }
166
279
  if (seen.has(path) || siteOwned.includes(path)) {
@@ -170,8 +283,17 @@ export function parseRouteManifest(pkg, version, raw) {
170
283
  const kind = KIND_OF_FILE[posix.basename(path)];
171
284
  if (entry.kind !== kind)
172
285
  throw new RoutesRefusedError(`${where}: kind must be ${JSON.stringify(kind)} for ${path}`);
173
- if (!isPlainPath(entry.module)) {
174
- throw new RoutesRefusedError(`${where}: module must name the package subpath to re-export from, as a plain path`);
286
+ if (!isPlainPath(entry.module) || !MODULE_RE.test(entry.module)) {
287
+ throw new RoutesRefusedError(`${where}: module must name the package subpath to re-export from, as a plain path of letters, digits and _ - . / ( ) [ ]`);
288
+ }
289
+ let waiver;
290
+ if (entry.waiver !== undefined) {
291
+ if (typeof entry.waiver !== "string" || !isOneLineText(entry.waiver)) {
292
+ throw new RoutesRefusedError(`${where}: waiver must be one line of text, with no control or line-separator character`);
293
+ }
294
+ if (kind !== "route")
295
+ throw new RoutesRefusedError(`${where}: only a route handler carries a waiver`);
296
+ waiver = entry.waiver;
175
297
  }
176
298
  const exports = stringList(entry.exports, `${where}: exports`);
177
299
  if (exports.length === 0)
@@ -210,10 +332,23 @@ export function parseRouteManifest(pkg, version, raw) {
210
332
  throw new RoutesRefusedError(`${where}: ${JSON.stringify(line)} is not a route-segment-config line`);
211
333
  }
212
334
  }
213
- return { path, kind, module: entry.module, exports, segmentConfig, config, metadataConfig };
335
+ return { path, kind, module: entry.module, exports, segmentConfig, config, metadataConfig, mount, waiver };
214
336
  });
215
337
  const oss = raw.oss === false ? false : undefined;
216
- return { package: pkg, version, prefix, config: raw.config, siteOwned, messages, oss, routes };
338
+ return {
339
+ package: pkg,
340
+ version,
341
+ prefix,
342
+ localeRoot: root,
343
+ siteGated: raw.siteGated === true,
344
+ appPrefixes,
345
+ siteSeam: raw.siteSeam === true,
346
+ config: raw.config,
347
+ siteOwned,
348
+ messages,
349
+ oss,
350
+ routes,
351
+ };
217
352
  }
218
353
  /**
219
354
  * The route manifests of the installed page packages, in package-name
@@ -272,6 +407,23 @@ export function readRouteManifests(siteDir) {
272
407
  throw new RoutesRefusedError(`${name}'s route manifest does not parse: ${err.message}`);
273
408
  }
274
409
  const manifest = parseRouteManifest(name, typeof meta.version === "string" ? meta.version : "0.0.0", raw);
410
+ for (const other of manifests) {
411
+ if (manifest.localeRoot && other.localeRoot) {
412
+ throw new RoutesRefusedError(`${name}'s route manifest claims the locale root, which ${other.package}'s already does`);
413
+ }
414
+ for (const mine of manifest.prefix) {
415
+ const clash = other.prefix.find((theirs) => overlaps(mine, theirs));
416
+ if (clash !== undefined) {
417
+ throw new RoutesRefusedError(`${name}'s route manifest: prefix ${JSON.stringify(mine)} overlaps ${other.package}'s ${JSON.stringify(clash)}`);
418
+ }
419
+ }
420
+ for (const mine of manifest.appPrefixes) {
421
+ const clash = other.appPrefixes.find((theirs) => overlaps(mine, theirs));
422
+ if (clash !== undefined) {
423
+ throw new RoutesRefusedError(`${name}'s route manifest: appPrefixes ${JSON.stringify(mine)} overlaps ${other.package}'s ${JSON.stringify(clash)}`);
424
+ }
425
+ }
426
+ }
275
427
  manifests.push({ ...manifest, root: dirname(installed) });
276
428
  }
277
429
  return manifests;
@@ -286,13 +438,15 @@ export function renderRouteFile(manifest, entry) {
286
438
  const lines = [`${GENERATED_ROUTE_HEADER}${manifest.package} ${manifest.version} — do not edit.`];
287
439
  if (manifest.oss === false)
288
440
  lines.unshift(OSS_FALSE_MARKER);
441
+ if (entry.waiver !== undefined)
442
+ lines.push(`// platform-decisions-waiver: ${entry.waiver}`);
289
443
  if (entry.config) {
290
444
  // The wrapper calls the page as the async function it is and returns its
291
445
  // tree — no element boundary of its own — so the route module keeps the
292
446
  // page's own contract (`(props) => Promise<ReactElement>`): what Next
293
447
  // mounts, and what a test that renders `await Page(props)` renders.
294
448
  // `app/[locale]/<path>` → the file's directory depth from the app root.
295
- const depth = posix.dirname(posix.join(LOCALE_DIR, entry.path)).split("/").length;
449
+ const depth = posix.dirname(posix.join(mountDir(entry.mount), entry.path)).split("/").length;
296
450
  // #11253 — a `metadataConfig` entry's `generateMetadata` reads the config
297
451
  // too (the checkout pages answer notFound() off a spoke before any
298
452
  // translation), so it is imported beside `Page` and wrapped, never
@@ -322,6 +476,16 @@ export function renderRouteFile(manifest, entry) {
322
476
  }
323
477
  return `${lines.join("\n")}\n`;
324
478
  }
479
+ /** The directory under the app an entry's `path` is relative to. */
480
+ function mountDir(mount) {
481
+ return mount === "app" ? APP_DIR : LOCALE_DIR;
482
+ }
483
+ /** Whether `text` is a file this generator wrote: its first line (after an `oss: false` marker) is the header. */
484
+ export function isGenerated(text) {
485
+ const lines = text.split("\n", 2);
486
+ const first = lines[0] === OSS_FALSE_MARKER ? (lines[1] ?? "") : (lines[0] ?? "");
487
+ return first.startsWith(GENERATED_ROUTE_HEADER);
488
+ }
325
489
  /** The scaffold lint's own glob (`template-overlay/tools/lint-architecture.ts`): `**` is zero or more whole segments, `*` stays inside one. */
326
490
  function globToRegExp(glob) {
327
491
  const segments = glob.split("/");
@@ -412,8 +576,8 @@ function recordFor(recorded, sitePath) {
412
576
  export function isRecordedRoute(siteDir, sitePath) {
413
577
  return recordFor(readRecorded(resolve(siteDir)), sitePath) !== undefined;
414
578
  }
415
- /** Routing files under `<web>/app/[locale]/<prefix>`, as site-relative POSIX paths, sorted. */
416
- function routingFilesUnder(web, siteDir, prefix) {
579
+ /** Routing files under `<web>/<mount dir>/<prefix>`, as site-relative POSIX paths, sorted. */
580
+ function routingFilesUnder(web, siteDir, prefix, mount = "locale") {
417
581
  const out = [];
418
582
  const walk = (dir) => {
419
583
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
@@ -427,7 +591,7 @@ function routingFilesUnder(web, siteDir, prefix) {
427
591
  }
428
592
  }
429
593
  };
430
- const root = join(web, LOCALE_DIR, prefix);
594
+ const root = join(web, mountDir(mount), prefix);
431
595
  if (existsSync(root))
432
596
  walk(root);
433
597
  return out.sort();
@@ -440,13 +604,12 @@ function plan(siteDir) {
440
604
  // The site's topology (`.ailk-site-manifest.json`): on a spoke, the paths
441
605
  // it does not carry are not its routes. A hub, or no manifest, carries all.
442
606
  const spoke = readSpokeShape(root);
607
+ const gate = siteGate(root);
608
+ const carries = (manifest, sitePath) => (spoke === undefined || !isSpokeExcluded(sitePath, spoke)) && (!manifest.siteGated || gate(sitePath));
443
609
  const planned = [];
444
610
  const notCarried = [];
445
611
  for (const manifest of manifests) {
446
- const carried = manifest.routes.filter((entry) => {
447
- const sitePath = relative(root, join(web, LOCALE_DIR, entry.path)).split(sep).join("/");
448
- return spoke === undefined || !isSpokeExcluded(sitePath, spoke);
449
- });
612
+ const carried = manifest.routes.filter((entry) => carries(manifest, relative(root, join(web, mountDir(entry.mount), entry.path)).split(sep).join("/")));
450
613
  if (manifest.config !== undefined && carried.some((entry) => entry.config)) {
451
614
  const configPath = join(web, `${manifest.config}.tsx`);
452
615
  if (!existsSync(configPath)) {
@@ -454,9 +617,9 @@ function plan(siteDir) {
454
617
  }
455
618
  }
456
619
  for (const entry of manifest.routes) {
457
- const absPath = join(web, LOCALE_DIR, entry.path);
620
+ const absPath = join(web, mountDir(entry.mount), entry.path);
458
621
  const sitePath = relative(root, absPath).split(sep).join("/");
459
- if (spoke !== undefined && isSpokeExcluded(sitePath, spoke)) {
622
+ if (!carries(manifest, sitePath)) {
460
623
  notCarried.push(sitePath);
461
624
  continue;
462
625
  }
@@ -465,9 +628,70 @@ function plan(siteDir) {
465
628
  }
466
629
  return { root, web, manifests, planned, recorded, notCarried };
467
630
  }
468
- /** The count check mode fails on: missing, stale and stray route files and orphaned overrides. */
631
+ /**
632
+ * Whether a `siteGated` manifest's entry at `sitePath` is a route of the site
633
+ * (#11259 D5): not inside the public tree on a site without `marketing`, and
634
+ * not under a gateable surface the site's `# Surfaces:` header leaves out. A
635
+ * site with no readable header carries every surface.
636
+ */
637
+ export function siteGate(siteDir) {
638
+ const noPublicTree = publicTreeRemoved(siteDir);
639
+ let surfaces;
640
+ const archPath = join(siteDir, "architecture.yaml");
641
+ if (existsSync(archPath)) {
642
+ const text = readFileSync(archPath, "utf8");
643
+ try {
644
+ surfaces = new Set(readArchitectureHeader(text).surfaces.map(canonicalizeSurface));
645
+ }
646
+ catch (err) {
647
+ // Only a missing or malformed header means "no header": a read error throws.
648
+ if (!(err instanceof AddModuleRefusedError))
649
+ throw err;
650
+ }
651
+ }
652
+ return (sitePath) => {
653
+ if (noPublicTree && isRemovedPublicRoutePath(sitePath))
654
+ return false;
655
+ if (surfaces === undefined || !sitePath.startsWith(`${ROUTE_ROOT}/`))
656
+ return true;
657
+ const top = `${ROUTE_ROOT}/${sitePath.slice(ROUTE_ROOT.length + 1).split("/")[0]}`;
658
+ const surface = GATEABLE_SURFACES.find((s) => s.routes.includes(top));
659
+ return surface === undefined || surfaces.has(surface.id);
660
+ };
661
+ }
662
+ /** The count check mode fails on: missing, stale and stray route files, orphaned overrides and missing seam aliases. */
469
663
  export function routesFailing(drift) {
470
- return drift.missing.length + drift.stale.length + drift.stray.length + drift.orphanedOverrides.length;
664
+ return (drift.missing.length +
665
+ drift.stale.length +
666
+ drift.stray.length +
667
+ drift.orphanedOverrides.length +
668
+ drift.seamAliasMissing.length);
669
+ }
670
+ /**
671
+ * The two site files that bind a `siteSeam` package's `<package>/site` to
672
+ * the site's config (#11257 D4, SEC-11257-1): `next.config.mjs`'s
673
+ * `resolve.alias` key and `jest.config.cjs`'s `moduleNameMapper` key, read as
674
+ * text. A missing line means a build or a suite would bind the package's
675
+ * stub, so check mode fails naming the file; a file the site does not have
676
+ * is named too.
677
+ */
678
+ function seamAliasMissing(web, siteDir, manifests) {
679
+ const out = [];
680
+ for (const manifest of manifests) {
681
+ if (!manifest.siteSeam || manifest.routes.length === 0)
682
+ continue;
683
+ const wants = [
684
+ ["next.config.mjs", `"${manifest.package}/site$"`],
685
+ ["jest.config.cjs", `"^${manifest.package}/site$"`],
686
+ ];
687
+ for (const [file, alias] of wants) {
688
+ const path = join(web, file);
689
+ const text = existsSync(path) ? readFileSync(path, "utf8") : "";
690
+ if (!text.includes(alias))
691
+ out.push(`${relative(siteDir, path).split(sep).join("/")}: ${alias}`);
692
+ }
693
+ }
694
+ return out;
471
695
  }
472
696
  /** How the site's route files and message overrides differ from the installed page packages. `routesFailing` zero means in sync. */
473
697
  export function checkRoutes(siteDir) {
@@ -480,6 +704,7 @@ export function checkRoutes(siteDir) {
480
704
  notCarried,
481
705
  siteKept: [],
482
706
  orphanedOverrides: orphanedOverrides(web, root, manifests),
707
+ seamAliasMissing: seamAliasMissing(web, root, manifests),
483
708
  generated: planned.length,
484
709
  };
485
710
  const known = new Set();
@@ -502,7 +727,13 @@ export function checkRoutes(siteDir) {
502
727
  if (manifest.routes.length === 0)
503
728
  continue;
504
729
  const kept = new Set(manifest.siteOwned.map((path) => relative(root, join(web, LOCALE_DIR, path)).split(sep).join("/")));
505
- for (const sitePath of manifest.prefix.flatMap((prefix) => routingFilesUnder(web, root, prefix))) {
730
+ const rootPage = join(web, LOCALE_DIR, ROOT_PAGE);
731
+ const underPrefixes = [
732
+ ...(manifest.localeRoot && existsSync(rootPage) ? [relative(root, rootPage).split(sep).join("/")] : []),
733
+ ...manifest.prefix.flatMap((prefix) => routingFilesUnder(web, root, prefix)),
734
+ ...manifest.appPrefixes.flatMap((prefix) => routingFilesUnder(web, root, prefix, "app")),
735
+ ];
736
+ for (const sitePath of underPrefixes) {
506
737
  if (known.has(sitePath))
507
738
  continue;
508
739
  known.add(sitePath);
@@ -594,16 +825,23 @@ function orphanedOverrides(web, siteDir, manifests) {
594
825
  /** Write every generated file that is missing or stale; a recorded route is left exactly as it is. */
595
826
  export function writeRoutes(siteDir) {
596
827
  const { planned } = plan(siteDir);
597
- const result = { written: [], current: [], recorded: [] };
828
+ const result = { written: [], current: [], recorded: [], kept: [] };
598
829
  for (const p of planned) {
599
830
  const exists = existsSync(p.absPath);
600
831
  if (p.record) {
601
832
  result.recorded.push({ path: p.sitePath, state: exists ? "replaced" : "removed", id: p.record.id });
602
833
  continue;
603
834
  }
604
- if (exists && readFileSync(p.absPath, "utf8") === p.text) {
605
- result.current.push(p.sitePath);
606
- continue;
835
+ if (exists) {
836
+ const text = readFileSync(p.absPath, "utf8");
837
+ if (text === p.text) {
838
+ result.current.push(p.sitePath);
839
+ continue;
840
+ }
841
+ if (!isGenerated(text)) {
842
+ result.kept.push(p.sitePath);
843
+ continue;
844
+ }
607
845
  }
608
846
  mkdirSync(dirname(p.absPath), { recursive: true });
609
847
  writeFileSync(p.absPath, p.text);
@@ -643,7 +881,12 @@ page takes the site's config it imports the manifest's config file from the
643
881
  app root (apps/web/account.config.tsx, say) and passes it in. Replace or remove a shipped route by recording it in
644
882
  customizations.yaml (an entry whose paths match the route file): a recorded
645
883
  route is reported as replaced or removed, never failed, and --write never
646
- touches it. Run --write after \`pnpm install\` (the manifests are read from the
884
+ touches it. A manifest may list several prefixes, and one manifest with
885
+ "root": true may ship the locale-root page.tsx. A manifest with
886
+ "siteGated": true ships only the routes the site selected: its public pages
887
+ are not carried when .ailk-site-manifest.json lists no marketing module, and
888
+ neither is any page under a surface the architecture.yaml "# Surfaces:" header
889
+ leaves out. Run --write after \`pnpm install\` (the manifests are read from the
647
890
  installed packages); the scaffold's preflight runs --check as \`pnpm routes:check\`.
648
891
  `;
649
892
  /** Parse the argv AFTER the `routes` word. Strict `node:util` parseArgs, like `parseSyncRoutesArgs`. */
@@ -682,6 +925,7 @@ export function formatRoutesReport(result, mode) {
682
925
  ...drift.stale.map((p) => ` stale: ${p}`),
683
926
  ...drift.stray.map((p) => ` stray: ${p}`),
684
927
  ...drift.orphanedOverrides.map((p) => ` orphaned override: ${p}`),
928
+ ...drift.seamAliasMissing.map((p) => ` missing site seam alias: ${p}`),
685
929
  ];
686
930
  if (failing.length === 0) {
687
931
  lines.push(`[create-ailk] routes: OK — ${drift.generated} generated route file(s) in sync`);
@@ -695,6 +939,8 @@ export function formatRoutesReport(result, mode) {
695
939
  lines.push(`[create-ailk] routes: wrote ${write.written.length} route file(s), ${write.current.length} already current`);
696
940
  for (const p of write.written)
697
941
  lines.push(` wrote: ${p}`);
942
+ for (const p of write.kept)
943
+ lines.push(` kept (not a generated file, never overwritten): ${p}`);
698
944
  }
699
945
  for (const r of result.recorded)
700
946
  lines.push(` ${r.state} (recorded): ${r.path} — customizations.yaml "${r.id}"`);
@@ -89,11 +89,13 @@ export function planSiteManifest(opts) {
89
89
  // #10774 D4.2 — the template's own code-route rows a spoke does not serve
90
90
  // (`/sign-in`, `/sign-up`) leave with the files the spoke filter dropped.
91
91
  const planned = plan.next ?? roster.text;
92
- const appended = withoutUnservedRouteRows(parseRosterFile(planned, roster.path), opts.targetDir, opts.topology).next ?? planned;
92
+ const appended = withoutUnservedRouteRows(parseRosterFile(planned, roster.path), opts.targetDir, opts.topology, opts.signIn).next ?? planned;
93
93
  const declared = new Set(JSON.parse(appended).rows.map((row) => row["route"]));
94
94
  const extra = [
95
95
  ...sampleRows(opts, declared),
96
- ...codeRouteRows(opts.targetDir, declared),
96
+ ...codeRouteRows(opts.targetDir, declared, opts.topology === "spoke"
97
+ ? { mcp: true, signIn: opts.signIn ?? "off" }
98
+ : null),
97
99
  ];
98
100
  const withRows = appendRows(appended, extra, roster);
99
101
  return insertRecord(withRows, opts, roster.path);
@@ -225,8 +227,8 @@ function sampleRows(opts, declared) {
225
227
  return out;
226
228
  }
227
229
  /** A code-route row for every page route on disk that `declared` does not name. */
228
- function codeRouteRows(targetDir, declared) {
229
- return servedRoutes(targetDir)
230
+ function codeRouteRows(targetDir, declared, spoke) {
231
+ return servedRoutes(targetDir, spoke)
230
232
  .filter((route) => !declared.has(route))
231
233
  .map((route) => ({ route, ...CODE_ROUTE_ROW }));
232
234
  }
@@ -6,7 +6,7 @@ import type { ModuleName } from "./parse-args.js";
6
6
  import type { ResolvedSiteChrome } from "./site-chrome.js";
7
7
  import { type MarkerMap } from "./substitute.js";
8
8
  import { type TemplateManifest } from "./template-manifest.js";
9
- import { type Topology } from "./topology.js";
9
+ import { type SignInMode, type SpokeShapeOptions, type Topology } from "./topology.js";
10
10
  /** The site-root file that is the roster of record (#6658 D7). */
11
11
  export declare const SITE_ROSTER_PATH = ".ailk-site-manifest.json";
12
12
  /**
@@ -189,14 +189,22 @@ export declare function planRosterAppend(opts: PlanRosterAppendOptions): RosterA
189
189
  * its parent (docs-blog's `/blog/[[...slug]]` serves `/blog`). The root
190
190
  * content renderers (`/[slug]`, `/[slug]/[detail]`) are not routes of their
191
191
  * own — they are how the content rows render — so they are left out.
192
+ *
193
+ * #11259 D6 — a page a carried page package ships (`PAGE_PACKAGE_ROUTES`
194
+ * `pages`) is served too, unless the site is a spoke that does not carry its
195
+ * path: the snapshot holds none of a package's generated route files, which
196
+ * `create-ailk routes --write` writes after the install. `spoke` is the
197
+ * site's spoke shape — `null` on a hub, read from the site when omitted.
192
198
  */
193
- export declare function servedRoutes(targetDir: string): string[];
199
+ export declare function servedRoutes(targetDir: string, spoke?: SpokeShapeOptions | null): string[];
200
+ /** The dependency and devDependency names of the site's `apps/web/package.json`; empty when it has none. */
201
+ export declare function webDependencies(targetDir: string): Set<string>;
194
202
  /**
195
203
  * `file`'s next text with its unserved code-route rows removed — every other
196
204
  * byte verbatim — and the dropped routes in file order; `next` is undefined
197
205
  * when none is dropped.
198
206
  */
199
- export declare function withoutUnservedRouteRows(file: RosterFile, targetDir: string, topology?: Topology): {
207
+ export declare function withoutUnservedRouteRows(file: RosterFile, targetDir: string, topology?: Topology, signIn?: SignInMode): {
200
208
  next: string | undefined;
201
209
  dropped: string[];
202
210
  };
@@ -36,9 +36,10 @@ import { diffTwoStrings } from "./lib/extract-module-bundle.js";
36
36
  import { publicTreeRemoved } from "./lib/site-modules.js";
37
37
  import { MODULE_SLICES, normalizeModules, } from "./module-architecture.js";
38
38
  import { substituteMarkers } from "./substitute.js";
39
- import { isUnservedSurfaceContent, pagePackageOfRoute, resolveSurfaces } from "./surfaces.js";
39
+ import { siteGate } from "./routes.js";
40
+ import { isUnservedSurfaceContent, PAGE_PACKAGE_ROUTES, pagePackageOfRoute, resolveSurfaces } from "./surfaces.js";
40
41
  import { BASE_LAYER_DIR, SHAPE_STARTERS, TEMPLATE_MANIFESTS, resolveTemplate, rosterDeclares, shippedManifestPath, templateTreeDir, } from "./template-manifest.js";
41
- import { readSiteTopology, SPOKE_REMOVAL_SEEDS } from "./topology.js";
42
+ import { isSpokeExcluded, readSpokeShape, } from "./topology.js";
42
43
  /** The site-root file that is the roster of record (#6658 D7). */
43
44
  export const SITE_ROSTER_PATH = ".ailk-site-manifest.json";
44
45
  /**
@@ -635,29 +636,54 @@ function spliceRows(file, rows) {
635
636
  * its parent (docs-blog's `/blog/[[...slug]]` serves `/blog`). The root
636
637
  * content renderers (`/[slug]`, `/[slug]/[detail]`) are not routes of their
637
638
  * own — they are how the content rows render — so they are left out.
639
+ *
640
+ * #11259 D6 — a page a carried page package ships (`PAGE_PACKAGE_ROUTES`
641
+ * `pages`) is served too, unless the site is a spoke that does not carry its
642
+ * path: the snapshot holds none of a package's generated route files, which
643
+ * `create-ailk routes --write` writes after the install. `spoke` is the
644
+ * site's spoke shape — `null` on a hub, read from the site when omitted.
638
645
  */
639
- export function servedRoutes(targetDir) {
646
+ export function servedRoutes(targetDir, spoke) {
640
647
  const root = join(targetDir, ROUTE_ROOT);
648
+ if (!existsSync(root))
649
+ return [];
641
650
  const routes = new Set();
642
- const stack = existsSync(root) ? [root] : [];
651
+ const add = (dir) => {
652
+ const segments = dir
653
+ .split(/[\\/]/)
654
+ .filter((segment) => segment !== "" && !/^\(.+\)$/.test(segment));
655
+ const last = segments[segments.length - 1];
656
+ if (last !== undefined && /^\[\[\.\.\..+\]\]$/.test(last))
657
+ segments.pop();
658
+ if (segments[0]?.startsWith("["))
659
+ return;
660
+ routes.add(`/${segments.join("/")}`);
661
+ };
662
+ const stack = [root];
643
663
  for (let cur = stack.pop(); cur !== undefined; cur = stack.pop()) {
644
664
  const entries = readdirSync(cur, { withFileTypes: true });
645
665
  for (const entry of entries) {
646
666
  if (entry.isDirectory())
647
667
  stack.push(join(cur, entry.name));
648
668
  }
649
- if (!entries.some((entry) => entry.isFile() && PAGE_FILE.test(entry.name))) {
650
- continue;
669
+ if (entries.some((entry) => entry.isFile() && PAGE_FILE.test(entry.name))) {
670
+ add(relative(root, cur));
651
671
  }
652
- const segments = relative(root, cur)
653
- .split(sep)
654
- .filter((segment) => segment !== "" && !/^\(.+\)$/.test(segment));
655
- const last = segments[segments.length - 1];
656
- if (last !== undefined && /^\[\[\.\.\..+\]\]$/.test(last))
657
- segments.pop();
658
- if (segments[0]?.startsWith("["))
672
+ }
673
+ const carried = webDependencies(targetDir);
674
+ const shape = spoke === undefined ? readSpokeShape(targetDir) : spoke;
675
+ const gate = siteGate(targetDir);
676
+ for (const row of PAGE_PACKAGE_ROUTES) {
677
+ if (!carried.has(row.package))
659
678
  continue;
660
- routes.add(`/${segments.join("/")}`);
679
+ for (const page of row.pages) {
680
+ const sitePath = `apps/web/app/[locale]/${page}`;
681
+ // #11259 D5 — a siteGated package's page the generator leaves `not carried` is not served.
682
+ if (row.siteGated && !gate(`${sitePath}/page.tsx`))
683
+ continue;
684
+ if (!shape || !isSpokeExcluded(sitePath, shape))
685
+ add(page);
686
+ }
661
687
  }
662
688
  return [...routes].sort();
663
689
  }
@@ -668,11 +694,12 @@ export function servedRoutes(targetDir) {
668
694
  * dynamic is never judged either: the root renderers are not in
669
695
  * `servedRoutes`.
670
696
  */
671
- function unservedRouteRow(targetDir, topology) {
697
+ function unservedRouteRow(targetDir, topology, signIn) {
672
698
  if (!existsSync(join(targetDir, ROUTE_ROOT)))
673
699
  return undefined;
674
- const spoke = (topology ?? readSiteTopology(targetDir)) === "spoke";
675
- const served = new Set(servedRoutes(targetDir));
700
+ // The spoke shape `planSiteManifest` passes `codeRouteRows`, so the two agree.
701
+ const shape = topology === undefined ? readSpokeShape(targetDir) : topology === "spoke" ? { mcp: true, signIn: signIn ?? "off" } : undefined;
702
+ const served = new Set(servedRoutes(targetDir, shape ?? null));
676
703
  const carried = webDependencies(targetDir);
677
704
  return (row) => {
678
705
  const route = row["route"];
@@ -686,12 +713,11 @@ function unservedRouteRow(targetDir, topology) {
686
713
  const pkg = pagePackageOfRoute(route.slice(1));
687
714
  if (pkg === undefined || !carried.has(pkg))
688
715
  return true;
689
- const sitePath = `apps/web/app/[locale]${route}`;
690
- return spoke && SPOKE_REMOVAL_SEEDS.some((seed) => sitePath === seed || sitePath.startsWith(`${seed}/`));
716
+ return shape !== undefined && isSpokeExcluded(`apps/web/app/[locale]${route}`, shape);
691
717
  };
692
718
  }
693
719
  /** The dependency and devDependency names of the site's `apps/web/package.json`; empty when it has none. */
694
- function webDependencies(targetDir) {
720
+ export function webDependencies(targetDir) {
695
721
  try {
696
722
  const pkg = JSON.parse(readFileSync(join(targetDir, "apps", "web", "package.json"), "utf8"));
697
723
  // The route generator's own reading (`readRouteManifests`): both lists.
@@ -706,8 +732,8 @@ function webDependencies(targetDir) {
706
732
  * byte verbatim — and the dropped routes in file order; `next` is undefined
707
733
  * when none is dropped.
708
734
  */
709
- export function withoutUnservedRouteRows(file, targetDir, topology) {
710
- const unserved = unservedRouteRow(targetDir, topology);
735
+ export function withoutUnservedRouteRows(file, targetDir, topology, signIn) {
736
+ const unserved = unservedRouteRow(targetDir, topology, signIn);
711
737
  const dropped = file.rows.filter((row) => unserved?.(row.value) === true);
712
738
  if (dropped.length === 0)
713
739
  return { next: undefined, dropped: [] };