anhedral 0.12.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 (184) hide show
  1. package/README.md +35 -172
  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 -39
  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 -80
  26. package/dist/command.js +9 -11
  27. package/dist/delivery-evidence.d.ts +1 -1
  28. package/dist/delivery-evidence.js +7 -36
  29. package/dist/delivery.d.ts +2 -8
  30. package/dist/delivery.js +23 -102
  31. package/dist/dependencies.d.ts +12 -58
  32. package/dist/dependencies.js +67 -189
  33. package/dist/index.d.ts +1 -3
  34. package/dist/index.js +1 -3
  35. package/dist/inspector-model.d.ts +2 -2
  36. package/dist/integration-service-readers.d.ts +1 -2
  37. package/dist/integration-service-readers.js +3 -84
  38. package/dist/lifecycle-model.d.ts +1 -1
  39. package/dist/lifecycle-model.js +1 -1
  40. package/dist/mobile-delivery.d.ts +1 -1
  41. package/dist/mobile-delivery.js +4 -0
  42. package/dist/platforms/mobile.d.ts +1 -1
  43. package/dist/platforms/mobile.js +64 -114
  44. package/dist/platforms/web.d.ts +3 -0
  45. package/dist/platforms/web.js +299 -0
  46. package/dist/project-config.d.ts +1 -1
  47. package/dist/project-config.js +0 -1
  48. package/dist/project-inspector.js +5 -36
  49. package/dist/project-state.d.ts +1 -3
  50. package/dist/project-state.js +6 -86
  51. package/dist/provider-auth.js +3 -32
  52. package/dist/provider-readiness.d.ts +1 -1
  53. package/dist/provider-readiness.js +5 -24
  54. package/dist/providers/adapters.js +9 -178
  55. package/dist/providers/api.d.ts +1 -1
  56. package/dist/providers/api.js +3 -3
  57. package/dist/providers/config.js +2 -48
  58. package/dist/providers/definitions.d.ts +1 -204
  59. package/dist/providers/definitions.js +0 -85
  60. package/dist/providers/provision.d.ts +1 -1
  61. package/dist/providers/receipts.js +1 -11
  62. package/dist/providers/recovery-verification.js +1 -61
  63. package/dist/providers/runtime.js +15 -35
  64. package/dist/providers/state.js +1 -7
  65. package/dist/provision.d.ts +5 -13
  66. package/dist/provision.js +4 -80
  67. package/dist/readiness.d.ts +1 -1
  68. package/dist/readiness.js +3 -6
  69. package/dist/registry/add.js +11 -38
  70. package/dist/registry/bootstrap.d.ts +3 -2
  71. package/dist/registry/bootstrap.js +4 -13
  72. package/dist/registry/commands.js +8 -10
  73. package/dist/registry/context.js +0 -1
  74. package/dist/registry/options.js +8 -26
  75. package/dist/registry/resolve.d.ts +3 -2
  76. package/dist/registry/resolve.js +26 -82
  77. package/dist/registry/types.d.ts +2 -7
  78. package/dist/registry/usage.js +2 -2
  79. package/dist/runtime-policy.d.ts +0 -2
  80. package/dist/runtime-policy.js +0 -13
  81. package/dist/scaffold/api.js +10 -2
  82. package/dist/scaffold/auth.d.ts +1 -2
  83. package/dist/scaffold/auth.js +57 -116
  84. package/dist/scaffold/backend.d.ts +2 -0
  85. package/dist/scaffold/backend.js +39 -0
  86. package/dist/scaffold/billing-config.d.ts +1 -0
  87. package/dist/scaffold/billing-config.js +73 -0
  88. package/dist/scaffold/billing-contracts.d.ts +2 -0
  89. package/dist/scaffold/billing-contracts.js +48 -0
  90. package/dist/scaffold/billing-providers.d.ts +1 -0
  91. package/dist/scaffold/billing-providers.js +249 -0
  92. package/dist/scaffold/billing-schema.d.ts +1 -0
  93. package/dist/scaffold/billing-schema.js +34 -0
  94. package/dist/scaffold/billing-security.d.ts +1 -0
  95. package/dist/scaffold/billing-security.js +46 -0
  96. package/dist/scaffold/billing-server.d.ts +1 -0
  97. package/dist/scaffold/billing-server.js +139 -0
  98. package/dist/scaffold/billing-store.d.ts +1 -0
  99. package/dist/scaffold/billing-store.js +72 -0
  100. package/dist/scaffold/billing.d.ts +2 -0
  101. package/dist/scaffold/billing.js +208 -0
  102. package/dist/scaffold/bootstrap.d.ts +2 -3
  103. package/dist/scaffold/bootstrap.js +37 -43
  104. package/dist/scaffold/compose.js +2 -12
  105. package/dist/scaffold/database.d.ts +1 -1
  106. package/dist/scaffold/database.js +20 -111
  107. package/dist/scaffold/documentation.d.ts +0 -1
  108. package/dist/scaffold/documentation.js +22 -82
  109. package/dist/scaffold/expo-auth.d.ts +3 -0
  110. package/dist/scaffold/expo-auth.js +203 -0
  111. package/dist/scaffold/expo-billing.d.ts +3 -0
  112. package/dist/scaffold/expo-billing.js +257 -0
  113. package/dist/scaffold/expo-runtime.d.ts +3 -0
  114. package/dist/scaffold/expo-runtime.js +43 -0
  115. package/dist/scaffold/integrations.d.ts +1 -2
  116. package/dist/scaffold/integrations.js +9 -5
  117. package/dist/scaffold/managed-email.d.ts +3 -0
  118. package/dist/scaffold/managed-email.js +47 -0
  119. package/dist/scaffold/native-ui.d.ts +2 -0
  120. package/dist/scaffold/native-ui.js +69 -0
  121. package/dist/scaffold/password-reset.d.ts +1 -0
  122. package/dist/scaffold/password-reset.js +99 -0
  123. package/dist/scaffold/private-files.d.ts +2 -0
  124. package/dist/scaffold/private-files.js +78 -0
  125. package/dist/scaffold/stack-documentation.d.ts +0 -1
  126. package/dist/scaffold/stack-documentation.js +3 -49
  127. package/dist/scaffold/styling.d.ts +1 -1
  128. package/dist/scaffold/styling.js +20 -28
  129. package/dist/scaffold/web-billing.d.ts +2 -0
  130. package/dist/scaffold/web-billing.js +48 -0
  131. package/dist/scaffold/workspace.js +53 -189
  132. package/dist/service-deletion.js +1 -1
  133. package/dist/service-descriptor.js +5 -12
  134. package/dist/service-model.d.ts +1 -1
  135. package/dist/service-operations.js +2 -32
  136. package/dist/service-readers.js +1 -32
  137. package/dist/services-command.d.ts +1 -1
  138. package/dist/services-command.js +3 -9
  139. package/dist/ship.d.ts +3 -316
  140. package/dist/ship.js +13 -143
  141. package/dist/stack-registry.d.ts +2 -43
  142. package/dist/stack-registry.js +80 -308
  143. package/dist/standard.js +7 -14
  144. package/dist/version.d.ts +1 -1
  145. package/dist/version.js +1 -1
  146. package/docs/anhedral-stack.md +23 -0
  147. package/docs/assets/anhedral-stack-light.png +0 -0
  148. package/docs/assets/anhedral-stack.png +0 -0
  149. package/docs/software-factory.md +25 -499
  150. package/docs/stack-standard.md +48 -226
  151. package/docs/verification.md +433 -0
  152. package/package.json +22 -21
  153. package/dist/neon-service-data.d.ts +0 -8
  154. package/dist/neon-service-data.js +0 -117
  155. package/dist/platforms/desktop.d.ts +0 -2
  156. package/dist/platforms/desktop.js +0 -415
  157. package/dist/platforms/extension.d.ts +0 -2
  158. package/dist/platforms/extension.js +0 -328
  159. package/dist/scaffold/lint.d.ts +0 -4
  160. package/dist/scaffold/lint.js +0 -56
  161. package/dist/scaffold/neon-realtime.d.ts +0 -2
  162. package/dist/scaffold/neon-realtime.js +0 -97
  163. package/dist/scaffold/services.d.ts +0 -5
  164. package/dist/scaffold/services.js +0 -108
  165. package/dist/scaffold/stream.d.ts +0 -2
  166. package/dist/scaffold/stream.js +0 -114
  167. package/dist/scaffold/void.d.ts +0 -4
  168. package/dist/scaffold/void.js +0 -256
  169. package/dist/scaffold/web.d.ts +0 -2
  170. package/dist/scaffold/web.js +0 -128
  171. package/dist/vercel-project.d.ts +0 -101
  172. package/dist/vercel-project.js +0 -305
  173. package/dist/vercel.d.ts +0 -67
  174. package/dist/vercel.js +0 -581
  175. package/dist/vinext.d.ts +0 -2
  176. package/dist/vinext.js +0 -86
  177. package/dist/void-execution.d.ts +0 -10
  178. package/dist/void-execution.js +0 -94
  179. package/dist/void-migrations.d.ts +0 -6
  180. package/dist/void-migrations.js +0 -110
  181. package/dist/void-state.d.ts +0 -16
  182. package/dist/void-state.js +0 -65
  183. package/dist/void.d.ts +0 -3
  184. package/dist/void.js +0 -5
