anhedral 0.15.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 (308) hide show
  1. package/README.md +29 -38
  2. package/assets/stack/ai-schema.ts.txt +5 -0
  3. package/assets/stack/ai.ts.txt +30 -0
  4. package/assets/stack/api-index.ts.txt +15 -0
  5. package/assets/stack/auth-features.ts.txt +4 -0
  6. package/assets/stack/auth-journal.json.txt +13 -0
  7. package/assets/stack/auth-migration.sql.txt +53 -0
  8. package/assets/stack/auth-routes.ts.txt +11 -0
  9. package/assets/stack/auth-schema.ts.txt +64 -0
  10. package/assets/stack/auth-snapshot.json.txt +346 -0
  11. package/assets/stack/auth.ts.txt +32 -0
  12. package/assets/stack/billing-mode.ts.txt +8 -0
  13. package/assets/stack/billing-schema.ts.txt +11 -0
  14. package/assets/stack/desktop.rs.txt +21 -0
  15. package/assets/stack/entitlement-guard.ts.txt +32 -0
  16. package/assets/stack/entitlements.ts.txt +8 -0
  17. package/assets/stack/events-schema.ts.txt +12 -0
  18. package/assets/stack/events.ts.txt +59 -0
  19. package/assets/stack/mobile-auth.ts.txt +25 -0
  20. package/assets/stack/mobile-billing.tsx.txt +63 -0
  21. package/assets/stack/mobile-session.tsx.txt +83 -0
  22. package/assets/stack/native-button.tsx.txt +108 -0
  23. package/assets/stack/native-global.css.txt +4 -0
  24. package/assets/stack/native-lib-utils.ts.txt +5 -0
  25. package/assets/stack/native-metro.config.js.txt +6 -0
  26. package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
  27. package/assets/stack/native-tailwind.config.js.txt +73 -0
  28. package/assets/stack/native-text.tsx.txt +89 -0
  29. package/assets/stack/purchases.ts.txt +65 -0
  30. package/assets/stack/revenuecat.ts.txt +88 -0
  31. package/assets/stack/rtc-schema.ts.txt +10 -0
  32. package/assets/stack/rtc.ts.txt +122 -0
  33. package/assets/stack/security.ts.txt +31 -0
  34. package/assets/stack/storage.ts.txt +36 -0
  35. package/assets/stack/stripe.ts.txt +126 -0
  36. package/assets/stack/web-sign-in.tsx.txt +51 -0
  37. package/assets/ui/LICENSE.react-native-reusables +21 -0
  38. package/assets/ui/UPSTREAM.json +7 -1
  39. package/assets/ui/catalog.json +891 -0
  40. package/assets/ui/extensions/registry.json +6 -0
  41. package/assets/ui/native/_controls.tsx +521 -0
  42. package/assets/ui/native/_core.tsx +118 -0
  43. package/assets/ui/native/_data.tsx +200 -0
  44. package/assets/ui/native/_display.tsx +453 -0
  45. package/assets/ui/native/_feedback.tsx +242 -0
  46. package/assets/ui/native/_legacy-dialog.tsx +38 -0
  47. package/assets/ui/native/_motion.tsx +520 -0
  48. package/assets/ui/native/_overlay.tsx +402 -0
  49. package/assets/ui/native/_selection.tsx +366 -0
  50. package/assets/ui/native/accordion.tsx +1 -0
  51. package/assets/ui/native/alert-dialog.tsx +11 -0
  52. package/assets/ui/native/alert.tsx +1 -0
  53. package/assets/ui/native/aspect-ratio.tsx +1 -0
  54. package/assets/ui/native/attachment.tsx +8 -0
  55. package/assets/ui/native/avatar.tsx +8 -0
  56. package/assets/ui/native/badge.tsx +1 -0
  57. package/assets/ui/native/breadcrumb.tsx +9 -0
  58. package/assets/ui/native/bubble.tsx +1 -0
  59. package/assets/ui/native/button-group.tsx +1 -0
  60. package/assets/ui/native/button.tsx +2 -1
  61. package/assets/ui/native/calendar.tsx +170 -0
  62. package/assets/ui/native/card.tsx +16 -5
  63. package/assets/ui/native/carousel.tsx +1 -0
  64. package/assets/ui/native/chart.tsx +193 -0
  65. package/assets/ui/native/checkbox.tsx +1 -0
  66. package/assets/ui/native/code-block.tsx +137 -0
  67. package/assets/ui/native/collapsible.tsx +1 -0
  68. package/assets/ui/native/combobox.tsx +1 -0
  69. package/assets/ui/native/command.tsx +11 -0
  70. package/assets/ui/native/context-menu.tsx +16 -0
  71. package/assets/ui/native/data-table.tsx +1 -0
  72. package/assets/ui/native/date-picker.tsx +43 -0
  73. package/assets/ui/native/dialog.tsx +14 -74
  74. package/assets/ui/native/direction.tsx +1 -0
  75. package/assets/ui/native/drawer.tsx +10 -0
  76. package/assets/ui/native/dropdown-menu.tsx +16 -0
  77. package/assets/ui/native/empty.tsx +8 -0
  78. package/assets/ui/native/field.tsx +13 -0
  79. package/assets/ui/native/hover-card.tsx +1 -0
  80. package/assets/ui/native/input-group.tsx +8 -0
  81. package/assets/ui/native/input-otp.tsx +1 -0
  82. package/assets/ui/native/input.tsx +2 -1
  83. package/assets/ui/native/item.tsx +12 -0
  84. package/assets/ui/native/kbd.tsx +1 -0
  85. package/assets/ui/native/marker.tsx +1 -0
  86. package/assets/ui/native/menubar.tsx +17 -0
  87. package/assets/ui/native/message-scroller.tsx +6 -0
  88. package/assets/ui/native/message.tsx +10 -0
  89. package/assets/ui/native/native-select.tsx +1 -0
  90. package/assets/ui/native/navigation-menu.tsx +10 -0
  91. package/assets/ui/native/pagination.tsx +9 -0
  92. package/assets/ui/native/popover.tsx +1 -0
  93. package/assets/ui/native/progress.tsx +1 -0
  94. package/assets/ui/native/questionnaire.tsx +130 -0
  95. package/assets/ui/native/radio-group.tsx +1 -0
  96. package/assets/ui/native/registry.json +1103 -0
  97. package/assets/ui/native/resizable.tsx +1 -0
  98. package/assets/ui/native/scroll-area.tsx +1 -0
  99. package/assets/ui/native/select.tsx +11 -0
  100. package/assets/ui/native/separator.tsx +1 -0
  101. package/assets/ui/native/sheet.tsx +10 -0
  102. package/assets/ui/native/sidebar.tsx +22 -0
  103. package/assets/ui/native/skeleton.tsx +1 -0
  104. package/assets/ui/native/slider.tsx +1 -0
  105. package/assets/ui/native/spinner.tsx +1 -0
  106. package/assets/ui/native/switch.tsx +1 -0
  107. package/assets/ui/native/table.tsx +10 -0
  108. package/assets/ui/native/tabs.tsx +1 -0
  109. package/assets/ui/native/textarea.tsx +1 -0
  110. package/assets/ui/native/toast.tsx +11 -0
  111. package/assets/ui/native/toggle-group.tsx +1 -0
  112. package/assets/ui/native/toggle.tsx +1 -0
  113. package/assets/ui/native/tooltip.tsx +1 -0
  114. package/assets/ui/native/trace.tsx +20 -0
  115. package/assets/ui/native/typography.tsx +15 -0
  116. package/dist/bin.js +7 -12
  117. package/dist/capabilities.d.ts +4 -33
  118. package/dist/capabilities.js +2 -66
  119. package/dist/capability-catalog.d.ts +83 -0
  120. package/dist/capability-catalog.js +121 -0
  121. package/dist/capability-command.d.ts +3 -0
  122. package/dist/capability-command.js +188 -0
  123. package/dist/capability-editor.d.ts +17 -0
  124. package/dist/capability-editor.js +97 -0
  125. package/dist/capability-recipes.d.ts +4 -0
  126. package/dist/capability-recipes.js +520 -0
  127. package/dist/capability-references.d.ts +4 -0
  128. package/dist/capability-references.js +7 -0
  129. package/dist/cli-commands.d.ts +1 -2
  130. package/dist/cli-commands.js +10 -104
  131. package/dist/cli-output.d.ts +1 -2
  132. package/dist/cli-output.js +6 -251
  133. package/dist/command-schema.js +39 -322
  134. package/dist/dependencies.d.ts +29 -6
  135. package/dist/dependencies.js +61 -14
  136. package/dist/index.d.ts +1 -42
  137. package/dist/index.js +1 -27
  138. package/dist/platforms/mobile.js +1 -20
  139. package/dist/platforms/web.d.ts +1 -1
  140. package/dist/platforms/web.js +27 -75
  141. package/dist/project-config.d.ts +2 -13
  142. package/dist/project-config.js +10 -82
  143. package/dist/registry/options.js +1 -5
  144. package/dist/registry/resolve.d.ts +1 -1
  145. package/dist/registry/resolve.js +2 -10
  146. package/dist/registry/usage.js +3 -9
  147. package/dist/scaffold/backend.js +0 -3
  148. package/dist/scaffold/database.js +2 -1
  149. package/dist/scaffold/documentation.js +82 -20
  150. package/dist/scaffold/expo-runtime.js +3 -4
  151. package/dist/scaffold/native-ui.js +12 -7
  152. package/dist/scaffold/stack-documentation.js +1 -1
  153. package/dist/scaffold/storage.d.ts +2 -0
  154. package/dist/scaffold/storage.js +21 -0
  155. package/dist/scaffold/workspace.js +26 -21
  156. package/dist/stack-registry.d.ts +2 -8
  157. package/dist/stack-registry.js +11 -87
  158. package/dist/standard.js +1 -11
  159. package/dist/ui-catalog.d.ts +26 -0
  160. package/dist/ui-catalog.js +31 -0
  161. package/dist/ui-command.d.ts +3 -0
  162. package/dist/ui-command.js +219 -0
  163. package/dist/ui-project.d.ts +22 -0
  164. package/dist/ui-project.js +110 -0
  165. package/dist/version.d.ts +1 -1
  166. package/dist/version.js +1 -1
  167. package/docs/anhedral-stack.md +4 -20
  168. package/docs/capabilities.md +110 -0
  169. package/docs/native-ui.md +102 -0
  170. package/docs/software-factory.md +16 -44
  171. package/docs/stack-standard.md +11 -60
  172. package/docs/ui.md +33 -0
  173. package/docs/verification.md +191 -0
  174. package/package.json +19 -18
  175. package/dist/access.d.ts +0 -10
  176. package/dist/access.js +0 -93
  177. package/dist/auth-schema-snapshot.d.ts +0 -346
  178. package/dist/auth-schema-snapshot.js +0 -347
  179. package/dist/auth-schema.d.ts +0 -1
  180. package/dist/auth-schema.js +0 -57
  181. package/dist/capability-contract.d.ts +0 -47
  182. package/dist/capability-contract.js +0 -129
  183. package/dist/catalog-model.d.ts +0 -24
  184. package/dist/catalog-model.js +0 -1
  185. package/dist/catalog-registration.d.ts +0 -16
  186. package/dist/catalog-registration.js +0 -22
  187. package/dist/catalog-snapshot.d.ts +0 -5
  188. package/dist/catalog-snapshot.js +0 -97
  189. package/dist/cli-delivery.d.ts +0 -3
  190. package/dist/cli-delivery.js +0 -112
  191. package/dist/cloudflare.d.ts +0 -25
  192. package/dist/cloudflare.js +0 -226
  193. package/dist/delivery-evidence.d.ts +0 -62
  194. package/dist/delivery-evidence.js +0 -157
  195. package/dist/delivery.d.ts +0 -82
  196. package/dist/delivery.js +0 -489
  197. package/dist/inspector-model.d.ts +0 -123
  198. package/dist/inspector-model.js +0 -1
  199. package/dist/integration-service-readers.d.ts +0 -12
  200. package/dist/integration-service-readers.js +0 -92
  201. package/dist/lifecycle-model.d.ts +0 -15
  202. package/dist/lifecycle-model.js +0 -20
  203. package/dist/lifecycle.d.ts +0 -11
  204. package/dist/lifecycle.js +0 -91
  205. package/dist/management.d.ts +0 -3
  206. package/dist/management.js +0 -47
  207. package/dist/mobile-delivery.d.ts +0 -77
  208. package/dist/mobile-delivery.js +0 -370
  209. package/dist/project-catalog.d.ts +0 -41
  210. package/dist/project-catalog.js +0 -288
  211. package/dist/project-inspector.d.ts +0 -4
  212. package/dist/project-inspector.js +0 -671
  213. package/dist/project-lifecycle.d.ts +0 -25
  214. package/dist/project-lifecycle.js +0 -57
  215. package/dist/project-state.d.ts +0 -47
  216. package/dist/project-state.js +0 -480
  217. package/dist/provider-auth.d.ts +0 -41
  218. package/dist/provider-auth.js +0 -180
  219. package/dist/provider-readiness.d.ts +0 -30
  220. package/dist/provider-readiness.js +0 -85
  221. package/dist/providers/adapters.d.ts +0 -17
  222. package/dist/providers/adapters.js +0 -103
  223. package/dist/providers/api.d.ts +0 -29
  224. package/dist/providers/api.js +0 -253
  225. package/dist/providers/config.d.ts +0 -15
  226. package/dist/providers/config.js +0 -136
  227. package/dist/providers/definitions.d.ts +0 -115
  228. package/dist/providers/definitions.js +0 -42
  229. package/dist/providers/provision.d.ts +0 -24
  230. package/dist/providers/provision.js +0 -76
  231. package/dist/providers/receipts.d.ts +0 -20
  232. package/dist/providers/receipts.js +0 -56
  233. package/dist/providers/recovery-verification.d.ts +0 -7
  234. package/dist/providers/recovery-verification.js +0 -52
  235. package/dist/providers/recovery.d.ts +0 -30
  236. package/dist/providers/recovery.js +0 -34
  237. package/dist/providers/runtime.d.ts +0 -10
  238. package/dist/providers/runtime.js +0 -234
  239. package/dist/providers/schema.d.ts +0 -28
  240. package/dist/providers/schema.js +0 -49
  241. package/dist/providers/state.d.ts +0 -55
  242. package/dist/providers/state.js +0 -283
  243. package/dist/provision.d.ts +0 -47
  244. package/dist/provision.js +0 -208
  245. package/dist/r2-service-data.d.ts +0 -2
  246. package/dist/r2-service-data.js +0 -136
  247. package/dist/readiness.d.ts +0 -23
  248. package/dist/readiness.js +0 -117
  249. package/dist/registry/add.d.ts +0 -24
  250. package/dist/registry/add.js +0 -210
  251. package/dist/registry/bootstrap.d.ts +0 -3
  252. package/dist/registry/bootstrap.js +0 -5
  253. package/dist/registry/commands.d.ts +0 -3
  254. package/dist/registry/commands.js +0 -83
  255. package/dist/registry/preview.d.ts +0 -11
  256. package/dist/registry/preview.js +0 -91
  257. package/dist/registry/receipt.d.ts +0 -3
  258. package/dist/registry/receipt.js +0 -68
  259. package/dist/repository.d.ts +0 -24
  260. package/dist/repository.js +0 -96
  261. package/dist/scaffold/auth.d.ts +0 -2
  262. package/dist/scaffold/auth.js +0 -76
  263. package/dist/scaffold/billing-config.d.ts +0 -1
  264. package/dist/scaffold/billing-config.js +0 -73
  265. package/dist/scaffold/billing-contracts.d.ts +0 -2
  266. package/dist/scaffold/billing-contracts.js +0 -48
  267. package/dist/scaffold/billing-providers.d.ts +0 -1
  268. package/dist/scaffold/billing-providers.js +0 -249
  269. package/dist/scaffold/billing-schema.d.ts +0 -1
  270. package/dist/scaffold/billing-schema.js +0 -34
  271. package/dist/scaffold/billing-security.d.ts +0 -1
  272. package/dist/scaffold/billing-security.js +0 -46
  273. package/dist/scaffold/billing-server.d.ts +0 -1
  274. package/dist/scaffold/billing-server.js +0 -139
  275. package/dist/scaffold/billing-store.d.ts +0 -1
  276. package/dist/scaffold/billing-store.js +0 -72
  277. package/dist/scaffold/billing.d.ts +0 -2
  278. package/dist/scaffold/billing.js +0 -208
  279. package/dist/scaffold/expo-auth.d.ts +0 -3
  280. package/dist/scaffold/expo-auth.js +0 -203
  281. package/dist/scaffold/expo-billing.d.ts +0 -3
  282. package/dist/scaffold/expo-billing.js +0 -257
  283. package/dist/scaffold/integrations.d.ts +0 -2
  284. package/dist/scaffold/integrations.js +0 -11
  285. package/dist/scaffold/managed-email.d.ts +0 -3
  286. package/dist/scaffold/managed-email.js +0 -47
  287. package/dist/scaffold/password-reset.d.ts +0 -1
  288. package/dist/scaffold/password-reset.js +0 -99
  289. package/dist/scaffold/private-files.d.ts +0 -2
  290. package/dist/scaffold/private-files.js +0 -78
  291. package/dist/scaffold/web-billing.d.ts +0 -2
  292. package/dist/scaffold/web-billing.js +0 -48
  293. package/dist/service-deletion.d.ts +0 -29
  294. package/dist/service-deletion.js +0 -195
  295. package/dist/service-descriptor.d.ts +0 -10
  296. package/dist/service-descriptor.js +0 -71
  297. package/dist/service-model.d.ts +0 -49
  298. package/dist/service-model.js +0 -8
  299. package/dist/service-operations.d.ts +0 -29
  300. package/dist/service-operations.js +0 -48
  301. package/dist/service-readers.d.ts +0 -8
  302. package/dist/service-readers.js +0 -216
  303. package/dist/services-command.d.ts +0 -39
  304. package/dist/services-command.js +0 -96
  305. package/dist/ship.d.ts +0 -35
  306. package/dist/ship.js +0 -107
  307. package/docs/assets/anhedral-stack-light.png +0 -0
  308. package/docs/assets/anhedral-stack.png +0 -0
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import { writeReactLintConfig } from './lint.js';
4
4
  import { appendGitignore, writeFile } from '../util.js';
