anhedral 0.13.0 → 0.16.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 (360) hide show
  1. package/README.md +23 -229
  2. package/assets/patches/audit-deps.mjs +12 -2
  3. package/assets/stack/ai-schema.ts.txt +5 -0
  4. package/assets/stack/ai.ts.txt +30 -0
  5. package/assets/stack/api-index.ts.txt +15 -0
  6. package/assets/stack/auth-features.ts.txt +4 -0
  7. package/assets/stack/auth-journal.json.txt +13 -0
  8. package/assets/stack/auth-migration.sql.txt +53 -0
  9. package/assets/stack/auth-routes.ts.txt +11 -0
  10. package/assets/stack/auth-schema.ts.txt +64 -0
  11. package/assets/stack/auth-snapshot.json.txt +346 -0
  12. package/assets/stack/auth.ts.txt +32 -0
  13. package/assets/stack/billing-mode.ts.txt +8 -0
  14. package/assets/stack/billing-schema.ts.txt +11 -0
  15. package/assets/stack/desktop.rs.txt +21 -0
  16. package/assets/stack/entitlement-guard.ts.txt +32 -0
  17. package/assets/stack/entitlements.ts.txt +8 -0
  18. package/assets/stack/events-schema.ts.txt +12 -0
  19. package/assets/stack/events.ts.txt +59 -0
  20. package/assets/stack/mobile-auth.ts.txt +25 -0
  21. package/assets/stack/mobile-billing.tsx.txt +63 -0
  22. package/assets/stack/mobile-session.tsx.txt +83 -0
  23. package/assets/stack/native-button.tsx.txt +108 -0
  24. package/assets/stack/native-global.css.txt +4 -0
  25. package/assets/stack/native-lib-utils.ts.txt +5 -0
  26. package/assets/stack/native-metro.config.js.txt +6 -0
  27. package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
  28. package/assets/stack/native-tailwind.config.js.txt +73 -0
  29. package/assets/stack/native-text.tsx.txt +89 -0
  30. package/assets/stack/purchases.ts.txt +65 -0
  31. package/assets/stack/revenuecat.ts.txt +88 -0
  32. package/assets/stack/rtc-schema.ts.txt +10 -0
  33. package/assets/stack/rtc.ts.txt +122 -0
  34. package/assets/stack/security.ts.txt +31 -0
  35. package/assets/stack/storage.ts.txt +36 -0
  36. package/assets/stack/stripe.ts.txt +126 -0
  37. package/assets/stack/web-sign-in.tsx.txt +51 -0
  38. package/assets/ui/LICENSE.react-native-reusables +21 -0
  39. package/assets/ui/LICENSE.shadcn +21 -0
  40. package/assets/ui/UPSTREAM.json +39 -0
  41. package/assets/ui/catalog.json +891 -0
  42. package/assets/ui/extensions/registry.json +6 -0
  43. package/assets/ui/native/_controls.tsx +521 -0
  44. package/assets/ui/native/_core.tsx +118 -0
  45. package/assets/ui/native/_data.tsx +200 -0
  46. package/assets/ui/native/_display.tsx +453 -0
  47. package/assets/ui/native/_feedback.tsx +242 -0
  48. package/assets/ui/native/_legacy-dialog.tsx +38 -0
  49. package/assets/ui/native/_motion.tsx +520 -0
  50. package/assets/ui/native/_overlay.tsx +402 -0
  51. package/assets/ui/native/_selection.tsx +366 -0
  52. package/assets/ui/native/accordion.tsx +1 -0
  53. package/assets/ui/native/alert-dialog.tsx +11 -0
  54. package/assets/ui/native/alert.tsx +1 -0
  55. package/assets/ui/native/aspect-ratio.tsx +1 -0
  56. package/assets/ui/native/attachment.tsx +8 -0
  57. package/assets/ui/native/avatar.tsx +8 -0
  58. package/assets/ui/native/badge.tsx +1 -0
  59. package/assets/ui/native/breadcrumb.tsx +9 -0
  60. package/assets/ui/native/bubble.tsx +1 -0
  61. package/assets/ui/native/button-group.tsx +1 -0
  62. package/assets/ui/native/button.tsx +86 -0
  63. package/assets/ui/native/calendar.tsx +170 -0
  64. package/assets/ui/native/card.tsx +44 -0
  65. package/assets/ui/native/carousel.tsx +1 -0
  66. package/assets/ui/native/chart.tsx +193 -0
  67. package/assets/ui/native/checkbox.tsx +1 -0
  68. package/assets/ui/native/code-block.tsx +137 -0
  69. package/assets/ui/native/collapsible.tsx +1 -0
  70. package/assets/ui/native/combobox.tsx +1 -0
  71. package/assets/ui/native/command.tsx +11 -0
  72. package/assets/ui/native/context-menu.tsx +16 -0
  73. package/assets/ui/native/data-table.tsx +1 -0
  74. package/assets/ui/native/date-picker.tsx +43 -0
  75. package/assets/ui/native/dialog.tsx +15 -0
  76. package/assets/ui/native/direction.tsx +1 -0
  77. package/assets/ui/native/drawer.tsx +10 -0
  78. package/assets/ui/native/dropdown-menu.tsx +16 -0
  79. package/assets/ui/native/empty.tsx +8 -0
  80. package/assets/ui/native/field.tsx +13 -0
  81. package/assets/ui/native/hover-card.tsx +1 -0
  82. package/assets/ui/native/input-group.tsx +8 -0
  83. package/assets/ui/native/input-otp.tsx +1 -0
  84. package/assets/ui/native/input.tsx +28 -0
  85. package/assets/ui/native/item.tsx +12 -0
  86. package/assets/ui/native/kbd.tsx +1 -0
  87. package/assets/ui/native/label.tsx +4 -0
  88. package/assets/ui/native/layout.tsx +26 -0
  89. package/assets/ui/native/marker.tsx +1 -0
  90. package/assets/ui/native/menubar.tsx +17 -0
  91. package/assets/ui/native/message-scroller.tsx +6 -0
  92. package/assets/ui/native/message.tsx +10 -0
  93. package/assets/ui/native/native-select.tsx +1 -0
  94. package/assets/ui/native/navigation-menu.tsx +10 -0
  95. package/assets/ui/native/pagination.tsx +9 -0
  96. package/assets/ui/native/popover.tsx +1 -0
  97. package/assets/ui/native/progress.tsx +1 -0
  98. package/assets/ui/native/questionnaire.tsx +130 -0
  99. package/assets/ui/native/radio-group.tsx +1 -0
  100. package/assets/ui/native/registry.json +1103 -0
  101. package/assets/ui/native/resizable.tsx +1 -0
  102. package/assets/ui/native/scroll-area.tsx +1 -0
  103. package/assets/ui/native/select.tsx +11 -0
  104. package/assets/ui/native/separator.tsx +1 -0
  105. package/assets/ui/native/sheet.tsx +10 -0
  106. package/assets/ui/native/sidebar.tsx +22 -0
  107. package/assets/ui/native/skeleton.tsx +1 -0
  108. package/assets/ui/native/slider.tsx +1 -0
  109. package/assets/ui/native/spinner.tsx +1 -0
  110. package/assets/ui/native/switch.tsx +1 -0
  111. package/assets/ui/native/table.tsx +10 -0
  112. package/assets/ui/native/tabs.tsx +1 -0
  113. package/assets/ui/native/text.tsx +20 -0
  114. package/assets/ui/native/textarea.tsx +1 -0
  115. package/assets/ui/native/theme-switcher.tsx +22 -0
  116. package/assets/ui/native/toast.tsx +11 -0
  117. package/assets/ui/native/toggle-group.tsx +1 -0
  118. package/assets/ui/native/toggle.tsx +1 -0
  119. package/assets/ui/native/tooltip.tsx +1 -0
  120. package/assets/ui/native/trace.tsx +20 -0
  121. package/assets/ui/native/typography.tsx +15 -0
  122. package/assets/ui/theme-storage.ts +25 -0
  123. package/assets/ui/theme.tsx +66 -0
  124. package/assets/ui/web/button.tsx +59 -0
  125. package/assets/ui/web/input.tsx +21 -0
  126. package/assets/ui/web/label.tsx +19 -0
  127. package/dist/bin.js +7 -12
  128. package/dist/capabilities.d.ts +4 -33
  129. package/dist/capabilities.js +2 -84
  130. package/dist/capability-catalog.d.ts +83 -0
  131. package/dist/capability-catalog.js +121 -0
  132. package/dist/capability-command.d.ts +3 -0
  133. package/dist/capability-command.js +188 -0
  134. package/dist/capability-editor.d.ts +17 -0
  135. package/dist/capability-editor.js +97 -0
  136. package/dist/capability-recipes.d.ts +4 -0
  137. package/dist/capability-recipes.js +520 -0
  138. package/dist/capability-references.d.ts +4 -0
  139. package/dist/capability-references.js +7 -0
  140. package/dist/cli-commands.d.ts +1 -2
  141. package/dist/cli-commands.js +10 -104
  142. package/dist/cli-output.d.ts +1 -2
  143. package/dist/cli-output.js +6 -251
  144. package/dist/command-schema.js +40 -374
  145. package/dist/dependencies.d.ts +34 -62
  146. package/dist/dependencies.js +112 -199
  147. package/dist/index.d.ts +1 -45
  148. package/dist/index.js +1 -30
  149. package/dist/platforms/mobile.js +29 -139
  150. package/dist/platforms/web.d.ts +3 -0
  151. package/dist/platforms/web.js +251 -0
  152. package/dist/project-config.d.ts +2 -13
  153. package/dist/project-config.js +10 -83
  154. package/dist/registry/context.js +0 -1
  155. package/dist/registry/options.js +6 -40
  156. package/dist/registry/resolve.d.ts +3 -4
  157. package/dist/registry/resolve.js +18 -108
  158. package/dist/registry/types.d.ts +1 -7
  159. package/dist/registry/usage.js +3 -9
  160. package/dist/runtime-policy.d.ts +0 -2
  161. package/dist/runtime-policy.js +0 -16
  162. package/dist/scaffold/backend.d.ts +0 -4
  163. package/dist/scaffold/backend.js +1 -189
  164. package/dist/scaffold/bootstrap.d.ts +2 -3
  165. package/dist/scaffold/bootstrap.js +37 -43
  166. package/dist/scaffold/compose.js +2 -14
  167. package/dist/scaffold/database.d.ts +1 -1
  168. package/dist/scaffold/database.js +19 -126
  169. package/dist/scaffold/documentation.d.ts +0 -1
  170. package/dist/scaffold/documentation.js +82 -84
  171. package/dist/scaffold/expo-runtime.d.ts +2 -2
  172. package/dist/scaffold/expo-runtime.js +9 -101
  173. package/dist/scaffold/native-ui.d.ts +2 -0
  174. package/dist/scaffold/native-ui.js +74 -0
  175. package/dist/scaffold/stack-documentation.d.ts +0 -1
  176. package/dist/scaffold/stack-documentation.js +3 -49
  177. package/dist/scaffold/storage.d.ts +2 -0
  178. package/dist/scaffold/storage.js +21 -0
  179. package/dist/scaffold/styling.d.ts +1 -1
  180. package/dist/scaffold/styling.js +20 -28
  181. package/dist/scaffold/workspace.js +63 -199
  182. package/dist/stack-registry.d.ts +2 -58
  183. package/dist/stack-registry.js +22 -446
  184. package/dist/standard.js +7 -24
  185. package/dist/ui-catalog.d.ts +26 -0
  186. package/dist/ui-catalog.js +31 -0
  187. package/dist/ui-command.d.ts +3 -0
  188. package/dist/ui-command.js +219 -0
  189. package/dist/ui-project.d.ts +22 -0
  190. package/dist/ui-project.js +110 -0
  191. package/dist/version.d.ts +1 -1
  192. package/dist/version.js +1 -1
  193. package/docs/anhedral-stack.md +4 -119
  194. package/docs/capabilities.md +110 -0
  195. package/docs/native-ui.md +102 -0
  196. package/docs/software-factory.md +16 -577
  197. package/docs/stack-standard.md +11 -307
  198. package/docs/ui.md +33 -0
  199. package/docs/verification.md +511 -0
  200. package/package.json +26 -27
  201. package/dist/access.d.ts +0 -10
  202. package/dist/access.js +0 -93
  203. package/dist/auth-schema-snapshot.d.ts +0 -346
  204. package/dist/auth-schema-snapshot.js +0 -347
  205. package/dist/auth-schema.d.ts +0 -1
  206. package/dist/auth-schema.js +0 -57
  207. package/dist/capability-contract.d.ts +0 -47
  208. package/dist/capability-contract.js +0 -168
  209. package/dist/catalog-model.d.ts +0 -24
  210. package/dist/catalog-model.js +0 -1
  211. package/dist/catalog-registration.d.ts +0 -16
  212. package/dist/catalog-registration.js +0 -22
  213. package/dist/catalog-snapshot.d.ts +0 -5
  214. package/dist/catalog-snapshot.js +0 -97
  215. package/dist/cli-delivery.d.ts +0 -3
  216. package/dist/cli-delivery.js +0 -172
  217. package/dist/cloudflare.d.ts +0 -25
  218. package/dist/cloudflare.js +0 -226
  219. package/dist/delivery-evidence.d.ts +0 -62
  220. package/dist/delivery-evidence.js +0 -186
  221. package/dist/delivery.d.ts +0 -88
  222. package/dist/delivery.js +0 -570
  223. package/dist/inspector-model.d.ts +0 -123
  224. package/dist/inspector-model.js +0 -1
  225. package/dist/integration-service-readers.d.ts +0 -13
  226. package/dist/integration-service-readers.js +0 -173
  227. package/dist/lifecycle-model.d.ts +0 -15
  228. package/dist/lifecycle-model.js +0 -20
  229. package/dist/lifecycle.d.ts +0 -11
  230. package/dist/lifecycle.js +0 -91
  231. package/dist/management.d.ts +0 -3
  232. package/dist/management.js +0 -47
  233. package/dist/mobile-delivery.d.ts +0 -77
  234. package/dist/mobile-delivery.js +0 -366
  235. package/dist/neon-service-data.d.ts +0 -8
  236. package/dist/neon-service-data.js +0 -117
  237. package/dist/platforms/desktop.d.ts +0 -2
  238. package/dist/platforms/desktop.js +0 -415
  239. package/dist/platforms/extension.d.ts +0 -2
  240. package/dist/platforms/extension.js +0 -328
  241. package/dist/project-catalog.d.ts +0 -41
  242. package/dist/project-catalog.js +0 -288
  243. package/dist/project-inspector.d.ts +0 -4
  244. package/dist/project-inspector.js +0 -702
  245. package/dist/project-lifecycle.d.ts +0 -25
  246. package/dist/project-lifecycle.js +0 -57
  247. package/dist/project-state.d.ts +0 -49
  248. package/dist/project-state.js +0 -563
  249. package/dist/provider-auth.d.ts +0 -41
  250. package/dist/provider-auth.js +0 -215
  251. package/dist/provider-readiness.d.ts +0 -30
  252. package/dist/provider-readiness.js +0 -104
  253. package/dist/providers/adapters.d.ts +0 -17
  254. package/dist/providers/adapters.js +0 -278
  255. package/dist/providers/api.d.ts +0 -29
  256. package/dist/providers/api.js +0 -253
  257. package/dist/providers/config.d.ts +0 -15
  258. package/dist/providers/config.js +0 -182
  259. package/dist/providers/definitions.d.ts +0 -318
  260. package/dist/providers/definitions.js +0 -127
  261. package/dist/providers/provision.d.ts +0 -24
  262. package/dist/providers/provision.js +0 -76
  263. package/dist/providers/receipts.d.ts +0 -20
  264. package/dist/providers/receipts.js +0 -66
  265. package/dist/providers/recovery-verification.d.ts +0 -7
  266. package/dist/providers/recovery-verification.js +0 -112
  267. package/dist/providers/recovery.d.ts +0 -30
  268. package/dist/providers/recovery.js +0 -34
  269. package/dist/providers/runtime.d.ts +0 -10
  270. package/dist/providers/runtime.js +0 -265
  271. package/dist/providers/schema.d.ts +0 -28
  272. package/dist/providers/schema.js +0 -49
  273. package/dist/providers/state.d.ts +0 -55
  274. package/dist/providers/state.js +0 -289
  275. package/dist/provision.d.ts +0 -55
  276. package/dist/provision.js +0 -284
  277. package/dist/r2-service-data.d.ts +0 -2
  278. package/dist/r2-service-data.js +0 -136
  279. package/dist/readiness.d.ts +0 -23
  280. package/dist/readiness.js +0 -122
  281. package/dist/registry/add.d.ts +0 -24
  282. package/dist/registry/add.js +0 -270
  283. package/dist/registry/bootstrap.d.ts +0 -2
  284. package/dist/registry/bootstrap.js +0 -14
  285. package/dist/registry/commands.d.ts +0 -3
  286. package/dist/registry/commands.js +0 -85
  287. package/dist/registry/presets.d.ts +0 -4
  288. package/dist/registry/presets.js +0 -41
  289. package/dist/registry/preview.d.ts +0 -11
  290. package/dist/registry/preview.js +0 -91
  291. package/dist/registry/receipt.d.ts +0 -3
  292. package/dist/registry/receipt.js +0 -68
  293. package/dist/repository.d.ts +0 -24
  294. package/dist/repository.js +0 -96
  295. package/dist/scaffold/auth.d.ts +0 -3
  296. package/dist/scaffold/auth.js +0 -151
  297. package/dist/scaffold/billing-config.d.ts +0 -1
  298. package/dist/scaffold/billing-config.js +0 -73
  299. package/dist/scaffold/billing-contracts.d.ts +0 -2
  300. package/dist/scaffold/billing-contracts.js +0 -48
  301. package/dist/scaffold/billing-providers.d.ts +0 -1
  302. package/dist/scaffold/billing-providers.js +0 -249
  303. package/dist/scaffold/billing-schema.d.ts +0 -1
  304. package/dist/scaffold/billing-schema.js +0 -34
  305. package/dist/scaffold/billing-security.d.ts +0 -1
  306. package/dist/scaffold/billing-security.js +0 -46
  307. package/dist/scaffold/billing-server.d.ts +0 -1
  308. package/dist/scaffold/billing-server.js +0 -139
  309. package/dist/scaffold/billing-store.d.ts +0 -1
  310. package/dist/scaffold/billing-store.js +0 -72
  311. package/dist/scaffold/billing.d.ts +0 -2
  312. package/dist/scaffold/billing.js +0 -216
  313. package/dist/scaffold/cloudflare-services.d.ts +0 -8
  314. package/dist/scaffold/cloudflare-services.js +0 -198
  315. package/dist/scaffold/expo-auth.d.ts +0 -3
  316. package/dist/scaffold/expo-auth.js +0 -192
  317. package/dist/scaffold/expo-billing.d.ts +0 -3
  318. package/dist/scaffold/expo-billing.js +0 -292
  319. package/dist/scaffold/integrations.d.ts +0 -4
  320. package/dist/scaffold/integrations.js +0 -12
  321. package/dist/scaffold/lint.d.ts +0 -4
  322. package/dist/scaffold/lint.js +0 -56
  323. package/dist/scaffold/neon-realtime.d.ts +0 -2
  324. package/dist/scaffold/neon-realtime.js +0 -97
  325. package/dist/scaffold/services.d.ts +0 -5
  326. package/dist/scaffold/services.js +0 -108
  327. package/dist/scaffold/stream.d.ts +0 -2
  328. package/dist/scaffold/stream.js +0 -114
  329. package/dist/scaffold/void.d.ts +0 -4
  330. package/dist/scaffold/void.js +0 -264
  331. package/dist/scaffold/web.d.ts +0 -2
  332. package/dist/scaffold/web.js +0 -130
  333. package/dist/service-deletion.d.ts +0 -29
  334. package/dist/service-deletion.js +0 -195
  335. package/dist/service-descriptor.d.ts +0 -10
  336. package/dist/service-descriptor.js +0 -78
  337. package/dist/service-model.d.ts +0 -49
  338. package/dist/service-model.js +0 -8
  339. package/dist/service-operations.d.ts +0 -29
  340. package/dist/service-operations.js +0 -78
  341. package/dist/service-readers.d.ts +0 -8
  342. package/dist/service-readers.js +0 -247
  343. package/dist/services-command.d.ts +0 -39
  344. package/dist/services-command.js +0 -102
  345. package/dist/ship.d.ts +0 -348
  346. package/dist/ship.js +0 -239
  347. package/dist/vercel-project.d.ts +0 -101
  348. package/dist/vercel-project.js +0 -305
  349. package/dist/vercel.d.ts +0 -67
  350. package/dist/vercel.js +0 -581
  351. package/dist/vinext.d.ts +0 -2
  352. package/dist/vinext.js +0 -86
  353. package/dist/void-execution.d.ts +0 -10
  354. package/dist/void-execution.js +0 -94
  355. package/dist/void-migrations.d.ts +0 -6
  356. package/dist/void-migrations.js +0 -110
  357. package/dist/void-state.d.ts +0 -16
  358. package/dist/void-state.js +0 -65
  359. package/dist/void.d.ts +0 -3
  360. package/dist/void.js +0 -5
