anhedral 0.11.1 → 0.12.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 (46) hide show
  1. package/README.md +126 -69
  2. package/dist/bin.js +48 -493
  3. package/dist/capabilities.d.ts +3 -3
  4. package/dist/capability-contract.js +4 -0
  5. package/dist/cli-arguments.d.ts +8 -0
  6. package/dist/cli-arguments.js +32 -0
  7. package/dist/cli-commands.d.ts +3 -0
  8. package/dist/cli-commands.js +114 -0
  9. package/dist/cli-delivery.d.ts +3 -0
  10. package/dist/cli-delivery.js +172 -0
  11. package/dist/cli-output.js +231 -205
  12. package/dist/delivery-evidence.d.ts +62 -0
  13. package/dist/delivery-evidence.js +186 -0
  14. package/dist/delivery.d.ts +3 -40
  15. package/dist/delivery.js +4 -181
  16. package/dist/dependencies.d.ts +1 -0
  17. package/dist/dependencies.js +2 -0
  18. package/dist/mobile-delivery.d.ts +21 -44
  19. package/dist/mobile-delivery.js +127 -80
  20. package/dist/provider-auth.js +3 -3
  21. package/dist/scaffold/documentation.js +1 -0
  22. package/dist/scaffold/stream.d.ts +2 -0
  23. package/dist/scaffold/stream.js +114 -0
  24. package/dist/service-readers.js +1 -1
  25. package/dist/services-command.js +8 -6
  26. package/dist/ship.d.ts +15 -15
  27. package/dist/stack-registry.d.ts +4 -2
  28. package/dist/stack-registry.js +16 -0
  29. package/dist/transaction-lock.d.ts +15 -0
  30. package/dist/transaction-lock.js +227 -0
  31. package/dist/transaction.js +2 -208
  32. package/dist/vercel-project.d.ts +101 -0
  33. package/dist/vercel-project.js +305 -0
  34. package/dist/vercel.d.ts +3 -36
  35. package/dist/vercel.js +3 -300
  36. package/dist/version.d.ts +1 -1
  37. package/dist/version.js +1 -1
  38. package/docs/software-factory.md +528 -0
  39. package/docs/stack-standard.md +196 -121
  40. package/docs/verification.md +444 -0
  41. package/package.json +3 -6
  42. package/docs/cli-design.md +0 -67
  43. package/docs/delivery-workflow.md +0 -98
  44. package/docs/plugin-ui.md +0 -102
  45. package/docs/provider-configuration.md +0 -116
  46. package/docs/void-verification.md +0 -185
