create-ailk 0.24.0 → 0.26.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 (638) hide show
  1. package/README.md +53 -22
  2. package/component-catalog.json +3 -3
  3. package/component-catalog.md +3 -3
  4. package/dist/add-module.js +4 -2
  5. package/dist/add-route.d.ts +12 -1
  6. package/dist/add-route.js +31 -3
  7. package/dist/cli.js +12 -7
  8. package/dist/derive-architecture.d.ts +3 -4
  9. package/dist/derive-architecture.js +65 -29
  10. package/dist/lib/design-checks.d.ts +9 -4
  11. package/dist/lib/design-checks.js +13 -7
  12. package/dist/lib/extract-module-bundle.js +29 -2
  13. package/dist/lib/fetch-template-snapshot.d.ts +2 -1
  14. package/dist/lib/fetch-template-snapshot.js +8 -3
  15. package/dist/lib/import-graph.d.ts +1 -1
  16. package/dist/lib/import-graph.js +4 -4
  17. package/dist/lib/module-license-gate.d.ts +12 -1
  18. package/dist/lib/module-license-gate.js +36 -15
  19. package/dist/lib/module-tier.d.ts +2 -8
  20. package/dist/lib/module-tier.js +13 -12
  21. package/dist/module-architecture.d.ts +20 -3
  22. package/dist/module-architecture.js +129 -552
  23. package/dist/paid-sections.d.ts +25 -1
  24. package/dist/paid-sections.js +88 -3
  25. package/dist/starter-grid.d.ts +6 -6
  26. package/dist/starter-grid.js +12 -5
  27. package/dist/surfaces.js +39 -2
  28. package/dist/template-record.d.ts +21 -3
  29. package/dist/template-record.js +38 -7
  30. package/dist/topology.d.ts +16 -3
  31. package/dist/topology.js +54 -23
  32. package/dist/update.d.ts +10 -1
  33. package/dist/update.js +715 -21
  34. package/package.json +3 -3
  35. package/release-scope.json +2 -2
  36. package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +8 -2
  37. package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +2 -2
  38. package/site-templates/marketing-site/ailk-template.json +7 -1
  39. package/site-templates/marketing-site/provenance.json +7 -1
  40. package/site-templates/saas-product/ailk-template.json +2 -1
  41. package/site-templates/saas-product/provenance.json +1 -0
  42. package/templates/.claude/cloudparity-repo-hooks.json +5 -0
  43. package/templates/.claude/hooks/template-guard.sh +137 -0
  44. package/templates/.claude/rules/extending.md +106 -0
  45. package/templates/.claude/rules/loop-contract.md +2 -2
  46. package/templates/.claude/settings.json +11 -0
  47. package/templates/.env.example +20 -5
  48. package/templates/.github/workflows/ci.yml +7 -4
  49. package/templates/CLAUDE.md +11 -1
  50. package/templates/CONVENTIONS.md +8 -10
  51. package/templates/README.md +14 -13
  52. package/templates/apps/api/.env.example +23 -2
  53. package/templates/apps/api/CLAUDE.md +119 -83
  54. package/templates/apps/api/jest.config.cjs +15 -5
  55. package/templates/apps/api/package.json +16 -20
  56. package/templates/apps/api/src/__tests__/trusted-origins.server.test.ts +2 -2
  57. package/templates/apps/api/src/__tests__/vercel-handler.test.ts +4 -4
  58. package/templates/apps/api/src/index.ts +1 -1
  59. package/templates/apps/api/src/lib/__mocks__/prisma-client.js +16 -0
  60. package/templates/apps/api/src/lib/__mocks__/prisma.ts +3 -3
  61. package/templates/apps/api/src/modules/commerce.ts +10 -0
  62. package/templates/apps/api/src/modules/content-write.ts +10 -0
  63. package/templates/apps/api/src/modules/multi-tenant.ts +10 -0
  64. package/templates/apps/api/src/modules/scheduling.ts +10 -0
  65. package/templates/apps/api/src/modules/signal-collectors.ts +10 -0
  66. package/templates/apps/api/src/modules/workspace.ts +10 -0
  67. package/templates/apps/api/src/server.ts +117 -1882
  68. package/templates/apps/api/vercel.json +2 -2
  69. package/templates/apps/mcp/CLAUDE.md +90 -26
  70. package/templates/apps/mcp/__tests__/app-entry.test.ts +4 -254
  71. package/templates/apps/mcp/__tests__/boot-file.test.ts +92 -0
  72. package/templates/apps/mcp/jest.config.cjs +6 -1
  73. package/templates/apps/mcp/package.json +5 -13
  74. package/templates/apps/mcp/src/app.ts +8 -7
  75. package/templates/apps/mcp/src/index.ts +6 -34
  76. package/templates/apps/mcp/src/lib/paid-tools.generated.ts +10 -0
  77. package/templates/apps/mcp/src/lib/topology.generated.ts +2 -2
  78. package/templates/apps/mcp/src/site.ts +12 -0
  79. package/templates/apps/web/.env.example +1 -1
  80. package/templates/apps/web/CLAUDE.md +31 -3
  81. package/templates/apps/web/app/.well-known/mcp.json/route.ts +9 -3
  82. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +43 -4
  83. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +35 -0
  84. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +117 -8
  85. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +14 -37
  86. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +6 -6
  87. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +20 -35
  88. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +108 -0
  89. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +111 -5
  90. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +78 -16
  91. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +132 -12
  92. package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +53 -1
  93. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +38 -0
  94. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +4 -2
  95. package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +47 -24
  96. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +23 -4
  97. package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +1 -1
  98. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +22 -1
  99. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +7 -3
  100. package/templates/apps/web/app/[locale]/layout.tsx +33 -13
  101. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +128 -0
  102. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +126 -0
  103. package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +43 -0
  104. package/templates/apps/web/app/[locale]/pricing/page.tsx +7 -3
  105. package/templates/apps/web/app/api/offerings/checkout/[lookupKey]/__tests__/route.test.ts +222 -0
  106. package/templates/apps/web/app/api/offerings/checkout/[lookupKey]/route.ts +10 -3
  107. package/templates/apps/web/app/api/revalidate/route.ts +3 -3
  108. package/templates/apps/web/auth.ts +10 -6
  109. package/templates/apps/web/i18n/request.ts +49 -1
  110. package/templates/apps/web/jest.config.cjs +1 -0
  111. package/templates/apps/web/lib/__tests__/account-config.test.ts +7 -0
  112. package/templates/apps/web/lib/__tests__/auth-email.test.ts +276 -0
  113. package/templates/apps/web/lib/auth-email.ts +103 -21
  114. package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +72 -23
  115. package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +94 -70
  116. package/templates/apps/web/lib/prisma-for-auth.ts +5 -2
  117. package/templates/apps/web/lib/relay.ts +2 -2
  118. package/templates/apps/web/lib/release-scope.ts +47 -0
  119. package/templates/apps/web/lib/server-api.ts +1 -1
  120. package/templates/apps/web/lib/sign-up-agreements.ts +291 -28
  121. package/templates/apps/web/lib/site-contributions.ts +18 -0
  122. package/templates/apps/web/messages/en.json +186 -20
  123. package/templates/apps/web/messages/site/en.json +1 -0
  124. package/templates/apps/web/src/lib/commerce-claim.ts +1 -1
  125. package/templates/customizations.yaml +37 -0
  126. package/templates/database/prisma.config.ts +10 -14
  127. package/templates/database/seed-test.ts +2 -2
  128. package/templates/database/seed.ts +5 -5
  129. package/templates/package.json +12 -6
  130. package/templates/pnpm-workspace.yaml +0 -1
  131. package/templates/project.yaml +16 -8
  132. package/templates/tools/jest/reporters.cjs +65 -0
  133. package/templates/tools/lint-architecture.ts +553 -7
  134. package/templates/tsconfig.json +1 -2
  135. package/versions.json +49 -36
  136. package/templates/apps/api/src/__tests__/commerce-claim-registration.test.ts +0 -409
  137. package/templates/apps/api/src/__tests__/factories/agent-caller.ts +0 -102
  138. package/templates/apps/api/src/__tests__/factories/content-fixture.ts +0 -138
  139. package/templates/apps/api/src/__tests__/factories/in-memory-prisma.ts +0 -441
  140. package/templates/apps/api/src/__tests__/factories/index.ts +0 -70
  141. package/templates/apps/api/src/__tests__/factories/lead-fixture.ts +0 -82
  142. package/templates/apps/api/src/__tests__/leads-forwarded-rate-limit.test.ts +0 -135
  143. package/templates/apps/api/src/__tests__/services/enrichment-shim.test.ts +0 -126
  144. package/templates/apps/api/src/__tests__/stripe-boot.test.ts +0 -132
  145. package/templates/apps/api/src/__tests__/support/hub-sign-in-fake-db.ts +0 -362
  146. package/templates/apps/api/src/bin/__tests__/rate-limit-probe.test.ts +0 -184
  147. package/templates/apps/api/src/bin/abandon-sweep.ts +0 -42
  148. package/templates/apps/api/src/bin/rate-limit-probe.ts +0 -53
  149. package/templates/apps/api/src/bin/spokes.ts +0 -198
  150. package/templates/apps/api/src/bin/stripe-connections-rekey.ts +0 -45
  151. package/templates/apps/api/src/config/__tests__/hub-require-spoke-key.test.ts +0 -196
  152. package/templates/apps/api/src/config/__tests__/index.test.ts +0 -233
  153. package/templates/apps/api/src/config/__tests__/modules.test.ts +0 -76
  154. package/templates/apps/api/src/config/__tests__/stripe-connection-key.test.ts +0 -185
  155. package/templates/apps/api/src/config/__tests__/trusted-origins.test.ts +0 -238
  156. package/templates/apps/api/src/config/index.ts +0 -596
  157. package/templates/apps/api/src/config/modules.ts +0 -83
  158. package/templates/apps/api/src/lib/__tests__/agent-store.test.ts +0 -581
  159. package/templates/apps/api/src/lib/__tests__/auth-email-budget.test.ts +0 -143
  160. package/templates/apps/api/src/lib/__tests__/consent-ledger-double.ts +0 -237
  161. package/templates/apps/api/src/lib/__tests__/consent-store.test.ts +0 -353
  162. package/templates/apps/api/src/lib/__tests__/content-adapter.test.ts +0 -201
  163. package/templates/apps/api/src/lib/__tests__/deliverable-asset-store.test.ts +0 -224
  164. package/templates/apps/api/src/lib/__tests__/error-serializer.test.ts +0 -120
  165. package/templates/apps/api/src/lib/__tests__/errors.test.ts +0 -94
  166. package/templates/apps/api/src/lib/__tests__/file-fallback.test.ts +0 -144
  167. package/templates/apps/api/src/lib/__tests__/fixtures/HomePage/home.mdx +0 -8
  168. package/templates/apps/api/src/lib/__tests__/flow-completion-store.test.ts +0 -149
  169. package/templates/apps/api/src/lib/__tests__/flow-rename-race.db.test.ts +0 -116
  170. package/templates/apps/api/src/lib/__tests__/hub-sign-in-store.test.ts +0 -209
  171. package/templates/apps/api/src/lib/__tests__/lead-capture-store.test.ts +0 -257
  172. package/templates/apps/api/src/lib/__tests__/lead-delivery.test.ts +0 -96
  173. package/templates/apps/api/src/lib/__tests__/outbound-http.test.ts +0 -125
  174. package/templates/apps/api/src/lib/__tests__/prisma.test.ts +0 -165
  175. package/templates/apps/api/src/lib/__tests__/require-commerce-claim.test.ts +0 -317
  176. package/templates/apps/api/src/lib/__tests__/require-paid-tier.test.ts +0 -129
  177. package/templates/apps/api/src/lib/__tests__/site.test.ts +0 -308
  178. package/templates/apps/api/src/lib/__tests__/slice-load.test.ts +0 -89
  179. package/templates/apps/api/src/lib/__tests__/spoke-store.test.ts +0 -202
  180. package/templates/apps/api/src/lib/__tests__/stripe-admission.test.ts +0 -217
  181. package/templates/apps/api/src/lib/__tests__/stripe.test.ts +0 -82
  182. package/templates/apps/api/src/lib/agent-store.ts +0 -613
  183. package/templates/apps/api/src/lib/auth-email-budget.ts +0 -161
  184. package/templates/apps/api/src/lib/consent-store.ts +0 -363
  185. package/templates/apps/api/src/lib/content-adapter.ts +0 -112
  186. package/templates/apps/api/src/lib/deliverable-asset-store.ts +0 -96
  187. package/templates/apps/api/src/lib/error-serializer.ts +0 -164
  188. package/templates/apps/api/src/lib/errors.ts +0 -95
  189. package/templates/apps/api/src/lib/file-fallback.ts +0 -87
  190. package/templates/apps/api/src/lib/flow-completion-store.ts +0 -136
  191. package/templates/apps/api/src/lib/hub-sign-in-store.ts +0 -455
  192. package/templates/apps/api/src/lib/lead-capture-store.ts +0 -122
  193. package/templates/apps/api/src/lib/lead-delivery.ts +0 -52
  194. package/templates/apps/api/src/lib/license-key-store.ts +0 -45
  195. package/templates/apps/api/src/lib/locales.ts +0 -201
  196. package/templates/apps/api/src/lib/outbound-http.ts +0 -127
  197. package/templates/apps/api/src/lib/prisma.ts +0 -21
  198. package/templates/apps/api/src/lib/proposal-paid-store.ts +0 -66
  199. package/templates/apps/api/src/lib/rate-limit-probe.ts +0 -165
  200. package/templates/apps/api/src/lib/rate-limit-store.ts +0 -142
  201. package/templates/apps/api/src/lib/require-commerce-claim.ts +0 -250
  202. package/templates/apps/api/src/lib/require-paid-tier.ts +0 -53
  203. package/templates/apps/api/src/lib/site.ts +0 -257
  204. package/templates/apps/api/src/lib/slice-load.ts +0 -90
  205. package/templates/apps/api/src/lib/spoke-store.ts +0 -180
  206. package/templates/apps/api/src/lib/stripe.ts +0 -321
  207. package/templates/apps/api/src/lib/webhook-idempotency.ts +0 -156
  208. package/templates/apps/api/src/middleware/__tests__/adversarial/bearer-token-format.test.ts +0 -111
  209. package/templates/apps/api/src/middleware/__tests__/adversarial/cookie-or-bearer-precedence.test.ts +0 -172
  210. package/templates/apps/api/src/middleware/__tests__/adversarial/csrf-bearer-skip.test.ts +0 -119
  211. package/templates/apps/api/src/middleware/__tests__/adversarial/csrf-cookie-path.test.ts +0 -138
  212. package/templates/apps/api/src/middleware/__tests__/adversarial/csrf-trusted-origins.test.ts +0 -142
  213. package/templates/apps/api/src/middleware/__tests__/adversarial/session-fixation.test.ts +0 -155
  214. package/templates/apps/api/src/middleware/__tests__/adversarial/session-timeout.test.ts +0 -139
  215. package/templates/apps/api/src/middleware/__tests__/auth.bearer-path.test.ts +0 -562
  216. package/templates/apps/api/src/middleware/__tests__/auth.both-present-precedence.test.ts +0 -76
  217. package/templates/apps/api/src/middleware/__tests__/auth.cookie-path.test.ts +0 -220
  218. package/templates/apps/api/src/middleware/__tests__/auth.database-not-configured.test.ts +0 -97
  219. package/templates/apps/api/src/middleware/__tests__/auth.hub-session-path.test.ts +0 -557
  220. package/templates/apps/api/src/middleware/__tests__/auth.neither-present.test.ts +0 -72
  221. package/templates/apps/api/src/middleware/__tests__/auth.optional-cookie.test.ts +0 -140
  222. package/templates/apps/api/src/middleware/__tests__/default-tenant.test.ts +0 -721
  223. package/templates/apps/api/src/middleware/__tests__/rate-limit-cross-isolate.db.test.ts +0 -220
  224. package/templates/apps/api/src/middleware/__tests__/rate-limit-store.test.ts +0 -430
  225. package/templates/apps/api/src/middleware/__tests__/rate-limit.test.ts +0 -1409
  226. package/templates/apps/api/src/middleware/__tests__/write-budget.test.ts +0 -174
  227. package/templates/apps/api/src/middleware/auth.ts +0 -864
  228. package/templates/apps/api/src/middleware/default-tenant.ts +0 -166
  229. package/templates/apps/api/src/middleware/rate-limit.ts +0 -983
  230. package/templates/apps/api/src/openapi/__tests__/openapi.test.ts +0 -391
  231. package/templates/apps/api/src/openapi/__tests__/spec-identity.test.ts +0 -182
  232. package/templates/apps/api/src/openapi/index.ts +0 -18
  233. package/templates/apps/api/src/openapi/spec.ts +0 -2148
  234. package/templates/apps/api/src/openapi/surface-drift.ts +0 -195
  235. package/templates/apps/api/src/routes/aeo/__tests__/index.test.ts +0 -175
  236. package/templates/apps/api/src/routes/aeo/index.ts +0 -107
  237. package/templates/apps/api/src/routes/auth/__tests__/auth-tokens.functional.test.ts +0 -196
  238. package/templates/apps/api/src/routes/auth/__tests__/auth-user.functional.test.ts +0 -249
  239. package/templates/apps/api/src/routes/auth/__tests__/hub-sign-in.test.ts +0 -532
  240. package/templates/apps/api/src/routes/auth/__tests__/tokens.test.ts +0 -313
  241. package/templates/apps/api/src/routes/auth/__tests__/transactional-email.test.ts +0 -413
  242. package/templates/apps/api/src/routes/auth/__tests__/user.test.ts +0 -609
  243. package/templates/apps/api/src/routes/auth/hub-sign-in.ts +0 -242
  244. package/templates/apps/api/src/routes/auth/tokens.ts +0 -211
  245. package/templates/apps/api/src/routes/auth/transactional-email.ts +0 -301
  246. package/templates/apps/api/src/routes/auth/user.ts +0 -305
  247. package/templates/apps/api/src/routes/billing/plan-checkout.ts +0 -332
  248. package/templates/apps/api/src/routes/checkout/__tests__/live-key.test.ts +0 -178
  249. package/templates/apps/api/src/routes/checkout/__tests__/offerings-authorization.test.ts +0 -1426
  250. package/templates/apps/api/src/routes/checkout/__tests__/session.test.ts +0 -448
  251. package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +0 -1742
  252. package/templates/apps/api/src/routes/checkout/index.ts +0 -34
  253. package/templates/apps/api/src/routes/checkout/session.ts +0 -171
  254. package/templates/apps/api/src/routes/checkout/sessions.ts +0 -540
  255. package/templates/apps/api/src/routes/consent/__tests__/account.test.ts +0 -386
  256. package/templates/apps/api/src/routes/consent/__tests__/sign-up-rate-limit.test.ts +0 -160
  257. package/templates/apps/api/src/routes/consent/account.ts +0 -268
  258. package/templates/apps/api/src/routes/consent/cookie.ts +0 -90
  259. package/templates/apps/api/src/routes/consent/index.ts +0 -26
  260. package/templates/apps/api/src/routes/consent/unsubscribe.ts +0 -127
  261. package/templates/apps/api/src/routes/content/__tests__/get-page.test.ts +0 -853
  262. package/templates/apps/api/src/routes/content/__tests__/list-pages.test.ts +0 -230
  263. package/templates/apps/api/src/routes/content/__tests__/list-types.test.ts +0 -44
  264. package/templates/apps/api/src/routes/content/__tests__/locale.test.ts +0 -118
  265. package/templates/apps/api/src/routes/content/__tests__/offerings.test.ts +0 -731
  266. package/templates/apps/api/src/routes/content/__tests__/pricing.test.ts +0 -753
  267. package/templates/apps/api/src/routes/content/__tests__/rate-limit.test.ts +0 -51
  268. package/templates/apps/api/src/routes/content/__tests__/search.test.ts +0 -450
  269. package/templates/apps/api/src/routes/content/__tests__/shown-offerings.test.ts +0 -762
  270. package/templates/apps/api/src/routes/content/get-page.ts +0 -183
  271. package/templates/apps/api/src/routes/content/index.ts +0 -49
  272. package/templates/apps/api/src/routes/content/list-pages.ts +0 -74
  273. package/templates/apps/api/src/routes/content/list-types.ts +0 -19
  274. package/templates/apps/api/src/routes/content/offerings.ts +0 -184
  275. package/templates/apps/api/src/routes/content/pricing.ts +0 -176
  276. package/templates/apps/api/src/routes/content/rate-limit.ts +0 -22
  277. package/templates/apps/api/src/routes/content/search.ts +0 -100
  278. package/templates/apps/api/src/routes/content/shown-offerings.ts +0 -229
  279. package/templates/apps/api/src/routes/leads/__tests__/capture.test.ts +0 -88
  280. package/templates/apps/api/src/routes/leads/__tests__/list.test.ts +0 -171
  281. package/templates/apps/api/src/routes/leads/__tests__/magnet-completion.test.ts +0 -515
  282. package/templates/apps/api/src/routes/leads/__tests__/spoke.test.ts +0 -392
  283. package/templates/apps/api/src/routes/leads/__tests__/track.test.ts +0 -165
  284. package/templates/apps/api/src/routes/leads/index.ts +0 -639
  285. package/templates/apps/api/src/routes/leads/list.ts +0 -104
  286. package/templates/apps/api/src/routes/project-listings/__tests__/configured-application.test.ts +0 -626
  287. package/templates/apps/api/src/routes/project-listings/__tests__/drafts.test.ts +0 -1268
  288. package/templates/apps/api/src/routes/project-listings/__tests__/founder-identity.test.ts +0 -847
  289. package/templates/apps/api/src/routes/project-listings/__tests__/me.test.ts +0 -491
  290. package/templates/apps/api/src/routes/project-listings/__tests__/public.test.ts +0 -476
  291. package/templates/apps/api/src/routes/project-listings/__tests__/resume-email.test.ts +0 -872
  292. package/templates/apps/api/src/routes/project-listings/__tests__/site-answers.test.ts +0 -1022
  293. package/templates/apps/api/src/routes/project-listings/__tests__/site-key.test.ts +0 -484
  294. package/templates/apps/api/src/routes/project-listings/__tests__/structured-address.test.ts +0 -535
  295. package/templates/apps/api/src/routes/project-listings/index.ts +0 -164
  296. package/templates/apps/api/src/routes/project-listings/me.ts +0 -87
  297. package/templates/apps/api/src/routes/project-listings/patch-copy.ts +0 -224
  298. package/templates/apps/api/src/routes/project-listings/patch-draft.ts +0 -102
  299. package/templates/apps/api/src/routes/project-listings/public.ts +0 -98
  300. package/templates/apps/api/src/routes/project-listings/respond.ts +0 -48
  301. package/templates/apps/api/src/routes/project-listings/resume-token.ts +0 -27
  302. package/templates/apps/api/src/routes/project-listings/start.ts +0 -140
  303. package/templates/apps/api/src/routes/project-listings/submit.ts +0 -130
  304. package/templates/apps/api/src/routes/project-listings/verify-email.ts +0 -150
  305. package/templates/apps/api/src/routes/requests/__tests__/confirm.test.ts +0 -686
  306. package/templates/apps/api/src/routes/requests/confirm.ts +0 -601
  307. package/templates/apps/api/src/routes/requests/index.ts +0 -54
  308. package/templates/apps/api/src/routes/test/auth/__tests__/session.test.ts +0 -306
  309. package/templates/apps/api/src/routes/test/auth/session.ts +0 -143
  310. package/templates/apps/api/src/routes/webhooks/README.md +0 -398
  311. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-checkout-consent.test.ts +0 -649
  312. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-dunning.test.ts +0 -749
  313. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-flow-checkout.test.ts +0 -449
  314. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-idempotency.test.ts +0 -264
  315. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-livemode-live.test.ts +0 -159
  316. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-livemode.test.ts +0 -158
  317. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-offerings.test.ts +0 -814
  318. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-org-billing.test.ts +0 -301
  319. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-proposal-paid.test.ts +0 -369
  320. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-rate-limit.test.ts +0 -215
  321. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-request-paid.test.ts +0 -301
  322. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-site-filter.test.ts +0 -809
  323. package/templates/apps/api/src/routes/webhooks/__tests__/stripe.test.ts +0 -1155
  324. package/templates/apps/api/src/routes/webhooks/index.ts +0 -141
  325. package/templates/apps/api/src/routes/webhooks/stripe-offerings.ts +0 -384
  326. package/templates/apps/api/src/routes/webhooks/stripe.ts +0 -2028
  327. package/templates/apps/api/src/services/__tests__/abandon-email.test.ts +0 -645
  328. package/templates/apps/api/src/services/__tests__/answer-distributions.test.ts +0 -132
  329. package/templates/apps/api/src/services/__tests__/audit-log.test.ts +0 -1028
  330. package/templates/apps/api/src/services/__tests__/checkout-plan.test.ts +0 -313
  331. package/templates/apps/api/src/services/__tests__/consent-ledger.test.ts +0 -503
  332. package/templates/apps/api/src/services/__tests__/consent-migration.test.ts +0 -65
  333. package/templates/apps/api/src/services/__tests__/consent.test.ts +0 -299
  334. package/templates/apps/api/src/services/__tests__/default-tenant.test.ts +0 -147
  335. package/templates/apps/api/src/services/__tests__/deliverable-fulfillment.test.ts +0 -877
  336. package/templates/apps/api/src/services/__tests__/deliverable-resend.test.ts +0 -379
  337. package/templates/apps/api/src/services/__tests__/dunning-policy.test.ts +0 -368
  338. package/templates/apps/api/src/services/__tests__/entitlements.test.ts +0 -142
  339. package/templates/apps/api/src/services/__tests__/hub-sign-in.test.ts +0 -854
  340. package/templates/apps/api/src/services/__tests__/keyless-workspace-predicate.test.ts +0 -234
  341. package/templates/apps/api/src/services/__tests__/lead-accept-user.test.ts +0 -251
  342. package/templates/apps/api/src/services/__tests__/lead-routing.test.ts +0 -2660
  343. package/templates/apps/api/src/services/__tests__/listing-config.test.ts +0 -166
  344. package/templates/apps/api/src/services/__tests__/magnet-completion.test.ts +0 -389
  345. package/templates/apps/api/src/services/__tests__/person.test.ts +0 -1204
  346. package/templates/apps/api/src/services/__tests__/plan-offerings.test.ts +0 -450
  347. package/templates/apps/api/src/services/__tests__/project-listings.counts.test.ts +0 -202
  348. package/templates/apps/api/src/services/__tests__/project-listings.fence.test.ts +0 -151
  349. package/templates/apps/api/src/services/__tests__/public-site-resolver.test.ts +0 -137
  350. package/templates/apps/api/src/services/__tests__/request-confirm.test.ts +0 -531
  351. package/templates/apps/api/src/services/__tests__/revalidation.test.ts +0 -372
  352. package/templates/apps/api/src/services/__tests__/slack-notify.test.ts +0 -348
  353. package/templates/apps/api/src/services/__tests__/spoke-resolution.test.ts +0 -660
  354. package/templates/apps/api/src/services/__tests__/usage-aggregation.test.ts +0 -941
  355. package/templates/apps/api/src/services/__tests__/usage-credits.test.ts +0 -588
  356. package/templates/apps/api/src/services/__tests__/verified-email.test.ts +0 -78
  357. package/templates/apps/api/src/services/abandon-email.ts +0 -336
  358. package/templates/apps/api/src/services/aeo-score.ts +0 -325
  359. package/templates/apps/api/src/services/answer-distributions.ts +0 -138
  360. package/templates/apps/api/src/services/audit-log.ts +0 -961
  361. package/templates/apps/api/src/services/checkout-buyer.ts +0 -168
  362. package/templates/apps/api/src/services/consent.ts +0 -834
  363. package/templates/apps/api/src/services/default-tenant.ts +0 -416
  364. package/templates/apps/api/src/services/deliverable-fulfillment.ts +0 -750
  365. package/templates/apps/api/src/services/dunning-policy.ts +0 -294
  366. package/templates/apps/api/src/services/enrichment-shim.ts +0 -53
  367. package/templates/apps/api/src/services/entitlements.ts +0 -338
  368. package/templates/apps/api/src/services/hub-sign-in.ts +0 -472
  369. package/templates/apps/api/src/services/lead-accept-user.ts +0 -126
  370. package/templates/apps/api/src/services/lead-promotion.ts +0 -160
  371. package/templates/apps/api/src/services/lead-routing.ts +0 -1372
  372. package/templates/apps/api/src/services/leads-inbox.ts +0 -312
  373. package/templates/apps/api/src/services/listing-config.ts +0 -178
  374. package/templates/apps/api/src/services/magnet-completion.ts +0 -242
  375. package/templates/apps/api/src/services/offerings/__tests__/catalog.test.ts +0 -348
  376. package/templates/apps/api/src/services/offerings/__tests__/checkout-session-record.test.ts +0 -268
  377. package/templates/apps/api/src/services/offerings/__tests__/connection.test.ts +0 -975
  378. package/templates/apps/api/src/services/offerings/__tests__/fixtures.ts +0 -416
  379. package/templates/apps/api/src/services/offerings/__tests__/org-products.test.ts +0 -400
  380. package/templates/apps/api/src/services/offerings/__tests__/readers.test.ts +0 -685
  381. package/templates/apps/api/src/services/offerings/__tests__/source.test.ts +0 -231
  382. package/templates/apps/api/src/services/offerings/catalog.ts +0 -318
  383. package/templates/apps/api/src/services/offerings/checkout-authorization.ts +0 -403
  384. package/templates/apps/api/src/services/offerings/checkout-session-record.ts +0 -192
  385. package/templates/apps/api/src/services/offerings/connection.ts +0 -1083
  386. package/templates/apps/api/src/services/offerings/index.ts +0 -614
  387. package/templates/apps/api/src/services/offerings/source.ts +0 -140
  388. package/templates/apps/api/src/services/offerings/store.ts +0 -150
  389. package/templates/apps/api/src/services/owner-workspaces.ts +0 -132
  390. package/templates/apps/api/src/services/person.ts +0 -1211
  391. package/templates/apps/api/src/services/plan-offerings.ts +0 -125
  392. package/templates/apps/api/src/services/project-listing-resume-email.ts +0 -326
  393. package/templates/apps/api/src/services/project-listings.ts +0 -2085
  394. package/templates/apps/api/src/services/public-site-resolver.ts +0 -396
  395. package/templates/apps/api/src/services/request-confirm.ts +0 -698
  396. package/templates/apps/api/src/services/revalidation.ts +0 -235
  397. package/templates/apps/api/src/services/slack-notify.ts +0 -291
  398. package/templates/apps/api/src/services/usage-aggregation.ts +0 -516
  399. package/templates/apps/api/src/services/usage-credits.ts +0 -340
  400. package/templates/apps/api/src/services/verified-email.ts +0 -71
  401. package/templates/apps/mcp/__tests__/abuse/daily-cap.test.ts +0 -52
  402. package/templates/apps/mcp/__tests__/abuse/email-validator.test.ts +0 -46
  403. package/templates/apps/mcp/__tests__/abuse/guard.test.ts +0 -198
  404. package/templates/apps/mcp/__tests__/abuse/honeypot.test.ts +0 -36
  405. package/templates/apps/mcp/__tests__/abuse/user-agent-deny.test.ts +0 -54
  406. package/templates/apps/mcp/__tests__/aeo-cli-parity.test.ts +0 -116
  407. package/templates/apps/mcp/__tests__/audit-single-page.test.ts +0 -299
  408. package/templates/apps/mcp/__tests__/boot.test.ts +0 -280
  409. package/templates/apps/mcp/__tests__/catalog-drift.test.ts +0 -359
  410. package/templates/apps/mcp/__tests__/config/modules.test.ts +0 -78
  411. package/templates/apps/mcp/__tests__/get_business_hours.test.ts +0 -82
  412. package/templates/apps/mcp/__tests__/get_faq.test.ts +0 -80
  413. package/templates/apps/mcp/__tests__/get_locations.test.ts +0 -65
  414. package/templates/apps/mcp/__tests__/get_offerings.test.ts +0 -557
  415. package/templates/apps/mcp/__tests__/get_pricing.test.ts +0 -524
  416. package/templates/apps/mcp/__tests__/get_site_info.test.ts +0 -81
  417. package/templates/apps/mcp/__tests__/http-transport.test.ts +0 -1232
  418. package/templates/apps/mcp/__tests__/index.test.ts +0 -195
  419. package/templates/apps/mcp/__tests__/lib/audit-single-page-readiness-scan.test.ts +0 -191
  420. package/templates/apps/mcp/__tests__/lib/commerce-claim.test.ts +0 -531
  421. package/templates/apps/mcp/__tests__/lib/content-adapter-parity.test.ts +0 -70
  422. package/templates/apps/mcp/__tests__/lib/content-adapter.test.ts +0 -162
  423. package/templates/apps/mcp/__tests__/lib/content-root.test.ts +0 -93
  424. package/templates/apps/mcp/__tests__/lib/errors.test.ts +0 -75
  425. package/templates/apps/mcp/__tests__/lib/fail-closed-tools.test.ts +0 -180
  426. package/templates/apps/mcp/__tests__/lib/public-workspace.test.ts +0 -124
  427. package/templates/apps/mcp/__tests__/list_pages.test.ts +0 -268
  428. package/templates/apps/mcp/__tests__/locale.test.ts +0 -120
  429. package/templates/apps/mcp/__tests__/module-exclusion.test.ts +0 -175
  430. package/templates/apps/mcp/__tests__/purchase-disabled.test.ts +0 -101
  431. package/templates/apps/mcp/__tests__/rate-limit-write.test.ts +0 -189
  432. package/templates/apps/mcp/__tests__/read_content.test.ts +0 -511
  433. package/templates/apps/mcp/__tests__/request_callback.test.ts +0 -160
  434. package/templates/apps/mcp/__tests__/search_content.test.ts +0 -271
  435. package/templates/apps/mcp/__tests__/server.test.ts +0 -388
  436. package/templates/apps/mcp/__tests__/start_purchase.test.ts +0 -448
  437. package/templates/apps/mcp/__tests__/submit_lead.test.ts +0 -222
  438. package/templates/apps/mcp/__tests__/subscribe_newsletter.test.ts +0 -152
  439. package/templates/apps/mcp/__tests__/tools/create_project.test.ts +0 -243
  440. package/templates/apps/mcp/__tests__/tools/purchase.test.ts +0 -451
  441. package/templates/apps/mcp/src/abuse/daily-cap.ts +0 -47
  442. package/templates/apps/mcp/src/abuse/email-validator.ts +0 -25
  443. package/templates/apps/mcp/src/abuse/honeypot.ts +0 -21
  444. package/templates/apps/mcp/src/abuse/index.ts +0 -349
  445. package/templates/apps/mcp/src/abuse/user-agent-deny.ts +0 -58
  446. package/templates/apps/mcp/src/boot.ts +0 -167
  447. package/templates/apps/mcp/src/config/modules.ts +0 -43
  448. package/templates/apps/mcp/src/http-transport.ts +0 -564
  449. package/templates/apps/mcp/src/lib/audit-single-page.ts +0 -308
  450. package/templates/apps/mcp/src/lib/commerce-claim.ts +0 -263
  451. package/templates/apps/mcp/src/lib/content-adapter.ts +0 -116
  452. package/templates/apps/mcp/src/lib/empty-content-adapter.ts +0 -140
  453. package/templates/apps/mcp/src/lib/errors.ts +0 -61
  454. package/templates/apps/mcp/src/lib/license-key-store.ts +0 -45
  455. package/templates/apps/mcp/src/lib/locales.ts +0 -171
  456. package/templates/apps/mcp/src/lib/prisma.ts +0 -39
  457. package/templates/apps/mcp/src/lib/public-workspace.ts +0 -133
  458. package/templates/apps/mcp/src/lib/resolve-locale.ts +0 -30
  459. package/templates/apps/mcp/src/lib/shown-offerings.ts +0 -105
  460. package/templates/apps/mcp/src/lib/site-config.ts +0 -53
  461. package/templates/apps/mcp/src/lib/stripe-tax-signal.ts +0 -59
  462. package/templates/apps/mcp/src/request-context.ts +0 -52
  463. package/templates/apps/mcp/src/server.ts +0 -343
  464. package/templates/apps/mcp/src/serverless-app.ts +0 -88
  465. package/templates/apps/mcp/src/tools/audit.ts +0 -127
  466. package/templates/apps/mcp/src/tools/capture_lead.ts +0 -66
  467. package/templates/apps/mcp/src/tools/create_project.ts +0 -134
  468. package/templates/apps/mcp/src/tools/get_business_hours.ts +0 -68
  469. package/templates/apps/mcp/src/tools/get_faq.ts +0 -71
  470. package/templates/apps/mcp/src/tools/get_locations.ts +0 -88
  471. package/templates/apps/mcp/src/tools/get_offerings.ts +0 -96
  472. package/templates/apps/mcp/src/tools/get_pricing.ts +0 -94
  473. package/templates/apps/mcp/src/tools/get_site_info.ts +0 -86
  474. package/templates/apps/mcp/src/tools/index.ts +0 -138
  475. package/templates/apps/mcp/src/tools/list_pages.ts +0 -68
  476. package/templates/apps/mcp/src/tools/person_notes.ts +0 -25
  477. package/templates/apps/mcp/src/tools/proposals.ts +0 -27
  478. package/templates/apps/mcp/src/tools/purchase.ts +0 -205
  479. package/templates/apps/mcp/src/tools/read_content.ts +0 -81
  480. package/templates/apps/mcp/src/tools/request_callback.ts +0 -52
  481. package/templates/apps/mcp/src/tools/search_content.ts +0 -63
  482. package/templates/apps/mcp/src/tools/subscribe_newsletter.ts +0 -54
  483. package/templates/apps/mcp/src/workspace-server.ts +0 -224
  484. package/templates/database/CHANGELOG.md +0 -981
  485. package/templates/database/LICENSE +0 -202
  486. package/templates/database/NOTICE +0 -2
  487. package/templates/database/README.md +0 -243
  488. package/templates/database/__tests__/agents.db.test.ts +0 -320
  489. package/templates/database/__tests__/appointment.db.test.ts +0 -106
  490. package/templates/database/__tests__/artifact-content-store.db.test.ts +0 -316
  491. package/templates/database/__tests__/composite-fence.db.test.ts +0 -206
  492. package/templates/database/__tests__/consent-ledger.db.test.ts +0 -345
  493. package/templates/database/__tests__/consent-source-checkout-migration.test.ts +0 -79
  494. package/templates/database/__tests__/fence-fan-out.db.test.ts +0 -715
  495. package/templates/database/__tests__/fixtures/appointment-create-probe.ts +0 -79
  496. package/templates/database/__tests__/fixtures/person-backfill.json +0 -264
  497. package/templates/database/__tests__/fixtures/person-contact-backfill.json +0 -182
  498. package/templates/database/__tests__/fixtures/project-listing-consent-probe.ts +0 -100
  499. package/templates/database/__tests__/flow-completion-migration.test.ts +0 -115
  500. package/templates/database/__tests__/flow-completion.db.test.ts +0 -136
  501. package/templates/database/__tests__/flow-workspace-key.db.test.ts +0 -263
  502. package/templates/database/__tests__/flows-listing-diagnostic.test.ts +0 -392
  503. package/templates/database/__tests__/flows-presets.test.ts +0 -173
  504. package/templates/database/__tests__/in-page-magnets-migration.test.ts +0 -161
  505. package/templates/database/__tests__/lead-idempotency-key.db.test.ts +0 -92
  506. package/templates/database/__tests__/member-area.db.test.ts +0 -257
  507. package/templates/database/__tests__/member-contract-migration.test.ts +0 -85
  508. package/templates/database/__tests__/member-contract.db.test.ts +0 -413
  509. package/templates/database/__tests__/offerings-checkout-session.db.test.ts +0 -270
  510. package/templates/database/__tests__/offerings-migration.test.ts +0 -197
  511. package/templates/database/__tests__/offerings-shown-price-ids-migration.test.ts +0 -86
  512. package/templates/database/__tests__/offerings.db.test.ts +0 -303
  513. package/templates/database/__tests__/outbound-message-action.db.test.ts +0 -80
  514. package/templates/database/__tests__/person-contact.db.test.ts +0 -563
  515. package/templates/database/__tests__/person-notes.db.test.ts +0 -249
  516. package/templates/database/__tests__/person.db.test.ts +0 -586
  517. package/templates/database/__tests__/piece-kind-migration.test.ts +0 -67
  518. package/templates/database/__tests__/piece-kind.db.test.ts +0 -208
  519. package/templates/database/__tests__/prefixed-ids.db.test.ts +0 -222
  520. package/templates/database/__tests__/project-listing-consent-at.db.test.ts +0 -111
  521. package/templates/database/__tests__/seed.test.ts +0 -272
  522. package/templates/database/__tests__/spoke-registry.db.test.ts +0 -191
  523. package/templates/database/__tests__/tenancy.test.ts +0 -141
  524. package/templates/database/__tests__/trial-magnet-migration.test.ts +0 -186
  525. package/templates/database/__tests__/user-cascade.test.ts +0 -140
  526. package/templates/database/_gitignore +0 -8
  527. package/templates/database/auth/.gitkeep +0 -0
  528. package/templates/database/auth/schema.prisma +0 -641
  529. package/templates/database/config/.gitkeep +0 -0
  530. package/templates/database/config/schema.prisma +0 -441
  531. package/templates/database/content/.gitkeep +0 -0
  532. package/templates/database/content/schema.prisma +0 -339
  533. package/templates/database/eslint.config.mjs +0 -69
  534. package/templates/database/flows/listing-diagnostic.ts +0 -182
  535. package/templates/database/flows/presets.ts +0 -315
  536. package/templates/database/inbox/.gitkeep +0 -0
  537. package/templates/database/inbox/README.md +0 -3
  538. package/templates/database/inbox/__tests__/schema.test.ts +0 -44
  539. package/templates/database/inbox/schema.prisma +0 -1447
  540. package/templates/database/jest.config.cjs +0 -36
  541. package/templates/database/migrations/20260508000000_add_inbox_namespace/migration.sql +0 -328
  542. package/templates/database/migrations/20260513000000_better_auth_migration/migration.sql +0 -100
  543. package/templates/database/migrations/20260515000000_add_user_billing_fields/migration.sql +0 -28
  544. package/templates/database/migrations/20260516000000_add_user_tier_care_plan_seat/migration.sql +0 -25
  545. package/templates/database/migrations/20260518000000_add_telemetry_records/migration.sql +0 -42
  546. package/templates/database/migrations/20260525000000_theme_wiring/migration.sql +0 -67
  547. package/templates/database/migrations/20260710000000_retire_commercial_tier/migration.sql +0 -21
  548. package/templates/database/migrations/20260712215647_add_multi_tenant_tenancy/migration.sql +0 -201
  549. package/templates/database/migrations/20260713143320_reanchor_site_config_to_workspace/migration.sql +0 -67
  550. package/templates/database/migrations/20260713174000_add_audit_logs/migration.sql +0 -46
  551. package/templates/database/migrations/20260713190000_drop_telemetry_records/migration.sql +0 -25
  552. package/templates/database/migrations/20260713192000_add_uuidv7_function/migration.sql +0 -49
  553. package/templates/database/migrations/20260713192429_prefixed_uuid_entity_ids/migration.sql +0 -197
  554. package/templates/database/migrations/20260713200000_add_org_billing/migration.sql +0 -32
  555. package/templates/database/migrations/20260714000000_add_lead_promotion_fields/migration.sql +0 -22
  556. package/templates/database/migrations/20260714010000_add_usage_billing_content_models/migration.sql +0 -151
  557. package/templates/database/migrations/20260714020000_add_usage_billing_auth_config_models/migration.sql +0 -223
  558. package/templates/database/migrations/20260714030000_credit_balance_non_negative/migration.sql +0 -22
  559. package/templates/database/migrations/20260714030000_widen_usage_billing_report_aggregates/migration.sql +0 -32
  560. package/templates/database/migrations/20260810233516_add_flow_engine_models/migration.sql +0 -40
  561. package/templates/database/migrations/20260811020000_add_flow_session_abandon_email_columns/migration.sql +0 -4
  562. package/templates/database/migrations/20260811030000_add_flow_session_abandon_email_index/migration.sql +0 -2
  563. package/templates/database/migrations/20260811040000_add_flow_session_segment/migration.sql +0 -2
  564. package/templates/database/migrations/20260811050000_add_deliverable_models/migration.sql +0 -29
  565. package/templates/database/migrations/20260812000000_add_deliverable_grant_send_columns/migration.sql +0 -6
  566. package/templates/database/migrations/20260902222948_add_waitlist_experiment_models/migration.sql +0 -39
  567. package/templates/database/migrations/20260902224500_add_waitlist_id_format_checks/migration.sql +0 -24
  568. package/templates/database/migrations/20260903004112_add_flow_session_flags_aeo_score/migration.sql +0 -3
  569. package/templates/database/migrations/20260903010000_add_playbook_instance/migration.sql +0 -33
  570. package/templates/database/migrations/20260904000000_add_waitlist_followup_send/migration.sql +0 -30
  571. package/templates/database/migrations/20260905230000_add_flow_checkout/migration.sql +0 -47
  572. package/templates/database/migrations/20260906000000_add_flow_checkout_idempotency/migration.sql +0 -16
  573. package/templates/database/migrations/20260907120000_add_project_listing/migration.sql +0 -47
  574. package/templates/database/migrations/20260907130000_add_project_listing_slack_columns/migration.sql +0 -10
  575. package/templates/database/migrations/20260907180000_add_listing_csv_send/migration.sql +0 -26
  576. package/templates/database/migrations/20260909120000_project_listings_platform/migration.sql +0 -90
  577. package/templates/database/migrations/20260909180000_listing_draft_and_fields/migration.sql +0 -174
  578. package/templates/database/migrations/20260910120000_listing_public_site_key/migration.sql +0 -14
  579. package/templates/database/migrations/20260911120000_listing_copy_edit_audit/migration.sql +0 -25
  580. package/templates/database/migrations/20260911140000_listing_structured_address/migration.sql +0 -32
  581. package/templates/database/migrations/20260911180000_consent_grants/migration.sql +0 -71
  582. package/templates/database/migrations/20260911200000_listing_site_answers/migration.sql +0 -30
  583. package/templates/database/migrations/20260912120000_listing_owner_link/migration.sql +0 -49
  584. package/templates/database/migrations/20260914120000_listing_founder_identity/migration.sql +0 -123
  585. package/templates/database/migrations/20260915120000_project_listing_solution/migration.sql +0 -15
  586. package/templates/database/migrations/20260916120000_artifact_content_store/migration.sql +0 -158
  587. package/templates/database/migrations/20260917120000_callback_request_confirm/migration.sql +0 -40
  588. package/templates/database/migrations/20260918120000_add_appointment/migration.sql +0 -67
  589. package/templates/database/migrations/20260918120000_asset_metadata_columns/migration.sql +0 -70
  590. package/templates/database/migrations/20260919120000_flow_workspace_key/migration.sql +0 -181
  591. package/templates/database/migrations/20260919130000_flow_definition_admin_columns/migration.sql +0 -172
  592. package/templates/database/migrations/20260919130000_workspace_meetings/migration.sql +0 -41
  593. package/templates/database/migrations/20260919140000_inbox_workspace_key/migration.sql +0 -185
  594. package/templates/database/migrations/20260920120000_lead_handled_at/migration.sql +0 -70
  595. package/templates/database/migrations/20260920130000_lead_workspace_source_index/migration.sql +0 -57
  596. package/templates/database/migrations/20260921120000_deliverable_grant_workspace_key/migration.sql +0 -68
  597. package/templates/database/migrations/20260922120000_tenancy_fence/migration.sql +0 -1067
  598. package/templates/database/migrations/20260923120000_listing_capturing_magnet/migration.sql +0 -210
  599. package/templates/database/migrations/20261003120000_spoke_registry/migration.sql +0 -80
  600. package/templates/database/migrations/20261003130000_scheduling_connection/migration.sql +0 -49
  601. package/templates/database/migrations/20261005120000_agents/migration.sql +0 -84
  602. package/templates/database/migrations/20261008120000_user_last_workspace/migration.sql +0 -35
  603. package/templates/database/migrations/20261008130000_lead_idempotency_key/migration.sql +0 -20
  604. package/templates/database/migrations/20261009120000_agent_grants/migration.sql +0 -33
  605. package/templates/database/migrations/20261010120000_person/migration.sql +0 -106
  606. package/templates/database/migrations/20261010121000_person_backfill/migration.sql +0 -132
  607. package/templates/database/migrations/20261010130000_agent_grants_people_read/migration.sql +0 -20
  608. package/templates/database/migrations/20261011120000_member_area/migration.sql +0 -158
  609. package/templates/database/migrations/20261011130000_agent_grants_member_pieces_manage/migration.sql +0 -21
  610. package/templates/database/migrations/20261012120000_member_contract/migration.sql +0 -192
  611. package/templates/database/migrations/20261013120000_lead_spoke_checkout/migration.sql +0 -20
  612. package/templates/database/migrations/20261014120000_consent_ledger/migration.sql +0 -122
  613. package/templates/database/migrations/20261014120000_person_contact/migration.sql +0 -231
  614. package/templates/database/migrations/20261015120000_person_notes/migration.sql +0 -77
  615. package/templates/database/migrations/20261015120000_rate_limit_counters/migration.sql +0 -43
  616. package/templates/database/migrations/20261016120000_piece_kind/migration.sql +0 -95
  617. package/templates/database/migrations/20261017120000_outbound_message_action/migration.sql +0 -30
  618. package/templates/database/migrations/20261018120000_flow_completion/migration.sql +0 -52
  619. package/templates/database/migrations/20261019120000_consent_source_checkout/migration.sql +0 -27
  620. package/templates/database/migrations/20261020120000_offerings_data_model/migration.sql +0 -146
  621. package/templates/database/migrations/20261021120000_offerings_checkout_session/migration.sql +0 -77
  622. package/templates/database/migrations/20261022120000_in_page_magnets/migration.sql +0 -45
  623. package/templates/database/migrations/20261023120000_offerings_shown_price_ids/migration.sql +0 -47
  624. package/templates/database/migrations/20261024120000_organization_plan_checkout_session/migration.sql +0 -16
  625. package/templates/database/migrations/20261025120000_trial_magnet/migration.sql +0 -28
  626. package/templates/database/migrations/20261026120000_trial_magnet_proof_line/migration.sql +0 -23
  627. package/templates/database/migrations/migration_lock.toml +0 -3
  628. package/templates/database/ops/.gitkeep +0 -0
  629. package/templates/database/ops/schema.prisma +0 -43
  630. package/templates/database/package.json +0 -89
  631. package/templates/database/schema.prisma +0 -71
  632. package/templates/database/scripts/db-generate-locked.sh +0 -80
  633. package/templates/database/scripts/person-backfill.sql +0 -132
  634. package/templates/database/tenancy.ts +0 -183
  635. package/templates/database/tsconfig.build.json +0 -16
  636. package/templates/database/tsconfig.flows.json +0 -15
  637. package/templates/database/tsconfig.json +0 -16
  638. package/templates/database/tsconfig.tenancy.json +0 -14
