anhedral 0.13.0 → 0.15.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 (170) hide show
  1. package/README.md +35 -232
  2. package/assets/patches/audit-deps.mjs +12 -2
  3. package/assets/ui/LICENSE.shadcn +21 -0
  4. package/assets/ui/UPSTREAM.json +33 -0
  5. package/assets/ui/native/button.tsx +85 -0
  6. package/assets/ui/native/card.tsx +33 -0
  7. package/assets/ui/native/dialog.tsx +75 -0
  8. package/assets/ui/native/input.tsx +27 -0
  9. package/assets/ui/native/label.tsx +4 -0
  10. package/assets/ui/native/layout.tsx +26 -0
  11. package/assets/ui/native/text.tsx +20 -0
  12. package/assets/ui/native/theme-switcher.tsx +22 -0
  13. package/assets/ui/theme-storage.ts +25 -0
  14. package/assets/ui/theme.tsx +66 -0
  15. package/assets/ui/web/button.tsx +59 -0
  16. package/assets/ui/web/input.tsx +21 -0
  17. package/assets/ui/web/label.tsx +19 -0
  18. package/dist/capabilities.d.ts +5 -5
  19. package/dist/capabilities.js +3 -21
  20. package/dist/capability-contract.d.ts +3 -3
  21. package/dist/capability-contract.js +11 -50
  22. package/dist/cli-delivery.d.ts +1 -1
  23. package/dist/cli-delivery.js +5 -65
  24. package/dist/cli-output.js +3 -3
  25. package/dist/command-schema.js +35 -86
  26. package/dist/delivery-evidence.d.ts +1 -1
  27. package/dist/delivery-evidence.js +7 -36
  28. package/dist/delivery.d.ts +2 -8
  29. package/dist/delivery.js +20 -101
  30. package/dist/dependencies.d.ts +6 -57
  31. package/dist/dependencies.js +54 -188
  32. package/dist/index.d.ts +1 -4
  33. package/dist/index.js +1 -4
  34. package/dist/inspector-model.d.ts +2 -2
  35. package/dist/integration-service-readers.d.ts +1 -2
  36. package/dist/integration-service-readers.js +3 -84
  37. package/dist/lifecycle-model.d.ts +1 -1
  38. package/dist/lifecycle-model.js +1 -1
  39. package/dist/mobile-delivery.d.ts +1 -1
  40. package/dist/mobile-delivery.js +4 -0
  41. package/dist/platforms/mobile.js +30 -121
  42. package/dist/platforms/web.d.ts +3 -0
  43. package/dist/platforms/web.js +299 -0
  44. package/dist/project-config.d.ts +1 -1
  45. package/dist/project-config.js +0 -1
  46. package/dist/project-inspector.js +5 -36
  47. package/dist/project-state.d.ts +1 -3
  48. package/dist/project-state.js +2 -85
  49. package/dist/provider-auth.js +3 -38
  50. package/dist/provider-readiness.d.ts +1 -1
  51. package/dist/provider-readiness.js +5 -24
  52. package/dist/providers/adapters.js +0 -175
  53. package/dist/providers/api.d.ts +1 -1
  54. package/dist/providers/api.js +3 -3
  55. package/dist/providers/config.js +2 -48
  56. package/dist/providers/definitions.d.ts +1 -204
  57. package/dist/providers/definitions.js +0 -85
  58. package/dist/providers/provision.d.ts +1 -1
  59. package/dist/providers/receipts.js +1 -11
  60. package/dist/providers/recovery-verification.js +1 -61
  61. package/dist/providers/runtime.js +4 -35
  62. package/dist/providers/state.js +1 -7
  63. package/dist/provision.d.ts +5 -13
  64. package/dist/provision.js +4 -80
  65. package/dist/readiness.d.ts +1 -1
  66. package/dist/readiness.js +3 -8
  67. package/dist/registry/add.js +10 -70
  68. package/dist/registry/bootstrap.d.ts +3 -2
  69. package/dist/registry/bootstrap.js +4 -13
  70. package/dist/registry/commands.js +8 -10
  71. package/dist/registry/context.js +0 -1
  72. package/dist/registry/options.js +8 -38
  73. package/dist/registry/resolve.d.ts +3 -4
  74. package/dist/registry/resolve.js +26 -108
  75. package/dist/registry/types.d.ts +1 -7
  76. package/dist/registry/usage.js +2 -2
  77. package/dist/runtime-policy.d.ts +0 -2
  78. package/dist/runtime-policy.js +0 -16
  79. package/dist/scaffold/auth.d.ts +1 -2
  80. package/dist/scaffold/auth.js +55 -130
  81. package/dist/scaffold/backend.d.ts +0 -4
  82. package/dist/scaffold/backend.js +1 -186
  83. package/dist/scaffold/billing-schema.d.ts +1 -1
  84. package/dist/scaffold/billing-schema.js +4 -4
  85. package/dist/scaffold/billing.js +11 -19
  86. package/dist/scaffold/bootstrap.d.ts +2 -3
  87. package/dist/scaffold/bootstrap.js +37 -43
  88. package/dist/scaffold/compose.js +2 -14
  89. package/dist/scaffold/database.d.ts +1 -1
  90. package/dist/scaffold/database.js +18 -126
  91. package/dist/scaffold/documentation.d.ts +0 -1
  92. package/dist/scaffold/documentation.js +22 -86
  93. package/dist/scaffold/expo-auth.js +33 -22
  94. package/dist/scaffold/expo-billing.js +17 -52
  95. package/dist/scaffold/expo-runtime.d.ts +2 -2
  96. package/dist/scaffold/expo-runtime.js +6 -97
  97. package/dist/scaffold/integrations.d.ts +1 -3
  98. package/dist/scaffold/integrations.js +9 -10
  99. package/dist/scaffold/managed-email.d.ts +3 -0
  100. package/dist/scaffold/managed-email.js +47 -0
  101. package/dist/scaffold/native-ui.d.ts +2 -0
  102. package/dist/scaffold/native-ui.js +69 -0
  103. package/dist/scaffold/password-reset.d.ts +1 -0
  104. package/dist/scaffold/password-reset.js +99 -0
  105. package/dist/scaffold/private-files.d.ts +2 -0
  106. package/dist/scaffold/private-files.js +78 -0
  107. package/dist/scaffold/stack-documentation.d.ts +0 -1
  108. package/dist/scaffold/stack-documentation.js +3 -49
  109. package/dist/scaffold/styling.d.ts +1 -1
  110. package/dist/scaffold/styling.js +20 -28
  111. package/dist/scaffold/web-billing.d.ts +2 -0
  112. package/dist/scaffold/web-billing.js +48 -0
  113. package/dist/scaffold/workspace.js +53 -194
  114. package/dist/service-deletion.js +1 -1
  115. package/dist/service-descriptor.js +5 -12
  116. package/dist/service-model.d.ts +1 -1
  117. package/dist/service-operations.js +2 -32
  118. package/dist/service-readers.js +1 -32
  119. package/dist/services-command.d.ts +1 -1
  120. package/dist/services-command.js +3 -9
  121. package/dist/ship.d.ts +3 -316
  122. package/dist/ship.js +10 -142
  123. package/dist/stack-registry.d.ts +2 -52
  124. package/dist/stack-registry.js +55 -403
  125. package/dist/standard.js +7 -14
  126. package/dist/version.d.ts +1 -1
  127. package/dist/version.js +1 -1
  128. package/docs/anhedral-stack.md +23 -122
  129. package/docs/assets/anhedral-stack-light.png +0 -0
  130. package/docs/assets/anhedral-stack.png +0 -0
  131. package/docs/software-factory.md +24 -557
  132. package/docs/stack-standard.md +47 -294
  133. package/docs/verification.md +320 -0
  134. package/package.json +20 -22
  135. package/dist/neon-service-data.d.ts +0 -8
  136. package/dist/neon-service-data.js +0 -117
  137. package/dist/platforms/desktop.d.ts +0 -2
  138. package/dist/platforms/desktop.js +0 -415
  139. package/dist/platforms/extension.d.ts +0 -2
  140. package/dist/platforms/extension.js +0 -328
  141. package/dist/registry/presets.d.ts +0 -4
  142. package/dist/registry/presets.js +0 -41
  143. package/dist/scaffold/cloudflare-services.d.ts +0 -8
  144. package/dist/scaffold/cloudflare-services.js +0 -198
  145. package/dist/scaffold/lint.d.ts +0 -4
  146. package/dist/scaffold/lint.js +0 -56
  147. package/dist/scaffold/neon-realtime.d.ts +0 -2
  148. package/dist/scaffold/neon-realtime.js +0 -97
  149. package/dist/scaffold/services.d.ts +0 -5
  150. package/dist/scaffold/services.js +0 -108
  151. package/dist/scaffold/stream.d.ts +0 -2
  152. package/dist/scaffold/stream.js +0 -114
  153. package/dist/scaffold/void.d.ts +0 -4
  154. package/dist/scaffold/void.js +0 -264
  155. package/dist/scaffold/web.d.ts +0 -2
  156. package/dist/scaffold/web.js +0 -130
  157. package/dist/vercel-project.d.ts +0 -101
  158. package/dist/vercel-project.js +0 -305
  159. package/dist/vercel.d.ts +0 -67
  160. package/dist/vercel.js +0 -581
  161. package/dist/vinext.d.ts +0 -2
  162. package/dist/vinext.js +0 -86
  163. package/dist/void-execution.d.ts +0 -10
  164. package/dist/void-execution.js +0 -94
  165. package/dist/void-migrations.d.ts +0 -6
  166. package/dist/void-migrations.js +0 -110
  167. package/dist/void-state.d.ts +0 -16
  168. package/dist/void-state.js +0 -65
  169. package/dist/void.d.ts +0 -3
  170. package/dist/void.js +0 -5