5
5
  import { childPackageName, jsString } from '../render.js';
6
- import { MOBILE_APP_DEPENDENCIES, EAS_CLI_VERSION } from '../dependencies.js';
6
+ import { MOBILE_APP_DEPENDENCIES } from '../dependencies.js';
7
7
  import { scaffoldNativeUI } from '../scaffold/native-ui.js';
8
8
  import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
9
9
  function expoScheme(projectName) {
@@ -39,12 +39,6 @@ export async function scaffoldExpo(context) {
39
39
  build: 'pnpm typecheck',
40
40
  typecheck: 'tsc --noEmit',
41
41
  lint: 'eslint . --max-warnings 0',
42
- 'eas:login': `pnpm dlx eas-cli@${EAS_CLI_VERSION} login`,
43
- 'build:simulator:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile simulator`,
44
- 'build:internal:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile preview`,
45
- 'build:internal:android': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform android --profile preview`,
46
- 'build:production:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile production`,
47
- 'build:production:android': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform android --profile production`,
48
42
  },
49
43
  dependencies: {
50
44
  ...MOBILE_APP_DEPENDENCIES.dependencies,
@@ -129,19 +123,6 @@ export default function HomeScreen() {
129
123
  }
130
124
  `);
131
125
  writeFile(path.join(dir, '.env.example'), '');
132
- writeFile(path.join(dir, 'eas.json'), JSON.stringify({
133
- cli: { version: '>= 16.0.0' },
134
- build: {
135
- development: { developmentClient: true, distribution: 'internal' },
136
- preview: {
137
- environment: 'preview',
138
- distribution: 'internal',
139
- android: { buildType: 'apk' },
140
- },
141
- simulator: { environment: 'preview', ios: { simulator: true } },
142
- production: { environment: 'production', autoIncrement: true },
143
- },
144
- }, null, 2) + '\n');
145
126
  scaffoldExpoRuntime(context);
146
127
  appendGitignore(dir, [
147
128
  '.env',
@@ -1,3 +1,3 @@
1
1
  import type { RecipeContext } from '../registry/types.js';
2
- export declare function scaffoldWeb({ root, options }: RecipeContext): void;
2
+ export declare function scaffoldWeb({ root, options, has }: RecipeContext): void;
3
3
  export declare const WEB_API_PROXY = "export interface ApiBinding { fetch(request: Request): Promise<Response> }\ntype Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };\nfunction developmentOrigin(configured?: string): string {\n const url = new URL(configured || 'http://127.0.0.1:8787');\n const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);\n const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];\n if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');\n return url.origin;\n}\nfunction backendOrigin(options: Options): string {\n if (options.development) return developmentOrigin(options.devOrigin);\n if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');\n return 'https://api.internal';\n}\nfunction apiTarget(request: Request, origin: string): URL {\n const url = new URL(request.url);\n if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');\n return new URL(url.pathname + url.search, origin);\n}\nfunction forwardedHeaders(request: Request): Headers {\n const headers = new Headers();\n for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {\n const value = request.headers.get(name); if (value) headers.set(name, value);\n }\n return headers;\n}\nfunction upstreamRequest(request: Request, target: URL): Request {\n const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };\n if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }\n return new Request(target, settings);\n}\nfunction privateResponse(response: Response, development: boolean): Response {\n const headers = new Headers(response.headers);\n for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);\n // Node fetch already decoded the local HTTP response. Next must frame/compress\n // those decoded bytes itself; the sidecar's wire headers no longer describe them.\n if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }\n headers.set('cache-control', 'private, no-store');\n return new Response(response.body, { status: response.status, headers });\n}\nexport async function proxyApi(request: Request, options: Options): Promise<Response> {\n try {\n const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));\n const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);\n return privateResponse(response, options.development);\n } catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }\n}\n";
@@ -1,9 +1,11 @@
1
+ import { initializeUiMetadata } from '../ui-project.js';
1
2
  import { readFileSync } from 'node:fs';
2
3
  import { fileURLToPath } from 'node:url';
4
+ import path from 'node:path';
3
5
  import { resourceName, childPackageName, jsString } from '../render.js';
4
6
  import { WEB_DEPENDENCIES } from '../dependencies.js';
5
7
  import { json, put, workerConfig } from '../scaffold/files.js';
6
- export function scaffoldWeb({ root, options }) {
8
+ export function scaffoldWeb({ root, options, has }) {
7
9
  const app = 'apps/web';
8
10
  json(root, `${app}/package.json`, {
9
11
  name: childPackageName(options.name, 'web'),
@@ -23,7 +25,7 @@ export function scaffoldWeb({ root, options }) {
23
25
  },
24
26
  dependencies: {
25
27
  ...WEB_DEPENDENCIES.dependencies,
26
- '@workspace/contracts': 'workspace:*',
28
+ ...(has('hono') ? { '@workspace/contracts': 'workspace:*' } : {}),
27
29
  '@workspace/styling': 'workspace:*',
28
30
  },
29
31
  devDependencies: {
@@ -37,7 +39,9 @@ export function scaffoldWeb({ root, options }) {
37
39
  compatibility_flags: ['nodejs_compat', 'global_fetch_strictly_public'],
38
40
  assets: { directory: '.open-next/assets', binding: 'ASSETS' },
39
41
  services: [
40
- { binding: 'ANHEDRAL_API', service: resourceName(options.name, 'api') },
42
+ ...(has('hono')
43
+ ? [{ binding: 'ANHEDRAL_API', service: resourceName(options.name, 'api') }]
44
+ : []),
41
45
  { binding: 'WORKER_SELF_REFERENCE', service: resourceName(options.name, 'web') },
42
46
  ],
43
47
  });
@@ -49,7 +53,7 @@ if (previewOrigin) {
49
53
  if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.pathname !== '/' || url.search || url.hash) throw new Error('ANHEDRAL_PREVIEW_ORIGIN must be an HTTP(S) origin.');
50
54
  allowedDevOrigins = [url.hostname];
51
55
  }
52
- const config: NextConfig = { allowedDevOrigins, transpilePackages: ['@workspace/contracts', '@workspace/styling'], images: { unoptimized: true } };
56
+ const config: NextConfig = { allowedDevOrigins, transpilePackages: ${JSON.stringify(has('hono') ? ['@workspace/contracts', '@workspace/styling'] : ['@workspace/styling'])}, images: { unoptimized: true } };
53
57
  export default config;
54
58
  `);
55
59
  put(root, `${app}/open-next.config.ts`, `import { defineCloudflareConfig } from '@opennextjs/cloudflare';
@@ -104,6 +108,7 @@ export default defineConfig([...next, ...ts, globalIgnores(['.next/**', '.open-n
104
108
  },
105
109
  iconLibrary: 'lucide',
106
110
  });
111
+ initializeUiMetadata(path.join(root, app), 'web');
107
112
  put(root, `${app}/lib/utils.ts`, `import { clsx, type ClassValue } from 'clsx';
108
113
  import { twMerge } from 'tailwind-merge';
109
114
  export function cn(...values: ClassValue[]) { return twMerge(clsx(values)); }
@@ -135,16 +140,29 @@ a { color: inherit; } .button, input { min-height: 2.75rem; padding: .65rem 1rem
135
140
  import Link from 'next/link';
136
141
  import './globals.css';
137
142
  export const metadata: Metadata = { title: ${jsString(options.name)}, description: 'Anhedral application' };
138
- export default function Layout({ children }: { children: React.ReactNode }) { return <html lang="en"><body><main><nav aria-label="Main"><Link href="/">Home</Link><Link href="/account">Account</Link></nav>{children}</main></body></html>; }
143
+ export default function Layout({ children }: { children: React.ReactNode }) { return <html lang="en"><body><main><nav aria-label="Main"><Link href="/">Home</Link></nav>{children}</main></body></html>; }
139
144
  `);
140
- put(root, `${app}/app/page.tsx`, `import { headers } from 'next/headers';
141
- export default async function Home() {
142
- const request = await headers();
143
- return <section className="stack"><h1>${escapeJsx(options.name)}</h1><p>Next.js on Cloudflare, with a shared Hono API.</p><p className="muted" data-rendering="server">Rendered on the server for {request.get('host') ?? 'this request'}.</p></section>;
145
+ put(root, `${app}/app/page.tsx`, `import { FoundationExample } from '@/components/foundation-example';
146
+ export default function Home() {
147
+ return <section className="stack"><h1>${escapeJsx(options.name)}</h1><p>Next.js on Cloudflare, with Anhedral UI.</p><p className="muted" data-rendering="server">Prerendered at build time; ready to hydrate in the browser.</p><FoundationExample /></section>;
148
+ }
149
+ `);
150
+ put(root, `${app}/components/foundation-example.tsx`, `'use client';
151
+ import { useState } from 'react';
152
+ import { Button } from '@/components/ui/button';
153
+ import { Input } from '@/components/ui/input';
154
+ import { Label } from '@/components/ui/label';
155
+ export function FoundationExample() {
156
+ const [idea, setIdea] = useState('My next application');
157
+ return <section className="stack"><Label htmlFor="idea">What will you build?</Label><Input id="idea" value={idea} onChange={event => setIdea(event.target.value)} /><p aria-live="polite">{idea}</p><Button onClick={() => setIdea('My next application')}>Reset example</Button></section>;
144
158
  }
145
159
  `);
146
160
  put(root, `${app}/app/loading.tsx`, `export default function Loading() { return <p role="status">Loading…</p>; }\n`);
147
161
  put(root, `${app}/app/error.tsx`, `'use client';\nexport default function ErrorPage({ reset }: { reset: () => void }) { return <section><h1>Unable to load this page</h1><button onClick={reset}>Try again</button></section>; }\n`);
162
+ put(root, `${app}/public/_headers`, '/_next/static/*\n Cache-Control: public, max-age=31536000, immutable\n/*\n X-Content-Type-Options: nosniff\n');
163
+ put(root, `${app}/public/robots.txt`, 'User-agent: *\nAllow: /\n');
164
+ if (!has('hono'))
165
+ return;
148
166
  put(root, `${app}/lib/api-proxy.ts`, WEB_API_PROXY);
149
167
  put(root, `${app}/lib/server-api.ts`, `import 'server-only';
150
168
  import { getCloudflareContext } from '@opennextjs/cloudflare';
@@ -172,31 +190,6 @@ export const PATCH = apiRequest;
172
190
  export const DELETE = apiRequest;
173
191
  export const HEAD = apiRequest;
174
192
  export const OPTIONS = apiRequest;
175
- `);
176
- put(root, `${app}/lib/auth-client.ts`, `import { createAuthClient } from 'better-auth/react';\nexport const authClient = createAuthClient();\n`);
177
- put(root, `${app}/app/sign-in/page.tsx`, WEB_SIGN_IN);
178
- put(root, `${app}/components/sign-out.tsx`, `'use client';
179
- import { useState } from 'react';
180
- import { useRouter } from 'next/navigation';
181
- import { authClient } from '@/lib/auth-client';
182
- import { Button } from '@/components/ui/button';
183
- export function SignOut() { const [error, setError] = useState(''); const [pending, setPending] = useState(false); const router = useRouter();
184
- async function logout() { setPending(true); setError(''); try { const result = await authClient.signOut(); if (result.error) throw Error('Unable to sign out.'); router.replace('/sign-in'); router.refresh(); } catch { setError('Unable to sign out. Please retry.'); } finally { setPending(false); } }
185
- return <><Button disabled={pending} onClick={() => void logout()}>{pending ? 'Signing out…' : 'Sign out'}</Button><p role="status">{error}</p></>; }
186
- `);
187
- put(root, `${app}/app/account/page.tsx`, `import { headers } from 'next/headers';
188
- import { redirect } from 'next/navigation';
189
- import { sessionSchema } from '@workspace/contracts';
190
- import { apiRequest } from '@/lib/server-api';
191
- import { SignOut } from '@/components/sign-out';
192
- export default async function Account() {
193
- const incoming = await headers();
194
- const response = await apiRequest(new Request('https://app.internal/api/session', { headers: { cookie: incoming.get('cookie') ?? '' } }));
195
- if (response.status === 401) redirect('/sign-in');
196
- if (!response.ok) throw Error('Session verification is unavailable.');
197
- const { user } = sessionSchema.parse(await response.json());
198
- return <section className="stack"><h1>Account</h1><p>{user.email}</p><SignOut /></section>;
199
- }
200
193
  `);
201
194
  put(root, `${app}/.env.example`, '# Development only. Production uses the ANHEDRAL_API service binding.\nAPI_INTERNAL_URL=http://127.0.0.1:8787\n');
202
195
  }
@@ -256,44 +249,3 @@ export async function proxyApi(request: Request, options: Options): Promise<Resp
256
249
  } catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }
257
250
  }
258
251
  `;
259
- const WEB_SIGN_IN = `'use client';
260
- import { useRef, useState, type FormEvent } from 'react';
261
- import { useRouter } from 'next/navigation';
262
- import Link from 'next/link';
263
- import { authClient } from '@/lib/auth-client';
264
- import { Button } from '@/components/ui/button';
265
- import { Input } from '@/components/ui/input';
266
- import { Label } from '@/components/ui/label';
267
- function verificationPending(create: boolean, signedIn: boolean): boolean { return create && !signedIn; }
268
- async function requestVerification(email: string) {
269
- const result = await authClient.sendVerificationEmail({ email, callbackURL: '/sign-in' });
270
- if (result.error) throw Error('Verification unavailable');
271
- }
272
- async function authenticate(data: FormData, create: boolean) {
273
- const email = String(data.get('email')); const password = String(data.get('password')); const name = String(data.get('name'));
274
- const result = create ? await authClient.signUp.email({ email, password, name, callbackURL: '/sign-in' }) : await authClient.signIn.email({ email, password });
275
- if (result.error) throw Error('Sign in failed.');
276
- return Boolean(result.data?.token);
277
- }
278
- export default function SignIn() {
279
- const form = useRef<HTMLFormElement>(null);
280
- const router = useRouter(); const [create, setCreate] = useState(false); const [pending, setPending] = useState(false); const [error, setError] = useState('');
281
- async function submit(event: FormEvent<HTMLFormElement>) { event.preventDefault(); if (pending) return; setPending(true); setError('');
282
- const data = new FormData(event.currentTarget);
283
- try { const signedIn = await authenticate(data, create); if (verificationPending(create, signedIn)) { form.current?.reset(); setCreate(false); setError('Check your email to verify your account, then sign in.'); return; } router.replace('/account'); router.refresh(); } catch { setError('Unable to sign in. Check your details and retry.'); } finally { setPending(false); }
284
- }
285
- async function resend() {
286
- const input = form.current?.querySelector<HTMLInputElement>('[name="email"]');
287
- if (pending || !input?.reportValidity()) return;
288
- const email = input.value;
289
- setPending(true); setError('');
290
- try {
291
- await requestVerification(email);
292
- setError('If verification is needed, check your email for the link.');
293
- } catch { setError('Unable to request verification. Please retry.'); }
294
- finally { setPending(false); }
295
- }
296
- const labels = create ? { title: 'Create account', password: 'new-password', toggle: 'Use an existing account' } : { title: 'Sign in', password: 'current-password', toggle: 'Create an account' };
297
- return <section className="stack"><h1>{labels.title}</h1><form ref={form} onSubmit={submit}>{create && <Label>Name<Input name="name" required autoComplete="name" /></Label>}<Label>Email<Input name="email" type="email" required autoComplete="email" /></Label><Label>Password<Input name="password" type="password" minLength={8} required autoComplete={labels.password} /></Label><Button type="submit" disabled={pending}>{pending ? 'Working…' : labels.title}</Button><p role="status">{error}</p><Link href="/reset-password">Forgot your password?</Link><Button type="button" disabled={pending} onClick={() => void resend()}>Resend verification email</Button><Button type="button" disabled={pending} onClick={() => setCreate(!create)}>{labels.toggle}</Button></form></section>;
298
- }
299
- `;
@@ -1,14 +1,3 @@
1
1
  export declare const PROJECT_CONFIG_FILE = "anhedral.json";
2
- export declare const PROJECT_CONFIG_MAX_BYTES: number;
3
- export declare const PROJECT_CONFIG_SECTIONS: readonly ["identity", "standard", "setup", "providers", "cloudflare", "registry"];
4
- export type ProjectSection = (typeof PROJECT_CONFIG_SECTIONS)[number];
5
- export type ProjectConfig = {
6
- schemaVersion: 1;
7
- } & Partial<Record<ProjectSection, unknown>>;
8
- /** Validate the envelope independently; each domain validates its own selected section. */
9
- export declare function parseProjectConfig(value: unknown): ProjectConfig;
10
- export declare function projectConfigPath(root: string): string;
11
- export declare function readProjectConfig(root: string): ProjectConfig;
12
- export declare function hasProjectSection(root: string, section: ProjectSection): boolean;
13
- export declare function readProjectSection<T = any>(root: string, section: ProjectSection): T;
14
- export declare function writeProjectSection(root: string, section: ProjectSection, value: unknown): void;
2
+ /** Called only inside a fresh staged workspace. Contains nonsecret generation provenance. */
3
+ export declare function writeProjectSection(root: string, section: string, value: unknown): void;
@@ -1,88 +1,16 @@
1
- import { randomUUID } from 'node:crypto';
2
- import { lstatSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
1
+ import { readFileSync, writeFileSync } from 'node:fs';
3
2
  import path from 'node:path';
4
- import { withSourceWriteLock } from './transaction.js';
5
- import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from './bounded-file.js';
6
3
  export const PROJECT_CONFIG_FILE = 'anhedral.json';
7
- export const PROJECT_CONFIG_MAX_BYTES = MAX_PROJECT_JSON_BYTES;
8
- export const PROJECT_CONFIG_SECTIONS = [
9
- 'identity',
10
- 'standard',
11
- 'setup',
12
- 'providers',
13
- 'cloudflare',
14
- 'registry',
15
- ];
16
- /** Validate the envelope independently; each domain validates its own selected section. */
17
- export function parseProjectConfig(value) {
18
- if (!value ||
19
- typeof value !== 'object' ||
20
- Array.isArray(value) ||
21
- value.schemaVersion !== 1 ||
22
- Object.keys(value).some((key) => key !== 'schemaVersion' && !PROJECT_CONFIG_SECTIONS.includes(key)))
23
- throw new Error('Invalid anhedral.json configuration.');
24
- return value;
25
- }
26
- export function projectConfigPath(root) {
27
- return path.join(root, PROJECT_CONFIG_FILE);
28
- }
29
- export function readProjectConfig(root) {
30
- const source = readBoundedFile(projectConfigPath(root), PROJECT_CONFIG_MAX_BYTES).toString('utf8');
31
- try {
32
- return parseProjectConfig(JSON.parse(source));
33
- }
34
- catch {
35
- throw new Error('Invalid anhedral.json configuration.');
36
- }
37
- }
38
- function assertSection(section) {
39
- if (!PROJECT_CONFIG_SECTIONS.includes(section))
40
- throw new Error('Unknown anhedral.json section.');
41
- }
42
- export function hasProjectSection(root, section) {
43
- assertSection(section);
44
- if (!lstatSync(projectConfigPath(root), { throwIfNoEntry: false }))
45
- return false;
46
- return Object.hasOwn(readProjectConfig(root), section);
47
- }
48
- // Domain callers retain responsibility for validating their complete section contracts.
49
- export function readProjectSection(root, section) {
50
- assertSection(section);
51
- const value = readProjectConfig(root)[section];
52
- if (!value || typeof value !== 'object' || Array.isArray(value))
53
- throw new Error(`Missing or invalid anhedral.json ${section} section.`);
54
- return value;
55
- }
56
- /** Atomically replace one section while preserving other domains' configuration. */
57
- function writeSection(root, section, value) {
58
- assertSection(section);
59
- if (!value || typeof value !== 'object' || Array.isArray(value))
60
- throw new Error(`Invalid anhedral.json ${section} section.`);
61
- const file = projectConfigPath(root);
62
- const previous = lstatSync(file, { throwIfNoEntry: false }) ? readProjectConfig(root) : {};
63
- const config = { ...previous, schemaVersion: 1, [section]: value };
64
- const ordered = {
65
- schemaVersion: 1,
66
- ...Object.fromEntries(PROJECT_CONFIG_SECTIONS.filter((key) => Object.hasOwn(config, key)).map((key) => [
67
- key,
68
- config[key],
69
- ])),
70
- };
71
- const bytes = JSON.stringify(ordered, null, 2) + '\n';
72
- if (Buffer.byteLength(bytes) > PROJECT_CONFIG_MAX_BYTES)
73
- throw new Error('anhedral.json exceeds its size limit.');
74
- // Avoid changing source bytes or permissions when the requested section is unchanged.
75
- if (lstatSync(file, { throwIfNoEntry: false }) && readFileSync(file, 'utf8') === bytes)
76
- return;
77
- const temporary = `${file}.${randomUUID()}.tmp`;
4
+ /** Called only inside a fresh staged workspace. Contains nonsecret generation provenance. */
5
+ export function writeProjectSection(root, section, value) {
6
+ const file = path.join(root, PROJECT_CONFIG_FILE);
7
+ let previous = {};
78
8
  try {
79
- writeFileSync(temporary, bytes, { mode: 0o600, flag: 'wx' });
80
- renameSync(temporary, file);
9
+ previous = JSON.parse(readFileSync(file, 'utf8'));
81
10
  }
82
- finally {
83
- rmSync(temporary, { force: true });
11
+ catch (error) {
12
+ if (error.code !== 'ENOENT')
13
+ throw error;
84
14
  }
85
- }
86
- export function writeProjectSection(root, section, value) {
87
- withSourceWriteLock(root, () => writeSection(root, section, value));
15
+ writeFileSync(file, JSON.stringify({ ...previous, schemaVersion: 1, [section]: value }, null, 2) + '\n');
88
16
  }
@@ -18,11 +18,7 @@ function parseStandardFlags(remaining) {
18
18
  gitSpecified = readGitFlag(token, gitSpecified);
19
19
  continue;
20
20
  }
21
- if (token === '--stripe' || token === '--revenuecat') {
22
- products.add(token.slice(2));
23
- continue;
24
- }
25
- throw new Error(`Unknown init option: ${token}. The core stack is always included; optional additions are --stripe and --revenuecat.`);
21
+ throw new Error(`Unknown init option: ${token}. Run anhedral init --help.`);
26
22
  }
27
23
  return { products, hosting, gitSpecified };
28
24
  }
@@ -1,6 +1,6 @@
1
1
  import type { Hosting, StandardOptions, StandardProduct, StackRegistryItem } from './types.js';
2
2
  export declare const CORE_PRODUCTS: readonly StandardProduct[];
3
- /** Every initialization uses one foundation; only payment additions are optional. */
3
+ /** Every initialization uses the same foundation. */
4
4
  export declare function resolveStandardProducts(selected: Set<StandardProduct>, hosting: Hosting): void;
5
5
  export interface ResolvedStackRegistry {
6
6
  schemaVersion: number;
@@ -1,16 +1,8 @@
1
1
  import { dependencyOrder } from '../dependency-order.js';
2
2
  import { STANDARD_PRODUCTS, STACK_REGISTRY, getStackDefinition, getStackItem, } from '../stack-registry.js';
3
3
  import { createResolutionContext } from './context.js';
4
- export const CORE_PRODUCTS = [
5
- 'next',
6
- 'expo',
7
- 'hono',
8
- 'd1',
9
- 'r2',
10
- 'better-auth',
11
- 'styling',
12
- ];
13
- /** Every initialization uses one foundation; only payment additions are optional. */
4
+ export const CORE_PRODUCTS = ['next', 'styling'];
5
+ /** Every initialization uses the same foundation. */
14
6
  export function resolveStandardProducts(selected, hosting) {
15
7
  if (hosting !== 'cloudflare')
16
8
  throw new Error('Anhedral applications use Cloudflare Workers.');
@@ -1,18 +1,12 @@
1
1
  import { COMMANDS, GLOBAL_OPTIONS, optionHelp } from '../command-schema.js';
2
- // Preserve the presentation API for consumers; all option text comes from typed definitions.
3
2
  export const COMMAND_HELP = Object.fromEntries(Object.entries(COMMANDS).map(([name, entry]) => [
4
3
  name,
5
- { ...entry, options: entry.options.filter((option) => !option.hidden).map(optionHelp) },
4
+ { ...entry, options: entry.options.map(optionHelp) },
6
5
  ]));
7
- const primary = ['init', 'auth', 'ship', 'add', 'registry', 'inspect', 'doctor', 'connect'];
8
- const common = GLOBAL_OPTIONS.map(optionHelp);
9
6
  export function commandHelp(command) {
10
7
  const entry = COMMAND_HELP[command];
11
8
  if (!entry)
12
9
  return undefined;
13
- return `${entry.description}\n\nUsage: anhedral ${entry.usage}\n\nOptions:\n${[...entry.options, ...common].map((option) => ` ${option}`).join('\n')}\n\nExamples:\n${entry.examples.map((example) => ` anhedral ${example}`).join('\n')}${entry.note ? `\n\n${entry.note}` : ''}\n`;
10
+ return `${entry.description}\n\nUsage: anhedral ${entry.usage}\n\nOptions:\n${[...entry.options, ...GLOBAL_OPTIONS.map(optionHelp)].map((option) => ` ${option}`).join('\n')}\n\n${entry.note}\n`;
14
11
  }
15
- export const STANDARD_USAGE = `Anhedral\nCreate and ship applications with one consistent core stack.\n\nUsage: anhedral <command> [options]\n\nStart here:\n${primary.map((name) => ` ${name.padEnd(12)}${COMMAND_HELP[name].description}`).join('\n')}\n\nDelivery tools:\n${Object.entries(COMMAND_HELP)
16
- .filter(([name]) => !primary.includes(name))
17
- .map(([name, entry]) => ` ${name.padEnd(12)}${entry.description}`)
18
- .join('\n')}\n\nDefault: Next.js web + native Expo + Hono + Drizzle/D1 + private R2, with Better Auth and shared styling. Stripe and RevenueCat are the only optional additions.\nExamples:\n anhedral init client-app\n anhedral init client-app --stripe --revenuecat\n anhedral auth client-app\n anhedral ship client-app --dry-run\n\nUse anhedral <command> --help for options and examples.\nUse anhedral help <command> for the same focused help.\nGlobal options:\n${common.map((option) => ` ${option}`).join('\n')}\n -v, --version Show the CLI version.\n`;
12
+ export const STANDARD_USAGE = `Anhedral — an open-source stack foundation\n\n${commandHelp('init')}\n${commandHelp('ui')}\n${commandHelp('add')}\n${commandHelp('stack')}\n -v, --version Show the CLI version.\n`;
@@ -6,14 +6,11 @@ export function scaffoldContracts(root) {
6
6
  import { createHttpClient, type HttpOptions } from './http';
7
7
 
8
8
  export const healthSchema = z.object({ ok: z.literal(true) });
9
- export const sessionSchema = z.object({ user: z.object({ id: z.string(), name: z.string(), email: z.email() }) });
10
- export type Session = z.infer<typeof sessionSchema>;
11
9
 
12
10
  export function createApiClient(baseURL = '/api', options: HttpOptions = {}) {
13
11
  const request = createHttpClient(baseURL, options);
14
12
  return {
15
13
  health: (init?: RequestInit) => request('/health', healthSchema, init),
16
- session: (init?: RequestInit) => request('/session', sessionSchema, init),
17
14
  };
18
15
  }
19
16
  `, { zod: STACK_DEPENDENCIES.zod });
@@ -36,5 +36,6 @@ process.exitCode = result.status ?? 1;
36
36
  });
37
37
  patchPackage(root, 'apps/api/package.json', { dependencies: { '@workspace/db': 'workspace:*' } });
38
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" + source);
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(); });"));
40
41
  }
@@ -1,40 +1,102 @@
1
+ import { capabilityReferences } from '../capability-references.js';
1
2
  import { put } from './files.js';
2
3
  export function writeSetupDocumentation(root, options) {
3
- put(root, 'AGENTS.md', `# Anhedral application
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}
4
8
 
5
- This project uses Next.js App Router/OpenNext for web and Expo for iOS/Android, a Hono Cloudflare Worker, Drizzle/D1, and private R2. Better Auth supplies the identity needed for private storage and payments. Shared styling tokens are in packages/styling; native components use the Anhedral-maintained shadcn port in packages/native-ui. Optional integrations are Stripe and RevenueCat only.
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.
6
12
 
7
- Hono owns authentication, authorization, persistence, and provider credentials. Clients use API contracts in packages/contracts and never import database/auth server code. Apps must not import each other's source. Keep one root pnpm lockfile. No secrets belong in client bundles.
13
+ ## Develop
8
14
 
9
- Review SQL produced by pnpm db:generate. Apply local migrations explicitly using pnpm db:migrate. Remote migrations require an explicit --remote and reviewed target. Builds and startup never migrate databases. R2 stays private; the API derives object namespaces from the verified user, never client-supplied ownership.
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.
10
17
 
11
- Run pnpm lint, pnpm typecheck, and pnpm build. Verify signup/signin/signout, anonymous rejection and cross-user file isolation. Payment additions require provider sandbox purchase/restore/webhook verification. Keep architecture and dated acceptance evidence in docs/architecture.md and docs/verification.md. Init does not provision, deploy or activate payment services.
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.
12
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
+ }
13
64
  put(root, 'README.md', `# ${options.name}
14
65
 
15
- Next.js web + native Expo + Hono + Drizzle/D1 + private R2. Better Auth provides email/password accounts for private files. ${options.products.includes('stripe') ? 'Stripe is selected. ' : ''}${options.products.includes('revenuecat') ? 'RevenueCat is selected.' : ''}
66
+ Next.js App Router/OpenNext + Expo native + shadcn UI + Hono/workerd + Drizzle/D1 + private R2.
16
67
 
17
- ## Local setup
68
+ ## Develop locally
18
69
 
19
- Use the Node and pnpm versions in package.json. Install dependencies if initialization used --skip-install.
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.
20
71
 
21
- 1. Copy apps/api/.dev.vars.example to apps/api/.dev.vars. Set BETTER_AUTH_SECRET to at least 32 random characters and keep BETTER_AUTH_URL=http://localhost:3000 for local web.
22
- 2. Run pnpm db:generate, review the generated SQL, then pnpm db:migrate (local D1 only by default).
23
- 3. Run pnpm dev. Open http://localhost:3000. Create an account using the Sign in / account link.
24
- 4. Native development uses pnpm --dir apps/mobile start. Configure EXPO_PUBLIC_API_URL in apps/mobile/.env for an API address reachable by the device and set BETTER_AUTH_URL to that origin when testing native. Use HTTPS outside local development.
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.
25
73
 
26
- ## Private files
74
+ ## UI and device capabilities
27
75
 
28
- Authenticated POST /api/files accepts raw bytes up to 1 MiB and returns an opaque id. GET /api/files/:id downloads it; DELETE /api/files/:id deletes it. Every operation is scoped to the signed-in user. Files are forced to download as application/octet-stream; bucket credentials and public bucket URLs are never sent to clients. Applications add their own file picker, quotas, retention and product UI.
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.
77
+
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.
79
+
80
+ ## Data and private storage
81
+
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.
83
+
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.
85
+
86
+ ## Your application
87
+
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
29
91
 
30
- ## Cloud resources and delivery
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.
31
93
 
32
- Initialization is local source generation. Configure the intended Cloudflare account, provision a D1 database and private R2 bucket using the CLI provider workflow, and review apps/api/wrangler.jsonc. Keep public R2 access disabled. Set production secrets through Wrangler. Review/apply remote migrations explicitly before deployment. Ship the API before the Next.js OpenNext Worker, then verify real authentication and file isolation. See docs/stack.md and anhedral.json for setup requirements.
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.
33
95
 
34
- Next.js supports request-rendered HTML and React Server Components. Production requires the ANHEDRAL_API service binding; API_INTERNAL_URL is restricted to loopback development. The default OpenNext adapter does not provision persistent ISR/cache storage. Private R2 and all database/auth/provider credentials belong only to Hono.
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.
35
97
 
36
- Stripe and RevenueCat remain inactive until client-owned provider products, credentials, origins and webhooks are configured. Verify sandbox flows before live activation.
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.
37
99
  `);
38
- put(root, 'docs/architecture.md', '# Architecture\n\nNext.js web / Expo native → Hono Worker → Drizzle/D1 and private R2. Better Auth identifies users. Record application flows, access boundaries and selected payment providers here.\n');
39
- put(root, 'docs/verification.md', '# Verification\n\nRecord dates, environments, commands, denied-access checks and unresolved acceptance gaps. Generated source is not production acceptance.\n');
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');
40
102
  }
@@ -13,7 +13,7 @@ type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
13
13
  function validProtocol(url: URL): boolean {
14
14
  return url.protocol === 'https:' || (__DEV__ && url.protocol === 'http:');
15
15
  }
16
- export function nativeApiOrigin(): string {
16
+ function nativeApiOrigin(): string {
17
17
  const configured = process.env.EXPO_PUBLIC_API_URL;
18
18
  if (!configured) throw new Error('Configure EXPO_PUBLIC_API_URL with the product origin reachable from this device.');
19
19
  const origin = new URL(configured);
@@ -26,14 +26,13 @@ function apiBaseURL(): string {
26
26
  return nativeApiOrigin() + '/api';
27
27
  }
28
28
 
29
- // A native auth adapter can provide its own session headers. No server secret belongs here.
30
- 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 = {}) {
31
31
  const client = () => createApiClient(apiBaseURL(), {
32
32
  ...options, credentials: 'omit',
33
33
  });
34
34
  return {
35
35
  health: (init?: RequestInit) => client().health(init),
36
- session: (init?: RequestInit) => client().session(init),
37
36
  };
38
37
  }
39
38