afyx-engineering-kit 0.0.0-stage → 0.1.0-alpha.3
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/.afyx-source-revision +1 -0
- package/LICENSE +21 -0
- package/README.md +377 -2
- package/SECURITY.md +74 -0
- package/afyx-context/LICENSE +21 -0
- package/afyx-context/README.md +155 -0
- package/afyx-context/afyx-context.json +30 -0
- package/afyx-context/contracts/integration-v1.schema.json +34 -0
- package/afyx-context/package-lock.json +53 -0
- package/afyx-context/package.json +34 -0
- package/afyx-context/scripts/benchmark.mjs +39 -0
- package/afyx-context/scripts/build.mjs +15 -0
- package/afyx-context/scripts/comparative-benchmark.mjs +342 -0
- package/afyx-context/scripts/comparative-worker.mjs +74 -0
- package/afyx-context/scripts/graph-integration-e2e.mjs +188 -0
- package/afyx-context/scripts/integrated-dogfood.mjs +309 -0
- package/afyx-context/src/budget.js +166 -0
- package/afyx-context/src/cli.js +110 -0
- package/afyx-context/src/coordination.js +343 -0
- package/afyx-context/src/engine.js +198 -0
- package/afyx-context/src/errors.js +14 -0
- package/afyx-context/src/graph-integration-worker.js +70 -0
- package/afyx-context/src/graph-integration.js +373 -0
- package/afyx-context/src/graph-mcp-bridge.js +103 -0
- package/afyx-context/src/index.js +25 -0
- package/afyx-context/src/integrations.js +87 -0
- package/afyx-context/src/memory.js +255 -0
- package/afyx-context/src/storage.js +364 -0
- package/afyx-context/test-fixtures/coordination-worker.mjs +52 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__init__.py +1 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__manifest__.py +4 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/__init__.py +1 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/sale_order.py +5 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__init__.py +1 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__manifest__.py +10 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/__init__.py +2 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order.py +20 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order_audit.py +11 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/security/ir.model.access.csv +2 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/views/sale_order_views.xml +14 -0
- package/afyx-forge/LICENSE +55 -0
- package/afyx-forge/README.md +126 -0
- package/afyx-forge/afyx-forge.json +28 -0
- package/afyx-forge/bin/afyx-forge +4 -0
- package/afyx-forge/bin/afyx-forge.cmd +3 -0
- package/afyx-forge/bin/afyx-forge.js +16 -0
- package/afyx-forge/contracts/forge-plan-v1.schema.json +172 -0
- package/afyx-forge/package.json +26 -0
- package/afyx-forge/src/classifier.js +190 -0
- package/afyx-forge/src/cli.js +111 -0
- package/afyx-forge/src/doctor.js +105 -0
- package/afyx-forge/src/guidance.js +120 -0
- package/afyx-forge/src/index.js +273 -0
- package/afyx-forge/src/planning.js +107 -0
- package/afyx-forge/src/policy.js +109 -0
- package/afyx-forge/src/workflow-refiner.js +151 -0
- package/afyx-graph/afyx-graph.json +20 -0
- package/afyx-graph/engine/LICENSE +21 -0
- package/afyx-graph/engine/README.md +104 -0
- package/afyx-graph/engine/release/RELEASE-MANIFEST.json +21 -0
- package/afyx-graph/engine/release/SHA256SUMS +2 -0
- package/afyx-graph/engine/release/afyx-graph-linux-x64.tar.gz +0 -0
- package/afyx-graph/engine/release/afyx-graph-win32-x64.zip +0 -0
- package/afyx-graph/engine/scripts/distribution-contract.mjs +212 -0
- package/afyx-graph/engine/scripts/distribution-product.json +33 -0
- package/bin/afyx-engineering-kit.mjs +61 -0
- package/install.ps1 +1053 -0
- package/install.sh +617 -0
- package/package.json +66 -4
- package/scripts/afyx-capability-orchestrator.mjs +752 -0
- package/scripts/afyx-claude-integration.mjs +547 -0
- package/scripts/afyx-context-artifact.mjs +105 -0
- package/scripts/afyx-credential-broker.mjs +75 -0
- package/scripts/afyx-doctor.ps1 +152 -0
- package/scripts/afyx-doctor.sh +146 -0
- package/scripts/afyx-forge-artifact.mjs +183 -0
- package/scripts/afyx-global-routing-policy.md +12 -0
- package/scripts/afyx-global-routing.mjs +168 -0
- package/scripts/afyx-graph-artifact.mjs +178 -0
- package/scripts/afyx-host-adapters.mjs +543 -0
- package/scripts/afyx-host-bridge-lifecycle.mjs +174 -0
- package/scripts/afyx-host-bridge.mjs +288 -0
- package/scripts/afyx-integration-contracts.mjs +825 -0
- package/scripts/afyx-mcp-integration.mjs +528 -0
- package/scripts/afyx-modular-integration.mjs +361 -0
- package/scripts/afyx-modular-runtime.mjs +451 -0
- package/scripts/afyx-native-skill-host.mjs +124 -0
- package/scripts/afyx-npm-installer.mjs +486 -0
- package/scripts/afyx-project.ps1 +205 -0
- package/scripts/afyx-project.sh +207 -0
- package/scripts/afyx-provider-backup.mjs +1206 -0
- package/scripts/afyx-provider-integration.mjs +724 -0
- package/scripts/afyx-provider-inventory.mjs +147 -0
- package/scripts/afyx-security-auditor.mjs +224 -0
- package/scripts/afyx-skill-engineering.mjs +354 -0
- package/scripts/afyx-tool-family-routing.mjs +64 -0
- package/scripts/afyx-universal-runtime.mjs +530 -0
- package/scripts/alpha_acceptance_preflight.py +240 -0
- package/scripts/benchmark-graph-memory.mjs +96 -0
- package/scripts/benchmark_capability_orchestrator.mjs +64 -0
- package/scripts/build-windows-installer.ps1 +259 -0
- package/scripts/build_forge_synthetic_image.py +328 -0
- package/scripts/check-reference-staleness.py +71 -0
- package/scripts/components.json +254 -0
- package/scripts/contracts/afyx-capability-request-v1.schema.json +189 -0
- package/scripts/contracts/afyx-capability-result-v1.schema.json +32 -0
- package/scripts/dogfood_engineering_comparison.mjs +303 -0
- package/scripts/engineering-assurance.json +28 -0
- package/scripts/install-afyx-context.ps1 +142 -0
- package/scripts/install-afyx-context.sh +126 -0
- package/scripts/install-afyx-forge.ps1 +265 -0
- package/scripts/install-afyx-forge.sh +273 -0
- package/scripts/install-afyx-graph.ps1 +571 -0
- package/scripts/install-afyx-graph.sh +438 -0
- package/scripts/install-codex-usage-tracker.ps1 +172 -0
- package/scripts/lib/AfyxComponents.psm1 +399 -0
- package/scripts/lib/AfyxSkillLifecycle.psm1 +289 -0
- package/scripts/lib/AfyxTerminal.psm1 +838 -0
- package/scripts/lib/afyx-components.sh +256 -0
- package/scripts/lib/afyx-skill-lifecycle.sh +271 -0
- package/scripts/link-global-dev.ps1 +193 -0
- package/scripts/link-global-dev.sh +130 -0
- package/scripts/phase8-paired-evidence.mjs +195 -0
- package/scripts/phase8-representative-workload.mjs +771 -0
- package/scripts/phase8-session-recorder.mjs +157 -0
- package/scripts/phase8_event_ledger.py +248 -0
- package/scripts/phase8_evidence_discovery.py +189 -0
- package/scripts/prepare-g6-package.mjs +349 -0
- package/scripts/resolve-git-release-artifacts.mjs +321 -0
- package/scripts/stage-npm-release.mjs +94 -0
- package/scripts/validate-afyx-graph.py +203 -0
- package/scripts/validate-components.py +194 -0
- package/scripts/validate-engineering-assurance.py +281 -0
- package/scripts/verify-graph-archive.mjs +64 -0
- package/skills/afyx-context/SKILL.md +26 -0
- package/skills/afyx-engineering-expert/README.md +42 -0
- package/skills/afyx-engineering-expert/SKILL.md +70 -0
- package/skills/afyx-engineering-expert/assets/result-template.md +15 -0
- package/skills/afyx-engineering-expert/references/ai-ml-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/business-analyst.md +17 -0
- package/skills/afyx-engineering-expert/references/clean-code-engineer.md +26 -0
- package/skills/afyx-engineering-expert/references/code-reviewer.md +24 -0
- package/skills/afyx-engineering-expert/references/cybersecurity-devsecops.md +17 -0
- package/skills/afyx-engineering-expert/references/data-analyst-bi.md +24 -0
- package/skills/afyx-engineering-expert/references/data-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/database-administrator.md +17 -0
- package/skills/afyx-engineering-expert/references/debugging-specialist.md +24 -0
- package/skills/afyx-engineering-expert/references/embedded-iot-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/erp-technical-specialist.md +17 -0
- package/skills/afyx-engineering-expert/references/hardware-diagnostics-auditor.md +24 -0
- package/skills/afyx-engineering-expert/references/hardware-electronics-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/integration-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/legacy-modernization-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/llmops-prompt-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/network-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/performance-benchmark-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/platform-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/product-manager.md +17 -0
- package/skills/afyx-engineering-expert/references/qa-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/site-reliability-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/software-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/solutions-architect.md +17 -0
- package/skills/afyx-engineering-expert/references/specialists-index.md +33 -0
- package/skills/afyx-engineering-expert/references/subject-matter-expert.md +17 -0
- package/skills/afyx-engineering-expert/references/system-analyst.md +17 -0
- package/skills/afyx-engineering-expert/references/technical-project-manager.md +24 -0
- package/skills/afyx-engineering-expert/references/technical-writer.md +24 -0
- package/skills/afyx-engineering-expert/references/ui-ux-designer.md +17 -0
- package/skills/afyx-engineering-expert/workflows/ai-data-erp.md +20 -0
- package/skills/afyx-engineering-expert/workflows/debugging.md +10 -0
- package/skills/afyx-engineering-expert/workflows/discovery-design.md +11 -0
- package/skills/afyx-engineering-expert/workflows/implementation.md +12 -0
- package/skills/afyx-engineering-expert/workflows/incident-reliability.md +12 -0
- package/skills/afyx-engineering-expert/workflows/review-audit.md +13 -0
- package/skills/afyx-forge/SKILL.md +43 -0
- package/skills/afyx-forge/references/adaptive-policy.md +19 -0
- package/skills/efficient-coding/SKILL.md +33 -0
- package/skills/efficient-coding/references/investigation.md +27 -0
- package/skills/efficient-coding/references/token-efficiency.md +25 -0
- package/skills/efficient-coding/references/tool-routing.md +13 -0
- package/skills/odoo-engineering/SKILL.md +33 -0
- package/skills/odoo-engineering/references/common.md +9 -0
- package/skills/odoo-engineering/references/odoo-10.md +32 -0
- package/skills/odoo-engineering/references/odoo-11.md +26 -0
- package/skills/odoo-engineering/references/odoo-12.md +31 -0
- package/skills/odoo-engineering/references/odoo-13.md +27 -0
- package/skills/odoo-engineering/references/odoo-14.md +31 -0
- package/skills/odoo-engineering/references/odoo-15.md +34 -0
- package/skills/odoo-engineering/references/odoo-16.md +37 -0
- package/skills/odoo-engineering/references/odoo-17.md +37 -0
- package/skills/odoo-engineering/references/odoo-18.md +48 -0
- package/skills/odoo-engineering/references/odoo-19.md +43 -0
- package/skills/odoo-engineering/references/odoo-20.md +39 -0
- package/skills/odoo-engineering/references/reference-schema.md +16 -0
- package/skills/odoo-engineering/references/version-detection.md +13 -0
- package/tools/codex-usage/CodexUsage.psm1 +496 -0
- package/tools/codex-usage/codex-usage-doctor.ps1 +150 -0
- package/tools/codex-usage/codex-usage-pricing.json +25 -0
- package/tools/codex-usage/codex-usage-stop.ps1 +167 -0
- package/tools/codex-usage/codex-usage-watch.ps1 +250 -0
- package/tools/codex-usage/vscode-user-task.json +31 -0
- package/tools/windows-setup/SetupBootstrapper.cs +258 -0
- package/uninstall.ps1 +189 -0
- package/uninstall.sh +167 -0
- package/update.ps1 +95 -0
- package/update.sh +67 -0
- package/verify.ps1 +411 -0
- package/verify.sh +265 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AFYX Universal Cross-Platform npm CLI Installer (Core Adapter)
|
|
5
|
+
*
|
|
6
|
+
* Exposes universal CLI entrypoint for AFYX Engineering Kit across Windows, Linux, and macOS.
|
|
7
|
+
* Bridges npm invocation to underlying PowerShell/Bash lifecycle scripts with hardened
|
|
8
|
+
* per-command argument allowlists, safety enforcement, deterministic fallback,
|
|
9
|
+
* and clear packaged component asset boundaries.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
13
|
+
import { dirname, join, resolve } from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { spawn } from 'node:child_process';
|
|
16
|
+
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = dirname(__filename);
|
|
19
|
+
export const PACKAGE_ROOT = resolve(__dirname, '..');
|
|
20
|
+
|
|
21
|
+
let cachedVersion = null;
|
|
22
|
+
export function getPackageVersion() {
|
|
23
|
+
if (cachedVersion) return cachedVersion;
|
|
24
|
+
try {
|
|
25
|
+
const pkgJsonPath = join(PACKAGE_ROOT, 'package.json');
|
|
26
|
+
if (existsSync(pkgJsonPath)) {
|
|
27
|
+
const data = JSON.parse(readFileSync(pkgJsonPath, 'utf8'));
|
|
28
|
+
cachedVersion = data.version || '0.1.0-alpha.1';
|
|
29
|
+
return cachedVersion;
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// fallback
|
|
33
|
+
}
|
|
34
|
+
return '0.1.0-alpha.1';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const SUPPORTED_COMMANDS = ['install', 'verify', 'doctor', 'update', 'uninstall'];
|
|
38
|
+
|
|
39
|
+
// Explicit per-command option allowlist
|
|
40
|
+
export const COMMAND_ALLOWED_OPTIONS = {
|
|
41
|
+
install: new Set([
|
|
42
|
+
'preset', 'provider', 'providerScope', 'workspaceRoot', 'skillsRoot',
|
|
43
|
+
'contextRuntimeRoot', 'forgeRuntimeRoot', 'graphRuntimeRoot',
|
|
44
|
+
'customComponents', 'componentActions',
|
|
45
|
+
'dryRun', 'validateOnly', 'force', 'allowDowngrade', 'offline', 'noBuildFallback',
|
|
46
|
+
'skipProviderConfiguration', 'nonInteractive'
|
|
47
|
+
]),
|
|
48
|
+
verify: new Set([
|
|
49
|
+
'preset', 'provider', 'providerScope', 'workspaceRoot', 'skillsRoot',
|
|
50
|
+
'contextRuntimeRoot', 'forgeRuntimeRoot', 'graphRuntimeRoot',
|
|
51
|
+
'customComponents'
|
|
52
|
+
]),
|
|
53
|
+
doctor: new Set([
|
|
54
|
+
'skillsRoot', 'project'
|
|
55
|
+
]),
|
|
56
|
+
update: new Set([
|
|
57
|
+
'preset', 'provider', 'providerScope', 'workspaceRoot', 'skillsRoot',
|
|
58
|
+
'contextRuntimeRoot', 'forgeRuntimeRoot', 'graphRuntimeRoot',
|
|
59
|
+
'customComponents', 'componentActions',
|
|
60
|
+
'dryRun', 'allowDowngrade', 'offline', 'noBuildFallback', 'skipProviderConfiguration',
|
|
61
|
+
'skipSelfUpdate', 'nonInteractive'
|
|
62
|
+
]),
|
|
63
|
+
uninstall: new Set([
|
|
64
|
+
'skillsRoot', 'provider', 'providerScope', 'workspaceRoot',
|
|
65
|
+
'graphRuntimeRoot', 'contextRuntimeRoot', 'forgeRuntimeRoot',
|
|
66
|
+
'componentActions',
|
|
67
|
+
'removeProviderConfiguration', 'removeAfyxGraph', 'removeAfyxContext', 'removeAfyxForge',
|
|
68
|
+
'dryRun', 'nonInteractive'
|
|
69
|
+
])
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export function getHelpText() {
|
|
73
|
+
const version = getPackageVersion();
|
|
74
|
+
return `AFYX Engineering Kit — Universal Cross-Platform CLI Installer v${version}
|
|
75
|
+
|
|
76
|
+
Usage:
|
|
77
|
+
afyx-engineering-kit <command> [options]
|
|
78
|
+
npx afyx-engineering-kit <command> [options]
|
|
79
|
+
|
|
80
|
+
Commands:
|
|
81
|
+
install Install AFYX components and provider integrations
|
|
82
|
+
verify Verify health and configuration of installed components
|
|
83
|
+
doctor Inspect environment readiness and diagnostic checks (read-only)
|
|
84
|
+
update Update installed AFYX components to the latest revision
|
|
85
|
+
uninstall Safely remove AFYX-managed components and provider entries
|
|
86
|
+
|
|
87
|
+
Options:
|
|
88
|
+
--preset <name> Component preset (minimal, recommended, full, custom)
|
|
89
|
+
--provider <names> Target AI provider host(s) (codex, antigravity, claude)
|
|
90
|
+
--provider-scope <scope> Integration scope (global, workspace)
|
|
91
|
+
--workspace-root <path> Target project workspace root for local configuration
|
|
92
|
+
--skills-root <path> Explicit target directory for skill installations
|
|
93
|
+
--context-runtime-root <path> Explicit runtime root for Afyx Context Engine
|
|
94
|
+
--forge-runtime-root <path> Explicit runtime root for Afyx Forge Core
|
|
95
|
+
--graph-runtime-root <path> Explicit runtime root for Afyx Graph (Windows)
|
|
96
|
+
--custom-component <id> Specify individual component (repeatable)
|
|
97
|
+
--component <id=action> Individual component lifecycle action (repeatable)
|
|
98
|
+
--skip-provider-configuration Bypass AI provider host MCP and skill registration
|
|
99
|
+
--skip-self-update Skip git self-update during update command
|
|
100
|
+
--remove-provider-configuration Remove configured provider entries during uninstall
|
|
101
|
+
--remove-afyx-graph Explicitly remove Afyx Graph runtime during uninstall
|
|
102
|
+
--remove-afyx-context Explicitly remove Afyx Context runtime during uninstall
|
|
103
|
+
--remove-afyx-forge Explicitly remove Afyx Forge runtime during uninstall
|
|
104
|
+
--dry-run, --what-if, -n Preview planned changes without modifying system
|
|
105
|
+
--validate-only Check prerequisites and component status without mutating
|
|
106
|
+
--force Force adoption or replacement where supported
|
|
107
|
+
--allow-downgrade Allow replacing a higher-version installation with this package
|
|
108
|
+
--offline Disable network requests during installation
|
|
109
|
+
--no-build-fallback Fail if pre-packaged binary archive is unavailable
|
|
110
|
+
--non-interactive, -y, --yes Bypass interactive confirmations
|
|
111
|
+
--project <path> Target directory for doctor inspection
|
|
112
|
+
--version, -v Display package version
|
|
113
|
+
--help, -h Display this help message
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
npx afyx-engineering-kit install --preset recommended
|
|
117
|
+
npx afyx-engineering-kit install --preset full --provider codex,antigravity --dry-run
|
|
118
|
+
npx afyx-engineering-kit verify --preset recommended
|
|
119
|
+
npx afyx-engineering-kit doctor
|
|
120
|
+
npx afyx-engineering-kit update
|
|
121
|
+
npx afyx-engineering-kit uninstall --component afyx-engineering-expert
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function parseCliArgs(rawArgs) {
|
|
126
|
+
const result = {
|
|
127
|
+
command: null,
|
|
128
|
+
options: {
|
|
129
|
+
customComponents: [],
|
|
130
|
+
componentActions: [],
|
|
131
|
+
},
|
|
132
|
+
errors: [],
|
|
133
|
+
showHelp: false,
|
|
134
|
+
showVersion: false,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const args = [...rawArgs];
|
|
138
|
+
|
|
139
|
+
if (args.length === 0) {
|
|
140
|
+
result.showHelp = true;
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const first = args[0];
|
|
145
|
+
if (first === '--help' || first === '-h' || first === 'help') {
|
|
146
|
+
result.showHelp = true;
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
if (first === '--version' || first === '-v' || first === 'version') {
|
|
150
|
+
result.showVersion = true;
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (SUPPORTED_COMMANDS.includes(first)) {
|
|
155
|
+
result.command = first;
|
|
156
|
+
args.shift();
|
|
157
|
+
} else if (first.startsWith('-')) {
|
|
158
|
+
result.errors.push(`Missing command. Expected one of: ${SUPPORTED_COMMANDS.join(', ')}`);
|
|
159
|
+
return result;
|
|
160
|
+
} else {
|
|
161
|
+
result.errors.push(`Unknown command: "${first}". Expected one of: ${SUPPORTED_COMMANDS.join(', ')}`);
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const recordOption = (key, flagName) => {
|
|
166
|
+
const allowed = COMMAND_ALLOWED_OPTIONS[result.command];
|
|
167
|
+
if (allowed && !allowed.has(key)) {
|
|
168
|
+
result.errors.push(`Option "${flagName}" is not supported for command "${result.command}".`);
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
for (let i = 0; i < args.length; i++) {
|
|
175
|
+
const arg = args[i];
|
|
176
|
+
|
|
177
|
+
if (arg === '--help' || arg === '-h') {
|
|
178
|
+
result.showHelp = true;
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
if (arg === '--version' || arg === '-v') {
|
|
182
|
+
result.showVersion = true;
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (arg === '--dry-run' || arg === '-n' || arg === '--what-if') {
|
|
187
|
+
if (recordOption('dryRun', arg)) result.options.dryRun = true;
|
|
188
|
+
} else if (arg === '--validate-only') {
|
|
189
|
+
if (recordOption('validateOnly', arg)) result.options.validateOnly = true;
|
|
190
|
+
} else if (arg === '--force') {
|
|
191
|
+
if (recordOption('force', arg)) result.options.force = true;
|
|
192
|
+
} else if (arg === '--allow-downgrade') {
|
|
193
|
+
if (recordOption('allowDowngrade', arg)) result.options.allowDowngrade = true;
|
|
194
|
+
} else if (arg === '--offline') {
|
|
195
|
+
if (recordOption('offline', arg)) result.options.offline = true;
|
|
196
|
+
} else if (arg === '--no-build-fallback') {
|
|
197
|
+
if (recordOption('noBuildFallback', arg)) result.options.noBuildFallback = true;
|
|
198
|
+
} else if (arg === '--skip-provider-configuration') {
|
|
199
|
+
if (recordOption('skipProviderConfiguration', arg)) result.options.skipProviderConfiguration = true;
|
|
200
|
+
} else if (arg === '--skip-self-update') {
|
|
201
|
+
if (recordOption('skipSelfUpdate', arg)) result.options.skipSelfUpdate = true;
|
|
202
|
+
} else if (arg === '--remove-provider-configuration') {
|
|
203
|
+
if (recordOption('removeProviderConfiguration', arg)) result.options.removeProviderConfiguration = true;
|
|
204
|
+
} else if (arg === '--remove-afyx-graph') {
|
|
205
|
+
if (recordOption('removeAfyxGraph', arg)) result.options.removeAfyxGraph = true;
|
|
206
|
+
} else if (arg === '--remove-afyx-context') {
|
|
207
|
+
if (recordOption('removeAfyxContext', arg)) result.options.removeAfyxContext = true;
|
|
208
|
+
} else if (arg === '--remove-afyx-forge') {
|
|
209
|
+
if (recordOption('removeAfyxForge', arg)) result.options.removeAfyxForge = true;
|
|
210
|
+
} else if (arg === '--non-interactive' || arg === '-y' || arg === '--yes') {
|
|
211
|
+
if (recordOption('nonInteractive', arg)) result.options.nonInteractive = true;
|
|
212
|
+
} else if (arg === '--preset' || arg.startsWith('--preset=')) {
|
|
213
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
214
|
+
if (!val) result.errors.push('--preset requires a value');
|
|
215
|
+
else if (recordOption('preset', '--preset')) result.options.preset = val;
|
|
216
|
+
} else if (arg === '--provider' || arg.startsWith('--provider=')) {
|
|
217
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
218
|
+
if (!val) result.errors.push('--provider requires a value');
|
|
219
|
+
else if (recordOption('provider', '--provider')) result.options.provider = val;
|
|
220
|
+
} else if (arg === '--provider-scope' || arg.startsWith('--provider-scope=')) {
|
|
221
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
222
|
+
if (!val) result.errors.push('--provider-scope requires a value');
|
|
223
|
+
else if (recordOption('providerScope', '--provider-scope')) result.options.providerScope = val;
|
|
224
|
+
} else if (arg === '--workspace-root' || arg.startsWith('--workspace-root=')) {
|
|
225
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
226
|
+
if (!val) result.errors.push('--workspace-root requires a value');
|
|
227
|
+
else if (recordOption('workspaceRoot', '--workspace-root')) result.options.workspaceRoot = val;
|
|
228
|
+
} else if (arg === '--skills-root' || arg.startsWith('--skills-root=')) {
|
|
229
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
230
|
+
if (!val) result.errors.push('--skills-root requires a value');
|
|
231
|
+
else if (recordOption('skillsRoot', '--skills-root')) result.options.skillsRoot = val;
|
|
232
|
+
} else if (arg === '--context-runtime-root' || arg.startsWith('--context-runtime-root=')) {
|
|
233
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
234
|
+
if (!val) result.errors.push('--context-runtime-root requires a value');
|
|
235
|
+
else if (recordOption('contextRuntimeRoot', '--context-runtime-root')) result.options.contextRuntimeRoot = val;
|
|
236
|
+
} else if (arg === '--forge-runtime-root' || arg.startsWith('--forge-runtime-root=')) {
|
|
237
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
238
|
+
if (!val) result.errors.push('--forge-runtime-root requires a value');
|
|
239
|
+
else if (recordOption('forgeRuntimeRoot', '--forge-runtime-root')) result.options.forgeRuntimeRoot = val;
|
|
240
|
+
} else if (arg === '--graph-runtime-root' || arg.startsWith('--graph-runtime-root=')) {
|
|
241
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
242
|
+
if (!val) result.errors.push('--graph-runtime-root requires a value');
|
|
243
|
+
else if (recordOption('graphRuntimeRoot', '--graph-runtime-root')) result.options.graphRuntimeRoot = val;
|
|
244
|
+
} else if (arg === '--project' || arg.startsWith('--project=')) {
|
|
245
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
246
|
+
if (!val) result.errors.push('--project requires a value');
|
|
247
|
+
else if (recordOption('project', '--project')) result.options.project = val;
|
|
248
|
+
} else if (arg === '--custom-component' || arg.startsWith('--custom-component=')) {
|
|
249
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
250
|
+
if (!val) result.errors.push('--custom-component requires a value');
|
|
251
|
+
else if (recordOption('customComponents', '--custom-component')) result.options.customComponents.push(val);
|
|
252
|
+
} else if (arg === '--component' || arg.startsWith('--component=')) {
|
|
253
|
+
const val = arg.includes('=') ? arg.split('=')[1] : args[++i];
|
|
254
|
+
if (!val) result.errors.push('--component requires a value');
|
|
255
|
+
else if (recordOption('componentActions', '--component')) result.options.componentActions.push(val);
|
|
256
|
+
} else {
|
|
257
|
+
result.errors.push(`Unknown option: "${arg}"`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Cross-option validation
|
|
262
|
+
if (result.options.skipProviderConfiguration && result.options.provider) {
|
|
263
|
+
result.errors.push('--skip-provider-configuration cannot be used together with --provider');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function buildSubprocessCall(command, options = {}, platform = process.platform, pkgRoot = PACKAGE_ROOT) {
|
|
270
|
+
const isWindows = platform === 'win32';
|
|
271
|
+
const env = { ...process.env };
|
|
272
|
+
|
|
273
|
+
// Graph runtime root is passed via environment variable across all backend scripts
|
|
274
|
+
if (options.graphRuntimeRoot) {
|
|
275
|
+
env.AFYX_GRAPH_RUNTIME_ROOT = options.graphRuntimeRoot;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Handle outside-git-checkout update behavior
|
|
279
|
+
let isGitRepo = true;
|
|
280
|
+
try {
|
|
281
|
+
isGitRepo = existsSync(join(pkgRoot, '.git'));
|
|
282
|
+
} catch {
|
|
283
|
+
isGitRepo = false;
|
|
284
|
+
}
|
|
285
|
+
const effectiveOptions = { ...options };
|
|
286
|
+
if (command === 'update' && !isGitRepo && !effectiveOptions.skipSelfUpdate) {
|
|
287
|
+
effectiveOptions.skipSelfUpdate = true;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (isWindows) {
|
|
291
|
+
let scriptName;
|
|
292
|
+
if (command === 'doctor') scriptName = join('scripts', 'afyx-doctor.ps1');
|
|
293
|
+
else if (command === 'update' && !isGitRepo) scriptName = 'install.ps1';
|
|
294
|
+
else scriptName = `${command}.ps1`;
|
|
295
|
+
|
|
296
|
+
const scriptPath = join(pkgRoot, scriptName);
|
|
297
|
+
const psArgs = [];
|
|
298
|
+
|
|
299
|
+
if (command === 'update' && !isGitRepo) {
|
|
300
|
+
psArgs.push('-UpdateInstalled');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (effectiveOptions.preset) psArgs.push('-Preset', effectiveOptions.preset);
|
|
304
|
+
if (effectiveOptions.provider) psArgs.push('-Provider', effectiveOptions.provider);
|
|
305
|
+
if (effectiveOptions.providerScope) psArgs.push('-ProviderScope', effectiveOptions.providerScope);
|
|
306
|
+
if (effectiveOptions.workspaceRoot) psArgs.push('-WorkspaceRoot', effectiveOptions.workspaceRoot);
|
|
307
|
+
if (effectiveOptions.skillsRoot) psArgs.push('-SkillsRoot', effectiveOptions.skillsRoot);
|
|
308
|
+
if (effectiveOptions.contextRuntimeRoot) psArgs.push('-ContextRuntimeRoot', effectiveOptions.contextRuntimeRoot);
|
|
309
|
+
if (effectiveOptions.forgeRuntimeRoot) psArgs.push('-ForgeRuntimeRoot', effectiveOptions.forgeRuntimeRoot);
|
|
310
|
+
if (effectiveOptions.graphRuntimeRoot && command === 'uninstall') psArgs.push('-GraphRuntimeRoot', effectiveOptions.graphRuntimeRoot);
|
|
311
|
+
if (effectiveOptions.project) psArgs.push('-ProjectPath', effectiveOptions.project);
|
|
312
|
+
|
|
313
|
+
if (effectiveOptions.customComponents && effectiveOptions.customComponents.length > 0) {
|
|
314
|
+
for (const comp of effectiveOptions.customComponents) {
|
|
315
|
+
psArgs.push('-CustomComponent', comp);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (effectiveOptions.componentActions && effectiveOptions.componentActions.length > 0) {
|
|
319
|
+
for (const act of effectiveOptions.componentActions) {
|
|
320
|
+
if (command === 'uninstall') {
|
|
321
|
+
psArgs.push('-Component', act);
|
|
322
|
+
} else {
|
|
323
|
+
psArgs.push('-ComponentAction', act);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// SupportsShouldProcess commands (install, update, uninstall)
|
|
329
|
+
if (effectiveOptions.dryRun && (command === 'install' || command === 'update' || command === 'uninstall')) {
|
|
330
|
+
psArgs.push('-WhatIf');
|
|
331
|
+
}
|
|
332
|
+
if (effectiveOptions.nonInteractive && (command === 'install' || command === 'update' || command === 'uninstall')) {
|
|
333
|
+
psArgs.push('-Confirm:$false');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (effectiveOptions.validateOnly && command === 'install') psArgs.push('-ValidateOnly');
|
|
337
|
+
if (effectiveOptions.force && command === 'install') psArgs.push('-Force');
|
|
338
|
+
if (effectiveOptions.allowDowngrade && (command === 'install' || command === 'update')) psArgs.push('-AllowDowngrade');
|
|
339
|
+
if (effectiveOptions.offline && (command === 'install' || command === 'update')) psArgs.push('-Offline');
|
|
340
|
+
if (effectiveOptions.noBuildFallback && (command === 'install' || command === 'update')) psArgs.push('-NoBuildFallback');
|
|
341
|
+
if (effectiveOptions.skipProviderConfiguration && (command === 'install' || command === 'update')) psArgs.push('-SkipProviderConfiguration');
|
|
342
|
+
if (effectiveOptions.skipSelfUpdate && command === 'update' && isGitRepo) psArgs.push('-SkipSelfUpdate');
|
|
343
|
+
if (effectiveOptions.removeProviderConfiguration && command === 'uninstall') psArgs.push('-RemoveProviderConfiguration');
|
|
344
|
+
if (effectiveOptions.removeAfyxGraph && command === 'uninstall') psArgs.push('-RemoveAfyxGraph');
|
|
345
|
+
if (effectiveOptions.removeAfyxContext && command === 'uninstall') psArgs.push('-RemoveAfyxContext');
|
|
346
|
+
if (effectiveOptions.removeAfyxForge && command === 'uninstall') psArgs.push('-RemoveAfyxForge');
|
|
347
|
+
|
|
348
|
+
// Prefer PowerShell 7+ (pwsh), fall back to Windows PowerShell (powershell.exe)
|
|
349
|
+
const executable = 'pwsh';
|
|
350
|
+
const invocationArgs = ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptPath, ...psArgs];
|
|
351
|
+
|
|
352
|
+
return {
|
|
353
|
+
executable,
|
|
354
|
+
fallbackExecutable: 'powershell.exe',
|
|
355
|
+
args: invocationArgs,
|
|
356
|
+
scriptPath,
|
|
357
|
+
env,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Linux & macOS (Bash)
|
|
362
|
+
let scriptName;
|
|
363
|
+
if (command === 'doctor') scriptName = join('scripts', 'afyx-doctor.sh');
|
|
364
|
+
else if (command === 'update' && !isGitRepo) scriptName = 'install.sh';
|
|
365
|
+
else scriptName = `${command}.sh`;
|
|
366
|
+
|
|
367
|
+
const scriptPath = join(pkgRoot, scriptName);
|
|
368
|
+
const shArgs = [scriptPath];
|
|
369
|
+
|
|
370
|
+
if (command === 'update' && !isGitRepo) {
|
|
371
|
+
shArgs.push('--update-installed');
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// In Linux/macOS bash scripts, non-interactive mode is activated by CI=1
|
|
375
|
+
if (effectiveOptions.nonInteractive) {
|
|
376
|
+
env.CI = '1';
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (effectiveOptions.preset) shArgs.push('--preset', effectiveOptions.preset);
|
|
380
|
+
if (effectiveOptions.provider) shArgs.push('--provider', effectiveOptions.provider);
|
|
381
|
+
if (effectiveOptions.providerScope) shArgs.push('--provider-scope', effectiveOptions.providerScope);
|
|
382
|
+
if (effectiveOptions.workspaceRoot) shArgs.push('--workspace-root', effectiveOptions.workspaceRoot);
|
|
383
|
+
if (effectiveOptions.skillsRoot) shArgs.push('--skills-root', effectiveOptions.skillsRoot);
|
|
384
|
+
if (effectiveOptions.contextRuntimeRoot) shArgs.push('--context-runtime-root', effectiveOptions.contextRuntimeRoot);
|
|
385
|
+
if (effectiveOptions.forgeRuntimeRoot) shArgs.push('--forge-runtime-root', effectiveOptions.forgeRuntimeRoot);
|
|
386
|
+
if (effectiveOptions.project) shArgs.push('--project', effectiveOptions.project);
|
|
387
|
+
|
|
388
|
+
if (effectiveOptions.customComponents && effectiveOptions.customComponents.length > 0) {
|
|
389
|
+
for (const comp of effectiveOptions.customComponents) {
|
|
390
|
+
shArgs.push('--custom-component', comp);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (effectiveOptions.componentActions && effectiveOptions.componentActions.length > 0) {
|
|
394
|
+
for (const act of effectiveOptions.componentActions) {
|
|
395
|
+
shArgs.push('--component', act);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (effectiveOptions.dryRun && (command === 'install' || command === 'update' || command === 'uninstall')) {
|
|
400
|
+
shArgs.push('--dry-run');
|
|
401
|
+
}
|
|
402
|
+
if (effectiveOptions.validateOnly && command === 'install') shArgs.push('--validate-only');
|
|
403
|
+
if (effectiveOptions.force && command === 'install') shArgs.push('--force');
|
|
404
|
+
if (effectiveOptions.allowDowngrade && (command === 'install' || command === 'update')) shArgs.push('--allow-downgrade');
|
|
405
|
+
if (effectiveOptions.offline && (command === 'install' || command === 'update')) shArgs.push('--offline');
|
|
406
|
+
if (effectiveOptions.noBuildFallback && (command === 'install' || command === 'update')) shArgs.push('--no-build-fallback');
|
|
407
|
+
if (effectiveOptions.skipProviderConfiguration && (command === 'install' || command === 'update')) shArgs.push('--skip-provider-configuration');
|
|
408
|
+
if (effectiveOptions.skipSelfUpdate && command === 'update' && isGitRepo) shArgs.push('--skip-self-update');
|
|
409
|
+
if (effectiveOptions.removeProviderConfiguration && command === 'uninstall') shArgs.push('--remove-provider-configuration');
|
|
410
|
+
if (effectiveOptions.removeAfyxGraph && command === 'uninstall') shArgs.push('--remove-afyx-graph');
|
|
411
|
+
if (effectiveOptions.removeAfyxContext && command === 'uninstall') shArgs.push('--remove-afyx-context');
|
|
412
|
+
if (effectiveOptions.removeAfyxForge && command === 'uninstall') shArgs.push('--remove-afyx-forge');
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
executable: 'bash',
|
|
416
|
+
args: shArgs,
|
|
417
|
+
scriptPath,
|
|
418
|
+
env,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export function executeSubprocess(callInfo, { onExit = null } = {}) {
|
|
423
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
424
|
+
let currentChild = null;
|
|
425
|
+
let resolved = false;
|
|
426
|
+
|
|
427
|
+
const cleanupSignalHandlers = () => {
|
|
428
|
+
process.removeListener('SIGINT', handleSigInt);
|
|
429
|
+
process.removeListener('SIGTERM', handleSigTerm);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
const handleSigInt = () => {
|
|
433
|
+
if (currentChild && !currentChild.killed) currentChild.kill('SIGINT');
|
|
434
|
+
};
|
|
435
|
+
const handleSigTerm = () => {
|
|
436
|
+
if (currentChild && !currentChild.killed) currentChild.kill('SIGTERM');
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
process.on('SIGINT', handleSigInt);
|
|
440
|
+
process.on('SIGTERM', handleSigTerm);
|
|
441
|
+
|
|
442
|
+
const run = (exe, args) => {
|
|
443
|
+
let child;
|
|
444
|
+
try {
|
|
445
|
+
child = spawn(exe, args, {
|
|
446
|
+
stdio: 'inherit',
|
|
447
|
+
cwd: process.cwd(),
|
|
448
|
+
env: callInfo.env || process.env,
|
|
449
|
+
});
|
|
450
|
+
} catch (err) {
|
|
451
|
+
if (callInfo.fallbackExecutable && exe !== callInfo.fallbackExecutable) {
|
|
452
|
+
run(callInfo.fallbackExecutable, args);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
cleanupSignalHandlers();
|
|
456
|
+
rejectPromise(err);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
currentChild = child;
|
|
461
|
+
let hasErrored = false;
|
|
462
|
+
|
|
463
|
+
child.on('error', (err) => {
|
|
464
|
+
hasErrored = true;
|
|
465
|
+
child.removeAllListeners('close');
|
|
466
|
+
if (callInfo.fallbackExecutable && exe !== callInfo.fallbackExecutable) {
|
|
467
|
+
run(callInfo.fallbackExecutable, args);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
cleanupSignalHandlers();
|
|
471
|
+
rejectPromise(err);
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
child.on('close', (code, signal) => {
|
|
475
|
+
if (hasErrored || resolved) return;
|
|
476
|
+
resolved = true;
|
|
477
|
+
cleanupSignalHandlers();
|
|
478
|
+
const finalCode = signal ? 1 : (code ?? 0);
|
|
479
|
+
if (onExit) onExit(finalCode);
|
|
480
|
+
resolvePromise(finalCode);
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
run(callInfo.executable, callInfo.args);
|
|
485
|
+
});
|
|
486
|
+
}
|