anhedral 0.18.0 → 0.20.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.
- package/README.md +10 -6
- package/assets/contracts/deployment-provenance.json +6 -6
- package/assets/contracts/operations-provenance.json +2 -1
- package/assets/launch/oj/OJ.LICENSE +21 -0
- package/assets/launch/oj/run.mjs +82 -0
- package/assets/launch/oj/runtime.json +21 -0
- package/assets/launch/root.tsx.txt +1 -2
- package/assets/launch/server.ts.txt +4 -2
- package/assets/ui/catalog.json +36 -324
- package/dist/{platforms/web.d.ts → api-proxy.d.ts} +1 -3
- package/dist/api-proxy.js +48 -0
- package/dist/capability-catalog.d.ts +3 -57
- package/dist/capability-catalog.js +3 -90
- package/dist/capability-command.d.ts +10 -2
- package/dist/capability-command.js +35 -99
- package/dist/capability-editor.js +21 -1
- package/dist/capability-recipes.js +8 -343
- package/dist/cli-commands.js +6 -1
- package/dist/command-schema.js +141 -2
- package/dist/command-types.d.ts +1 -0
- package/dist/composition.d.ts +4 -14
- package/dist/composition.js +6 -6
- package/dist/contracts/cli-transport.d.ts +139 -40
- package/dist/contracts/cli-transport.js +96 -27
- package/dist/contracts/deployment.d.ts +7 -56
- package/dist/contracts/deployment.js +9 -45
- package/dist/contracts/production-transport.d.ts +71 -0
- package/dist/contracts/production-transport.js +56 -0
- package/dist/contracts/source-profile.js +1 -1
- package/dist/contracts/staging-transport.d.ts +2 -2
- package/dist/credential-helper.d.ts +2 -0
- package/dist/credential-helper.js +44 -0
- package/dist/dependencies.d.ts +0 -27
- package/dist/dependencies.js +3 -67
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -2
- package/dist/launch.d.ts +11 -5
- package/dist/launch.js +21 -9
- package/dist/platform-command.js +245 -42
- package/dist/platform-production.d.ts +16 -0
- package/dist/platform-production.js +135 -0
- package/dist/platform-state.d.ts +4 -1
- package/dist/platform-state.js +28 -5
- package/dist/platforms/tanstack.d.ts +2 -0
- package/dist/platforms/tanstack.js +113 -20
- package/dist/registry/usage.js +3 -1
- package/dist/release-artifact.d.ts +18 -0
- package/dist/release-artifact.js +169 -0
- package/dist/scaffold/bootstrap.d.ts +3 -3
- package/dist/scaffold/styling.d.ts +3 -2
- package/dist/stack-update.d.ts +39 -0
- package/dist/stack-update.js +346 -0
- package/dist/transaction.d.ts +1 -0
- package/dist/transaction.js +2 -0
- package/dist/ui-catalog.d.ts +3 -5
- package/dist/ui-catalog.js +8 -24
- package/dist/ui-command.d.ts +1 -1
- package/dist/ui-command.js +18 -57
- package/dist/ui-project.d.ts +2 -2
- package/dist/ui-project.js +8 -36
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +7 -7
- package/docs/software-factory.md +83 -16
- package/docs/stack-standard.md +1 -1
- package/package.json +1 -4
- package/assets/stack/ai-schema.ts.txt +0 -5
- package/assets/stack/ai.ts.txt +0 -30
- package/assets/stack/desktop.rs.txt +0 -21
- package/assets/stack/event-retention.sql.txt +0 -10
- package/assets/stack/events-schema.ts.txt +0 -12
- package/assets/stack/events.ts.txt +0 -59
- package/assets/stack/mobile-auth.ts.txt +0 -25
- package/assets/stack/mobile-billing.tsx.txt +0 -63
- package/assets/stack/mobile-session.tsx.txt +0 -83
- package/assets/stack/native-button.tsx.txt +0 -108
- package/assets/stack/native-global.css.txt +0 -4
- package/assets/stack/native-lib-utils.ts.txt +0 -5
- package/assets/stack/native-metro.config.js.txt +0 -6
- package/assets/stack/native-nativewind-env.d.ts.txt +0 -1
- package/assets/stack/native-tailwind.config.js.txt +0 -73
- package/assets/stack/native-text.tsx.txt +0 -89
- package/assets/stack/purchases.ts.txt +0 -65
- package/assets/stack/revenuecat.ts.txt +0 -88
- package/assets/stack/rtc-schema.ts.txt +0 -10
- package/assets/stack/rtc.ts.txt +0 -122
- package/assets/stack/web-sign-in.tsx.txt +0 -51
- package/dist/capabilities.d.ts +0 -11
- package/dist/capabilities.js +0 -14
- package/dist/dependency-order.d.ts +0 -2
- package/dist/dependency-order.js +0 -24
- package/dist/platforms/lint.d.ts +0 -1
- package/dist/platforms/lint.js +0 -5
- package/dist/platforms/web.js +0 -251
- package/dist/project-config.d.ts +0 -3
- package/dist/project-config.js +0 -16
- package/dist/registry/context.d.ts +0 -3
- package/dist/registry/context.js +0 -20
- package/dist/registry/options.d.ts +0 -2
- package/dist/registry/options.js +0 -47
- package/dist/registry/resolve.d.ts +0 -11
- package/dist/registry/resolve.js +0 -46
- package/dist/registry/types.d.ts +0 -60
- package/dist/scaffold/api.d.ts +0 -2
- package/dist/scaffold/api.js +0 -38
- package/dist/scaffold/backend.d.ts +0 -2
- package/dist/scaffold/backend.js +0 -36
- package/dist/scaffold/compose.d.ts +0 -4
- package/dist/scaffold/compose.js +0 -30
- package/dist/scaffold/database.d.ts +0 -2
- package/dist/scaffold/database.js +0 -41
- package/dist/scaffold/documentation.d.ts +0 -2
- package/dist/scaffold/documentation.js +0 -71
- package/dist/scaffold/environment.d.ts +0 -4
- package/dist/scaffold/environment.js +0 -22
- package/dist/scaffold/stack-documentation.d.ts +0 -2
- package/dist/scaffold/stack-documentation.js +0 -6
- package/dist/scaffold/storage.d.ts +0 -2
- package/dist/scaffold/storage.js +0 -21
- package/dist/scaffold/workspace.d.ts +0 -3
- package/dist/scaffold/workspace.js +0 -141
- package/dist/stack-registry.d.ts +0 -35
- package/dist/stack-registry.js +0 -189
- package/dist/standard.d.ts +0 -8
- package/dist/standard.js +0 -109
- package/dist/workspace-graph.d.ts +0 -7
- package/dist/workspace-graph.js +0 -74
- /package/dist/{registry/types.js → command-types.js} +0 -0
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function scaffoldWeb({ root, options, has }: RecipeContext): void;
|
|
3
|
-
export declare const WEB_API_PROXY = "export interface ApiBinding { fetch(request: Request): Promise<Response> }\ntype Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };\nfunction developmentOrigin(configured?: string): string {\n const url = new URL(configured || 'http://127.0.0.1:8787');\n const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);\n const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];\n if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');\n return url.origin;\n}\nfunction backendOrigin(options: Options): string {\n if (options.development) return developmentOrigin(options.devOrigin);\n if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');\n return 'https://api.internal';\n}\nfunction apiTarget(request: Request, origin: string): URL {\n const url = new URL(request.url);\n if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');\n return new URL(url.pathname + url.search, origin);\n}\nfunction forwardedHeaders(request: Request): Headers {\n const headers = new Headers();\n for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {\n const value = request.headers.get(name); if (value) headers.set(name, value);\n }\n return headers;\n}\nfunction upstreamRequest(request: Request, target: URL): Request {\n const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };\n if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }\n return new Request(target, settings);\n}\nfunction privateResponse(response: Response, development: boolean): Response {\n const headers = new Headers(response.headers);\n for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);\n // Node fetch already decoded the local HTTP response. Next must frame/compress\n // those decoded bytes itself; the sidecar's wire headers no longer describe them.\n if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }\n headers.set('cache-control', 'private, no-store');\n return new Response(response.body, { status: response.status, headers });\n}\nexport async function proxyApi(request: Request, options: Options): Promise<Response> {\n try {\n const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));\n const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);\n return privateResponse(response, options.development);\n } catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }\n}\n";
|
|
1
|
+
export declare const WEB_API_PROXY = "export interface ApiBinding { fetch(request: Request): Promise<Response> }\ntype Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };\nfunction developmentOrigin(configured?: string): string {\n const url = new URL(configured || 'http://127.0.0.1:8787');\n const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);\n const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];\n if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');\n return url.origin;\n}\nfunction backendOrigin(options: Options): string {\n if (options.development) return developmentOrigin(options.devOrigin);\n if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');\n return 'https://api.internal';\n}\nfunction apiTarget(request: Request, origin: string): URL {\n const url = new URL(request.url);\n if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');\n return new URL(url.pathname + url.search, origin);\n}\nfunction forwardedHeaders(request: Request): Headers {\n const headers = new Headers();\n for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {\n const value = request.headers.get(name); if (value) headers.set(name, value);\n }\n return headers;\n}\nfunction upstreamRequest(request: Request, target: URL): Request {\n const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };\n if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }\n return new Request(target, settings);\n}\nfunction privateResponse(response: Response, development: boolean): Response {\n const headers = new Headers(response.headers);\n for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);\n // Node fetch already decoded the local HTTP response. The server must frame/compress\n // those decoded bytes itself; the sidecar's wire headers no longer describe them.\n if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }\n headers.set('cache-control', 'private, no-store');\n return new Response(response.body, { status: response.status, headers });\n}\nexport async function proxyApi(request: Request, options: Options): Promise<Response> {\n try {\n const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));\n const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);\n return privateResponse(response, options.development);\n } catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }\n}\n";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const WEB_API_PROXY = `export interface ApiBinding { fetch(request: Request): Promise<Response> }
|
|
2
|
+
type Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };
|
|
3
|
+
function developmentOrigin(configured?: string): string {
|
|
4
|
+
const url = new URL(configured || 'http://127.0.0.1:8787');
|
|
5
|
+
const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
6
|
+
const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];
|
|
7
|
+
if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');
|
|
8
|
+
return url.origin;
|
|
9
|
+
}
|
|
10
|
+
function backendOrigin(options: Options): string {
|
|
11
|
+
if (options.development) return developmentOrigin(options.devOrigin);
|
|
12
|
+
if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');
|
|
13
|
+
return 'https://api.internal';
|
|
14
|
+
}
|
|
15
|
+
function apiTarget(request: Request, origin: string): URL {
|
|
16
|
+
const url = new URL(request.url);
|
|
17
|
+
if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');
|
|
18
|
+
return new URL(url.pathname + url.search, origin);
|
|
19
|
+
}
|
|
20
|
+
function forwardedHeaders(request: Request): Headers {
|
|
21
|
+
const headers = new Headers();
|
|
22
|
+
for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {
|
|
23
|
+
const value = request.headers.get(name); if (value) headers.set(name, value);
|
|
24
|
+
}
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
|
27
|
+
function upstreamRequest(request: Request, target: URL): Request {
|
|
28
|
+
const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };
|
|
29
|
+
if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }
|
|
30
|
+
return new Request(target, settings);
|
|
31
|
+
}
|
|
32
|
+
function privateResponse(response: Response, development: boolean): Response {
|
|
33
|
+
const headers = new Headers(response.headers);
|
|
34
|
+
for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);
|
|
35
|
+
// Node fetch already decoded the local HTTP response. The server must frame/compress
|
|
36
|
+
// those decoded bytes itself; the sidecar's wire headers no longer describe them.
|
|
37
|
+
if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }
|
|
38
|
+
headers.set('cache-control', 'private, no-store');
|
|
39
|
+
return new Response(response.body, { status: response.status, headers });
|
|
40
|
+
}
|
|
41
|
+
export async function proxyApi(request: Request, options: Options): Promise<Response> {
|
|
42
|
+
try {
|
|
43
|
+
const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));
|
|
44
|
+
const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);
|
|
45
|
+
return privateResponse(response, options.development);
|
|
46
|
+
} catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
@@ -8,7 +8,7 @@ export declare const CAPABILITIES: {
|
|
|
8
8
|
readonly 'database-auth': {
|
|
9
9
|
readonly name: "Drizzle / D1 / Better Auth";
|
|
10
10
|
readonly requires: readonly ["hono"];
|
|
11
|
-
readonly targets: readonly ["packages/db/package.json", "packages/db/src/index.ts", "packages/db/src/schema.ts", "apps/api/src/auth.ts", "apps/api/src/auth-features.ts", "apps/api/src/security.ts", "apps/api/src/auth-platform.ts", "apps/api/src/features/auth.ts", "apps/web/lib/auth-client.ts"];
|
|
11
|
+
readonly targets: readonly ["packages/db/package.json", "packages/db/src/index.ts", "packages/db/src/schema.ts", "apps/api/src/auth.ts", "apps/api/src/auth-features.ts", "apps/api/src/security.ts", "apps/api/src/auth-platform.ts", "apps/api/src/features/auth.ts", "apps/web/src/lib/auth-client.ts"];
|
|
12
12
|
readonly configuration: readonly ["D1 resource ID", "BETTER_AUTH_SECRET", "PUBLIC_APP_URL", "explicit auth methods", "reviewed migrations"];
|
|
13
13
|
};
|
|
14
14
|
readonly r2: {
|
|
@@ -23,65 +23,11 @@ export declare const CAPABILITIES: {
|
|
|
23
23
|
readonly targets: readonly ["apps/api/src/features/stripe.ts", "apps/api/src/features/entitlements.ts", "apps/api/src/entitlement-guard.ts", "apps/api/src/billing-mode.ts", "apps/api/src/billing-providers.ts", "packages/db/src/billing-schema.ts"];
|
|
24
24
|
readonly configuration: readonly ["Stripe test credentials", "allowed prices", "webhook endpoint", "billing schema migration"];
|
|
25
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", "packages/db/src/events-schema.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", "packages/db/src/rtc-schema.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", "packages/db/src/ai-schema.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/package.json", "apps/mobile/App.tsx", "apps/mobile/anhedral-entry.tsx", "apps/mobile/lib/auth-client.ts", "apps/mobile/components/session-controls.tsx"];
|
|
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", "apps/mobile/global.css", "apps/mobile/metro.config.js", "apps/mobile/components/ui/button.tsx", "apps/mobile/components/ui/text.tsx"];
|
|
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/package.json", "apps/extension/wxt.config.ts", "apps/extension/anhedral-background.ts", "apps/extension/entrypoints/background.ts"];
|
|
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/index.html", "apps/extension/entrypoints/sidepanel/main.tsx"];
|
|
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/package.json", "apps/desktop/Cargo.toml", "apps/desktop/src/main.rs"];
|
|
78
|
-
readonly configuration: readonly ["Rust toolchain and native platform libraries", "native account flow and distribution"];
|
|
79
|
-
};
|
|
80
26
|
};
|
|
81
27
|
export type Capability = keyof typeof CAPABILITIES;
|
|
82
28
|
export declare const CAPABILITY_IDS: Capability[];
|
|
83
29
|
export declare function capabilityOrder(requested: readonly string[], installed: readonly Capability[], includeDependencies: boolean): Capability[];
|
|
84
|
-
/** The sole
|
|
30
|
+
/** The sole source composition, extended only by backend, storage and payments. */
|
|
85
31
|
export declare const ANHEDRAL_STACK: {
|
|
86
32
|
readonly schemaVersion: 1;
|
|
87
33
|
readonly id: "anhedral-stack";
|
|
@@ -96,7 +42,7 @@ export declare const ANHEDRAL_STACK: {
|
|
|
96
42
|
readonly name: "Backend";
|
|
97
43
|
readonly description: "API, database and authentication together.";
|
|
98
44
|
readonly requires: string[];
|
|
99
|
-
readonly targets: readonly ["apps/api/package.json", "apps/api/wrangler.jsonc", "apps/api/src/index.ts", "apps/api/src/environment.ts", "apps/api/src/capabilities.ts", "apps/api/src/custom-environment.ts",
|
|
45
|
+
readonly targets: readonly ["apps/api/package.json", "apps/api/wrangler.jsonc", "apps/api/src/index.ts", "apps/api/src/environment.ts", "apps/api/src/capabilities.ts", "apps/api/src/custom-environment.ts", "packages/db/package.json", "packages/db/src/index.ts", "packages/db/src/schema.ts", "apps/api/src/auth.ts", "apps/api/src/auth-features.ts", "apps/api/src/security.ts", "apps/api/src/auth-platform.ts", "apps/api/src/features/auth.ts", "apps/web/src/lib/auth-client.ts"];
|
|
100
46
|
};
|
|
101
47
|
readonly r2: {
|
|
102
48
|
readonly name: "Private storage";
|
|
@@ -24,7 +24,7 @@ export const CAPABILITIES = {
|
|
|
24
24
|
'apps/api/src/security.ts',
|
|
25
25
|
'apps/api/src/auth-platform.ts',
|
|
26
26
|
'apps/api/src/features/auth.ts',
|
|
27
|
-
'apps/web/lib/auth-client.ts',
|
|
27
|
+
'apps/web/src/lib/auth-client.ts',
|
|
28
28
|
],
|
|
29
29
|
configuration: [
|
|
30
30
|
'D1 resource ID',
|
|
@@ -58,90 +58,6 @@ export const CAPABILITIES = {
|
|
|
58
58
|
'billing schema migration',
|
|
59
59
|
],
|
|
60
60
|
},
|
|
61
|
-
realtime: {
|
|
62
|
-
name: 'Realtime events',
|
|
63
|
-
requires: ['database-auth'],
|
|
64
|
-
targets: ['apps/api/src/features/events.ts', 'packages/db/src/events-schema.ts'],
|
|
65
|
-
configuration: ['event schema migration'],
|
|
66
|
-
},
|
|
67
|
-
rtc: {
|
|
68
|
-
name: 'Realtime RTC',
|
|
69
|
-
requires: ['database-auth'],
|
|
70
|
-
targets: ['apps/api/src/features/rtc.ts', 'packages/db/src/rtc-schema.ts'],
|
|
71
|
-
configuration: ['Cloudflare Realtime SFU app ID and secret'],
|
|
72
|
-
},
|
|
73
|
-
ai: {
|
|
74
|
-
name: 'Workers AI',
|
|
75
|
-
requires: ['database-auth'],
|
|
76
|
-
targets: ['apps/api/src/features/ai.ts', 'packages/db/src/ai-schema.ts'],
|
|
77
|
-
configuration: ['Workers AI binding', 'explicit model selection and daily quota'],
|
|
78
|
-
},
|
|
79
|
-
expo: {
|
|
80
|
-
name: 'Expo mobile app',
|
|
81
|
-
requires: ['database-auth'],
|
|
82
|
-
targets: [
|
|
83
|
-
'apps/mobile/package.json',
|
|
84
|
-
'apps/mobile/App.tsx',
|
|
85
|
-
'apps/mobile/anhedral-entry.tsx',
|
|
86
|
-
'apps/mobile/lib/auth-client.ts',
|
|
87
|
-
'apps/mobile/components/session-controls.tsx',
|
|
88
|
-
],
|
|
89
|
-
configuration: [
|
|
90
|
-
'device-reachable API URL',
|
|
91
|
-
'trusted native origin',
|
|
92
|
-
'native development build',
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
'native-ui': {
|
|
96
|
-
name: 'Anhedral UI for Expo',
|
|
97
|
-
requires: ['expo'],
|
|
98
|
-
targets: [
|
|
99
|
-
'apps/mobile/components.json',
|
|
100
|
-
'apps/mobile/global.css',
|
|
101
|
-
'apps/mobile/metro.config.js',
|
|
102
|
-
'apps/mobile/components/ui/button.tsx',
|
|
103
|
-
'apps/mobile/components/ui/text.tsx',
|
|
104
|
-
],
|
|
105
|
-
configuration: ['Android/iOS interaction validation'],
|
|
106
|
-
},
|
|
107
|
-
revenuecat: {
|
|
108
|
-
name: 'RevenueCat mobile subscriptions',
|
|
109
|
-
requires: ['expo', 'stripe'],
|
|
110
|
-
targets: ['apps/mobile/lib/purchases.ts', 'apps/api/src/features/revenuecat.ts'],
|
|
111
|
-
configuration: [
|
|
112
|
-
'RevenueCat app/project, public SDK keys and server credentials',
|
|
113
|
-
'store sandbox validation',
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
wxt: {
|
|
117
|
-
name: 'WXT browser extension',
|
|
118
|
-
requires: ['database-auth'],
|
|
119
|
-
targets: [
|
|
120
|
-
'apps/extension/package.json',
|
|
121
|
-
'apps/extension/wxt.config.ts',
|
|
122
|
-
'apps/extension/anhedral-background.ts',
|
|
123
|
-
'apps/extension/entrypoints/background.ts',
|
|
124
|
-
],
|
|
125
|
-
configuration: ['API origin and host permissions', 'extension authentication flow'],
|
|
126
|
-
},
|
|
127
|
-
'side-panel': {
|
|
128
|
-
name: 'Side Panel API',
|
|
129
|
-
requires: ['wxt'],
|
|
130
|
-
targets: [
|
|
131
|
-
'apps/extension/entrypoints/sidepanel/index.html',
|
|
132
|
-
'apps/extension/entrypoints/sidepanel/main.tsx',
|
|
133
|
-
],
|
|
134
|
-
configuration: ['Chromium side panel validation'],
|
|
135
|
-
},
|
|
136
|
-
gpui: {
|
|
137
|
-
name: 'GPUI native desktop app',
|
|
138
|
-
requires: ['database-auth'],
|
|
139
|
-
targets: ['apps/desktop/package.json', 'apps/desktop/Cargo.toml', 'apps/desktop/src/main.rs'],
|
|
140
|
-
configuration: [
|
|
141
|
-
'Rust toolchain and native platform libraries',
|
|
142
|
-
'native account flow and distribution',
|
|
143
|
-
],
|
|
144
|
-
},
|
|
145
61
|
};
|
|
146
62
|
export const CAPABILITY_IDS = Object.keys(CAPABILITIES);
|
|
147
63
|
export function capabilityOrder(requested, installed, includeDependencies) {
|
|
@@ -163,7 +79,7 @@ export function capabilityOrder(requested, installed, includeDependencies) {
|
|
|
163
79
|
visit(id);
|
|
164
80
|
return [...selected];
|
|
165
81
|
}
|
|
166
|
-
/** The sole
|
|
82
|
+
/** The sole source composition, extended only by backend, storage and payments. */
|
|
167
83
|
export const ANHEDRAL_STACK = {
|
|
168
84
|
schemaVersion: 1,
|
|
169
85
|
id: 'anhedral-stack',
|
|
@@ -184,10 +100,7 @@ export const ANHEDRAL_STACK = {
|
|
|
184
100
|
name: 'Backend',
|
|
185
101
|
description: 'API, database and authentication together.',
|
|
186
102
|
requires: [],
|
|
187
|
-
targets: [
|
|
188
|
-
...CAPABILITIES.hono.targets,
|
|
189
|
-
...CAPABILITIES['database-auth'].targets.map((target) => target === 'apps/web/lib/auth-client.ts' ? 'apps/web/src/lib/auth-client.ts' : target),
|
|
190
|
-
],
|
|
103
|
+
targets: [...CAPABILITIES.hono.targets, ...CAPABILITIES['database-auth'].targets],
|
|
191
104
|
},
|
|
192
105
|
r2: {
|
|
193
106
|
name: 'Private storage',
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { type OutputOptions } from './cli-output.js';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { CapabilityEditor } from './capability-editor.js';
|
|
3
|
+
import type { CommandRunner } from './command-types.js';
|
|
4
|
+
export declare function projectRoot(cwd: string, allowRecovery?: boolean): string;
|
|
5
|
+
export declare function readState(e: CapabilityEditor): {
|
|
6
|
+
installed: ("hono" | "database-auth" | "r2" | "stripe")[];
|
|
7
|
+
managedFiles: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
/** Identify the source before any recovery or source mutation. One missing manifest can be an interrupted add. */
|
|
10
|
+
export declare function assertPublicWorkspace(root: string, allowRecovery?: boolean, command?: 'add' | 'stack'): void;
|
|
11
|
+
export declare function runCapabilityCommand(command: 'add' | 'stack', args: string[], output: OutputOptions, run?: CommandRunner): Promise<void>;
|
|
@@ -5,13 +5,15 @@ import { createReporter } from './cli-output.js';
|
|
|
5
5
|
import { ANHEDRAL_STACK, PUBLIC_STACK_ADDITIONS, CAPABILITIES, CAPABILITY_IDS, capabilityOrder, } from './capability-catalog.js';
|
|
6
6
|
import { CapabilityEditor } from './capability-editor.js';
|
|
7
7
|
import { addCapabilityRecipe, composeCapabilities } from './capability-recipes.js';
|
|
8
|
+
import { normalizeOjFoundation } from './platforms/tanstack.js';
|
|
9
|
+
import { GENERATOR_VERSION } from './version.js';
|
|
8
10
|
import { PostCommitError, runStagedTransaction, recoverInterruptedTransaction, } from './transaction.js';
|
|
9
11
|
import { put } from './scaffold/files.js';
|
|
10
12
|
import { execFile } from './util.js';
|
|
11
13
|
import { capabilityReferences } from './capability-references.js';
|
|
12
14
|
import { configureDependencyPatches } from './dependency-patches.js';
|
|
13
15
|
import { composeSourceProvenance } from './composition.js';
|
|
14
|
-
function projectRoot(cwd, allowRecovery = false) {
|
|
16
|
+
export function projectRoot(cwd, allowRecovery = false) {
|
|
15
17
|
let root = realpathSync(cwd);
|
|
16
18
|
for (;;) {
|
|
17
19
|
if (existsSync(path.join(root, 'anhedral.json')) ||
|
|
@@ -26,7 +28,7 @@ function projectRoot(cwd, allowRecovery = false) {
|
|
|
26
28
|
}
|
|
27
29
|
throw Error('No Anhedral workspace found. Select a generated project with --cwd.');
|
|
28
30
|
}
|
|
29
|
-
function readState(e) {
|
|
31
|
+
export function readState(e) {
|
|
30
32
|
const project = e.json('anhedral.json');
|
|
31
33
|
const state = project.capabilities ?? { schemaVersion: 1, installed: [], managedFiles: {} };
|
|
32
34
|
if (state.schemaVersion !== 1 ||
|
|
@@ -43,17 +45,16 @@ function readState(e) {
|
|
|
43
45
|
throw Error(`Invalid capability state: ${id} requires ${parent}.`);
|
|
44
46
|
return { installed, managedFiles: state.managedFiles };
|
|
45
47
|
}
|
|
46
|
-
const archivedStack = 'codex/preserved-progressive-stack-20261102';
|
|
47
48
|
const publicGroups = {
|
|
48
49
|
backend: ['hono', 'database-auth'],
|
|
49
50
|
r2: ['r2'],
|
|
50
51
|
stripe: ['stripe'],
|
|
51
52
|
};
|
|
52
53
|
function publicScopeError(command = 'add') {
|
|
53
|
-
return commandArgumentError(command,
|
|
54
|
+
return commandArgumentError(command, 'The CLI edits only the Anhedral Stack: TanStack Start with OJ and shadcn.');
|
|
54
55
|
}
|
|
55
56
|
/** Identify the source before any recovery or source mutation. One missing manifest can be an interrupted add. */
|
|
56
|
-
function assertPublicWorkspace(root, allowRecovery = false, command = 'add') {
|
|
57
|
+
export function assertPublicWorkspace(root, allowRecovery = false, command = 'add') {
|
|
57
58
|
const editor = new CapabilityEditor(root, {});
|
|
58
59
|
const recovering = allowRecovery && existsSync(path.join(root, '.anhedral-journal.json'));
|
|
59
60
|
const hasWeb = existsSync(path.join(root, 'apps/web/package.json'));
|
|
@@ -73,7 +74,9 @@ function assertPublicWorkspace(root, allowRecovery = false, command = 'add') {
|
|
|
73
74
|
if (Array.isArray(configuration.capabilities?.installed) &&
|
|
74
75
|
configuration.capabilities.installed.some((id) => !['hono', 'database-auth', 'r2', 'stripe'].includes(id)))
|
|
75
76
|
throw publicScopeError(command);
|
|
76
|
-
if (
|
|
77
|
+
if (configuration.setup?.stack !== 'anhedral-stack' ||
|
|
78
|
+
composition?.contractVersion !== 2 ||
|
|
79
|
+
composition?.foundation !== 'tanstack-start')
|
|
77
80
|
throw publicScopeError(command);
|
|
78
81
|
}
|
|
79
82
|
else if (!recovering)
|
|
@@ -122,12 +125,12 @@ function publicStackState(root, state) {
|
|
|
122
125
|
resourcesProvisionedByCli: false,
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
|
-
export async function runCapabilityCommand(command, args, output, run = execFile
|
|
128
|
+
export async function runCapabilityCommand(command, args, output, run = execFile) {
|
|
126
129
|
const parsed = commandArguments(command, args);
|
|
127
|
-
if (
|
|
130
|
+
if (command === 'add') {
|
|
128
131
|
const unsupported = parsed.positional.filter((id) => !PUBLIC_STACK_ADDITIONS.includes(id));
|
|
129
132
|
if (unsupported.length)
|
|
130
|
-
throw commandArgumentError('add',
|
|
133
|
+
throw commandArgumentError('add', 'Choose backend, r2 or stripe for the Anhedral Stack.');
|
|
131
134
|
}
|
|
132
135
|
let result;
|
|
133
136
|
if (command === 'stack') {
|
|
@@ -135,65 +138,13 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
135
138
|
if (extra.length || !['list', 'status', 'doctor'].includes(action))
|
|
136
139
|
throw commandArgumentError('stack', 'Use stack list, status or doctor.');
|
|
137
140
|
if (action === 'list')
|
|
138
|
-
result =
|
|
139
|
-
scope === 'public'
|
|
140
|
-
? { stack: ANHEDRAL_STACK, resourcesProvisionedByCli: false }
|
|
141
|
-
: {
|
|
142
|
-
launchAdditions: {
|
|
143
|
-
backend: ['hono', 'database-auth'],
|
|
144
|
-
r2: ['r2'],
|
|
145
|
-
stripe: ['stripe'],
|
|
146
|
-
},
|
|
147
|
-
capabilities: CAPABILITY_IDS.map((id) => ({ id, ...CAPABILITIES[id] })),
|
|
148
|
-
provisioning: 'Separate from source installation',
|
|
149
|
-
};
|
|
141
|
+
result = { stack: ANHEDRAL_STACK, resourcesProvisionedByCli: false };
|
|
150
142
|
else {
|
|
151
143
|
const root = projectRoot(process.cwd());
|
|
152
|
-
|
|
153
|
-
assertPublicWorkspace(root, false, 'stack');
|
|
144
|
+
assertPublicWorkspace(root, false, 'stack');
|
|
154
145
|
const e = new CapabilityEditor(root, {});
|
|
155
146
|
const state = readState(e);
|
|
156
|
-
|
|
157
|
-
const missing = CAPABILITIES[id].requires.filter((parent) => !state.installed.includes(parent));
|
|
158
|
-
const installed = state.installed.includes(id);
|
|
159
|
-
const missingFiles = installed
|
|
160
|
-
? CAPABILITIES[id].targets
|
|
161
|
-
.map((target) => target === 'apps/web/lib/auth-client.ts' &&
|
|
162
|
-
e.json('apps/web/package.json').dependencies?.['@tanstack/react-start']
|
|
163
|
-
? 'apps/web/src/lib/auth-client.ts'
|
|
164
|
-
: target)
|
|
165
|
-
.filter((target) => !existsSync(path.join(root, target)))
|
|
166
|
-
: [];
|
|
167
|
-
return {
|
|
168
|
-
id,
|
|
169
|
-
name: CAPABILITIES[id].name,
|
|
170
|
-
sourceState: installed
|
|
171
|
-
? missingFiles.length
|
|
172
|
-
? 'incomplete'
|
|
173
|
-
: 'installed'
|
|
174
|
-
: missing.length
|
|
175
|
-
? 'locked'
|
|
176
|
-
: 'available',
|
|
177
|
-
missingPrerequisites: missing,
|
|
178
|
-
missingFiles,
|
|
179
|
-
configuration: installed ? CAPABILITIES[id].configuration : [],
|
|
180
|
-
activation: 'not verified',
|
|
181
|
-
};
|
|
182
|
-
});
|
|
183
|
-
const foundationReady = existsSync(path.join(root, 'apps/web/package.json')) &&
|
|
184
|
-
!!(e.json('apps/web/package.json').dependencies?.next ||
|
|
185
|
-
e.json('apps/web/package.json').dependencies?.['@tanstack/react-start']);
|
|
186
|
-
const sourceReady = foundationReady && capabilities.every((c) => c.sourceState !== 'incomplete');
|
|
187
|
-
result = {
|
|
188
|
-
root,
|
|
189
|
-
foundationReady,
|
|
190
|
-
sourceReady,
|
|
191
|
-
capabilities,
|
|
192
|
-
runtimeAcceptance: 'not evaluated',
|
|
193
|
-
resourcesProvisionedByCli: false,
|
|
194
|
-
};
|
|
195
|
-
if (scope === 'public')
|
|
196
|
-
result = publicStackState(root, state);
|
|
147
|
+
result = publicStackState(root, state);
|
|
197
148
|
if (action === 'doctor' && !result.sourceReady)
|
|
198
149
|
process.exitCode = 1;
|
|
199
150
|
}
|
|
@@ -202,13 +153,12 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
202
153
|
if (!parsed.positional.length || parsed.positional.length > CAPABILITY_IDS.length)
|
|
203
154
|
throw commandArgumentError('add', 'Choose one or more capabilities from anhedral stack list.');
|
|
204
155
|
const root = projectRoot(process.cwd(), !parsed.has('--dry-run'));
|
|
205
|
-
|
|
206
|
-
assertPublicWorkspace(root, !parsed.has('--dry-run'));
|
|
156
|
+
assertPublicWorkspace(root, !parsed.has('--dry-run'));
|
|
207
157
|
if (!parsed.has('--dry-run') && existsSync(path.join(root, '.anhedral-journal.json')))
|
|
208
158
|
recoverInterruptedTransaction(root);
|
|
209
159
|
const e = new CapabilityEditor(root, {});
|
|
210
160
|
const state = readState(e);
|
|
211
|
-
|
|
161
|
+
{
|
|
212
162
|
assertPublicWorkspace(root);
|
|
213
163
|
if (state.installed.some((id) => !['hono', 'database-auth', 'r2', 'stripe'].includes(id)))
|
|
214
164
|
throw publicScopeError();
|
|
@@ -217,20 +167,11 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
217
167
|
const manifest = e.json('package.json');
|
|
218
168
|
if (typeof manifest.name !== 'string' || !manifest.name)
|
|
219
169
|
throw Error('The workspace needs a package name.');
|
|
220
|
-
if (!(e.json('apps/web/package.json').dependencies?.next ||
|
|
221
|
-
e.json('apps/web/package.json').dependencies?.['@tanstack/react-start']))
|
|
222
|
-
throw Error('An Anhedral Next.js or TanStack Start foundation is required.');
|
|
223
170
|
for (const id of state.installed)
|
|
224
|
-
for (const
|
|
225
|
-
const target = original === 'apps/web/lib/auth-client.ts' &&
|
|
226
|
-
e.json('apps/web/package.json').dependencies?.['@tanstack/react-start']
|
|
227
|
-
? 'apps/web/src/lib/auth-client.ts'
|
|
228
|
-
: original;
|
|
171
|
+
for (const target of CAPABILITIES[id].targets)
|
|
229
172
|
if (!existsSync(path.join(root, target)))
|
|
230
173
|
throw Error(`Installed capability is incomplete: ${id} (${target}). Reconcile its source first.`);
|
|
231
|
-
|
|
232
|
-
if (scope === 'public' &&
|
|
233
|
-
!parsed.has('--with-dependencies') &&
|
|
174
|
+
if (!parsed.has('--with-dependencies') &&
|
|
234
175
|
!parsed.positional.includes('backend') &&
|
|
235
176
|
!(state.installed.includes('hono') && state.installed.includes('database-auth')) &&
|
|
236
177
|
parsed.positional.some((id) => id === 'r2' || id === 'stripe'))
|
|
@@ -240,6 +181,10 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
240
181
|
];
|
|
241
182
|
const additions = capabilityOrder(requested, state.installed, parsed.has('--with-dependencies'));
|
|
242
183
|
const installed = [...state.installed, ...additions];
|
|
184
|
+
const beforeConfiguration = e.json('anhedral.json');
|
|
185
|
+
const metadataChanged = beforeConfiguration.setup?.cliVersion !== GENERATOR_VERSION ||
|
|
186
|
+
beforeConfiguration.composition?.generatorVersion !== GENERATOR_VERSION;
|
|
187
|
+
const foundationChanged = normalizeOjFoundation(e, state.installed, metadataChanged);
|
|
243
188
|
const composition = composeSourceProvenance(e.json('anhedral.json').composition, installed, additions);
|
|
244
189
|
for (const id of additions)
|
|
245
190
|
addCapabilityRecipe(e, id, manifest.name);
|
|
@@ -248,6 +193,9 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
248
193
|
if (e.read(file) === null)
|
|
249
194
|
e.create(file, source);
|
|
250
195
|
composeCapabilities(e, installed);
|
|
196
|
+
}
|
|
197
|
+
if (additions.length || foundationChanged || metadataChanged) {
|
|
198
|
+
e.set('anhedral.json', ['setup', 'cliVersion'], GENERATOR_VERSION);
|
|
251
199
|
e.set('anhedral.json', ['composition'], composition);
|
|
252
200
|
e.set('anhedral.json', ['capabilities'], {
|
|
253
201
|
schemaVersion: 1,
|
|
@@ -259,26 +207,18 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
259
207
|
const files = [...e.writes.keys()];
|
|
260
208
|
const plan = {
|
|
261
209
|
root,
|
|
262
|
-
added:
|
|
263
|
-
? PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].some((capability) => additions.includes(capability)))
|
|
264
|
-
: additions,
|
|
210
|
+
added: PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].some((capability) => additions.includes(capability))),
|
|
265
211
|
alreadyInstalled: parsed.positional.filter((id) => id === 'backend'
|
|
266
212
|
? state.installed.includes('hono') && state.installed.includes('database-auth')
|
|
267
213
|
: state.installed.includes(id)),
|
|
268
|
-
installed:
|
|
269
|
-
? PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].every((capability) => installed.includes(capability)))
|
|
270
|
-
: installed,
|
|
214
|
+
installed: PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].every((capability) => installed.includes(capability))),
|
|
271
215
|
files,
|
|
272
|
-
configuration:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
])),
|
|
279
|
-
],
|
|
280
|
-
}))
|
|
281
|
-
: additions.map((id) => ({ id, requirements: CAPABILITIES[id].configuration })),
|
|
216
|
+
configuration: PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].some((capability) => additions.includes(capability))).map((id) => ({
|
|
217
|
+
id,
|
|
218
|
+
requirements: [
|
|
219
|
+
...new Set(publicGroups[id].flatMap((capability) => [...CAPABILITIES[capability].configuration])),
|
|
220
|
+
],
|
|
221
|
+
})),
|
|
282
222
|
dryRun: parsed.has('--dry-run'),
|
|
283
223
|
resourcesProvisionedByCli: false,
|
|
284
224
|
activation: 'not verified',
|
|
@@ -324,16 +264,12 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
324
264
|
const format = () => {
|
|
325
265
|
if (command === 'add')
|
|
326
266
|
return `${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.`;
|
|
327
|
-
else
|
|
267
|
+
else {
|
|
328
268
|
const rows = parsed.positional[0] === 'list'
|
|
329
269
|
? PUBLIC_STACK_ADDITIONS.map((id) => `${id}\t${ANHEDRAL_STACK.additions[id].name}`)
|
|
330
270
|
: result.additions.map((item) => `${item.id}\t${item.sourceState}`);
|
|
331
271
|
return `${ANHEDRAL_STACK.name}\n${ANHEDRAL_STACK.foundation.name}\n${rows.join('\n')}\nSource state is not live provider activation.`;
|
|
332
272
|
}
|
|
333
|
-
else
|
|
334
|
-
return (result.capabilities
|
|
335
|
-
.map((item) => `${item.id}\t${item.sourceState ?? item.name}\t${item.requires?.join(', ') ?? ''}`)
|
|
336
|
-
.join('\n') + '\nSource state is not live provider activation.');
|
|
337
273
|
};
|
|
338
274
|
createReporter(output, format).result(result);
|
|
339
275
|
}
|
|
@@ -2,7 +2,7 @@ import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from './bounded-file.js';
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { existsSync, lstatSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { parse, modify, applyEdits } from 'jsonc-parser';
|
|
5
|
+
import { parse, visit, modify, applyEdits } from 'jsonc-parser';
|
|
6
6
|
export const fingerprint = (source) => createHash('sha256').update(source).digest('hex');
|
|
7
7
|
/** A bounded, read-only overlay until every capability has passed preflight. */
|
|
8
8
|
export class CapabilityEditor {
|
|
@@ -52,6 +52,26 @@ export class CapabilityEditor {
|
|
|
52
52
|
const value = parse(source, errors, { allowTrailingComma: true });
|
|
53
53
|
if (errors.length || !value || typeof value !== 'object' || Array.isArray(value))
|
|
54
54
|
throw Error(`Invalid JSON/JSONC in ${relative}.`);
|
|
55
|
+
// JSON modification targets the first property while runtime parsers use the last.
|
|
56
|
+
// Compare decoded keys in each object so escaped aliases cannot bypass this guard.
|
|
57
|
+
const objects = [];
|
|
58
|
+
let duplicate = false;
|
|
59
|
+
visit(source, {
|
|
60
|
+
onObjectBegin() {
|
|
61
|
+
objects.push(new Set());
|
|
62
|
+
},
|
|
63
|
+
onObjectProperty(property) {
|
|
64
|
+
const keys = objects.at(-1);
|
|
65
|
+
if (keys.has(property))
|
|
66
|
+
duplicate = true;
|
|
67
|
+
keys.add(property);
|
|
68
|
+
},
|
|
69
|
+
onObjectEnd() {
|
|
70
|
+
objects.pop();
|
|
71
|
+
},
|
|
72
|
+
}, { allowTrailingComma: true });
|
|
73
|
+
if (duplicate)
|
|
74
|
+
throw Error(`Duplicate JSON object keys in ${relative}; preserve and reconcile them before editing source.`);
|
|
55
75
|
return value;
|
|
56
76
|
}
|
|
57
77
|
create(relative, source) {
|