create-ailk 0.2.0 → 0.3.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 (273) hide show
  1. package/component-catalog.md +50 -53
  2. package/dist/lib/apply-module-patches.d.ts +47 -0
  3. package/dist/lib/apply-module-patches.js +370 -0
  4. package/dist/lib/extract-module-bundle.d.ts +12 -3
  5. package/dist/lib/extract-module-bundle.js +236 -24
  6. package/dist/lib/fetch-module.d.ts +3 -38
  7. package/dist/lib/fetch-module.js +26 -8
  8. package/dist/lib/module-license-gate.d.ts +2 -0
  9. package/dist/lib/module-license-gate.js +1 -0
  10. package/dist/lib/paid-paths.d.ts +16 -0
  11. package/dist/lib/paid-paths.js +90 -0
  12. package/dist/module-architecture.d.ts +139 -23
  13. package/dist/module-architecture.js +668 -25
  14. package/dist/parse-args.d.ts +2 -2
  15. package/dist/parse-args.js +3 -1
  16. package/dist/programmatic.d.ts +2 -1
  17. package/dist/programmatic.js +15 -4
  18. package/dist/surfaces.d.ts +12 -36
  19. package/dist/surfaces.js +35 -5
  20. package/dist/sync-routes.js +31 -1
  21. package/package.json +2 -2
  22. package/templates/.claude/agents/web.md +2 -3
  23. package/templates/.claude/rules/architecture.md +5 -5
  24. package/templates/.claude/skills/README.md +2 -1
  25. package/templates/.env.example +21 -9
  26. package/templates/CONVENTIONS.md +6 -7
  27. package/templates/apps/api/.env.example +9 -0
  28. package/templates/apps/api/CLAUDE.md +33 -5
  29. package/templates/apps/api/package.json +0 -1
  30. package/templates/apps/api/src/__tests__/cors.test.ts +195 -0
  31. package/templates/apps/api/src/__tests__/module-exclusion.test.ts +60 -2
  32. package/templates/apps/api/src/__tests__/vercel-handler.test.ts +159 -0
  33. package/templates/apps/api/src/config/__tests__/modules.test.ts +76 -0
  34. package/templates/apps/api/src/config/index.ts +19 -0
  35. package/templates/apps/api/src/config/modules.ts +12 -14
  36. package/templates/apps/api/src/lib/__mocks__/prisma.ts +3 -0
  37. package/templates/apps/api/src/lib/__tests__/slice-load.test.ts +89 -0
  38. package/templates/apps/api/src/lib/slice-load.ts +90 -0
  39. package/templates/apps/api/src/openapi/__tests__/openapi.test.ts +52 -32
  40. package/templates/apps/api/src/openapi/__tests__/spec-identity.test.ts +182 -0
  41. package/templates/apps/api/src/openapi/__tests__/surface-drift.test.ts +293 -0
  42. package/templates/apps/api/src/openapi/index.ts +9 -3
  43. package/templates/apps/api/src/openapi/spec.ts +505 -65
  44. package/templates/apps/api/src/openapi/surface-drift.ts +195 -0
  45. package/templates/apps/api/src/routes/content/__tests__/create.test.ts +14 -0
  46. package/templates/apps/api/src/routes/content/__tests__/delete.test.ts +14 -0
  47. package/templates/apps/api/src/routes/content/__tests__/update.test.ts +14 -0
  48. package/templates/apps/api/src/routes/content/index.ts +38 -11
  49. package/templates/apps/api/src/routes/project-listings/__tests__/configured-application.test.ts +17 -0
  50. package/templates/apps/api/src/routes/project-listings/__tests__/drafts.test.ts +17 -0
  51. package/templates/apps/api/src/routes/project-listings/__tests__/founder-identity.test.ts +796 -0
  52. package/templates/apps/api/src/routes/project-listings/__tests__/me.test.ts +10 -0
  53. package/templates/apps/api/src/routes/project-listings/__tests__/public.test.ts +38 -0
  54. package/templates/apps/api/src/routes/project-listings/__tests__/resume-email.test.ts +814 -0
  55. package/templates/apps/api/src/routes/project-listings/__tests__/site-answers.test.ts +10 -0
  56. package/templates/apps/api/src/routes/project-listings/__tests__/site-key.test.ts +24 -0
  57. package/templates/apps/api/src/routes/project-listings/__tests__/structured-address.test.ts +17 -0
  58. package/templates/apps/api/src/routes/project-listings/index.ts +37 -10
  59. package/templates/apps/api/src/routes/project-listings/me.ts +10 -0
  60. package/templates/apps/api/src/routes/project-listings/patch-draft.ts +5 -0
  61. package/templates/apps/api/src/routes/project-listings/public.ts +5 -0
  62. package/templates/apps/api/src/routes/project-listings/respond.ts +11 -0
  63. package/templates/apps/api/src/routes/project-listings/resume-token.ts +5 -0
  64. package/templates/apps/api/src/routes/project-listings/start.ts +30 -0
  65. package/templates/apps/api/src/routes/project-listings/submit.ts +5 -0
  66. package/templates/apps/api/src/routes/project-listings/verify-email.ts +150 -0
  67. package/templates/apps/api/src/server.ts +459 -135
  68. package/templates/apps/api/src/services/deliverable-fulfillment.ts +10 -0
  69. package/templates/apps/api/src/services/listing-config.ts +58 -0
  70. package/templates/apps/api/src/services/project-listing-resume-email.ts +326 -0
  71. package/templates/apps/api/src/services/project-listings.ts +229 -4
  72. package/templates/apps/api/src/vercel-handler.ts +60 -26
  73. package/templates/apps/mcp/.env.example +8 -0
  74. package/templates/apps/mcp/CLAUDE.md +2 -2
  75. package/templates/apps/mcp/__tests__/catalog-drift.test.ts +21 -0
  76. package/templates/apps/mcp/__tests__/config/modules.test.ts +78 -0
  77. package/templates/apps/mcp/__tests__/module-exclusion.test.ts +1 -1
  78. package/templates/apps/mcp/src/config/modules.ts +14 -13
  79. package/templates/apps/mcp/src/server.ts +8 -4
  80. package/templates/apps/mcp/src/tools/index.ts +7 -22
  81. package/templates/apps/web/.env.example +15 -0
  82. package/templates/apps/web/app/[locale]/(authed)/{waitlist/__tests__ → __tests__}/gate.test.tsx +4 -4
  83. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +2 -1
  84. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +2 -1
  85. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +2 -1
  86. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +1 -0
  87. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +1 -0
  88. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +2 -1
  89. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +1 -0
  90. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +1 -0
  91. package/templates/apps/web/app/llms.txt/route.ts +12 -9
  92. package/templates/apps/web/jest.config.cjs +14 -13
  93. package/templates/apps/web/next.config.mjs +1 -3
  94. package/templates/apps/web/package.json +0 -6
  95. package/templates/apps/web/public/android-chrome-192x192.png +0 -0
  96. package/templates/apps/web/public/android-chrome-512x512.png +0 -0
  97. package/templates/apps/web/public/apple-touch-icon.png +0 -0
  98. package/templates/apps/web/public/favicon-16x16.png +0 -0
  99. package/templates/apps/web/public/favicon-32x32.png +0 -0
  100. package/templates/apps/web/public/favicon.ico +0 -0
  101. package/templates/apps/web/public/favicon.svg +6 -3
  102. package/templates/apps/web/public/lockup-horizontal.svg +4 -0
  103. package/templates/apps/web/public/logomark.svg +4 -0
  104. package/templates/apps/web/public/site.webmanifest +2 -2
  105. package/templates/apps/web/public/wordmark.svg +4 -0
  106. package/templates/database/CHANGELOG.md +33 -0
  107. package/templates/database/inbox/schema.prisma +67 -0
  108. package/templates/database/migrations/20260914120000_listing_founder_identity/migration.sql +123 -0
  109. package/templates/database/package.json +1 -1
  110. package/templates/package.json +1 -1
  111. package/templates/.claude/skills/scaffold-commerce/SKILL.md +0 -807
  112. package/templates/.claude/skills/scaffold-commerce/references/lookup-keys-template.md +0 -71
  113. package/templates/.claude/skills/scaffold-commerce/references/marketplace-brand-pages.md +0 -83
  114. package/templates/.claude/skills/scaffold-commerce/templates/checkout-route.template.ts +0 -370
  115. package/templates/.claude/skills/scaffold-commerce/templates/invoice-route.template.ts +0 -376
  116. package/templates/.claude/skills/scaffold-commerce/templates/marketplace-cta-route.tsx.tmpl +0 -72
  117. package/templates/.claude/skills/scaffold-commerce/templates/payment-link-route.template.ts +0 -471
  118. package/templates/.claude/skills/scaffold-commerce/templates/portal-route.template.ts +0 -365
  119. package/templates/.claude/skills/scaffold-commerce/templates/stripe-config.template.ts +0 -60
  120. package/templates/.claude/skills/scaffold-commerce/templates/subscription-route.template.ts +0 -446
  121. package/templates/apps/api/src/__tests__/server.test.ts +0 -253
  122. package/templates/apps/api/src/bin/deliverable-resend.ts +0 -144
  123. package/templates/apps/api/src/bin/deliverable-upload.ts +0 -114
  124. package/templates/apps/api/src/bin/followup-sweep.ts +0 -44
  125. package/templates/apps/api/src/bin/listing-csv-sweep.ts +0 -46
  126. package/templates/apps/api/src/bin/seed-presets.ts +0 -58
  127. package/templates/apps/api/src/bin/seed-waitlist-experiments.ts +0 -104
  128. package/templates/apps/api/src/bin/session-retention-sweep.ts +0 -46
  129. package/templates/apps/api/src/lib/__tests__/stripe.test.ts +0 -74
  130. package/templates/apps/api/src/lib/stripe.ts +0 -52
  131. package/templates/apps/api/src/lib/tenant-db.ts +0 -225
  132. package/templates/apps/api/src/lib/ws-token.ts +0 -91
  133. package/templates/apps/api/src/middleware/tenant.ts +0 -99
  134. package/templates/apps/api/src/routes/billing/__tests__/portal.test.ts +0 -450
  135. package/templates/apps/api/src/routes/billing/__tests__/read.test.ts +0 -262
  136. package/templates/apps/api/src/routes/billing/__tests__/usage.test.ts +0 -436
  137. package/templates/apps/api/src/routes/billing/index.ts +0 -36
  138. package/templates/apps/api/src/routes/billing/portal.ts +0 -182
  139. package/templates/apps/api/src/routes/billing/read.ts +0 -75
  140. package/templates/apps/api/src/routes/billing/usage.ts +0 -153
  141. package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +0 -687
  142. package/templates/apps/api/src/routes/checkout/index.ts +0 -13
  143. package/templates/apps/api/src/routes/checkout/sessions.ts +0 -197
  144. package/templates/apps/api/src/routes/deliverables/__tests__/index.test.ts +0 -393
  145. package/templates/apps/api/src/routes/deliverables/index.ts +0 -200
  146. package/templates/apps/api/src/routes/flow-checkouts/__tests__/index.test.ts +0 -443
  147. package/templates/apps/api/src/routes/flow-checkouts/index.ts +0 -82
  148. package/templates/apps/api/src/routes/flows/README.md +0 -147
  149. package/templates/apps/api/src/routes/flows/__tests__/index.test.ts +0 -752
  150. package/templates/apps/api/src/routes/flows/__tests__/recommender.test.ts +0 -671
  151. package/templates/apps/api/src/routes/flows/index.ts +0 -202
  152. package/templates/apps/api/src/routes/flows/recommender.ts +0 -443
  153. package/templates/apps/api/src/routes/project-listings/__tests__/copy-edit.test.ts +0 -815
  154. package/templates/apps/api/src/routes/project-listings/__tests__/me-route-precedence.test.ts +0 -221
  155. package/templates/apps/api/src/routes/project-listings/__tests__/tenant-isolation.test.ts +0 -566
  156. package/templates/apps/api/src/routes/project-listings/get.ts +0 -70
  157. package/templates/apps/api/src/routes/project-listings/list.ts +0 -47
  158. package/templates/apps/api/src/routes/project-listings/patch.ts +0 -136
  159. package/templates/apps/api/src/routes/schedule/__tests__/index.test.ts +0 -490
  160. package/templates/apps/api/src/routes/schedule/index.ts +0 -249
  161. package/templates/apps/api/src/routes/slack/__tests__/actions.test.ts +0 -385
  162. package/templates/apps/api/src/routes/slack/actions.ts +0 -177
  163. package/templates/apps/api/src/routes/slack/index.ts +0 -38
  164. package/templates/apps/api/src/routes/waitlist-experiments/__tests__/tenant-isolation.test.ts +0 -577
  165. package/templates/apps/api/src/routes/waitlist-experiments/comparison.ts +0 -78
  166. package/templates/apps/api/src/routes/waitlist-experiments/index.ts +0 -41
  167. package/templates/apps/api/src/routes/waitlist-experiments/list.ts +0 -64
  168. package/templates/apps/api/src/routes/waitlist-experiments/respond.ts +0 -42
  169. package/templates/apps/api/src/routes/waitlist-experiments/signup.ts +0 -84
  170. package/templates/apps/api/src/routes/waitlist-experiments/signups.ts +0 -119
  171. package/templates/apps/api/src/routes/waitlist-signups/__tests__/index.test.ts +0 -238
  172. package/templates/apps/api/src/routes/waitlist-signups/index.ts +0 -101
  173. package/templates/apps/api/src/routes/webhooks/README.md +0 -80
  174. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-flow-checkout.test.ts +0 -315
  175. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-idempotency.test.ts +0 -247
  176. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-org-billing.test.ts +0 -270
  177. package/templates/apps/api/src/routes/webhooks/__tests__/stripe-rate-limit.test.ts +0 -198
  178. package/templates/apps/api/src/routes/webhooks/__tests__/stripe.test.ts +0 -633
  179. package/templates/apps/api/src/routes/webhooks/index.ts +0 -41
  180. package/templates/apps/api/src/routes/webhooks/stripe.ts +0 -481
  181. package/templates/apps/api/src/routes/workspaces/__tests__/config-tenant-isolation.test.ts +0 -356
  182. package/templates/apps/api/src/routes/workspaces/__tests__/tenant-isolation.test.ts +0 -671
  183. package/templates/apps/api/src/routes/workspaces/config.ts +0 -125
  184. package/templates/apps/api/src/routes/workspaces/index.ts +0 -194
  185. package/templates/apps/api/src/routes/workspaces/sessions.ts +0 -218
  186. package/templates/apps/api/src/services/__tests__/flow-aggregate.test.ts +0 -425
  187. package/templates/apps/api/src/services/__tests__/flow-engine.test.ts +0 -2840
  188. package/templates/apps/api/src/services/__tests__/lead-promotion.test.ts +0 -393
  189. package/templates/apps/api/src/services/__tests__/listing-csv-sweep.test.ts +0 -560
  190. package/templates/apps/api/src/services/__tests__/listing-promotion.test.ts +0 -684
  191. package/templates/apps/api/src/services/__tests__/playbook-compile.test.ts +0 -406
  192. package/templates/apps/api/src/services/__tests__/playbook-render.test.ts +0 -290
  193. package/templates/apps/api/src/services/__tests__/project-listing-decision.test.ts +0 -736
  194. package/templates/apps/api/src/services/__tests__/project-listing-flow.test.ts +0 -475
  195. package/templates/apps/api/src/services/__tests__/project-listing-issue.test.ts +0 -340
  196. package/templates/apps/api/src/services/__tests__/recommender-capture.test.ts +0 -983
  197. package/templates/apps/api/src/services/__tests__/tenant-context-cascade.test.ts +0 -71
  198. package/templates/apps/api/src/services/__tests__/tenant-context.test.ts +0 -379
  199. package/templates/apps/api/src/services/__tests__/usage-metering.test.ts +0 -768
  200. package/templates/apps/api/src/services/__tests__/waitlist-dashboard.test.ts +0 -1314
  201. package/templates/apps/api/src/services/__tests__/waitlist-experiments.test.ts +0 -341
  202. package/templates/apps/api/src/services/__tests__/waitlist-followup.test.ts +0 -567
  203. package/templates/apps/api/src/services/__tests__/waitlist-scoring.test.ts +0 -474
  204. package/templates/apps/api/src/services/__tests__/waitlist-signups.test.ts +0 -354
  205. package/templates/apps/api/src/services/flow-aggregate.ts +0 -232
  206. package/templates/apps/api/src/services/flow-checkouts.ts +0 -123
  207. package/templates/apps/api/src/services/flow-engine.ts +0 -1296
  208. package/templates/apps/api/src/services/lead-promotion.ts +0 -176
  209. package/templates/apps/api/src/services/listing-csv-sweep.ts +0 -455
  210. package/templates/apps/api/src/services/listing-promotion.ts +0 -342
  211. package/templates/apps/api/src/services/playbook-compile.ts +0 -398
  212. package/templates/apps/api/src/services/playbook-render.ts +0 -263
  213. package/templates/apps/api/src/services/project-listing-decision.ts +0 -510
  214. package/templates/apps/api/src/services/project-listing-flow.ts +0 -426
  215. package/templates/apps/api/src/services/project-listing-issue.ts +0 -251
  216. package/templates/apps/api/src/services/recommender-capture.ts +0 -835
  217. package/templates/apps/api/src/services/scheduling/cal-provider.ts +0 -392
  218. package/templates/apps/api/src/services/scheduling/index.ts +0 -63
  219. package/templates/apps/api/src/services/scheduling/types.ts +0 -88
  220. package/templates/apps/api/src/services/tenant-context.ts +0 -451
  221. package/templates/apps/api/src/services/usage-metering.ts +0 -699
  222. package/templates/apps/api/src/services/waitlist-dashboard.ts +0 -947
  223. package/templates/apps/api/src/services/waitlist-experiments.ts +0 -213
  224. package/templates/apps/api/src/services/waitlist-followup.ts +0 -486
  225. package/templates/apps/api/src/services/waitlist-scoring.ts +0 -166
  226. package/templates/apps/api/src/services/waitlist-signups.ts +0 -165
  227. package/templates/apps/mcp/__tests__/schedule_tools.test.ts +0 -242
  228. package/templates/apps/mcp/src/tools/create_booking.ts +0 -58
  229. package/templates/apps/mcp/src/tools/get_event_meta.ts +0 -55
  230. package/templates/apps/mcp/src/tools/get_flow.ts +0 -61
  231. package/templates/apps/mcp/src/tools/list_availability.ts +0 -67
  232. package/templates/apps/mcp/src/tools/submit_flow_step.ts +0 -83
  233. package/templates/apps/web/app/[locale]/(authed)/waitlist/[experimentId]/page.tsx +0 -309
  234. package/templates/apps/web/app/[locale]/(authed)/waitlist/[experimentId]/signups/[leadId]/page.tsx +0 -149
  235. package/templates/apps/web/app/[locale]/(authed)/waitlist/__tests__/comparison.test.tsx +0 -273
  236. package/templates/apps/web/app/[locale]/(authed)/waitlist/__tests__/list.test.tsx +0 -171
  237. package/templates/apps/web/app/[locale]/(authed)/waitlist/__tests__/signup.test.tsx +0 -179
  238. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ExperimentsTable.tsx +0 -116
  239. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/OfferFunnelTable.tsx +0 -66
  240. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/RollupTicker.tsx +0 -61
  241. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ScoreTrace.tsx +0 -114
  242. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/SignupsTable.tsx +0 -139
  243. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/WaitlistComparisonTabs.tsx +0 -85
  244. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/status-badges.tsx +0 -67
  245. package/templates/apps/web/app/[locale]/(authed)/waitlist/page.tsx +0 -179
  246. package/templates/apps/web/app/[locale]/blog/[[...slug]]/page.tsx +0 -178
  247. package/templates/apps/web/app/[locale]/dev/purchase/__tests__/actions.test.ts +0 -160
  248. package/templates/apps/web/app/[locale]/dev/purchase/error.tsx +0 -25
  249. package/templates/apps/web/app/[locale]/dev/purchase/page.tsx +0 -117
  250. package/templates/apps/web/app/[locale]/dev/purchase/purchase.actions.ts +0 -58
  251. package/templates/apps/web/app/[locale]/docs/[[...slug]]/page.tsx +0 -119
  252. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/checkout.actions.test.ts +0 -287
  253. package/templates/apps/web/app/[locale]/flows/[slug]/checkout.actions.ts +0 -254
  254. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -532
  255. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -121
  256. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.checkout.test.tsx +0 -457
  257. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -396
  258. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -114
  259. package/templates/apps/web/app/[locale]/projects/apply/ListingApplicationClient.tsx +0 -110
  260. package/templates/apps/web/app/[locale]/projects/apply/__tests__/ListingApplicationClient.test.tsx +0 -96
  261. package/templates/apps/web/app/[locale]/schedule/__tests__/page.test.tsx +0 -117
  262. package/templates/apps/web/app/[locale]/schedule/confirmed/__tests__/page.test.tsx +0 -96
  263. package/templates/apps/web/app/[locale]/schedule/confirmed/page.tsx +0 -92
  264. package/templates/apps/web/app/[locale]/schedule/page.tsx +0 -82
  265. package/templates/apps/web/content/en/blog/README.txt +0 -25
  266. package/templates/apps/web/content/en/docs/index.mdx +0 -28
  267. package/templates/apps/web/lib/__mocks__/source-server.js +0 -31
  268. package/templates/apps/web/lib/blog-list-data.ts +0 -95
  269. package/templates/apps/web/lib/blog-post-data.ts +0 -79
  270. package/templates/apps/web/lib/source.ts +0 -34
  271. package/templates/apps/web/public/logomark-dark.svg +0 -4
  272. package/templates/apps/web/public/logomark-light.svg +0 -4
  273. package/templates/apps/web/source.config.ts +0 -78
