anhedral 0.15.0 → 0.17.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 (246) hide show
  1. package/README.md +82 -34
  2. package/assets/stack/ai-schema.ts.txt +5 -0
  3. package/assets/stack/ai.ts.txt +30 -0
  4. package/assets/stack/api-index.ts.txt +15 -0
  5. package/assets/stack/auth-features.ts.txt +4 -0
  6. package/assets/stack/auth-journal.json.txt +13 -0
  7. package/assets/stack/auth-migration.sql.txt +53 -0
  8. package/assets/stack/auth-routes.ts.txt +11 -0
  9. package/assets/stack/auth-schema.ts.txt +64 -0
  10. package/assets/stack/auth-snapshot.json.txt +346 -0
  11. package/assets/stack/auth.ts.txt +32 -0
  12. package/assets/stack/billing-mode.ts.txt +8 -0
  13. package/assets/stack/billing-schema.ts.txt +11 -0
  14. package/assets/stack/desktop.rs.txt +21 -0
  15. package/assets/stack/entitlement-guard.ts.txt +32 -0
  16. package/assets/stack/entitlements.ts.txt +8 -0
  17. package/assets/stack/events-schema.ts.txt +12 -0
  18. package/assets/stack/events.ts.txt +59 -0
  19. package/assets/stack/mobile-auth.ts.txt +25 -0
  20. package/assets/stack/mobile-billing.tsx.txt +63 -0
  21. package/assets/stack/mobile-session.tsx.txt +83 -0
  22. package/assets/stack/native-button.tsx.txt +108 -0
  23. package/assets/stack/native-global.css.txt +4 -0
  24. package/assets/stack/native-lib-utils.ts.txt +5 -0
  25. package/assets/stack/native-metro.config.js.txt +6 -0
  26. package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
  27. package/assets/stack/native-tailwind.config.js.txt +73 -0
  28. package/assets/stack/native-text.tsx.txt +89 -0
  29. package/assets/stack/purchases.ts.txt +65 -0
  30. package/assets/stack/revenuecat.ts.txt +88 -0
  31. package/assets/stack/rtc-schema.ts.txt +10 -0
  32. package/assets/stack/rtc.ts.txt +122 -0
  33. package/assets/stack/security.ts.txt +31 -0
  34. package/assets/stack/storage.ts.txt +36 -0
  35. package/assets/stack/stripe.ts.txt +126 -0
  36. package/assets/stack/web-sign-in.tsx.txt +51 -0
  37. package/assets/ui/LICENSE.react-native-reusables +21 -0
  38. package/assets/ui/UPSTREAM.json +0 -11
  39. package/assets/ui/catalog.json +891 -0
  40. package/assets/ui/extensions/registry.json +6 -0
  41. package/dist/bin.js +7 -12
  42. package/dist/capabilities.d.ts +4 -33
  43. package/dist/capabilities.js +2 -66
  44. package/dist/capability-catalog.d.ts +83 -0
  45. package/dist/capability-catalog.js +121 -0
  46. package/dist/capability-command.d.ts +3 -0
  47. package/dist/capability-command.js +188 -0
  48. package/dist/capability-editor.d.ts +17 -0
  49. package/dist/capability-editor.js +97 -0
  50. package/dist/capability-recipes.d.ts +4 -0
  51. package/dist/capability-recipes.js +520 -0
  52. package/dist/capability-references.d.ts +4 -0
  53. package/dist/capability-references.js +7 -0
  54. package/dist/cli-commands.d.ts +1 -2
  55. package/dist/cli-commands.js +10 -104
  56. package/dist/cli-output.d.ts +1 -2
  57. package/dist/cli-output.js +6 -251
  58. package/dist/command-schema.js +39 -322
  59. package/dist/dependencies.d.ts +29 -9
  60. package/dist/dependencies.js +57 -64
  61. package/dist/index.d.ts +1 -42
  62. package/dist/index.js +1 -27
  63. package/dist/platforms/web.d.ts +1 -1
  64. package/dist/platforms/web.js +27 -75
  65. package/dist/project-config.d.ts +2 -13
  66. package/dist/project-config.js +10 -82
  67. package/dist/registry/options.js +1 -5
  68. package/dist/registry/resolve.d.ts +1 -1
  69. package/dist/registry/resolve.js +4 -10
  70. package/dist/registry/usage.js +3 -9
  71. package/dist/scaffold/backend.js +0 -3
  72. package/dist/scaffold/database.js +2 -1
  73. package/dist/scaffold/documentation.js +56 -25
  74. package/dist/scaffold/stack-documentation.js +1 -1
  75. package/dist/scaffold/storage.d.ts +2 -0
  76. package/dist/scaffold/storage.js +21 -0
  77. package/dist/scaffold/workspace.js +21 -22
  78. package/dist/stack-registry.d.ts +2 -10
  79. package/dist/stack-registry.js +12 -98
  80. package/dist/standard.js +1 -11
  81. package/dist/ui-catalog.d.ts +26 -0
  82. package/dist/ui-catalog.js +31 -0
  83. package/dist/ui-command.d.ts +3 -0
  84. package/dist/ui-command.js +219 -0
  85. package/dist/ui-project.d.ts +22 -0
  86. package/dist/ui-project.js +110 -0
  87. package/dist/version.d.ts +1 -1
  88. package/dist/version.js +1 -1
  89. package/docs/anhedral-stack.md +12 -23
  90. package/docs/assets/anhedral-stack-light.png +0 -0
  91. package/docs/assets/anhedral-stack.png +0 -0
  92. package/docs/capabilities.md +110 -0
  93. package/docs/native-ui.md +47 -0
  94. package/docs/software-factory.md +35 -50
  95. package/docs/stack-standard.md +19 -70
  96. package/docs/ui.md +33 -0
  97. package/docs/verification.md +6 -876
  98. package/package.json +21 -16
  99. package/assets/ui/native/button.tsx +0 -85
  100. package/assets/ui/native/card.tsx +0 -33
  101. package/assets/ui/native/dialog.tsx +0 -75
  102. package/assets/ui/native/input.tsx +0 -27
  103. package/assets/ui/native/label.tsx +0 -4
  104. package/assets/ui/native/layout.tsx +0 -26
  105. package/assets/ui/native/text.tsx +0 -20
  106. package/assets/ui/native/theme-switcher.tsx +0 -22
  107. package/assets/ui/theme-storage.ts +0 -25
  108. package/assets/ui/theme.tsx +0 -66
  109. package/dist/access.d.ts +0 -10
  110. package/dist/access.js +0 -93
  111. package/dist/auth-schema-snapshot.d.ts +0 -346
  112. package/dist/auth-schema-snapshot.js +0 -347
  113. package/dist/auth-schema.d.ts +0 -1
  114. package/dist/auth-schema.js +0 -57
  115. package/dist/capability-contract.d.ts +0 -47
  116. package/dist/capability-contract.js +0 -129
  117. package/dist/catalog-model.d.ts +0 -24
  118. package/dist/catalog-model.js +0 -1
  119. package/dist/catalog-registration.d.ts +0 -16
  120. package/dist/catalog-registration.js +0 -22
  121. package/dist/catalog-snapshot.d.ts +0 -5
  122. package/dist/catalog-snapshot.js +0 -97
  123. package/dist/cli-delivery.d.ts +0 -3
  124. package/dist/cli-delivery.js +0 -112
  125. package/dist/cloudflare.d.ts +0 -25
  126. package/dist/cloudflare.js +0 -226
  127. package/dist/delivery-evidence.d.ts +0 -62
  128. package/dist/delivery-evidence.js +0 -157
  129. package/dist/delivery.d.ts +0 -82
  130. package/dist/delivery.js +0 -489
  131. package/dist/inspector-model.d.ts +0 -123
  132. package/dist/inspector-model.js +0 -1
  133. package/dist/integration-service-readers.d.ts +0 -12
  134. package/dist/integration-service-readers.js +0 -92
  135. package/dist/lifecycle-model.d.ts +0 -15
  136. package/dist/lifecycle-model.js +0 -20
  137. package/dist/lifecycle.d.ts +0 -11
  138. package/dist/lifecycle.js +0 -91
  139. package/dist/management.d.ts +0 -3
  140. package/dist/management.js +0 -47
  141. package/dist/mobile-delivery.d.ts +0 -77
  142. package/dist/mobile-delivery.js +0 -370
  143. package/dist/platforms/mobile.d.ts +0 -2
  144. package/dist/platforms/mobile.js +0 -156
  145. package/dist/project-catalog.d.ts +0 -41
  146. package/dist/project-catalog.js +0 -288
  147. package/dist/project-inspector.d.ts +0 -4
  148. package/dist/project-inspector.js +0 -671
  149. package/dist/project-lifecycle.d.ts +0 -25
  150. package/dist/project-lifecycle.js +0 -57
  151. package/dist/project-state.d.ts +0 -47
  152. package/dist/project-state.js +0 -480
  153. package/dist/provider-auth.d.ts +0 -41
  154. package/dist/provider-auth.js +0 -180
  155. package/dist/provider-readiness.d.ts +0 -30
  156. package/dist/provider-readiness.js +0 -85
  157. package/dist/providers/adapters.d.ts +0 -17
  158. package/dist/providers/adapters.js +0 -103
  159. package/dist/providers/api.d.ts +0 -29
  160. package/dist/providers/api.js +0 -253
  161. package/dist/providers/config.d.ts +0 -15
  162. package/dist/providers/config.js +0 -136
  163. package/dist/providers/definitions.d.ts +0 -115
  164. package/dist/providers/definitions.js +0 -42
  165. package/dist/providers/provision.d.ts +0 -24
  166. package/dist/providers/provision.js +0 -76
  167. package/dist/providers/receipts.d.ts +0 -20
  168. package/dist/providers/receipts.js +0 -56
  169. package/dist/providers/recovery-verification.d.ts +0 -7
  170. package/dist/providers/recovery-verification.js +0 -52
  171. package/dist/providers/recovery.d.ts +0 -30
  172. package/dist/providers/recovery.js +0 -34
  173. package/dist/providers/runtime.d.ts +0 -10
  174. package/dist/providers/runtime.js +0 -234
  175. package/dist/providers/schema.d.ts +0 -28
  176. package/dist/providers/schema.js +0 -49
  177. package/dist/providers/state.d.ts +0 -55
  178. package/dist/providers/state.js +0 -283
  179. package/dist/provision.d.ts +0 -47
  180. package/dist/provision.js +0 -208
  181. package/dist/r2-service-data.d.ts +0 -2
  182. package/dist/r2-service-data.js +0 -136
  183. package/dist/readiness.d.ts +0 -23
  184. package/dist/readiness.js +0 -117
  185. package/dist/registry/add.d.ts +0 -24
  186. package/dist/registry/add.js +0 -210
  187. package/dist/registry/bootstrap.d.ts +0 -3
  188. package/dist/registry/bootstrap.js +0 -5
  189. package/dist/registry/commands.d.ts +0 -3
  190. package/dist/registry/commands.js +0 -83
  191. package/dist/registry/preview.d.ts +0 -11
  192. package/dist/registry/preview.js +0 -91
  193. package/dist/registry/receipt.d.ts +0 -3
  194. package/dist/registry/receipt.js +0 -68
  195. package/dist/repository.d.ts +0 -24
  196. package/dist/repository.js +0 -96
  197. package/dist/scaffold/auth.d.ts +0 -2
  198. package/dist/scaffold/auth.js +0 -76
  199. package/dist/scaffold/billing-config.d.ts +0 -1
  200. package/dist/scaffold/billing-config.js +0 -73
  201. package/dist/scaffold/billing-contracts.d.ts +0 -2
  202. package/dist/scaffold/billing-contracts.js +0 -48
  203. package/dist/scaffold/billing-providers.d.ts +0 -1
  204. package/dist/scaffold/billing-providers.js +0 -249
  205. package/dist/scaffold/billing-schema.d.ts +0 -1
  206. package/dist/scaffold/billing-schema.js +0 -34
  207. package/dist/scaffold/billing-security.d.ts +0 -1
  208. package/dist/scaffold/billing-security.js +0 -46
  209. package/dist/scaffold/billing-server.d.ts +0 -1
  210. package/dist/scaffold/billing-server.js +0 -139
  211. package/dist/scaffold/billing-store.d.ts +0 -1
  212. package/dist/scaffold/billing-store.js +0 -72
  213. package/dist/scaffold/billing.d.ts +0 -2
  214. package/dist/scaffold/billing.js +0 -208
  215. package/dist/scaffold/expo-auth.d.ts +0 -3
  216. package/dist/scaffold/expo-auth.js +0 -203
  217. package/dist/scaffold/expo-billing.d.ts +0 -3
  218. package/dist/scaffold/expo-billing.js +0 -257
  219. package/dist/scaffold/expo-runtime.d.ts +0 -3
  220. package/dist/scaffold/expo-runtime.js +0 -43
  221. package/dist/scaffold/integrations.d.ts +0 -2
  222. package/dist/scaffold/integrations.js +0 -11
  223. package/dist/scaffold/managed-email.d.ts +0 -3
  224. package/dist/scaffold/managed-email.js +0 -47
  225. package/dist/scaffold/native-ui.d.ts +0 -2
  226. package/dist/scaffold/native-ui.js +0 -69
  227. package/dist/scaffold/password-reset.d.ts +0 -1
  228. package/dist/scaffold/password-reset.js +0 -99
  229. package/dist/scaffold/private-files.d.ts +0 -2
  230. package/dist/scaffold/private-files.js +0 -78
  231. package/dist/scaffold/web-billing.d.ts +0 -2
  232. package/dist/scaffold/web-billing.js +0 -48
  233. package/dist/service-deletion.d.ts +0 -29
  234. package/dist/service-deletion.js +0 -195
  235. package/dist/service-descriptor.d.ts +0 -10
  236. package/dist/service-descriptor.js +0 -71
  237. package/dist/service-model.d.ts +0 -49
  238. package/dist/service-model.js +0 -8
  239. package/dist/service-operations.d.ts +0 -29
  240. package/dist/service-operations.js +0 -48
  241. package/dist/service-readers.d.ts +0 -8
  242. package/dist/service-readers.js +0 -216
  243. package/dist/services-command.d.ts +0 -39
  244. package/dist/services-command.js +0 -96
  245. package/dist/ship.d.ts +0 -35
  246. package/dist/ship.js +0 -107
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry.json",
3
+ "name": "anhedral-native",
4
+ "homepage": "https://anhedral.com",
5
+ "items": []
6
+ }
package/dist/bin.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { argv } from 'node:process';
3
3
  import { runCommand } from './cli-commands.js';
