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.
Files changed (208) hide show
  1. package/.afyx-source-revision +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +377 -2
  4. package/SECURITY.md +74 -0
  5. package/afyx-context/LICENSE +21 -0
  6. package/afyx-context/README.md +155 -0
  7. package/afyx-context/afyx-context.json +30 -0
  8. package/afyx-context/contracts/integration-v1.schema.json +34 -0
  9. package/afyx-context/package-lock.json +53 -0
  10. package/afyx-context/package.json +34 -0
  11. package/afyx-context/scripts/benchmark.mjs +39 -0
  12. package/afyx-context/scripts/build.mjs +15 -0
  13. package/afyx-context/scripts/comparative-benchmark.mjs +342 -0
  14. package/afyx-context/scripts/comparative-worker.mjs +74 -0
  15. package/afyx-context/scripts/graph-integration-e2e.mjs +188 -0
  16. package/afyx-context/scripts/integrated-dogfood.mjs +309 -0
  17. package/afyx-context/src/budget.js +166 -0
  18. package/afyx-context/src/cli.js +110 -0
  19. package/afyx-context/src/coordination.js +343 -0
  20. package/afyx-context/src/engine.js +198 -0
  21. package/afyx-context/src/errors.js +14 -0
  22. package/afyx-context/src/graph-integration-worker.js +70 -0
  23. package/afyx-context/src/graph-integration.js +373 -0
  24. package/afyx-context/src/graph-mcp-bridge.js +103 -0
  25. package/afyx-context/src/index.js +25 -0
  26. package/afyx-context/src/integrations.js +87 -0
  27. package/afyx-context/src/memory.js +255 -0
  28. package/afyx-context/src/storage.js +364 -0
  29. package/afyx-context/test-fixtures/coordination-worker.mjs +52 -0
  30. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__init__.py +1 -0
  31. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__manifest__.py +4 -0
  32. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/__init__.py +1 -0
  33. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/sale_order.py +5 -0
  34. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__init__.py +1 -0
  35. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__manifest__.py +10 -0
  36. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/__init__.py +2 -0
  37. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order.py +20 -0
  38. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order_audit.py +11 -0
  39. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/security/ir.model.access.csv +2 -0
  40. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/views/sale_order_views.xml +14 -0
  41. package/afyx-forge/LICENSE +55 -0
  42. package/afyx-forge/README.md +126 -0
  43. package/afyx-forge/afyx-forge.json +28 -0
  44. package/afyx-forge/bin/afyx-forge +4 -0
  45. package/afyx-forge/bin/afyx-forge.cmd +3 -0
  46. package/afyx-forge/bin/afyx-forge.js +16 -0
  47. package/afyx-forge/contracts/forge-plan-v1.schema.json +172 -0
  48. package/afyx-forge/package.json +26 -0
  49. package/afyx-forge/src/classifier.js +190 -0
  50. package/afyx-forge/src/cli.js +111 -0
  51. package/afyx-forge/src/doctor.js +105 -0
  52. package/afyx-forge/src/guidance.js +120 -0
  53. package/afyx-forge/src/index.js +273 -0
  54. package/afyx-forge/src/planning.js +107 -0
  55. package/afyx-forge/src/policy.js +109 -0
  56. package/afyx-forge/src/workflow-refiner.js +151 -0
  57. package/afyx-graph/afyx-graph.json +20 -0
  58. package/afyx-graph/engine/LICENSE +21 -0
  59. package/afyx-graph/engine/README.md +104 -0
  60. package/afyx-graph/engine/release/RELEASE-MANIFEST.json +21 -0
  61. package/afyx-graph/engine/release/SHA256SUMS +2 -0
  62. package/afyx-graph/engine/release/afyx-graph-linux-x64.tar.gz +0 -0
  63. package/afyx-graph/engine/release/afyx-graph-win32-x64.zip +0 -0
  64. package/afyx-graph/engine/scripts/distribution-contract.mjs +212 -0
  65. package/afyx-graph/engine/scripts/distribution-product.json +33 -0
  66. package/bin/afyx-engineering-kit.mjs +61 -0
  67. package/install.ps1 +1053 -0
  68. package/install.sh +617 -0
  69. package/package.json +66 -4
  70. package/scripts/afyx-capability-orchestrator.mjs +752 -0
  71. package/scripts/afyx-claude-integration.mjs +547 -0
  72. package/scripts/afyx-context-artifact.mjs +105 -0
  73. package/scripts/afyx-credential-broker.mjs +75 -0
  74. package/scripts/afyx-doctor.ps1 +152 -0
  75. package/scripts/afyx-doctor.sh +146 -0
  76. package/scripts/afyx-forge-artifact.mjs +183 -0
  77. package/scripts/afyx-global-routing-policy.md +12 -0
  78. package/scripts/afyx-global-routing.mjs +168 -0
  79. package/scripts/afyx-graph-artifact.mjs +178 -0
  80. package/scripts/afyx-host-adapters.mjs +543 -0
  81. package/scripts/afyx-host-bridge-lifecycle.mjs +174 -0
  82. package/scripts/afyx-host-bridge.mjs +288 -0
  83. package/scripts/afyx-integration-contracts.mjs +825 -0
  84. package/scripts/afyx-mcp-integration.mjs +528 -0
  85. package/scripts/afyx-modular-integration.mjs +361 -0
  86. package/scripts/afyx-modular-runtime.mjs +451 -0
  87. package/scripts/afyx-native-skill-host.mjs +124 -0
  88. package/scripts/afyx-npm-installer.mjs +486 -0
  89. package/scripts/afyx-project.ps1 +205 -0
  90. package/scripts/afyx-project.sh +207 -0
  91. package/scripts/afyx-provider-backup.mjs +1206 -0
  92. package/scripts/afyx-provider-integration.mjs +724 -0
  93. package/scripts/afyx-provider-inventory.mjs +147 -0
  94. package/scripts/afyx-security-auditor.mjs +224 -0
  95. package/scripts/afyx-skill-engineering.mjs +354 -0
  96. package/scripts/afyx-tool-family-routing.mjs +64 -0
  97. package/scripts/afyx-universal-runtime.mjs +530 -0
  98. package/scripts/alpha_acceptance_preflight.py +240 -0
  99. package/scripts/benchmark-graph-memory.mjs +96 -0
  100. package/scripts/benchmark_capability_orchestrator.mjs +64 -0
  101. package/scripts/build-windows-installer.ps1 +259 -0
  102. package/scripts/build_forge_synthetic_image.py +328 -0
  103. package/scripts/check-reference-staleness.py +71 -0
  104. package/scripts/components.json +254 -0
  105. package/scripts/contracts/afyx-capability-request-v1.schema.json +189 -0
  106. package/scripts/contracts/afyx-capability-result-v1.schema.json +32 -0
  107. package/scripts/dogfood_engineering_comparison.mjs +303 -0
  108. package/scripts/engineering-assurance.json +28 -0
  109. package/scripts/install-afyx-context.ps1 +142 -0
  110. package/scripts/install-afyx-context.sh +126 -0
  111. package/scripts/install-afyx-forge.ps1 +265 -0
  112. package/scripts/install-afyx-forge.sh +273 -0
  113. package/scripts/install-afyx-graph.ps1 +571 -0
  114. package/scripts/install-afyx-graph.sh +438 -0
  115. package/scripts/install-codex-usage-tracker.ps1 +172 -0
  116. package/scripts/lib/AfyxComponents.psm1 +399 -0
  117. package/scripts/lib/AfyxSkillLifecycle.psm1 +289 -0
  118. package/scripts/lib/AfyxTerminal.psm1 +838 -0
  119. package/scripts/lib/afyx-components.sh +256 -0
  120. package/scripts/lib/afyx-skill-lifecycle.sh +271 -0
  121. package/scripts/link-global-dev.ps1 +193 -0
  122. package/scripts/link-global-dev.sh +130 -0
  123. package/scripts/phase8-paired-evidence.mjs +195 -0
  124. package/scripts/phase8-representative-workload.mjs +771 -0
  125. package/scripts/phase8-session-recorder.mjs +157 -0
  126. package/scripts/phase8_event_ledger.py +248 -0
  127. package/scripts/phase8_evidence_discovery.py +189 -0
  128. package/scripts/prepare-g6-package.mjs +349 -0
  129. package/scripts/resolve-git-release-artifacts.mjs +321 -0
  130. package/scripts/stage-npm-release.mjs +94 -0
  131. package/scripts/validate-afyx-graph.py +203 -0
  132. package/scripts/validate-components.py +194 -0
  133. package/scripts/validate-engineering-assurance.py +281 -0
  134. package/scripts/verify-graph-archive.mjs +64 -0
  135. package/skills/afyx-context/SKILL.md +26 -0
  136. package/skills/afyx-engineering-expert/README.md +42 -0
  137. package/skills/afyx-engineering-expert/SKILL.md +70 -0
  138. package/skills/afyx-engineering-expert/assets/result-template.md +15 -0
  139. package/skills/afyx-engineering-expert/references/ai-ml-engineer.md +17 -0
  140. package/skills/afyx-engineering-expert/references/business-analyst.md +17 -0
  141. package/skills/afyx-engineering-expert/references/clean-code-engineer.md +26 -0
  142. package/skills/afyx-engineering-expert/references/code-reviewer.md +24 -0
  143. package/skills/afyx-engineering-expert/references/cybersecurity-devsecops.md +17 -0
  144. package/skills/afyx-engineering-expert/references/data-analyst-bi.md +24 -0
  145. package/skills/afyx-engineering-expert/references/data-engineer.md +24 -0
  146. package/skills/afyx-engineering-expert/references/database-administrator.md +17 -0
  147. package/skills/afyx-engineering-expert/references/debugging-specialist.md +24 -0
  148. package/skills/afyx-engineering-expert/references/embedded-iot-engineer.md +24 -0
  149. package/skills/afyx-engineering-expert/references/erp-technical-specialist.md +17 -0
  150. package/skills/afyx-engineering-expert/references/hardware-diagnostics-auditor.md +24 -0
  151. package/skills/afyx-engineering-expert/references/hardware-electronics-engineer.md +24 -0
  152. package/skills/afyx-engineering-expert/references/integration-engineer.md +24 -0
  153. package/skills/afyx-engineering-expert/references/legacy-modernization-engineer.md +24 -0
  154. package/skills/afyx-engineering-expert/references/llmops-prompt-engineer.md +24 -0
  155. package/skills/afyx-engineering-expert/references/network-engineer.md +24 -0
  156. package/skills/afyx-engineering-expert/references/performance-benchmark-engineer.md +24 -0
  157. package/skills/afyx-engineering-expert/references/platform-engineer.md +24 -0
  158. package/skills/afyx-engineering-expert/references/product-manager.md +17 -0
  159. package/skills/afyx-engineering-expert/references/qa-engineer.md +17 -0
  160. package/skills/afyx-engineering-expert/references/site-reliability-engineer.md +17 -0
  161. package/skills/afyx-engineering-expert/references/software-engineer.md +17 -0
  162. package/skills/afyx-engineering-expert/references/solutions-architect.md +17 -0
  163. package/skills/afyx-engineering-expert/references/specialists-index.md +33 -0
  164. package/skills/afyx-engineering-expert/references/subject-matter-expert.md +17 -0
  165. package/skills/afyx-engineering-expert/references/system-analyst.md +17 -0
  166. package/skills/afyx-engineering-expert/references/technical-project-manager.md +24 -0
  167. package/skills/afyx-engineering-expert/references/technical-writer.md +24 -0
  168. package/skills/afyx-engineering-expert/references/ui-ux-designer.md +17 -0
  169. package/skills/afyx-engineering-expert/workflows/ai-data-erp.md +20 -0
  170. package/skills/afyx-engineering-expert/workflows/debugging.md +10 -0
  171. package/skills/afyx-engineering-expert/workflows/discovery-design.md +11 -0
  172. package/skills/afyx-engineering-expert/workflows/implementation.md +12 -0
  173. package/skills/afyx-engineering-expert/workflows/incident-reliability.md +12 -0
  174. package/skills/afyx-engineering-expert/workflows/review-audit.md +13 -0
  175. package/skills/afyx-forge/SKILL.md +43 -0
  176. package/skills/afyx-forge/references/adaptive-policy.md +19 -0
  177. package/skills/efficient-coding/SKILL.md +33 -0
  178. package/skills/efficient-coding/references/investigation.md +27 -0
  179. package/skills/efficient-coding/references/token-efficiency.md +25 -0
  180. package/skills/efficient-coding/references/tool-routing.md +13 -0
  181. package/skills/odoo-engineering/SKILL.md +33 -0
  182. package/skills/odoo-engineering/references/common.md +9 -0
  183. package/skills/odoo-engineering/references/odoo-10.md +32 -0
  184. package/skills/odoo-engineering/references/odoo-11.md +26 -0
  185. package/skills/odoo-engineering/references/odoo-12.md +31 -0
  186. package/skills/odoo-engineering/references/odoo-13.md +27 -0
  187. package/skills/odoo-engineering/references/odoo-14.md +31 -0
  188. package/skills/odoo-engineering/references/odoo-15.md +34 -0
  189. package/skills/odoo-engineering/references/odoo-16.md +37 -0
  190. package/skills/odoo-engineering/references/odoo-17.md +37 -0
  191. package/skills/odoo-engineering/references/odoo-18.md +48 -0
  192. package/skills/odoo-engineering/references/odoo-19.md +43 -0
  193. package/skills/odoo-engineering/references/odoo-20.md +39 -0
  194. package/skills/odoo-engineering/references/reference-schema.md +16 -0
  195. package/skills/odoo-engineering/references/version-detection.md +13 -0
  196. package/tools/codex-usage/CodexUsage.psm1 +496 -0
  197. package/tools/codex-usage/codex-usage-doctor.ps1 +150 -0
  198. package/tools/codex-usage/codex-usage-pricing.json +25 -0
  199. package/tools/codex-usage/codex-usage-stop.ps1 +167 -0
  200. package/tools/codex-usage/codex-usage-watch.ps1 +250 -0
  201. package/tools/codex-usage/vscode-user-task.json +31 -0
  202. package/tools/windows-setup/SetupBootstrapper.cs +258 -0
  203. package/uninstall.ps1 +189 -0
  204. package/uninstall.sh +167 -0
  205. package/update.ps1 +95 -0
  206. package/update.sh +67 -0
  207. package/verify.ps1 +411 -0
  208. package/verify.sh +265 -0