@@ -1,35 +1,23 @@
1
- import { scaffoldCloudflareServiceContext } from './cloudflare-services.js';
2
1
  import { writeProjectSection } from '../project-config.js';
3
- import { existsSync, rmSync } from 'node:fs';
2
+ import { existsSync } from 'node:fs';
4
3
  import path from 'node:path';
5
4
  import { installStackItem } from '../stack-registry.js';
6
5
  import { createRecipeContext } from '../registry/context.js';
7
6
  import { inspectWorkspaceGraph } from '../workspace-graph.js';
8
7
  import { writeStandardRoot } from './workspace.js';
9
- import { normalizeSharedLint } from './lint.js';
10
- import { configureVoidDelivery } from './void.js';
11
8
  /** Only used in a fresh staged workspace. Existing applications are never overlaid. */
12
9
  export async function composeStack(root, options, registry) {
13
10
  const context = createRecipeContext(root, options);
14
- if (!context.has('next') && !context.has('vinext')) {
15
- for (const directory of ['apps/web', 'packages/ui'])
16
- rmSync(path.join(root, directory), { recursive: true, force: true });
17
- }
18
11
  for (const item of registry.items)
19
12
  Object.assign(context.bindings, item.bindings);
20
13
  for (const item of registry.items) {
21
14
  if (item.installer === 'recipe')
22
15
  await installStackItem(item, context);
23
16
  }
24
- scaffoldCloudflareServiceContext(context);
25
- normalizeSharedLint(root);
26
17
  writeStandardRoot(root, options, registry);
27
- configureVoidDelivery(root);
28
18
  for (const item of registry.items) {
29
19
  for (const target of item.targets) {
30
- if (!existsSync(path.join(root, target)) &&
31
- !(target.endsWith('/wrangler.jsonc') &&
32
- existsSync(path.join(root, target.replace('/wrangler.jsonc', '/anhedral.cloudflare.json')))))
20
+ if (!existsSync(path.join(root, target)))
33
21
  throw new Error(`Registry target missing: ${item.name} -> ${target}.`);
34
22
  }
35
23
  }
@@ -1,2 +1,2 @@
1
1
  import type { RecipeContext } from '../registry/types.js';
2
- export declare function scaffoldDatabase({ root, options, runtimeApp, has }: RecipeContext): void;
2
+ export declare function scaffoldDatabase({ root }: RecipeContext): void;
@@ -1,148 +1,41 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
- import { writeEnvironmentFile } from './environment.js';
4
3
  import { STACK_DEPENDENCIES } from '../dependencies.js';
5
- import { put, patchPackage, readJson, json, sharedPackage } from './files.js';
6
- export function scaffoldDatabase({ root, options, runtimeApp, has }) {
7
- const app = `apps/${runtimeApp}`;
8
- const postgres = has('neon');
9
- const directory = 'packages/db';
10
- sharedPackage(root, 'db', postgres
11
- ? `import { drizzle } from 'drizzle-orm/neon-http';
12
- import { neon } from '@neondatabase/serverless';
13
- import * as schema from './schema';
14
- export function createDatabase(connectionString: string) {
15
- // HTTP supports independent queries and batches; migrations use a separate transactional connection.
16
- return drizzle(neon(connectionString), { schema });
17
- }
18
- `
19
- : `import { drizzle } from 'drizzle-orm/d1';
4
+ import { put, patchPackage, sharedPackage } from './files.js';
5
+ export function scaffoldDatabase({ root }) {
6
+ sharedPackage(root, 'db', `import { drizzle } from 'drizzle-orm/d1';
20
7
  import * as schema from './schema';
21
8
  export function createDatabase(binding: Parameters<typeof drizzle>[0]) { return drizzle(binding, { schema }); }
22
- `, {
23
- 'drizzle-orm': STACK_DEPENDENCIES['drizzle-orm'],
24
- ...(postgres
25
- ? { '@neondatabase/serverless': STACK_DEPENDENCIES['@neondatabase/serverless'] }
26
- : {}),
27
- });
28
- put(root, `${directory}/src/schema.ts`, '// Define product tables here; generate and review SQL before migration.\nexport {};\n');
29
- put(root, `${directory}/drizzle/.gitkeep`, '');
30
- if (postgres)
31
- put(root, `${directory}/migration-environment.ts`, `import { existsSync } from 'node:fs';
32
- import { loadEnvFile } from 'node:process';
33
- import { fileURLToPath } from 'node:url';
34
- const root = new URL('./', import.meta.url);
35
- export function migrationEnvironment() {
36
- // Existing process values win; local overrides precede shared defaults.
37
- for (const name of ['.env.local', '.env']) {
38
- const file = fileURLToPath(new URL(name, root));
39
- if (existsSync(file)) loadEnvFile(file);
40
- }
41
- return { root, connectionString: process.env.DATABASE_URL_UNPOOLED };
42
- }
43
- `);
44
- put(root, `${directory}/drizzle.config.ts`, postgres
45
- ? `import { relative } from 'node:path';
46
- import { fileURLToPath } from 'node:url';
47
- import { defineConfig } from 'drizzle-kit';
48
- import { migrationEnvironment } from './migration-environment';
49
- const { root, connectionString: url } = migrationEnvironment();
50
- export default defineConfig({
51
- dialect: 'postgresql',
52
- schema: fileURLToPath(new URL('./src/schema.ts', root)),
53
- out: relative(process.cwd(), fileURLToPath(new URL('./drizzle/', root))),
54
- ...(url ? { dbCredentials: { url } } : {}),
55
- });
56
- `
57
- : `import { fileURLToPath } from 'node:url';
9
+ `, { 'drizzle-orm': STACK_DEPENDENCIES['drizzle-orm'] });
10
+ put(root, 'packages/db/src/schema.ts', '// Add application tables here. Generate and review SQL before migration.\nexport {};\n');
11
+ put(root, 'packages/db/drizzle/.gitkeep', '');
12
+ put(root, 'packages/db/drizzle.config.ts', `import { fileURLToPath } from 'node:url';
58
13
  import { relative } from 'node:path';
59
14
  import { defineConfig } from 'drizzle-kit';
60
- export default defineConfig({
61
- dialect: 'sqlite',
62
- schema: fileURLToPath(new URL('./src/schema.ts', import.meta.url)),
63
- out: relative(process.cwd(), fileURLToPath(new URL('./drizzle/', import.meta.url))),
64
- });
15
+ export default defineConfig({ dialect: 'sqlite', schema: fileURLToPath(new URL('./src/schema.ts', import.meta.url)), out: relative(process.cwd(), fileURLToPath(new URL('./drizzle/', import.meta.url))) });
65
16
  `);
66
- put(root, `${directory}/src/migrate.ts`, postgres
67
- ? `import { fileURLToPath } from 'node:url';
68
- import { Pool, neonConfig } from '@neondatabase/serverless';
69
- import { drizzle } from 'drizzle-orm/neon-serverless';
70
- import { migrate } from 'drizzle-orm/neon-serverless/migrator';
71
- import { migrationEnvironment } from '../migration-environment';
72
- const { root, connectionString } = migrationEnvironment();
73
- if (!connectionString) throw new Error('Configure DATABASE_URL_UNPOOLED for the intended migration branch and role.');
74
- let url: URL;
75
- try { url = new URL(connectionString); } catch { throw new Error('Configure a valid direct PostgreSQL migration URL.'); }
76
- if (!['postgres:', 'postgresql:'].includes(url.protocol) || url.hostname.includes('-pooler.'))
77
- throw new Error('Migrations require a direct PostgreSQL connection.');
78
- neonConfig.webSocketConstructor = WebSocket;
79
- const pool = new Pool({ connectionString });
80
- try {
81
- await migrate(drizzle(pool), { migrationsFolder: fileURLToPath(new URL('drizzle/', root)) });
82
- } catch {
83
- throw new Error('Database migration failed. Inspect the selected branch and migration history before retrying.');
84
- } finally {
85
- await pool.end();
86
- }
87
- `
88
- : `import { spawnSync } from 'node:child_process';
17
+ put(root, 'packages/db/src/migrate.ts', `import { spawnSync } from 'node:child_process';
89
18
  import { fileURLToPath } from 'node:url';
90
19
  const args = process.argv.slice(2);
91
- if (args.length > 1 || args.some((arg) => !['--local', '--remote'].includes(arg)))
92
- throw new Error('Usage: pnpm db:migrate [--local|--remote] (defaults to local).');
20
+ if (args.length > 1 || args.some((arg) => !['--local', '--remote'].includes(arg))) throw new Error('Usage: pnpm db:migrate [--local|--remote] (defaults to local).');
93
21
  const pnpm = process.env.npm_execpath;
94
22
  if (!pnpm) throw new Error('Run migrations through pnpm db:migrate.');
95
- const root = fileURLToPath(new URL('../../../apps/${runtimeApp}/', import.meta.url));
96
- const result = spawnSync(process.execPath, [pnpm, 'exec', 'wrangler', 'd1', 'migrations', 'apply', 'DB',
97
- args[0] ?? '--local', '--config', fileURLToPath(new URL('../../../apps/${runtimeApp}/wrangler.jsonc', import.meta.url)),
98
- ], { cwd: root, stdio: 'inherit', shell: false });
23
+ const root = fileURLToPath(new URL('../../../apps/api/', import.meta.url));
24
+ const result = spawnSync(process.execPath, [pnpm, 'exec', 'wrangler', 'd1', 'migrations', 'apply', 'DB', args[0] ?? '--local', '--config', fileURLToPath(new URL('../../../apps/api/wrangler.jsonc', import.meta.url))], { cwd: root, stdio: 'inherit', shell: false });
99
25
  if (result.error) throw result.error;
100
26
  process.exitCode = result.status ?? 1;
101
27
  `);
102
- patchPackage(root, `${directory}/package.json`, {
28
+ patchPackage(root, 'packages/db/package.json', {
103
29
  exports: { '.': './src/index.ts', './schema': './src/schema.ts' },
104
- dependencies: {
105
- 'drizzle-orm': STACK_DEPENDENCIES['drizzle-orm'],
106
- ...(postgres
107
- ? { '@neondatabase/serverless': STACK_DEPENDENCIES['@neondatabase/serverless'] }
108
- : {}),
109
- },
110
30
  devDependencies: {
111
31
  'drizzle-kit': STACK_DEPENDENCIES['drizzle-kit'],
112
- tsx: STACK_DEPENDENCIES['tsx'],
113
- ...(!postgres ? { wrangler: STACK_DEPENDENCIES['wrangler'] } : {}),
32
+ tsx: STACK_DEPENDENCIES.tsx,
33
+ wrangler: STACK_DEPENDENCIES.wrangler,
114
34
  },
115
35
  scripts: { 'db:generate': 'drizzle-kit generate', 'db:migrate': 'tsx src/migrate.ts' },
116
36
  });
117
- const tsconfig = readJson(root, `${directory}/tsconfig.json`);
118
- tsconfig.include = [...new Set([...(tsconfig.include ?? []), 'drizzle.config.ts'])];
119
- json(root, `${directory}/tsconfig.json`, tsconfig);
120
- if (has('hono')) {
121
- patchPackage(root, 'apps/api/package.json', {
122
- dependencies: { '@workspace/db': 'workspace:*' },
123
- });
124
- const source = readFileSync(path.join(root, 'apps/api/src/index.ts'), 'utf8');
125
- put(root, 'apps/api/src/index.ts', "import { createDatabase } from '@workspace/db';\n" +
126
- source
127
- .replace(source.includes('Variables: {') ? 'Variables: {' : 'Bindings: Env', source.includes('Variables: {')
128
- ? 'Variables: { database: () => ReturnType<typeof createDatabase>;'
129
- : 'Bindings: Env; Variables: { database: () => ReturnType<typeof createDatabase> }')
130
- .replace('const health = createRoute({', `// Construct the database only when a route needs it: c.get('database')().
131
- app.use('/api/*', async (c, next) => {
132
- c.set('database', () => createDatabase(${postgres ? 'c.env.DATABASE_URL' : 'c.env.DB'}));
133
- await next();
134
- });
135
- const health = createRoute({`));
136
- }
137
- if (postgres) {
138
- const native = runtimeApp === 'web' && options.hosting === 'vercel';
139
- writeEnvironmentFile(root, `${app}/${native ? '.env.example' : '.dev.vars.example'}`, {
140
- DATABASE_URL: '',
141
- });
142
- writeEnvironmentFile(root, `${directory}/.env.example`, { DATABASE_URL_UNPOOLED: '' });
143
- if (!native)
144
- put(root, `${app}/${runtimeApp === 'api' ? 'src/' : ''}database-secrets.d.ts`, runtimeApp === 'api'
145
- ? 'interface Env { DATABASE_URL: string }\n'
146
- : 'declare namespace Cloudflare { interface Env { DATABASE_URL: string } }\n');
147
- }
37
+ patchPackage(root, 'apps/api/package.json', { dependencies: { '@workspace/db': 'workspace:*' } });
38
+ const source = readFileSync(path.join(root, 'apps/api/src/index.ts'), 'utf8');
39
+ put(root, 'apps/api/src/index.ts', "import { createDatabase } from '@workspace/db';\n" +
40
+ source.replace('const app = new OpenAPIHono<{ Bindings: Env }>();', "const app = new OpenAPIHono<{ Bindings: Env; Variables: { database: () => ReturnType<typeof createDatabase> } }>();\napp.use('*', async (c, next) => { c.set('database', () => createDatabase(c.env.DB)); await next(); });"));
148
41
  }
@@ -1,3 +1,2 @@
1
1
  import type { StandardOptions } from '../registry/types.js';
2
- export declare function workerBuildSuffix(options: StandardOptions): string;
3
2
  export declare function writeSetupDocumentation(root: string, options: StandardOptions): void;
@@ -1,104 +1,102 @@
1
- import { usesVoidSelection } from '../runtime-policy.js';
2
- import { markdownHeading } from '../render.js';
3
- import { existsSync, readFileSync } from 'node:fs';
4
- import path from 'node:path';
1
+ import { capabilityReferences } from '../capability-references.js';
5
2
  import { put } from './files.js';
6
- export function workerBuildSuffix(options) {
7
- return options.products.includes('next') && options.hosting === 'cloudflare'
8
- ? ' && pnpm build:worker'
9
- : '';
10
- }
11
3
  export function writeSetupDocumentation(root, options) {
12
- const has = (product) => options.products.includes(product);
13
- const agentsFile = path.join(root, 'AGENTS.md');
14
- const voidSelected = usesVoidSelection(options.products, options.hosting);
15
- const existingAgents = existsSync(agentsFile) && (has('next') || has('vinext'))
16
- ? readFileSync(agentsFile, 'utf8') + '\n'
17
- : '';
18
- put(root, 'AGENTS.md', existingAgents +
19
- `# Anhedral delivery standard
20
-
21
- Keep accounts, source, infrastructure, billing, and recovery client-owned. Use the available developer tools and the selected platforms’ native toolchains for implementation and verification. Use provider plugins, APIs/MCP and CLIs for operations; Void owns Cloudflare provisioning and deployment for supported selections; Anhedral owns composition, customer ownership and verification. New Expo workspaces, explicit OpenNext, queue/DLQ and Basin selections use Wrangler delivery.
22
-
23
- Plain init creates a minimal Expo client with shadcn conventions, NativeWind and shared styling. Generate Hono, contracts, database, auth, storage and integrations only when selected or required by selected capabilities. Use --preset full-product for the complete compatible selection, not mutually exclusive alternatives. Inspect docs/stack.md and anhedral.json for this project's actual selection. New Expo static web uses Cloudflare; native uses EXPO_PUBLIC_API_URL only when an API is selected. Next.js on Vercel and Vinext on Cloudflare are explicit alternatives. Respect account, budget, audience and release scope. Initialization does not deploy or activate paid services.
4
+ if (!options.products.includes('hono') && !options.products.includes('expo')) {
5
+ for (const [file, source] of Object.entries(capabilityReferences()))
6
+ put(root, file, source);
7
+ put(root, 'README.md', `# ${options.name}
8
+
9
+ Next.js on Cloudflare Workers through OpenNext, with Anhedral UI from the start.
10
+ Init creates only apps/web. Use anhedral stack status to inspect later source additions.
11
+ No providers are provisioned by source generation.
12
+
13
+ ## Develop
14
+
15
+ Use the Node/pnpm versions in package.json. Run pnpm install if generation skipped
16
+ installation, then pnpm dev. Open the URL printed by Next.js.
17
+
18
+ ## Anhedral UI
19
+
20
+ The initial page uses editable Button, Input and Label source from the reviewed
21
+ shadcn baseline. Application-local source belongs to you. Shared tokens live in
22
+ packages/styling; preserve attribution in ANHEDRAL_UI_LICENSES and UPSTREAM.json.
23
+ Anhedral UI is a CLI/catalog/theme convention, not a runtime component package.
24
+
25
+ Use anhedral ui list, anhedral ui add card --web, anhedral ui diff button --web,
26
+ and anhedral ui doctor --web. Use --cwd apps/web to select this application or
27
+ --all explicitly for multiple clients. --dry-run previews init/add without network
28
+ or writes. Updates are opt-in; never overwrite customized components silently.
29
+
30
+ Native UI uses the React Native Reusables NativeWind registry in compatible Expo
31
+ projects, preferring reviewed Anhedral extensions when present. It requires Expo,
32
+ not a backend. Use anhedral add expo, then add native-ui, for the reviewed client/setup recipes.
33
+ Standalone UI commands do not create native clients or backend services; existing
34
+ Expo applications need the upstream NativeWind/RNR setup before native ui init.
35
+
36
+ ## Add strategically
37
+
38
+ Add Hono when a dedicated API is justified, then Drizzle/D1/Better Auth when the
39
+ product needs data and authentication. Use anhedral add <capability> --dry-run --json
40
+ to review changes, then apply them. Missing parents require explicit selection or
41
+ --with-dependencies. See docs/anhedral/capabilities.md for the complete catalog and
42
+ source-protection contract. No provision or deployment command is implemented here.
43
+ Consumers own integrations, deployment and application distribution. Run pnpm check
44
+ and review your changes before deployment. Builds/startup never migrate databases.
45
+ `);
46
+ put(root, 'AGENTS.md', `# Minimal application foundation
47
+
48
+ Start with Next.js/OpenNext/Workers and source-owned Anhedral UI. Do not add an API,
49
+ database, authentication, R2 or native client without a concrete feature need.
50
+ Use anhedral add and stack list/status/doctor to compose selected capabilities.
51
+ Preview additions first, preserve edited source, and configure selected auth methods
52
+ explicitly. Source installation is not provider activation. Use anhedral ui
53
+ add/list/diff/doctor to manage platform-specific source; web uses
54
+ official shadcn and native uses RNR/NativeWind with reviewed Anhedral extensions.
55
+ UI requires its application platform, not Hono or a database. Share tokens, not
56
+ DOM/native primitives. Preserve consumer edits, attribution and upstream metadata.
57
+ Never automatically overwrite installed components. Read version-matched framework
58
+ guides and run pnpm check. Never migrate a configured database during checks/builds.
59
+ `);
60
+ put(root, 'docs/architecture.md', '# Architecture\n\nNext.js → OpenNext → Cloudflare Workers, with Anhedral UI. Record feature-driven additions here.\n');
61
+ put(root, 'docs/verification.md', '# Verification\n\nRecord commands, outcomes and environment. Source generation is not deployment acceptance.\n');
62
+ return;
63
+ }
64
+ put(root, 'README.md', `# ${options.name}
24
65
 
25
- Hono owns server identity, authorization, persistence and privileged integrations. Web routes only proxy/adapt API calls. Share framework-independent validation and HTTP clients in packages/contracts; applications never import another app’s source. Use pnpm workspaces and Turborepo with one root pnpm-lock.yaml. Add apps and shared packages only when needed. All services belong in apps/*, reusable code in packages/*. Shared styling is named styling. Keep secrets and privileged integrations out of client bundles. When accounts are selected, prefer Better Auth unless Clerk is explicitly selected; native Clerk integration remains owner implementation. Preserve selected supported identity providers in existing and explicit compatibility profiles. Protect product routes explicitly and implement resource authorization.
66
+ Next.js App Router/OpenNext + Expo native + shadcn UI + Hono/workerd + Drizzle/D1 + private R2.
26
67
 
27
- Use private R2 Worker bindings. KV is eventually consistent configuration/cache, never transactional authority. Neon uses Drizzle and direct serverless HTTP with a server-only DATABASE_URL. HTTP supports independent queries and batches; interactive transactions require a reviewed WebSocket or PostgreSQL adapter. Define job retries, concurrency, idempotency and failure handling. Keep database factories and schemas in packages/db/src, SQL and metadata in packages/db/drizzle, and migration configuration in packages/db/drizzle.config.ts. Only server packages import @workspace/db; clients use API contracts and endpoints. Review generated SQL before deployment. One server target owns deployment migrations; other server targets only consume the database. Manual migration tasks are uncached and never part of builds or startup. Review SQL migrations before applying them.
68
+ ## Develop locally
28
69
 
29
- ${has('neon-realtime') ? 'Neon Realtime uses separate @workspace/neon-realtime/server and /client exports; follow packages/neon-realtime/README.md. Enable the intended branch and exact allowed origins manually. Keep DATABASE_URL and NEON_REALTIME_SECRET server-only; pass the public NEON_REALTIME_URL to clients through framework-specific public configuration. Authenticate query sealing, derive user/tenant scope from verified identity and implement bounded read-only queries, renewal and cross-tenant checks. Neon Realtime is beta without RLS; no arbitrary SQL endpoint, automatic Realtime provisioning or verified product flow is generated.\n' : ''}
70
+ Use the Node and pnpm versions in package.json. Run pnpm install if generation used --skip-install. Run pnpm dev and open the web URL printed by Next (normally http://localhost:3000). Hono runs on http://127.0.0.1:8787; web /api/health proxies to it. No accounts or secrets are needed for the starter health flow.
30
71
 
31
- Developer tooling includes Cloudflare’s security-audit skill (https://github.com/cloudflare/security-audit-skill) for repository security reviews.
72
+ Start native separately with pnpm --dir apps/mobile start. Copy apps/mobile/.env.example to apps/mobile/.env and set EXPO_PUBLIC_API_URL to the API origin reachable from the device. Local HTTP is development-only; use HTTPS outside development.
32
73
 
33
- For new projects, guide GitHub sign-in and the user's Git identity. Review files and secret ignores, commit the initial source, then use anhedral repository --create for a private repository under the authenticated user. Preserve existing origins and visibility; use an explicitly selected organization when requested. Connect Vercel with --git and verify actual GitHub installation access. For Git delivery, commit and push reviewed changes, wait for production, then use anhedral adopt and anhedral verify. Adoption checks exact repository, production branch and commit without uploading again. Use anhedral ship only for an explicit CLI delivery. Recover a fresh clone with anhedral recover; rerun product verification because prior test evidence is not recovered. Use anhedral doctor --providers to inspect installed tools and recorded provider context.
74
+ ## UI and device capabilities
34
75
 
35
- Keep project identity, setup, registry, provider settings and selected hosting configuration in the single root anhedral.json. Consult docs/stack.md for the current generated options, targets and setup requirements. Maintain docs/architecture.md with selected components, rationale, alternatives, data/access boundaries, and a diagram of actual connections. Maintain docs/verification.md with product acceptance criteria, exercised flows, evidence, and blockers. Generated setup is a starter, not implemented product behavior.
76
+ Web uses DOM shadcn; native uses editable source in packages/native-ui. Share tokens through packages/styling. The shadcn fork is an upstream review source, not an application runtime dependency. Review copied provenance and licenses; adopt later UI changes explicitly without overwriting your edits.
36
77
 
37
- For maintenance, treat static-analysis findings as candidates: trace dynamic entrypoints, shared consumers and authoritative live configuration before removing code or flags. Preserve kill switches, recovery paths and access controls. Keep one cleanup rationale per change and record evidence and remaining uncertainty in docs/verification.md. Diagnose flaky tests from CI history and causal evidence; fix the cause without weakening assertions or required checks. Change agent instructions in response to demonstrated failures, keeping shared context short. The Anhedral software factory's evidence-driven maintenance section supplies the detailed workflow.
78
+ Use Expo SDK packages directly for application capabilities. UI components may compose them for presentation, such as a Copy button using Expo Clipboard; application permissions, background work, uploads and push registration belong to your application. Keep the tested Expo/React Native/React runtime consistent with native-ui peers. Add packages as needed from apps/mobile with pnpm expo install <package>, checking platform support and native configuration. Rebuild the development client after native dependency/configuration changes. Validate web separately from Android/iOS; use physical devices for device-only capabilities.
38
79
 
39
- Run pnpm check. Starters contain no application tests yet: add workspace tests and a meaningful root test:live script before claiming product verification. Use pnpm exec fallow during development and pnpm exec fallow audit for changes. Fix legitimate findings; use narrow documented exceptions. Verify real UI flows with Computer Use and Control Chrome, plus relevant integrations, native apps/simulators, and deployed previews. Carry an authorized build-and-ship request through deployment and live verification; ask only for authorization that is still missing.
40
- `);
41
- put(root, 'README.md', `# ${markdownHeading(options.name)}
80
+ ## Data and private storage
42
81
 
43
- Initialized with the Anhedral Application Stack & Delivery Standard and pnpm/Turborepo. Expo uses universal frontend tooling; explicit Vinext/Next.js uses the pinned shadcn monorepo foundation.
82
+ Add tables in packages/db/src/schema.ts. Run pnpm db:generate, review SQL, then explicitly run pnpm db:migrate (local by default). Builds and startup do not migrate databases. Configure real D1 and private R2 identities in apps/api/wrangler.jsonc for your own deployment. Never enable public bucket access or put service credentials in clients.
44
83
 
45
- Initial selection: ${options.products.join(', ')}. Project configuration is recorded in anhedral.json: identity, setup, standard, registry, providers, and the selected cloudflare/vercel hosting sections. Current selections and additions are summarized in [docs/stack.md](docs/stack.md). ${has('vinext') ? 'Vinext App Router on Cloudflare Workers.' : has('next') ? `Next.js hosting: ${options.hosting === 'cloudflare' ? 'Cloudflare Workers + OpenNext' : 'Vercel (native Next.js default)'}.` : ''}
84
+ apps/api/src/private-storage.ts is a server-side helper; it exposes no file routes. Implement your application's identity, authorization, ownership and limits before exposing database or object APIs.
46
85
 
47
- Run pnpm install, commit pnpm-lock.yaml, then pnpm dev. Run pnpm check for lint, types, Fallow audit, tests and build. Without a Git comparison base, audit runs the full Fallow gate. Add meaningful product tests and integration checks as behavior is implemented. The tests task runs only workspaces that define tests; init does not claim product verification.
86
+ ## Your application
48
87
 
49
- ${has('next') && options.hosting === 'vercel' ? 'Native Next.js uses customer-owned Vercel. Connect with the intended scope and personal/commercial use before shipping. Default to private all-deployment protection unless public access was requested; verify protection before linking Git or uploading code. Run anhedral doctor --providers for prerequisites and recorded provider context. Configure server secrets in that project; use cache components, partial prefetching, Link navigation and Suspense deliberately. ' : ''}${voidSelected ? 'Void owns provisioning and publication in the customer account. Keep explicit resources in anhedral.cloudflare.json and configuration in void.config.ts; commit void.lock.json after provisioning and serialize initial deployment across apps. Generated .void/ and .void-wrangler.jsonc are ignored. Copy each app’s env.example to its .env for local tooling; production server secrets use void secret with values passed via stdin. Local dotenv files remain private and untracked; they are not bundled into source or client assets. Supply public VITE_* values for Vite clients through the build environment. Vinext loads the app .env for local builds and maps NEXT_PUBLIC_* values into client bundles; supply those values in the production build environment. Generate Worker types before development. ' : ''}${has('vinext') ? 'Build with pnpm build, then pnpm --dir apps/web preview to exercise the production Worker. Vinext provides a Next-compatible API surface; native Next.js is an explicit framework option. ' : ''}${has('next') && options.hosting === 'cloudflare' ? 'Use the web preview script to exercise the actual OpenNext Worker runtime. ' : ''}Initialization does not provision infrastructure or deploy.
88
+ You own development, authentication, email, payments and hosting. Add Stripe or RevenueCat yourself if needed. This scaffold has no Platform account, managed provider connection or production activation. Generated configuration and scripts are yours to change. See docs/stack.md and run pnpm check before reviewing changes.
89
+ `);
90
+ put(root, 'AGENTS.md', `# Application foundation
50
91
 
51
- ${has('expo') ? 'apps/mobile is the universal Expo web/iOS/Android frontend. Root pnpm dev exports static web and starts its Wrangler gateway on port 3000 plus Hono on port 8787 when selected. Native Metro uses pnpm --dir apps/mobile start; native iOS/Android scripts remain available. Browser changes require pnpm --dir apps/mobile build:web to re-export initially; no HMR is implied. worker/index.ts is the asset gateway and dist holds web assets. New Expo workspaces use Wrangler for selected Cloudflare targets. Export static web for the Cloudflare asset gateway. If Hono is selected, /api/* routes through its API binding before asset fallback; native uses public EXPO_PUBLIC_API_URL. Without Hono there is no API binding or origin to configure. Server credentials remain outside client bundles. Validate browser/API routing and iOS/Android exports separately; exports are not device or store acceptance. SDK 57 stays pinned. Static dynamic routes need generateStaticParams at build time or a deliberately implemented SPA/server profile; unknown paths do not gain SSR automatically. Experimental Expo SSR is not enabled by default. ' : ''}${has('hono') ? 'Hono is the backend. packages/contracts supplies public validation and the HTTP client. API /health and /openapi.json are public diagnostics; product routes require explicit authorization. ' : ''}${has('hono') && (has('vinext') || has('next')) ? `Web /api/* proxies to Hono and forwards session cookies. Check /api/health through the web origin. ${options.hosting === 'cloudflare' ? 'The web API service binding targets the API Worker; start both with root pnpm dev.' : 'Configure server-only apps/web/.env.local API_URL for local development and the web deployment environment API_URL with the API HTTPS origin before delivery. For a Cloudflare Access-protected API, configure a scoped service-token policy and server-only API_ACCESS_CLIENT_ID/API_ACCESS_CLIENT_SECRET on Vercel.'} Web never receives database/auth-server secrets. ` : ''}${has('hono') && (has('d1') || has('neon')) ? "Hono routes use c.get('database')() for a lazy Drizzle connection. " : ''}${has('better-auth') && (has('vinext') || has('next')) ? 'Set the API BETTER_AUTH_URL to the public web origin, configure its BETTER_AUTH_SECRET, apply reviewed database migrations, then test /sign-in and protected /api/session through web. ' : ''}
92
+ Use Next.js App Router/OpenNext for web, Expo for native, DOM shadcn and the Anhedral native shadcn port, Hono on Workers/workerd, Drizzle/D1 and private R2. Shared contracts belong in packages/contracts, native components in packages/native-ui, tokens in packages/styling, and server schema/migrations in packages/db.
52
93
 
53
- Security gate: pnpm audit:deps preserves the standard pnpm audit JSON in .anhedral-audit-report.json and blocks high or critical findings except the two exact verified braces/node-forge mitigations. Resolve findings through compatible upstream dependency updates. If the lock contains braces@3.0.3, Anhedral supplies a temporary exact-version pnpm patch in patches/ and records it in pnpm-workspace.yaml. It bounds nesting to 100 and rejects cyclic AST traversal; commit the patch and updated lock. When node-forge@1.4.0 occurs, a second exact patch fixes RSA DigestAlgorithm/NULL validation in the Node source and both shipped browser bundles. Only GHSA-vfj7-8cjw-p6xm for patched braces@3.0.3 and GHSA-86w9-cpqp-85rv for patched node-forge@1.4.0 can pass after verifying the exact advisory and version, effective pnpm patch map, and patch SHA-256. Runtime regressions across the affected entrypoints run in the Anhedral CLI repository tests. Upstream findings stay visible; missing or altered patch configuration and unrelated high/critical findings block delivery.
94
+ Hono owns privileged operations. Clients and Next server actions call the API; apps never import one another's source. Keep database/storage credentials server-side. The starter has no authentication, payment integration or public file APIs. Implement identity and authorization before exposing private data. A private bucket is not user authorization.
54
95
 
55
- ${has('next') && options.hosting === 'cloudflare' ? 'OpenNext is configured without a provisioned incremental-cache bucket. Choose and configure a cache adapter before using ISR or cache features that require shared persistence.\n' : ''}
56
- ${has('neon') ? 'Configure DATABASE_URL_UNPOOLED separately in packages/db/.env for transactional migrations on the intended branch. Configure server-only DATABASE_URL for the intended Neon branch and role. Direct HTTP needs no Hyperdrive or connection cleanup. Review migrations and authorization; interactive transactions require a reviewed WebSocket or PostgreSQL adapter.\n' : ''}
57
- ${has('neon') || has('d1') ? 'packages/db/src owns the reusable database factory, schema and migration entry point. Generated SQL lives in packages/db/drizzle; the config resolves paths from its own directory. Run pnpm db:generate, review SQL, then pnpm db:migrate. These tasks are uncached and separate from application builds. D1 defaults to local; pass -- --remote explicitly for the selected Worker database. Browser and native interfaces use an API, never database credentials.\n' : ''}
58
- ${has('expo') && has('better-auth') ? 'Expo identity includes the server Expo plugin with the exact configured scheme, SecureStore native client/cookie adapter, separate browser client, sign-in/account screens and shared protected session contracts. Configure secrets/origins and apply reviewed migrations. Local transport checks do not replace development-build/device acceptance. ' : ''}${has('better-auth') ? 'Core Better Auth tables are included in the Drizzle schema. Review and apply migrations before using /api/auth. Configure BETTER_AUTH_SECRET, BETTER_AUTH_URL and trusted origins for the correct environment.\n' : ''}
59
- ${has('clerk') ? `${has('next') || has('vinext') ? 'The web starter includes ClerkProvider, middleware and sign-in/sign-up pages. Configure NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and server-only CLERK_SECRET_KEY. ' : ''}${has('hono') ? 'packages/auth exports a Clerk request authentication helper. Configure its server secret and publishable key, supply explicit authorized origins, and wire it into product routes; the API health route remains public. ' : ''}Authentication does not establish resource authorization.\n` : ''}
60
- ${has('r2') ? 'FILES is a private R2 binding. Implement authentication and file-level authorization before exposing file routes. Clients never receive R2 credentials.\n' : ''}
61
- ${has('neon-realtime') ? 'Neon Realtime is an optional beta live SQL foundation, separate from Durable Object rooms. Read [packages/neon-realtime/README.md](packages/neon-realtime/README.md) for the server/client factories and Drizzle adapter. Manually enable the intended branch, configure exact allowed origins and set server-only NEON_REALTIME_SECRET with DATABASE_URL; NEON_REALTIME_URL is public client transport configuration. Authenticate sealing requests and scope every query to verified user/tenant access. Implement subscriptions, authorized renewal and isolation tests; RLS, automatic Realtime provisioning and a public SQL endpoint are not provided. Live behavior remains unverified.\n' : ''}
62
- ${has('stream') ? 'Cloudflare Stream provides optional one-to-many WHIP/WHEP live video. Follow packages/stream/README.md and import the management factory only from @workspace/stream/server. Configure server-only STREAM_API_TOKEN and STREAM_ACCOUNT_ID manually. Authorize creators and input ownership; never return secret WHIP URLs to viewers. Implement playback token issuance for private media, browser signaling/UI and session cleanup. Stream activation, live inputs and runtime credentials are not automatically provisioned; live behavior remains unverified.\n' : ''}
63
- ${has('realtime') ? 'Durable Object rooms support hibernating WebSockets; the public entrypoint remains disabled until room authorization and short-lived tickets are implemented.\n' : ''}
64
- ${has('queues') ? 'Queue processing retries unimplemented jobs and uses a dead-letter queue. Add product processing and transactional idempotency before acknowledging messages.\n' : ''}
65
- ${has('basin') ? 'Basin uses a Pipelines stream binding. Configure its stream, sink, R2/catalog and SQL in client-owned infrastructure; it is distinct from operational logs.\n' : ''}
66
- ${has('neon') ? 'Neon provisioning configures the server runtime DATABASE_URL only. Set a separate direct DATABASE_URL_UNPOOLED in ignored packages/db/.env for the intended migration database and role. Run pnpm db:generate, review SQL, then pnpm db:migrate before testing authentication or application data.\n' : ''}
67
- The root pnpm test command runs workspace test tasks; no application tests or test:live script are generated. Implement them for the product before verification.\n\nProvider packages are SDK factories or integration boundaries, not finished business features. Connect only needed packages to server entrypoints. Selected Stripe/RevenueCat billing generates authenticated Hono APIs, provider-verified webhook inbox, scheduled reconciliation and DB-backed entitlement enforcement; read packages/billing/README.md, configure plans/keys/IDs and review/apply SQL. Independent providers share the verified auth user ID; clients never grant access. Local data needs a platform-specific SQLite/filesystem adapter. Sentry needs a platform SDK and runtime initialization. Expo + Better Auth generates native/browser session clients, exact trusted scheme and sign-in/account screens; verify native behavior on a development build/device. Selected RevenueCat generates native purchase/restore/manage wiring; real development-build/store purchase acceptance remains required.
96
+ Keep DOM shadcn and native UI implementations separate, sharing tokens and contracts. Import editable application-local UI source; preserve its provenance, licenses and consumer edits during explicit updates. Use Expo SDK APIs directly for feature capabilities, adding UI adapters only for meaningful presentation or interaction. Keep permission policy and background/provider behavior in application services. The mobile app owns the tested Expo/React Native/React runtime; native-ui peers must match it. Add only needed SDK packages using Expo's compatible installer from apps/mobile and inspect platform support/autolinking/config plugins. Rebuild development clients for native changes and verify Android/iOS behavior separately from browser rendering. Consider @expo/ui controls selectively; do not replace the native port wholesale.
68
97
 
69
- When the product needs a domain, purchase it in the client's GoDaddy account, then add its zone to the client's Cloudflare account and configure Cloudflare nameservers. The client retains registration, renewal, billing and recovery ownership. Verify DNS records and zone activation before connecting application domains and mail. Inbound mail uses Cloudflare Email Routing. Outbound business and application mail defaults to Cloudflare Email Sending; Resend is an alternative when selected. Configure the selected mail provider before use; init does not provision domains or mail services. GitHub Actions runs PR checks and never deploys automatically. Respect existing authorization; request only missing approval for paid activation, material spending, architecture changes or release.
70
- `);
71
- put(root, '.github/workflows/check.yml', `name: Check
72
- on:
73
- pull_request:
74
- push:
75
- branches: [main]
76
- permissions:
77
- contents: read
78
- jobs:
79
- check:
80
- runs-on: ubuntu-latest
81
- timeout-minutes: 20
82
- steps:
83
- - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
84
- with:
85
- fetch-depth: 0
86
- persist-credentials: false
87
- - uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271
88
- - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
89
- with:
90
- node-version: '${voidSelected ? '24.21.0' : '22'}'
91
- cache: pnpm
92
- - run: pnpm install --frozen-lockfile
93
- - run: pnpm lint && pnpm typecheck && pnpm audit:deps
94
- - name: Audit pull request
95
- if: github.event_name == 'pull_request'
96
- env:
97
- AUDIT_BASE: \${{ github.event.pull_request.base.sha }}
98
- run: pnpm exec fallow audit --base "$AUDIT_BASE"
99
- - name: Audit branch
100
- if: github.event_name != 'pull_request'
101
- run: pnpm audit:full
102
- - run: pnpm test && pnpm build${workerBuildSuffix(options)}
98
+ Use pnpm dev for web/API and pnpm --dir apps/mobile start for native. Read version-matched framework documentation. Run pnpm check and exercise changed flows. Review generated SQL and apply migrations explicitly; never migrate a configured remote database during tests, build or startup. Consumers own integration and hosting decisions. Preserve existing source; never reinitialize over an application.
103
99
  `);
100
+ put(root, 'docs/architecture.md', '# Architecture\n\nNext.js / Expo → Hono → Drizzle/D1 and private R2. Record application-owned identity, access rules and integrations here.\n');
101
+ put(root, 'docs/verification.md', '# Verification\n\nRecord commands, outcomes and environment. Generated source is not production acceptance.\n');
104
102
  }
@@ -1,3 +1,3 @@
1
1
  import type { RecipeContext } from '../registry/types.js';
2
- /** Expo remains a static universal client. Its Worker owns only assets and API transport. */
3
- export declare function scaffoldExpoRuntime({ root, options, has }: RecipeContext): void;
2
+ /** Native uses the public product origin; all browser transport belongs to Next. */
3
+ export declare function scaffoldExpoRuntime({ root }: RecipeContext): void;
@@ -1,109 +1,19 @@
1
1
  import { writeEnvironmentFile } from './environment.js';
2
- import { STACK_DEPENDENCIES } from '../dependencies.js';
3
- import { resourceName } from '../render.js';
4
- import { json, patchPackage, put, workerConfig } from './files.js';
5
- /** Expo remains a static universal client. Its Worker owns only assets and API transport. */
6
- export function scaffoldExpoRuntime({ root, options, has }) {
2
+ import { patchPackage, put } from './files.js';
3
+ /** Native uses the public product origin; all browser transport belongs to Next. */
4
+ export function scaffoldExpoRuntime({ root }) {
7
5
  const directory = 'apps/mobile';
8
- const api = has('hono');
9
- const webPort = has('vinext') || has('next') ? 3001 : 3000;
10
- json(root, `${directory}/wrangler.jsonc`, {
11
- ...workerConfig(resourceName(options.name, 'mobile')),
12
- main: 'worker/index.ts',
13
- assets: {
14
- directory: './dist',
15
- binding: 'ASSETS',
16
- run_worker_first: ['/api', '/api/*'],
17
- html_handling: 'auto-trailing-slash',
18
- not_found_handling: '404-page',
19
- },
20
- ...(api ? { services: [{ binding: 'API', service: resourceName(options.name, 'api') }] } : {}),
21
- });
22
6
  patchPackage(root, `${directory}/package.json`, {
23
- scripts: {
24
- dev: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
25
- start: 'expo start -c',
26
- web: 'pnpm dev',
27
- build: 'pnpm typecheck && pnpm build:web && pnpm build:worker',
28
- 'build:worker': 'wrangler deploy --dry-run --outdir .output/worker',
29
- preview: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
30
- deploy: 'pnpm build:web && wrangler deploy',
31
- typecheck: 'tsc --noEmit && pnpm typecheck:worker',
32
- 'typecheck:worker': 'tsc --project tsconfig.worker.json --noEmit',
33
- lint: 'eslint app components lib worker --max-warnings 0',
34
- },
35
- ...(api ? { dependencies: { '@workspace/contracts': 'workspace:*' } } : {}),
36
- devDependencies: { wrangler: STACK_DEPENDENCIES.wrangler },
37
- });
38
- json(root, `${directory}/tsconfig.worker.json`, {
39
- compilerOptions: {
40
- target: 'ES2022',
41
- lib: ['ES2022', 'DOM', 'DOM.Iterable'],
42
- module: 'ESNext',
43
- moduleResolution: 'Bundler',
44
- strict: true,
45
- skipLibCheck: true,
46
- noEmit: true,
47
- types: [],
48
- },
49
- include: ['worker/**/*.ts'],
50
- });
51
- put(root, `${directory}/worker/index.ts`, `interface Binding { fetch(request: Request): Promise<Response> }
52
- interface Env { ASSETS: Binding; ${api ? 'API: Binding;' : ''} }
53
-
54
- ${api
55
- ? `// Browser-supplied edge identity headers never cross the API boundary.
56
- function forwardedHeaders(request: Request): Headers {
57
- const headers = new Headers();
58
- for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {
59
- const value = request.headers.get(name);
60
- if (value) headers.set(name, value);
61
- }
62
- return headers;
63
- }
64
- function privateResponse(response: Response): Response {
65
- const headers = new Headers(response.headers);
66
- for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);
67
- headers.set('cache-control', 'private, no-store');
68
- return new Response(response.body, { status: response.status, headers });
69
- }
70
- async function proxyApi(request: Request, env: Env): Promise<Response> {
71
- const url = new URL(request.url);
72
- const target = new URL('https://api.internal');
73
- target.pathname = url.pathname;
74
- target.search = url.search;
75
- try {
76
- const upstream = new Request(new Request(target, request), {
77
- headers: forwardedHeaders(request), redirect: 'manual',
78
- signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]),
7
+ dependencies: { '@workspace/contracts': 'workspace:*' },
79
8
  });
80
- return privateResponse(await env.API.fetch(upstream));
81
- } catch {
82
- return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } });
83
- }
84
- }
85
- `
86
- : ''}
87
- export default {
88
- async fetch(request: Request, env: Env): Promise<Response> {
89
- const pathname = new URL(request.url).pathname;
90
- const apiPath = pathname === '/api' || pathname.startsWith('/api/');
91
- if (!apiPath) return env.ASSETS.fetch(request);
92
- ${api ? 'return proxyApi(request, env);' : "return Response.json({ error: 'API not configured' }, { status: 404, headers: { 'cache-control': 'private, no-store' } });"}
93
- },
94
- };
95
- `);
96
- if (!api)
97
- return;
98
- put(root, `${directory}/lib/api-client.ts`, `import { Platform } from 'react-native';
99
- import { createApiClient } from '@workspace/contracts';
9
+ put(root, `${directory}/lib/api-client.ts`, `import { createApiClient } from '@workspace/contracts';
100
10
 
101
11
  type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
102
12
 
103
13
  function validProtocol(url: URL): boolean {
104
14
  return url.protocol === 'https:' || (__DEV__ && url.protocol === 'http:');
105
15
  }
106
- export function nativeApiOrigin(): string {
16
+ function nativeApiOrigin(): string {
107
17
  const configured = process.env.EXPO_PUBLIC_API_URL;
108
18
  if (!configured) throw new Error('Configure EXPO_PUBLIC_API_URL with the product origin reachable from this device.');
109
19
  const origin = new URL(configured);
@@ -113,18 +23,16 @@ export function nativeApiOrigin(): string {
113
23
  return origin.origin;
114
24
  }
115
25
  function apiBaseURL(): string {
116
- if (Platform.OS === 'web') return '/api';
117
26
  return nativeApiOrigin() + '/api';
118
27
  }
119
28
 
120
- // A native auth adapter can provide its own session headers. No server secret belongs here.
121
- export function createApplicationApiClient(options: Options = {}) {
29
+ // Consumers can extend transport headers for their own application. No server secret belongs here.
30
+ function createApplicationApiClient(options: Options = {}) {
122
31
  const client = () => createApiClient(apiBaseURL(), {
123
- ...options, credentials: Platform.OS === 'web' ? 'same-origin' : 'omit',
32
+ ...options, credentials: 'omit',
124
33
  });
125
34
  return {
126
35
  health: (init?: RequestInit) => client().health(init),
127
- session: (init?: RequestInit) => client().session(init),
128
36
  };
129
37
  }
130
38
 
@@ -0,0 +1,2 @@
1
+ /** Anhedral-maintained native shadcn port. Never imported by the DOM application. */
2
+ export declare function scaffoldNativeUI(root: string): void;