4
- import { DELIVERY_COMMANDS } from './cli-delivery.js';
5
4
  import { STANDARD_USAGE, commandHelp } from './registry/usage.js';
6
5
  import { GENERATOR_VERSION } from './version.js';
7
6
  import { PostCommitError } from './transaction.js';
@@ -54,22 +53,18 @@ async function main() {
54
53
  process.env.ANHEDRAL_VERBOSE = '1';
55
54
  await runCommand(command, args, { json, quiet: global.quiet });
56
55
  }
57
- const errorCodes = {
58
- ...Object.fromEntries([...DELIVERY_COMMANDS, 'repository', 'integrations'].map((name) => [name, 'DELIVERY_FAILED'])),
59
- inspect: 'INSPECTION_FAILED',
60
- services: 'SERVICE_FAILED',
61
- auth: 'AUTH_FAILED',
62
- doctor: 'INVALID_ARGUMENT',
63
- init: 'GENERATION_FAILED',
64
- add: 'ADDITION_FAILED',
65
- registry: 'REGISTRY_FAILED',
66
- };
67
56
  function failureCode(error) {
68
57
  if (error instanceof CliArgumentError)
69
58
  return error.code;
70
59
  if (error instanceof PostCommitError)
71
60
  return 'POST_COMMIT_FAILED';
72
- return Object.hasOwn(errorCodes, command ?? '') ? errorCodes[command] : 'UNKNOWN_COMMAND';
61
+ return command === 'init'
62
+ ? 'GENERATION_FAILED'
63
+ : command === 'add' || command === 'stack'
64
+ ? 'CAPABILITY_COMMAND_FAILED'
65
+ : command === 'ui'
66
+ ? 'UI_COMMAND_FAILED'
67
+ : 'UNKNOWN_COMMAND';
73
68
  }
