afyx-engineering-kit 0.0.0-stage → 0.1.0-alpha.4
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
package/install.ps1
ADDED
|
@@ -0,0 +1,1053 @@
|
|
|
1
|
+
[CmdletBinding(SupportsShouldProcess)]
|
|
2
|
+
param(
|
|
3
|
+
[string]$SkillsRoot = (Join-Path $env:USERPROFILE '.agents\skills'),
|
|
4
|
+
[switch]$Force,
|
|
5
|
+
[switch]$ValidateOnly,
|
|
6
|
+
[string[]]$ComponentAction = @(),
|
|
7
|
+
[string]$Preset = '',
|
|
8
|
+
[string[]]$CustomComponent = @(),
|
|
9
|
+
[switch]$UpdateInstalled,
|
|
10
|
+
[switch]$Offline,
|
|
11
|
+
[switch]$NoBuildFallback,
|
|
12
|
+
[switch]$AllowDirtySource,
|
|
13
|
+
[switch]$AllowDowngrade,
|
|
14
|
+
[switch]$InstallUsageTracker,
|
|
15
|
+
[switch]$SkipUsageTracker,
|
|
16
|
+
[switch]$SkipGraphMcp,
|
|
17
|
+
[switch]$SkipGraphPathUpdate,
|
|
18
|
+
[string[]]$Provider = @(),
|
|
19
|
+
[ValidateSet('global', 'workspace')][string]$ProviderScope = 'global',
|
|
20
|
+
[string]$WorkspaceRoot = (Get-Location).Path,
|
|
21
|
+
[string]$GeminiHome = $(if ($env:AFYX_GEMINI_HOME) { $env:AFYX_GEMINI_HOME } else { Join-Path $env:USERPROFILE '.gemini' }),
|
|
22
|
+
[string]$ClaudeHome = $(if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $env:USERPROFILE '.claude' }),
|
|
23
|
+
[string]$ClaudeConfigDir = $(if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { '' }),
|
|
24
|
+
[switch]$SkipProviderConfiguration,
|
|
25
|
+
[string]$ContextRuntimeRoot = $(if ($env:AFYX_CONTEXT_RUNTIME_ROOT) { $env:AFYX_CONTEXT_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\context' }),
|
|
26
|
+
[string]$ForgeRuntimeRoot = $(if ($env:AFYX_FORGE_RUNTIME_ROOT) { $env:AFYX_FORGE_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\forge' }),
|
|
27
|
+
[string]$AfyxInstallRoot = $(if ($env:AFYX_INSTALL_ROOT) { $env:AFYX_INSTALL_ROOT } else { Join-Path $env:USERPROFILE '.afyx' }),
|
|
28
|
+
[string]$HostBridgeRuntimeRoot = $(if ($env:AFYX_HOST_BRIDGE_RUNTIME_ROOT) { $env:AFYX_HOST_BRIDGE_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\host-bridge' })
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
Set-StrictMode -Version Latest
|
|
32
|
+
$ErrorActionPreference = 'Stop'
|
|
33
|
+
|
|
34
|
+
$packageRoot = $PSScriptRoot
|
|
35
|
+
if ($CustomComponent.Count) {
|
|
36
|
+
$CustomComponent = @($CustomComponent | ForEach-Object { $_ -split ',' } | ForEach-Object { $_.Trim() } | Where-Object { $_ })
|
|
37
|
+
}
|
|
38
|
+
if ($Provider.Count) {
|
|
39
|
+
$Provider = @($Provider | ForEach-Object { $_ -split ',' } | ForEach-Object { $_.Trim() } | Where-Object { $_ })
|
|
40
|
+
}
|
|
41
|
+
$bundledEfficientCoding = Join-Path $packageRoot 'skills\efficient-coding'
|
|
42
|
+
$bundledOdooEngineering = Join-Path $packageRoot 'skills\odoo-engineering'
|
|
43
|
+
$bundledEngineeringExpert = Join-Path $packageRoot 'skills\afyx-engineering-expert'
|
|
44
|
+
$efficientTarget = Join-Path $SkillsRoot 'efficient-coding'
|
|
45
|
+
$odooTarget = Join-Path $SkillsRoot 'odoo-engineering'
|
|
46
|
+
$expertTarget = Join-Path $SkillsRoot 'afyx-engineering-expert'
|
|
47
|
+
$usageTrackerInstaller = Join-Path $packageRoot 'scripts\install-codex-usage-tracker.ps1'
|
|
48
|
+
$graphInstaller = Join-Path $packageRoot 'scripts\install-afyx-graph.ps1'
|
|
49
|
+
$graphMetadataPath = Join-Path $packageRoot 'afyx-graph\afyx-graph.json'
|
|
50
|
+
$contextInstaller = Join-Path $packageRoot 'scripts\install-afyx-context.ps1'
|
|
51
|
+
$contextMetadataPath = Join-Path $packageRoot 'afyx-context\afyx-context.json'
|
|
52
|
+
$contextCompanionSource = Join-Path $packageRoot 'skills\afyx-context'
|
|
53
|
+
$forgeInstaller = Join-Path $packageRoot 'scripts\install-afyx-forge.ps1'
|
|
54
|
+
$forgeMetadataPath = Join-Path $packageRoot 'afyx-forge\afyx-forge.json'
|
|
55
|
+
$forgeCompanionSource = Join-Path $packageRoot 'skills\afyx-forge'
|
|
56
|
+
$graphRuntimeRoot = if ($env:AFYX_GRAPH_RUNTIME_ROOT) { $env:AFYX_GRAPH_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\graph' }
|
|
57
|
+
$codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $env:USERPROFILE '.codex' }
|
|
58
|
+
|
|
59
|
+
if ($InstallUsageTracker -and $SkipUsageTracker) { throw '-InstallUsageTracker and -SkipUsageTracker cannot be used together.' }
|
|
60
|
+
|
|
61
|
+
# One component truth: scripts/components.json, read through the shared module.
|
|
62
|
+
Import-Module (Join-Path $packageRoot 'scripts\lib\AfyxComponents.psm1') -Force
|
|
63
|
+
Import-Module (Join-Path $packageRoot 'scripts\lib\AfyxSkillLifecycle.psm1') -Force -DisableNameChecking
|
|
64
|
+
Import-Module (Join-Path $packageRoot 'scripts\lib\AfyxTerminal.psm1') -Force
|
|
65
|
+
$terminal = New-AfyxTerminalContext
|
|
66
|
+
$providerRegistry = @(Get-AfyxProviderRegistry)
|
|
67
|
+
$providerIds = @($providerRegistry | ForEach-Object { [string]$_.provider })
|
|
68
|
+
$codexHost = Get-AfyxCodexHost
|
|
69
|
+
$codexCommandDetected = if ($codexHost.State -eq 'CLI_READY') { [pscustomobject]@{ Source = $codexHost.Path } } else { $null }
|
|
70
|
+
$agyCommandDetected = Get-Command agy -ErrorAction SilentlyContinue
|
|
71
|
+
$antigravityCommandDetected = if ($agyCommandDetected) { $agyCommandDetected } else { Get-Command antigravity -ErrorAction SilentlyContinue }
|
|
72
|
+
$claudeCommandDetected = Get-Command claude -ErrorAction SilentlyContinue
|
|
73
|
+
$vscodeExtensionDetected = [bool](Get-ChildItem -Path (Join-Path $env:USERPROFILE '.vscode\extensions\openai.chatgpt-*') -Directory -ErrorAction SilentlyContinue | Select-Object -First 1)
|
|
74
|
+
# Read-only IDE discovery: distinguish an installed IDE from a usable provider CLI.
|
|
75
|
+
# IDE-only installs are displayed but never silently offered unsupported MCP mutation.
|
|
76
|
+
$claudeVsCodeDetected = [bool](Get-ChildItem -Path (Join-Path $env:USERPROFILE '.vscode\extensions\anthropic.claude-code-*') -Directory -ErrorAction SilentlyContinue | Select-Object -First 1)
|
|
77
|
+
$claudeAvailabilityState = if ($claudeCommandDetected -and $claudeVsCodeDetected) {
|
|
78
|
+
'CLI_AND_EXTENSION'
|
|
79
|
+
} elseif ($claudeCommandDetected) {
|
|
80
|
+
'CLI_AVAILABLE'
|
|
81
|
+
} elseif ($claudeVsCodeDetected) {
|
|
82
|
+
'EXTENSION_ONLY'
|
|
83
|
+
} else {
|
|
84
|
+
'UNAVAILABLE'
|
|
85
|
+
}
|
|
86
|
+
$antigravityIdeCandidates = @(
|
|
87
|
+
$(if ($env:LOCALAPPDATA) { Join-Path $env:LOCALAPPDATA 'Programs\Antigravity\Antigravity.exe' }),
|
|
88
|
+
$(if ($env:LOCALAPPDATA) { Join-Path $env:LOCALAPPDATA 'Programs\Google Antigravity\Antigravity.exe' }),
|
|
89
|
+
$(if ($env:ProgramFiles) { Join-Path $env:ProgramFiles 'Google\Antigravity\Antigravity.exe' })
|
|
90
|
+
) | Where-Object { $_ }
|
|
91
|
+
$antigravityIdePath = @($antigravityIdeCandidates | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf } | Select-Object -First 1)
|
|
92
|
+
$antigravityIdeDetected = $antigravityIdePath.Count -gt 0
|
|
93
|
+
$explicitSelection = @(
|
|
94
|
+
@('Preset', 'CustomComponent', 'ComponentAction', 'Provider', 'Force', 'UpdateInstalled', 'InstallUsageTracker', 'SkipUsageTracker', 'SkipProviderConfiguration', 'Confirm') |
|
|
95
|
+
Where-Object { $PSBoundParameters.ContainsKey($_) }
|
|
96
|
+
)
|
|
97
|
+
$wizardMode = $terminal.Interactive -and -not $ValidateOnly -and -not $WhatIfPreference -and -not $env:CI -and $explicitSelection.Count -eq 0
|
|
98
|
+
if ($wizardMode) {
|
|
99
|
+
$inventoryNode = Get-Command node -ErrorAction SilentlyContinue
|
|
100
|
+
$providerInventory = @()
|
|
101
|
+
if ($inventoryNode) {
|
|
102
|
+
$inventoryJson = & $inventoryNode.Source (Join-Path $packageRoot 'scripts\afyx-provider-inventory.mjs')
|
|
103
|
+
if ($LASTEXITCODE -eq 0 -and $inventoryJson) {
|
|
104
|
+
$providerInventory = @($inventoryJson | ConvertFrom-Json)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if ($providerInventory.Count) {
|
|
108
|
+
$codexProduct = $providerInventory | Where-Object { $_.id -eq 'codex' } | Select-Object -First 1
|
|
109
|
+
$claudeProduct = $providerInventory | Where-Object { $_.id -eq 'claude' } | Select-Object -First 1
|
|
110
|
+
$antigravityProduct = $providerInventory | Where-Object { $_.id -eq 'antigravity' } | Select-Object -First 1
|
|
111
|
+
$vscodeExtensionDetected = @($codexProduct.products | Where-Object { $_.type -eq 'VS Code Extension' }).Count -gt 0
|
|
112
|
+
$claudeVsCodeDetected = @($claudeProduct.products | Where-Object { $_.type -eq 'VS Code Extension' }).Count -gt 0
|
|
113
|
+
$antigravityIdeDetected = @($antigravityProduct.products | Where-Object { $_.type -eq 'IDE/Desktop' }).Count -gt 0
|
|
114
|
+
$claudeAvailabilityState = if ($claudeCommandDetected -and $claudeVsCodeDetected) { 'CLI_AND_EXTENSION' }
|
|
115
|
+
elseif ($claudeCommandDetected) { 'CLI_AVAILABLE' }
|
|
116
|
+
elseif ($claudeVsCodeDetected) { 'EXTENSION_ONLY' }
|
|
117
|
+
else { 'UNAVAILABLE' }
|
|
118
|
+
}
|
|
119
|
+
$providerSnapshot = @()
|
|
120
|
+
foreach ($entry in @($providerInventory | Where-Object { $_.supported })) {
|
|
121
|
+
$providerSnapshot += [string]$entry.name
|
|
122
|
+
if (-not @($entry.products).Count) { $providerSnapshot += ' - Unavailable' }
|
|
123
|
+
foreach ($product in @($entry.products)) {
|
|
124
|
+
$versionLabel = if ($product.version) { " · $($product.version)" } else { '' }
|
|
125
|
+
$providerSnapshot += " + $($product.type) · Installed$versionLabel"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
$otherDetected = @($providerInventory | Where-Object { -not $_.supported -and $_.installed })
|
|
129
|
+
if ($otherDetected.Count) {
|
|
130
|
+
$providerSnapshot += 'OTHER DETECTED'
|
|
131
|
+
foreach ($entry in $otherDetected) { $providerSnapshot += " - $($entry.name) · $($entry.status)" }
|
|
132
|
+
}
|
|
133
|
+
if (-not $providerSnapshot.Count) { $providerSnapshot = @('Provider inventory unavailable') }
|
|
134
|
+
Enable-AfyxDashboard -Terminal $terminal -Providers $providerSnapshot
|
|
135
|
+
}
|
|
136
|
+
if (-not (Test-AfyxDashboard -Terminal $terminal)) {
|
|
137
|
+
Show-AfyxBanner -Terminal $terminal -Subtitle 'Interactive Installer | Midnight Circuit'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
if ($wizardMode) {
|
|
142
|
+
try {
|
|
143
|
+
Show-AfyxStep -Current 1 -Terminal $terminal
|
|
144
|
+
Write-AfyxSection -Title 'Welcome & Environment' -Terminal $terminal
|
|
145
|
+
Write-AfyxStatus -Status INFO -Name 'Afyx Forge Core' -Detail 'optional Alpha assistive planner; formal 36-cell eval waived/not run; autonomous execution not authorized' -Terminal $terminal
|
|
146
|
+
Write-AfyxStatus -Status INFO -Name 'Afyx Context' -Detail 'optional to install; enabled by default when healthy; used only when needed' -Terminal $terminal
|
|
147
|
+
$presetOptions = @(
|
|
148
|
+
[pscustomobject]@{ Id = 'recommended'; Label = 'Recommended'; Detail = 'Core skills + Engineering Expert'; Enabled = $true },
|
|
149
|
+
[pscustomobject]@{ Id = 'minimal'; Label = 'Minimal'; Detail = 'Core engineering skills'; Enabled = $true },
|
|
150
|
+
[pscustomobject]@{ Id = 'full'; Label = 'Full'; Detail = 'All six core products (Graph, Context, Forge, Skills) + Codex usage tracking (Windows)'; Enabled = $true },
|
|
151
|
+
[pscustomobject]@{ Id = 'custom'; Label = 'Custom'; Detail = 'Choose exact components'; Enabled = $true }
|
|
152
|
+
)
|
|
153
|
+
Show-AfyxStep -Current 2 -Terminal $terminal
|
|
154
|
+
$Preset = Read-AfyxSingleChoice -Prompt 'Choose an installation preset' -Options $presetOptions -DefaultId 'recommended' -Terminal $terminal
|
|
155
|
+
Write-AfyxStatus -Status INFO -Name 'Preset selected' -Detail $Preset -Terminal $terminal
|
|
156
|
+
if ($Preset -eq 'custom') {
|
|
157
|
+
$componentOptions = @()
|
|
158
|
+
foreach ($component in @(Get-AfyxComponentContract)) {
|
|
159
|
+
$detail = "$($component.type); $($component.tier)"
|
|
160
|
+
if ([string]$component.id -eq 'afyx-context') { $detail += '; optional to install, enabled unless explicitly OFF, used on demand' }
|
|
161
|
+
elseif ([string]$component.id -eq 'afyx-forge') { $detail += '; alpha; bounded engineering guidance' }
|
|
162
|
+
elseif ([string]$component.id -eq 'codex-usage-tracking') { $detail += '; Codex/Windows only' }
|
|
163
|
+
$componentOptions += [pscustomobject]@{ Id = [string]$component.id; Label = [string]$component.name; Detail = $detail; Enabled = $true }
|
|
164
|
+
}
|
|
165
|
+
$CustomComponent = @(Read-AfyxMultiChoice -Prompt 'Select components' -Options $componentOptions -DefaultId @('efficient-coding', 'odoo-engineering') -Terminal $terminal)
|
|
166
|
+
Write-AfyxStatus -Status INFO -Name 'Components selected' -Detail ($CustomComponent -join ', ') -Terminal $terminal
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
Show-AfyxStep -Current 3 -Terminal $terminal
|
|
170
|
+
$codexDetected = [bool]$codexCommandDetected
|
|
171
|
+
$antigravityDetected = [bool]$antigravityCommandDetected
|
|
172
|
+
$claudeDetail = switch ($claudeAvailabilityState) {
|
|
173
|
+
'CLI_AND_EXTENSION' { 'CLI and VS Code extension detected; MCP supported' }
|
|
174
|
+
'CLI_AVAILABLE' { 'native CLI detected; MCP adapter supported' }
|
|
175
|
+
'EXTENSION_ONLY' { 'VS Code extension detected — standalone CLI unavailable' }
|
|
176
|
+
default { 'not detected: claude CLI or VS Code extension' }
|
|
177
|
+
}
|
|
178
|
+
$claudeEnabled = $claudeAvailabilityState -ne 'UNAVAILABLE'
|
|
179
|
+
$providerOptions = @(
|
|
180
|
+
[pscustomobject]@{ Id = 'codex'; Label = 'Codex'; Detail = $(if ($codexDetected) { 'native CLI detected' } elseif ($vscodeExtensionDetected) { 'extension detected; native Codex CLI is still required for MCP configuration' } else { $codexHost.Detail }); Enabled = $codexDetected },
|
|
181
|
+
[pscustomobject]@{ Id = 'antigravity'; Label = 'Antigravity'; Detail = $(if ($antigravityDetected) { 'CLI detected; MCP adapter supported' } elseif ($antigravityIdeDetected) { 'IDE detected; compatible CLI not found, MCP integration unavailable' } else { 'not detected: agy/antigravity CLI or recognized IDE path' }); Enabled = $antigravityDetected },
|
|
182
|
+
[pscustomobject]@{ Id = 'claude'; Label = 'Claude Code'; Detail = $claudeDetail; Enabled = $claudeEnabled },
|
|
183
|
+
[pscustomobject]@{ Id = 'skip'; Label = 'Skip provider configuration'; Detail = 'skills/runtimes only; no MCP registration'; Enabled = $true }
|
|
184
|
+
)
|
|
185
|
+
$supportedOptions = @($providerOptions | Where-Object { $_.Id -ne 'skip' })
|
|
186
|
+
$unsupportedOptions = @($providerInventory | Where-Object { -not $_.supported -and $_.installed } | ForEach-Object {
|
|
187
|
+
[pscustomobject]@{ Id = [string]$_.id; Label = [string]$_.name; Detail = "$($_.status) · no AFYX provider configuration"; Enabled = $false }
|
|
188
|
+
})
|
|
189
|
+
$providerOptions = @($supportedOptions + $unsupportedOptions | Sort-Object -Property Label) + @($providerOptions | Where-Object { $_.Id -eq 'skip' })
|
|
190
|
+
$detectedProviderDefaults = @($providerOptions | Where-Object { $_.Enabled -and $_.Id -ne 'skip' } | ForEach-Object { $_.Id })
|
|
191
|
+
if (-not $detectedProviderDefaults.Count) { $detectedProviderDefaults = @('skip') }
|
|
192
|
+
$providerChoice = @(Read-AfyxMultiChoice -Prompt 'Select provider integrations' -Options $providerOptions -DefaultId $detectedProviderDefaults -Terminal $terminal)
|
|
193
|
+
Write-AfyxStatus -Status INFO -Name 'Provider selection' -Detail ($providerChoice -join ', ') -Terminal $terminal
|
|
194
|
+
if ('skip' -in $providerChoice) {
|
|
195
|
+
if ($providerChoice.Count -ne 1) { throw 'Skip provider configuration cannot be combined with a provider.' }
|
|
196
|
+
$Provider = @()
|
|
197
|
+
$SkipProviderConfiguration = $true
|
|
198
|
+
} else {
|
|
199
|
+
$Provider = @($providerChoice)
|
|
200
|
+
if (-not $Provider.Count) { $SkipProviderConfiguration = $true }
|
|
201
|
+
}
|
|
202
|
+
if (@($Provider | Where-Object { $_ -in @('antigravity', 'claude') }).Count) {
|
|
203
|
+
$workspaceCompatible = 'codex' -notin $Provider
|
|
204
|
+
$scopeOptions = @(
|
|
205
|
+
[pscustomobject]@{ Id = 'workspace'; Label = 'Workspace'; Detail = $(if ($workspaceCompatible) { 'project-local provider skills and MCP configuration' } else { 'unavailable when Codex is selected; Codex MCP is user-scoped' }); Enabled = $workspaceCompatible },
|
|
206
|
+
[pscustomobject]@{ Id = 'global'; Label = 'Global'; Detail = 'user-level configuration for every selected provider'; Enabled = $true }
|
|
207
|
+
)
|
|
208
|
+
$ProviderScope = Read-AfyxSingleChoice -Prompt 'Choose compatible provider scope' -Options $scopeOptions -DefaultId $(if ($workspaceCompatible) { 'workspace' } else { 'global' }) -Terminal $terminal
|
|
209
|
+
Write-AfyxStatus -Status INFO -Name 'Provider scope' -Detail $ProviderScope -Terminal $terminal
|
|
210
|
+
}
|
|
211
|
+
} catch [System.OperationCanceledException] {
|
|
212
|
+
Write-AfyxStatus -Status SKIPPED -Name 'Installation cancelled' -Detail 'no configuration changes were made' -Terminal $terminal
|
|
213
|
+
exit 130
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (-not $Provider.Count) {
|
|
218
|
+
if (-not $wizardMode -and -not $SkipProviderConfiguration -and -not $ValidateOnly -and -not $WhatIfPreference -and -not $env:CI -and $terminal.Interactive) {
|
|
219
|
+
$detected = @()
|
|
220
|
+
if ($codexCommandDetected) { $detected += 'codex' }
|
|
221
|
+
if ($antigravityCommandDetected) { $detected += 'antigravity' }
|
|
222
|
+
if ($claudeCommandDetected) { $detected += 'claude' }
|
|
223
|
+
Write-Host "Provider hosts detected: $(if ($detected.Count) { $detected -join ', ' } else { 'none' })"
|
|
224
|
+
do { $choice = (Read-Host 'Provider selection: [A] All detected / [R] Recommended Codex / [C] Custom / [S] Skip [A]').Trim() } until ($choice -match '(?i)^(|a|all|r|recommended|c|custom|s|skip)$')
|
|
225
|
+
if ($choice -match '(?i)^(|a|all)$') { if ($detected.Count) { $Provider = $detected } else { $SkipProviderConfiguration = $true } }
|
|
226
|
+
elseif ($choice -match '(?i)^(c|custom)$') { $Provider = @((Read-Host 'Provider ids (comma-separated)').Split(',') | ForEach-Object { $_.Trim() } | Where-Object { $_ }) }
|
|
227
|
+
elseif ($choice -match '(?i)^(s|skip)$') { $SkipProviderConfiguration = $true }
|
|
228
|
+
else { $Provider = @('codex') }
|
|
229
|
+
} elseif (-not $SkipProviderConfiguration) { $Provider = @('codex') }
|
|
230
|
+
}
|
|
231
|
+
$unknownProviders = @($Provider | Where-Object { $_ -notin $providerIds })
|
|
232
|
+
if ($unknownProviders.Count) { throw "Unknown provider(s): $($unknownProviders -join ', ')" }
|
|
233
|
+
$Provider = @($providerIds | Where-Object { $_ -in $Provider })
|
|
234
|
+
$providerSkillRoots = @()
|
|
235
|
+
if ('codex' -in $Provider) {
|
|
236
|
+
$providerSkillRoots += $(if ($PSBoundParameters.ContainsKey('SkillsRoot')) { $SkillsRoot } else { Join-Path $env:USERPROFILE '.agents\skills' })
|
|
237
|
+
}
|
|
238
|
+
if ('antigravity' -in $Provider) {
|
|
239
|
+
if ($ProviderScope -eq 'workspace') { $providerSkillRoots += (Join-Path $WorkspaceRoot '.agents\skills') }
|
|
240
|
+
else { $providerSkillRoots += @((Join-Path $GeminiHome 'config\skills'), (Join-Path $GeminiHome 'antigravity-cli\skills')) }
|
|
241
|
+
}
|
|
242
|
+
if ('claude' -in $Provider) {
|
|
243
|
+
$providerSkillRoots += $(if ($ProviderScope -eq 'workspace') { Join-Path $WorkspaceRoot '.claude\skills' } else { Join-Path $ClaudeHome 'skills' })
|
|
244
|
+
}
|
|
245
|
+
if (-not $PSBoundParameters.ContainsKey('SkillsRoot') -and $providerSkillRoots.Count) { $SkillsRoot = $providerSkillRoots[0] }
|
|
246
|
+
$primarySkillsPath = [System.IO.Path]::GetFullPath($SkillsRoot)
|
|
247
|
+
$additionalSkillRoots = @($providerSkillRoots |
|
|
248
|
+
Where-Object { [System.IO.Path]::GetFullPath($_) -ne $primarySkillsPath } |
|
|
249
|
+
Select-Object -Unique)
|
|
250
|
+
$efficientTarget = Join-Path $SkillsRoot 'efficient-coding'
|
|
251
|
+
$odooTarget = Join-Path $SkillsRoot 'odoo-engineering'
|
|
252
|
+
$expertTarget = Join-Path $SkillsRoot 'afyx-engineering-expert'
|
|
253
|
+
$componentContext = New-AfyxComponentContext -SkillsRoot $SkillsRoot -GraphRoot $graphRuntimeRoot -ContextRoot $ContextRuntimeRoot -ForgeRoot $ForgeRuntimeRoot -CodexHome $codexHome
|
|
254
|
+
$componentStates = @{}
|
|
255
|
+
foreach ($componentState in (Get-AfyxComponentStates -Context $componentContext)) { $componentStates[$componentState.Id] = $componentState }
|
|
256
|
+
foreach ($component in (Get-AfyxComponentContract | Where-Object { $_.type -eq 'skill' })) {
|
|
257
|
+
$state = $componentStates[[string]$component.id]
|
|
258
|
+
if ($state.State -eq 'NOT INSTALLED') { continue }
|
|
259
|
+
$installedOwnership = Get-AfyxSkillOwnership -Target $state.Path -Component ([string]$component.id) -ExpectedOwner ([string]$component.ownership)
|
|
260
|
+
if ($installedOwnership -eq 'AFYX_OWNED_MODIFIED') {
|
|
261
|
+
$state.State = 'DRIFTED'
|
|
262
|
+
$state.Detail = 'Afyx ownership verified but installed content was modified'
|
|
263
|
+
} elseif ($installedOwnership -notin @('AFYX_OWNED_UNMODIFIED', 'EXTERNAL_UPSTREAM')) {
|
|
264
|
+
$state.State = 'UNKNOWN'
|
|
265
|
+
$state.Detail = "installed ownership is $installedOwnership"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
$componentActions = @{}
|
|
269
|
+
$retiredComponentIds = @('prompt-master', 'headroom')
|
|
270
|
+
function Assert-ActiveComponentId([string]$Id) {
|
|
271
|
+
if ($Id -in $retiredComponentIds) {
|
|
272
|
+
throw "Component '$Id' is retired from Afyx Kit and remains externally/user managed; no changes were made."
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
foreach ($specification in $ComponentAction) {
|
|
276
|
+
if ($specification -notmatch '^([a-z0-9-]+)=(skip|install|update|repair|adopt)$') {
|
|
277
|
+
throw "Invalid -ComponentAction '$specification'. Use component-id=skip|install|update|repair|adopt."
|
|
278
|
+
}
|
|
279
|
+
Assert-ActiveComponentId $Matches[1]
|
|
280
|
+
$componentActions[$Matches[1]] = $Matches[2]
|
|
281
|
+
}
|
|
282
|
+
$knownSelectable = @('efficient-coding', 'odoo-engineering', 'afyx-engineering-expert', 'afyx-graph', 'afyx-context', 'afyx-forge', 'codex-usage-tracking')
|
|
283
|
+
foreach ($id in $componentActions.Keys) { if ($id -notin $knownSelectable) { throw "Unknown selectable component: $id" } }
|
|
284
|
+
if ($Preset -and $Preset -notin @('minimal', 'recommended', 'full', 'custom')) { throw "Unknown preset: $Preset" }
|
|
285
|
+
if (-not $Preset -and $CustomComponent.Count) { throw '-CustomComponent requires -Preset custom.' }
|
|
286
|
+
foreach ($id in $CustomComponent) { Assert-ActiveComponentId $id }
|
|
287
|
+
if ($Preset -and ($ComponentAction.Count -or $Force -or $InstallUsageTracker -or $SkipUsageTracker)) {
|
|
288
|
+
throw 'A preset is immutable for one operation; do not combine it with ComponentAction, Force, InstallUsageTracker, or SkipUsageTracker.'
|
|
289
|
+
}
|
|
290
|
+
$controlPlan = if ($Preset) { Get-AfyxControlPlan -Preset $Preset -CustomComponent $CustomComponent -Provider $Provider -Context $componentContext -StateById $componentStates } else { $null }
|
|
291
|
+
|
|
292
|
+
function Get-AvailableVersion([string]$Id) {
|
|
293
|
+
switch ($Id) {
|
|
294
|
+
'efficient-coding' { return Get-AfyxSkillVersion -Directory $bundledEfficientCoding }
|
|
295
|
+
'odoo-engineering' { return Get-AfyxSkillVersion -Directory $bundledOdooEngineering }
|
|
296
|
+
'afyx-engineering-expert' { return Get-AfyxSkillVersion -Directory $bundledEngineeringExpert }
|
|
297
|
+
'afyx-graph' { return (Get-Content -Raw -LiteralPath $graphMetadataPath | ConvertFrom-Json).product_version }
|
|
298
|
+
'afyx-context' { return (Get-Content -Raw -LiteralPath $contextMetadataPath | ConvertFrom-Json).product_version }
|
|
299
|
+
'afyx-forge' { return (Get-Content -Raw -LiteralPath $forgeMetadataPath | ConvertFrom-Json).product_version }
|
|
300
|
+
default { return '' }
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function Compare-AfyxVersion([string]$Installed, [string]$Available) {
|
|
305
|
+
if (-not $Installed -or -not $Available) { return 0 }
|
|
306
|
+
try { return ([version]$Installed).CompareTo([version]$Available) }
|
|
307
|
+
catch { return [string]::Compare($Installed, $Available, $true) }
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function Get-ComponentAction([string]$Id, [string]$Label) {
|
|
311
|
+
$state = $componentStates[$Id]
|
|
312
|
+
if ($componentActions.ContainsKey($Id)) { $action = $componentActions[$Id] }
|
|
313
|
+
elseif ($controlPlan) {
|
|
314
|
+
$planItem = @($controlPlan.Components | Where-Object { $_.Id -eq $Id })[0]
|
|
315
|
+
if (-not $planItem.Desired -or $planItem.Drift -eq 'NOT_APPLICABLE') { $action = 'skip' }
|
|
316
|
+
elseif ($planItem.Repair -eq 'BLOCKED') { $action = 'blocked' }
|
|
317
|
+
elseif ($planItem.Repair -eq 'INSTALL') { $action = 'install' }
|
|
318
|
+
elseif ($planItem.Repair -eq 'REPAIR') { $action = 'repair' }
|
|
319
|
+
else {
|
|
320
|
+
$available = Get-AvailableVersion $Id
|
|
321
|
+
if ($state.State -eq 'HEALTHY' -and $available) {
|
|
322
|
+
$comp = Compare-AfyxVersion $state.Version $available
|
|
323
|
+
if ($comp -lt 0) { $action = 'update' }
|
|
324
|
+
elseif ($comp -gt 0 -and ($AllowDowngrade -or $Force)) { $action = 'downgrade' }
|
|
325
|
+
else { $action = 'skip' }
|
|
326
|
+
} else { $action = 'skip' }
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
elseif ($Force) {
|
|
330
|
+
if ($state.State -eq 'UNKNOWN') { throw "$Label ownership is unknown; -Force cannot take ownership." }
|
|
331
|
+
$action = if ($state.State -eq 'NOT INSTALLED') { 'install' }
|
|
332
|
+
elseif ($state.State -in @('INCOMPLETE', 'INVALID', 'DRIFTED')) { 'repair' }
|
|
333
|
+
elseif ($available -and (Compare-AfyxVersion $state.Version $available) -gt 0) { 'downgrade' }
|
|
334
|
+
else { 'update' }
|
|
335
|
+
} elseif ($UpdateInstalled) {
|
|
336
|
+
$available = Get-AvailableVersion $Id
|
|
337
|
+
if ($state.State -in @('INCOMPLETE', 'INVALID', 'DRIFTED')) { $action = 'repair' }
|
|
338
|
+
elseif ($state.State -eq 'HEALTHY' -and $available) {
|
|
339
|
+
$comp = Compare-AfyxVersion $state.Version $available
|
|
340
|
+
if ($comp -lt 0) { $action = 'update' }
|
|
341
|
+
elseif ($comp -gt 0 -and $AllowDowngrade) { $action = 'downgrade' }
|
|
342
|
+
else { $action = 'skip' }
|
|
343
|
+
} else { $action = 'skip' }
|
|
344
|
+
} elseif ($WhatIfPreference -or $env:CI -or -not $terminal.Interactive) { $action = 'skip' }
|
|
345
|
+
else {
|
|
346
|
+
$available = Get-AvailableVersion $Id
|
|
347
|
+
$versionDetail = if ($state.Version -or $available) { " installed=$($state.Version) available=$available" } else { '' }
|
|
348
|
+
if ($state.State -eq 'NOT INSTALLED') {
|
|
349
|
+
do { $answer = (Read-Host "$Label is not installed.$versionDetail [I] Install / [S] Skip [S]").Trim() } until ($answer -match '(?i)^(|i|install|s|skip)$')
|
|
350
|
+
$action = if ($answer -match '(?i)^(i|install)$') { 'install' } else { 'skip' }
|
|
351
|
+
} elseif ($state.State -eq 'HEALTHY') {
|
|
352
|
+
$default = if ($available -and (Compare-AfyxVersion $state.Version $available) -lt 0) { 'U' } else { 'S' }
|
|
353
|
+
do { $answer = (Read-Host "$Label is healthy.$versionDetail [U] Update / [S] Skip [$default]").Trim() } until ($answer -match '(?i)^(|u|update|s|skip)$')
|
|
354
|
+
$action = if ($answer -match '(?i)^(u|update)$' -or (-not $answer -and $default -eq 'U')) { 'update' } else { 'skip' }
|
|
355
|
+
} elseif ($state.State -in @('INCOMPLETE', 'INVALID', 'DRIFTED')) {
|
|
356
|
+
do { $answer = (Read-Host "$Label is $($state.State): $($state.Detail) [R] Repair / [S] Skip [S]").Trim() } until ($answer -match '(?i)^(|r|repair|s|skip)$')
|
|
357
|
+
$action = if ($answer -match '(?i)^(r|repair)$') { 'repair' } else { 'skip' }
|
|
358
|
+
} else {
|
|
359
|
+
do { $answer = (Read-Host "$Label ownership/health is unknown. [A] Adopt verified legacy install / [S] Skip [S]").Trim() } until ($answer -match '(?i)^(|a|adopt|s|skip)$')
|
|
360
|
+
$action = if ($answer -match '(?i)^(a|adopt)$') { 'adopt' } else { 'skip' }
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if ($action -eq 'blocked') { return $action }
|
|
364
|
+
$allowed = switch ($state.State) {
|
|
365
|
+
'NOT INSTALLED' { @('install', 'skip') }
|
|
366
|
+
'HEALTHY' { @('update', 'downgrade', 'repair', 'adopt', 'skip') }
|
|
367
|
+
{ $_ -in @('INCOMPLETE', 'INVALID', 'DRIFTED') } { @('repair', 'skip') }
|
|
368
|
+
'UNKNOWN' { @('adopt', 'skip') }
|
|
369
|
+
default { @('skip') }
|
|
370
|
+
}
|
|
371
|
+
if ($action -notin $allowed) { throw "$Label state $($state.State) does not permit '$action' (allowed: $($allowed -join ', '))." }
|
|
372
|
+
return $action
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function Resolve-ComponentAction([string]$Id, [string]$Label) {
|
|
376
|
+
if ($Id -eq 'codex-usage-tracking') {
|
|
377
|
+
if ('codex' -notin $Provider) { return 'skip' }
|
|
378
|
+
if ($InstallUsageTracker) {
|
|
379
|
+
$state = $componentStates[$Id]
|
|
380
|
+
if ($state.State -eq 'NOT INSTALLED') { return 'install' }
|
|
381
|
+
if ($state.State -in @('INCOMPLETE', 'INVALID', 'DRIFTED')) { return 'repair' }
|
|
382
|
+
return 'update'
|
|
383
|
+
}
|
|
384
|
+
if ($SkipUsageTracker) { return 'skip' }
|
|
385
|
+
}
|
|
386
|
+
return Get-ComponentAction $Id $Label
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function Test-SkillManifest([string]$SkillDirectory) {
|
|
390
|
+
$manifest = Join-Path $SkillDirectory 'SKILL.md'
|
|
391
|
+
if (-not (Test-Path -LiteralPath $manifest -PathType Leaf)) { return $false }
|
|
392
|
+
return (Get-Content -LiteralPath $manifest -TotalCount 1 -Encoding utf8) -eq '---'
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function Read-ReplaceChoice([string]$Label) {
|
|
396
|
+
if ($Force) { return 'Replace' }
|
|
397
|
+
if ($WhatIfPreference -or $env:CI -or -not $terminal.Interactive) { return 'Skip' }
|
|
398
|
+
do { $answer = (Read-Host "$Label [S] Skip / [R] Replace [S]").Trim() } until ($answer -match '(?i)^(|s|skip|r|replace)$')
|
|
399
|
+
if ($answer -match '(?i)^(r|replace)$') { return 'Replace' }
|
|
400
|
+
return 'Skip'
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function Read-InstallChoice([string]$Label) {
|
|
404
|
+
if ($WhatIfPreference -or $env:CI -or -not $terminal.Interactive) { return $false }
|
|
405
|
+
do { $answer = (Read-Host "$Label [Y/N] [N]").Trim() } until ($answer -match '(?i)^(|y|yes|n|no)$')
|
|
406
|
+
return $answer -match '(?i)^(y|yes)$'
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function Install-ManagedSkillSafely([string]$Component, [string]$Name, [string]$Source, [string]$Target, [bool]$ReplaceExisting, [string]$InstallRoot = $SkillsRoot, [bool]$AuthorizeRepair = $false) {
|
|
410
|
+
if ((Test-Path -LiteralPath $Target) -and -not $ReplaceExisting) { return 'skipped' }
|
|
411
|
+
if ($WhatIfPreference) { Write-Host "WhatIf: would stage and install $Name at $Target"; return 'planned' }
|
|
412
|
+
Assert-AfyxSkillTarget -SkillsRoot $InstallRoot -Target $Target
|
|
413
|
+
$parent = Split-Path -Parent $Target
|
|
414
|
+
New-Item -ItemType Directory -Force -Path $parent | Out-Null
|
|
415
|
+
$stage = Join-Path $parent ".$((Split-Path -Leaf $Target))-stage-$([guid]::NewGuid().ToString('N'))"
|
|
416
|
+
try {
|
|
417
|
+
Copy-Item -LiteralPath $Source -Destination $stage -Recurse -Force -ErrorAction Stop
|
|
418
|
+
if (-not (Test-SkillManifest $stage)) { throw "$Name staged manifest is invalid." }
|
|
419
|
+
$planRepair = $controlPlan -and @($controlPlan.Components | Where-Object { $_.Id -eq $Component -and $_.Repair -eq 'REPAIR' }).Count -eq 1
|
|
420
|
+
$authorized = $Force -or $componentActions.ContainsKey($Component) -or $planRepair -or $AuthorizeRepair
|
|
421
|
+
Install-AfyxSkillTransaction -SkillsRoot $InstallRoot -Component $Component -Name $Name -Stage $stage -Target $Target -Owner afyx -Version (Get-AfyxSkillVersion -Directory $Source) -AuthorizeUnproven:$authorized
|
|
422
|
+
} finally {
|
|
423
|
+
if (Test-Path -LiteralPath $stage) { Remove-Item -LiteralPath $stage -Recurse -Force -ErrorAction SilentlyContinue }
|
|
424
|
+
}
|
|
425
|
+
return $(if ($ReplaceExisting) { 'replaced' } else { 'installed' })
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function Adopt-LegacySkillSafely([string]$Component, [string]$Name, [string]$Target) {
|
|
429
|
+
$contract = @(Get-AfyxComponentContract | Where-Object { $_.id -eq $Component })[0]
|
|
430
|
+
$legacyVersion = if ($contract.PSObject.Properties['legacy_version']) { [string]$contract.legacy_version } else { '' }
|
|
431
|
+
$legacyDigest = if ($contract.PSObject.Properties['legacy_content_digest']) { [string]$contract.legacy_content_digest } else { '' }
|
|
432
|
+
$repository = if ($contract.PSObject.Properties['source']) { [string]$contract.source } else { '' }
|
|
433
|
+
$revision = if ($contract.PSObject.Properties['source_revision']) { [string]$contract.source_revision } else { '' }
|
|
434
|
+
$current = Get-AfyxSkillOwnership -Target $Target -Component $Component -ExpectedOwner ([string]$contract.ownership)
|
|
435
|
+
if ($current -in @('AFYX_OWNED_UNMODIFIED', 'EXTERNAL_UPSTREAM')) { return 'already adopted' }
|
|
436
|
+
$provenance = Get-AfyxLegacySkillProvenance -Target $Target -Component $Component -Owner ([string]$contract.ownership) `
|
|
437
|
+
-LegacyVersion $legacyVersion -LegacyContentSha256 $legacyDigest -SourceRepository $repository -SourceRevision $revision
|
|
438
|
+
if ($provenance -ne 'MATCH') { throw "Refusing to adopt $Name because legacy provenance is $provenance." }
|
|
439
|
+
if ($WhatIfPreference) { Write-Host "WhatIf: would adopt verified legacy $Name at $Target after durable backup"; return 'planned adoption' }
|
|
440
|
+
return Adopt-AfyxLegacySkill -SkillsRoot $SkillsRoot -Target $Target -Component $Component -Owner ([string]$contract.ownership) `
|
|
441
|
+
-Version $legacyVersion -LegacyVersion $legacyVersion -LegacyContentSha256 $legacyDigest `
|
|
442
|
+
-SourceRepository $repository -SourceRevision $revision
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (-not (Test-SkillManifest $bundledEfficientCoding)) { throw 'Bundled Efficient Coding is invalid or missing.' }
|
|
446
|
+
if (-not (Test-SkillManifest $bundledOdooEngineering)) { throw 'Bundled Odoo Engineering is invalid or missing.' }
|
|
447
|
+
if (-not (Test-SkillManifest $bundledEngineeringExpert)) { throw 'Bundled Afyx Engineering Expert is invalid or missing.' }
|
|
448
|
+
if (-not (Test-Path -LiteralPath $graphMetadataPath -PathType Leaf)) { throw 'Bundled Afyx Graph metadata is missing.' }
|
|
449
|
+
if (-not (Test-Path -LiteralPath $contextMetadataPath -PathType Leaf)) { throw 'Bundled Afyx Context metadata is missing.' }
|
|
450
|
+
|
|
451
|
+
$componentLabels = [ordered]@{
|
|
452
|
+
'efficient-coding' = 'Efficient Coding'
|
|
453
|
+
'odoo-engineering' = 'Odoo Engineering'
|
|
454
|
+
'afyx-engineering-expert' = 'Afyx Engineering Expert'
|
|
455
|
+
'afyx-graph' = 'Afyx Graph'
|
|
456
|
+
'afyx-context' = 'Afyx Context Engine'
|
|
457
|
+
'afyx-forge' = 'Afyx Forge Core'
|
|
458
|
+
'codex-usage-tracking' = 'Usage Tracking'
|
|
459
|
+
}
|
|
460
|
+
$actionDecisions = [ordered]@{}
|
|
461
|
+
if ($controlPlan) {
|
|
462
|
+
foreach ($decision in $componentLabels.GetEnumerator()) {
|
|
463
|
+
$actionDecisions[$decision.Key] = Resolve-ComponentAction ([string]$decision.Key) ([string]$decision.Value)
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
$codexCliDetected = [bool]$codexCommandDetected
|
|
468
|
+
$graphMetadata = Get-Content -Raw -LiteralPath $graphMetadataPath | ConvertFrom-Json
|
|
469
|
+
$distProductPath = Join-Path $packageRoot 'afyx-graph\engine\scripts\distribution-product.json'
|
|
470
|
+
$graphReleaseChannel = if (Test-Path -LiteralPath $distProductPath -PathType Leaf) {
|
|
471
|
+
(Get-Content -Raw -LiteralPath $distProductPath | ConvertFrom-Json).releaseChannel
|
|
472
|
+
} elseif ($graphMetadata.PSObject.Properties['release_channel']) {
|
|
473
|
+
[string]$graphMetadata.release_channel
|
|
474
|
+
} else {
|
|
475
|
+
'technical-alpha'
|
|
476
|
+
}
|
|
477
|
+
$states = [ordered]@{
|
|
478
|
+
'Efficient Coding' = $componentStates['efficient-coding'].State
|
|
479
|
+
'Odoo Engineering' = $componentStates['odoo-engineering'].State
|
|
480
|
+
'Afyx Engineering Expert' = $componentStates['afyx-engineering-expert'].State
|
|
481
|
+
'Afyx Graph' = $componentStates['afyx-graph'].State
|
|
482
|
+
'Afyx Context Engine' = $componentStates['afyx-context'].State
|
|
483
|
+
'Afyx Forge Core' = $componentStates['afyx-forge'].State
|
|
484
|
+
'Usage Tracking' = $componentStates['codex-usage-tracking'].State
|
|
485
|
+
}
|
|
486
|
+
Write-AfyxSection -Title 'Component Inventory' -Terminal $terminal
|
|
487
|
+
foreach ($entry in $states.GetEnumerator()) {
|
|
488
|
+
$id = switch ($entry.Key) { 'Efficient Coding' { 'efficient-coding' } 'Odoo Engineering' { 'odoo-engineering' } 'Afyx Engineering Expert' { 'afyx-engineering-expert' } 'Afyx Graph' { 'afyx-graph' } 'Afyx Context Engine' { 'afyx-context' } 'Afyx Forge Core' { 'afyx-forge' } default { 'codex-usage-tracking' } }
|
|
489
|
+
$installed = $componentStates[$id].Version
|
|
490
|
+
$available = Get-AvailableVersion $id
|
|
491
|
+
$status = if ($entry.Value -eq 'HEALTHY' -and $installed -and $available -and (Compare-AfyxVersion $installed $available) -lt 0) { 'UPDATE AVAILABLE' }
|
|
492
|
+
elseif ($entry.Value -eq 'HEALTHY') { 'HEALTHY' }
|
|
493
|
+
elseif ($entry.Value -eq 'NOT INSTALLED') { 'NOT INSTALLED' }
|
|
494
|
+
else { 'BLOCKED' }
|
|
495
|
+
$detail = "installed=$(if ($installed) { $installed } else { 'n/a' }); available=$(if ($available) { $available } else { 'external/n/a' }); ownership=$($componentStates[$id].Ownership)"
|
|
496
|
+
Write-AfyxStatus -Status $status -Name $entry.Key -Detail $detail -Terminal $terminal
|
|
497
|
+
}
|
|
498
|
+
if ($controlPlan) {
|
|
499
|
+
Write-AfyxSection -Title "Desired State Plan | $($controlPlan.Identity)" -Terminal $terminal
|
|
500
|
+
foreach ($item in $controlPlan.Components) {
|
|
501
|
+
$decidedAction = [string]$actionDecisions[[string]$item.Id]
|
|
502
|
+
$planStatus = if ($decidedAction -eq 'blocked') { 'BLOCKED' }
|
|
503
|
+
elseif ($decidedAction -ne 'skip') { 'PLANNED' }
|
|
504
|
+
elseif ($item.Drift -eq 'IN_SYNC') { 'NO CHANGE' }
|
|
505
|
+
elseif ($item.Drift -eq 'EXTRA') { 'EXTRA' }
|
|
506
|
+
else { 'SKIPPED' }
|
|
507
|
+
$planDetail = "action=$decidedAction; desired=$($item.Desired); actual=$($item.ActualState); drift=$($item.Drift); ownership=$($item.ActualOwnership); repair=$($item.Repair)"
|
|
508
|
+
if ($planStatus -eq 'EXTRA') { $planDetail += '; installed optional component is outside this desired preset and will be preserved' }
|
|
509
|
+
Write-AfyxStatus -Status $planStatus -Name $item.Id -Detail $planDetail -Terminal $terminal
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
Write-AfyxSection -Title 'Prerequisite Inventory' -Terminal $terminal
|
|
513
|
+
$gitVersion = try { (& git --version 2>$null) -join ' ' } catch { '' }
|
|
514
|
+
$nodeVersion = try { (& node --version 2>$null) -join ' ' } catch { '' }
|
|
515
|
+
$npmVersion = try { (& npm --version 2>$null) -join ' ' } catch { '' }
|
|
516
|
+
Write-AfyxStatus -Status HEALTHY -Name 'OS/architecture [REQUIRED]' -Detail "$([System.Runtime.InteropServices.RuntimeInformation]::OSDescription) / $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)" -Terminal $terminal
|
|
517
|
+
Write-AfyxStatus -Status HEALTHY -Name 'Platform shell [REQUIRED]' -Detail "PowerShell $($PSVersionTable.PSVersion)" -Terminal $terminal
|
|
518
|
+
Write-AfyxStatus -Status $(if ($gitVersion) { 'HEALTHY' } else { 'BLOCKED' }) -Name 'Git [REQUIRED]' -Detail $(if ($gitVersion) { $gitVersion } else { 'missing; install Git for Windows from https://git-scm.com/' }) -Terminal $terminal
|
|
519
|
+
$codexRequired = 'codex' -in $Provider -or -not $Provider.Count
|
|
520
|
+
$codexStatus = if ($codexCliDetected) { 'HEALTHY' } elseif ($codexRequired) { 'BLOCKED' } elseif ($vscodeExtensionDetected) { 'HEALTHY' } else { 'SKIPPED' }
|
|
521
|
+
$codexLabel = if ($codexRequired) { 'Codex host [REQUIRED]' } else { 'Codex host' }
|
|
522
|
+
$codexDetail = if ($codexCliDetected) { "native CLI detected ($($codexHost.Command))" } elseif ($codexRequired) { "$($codexHost.Detail) A VS Code extension does not provide native MCP configuration." } elseif ($vscodeExtensionDetected) { 'VS Code extension detected; native CLI not selected' } else { 'not detected; required only when selected' }
|
|
523
|
+
Write-AfyxStatus -Status $codexStatus -Name $codexLabel -Detail $codexDetail -Terminal $terminal
|
|
524
|
+
Write-AfyxStatus -Status $(if ($antigravityCommandDetected) { 'HEALTHY' } else { 'SKIPPED' }) -Name 'Antigravity host' -Detail $(if ($antigravityCommandDetected) { 'compatible CLI detected' } elseif ($antigravityIdeDetected) { 'IDE detected; compatible CLI required for automatic MCP registration' } else { 'not detected; required only when selected' }) -Terminal $terminal
|
|
525
|
+
$claudePrereqStatus = switch ($claudeAvailabilityState) {
|
|
526
|
+
'CLI_AND_EXTENSION' { 'HEALTHY' }
|
|
527
|
+
'CLI_AVAILABLE' { 'HEALTHY' }
|
|
528
|
+
'EXTENSION_ONLY' { 'HEALTHY' }
|
|
529
|
+
default { if ('claude' -in $Provider) { 'BLOCKED' } else { 'SKIPPED' } }
|
|
530
|
+
}
|
|
531
|
+
$claudePrereqDetail = switch ($claudeAvailabilityState) {
|
|
532
|
+
'CLI_AND_EXTENSION' { "native CLI and VS Code extension detected ($($claudeCommandDetected.Source))" }
|
|
533
|
+
'CLI_AVAILABLE' { "native CLI detected ($($claudeCommandDetected.Source))" }
|
|
534
|
+
'EXTENSION_ONLY' { 'VS Code extension detected — standalone CLI unavailable' }
|
|
535
|
+
default { 'not detected; required only when selected' }
|
|
536
|
+
}
|
|
537
|
+
Write-AfyxStatus -Status $claudePrereqStatus -Name 'Claude Code host' -Detail $claudePrereqDetail -Terminal $terminal
|
|
538
|
+
Write-AfyxStatus -Status $(if ($nodeVersion) { 'HEALTHY' } else { 'BLOCKED' }) -Name 'Node.js >=22.5.0 [COMPONENT_REQUIRED:Graph/Context]' -Detail $(if ($nodeVersion) { $nodeVersion } else { 'missing; install from https://nodejs.org/ before selecting Graph or Context' }) -Terminal $terminal
|
|
539
|
+
Write-AfyxStatus -Status $(if ($npmVersion) { 'HEALTHY' } else { 'SKIPPED' }) -Name 'npm [BUILD_ONLY:Afyx Graph]' -Detail $(if ($npmVersion) { $npmVersion } else { 'missing; needed only for automatic local fallback' }) -Terminal $terminal
|
|
540
|
+
Write-AfyxStatus -Status HEALTHY -Name 'Archive/checksum [COMPONENT_REQUIRED:Afyx Graph]' -Detail 'Expand-Archive + Get-FileHash available' -Terminal $terminal
|
|
541
|
+
$sourceIsCheckout = $gitVersion -and (Test-Path -LiteralPath (Join-Path $packageRoot '.git'))
|
|
542
|
+
$sourceBranch = if ($sourceIsCheckout) { (& git -C $packageRoot branch --show-current 2>$null) -join '' } else { 'PACKAGED' }
|
|
543
|
+
$sourceCommit = if ($sourceIsCheckout) { (& git -C $packageRoot rev-parse HEAD 2>$null) -join '' } elseif (Test-Path -LiteralPath (Join-Path $packageRoot '.afyx-source-revision') -PathType Leaf) { (Get-Content -Raw -LiteralPath (Join-Path $packageRoot '.afyx-source-revision')).Trim() } else { 'unavailable' }
|
|
544
|
+
$sourceDirty = if ($sourceIsCheckout) { [bool]((& git -C $packageRoot status --porcelain 2>$null) -join '') } else { $false }
|
|
545
|
+
if (-not $sourceBranch) { $sourceBranch = 'DETACHED' }
|
|
546
|
+
Write-AfyxStatus -Status $(if ($sourceDirty) { 'WARNING' } else { 'HEALTHY' }) -Name 'Source identity' -Detail "branch=$sourceBranch; commit=$sourceCommit; dirty=$sourceDirty; channel=$graphReleaseChannel" -Terminal $terminal
|
|
547
|
+
Write-AfyxSection -Title 'Provider Plan' -Terminal $terminal
|
|
548
|
+
if ($SkipProviderConfiguration) { Write-AfyxStatus -Status SKIPPED -Name 'Provider configuration' -Detail 'skipped explicitly; no provider configuration will change' -Terminal $terminal }
|
|
549
|
+
foreach ($providerId in $Provider) {
|
|
550
|
+
$providerRecord = @($providerRegistry | Where-Object { $_.provider -eq $providerId })[0]
|
|
551
|
+
$detected = if ($providerId -eq 'codex') { [bool]$codexCommandDetected }
|
|
552
|
+
elseif ($providerId -eq 'antigravity') { [bool]$antigravityCommandDetected }
|
|
553
|
+
else { $claudeAvailabilityState -ne 'UNAVAILABLE' }
|
|
554
|
+
$configPath = if ($providerId -eq 'codex') { Join-Path $codexHome 'config.toml' }
|
|
555
|
+
elseif ($providerId -eq 'antigravity' -and $ProviderScope -eq 'workspace') { Join-Path $WorkspaceRoot '.agents\mcp_config.json' }
|
|
556
|
+
elseif ($providerId -eq 'antigravity') { Join-Path $GeminiHome 'config\mcp_config.json' }
|
|
557
|
+
elseif ($ProviderScope -eq 'workspace') { Join-Path $WorkspaceRoot '.mcp.json' }
|
|
558
|
+
elseif ($ClaudeConfigDir) { Join-Path $ClaudeConfigDir '.claude.json' }
|
|
559
|
+
else { Join-Path $env:USERPROFILE '.claude.json' }
|
|
560
|
+
$effectiveScope = if ($providerId -eq 'codex') { 'global' } else { $ProviderScope }
|
|
561
|
+
Write-AfyxStatus -Status $(if ($detected) { 'PLANNED' } else { 'BLOCKED' }) -Name $providerRecord.name -Detail "detected=$detected; scope=$effectiveScope; capabilities=$($providerRecord.capabilities); planned-config=$configPath" -Terminal $terminal
|
|
562
|
+
if ($providerId -eq 'antigravity') {
|
|
563
|
+
$plannedSkills = if ($ProviderScope -eq 'workspace') { Join-Path $WorkspaceRoot '.agents\skills' }
|
|
564
|
+
else { @((Join-Path $GeminiHome 'config\skills'), (Join-Path $GeminiHome 'antigravity-cli\skills')) -join ';' }
|
|
565
|
+
Write-AfyxStatus -Status PLANNED -Name 'Antigravity skills' -Detail $plannedSkills -Terminal $terminal
|
|
566
|
+
} elseif ($providerId -eq 'claude') {
|
|
567
|
+
$plannedSkills = if ($ProviderScope -eq 'workspace') { Join-Path $WorkspaceRoot '.claude\skills' } else { Join-Path $ClaudeHome 'skills' }
|
|
568
|
+
Write-AfyxStatus -Status PLANNED -Name 'Claude Code skills' -Detail $plannedSkills -Terminal $terminal
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
$graphState = $states['Afyx Graph']
|
|
572
|
+
$graphAction = if ($ValidateOnly) { 'skip' } elseif ($controlPlan) { [string]$actionDecisions['afyx-graph'] } else { Resolve-ComponentAction 'afyx-graph' 'Afyx Graph' }
|
|
573
|
+
$contextAction = if ($ValidateOnly) { 'skip' } elseif ($controlPlan) { [string]$actionDecisions['afyx-context'] } else { Resolve-ComponentAction 'afyx-context' 'Afyx Context Engine' }
|
|
574
|
+
$forgeAction = if ($ValidateOnly) { 'skip' } elseif ($controlPlan) { [string]$actionDecisions['afyx-forge'] } else { Resolve-ComponentAction 'afyx-forge' 'Afyx Forge Core' }
|
|
575
|
+
$providerTool = Join-Path $packageRoot 'scripts\afyx-provider-integration.mjs'
|
|
576
|
+
$hostBridgeLifecycle = Join-Path $packageRoot 'scripts\afyx-host-bridge-lifecycle.mjs'
|
|
577
|
+
$nodeCommand = Get-Command node -ErrorAction SilentlyContinue
|
|
578
|
+
$plannedProviderEntry = Join-Path $graphRuntimeRoot 'current\lib\dist\bin\afyx-graph.js'
|
|
579
|
+
$providerMcpRequested = -not $SkipGraphMcp -and -not $SkipProviderConfiguration -and $Provider.Count -and `
|
|
580
|
+
($graphAction -ne 'skip' -or (Test-Path -LiteralPath $plannedProviderEntry -PathType Leaf))
|
|
581
|
+
function Get-AfyxProviderArguments([string]$Entry) {
|
|
582
|
+
$arguments = @($providerTool, '--providers', ($Provider -join ','), '--scope', $ProviderScope,
|
|
583
|
+
'--workspace-root', $WorkspaceRoot, '--gemini-home', $GeminiHome, '--codex-home', $codexHome,
|
|
584
|
+
'--node', $nodeCommand.Source, '--entry', $Entry)
|
|
585
|
+
if ($codexCommandDetected) { $arguments += @('--codex', $codexCommandDetected.Source) }
|
|
586
|
+
if ($claudeCommandDetected) { $arguments += @('--claude', $claudeCommandDetected.Source) }
|
|
587
|
+
elseif ($claudeVsCodeDetected) { $arguments += @('--claude-extension') }
|
|
588
|
+
if ($ClaudeConfigDir) { $arguments += @('--claude-config-dir', $ClaudeConfigDir) }
|
|
589
|
+
return $arguments
|
|
590
|
+
}
|
|
591
|
+
function Get-AfyxWorkflowProviderArguments([string]$Entry, [string[]]$TargetProviders) {
|
|
592
|
+
$arguments = @($providerTool, '--providers', ($TargetProviders -join ','), '--scope', $ProviderScope,
|
|
593
|
+
'--workspace-root', $WorkspaceRoot, '--gemini-home', $GeminiHome, '--codex-home', $codexHome,
|
|
594
|
+
'--node', $nodeCommand.Source, '--entry', $Entry, '--server', 'afyx_workflow', '--mode', 'workflow',
|
|
595
|
+
'--tool', 'afyx_workflow', '--install-root', $AfyxInstallRoot, '--authorize', 'afyx-graph,afyx-context')
|
|
596
|
+
if ($claudeCommandDetected) { $arguments += @('--claude', $claudeCommandDetected.Source) }
|
|
597
|
+
elseif ($claudeVsCodeDetected) { $arguments += @('--claude-extension') }
|
|
598
|
+
if ($ClaudeConfigDir) { $arguments += @('--claude-config-dir', $ClaudeConfigDir) }
|
|
599
|
+
return $arguments
|
|
600
|
+
}
|
|
601
|
+
if (-not $ValidateOnly -and $providerMcpRequested -and $nodeCommand -and ('codex' -notin $Provider -or $codexCliDetected)) {
|
|
602
|
+
$preflightArguments = Get-AfyxProviderArguments $plannedProviderEntry
|
|
603
|
+
$preflightJson = (& $nodeCommand.Source @preflightArguments 2>$null) -join ''
|
|
604
|
+
try { $preflightResult = $preflightJson | ConvertFrom-AfyxJson -Depth 20 }
|
|
605
|
+
catch { throw "Provider preflight did not return valid JSON: $preflightJson" }
|
|
606
|
+
if (-not $preflightResult -or -not $preflightResult.PSObject.Properties['providers']) {
|
|
607
|
+
throw "Provider preflight result missing 'providers': $preflightJson"
|
|
608
|
+
}
|
|
609
|
+
$preflightBlocked = @($preflightResult.providers | Where-Object {
|
|
610
|
+
$_.status -in @('BLOCKED', 'INCOMPATIBLE') -and
|
|
611
|
+
-not ($_.reason -in @('GRAPH_RUNTIME_UNAVAILABLE', 'MCP_RUNTIME_UNAVAILABLE') -and $graphAction -ne 'skip')
|
|
612
|
+
})
|
|
613
|
+
if ($preflightBlocked.Count) {
|
|
614
|
+
$blocked = $preflightBlocked[0]
|
|
615
|
+
throw "Provider plan is blocked before mutation: $($blocked.provider): $($blocked.reason): $($blocked.detail)"
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if ($ValidateOnly) {
|
|
620
|
+
[pscustomobject]@{
|
|
621
|
+
BundledEfficientCoding = Test-SkillManifest $bundledEfficientCoding
|
|
622
|
+
InstalledEfficientCoding = $states['Efficient Coding'] -eq 'HEALTHY'
|
|
623
|
+
EfficientCodingState = $states['Efficient Coding']
|
|
624
|
+
EfficientCodingVersion = $componentStates['efficient-coding'].Version
|
|
625
|
+
BundledOdooEngineering = Test-SkillManifest $bundledOdooEngineering
|
|
626
|
+
InstalledOdooEngineering = $states['Odoo Engineering'] -eq 'HEALTHY'
|
|
627
|
+
OdooEngineeringState = $states['Odoo Engineering']
|
|
628
|
+
OdooEngineeringVersion = $componentStates['odoo-engineering'].Version
|
|
629
|
+
BundledAfyxEngineeringExpert = Test-SkillManifest $bundledEngineeringExpert
|
|
630
|
+
InstalledAfyxEngineeringExpert = $states['Afyx Engineering Expert'] -eq 'HEALTHY'
|
|
631
|
+
AfyxEngineeringExpertState = $states['Afyx Engineering Expert']
|
|
632
|
+
AfyxEngineeringExpertVersion = $componentStates['afyx-engineering-expert'].Version
|
|
633
|
+
BundledAfyxGraphSource = Test-Path -LiteralPath (Join-Path $packageRoot 'afyx-graph\engine\package.json')
|
|
634
|
+
InstalledAfyxGraph = $states['Afyx Graph'] -eq 'HEALTHY'
|
|
635
|
+
AfyxGraphState = $states['Afyx Graph']
|
|
636
|
+
AfyxGraphVersion = $graphMetadata.product_version
|
|
637
|
+
AfyxGraphRuntimeRoot = $graphRuntimeRoot
|
|
638
|
+
BundledAfyxContextSource = Test-Path -LiteralPath (Join-Path $packageRoot 'afyx-context\package.json')
|
|
639
|
+
InstalledAfyxContext = $states['Afyx Context Engine'] -eq 'HEALTHY'
|
|
640
|
+
AfyxContextState = $states['Afyx Context Engine']
|
|
641
|
+
AfyxContextVersion = (Get-Content -Raw -LiteralPath $contextMetadataPath | ConvertFrom-Json).product_version
|
|
642
|
+
AfyxContextRuntimeRoot = $ContextRuntimeRoot
|
|
643
|
+
BundledAfyxForgeSource = Test-Path -LiteralPath (Join-Path $packageRoot 'afyx-forge\afyx-forge.json')
|
|
644
|
+
InstalledAfyxForge = $states['Afyx Forge Core'] -eq 'HEALTHY'
|
|
645
|
+
AfyxForgeState = $states['Afyx Forge Core']
|
|
646
|
+
AfyxForgeVersion = (Get-Content -Raw -LiteralPath $forgeMetadataPath | ConvertFrom-Json).product_version
|
|
647
|
+
AfyxForgeRuntimeRoot = $ForgeRuntimeRoot
|
|
648
|
+
InstalledUsageTracker = $states['Usage Tracking'] -eq 'HEALTHY'
|
|
649
|
+
UsageTrackerState = $states['Usage Tracking']
|
|
650
|
+
CodexCliDetected = $codexCliDetected
|
|
651
|
+
VsCodeExtensionDetected = $vscodeExtensionDetected
|
|
652
|
+
ControlPlanIdentity = if ($controlPlan) { $controlPlan.Identity } else { 'LEGACY_INTERACTIVE' }
|
|
653
|
+
ControlPlanDrift = if ($controlPlan) { @($controlPlan.Components | Where-Object { $_.Desired -and $_.Drift -ne 'IN_SYNC' -and $_.Drift -ne 'NOT_APPLICABLE' }).Count } else { 0 }
|
|
654
|
+
} | Format-List
|
|
655
|
+
exit 0
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if ($controlPlan) {
|
|
659
|
+
$blockedPlanItems = @($controlPlan.Components | Where-Object { $_.Desired -and $_.Repair -eq 'BLOCKED' })
|
|
660
|
+
if ($blockedPlanItems.Count) {
|
|
661
|
+
$blockedSummary = ($blockedPlanItems | ForEach-Object { "$($_.Id):$($_.Drift):$($_.ActualOwnership)" }) -join ', '
|
|
662
|
+
throw "Desired-state plan is blocked before mutation: $blockedSummary"
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (-not $SkipProviderConfiguration -and 'codex' -in $Provider -and -not $codexCliDetected) { throw "Selected Codex MCP integration requires a native Codex CLI. $($codexHost.Detail)" }
|
|
667
|
+
if (-not $SkipProviderConfiguration -and 'antigravity' -in $Provider -and -not $agyCommandDetected -and -not (Get-Command antigravity -ErrorAction SilentlyContinue)) { throw 'Selected Antigravity provider host was not detected.' }
|
|
668
|
+
if (-not $SkipProviderConfiguration -and 'claude' -in $Provider -and $claudeAvailabilityState -eq 'UNAVAILABLE') { throw 'Selected Claude Code provider host was not detected.' }
|
|
669
|
+
if ($providerMcpRequested -and -not $nodeCommand) { throw 'Node.js is required for selected provider MCP configuration.' }
|
|
670
|
+
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { throw 'Git is required for Afyx source validation and lifecycle updates.' }
|
|
671
|
+
|
|
672
|
+
if ($graphAction -ne 'skip') {
|
|
673
|
+
$graphReleaseCandidates = @(
|
|
674
|
+
(Join-Path $packageRoot 'afyx-graph\engine\release\afyx-graph-win32-x64.zip'),
|
|
675
|
+
(Join-Path $packageRoot "afyx-graph\engine\release\afyx-graph-v$($graphMetadata.product_version)-win32-x64.zip"),
|
|
676
|
+
(Join-Path $packageRoot "afyx-graph\release\afyx-graph-v$($graphMetadata.product_version)-win32-x64.zip"),
|
|
677
|
+
(Join-Path $packageRoot 'afyx-graph\release\afyx-graph-win32-x64.zip')
|
|
678
|
+
)
|
|
679
|
+
$hasReleaseCache = [bool](@($graphReleaseCandidates | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf }).Count)
|
|
680
|
+
if (-not $hasReleaseCache) {
|
|
681
|
+
$resolverScript = Join-Path $packageRoot 'scripts\resolve-git-release-artifacts.mjs'
|
|
682
|
+
if ((Test-Path -LiteralPath $resolverScript -PathType Leaf) -and (Get-Command node -ErrorAction SilentlyContinue)) {
|
|
683
|
+
& node $resolverScript 2>$null
|
|
684
|
+
$hasReleaseCache = [bool](@($graphReleaseCandidates | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf }).Count)
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
if (-not $hasReleaseCache) {
|
|
688
|
+
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
|
|
689
|
+
$tarCmd = Get-Command tar -ErrorAction SilentlyContinue
|
|
690
|
+
$enginePackage = Join-Path $packageRoot 'afyx-graph\engine\package.json'
|
|
691
|
+
if (-not (Test-Path -LiteralPath $enginePackage -PathType Leaf)) {
|
|
692
|
+
throw "Afyx Graph installation is BLOCKED: release cache is absent and source engine is missing at $enginePackage."
|
|
693
|
+
}
|
|
694
|
+
if (-not $sourceIsCheckout -or -not $gitCmd -or -not $tarCmd) {
|
|
695
|
+
throw "Afyx Graph installation is BLOCKED: Git and tar are required for clean source staging when building from local repository."
|
|
696
|
+
}
|
|
697
|
+
$gitStatus = & $gitCmd.Source -C $packageRoot status --porcelain -- afyx-graph 2>$null
|
|
698
|
+
$graphSourceDirty = [bool]($gitStatus -join '')
|
|
699
|
+
if ($graphSourceDirty -and -not $AllowDirtySource) {
|
|
700
|
+
$headCommit = (& $gitCmd.Source -C $packageRoot rev-parse HEAD 2>$null).Trim()
|
|
701
|
+
if (-not $headCommit -or $headCommit -notmatch '^[0-9a-f]{7,64}$') {
|
|
702
|
+
throw "Afyx Graph installation is BLOCKED: local afyx-graph source has uncommitted changes and HEAD commit is unavailable. Commit the changes or specify -AllowDirtySource for development builds."
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if ($wizardMode) {
|
|
709
|
+
Show-AfyxStep -Current 4 -Terminal $terminal
|
|
710
|
+
Write-AfyxSection -Title 'Review Actual Planned Changes' -Terminal $terminal
|
|
711
|
+
Write-AfyxStatus -Status INFO -Name 'Policy' -Detail 'Only AFYX-owned entries will be changed; state backup enables rollback' -Terminal $terminal
|
|
712
|
+
Write-AfyxStatus -Status INFO -Name 'Target: Skills' -Detail $SkillsRoot -Terminal $terminal
|
|
713
|
+
if ($graphAction -ne 'skip') {
|
|
714
|
+
Write-AfyxStatus -Status INFO -Name 'Target: Afyx Graph' -Detail $graphRuntimeRoot -Terminal $terminal
|
|
715
|
+
}
|
|
716
|
+
if ($contextAction -ne 'skip') {
|
|
717
|
+
Write-AfyxStatus -Status INFO -Name 'Target: Context' -Detail $ContextRuntimeRoot -Terminal $terminal
|
|
718
|
+
}
|
|
719
|
+
if ($forgeAction -ne 'skip') {
|
|
720
|
+
Write-AfyxStatus -Status INFO -Name 'Target: Forge' -Detail $ForgeRuntimeRoot -Terminal $terminal
|
|
721
|
+
}
|
|
722
|
+
Write-AfyxStatus -Status INFO -Name 'Target: Host Bridge' -Detail $HostBridgeRuntimeRoot -Terminal $terminal
|
|
723
|
+
$mutationPreview = @()
|
|
724
|
+
foreach ($decision in $actionDecisions.GetEnumerator()) {
|
|
725
|
+
if ([string]$decision.Value -eq 'skip') { continue }
|
|
726
|
+
$mutationPreview += [pscustomobject]@{ Id = [string]$decision.Key; Action = [string]$decision.Value }
|
|
727
|
+
Write-AfyxStatus -Status PLANNED -Name ([string]$decision.Key) -Detail ([string]$decision.Value) -Terminal $terminal
|
|
728
|
+
}
|
|
729
|
+
if (-not $SkipProviderConfiguration) {
|
|
730
|
+
foreach ($providerId in $Provider) {
|
|
731
|
+
$effectiveScope = if ($providerId -eq 'codex') { 'global' } else { $ProviderScope }
|
|
732
|
+
Write-AfyxStatus -Status PLANNED -Name "$providerId provider" -Detail "scope=$effectiveScope; Afyx-owned entries only" -Terminal $terminal
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (-not $mutationPreview.Count) { Write-AfyxStatus -Status 'NO CHANGE' -Name 'Components' -Detail 'selected component versions and ownership are already healthy' -Terminal $terminal }
|
|
736
|
+
|
|
737
|
+
if (Test-AfyxDashboard -Terminal $terminal) {
|
|
738
|
+
$terminal.DashboardState.Scroll[2] = 0
|
|
739
|
+
Show-AfyxDashboard -Terminal $terminal -ForceFull
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
try {
|
|
743
|
+
if (($mutationPreview.Count -or (-not $SkipProviderConfiguration -and $Provider.Count)) -and -not (Read-AfyxConfirmation -Prompt 'Apply the reviewed plan?' -Terminal $terminal)) {
|
|
744
|
+
Write-AfyxStatus -Status SKIPPED -Name 'Installation cancelled' -Detail 'no configuration changes were made' -Terminal $terminal
|
|
745
|
+
exit 0
|
|
746
|
+
}
|
|
747
|
+
} catch [System.OperationCanceledException] {
|
|
748
|
+
Write-AfyxStatus -Status SKIPPED -Name 'Installation cancelled' -Detail 'no configuration changes were made' -Terminal $terminal
|
|
749
|
+
exit 130
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function Invoke-AfyxInstallStage {
|
|
754
|
+
param(
|
|
755
|
+
[Parameter(Mandatory)][scriptblock]$Action,
|
|
756
|
+
[Parameter(Mandatory)][string]$Stage,
|
|
757
|
+
[string]$Description = ''
|
|
758
|
+
)
|
|
759
|
+
if (-not $wizardMode -or -not $terminal.Ansi) {
|
|
760
|
+
$output = & $Action 2>&1
|
|
761
|
+
$success = [bool]$?
|
|
762
|
+
$output | Out-Host
|
|
763
|
+
return $success
|
|
764
|
+
}
|
|
765
|
+
$logRoot = Join-Path $AfyxInstallRoot 'logs'
|
|
766
|
+
New-Item -ItemType Directory -Path $logRoot -Force | Out-Null
|
|
767
|
+
$stageSlug = $Stage -replace '[^a-zA-Z0-9_-]', '_'
|
|
768
|
+
$logFile = Join-Path $logRoot ("installer-$stageSlug-$([guid]::NewGuid().ToString('N')).log")
|
|
769
|
+
$detailStart = if ($Description) { "$Description; log: $logFile" } else { "in progress; log: $logFile" }
|
|
770
|
+
Write-AfyxStatus -Status PLANNED -Name $Stage -Detail $detailStart -Terminal $terminal
|
|
771
|
+
$failure = $null
|
|
772
|
+
$global:LASTEXITCODE = 0
|
|
773
|
+
try {
|
|
774
|
+
& $Action *> $logFile
|
|
775
|
+
$success = [bool]$? -and ($LASTEXITCODE -eq 0 -or $LASTEXITCODE -eq $null)
|
|
776
|
+
} catch {
|
|
777
|
+
$failure = $_
|
|
778
|
+
$success = $false
|
|
779
|
+
}
|
|
780
|
+
if (-not $success) {
|
|
781
|
+
$lastLogLines = @(
|
|
782
|
+
if (Test-Path -LiteralPath $logFile) {
|
|
783
|
+
Get-Content -LiteralPath $logFile -Tail 10 | Where-Object { $_ -match '\S' }
|
|
784
|
+
}
|
|
785
|
+
)
|
|
786
|
+
$tailSummary = if ($lastLogLines.Count) { $lastLogLines[-1] } else { '' }
|
|
787
|
+
$diagMsg = if ($failure) { $failure.Exception.Message } elseif ($tailSummary) { $tailSummary } else { "Process exited with code $LASTEXITCODE" }
|
|
788
|
+
Write-AfyxStatus -Status FAILED -Name $Stage -Detail "$diagMsg; log: $logFile" -Terminal $terminal
|
|
789
|
+
if ($failure) { throw $failure }
|
|
790
|
+
else { throw "$Stage failed: $diagMsg (log: $logFile)" }
|
|
791
|
+
} else {
|
|
792
|
+
Write-AfyxStatus -Status HEALTHY -Name $Stage -Detail "completed successfully" -Terminal $terminal
|
|
793
|
+
}
|
|
794
|
+
return $success
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if ($wizardMode) { Show-AfyxStep -Current 4 -Terminal $terminal }
|
|
798
|
+
|
|
799
|
+
$summary = [ordered]@{}
|
|
800
|
+
$changesApplied = $false
|
|
801
|
+
$skillActions = @{}
|
|
802
|
+
$skillDefinitions = @(
|
|
803
|
+
@{ Id = 'efficient-coding'; Name = 'Efficient Coding'; Source = $bundledEfficientCoding; Target = $efficientTarget },
|
|
804
|
+
@{ Id = 'odoo-engineering'; Name = 'Odoo Engineering'; Source = $bundledOdooEngineering; Target = $odooTarget },
|
|
805
|
+
@{ Id = 'afyx-engineering-expert'; Name = 'Afyx Engineering Expert'; Source = $bundledEngineeringExpert; Target = $expertTarget }
|
|
806
|
+
)
|
|
807
|
+
# Prevalidate selected runtime companions before skill, runtime, or MCP mutation.
|
|
808
|
+
# A foreign or modified provider skill must block the plan, not cause a partial
|
|
809
|
+
# install followed by an ownership conflict late in the transaction.
|
|
810
|
+
if (-not $SkipProviderConfiguration -and $Provider.Count) {
|
|
811
|
+
$requestedCompanions = @()
|
|
812
|
+
foreach ($id in @('afyx-context', 'afyx-forge')) {
|
|
813
|
+
$selected = if ($controlPlan) { $id -in $controlPlan.DesiredComponents }
|
|
814
|
+
else { $componentActions.ContainsKey($id) -and $componentActions[$id] -ne 'skip' }
|
|
815
|
+
if ($selected -and ($id -ne 'afyx-context' -or $env:AFYX_CONTEXT_OPT_IN -ne '0')) {
|
|
816
|
+
$requestedCompanions += $id
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
foreach ($id in $requestedCompanions) {
|
|
820
|
+
foreach ($root in @($providerSkillRoots | Select-Object -Unique)) {
|
|
821
|
+
$candidate = Join-Path $root $id
|
|
822
|
+
$ownership = Get-AfyxSkillOwnership -Target $candidate -Component $id -ExpectedOwner 'afyx'
|
|
823
|
+
if ($ownership -notin @('NOT_INSTALLED', 'AFYX_OWNED_UNMODIFIED')) {
|
|
824
|
+
throw "Provider companion preflight blocked before mutation: $candidate ($ownership)."
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
foreach ($component in $skillDefinitions) {
|
|
830
|
+
$skillActions[$component.Id] = if ($controlPlan) { [string]$actionDecisions[$component.Id] } else { Resolve-ComponentAction $component.Id $component.Name }
|
|
831
|
+
}
|
|
832
|
+
foreach ($additionalRoot in $additionalSkillRoots) {
|
|
833
|
+
foreach ($component in $skillDefinitions) {
|
|
834
|
+
$replicaDesired = if ($controlPlan) { $component.Id -in $controlPlan.DesiredComponents } else { $skillActions[$component.Id] -notin @('skip', 'adopt') }
|
|
835
|
+
if (-not $replicaDesired) { continue }
|
|
836
|
+
$target = Join-Path $additionalRoot $component.Id
|
|
837
|
+
$ownership = Get-AfyxSkillOwnership -Target $target -Component $component.Id -ExpectedOwner 'afyx'
|
|
838
|
+
if ($ownership -notin @('NOT_INSTALLED', 'AFYX_OWNED_UNMODIFIED', 'AFYX_OWNED_MODIFIED')) {
|
|
839
|
+
throw "Provider skill plan is blocked at $target because ownership is $ownership."
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
foreach ($component in $skillDefinitions) {
|
|
844
|
+
$action = $skillActions[$component.Id]
|
|
845
|
+
if ($action -eq 'skip') { $summary[$component.Name] = 'skipped'; continue }
|
|
846
|
+
Write-AfyxStatus -Status INFO -Name $component.Name -Detail "$action in progress" -Terminal $terminal
|
|
847
|
+
if ($action -eq 'adopt') { $summary[$component.Name] = Adopt-LegacySkillSafely $component.Id $component.Name $component.Target }
|
|
848
|
+
else { $summary[$component.Name] = Install-ManagedSkillSafely $component.Id $component.Name $component.Source $component.Target ($action -in @('update', 'repair', 'downgrade')) }
|
|
849
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
850
|
+
}
|
|
851
|
+
foreach ($additionalRoot in $additionalSkillRoots) {
|
|
852
|
+
foreach ($component in $skillDefinitions) {
|
|
853
|
+
$action = $skillActions[$component.Id]
|
|
854
|
+
$replicaDesired = if ($controlPlan) { $component.Id -in $controlPlan.DesiredComponents } else { $action -notin @('skip', 'adopt') }
|
|
855
|
+
if (-not $replicaDesired) { continue }
|
|
856
|
+
$target = Join-Path $additionalRoot $component.Id
|
|
857
|
+
$ownership = Get-AfyxSkillOwnership -Target $target -Component $component.Id -ExpectedOwner 'afyx'
|
|
858
|
+
if ($ownership -notin @('NOT_INSTALLED', 'AFYX_OWNED_UNMODIFIED', 'AFYX_OWNED_MODIFIED')) {
|
|
859
|
+
throw "Refusing to replace $($component.Name) at provider skill root $additionalRoot because ownership is $ownership."
|
|
860
|
+
}
|
|
861
|
+
if ($ownership -eq 'AFYX_OWNED_UNMODIFIED' -and (Get-AfyxSkillVersion -Directory $target) -eq (Get-AfyxSkillVersion -Directory $component.Source)) {
|
|
862
|
+
$summary["$($component.Name) [$additionalRoot]"] = 'skipped'
|
|
863
|
+
continue
|
|
864
|
+
}
|
|
865
|
+
$replicate = Install-ManagedSkillSafely $component.Id $component.Name $component.Source $target ($ownership -ne 'NOT_INSTALLED') $additionalRoot ($ownership -eq 'AFYX_OWNED_MODIFIED')
|
|
866
|
+
$summary["$($component.Name) [$additionalRoot]"] = $replicate
|
|
867
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
if ($graphAction -eq 'skip') { $summary['Afyx Graph'] = 'skipped' }
|
|
872
|
+
else {
|
|
873
|
+
Write-AfyxStatus -Status INFO -Name 'Afyx Graph' -Detail "$graphAction in progress" -Terminal $terminal
|
|
874
|
+
$arguments = if ($graphState -eq 'NOT INSTALLED') { @{} } elseif ($graphAction -eq 'update') { @{ Update = $true } } else { @{ Replace = $true } }
|
|
875
|
+
$arguments.RuntimeRoot = $graphRuntimeRoot
|
|
876
|
+
if ($Offline) { $arguments.Offline = $true }
|
|
877
|
+
if ($NoBuildFallback) { $arguments.NoBuildFallback = $true }
|
|
878
|
+
if ($AllowDirtySource) { $arguments.AllowDirtySource = $true }
|
|
879
|
+
if ($SkipGraphPathUpdate) { $arguments.SkipPathUpdate = $true }
|
|
880
|
+
# ProviderAdapter/v1 owns one transactional MCP configuration pass for every selected provider.
|
|
881
|
+
$arguments.SkipMcp = $true
|
|
882
|
+
if (-not (Invoke-AfyxInstallStage -Stage 'Afyx Graph' -Description "$graphAction local build / package verification" -Action { & $graphInstaller -Confirm:$false -WhatIf:$WhatIfPreference @arguments })) { throw 'Afyx Graph installation failed.' }
|
|
883
|
+
$summary['Afyx Graph'] = $graphAction
|
|
884
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
if ($providerMcpRequested) {
|
|
888
|
+
$installedEntry = Join-Path $graphRuntimeRoot 'current\lib\dist\bin\afyx-graph.js'
|
|
889
|
+
$providerArguments = Get-AfyxProviderArguments $installedEntry
|
|
890
|
+
if (-not $WhatIfPreference) { $providerArguments += '--apply' }
|
|
891
|
+
if ($WhatIfPreference) { Write-Host "WhatIf: would configure selected provider MCP entries through ProviderAdapter/v1" }
|
|
892
|
+
elseif (Test-Path -LiteralPath $installedEntry -PathType Leaf) {
|
|
893
|
+
$providerJson = (& $nodeCommand.Source @providerArguments) -join ''
|
|
894
|
+
$providerResult = $providerJson | ConvertFrom-AfyxJson -Depth 20
|
|
895
|
+
Write-Host "Provider transaction: $($providerResult.status)"
|
|
896
|
+
if ($LASTEXITCODE -ne 0 -or $providerResult.status -eq 'BLOCKED') { throw "Provider configuration failed: $providerJson" }
|
|
897
|
+
foreach ($providerEntry in $providerResult.providers) { $summary["$($providerEntry.provider) MCP"] = $providerEntry.status }
|
|
898
|
+
if (@($providerResult.providers | Where-Object { $_.changed }).Count) { $changesApplied = $true }
|
|
899
|
+
} else { throw 'Installed Graph entry is unavailable for selected provider configuration.' }
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
$shouldInstallHostBridge = (-not $SkipProviderConfiguration) -and (
|
|
903
|
+
$changesApplied -or
|
|
904
|
+
(@($actionDecisions.Values | Where-Object { $_ -notin @('skip', 'blocked') }).Count -gt 0) -or
|
|
905
|
+
($controlPlan -and $controlPlan.DesiredComponents.Count -gt 0)
|
|
906
|
+
)
|
|
907
|
+
if ($shouldInstallHostBridge) {
|
|
908
|
+
$hostBridgeInstalledEntry = Join-Path $HostBridgeRuntimeRoot 'current\afyx-host-bridge.mjs'
|
|
909
|
+
if ($WhatIfPreference) {
|
|
910
|
+
Write-Host "WhatIf: would install AfyxHostBridge/v1 at $HostBridgeRuntimeRoot"
|
|
911
|
+
} else {
|
|
912
|
+
$bridgeJson = (& $nodeCommand.Source $hostBridgeLifecycle '--install' '--source-root' (Join-Path $packageRoot 'scripts') `
|
|
913
|
+
'--runtime-root' $HostBridgeRuntimeRoot '--source-revision' $sourceCommit) -join ''
|
|
914
|
+
if ($LASTEXITCODE -ne 0) { throw "Host bridge installation failed: $bridgeJson" }
|
|
915
|
+
$bridgeResult = $bridgeJson | ConvertFrom-AfyxJson -Depth 10
|
|
916
|
+
if ($bridgeResult.status -ne 'READY') { throw "Host bridge verification failed: $bridgeJson" }
|
|
917
|
+
$summary['Afyx Universal Host Bridge'] = if ($bridgeResult.changed) { 'installed' } else { 'skipped' }
|
|
918
|
+
if ($bridgeResult.changed) { $changesApplied = $true }
|
|
919
|
+
}
|
|
920
|
+
$workflowProviders = @($Provider | Where-Object { $_ -eq 'antigravity' -or ($_ -eq 'claude' -and $ProviderScope -eq 'workspace') })
|
|
921
|
+
if ($workflowProviders.Count -and (Test-Path -LiteralPath $hostBridgeInstalledEntry -PathType Leaf)) {
|
|
922
|
+
$wfArguments = Get-AfyxWorkflowProviderArguments $hostBridgeInstalledEntry $workflowProviders
|
|
923
|
+
if (-not $WhatIfPreference) { $wfArguments += '--apply' }
|
|
924
|
+
if ($WhatIfPreference) { Write-Host "WhatIf: would configure host bridge MCP entries through ProviderAdapter/v1" }
|
|
925
|
+
else {
|
|
926
|
+
$wfJson = (& $nodeCommand.Source @wfArguments) -join ''
|
|
927
|
+
$wfResult = $wfJson | ConvertFrom-AfyxJson -Depth 20
|
|
928
|
+
if ($LASTEXITCODE -ne 0 -or $wfResult.status -eq 'BLOCKED') { throw "Host bridge provider configuration failed: $wfJson" }
|
|
929
|
+
foreach ($wfEntry in $wfResult.providers) { $summary["$($wfEntry.provider) workflow MCP"] = $wfEntry.status }
|
|
930
|
+
if (@($wfResult.providers | Where-Object { $_.changed }).Count) { $changesApplied = $true }
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
$contextState = $states['Afyx Context Engine']
|
|
936
|
+
if ($contextAction -eq 'skip') { $summary['Afyx Context Engine'] = 'skipped' }
|
|
937
|
+
else {
|
|
938
|
+
Write-AfyxStatus -Status INFO -Name 'Afyx Context Engine' -Detail "$contextAction in progress; task-based enablement available; Graph consumer registration still requires integration support" -Terminal $terminal
|
|
939
|
+
$contextArguments = @{ RuntimeRoot = $ContextRuntimeRoot }
|
|
940
|
+
if ($contextAction -eq 'update') { $contextArguments.Update = $true }
|
|
941
|
+
elseif ($contextAction -in @('repair', 'downgrade')) { $contextArguments.Repair = $true }
|
|
942
|
+
if (-not (Invoke-AfyxInstallStage -Stage 'Afyx Context Engine' -Description "$contextAction runtime" -Action { & $contextInstaller -Confirm:$false -WhatIf:$WhatIfPreference @contextArguments })) { throw 'Afyx Context installation failed.' }
|
|
943
|
+
$summary['Afyx Context Engine'] = $contextAction
|
|
944
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
# Provider integration of the selected ACE runtime is a separate, Afyx-owned
|
|
948
|
+
# skill companion. It does not change Graph MCP responses or external provider
|
|
949
|
+
# toggles. Native Context CLI remains independently usable without this skill.
|
|
950
|
+
$contextCompanionDesired = -not $SkipProviderConfiguration -and $env:AFYX_CONTEXT_OPT_IN -ne '0' -and (
|
|
951
|
+
$(if ($controlPlan) { 'afyx-context' -in $controlPlan.DesiredComponents }
|
|
952
|
+
else { $contextAction -ne 'skip' })
|
|
953
|
+
)
|
|
954
|
+
$contextReadyForCompanion = $contextAction -ne 'skip' -or $contextState -eq 'HEALTHY'
|
|
955
|
+
if ($contextCompanionDesired -and $contextReadyForCompanion -and $Provider.Count) {
|
|
956
|
+
if (-not (Test-SkillManifest $contextCompanionSource)) { throw 'Bundled Afyx Context provider companion is invalid.' }
|
|
957
|
+
foreach ($root in @($providerSkillRoots | Select-Object -Unique)) {
|
|
958
|
+
$target = Join-Path $root 'afyx-context'
|
|
959
|
+
$ownership = Get-AfyxSkillOwnership -Target $target -Component 'afyx-context' -ExpectedOwner 'afyx'
|
|
960
|
+
if ($ownership -eq 'AFYX_OWNED_UNMODIFIED' -and
|
|
961
|
+
(Get-AfyxSkillVersion -Directory $target) -eq (Get-AfyxSkillVersion -Directory $contextCompanionSource)) {
|
|
962
|
+
$summary["Afyx Context Companion [$root]"] = 'skipped'
|
|
963
|
+
continue
|
|
964
|
+
}
|
|
965
|
+
if ($ownership -notin @('NOT_INSTALLED', 'AFYX_OWNED_UNMODIFIED')) {
|
|
966
|
+
throw "Refusing automatic Context companion replacement at $target because ownership is $ownership."
|
|
967
|
+
}
|
|
968
|
+
$summary["Afyx Context Companion [$root]"] = Install-ManagedSkillSafely 'afyx-context' 'Afyx Context Companion' $contextCompanionSource $target ($ownership -eq 'AFYX_OWNED_UNMODIFIED') $root
|
|
969
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
$forgeState = $states['Afyx Forge Core']
|
|
974
|
+
if ($forgeAction -eq 'skip') { $summary['Afyx Forge Core'] = 'skipped' }
|
|
975
|
+
else {
|
|
976
|
+
Write-AfyxStatus -Status INFO -Name 'Afyx Forge Core' -Detail "$forgeAction in progress; Guidance Alpha mode active" -Terminal $terminal
|
|
977
|
+
$forgeArguments = @{ RuntimeRoot = $ForgeRuntimeRoot }
|
|
978
|
+
if ($forgeAction -eq 'update') { $forgeArguments.Update = $true }
|
|
979
|
+
elseif ($forgeAction -in @('repair', 'downgrade')) { $forgeArguments.Repair = $true }
|
|
980
|
+
if (-not (Invoke-AfyxInstallStage -Stage 'Afyx Forge Core' -Description "$forgeAction runtime" -Action { & $forgeInstaller -Confirm:$false -WhatIf:$WhatIfPreference @forgeArguments })) { throw 'Afyx Forge Core installation failed.' }
|
|
981
|
+
$summary['Afyx Forge Core'] = $forgeAction
|
|
982
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
983
|
+
}
|
|
984
|
+
# The selected Forge Core contributes a skill surface, not autonomous runtime
|
|
985
|
+
# execution. Formal A8 acceptance remains gated.
|
|
986
|
+
$forgeCompanionDesired = -not $SkipProviderConfiguration -and (
|
|
987
|
+
$(if ($controlPlan) { 'afyx-forge' -in $controlPlan.DesiredComponents }
|
|
988
|
+
else { $forgeAction -ne 'skip' })
|
|
989
|
+
)
|
|
990
|
+
$forgeReadyForCompanion = $forgeAction -ne 'skip' -or $states['Afyx Forge Core'] -eq 'HEALTHY'
|
|
991
|
+
if ($forgeCompanionDesired -and $forgeReadyForCompanion -and $Provider.Count) {
|
|
992
|
+
if (-not (Test-SkillManifest $forgeCompanionSource)) { throw 'Bundled Afyx Forge provider companion is invalid.' }
|
|
993
|
+
foreach ($root in @($providerSkillRoots | Select-Object -Unique)) {
|
|
994
|
+
$target = Join-Path $root 'afyx-forge'
|
|
995
|
+
$ownership = Get-AfyxSkillOwnership -Target $target -Component 'afyx-forge' -ExpectedOwner 'afyx'
|
|
996
|
+
if ($ownership -eq 'AFYX_OWNED_UNMODIFIED' -and
|
|
997
|
+
(Get-AfyxSkillVersion -Directory $target) -eq (Get-AfyxSkillVersion -Directory $forgeCompanionSource)) {
|
|
998
|
+
$summary["Afyx Forge Companion [$root]"] = 'skipped'
|
|
999
|
+
continue
|
|
1000
|
+
}
|
|
1001
|
+
if ($ownership -notin @('NOT_INSTALLED', 'AFYX_OWNED_UNMODIFIED')) {
|
|
1002
|
+
throw "Refusing automatic Forge companion replacement at $target because ownership is $ownership."
|
|
1003
|
+
}
|
|
1004
|
+
$summary["Afyx Forge Companion [$root]"] = Install-ManagedSkillSafely 'afyx-forge' 'Afyx Forge Companion' $forgeCompanionSource $target ($ownership -eq 'AFYX_OWNED_UNMODIFIED') $root
|
|
1005
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
$usageAction = if ($controlPlan) { [string]$actionDecisions['codex-usage-tracking'] } else { Resolve-ComponentAction 'codex-usage-tracking' 'Usage Tracking' }
|
|
1010
|
+
if ($usageAction -eq 'skip') { $summary['Usage Tracking'] = 'skipped'; Write-Host 'Usage Tracking: skipped' }
|
|
1011
|
+
else {
|
|
1012
|
+
Write-AfyxStatus -Status INFO -Name 'Usage Tracking' -Detail "$usageAction in progress" -Terminal $terminal
|
|
1013
|
+
if (-not (Invoke-AfyxInstallStage -Stage 'Usage Tracking' -Description "$usageAction tracking hooks" -Action { & $usageTrackerInstaller -Confirm:$false -WhatIf:$WhatIfPreference })) { throw 'Codex Usage Tracking installation failed.' }
|
|
1014
|
+
$summary['Usage Tracking'] = $usageAction
|
|
1015
|
+
if (-not $WhatIfPreference) { $changesApplied = $true }
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
$receipt = @()
|
|
1019
|
+
foreach ($entry in $summary.GetEnumerator()) {
|
|
1020
|
+
$componentId = switch ($entry.Key) {
|
|
1021
|
+
'Efficient Coding' { 'efficient-coding' }
|
|
1022
|
+
'Odoo Engineering' { 'odoo-engineering' }
|
|
1023
|
+
'Afyx Engineering Expert' { 'afyx-engineering-expert' }
|
|
1024
|
+
'Afyx Graph' { 'afyx-graph' }
|
|
1025
|
+
'Afyx Context Engine' { 'afyx-context' }
|
|
1026
|
+
'Afyx Forge Core' { 'afyx-forge' }
|
|
1027
|
+
'Usage Tracking' { 'codex-usage-tracking' }
|
|
1028
|
+
default { '' }
|
|
1029
|
+
}
|
|
1030
|
+
$componentState = if ($componentId) { [string]$componentStates[$componentId].State } else { '' }
|
|
1031
|
+
$receipt += [pscustomobject]@{
|
|
1032
|
+
Status = Get-AfyxOutcomeStatus -ComponentState $componentState -Action ([string]$entry.Value) -WhatIf:$WhatIfPreference
|
|
1033
|
+
Name = [string]$entry.Key
|
|
1034
|
+
Detail = "outcome=$($entry.Value)"
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
if ($wizardMode) { Show-AfyxStep -Current 5 -Terminal $terminal }
|
|
1038
|
+
Show-AfyxReceipt -Items $receipt -Terminal $terminal
|
|
1039
|
+
if ($wizardMode) {
|
|
1040
|
+
Write-AfyxText -Terminal $terminal -Tone Muted -Text "Verify: run '$packageRoot\verify.ps1' with preset $Preset and the same provider, scope, workspace, and runtime roots."
|
|
1041
|
+
Write-AfyxText -Terminal $terminal -Tone Muted -Text "Recovery: rerun this installer to repair AFYX-owned drift, or review & '$packageRoot\uninstall.ps1' -WhatIf before removal."
|
|
1042
|
+
}
|
|
1043
|
+
if ($WhatIfPreference) { Write-AfyxStatus -Status PLANNED -Name 'WhatIf complete' -Detail 'no files or configuration were changed' -Terminal $terminal }
|
|
1044
|
+
elseif ($changesApplied) { Write-AfyxStatus -Status 'RESTART REQUIRED' -Name 'Provider session' -Detail 'start a new provider session to load installed components' -Terminal $terminal }
|
|
1045
|
+
else { Write-AfyxStatus -Status 'NO CHANGE' -Name 'Installation' -Detail 'existing healthy components were preserved' -Terminal $terminal }
|
|
1046
|
+
} catch {
|
|
1047
|
+
if (Test-AfyxDashboard -Terminal $terminal) {
|
|
1048
|
+
Write-AfyxStatus -Status FAILED -Name 'Installation stopped' -Detail $_.Exception.Message -Terminal $terminal
|
|
1049
|
+
}
|
|
1050
|
+
throw
|
|
1051
|
+
} finally {
|
|
1052
|
+
Disable-AfyxDashboard -Terminal $terminal
|
|
1053
|
+
}
|