@@ -7,7 +7,7 @@
7
7
  * composition is downstream work, so the default (`marketing`) reproduces
8
8
  * today's fixed-tree scaffold exactly.
9
9
  */
10
- export declare const RECOGNIZED_MODULES: readonly ["marketing", "docs", "multi-tenant", "scheduling"];
10
+ export declare const RECOGNIZED_MODULES: readonly ["marketing", "docs-blog", "multi-tenant", "scheduling", "signal-collectors", "commerce"];
11
11
  export type ModuleName = (typeof RECOGNIZED_MODULES)[number];
12
12
  export interface CliOptions {
13
13
  /** Positional target directory (the dir to scaffold into). Optional only
@@ -16,7 +16,7 @@ export interface CliOptions {
16
16
  install: boolean;
17
17
  help: boolean;
18
18
  version: boolean;
19
- /** Selected modules (recognized: marketing, docs, multi-tenant, scheduling).
19
+ /** Selected modules (recognized: marketing, docs-blog, multi-tenant, scheduling).
20
20
  * Defaults to ['marketing'] when the flag is absent. */
21
21
  modules: string[];
22
22
  /** Explicitly requested route surfaces (`--surfaces`). Empty when the flag is
@@ -20,9 +20,11 @@ import { RECOGNIZED_SURFACES, parseSurfaces } from "./surfaces.js";
20
20
  */
21
21
  export const RECOGNIZED_MODULES = [
22
22
  "marketing",
23
- "docs",
23
+ "docs-blog",
24
24
  "multi-tenant",
25
25
  "scheduling",
26
+ "signal-collectors",
27
+ "commerce",
26
28
  ];
27
29
  /** The default module selection when `--modules` is absent (reproduces today's scaffold). */
28
30
  const DEFAULT_MODULES = ["marketing"];
@@ -29,7 +29,8 @@ export interface ScaffoldOptions {
29
29
  */
30
30
  preset?: string;
31
31
  /**
32
- * Selected modules (recognized: marketing, docs, multi-tenant). Defaults to
32
+ * Selected modules (recognized: marketing, docs-blog, multi-tenant,
33
+ * scheduling). Defaults to
33
34
  * ['marketing']. The scaffolder does NOT yet vary the copied template tree by
34
35
  * module (per-module template composition is downstream work), so the copied
35
36
  * files are today's fixed-tree scaffold — BUT the derived `architecture.yaml`
@@ -134,11 +134,17 @@ export async function scaffold(opts) {
134
134
  ...(opts.fetchImpl !== undefined ? { fetchImpl: opts.fetchImpl } : {}),
135
135
  });
136
136
  const result = scaffoldSync(opts);
137
+ // Threaded to extractModuleBundle for `package.json` patch targets'
138
+ // `workspace:*` substitution (spec 5418 § 3 D2) — the same version map
139
+ // `scaffoldSync` already reads for `copyTemplate`, re-read here since
140
+ // `scaffold()` doesn't share `scaffoldSync`'s call frame.
141
+ const versions = readVersionMap();
137
142
  for (const [moduleName, bytes] of bundles) {
138
143
  await extractModuleBundle({
139
144
  bytes,
140
145
  targetDir: result.targetDir,
141
146
  moduleName,
147
+ versions,
142
148
  });
143
149
  }
144
150
  return result;
@@ -194,10 +200,15 @@ export function syncArchitectureSync(opts) {
194
200
  * stats paths and returns strings, and never writes or deletes.
195
201
  *
196
202
  * Routes only, deliberately. A surface's content directories are informational
197
- * (`Surface.content`), not drift: `apps/web/content/<locale>/{blog,docs}` must
198
- * exist in EVERY scaffold `source.config.ts` resolves those paths at build
199
- * time whether or not the route is mounted — so sweeping content here would
200
- * tell every operator to delete directories the build requires.
203
+ * (`Surface.content`), not drift, so sweeping content here would tell an
204
+ * operator to delete directories that merely hold their own copy.
205
+ *
206
+ * This used to rest on a stronger claim — that `apps/web/content/<locale>/
207
+ * {blog,docs}` must exist in EVERY scaffold, because `source.config.ts`
208
+ * resolved those paths at build time whether or not the route mounted. D-46
209
+ * retired it: `source.config.ts` leaves with the docs + blog module (#5365 D3),
210
+ * so a Free scaffold defines no Fumadocs collection and carries neither
211
+ * directory.
201
212
  */
202
213
  function findUndeclaredSurfacePaths(targetAbs, enabled) {
203
214
  return excludedRoutePaths(enabled)
@@ -1,36 +1,3 @@
1
- /**
2
- * Route-surface registry — which public routes a scaffolded site carries.
3
- *
4
- * A SURFACE is one public route surface of the presentation tier (see
5
- * architecture.yaml `composition_model`): a hub route plus the detail route and
6
- * content directories that feed it. The registry is the single source of the
7
- * surface vocabulary, in the same spirit as `module-architecture.ts` is the
8
- * single source of the module→architecture-slice mapping — a code registry, not
9
- * N hand-maintained template trees.
10
- *
11
- * Two tiers:
12
- *
13
- * - CORE_SURFACE_PATHS — the routes every AILK site has regardless of what
14
- * the business is (`/`, `/about`, `/contact`, `/faq`, `/thanks/{slug}`).
15
- * Always scaffolded, never gateable.
16
- * - GATEABLE_SURFACES — everything else. A surface is scaffolded ONLY when
17
- * the declared architecture carries it; otherwise its route directories are
18
- * skipped by `copyTemplate` and the routes are ABSENT from the scaffold,
19
- * not present-and-placeholdering (spec #4154 D1).
20
- *
21
- * The default (`--modules marketing`) enables NO gateable surface: every one of
22
- * them is a claim about the business that the scaffolder cannot make. The path
23
- * from there is the `suggest-site-pages` → `scaffold-page` skill pair that
24
- * already ships in `templates/.claude/skills/`.
25
- *
26
- * Zero runtime dependencies — create-ailk is a published, standalone CLI.
27
- *
28
- * Deliberately imports nothing from `parse-args.ts`: that module imports THIS
29
- * one (for the `--surfaces` vocabulary in its help text), so a back-import
30
- * would close a cycle. The module vocabulary is re-stated here as the keys of
31
- * `MODULE_SURFACES`, and `__tests__/surface-gating.test.ts` asserts those keys
32
- * equal `RECOGNIZED_MODULES` so the two cannot drift.
33
- */
34
1
  /**
35
2
  * Route paths (site-relative, for the record written into `architecture.yaml`)
36
3
  * that every scaffold carries.
@@ -88,9 +55,18 @@ export declare const RECOGNIZED_SURFACES: readonly string[];
88
55
  * Surfaces each recognized module contributes.
89
56
  *
90
57
  * `marketing` (the default) contributes NONE — a default scaffold is core-only.
91
- * `docs` mounts the Fumadocs presentation surface; `multi-tenant` brings the
92
- * flow-stepper surface with its API-backed engine; `scheduling` brings the
93
- * booking page and the confirmation page the module owns.
58
+ * `docs-blog` mounts BOTH Fumadocs presentation surfaces: D-46 made docs and
59
+ * blog one Pro module, so `/blog` is no longer a Free surface that any scaffold
60
+ * can turn on. `multi-tenant` contributes no surface of its own — it USED to
61
+ * carry `flows`, but D-48 reassigns that surface to `signal-collectors`
62
+ * (#5366), which now brings the flow-stepper surface with its API-backed
63
+ * engine; `scheduling` brings the booking page and the confirmation page the
64
+ * module owns.
65
+ *
66
+ * A surface named here is MODULE-GATED: `resolveSurfaces` refuses it as an
67
+ * explicit `--surfaces` value unless the module that owns it was selected
68
+ * (#5365 FR5). Without that, `--surfaces blog` on a keyless scaffold would
69
+ * declare a surface whose route files the starter no longer contains.
94
70
  */
95
71
  export declare const MODULE_SURFACES: Record<string, readonly string[]>;
96
72
  /** Thrown on an unrecognized surface id. Mirrors parse-args' ParseError shape. */
package/dist/surfaces.js CHANGED
@@ -230,15 +230,26 @@ export const RECOGNIZED_SURFACES = GATEABLE_SURFACES.map((s) => s.id);
230
230
  * Surfaces each recognized module contributes.
231
231
  *
232
232
  * `marketing` (the default) contributes NONE — a default scaffold is core-only.
233
- * `docs` mounts the Fumadocs presentation surface; `multi-tenant` brings the
234
- * flow-stepper surface with its API-backed engine; `scheduling` brings the
235
- * booking page and the confirmation page the module owns.
233
+ * `docs-blog` mounts BOTH Fumadocs presentation surfaces: D-46 made docs and
234
+ * blog one Pro module, so `/blog` is no longer a Free surface that any scaffold
235
+ * can turn on. `multi-tenant` contributes no surface of its own — it USED to
236
+ * carry `flows`, but D-48 reassigns that surface to `signal-collectors`
237
+ * (#5366), which now brings the flow-stepper surface with its API-backed
238
+ * engine; `scheduling` brings the booking page and the confirmation page the
239
+ * module owns.
240
+ *
241
+ * A surface named here is MODULE-GATED: `resolveSurfaces` refuses it as an
242
+ * explicit `--surfaces` value unless the module that owns it was selected
243
+ * (#5365 FR5). Without that, `--surfaces blog` on a keyless scaffold would
244
+ * declare a surface whose route files the starter no longer contains.
236
245
  */
237
246
  export const MODULE_SURFACES = {
238
247
  marketing: [],
239
- docs: ["docs"],
240
- "multi-tenant": ["flows"],
248
+ "docs-blog": ["docs", "blog"],
249
+ "multi-tenant": [],
241
250
  scheduling: ["schedule"],
251
+ "signal-collectors": ["flows"],
252
+ commerce: [],
242
253
  };
243
254
  /** Thrown on an unrecognized surface id. Mirrors parse-args' ParseError shape. */
244
255
  export class SurfaceError extends Error {
@@ -290,14 +301,33 @@ export function resolveSurfaces(modules = ["marketing"], explicit = []) {
290
301
  for (const s of contributed)
291
302
  set.add(s);
292
303
  }
304
+ const selected = new Set(modules.map((m) => m.trim().toLowerCase()));
293
305
  for (const s of explicit) {
294
306
  if (!RECOGNIZED_SURFACES.includes(s)) {
295
307
  throw new SurfaceError(`unknown surface "${s}". Recognized: ${RECOGNIZED_SURFACES.join(", ")}`);
296
308
  }
309
+ // A surface a module OWNS cannot be declared without that module (#5365
310
+ // FR5/D12). The starter no longer carries the route files, so a bare
311
+ // `--surfaces blog` would declare a surface that serves 404 with no error
312
+ // anywhere — the silent-wrong-result this refusal closes. Keyed on
313
+ // MODULE_SURFACES, never on a surface id, so every module inherits it.
314
+ const owner = moduleOwningSurface(s);
315
+ if (owner !== undefined && !selected.has(owner)) {
316
+ throw new SurfaceError(`surface "${s}" is delivered by the "${owner}" module — add it with ` +
317
+ `--modules ${owner} (a paid module also needs AILK_LICENSE_KEY).`);
318
+ }
297
319
  set.add(s);
298
320
  }
299
321
  return [...set].sort();
300
322
  }
323
+ /** The module that owns a gateable surface, or undefined if no module does. */
324
+ function moduleOwningSurface(surface) {
325
+ for (const [moduleName, contributed] of Object.entries(MODULE_SURFACES)) {
326
+ if (contributed.includes(surface))
327
+ return moduleName;
328
+ }
329
+ return undefined;
330
+ }
301
331
  /**
302
332
  * The template-relative route directories to SKIP when copying the template —
303
333
  * every gateable surface not in `enabled`.
@@ -35,6 +35,18 @@ import { substituteMarkers } from "./substitute.js";
35
35
  import { GATEABLE_SURFACES, NON_ROUTE_DIRS, ROUTE_DEPENDENCIES, ROUTE_MESSAGE_NAMESPACES, ROUTE_SINCE, surfaceForRouteDir, } from "./surfaces.js";
36
36
  /** Template-relative prefix every `apps/web` route directory sits under. */
37
37
  const ROUTE_ROOT = "apps/web/app/[locale]";
38
+ /**
39
+ * `<surface id>/<entry name>` pairs that live directly under a GATEABLE
40
+ * surface's top-level directory but belong to a DIFFERENT module (#5366).
41
+ * `projects/apply` (#5048) is signal-collectors' own owned file
42
+ * (`ListingApplicationClient.tsx`, D-48) — its module bundle restores it
43
+ * whenever signal-collectors is selected, independent of the unrelated
44
+ * "projects" content surface's own selection. See the doc comment on
45
+ * `syncRoutes`'s `carried` computation.
46
+ */
47
+ const NESTED_FOREIGN_MODULE_ENTRIES = new Set([
48
+ "projects/apply",
49
+ ]);
38
50
  /**
39
51
  * The template's route directories, ROUTE_ROOT-relative and sorted.
40
52
  *
@@ -120,12 +132,30 @@ export function syncRoutes(opts) {
120
132
  throw new Error(`not a scaffolded repo: no architecture.yaml at ${targetAbs}. Run \`create-ailk <target-dir>\` to scaffold first.`);
121
133
  }
122
134
  // Presence of any of a surface's route dirs means the site carries it.
135
+ // A surface's directory containing ONLY entries in
136
+ // `NESTED_FOREIGN_MODULE_ENTRIES` does not count as present (#5366): a
137
+ // DIFFERENT module can own a companion sub-route nested under an unrelated
138
+ // content surface's URL segment — `projects/apply` (#5048) is
139
+ // signal-collectors' own owned file (D-48), and its module bundle restores
140
+ // it whenever signal-collectors is selected, regardless of whether the
141
+ // unrelated "projects" CONTENT surface is separately requested. Without
142
+ // this exclusion, a signal-collectors-only scaffold would falsely read as
143
+ // "carries projects" the moment its bundle lands that one file.
123
144
  const carried = new Set();
124
145
  const skippedSurfaces = [];
125
146
  for (const surface of GATEABLE_SURFACES) {
126
147
  const present = surface.routes.some((r) => {
127
148
  const p = join(targetAbs, r);
128
- return existsSync(p) && statSync(p).isDirectory();
149
+ if (!existsSync(p) || !statSync(p).isDirectory())
150
+ return false;
151
+ const entries = readdirSync(p);
152
+ // An ancestor dir left empty by a consumer-side deletion (AC-2's
153
+ // "ancestor also missing" case) still counts as carried — only a
154
+ // NON-empty directory whose entries are entirely foreign (the
155
+ // `projects`/`apply` case above) does not.
156
+ if (entries.length === 0)
157
+ return true;
158
+ return entries.some((name) => !NESTED_FOREIGN_MODULE_ENTRIES.has(`${surface.id}/${name}`));
129
159
  });
130
160
  if (present)
131
161
  carried.add(surface.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ailk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "test": "tsc -b && node scripts/build-templates.mjs && jest",
48
48
  "test:watch": "jest --watch",
49
49
  "test:coverage": "jest --coverage",
50
- "build-templates": "node scripts/build-templates.mjs",
50
+ "build-templates": "tsc -b && node scripts/build-templates.mjs",
51
51
  "build-catalog": "node scripts/build-component-catalog.mjs",
52
52
  "check-catalog": "node scripts/build-component-catalog.mjs --check"
53
53
  }
@@ -72,9 +72,8 @@ Run `pnpm preflight` before opening a PR.
72
72
  speak to the API via `@working-theory/api-client`.
73
73
  - Importing `@working-theory/database` — `apps/web` does not touch the DB;
74
74
  route through `apps/api`.
75
- - Importing `stripe`, `resend`, `@react-email/*` directly — wrap
76
- through `@working-theory/stripe-client` or `@working-theory/email`, server-side via
77
- `apps/api`.
75
+ - Importing `resend`, `@react-email/*` directly — wrap through
76
+ `@working-theory/email`, server-side via `apps/api`.
78
77
  - Adding a `utils.ts`, `helpers.ts`, `common.ts`, or `misc.ts` file
79
78
  — use a descriptive name.
80
79
  - Reformatting unrelated lines. Diff is the contract.
@@ -28,10 +28,10 @@ other.
28
28
  - Need database access? Only `apps/api` and `apps/mcp` import
29
29
  `@working-theory/database`. `apps/web` never reads the database directly — it
30
30
  goes through the HTTP API.
31
- - Cross-cutting integrations (auth, payments, email, analytics) go
32
- through their wrapper packages: `@working-theory/auth-client`,
33
- `@working-theory/stripe-client`, `@working-theory/email`, `@working-theory/analytics`. Never
34
- import `next-auth`, `stripe`, `resend`, etc. directly.
31
+ - Cross-cutting integrations (auth, email, analytics) go through their
32
+ wrapper packages: `@working-theory/auth-client`, `@working-theory/email`,
33
+ `@working-theory/analytics`. Never import `next-auth`, `resend`, etc.
34
+ directly.
35
35
 
36
36
  ## What you can verify, what you can't
37
37
 
@@ -62,5 +62,5 @@ These never appear in source code:
62
62
  by being named on a ban-list. Live keys live in your deployment
63
63
  platform's secrets store, never in source files or `.env`.
64
64
  - Direct vendor SDK imports outside the wrapper packages
65
- (`import 'stripe'` outside `@working-theory/stripe-client`, etc.).
65
+ (`import 'resend'` outside `@working-theory/email`, etc.).
66
66
  - Hardcoded production database URLs in committed files.
@@ -17,12 +17,13 @@ local project's issues.
17
17
  | -------------------- | ------------------------------------------------------ | ---------------------------------------------------- |
18
18
  | `suggest-site-pages` | Generic page-type suggestions by category | coming soon — issue #361 (working-theory-labs/ai-launch-kit) |
19
19
  | `scaffold-page` | Generate a page with the appropriate schema.org type | coming soon — issue #362 (working-theory-labs/ai-launch-kit) |
20
- | `scaffold-commerce` | Sell stuff: external store link or direct payments | coming soon — issue #363 (working-theory-labs/ai-launch-kit) |
21
20
  | `scaffold-auth` | Wire up an auth flow against `@working-theory/auth-client` | coming soon — issue #364 (working-theory-labs/ai-launch-kit) |
22
21
  | `audit-site` | Run `ailk audit` and explain the results | coming soon — issue #365 (working-theory-labs/ai-launch-kit) |
23
22
  | `add-schema` | Add Product / Service / FAQ schema to an existing page | coming soon — issue #366 (working-theory-labs/ai-launch-kit) |
24
23
  | `provision-config` | Generate `vercel.json` and environment templates | coming soon — issue #367 (working-theory-labs/ai-launch-kit) |
25
24
 
25
+ `scaffold-commerce` is delivered with the commerce module (`--modules commerce`, licensed).
26
+
26
27
  ## How a skill ships
27
28
 
28
29
  When a skill is built upstream, this directory will contain a
@@ -98,11 +98,20 @@ CONTENT_BACKEND=mdx
98
98
  # default.
99
99
  # RESEND_AUDIENCE_ID=
100
100
  #
101
- # The public base URL this API is reachable at used ONLY to build the
102
- # deliverable-delivery download link (#3961 D5):
103
- # `${AILK_PUBLIC_API_URL}/v1/deliverables/:grantId`. Unset means a relative
104
- # link (base ""), which is not usable from an email client set this in any
105
- # deployment that uses the `deliverables` block.
101
+ # The public base URL this API is reachable at, e.g. https://api.example.com
102
+ # (no trailing slash). This is the API's OWN origin — distinct from
103
+ # FRONTEND_URL (the site the browser loads) and from `_site.mdx`'s `baseUrl`
104
+ # (the site's public web origin). A deployment typically serves the site from
105
+ # example.com and this API from api.example.com, so neither of the other two
106
+ # can stand in for it. Two consumers:
107
+ #
108
+ # 1. The deliverable-delivery download link (#3961 D5):
109
+ # `${AILK_PUBLIC_API_URL}/v1/deliverables/:grantId`. Unset means a
110
+ # relative link (base ""), which is not usable from an email client — set
111
+ # this in any deployment that uses the `deliverables` block.
112
+ # 2. The OpenAPI `servers` block (#5306). Unset degrades to a single
113
+ # document-relative server (`/`), which an agent resolves against the
114
+ # origin it fetched the spec from — correct, just less explicit.
106
115
  # AILK_PUBLIC_API_URL=
107
116
  #
108
117
  # The apps/api origin @working-theory/api-client calls from
@@ -313,11 +322,14 @@ CONTENT_BACKEND=mdx
313
322
  # apps/api's origin as seen from apps/web's SERVER process — the api-client's
314
323
  # base URL (getApiBase(), packages/api-client/src/http.ts) for every flow
315
324
  # Server Action call (flows.get / submitStep / save / checkout). AILK_API_URL
316
- # wins; NEXT_PUBLIC_API_URL is the fallback; both unset resolves to
325
+ # wins; NEXT_PUBLIC_AILK_API_URL (apps/web/.env.example) is the fallback, and
326
+ # is also what getApiBase() resolves in the BROWSER, where only a
327
+ # NEXT_PUBLIC_-prefixed name is inlined (#5397); NEXT_PUBLIC_API_URL is still
328
+ # read after it as a DEPRECATED fallback for deployments that set it under the
329
+ # old behaviour — do not set it in a new one. All unset resolves to
317
330
  # http://localhost:3001 (local dev only — off-localhost every save / checkout
318
- # call fails as `network`). Distinct from NEXT_PUBLIC_AILK_API_URL
319
- # (apps/web/.env.example), which BROWSER-side blocks post to directly. Set on
320
- # every apps/web deployment whose API is not on localhost.
331
+ # call fails as `network`). Set AILK_API_URL on every apps/web deployment whose
332
+ # API is not on localhost.
321
333
  # AILK_API_URL=http://localhost:3001
322
334
  #
323
335
  # NEXT_PUBLIC_ENABLED_LOCALES — do NOT set by hand. Baked at build time by
@@ -174,13 +174,12 @@ Vendor SDKs are imported only inside their `@working-theory/*` wrapper. The
174
174
  wrapper exports a typed, project-flavored interface; your code imports
175
175
  from the wrapper.
176
176
 
177
- | Vendor | Wrapper package | Where you use it |
178
- | ------------------- | --------------------- | ---------------------------- |
179
- | Stripe | `@working-theory/stripe-client` | `apps/api` checkout/webhooks |
180
- | NextAuth | `@working-theory/auth-client` | `apps/api`, `apps/web` |
181
- | Resend / Nodemailer | `@working-theory/email` | `apps/api` |
182
- | Analytics | `@working-theory/analytics` | `apps/web`, `apps/api` |
183
- | Prisma | `@working-theory/database` | `apps/api`, `apps/mcp` |
177
+ | Vendor | Wrapper package | Where you use it |
178
+ | ------------------- | ----------------------------- | ---------------------- |
179
+ | NextAuth | `@working-theory/auth-client` | `apps/api`, `apps/web` |
180
+ | Resend / Nodemailer | `@working-theory/email` | `apps/api` |
181
+ | Analytics | `@working-theory/analytics` | `apps/web`, `apps/api` |
182
+ | Prisma | `@working-theory/database` | `apps/api`, `apps/mcp` |
184
183
 
185
184
  The wrapper is where retries, signature verification, error mapping,
186
185
  and config defaults live. Don't reinvent them per consumer.
@@ -58,6 +58,15 @@ STRIPE_WEBHOOK_SECRET=whsec_xxx
58
58
  # (#4288) lands as a second value here with no change to the section.
59
59
  # SCHEDULING_PROVIDER=cal
60
60
 
61
+ # =============================================================================
62
+ # Paid modules (D-44, #5368)
63
+ # =============================================================================
64
+ # Comma-separated allowlist of installed paid modules, e.g.
65
+ # "multi-tenant,scheduling". Unset (the default) or "" means NO paid modules
66
+ # — installed modules enable themselves explicitly. Recognized keys: docs,
67
+ # multi-tenant, scheduling, content-write. Must match apps/mcp's value.
68
+ # AILK_ENABLED_MODULES=
69
+
61
70
  # ── Project listings — site addressing (#5048 D2) ───────────────────────────
62
71
  # AILK_SITE_ID is this deployment's own site identifier. Unset means "default".
63
72
  # It is read SERVER-SIDE only; no request body carries a site identifier.
@@ -8,6 +8,26 @@ Inherits root `CLAUDE.md`. This file adds API-specific rules.
8
8
  - Persistence: configurable adapter (default DB; file fallback so OSS works without DB config)
9
9
  - Email: operator-notification stub at OSS; routing pipeline at Pro (in `@working-theory/*`)
10
10
 
11
+ ## Deploy path
12
+
13
+ **The supported deploy path is plain `tsc` output, traced and compiled by `@vercel/node`.** `vercel.json` sets `framework: null` and routes every request to `/api/index.ts`; `build:vercel` runs `prisma generate` and two package builds and does NOT compile `apps/api` — Vercel's own builder does, through `nodeFileTrace`. That tracer is what decides which files ship.
14
+
15
+ **Bundling `apps/api` is NOT a supported deploy path** (#5334). This is a property of the analysers, not a policy:
16
+
17
+ - Paid-module slices are loaded through an indirect dynamic `import()`, because a string literal at the call site would make `tsc` resolve a path the OSS strip removes (#5182).
18
+ - esbuild bundles a dynamic `import()` **only** when its argument is a string literal at the call site — the same predicate `tsc` resolves on. So no expression shape satisfies both the strip and a bundler.
19
+ - In a bundled build the specifier therefore survives verbatim and Node resolves it against the **bundle's output directory** rather than its source module's: `"./list.js"`, written in `src/routes/project-listings/index.ts`, becomes `dist/list.js` and does not exist. esbuild emits no warning. The throw lands inside `build()`, which is construction, so **every route 500s rather than one** — measured in production, nine hours of total API outage on a consuming site.
20
+
21
+ If a dependency is forcing you toward a bundler (an extensionless relative import in a published `dist`, say), fix the dependency's packaging — don't bundle `apps/api`. If you bundle anyway, `loadSlice()` (`src/lib/slice-load.ts`) makes the failure say so at boot instead of failing mute; it does not make bundling work.
22
+
23
+ Three gates hold this together. Run them from the repo root, with `apps/api/dist` built:
24
+
25
+ ```bash
26
+ pnpm slice-reachability:check # every slice specifier is reachable to @vercel/nft
27
+ pnpm artifact-boots:check # the traced artifact boots and answers /health 200
28
+ pnpm bundled-build:check # a bundled build fails, and says why
29
+ ```
30
+
11
31
  ## API ↔ MCP parity (hard rule)
12
32
 
13
33
  Every endpoint here has a 1:1 MCP tool in `apps/mcp`. When you add, change, or remove an endpoint, update the MCP tool in the same PR. CI enforces — broken parity fails the build.
@@ -17,8 +37,9 @@ Every endpoint here has a 1:1 MCP tool in `apps/mcp`. When you add, change, or r
17
37
  Routes are versioned under `/v1/*`:
18
38
 
19
39
  - `/v1/leads/{submit,subscribe,callback}` — lead capture, newsletter subscription, callback request
20
- - `/v1/flows/:slug` (GET), `/v1/flows/:slug/steps` (POST) — serve a flow config + submit a step's answers; server-side per-step partial-state persistence (#3956)
21
- - `/v1/flows/:slug/aggregate` (GET) — anonymous, site-scoped per-question response counts across all completed respondents for the results reveal (#4771): respondents are completed `FlowSession` rows (not `Lead` rows — a recommending-mode respondent has no Lead until the email moment), question metadata + the chart flag come from the `WaitlistExperiment` register, and only `resultsReveal`-flagged `single`/`multi` questions are returned (`src/services/flow-aggregate.ts`). No individual answer, email, name, session id, or score in the response; no auth. No MCP twin — recorded exception (an agent walking a flow already gets everything it needs from `submit_flow_step`'s own response; "how everyone else answered" changes none of it).
40
+ - `/v1/flows/:slug` (GET), `/v1/flows/:slug/steps` (POST) — serve a flow config + submit a step's answers; server-side per-step partial-state persistence (#3956). Module: `signal-collectors` (D-48, #5366) — registers only when the module is enabled; MCP twins `get_flow`/`submit_flow_step` carry the same `module` tag (D7).
41
+ - `/v1/flows/:slug/aggregate` (GET) — anonymous, site-scoped per-question response counts across all completed respondents for the results reveal (#4771): respondents are completed `FlowSession` rows (not `Lead` rows — a recommending-mode respondent has no Lead until the email moment), question metadata + the chart flag come from the `WaitlistExperiment` register, and only `resultsReveal`-flagged `single`/`multi` questions are returned (`src/services/flow-aggregate.ts`). No individual answer, email, name, session id, or score in the response; no auth. Module: `signal-collectors`. No MCP twin — recorded exception (an agent walking a flow already gets everything it needs from `submit_flow_step`'s own response; "how everyone else answered" changes none of it).
42
+ - `/v1/deliverables/:grantId` (GET) — the capability-token download route for gated PDFs and reports, including client deliverables (#3961 D5); the token itself is the sole gate, no auth preHandler applies (`src/routes/deliverables/index.ts`). Module: `signal-collectors` (D-48, #5366). No MCP twin — identity-bound capability-link download (#3591 exception, the same shape as `/v1/waitlist-signups/me`).
22
43
  - `/v1/flows/:slug/save` (POST), `/v1/flows/:slug/checkout` (POST) — the recommender's email moment (#4841): `save` creates the FlowSession + Lead (+ the T+0 DeliverableGrant) for the permalink's answers; `checkout` does the same, records the `FlowCheckout` buyer row at a SERVER-recomputed `price()` (the body carries no amount — `flowCheckoutInputSchema` is strict), and opens a Stripe TEST-mode Checkout Session whose metadata carries the permalink + offer key (`src/routes/flows/recommender.ts`, `src/services/recommender-capture.ts`, `packages/stripe-client`'s `createQuotedCheckoutSession`). Anonymous, rate-limited; a non-`sk_test_` key is refused before any side effect. No MCP twin — recorded exception: an agent walking a flow has no email to give and no card to pay with; the anonymous MCP surface is identity-blind.
23
44
  - `/v1/content/{types,:type,:type/:slug}` — public content reads
24
45
  - `/v1/auth/tokens`, `/v1/user/{profile,data/:key}` — local auth + user data
@@ -28,9 +49,11 @@ Routes are versioned under `/v1/*`:
28
49
  - `/v1/schedule/availability` (GET), `/v1/schedule/event-meta` (GET), `/v1/schedule/book` (POST) — anonymous scheduling proxy behind the provider seam (`src/services/scheduling/`); Cal.com v2 today, a self-hosted engine later, same three calls. `event-meta` is the meta-only read (title · duration · description · price) so rendering an event's facts never fetches an availability window (#4633). `CAL_API_KEY` is read server-side only. MCP twins: `list_availability` / `get_event_meta` / `create_booking` (#4416, #4633)
29
50
  - `/v1/aeo/score` (POST), `/v1/aeo/score/example` (GET) — anonymous instant AEO score for a respondent-supplied URL, and the bundled pre-launch example, both fed by the SSRF-guarded crawler at `@working-theory/aeo/fetch` and the pure scorer at `@working-theory/aeo` (`src/services/aeo-score.ts`, #4666). No MCP twin — recorded exception, brief D7 (exposing an arbitrary-URL crawler to anonymous agents is a security-posture decision; `apps/mcp/src/tools/audit.ts` deliberately stays same-origin-locked instead).
30
51
  - `/v1/waitlist-experiments` (GET), `/v1/waitlist-experiments/:experimentId` (GET), `/v1/waitlist-experiments/:experimentId/signups` (GET), `/v1/waitlist-experiments/:experimentId/signups/:leadId` (GET) — the operator-dashboard read API for Parallel Waitlist Validation (#4665 D7, B0): tenant-scoped list + rollup, per-waitlist comparison, paginated signups, and a signup drill-down over A1's `WaitlistExperiment` / `WaitlistScore` / `Lead` rows (`src/services/waitlist-dashboard.ts`, #4671). Role floor `owner|admin` (signup PII); the platform-operator scope (`isSentinel(organizationId) && role === "owner"`, ALSO requiring `AILK_OPERATOR_EMAIL` to be set — fail-closed, PR #4687) sees every site, an ordinary owner/admin sees only its own `siteId`. No MCP twin — identity-bound tenant routes (#3591 exception, same shape as `/v1/billing/*`).
31
- - `/v1/waitlist-signups/me` (GET, `?experimentKey=<slug>`) — the respondent read (#4731): a signed-in, **email-verified** user's OWN newest signup for one experiment (`experimentKey`, `waitlistKey`, `completedAt`, `tier`, `score`, `aeoScore`, `answers.q3` — seven fields, nothing more; `src/services/waitlist-signups.ts` is the only read path). Registered in `authScope` only (auth, no tenant guard — a respondent has no workspace). Identity is `request.userId`; the email is the `User`'s, never a parameter; `emailVerified !== true` → 403 `email_unverified` before any `Lead` read; no match → 404 `signup_not_found`; every read scoped to `currentSiteId()`. No MCP twin — identity-bound (#3591 exception).
52
+ - `/v1/waitlist-signups/me` (GET, `?experimentKey=<slug>`) — the respondent read (#4731): a signed-in, **email-verified** user's OWN newest signup for one experiment (`experimentKey`, `waitlistKey`, `completedAt`, `tier`, `score`, `aeoScore`, `answers.q3` — seven fields, nothing more; `src/services/waitlist-signups.ts` is the only read path). Registered in `authScope` only (auth, no tenant guard — a respondent has no workspace). Identity is `request.userId`; the email is the `User`'s, never a parameter; `emailVerified !== true` → 403 `email_unverified` before any `Lead` read; no match → 404 `signup_not_found`; every read scoped to `currentSiteId()`. Module: `signal-collectors` (D-48, #5366). No MCP twin — identity-bound (#3591 exception).
32
53
  - `/v1/flow-checkouts/me` (GET) — the respondent purchases read (#4984, FEAT-022 M2): a signed-in, **email-verified** user's OWN `FlowCheckout` rows, newest first, `[]` when none (`id`, `flowSlug`, `experimentKey`, `offerKey`, `status`, `amountMinor`, `currency`, `period`, `completedAt`, `createdAt` — ten fields, nothing more; `src/services/flow-checkouts.ts` is the only read path). Registered in `authScope` only, beside `/v1/waitlist-signups/me`. Identity is `request.userId`; rows are joined through the promotion link (`Lead.promotedUserId = userId`, `src/services/lead-promotion.ts`) — never by an email, and no query parameter is read; `emailVerified !== true` → 403 `email_unverified` before any `Lead` read; every read scoped to `currentSiteId()`. No MCP twin — identity-bound (#3591 exception).
33
- - `/v1/project-listings/me` (GET) — the FOUNDER'S OWN listings read (#5295): a signed-in user's own `ProjectListing` rows, newest first, `[]` when none. Registered in `authScope` only, beside `/v1/flow-checkouts/me` — a founder is not a workspace member, so the tenant guard's default-deny would answer 403 for their own submission. Identity is `request.userId`; rows are joined through the owner link (`ProjectListing.ownerUserId = userId`, stamped by `src/services/listing-promotion.ts`) — **never** by `founderEmail`, at any stage, and no query parameter is read. `founderEmail` is an unverified string typed into an anonymous form, so a read-time email match would hand one of two people sharing an address the other's submission. The row shape is `projectListingDraftSchema` (the founder-facing shape the anonymous draft read already uses — no `siteId`, `leadId`, `decidedBy`, `issueUrl`, or `experimentKey`). The route is ADDITIVE: `PROJECT_LISTING_ROLES` stays `owner|admin` and the tenant-scoped list/get/patch routes are unchanged. No MCP twin — identity-bound (#3591 exception).
54
+ - `/v1/project-listings/me` (GET) — the FOUNDER'S OWN listings read (#5295): a signed-in user's own `ProjectListing` rows, newest first, `[]` when none. Registered in `authScope` only, beside `/v1/flow-checkouts/me` — a founder is not a workspace member, so the tenant guard's default-deny would answer 403 for their own submission. Identity is `request.userId`; rows are joined through the owner link (`ProjectListing.ownerUserId = userId`, stamped by `src/services/listing-promotion.ts`) — **never** by `founderEmail`, at any stage, and no query parameter is read. `founderEmail` is an unverified string typed into an anonymous form, so a read-time email match would hand one of two people sharing an address the other's submission. The row shape is `projectListingDraftSchema` (the founder-facing shape the anonymous draft read already uses — no `siteId`, `leadId`, `decidedBy`, `issueUrl`, or `experimentKey`). The route is ADDITIVE: `PROJECT_LISTING_ROLES` stays `owner|admin` and the tenant-scoped list/get/patch routes are unchanged. Module: `signal-collectors` (D-48, #5366) — not severable from the anonymous listing-application routes below (same static barrel, D4). No MCP twin — identity-bound (#3591 exception).
55
+ - `/v1/project-listings/{start,submit}` (POST), `/v1/project-listings/:id` (PATCH, draft), `/v1/project-listings/public` (GET) — the anonymous founder's-application lifecycle (#4998, reshaped by #5036): draft start/patch/submit plus the public shelves read, identity-blind and rate-limited alongside the leads routes. Module: `signal-collectors`. No MCP twin — anonymous form-lifecycle routes, not agent-facing.
56
+ - `/v1/slack/actions` (POST) — the project-listing operator decision (Slack Approve/Reject, #4999): verifies the Slack signature, applies the decision via `src/services/project-listing-decision.ts`. Module: `signal-collectors`. No MCP twin — a Slack-signed webhook, not agent-facing.
34
57
 
35
58
  The workspace site-config routes are **identity-bound tenant routes** (guarded by the tenant preHandler; the write scope is the caller's active workspace, never a body-supplied id). Like the sibling `/v1/workspaces/*` routes they have **no anonymous MCP twin** — the OSS MCP surface is identity-blind (`apps/mcp/CLAUDE.md`), so the "1:1 MCP tool" rule above does not apply to them; the tenant-scoped authed MCP surface is tracked in #3591. The `/v1/billing/*` and `/v1/waitlist-experiments/*` routes are the same shape — identity-bound tenant routes, admin/settings-facing rather than agent-facing, no MCP twin.
36
59
 
@@ -118,8 +141,13 @@ sweep's own DB constraint (never a caller-side lock).
118
141
  - Don't return 200 with `{ ok: false }`.
119
142
  - Don't read MDX directly — use `@working-theory/content-adapters`.
120
143
  - Don't put session state in `apps/api`. It's stateless.
144
+ - Don't bundle `apps/api` (esbuild, rollup, webpack). Slice specifiers cannot survive it — see `## Deploy path`.
145
+
146
+ Last updated: 2026-09-14 — doc-sync: signal-collectors module extraction (D-48, #5366) — added the `module: signal-collectors` note to the flows/waitlist-signups-me/project-listings-me endpoints, added the previously-undocumented `/v1/deliverables/:grantId`, `/v1/project-listings/{start,submit,:id,public}` and `/v1/slack/actions` rows — verified against `apps/api/src/server.ts` and each route's own header.
147
+
148
+ Prior: 2026-09-12 — doc-sync: added the `## Deploy path` section and the matching `## What NOT to do` line (#5334), recording that bundling `apps/api` is not a supported deploy path and naming the three gates — verified against `apps/api/vercel.json`, `apps/api/src/lib/slice-load.ts` and `scripts/check-bundled-build-diagnoses.ts`.
121
149
 
122
- Last updated: 2026-09-12 — doc-sync: added `GET /v1/project-listings/me` (#5295), the auth-scoped founder read joined on the owner link, to Endpoint conventions — verified against `apps/api/src/routes/project-listings/me.ts` and `apps/api/src/server.ts`.
150
+ Prior: 2026-09-12 — doc-sync: added `GET /v1/project-listings/me` (#5295), the auth-scoped founder read joined on the owner link, to Endpoint conventions — verified against `apps/api/src/routes/project-listings/me.ts` and `apps/api/src/server.ts`.
123
151
 
124
152
  Prior: 2026-09-07 — doc-sync: added `listing-csv:sweep` (#5001), the weekly founder-CSV sweep, to `## Scheduled sweeps (external cron)` — verified against `apps/api/src/bin/listing-csv-sweep.ts` and `apps/api/package.json`.
125
153
 
@@ -46,7 +46,6 @@
46
46
  "@working-theory/observability": "workspace:*",
47
47
  "@working-theory/schema": "workspace:*",
48
48
  "@working-theory/site-config": "workspace:*",
49
- "@working-theory/stripe-client": "workspace:*",
50
49
  "@working-theory/validation": "workspace:*",
51
50
  "dotenv": "^17.4.2",
52
51
  "fastify": "^5.12.1",