package/dist/update.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * `create-ailk update [<target-dir>]` — bring template fixes into a site's
3
- * already-copied `apps/web`, `apps/api` and `apps/mcp` code (#8522).
3
+ * already-copied `apps/web`, `apps/api` and `apps/mcp` code (#8522), and
4
+ * the root `tools/` files their jest configs require (#9654).
4
5
  *
5
6
  * Reads `.ailk-template-files.json` (`template-record.ts`) to tell an
6
7
  * untouched copy from an owner's edit. An untouched file whose template
@@ -13,26 +14,39 @@
13
14
  * template test that imports a file left under review or skipped is held at
14
15
  * the site's version with it, so a run never leaves a test newer than the
15
16
  * code it exercises (#8704). A site with no record gets one backfilled from
16
- * `.ailk-site-manifest.json`'s `patternVersion` on its first run, then
17
- * updates normally. Every refusal throws before the first write.
17
+ * `.ailk-site-manifest.json`'s `patternVersion` on its first run — one row
18
+ * per in-scope path of that version's snapshot, on disk or not (#9527) —
19
+ * then updates normally. A site scaffolded before `@working-theory/mcp-server`
20
+ * (#9460) has its copied `apps/mcp` moved to the boot set (#9567): the
21
+ * record's own rules retire the copied server files, and what the record
22
+ * cannot see — the dependency, the hub seam's imports, the bundle-delivered
23
+ * paid tools — is planned here and applied with them. The paid MCP tool
24
+ * registry is rewritten from `apps/mcp/package.json` on every run, as the
25
+ * module-presence flags are. A site scaffolded before `@working-theory/api`
26
+ * (#9564) has its copied `apps/api` moved to the boot file the same way
27
+ * (#9566): the record retires the copied server files and lands the boot
28
+ * files; the app's rename, its dependencies and delegating scripts, and the
29
+ * bundle-delivered module files are planned here. Every refusal throws
30
+ * before the first write.
18
31
  *
19
32
  * Pure module: no `import.meta.url` — the CLI supplies `templatesDir`, the
20
33
  * `adopt.ts` / `add-route.ts` split.
21
34
  */
22
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync, } from "node:fs";
35
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, rmdirSync, writeFileSync, } from "node:fs";
23
36
  import { dirname, join, resolve, sep } from "node:path";
24
37
  import { parseArgs } from "node:util";
25
38
  import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
26
39
  import { buildScaffoldMarkers, isExcluded, isTextFile, renderTemplateFile, templateDestination } from "./copy.js";
27
40
  import { fetchTemplateSnapshot } from "./lib/fetch-template-snapshot.js";
28
41
  import { mergeThreeWay } from "./lib/merge-three-way.js";
29
- import { MODULE_FLAGS_PATH, writeModuleFlags } from "./paid-sections.js";
42
+ import { MODULE_SLICES } from "./module-architecture.js";
43
+ import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, writeModuleFlags, writePaidMcpTools, } from "./paid-sections.js";
30
44
  import { ParseError } from "./parse-args.js";
31
45
  import { SITE_ROSTER_PATH } from "./site-roster.js";
32
46
  import { SPOKE_CHECKOUT_TEMPLATE_PATHS } from "./spoke-checkout.js";
33
47
  import { excludedRoutePaths } from "./surfaces.js";
34
- import { TEMPLATE_RECORD_PATH, isRecordable, parseTemplateRecord, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
35
- import { TopologyError, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
48
+ import { DATABASE_BOOT_FILES, ROOT_TOOL_FILES, TEMPLATE_RECORD_PATH, isRecordable, parseTemplateRecord, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
49
+ import { MCP_SEAM_PATH, MCP_SERVER_HUB, TopologyError, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
36
50
  /** A refusal the CLI exits 2 on, thrown before anything is written. */
37
51
  export class UpdateRefusedError extends Error {
38
52
  exitCode = 2;
@@ -60,9 +74,20 @@ function versionOlder(a, b) {
60
74
  }
61
75
  return false;
62
76
  }
63
- /** Every file under `templatesDir`'s three app trees, raw bytes keyed by destination path (D3). */
77
+ /** The reason a boot file is skipped on a site whose `database/` is still the copied package (#9569 DD8). */
78
+ const DATABASE_PACKAGE_GUARD = "database/ is still a package here — convert it to the thin consumer first";
79
+ /**
80
+ * Every file under `templatesDir`'s three app trees, plus each of the
81
+ * `DATABASE_BOOT_FILES` (#9569 DD8) and `ROOT_TOOL_FILES` (#9654) present
82
+ * there, raw bytes keyed by destination path (D3).
83
+ */
64
84
  function walkLocalTemplates(templatesDir) {
65
85
  const out = new Map();
86
+ for (const boot of [...DATABASE_BOOT_FILES, ...ROOT_TOOL_FILES]) {
87
+ const abs = join(templatesDir, ...boot.split("/"));
88
+ if (existsSync(abs))
89
+ out.set(boot, readFileSync(abs));
90
+ }
66
91
  for (const app of ["web", "api", "mcp"]) {
67
92
  const root = join(templatesDir, "apps", app);
68
93
  if (!existsSync(root))
@@ -180,6 +205,537 @@ function importedHeldFiles(fromPath, text, held) {
180
205
  }
181
206
  return [...out];
182
207
  }
208
+ // ── The MCP move (#9567): a copied apps/mcp becomes the boot set ──────────
209
+ const MCP_SERVER_PACKAGE = "@working-theory/mcp-server";
210
+ const MCP_PACKAGE_JSON = "apps/mcp/package.json";
211
+ const MCP_SRC = "apps/mcp/src";
212
+ /** The boot set (#9460 DD2): all `apps/mcp/src` holds after the move. */
213
+ const MCP_BOOT_SET = new Set([
214
+ `${MCP_SRC}/index.ts`,
215
+ `${MCP_SRC}/app.ts`,
216
+ `${MCP_SRC}/site.ts`,
217
+ MCP_SEAM_PATH,
218
+ PAID_MCP_TOOLS_PATH,
219
+ ]);
220
+ /**
221
+ * The paid tool files a module bundle delivered before #9460 (DD5) — never
222
+ * recorded, so the move names them. Their packages now ride
223
+ * `apps/mcp/package.json`. Frozen as of #9460; never extend: no bundle
224
+ * delivers a file under `apps/mcp/src` any more.
225
+ */
226
+ const BUNDLED_MCP_TOOLS = new Set([
227
+ "agent_context",
228
+ "create_booking",
229
+ "get_event_meta",
230
+ "get_flow",
231
+ "inbox_applications",
232
+ "inbox_messages",
233
+ "inbox_submissions",
234
+ "list_availability",
235
+ "list_meetings",
236
+ "person_notes",
237
+ "proposals",
238
+ "submit_flow_step",
239
+ ].map((name) => `${MCP_SRC}/tools/${name}.ts`));
240
+ /**
241
+ * The sha256 of every `apps/mcp/src` file a create-ailk template shipped
242
+ * before #9460 — the published tarballs 0.1.0 to 0.24.0, each one a blob in
243
+ * git history before the #9460 merge (#9654). A file under `apps/mcp/src`
244
+ * whose bytes hash into this set is a template copy, never a site edit, so
245
+ * the move removes it even where the record names another copy or none.
246
+ * Frozen as of #9460; never extend: no template ships a server file under
247
+ * `apps/mcp/src` any more.
248
+ */
249
+ const PRIOR_MCP_TEMPLATE_HASHES = new Set([
250
+ "02789f25139dd78952a77c2d6f7a7057d73d18cdf45845913ad4d35964ad0e16",
251
+ "035a4f5eda5d7a00046f6f3446100dd1e34f85f894f000b04a931e094799c03e",
252
+ "06fe9518a954091284571ec253abea979c738ee3556b73f8993c759607eb3c4b",
253
+ "0702b6d5012dab15d4030be01923ed8da8b0a237028e6c88053c8fdcee63e155",
254
+ "09fedce92b189911964733f6a2535d0d3b0f0104ac18a1ff76abf5fd96261922",
255
+ "0d42d4c17a35867245fc86c48efa5b6dd2c0f89a03c564f68b7661cde98dddf4",
256
+ "0dc43a72c6d2fd1a5f36f037d9b01abcb9a11d1653a04fb033b5b6b223fcfbd8",
257
+ "0fb7cd858e7cd3c1f8757824184519f2494f9c12ec49290d7b97ee7656a7f405",
258
+ "115ac6b648a45e5e1b22193097e92a8ee4da844be5853ca202cb624651ef4c56",
259
+ "16cefcfebbcadb2505b8d8253c853b2d2098209fa4bac84fe39dc7f6b38c02c3",
260
+ "16eaefbceb5edcc3a8039d8ef55776d1a1e317521ecca17386673b87852c4099",
261
+ "17c6e5115ba947d53dcbb632990f6b66d570ea1657d022c51bf62e09c0b58194",
262
+ "17cc5d3eed8849a33f2eebd0d12ffa72c9ffebcccf5a4818aaf8f94fca05aa0f",
263
+ "18185d6f4e4777a7b0856a971c509ce0e094f8ccb8206eb6a1e78d38030c3763",
264
+ "1c5f0f0cdd304b3aff3934e6f0878adb18fc6555be030cb81e3d4a0764d65c43",
265
+ "1d328a242845e31426f28c33d58bf5be7be76f526e066858f77916ef2b28af41",
266
+ "1d5810272869e6a2f66941f862ec7c39a54af82e13ff33d4bff4a19e0d52f1a4",
267
+ "1ddc5b3a79b4a6453a0ac1f6e60ef3463b58221fb5ee313d52c57e9928ea8cdc",
268
+ "2131309a986b964e99a9a9589a0c236d5d830b14d66653e2008289eae2e2cf94",
269
+ "21cd9825d4b7ae057c10b5ca7d01c83387be20be66bf8c38814e7db592a7517e",
270
+ "21d28634fc19f15389ec99a3e6005490faff1c1d364bc7bd3a1f387edab09434",
271
+ "22c245c92b973d86f425b934bd65229c0017801e738a80db19aa0a174d7142c0",
272
+ "23d1318bb8b9aaf489c62ce667d8ba56110f48c8b7c401713a3ac4849c0978bb",
273
+ "2d901fec3ca30024d39274b9dc27156b4d366c86a5c3fb2897a8ca9b97b6d2d9",
274
+ "2dfe47a0e1d6904b5b183fc4aeb067e492127f3ee39058677895a9cc5e270b9e",
275
+ "2eeb3c272e60e1dbf87f868fecac8526f265a4f5327afbeb5ee4c3ecebb848db",
276
+ "3110e5b85f764e39e0e9c7164290cd62a1be51b90e49ed38611a004143a6b130",
277
+ "31afce85a1982d17c9e1d8069e54913b0bdb295010104541ea04b061084b314e",
278
+ "36bc7bea57167851ae81b4baa57daee2fad4f2db9b96b730a72e2ca0c69d75b7",
279
+ "38fab15821f26449c149c12851ff7a857db89d55c4722f797b15274e31a4a4bf",
280
+ "39ef3340a53926a8e8dd77f78924d1975fa5284ab7ae2b99bb8602b20bb7e7a8",
281
+ "3bb46c8ea91349d7551a66c13462f99910ead5b813f0aa51a1b7ab1671f3576a",
282
+ "3cc84368f3eaaf7e875a145fabf7ac644ee4ef1fa785cf548c9639a69985661e",
283
+ "40a538c6a84a95690dc810a5249b74e67c234fc5cf4f6cc6476d7961f67ecbdd",
284
+ "426e33baaeed2bb51a720fce286dba4da00d94418d3554c628c87b3d14e03116",
285
+ "428c570d20f07c9069578c8729c2dcf7eb6eab3b956f8c20eccbabae2f518272",
286
+ "436fc6ed239cf5b4612ee4dbf102debaf5384a3872a30a834d1042e521e318f3",
287
+ "443a31b8af758901d5685134d5046cf4880b534268a9e9cc2ea85185cb5f54ee",
288
+ "443c60fd527c7703b5f3af9ad9b6efd49c359fdde717228254961ea9e7815117",
289
+ "4b28c6e6a6799eb9548720a9f16bafd93a15baa04cacbec950c23e2e5be0f1aa",
290
+ "4b8e654da8220df69a4c4457c1527c2bea9f5aed73d67458c4ce2a14f1b87e8f",
291
+ "4d01e1fcdda1f941789894a6a54d2940f47096c39f37609a5e908c0aa84789db",
292
+ "52583caf9f8946c36133949278449dceeb0ac8f74360534ca91b96938d80446c",
293
+ "5364243db73f8687c1c0ec9cc2516e95efb43a756e295ae8b6469fd55f940649",
294
+ "578dd3161d2dc283011a069a4d426037ba665f0f787a317779115b570a74269f",
295
+ "59882d160c82e5be765102c13dd3c05fbd7e48673408f89c194c8e021ae29797",
296
+ "5ae7a51f8d439d331c5a02229b4109daa5299de6c12d821b78bbc14feda8413f",
297
+ "5ed07e4eed1e6cc7d19185669a14b8df974ea640d283676f33f4db8566fb8cdc",
298
+ "5f60e2bd4fb529c02e195b1aef3bf2ebfa55db05212ae9888e265f3f2f9fade8",
299
+ "6022594cc246c8f3453935781607fa3750b7c8e5b29fab9c841f13364cc9d08a",
300
+ "60b1ed4e37ecc2e045726f2fd93ef90cc9dea33718532a90e365d6d64d803047",
301
+ "659248c6e0c85075142c6a86395fb2b6b2bdf36895dfb2aeb5ab5e044528f11b",
302
+ "66d95e135f59ff1ccdcf3480bd22eac81a559ef0a4439d9a34ce6c25a6885ada",
303
+ "68976a1295acc8ed025a8a3ab30d78492c7e40e4320ac5acecc53f9e7f2aa04f",
304
+ "69cebf99ae494a0fd06b4b9408587f230def919dceb4fbcf3ef950f243bbf486",
305
+ "6b919aa697e9785f175201193e498b17b6c64ffe08c34a9a3ff728d660aa68cf",
306
+ "6da43872f0bee03f3028183795d41ea257c6102928175efe162ffb0fd37849c8",
307
+ "6e86925727a045268249248e9dffd7e8869f2604af43fda27c8acf75982988de",
308
+ "6e8f01a9c1f20f580e2dec7fe8a4c811ffd88621612aac03604aedeaeb9b7c90",
309
+ "715ed89d03445103ca05c0686c8f6fc7cef0c61b18767c285777bb65122fa81a",
310
+ "74a2c97adba8e0390a281fddbc5dce3ec7f9e97577b2fcb9abcf0bdcee01b63c",
311
+ "75abc78c74f28259d817cf159b3969c548395131de6255978b9df4d275aa1544",
312
+ "77d1aacb454904eded6d9a043de7f95922d53bae9693df48b106a74de7405e98",
313
+ "78826164442493682a624ba492f6e39b3479208d93a7aa2fdfca70005333255f",
314
+ "792e6b2cf89272fe9860d585a23687e14881533f3644dd5b1e8e30ea89e6f4a2",
315
+ "7afb50314471ab4e8f31099db49e29a96e56efd83ba960a42732e177654c874d",
316
+ "7b7d5053aaa6358eb66042cfca9e2fe6280d354e23a303c129f08a413bf94c4c",
317
+ "7ed1787f0d71fceb92fb687a8d4e6a5ffc49896ee586303b4311035ba60ba2d2",
318
+ "81dd15a6b1479896458106b946edc0ac76f6c0acf4d525307b092ed11d2f4596",
319
+ "83eaa71438882dde8edf0d7978644a93c802a08a50804f5b2c62d01eaeb4edc9",
320
+ "8441a52d587584cccd6f1fbe3ba5204c9c49a9c6d452d9f844d34dcc0448ad76",
321
+ "847d648346ea4bd0d2f349399527f5a907e05367c6764696b724f3382090089e",
322
+ "85df33660e2291ffe1e77b7103e4705c31b93dd7a294872b6c0fca52a3bd3079",
323
+ "8a9eea9c23a94ff9df729a4aa423e62b02c0632e398bf01524f1caeed61944b9",
324
+ "8e7d112d48976c7ae66203b6c45e8c20708f60a4486411a30af7857e214b8d27",
325
+ "91945c6e325758d09d7f70586f63bda0758f187247e4a8cfab05d9ed45c1e25b",
326
+ "960723d00c54a88af4142cde66b77c5e70cd3b39f59dce462fdf8d153846a9cf",
327
+ "9623a2f691777ea1fea280782240837b24b8202082bf98dbaa2ea48c670774b8",
328
+ "9ebfb38044ad35af8156803be6bb975a7c6b1624fa511037d56beb7b9e0d3579",
329
+ "9ede34ab75c67dc0fe134d7bf64d040e250cec85111ef9fb11be745af5e90277",
330
+ "a03fd2d78e6e4982209e193ad27f0732035c2c2eb5edfcdd8e3093a42e5334a4",
331
+ "a14cf80e8cfc09105cd856bc5723a4b1a231f6ad8f08e5a443360c480a6b483b",
332
+ "a17f89416b31fb883dc9a5c389b021332b2b40e5052fe344e1aec96872475d5f",
333
+ "a20b034a648c2b9daaf3ca817a2229ce7e0136b0fc7487c7fed5fe0cdf1e9e7b",
334
+ "a4495346b79124d1b17f6082f0c1f1f99d3845f4f98cfde83543f2eadf600666",
335
+ "a6d6d6be76cff255bbf77d529dee8775817dae75725bf24964febbbc7cf8d508",
336
+ "a7421e1949c4f3671cfb0d758fecb3b87aab3df03d0feaed0259443ebb2a4353",
337
+ "ac7cd310467561330d3cc2914fd29c9a16ecd27d7f8413dd1120e28ce9ee3ad7",
338
+ "add424a2fbb1027d67270dca6e5e1e0e384dd37a729ba5c091022bc30b3d85c1",
339
+ "af5c4f3113285a137019f7bcbb905c04f0de3b6917d709a0fc8df3f0f39beda9",
340
+ "b0c8bc973e3b9f7fdaf95cb02ca111cb685db2ac98559c859071b4f26f600bf4",
341
+ "b455cd835c1769af463b4ebd91fa6716effbad6f8210df12d47637977b34c6e2",
342
+ "b7140dd15cac5f55309991e7ce1b438a9514a4b289c9ef807f75ed576246fc26",
343
+ "b7198546881c491e233018dadd3fbdb6378694e8a15b762b56c17a1c61d10c91",
344
+ "b7d1e33111a13249d6bc4d0a9334074430bc94f1a0c79d94f5c6f5907b76ae30",
345
+ "b9bd1f23c0e84f91cf7d46db46cab4cb1232574b0f6c9d6f5926fa0bab110570",
346
+ "ba7e5b4db4fd020b0aadace2083aacfb9ffafa63465d2026e4a79804eb8cd493",
347
+ "bb321afe40c6d7495676f9157bc80bbab9d5241fa84340133770b1ba3006d166",
348
+ "bced6c526cd757d87b4d725e247497b6e1286192b758421786c645719c3b4dfd",
349
+ "bf398a05bdbdb85a8034ecfd9f4d865587b7d25352a06f3c9f3ca1c0deed6787",
350
+ "bf4a2222b34a4fdabccd696341f6168104d3d7d74df036187347650ecf350d32",
351
+ "c1513e2317857959145d66659c3b147cc885ca46f4c239ed85f52a833d058971",
352
+ "c371bdde5f7ace2448c46a0e009d799bdb90d3351d42131234181d1efd2b486f",
353
+ "c57ccbaddda8c7d538d103c2b2d96889a815cbcc4469f5f6780b0883d99b4006",
354
+ "c5a448c17e6bba3379ee938b17309c02eb851cbf5fb54dcd6ec490503b70b121",
355
+ "c5d35895a261227c6cf537daeac4b24a98d91ea65e8322d7ca5c47d05c83570c",
356
+ "c64f4b1a9dba4d1fa76f8aea664c81e35961dca2e3f44f63a6783f5164951560",
357
+ "c676077b914411e737376f9604087aab67ba2f300aedb99e76a5839f1798827b",
358
+ "ca076f76130bd3e35488bfe23d7f55f1829164a4e09035459f3af2aee1d91ace",
359
+ "ca842e6ec1748a84fa30adde6f93a84e7b98b6211afbb3e7907e9b6b9b65fed2",
360
+ "ce7ada5214b23c595422399fbd10a8e95bb1b9b30a345c2117bf1954cc2163a6",
361
+ "d2b460eee83c40d26db73bded9ad30666fe970eb991c925727eed5e45d1a5cb4",
362
+ "d4cba3c71603c40bf0a8b6e1643a157e2028d3743b238fb932e059381a17deb9",
363
+ "d5fcd1015582870231c52f490b8daac7a89dbaa2d387f285e118fff98bf7ada2",
364
+ "d96ff716399aca50bd6f5c43bb37721e2d4cbb43793a453119f6e15e6eeca34b",
365
+ "da75ba145c8142544d6211b4eaba8485549511766e2c0d248ac2308b502cf986",
366
+ "dfbcfe0f30c6079153b5ab51096ef106716a713a7d6169b2ec00840423640560",
367
+ "e1945e3ff2b6d806fc459c90d0253ca71f2adac5bedc6c578ca21506f9dc094a",
368
+ "e43789a019a1c487b42cc785175f0b08b36a7e4f5ae72e40a6c1835f9d02b2d6",
369
+ "e482750dfb358f78b1142a8707cb007cc7a5e5c863614b05d0289f4843d10b6f",
370
+ "e4948f0dadc17dcae583e2d8732a1e95c8268d4e5bf68bc38e97e05a251b9fcb",
371
+ "e4aff38f30ca76f6da6ec4bf98c71a51d8fc41877ddcf791aeb61fcf34bb44ea",
372
+ "e59294cc6a47cabd5df6ab635dd3748f42610e1691b248d24b8962fc3661df43",
373
+ "e7c7711f3512fdd51bdd175098ffe97c1c4483b4369b2627bbf00eafd65c00af",
374
+ "e7feca03ec0681bee9bba97b9ee5024215899f95aad72cca08c0902b969bee5c",
375
+ "e97b05627ca65f8656167b5ffefb8236cce711173a98430d7ac7f063dc598223",
376
+ "e9ba0a0e497e5d12662a473b81e0cb09f81a094c2763266769e08f5556718f15",
377
+ "e9c9f8d30528a30084e58d41d93d7e4d58d07a4bd8f1e2c1d132c2525669e8a5",
378
+ "ec28dcc626ae59a3c5208f342ba8090c3e8640c6e4930a4b518dfdaa4ccdb773",
379
+ "ef7f59acd7f5de7287681786bb96f1907ac72a9cca7d49732c33320359725ef9",
380
+ "f37c56da121f8cba9c0a55bc69ef701e3d81c63a15f1a9ff354efc4fed58ff39",
381
+ "f562f262c2b26f3e613a50aea737bf7b021d8c4ea9e769ce6b4728675fd68b9e",
382
+ "f6f9e117ab5d1e68b7b99baa30ab822c0126467b8941195a187bf3af20f7faa5",
383
+ "f8d26912ffbc7c1a7b73a0916111aa5c969d98a60b211ff7ca75d8e7828d86c1",
384
+ "f984b95c8a9759cdd988722b7de5be6654c69e0ceb12abc4847115f964087fc0",
385
+ "fc43fb068d3816a65a00144f32ebd3fb077f474090de8c1c99dd77f542c35c43",
386
+ "fdbdd75dc3b798c548ddf28a3c730fa61f64dc1b48d30ff65e190bbc7bb097ba",
387
+ "ffe3db23d21ce93dbb8b832a04318cf23aaa8b1d6db11185ebcf30a634e86e6d",
388
+ ]);
389
+ /** The old hub seam's two relative imports; each is now `MCP_SERVER_HUB` (DD7). */
390
+ const OLD_HUB_SEAM_IMPORTS = ['"./public-workspace.js"', '"./license-key-store.js"'];
391
+ /** Every file under `root`, as `/`-separated paths relative to `targetDir`. */
392
+ function filesUnder(targetDir, root) {
393
+ const out = [];
394
+ const stack = [join(targetDir, ...root.split("/"))];
395
+ for (let dir = stack.pop(); dir !== undefined; dir = stack.pop()) {
396
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
397
+ const abs = join(dir, entry.name);
398
+ if (entry.isDirectory())
399
+ stack.push(abs);
400
+ else if (entry.isFile())
401
+ out.push(abs.slice(targetDir.length + 1).split(sep).join("/"));
402
+ }
403
+ }
404
+ return out.sort();
405
+ }
406
+ /** `pkg` (a parsed package.json) with `entries` merged into `dependencies`, keys sorted. */
407
+ function withDependencies(pkg, entries) {
408
+ const deps = { ...(pkg.dependencies ?? {}), ...entries };
409
+ pkg.dependencies = Object.fromEntries(Object.keys(deps).sort().map((key) => [key, deps[key]]));
410
+ return `${JSON.stringify(pkg, null, 2)}\n`;
411
+ }
412
+ /**
413
+ * `^<version>` per package from the running `versions.json`, for a move of
414
+ * `apps/<app>` to `pkg` (#9567 / #9566). Throws — before any write — naming
415
+ * the first package `versions` lacks.
416
+ */
417
+ function resolveMoveVersions(app, pkg, packages, versions) {
418
+ const entries = {};
419
+ for (const name of packages) {
420
+ const v = versions[name];
421
+ if (v === undefined) {
422
+ throw new UpdateRefusedError(`moving apps/${app} to ${pkg} needs a version for ${name}, and this create-ailk's versions.json has none`);
423
+ }
424
+ entries[name] = `^${v}`;
425
+ }
426
+ return entries;
427
+ }
428
+ /**
429
+ * Every unrecorded file under `src`, sorted into what a move removes and
430
+ * what it lists for review: a `bundled` file (bundle-delivered, never
431
+ * recorded) is removed even at a boot-set path (#9566: the #9564→#9565
432
+ * window's in-app module objects sit where the template's re-exports land);
433
+ * any other boot-set file is left to the record; a file whose bytes hash
434
+ * into `templateCopies` is a prior template copy and is removed (#9654); the
435
+ * rest is reviewed with `reason`, never deleted.
436
+ */
437
+ function classifyUnrecorded(targetDir, src, bootSet, recorded, bundled, reason, templateCopies = new Set()) {
438
+ const deletes = [];
439
+ const review = [];
440
+ for (const path of filesUnder(targetDir, src)) {
441
+ if (recorded.has(path))
442
+ continue;
443
+ if (bundled.has(path)) {
444
+ deletes.push(path);
445
+ continue;
446
+ }
447
+ if (bootSet.has(path))
448
+ continue;
449
+ const hash = sha256Hex(readFileSync(join(targetDir, ...path.split("/"))));
450
+ if (templateCopies.has(hash))
451
+ deletes.push(path);
452
+ else
453
+ review.push({ path, reason });
454
+ }
455
+ return { deletes, review };
456
+ }
457
+ /**
458
+ * The move a site scaffolded before #9460 needs, or `undefined` when its
459
+ * `apps/mcp` already depends on the server. README § "Move an existing
460
+ * site's apps/mcp to this package", steps 1, 5 and 6 — steps 2 to 4 are the
461
+ * record's own rows and the registry write. Throws before any write when
462
+ * `versions` lacks a package the move must declare.
463
+ */
464
+ function planMcpMove(targetDir, modules, hub, recorded, versions) {
465
+ const pkgText = readFileSync(join(targetDir, MCP_PACKAGE_JSON), "utf8");
466
+ let pkg;
467
+ try {
468
+ pkg = JSON.parse(pkgText);
469
+ }
470
+ catch (err) {
471
+ throw new UpdateRefusedError(`${MCP_PACKAGE_JSON} is not valid JSON: ${err.message}`);
472
+ }
473
+ if (Object.hasOwn(pkg.dependencies ?? {}, MCP_SERVER_PACKAGE))
474
+ return undefined;
475
+ const packages = [MCP_SERVER_PACKAGE];
476
+ for (const name of modules) {
477
+ for (const pack of MODULE_SLICES[name].paidMcpToolPackages ?? []) {
478
+ if (!packages.includes(pack))
479
+ packages.push(pack);
480
+ }
481
+ }
482
+ const entries = resolveMoveVersions("mcp", MCP_SERVER_PACKAGE, packages, versions);
483
+ const move = { packageJson: withDependencies(pkg, entries), deletes: [], review: [] };
484
+ const seamPath = join(targetDir, ...MCP_SEAM_PATH.split("/"));
485
+ if (hub && existsSync(seamPath)) {
486
+ const before = readFileSync(seamPath, "utf8");
487
+ let after = before;
488
+ for (const spec of OLD_HUB_SEAM_IMPORTS)
489
+ after = after.split(spec).join(`"${MCP_SERVER_HUB}"`);
490
+ if (after !== before)
491
+ move.seam = after;
492
+ }
493
+ if (!existsSync(join(targetDir, ...MCP_SRC.split("/")))) {
494
+ throw new UpdateRefusedError(`${MCP_PACKAGE_JSON} is present but ${MCP_SRC}/ is not, so apps/mcp cannot be moved to ${MCP_SERVER_PACKAGE}`);
495
+ }
496
+ const unrecorded = classifyUnrecorded(targetDir, MCP_SRC, MCP_BOOT_SET, recorded, BUNDLED_MCP_TOOLS, `not in the boot set apps/mcp/src is since ${MCP_SERVER_PACKAGE} (#9460); move it into a package or delete it`, PRIOR_MCP_TEMPLATE_HASHES);
497
+ move.deletes = unrecorded.deletes;
498
+ move.review = unrecorded.review;
499
+ return move;
500
+ }
501
+ /** Remove every directory under `root` left empty — `root` itself stays. */
502
+ function pruneEmptyDirs(root) {
503
+ for (const entry of readdirSync(root, { withFileTypes: true })) {
504
+ if (!entry.isDirectory())
505
+ continue;
506
+ const abs = join(root, entry.name);
507
+ pruneEmptyDirs(abs);
508
+ if (readdirSync(abs).length === 0)
509
+ rmdirSync(abs);
510
+ }
511
+ }
512
+ // ── The API move (#9566): a copied apps/api becomes the boot file ─────────
513
+ const API_PACKAGE = "@working-theory/api";
514
+ /** The app's name since #9564 D10 — the copied app's `@working-theory/api` would shadow the dependency. */
515
+ const API_APP_NAME = "@working-theory/app-api";
516
+ const API_PACKAGE_JSON = "apps/api/package.json";
517
+ const API_SRC = "apps/api/src";
518
+ /** The boot's module objects, one `apps/api/src/modules/<name>.ts` per `@working-theory/api-<name>` (#9565 D5). */
519
+ const API_MODULES_DIR = `${API_SRC}/modules`;
520
+ /**
521
+ * The scripts #9564 D9 retargets at the installed package: the four base
522
+ * bins run its compiled `dist/bin/<name>.js`, and `build:vercel` builds the
523
+ * renamed app. `db:*`, `dev`, `start` and the module bins stay as the site
524
+ * has them.
525
+ */
526
+ const API_DELEGATING_SCRIPTS = [
527
+ "abandon:sweep",
528
+ "rate-limit:probe",
529
+ "spokes",
530
+ "stripe-connections:rekey",
531
+ "build:vercel",
532
+ ];
533
+ /**
534
+ * The module files a module bundle delivered under `apps/api/src` before
535
+ * #9565 (D6) — never recorded, so the move names them; their modules now
536
+ * ride `apps/api/package.json` as packages. The pre-#9565 `MODULE_SLICES`
537
+ * `apps/api/` entries at 328494dba, all 144, the six `modules/<name>.ts`
538
+ * among them: between #9564 and #9565 a bundle delivered each module
539
+ * OBJECT in-app, at the very path the template's one-statement re-export
540
+ * now takes, importing the routes beside it — so an unrecorded file there
541
+ * is the old object and goes, and the re-export lands over it. Frozen as of
542
+ * #9565; never extend: no bundle delivers a file under `apps/api/src` any
543
+ * more.
544
+ */
545
+ const BUNDLED_API_FILES = new Set([
546
+ "__tests__/content-write-production-boot.test.ts",
547
+ "__tests__/listings-forwarded-rate-limit.test.ts",
548
+ "__tests__/openapi-keyless-hub.test.ts",
549
+ "__tests__/schedule-forwarded-rate-limit.test.ts",
550
+ "bin/deliverable-resend.ts",
551
+ "bin/deliverable-upload.ts",
552
+ "bin/flows-copy.ts",
553
+ "bin/followup-sweep.ts",
554
+ "bin/listing-csv-sweep.ts",
555
+ "bin/member-request-match.ts",
556
+ "bin/seed-presets.ts",
557
+ "bin/seed-waitlist-experiments.ts",
558
+ "bin/session-retention-sweep.ts",
559
+ "config/__tests__/scheduling-credential-key.test.ts",
560
+ "lib/asset-store.ts",
561
+ "lib/member-request-match.ts",
562
+ "lib/public-meetings-config.ts",
563
+ "lib/ws-token.ts",
564
+ "modules/commerce.ts",
565
+ "modules/content-write.ts",
566
+ "modules/multi-tenant.ts",
567
+ "modules/scheduling.ts",
568
+ "modules/signal-collectors.ts",
569
+ "modules/workspace.ts",
570
+ "routes/assets/index.ts",
571
+ "routes/assets/manage.ts",
572
+ "routes/assets/read.ts",
573
+ "routes/assets/upload.ts",
574
+ "routes/billing/index.ts",
575
+ "routes/billing/portal.ts",
576
+ "routes/billing/read.ts",
577
+ "routes/billing/stripe-connection.ts",
578
+ "routes/billing/stripe-products.ts",
579
+ "routes/billing/usage.ts",
580
+ "routes/consent/platform.ts",
581
+ "routes/deliverables/index.ts",
582
+ "routes/flow-checkouts/index.ts",
583
+ "routes/flows/README.md",
584
+ "routes/flows/index.ts",
585
+ "routes/flows/recommender.ts",
586
+ "routes/magnets/index.ts",
587
+ "routes/member/appointments.ts",
588
+ "routes/member/artifact-review.ts",
589
+ "routes/member/artifacts.ts",
590
+ "routes/member/availability.ts",
591
+ "routes/member/billing.ts",
592
+ "routes/member/bookings.ts",
593
+ "routes/member/consents.ts",
594
+ "routes/member/deletion-request.ts",
595
+ "routes/member/meeting-types.ts",
596
+ "routes/member/messages.ts",
597
+ "routes/member/onboarding.ts",
598
+ "routes/member/pieces.ts",
599
+ "routes/member/profile.ts",
600
+ "routes/member/purchases.ts",
601
+ "routes/member/request-form.ts",
602
+ "routes/member/requests.ts",
603
+ "routes/project-listings/__tests__/directory.test.ts",
604
+ "routes/project-listings/get.ts",
605
+ "routes/project-listings/list.ts",
606
+ "routes/project-listings/patch.ts",
607
+ "routes/schedule/__tests__/appointments.test.ts",
608
+ "routes/schedule/__tests__/meeting-types.test.ts",
609
+ "routes/schedule/__tests__/meetings.test.ts",
610
+ "routes/schedule/__tests__/public-connection.test.ts",
611
+ "routes/schedule/__tests__/spoke.test.ts",
612
+ "routes/schedule/appointments.ts",
613
+ "routes/schedule/index.ts",
614
+ "routes/schedule/meeting-types.ts",
615
+ "routes/slack/actions.ts",
616
+ "routes/slack/index.ts",
617
+ "routes/subscription/index.ts",
618
+ "routes/subscription/me.ts",
619
+ "routes/subscription/portal.ts",
620
+ "routes/waitlist-experiments/comparison.ts",
621
+ "routes/waitlist-experiments/index.ts",
622
+ "routes/waitlist-experiments/list.ts",
623
+ "routes/waitlist-experiments/respond.ts",
624
+ "routes/waitlist-experiments/signup.ts",
625
+ "routes/waitlist-experiments/signups.ts",
626
+ "routes/waitlist-signups/index.ts",
627
+ "routes/webhooks/__tests__/calcom-connection.test.ts",
628
+ "routes/webhooks/__tests__/calcom.test.ts",
629
+ "routes/webhooks/calcom.ts",
630
+ "routes/workspaces/__tests__/meetings-connection.test.ts",
631
+ "routes/workspaces/__tests__/meetings.test.ts",
632
+ "routes/workspaces/agents.ts",
633
+ "routes/workspaces/callbacks.ts",
634
+ "routes/workspaces/config.ts",
635
+ "routes/workspaces/content.ts",
636
+ "routes/workspaces/general.ts",
637
+ "routes/workspaces/index.ts",
638
+ "routes/workspaces/meetings.ts",
639
+ "routes/workspaces/members.ts",
640
+ "routes/workspaces/messages-out.ts",
641
+ "routes/workspaces/messages.ts",
642
+ "routes/workspaces/offerings.ts",
643
+ "routes/workspaces/orders.ts",
644
+ "routes/workspaces/people.ts",
645
+ "routes/workspaces/pieces.ts",
646
+ "routes/workspaces/plan.ts",
647
+ "routes/workspaces/requests.ts",
648
+ "routes/workspaces/sessions.ts",
649
+ "routes/workspaces/submissions.ts",
650
+ "routes/workspaces/subscribers.ts",
651
+ "routes/workspaces/trial.ts",
652
+ "services/__tests__/lead-promotion.test.ts",
653
+ "services/__tests__/leads-inbox.test.ts",
654
+ "services/flow-aggregate.ts",
655
+ "services/flow-checkouts.ts",
656
+ "services/flow-copy.ts",
657
+ "services/flow-engine.ts",
658
+ "services/inbox-messages.ts",
659
+ "services/inbox-orders.ts",
660
+ "services/inbox-submissions.ts",
661
+ "services/listing-csv-sweep.ts",
662
+ "services/listing-promotion.ts",
663
+ "services/playbook-compile.ts",
664
+ "services/playbook-render.ts",
665
+ "services/project-listing-decision.ts",
666
+ "services/project-listing-flow.ts",
667
+ "services/project-listing-issue.ts",
668
+ "services/proposal-payments.ts",
669
+ "services/recommender-capture.ts",
670
+ "services/scheduling/__tests__/appointments.test.ts",
671
+ "services/scheduling/__tests__/cal-provider.test.ts",
672
+ "services/scheduling/__tests__/connections.test.ts",
673
+ "services/scheduling/__tests__/meetings.test.ts",
674
+ "services/scheduling/__tests__/provider-resolution.test.ts",
675
+ "services/scheduling/appointments.ts",
676
+ "services/scheduling/cal-provider.ts",
677
+ "services/scheduling/connections.ts",
678
+ "services/scheduling/index.ts",
679
+ "services/scheduling/meetings.ts",
680
+ "services/scheduling/resolve.ts",
681
+ "services/scheduling/types.ts",
682
+ "services/subscription.ts",
683
+ "services/trial.ts",
684
+ "services/waitlist-dashboard.ts",
685
+ "services/waitlist-experiments.ts",
686
+ "services/waitlist-followup.ts",
687
+ "services/waitlist-operator-reads.ts",
688
+ "services/waitlist-scoring.ts",
689
+ "services/waitlist-signups.ts",
690
+ ].map((path) => `${API_SRC}/${path}`));
691
+ /**
692
+ * The move a site scaffolded before #9565 needs, or `undefined` when its
693
+ * `apps/api` already depends on the package AND all six module packages. A
694
+ * site from before #9564 lacks all seven; one scaffolded in the #9564→#9565
695
+ * window depends on the package but carries the six module objects in-app
696
+ * (bundle-delivered, unrecorded) and lacks their packages — either is the
697
+ * move. The boot files, the module objects and the copied server files are
698
+ * the record's own rows (the running template's `apps/api/src` IS the boot
699
+ * set); this plans what the record cannot see. Throws before any write when
700
+ * `versions` lacks a package the move must declare.
701
+ */
702
+ function planApiMove(targetDir, templatesDir, bootSet, recorded, versions) {
703
+ const pkgText = readFileSync(join(targetDir, API_PACKAGE_JSON), "utf8");
704
+ let pkg;
705
+ try {
706
+ pkg = JSON.parse(pkgText);
707
+ }
708
+ catch (err) {
709
+ throw new UpdateRefusedError(`${API_PACKAGE_JSON} is not valid JSON: ${err.message}`);
710
+ }
711
+ const modulesDir = join(templatesDir, ...API_MODULES_DIR.split("/"));
712
+ const packages = [
713
+ API_PACKAGE,
714
+ ...(existsSync(modulesDir) ? readdirSync(modulesDir) : [])
715
+ .filter((file) => file.endsWith(".ts"))
716
+ .map((file) => `${API_PACKAGE}-${file.slice(0, -".ts".length)}`),
717
+ ];
718
+ const deps = pkg.dependencies ?? {};
719
+ if (packages.every((name) => Object.hasOwn(deps, name)))
720
+ return undefined;
721
+ const entries = resolveMoveVersions("api", API_PACKAGE, packages, versions);
722
+ if (pkg.name === API_PACKAGE)
723
+ pkg.name = API_APP_NAME;
724
+ const templateScripts = JSON.parse(readFileSync(join(templatesDir, ...API_PACKAGE_JSON.split("/")), "utf8")).scripts ?? {};
725
+ for (const key of API_DELEGATING_SCRIPTS) {
726
+ const script = templateScripts[key];
727
+ if (script !== undefined)
728
+ (pkg.scripts ??= {})[key] = script;
729
+ }
730
+ const move = { packageJson: withDependencies(pkg, entries), deletes: [], review: [] };
731
+ if (!existsSync(join(targetDir, ...API_SRC.split("/")))) {
732
+ throw new UpdateRefusedError(`${API_PACKAGE_JSON} is present but ${API_SRC}/ is not, so apps/api cannot be moved to ${API_PACKAGE}`);
733
+ }
734
+ const unrecorded = classifyUnrecorded(targetDir, API_SRC, bootSet, recorded, BUNDLED_API_FILES, `not in the boot file apps/api/src is since ${API_PACKAGE} (#9564); move it into a package or delete it`);
735
+ move.deletes = unrecorded.deletes;
736
+ move.review = unrecorded.review;
737
+ return move;
738
+ }
183
739
  export async function updateSite(opts) {
184
740
  const targetDir = resolve(opts.targetDir);
185
741
  const version = opts.version;
@@ -252,7 +808,13 @@ export async function updateSite(opts) {
252
808
  const spokeExclusionList = spoke !== undefined ? spokeExclusions(opts.templatesDir, spoke) : undefined;
253
809
  // #8748 D3 — the standard spoke checkout is a commerce spoke's alone.
254
810
  const sellsAsSpoke = spoke !== undefined && header.modules.includes("commerce");
811
+ // #9569 DD8 — a `database/` that is still a package (the pre-thin copy) is
812
+ // never touched: its boot paths are out of scope, reported under the guard.
813
+ const databaseIsPackage = existsSync(join(targetDir, "database", "package.json"));
814
+ const bootFileGuarded = (destRel) => databaseIsPackage && DATABASE_BOOT_FILES.includes(destRel);
255
815
  const outOfScope = (destRel) => {
816
+ if (bootFileGuarded(destRel))
817
+ return true;
256
818
  if (isExcluded(destRel, excludedRoutes))
257
819
  return true;
258
820
  if (!sellsAsSpoke && isExcluded(destRel, SPOKE_CHECKOUT_TEMPLATE_PATHS))
@@ -292,6 +854,15 @@ export async function updateSite(opts) {
292
854
  return result;
293
855
  }
294
856
  // ── The backfill: fetch the old base and build the synthetic record ──
857
+ // Every in-scope snapshot path gets a row at the snapshot's hash, present
858
+ // on disk or not (#9527): an absent one then reads as "deleted locally"
859
+ // on this run and every later one, exactly as a scaffold-written row
860
+ // whose file the owner removed — never as a new template file to add —
861
+ // and a copy the owner later restores from the snapshot reads as
862
+ // untouched. Out-of-scope paths (rules i/ii) stay unrecorded. The absent
863
+ // rows also feed `knownPaths` on every later run, so a new template file
864
+ // under an absent recorded directory is never added — the same reading as
865
+ // "the owner deleted that directory" (rule iii).
295
866
  let knownSnapshotPaths;
296
867
  if (backfillPatternVersion !== undefined) {
297
868
  const base = await loadVersionMap(backfillPatternVersion);
@@ -303,19 +874,47 @@ export async function updateSite(opts) {
303
874
  for (const [path, bytes] of [...base.entries()].sort(([a], [b]) => a.localeCompare(b))) {
304
875
  if (outOfScope(path))
305
876
  continue;
306
- if (!existsSync(join(targetDir, ...path.split("/"))))
307
- continue;
308
877
  files[path] = { sha256: sha256Hex(bytes), version: backfillPatternVersion };
309
878
  }
310
879
  record = { schema: 1, projectName: record.projectName, files };
311
880
  }
881
+ // ── The MCP move (#9567), planned before the first write ──────────────
882
+ // A site scaffolded before #9460 carries the server under apps/mcp/src and
883
+ // no @working-theory/mcp-server dependency. Its recorded copies the running
884
+ // template no longer has fall out through the rows below — removed when
885
+ // untouched, reviewed when edited — and index.ts, app.ts and site.ts arrive
886
+ // as any template change does. The rest is planned here: the dependency
887
+ // and each carried module's paid pack, the hub seam's two imports, and the
888
+ // bundle-delivered paid tools the record never saw. A `--without-mcp`
889
+ // spoke has no apps/mcp and plans nothing.
890
+ const mcpPkgPath = join(targetDir, ...MCP_PACKAGE_JSON.split("/"));
891
+ const mcpMove = existsSync(mcpPkgPath)
892
+ ? planMcpMove(targetDir, header.modules, spoke === undefined, new Set(Object.keys(record.files)), opts.versions ?? {})
893
+ : undefined;
894
+ // ── The API move (#9566), planned before the first write ──────────────
895
+ // A site scaffolded before #9564 carries the server under apps/api/src, an
896
+ // apps/api still named @working-theory/api and no @working-theory/api
897
+ // dependency. The running template's apps/api/src is the boot set: its
898
+ // recorded copies the template no longer has fall out through the rows
899
+ // below, and server.ts, index.ts and the six module objects arrive as any
900
+ // template change does. Planned here: the rename, the package and the six
901
+ // module packages (the boot passes all six on every boot, #9565 D5), the
902
+ // delegating scripts (#9564 D9) and the bundle-delivered module files the
903
+ // record never saw. A spoke has no apps/api and plans nothing.
904
+ const apiPkgPath = join(targetDir, ...API_PACKAGE_JSON.split("/"));
905
+ const apiMove = existsSync(apiPkgPath)
906
+ ? planApiMove(targetDir, opts.templatesDir, new Set([...newMap.keys()].filter((path) => path.startsWith(`${API_SRC}/`))), new Set(Object.keys(record.files)), opts.versions ?? {})
907
+ : undefined;
312
908
  // ── Every recorded row (D4) ────────────────────────────────────────────
313
909
  const updated = [];
314
910
  const merged = [];
315
911
  const added = [];
316
912
  const removed = [];
317
913
  const current = [];
318
- const review = [];
914
+ const review = [
915
+ ...(mcpMove?.review ?? []),
916
+ ...(apiMove?.review ?? []),
917
+ ];
319
918
  const skipped = [];
320
919
  const nextFiles = { ...record.files };
321
920
  const writes = [];
@@ -323,12 +922,26 @@ export async function updateSite(opts) {
323
922
  for (const path of Object.keys(record.files).sort()) {
324
923
  const rec = record.files[path];
325
924
  if (outOfScope(path)) {
326
- skipped.push({ path, reason: "outside this site's scope" });
925
+ skipped.push({
926
+ path,
927
+ reason: bootFileGuarded(path) ? DATABASE_PACKAGE_GUARD : "outside this site's scope",
928
+ });
327
929
  continue;
328
930
  }
329
931
  const abs = join(targetDir, ...path.split("/"));
330
932
  if (!existsSync(abs)) {
331
- skipped.push({ path, reason: "deleted locally" });
933
+ if (newMap.get(path) === undefined) {
934
+ // Gone here and gone from the template: nothing to keep a row for.
935
+ delete nextFiles[path];
936
+ removed.push(path);
937
+ continue;
938
+ }
939
+ skipped.push({
940
+ path,
941
+ reason: backfillPatternVersion !== undefined
942
+ ? `not in this site; recorded from ${backfillPatternVersion} as deleted locally`
943
+ : "deleted locally",
944
+ });
332
945
  continue;
333
946
  }
334
947
  const diskBytes = readFileSync(abs);
@@ -352,6 +965,15 @@ export async function updateSite(opts) {
352
965
  }
353
966
  // Edited.
354
967
  if (newBytes === undefined) {
968
+ // #9654 — the bytes are a pre-#9460 template copy, just not the one
969
+ // the row names: not an edit, so it is retired as an untouched copy
970
+ // is, on the move's run or any later one.
971
+ if (path.startsWith(`${MCP_SRC}/`) && PRIOR_MCP_TEMPLATE_HASHES.has(diskHash)) {
972
+ deletes.push(path);
973
+ delete nextFiles[path];
974
+ removed.push(path);
975
+ continue;
976
+ }
355
977
  review.push({ path, reason: `edited here, removed from the template in ${version}` });
356
978
  continue;
357
979
  }
@@ -421,17 +1043,38 @@ export async function updateSite(opts) {
421
1043
  }
422
1044
  }
423
1045
  // ── Every recordable path the running template has that this record does not (D4) ──
1046
+ // A path the API move retires (#9566) reads as absent: the old in-app
1047
+ // module object at a boot-set path goes before the writes below, and the
1048
+ // template's re-export lands there as an added file.
1049
+ const retired = new Set(apiMove?.deletes ?? []);
424
1050
  const knownPaths = new Set([...Object.keys(record.files), ...(knownSnapshotPaths ?? [])]);
425
1051
  for (const path of [...newMap.keys()].sort()) {
426
1052
  if (Object.prototype.hasOwnProperty.call(record.files, path))
427
1053
  continue;
1054
+ // The guard runs before the disk check, so a full-copy site's boot path
1055
+ // reads as guarded, never as "exists, not in the record" (#9569 DD8).
1056
+ if (bootFileGuarded(path)) {
1057
+ skipped.push({ path, reason: DATABASE_PACKAGE_GUARD });
1058
+ continue;
1059
+ }
428
1060
  const abs = join(targetDir, ...path.split("/"));
429
1061
  const newBytes = newMap.get(path);
430
- if (existsSync(abs)) {
1062
+ if (existsSync(abs) && !retired.has(path)) {
431
1063
  const diskBytes = readFileSync(abs);
432
- if (sha256Hex(diskBytes) !== sha256Hex(newBytes)) {
1064
+ const newHash = sha256Hex(newBytes);
1065
+ if (sha256Hex(diskBytes) !== newHash) {
433
1066
  skipped.push({ path, reason: "exists, not in the record" });
434
1067
  }
1068
+ else if (DATABASE_BOOT_FILES.includes(path) || ROOT_TOOL_FILES.includes(path)) {
1069
+ // Adoption (#9569 DD8): a thin site converted by hand, or scaffolded
1070
+ // before the boot files were recorded, gains the row for a copy that
1071
+ // already equals the running template's — and so (#9654) does a root
1072
+ // tools/ file a site scaffolded before tools/ was recorded, or copied
1073
+ // by hand. App paths keep today's behaviour: an unrecorded, identical
1074
+ // copy stays unrecorded.
1075
+ nextFiles[path] = { sha256: newHash, version };
1076
+ current.push(path);
1077
+ }
435
1078
  continue;
436
1079
  }
437
1080
  if (outOfScope(path))
@@ -493,6 +1136,12 @@ export async function updateSite(opts) {
493
1136
  .sort(([a], [b]) => a.localeCompare(b))
494
1137
  .map(([file, tests]) => ({ file, tests }));
495
1138
  // ── Apply: writes and removals, then the record (D4 Order) ───────────
1139
+ // #9566 — the API move's removals first: a retired file at a boot-set
1140
+ // path is overwritten by the write that follows, never deleted after it.
1141
+ for (const path of apiMove?.deletes ?? []) {
1142
+ rmSync(join(targetDir, ...path.split("/")));
1143
+ removed.push(path);
1144
+ }
496
1145
  for (const write of writes.filter((w) => notHeld(w.path))) {
497
1146
  const abs = join(targetDir, ...write.path.split("/"));
498
1147
  mkdirSync(dirname(abs), { recursive: true });
@@ -524,6 +1173,34 @@ export async function updateSite(opts) {
524
1173
  moved.added.push(MODULE_FLAGS_PATH);
525
1174
  else if (flags === "updated")
526
1175
  moved.updated.push(MODULE_FLAGS_PATH);
1176
+ // #9567 — the MCP move's writes, then the paid MCP tool registry from the
1177
+ // site's own apps/mcp/package.json on every run (REGENERATED_APP_PATHS,
1178
+ // #9460 DD6) — after the move, so a pack the move declared is a row.
1179
+ if (mcpMove !== undefined) {
1180
+ writeFileSync(mcpPkgPath, mcpMove.packageJson);
1181
+ moved.updated.push(MCP_PACKAGE_JSON);
1182
+ if (mcpMove.seam !== undefined) {
1183
+ writeFileSync(join(targetDir, ...MCP_SEAM_PATH.split("/")), mcpMove.seam);
1184
+ moved.updated.push(MCP_SEAM_PATH);
1185
+ }
1186
+ for (const path of mcpMove.deletes) {
1187
+ rmSync(join(targetDir, ...path.split("/")));
1188
+ moved.removed.push(path);
1189
+ }
1190
+ pruneEmptyDirs(join(targetDir, ...MCP_SRC.split("/")));
1191
+ }
1192
+ const registry = writePaidMcpTools(targetDir);
1193
+ if (registry === "added")
1194
+ moved.added.push(PAID_MCP_TOOLS_PATH);
1195
+ else if (registry === "updated")
1196
+ moved.updated.push(PAID_MCP_TOOLS_PATH);
1197
+ // #9566 — the API move's package.json, then the directories its removals
1198
+ // (applied above, before the writes) left empty.
1199
+ if (apiMove !== undefined) {
1200
+ writeFileSync(apiPkgPath, apiMove.packageJson);
1201
+ moved.updated.push(API_PACKAGE_JSON);
1202
+ pruneEmptyDirs(join(targetDir, ...API_SRC.split("/")));
1203
+ }
527
1204
  return {
528
1205
  targetDir,
529
1206
  version,
@@ -576,6 +1253,13 @@ export function formatUpdateReport(result) {
576
1253
  if (nothingHappened) {
577
1254
  return `[create-ailk] Already up to date (create-ailk ${result.version}).\n`;
578
1255
  }
1256
+ // #9567 / #9566 — the MCP and API moves add dependencies (the mcp README
1257
+ // § Move, step 7, names the install; the API half says the same).
1258
+ for (const pkgJson of [MCP_PACKAGE_JSON, API_PACKAGE_JSON]) {
1259
+ if (result.updated.includes(pkgJson)) {
1260
+ lines.push(`${pkgJson} gained dependencies: run \`pnpm install\`.`);
1261
+ }
1262
+ }
579
1263
  return lines.join("\n") + "\n";
580
1264
  }
581
1265
  export const UPDATE_HELP = `create-ailk update — bring template fixes into a site's copied app code.
@@ -591,17 +1275,27 @@ Options:
591
1275
 
592
1276
  Reads .ailk-template-files.json (written beside .ailk-site-manifest.json by
593
1277
  every template scaffold) to tell an untouched copy from an edit. An
594
- untouched apps/web, apps/api or apps/mcp file whose template copy changed is
595
- overwritten. An edited file whose template copy also changed is three-way
596
- merged with \`git\` (git must be on PATH); a conflict leaves the file alone
597
- and is listed under "Needs review". Every template test that imports a file
1278
+ untouched apps/web, apps/api or apps/mcp file, or a root tools/jest file the
1279
+ app jest configs require, whose template copy changed is overwritten. An
1280
+ edited file whose template copy also changed is three-way merged with
1281
+ \`git\` (git must be on PATH); a conflict leaves the file alone and is
1282
+ listed under "Needs review". Every template test that imports a file
598
1283
  left under "Needs review" or "Skipped" (by a relative import) is held at the
599
1284
  site's version with it, its record entry is not advanced, and it is listed
600
1285
  under "Held back with <file>" — reconcile the file, then run update again to
601
1286
  bring its tests forward. Every other file in the run still updates.
602
1287
  A site with no record gets one on its first run, from the version its
603
- .ailk-site-manifest.json already records. Commit before running, and review
604
- the diff after.
1288
+ .ailk-site-manifest.json already records. A site scaffolded before
1289
+ @working-theory/mcp-server has its copied apps/mcp moved to the boot set:
1290
+ the server and each module's paid MCP pack join apps/mcp/package.json, the
1291
+ copied server files go, and apps/mcp/src/lib/paid-tools.generated.ts is
1292
+ rewritten on every run. A site scaffolded before @working-theory/api has its
1293
+ copied apps/api moved to the boot file: the app becomes @working-theory/app-api,
1294
+ the package and the six @working-theory/api-<module> packages join
1295
+ apps/api/package.json, its bins and build:vercel delegate to the package, and
1296
+ the copied server files go. Run \`pnpm install\` after either move, since the
1297
+ app's package.json gained dependencies. Commit before running, and review the
1298
+ diff after.
605
1299
  `;
606
1300
  /** Parse the argv AFTER the `update` word. Strict `node:util` parseArgs, like `parseAdoptArgs`. */
607
1301
  export function parseUpdateArgs(argv) {