@lesliechan721/aw 0.1.0-beta.73 → 0.1.0-beta.74
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/dist/authoring/assets/aw-runtime-config.mjs +65 -43
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
- package/dist/authoring/scripts/add-skill.mjs +5 -14
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +4 -28
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +2 -2
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +0 -1
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +234 -1422
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/aw-skill-eval-materializer.d.ts +2 -0
- package/dist/scripts/aw-skill-eval-materializer.js +19 -80
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/test-plugin-scripts.js +6 -8
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +1 -1
- package/dist/src/commands/aw-capabilities.js +2 -2
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.js +3 -3
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.d.ts +4 -0
- package/dist/src/commands/deployment-confirmation.js +20 -0
- package/dist/src/commands/deployment-confirmation.js.map +1 -0
- package/dist/src/commands/managed-commands.js +4 -2
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/offline-cleanup-evidence.d.ts +3 -1
- package/dist/src/commands/offline-cleanup-evidence.js +9 -4
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +6 -0
- package/dist/src/commands/operation-plan.js +29 -2
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/options.d.ts +6 -2
- package/dist/src/commands/options.js +5 -4
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +29 -41
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.js +5 -5
- package/dist/src/commands/public-config-confirmation.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +47 -0
- package/dist/src/commands/public-lifecycle-result.js +119 -4
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -0
- package/dist/src/commands/public-lifecycle.js +15 -2
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.d.ts +1 -0
- package/dist/src/commands/public-plugin-query.js +28 -8
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +12 -11
- package/dist/src/commands/rebuild-command.js +529 -769
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +21 -43
- package/dist/src/commands/rebuild-integration.js +306 -3600
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +13 -0
- package/dist/src/commands/rebuild-operations.js +60 -15
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +59 -0
- package/dist/src/commands/rebuild-platform-integration.js +1200 -0
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
- package/dist/src/commands/review-inspection.js +41 -4
- package/dist/src/commands/review-inspection.js.map +1 -1
- package/dist/src/commands/review-preparation.d.ts +2 -0
- package/dist/src/commands/review-preparation.js +23 -60
- package/dist/src/commands/review-preparation.js.map +1 -1
- package/dist/src/commands/skill-eval.js +1 -0
- package/dist/src/commands/skill-eval.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +3 -1
- package/dist/src/commands/status-v6.js +24 -15
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/targets-command.d.ts +9 -0
- package/dist/src/commands/targets-command.js +57 -6
- package/dist/src/commands/targets-command.js.map +1 -1
- package/dist/src/commands/write-commands.js +43 -28
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +2 -2
- package/dist/src/constants.js +2 -2
- package/dist/src/constants.js.map +1 -1
- package/dist/src/generators/local-plugin.js +59 -248
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/index.js +40 -14
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +1 -1
- package/dist/src/output/command-receipt.js +3 -1
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/native-consent.d.ts +2 -0
- package/dist/src/output/native-consent.js +5 -0
- package/dist/src/output/native-consent.js.map +1 -0
- package/dist/src/output/public-result.js +60 -0
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/rebuild-progress.js +5 -5
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.js +19 -2
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/platforms/capabilities.d.ts +10 -0
- package/dist/src/platforms/capabilities.js +158 -0
- package/dist/src/platforms/capabilities.js.map +1 -0
- package/dist/src/platforms/contracts.d.ts +338 -0
- package/dist/src/platforms/contracts.js +2 -0
- package/dist/src/platforms/contracts.js.map +1 -0
- package/dist/src/platforms/cursor-workspace-hook.d.ts +22 -0
- package/dist/src/platforms/cursor-workspace-hook.js +185 -0
- package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
- package/dist/src/platforms/discovery.d.ts +74 -0
- package/dist/src/platforms/discovery.js +582 -0
- package/dist/src/platforms/discovery.js.map +1 -0
- package/dist/src/platforms/gemini-activation.d.ts +36 -0
- package/dist/src/platforms/gemini-activation.js +331 -0
- package/dist/src/platforms/gemini-activation.js.map +1 -0
- package/dist/src/platforms/gemini-consent.d.ts +8 -0
- package/dist/src/platforms/gemini-consent.js +79 -0
- package/dist/src/platforms/gemini-consent.js.map +1 -0
- package/dist/src/platforms/identity.d.ts +4 -0
- package/dist/src/platforms/identity.js +22 -0
- package/dist/src/platforms/identity.js.map +1 -0
- package/dist/src/platforms/inspection-grok.d.ts +4 -0
- package/dist/src/platforms/inspection-grok.js +173 -0
- package/dist/src/platforms/inspection-grok.js.map +1 -0
- package/dist/src/platforms/inspection-native.d.ts +6 -0
- package/dist/src/platforms/inspection-native.js +379 -0
- package/dist/src/platforms/inspection-native.js.map +1 -0
- package/dist/src/platforms/inspection-pi.d.ts +4 -0
- package/dist/src/platforms/inspection-pi.js +212 -0
- package/dist/src/platforms/inspection-pi.js.map +1 -0
- package/dist/src/platforms/inspection.d.ts +13 -0
- package/dist/src/platforms/inspection.js +189 -0
- package/dist/src/platforms/inspection.js.map +1 -0
- package/dist/src/platforms/layout.d.ts +21 -0
- package/dist/src/platforms/layout.js +239 -0
- package/dist/src/platforms/layout.js.map +1 -0
- package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
- package/dist/src/platforms/lifecycle-native-services.js +147 -0
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
- package/dist/src/platforms/lifecycle-native.d.ts +9 -0
- package/dist/src/platforms/lifecycle-native.js +252 -0
- package/dist/src/platforms/lifecycle-native.js.map +1 -0
- package/dist/src/platforms/lifecycle.d.ts +25 -0
- package/dist/src/platforms/lifecycle.js +452 -0
- package/dist/src/platforms/lifecycle.js.map +1 -0
- package/dist/src/platforms/managed-command-placement.d.ts +8 -0
- package/dist/src/platforms/managed-command-placement.js +79 -0
- package/dist/src/platforms/managed-command-placement.js.map +1 -0
- package/dist/src/platforms/projection-code-extension.d.ts +8 -0
- package/dist/src/platforms/projection-code-extension.js +121 -0
- package/dist/src/platforms/projection-code-extension.js.map +1 -0
- package/dist/src/platforms/projection-command-resources.d.ts +7 -0
- package/dist/src/platforms/projection-command-resources.js +74 -0
- package/dist/src/platforms/projection-command-resources.js.map +1 -0
- package/dist/src/platforms/projection-files.d.ts +27 -0
- package/dist/src/platforms/projection-files.js +111 -0
- package/dist/src/platforms/projection-files.js.map +1 -0
- package/dist/src/platforms/projection-marketplace.d.ts +19 -0
- package/dist/src/platforms/projection-marketplace.js +42 -0
- package/dist/src/platforms/projection-marketplace.js.map +1 -0
- package/dist/src/platforms/projection.d.ts +10 -0
- package/dist/src/platforms/projection.js +446 -0
- package/dist/src/platforms/projection.js.map +1 -0
- package/dist/src/platforms/registry.d.ts +4 -0
- package/dist/src/platforms/registry.js +30 -0
- package/dist/src/platforms/registry.js.map +1 -0
- package/dist/src/platforms/supplement-layout.d.ts +16 -0
- package/dist/src/platforms/supplement-layout.js +31 -0
- package/dist/src/platforms/supplement-layout.js.map +1 -0
- package/dist/src/portable/commands.d.ts +7 -5
- package/dist/src/portable/commands.js +6 -1
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +8 -6
- package/dist/src/portable/materializer.js +47 -245
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery-layout.js +2 -15
- package/dist/src/portable/recovery-layout.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +10 -1
- package/dist/src/portable/recovery.js +34 -8
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +4 -7
- package/dist/src/recovery/coordinator.js +151 -119
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/demand.d.ts +1 -1
- package/dist/src/recovery/demand.js +10 -42
- package/dist/src/recovery/demand.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.js +112 -52
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +4 -22
- package/dist/src/recovery/joint-demand.js +43 -40
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/receipt.d.ts +23 -8
- package/dist/src/recovery/retirement.d.ts +1 -1
- package/dist/src/recovery/retirement.js +122 -29
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/recovery/status.d.ts +13 -6
- package/dist/src/recovery/status.js +479 -79
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/recovery/types.d.ts +3 -3
- package/dist/src/review/platform-profile.d.ts +3 -0
- package/dist/src/review/platform-profile.js +16 -0
- package/dist/src/review/platform-profile.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +1 -0
- package/dist/src/review/review-profile.js +8 -2
- package/dist/src/review/review-profile.js.map +1 -1
- package/dist/src/review/review-selection.d.ts +2 -11
- package/dist/src/review/review-selection.js +97 -71
- package/dist/src/review/review-selection.js.map +1 -1
- package/dist/src/review/review-types.d.ts +3 -0
- package/dist/src/review/review-types.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +44 -9
- package/dist/src/review/skill-materialization.js +112 -136
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.d.ts +8 -5
- package/dist/src/review/source-binding.js +99 -41
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/agent-management.js +112 -10
- package/dist/src/tui/agent-management.js.map +1 -1
- package/dist/src/tui/agent-settings.d.ts +3 -0
- package/dist/src/tui/agent-settings.js +10 -11
- package/dist/src/tui/agent-settings.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +58 -20
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.js +2 -2
- package/dist/src/tui/content-item-card.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +198 -152
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +5 -9
- package/dist/src/tui/controller.js +40 -18
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/deployment-view.d.ts +10 -0
- package/dist/src/tui/deployment-view.js +91 -0
- package/dist/src/tui/deployment-view.js.map +1 -0
- package/dist/src/tui/glossary.js +4 -4
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/tui/model.d.ts +5 -0
- package/dist/src/tui/model.js +73 -12
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.js +2 -1
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
- package/dist/src/tui/operation-history.d.ts +5 -4
- package/dist/src/tui/operation-history.js.map +1 -1
- package/dist/src/tui/operation-review-planner.d.ts +7 -2
- package/dist/src/tui/operation-review-planner.js +97 -42
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/tui/plugin-content.d.ts +5 -3
- package/dist/src/tui/plugin-content.js +70 -508
- package/dist/src/tui/plugin-content.js.map +1 -1
- package/dist/src/tui/plugin-detail.d.ts +3 -2
- package/dist/src/tui/plugin-detail.js +33 -25
- package/dist/src/tui/plugin-detail.js.map +1 -1
- package/dist/src/tui/scoped-inventory.d.ts +10 -6
- package/dist/src/tui/scoped-inventory.js +34 -1
- package/dist/src/tui/scoped-inventory.js.map +1 -1
- package/dist/src/types.d.ts +4 -63
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +10 -4
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +26 -2
- package/dist/src/utils/artifact-plan.js +113 -489
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +100 -93
- package/dist/src/utils/artifact-renderer.js +173 -346
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +21 -11
- package/dist/src/utils/artifact-request.js +56 -80
- package/dist/src/utils/artifact-request.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +30 -146
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-digests.d.ts +2 -12
- package/dist/src/utils/catalog-digests.js +0 -39
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +7 -0
- package/dist/src/utils/catalog-source-references.js +234 -19
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-config-observation.d.ts +19 -0
- package/dist/src/utils/codex-config-observation.js +145 -0
- package/dist/src/utils/codex-config-observation.js.map +1 -0
- package/dist/src/utils/codex-executable-discovery.d.ts +2 -0
- package/dist/src/utils/codex-executable-discovery.js +47 -13
- package/dist/src/utils/codex-executable-discovery.js.map +1 -1
- package/dist/src/utils/codex-manager.js +1 -1
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +3 -0
- package/dist/src/utils/codex-native-observation.js +53 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/codex-shared-native.d.ts +3 -1
- package/dist/src/utils/codex-shared-native.js +46 -5
- package/dist/src/utils/codex-shared-native.js.map +1 -1
- package/dist/src/utils/codex-skill-staging.d.ts +4 -3
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-surface-analysis.d.ts +5 -2
- package/dist/src/utils/codex-surface-analysis.js +28 -57
- package/dist/src/utils/codex-surface-analysis.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +34 -0
- package/dist/src/utils/component-command-preparation.js +228 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -0
- package/dist/src/utils/component-resources.d.ts +43 -0
- package/dist/src/utils/component-resources.js +304 -0
- package/dist/src/utils/component-resources.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +17 -6
- package/dist/src/utils/dynamic-skill-tree.js +7 -3
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +11 -44
- package/dist/src/utils/local-marketplace.js +11 -638
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-evidence.d.ts +2 -2
- package/dist/src/utils/managed-command-evidence.js +5 -81
- package/dist/src/utils/managed-command-evidence.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +5 -2
- package/dist/src/utils/managed-command-materialization.js +35 -35
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-preparation.d.ts +67 -0
- package/dist/src/utils/managed-command-preparation.js +146 -0
- package/dist/src/utils/managed-command-preparation.js.map +1 -0
- package/dist/src/utils/managed-command-review.d.ts +26 -0
- package/dist/src/utils/managed-command-review.js +68 -0
- package/dist/src/utils/managed-command-review.js.map +1 -0
- package/dist/src/utils/managed-command-store.js +26 -15
- package/dist/src/utils/managed-command-store.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +19 -0
- package/dist/src/utils/native-cli.js +45 -2
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-demand.d.ts +20 -1
- package/dist/src/utils/native-demand.js.map +1 -1
- package/dist/src/utils/native-tool-review.d.ts +3 -6
- package/dist/src/utils/native-tool-review.js +25 -11
- package/dist/src/utils/native-tool-review.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +26 -3
- package/dist/src/utils/ownership.js +95 -9
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -1
- package/dist/src/utils/paths.js +2 -0
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +46 -0
- package/dist/src/utils/platform-empty-state.js +123 -0
- package/dist/src/utils/platform-empty-state.js.map +1 -0
- package/dist/src/utils/plugin-config-impact.d.ts +17 -11
- package/dist/src/utils/plugin-config-impact.js +46 -62
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-write.js +52 -53
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +0 -2
- package/dist/src/utils/plugin-config.js +0 -6
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-dependencies.d.ts +1 -1
- package/dist/src/utils/plugin-dependencies.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +5 -7
- package/dist/src/utils/runtime-config.js +12 -25
- package/dist/src/utils/runtime-config.js.map +1 -1
- package/dist/src/utils/windows-npm-shim.js +19 -2
- package/dist/src/utils/windows-npm-shim.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/utils/claude-native-render-receipt.d.ts +0 -14
- package/dist/src/utils/claude-native-render-receipt.js +0 -26
- package/dist/src/utils/claude-native-render-receipt.js.map +0 -1
- package/dist/src/utils/claude-skills-root.d.ts +0 -8
- package/dist/src/utils/claude-skills-root.js +0 -87
- package/dist/src/utils/claude-skills-root.js.map +0 -1
- package/dist/src/utils/codex-native-render-receipt.d.ts +0 -40
- package/dist/src/utils/codex-native-render-receipt.js +0 -205
- package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
- package/dist/src/utils/slash-commands.d.ts +0 -1
- package/dist/src/utils/slash-commands.js +0 -2
- package/dist/src/utils/slash-commands.js.map +0 -1
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
import { constants } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { PLATFORM_TARGETS } from '@lesliechan721/aw-plugin-core';
|
|
6
|
+
import { DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS, MINIMUM_AGENT_VERSIONS } from '../constants.js';
|
|
7
|
+
import { discoverCodexExecutables, rethrowFatalError } from '../utils/codex-executable-discovery.js';
|
|
8
|
+
import { extractStrictSemVerTokenFromVersionOutput } from '../utils/agent-version.js';
|
|
9
|
+
import { compareStrictSemVer } from '../utils/manifest.js';
|
|
10
|
+
import { runNativeCli } from '../utils/native-cli.js';
|
|
11
|
+
import { getCodexHome, getClaudeHome, readEnvironmentValue, resolveUserHome } from '../utils/state-paths.js';
|
|
12
|
+
import { resolveWindowsNpmCommand } from '../utils/windows-npm-shim.js';
|
|
13
|
+
import { assertTestReadablePath } from '../utils/test-path-fence.js';
|
|
14
|
+
export const TARGET_DISPLAY_NAMES = {
|
|
15
|
+
codex: 'Codex', claude: 'Claude Code', cursor: 'Cursor', antigravity: 'Antigravity',
|
|
16
|
+
opencode: 'OpenCode', pi: 'Pi', gemini: 'Gemini CLI', copilot: 'GitHub Copilot CLI',
|
|
17
|
+
grok: 'Grok Build', generic: 'Generic',
|
|
18
|
+
};
|
|
19
|
+
const cliProfiles = {
|
|
20
|
+
claude: { names: ['claude'], minimum: MINIMUM_AGENT_VERSIONS.claude, identity: /Claude Code/iu, packageName: '@anthropic-ai/claude-code' },
|
|
21
|
+
cursor: { names: ['cursor-agent', 'agent'], minimum: '2026.11.05-86047df', identity: /Cursor(?: Agent)?/iu },
|
|
22
|
+
antigravity: { names: ['agy'], minimum: '1.3.4', identity: /(?:Antigravity|\bagy\b)/iu },
|
|
23
|
+
opencode: { names: ['opencode'], minimum: '2.0.0', identity: /\bopencode\b/iu, packageName: 'opencode-ai' },
|
|
24
|
+
pi: { names: ['pi'], minimum: '1.0.0',
|
|
25
|
+
identity: /(?:pi coding agent|pi-coding-agent)|^pi - AI coding assistant with read, bash, edit, write tools\r?$/imu,
|
|
26
|
+
packageName: '@earendil-works/pi-coding-agent' },
|
|
27
|
+
gemini: { names: ['gemini'], minimum: '0.63.0', identity: /Gemini(?: CLI)?/iu, packageName: '@google/gemini-cli' },
|
|
28
|
+
copilot: { names: ['copilot'], minimum: '1.0.95', identity: /(?:GitHub Copilot|Copilot CLI)/iu, packageName: '@github/copilot' },
|
|
29
|
+
grok: { names: ['grok'], identity: /\bgrok\b/iu, packageName: '@xai-official/grok' },
|
|
30
|
+
};
|
|
31
|
+
const MAX_PROBE_OUTPUT_BYTES = 1024 * 1024;
|
|
32
|
+
const GEMINI_NPM_VERSION_PROBE_TIMEOUT_MS = 10_000;
|
|
33
|
+
function diagnostic(platform, code, message) {
|
|
34
|
+
return { code, severity: 'warning', message, subject: { target: platform } };
|
|
35
|
+
}
|
|
36
|
+
function productId(platform, product, entry, fallback = '') {
|
|
37
|
+
return JSON.stringify([platform, product, entry?.kind === 'cli' ? entry.executable : '',
|
|
38
|
+
entry?.kind === 'generic' ? entry.root : entry?.configRoot ?? fallback]);
|
|
39
|
+
}
|
|
40
|
+
function installation(platform, product, entry, availability, version, reasonCodes, fallback) {
|
|
41
|
+
return { id: productId(platform, product, entry, fallback), product, version, availability, reasonCodes, entry };
|
|
42
|
+
}
|
|
43
|
+
export function resolvePlatformConfigRoot(platform, ctx) {
|
|
44
|
+
const env = ctx.env ?? process.env;
|
|
45
|
+
const home = resolveUserHome(env, ctx.platform ?? process.platform);
|
|
46
|
+
if (platform === 'codex')
|
|
47
|
+
return getCodexHome(env, ctx.platform);
|
|
48
|
+
if (platform === 'claude')
|
|
49
|
+
return getClaudeHome(env, ctx.platform);
|
|
50
|
+
if (platform === 'gemini') {
|
|
51
|
+
const root = readEnvironmentValue(env, 'GEMINI_CLI_HOME', ctx.platform) ?? home;
|
|
52
|
+
if (!path.isAbsolute(root) || root.includes('\0'))
|
|
53
|
+
throw new Error('clientConfigRootInvalid');
|
|
54
|
+
return path.join(root, '.gemini');
|
|
55
|
+
}
|
|
56
|
+
if (platform === 'grok') {
|
|
57
|
+
const root = readEnvironmentValue(env, 'GROK_HOME', ctx.platform) ?? path.join(home, '.grok');
|
|
58
|
+
if (!path.isAbsolute(root) || root.includes('\0'))
|
|
59
|
+
throw new Error('clientConfigRootInvalid');
|
|
60
|
+
return root;
|
|
61
|
+
}
|
|
62
|
+
if (platform === 'copilot') {
|
|
63
|
+
const root = readEnvironmentValue(env, 'COPILOT_HOME', ctx.platform) ?? path.join(home, '.copilot');
|
|
64
|
+
if (!path.isAbsolute(root) || root.includes('\0'))
|
|
65
|
+
throw new Error('clientConfigRootInvalid');
|
|
66
|
+
return root;
|
|
67
|
+
}
|
|
68
|
+
if (platform === 'pi') {
|
|
69
|
+
// Pi 1.5 getAgentDir/normalizePath: use only the official override. Relative
|
|
70
|
+
// paths have the same meaning as in the Native invocation's exact cwd.
|
|
71
|
+
const windows = (ctx.platform ?? process.platform) === 'win32';
|
|
72
|
+
const paths = windows ? path.win32 : path.posix;
|
|
73
|
+
let root = readEnvironmentValue(env, 'PI_CODING_AGENT_DIR', ctx.platform) || paths.join(home, '.pi', 'agent');
|
|
74
|
+
if (windows && root.startsWith('/') && !root.startsWith('//') && !root.includes('\\')) {
|
|
75
|
+
const drive = root.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/iu);
|
|
76
|
+
if (drive)
|
|
77
|
+
root = `${drive[1].toUpperCase()}:\\${(drive[2] ?? '').replaceAll('/', '\\')}`;
|
|
78
|
+
}
|
|
79
|
+
if (root === '~')
|
|
80
|
+
root = home;
|
|
81
|
+
else if (root.startsWith('~/') || windows && root.startsWith('~\\'))
|
|
82
|
+
root = paths.join(home, root.slice(2));
|
|
83
|
+
if (root.startsWith('file://'))
|
|
84
|
+
root = fileURLToPath(root, { windows });
|
|
85
|
+
if (root.includes('\0'))
|
|
86
|
+
throw new Error('clientConfigRootInvalid');
|
|
87
|
+
return paths.resolve(ctx.cwd, root);
|
|
88
|
+
}
|
|
89
|
+
if (platform === 'generic')
|
|
90
|
+
return path.join(home, '.agents', 'skills');
|
|
91
|
+
if (platform === 'opencode') {
|
|
92
|
+
const root = readEnvironmentValue(env, 'XDG_CONFIG_HOME', ctx.platform) ?? path.join(home, '.config');
|
|
93
|
+
if (!path.isAbsolute(root) || root.includes('\0'))
|
|
94
|
+
throw new Error('clientConfigRootInvalid');
|
|
95
|
+
return path.join(root, 'opencode');
|
|
96
|
+
}
|
|
97
|
+
return path.join(home, platform === 'antigravity' ? '.gemini/config' : `.${platform}`);
|
|
98
|
+
}
|
|
99
|
+
async function probe(ctx, command, args, timeoutMs = DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS) {
|
|
100
|
+
ctx.signal?.throwIfAborted();
|
|
101
|
+
const result = await runNativeCli({ command, args, cwd: ctx.cwd, env: ctx.env,
|
|
102
|
+
signal: ctx.signal, timeoutMs }, ctx.runner);
|
|
103
|
+
if (result.exitCode !== 0 || Buffer.byteLength(result.stdout) + Buffer.byteLength(result.stderr) > MAX_PROBE_OUTPUT_BYTES) {
|
|
104
|
+
throw new Error('probeFailed');
|
|
105
|
+
}
|
|
106
|
+
return `${result.stdout}\n${result.stderr}`;
|
|
107
|
+
}
|
|
108
|
+
async function present(file) {
|
|
109
|
+
try {
|
|
110
|
+
return (await fs.stat(file)).isFile();
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (['ENOENT', 'ENOTDIR'].includes(error.code ?? ''))
|
|
114
|
+
return false;
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function cliPaths(names, ctx) {
|
|
119
|
+
const os = ctx.platform ?? process.platform;
|
|
120
|
+
const env = ctx.env ?? process.env;
|
|
121
|
+
const pathValue = readEnvironmentValue(env, 'PATH', os);
|
|
122
|
+
if (pathValue === undefined)
|
|
123
|
+
return { paths: [], incomplete: false };
|
|
124
|
+
const directories = pathValue.split(os === 'win32' ? ';' : ':');
|
|
125
|
+
const extensions = os === 'win32' ? ['.exe', '.com', '.cmd', '.bat', ''] : [''];
|
|
126
|
+
const result = [];
|
|
127
|
+
let incomplete = false;
|
|
128
|
+
for (const directory of directories)
|
|
129
|
+
for (const name of names) {
|
|
130
|
+
for (const extension of extensions) {
|
|
131
|
+
const file = path.resolve(ctx.cwd, directory.replace(/^"|"$/gu, ''), name + extension);
|
|
132
|
+
try {
|
|
133
|
+
if (!await present(file))
|
|
134
|
+
continue;
|
|
135
|
+
if (os !== 'win32')
|
|
136
|
+
await fs.access(file, constants.X_OK);
|
|
137
|
+
result.push(await fs.realpath(file));
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
rethrowFatalError(error);
|
|
142
|
+
ctx.signal?.throwIfAborted();
|
|
143
|
+
incomplete = true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return { paths: [...new Set(result)], incomplete };
|
|
148
|
+
}
|
|
149
|
+
export async function installationInvocation(product, ctx, args) {
|
|
150
|
+
if (product.entry?.kind !== 'cli')
|
|
151
|
+
throw new Error('clientEntryUnavailable');
|
|
152
|
+
const executable = product.entry.executable;
|
|
153
|
+
if (executable.endsWith('.js'))
|
|
154
|
+
return { command: process.execPath, args: [executable, ...args], cwd: ctx.cwd, env: ctx.env, signal: ctx.signal };
|
|
155
|
+
const commandName = path.basename(executable).replace(/\.(?:cmd|exe|com|bat)$/iu, '');
|
|
156
|
+
const profile = Object.values(cliProfiles).find((candidate) => candidate.names.some((name) => name === commandName));
|
|
157
|
+
if ((ctx.platform ?? process.platform) === 'win32' && profile && 'packageName' in profile) {
|
|
158
|
+
const resolved = await resolveWindowsNpmCommand({ command: executable, packageName: profile.packageName,
|
|
159
|
+
binName: profile.names[0], cwd: ctx.cwd, env: ctx.env });
|
|
160
|
+
return { command: resolved.command, args: [...resolved.argsPrefix, ...args], cwd: ctx.cwd, env: ctx.env, signal: ctx.signal };
|
|
161
|
+
}
|
|
162
|
+
if (/\.(?:cmd|bat)$/iu.test(executable))
|
|
163
|
+
throw new Error('clientLauncherUnsupported');
|
|
164
|
+
return { command: executable, args, cwd: ctx.cwd, env: ctx.env, signal: ctx.signal };
|
|
165
|
+
}
|
|
166
|
+
/** Metadata binds the declared version to this npm JS entry; discovery still probes it. */
|
|
167
|
+
async function geminiNpmIdentity(ctx, invocation, versionOutput, requiredBin) {
|
|
168
|
+
const entry = invocation.command === process.execPath && invocation.args.length === 2
|
|
169
|
+
&& invocation.args[1] === '--version' ? invocation.args[0] : undefined;
|
|
170
|
+
const version = versionOutput.trim();
|
|
171
|
+
if (!entry || !path.isAbsolute(entry) || !entry.endsWith('.js')
|
|
172
|
+
|| extractStrictSemVerTokenFromVersionOutput(version) !== version)
|
|
173
|
+
return false;
|
|
174
|
+
try {
|
|
175
|
+
const actualEntry = await fs.realpath(entry);
|
|
176
|
+
// Official npm layouts place the entry at the package root or one directory below it.
|
|
177
|
+
for (const root of [path.dirname(actualEntry), path.dirname(path.dirname(actualEntry))]) {
|
|
178
|
+
const file = await containedFile(root, path.join(root, 'package.json'));
|
|
179
|
+
if (!file)
|
|
180
|
+
continue;
|
|
181
|
+
const metadata = JSON.parse(await smallText(file));
|
|
182
|
+
if (!metadata || typeof metadata !== 'object' || Array.isArray(metadata))
|
|
183
|
+
return false;
|
|
184
|
+
const pkg = metadata;
|
|
185
|
+
if (pkg.name !== '@google/gemini-cli' || pkg.version !== version
|
|
186
|
+
|| !pkg.bin || typeof pkg.bin !== 'object' || Array.isArray(pkg.bin))
|
|
187
|
+
return false;
|
|
188
|
+
const bin = pkg.bin.gemini;
|
|
189
|
+
if (typeof bin !== 'string' || path.isAbsolute(bin))
|
|
190
|
+
return false;
|
|
191
|
+
const parts = bin.replace(/^\.\//u, '').split(/[/\\]/u);
|
|
192
|
+
if (!parts.length || parts.some((part) => !part || part === '.' || part === '..'))
|
|
193
|
+
return false;
|
|
194
|
+
if (requiredBin && parts.join('/') !== requiredBin)
|
|
195
|
+
return false;
|
|
196
|
+
return await containedFile(root, path.join(root, ...parts)) === actualEntry;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
rethrowFatalError(error);
|
|
201
|
+
ctx.signal?.throwIfAborted();
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
async function discoverCli(platform, ctx) {
|
|
206
|
+
const profile = cliProfiles[platform];
|
|
207
|
+
const products = [];
|
|
208
|
+
const candidates = await cliPaths(profile.names, ctx);
|
|
209
|
+
const diagnostics = candidates.incomplete ? [diagnostic(platform, 'clientEntryUnresolved', 'A client entry could not be inspected safely. Repair its permissions or launcher and check again.')] : [];
|
|
210
|
+
for (const executable of candidates.paths) {
|
|
211
|
+
const entry = { kind: 'cli', executable, configRoot: resolvePlatformConfigRoot(platform, ctx) };
|
|
212
|
+
const product = installation(platform, 'cli', entry, 'unknown', null, ['clientProbeFailed']);
|
|
213
|
+
try {
|
|
214
|
+
const invocation = await installationInvocation(product, ctx, ['--version']);
|
|
215
|
+
const directGeminiVersion = platform === 'gemini' && await geminiNpmIdentity(ctx, invocation, '0.67.0', 'bundle/gemini.js');
|
|
216
|
+
// Fixed 0.67.0 otherwise loads the CLI twice by relaunching Node. Keep
|
|
217
|
+
// this environment override local to its actual version probe.
|
|
218
|
+
const versionContext = directGeminiVersion ? { ...ctx, env: { ...(ctx.env ?? process.env), GEMINI_CLI_NO_RELAUNCH: 'true' } } : ctx;
|
|
219
|
+
const versionOutput = await probe(versionContext, invocation.command, invocation.args, directGeminiVersion ? GEMINI_NPM_VERSION_PROBE_TIMEOUT_MS : DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS);
|
|
220
|
+
if (!profile.identity.test(versionOutput)
|
|
221
|
+
&& !(platform === 'gemini' && await geminiNpmIdentity(ctx, invocation, versionOutput))) {
|
|
222
|
+
const help = await probe(ctx, invocation.command, [...invocation.args.slice(0, -1), '--help']);
|
|
223
|
+
if (!profile.identity.test(help)) {
|
|
224
|
+
product.reasonCodes = ['clientIdentityUnconfirmed'];
|
|
225
|
+
throw new Error('clientIdentityUnconfirmed');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const version = platform === 'cursor' ? versionOutput.match(/\b(\d{4}\.\d{2}\.\d{2}-[a-z0-9]+)\b/u)?.[1] ?? null
|
|
229
|
+
: extractStrictSemVerTokenFromVersionOutput(platform === 'opencode'
|
|
230
|
+
? versionOutput.replace(/\bopencode\s+v(?=\d)/giu, 'opencode ')
|
|
231
|
+
: platform === 'copilot' ? versionOutput.replace(/^GitHub Copilot CLI ([^\s]+)\.\r?$/gmu, 'GitHub Copilot CLI $1') : versionOutput);
|
|
232
|
+
product.version = version;
|
|
233
|
+
if (!version) {
|
|
234
|
+
product.reasonCodes = ['clientVersionUnknown'];
|
|
235
|
+
if (platform === 'grok')
|
|
236
|
+
product.availability = 'available';
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const minimum = 'minimum' in profile ? profile.minimum : undefined;
|
|
240
|
+
const compatible = !minimum || (platform === 'cursor' ? version >= minimum : compareStrictSemVer(version, minimum) >= 0);
|
|
241
|
+
product.availability = compatible ? 'available' : 'unsupported';
|
|
242
|
+
product.reasonCodes = compatible ? [] : ['clientVersionUnsupported'];
|
|
243
|
+
}
|
|
244
|
+
if (platform === 'grok' && product.availability === 'available') {
|
|
245
|
+
// Grok has an interface gate instead of an invented numeric minimum.
|
|
246
|
+
const baseArgs = invocation.args.slice(0, -1);
|
|
247
|
+
const help = await probe(ctx, invocation.command, [...baseArgs, 'plugin', '--help']);
|
|
248
|
+
const list = await probe(ctx, invocation.command, [...baseArgs, 'plugin', 'list', '--help']);
|
|
249
|
+
if (!['install', 'uninstall', 'enable', 'disable'].every((name) => new RegExp(`\\b${name}\\b`, 'u').test(help))
|
|
250
|
+
|| !list.includes('--json')) {
|
|
251
|
+
product.availability = 'unsupported';
|
|
252
|
+
product.reasonCodes = ['clientInstallInterfaceUnsupported'];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
rethrowFatalError(error);
|
|
258
|
+
ctx.signal?.throwIfAborted();
|
|
259
|
+
diagnostics.push(diagnostic(platform, product.reasonCodes[0], 'The client identity, version, or read-only interface could not be confirmed. Repair the client and check again.'));
|
|
260
|
+
}
|
|
261
|
+
products.push(product);
|
|
262
|
+
}
|
|
263
|
+
return result(platform, products, diagnostics);
|
|
264
|
+
}
|
|
265
|
+
function result(platform, installations, diagnostics) {
|
|
266
|
+
const states = installations.map((item) => item.availability);
|
|
267
|
+
const availability = states.includes('available') ? 'available' : states.includes('unknown') || diagnostics.length ? 'unknown'
|
|
268
|
+
: states.includes('unsupported') ? 'unsupported' : states.includes('notApplicable') ? 'notApplicable' : 'missing';
|
|
269
|
+
return { platform, availability, installations, diagnostics };
|
|
270
|
+
}
|
|
271
|
+
async function discoverCodex(ctx) {
|
|
272
|
+
const found = await discoverCodexExecutables({ ...ctx, queryRunner: ctx.runner });
|
|
273
|
+
const products = [];
|
|
274
|
+
for (const candidate of found.candidates) {
|
|
275
|
+
const executable = candidate.manager.argsPrefix[0] ?? candidate.manager.command;
|
|
276
|
+
const entry = { kind: 'cli', executable, configRoot: resolvePlatformConfigRoot('codex', ctx) };
|
|
277
|
+
const product = installation('codex', candidate.manager.kind === 'app' ? 'app' : 'cli', entry, 'unknown', null, ['clientProbeFailed']);
|
|
278
|
+
try {
|
|
279
|
+
const output = await probe(ctx, candidate.manager.command, [...candidate.manager.argsPrefix, '--version']);
|
|
280
|
+
const version = extractStrictSemVerTokenFromVersionOutput(output);
|
|
281
|
+
if (!version || !/\bcodex(?:-cli)?\b/iu.test(output) || candidate.expectedVersion && version !== candidate.expectedVersion)
|
|
282
|
+
throw new Error('clientIdentityUnconfirmed');
|
|
283
|
+
product.version = version;
|
|
284
|
+
product.availability = compareStrictSemVer(version, MINIMUM_AGENT_VERSIONS.codex) >= 0 ? 'available' : 'unsupported';
|
|
285
|
+
product.reasonCodes = product.availability === 'available' ? [] : ['clientVersionUnsupported'];
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
rethrowFatalError(error);
|
|
289
|
+
ctx.signal?.throwIfAborted();
|
|
290
|
+
}
|
|
291
|
+
products.push(product);
|
|
292
|
+
}
|
|
293
|
+
for (const app of found.appsWithoutExecutable ?? []) {
|
|
294
|
+
products.push(installation('codex', 'app', null, 'unsupported', null, ['clientInstallEntryUnavailable'], app));
|
|
295
|
+
}
|
|
296
|
+
for (const executable of found.appExecutables ?? []) {
|
|
297
|
+
if (products.some((product) => product.product === 'app' && product.entry?.kind === 'cli' && product.entry.executable === executable))
|
|
298
|
+
continue;
|
|
299
|
+
const shared = products.find((product) => product.entry?.kind === 'cli' && product.entry.executable === executable);
|
|
300
|
+
if (shared)
|
|
301
|
+
products.push(installation('codex', 'app', shared.entry, shared.availability, shared.version, [...shared.reasonCodes]));
|
|
302
|
+
}
|
|
303
|
+
const diagnostics = found.diagnostics.map(() => diagnostic('codex', 'clientDiscoveryIncomplete', 'Codex discovery could not complete safely. Repair the client entry or check again.'));
|
|
304
|
+
if (found.foundEntry && !products.length && !diagnostics.length)
|
|
305
|
+
diagnostics.push(diagnostic('codex', 'clientEntryUnresolved', 'A Codex entry exists but could not be resolved safely. Repair the client.'));
|
|
306
|
+
return result('codex', products, diagnostics);
|
|
307
|
+
}
|
|
308
|
+
const APP_NAMES = { cursor: 'Cursor', antigravity: 'Antigravity', opencode: 'OpenCode' };
|
|
309
|
+
async function containedFile(root, file) {
|
|
310
|
+
if (!await present(file))
|
|
311
|
+
return null;
|
|
312
|
+
const [canonicalRoot, canonicalFile] = await Promise.all([fs.realpath(root), fs.realpath(file)]);
|
|
313
|
+
const relative = path.relative(canonicalRoot, canonicalFile);
|
|
314
|
+
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
|
|
315
|
+
throw new Error('appIdentityUnsafe');
|
|
316
|
+
return canonicalFile;
|
|
317
|
+
}
|
|
318
|
+
async function smallText(file) {
|
|
319
|
+
const stat = await fs.stat(file);
|
|
320
|
+
if (!stat.isFile() || stat.size > 64 * 1024)
|
|
321
|
+
throw new Error('appMetadataInvalid');
|
|
322
|
+
return fs.readFile(file, 'utf8');
|
|
323
|
+
}
|
|
324
|
+
async function appRuntime(platform, root, product, ctx) {
|
|
325
|
+
if (platform !== 'opencode')
|
|
326
|
+
return;
|
|
327
|
+
// Official DesktopCli resolves this packaged resources binary and its version
|
|
328
|
+
// file. It is read in place; AW never stages the executable or starts serve.
|
|
329
|
+
const runtime = await containedFile(path.dirname(root), path.join(root, (ctx.platform ?? process.platform) === 'win32' ? 'opencode-cli.exe' : 'opencode-cli'));
|
|
330
|
+
if (!runtime) {
|
|
331
|
+
product.availability = 'unsupported';
|
|
332
|
+
product.reasonCodes = ['clientLocalRuntimeMissing'];
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if ((ctx.platform ?? process.platform) !== 'win32')
|
|
336
|
+
await fs.access(runtime, constants.X_OK);
|
|
337
|
+
let version = null;
|
|
338
|
+
const versionFile = await containedFile(path.dirname(root), path.join(root, 'opencode-cli.version'));
|
|
339
|
+
if (versionFile) {
|
|
340
|
+
const value = (await smallText(versionFile)).trim();
|
|
341
|
+
version = extractStrictSemVerTokenFromVersionOutput(value) === value ? value : null;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
const output = await probe(ctx, runtime, ['--version']);
|
|
345
|
+
if (/\bopencode\b/iu.test(output))
|
|
346
|
+
version = extractStrictSemVerTokenFromVersionOutput(output.replace(/\bopencode\s+v(?=\d)/giu, 'opencode '));
|
|
347
|
+
}
|
|
348
|
+
if (!version) {
|
|
349
|
+
product.availability = 'unknown';
|
|
350
|
+
product.reasonCodes = ['clientRuntimeVersionUnknown'];
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
product.version = version;
|
|
354
|
+
product.availability = compareStrictSemVer(version, '2.0.0') >= 0 ? 'available' : 'unsupported';
|
|
355
|
+
product.reasonCodes = product.availability === 'available' ? [] : ['clientRuntimeVersionUnsupported'];
|
|
356
|
+
const remote = readEnvironmentValue(ctx.env ?? process.env, 'OPENCODE_SERVER_URL', ctx.platform);
|
|
357
|
+
if (remote) {
|
|
358
|
+
let local = false;
|
|
359
|
+
try {
|
|
360
|
+
local = ['127.0.0.1', 'localhost', '[::1]'].includes(new URL(remote).hostname);
|
|
361
|
+
}
|
|
362
|
+
catch { /* Unknown endpoint is not a local runtime. */ }
|
|
363
|
+
if (!local) {
|
|
364
|
+
product.availability = 'unknown';
|
|
365
|
+
product.reasonCodes = ['clientLocalRuntimeUnconfirmed'];
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function appProduct(platform, root, ctx) {
|
|
370
|
+
const entry = { kind: 'directory', configRoot: resolvePlatformConfigRoot(platform, ctx) };
|
|
371
|
+
const product = installation(platform, 'app', entry, 'unknown', null, ['clientVersionUnknown']);
|
|
372
|
+
product.id = JSON.stringify([platform, 'app', root, entry.configRoot]);
|
|
373
|
+
return product;
|
|
374
|
+
}
|
|
375
|
+
function cursorVersion(product, version) {
|
|
376
|
+
const match = version.match(/^(\d+)\.(\d+)(?:\.\d+)?$/u);
|
|
377
|
+
if (!match)
|
|
378
|
+
return;
|
|
379
|
+
product.version = version;
|
|
380
|
+
product.availability = Number(match[1]) > 3 || Number(match[1]) === 3 && Number(match[2]) >= 29 ? 'available' : 'unsupported';
|
|
381
|
+
product.reasonCodes = product.availability === 'available' ? [] : ['clientVersionUnsupported'];
|
|
382
|
+
}
|
|
383
|
+
async function discoverApps(platform, ctx) {
|
|
384
|
+
const installations = [];
|
|
385
|
+
const diagnostics = [];
|
|
386
|
+
const os = ctx.platform ?? process.platform;
|
|
387
|
+
const recordFailure = (error) => {
|
|
388
|
+
rethrowFatalError(error);
|
|
389
|
+
ctx.signal?.throwIfAborted();
|
|
390
|
+
diagnostics.push(diagnostic(platform, 'appDiscoveryIncomplete', 'The App identity or local runtime could not be inspected safely. Repair the App and check again.'));
|
|
391
|
+
};
|
|
392
|
+
if (os === 'darwin') {
|
|
393
|
+
const directories = ctx.macApplicationsDirectories ?? [path.join(resolveUserHome(ctx.env ?? process.env, os), 'Applications'), '/Applications'];
|
|
394
|
+
for (const directory of directories) {
|
|
395
|
+
const bundle = path.join(directory, `${APP_NAMES[platform]}.app`);
|
|
396
|
+
let product;
|
|
397
|
+
try {
|
|
398
|
+
assertTestReadablePath(bundle, 'App discovery', 'Use isolated macApplicationsDirectories for App discovery.');
|
|
399
|
+
const plist = await containedFile(bundle, path.join(bundle, 'Contents', 'Info.plist'));
|
|
400
|
+
if (!plist)
|
|
401
|
+
continue;
|
|
402
|
+
const canonicalBundle = await fs.realpath(bundle);
|
|
403
|
+
product = appProduct(platform, canonicalBundle, ctx);
|
|
404
|
+
installations.push(product);
|
|
405
|
+
const read = async (key) => (await probe(ctx, '/usr/bin/plutil', ['-extract', key, 'raw', '-o', '-', plist])).trim();
|
|
406
|
+
const identity = await read('CFBundleIdentifier');
|
|
407
|
+
if (platform === 'cursor' && identity !== 'com.todesktop.230313mzl4w4u92'
|
|
408
|
+
|| platform === 'opencode' && identity !== 'ai.opencode.desktop') {
|
|
409
|
+
installations.pop();
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if (platform === 'antigravity' && (!identity.startsWith('com.google.') || await read('CFBundleName') !== 'Antigravity')) {
|
|
413
|
+
installations.pop();
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (platform === 'antigravity') {
|
|
417
|
+
// The official App is distributed into Applications. Validate the
|
|
418
|
+
// sealed Google application, rather than treating a display name as identity.
|
|
419
|
+
product.reasonCodes = ['appIdentityUnconfirmed'];
|
|
420
|
+
await probe(ctx, '/usr/bin/codesign', ['--verify', '--strict', '-R=anchor apple generic and certificate leaf[subject.O] = "Google LLC"', canonicalBundle]);
|
|
421
|
+
const signature = await probe(ctx, '/usr/bin/codesign', ['--display', '--verbose=2', canonicalBundle]);
|
|
422
|
+
if (!/Authority=Developer ID Application: Google LLC \(/u.test(signature)
|
|
423
|
+
|| !signature.split(/\r?\n/u).includes(`Identifier=${identity}`))
|
|
424
|
+
continue;
|
|
425
|
+
product.availability = 'available';
|
|
426
|
+
product.reasonCodes = [];
|
|
427
|
+
try {
|
|
428
|
+
product.version = extractStrictSemVerTokenFromVersionOutput(await read('CFBundleShortVersionString'));
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
rethrowFatalError(error);
|
|
432
|
+
ctx.signal?.throwIfAborted();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
else if (platform === 'cursor')
|
|
436
|
+
cursorVersion(product, await read('CFBundleShortVersionString'));
|
|
437
|
+
else
|
|
438
|
+
await appRuntime(platform, path.join(canonicalBundle, 'Contents', 'Resources'), product, ctx);
|
|
439
|
+
}
|
|
440
|
+
catch (error) {
|
|
441
|
+
if (product) {
|
|
442
|
+
product.availability = 'unknown';
|
|
443
|
+
product.reasonCodes = ['appIdentityOrRuntimeUnconfirmed'];
|
|
444
|
+
}
|
|
445
|
+
recordFailure(error);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
else if (os === 'win32' && platform !== 'antigravity') {
|
|
450
|
+
const env = ctx.env ?? process.env;
|
|
451
|
+
const directories = ctx.windowsApplicationsDirectories ?? [
|
|
452
|
+
readEnvironmentValue(env, 'LOCALAPPDATA', os) ? path.join(readEnvironmentValue(env, 'LOCALAPPDATA', os), 'Programs') : undefined,
|
|
453
|
+
readEnvironmentValue(env, 'ProgramFiles', os),
|
|
454
|
+
].filter((entry) => Boolean(entry));
|
|
455
|
+
for (const directory of directories) {
|
|
456
|
+
const root = path.join(directory, platform === 'cursor' ? 'cursor' : 'OpenCode');
|
|
457
|
+
let product;
|
|
458
|
+
try {
|
|
459
|
+
const executable = await containedFile(root, path.join(root, `${APP_NAMES[platform]}.exe`));
|
|
460
|
+
if (!executable)
|
|
461
|
+
continue;
|
|
462
|
+
product = appProduct(platform, await fs.realpath(root), ctx);
|
|
463
|
+
installations.push(product);
|
|
464
|
+
const metadata = JSON.parse(await probe({ ...ctx, env: { ...env, AW_DISCOVERY_EXECUTABLE: executable } }, 'powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', '(Get-Item -LiteralPath $env:AW_DISCOVERY_EXECUTABLE).VersionInfo | Select-Object ProductName,ProductVersion,OriginalFilename | ConvertTo-Json -Compress']));
|
|
465
|
+
if (metadata.ProductName !== APP_NAMES[platform] || typeof metadata.OriginalFilename !== 'string'
|
|
466
|
+
|| metadata.OriginalFilename.toLowerCase() !== `${APP_NAMES[platform]}.exe`.toLowerCase()) {
|
|
467
|
+
product.reasonCodes = ['appIdentityUnconfirmed'];
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (platform === 'cursor' && typeof metadata.ProductVersion === 'string')
|
|
471
|
+
cursorVersion(product, metadata.ProductVersion);
|
|
472
|
+
else if (platform === 'opencode')
|
|
473
|
+
await appRuntime(platform, path.join(root, 'resources'), product, ctx);
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
if (product) {
|
|
477
|
+
product.availability = 'unknown';
|
|
478
|
+
product.reasonCodes = ['appIdentityOrRuntimeUnconfirmed'];
|
|
479
|
+
}
|
|
480
|
+
recordFailure(error);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (!directories.length)
|
|
484
|
+
diagnostics.push(diagnostic(platform, 'appDiscoveryUnverified', 'The official Windows installation roots could not be resolved.'));
|
|
485
|
+
}
|
|
486
|
+
else if (os === 'linux' && platform !== 'antigravity') {
|
|
487
|
+
const env = ctx.env ?? process.env;
|
|
488
|
+
const dataHome = readEnvironmentValue(env, 'XDG_DATA_HOME', os) ?? path.join(resolveUserHome(env, os), '.local', 'share');
|
|
489
|
+
const directories = ctx.linuxDesktopDirectories ?? [path.join(dataHome, 'applications'), '/usr/local/share/applications', '/usr/share/applications'];
|
|
490
|
+
for (const directory of directories) {
|
|
491
|
+
const desktop = path.join(directory, platform === 'opencode' ? 'ai.opencode.desktop.desktop' : 'cursor.desktop');
|
|
492
|
+
let product;
|
|
493
|
+
try {
|
|
494
|
+
if (!await present(desktop))
|
|
495
|
+
continue;
|
|
496
|
+
const metadata = await smallText(desktop);
|
|
497
|
+
if (platform === 'opencode' ? !/^StartupWMClass=ai\.opencode\.desktop$/mu.test(metadata) || !/^Name=OpenCode$/mu.test(metadata)
|
|
498
|
+
: !/^StartupWMClass=Cursor$/mu.test(metadata) || !/^Name=Cursor$/mu.test(metadata))
|
|
499
|
+
continue;
|
|
500
|
+
const command = metadata.match(/^Exec=(?:"([^"\n]+)"|([^\s]+))/mu);
|
|
501
|
+
const executable = command?.[1] ?? command?.[2];
|
|
502
|
+
product = appProduct(platform, await fs.realpath(desktop), ctx);
|
|
503
|
+
installations.push(product);
|
|
504
|
+
if (!executable || !path.isAbsolute(executable) || !await present(executable)) {
|
|
505
|
+
product.reasonCodes = ['clientLocalRuntimeUnconfirmed'];
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
const root = path.dirname(await fs.realpath(executable));
|
|
509
|
+
if (platform === 'opencode')
|
|
510
|
+
await appRuntime(platform, path.join(root, 'resources'), product, ctx);
|
|
511
|
+
else {
|
|
512
|
+
const manifest = await containedFile(root, path.join(root, 'resources', 'app', 'product.json'));
|
|
513
|
+
const packageFile = await containedFile(root, path.join(root, 'resources', 'app', 'package.json'));
|
|
514
|
+
if (!manifest || !packageFile) {
|
|
515
|
+
product.reasonCodes = ['appIdentityUnconfirmed'];
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
const identity = JSON.parse(await smallText(manifest));
|
|
519
|
+
if (identity.applicationName !== 'cursor' || identity.nameShort !== 'Cursor') {
|
|
520
|
+
product.reasonCodes = ['appIdentityUnconfirmed'];
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
const pkg = JSON.parse(await smallText(packageFile));
|
|
524
|
+
if (typeof pkg.version === 'string')
|
|
525
|
+
cursorVersion(product, pkg.version);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
if (product) {
|
|
530
|
+
product.availability = 'unknown';
|
|
531
|
+
product.reasonCodes = ['appIdentityOrRuntimeUnconfirmed'];
|
|
532
|
+
}
|
|
533
|
+
recordFailure(error);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
else
|
|
538
|
+
diagnostics.push(diagnostic(platform, 'appDiscoveryUnverified', 'This OS has no verified bounded discovery entry for the official App. Check the App settings or use a supported CLI.'));
|
|
539
|
+
return { installations, diagnostics };
|
|
540
|
+
}
|
|
541
|
+
export async function discoverPlatform(platform, ctx) {
|
|
542
|
+
try {
|
|
543
|
+
ctx.signal?.throwIfAborted();
|
|
544
|
+
if (platform === 'generic') {
|
|
545
|
+
const entry = { kind: 'generic', root: resolvePlatformConfigRoot(platform, ctx) };
|
|
546
|
+
return result(platform, [installation(platform, 'generic', entry, 'notApplicable', null, ['clientNotApplicable'])], []);
|
|
547
|
+
}
|
|
548
|
+
if (platform === 'codex')
|
|
549
|
+
return await discoverCodex(ctx);
|
|
550
|
+
const cli = await discoverCli(platform, ctx);
|
|
551
|
+
if (platform === 'cursor' || platform === 'antigravity' || platform === 'opencode') {
|
|
552
|
+
const app = await discoverApps(platform, ctx);
|
|
553
|
+
return result(platform, [...cli.installations, ...app.installations], [...cli.diagnostics, ...app.diagnostics]);
|
|
554
|
+
}
|
|
555
|
+
return cli;
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
rethrowFatalError(error);
|
|
559
|
+
ctx.signal?.throwIfAborted();
|
|
560
|
+
return result(platform, [], [diagnostic(platform, 'clientDiscoveryIncomplete', 'The client discovery could not complete. Check permissions and retry.')]);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
export async function discoverPlatforms(ctx) {
|
|
564
|
+
return Promise.all(PLATFORM_TARGETS.map((platform) => discoverPlatform(platform, ctx)));
|
|
565
|
+
}
|
|
566
|
+
export function targetAvailabilityViews(discovery, selected) {
|
|
567
|
+
return discovery.map((item) => ({ ...item, id: item.platform, displayName: TARGET_DISPLAY_NAMES[item.platform], selected: selected.includes(item.platform),
|
|
568
|
+
recovery: item.availability === 'available' ? [] : item.availability === 'notApplicable' ? ['General output. No client is required.']
|
|
569
|
+
: [`Install or repair ${TARGET_DISPLAY_NAMES[item.platform]}, then check again.`, 'Forced selection saves the preference. It does not bypass installation requirements.'] }));
|
|
570
|
+
}
|
|
571
|
+
export function requiresTargetConfirmation(availability) {
|
|
572
|
+
return availability !== 'available' && availability !== 'notApplicable';
|
|
573
|
+
}
|
|
574
|
+
export class TargetSelectionConfirmationRequiredError extends Error {
|
|
575
|
+
availability;
|
|
576
|
+
constructor(availability) {
|
|
577
|
+
super('targetSelectionConfirmationRequired');
|
|
578
|
+
this.availability = availability;
|
|
579
|
+
this.name = 'TargetSelectionConfirmationRequiredError';
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
//# sourceMappingURL=discovery.js.map
|