@@ -1 +1 @@
1
- export declare function scaffoldBillingSchema(root: string, postgres: boolean): void;
1
+ export declare function scaffoldBillingSchema(root: string): void;
@@ -1,10 +1,10 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { put } from './files.js';
4
- export function scaffoldBillingSchema(root, postgres) {
5
- const table = postgres ? 'pgTable' : 'sqliteTable';
6
- const integer = postgres ? "bigint(name, { mode: 'number' })" : 'integer(name)';
7
- put(root, 'packages/db/src/billing-schema.ts', `import { ${table}, text, ${postgres ? 'bigint' : 'integer'}, index } from 'drizzle-orm/${postgres ? 'pg-core' : 'sqlite-core'}';
4
+ export function scaffoldBillingSchema(root) {
5
+ const table = 'sqliteTable';
6
+ const integer = 'integer(name)';
7
+ put(root, 'packages/db/src/billing-schema.ts', `import { ${table}, text, integer, index } from 'drizzle-orm/sqlite-core';
8
8
  const number = (name: string) => ${integer};
9
9
 
10
10
  // Billing IDs are verified auth subjects, including external identity providers.
@@ -1,7 +1,8 @@
1
- import { existsSync, readFileSync } from 'node:fs';
1
+ import { readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { STACK_DEPENDENCIES } from '../dependencies.js';
4
4
  import { scaffoldBillingContracts } from './billing-contracts.js';
5
+ import { scaffoldWebBilling } from './web-billing.js';
5
6
  import { scaffoldExpoBilling } from './expo-billing.js';
6
7
  import { scaffoldBillingSchema } from './billing-schema.js';
7
8
  import { BILLING_CONFIG } from './billing-config.js';
@@ -13,19 +14,14 @@ import { writeEnvironmentFile } from './environment.js';
13
14
  import { json, patchPackage, put, readJson, sharedPackage } from './files.js';
14
15
  function applicationBilling(context) {
15
16
  const { has } = context;
16
- const database = has('neon') ? 'env.DATABASE_URL' : 'env.DB';
17
- const authenticate = has('clerk')
18
- ? `const state = await authenticate(request, env.CLERK_SECRET_KEY, env.CLERK_PUBLISHABLE_KEY, [new URL(env.BILLING_ORIGIN).origin]);
19
- const subject = state.toAuth()?.userId;
20
- if (!subject) throw new BillingError(401, 'Sign in to access billing.');
21
- return subject;`
22
- : `const session = await createAuth(createDatabase(${database}), env.BETTER_AUTH_SECRET, env.BETTER_AUTH_URL).api.getSession({ headers: request.headers });
17
+ const database = 'env.DB';
18
+ const authenticate = `const session = await createAuth(createDatabase(env.DB), env.BETTER_AUTH_SECRET, env.BETTER_AUTH_URL, env).api.getSession({ headers: request.headers });
23
19
  if (!session) throw new BillingError(401, 'Sign in to access billing.');
24
20
  return session.user.id;`;
25
21
  return `import { Hono, type Context } from 'hono';
26
22
  import { z } from 'zod';
27
23
  import { createDatabase } from '@workspace/db';
28
- import { ${has('clerk') ? 'authenticate' : 'createAuth'} } from '@workspace/auth';
24
+ import { createAuth } from '@workspace/auth';
29
25
  import { createBilling, BillingError, type Billing } from '@workspace/billing/server';
30
26
 
31
27
  type BillingContext = Context<{ Bindings: Env }>;
@@ -114,6 +110,7 @@ function connectApi(context) {
114
110
  const { root } = context;
115
111
  put(root, 'apps/api/src/billing.ts', applicationBilling(context));
116
112
  put(root, 'apps/api/src/billing-env.d.ts', `import type { BillingEnv } from '@workspace/billing/config';
113
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- Merge billing bindings with Wrangler's generated Env.
117
114
  declare global { interface Env extends BillingEnv {} }
118
115
  export {};
119
116
  `);
@@ -132,8 +129,7 @@ export default {
132
129
  context.waitUntil(drainBilling(env));
133
130
  },
134
131
  };`));
135
- const voidSelected = existsSync(path.join(root, 'apps/api/void.config.ts'));
136
- const configuration = `apps/api/${voidSelected ? 'anhedral.cloudflare.json' : 'wrangler.jsonc'}`;
132
+ const configuration = 'apps/api/wrangler.jsonc';
137
133
  const config = readJson(root, configuration);
138
134
  const triggers = (config.triggers ?? {});
139
135
  config.triggers = {
@@ -141,20 +137,15 @@ export default {
141
137
  crons: [...new Set([...(triggers.crons ?? []), '*/5 * * * *'])],
142
138
  };
143
139
  json(root, configuration, config);
144
- if (voidSelected)
145
- put(root, 'apps/api/crons/scheduled.ts', `import application from '../src/index';
146
- export const cron = ['*/5 * * * *'];
147
- export default application.scheduled;
148
- `);
149
140
  }
150
141
  export function scaffoldBilling(context) {
151
142
  const { root, has } = context;
152
143
  if (!has('hono'))
153
144
  throw new Error('Billing requires the shared Hono runtime.');
154
- if (!has('d1') && !has('neon'))
155
- throw new Error('Billing requires a selected database.');
145
+ if (!has('d1'))
146
+ throw new Error('Billing requires the core D1 database.');
156
147
  scaffoldBillingContracts(root);
157
- scaffoldBillingSchema(root, has('neon'));
148
+ scaffoldBillingSchema(root);
158
149
  sharedPackage(root, 'billing', "export { createBilling, BillingError } from './server';\n", {
159
150
  '@workspace/contracts': 'workspace:*',
160
151
  '@workspace/db': 'workspace:*',
@@ -196,6 +187,7 @@ export function scaffoldBilling(context) {
196
187
  : {}),
197
188
  });
198
189
  scaffoldExpoBilling(context);
190
+ scaffoldWebBilling(context);
199
191
  put(root, 'packages/billing/README.md', BILLING_README);
200
192
  }
201
193
  const BILLING_README = `# Shared billing
@@ -1,5 +1,4 @@
1
1
  import type { StandardRunner } from '../registry/types.js';
2
- export declare function assertBootstrapPlatform(run: StandardRunner, platform?: NodeJS.Platform): void;
3
- /** Planning and diagnostics support older Node releases; generated dependencies do not. */
4
2
  export declare function assertWorkspaceRuntime(run: StandardRunner, version?: string): void;
5
- export declare function bootstrapWorkspace(root: string, name: string, run: StandardRunner, webOnly?: boolean): void;
3
+ /** No downloaded template, disposable Next app or initialization-time cloud operation. */
4
+ export declare function bootstrapWorkspace(root: string, name: string, run: StandardRunner): void;
@@ -1,48 +1,42 @@
1
- import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from 'node:fs';
2
- import path from 'node:path';
3
- import { execFile, appendGitignore } from '../util.js';
4
- import { bootstrapArguments } from '../registry/bootstrap.js';
5
1
  import { supportsWorkspaceRuntime } from '../runtime-policy.js';
6
- export function assertBootstrapPlatform(run, platform = process.platform) {
7
- if (platform === 'win32' && run === execFile)
8
- throw new Error('Native Windows initialization is blocked because the upstream shadcn monorepo bootstrap writes component files outside the project. Run Anhedral inside WSL. Planning and doctor remain available on Windows.');
9
- }
10
- /** Planning and diagnostics support older Node releases; generated dependencies do not. */
2
+ import { execFile } from '../util.js';
3
+ import { STACK_DEPENDENCIES } from '../dependencies.js';
4
+ import { json, put } from './files.js';
11
5
  export function assertWorkspaceRuntime(run, version = process.versions.node) {
12
- if (run !== execFile)
13
- return;
14
- if (!supportsWorkspaceRuntime(version))
15
- throw new Error('Generated workspaces require Node.js 22.13+ on the 22.x line or Node.js 24+. Planning and doctor remain available on older CLI-supported versions.');
6
+ if (run === execFile && !supportsWorkspaceRuntime(version))
7
+ throw new Error('Generated workspaces require Node.js 22.13+ on the 22.x line or Node.js 24+.');
16
8
  }
17
- export function bootstrapWorkspace(root, name, run, webOnly = false) {
18
- assertBootstrapPlatform(run);
9
+ /** No downloaded template, disposable Next app or initialization-time cloud operation. */
10
+ export function bootstrapWorkspace(root, name, run) {
19
11
  assertWorkspaceRuntime(run);
20
- const temporary = path.join(root, '.bootstrap');
21
- mkdirSync(temporary);
22
- try {
23
- run('pnpm', bootstrapArguments(name, temporary), root);
24
- const generated = path.join(temporary, name);
25
- if (!existsSync(path.join(generated, 'pnpm-workspace.yaml')) ||
26
- !existsSync(path.join(generated, 'apps/web/package.json')))
27
- throw new Error('Official shadcn bootstrap did not produce the expected monorepo.');
28
- const ignored = ['.git', 'node_modules', '.next', '.turbo'];
29
- const seed = !webOnly && existsSync(path.join(root, '.gitignore'))
30
- ? readFileSync(path.join(root, '.gitignore'), 'utf8')
31
- : '';
32
- for (const entry of webOnly ? ['apps/web', 'packages/ui'] : readdirSync(generated)) {
33
- if (ignored.includes(entry))
34
- continue;
35
- if (webOnly && existsSync(path.join(root, entry)))
36
- throw new Error(`Web foundation target already exists: ${entry}.`);
37
- cpSync(path.join(generated, entry), path.join(root, entry), {
38
- recursive: true,
39
- filter: (source) => !ignored.includes(path.basename(source)),
40
- });
41
- }
42
- if (seed)
43
- appendGitignore(root, seed.split(/\r?\n/));
44
- }
45
- finally {
46
- rmSync(temporary, { recursive: true, force: true });
47
- }
12
+ json(root, 'package.json', { name, private: true });
13
+ put(root, 'pnpm-workspace.yaml', 'packages:\n - apps/*\n - packages/*\n');
14
+ json(root, 'packages/typescript-config/package.json', {
15
+ name: '@workspace/typescript-config',
16
+ private: true,
17
+ exports: { './base.json': './base.json' },
18
+ });
19
+ json(root, 'packages/typescript-config/base.json', {
20
+ compilerOptions: {
21
+ strict: true,
22
+ skipLibCheck: true,
23
+ target: 'ES2022',
24
+ module: 'ESNext',
25
+ moduleResolution: 'Bundler',
26
+ },
27
+ });
28
+ json(root, 'packages/eslint-config/package.json', {
29
+ name: '@workspace/eslint-config',
30
+ private: true,
31
+ type: 'module',
32
+ exports: { './base': './base.js', './react-internal': './react-internal.js' },
33
+ dependencies: {
34
+ typescript: STACK_DEPENDENCIES.typescript,
35
+ eslint: STACK_DEPENDENCIES.eslint,
36
+ '@typescript-eslint/parser': STACK_DEPENDENCIES['@typescript-eslint/parser'],
37
+ '@typescript-eslint/eslint-plugin': STACK_DEPENDENCIES['@typescript-eslint/eslint-plugin'],
38
+ },
39
+ });
40
+ put(root, 'packages/eslint-config/base.js', "import parser from '@typescript-eslint/parser';\nimport plugin from '@typescript-eslint/eslint-plugin';\nexport const config = [{ ignores: ['dist/**', '.output/**', '.wrangler/**', 'worker-configuration.d.ts'] }, { files: ['**/*.{ts,tsx,cts,mts}'], languageOptions: { parser, parserOptions: { ecmaFeatures: { jsx: true } } }, plugins: { '@typescript-eslint': plugin }, rules: { ...plugin.configs.recommended.rules, 'no-undef': 'off', 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }] } }];\n");
41
+ put(root, 'packages/eslint-config/react-internal.js', "export { config } from './base.js';\n");
48
42
  }
@@ -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,40 @@
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" + source);
148
40
  }
@@ -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,40 @@
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';
5
1
  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
2
  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.
24
-
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.
3
+ put(root, 'AGENTS.md', `# Anhedral application
26
4
 
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.
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.
28
6
 
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' : ''}
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.
30
8
 
31
- Developer tooling includes Cloudflare’s security-audit skill (https://github.com/cloudflare/security-audit-skill) for repository security reviews.
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.
32
10
 
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.
34
-
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.
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.
12
+ `);
13
+ put(root, 'README.md', `# ${options.name}
36
14
 
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.
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.' : ''}
38
16
 
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)}
17
+ ## Local setup
42
18
 
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.
19
+ Use the Node and pnpm versions in package.json. Install dependencies if initialization used --skip-install.
44
20
 
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)'}.` : ''}
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.
46
25
 
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.
26
+ ## Private files
48
27
 
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.
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.
50
29
 
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. ' : ''}
30
+ ## Cloud resources and delivery
52
31
 
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.
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.
54
33
 
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.
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.
68
35
 
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)}
36
+ Stripe and RevenueCat remain inactive until client-owned provider products, credentials, origins and webhooks are configured. Verify sandbox flows before live activation.
103
37
  `);
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');
104
40
  }