@@ -1,7 +1,7 @@
1
1
  import { type DeliveryRunner } from './project-state.js';
2
2
  import { type CloudflareRequest } from './cloudflare.js';
3
3
  interface Resource {
4
- kind: 'd1' | 'r2' | 'kv' | 'queue' | 'stream';
4
+ kind: 'd1' | 'r2';
5
5
  name: string;
6
6
  id?: string;
7
7
  target: string;
@@ -11,7 +11,7 @@ export declare function planProvisioning(root: string): {
11
11
  projectId: string;
12
12
  accountId: string | null;
13
13
  resources: Resource[];
14
- externalIntegrations: string[];
14
+ externalIntegrations: never[];
15
15
  };
16
16
  export declare function provisionApplication(root: string, dryRun?: boolean, run?: DeliveryRunner, suppliedRequest?: CloudflareRequest): Promise<{
17
17
  schemaVersion: number;
@@ -26,21 +26,13 @@ export declare function provisionApplication(root: string, dryRun?: boolean, run
26
26
  createdByProject: boolean;
27
27
  }[];
28
28
  state: string;
29
- externalIntegrations: string[];
29
+ externalIntegrations: never[];
30
30
  } | {
31
31
  mutation: boolean;
32
32
  projectId: string;
33
33
  accountId: string | null;
34
34
  resources: Resource[];
35
- externalIntegrations: string[];
36
- } | {
37
- mutation: boolean;
38
- writer: "void";
39
- deferredToDeployment: boolean;
40
- projectId: string;
41
- accountId: string | null;
42
- resources: Resource[];
43
- externalIntegrations: string[];
35
+ externalIntegrations: never[];
44
36
  }>;
45
37
  /** Reconcile committed identities against the customer account without creating resources or rewriting configuration. */
46
38
  export declare function inspectApplicationResources(root: string, request: CloudflareRequest): Promise<{
@@ -50,6 +42,6 @@ export declare function inspectApplicationResources(root: string, request: Cloud
50
42
  id: string;
51
43
  target: string;
52
44
  }[];
53
- externalIntegrations: string[];
45
+ externalIntegrations: never[];
54
46
  }>;
55
47
  export {};
package/dist/provision.js CHANGED
@@ -8,30 +8,9 @@ import { cloudflareRequest, listCloudflare } from './cloudflare.js';
8
8
  const resourceTypes = {
9
9
  d1: { endpoint: '/d1/database', nameField: 'name', idField: 'uuid' },
10
10
  r2: { endpoint: '/r2/buckets', nameField: 'name', idField: 'name' },
11
- kv: { endpoint: '/storage/kv/namespaces', nameField: 'title', idField: 'id' },
12
- queue: { endpoint: '/queues', nameField: 'queue_name', idField: 'queue_id' },
13
- stream: { endpoint: '/pipelines/v1/streams', nameField: 'name', idField: 'id' },
14
11
  };
15
12
  async function listResources(request, kind) {
16
13
  const { endpoint } = resourceTypes[kind];
17
- if (kind === 'stream') {
18
- const streams = [];
19
- let bytes = 0;
20
- for (let page = 0; page < 1000; page++) {
21
- const response = await request('GET', `${endpoint}?page=${page}&per_page=100`);
22
- if (!Array.isArray(response.result))
23
- throw new Error('Unsupported stream listing.');
24
- if (response.result.some((item) => !item || typeof item !== 'object' || Array.isArray(item)))
25
- throw new Error('Unsupported stream resource.');
26
- streams.push(...response.result);
27
- bytes += Buffer.byteLength(JSON.stringify(response.result));
28
- if (streams.length > 10_000 || bytes > 10 * 1024 * 1024)
29
- throw new Error('Stream listing exceeded collection limit; select resource IDs explicitly.');
30
- if (response.result.length < 100)
31
- return streams;
32
- }
33
- throw new Error('Stream listing exceeded pagination limit.');
34
- }
35
14
  if (kind !== 'r2')
36
15
  return listCloudflare(request, endpoint);
37
16
  const value = (await request('GET', endpoint)).result;
@@ -39,15 +18,6 @@ async function listResources(request, kind) {
39
18
  throw new Error('Unsupported or truncated R2 bucket listing; select resources explicitly with provider tooling.');
40
19
  return value.buckets;
41
20
  }
42
- async function assertPrivateStream(request, id) {
43
- if (!/^[a-f0-9]{32}$/i.test(id))
44
- throw new Error('Invalid Basin stream ID.');
45
- const stream = (await request('GET', `${resourceTypes.stream.endpoint}/${id}`)).result;
46
- if (stream?.http?.enabled !== false ||
47
- stream.worker_binding?.enabled !== true ||
48
- stream.format?.type !== 'json')
49
- throw new Error('Basin stream must use a private Worker binding with JSON events and HTTP ingestion disabled.');
50
- }
51
21
  /** Provisioning and recovery use the same independently verified private-storage policy. */
52
22
  async function assertPrivateBucket(request, name) {
53
23
  const endpoint = `${resourceTypes.r2.endpoint}/${encodeURIComponent(name)}/domains`;
@@ -74,7 +44,6 @@ export function planProvisioning(root) {
74
44
  for (const [kind, field] of [
75
45
  ['d1', 'd1_databases'],
76
46
  ['r2', 'r2_buckets'],
77
- ['kv', 'kv_namespaces'],
78
47
  ]) {
79
48
  const entries = config[field];
80
49
  if (entries === undefined)
@@ -84,12 +53,8 @@ export function planProvisioning(root) {
84
53
  entries.forEach((entry, index) => {
85
54
  if (!entry || typeof entry.binding !== 'string' || entry.jurisdiction)
86
55
  throw new Error('Use an explicit provider workflow for jurisdiction-specific resources.');
87
- const name = resourceName(kind === 'd1'
88
- ? entry.database_name
89
- : kind === 'r2'
90
- ? entry.bucket_name
91
- : (entry.anhedral_name ?? `${project.name}-${entry.binding.toLowerCase()}`));
92
- const id = kind === 'd1' ? entry.database_id : kind === 'kv' ? entry.id : undefined;
56
+ const name = resourceName(kind === 'd1' ? entry.database_name : entry.bucket_name);
57
+ const id = kind === 'd1' ? entry.database_id : undefined;
93
58
  resources.push({
94
59
  kind,
95
60
  name,
@@ -99,40 +64,12 @@ export function planProvisioning(root) {
99
64
  });
100
65
  });
101
66
  }
102
- const queues = config.queues;
103
- for (const entry of [...(queues?.producers ?? []), ...(queues?.consumers ?? [])]) {
104
- resources.push({ kind: 'queue', name: resourceName(entry.queue), target: target.id });
105
- if ('dead_letter_queue' in entry && entry.dead_letter_queue)
106
- resources.push({
107
- kind: 'queue',
108
- name: resourceName(entry.dead_letter_queue),
109
- target: target.id,
110
- });
111
- }
112
- if (config.pipelines !== undefined) {
113
- if (!Array.isArray(config.pipelines))
114
- throw new Error('Invalid Basin stream bindings.');
115
- config.pipelines.forEach((entry, index) => {
116
- if (!entry ||
117
- typeof entry.binding !== 'string' ||
118
- typeof entry.stream !== 'string' ||
119
- entry.pipeline)
120
- throw new Error('Use explicit Basin stream bindings.');
121
- resources.push({
122
- kind: 'stream',
123
- name: resourceName(`${project.name}-${entry.binding.toLowerCase()}`),
124
- target: target.id,
125
- id: entry.stream.startsWith('REPLACE_WITH_') ? undefined : entry.stream,
126
- field: ['pipelines', index, 'stream'],
127
- });
128
- });
129
- }
130
67
  }
131
68
  return {
132
69
  projectId: project.id,
133
70
  accountId: project.accountId,
134
71
  resources,
135
- externalIntegrations: ['hyperdrive'].filter((key) => project.targets.some((target) => key in readConfig(targetDirectory(root, target)))),
72
+ externalIntegrations: [],
136
73
  };
137
74
  }
138
75
  export async function provisionApplication(root, dryRun = false, run = defaultRunner, suppliedRequest) {
@@ -141,8 +78,6 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
141
78
  assertNoDeletedServices(root, plan.resources);
142
79
  if (dryRun)
143
80
  return { ...plan, mutation: false };
144
- if (readApplication(root).deliveryEngine === 'void')
145
- return { ...plan, mutation: false, writer: 'void', deferredToDeployment: true };
146
81
  return withApplicationLock(root, async () => {
147
82
  const project = readApplication(root);
148
83
  const plan = planProvisioning(root);
@@ -171,7 +106,7 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
171
106
  previous.resources.some((entry) => !entry ||
172
107
  typeof entry !== 'object' ||
173
108
  Array.isArray(entry) ||
174
- !['d1', 'r2', 'kv', 'queue', 'stream'].includes(String(entry.kind)) ||
109
+ !['d1', 'r2'].includes(String(entry.kind)) ||
175
110
  ['name', 'id'].some((field) => typeof entry[field] !== 'string') ||
176
111
  typeof entry.reused !== 'boolean'))
177
112
  throw new Error('Previous resource ownership cannot be verified.');
@@ -197,13 +132,6 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
197
132
  if (!value)
198
133
  value = (await request('POST', endpoint, {
199
134
  [nameField]: resource.name,
200
- ...(resource.kind === 'stream'
201
- ? {
202
- http: { enabled: false, authentication: true },
203
- worker_binding: { enabled: true },
204
- format: { type: 'json', unstructured: true },
205
- }
206
- : {}),
207
135
  })).result;
208
136
  if (!value || typeof value[idField] !== 'string' || !value[idField])
209
137
  throw new Error('Provider did not return a resource identity; inspect provider state before retrying.');
@@ -231,8 +159,6 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
231
159
  });
232
160
  if (resource.kind === 'r2')
233
161
  await assertPrivateBucket(request, resource.name);
234
- if (resource.kind === 'stream')
235
- await assertPrivateStream(request, receipt.id);
236
162
  }
237
163
  assertConfiguration();
238
164
  if (resource.id && receipt.id !== resource.id)
@@ -276,8 +202,6 @@ export async function inspectApplicationResources(root, request) {
276
202
  throw new Error('Committed resource identity differs from the registered account; recovery will not replace it.');
277
203
  if (resource.kind === 'r2')
278
204
  await assertPrivateBucket(request, resource.name);
279
- if (resource.kind === 'stream')
280
- await assertPrivateStream(request, id);
281
205
  receipts.push({ kind: resource.kind, name: resource.name, id, target: resource.target });
282
206
  }
283
207
  return { resources: receipts, externalIntegrations: plan.externalIntegrations };
@@ -17,7 +17,7 @@ export declare function validateSetupPlan(plan: unknown): asserts plan is {
17
17
  cliVersion: string;
18
18
  registryVersion: 1;
19
19
  products: StandardProduct[];
20
- hosting: 'cloudflare' | 'vercel';
20
+ hosting: 'cloudflare';
21
21
  name?: string;
22
22
  registry: ResolvedStackRegistry;
23
23
  };
package/dist/readiness.js CHANGED
@@ -45,10 +45,7 @@ export function inspectProject(root) {
45
45
  }
46
46
  record('selection', standard.schemaVersion === 1 &&
47
47
  JSON.stringify(standard.products) === JSON.stringify(plan.products) &&
48
- standard.hosting ===
49
- (plan.products.includes('next') || plan.products.includes('vinext')
50
- ? plan.hosting
51
- : null), 'Setup plan matches project selection');
48
+ standard.hosting === plan.hosting, 'Setup plan matches project selection');
52
49
  }
53
50
  catch {
54
51
  record('setup-plan', false, 'Missing, invalid or unsupported setup plan; inspect the project before changing it');
@@ -76,11 +73,11 @@ export function validateSetupPlan(plan) {
76
73
  !value.products.length ||
77
74
  !value.products.every((id) => STANDARD_PRODUCTS.includes(id)))
78
75
  throw new Error('Unknown setup capabilities.');
79
- if (value.hosting !== 'cloudflare' && value.hosting !== 'vercel')
76
+ if (value.hosting !== 'cloudflare')
80
77
  throw new Error('Invalid hosting.');
81
78
  validateRequirements(value.setup, value.products);
82
79
  const selected = new Set(value.products);
83
- resolveStandardProducts(selected, value.hosting, false);
80
+ resolveStandardProducts(selected, value.hosting);
84
81
  if (selected.size !== value.products.length)
85
82
  throw new Error('Invalid or incomplete setup selection.');
86
83
  if (value.name !== undefined && typeof value.name !== 'string')
@@ -1,23 +1,20 @@
1
- import { PROJECT_CONFIG_FILE, readProjectSection, writeProjectSection, hasProjectSection, } from '../project-config.js';
1
+ import { PROJECT_CONFIG_FILE, readProjectSection, writeProjectSection } from '../project-config.js';
2
2
  import { configureDependencyPatches } from '../dependency-patches.js';
3
3
  import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
4
- import { bootstrapWorkspace, assertWorkspaceRuntime } from '../scaffold/bootstrap.js';
4
+ import { assertWorkspaceRuntime } from '../scaffold/bootstrap.js';
5
5
  import { registerApplication } from '../project-state.js';
6
- import { registerVercelApplication } from '../vercel.js';
7
6
  import { existsSync, lstatSync, readFileSync, realpathSync, rmSync } from 'node:fs';
8
7
  import path from 'node:path';
9
8
  import { isDeepStrictEqual } from 'node:util';
10
9
  import { applyEdits, modify, parse } from 'jsonc-parser';
11
- import { STANDARD_PRODUCTS, installStackItem } from '../stack-registry.js';
10
+ import { installStackItem } from '../stack-registry.js';
12
11
  import { inspectProject, validateSetupPlan } from '../readiness.js';
13
12
  import { GENERATOR_VERSION } from '../version.js';
14
13
  import { runStagedTransaction } from '../transaction.js';
15
14
  import { inspectWorkspaceGraph } from '../workspace-graph.js';
16
15
  import { execFile } from '../util.js';
17
- import { supportsVoidRuntime, usesVoidSelection } from '../runtime-policy.js';
18
16
  import { put } from '../scaffold/files.js';
19
17
  import { writeStandardRoot } from '../scaffold/workspace.js';
20
- import { configureVoidDelivery, refreshVoidEnvironment } from '../scaffold/void.js';
21
18
  import { createRecipeContext } from './context.js';
22
19
  import { resolveStackRegistry, resolveStandardProducts } from './resolve.js';
23
20
  import { sourceFiles, configurationFingerprints } from './receipt.js';
@@ -41,6 +38,9 @@ export async function addStackItems(root, request, run = execFile) {
41
38
  if (!request.items.length)
42
39
  throw new Error('Select at least one registry item.');
43
40
  const plan = readProjectSection(root, 'setup');
41
+ if (Array.isArray(plan?.registry?.items) &&
42
+ plan.registry.items.some((item) => item.name === 'stripe' && item.package))
43
+ throw new Error('This project uses the legacy billing SDK recipe. Use its pinned CLI or perform a reviewed billing migration before adding capabilities.');
44
44
  validateSetupPlan(plan);
45
45
  if (plan.cliVersion !== GENERATOR_VERSION)
46
46
  throw new Error('Use the project CLI version before adding recipes.');
@@ -57,21 +57,11 @@ export async function addStackItems(root, request, run = execFile) {
57
57
  const originalConfiguration = configurationFingerprints(root);
58
58
  const selected = new Set(plan.products);
59
59
  for (const id of request.items) {
60
- if (!STANDARD_PRODUCTS.includes(id))
60
+ if (!['stripe', 'revenuecat'].includes(id))
61
61
  throw new Error(`Unknown stack product: ${id}.`);
62
62
  selected.add(id);
63
63
  }
64
- if ((selected.has('queues') || selected.has('basin')) &&
65
- hasProjectSection(root, 'cloudflare') &&
66
- readProjectSection(root, 'cloudflare').deliveryEngine === 'void')
67
- throw new Error('Queues with dead-letter recovery and Basin require Wrangler delivery. They cannot be added to a Void project.');
68
- resolveStandardProducts(selected, plan.hosting, false);
69
- const voidSelected = usesVoidSelection([...selected], plan.hosting);
70
- if (!request.dryRun &&
71
- voidSelected &&
72
- run === execFile &&
73
- !supportsVoidRuntime(process.versions.node))
74
- throw new Error('Cloudflare workspaces using Void require Node.js 24.21.0 or newer.');
64
+ resolveStandardProducts(selected, plan.hosting);
75
65
  const options = {
76
66
  root,
77
67
  name: plan.name ?? path.basename(root),
@@ -102,39 +92,28 @@ export async function addStackItems(root, request, run = execFile) {
102
92
  items: registry.items
103
93
  .filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item))
104
94
  .map((item) => item.name),
105
- bootstrapRequired: recipes.some((item) => ['vinext', 'next'].includes(item.name)) &&
106
- !existsSync(path.join(root, 'apps/web/package.json')),
95
+ bootstrapRequired: false,
107
96
  filesChecked: true,
108
97
  targets: recipes.flatMap((item) => item.targets),
109
98
  files: commitPaths,
110
99
  conflicts,
111
100
  ...(request.preview ? { previews: [] } : {}),
112
101
  };
113
- // The upstream web generator requires network access and executes package scripts.
114
- // A preview reports the resolved selection without invoking that generator.
115
- if (request.dryRun && result.bootstrapRequired) {
116
- result.filesChecked = false;
117
- if (request.preview)
118
- throw new Error('Source preview requires a new web bootstrap and cannot run offline. Use add --dry-run for the selection plan.');
119
- return result;
120
- }
121
102
  await runStagedTransaction(root, {
122
103
  dryRun: !!request.dryRun,
123
104
  commitPaths,
124
105
  seedPaths: [...before.keys(), PROJECT_CONFIG_FILE],
125
106
  build: async (stage) => {
126
107
  const context = createRecipeContext(stage, options);
108
+ context.updating = true;
127
109
  for (const item of registry.items)
128
110
  Object.assign(context.bindings, item.bindings);
129
- if (recipes.some((item) => ['vinext', 'next'].includes(item.name)) &&
130
- !existsSync(path.join(stage, 'apps/web/package.json')))
131
- bootstrapWorkspace(stage, options.name, run, true);
132
111
  for (const item of recipes)
133
112
  await installStackItem(item, context);
134
113
  // Configuration items affect the existing runtime without regenerating its application source.
135
114
  const configurationItems = registry.items.filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item) && item.bindings);
136
115
  if (configurationItems.length) {
137
- const directory = `apps/${context.runtimeApp}`;
116
+ const directory = 'apps/api';
138
117
  const file = `${directory}/${existsSync(path.join(stage, directory, 'anhedral.cloudflare.json')) ? 'anhedral.cloudflare.json' : 'wrangler.jsonc'}`;
139
118
  let content = readFileSync(path.join(stage, file), 'utf8');
140
119
  const config = parse(content);
@@ -149,12 +128,6 @@ export async function addStackItems(root, request, run = execFile) {
149
128
  put(stage, file, content);
150
129
  }
151
130
  writeStandardRoot(stage, options, registry, true);
152
- if (voidSelected) {
153
- configureVoidDelivery(stage);
154
- refreshVoidEnvironment(stage);
155
- }
156
- if (options.products.includes('next') && options.hosting === 'vercel')
157
- registerVercelApplication(stage);
158
131
  if ([...sourceFiles(stage).keys()].some((file) => /^apps\/[^/]+\/(?:wrangler\.jsonc|anhedral\.cloudflare\.json)$/.test(file)))
159
132
  registerApplication(stage, true);
160
133
  if (!request.dryRun)
@@ -1,2 +1,3 @@
1
- export declare const BOOTSTRAP_COMMAND: readonly ["pnpm", "dlx", "shadcn@4.21.4", "init", "--monorepo", "--template", "next"];
2
- export declare function bootstrapArguments(name: string, cwd: string): string[];
1
+ /** The foundation is generated locally from this exact CLI version. */
2
+ export declare const BOOTSTRAP_COMMAND: readonly ["anhedral", "init"];
3
+ export declare function bootstrapArguments(name: string, _cwd: string): string[];
@@ -1,14 +1,5 @@
1
- import { SHADCN_VERSION } from '../dependencies.js';
2
- const SHADCN_PACKAGE = `shadcn@${SHADCN_VERSION}`;
3
- export const BOOTSTRAP_COMMAND = [
4
- 'pnpm',
5
- 'dlx',
6
- SHADCN_PACKAGE,
7
- 'init',
8
- '--monorepo',
9
- '--template',
10
- 'next',
11
- ];
12
- export function bootstrapArguments(name, cwd) {
13
- return [...BOOTSTRAP_COMMAND.slice(1), '--defaults', '--name', name, '--cwd', cwd];
1
+ /** The foundation is generated locally from this exact CLI version. */
2
+ export const BOOTSTRAP_COMMAND = ['anhedral', 'init'];
3
+ export function bootstrapArguments(name, _cwd) {
4
+ return ['init', name];
14
5
  }
@@ -3,16 +3,14 @@ import { addStackItems } from './add.js';
3
3
  import { STACK_REGISTRY, STANDARD_PRODUCTS, getStackItem } from '../stack-registry.js';
4
4
  import { printResult } from '../cli-output.js';
5
5
  import { commandHelp } from './usage.js';
6
- import { CliArgumentError, suggest } from '../cli-arguments.js';
6
+ import { CliArgumentError, suggest, commandArguments } from '../cli-arguments.js';
7
7
  export async function runRegistry(args, json, output = { json }) {
8
- const positional = args.filter((arg) => arg !== '--json');
9
- if (positional.includes('--help') || positional.includes('-h')) {
8
+ const parsed = commandArguments('registry', args);
9
+ if (parsed.has('--help')) {
10
10
  console.log(commandHelp('registry'));
11
11
  return;
12
12
  }
13
- if (positional.some((arg) => arg.startsWith('-')))
14
- throw new Error('Unknown registry option.');
15
- const [action = 'list', name, ...extra] = positional;
13
+ const [action = 'list', name, ...extra] = parsed.positional;
16
14
  if (action === 'capabilities' && !name && !extra.length) {
17
15
  if (output.quiet && !json)
18
16
  return;
@@ -69,12 +67,12 @@ export async function runAdd(args, output = {}) {
69
67
  }
70
68
  const items = positional;
71
69
  if (!items.length)
72
- throw new Error('Select bundled parts: anhedral add <items...> [--cwd <directory>].');
70
+ throw new Error('Select payments: anhedral add stripe revenuecat [--cwd <directory>].');
73
71
  for (const item of items) {
74
- if (STANDARD_PRODUCTS.includes(item))
72
+ if (['stripe', 'revenuecat'].includes(item))
75
73
  continue;
76
- const correction = suggest(item, STANDARD_PRODUCTS);
77
- throw new CliArgumentError(`Unknown stack part.${correction ? ` Did you mean ${correction}?` : ''}`, 'Select a project with --cwd <directory> and run anhedral registry list for bundled parts.');
74
+ const correction = suggest(item, ['stripe', 'revenuecat']);
75
+ throw new CliArgumentError(`Unknown stack part.${correction ? ` Did you mean ${correction}?` : ''}`, 'Select a project with --cwd <directory>; optional additions are stripe and revenuecat.');
78
76
  }
79
77
  printResult('add', await addStackItems(process.cwd(), {
80
78
  items,
@@ -4,7 +4,6 @@ export function createRecipeContext(root, options) {
4
4
  root,
5
5
  options,
6
6
  has: (product) => selected.has(product),
7
- runtimeApp: selected.has('hono') ? 'api' : 'web',
8
7
  bindings: {},
9
8
  };
10
9
  }
@@ -1,48 +1,30 @@
1
1
  import { resolveStandardProducts } from './resolve.js';
2
2
  import path from 'node:path';
3
3
  import { packageNameFromText } from '../render.js';
4
- import { STANDARD_PRODUCTS } from '../stack-registry.js';
5
4
  function readGitFlag(token, previous) {
6
5
  const value = token === '--git';
7
6
  if (previous !== undefined && value !== previous)
8
7
  throw new Error('Conflicting Git options.');
9
8
  return value;
10
9
  }
11
- function readHostingFlag(value, previous, specified) {
12
- if (value !== 'cloudflare' && value !== 'vercel')
13
- throw new Error('hosting must be cloudflare or vercel.');
14
- if (specified && previous !== value)
15
- throw new Error('Conflicting hosting options.');
16
- return value;
17
- }
18
10
  function parseStandardFlags(remaining) {
19
11
  const products = new Set();
20
- let hosting = 'cloudflare';
21
- let hostingSpecified = false;
12
+ const hosting = 'cloudflare';
22
13
  let gitSpecified;
23
- for (let index = 0; index < remaining.length; index++) {
24
- const token = remaining[index];
14
+ for (const token of remaining) {
25
15
  if (['--skip-install', '--dry-run', '--json', '--verbose'].includes(token))
26
16
  continue;
27
17
  if (token === '--git' || token === '--no-git') {
28
18
  gitSpecified = readGitFlag(token, gitSpecified);
29
19
  continue;
30
20
  }
31
- if (token === '--hosting' || token.startsWith('--hosting=')) {
32
- const value = token === '--hosting' ? remaining[++index] : token.slice('--hosting='.length);
33
- hosting = readHostingFlag(value, hosting, hostingSpecified);
34
- hostingSpecified = true;
21
+ if (token === '--stripe' || token === '--revenuecat') {
22
+ products.add(token.slice(2));
35
23
  continue;
36
24
  }
37
- const value = token.replace(/^--/, '');
38
- if (!STANDARD_PRODUCTS.includes(value)) {
39
- throw new Error(`Unknown standard product: ${token}. Select only required products.`);
40
- }
41
- products.add(value);
25
+ throw new Error(`Unknown init option: ${token}. The core stack is always included; optional additions are --stripe and --revenuecat.`);
42
26
  }
43
- if (!hostingSpecified && products.has('next'))
44
- hosting = 'vercel';
45
- return { products, hosting, hostingSpecified, gitSpecified };
27
+ return { products, hosting, gitSpecified };
46
28
  }
47
29
  export function parseStandardOptions(args) {
48
30
  const remaining = [...args];
@@ -51,8 +33,8 @@ export function parseStandardOptions(args) {
51
33
  if (!directory || directory.startsWith('-'))
52
34
  throw new Error('Specify a valid initialization directory.');
53
35
  const root = path.resolve(directory);
54
- const { products, hosting, hostingSpecified, gitSpecified } = parseStandardFlags(remaining);
55
- resolveStandardProducts(products, hosting, hostingSpecified);
36
+ const { products, hosting, gitSpecified } = parseStandardFlags(remaining);
37
+ resolveStandardProducts(products, hosting);
56
38
  return {
57
39
  root,
58
40
  name: packageNameFromText(path.basename(root)),
@@ -1,6 +1,7 @@
1
1
  import type { Hosting, StandardOptions, StandardProduct, StackRegistryItem } from './types.js';
2
- /** Apply default selections once. All callers then use the same strict graph resolver. */
3
- export declare function resolveStandardProducts(selected: Set<StandardProduct>, hosting: Hosting, hostingSpecified: boolean): void;
2
+ export declare const CORE_PRODUCTS: readonly StandardProduct[];
3
+ /** Every initialization uses one foundation; only payment additions are optional. */
4
+ export declare function resolveStandardProducts(selected: Set<StandardProduct>, hosting: Hosting): void;
4
5
  export interface ResolvedStackRegistry {
5
6
  schemaVersion: number;
6
7
  name: string;
@@ -1,102 +1,46 @@
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
- function hasServer(context) {
5
- return context.has('hono') || context.has('vinext') || context.has('next');
6
- }
7
- function needsWorker(name, context) {
8
- const definition = getStackDefinition(name);
9
- return (definition.runtime === 'worker' ||
10
- (definition.runtime === 'optional-worker' && hasServer(context)));
11
- }
12
- function validateProducts(selected, hosting) {
13
- if (!['cloudflare', 'vercel'].includes(hosting))
14
- throw new Error('hosting must be cloudflare or vercel.');
15
- for (const id of selected) {
16
- if (!STANDARD_PRODUCTS.includes(id))
17
- throw new Error(`Unknown stack product: ${id}.`);
18
- const { conflicts = [], requiresAny = [], requiresAll = [] } = getStackDefinition(id).selection;
19
- const conflict = conflicts.find((other) => selected.has(other));
20
- if (conflict)
21
- throw new Error(`Choose one of ${id} / ${conflict}.`);
22
- if (requiresAny.length && !requiresAny.some((other) => selected.has(other)))
23
- throw new Error(`${id} requires an explicitly selected ${requiresAny.join(' or ')} capability.`);
24
- const missing = requiresAll.filter((other) => !selected.has(other));
25
- if (missing.length)
26
- throw new Error(`${id} requires ${missing.join(', ')}; select it explicitly.`);
27
- }
28
- if (selected.has('vinext') && hosting !== 'cloudflare')
29
- throw new Error('Vinext requires Cloudflare hosting; select --next for Vercel.');
30
- }
31
- /** Apply default selections once. All callers then use the same strict graph resolver. */
32
- export function resolveStandardProducts(selected, hosting, hostingSpecified) {
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. */
14
+ export function resolveStandardProducts(selected, hosting) {
15
+ if (hosting !== 'cloudflare')
16
+ throw new Error('Anhedral applications use Cloudflare Workers.');
33
17
  for (const id of selected)
34
18
  getStackDefinition(id);
35
- if (![...selected].some((id) => getStackDefinition(id).type === 'application'))
36
- selected.add(hosting === 'vercel' ? 'next' : 'vinext');
37
- // Resolve single-provider defaults before alternatives (e.g. Realtime's Neon
38
- // before Better Auth chooses a database), independently of CLI flag order.
39
- const defaults = [...selected].sort((left, right) => (getStackDefinition(left).selection.requiresAny?.length ?? 0) -
40
- (getStackDefinition(right).selection.requiresAny?.length ?? 0) || left.localeCompare(right));
41
- for (const id of defaults) {
42
- const definition = getStackDefinition(id);
43
- const alternatives = definition.selection.requiresAny ?? [];
44
- if (definition.fallbackDependency &&
45
- !alternatives.some((other) => selected.has(other)))
46
- selected.add(definition.fallbackDependency);
47
- }
48
- const context = createResolutionContext({ products: [...selected], hosting });
49
- if (context.has('next') &&
50
- hosting === 'vercel' &&
51
- [...selected].some((id) => needsWorker(id, context)))
52
- selected.add('hono');
53
- if (hostingSpecified && !selected.has('next') && !selected.has('vinext'))
54
- throw new Error('--hosting applies to the web application.');
19
+ for (const product of CORE_PRODUCTS)
20
+ selected.add(product);
55
21
  resolveStackRegistry({ products: [...selected], hosting });
56
22
  }
57
- function itemDependencies(name, context) {
58
- const definition = getStackDefinition(name);
59
- const dependencies = new Set(definition.registryDependencies);
60
- if (definition.runtime) {
61
- if (!hasServer(context) && definition.runtime !== 'optional-worker')
62
- throw new Error(`${name} requires a server runtime.`);
63
- if (needsWorker(name, context) &&
64
- !context.has('hono') &&
65
- !(context.options.hosting === 'cloudflare' && (context.has('vinext') || context.has('next'))))
66
- throw new Error(`${name} requires a Cloudflare runtime.`);
67
- if (hasServer(context))
68
- dependencies.add(context.has('hono') ? 'hono' : context.has('vinext') ? 'vinext' : 'next');
69
- }
70
- for (const dependency of definition.resolveDependencies?.(context) ?? [])
71
- dependencies.add(dependency);
72
- return dependencies;
73
- }
74
23
  export function resolveStackRegistry(options) {
75
- const selected = new Set(options.products);
76
- validateProducts(selected, options.hosting);
77
- if (![...selected].some((id) => getStackDefinition(id).type === 'application'))
78
- throw new Error('Stack registry requires an application.');
79
- const context = createResolutionContext(options);
24
+ if (options.hosting !== 'cloudflare')
25
+ throw new Error('Anhedral applications use Cloudflare Workers.');
26
+ for (const id of options.products)
27
+ if (!STANDARD_PRODUCTS.includes(id))
28
+ throw new Error(`Unknown stack product: ${id}.`);
29
+ const products = [...new Set([...CORE_PRODUCTS, ...options.products])];
30
+ const context = createResolutionContext({ ...options, products });
80
31
  const resolved = new Map();
81
- const collect = (name) => {
32
+ function collect(name) {
82
33
  if (resolved.has(name))
83
34
  return;
84
35
  const definition = getStackDefinition(name);
85
36
  const metadata = getStackItem(name);
86
- const dependencies = itemDependencies(name, context);
87
- metadata.registryDependencies = [...dependencies];
88
- metadata.environment = definition.resolveEnvironment?.(context) ?? metadata.environment;
89
- metadata.targets = definition.resolveTargets?.(context) ?? metadata.targets;
90
37
  if (definition.configure)
91
38
  metadata.bindings = definition.configure(context);
92
- if (definition.package)
93
- metadata.package =
94
- definition.resolvePackage?.(context, definition.package) ?? definition.package;
95
39
  resolved.set(name, metadata);
96
- for (const dependency of dependencies)
40
+ for (const dependency of metadata.registryDependencies)
97
41
  collect(dependency);
98
- };
99
- for (const name of ['workspace', 'typescript', 'eslint', ...[...selected].sort()])
42
+ }
43
+ for (const name of ['workspace', 'typescript', 'eslint', ...products.sort()])
100
44
  collect(name);
101
45
  const graph = new Map([...resolved].map(([name, item]) => [name, item.registryDependencies]));
102
46
  return {