@@ -0,0 +1,3 @@
1
+ import { type OutputOptions } from './cli-output.js';
2
+ /** Dispatch only after global help, output mode and working-directory handling. */
3
+ export declare function runCommand(command: string, args: string[], output: OutputOptions): Promise<void>;
@@ -0,0 +1,114 @@
1
+ import path from 'node:path';
2
+ import { commandArguments, commandArgumentError } from './cli-arguments.js';
3
+ import { printResult } from './cli-output.js';
4
+ import { DELIVERY_COMMANDS, runDelivery } from './cli-delivery.js';
5
+ import { runServiceCommand } from './services-command.js';
6
+ import { inspectApplication } from './project-inspector.js';
7
+ import { integrationStatus, recoverIntegrationResource } from './providers/recovery.js';
8
+ import { INTEGRATION_PROVIDERS } from './providers/config.js';
9
+ import { authenticateProviders } from './provider-auth.js';
10
+ import { setupRepository } from './repository.js';
11
+ import { inspectProviderReadiness } from './provider-readiness.js';
12
+ import { inspectProject } from './readiness.js';
13
+ import { parseStandardOptions, scaffoldStandardProject } from './standard.js';
14
+ import { runAdd, runRegistry } from './registry/commands.js';
15
+ function projectRoot(command, options) {
16
+ if (options.positional.length > 1)
17
+ throw commandArgumentError(command, 'Specify one application directory.');
18
+ return path.resolve(options.positional[0] ?? process.cwd());
19
+ }
20
+ async function runInspect(args, output) {
21
+ const options = commandArguments('inspect', args);
22
+ if (options.positional.length > 1)
23
+ throw commandArgumentError('inspect', 'Specify at most one project directory.');
24
+ printResult('inspect', inspectApplication(projectRoot('inspect', options)), output);
25
+ }
26
+ async function runIntegrations(args, output) {
27
+ const options = commandArguments('integrations', args);
28
+ const action = options.positional.shift();
29
+ const root = projectRoot('integrations', options);
30
+ if (action === 'status') {
31
+ if (['--provider', '--operation', '--resource'].some(options.has))
32
+ throw commandArgumentError('integrations', 'Integration status accepts no recovery options.');
33
+ printResult('integrations', integrationStatus(root), output);
34
+ return;
35
+ }
36
+ if (action !== 'recover')
37
+ throw commandArgumentError('integrations', 'Use integrations status or integrations recover.');
38
+ const provider = options.value('--provider');
39
+ const operation = options.value('--operation');
40
+ const resourceId = options.value('--resource');
41
+ if (!INTEGRATION_PROVIDERS.includes(provider) || !operation || !resourceId)
42
+ throw commandArgumentError('integrations', 'Recovery requires --provider, --operation and --resource.');
43
+ printResult('integrations', await recoverIntegrationResource(root, { provider, operation, resourceId }), output);
44
+ }
45
+ async function runAuth(args, output) {
46
+ const options = commandArguments('auth', args);
47
+ const result = await authenticateProviders(projectRoot('auth', options), {
48
+ provider: options.value('--provider'),
49
+ status: options.has('--status'),
50
+ interactive: !output.json &&
51
+ !output.quiet &&
52
+ !options.has('--non-interactive') &&
53
+ Boolean(process.stdin.isTTY),
54
+ });
55
+ printResult('auth', result, output);
56
+ if (!result.authenticated)
57
+ process.exitCode = 1;
58
+ }
59
+ async function runRepository(args, output) {
60
+ const options = commandArguments('repository', args);
61
+ const visibility = options.value('--visibility') ?? 'private';
62
+ if (visibility !== 'private' && visibility !== 'public')
63
+ throw commandArgumentError('repository', 'Visibility must be private or public.');
64
+ printResult('repository', await setupRepository(projectRoot('repository', options), {
65
+ owner: options.value('--owner'),
66
+ name: options.value('--name'),
67
+ visibility,
68
+ create: options.has('--create'),
69
+ }), output);
70
+ }
71
+ async function runDoctor(args, output) {
72
+ const options = commandArguments('doctor', args);
73
+ const root = projectRoot('doctor', options);
74
+ const report = options.has('--providers')
75
+ ? await inspectProviderReadiness(root)
76
+ : inspectProject(root);
77
+ printResult('doctor', report, output);
78
+ if (!report.localReady ||
79
+ ('prerequisitesReady' in report &&
80
+ (!report.prerequisitesReady || report.providerVerification !== 'verified-existing-context')))
81
+ process.exitCode = 1;
82
+ }
83
+ async function runInit(args, output) {
84
+ let options;
85
+ try {
86
+ options = parseStandardOptions(args);
87
+ }
88
+ catch (error) {
89
+ throw commandArgumentError('init', error instanceof Error ? error.message : String(error));
90
+ }
91
+ await scaffoldStandardProject(options, undefined, output);
92
+ }
93
+ const handlers = {
94
+ init: runInit,
95
+ inspect: runInspect,
96
+ integrations: runIntegrations,
97
+ auth: runAuth,
98
+ repository: runRepository,
99
+ doctor: runDoctor,
100
+ services: async (args, output) => printResult('services', await runServiceCommand(process.cwd(), args), output),
101
+ add: runAdd,
102
+ registry: (args, output) => runRegistry(args, Boolean(output.json), output),
103
+ ...Object.fromEntries(DELIVERY_COMMANDS.map((command) => [
104
+ command,
105
+ (args, output) => runDelivery(command, args, output),
106
+ ])),
107
+ };
108
+ /** Dispatch only after global help, output mode and working-directory handling. */
109
+ export async function runCommand(command, args, output) {
110
+ const handler = Object.hasOwn(handlers, command) ? handlers[command] : undefined;
111
+ if (!handler)
112
+ throw commandArgumentError(command, 'Unknown command. Run anhedral --help.');
113
+ await handler(args, output);
114
+ }
@@ -0,0 +1,3 @@
1
+ import { type OutputOptions } from './cli-output.js';
2
+ export declare const DELIVERY_COMMANDS: readonly ["register", "connect", "provision", "ship", "status", "manage", "verify", "rollback", "adopt", "recover"];
3
+ export declare function runDelivery(command: string, args: string[], output: OutputOptions): Promise<void>;
@@ -0,0 +1,172 @@
1
+ import path from 'node:path';
2
+ import { commandArguments, commandArgumentError } from './cli-arguments.js';
3
+ import { printResult } from './cli-output.js';
4
+ import { hasProjectSection, readProjectSection } from './project-config.js';
5
+ import { recoverDeliveryLock } from './project-state.js';
6
+ import { readLifecycleOperation } from './lifecycle.js';
7
+ import { buildMobileApplication } from './mobile-delivery.js';
8
+ import { shipCloudflareApplication, shipSelectedVercelApplication, shipSelectedStack, } from './ship.js';
9
+ import { planProvisioning, provisionApplication } from './provision.js';
10
+ import { writeManagementOverview } from './management.js';
11
+ import { registerApplication, connectApplication, applicationStatus, verifyApplication, rollbackApplication, recoverApplication, } from './delivery.js';
12
+ import { registerVercelApplication, connectVercelApplication, vercelApplicationStatus, verifyVercelApplication, rollbackVercelApplication, adoptVercelApplication, recoverVercelApplication, writeVercelOverview, } from './vercel.js';
13
+ export const DELIVERY_COMMANDS = [
14
+ 'register',
15
+ 'connect',
16
+ 'provision',
17
+ 'ship',
18
+ 'status',
19
+ 'manage',
20
+ 'verify',
21
+ 'rollback',
22
+ 'adopt',
23
+ 'recover',
24
+ ];
25
+ function deliveryOptions(command, args) {
26
+ const options = commandArguments(command, args);
27
+ const error = (message) => commandArgumentError(command, message);
28
+ if (options.positional.length > 1)
29
+ throw error('Specify at most one application directory.');
30
+ function choice(flag, choices, message) {
31
+ const value = options.value(flag);
32
+ if (value === undefined)
33
+ return undefined;
34
+ if (!choices.includes(value))
35
+ throw error(message);
36
+ return value;
37
+ }
38
+ return {
39
+ root: path.resolve(options.positional[0] ?? process.cwd()),
40
+ account: options.value('--account'),
41
+ audience: choice('--audience', ['public', 'private'], 'Specify --audience public or private.'),
42
+ emails: options.values('--allow-email'),
43
+ provider: choice('--provider', ['vercel', 'cloudflare'], 'Specify one provider: vercel or cloudflare.'),
44
+ scope: options.value('--scope'),
45
+ use: choice('--use', ['personal', 'commercial'], 'Specify --use personal or commercial.'),
46
+ create: options.has('--create'),
47
+ git: options.has('--git'),
48
+ platform: choice('--platform', ['ios', 'android'], 'Select one mobile platform.'),
49
+ profile: options.value('--profile'),
50
+ releaseId: options.value('--release'),
51
+ dryRun: options.has('--dry-run'),
52
+ refresh: options.has('--refresh'),
53
+ local: options.has('--local'),
54
+ lock: options.has('--lock'),
55
+ dataCompatible: options.has('--data-compatible'),
56
+ };
57
+ }
58
+ function isVercel(command, { root, provider }) {
59
+ if (provider)
60
+ return provider === 'vercel';
61
+ if (hasProjectSection(root, 'vercel'))
62
+ return true;
63
+ return (command === 'register' &&
64
+ hasProjectSection(root, 'setup') &&
65
+ readProjectSection(root, 'setup').hosting === 'vercel');
66
+ }
67
+ function releaseId(command, options) {
68
+ if (!options.releaseId)
69
+ throw commandArgumentError(command, 'Rollback requires --release <recorded-id>.');
70
+ return options.releaseId;
71
+ }
72
+ async function vercelCommand(command, options) {
73
+ const { root, account, emails, audience, use, scope, create, git, dryRun, refresh, local } = options;
74
+ if (account || emails.length)
75
+ throw commandArgumentError(command, 'Cloudflare account/member flags require --provider cloudflare.');
76
+ switch (command) {
77
+ case 'register':
78
+ return registerVercelApplication(root);
79
+ case 'connect':
80
+ if (!audience || !use)
81
+ throw commandArgumentError(command, 'Vercel connect requires --audience public|private and --use personal|commercial.');
82
+ return connectVercelApplication(root, { scope, audience, use, create, git });
83
+ case 'ship':
84
+ return shipSelectedVercelApplication(root, dryRun);
85
+ case 'adopt':
86
+ return adoptVercelApplication(root);
87
+ case 'recover':
88
+ return recoverVercelApplication(root);
89
+ case 'verify':
90
+ return verifyVercelApplication(root);
91
+ case 'rollback':
92
+ return rollbackVercelApplication(root, releaseId(command, options), options.dataCompatible);
93
+ case 'status':
94
+ return vercelApplicationStatus(root, refresh);
95
+ case 'manage': {
96
+ const snapshot = await vercelApplicationStatus(root, !local);
97
+ return { file: writeVercelOverview(root, snapshot), evidence: snapshot.evidence };
98
+ }
99
+ default:
100
+ throw commandArgumentError(command, 'Vercel project creation is handled by connect --create; Cloudflare resource provisioning requires --provider cloudflare.');
101
+ }
102
+ }
103
+ async function cloudflareCommand(command, options) {
104
+ const { root, account, audience, emails, scope, use, create, git, dryRun, refresh, local } = options;
105
+ if (scope || use || create || git)
106
+ throw commandArgumentError(command, 'Vercel connect options require a Vercel web manifest or --provider vercel.');
107
+ switch (command) {
108
+ case 'register':
109
+ return registerApplication(root);
110
+ case 'connect':
111
+ return connectApplication(root, account, audience, undefined, emails);
112
+ case 'provision':
113
+ return dryRun ? planProvisioning(root) : provisionApplication(root);
114
+ case 'ship':
115
+ return shipCloudflareApplication(root, dryRun);
116
+ case 'adopt':
117
+ throw commandArgumentError(command, 'Git deployment adoption requires --provider vercel.');
118
+ case 'recover':
119
+ return recoverApplication(root);
120
+ case 'verify':
121
+ return verifyApplication(root);
122
+ case 'rollback':
123
+ return rollbackApplication(root, releaseId(command, options), options.dataCompatible);
124
+ case 'manage': {
125
+ const snapshot = await applicationStatus(root, !local);
126
+ return { file: writeManagementOverview(root, snapshot), evidence: snapshot.evidence };
127
+ }
128
+ default:
129
+ return applicationStatus(root, refresh);
130
+ }
131
+ }
132
+ async function executeDelivery(command, options) {
133
+ const { root, provider, platform, profile, dryRun, lock, refresh } = options;
134
+ if (command === 'recover' && lock) {
135
+ if (provider || refresh)
136
+ throw commandArgumentError(command, 'Local lock recovery cannot be combined with provider recovery or --refresh.');
137
+ return { result: recoverDeliveryLock(root), blockedStates: [] };
138
+ }
139
+ if (platform || profile) {
140
+ if (!platform || !profile || provider)
141
+ throw commandArgumentError(command, 'Mobile shipping requires --platform and --profile, without --provider.');
142
+ return {
143
+ result: await buildMobileApplication(root, { platform, profile, dryRun }),
144
+ blockedStates: ['configuration-required', 'provider-configuration-required'],
145
+ };
146
+ }
147
+ // Resolve hosting before the mixed-stack path, retaining its configuration preflight.
148
+ const web = isVercel(command, options);
149
+ if (command === 'ship' && !provider)
150
+ return {
151
+ result: await shipSelectedStack(root, dryRun),
152
+ blockedStates: ['configuration-required', 'provider-configuration-required', 'partial'],
153
+ };
154
+ let result = await (web ? vercelCommand : cloudflareCommand)(command, options);
155
+ if (command === 'status')
156
+ result = { ...result, operation: readLifecycleOperation(root) };
157
+ return {
158
+ result,
159
+ blockedStates: web
160
+ ? ['provider-configuration-required']
161
+ : ['configuration-required', 'provider-configuration-required'],
162
+ };
163
+ }
164
+ export async function runDelivery(command, args, output) {
165
+ const { result, blockedStates } = await executeDelivery(command, deliveryOptions(command, args));
166
+ printResult(command, result, output);
167
+ if (result &&
168
+ typeof result === 'object' &&
169
+ 'state' in result &&
170
+ blockedStates.includes(String(result.state)))
171
+ process.exitCode = 1;
172
+ }