anhedral 0.17.0 → 0.19.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 +33 -68
- package/assets/contracts/LICENSE +201 -0
- package/assets/contracts/LICENSE.environment +201 -0
- package/assets/contracts/LICENSE.operations +201 -0
- package/assets/contracts/deployment-provenance.json +15 -0
- package/assets/contracts/environment-provenance.json +11 -0
- package/assets/contracts/operations-provenance.json +12 -0
- package/assets/launch/application.server.ts.txt +13 -0
- package/assets/launch/auth-client.ts.txt +4 -0
- package/assets/launch/home.tsx.txt +20 -0
- package/assets/launch/minimal-application.server.ts.txt +5 -0
- package/assets/launch/minimal-server.ts.txt +7 -0
- 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/request-context.ts.txt +3 -0
- package/assets/launch/root.tsx.txt +26 -0
- package/assets/launch/router.tsx.txt +21 -0
- package/assets/launch/server.ts.txt +15 -0
- package/assets/launch/sign-in.tsx.txt +53 -0
- package/assets/launch/styles.css.txt +19 -0
- package/assets/security/credential-patterns.d.mts +3 -0
- package/assets/security/credential-patterns.mjs +59 -0
- package/assets/stack/api-index.ts.txt +6 -1
- package/assets/stack/stripe.ts.txt +30 -13
- 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/bin.js +55 -36
- package/dist/capability-catalog.d.ts +36 -57
- package/dist/capability-catalog.js +65 -67
- package/dist/capability-command.d.ts +3 -3
- package/dist/capability-command.js +146 -59
- package/dist/capability-editor.js +6 -5
- package/dist/capability-recipes.js +9 -296
- package/dist/cli-arguments.d.ts +2 -0
- package/dist/cli-arguments.js +101 -50
- package/dist/cli-commands.d.ts +1 -1
- package/dist/cli-commands.js +31 -5
- package/dist/cli-errors.d.ts +18 -0
- package/dist/cli-errors.js +63 -0
- package/dist/cli-output.d.ts +22 -0
- package/dist/cli-output.js +42 -7
- package/dist/command-runner.js +88 -0
- package/dist/command-schema.d.ts +16 -0
- package/dist/command-schema.js +496 -21
- package/dist/command-types.d.ts +1 -0
- package/dist/command-types.js +1 -0
- package/dist/completion.d.ts +2 -0
- package/dist/completion.js +201 -0
- package/dist/composition.d.ts +25 -0
- package/dist/composition.js +28 -0
- package/dist/contracts/cli-transport.d.ts +316 -0
- package/dist/contracts/cli-transport.js +236 -0
- package/dist/contracts/deployment.d.ts +233 -0
- package/dist/contracts/deployment.js +198 -0
- package/dist/contracts/environment-file.d.ts +7 -0
- package/dist/contracts/environment-file.js +112 -0
- package/dist/contracts/environment-transport.d.ts +79 -0
- package/dist/contracts/environment-transport.js +110 -0
- package/dist/contracts/production-transport.d.ts +71 -0
- package/dist/contracts/production-transport.js +56 -0
- package/dist/contracts/runtime-logs-transport.d.ts +127 -0
- package/dist/contracts/runtime-logs-transport.js +50 -0
- package/dist/contracts/source-bundle.d.ts +11 -0
- package/dist/contracts/source-bundle.js +197 -0
- package/dist/contracts/source-profile.d.ts +4 -0
- package/dist/contracts/source-profile.js +5 -0
- package/dist/contracts/staging-transport.d.ts +79 -0
- package/dist/contracts/staging-transport.js +43 -0
- package/dist/dependencies.d.ts +9 -27
- package/dist/dependencies.js +19 -66
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/launch.d.ts +27 -0
- package/dist/launch.js +262 -0
- package/dist/platform-command.d.ts +9 -0
- package/dist/platform-command.js +787 -0
- package/dist/platform-environment.d.ts +18 -0
- package/dist/platform-environment.js +257 -0
- package/dist/platform-operations.d.ts +26 -0
- package/dist/platform-operations.js +155 -0
- package/dist/platform-production.d.ts +16 -0
- package/dist/platform-production.js +135 -0
- package/dist/platform-source.d.ts +8 -0
- package/dist/platform-source.js +111 -0
- package/dist/platform-state.d.ts +15 -0
- package/dist/platform-state.js +229 -0
- package/dist/platforms/tanstack.d.ts +10 -0
- package/dist/platforms/tanstack.js +248 -0
- package/dist/registry/usage.d.ts +4 -1
- package/dist/registry/usage.js +59 -4
- package/dist/scaffold/bootstrap.d.ts +3 -3
- package/dist/scaffold/styling.d.ts +3 -2
- package/dist/transaction.js +28 -3
- package/dist/ui-catalog.d.ts +3 -5
- package/dist/ui-catalog.js +8 -24
- package/dist/ui-command.d.ts +3 -1
- package/dist/ui-command.js +74 -72
- package/dist/ui-project.d.ts +4 -2
- package/dist/ui-project.js +40 -38
- package/dist/util.js +40 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +23 -89
- package/docs/software-factory.md +208 -9
- package/docs/stack-standard.md +7 -17
- package/docs/ui.md +9 -22
- package/package.json +26 -22
- 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/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 -44
- 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 -131
- 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 -94
- package/dist/workspace-graph.d.ts +0 -7
- package/dist/workspace-graph.js +0 -74
- package/docs/anhedral-stack.md +0 -12
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/native-ui.md +0 -47
- /package/dist/{registry/types.js → command-runner.d.ts} +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
|
+
`;
|
package/dist/bin.js
CHANGED
|
@@ -3,22 +3,53 @@ import { argv } from 'node:process';
|
|
|
3
3
|
import { runCommand } from './cli-commands.js';
|
|
4
4
|
import { STANDARD_USAGE, commandHelp } from './registry/usage.js';
|
|
5
5
|
import { GENERATOR_VERSION } from './version.js';
|
|
6
|
-
import {
|
|
6
|
+
import { describeFailure } from './cli-errors.js';
|
|
7
|
+
import { commandDefinition, GLOBAL_OPTIONS } from './command-schema.js';
|
|
7
8
|
import { CliArgumentError, globalArguments, inlineArguments, validateCommand, } from './cli-arguments.js';
|
|
8
|
-
|
|
9
|
-
let
|
|
9
|
+
const input = argv.slice(2);
|
|
10
|
+
let [command, ...args] = input;
|
|
11
|
+
const separator = input.indexOf('--');
|
|
12
|
+
let json = input.slice(0, separator < 0 ? undefined : separator).includes('--json');
|
|
13
|
+
function beforeSeparator(values) {
|
|
14
|
+
const end = values.indexOf('--');
|
|
15
|
+
return values.slice(0, end < 0 ? undefined : end);
|
|
16
|
+
}
|
|
10
17
|
function helpRequested() {
|
|
11
18
|
return ([undefined, '--help', '-h', 'help'].includes(command) ||
|
|
12
|
-
args.
|
|
13
|
-
args.includes('-h'));
|
|
19
|
+
beforeSeparator(args).some((arg) => arg === '--help' || arg === '-h'));
|
|
14
20
|
}
|
|
15
21
|
function printHelp() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
let topics = [];
|
|
23
|
+
if (command === 'help') {
|
|
24
|
+
topics = beforeSeparator(args).filter((arg) => !['--json', '--help', '-h'].includes(arg));
|
|
25
|
+
}
|
|
26
|
+
else if (command && !['--help', '-h'].includes(command)) {
|
|
27
|
+
topics = [command];
|
|
28
|
+
let definition = commandDefinition(command);
|
|
29
|
+
const options = [...(definition?.options ?? []), ...GLOBAL_OPTIONS];
|
|
30
|
+
const values = beforeSeparator(args);
|
|
31
|
+
let leafArguments = 0;
|
|
32
|
+
for (let index = 0; index < values.length; index++) {
|
|
33
|
+
const value = values[index];
|
|
34
|
+
if (value.startsWith('-')) {
|
|
35
|
+
const option = options.find((item) => item.flag === value || item.aliases?.includes(value));
|
|
36
|
+
if (option?.arity && values[index + 1] && !values[index + 1].startsWith('-'))
|
|
37
|
+
index++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (!definition?.children) {
|
|
41
|
+
leafArguments++;
|
|
42
|
+
if (leafArguments > (definition?.positional?.max ?? 0))
|
|
43
|
+
throw new CliArgumentError('Unknown help topic.', `Run anhedral ${topics.join(' ')} --help.`);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
topics.push(value);
|
|
47
|
+
definition = definition.children[value];
|
|
48
|
+
if (!definition)
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const help = topics.length ? commandHelp(topics) : STANDARD_USAGE;
|
|
22
53
|
if (!help)
|
|
23
54
|
throw new CliArgumentError('Unknown help topic.', 'Run anhedral --help.');
|
|
24
55
|
console.log(json ? JSON.stringify({ usage: help }) : help);
|
|
@@ -32,11 +63,13 @@ function selectDirectory(directory) {
|
|
|
32
63
|
}
|
|
33
64
|
}
|
|
34
65
|
async function main() {
|
|
35
|
-
const global = globalArguments(
|
|
66
|
+
const global = globalArguments(input);
|
|
36
67
|
[command, ...args] = global.args;
|
|
37
68
|
json = global.json;
|
|
38
|
-
if (json)
|
|
39
|
-
args.
|
|
69
|
+
if (json) {
|
|
70
|
+
const end = args.indexOf('--');
|
|
71
|
+
args.splice(end < 0 ? args.length : end, 0, '--json');
|
|
72
|
+
}
|
|
40
73
|
args = inlineArguments(command, args);
|
|
41
74
|
if (helpRequested())
|
|
42
75
|
return printHelp();
|
|
@@ -51,32 +84,18 @@ async function main() {
|
|
|
51
84
|
process.env.ANHEDRAL_QUIET = '1';
|
|
52
85
|
if (global.verbose && !json && !global.quiet)
|
|
53
86
|
process.env.ANHEDRAL_VERBOSE = '1';
|
|
54
|
-
await runCommand(command, args, {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return 'POST_COMMIT_FAILED';
|
|
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';
|
|
87
|
+
await runCommand(command, args, {
|
|
88
|
+
json,
|
|
89
|
+
quiet: global.quiet,
|
|
90
|
+
human: global.human,
|
|
91
|
+
nonInteractive: global.nonInteractive,
|
|
92
|
+
});
|
|
68
93
|
}
|
|
69
94
|
try {
|
|
70
95
|
await main();
|
|
71
96
|
}
|
|
72
97
|
catch (error) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const nextAction = error instanceof CliArgumentError
|
|
76
|
-
? error.nextAction
|
|
77
|
-
: `Run anhedral ${command && commandHelp(command) ? command + ' ' : ''}--help.`;
|
|
78
|
-
console.error(json
|
|
79
|
-
? JSON.stringify({ error: message, code, nextAction })
|
|
80
|
-
: `Error: ${message}\nNext: ${nextAction}`);
|
|
98
|
+
const failure = describeFailure(error, command);
|
|
99
|
+
console.error(json ? JSON.stringify(failure) : `Error: ${failure.error}\nNext: ${failure.nextAction}`);
|
|
81
100
|
process.exitCode = 1;
|
|
82
101
|
}
|
|
@@ -2,13 +2,13 @@ export declare const CAPABILITIES: {
|
|
|
2
2
|
readonly hono: {
|
|
3
3
|
readonly name: "Hono backend API";
|
|
4
4
|
readonly requires: readonly [];
|
|
5
|
-
readonly targets: readonly ["apps/api"];
|
|
5
|
+
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"];
|
|
6
6
|
readonly configuration: readonly ["ANHEDRAL_API service binding"];
|
|
7
7
|
};
|
|
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", "apps/api/src/auth.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: {
|
|
@@ -20,64 +20,43 @@ export declare const CAPABILITIES: {
|
|
|
20
20
|
readonly stripe: {
|
|
21
21
|
readonly name: "Stripe payments";
|
|
22
22
|
readonly requires: readonly ["database-auth"];
|
|
23
|
-
readonly targets: readonly ["apps/api/src/features/stripe.ts"];
|
|
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"];
|
|
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
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[];
|
|
30
|
+
/** The sole source composition, extended only by backend, storage and payments. */
|
|
31
|
+
export declare const ANHEDRAL_STACK: {
|
|
32
|
+
readonly schemaVersion: 1;
|
|
33
|
+
readonly id: "anhedral-stack";
|
|
34
|
+
readonly name: "Anhedral Stack";
|
|
35
|
+
readonly foundation: {
|
|
36
|
+
readonly id: "tanstack-start";
|
|
37
|
+
readonly name: "TanStack Start + Anhedral UI";
|
|
38
|
+
readonly targets: readonly ["apps/web/package.json", "apps/web/src/router.tsx", "apps/web/src/server.ts", "apps/web/src/routes/__root.tsx", "apps/web/src/routes/index.tsx"];
|
|
39
|
+
};
|
|
40
|
+
readonly additions: {
|
|
41
|
+
readonly backend: {
|
|
42
|
+
readonly name: "Backend";
|
|
43
|
+
readonly description: "API, database and authentication together.";
|
|
44
|
+
readonly requires: string[];
|
|
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"];
|
|
46
|
+
};
|
|
47
|
+
readonly r2: {
|
|
48
|
+
readonly name: "Private storage";
|
|
49
|
+
readonly description: "Authenticated, owner-scoped object storage.";
|
|
50
|
+
readonly requires: readonly ["backend"];
|
|
51
|
+
readonly targets: readonly ["apps/api/src/features/storage.ts"];
|
|
52
|
+
};
|
|
53
|
+
readonly stripe: {
|
|
54
|
+
readonly name: "Payments and subscriptions";
|
|
55
|
+
readonly description: "Stripe subscription and entitlement source.";
|
|
56
|
+
readonly requires: readonly ["backend"];
|
|
57
|
+
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"];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export type PublicStackAddition = keyof typeof ANHEDRAL_STACK.additions;
|
|
62
|
+
export declare const PUBLIC_STACK_ADDITIONS: PublicStackAddition[];
|
|
@@ -2,13 +2,30 @@ export const CAPABILITIES = {
|
|
|
2
2
|
hono: {
|
|
3
3
|
name: 'Hono backend API',
|
|
4
4
|
requires: [],
|
|
5
|
-
targets: [
|
|
5
|
+
targets: [
|
|
6
|
+
'apps/api/package.json',
|
|
7
|
+
'apps/api/wrangler.jsonc',
|
|
8
|
+
'apps/api/src/index.ts',
|
|
9
|
+
'apps/api/src/environment.ts',
|
|
10
|
+
'apps/api/src/capabilities.ts',
|
|
11
|
+
'apps/api/src/custom-environment.ts',
|
|
12
|
+
],
|
|
6
13
|
configuration: ['ANHEDRAL_API service binding'],
|
|
7
14
|
},
|
|
8
15
|
'database-auth': {
|
|
9
16
|
name: 'Drizzle / D1 / Better Auth',
|
|
10
17
|
requires: ['hono'],
|
|
11
|
-
targets: [
|
|
18
|
+
targets: [
|
|
19
|
+
'packages/db/package.json',
|
|
20
|
+
'packages/db/src/index.ts',
|
|
21
|
+
'packages/db/src/schema.ts',
|
|
22
|
+
'apps/api/src/auth.ts',
|
|
23
|
+
'apps/api/src/auth-features.ts',
|
|
24
|
+
'apps/api/src/security.ts',
|
|
25
|
+
'apps/api/src/auth-platform.ts',
|
|
26
|
+
'apps/api/src/features/auth.ts',
|
|
27
|
+
'apps/web/src/lib/auth-client.ts',
|
|
28
|
+
],
|
|
12
29
|
configuration: [
|
|
13
30
|
'D1 resource ID',
|
|
14
31
|
'BETTER_AUTH_SECRET',
|
|
@@ -26,7 +43,14 @@ export const CAPABILITIES = {
|
|
|
26
43
|
stripe: {
|
|
27
44
|
name: 'Stripe payments',
|
|
28
45
|
requires: ['database-auth'],
|
|
29
|
-
targets: [
|
|
46
|
+
targets: [
|
|
47
|
+
'apps/api/src/features/stripe.ts',
|
|
48
|
+
'apps/api/src/features/entitlements.ts',
|
|
49
|
+
'apps/api/src/entitlement-guard.ts',
|
|
50
|
+
'apps/api/src/billing-mode.ts',
|
|
51
|
+
'apps/api/src/billing-providers.ts',
|
|
52
|
+
'packages/db/src/billing-schema.ts',
|
|
53
|
+
],
|
|
30
54
|
configuration: [
|
|
31
55
|
'Stripe test credentials',
|
|
32
56
|
'allowed prices',
|
|
@@ -34,70 +58,6 @@ export const CAPABILITIES = {
|
|
|
34
58
|
'billing schema migration',
|
|
35
59
|
],
|
|
36
60
|
},
|
|
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
61
|
};
|
|
102
62
|
export const CAPABILITY_IDS = Object.keys(CAPABILITIES);
|
|
103
63
|
export function capabilityOrder(requested, installed, includeDependencies) {
|
|
@@ -119,3 +79,41 @@ export function capabilityOrder(requested, installed, includeDependencies) {
|
|
|
119
79
|
visit(id);
|
|
120
80
|
return [...selected];
|
|
121
81
|
}
|
|
82
|
+
/** The sole source composition, extended only by backend, storage and payments. */
|
|
83
|
+
export const ANHEDRAL_STACK = {
|
|
84
|
+
schemaVersion: 1,
|
|
85
|
+
id: 'anhedral-stack',
|
|
86
|
+
name: 'Anhedral Stack',
|
|
87
|
+
foundation: {
|
|
88
|
+
id: 'tanstack-start',
|
|
89
|
+
name: 'TanStack Start + Anhedral UI',
|
|
90
|
+
targets: [
|
|
91
|
+
'apps/web/package.json',
|
|
92
|
+
'apps/web/src/router.tsx',
|
|
93
|
+
'apps/web/src/server.ts',
|
|
94
|
+
'apps/web/src/routes/__root.tsx',
|
|
95
|
+
'apps/web/src/routes/index.tsx',
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
additions: {
|
|
99
|
+
backend: {
|
|
100
|
+
name: 'Backend',
|
|
101
|
+
description: 'API, database and authentication together.',
|
|
102
|
+
requires: [],
|
|
103
|
+
targets: [...CAPABILITIES.hono.targets, ...CAPABILITIES['database-auth'].targets],
|
|
104
|
+
},
|
|
105
|
+
r2: {
|
|
106
|
+
name: 'Private storage',
|
|
107
|
+
description: 'Authenticated, owner-scoped object storage.',
|
|
108
|
+
requires: ['backend'],
|
|
109
|
+
targets: [...CAPABILITIES.r2.targets],
|
|
110
|
+
},
|
|
111
|
+
stripe: {
|
|
112
|
+
name: 'Payments and subscriptions',
|
|
113
|
+
description: 'Stripe subscription and entitlement source.',
|
|
114
|
+
requires: ['backend'],
|
|
115
|
+
targets: [...CAPABILITIES.stripe.targets],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
export const PUBLIC_STACK_ADDITIONS = Object.keys(ANHEDRAL_STACK.additions);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
export declare function runCapabilityCommand(command: 'add' | 'stack', args: string[], output: OutputOptions, run?:
|
|
1
|
+
import { type OutputOptions } from './cli-output.js';
|
|
2
|
+
import type { CommandRunner } from './command-types.js';
|
|
3
|
+
export declare function runCapabilityCommand(command: 'add' | 'stack', args: string[], output: OutputOptions, run?: CommandRunner): Promise<void>;
|