74
69
  try {
75
70
  await main();
@@ -1,40 +1,11 @@
1
- import type { StandardOptions, StandardProduct, SetupRequirements, StackSelection } from './registry/types.js';
2
- export type Capability = SetupRequirements & {
3
- selection: StackSelection;
4
- };
5
- export declare const CAPABILITIES: Record<StandardProduct, Capability>;
6
- export declare const CAPABILITY_REGISTRY: {
7
- schemaVersion: number;
8
- cliVersion: string;
9
- capabilities: Record<"next" | "expo" | "better-auth" | "styling" | "hono" | "d1" | "r2" | "stripe" | "revenuecat", Capability>;
10
- };
1
+ import type { StandardOptions } from './registry/types.js';
11
2
  export declare function createSetupPlan(options: StandardOptions, registry?: import("./registry/resolve.js").ResolvedStackRegistry): {
12
3
  schemaVersion: number;
13
4
  cliVersion: string;
14
- registryVersion: number;
15
- standard: string;
16
5
  root: string;
17
6
  name: string;
18
- products: ("next" | "expo" | "better-auth" | "styling" | "hono" | "d1" | "r2" | "stripe" | "revenuecat")[];
19
- hosting: "cloudflare";
20
- registry: import("./registry/resolve.js").ResolvedStackRegistry;
21
- bootstrap: ("anhedral" | "init")[];
7
+ products: ("hono" | "r2" | "next" | "styling" | "d1")[];
22
8
  dryRun: boolean;
23
- setup: {
24
- tools: string[];
25
- access: string[];
26
- capabilities: {
27
- selection: StackSelection;
28
- status: "planned" | "starter";
29
- purpose: string;
30
- tools: readonly string[];
31
- access: readonly string[];
32
- credentials: readonly string[];
33
- resources: readonly string[];
34
- verify: readonly string[];
35
- id: "next" | "expo" | "better-auth" | "styling" | "hono" | "d1" | "r2" | "stripe" | "revenuecat";
36
- }[];
37
- completion: string[];
38
- resourcesProvisioned: boolean;
39
- };
9
+ registry: import("./registry/resolve.js").ResolvedStackRegistry;
10
+ resourcesProvisioned: boolean;
40
11
  };
@@ -1,78 +1,14 @@
1
1
  import { resolveStackRegistry } from './registry/resolve.js';
2
- import { BOOTSTRAP_COMMAND } from './registry/bootstrap.js';
3
2
  import { GENERATOR_VERSION } from './version.js';
4
- import { PACKAGE_MANAGER } from './dependencies.js';
5
- import { STANDARD_PRODUCTS, getStackDefinition } from './stack-registry.js';
6
- export const CAPABILITIES = Object.fromEntries(STANDARD_PRODUCTS.map((id) => {
7
- const definition = getStackDefinition(id);
8
- return [id, { ...definition.setup, selection: definition.selection }];
9
- }));
10
- export const CAPABILITY_REGISTRY = {
11
- schemaVersion: 1,
12
- cliVersion: GENERATOR_VERSION,
13
- capabilities: CAPABILITIES,
14
- };
15
- const HOSTING_SETUP = {
16
- cloudflare: {
17
- tools: ['Wrangler'],
18
- access: [
19
- 'Client-owned Cloudflare account; account ID; scoped OAuth/API access; service-compatible plan; DNS access only when needed',
20
- ],
21
- },
22
- };
23
3
  export function createSetupPlan(options, registry = resolveStackRegistry(options)) {
24
- const items = new Map(registry.items.map((item) => [item.name, item]));
25
- const capabilities = options.products.map((id) => {
26
- const item = items.get(id);
27
- return {
28
- id,
29
- ...item.setup,
30
- selection: item.selection,
31
- status: options.dryRun ? 'planned' : 'starter',
32
- };
33
- });
34
- const providers = [
35
- ...new Set([
36
- ...capabilities.flatMap(({ tools }) => tools.includes('Wrangler') ? ['cloudflare'] : []),
37
- ]),
38
- ].map(() => HOSTING_SETUP.cloudflare);
39
4
  return {
40
5
  schemaVersion: 1,
41
6
  cliVersion: GENERATOR_VERSION,
42
- registryVersion: CAPABILITY_REGISTRY.schemaVersion,
43
- standard: 'anhedral-application-stack',
44
7
  root: options.root,
45
8
  name: options.name,
46
9
  products: options.products,
47
- hosting: options.hosting,
48
- registry,
49
- bootstrap: [...BOOTSTRAP_COMMAND],
50
10
  dryRun: options.dryRun,
51
- setup: {
52
- tools: [
53
- ...new Set([
54
- 'Git',
55
- 'Node.js 22.13+ on 22.x, or Node.js 24+ for generated workspaces',
56
- PACKAGE_MANAGER.replace('@', ' '),
57
- 'GitHub integration or gh',
58
- ...providers.flatMap((provider) => provider.tools),
59
- ...capabilities.flatMap((item) => item.tools),
60
- ]),
61
- ],
62
- access: [
63
- 'User-owned GitHub repository and CI access',
64
- ...providers.flatMap((provider) => provider.access),
65
- ],
66
- capabilities,
67
- completion: [
68
- 'Guide GitHub authentication, own local Git checkout, reviewed initial commit and private user-owned remote; verify the selected deployment source connection',
69
- 'Discover available plugins and fallbacks; verify the selected account and scope',
70
- 'Configure separate environments, bindings and server-side secrets',
71
- 'Implement starter behavior and meaningful tests',
72
- 'Run pnpm check plus platform/provider verification',
73
- 'Verify deployed preview; obtain required production authorization; record rollback and operating ownership',
74
- ],
75
- resourcesProvisioned: false,
76
- },
11
+ registry,
12
+ resourcesProvisioned: false,
77
13
  };
78
14
  }
@@ -0,0 +1,83 @@
1
+ export declare const CAPABILITIES: {
2
+ readonly hono: {
3
+ readonly name: "Hono backend API";
4
+ readonly requires: readonly [];
5
+ readonly targets: readonly ["apps/api"];
6
+ readonly configuration: readonly ["ANHEDRAL_API service binding"];
7
+ };
8
+ readonly 'database-auth': {
9
+ readonly name: "Drizzle / D1 / Better Auth";
10
+ readonly requires: readonly ["hono"];
11
+ readonly targets: readonly ["packages/db", "apps/api/src/auth.ts"];
12
+ readonly configuration: readonly ["D1 resource ID", "BETTER_AUTH_SECRET", "PUBLIC_APP_URL", "explicit auth methods", "reviewed migrations"];
13
+ };
14
+ readonly r2: {
15
+ readonly name: "Private R2 storage";
16
+ readonly requires: readonly ["database-auth"];
17
+ readonly targets: readonly ["apps/api/src/features/storage.ts"];
18
+ readonly configuration: readonly ["private R2 bucket and FILES binding"];
19
+ };
20
+ readonly stripe: {
21
+ readonly name: "Stripe payments";
22
+ readonly requires: readonly ["database-auth"];
23
+ readonly targets: readonly ["apps/api/src/features/stripe.ts"];
24
+ readonly configuration: readonly ["Stripe test credentials", "allowed prices", "webhook endpoint", "billing schema migration"];
25
+ };
26
+ readonly realtime: {
27
+ readonly name: "Realtime events";
28
+ readonly requires: readonly ["database-auth"];
29
+ readonly targets: readonly ["apps/api/src/features/events.ts"];
30
+ readonly configuration: readonly ["event schema migration"];
31
+ };
32
+ readonly rtc: {
33
+ readonly name: "Realtime RTC";
34
+ readonly requires: readonly ["database-auth"];
35
+ readonly targets: readonly ["apps/api/src/features/rtc.ts"];
36
+ readonly configuration: readonly ["Cloudflare Realtime SFU app ID and secret"];
37
+ };
38
+ readonly ai: {
39
+ readonly name: "Workers AI";
40
+ readonly requires: readonly ["database-auth"];
41
+ readonly targets: readonly ["apps/api/src/features/ai.ts"];
42
+ readonly configuration: readonly ["Workers AI binding", "explicit model selection and daily quota"];
43
+ };
44
+ readonly expo: {
45
+ readonly name: "Expo mobile app";
46
+ readonly requires: readonly ["database-auth"];
47
+ readonly targets: readonly ["apps/mobile"];
48
+ readonly configuration: readonly ["device-reachable API URL", "trusted native origin", "native development build"];
49
+ };
50
+ readonly 'native-ui': {
51
+ readonly name: "Anhedral UI for Expo";
52
+ readonly requires: readonly ["expo"];
53
+ readonly targets: readonly ["apps/mobile/components.json"];
54
+ readonly configuration: readonly ["Android/iOS interaction validation"];
55
+ };
56
+ readonly revenuecat: {
57
+ readonly name: "RevenueCat mobile subscriptions";
58
+ readonly requires: readonly ["expo", "stripe"];
59
+ readonly targets: readonly ["apps/mobile/lib/purchases.ts", "apps/api/src/features/revenuecat.ts"];
60
+ readonly configuration: readonly ["RevenueCat app/project, public SDK keys and server credentials", "store sandbox validation"];
61
+ };
62
+ readonly wxt: {
63
+ readonly name: "WXT browser extension";
64
+ readonly requires: readonly ["database-auth"];
65
+ readonly targets: readonly ["apps/extension"];
66
+ readonly configuration: readonly ["API origin and host permissions", "extension authentication flow"];
67
+ };
68
+ readonly 'side-panel': {
69
+ readonly name: "Side Panel API";
70
+ readonly requires: readonly ["wxt"];
71
+ readonly targets: readonly ["apps/extension/entrypoints/sidepanel"];
72
+ readonly configuration: readonly ["Chromium side panel validation"];
73
+ };
74
+ readonly gpui: {
75
+ readonly name: "GPUI native desktop app";
76
+ readonly requires: readonly ["database-auth"];
77
+ readonly targets: readonly ["apps/desktop"];
78
+ readonly configuration: readonly ["Rust toolchain and native platform libraries", "native account flow and distribution"];
79
+ };
80
+ };
81
+ export type Capability = keyof typeof CAPABILITIES;
82
+ export declare const CAPABILITY_IDS: Capability[];
83
+ export declare function capabilityOrder(requested: readonly string[], installed: readonly Capability[], includeDependencies: boolean): Capability[];
@@ -0,0 +1,121 @@
1
+ export const CAPABILITIES = {
2
+ hono: {
3
+ name: 'Hono backend API',
4
+ requires: [],
5
+ targets: ['apps/api'],
6
+ configuration: ['ANHEDRAL_API service binding'],
7
+ },
8
+ 'database-auth': {
9
+ name: 'Drizzle / D1 / Better Auth',
10
+ requires: ['hono'],
11
+ targets: ['packages/db', 'apps/api/src/auth.ts'],
12
+ configuration: [
13
+ 'D1 resource ID',
14
+ 'BETTER_AUTH_SECRET',
15
+ 'PUBLIC_APP_URL',
16
+ 'explicit auth methods',
17
+ 'reviewed migrations',
18
+ ],
19
+ },
20
+ r2: {
21
+ name: 'Private R2 storage',
22
+ requires: ['database-auth'],
23
+ targets: ['apps/api/src/features/storage.ts'],
24
+ configuration: ['private R2 bucket and FILES binding'],
25
+ },
26
+ stripe: {
27
+ name: 'Stripe payments',
28
+ requires: ['database-auth'],
29
+ targets: ['apps/api/src/features/stripe.ts'],
30
+ configuration: [
31
+ 'Stripe test credentials',
32
+ 'allowed prices',
33
+ 'webhook endpoint',
34
+ 'billing schema migration',
35
+ ],
36
+ },
37
+ realtime: {
38
+ name: 'Realtime events',
39
+ requires: ['database-auth'],
40
+ targets: ['apps/api/src/features/events.ts'],
41
+ configuration: ['event schema migration'],
42
+ },
43
+ rtc: {
44
+ name: 'Realtime RTC',
45
+ requires: ['database-auth'],
46
+ targets: ['apps/api/src/features/rtc.ts'],
47
+ configuration: ['Cloudflare Realtime SFU app ID and secret'],
48
+ },
49
+ ai: {
50
+ name: 'Workers AI',
51
+ requires: ['database-auth'],
52
+ targets: ['apps/api/src/features/ai.ts'],
53
+ configuration: ['Workers AI binding', 'explicit model selection and daily quota'],
54
+ },
55
+ expo: {
56
+ name: 'Expo mobile app',
57
+ requires: ['database-auth'],
58
+ targets: ['apps/mobile'],
59
+ configuration: [
60
+ 'device-reachable API URL',
61
+ 'trusted native origin',
62
+ 'native development build',
63
+ ],
64
+ },
65
+ 'native-ui': {
66
+ name: 'Anhedral UI for Expo',
67
+ requires: ['expo'],
68
+ targets: ['apps/mobile/components.json'],
69
+ configuration: ['Android/iOS interaction validation'],
70
+ },
71
+ revenuecat: {
72
+ name: 'RevenueCat mobile subscriptions',
73
+ requires: ['expo', 'stripe'],
74
+ targets: ['apps/mobile/lib/purchases.ts', 'apps/api/src/features/revenuecat.ts'],
75
+ configuration: [
76
+ 'RevenueCat app/project, public SDK keys and server credentials',
77
+ 'store sandbox validation',
78
+ ],
79
+ },
80
+ wxt: {
81
+ name: 'WXT browser extension',
82
+ requires: ['database-auth'],
83
+ targets: ['apps/extension'],
84
+ configuration: ['API origin and host permissions', 'extension authentication flow'],
85
+ },
86
+ 'side-panel': {
87
+ name: 'Side Panel API',
88
+ requires: ['wxt'],
89
+ targets: ['apps/extension/entrypoints/sidepanel'],
90
+ configuration: ['Chromium side panel validation'],
91
+ },
92
+ gpui: {
93
+ name: 'GPUI native desktop app',
94
+ requires: ['database-auth'],
95
+ targets: ['apps/desktop'],
96
+ configuration: [
97
+ 'Rust toolchain and native platform libraries',
98
+ 'native account flow and distribution',
99
+ ],
100
+ },
101
+ };
102
+ export const CAPABILITY_IDS = Object.keys(CAPABILITIES);
103
+ export function capabilityOrder(requested, installed, includeDependencies) {
104
+ const selected = new Set();
105
+ function visit(name) {
106
+ if (!Object.hasOwn(CAPABILITIES, name))
107
+ throw Error(`Unknown capability: ${name}. Run anhedral stack list.`);
108
+ const id = name;
109
+ if (installed.includes(id) || selected.has(id))
110
+ return;
111
+ for (const parent of CAPABILITIES[id].requires) {
112
+ if (!installed.includes(parent) && !requested.includes(parent) && !includeDependencies)
113
+ throw Error(`${id} requires ${parent}. Add it first or explicitly use --with-dependencies.`);
114
+ visit(parent);
115
+ }
116
+ selected.add(id);
117
+ }
118
+ for (const id of requested)
119
+ visit(id);
120
+ return [...selected];
121
+ }
@@ -0,0 +1,3 @@
1
+ import type { OutputOptions } from './cli-output.js';
2
+ import type { StandardRunner } from './registry/types.js';
3
+ export declare function runCapabilityCommand(command: 'add' | 'stack', args: string[], output: OutputOptions, run?: StandardRunner): Promise<void>;
@@ -0,0 +1,188 @@
1
+ import { existsSync, realpathSync, statSync, chmodSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { commandArguments, commandArgumentError } from './cli-arguments.js';
4
+ import { CAPABILITIES, CAPABILITY_IDS, capabilityOrder, } from './capability-catalog.js';
5
+ import { CapabilityEditor } from './capability-editor.js';
6
+ import { addCapabilityRecipe, composeCapabilities } from './capability-recipes.js';
7
+ import { PostCommitError, runStagedTransaction } from './transaction.js';
8
+ import { put } from './scaffold/files.js';
9
+ import { execFile } from './util.js';
10
+ import { capabilityReferences } from './capability-references.js';
11
+ import { configureDependencyPatches } from './dependency-patches.js';
12
+ function projectRoot(cwd) {
13
+ let root = realpathSync(cwd);
14
+ for (;;) {
15
+ if (existsSync(path.join(root, 'anhedral.json')))
16
+ return root;
17
+ if (existsSync(path.join(root, '.git')))
18
+ break;
19
+ const parent = path.dirname(root);
20
+ if (parent === root)
21
+ break;
22
+ root = parent;
23
+ }
24
+ throw Error('No Anhedral workspace found. Select a generated project with --cwd.');
25
+ }
26
+ function readState(e) {
27
+ const project = e.json('anhedral.json');
28
+ const state = project.capabilities ?? { schemaVersion: 1, installed: [], managedFiles: {} };
29
+ if (state.schemaVersion !== 1 ||
30
+ !Array.isArray(state.installed) ||
31
+ state.installed.some((id) => typeof id !== 'string' || !Object.hasOwn(CAPABILITIES, id)) ||
32
+ !state.managedFiles ||
33
+ typeof state.managedFiles !== 'object' ||
34
+ Array.isArray(state.managedFiles))
35
+ throw Error('Invalid capability state; preserve and reconcile anhedral.json.');
36
+ const installed = [...new Set(state.installed)];
37
+ for (const id of installed)
38
+ for (const parent of CAPABILITIES[id].requires)
39
+ if (!installed.includes(parent))
40
+ throw Error(`Invalid capability state: ${id} requires ${parent}.`);
41
+ return { installed, managedFiles: state.managedFiles };
42
+ }
43
+ export async function runCapabilityCommand(command, args, output, run = execFile) {
44
+ const parsed = commandArguments(command, args);
45
+ let result;
46
+ if (command === 'stack') {
47
+ const [action, ...extra] = parsed.positional;
48
+ if (extra.length || !['list', 'status', 'doctor'].includes(action))
49
+ throw commandArgumentError('stack', 'Use stack list, status or doctor.');
50
+ if (action === 'list')
51
+ result = {
52
+ capabilities: CAPABILITY_IDS.map((id) => ({ id, ...CAPABILITIES[id] })),
53
+ provisioning: 'Separate from source installation',
54
+ };
55
+ else {
56
+ const root = projectRoot(process.cwd());
57
+ const e = new CapabilityEditor(root, {});
58
+ const state = readState(e);
59
+ const capabilities = CAPABILITY_IDS.map((id) => {
60
+ const missing = CAPABILITIES[id].requires.filter((parent) => !state.installed.includes(parent));
61
+ const installed = state.installed.includes(id);
62
+ const missingFiles = installed
63
+ ? CAPABILITIES[id].targets.filter((target) => !existsSync(path.join(root, target)))
64
+ : [];
65
+ return {
66
+ id,
67
+ name: CAPABILITIES[id].name,
68
+ sourceState: installed
69
+ ? missingFiles.length
70
+ ? 'incomplete'
71
+ : 'installed'
72
+ : missing.length
73
+ ? 'locked'
74
+ : 'available',
75
+ missingPrerequisites: missing,
76
+ missingFiles,
77
+ configuration: installed ? CAPABILITIES[id].configuration : [],
78
+ activation: 'not verified',
79
+ };
80
+ });
81
+ const foundationReady = existsSync(path.join(root, 'apps/web/package.json')) &&
82
+ !!e.json('apps/web/package.json').dependencies?.next;
83
+ const sourceReady = foundationReady && capabilities.every((c) => c.sourceState !== 'incomplete');
84
+ result = {
85
+ root,
86
+ foundationReady,
87
+ sourceReady,
88
+ capabilities,
89
+ runtimeAcceptance: 'not evaluated',
90
+ resourcesProvisionedByCli: false,
91
+ };
92
+ if (action === 'doctor' && !sourceReady)
93
+ process.exitCode = 1;
94
+ }
95
+ }
96
+ else {
97
+ if (!parsed.positional.length || parsed.positional.length > CAPABILITY_IDS.length)
98
+ throw commandArgumentError('add', 'Choose one or more capabilities from anhedral stack list.');
99
+ const root = projectRoot(process.cwd());
100
+ const e = new CapabilityEditor(root, {});
101
+ const state = readState(e);
102
+ Object.assign(e.managed, state.managedFiles);
103
+ const manifest = e.json('package.json');
104
+ if (typeof manifest.name !== 'string' || !manifest.name)
105
+ throw Error('The workspace needs a package name.');
106
+ if (!e.json('apps/web/package.json').dependencies?.next)
107
+ throw Error('A Next.js foundation is required.');
108
+ for (const id of state.installed)
109
+ for (const target of CAPABILITIES[id].targets)
110
+ if (!existsSync(path.join(root, target)))
111
+ throw Error(`Installed capability is incomplete: ${id} (${target}). Reconcile its source first.`);
112
+ const additions = capabilityOrder(parsed.positional, state.installed, parsed.has('--with-dependencies'));
113
+ const installed = [...state.installed, ...additions];
114
+ for (const id of additions)
115
+ addCapabilityRecipe(e, id, manifest.name);
116
+ if (additions.length) {
117
+ for (const [file, source] of Object.entries(capabilityReferences()))
118
+ if (e.read(file) === null)
119
+ e.create(file, source);
120
+ composeCapabilities(e, installed);
121
+ e.set('anhedral.json', ['capabilities'], {
122
+ schemaVersion: 1,
123
+ installed,
124
+ managedFiles: e.managed,
125
+ resourcesProvisionedByCli: false,
126
+ });
127
+ }
128
+ const files = [...e.writes.keys()];
129
+ const plan = {
130
+ root,
131
+ added: additions,
132
+ alreadyInstalled: parsed.positional.filter((id) => state.installed.includes(id)),
133
+ installed,
134
+ files,
135
+ configuration: additions.map((id) => ({ id, requirements: CAPABILITIES[id].configuration })),
136
+ dryRun: parsed.has('--dry-run'),
137
+ resourcesProvisionedByCli: false,
138
+ activation: 'not verified',
139
+ };
140
+ const installDependencies = () => {
141
+ if (parsed.has('--skip-install'))
142
+ return;
143
+ run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile'], root);
144
+ if (configureDependencyPatches(root))
145
+ run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile'], root);
146
+ run('pnpm', ['install', '--frozen-lockfile'], root);
147
+ };
148
+ if (!parsed.has('--dry-run') && files.length) {
149
+ await runStagedTransaction(root, {
150
+ commitPaths: files,
151
+ prepare: () => e.verify(),
152
+ build: async (stage) => {
153
+ for (const [file, source] of e.writes) {
154
+ put(stage, file, source);
155
+ if (e.before.get(file) !== null)
156
+ chmodSync(path.join(stage, file), statSync(path.join(root, file)).mode & 0o777);
157
+ }
158
+ e.verify();
159
+ },
160
+ afterCommit: installDependencies,
161
+ });
162
+ }
163
+ if (!parsed.has('--dry-run') && !files.length) {
164
+ e.verify();
165
+ try {
166
+ installDependencies();
167
+ }
168
+ catch (error) {
169
+ throw new PostCommitError([], error);
170
+ }
171
+ }
172
+ result = {
173
+ ...plan,
174
+ sourceInstalled: !parsed.has('--dry-run'),
175
+ dependenciesInstalled: !parsed.has('--dry-run') && !parsed.has('--skip-install'),
176
+ };
177
+ }
178
+ if (output.json)
179
+ console.log(JSON.stringify(result, null, 2));
180
+ else if (!output.quiet) {
181
+ if (command === 'add')
182
+ console.log(`${parsed.has('--dry-run') ? 'Plan' : 'Source additions'}: ${result.added.join(', ') || 'already installed'}\n${result.files.map((file) => ' ' + file).join('\n')}\nReview capability configuration and migrations before deployment. No resources were provisioned.`);
183
+ else
184
+ console.log(result.capabilities
185
+ .map((item) => `${item.id}\t${item.sourceState ?? item.name}\t${item.requires?.join(', ') ?? ''}`)
186
+ .join('\n') + '\nSource state is not live provider activation.');
187
+ }
188
+ }
@@ -0,0 +1,17 @@
1
+ export declare const fingerprint: (source: string | Buffer) => string;
2
+ /** A bounded, read-only overlay until every capability has passed preflight. */
3
+ export declare class CapabilityEditor {
4
+ readonly root: string;
5
+ readonly managed: Record<string, string>;
6
+ readonly writes: Map<string, string>;
7
+ readonly before: Map<string, string | null>;
8
+ constructor(root: string, managed: Record<string, string>);
9
+ private file;
10
+ read(relative: string): string | null;
11
+ json(relative: string): Record<string, any>;
12
+ create(relative: string, source: string): void;
13
+ owned(relative: string, source: string): void;
14
+ set(relative: string, keys: (string | number)[], value: unknown): void;
15
+ merge(relative: string, section: string, values: Record<string, unknown>): void;
16
+ verify(): void;
17
+ }