package/update.ps1 ADDED
@@ -0,0 +1,95 @@
1
+ [CmdletBinding(SupportsShouldProcess)]
2
+ param(
3
+ [string]$SkillsRoot = (Join-Path $env:USERPROFILE '.agents\skills'),
4
+ [switch]$SkipSelfUpdate,
5
+
6
+ [string[]]$ComponentAction = @(),
7
+ [string]$Preset = '',
8
+ [string[]]$CustomComponent = @(),
9
+
10
+ [switch]$Offline,
11
+
12
+ [switch]$NoBuildFallback,
13
+
14
+ [switch]$AllowDirtySource,
15
+ [switch]$InstallUsageTracker,
16
+ [switch]$SkipUsageTracker,
17
+ [switch]$SkipGraphMcp,
18
+ [switch]$SkipGraphPathUpdate,
19
+ [string[]]$Provider = @(),
20
+ [ValidateSet('global', 'workspace')][string]$ProviderScope = 'global',
21
+ [string]$WorkspaceRoot = (Get-Location).Path,
22
+ [string]$GeminiHome = $(if ($env:AFYX_GEMINI_HOME) { $env:AFYX_GEMINI_HOME } else { Join-Path $env:USERPROFILE '.gemini' }),
23
+ [string]$ClaudeHome = $(if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $env:USERPROFILE '.claude' }),
24
+ [string]$ClaudeConfigDir = $(if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { '' }),
25
+ [switch]$SkipProviderConfiguration,
26
+ [string]$ContextRuntimeRoot = $(if ($env:AFYX_CONTEXT_RUNTIME_ROOT) { $env:AFYX_CONTEXT_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\context' }),
27
+ [string]$ForgeRuntimeRoot = $(if ($env:AFYX_FORGE_RUNTIME_ROOT) { $env:AFYX_FORGE_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\forge' }),
28
+ [string]$AfyxInstallRoot = $(if ($env:AFYX_INSTALL_ROOT) { $env:AFYX_INSTALL_ROOT } else { Join-Path $env:USERPROFILE '.afyx' }),
29
+ [string]$HostBridgeRuntimeRoot = $(if ($env:AFYX_HOST_BRIDGE_RUNTIME_ROOT) { $env:AFYX_HOST_BRIDGE_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\host-bridge' })
30
+ )
31
+
32
+ Set-StrictMode -Version Latest
33
+ $ErrorActionPreference = 'Stop'
34
+ $installer = Join-Path $PSScriptRoot 'install.ps1'
35
+ $root = $PSScriptRoot
36
+ if (-not $PSBoundParameters.ContainsKey('SkillsRoot') -and $ProviderScope -eq 'workspace' -and 'antigravity' -in $Provider) {
37
+ $SkillsRoot = Join-Path $WorkspaceRoot '.agents\skills'
38
+ }
39
+
40
+ if ($InstallUsageTracker -and $SkipUsageTracker) {
41
+ Write-Error '-InstallUsageTracker and -SkipUsageTracker cannot be used together.'
42
+ exit 1
43
+ }
44
+
45
+ foreach ($id in $CustomComponent) {
46
+ if ($id -in @('prompt-master', 'headroom')) {
47
+ throw "Component '$id' is retired from Afyx Kit and remains externally/user managed; no changes were made."
48
+ }
49
+ }
50
+ foreach ($specification in $ComponentAction) {
51
+ if ($specification -match '^([a-z0-9-]+)=' -and $Matches[1] -in @('prompt-master', 'headroom')) {
52
+ throw "Component '$($Matches[1])' is retired from Afyx Kit and remains externally/user managed; no changes were made."
53
+ }
54
+ }
55
+
56
+ Write-Host 'Afyx Engineering Kit — Windows updater (PowerShell)'
57
+
58
+ if ($Offline -and -not $SkipSelfUpdate) {
59
+ Write-Host 'Offline mode: self-update skipped; using the current local source intentionally.'
60
+ } elseif (-not $SkipSelfUpdate) {
61
+ $git = Get-Command git -ErrorAction SilentlyContinue
62
+ if (-not $git) {
63
+ Write-Error 'Git executable not found. Self-update cannot be performed. Re-run with -SkipSelfUpdate only if using the current checkout intentionally.'
64
+ exit 1
65
+ }
66
+ if (Test-Path -LiteralPath (Join-Path $root '.git')) { & git -C $root rev-parse --is-inside-work-tree *> $null }
67
+ if (-not (Test-Path -LiteralPath (Join-Path $root '.git')) -or $LASTEXITCODE -ne 0) {
68
+ Write-Warning 'Self-update unavailable: source directory is not a Git repository. Continuing with current source.'
69
+ } else {
70
+ $status = & git -C $root status --porcelain
71
+ if ($LASTEXITCODE -ne 0) { Write-Error 'Unable to inspect Git worktree status; updater aborted.'; exit 1 }
72
+ if ($status) {
73
+ Write-Error 'Local changes detected. Self-update and installation aborted. Run git status to handle local changes, or intentionally use .\update.ps1 -SkipSelfUpdate.'
74
+ exit 1
75
+ }
76
+ if ($WhatIfPreference) {
77
+ Write-Host 'WhatIf: skipping git pull --ff-only; repository will not be modified.'
78
+ } else {
79
+ & git -C $root pull --ff-only
80
+ if ($LASTEXITCODE -ne 0) { Write-Error 'Self-update failed; installer was not run.'; exit 1 }
81
+ }
82
+ }
83
+ } else { Write-Host 'Self-update skipped by -SkipSelfUpdate; using current local source intentionally.' }
84
+
85
+ $usageArguments = @{}
86
+ if ($InstallUsageTracker) { $usageArguments.InstallUsageTracker = $true }
87
+ elseif ($SkipUsageTracker) { $usageArguments.SkipUsageTracker = $true }
88
+
89
+ & $installer -SkillsRoot $SkillsRoot -UpdateInstalled -ComponentAction $ComponentAction -Preset $Preset -CustomComponent $CustomComponent -Offline:$Offline -NoBuildFallback:$NoBuildFallback -AllowDirtySource:$AllowDirtySource -SkipGraphMcp:$SkipGraphMcp -SkipGraphPathUpdate:$SkipGraphPathUpdate -Provider $Provider -ProviderScope $ProviderScope -WorkspaceRoot $WorkspaceRoot -GeminiHome $GeminiHome -ClaudeHome $ClaudeHome -ClaudeConfigDir $ClaudeConfigDir -SkipProviderConfiguration:$SkipProviderConfiguration -ContextRuntimeRoot $ContextRuntimeRoot -ForgeRuntimeRoot $ForgeRuntimeRoot -AfyxInstallRoot $AfyxInstallRoot -HostBridgeRuntimeRoot $HostBridgeRuntimeRoot -Confirm:$false -WhatIf:$WhatIfPreference @usageArguments
90
+ $installerSucceeded = $?
91
+ $installerExitCode = 0
92
+ if (Test-Path -LiteralPath variable:LASTEXITCODE) { $installerExitCode = [int]$LASTEXITCODE }
93
+ if (-not $installerSucceeded -and $installerExitCode -eq 0) { $installerExitCode = 1 }
94
+ if ($installerExitCode -ne 0) { exit $installerExitCode }
95
+ exit 0
package/update.sh ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
5
+ printf 'Afyx Engineering Kit — Linux/macOS updater (Bash)\n'
6
+ skip_self_update=false
7
+ dry_run=false
8
+ offline=false
9
+ args=()
10
+ while (($#)); do
11
+ case "$1" in
12
+ --skip-self-update) skip_self_update=true; shift ;;
13
+ --dry-run) dry_run=true; args+=("--dry-run"); shift ;;
14
+ --offline) offline=true; args+=("--offline"); shift ;;
15
+ *) args+=("$1"); shift ;;
16
+ esac
17
+ done
18
+
19
+ previous=
20
+ for argument in "${args[@]}"; do
21
+ if [[ "$previous" == --custom-component ]]; then
22
+ case "$argument" in prompt-master|headroom) printf "Component '%s' is retired from Afyx Kit and remains externally/user managed; no changes were made.\n" "$argument" >&2; exit 2 ;; esac
23
+ elif [[ "$previous" == --component ]]; then
24
+ case "$argument" in prompt-master=*|headroom=*) component="${argument%%=*}"; printf "Component '%s' is retired from Afyx Kit and remains externally/user managed; no changes were made.\n" "$component" >&2; exit 2 ;; esac
25
+ fi
26
+ case "$argument" in --custom-component|--component) previous="$argument" ;; *) previous= ;; esac
27
+ done
28
+
29
+ if "$offline"; then
30
+ printf 'Offline mode: self-update skipped; using the current local source intentionally.\n'
31
+ elif "$skip_self_update"; then
32
+ printf 'Self-update skipped by --skip-self-update; using current local source intentionally.\n'
33
+ else
34
+ if ! command -v git >/dev/null 2>&1; then
35
+ printf '[ERROR] Git executable not found. Self-update cannot be performed. Re-run with --skip-self-update only if using the current checkout intentionally.\n' >&2
36
+ exit 1
37
+ fi
38
+ if ! git -C "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
39
+ printf '[INFO] Self-update unavailable: source directory is not a Git repository. Continuing with current source.\n'
40
+ else
41
+ if ! status="$(git -C "$root" status --porcelain)"; then
42
+ printf '[ERROR] Unable to inspect Git worktree status; updater aborted.\n' >&2
43
+ exit 1
44
+ fi
45
+ if [[ -n "$status" ]]; then
46
+ printf '[ERROR] Local changes detected. Self-update and installation aborted. Run git status to handle local changes, or intentionally use ./update.sh --skip-self-update.\n' >&2
47
+ exit 1
48
+ fi
49
+ if "$dry_run"; then
50
+ printf 'Dry-run: skipping git pull --ff-only; repository will not be modified.\n'
51
+ else
52
+ if ! git -C "$root" rev-parse --abbrev-ref --symbolic-full-name '@{upstream}' >/dev/null 2>&1; then
53
+ printf '[INFO] No upstream branch is configured; self-update skipped. Configure an upstream or use --skip-self-update intentionally.\n'
54
+ elif ! git -C "$root" pull --ff-only; then
55
+ printf '[ERROR] Self-update failed; installer was not run.\n' >&2
56
+ exit 1
57
+ fi
58
+ fi
59
+ fi
60
+ fi
61
+
62
+ set +e
63
+ bash "$root/install.sh" --update-installed "${args[@]}"
64
+ installer_exit_code=$?
65
+ set -e
66
+ if ((installer_exit_code != 0)); then exit "$installer_exit_code"; fi
67
+ exit 0
package/verify.ps1 ADDED
@@ -0,0 +1,411 @@
1
+ [CmdletBinding()]
2
+ param(
3
+ [string]$SkillsRoot = (Join-Path $env:USERPROFILE '.agents\skills'),
4
+ [string]$Preset = '',
5
+ [string[]]$CustomComponent = @(),
6
+ [string[]]$Provider = @('codex'),
7
+ [ValidateSet('global', 'workspace')][string]$ProviderScope = 'global',
8
+ [string]$WorkspaceRoot = (Get-Location).Path,
9
+ [string]$GeminiHome = $(if ($env:AFYX_GEMINI_HOME) { $env:AFYX_GEMINI_HOME } else { Join-Path $env:USERPROFILE '.gemini' }),
10
+ [string]$ClaudeHome = $(if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $env:USERPROFILE '.claude' }),
11
+ [string]$ClaudeConfigDir = $(if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { '' }),
12
+ [string]$ContextRuntimeRoot = $(if ($env:AFYX_CONTEXT_RUNTIME_ROOT) { $env:AFYX_CONTEXT_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\context' }),
13
+ [string]$ForgeRuntimeRoot = $(if ($env:AFYX_FORGE_RUNTIME_ROOT) { $env:AFYX_FORGE_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\forge' }),
14
+ [string]$AfyxInstallRoot = $(if ($env:AFYX_INSTALL_ROOT) { $env:AFYX_INSTALL_ROOT } else { Join-Path $env:USERPROFILE '.afyx' }),
15
+ [string]$HostBridgeRuntimeRoot = $(if ($env:AFYX_HOST_BRIDGE_RUNTIME_ROOT) { $env:AFYX_HOST_BRIDGE_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\host-bridge' })
16
+ )
17
+
18
+ Set-StrictMode -Version Latest
19
+ $ErrorActionPreference = 'Stop'
20
+ $coreFailure = $false
21
+ $configuredProviders = @()
22
+ $codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $env:USERPROFILE '.codex' }
23
+ $configPath = Join-Path $codexHome 'config.toml'
24
+ $graphRoot = if ($env:AFYX_GRAPH_RUNTIME_ROOT) { $env:AFYX_GRAPH_RUNTIME_ROOT } else { Join-Path $env:USERPROFILE '.afyx\graph' }
25
+ Import-Module (Join-Path $PSScriptRoot 'scripts\lib\AfyxTerminal.psm1') -Force
26
+ $terminal = New-AfyxTerminalContext
27
+
28
+ function Write-Result([string]$State, [string]$Name, [string]$Detail = '') {
29
+ $status = switch ($State) {
30
+ 'OK' { 'HEALTHY' }
31
+ 'FAIL' { 'BLOCKED' }
32
+ 'WARN' { 'WARNING' }
33
+ default { $State }
34
+ }
35
+ Write-AfyxStatus -Status $status -Name $Name -Detail $Detail -Terminal $terminal
36
+ }
37
+
38
+ # One component truth: scripts/components.json, read through the shared module.
39
+ Import-Module (Join-Path $PSScriptRoot 'scripts\lib\AfyxComponents.psm1') -Force
40
+ Import-Module (Join-Path $PSScriptRoot 'scripts\lib\AfyxSkillLifecycle.psm1') -Force -DisableNameChecking
41
+ $providerIds = @(Get-AfyxProviderRegistry | ForEach-Object { [string]$_.provider })
42
+ $unknownProviders = @($Provider | Where-Object { $_ -notin $providerIds })
43
+ if ($unknownProviders.Count) { throw "Unknown provider(s): $($unknownProviders -join ', ')" }
44
+ $providerSkillRoots = @()
45
+ if ('codex' -in $Provider) {
46
+ $providerSkillRoots += $(if ($PSBoundParameters.ContainsKey('SkillsRoot')) { $SkillsRoot } else { Join-Path $env:USERPROFILE '.agents\skills' })
47
+ }
48
+ if ('antigravity' -in $Provider) {
49
+ if ($ProviderScope -eq 'workspace') { $providerSkillRoots += (Join-Path $WorkspaceRoot '.agents\skills') }
50
+ else { $providerSkillRoots += @((Join-Path $GeminiHome 'config\skills'), (Join-Path $GeminiHome 'antigravity-cli\skills')) }
51
+ }
52
+ if ('claude' -in $Provider) {
53
+ $providerSkillRoots += $(if ($ProviderScope -eq 'workspace') { Join-Path $WorkspaceRoot '.claude\skills' } else { Join-Path $ClaudeHome 'skills' })
54
+ }
55
+ if (-not $PSBoundParameters.ContainsKey('SkillsRoot') -and $providerSkillRoots.Count) { $SkillsRoot = $providerSkillRoots[0] }
56
+ $primarySkillsPath = [System.IO.Path]::GetFullPath($SkillsRoot)
57
+ $additionalSkillRoots = @($providerSkillRoots |
58
+ Where-Object { [System.IO.Path]::GetFullPath($_) -ne $primarySkillsPath } |
59
+ Select-Object -Unique)
60
+ $componentContext = New-AfyxComponentContext -SkillsRoot $SkillsRoot -GraphRoot $graphRoot -ContextRoot $ContextRuntimeRoot -ForgeRoot $ForgeRuntimeRoot -CodexHome $codexHome
61
+ $componentStates = @{}
62
+ foreach ($componentState in (Get-AfyxComponentStates -Context $componentContext)) { $componentStates[$componentState.Id] = $componentState }
63
+ if ($Preset) {
64
+ foreach ($component in (Get-AfyxComponentContract | Where-Object { $_.type -eq 'skill' })) {
65
+ $state = $componentStates[[string]$component.id]
66
+ if ($state.State -eq 'NOT INSTALLED') { continue }
67
+ $installedOwnership = Get-AfyxSkillOwnership -Target $state.Path -Component ([string]$component.id) -ExpectedOwner ([string]$component.ownership)
68
+ if ($installedOwnership -eq 'AFYX_OWNED_MODIFIED') {
69
+ $state.State = 'DRIFTED'; $state.Detail = 'Afyx ownership verified but installed content was modified'
70
+ } elseif ($installedOwnership -notin @('AFYX_OWNED_UNMODIFIED', 'EXTERNAL_UPSTREAM')) {
71
+ $state.State = 'UNKNOWN'; $state.Detail = "installed ownership is $installedOwnership"
72
+ }
73
+ }
74
+ }
75
+ if ($Preset -and $Preset -notin @('minimal', 'recommended', 'full', 'custom')) { throw "Unknown preset: $Preset" }
76
+ if (-not $Preset -and $CustomComponent.Count) { throw '-CustomComponent requires -Preset custom.' }
77
+ foreach ($id in $CustomComponent) {
78
+ if ($id -in @('prompt-master', 'headroom')) {
79
+ throw "Component '$id' is retired from Afyx Kit and remains externally/user managed; no changes were made."
80
+ }
81
+ }
82
+ $controlPlan = if ($Preset) { Get-AfyxControlPlan -Preset $Preset -CustomComponent $CustomComponent -Provider $Provider -Context $componentContext -StateById $componentStates } else { $null }
83
+
84
+ Show-AfyxBanner -Terminal $terminal -Subtitle 'Readiness Verification | Midnight Circuit'
85
+ $gitSource = Get-Command git -ErrorAction SilentlyContinue
86
+ if ($gitSource -and (Test-Path -LiteralPath (Join-Path $PSScriptRoot '.git'))) {
87
+ $sourceCommit = (& git -C $PSScriptRoot rev-parse HEAD 2>$null) -join ''
88
+ $sourceBranch = (& git -C $PSScriptRoot branch --show-current 2>$null) -join ''
89
+ if (-not $sourceBranch) { $sourceBranch = 'DETACHED' }
90
+ $sourceDirty = [bool]((& git -C $PSScriptRoot status --porcelain 2>$null) -join '')
91
+ Write-Result $(if ($sourceDirty) { 'WARN' } else { 'OK' }) 'Source identity' "branch=$sourceBranch; commit=$sourceCommit; dirty=$sourceDirty"
92
+ } elseif (Test-Path -LiteralPath (Join-Path $PSScriptRoot '.afyx-source-revision') -PathType Leaf) {
93
+ $sourceCommit = (Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot '.afyx-source-revision')).Trim()
94
+ Write-Result $(if ($sourceCommit -match '^[0-9a-f]{40}$') { 'OK' } else { 'FAIL' }) 'Source identity' "branch=PACKAGED; commit=$sourceCommit; dirty=False"
95
+ }
96
+ foreach ($providerRecord in (Get-AfyxProviderRegistry)) {
97
+ Write-Result 'INFO' "Provider adapter: $($providerRecord.name)" "primary=$($providerRecord.primary); ownership=$($providerRecord.ownership_class); capabilities=$($providerRecord.capabilities); policy=$($providerRecord.configuration_policy)"
98
+ }
99
+ if ($Provider.Count) {
100
+ $nodeCommand = Get-Command node -ErrorAction SilentlyContinue
101
+ $entry = Join-Path $graphRoot 'current\lib\dist\bin\afyx-graph.js'
102
+ if ($nodeCommand -and (Test-Path -LiteralPath $entry -PathType Leaf)) {
103
+ $providerTool = Join-Path $PSScriptRoot 'scripts\afyx-provider-integration.mjs'
104
+ $providerArguments = @($providerTool, '--providers', ($Provider -join ','), '--scope', $ProviderScope,
105
+ '--workspace-root', $WorkspaceRoot, '--gemini-home', $GeminiHome, '--codex-home', $codexHome,
106
+ '--node', $nodeCommand.Source, '--entry', $entry)
107
+ $codexHost = Get-AfyxCodexHost
108
+ $codexCommand = if ($codexHost.State -eq 'CLI_READY') { [pscustomobject]@{ Source = $codexHost.Path } } else { $null }
109
+ $claudeCommand = Get-Command claude -ErrorAction SilentlyContinue
110
+ if ($codexCommand) { $providerArguments += @('--codex', $codexCommand.Source) }
111
+ if ($claudeCommand) { $providerArguments += @('--claude', $claudeCommand.Source) }
112
+ if ($ClaudeConfigDir) { $providerArguments += @('--claude-config-dir', $ClaudeConfigDir) }
113
+ $providerJson = (& $nodeCommand.Source @providerArguments) -join ''
114
+ try {
115
+ $providerResult = $providerJson | ConvertFrom-AfyxJson -Depth 20
116
+ $configuredProviders = @($providerResult.providers | Where-Object { $_.status -in @('READY', 'CONFIGURED', 'CONFIGURED_RESTART_REQUIRED') })
117
+ foreach ($providerEntry in $providerResult.providers) {
118
+ $level = if ($providerEntry.status -in @('READY', 'CONFIGURED', 'CONFIGURED_RESTART_REQUIRED')) { 'OK' } elseif ($providerEntry.status -in @('BLOCKED', 'INCOMPATIBLE')) { 'FAIL' } else { 'INFO' }
119
+ Write-Result $level "$($providerEntry.provider) MCP" "$($providerEntry.status): $($providerEntry.detail)"
120
+ if ($level -eq 'FAIL') { $coreFailure = $true }
121
+ }
122
+ } catch { Write-Result 'FAIL' 'Provider MCP' 'provider status was not valid JSON'; $coreFailure = $true }
123
+ } else { Write-Result 'INFO' 'Provider MCP' 'BLOCKED: Graph runtime or Node.js unavailable' }
124
+ }
125
+ if ($controlPlan) {
126
+ Write-Result 'INFO' 'Desired state plan' $controlPlan.Identity
127
+ foreach ($item in $controlPlan.Components) {
128
+ if ($item.Drift -eq 'IN_SYNC') { Write-Result 'OK' "Plan/$($item.Id)" 'IN_SYNC' }
129
+ elseif ($item.Drift -eq 'NOT_APPLICABLE' -or -not $item.Desired) { Write-Result 'INFO' "Plan/$($item.Id)" "$($item.Drift); preserved" }
130
+ elseif ($item.Id -eq 'codex-usage-tracking' -and $item.Drift -eq 'MISSING') { Write-Result 'INFO' "Plan/$($item.Id)" 'optional; explicit installation was not requested' }
131
+ else { Write-Result 'FAIL' "Plan/$($item.Id)" "$($item.Drift); ownership=$($item.ActualOwnership); repair=$($item.Repair)"; $coreFailure = $true }
132
+ }
133
+ }
134
+ foreach ($additionalRoot in $additionalSkillRoots) {
135
+ foreach ($component in Get-AfyxComponentContract | Where-Object { $_.type -eq 'skill' -and $_.ownership -eq 'afyx' }) {
136
+ $desired = -not $controlPlan -or [string]$component.id -in $controlPlan.DesiredComponents
137
+ $target = Join-Path $additionalRoot ([string]$component.install_path)
138
+ $ownership = Get-AfyxSkillOwnership -Target $target -Component ([string]$component.id) -ExpectedOwner ([string]$component.ownership)
139
+ if ($ownership -eq 'AFYX_OWNED_UNMODIFIED') { Write-Result 'OK' "Provider skill/$($component.id)" "$additionalRoot; ownership verified" }
140
+ elseif ($ownership -eq 'NOT_INSTALLED' -and -not $desired) { Write-Result 'INFO' "Provider skill/$($component.id)" "$additionalRoot; not selected" }
141
+ elseif ($desired) { Write-Result 'FAIL' "Provider skill/$($component.id)" "$additionalRoot; $ownership"; $coreFailure = $true }
142
+ }
143
+ }
144
+ # Inspect effective on-disk provider companion ownership instead of inferring
145
+ # integration from runtime metadata or a planned routing status.
146
+ if ($controlPlan -and $Provider.Count) {
147
+ foreach ($id in @('afyx-context', 'afyx-forge')) {
148
+ if ($id -notin $controlPlan.DesiredComponents) { continue }
149
+ if ($id -eq 'afyx-context' -and $env:AFYX_CONTEXT_OPT_IN -eq '0') {
150
+ Write-Result 'INFO' 'Afyx Context Companion' 'explicitly disabled; no automatic re-enable'
151
+ continue
152
+ }
153
+ $state = $componentStates[$id]
154
+ if ($state.State -ne 'HEALTHY') { continue } # Reported by the normal desired-state check.
155
+ foreach ($root in @($providerSkillRoots | Select-Object -Unique)) {
156
+ $target = Join-Path $root $id
157
+ $ownerState = Get-AfyxSkillOwnership -Target $target -Component $id -ExpectedOwner 'afyx'
158
+ if ($ownerState -eq 'AFYX_OWNED_UNMODIFIED') {
159
+ Write-Result 'OK' "Provider companion/$id" "$root; ownership verified; invocation remains on demand"
160
+ } elseif ($ownerState -eq 'NOT_INSTALLED' -and $configuredProviders.Count -eq 0) {
161
+ Write-Result 'INFO' "Provider companion/$id" "$root; provider integration is not configured"
162
+ } else {
163
+ Write-Result 'FAIL' "Provider companion/$id" "$root; ownership=$ownerState; expected an Afyx-owned skill for the selected runtime"
164
+ $coreFailure = $true
165
+ }
166
+ }
167
+ }
168
+ }
169
+ $git = Get-Command git -ErrorAction SilentlyContinue
170
+ $node = Get-Command node -ErrorAction SilentlyContinue
171
+ $npm = Get-Command npm -ErrorAction SilentlyContinue
172
+ Write-Result 'OK' 'OS/architecture [REQUIRED]' "$([System.Runtime.InteropServices.RuntimeInformation]::OSDescription) / $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)"
173
+ Write-Result 'OK' 'Platform shell [REQUIRED]' "PowerShell $($PSVersionTable.PSVersion)"
174
+ if ($git) { Write-Result 'OK' 'Git [REQUIRED]' ((& git --version 2>$null) -join ' ') } else { Write-Result 'FAIL' 'Git [REQUIRED]' 'missing; install Git for Windows from https://git-scm.com/'; $coreFailure = $true }
175
+ if ($node) {
176
+ $nodeText = (& node --version 2>$null) -join ' '
177
+ $match = [regex]::Match($nodeText, '(\d+)\.(\d+)\.(\d+)')
178
+ if ($match.Success -and [version]$match.Value -ge [version]'22.5.0') { Write-Result 'OK' 'Node.js [COMPONENT_REQUIRED:Afyx Graph]' $nodeText }
179
+ else { Write-Result 'WARN' 'Node.js [COMPONENT_REQUIRED:Afyx Graph]' "$nodeText; requires >=22.5.0" }
180
+ } else { Write-Result 'INFO' 'Node.js [COMPONENT_REQUIRED:Afyx Graph]' 'missing; install from https://nodejs.org/ before selecting Afyx Graph' }
181
+ if ($node) { Write-Result 'OK' 'Node.js [COMPONENT_REQUIRED:Afyx Context]' ((& node --version 2>$null) -join ' ') }
182
+ else { Write-Result 'INFO' 'Node.js [COMPONENT_REQUIRED:Afyx Context]' 'missing; required only when Afyx Context is selected' }
183
+ if ($npm) { Write-Result 'OK' 'npm [BUILD_ONLY:Afyx Graph]' ((& npm --version 2>$null) -join ' ') } else { Write-Result 'INFO' 'npm [BUILD_ONLY:Afyx Graph]' 'missing; required only for local artifact fallback' }
184
+ Write-Result 'OK' 'Archive/checksum [COMPONENT_REQUIRED:Afyx Graph]' 'Expand-Archive and Get-FileHash available'
185
+ $codexRequired = 'codex' -in $Provider -or -not $Provider.Count
186
+ $antigravityRequired = 'antigravity' -in $Provider
187
+ $claudeRequired = 'claude' -in $Provider
188
+
189
+ $codexHost = Get-AfyxCodexHost
190
+ $codex = if ($codexHost.State -eq 'CLI_READY') { [pscustomobject]@{ Source = $codexHost.Path } } else { $null }
191
+ $extension = [bool](Get-ChildItem -Path (Join-Path $env:USERPROFILE '.vscode\extensions\openai.chatgpt-*') -Directory -ErrorAction SilentlyContinue | Select-Object -First 1)
192
+ if ($codex) {
193
+ try {
194
+ $version = (& $codex.Source --version 2>$null) -join ' '
195
+ if ($LASTEXITCODE -ne 0) { throw 'version command returned a non-zero exit code' }
196
+ Write-Result 'OK' 'Codex CLI' $version
197
+ }
198
+ catch {
199
+ Write-Result $(if ($codexRequired) { 'FAIL' } else { 'WARN' }) 'Codex CLI' 'version command failed'
200
+ if ($codexRequired) { $coreFailure = $true }
201
+ }
202
+ } else { Write-Result 'INFO' 'Codex CLI' $(if ($codexRequired) { 'not found' } else { 'not found (optional)' }) }
203
+ if ($extension) { Write-Result 'OK' 'VS Code extension' 'detected' } else { Write-Result 'INFO' 'VS Code extension' 'not detected' }
204
+ if ($codexRequired -and -not $codex) {
205
+ Write-Result 'FAIL' 'Codex host' "$($codexHost.Detail) A VS Code extension does not provide native MCP configuration."
206
+ $coreFailure = $true
207
+ }
208
+
209
+ if ($antigravityRequired) {
210
+ $antigravity = Get-Command agy -ErrorAction SilentlyContinue
211
+ if (-not $antigravity) { $antigravity = Get-Command antigravity -ErrorAction SilentlyContinue }
212
+ if ($antigravity) {
213
+ try {
214
+ $version = (& $antigravity.Source --version 2>$null) -join ' '
215
+ Write-Result 'OK' 'Antigravity host' "detected ($version)"
216
+ } catch {
217
+ Write-Result 'FAIL' 'Antigravity host' 'version command failed'
218
+ $coreFailure = $true
219
+ }
220
+ } else {
221
+ Write-Result 'FAIL' 'Antigravity host' 'not found; install agy/antigravity'
222
+ $coreFailure = $true
223
+ }
224
+ }
225
+
226
+ if ($claudeRequired) {
227
+ $claude = Get-Command claude.exe -ErrorAction SilentlyContinue
228
+ if (-not $claude) { $claude = Get-Command claude.cmd -ErrorAction SilentlyContinue }
229
+ if (-not $claude) { $claude = Get-Command claude -ErrorAction SilentlyContinue }
230
+ if ($claude) {
231
+ try {
232
+ $version = (& claude --version 2>$null) -join ' '
233
+ Write-Result 'OK' 'Claude Code host' "detected ($version)"
234
+ } catch {
235
+ Write-Result 'FAIL' 'Claude Code host' 'version command failed'
236
+ $coreFailure = $true
237
+ }
238
+ } else {
239
+ Write-Result 'FAIL' 'Claude Code host' 'not found; install Claude Code CLI'
240
+ $coreFailure = $true
241
+ }
242
+ }
243
+
244
+ $requiredIds = if ($controlPlan) { @($controlPlan.DesiredComponents) } else { @('efficient-coding', 'odoo-engineering') }
245
+ foreach ($component in ($componentStates.Values | Where-Object { $_.Id -in $requiredIds -and $_.Type -eq 'skill' } | Sort-Object { $requiredIds.IndexOf($_.Id) })) {
246
+ if ($component.State -eq 'HEALTHY') { Write-Result 'OK' $component.Name $component.Detail }
247
+ else { Write-Result 'FAIL' $component.Name "$($component.State): $($component.Detail)"; $coreFailure = $true }
248
+ }
249
+
250
+ $expert = $componentStates['afyx-engineering-expert']
251
+ switch ($expert.State) {
252
+ 'HEALTHY' { Write-Result 'OK' $expert.Name "$($expert.Version); optional skill valid" }
253
+ 'NOT INSTALLED' { Write-Result 'INFO' $expert.Name 'not installed (optional)' }
254
+ default { Write-Result 'WARN' $expert.Name "$($expert.State): $($expert.Detail) (optional)" }
255
+ }
256
+
257
+ $graph = $componentStates['afyx-graph']
258
+ switch ($graph.State) {
259
+ 'NOT INSTALLED' { Write-Result 'INFO' 'Afyx Graph' 'not installed (optional)' }
260
+ 'HEALTHY' {
261
+ $graphCli = Join-Path $graph.Path 'bin\afyx-graph.cmd'
262
+ try {
263
+ $reported = (& $graphCli --version 2>$null) -join ' '
264
+ if ($LASTEXITCODE -ne 0 -or $reported -notmatch [regex]::Escape([string]$graph.Version)) { throw 'version mismatch' }
265
+ & $graphCli help *> $null
266
+ if ($LASTEXITCODE -ne 0) { throw 'help command failed' }
267
+ Write-Result 'OK' 'Afyx Graph' "$reported; executable verification passed"
268
+ } catch { Write-Result 'FAIL' 'Afyx Graph' "metadata is healthy but executable verification failed: $($_.Exception.Message)"; $coreFailure = $true }
269
+ }
270
+ 'INCOMPLETE' { Write-Result 'WARN' 'Afyx Graph' 'incomplete Afyx-owned runtime (optional)' }
271
+ 'INVALID' { Write-Result 'WARN' 'Afyx Graph' 'invalid metadata (optional)' }
272
+ default { Write-Result 'WARN' 'Afyx Graph' "state $($graph.State): $($graph.Detail) (optional)" }
273
+ }
274
+ if ($codexRequired) {
275
+ if ($graph.State -eq 'HEALTHY' -and $node -and $codex) {
276
+ $entry = Join-Path $graph.Path 'current\lib\dist\bin\afyx-graph.js'
277
+ $integrationTool = Join-Path $PSScriptRoot 'scripts\afyx-mcp-integration.mjs'
278
+ $integrationJson = (& $node.Source $integrationTool --node $node.Source --entry $entry --codex $codex.Source --codex-home $codexHome 2>$null) -join ''
279
+ try {
280
+ $integration = $integrationJson | ConvertFrom-Json
281
+ $level = if ($integration.mcp -eq 'MCP_REACHABLE') { 'OK' } elseif ($integration.mcp -eq 'MCP_NOT_CONFIGURED') { 'INFO' } else { 'WARN' }
282
+ Write-Result $level 'Afyx Graph MCP' "$($integration.mcp): $($integration.detail)"
283
+ } catch { Write-Result 'WARN' 'Afyx Graph MCP' 'MCP_BLOCKED: integration status unavailable' }
284
+ } elseif (-not $codex) { Write-Result 'INFO' 'Afyx Graph MCP' 'MCP_BLOCKED: Codex CLI unavailable' }
285
+ elseif ($graph.State -ne 'HEALTHY') { Write-Result 'INFO' 'Afyx Graph MCP' 'MCP_BLOCKED: Graph runtime unavailable' }
286
+ else { Write-Result 'INFO' 'Afyx Graph MCP' 'MCP_NOT_CONFIGURED' }
287
+ }
288
+ $context = $componentStates['afyx-context']
289
+ switch ($context.State) {
290
+ 'NOT INSTALLED' { Write-Result 'INFO' 'Afyx Context Engine' 'not installed (optional; explicit selection only)' }
291
+ 'HEALTHY' {
292
+ $contextCli = Join-Path $context.Path 'current\bin\afyx-context.cmd'
293
+ try {
294
+ $reported = (& $contextCli --version 2>$null) -join ' '
295
+ if ($LASTEXITCODE -ne 0 -or $reported -notmatch [regex]::Escape([string]$context.Version)) { throw 'version mismatch' }
296
+ & $contextCli --help *> $null
297
+ if ($LASTEXITCODE -ne 0) { throw 'help command failed' }
298
+ Write-Result 'OK' 'Afyx Context Engine' "$reported; integrity and executable verification passed; Graph integration remains OFF"
299
+ } catch { Write-Result 'FAIL' 'Afyx Context Engine' "metadata is healthy but executable verification failed: $($_.Exception.Message)"; $coreFailure = $true }
300
+ }
301
+ default { Write-Result 'WARN' 'Afyx Context Engine' "$($context.State): $($context.Detail) (optional)" }
302
+ }
303
+
304
+ $forge = $componentStates['afyx-forge']
305
+ switch ($forge.State) {
306
+ 'NOT INSTALLED' { Write-Result 'INFO' 'Afyx Forge Core' 'not installed (optional; selectable via custom preset)' }
307
+ 'HEALTHY' {
308
+ $forgeCli = Join-Path $forge.Path 'bin\afyx-forge.cmd'
309
+ try {
310
+ & (Join-Path $PSScriptRoot 'scripts\install-afyx-forge.ps1') -RuntimeRoot $forge.Path -Verify *> $null
311
+ if ($LASTEXITCODE -ne 0) { throw 'integrity check failed' }
312
+ $reported = (& $forgeCli --version 2>$null) -join ' '
313
+ if ($LASTEXITCODE -ne 0 -or $reported -notmatch [regex]::Escape([string]$forge.Version)) { throw 'version mismatch' }
314
+ $doctorOut = (& $forgeCli doctor 2>$null) -join ' '
315
+ if ($LASTEXITCODE -ne 0) { throw 'doctor command failed' }
316
+ Write-Result 'OK' 'Afyx Forge Core' "$reported; integrity and executable verification passed; local A8 GO owner-approved, formal 0/36 waived"
317
+ } catch { Write-Result 'FAIL' 'Afyx Forge Core' "metadata is healthy but executable verification failed: $($_.Exception.Message)"; $coreFailure = $true }
318
+ }
319
+ default { Write-Result 'WARN' 'Afyx Forge Core' "$($forge.State): $($forge.Detail) (optional)" }
320
+ }
321
+ if ($codexRequired) {
322
+ if (Test-Path -LiteralPath $configPath -PathType Leaf) { Write-Result 'OK' 'Codex config' 'read-only check completed' }
323
+ else { Write-Result 'WARN' 'Codex config' 'not found; optional MCP entries unavailable' }
324
+ }
325
+
326
+ $usageComponent = $componentStates['codex-usage-tracking']
327
+ $hooksPath = Join-Path $codexHome 'hooks.json'
328
+ $tasksPath = Join-Path $env:APPDATA 'Code\User\tasks.json'
329
+ $usagePresent = $usageComponent.State -notin @('NOT INSTALLED', 'UNKNOWN')
330
+ if (-not $usagePresent -and (Test-Path -LiteralPath $hooksPath -PathType Leaf)) {
331
+ try { $usagePresent = (Get-Content -Raw -LiteralPath $hooksPath) -match '(?i)(Afyx Codex Usage Tracking|codex-usage-stop\.ps1)' } catch { }
332
+ }
333
+ if (-not $usagePresent -and (Test-Path -LiteralPath $tasksPath -PathType Leaf)) {
334
+ try { $usagePresent = (Get-Content -Raw -LiteralPath $tasksPath) -match 'Codex: Watch Token Usage' } catch { }
335
+ }
336
+ if (-not $usagePresent) {
337
+ Write-Result 'INFO' 'Codex Usage Tracker' 'optional; not installed'
338
+ } else {
339
+ if ($usageComponent.State -eq 'HEALTHY') { Write-Result 'OK' 'Codex Usage Tracker' 'runtime files installed' }
340
+ else { Write-Result 'WARN' 'Codex Usage Tracker' 'runtime files incomplete (optional)' }
341
+
342
+ $hookConfigured = $false
343
+ if (Test-Path -LiteralPath $hooksPath -PathType Leaf) {
344
+ try {
345
+ $hooksDocument = Get-Content -Raw -LiteralPath $hooksPath | ConvertFrom-AfyxJson -Depth 50 -ErrorAction Stop
346
+ $hookConfigured = [bool](@($hooksDocument.hooks.Stop | ForEach-Object { $_.hooks } | Where-Object {
347
+ ([string]$_.statusMessage -eq 'Afyx Codex Usage Tracking') -or
348
+ ([string]$_.commandWindows -match '(?i)codex-usage-stop\.ps1') -or
349
+ ([string]$_.command -match '(?i)codex-usage-stop\.ps1')
350
+ }).Count)
351
+ } catch { Write-Result 'WARN' 'Codex Usage Hook' 'hooks.json is invalid JSON' }
352
+ }
353
+ if ($hookConfigured) { Write-Result 'OK' 'Codex Usage Hook' 'global Stop hook configured' }
354
+ else { Write-Result 'WARN' 'Codex Usage Hook' 'global Stop hook not configured (optional)' }
355
+
356
+ try {
357
+ $pricing = Get-Content -Raw -LiteralPath (Join-Path $codexHome 'tools\codex-usage-pricing.json') | ConvertFrom-AfyxJson -Depth 20 -ErrorAction Stop
358
+ if ($pricing.unit_tokens -and $pricing.models) { Write-Result 'OK' 'Codex Usage Pricing' 'valid' }
359
+ else { throw 'required pricing fields missing' }
360
+ } catch { Write-Result 'WARN' 'Codex Usage Pricing' 'missing or invalid (optional)' }
361
+
362
+ $taskConfigured = $false
363
+ if (Test-Path -LiteralPath $tasksPath -PathType Leaf) {
364
+ try {
365
+ $taskDocument = Get-Content -Raw -LiteralPath $tasksPath | ConvertFrom-AfyxJson -Depth 30 -ErrorAction Stop
366
+ $taskConfigured = [bool](@($taskDocument.tasks | Where-Object { $_.label -eq 'Codex: Watch Token Usage' }).Count)
367
+ } catch { }
368
+ }
369
+ if ($taskConfigured) { Write-Result 'OK' 'Codex Usage VS Code Task' 'configured' }
370
+ else { Write-Result 'WARN' 'Codex Usage VS Code Task' 'not configured (optional fallback)' }
371
+ Write-Result 'INFO' 'Codex Usage Hook trust' 'verify with /hooks'
372
+ }
373
+
374
+ if ($Provider.Count -and $node) {
375
+ $workflowProviders = @($Provider | Where-Object { $_ -eq 'antigravity' -or ($_ -eq 'claude' -and $ProviderScope -eq 'workspace') })
376
+ $bridgeLifecycle = Join-Path $PSScriptRoot 'scripts\afyx-host-bridge-lifecycle.mjs'
377
+ $bridgeJson = (& $node.Source $bridgeLifecycle '--runtime-root' $HostBridgeRuntimeRoot 2>$null) -join ''
378
+ try { $bridge = $bridgeJson | ConvertFrom-AfyxJson -Depth 10 }
379
+ catch { $bridge = $null }
380
+ if ($bridge -and $bridge.status -eq 'READY') {
381
+ Write-Result 'OK' 'Afyx Universal Host Bridge' "$($bridge.sourceRevision); integrity verified"
382
+ if ($workflowProviders.Count) {
383
+ $providerArgs = @((Join-Path $PSScriptRoot 'scripts\afyx-provider-integration.mjs'), '--providers', ($workflowProviders -join ','),
384
+ '--scope', $ProviderScope, '--workspace-root', $WorkspaceRoot, '--gemini-home', $GeminiHome,
385
+ '--codex-home', $codexHome, '--node', $node.Source, '--entry', $bridge.entry,
386
+ '--server', 'afyx_workflow', '--mode', 'workflow', '--tool', 'afyx_workflow',
387
+ '--install-root', $AfyxInstallRoot, '--authorize', 'afyx-graph,afyx-context', '--verify')
388
+ if ($claudeCommand) { $providerArgs += @('--claude', $claudeCommand.Source) }
389
+ if ($ClaudeConfigDir) { $providerArgs += @('--claude-config-dir', $ClaudeConfigDir) }
390
+ $providerJson = (& $node.Source @providerArgs 2>$null) -join ''
391
+ try { $providerResult = $providerJson | ConvertFrom-AfyxJson -Depth 20 }
392
+ catch { $providerResult = $null }
393
+ if (-not $providerResult -or $providerResult.status -eq 'BLOCKED') {
394
+ Write-Result 'FAIL' 'Afyx workflow MCP' $(if ($providerJson) { $providerJson } else { 'provider verification failed' })
395
+ $coreFailure = $true
396
+ } else {
397
+ Write-Result 'OK' 'Afyx workflow MCP' $providerResult.status
398
+ }
399
+ } else {
400
+ Write-Result 'INFO' 'Afyx workflow MCP' 'session/workspace-isolated; direct CLI and session override available'
401
+ }
402
+ } elseif ($workflowProviders.Count -or (Test-Path -LiteralPath $HostBridgeRuntimeRoot)) {
403
+ Write-Result 'FAIL' 'Afyx Universal Host Bridge' $(if ($bridgeJson) { $bridgeJson } else { 'not installed or integrity verification failed' })
404
+ $coreFailure = $true
405
+ } else {
406
+ Write-Result 'INFO' 'Afyx Universal Host Bridge' 'not installed (managed infrastructure for Antigravity/Claude workflow)'
407
+ }
408
+ }
409
+
410
+ if ($coreFailure) { Write-Result 'FAIL' 'Core readiness'; exit 1 }
411
+ Write-Result 'OK' 'Core readiness' 'ready; optional enhancement warnings do not affect this result'