@lesliechan721/aw 0.1.0-beta.8 → 0.1.0-beta.81
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-config.mjs +100 -501
- package/dist/authoring/assets/aw-config.mjs.map +1 -1
- package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
- package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.mjs +17 -40
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +74 -98
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +79 -92
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +103 -127
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs +2 -2
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +490 -2841
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-skill.mjs +1 -1
- package/dist/native-runtime/reader-runtime.mjs +34 -0
- package/dist/native-runtime/reader.d.mts +6 -0
- package/dist/native-runtime/reader.mjs +11 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +30 -0
- package/dist/scripts/aw-skill-eval-materializer.js +278 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +1 -0
- package/dist/scripts/bundle-plugins.js +27 -8
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +7 -8
- package/dist/scripts/plugin-staging.js +16 -15
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/plugin-test-reporter.d.mts +2 -0
- package/dist/scripts/plugin-test-reporter.mjs +21 -0
- package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +5 -0
- package/dist/scripts/test-plugin-scripts.js +273 -78
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/scripts/test-workers.d.mts +24 -0
- package/dist/scripts/test-workers.mjs +59 -0
- package/dist/scripts/test-workers.mjs.map +1 -0
- package/dist/src/adapters/helpers.d.ts +7 -0
- package/dist/src/adapters/helpers.js.map +1 -1
- package/dist/src/authoring/workspace-commands.d.ts +5 -1
- package/dist/src/authoring/workspace-commands.js +7 -2
- package/dist/src/authoring/workspace-commands.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +2 -2
- package/dist/src/commands/aw-capabilities.js +41 -29
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/catalog-dev-source.d.ts +58 -13
- package/dist/src/commands/catalog-dev-source.js +549 -305
- package/dist/src/commands/catalog-dev-source.js.map +1 -1
- package/dist/src/commands/catalog-generation.d.ts +14 -19
- package/dist/src/commands/catalog-generation.js +5 -10
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/catalog-publication-inspection.d.ts +70 -30
- package/dist/src/commands/catalog-publication-inspection.js +511 -91
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
- package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
- package/dist/src/commands/catalog-publication-journal.js +292 -0
- package/dist/src/commands/catalog-publication-journal.js.map +1 -0
- package/dist/src/commands/catalog-publication-target.d.ts +2 -1
- package/dist/src/commands/catalog-publication-target.js +37 -2
- package/dist/src/commands/catalog-publication-target.js.map +1 -1
- package/dist/src/commands/catalog-publish.d.ts +82 -15
- package/dist/src/commands/catalog-publish.js +722 -219
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +55 -35
- package/dist/src/commands/catalog-source.js +298 -148
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-status.d.ts +6 -26
- package/dist/src/commands/catalog-status.js +9 -147
- package/dist/src/commands/catalog-status.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +104 -0
- package/dist/src/commands/catalog-store.js +685 -0
- package/dist/src/commands/catalog-store.js.map +1 -0
- package/dist/src/commands/catalog-workspace-resolution.d.ts +17 -0
- package/dist/src/commands/catalog-workspace-resolution.js +57 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.js +32 -20
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
- package/dist/src/commands/dependency-operation-plan.js +289 -7
- 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/init.d.ts +5 -11
- package/dist/src/commands/init.js +30 -51
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +32 -0
- package/dist/src/commands/intent-command.js +171 -0
- package/dist/src/commands/intent-command.js.map +1 -0
- package/dist/src/commands/managed-commands.d.ts +35 -0
- package/dist/src/commands/managed-commands.js +361 -0
- package/dist/src/commands/managed-commands.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +46 -0
- package/dist/src/commands/offline-cleanup-evidence.js +158 -10
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +190 -0
- package/dist/src/commands/operation-plan.js +99 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +47 -0
- package/dist/src/commands/operation-planner.js +142 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +16 -20
- package/dist/src/commands/options.js +94 -41
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +88 -45
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +8 -0
- package/dist/src/commands/public-config-confirmation.js +56 -0
- package/dist/src/commands/public-config-confirmation.js.map +1 -0
- package/dist/src/commands/public-interruption.d.ts +9 -0
- package/dist/src/commands/public-interruption.js +23 -0
- package/dist/src/commands/public-interruption.js.map +1 -0
- package/dist/src/commands/public-lifecycle-result.d.ts +102 -0
- package/dist/src/commands/public-lifecycle-result.js +307 -0
- package/dist/src/commands/public-lifecycle-result.js.map +1 -0
- package/dist/src/commands/public-lifecycle.d.ts +28 -0
- package/dist/src/commands/public-lifecycle.js +492 -0
- package/dist/src/commands/public-lifecycle.js.map +1 -0
- package/dist/src/commands/public-plugin-query.d.ts +16 -0
- package/dist/src/commands/public-plugin-query.js +193 -0
- package/dist/src/commands/public-plugin-query.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +166 -28
- package/dist/src/commands/rebuild-command.js +3745 -813
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +137 -25
- package/dist/src/commands/rebuild-integration.js +1343 -2535
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +73 -22
- package/dist/src/commands/rebuild-operations.js +313 -216
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +62 -0
- package/dist/src/commands/rebuild-platform-integration.js +1317 -0
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
- package/dist/src/commands/reconcile-operation-plan.js +47 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-inspection.d.ts +60 -0
- package/dist/src/commands/review-inspection.js +436 -0
- package/dist/src/commands/review-inspection.js.map +1 -0
- package/dist/src/commands/review-preparation.d.ts +51 -0
- package/dist/src/commands/review-preparation.js +400 -0
- package/dist/src/commands/review-preparation.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +6 -6
- package/dist/src/commands/runtime.js +44 -24
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +41 -0
- package/dist/src/commands/skill-eval.js +407 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +319 -0
- package/dist/src/commands/status-v6.js +2979 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/targets-command.d.ts +38 -0
- package/dist/src/commands/targets-command.js +182 -0
- package/dist/src/commands/targets-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +8 -5
- package/dist/src/commands/wizard.js +7 -4
- package/dist/src/commands/wizard.js.map +1 -1
- package/dist/src/commands/write-commands.d.ts +9 -3
- package/dist/src/commands/write-commands.js +143 -85
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +6 -6
- package/dist/src/constants.js +6 -6
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +70 -0
- package/dist/src/eval/manifest-v1.js +358 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +7 -2
- package/dist/src/generators/local-plugin.js +313 -389
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +5 -2
- package/dist/src/generators/permissions.js +28 -15
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +2 -31
- package/dist/src/index.js +1666 -1827
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.d.ts +63 -0
- package/dist/src/intent/deployment-preferences.js +170 -0
- package/dist/src/intent/deployment-preferences.js.map +1 -0
- package/dist/src/intent/diagnostics.d.ts +11 -0
- package/dist/src/intent/diagnostics.js +14 -0
- package/dist/src/intent/diagnostics.js.map +1 -0
- package/dist/src/intent/intent-codec.d.ts +19 -0
- package/dist/src/intent/intent-codec.js +117 -0
- package/dist/src/intent/intent-codec.js.map +1 -0
- package/dist/src/intent/intent-store.d.ts +43 -0
- package/dist/src/intent/intent-store.js +118 -0
- package/dist/src/intent/intent-store.js.map +1 -0
- package/dist/src/intent/scope-context.d.ts +33 -0
- package/dist/src/intent/scope-context.js +149 -0
- package/dist/src/intent/scope-context.js.map +1 -0
- package/dist/src/intent/work-context.d.ts +13 -0
- package/dist/src/intent/work-context.js +22 -0
- package/dist/src/intent/work-context.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +47 -46
- package/dist/src/output/command-receipt.js +286 -79
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/model.d.ts +3 -11
- 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.d.ts +49 -0
- package/dist/src/output/public-result.js +240 -0
- package/dist/src/output/public-result.js.map +1 -0
- package/dist/src/output/rebuild-progress.js +20 -15
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.d.ts +7 -0
- package/dist/src/output/receipt-projection.js +592 -0
- package/dist/src/output/receipt-projection.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +12 -0
- package/dist/src/platforms/capabilities.js +205 -0
- package/dist/src/platforms/capabilities.js.map +1 -0
- package/dist/src/platforms/contracts.d.ts +358 -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 +28 -0
- package/dist/src/platforms/cursor-workspace-hook.js +198 -0
- package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
- package/dist/src/platforms/discovery.d.ts +91 -0
- package/dist/src/platforms/discovery.js +653 -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 +81 -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 +212 -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 +406 -0
- package/dist/src/platforms/inspection-native.js.map +1 -0
- package/dist/src/platforms/inspection-opencode.d.ts +4 -0
- package/dist/src/platforms/inspection-opencode.js +98 -0
- package/dist/src/platforms/inspection-opencode.js.map +1 -0
- package/dist/src/platforms/inspection-pi.d.ts +3 -0
- package/dist/src/platforms/inspection-pi.js +282 -0
- package/dist/src/platforms/inspection-pi.js.map +1 -0
- package/dist/src/platforms/inspection-query.d.ts +12 -0
- package/dist/src/platforms/inspection-query.js +96 -0
- package/dist/src/platforms/inspection-query.js.map +1 -0
- package/dist/src/platforms/inspection.d.ts +17 -0
- package/dist/src/platforms/inspection.js +227 -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 +13 -0
- package/dist/src/platforms/lifecycle-native.js +283 -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 +494 -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/platforms/supplement-state.d.ts +13 -0
- package/dist/src/platforms/supplement-state.js +82 -0
- package/dist/src/platforms/supplement-state.js.map +1 -0
- package/dist/src/portable/commands.d.ts +58 -11
- package/dist/src/portable/commands.js +94 -350
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/historical-materialization.d.ts +22 -0
- package/dist/src/portable/historical-materialization.js +124 -0
- package/dist/src/portable/historical-materialization.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +24 -4
- package/dist/src/portable/materializer.js +189 -259
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery-layout.d.ts +17 -0
- package/dist/src/portable/recovery-layout.js +42 -0
- package/dist/src/portable/recovery-layout.js.map +1 -0
- package/dist/src/portable/recovery.d.ts +153 -0
- package/dist/src/portable/recovery.js +367 -0
- package/dist/src/portable/recovery.js.map +1 -0
- package/dist/src/portable/writer.d.ts +67 -0
- package/dist/src/portable/writer.js +321 -0
- package/dist/src/portable/writer.js.map +1 -0
- package/dist/src/recovery/coordinator.d.ts +141 -0
- package/dist/src/recovery/coordinator.js +1254 -0
- package/dist/src/recovery/coordinator.js.map +1 -0
- package/dist/src/recovery/demand.d.ts +51 -0
- package/dist/src/recovery/demand.js +159 -0
- package/dist/src/recovery/demand.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +25 -0
- package/dist/src/recovery/joint-coordinator.js +991 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -0
- package/dist/src/recovery/joint-demand.d.ts +50 -0
- package/dist/src/recovery/joint-demand.js +197 -0
- package/dist/src/recovery/joint-demand.js.map +1 -0
- package/dist/src/recovery/performance.d.ts +4 -0
- package/dist/src/recovery/performance.js +26 -0
- package/dist/src/recovery/performance.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +98 -0
- package/dist/src/recovery/receipt.js +2 -0
- package/dist/src/recovery/receipt.js.map +1 -0
- package/dist/src/recovery/retirement.d.ts +47 -0
- package/dist/src/recovery/retirement.js +469 -0
- package/dist/src/recovery/retirement.js.map +1 -0
- package/dist/src/recovery/status.d.ts +126 -0
- package/dist/src/recovery/status.js +1073 -0
- package/dist/src/recovery/status.js.map +1 -0
- package/dist/src/recovery/types.d.ts +85 -0
- package/dist/src/recovery/types.js +2 -0
- package/dist/src/recovery/types.js.map +1 -0
- package/dist/src/review/eval-source-input.d.ts +43 -0
- package/dist/src/review/eval-source-input.js +207 -0
- package/dist/src/review/eval-source-input.js.map +1 -0
- package/dist/src/review/platform-profile.d.ts +3 -0
- package/dist/src/review/platform-profile.js +14 -0
- package/dist/src/review/platform-profile.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +20 -0
- package/dist/src/review/review-profile.js +276 -0
- package/dist/src/review/review-profile.js.map +1 -0
- package/dist/src/review/review-selection.d.ts +20 -0
- package/dist/src/review/review-selection.js +495 -0
- package/dist/src/review/review-selection.js.map +1 -0
- package/dist/src/review/review-types.d.ts +71 -0
- package/dist/src/review/review-types.js +16 -0
- package/dist/src/review/review-types.js.map +1 -0
- package/dist/src/review/skill-materialization.d.ts +62 -0
- package/dist/src/review/skill-materialization.js +205 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +201 -0
- package/dist/src/review/source-binding.js +773 -0
- package/dist/src/review/source-binding.js.map +1 -0
- package/dist/src/tui/agent-management.d.ts +23 -0
- package/dist/src/tui/agent-management.js +319 -0
- package/dist/src/tui/agent-management.js.map +1 -0
- package/dist/src/tui/agent-settings.d.ts +47 -0
- package/dist/src/tui/agent-settings.js +97 -0
- package/dist/src/tui/agent-settings.js.map +1 -0
- package/dist/src/tui/catalog-freshness.d.ts +1 -0
- package/dist/src/tui/catalog-freshness.js +2 -0
- package/dist/src/tui/catalog-freshness.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +18 -53
- package/dist/src/tui/catalog-generation.js +136 -224
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
- package/dist/src/tui/catalog-sources/projection.js +17 -0
- package/dist/src/tui/catalog-sources/projection.js.map +1 -0
- package/dist/src/tui/catalog-sources/review.d.ts +3 -0
- package/dist/src/tui/catalog-sources/review.js +13 -0
- package/dist/src/tui/catalog-sources/review.js.map +1 -0
- package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
- package/dist/src/tui/catalog-sources/screens.js +40 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +32 -0
- package/dist/src/tui/catalog-sources/session.js +300 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +54 -0
- package/dist/src/tui/catalog-sources/types.js +2 -0
- package/dist/src/tui/catalog-sources/types.js.map +1 -0
- package/dist/src/tui/catalog-store-task.d.ts +16 -0
- package/dist/src/tui/catalog-store-task.js +19 -0
- package/dist/src/tui/catalog-store-task.js.map +1 -0
- package/dist/src/tui/clipboard.d.ts +13 -0
- package/dist/src/tui/clipboard.js +95 -0
- package/dist/src/tui/clipboard.js.map +1 -0
- package/dist/src/tui/components.d.ts +113 -3
- package/dist/src/tui/components.js +201 -36
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +29 -0
- package/dist/src/tui/config-array-draft.js +48 -0
- package/dist/src/tui/config-array-draft.js.map +1 -0
- package/dist/src/tui/config-leaf-editor.d.ts +43 -0
- package/dist/src/tui/config-leaf-editor.js +224 -0
- package/dist/src/tui/config-leaf-editor.js.map +1 -0
- package/dist/src/tui/config-references.d.ts +38 -0
- package/dist/src/tui/config-references.js +82 -0
- package/dist/src/tui/config-references.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +20 -0
- package/dist/src/tui/config-value-presentation.js +104 -0
- package/dist/src/tui/config-value-presentation.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +13 -4
- package/dist/src/tui/console-app-v4.js +9764 -2210
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.d.ts +13 -0
- package/dist/src/tui/content-item-card.js +51 -0
- package/dist/src/tui/content-item-card.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +7 -4
- package/dist/src/tui/controller-runtime.js +2064 -779
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +669 -106
- package/dist/src/tui/controller.js +3617 -971
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/dependency-graph-view.d.ts +39 -0
- package/dist/src/tui/dependency-graph-view.js +121 -0
- package/dist/src/tui/dependency-graph-view.js.map +1 -0
- package/dist/src/tui/dependency-graph.d.ts +81 -0
- package/dist/src/tui/dependency-graph.js +452 -0
- package/dist/src/tui/dependency-graph.js.map +1 -0
- package/dist/src/tui/deployment-view.d.ts +10 -0
- package/dist/src/tui/deployment-view.js +108 -0
- package/dist/src/tui/deployment-view.js.map +1 -0
- package/dist/src/tui/diagnostic-projection.d.ts +23 -0
- package/dist/src/tui/diagnostic-projection.js +595 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +6 -3
- package/dist/src/tui/diagnostics.js +14 -2
- package/dist/src/tui/diagnostics.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +55 -0
- package/dist/src/tui/entity-cards.js +298 -0
- package/dist/src/tui/entity-cards.js.map +1 -0
- package/dist/src/tui/glossary.d.ts +25 -0
- package/dist/src/tui/glossary.js +72 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/index.d.ts +6 -2
- package/dist/src/tui/index.js +5 -2
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/input-display.d.ts +1 -0
- package/dist/src/tui/input-display.js +23 -1
- package/dist/src/tui/input-display.js.map +1 -1
- package/dist/src/tui/keys.d.ts +44 -0
- package/dist/src/tui/keys.js +43 -15
- package/dist/src/tui/keys.js.map +1 -1
- package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
- package/dist/src/tui/lifecycle-action-view.js +36 -0
- package/dist/src/tui/lifecycle-action-view.js.map +1 -0
- package/dist/src/tui/model.d.ts +243 -45
- package/dist/src/tui/model.js +1402 -415
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
- package/dist/src/tui/operation-diagnostic-screens.js +72 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +82 -0
- package/dist/src/tui/operation-history.js +136 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +28 -0
- package/dist/src/tui/operation-review-planner.js +1396 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/plugin-content.d.ts +33 -0
- package/dist/src/tui/plugin-content.js +245 -0
- package/dist/src/tui/plugin-content.js.map +1 -0
- package/dist/src/tui/plugin-detail.d.ts +72 -0
- package/dist/src/tui/plugin-detail.js +260 -0
- package/dist/src/tui/plugin-detail.js.map +1 -0
- package/dist/src/tui/plugin-write-task.d.ts +69 -0
- package/dist/src/tui/plugin-write-task.js +286 -0
- package/dist/src/tui/plugin-write-task.js.map +1 -0
- package/dist/src/tui/prompt.js +4 -15
- package/dist/src/tui/prompt.js.map +1 -1
- package/dist/src/tui/query-header.d.ts +30 -0
- package/dist/src/tui/query-header.js +40 -0
- package/dist/src/tui/query-header.js.map +1 -0
- package/dist/src/tui/reader.d.ts +38 -0
- package/dist/src/tui/reader.js +49 -0
- package/dist/src/tui/reader.js.map +1 -0
- package/dist/src/tui/router.d.ts +186 -35
- package/dist/src/tui/router.js +338 -50
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +45 -0
- package/dist/src/tui/scoped-flow.js +96 -0
- package/dist/src/tui/scoped-flow.js.map +1 -0
- package/dist/src/tui/scoped-inventory.d.ts +126 -0
- package/dist/src/tui/scoped-inventory.js +258 -0
- package/dist/src/tui/scoped-inventory.js.map +1 -0
- package/dist/src/tui/screen-registry.d.ts +701 -0
- package/dist/src/tui/screen-registry.js +226 -0
- package/dist/src/tui/screen-registry.js.map +1 -0
- package/dist/src/tui/session-console-app.d.ts +6 -0
- package/dist/src/tui/session-console-app.js +13 -0
- package/dist/src/tui/session-console-app.js.map +1 -0
- package/dist/src/tui/session-host.d.ts +45 -0
- package/dist/src/tui/session-host.js +219 -0
- package/dist/src/tui/session-host.js.map +1 -0
- package/dist/src/tui/source-detail-card.d.ts +29 -0
- package/dist/src/tui/source-detail-card.js +45 -0
- package/dist/src/tui/source-detail-card.js.map +1 -0
- package/dist/src/tui/theme.d.ts +12 -0
- package/dist/src/tui/theme.js +12 -0
- package/dist/src/tui/theme.js.map +1 -1
- package/dist/src/tui/viewport.d.ts +1 -0
- package/dist/src/tui/viewport.js +23 -0
- package/dist/src/tui/viewport.js.map +1 -1
- package/dist/src/tui/wizard.js +37 -13
- package/dist/src/tui/wizard.js.map +1 -1
- package/dist/src/types.d.ts +220 -118
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +13 -4
- package/dist/src/utils/agent-version.js +27 -4
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +33 -7
- package/dist/src/utils/artifact-plan.js +115 -430
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +114 -83
- package/dist/src/utils/artifact-renderer.js +213 -364
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +44 -0
- package/dist/src/utils/artifact-request.js +80 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +6 -2
- package/dist/src/utils/artifact-sources.js +17 -0
- package/dist/src/utils/artifact-sources.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +57 -173
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
- package/dist/src/utils/catalog-capability-projection.js +14 -0
- package/dist/src/utils/catalog-capability-projection.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +2 -2
- package/dist/src/utils/catalog-digests.js +7 -18
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-generation-error.d.ts +5 -1
- package/dist/src/utils/catalog-generation-error.js +14 -0
- package/dist/src/utils/catalog-generation-error.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +36 -5
- package/dist/src/utils/catalog-generation-resolver.js +221 -77
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +159 -28
- package/dist/src/utils/catalog-generation-service.js +1186 -525
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.d.ts +9 -0
- package/dist/src/utils/catalog-generation-state.js +97 -106
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +38 -24
- package/dist/src/utils/catalog-generation-store.js +337 -272
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
- package/dist/src/utils/{catalog-manifest-v5.js → catalog-manifest-v7.js} +23 -35
- package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
- package/dist/src/utils/catalog-operation-context.d.ts +6 -14
- package/dist/src/utils/catalog-operation-context.js +69 -169
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-public-error.js +8 -4
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +7 -3
- package/dist/src/utils/catalog-runtime-projection.js +5 -40
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +2 -2
- package/dist/src/utils/catalog-source-impact.d.ts +21 -0
- package/dist/src/utils/catalog-source-impact.js +344 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +23 -2
- package/dist/src/utils/catalog-source-references.js +456 -382
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +14 -1
- package/dist/src/utils/catalog-sources.js +178 -18
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/codex-config.d.ts +2 -0
- package/dist/src/utils/codex-config.js +22 -1
- package/dist/src/utils/codex-config.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
- package/dist/src/utils/codex-executable-discovery.js +431 -0
- package/dist/src/utils/codex-executable-discovery.js.map +1 -0
- package/dist/src/utils/codex-manager.d.ts +47 -18
- package/dist/src/utils/codex-manager.js +88 -622
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
- package/dist/src/utils/codex-marketplace-path.js +45 -0
- package/dist/src/utils/codex-marketplace-path.js.map +1 -0
- package/dist/src/utils/codex-native-observation.d.ts +49 -0
- package/dist/src/utils/codex-native-observation.js +169 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -0
- package/dist/src/utils/codex-reconciler.d.ts +123 -0
- package/dist/src/utils/codex-reconciler.js +322 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +45 -0
- package/dist/src/utils/codex-shared-native.js +122 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- 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-skills-root.d.ts +4 -0
- package/dist/src/utils/codex-skills-root.js +25 -0
- package/dist/src/utils/codex-skills-root.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +49 -0
- package/dist/src/utils/codex-surface-analysis.js +220 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- 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 +51 -0
- package/dist/src/utils/component-resources.js +322 -0
- package/dist/src/utils/component-resources.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
- package/dist/src/utils/dynamic-skill-tree.js +32 -9
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +16 -0
- package/dist/src/utils/git-catalog-provider.js +167 -120
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +17 -12
- package/dist/src/utils/local-marketplace.js +85 -195
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-closure.d.ts +3 -0
- package/dist/src/utils/managed-command-closure.js +35 -0
- package/dist/src/utils/managed-command-closure.js.map +1 -0
- package/dist/src/utils/managed-command-evidence.d.ts +7 -0
- package/dist/src/utils/managed-command-evidence.js +10 -0
- package/dist/src/utils/managed-command-evidence.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +124 -0
- package/dist/src/utils/managed-command-materialization.js +369 -0
- package/dist/src/utils/managed-command-materialization.js.map +1 -0
- 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-runtime.d.ts +33 -0
- package/dist/src/utils/managed-command-runtime.js +121 -0
- package/dist/src/utils/managed-command-runtime.js.map +1 -0
- package/dist/src/utils/managed-command-store.d.ts +143 -0
- package/dist/src/utils/managed-command-store.js +665 -0
- package/dist/src/utils/managed-command-store.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +1 -3
- package/dist/src/utils/manifest.js +1 -3
- package/dist/src/utils/manifest.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +1 -10
- package/dist/src/utils/multi-source-catalog.js +9 -175
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +74 -5
- package/dist/src/utils/native-cli.js +479 -31
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-demand.d.ts +29 -0
- package/dist/src/utils/native-demand.js +4 -0
- package/dist/src/utils/native-demand.js.map +1 -0
- package/dist/src/utils/native-tool-context.d.ts +14 -0
- package/dist/src/utils/native-tool-context.js +38 -0
- package/dist/src/utils/native-tool-context.js.map +1 -0
- package/dist/src/utils/native-tool-review.d.ts +18 -0
- package/dist/src/utils/native-tool-review.js +116 -0
- package/dist/src/utils/native-tool-review.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +0 -1
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +103 -21
- package/dist/src/utils/ownership.js +232 -210
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/path-catalog-provider.d.ts +1 -1
- package/dist/src/utils/path-catalog-provider.js +47 -62
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -2
- package/dist/src/utils/paths.js +5 -3
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +45 -0
- package/dist/src/utils/platform-empty-state.js +159 -0
- package/dist/src/utils/platform-empty-state.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -1
- package/dist/src/utils/platform-support.js +1 -1
- package/dist/src/utils/platform-support.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +64 -0
- package/dist/src/utils/plugin-config-impact.js +307 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-references.d.ts +89 -0
- package/dist/src/utils/plugin-config-references.js +335 -0
- package/dist/src/utils/plugin-config-references.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +109 -27
- package/dist/src/utils/plugin-config-write.js +1242 -348
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +187 -109
- package/dist/src/utils/plugin-config.js +916 -1147
- 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/plugin-scripts.d.ts +78 -127
- package/dist/src/utils/plugin-scripts.js +566 -524
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-lock.js +14 -5
- package/dist/src/utils/process-lock.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +2 -2
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/project-boundary.d.ts +11 -13
- package/dist/src/utils/project-boundary.js +28 -34
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/rendered-contract.js +18 -1
- package/dist/src/utils/rendered-contract.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +18 -0
- package/dist/src/utils/runtime-config.js +64 -0
- package/dist/src/utils/runtime-config.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
- package/dist/src/utils/runtime-skill-closure.js +47 -6
- package/dist/src/utils/runtime-skill-closure.js.map +1 -1
- package/dist/src/utils/safe-fs.d.ts +21 -0
- package/dist/src/utils/safe-fs.js +111 -0
- package/dist/src/utils/safe-fs.js.map +1 -0
- package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
- package/dist/src/utils/safe-operation-diagnostic.js +33 -0
- package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
- package/dist/src/utils/sensitive-content.d.ts +4 -0
- package/dist/src/utils/sensitive-content.js +36 -0
- package/dist/src/utils/sensitive-content.js.map +1 -0
- package/dist/src/utils/state-paths.d.ts +8 -3
- package/dist/src/utils/state-paths.js +53 -16
- package/dist/src/utils/state-paths.js.map +1 -1
- package/dist/src/utils/target-eligibility.d.ts +4 -3
- package/dist/src/utils/target-eligibility.js +12 -6
- package/dist/src/utils/target-eligibility.js.map +1 -1
- package/dist/src/utils/windows-claude-shim.d.ts +7 -0
- package/dist/src/utils/windows-claude-shim.js +10 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/src/utils/windows-npm-shim.d.ts +16 -0
- package/dist/src/utils/windows-npm-shim.js +155 -0
- package/dist/src/utils/windows-npm-shim.js.map +1 -0
- package/dist/vitest.config.js +105 -9
- package/dist/vitest.config.js.map +1 -1
- package/package.json +30 -21
- package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
- package/dist/scripts/aw-skill-eval-engine.js +0 -31
- package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
- package/dist/scripts/codex-eval-app-server.d.ts +0 -91
- package/dist/scripts/codex-eval-app-server.js +0 -1334
- package/dist/scripts/codex-eval-app-server.js.map +0 -1
- package/dist/scripts/codex-eval-isolation.d.ts +0 -61
- package/dist/scripts/codex-eval-isolation.js +0 -318
- package/dist/scripts/codex-eval-isolation.js.map +0 -1
- package/dist/scripts/codex-eval-process-management.d.ts +0 -8
- package/dist/scripts/codex-eval-process-management.js +0 -69
- package/dist/scripts/codex-eval-process-management.js.map +0 -1
- package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
- package/dist/scripts/codex-eval-process-tree.js +0 -803
- package/dist/scripts/codex-eval-process-tree.js.map +0 -1
- package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
- package/dist/scripts/codex-eval-runtime-config.js +0 -843
- package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
- package/dist/scripts/codex-trigger-eval.d.ts +0 -84
- package/dist/scripts/codex-trigger-eval.js +0 -968
- package/dist/scripts/codex-trigger-eval.js.map +0 -1
- package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
- package/dist/scripts/eval-plugin-skills-audited.js +0 -261
- package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
- package/dist/scripts/eval-plugin-skills.d.ts +0 -45
- package/dist/scripts/eval-plugin-skills.js +0 -1589
- package/dist/scripts/eval-plugin-skills.js.map +0 -1
- package/dist/scripts/eval-run-layout.d.ts +0 -17
- package/dist/scripts/eval-run-layout.js +0 -26
- package/dist/scripts/eval-run-layout.js.map +0 -1
- package/dist/scripts/plugin-eval-contract.d.ts +0 -189
- package/dist/scripts/plugin-eval-contract.js +0 -745
- package/dist/scripts/plugin-eval-contract.js.map +0 -1
- package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
- package/dist/scripts/plugin-eval-materializer.js +0 -421
- package/dist/scripts/plugin-eval-materializer.js.map +0 -1
- package/dist/scripts/skill-reporting.d.ts +0 -212
- package/dist/scripts/skill-reporting.js +0 -922
- package/dist/scripts/skill-reporting.js.map +0 -1
- package/dist/src/commands/catalog-context.d.ts +0 -52
- package/dist/src/commands/catalog-context.js +0 -156
- package/dist/src/commands/catalog-context.js.map +0 -1
- package/dist/src/commands/review-publication.d.ts +0 -99
- package/dist/src/commands/review-publication.js +0 -904
- package/dist/src/commands/review-publication.js.map +0 -1
- package/dist/src/commands/status-v5.d.ts +0 -169
- package/dist/src/commands/status-v5.js +0 -1135
- package/dist/src/commands/status-v5.js.map +0 -1
- package/dist/src/portable/skills-cli.d.ts +0 -43
- package/dist/src/portable/skills-cli.js +0 -148
- package/dist/src/portable/skills-cli.js.map +0 -1
- package/dist/src/utils/catalog-manifest-v5.d.ts +0 -5
- package/dist/src/utils/catalog-manifest-v5.js.map +0 -1
- package/dist/src/utils/catalog-source-cache.d.ts +0 -62
- package/dist/src/utils/catalog-source-cache.js +0 -321
- package/dist/src/utils/catalog-source-cache.js.map +0 -1
- package/dist/src/utils/codex-project-surface.d.ts +0 -3
- package/dist/src/utils/codex-project-surface.js +0 -49
- package/dist/src/utils/codex-project-surface.js.map +0 -1
- package/dist/src/utils/lifecycle-active-store.d.ts +0 -147
- package/dist/src/utils/lifecycle-active-store.js +0 -1064
- package/dist/src/utils/lifecycle-active-store.js.map +0 -1
- package/dist/src/utils/plugin-release.d.ts +0 -2
- package/dist/src/utils/plugin-release.js +0 -2
- package/dist/src/utils/plugin-release.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
|
@@ -1,16 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { assertSafePluginConfigSegment, coercePluginConfigUpdates,
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
import { resolveWorkContext } from '../intent/work-context.js';
|
|
2
|
+
import { readDemand, demandNativeProjection } from '../recovery/demand.js';
|
|
3
|
+
import { createScopeContext } from '../intent/scope-context.js';
|
|
4
|
+
import { selectPluginConfigProfile, NATIVE_PLATFORM_TARGETS, getCommandPackageId } from '@lesliechan721/aw-plugin-core/manifest';
|
|
5
|
+
import { readScopedRecoveryStatus } from '../recovery/status.js';
|
|
6
|
+
import { syncWriteCommand } from '../commands/write-commands.js';
|
|
7
|
+
import { CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION, } from '../types.js';
|
|
8
|
+
import { getDefaultNativeCliRunner, prepareNativeCliExecution } from './native-cli.js';
|
|
9
|
+
import { assertPluginConfigMutationCandidate, assertSafePluginConfigSegment, coercePluginConfigUpdates, patchPluginConfigStore, PluginConfigSchemaResolutionError, readPluginConfigStore, readNamespacedPluginConfigStoreIdentity, resetPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigStorePath, resolvePluginConfigSchemaAccess, summarizeEffectivePluginConfig, } from './plugin-config.js';
|
|
10
|
+
import { analyzePluginConfigMutationImpact, discoverPluginConfigManagedCommandPackages, pluginConfigTargetRenderScopes, pluginSharedNativeConfigRenderUnits } from './plugin-config-impact.js';
|
|
11
|
+
import { collectPluginConfigReferenceEvidence, resolvePluginConfigReferencePlugins, resolvePluginConfigReferenceConsumers } from './plugin-config-references.js';
|
|
12
|
+
import { orderPluginMetasByDependencies, resolvePluginMetaDependencyClosure } from './plugin-dependencies.js';
|
|
13
|
+
import { assertManagedCommandPackageNativeToolsUnchanged, discoverInstalledPluginManagedCommandPackages, syncPluginManagedCommandPackage, } from './managed-command-materialization.js';
|
|
14
|
+
import { listManagedCommandPackages, managedCommandDiagnostic, readInstalledCommandProducer } from './managed-command-store.js';
|
|
15
|
+
import { collectSensitivePluginConfigValues, redactPluginScriptOutput, } from './plugin-scripts.js';
|
|
16
|
+
import { resolveClaudeProjectKey, resolveCodexProjectKey, resolveCliPackageRoot } from './paths.js';
|
|
17
|
+
import { createProjectLocationKey, resolveRequiredCanonicalRepoRoot } from './state-paths.js';
|
|
18
|
+
import { readSafeOperationError } from './safe-operation-diagnostic.js';
|
|
13
19
|
import { withAwHomeMutationLock, } from './aw-home-mutation-lock.js';
|
|
20
|
+
import fs from 'fs-extra';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
import { parsePluginId } from './multi-source-catalog.js';
|
|
23
|
+
import crypto from 'node:crypto';
|
|
24
|
+
export function buildConfigMutationReceipt(command, receipt) {
|
|
25
|
+
return {
|
|
26
|
+
...receipt,
|
|
27
|
+
receiptSchemaVersion: CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION,
|
|
28
|
+
command,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function publicConfigApplyTargetResult(result) {
|
|
32
|
+
return {
|
|
33
|
+
target: {
|
|
34
|
+
pluginName: result.target.pluginName,
|
|
35
|
+
...(result.target.pluginId ? { pluginId: result.target.pluginId } : {}),
|
|
36
|
+
platform: result.target.platform,
|
|
37
|
+
scope: result.target.scope,
|
|
38
|
+
},
|
|
39
|
+
action: result.action,
|
|
40
|
+
state: result.state,
|
|
41
|
+
...(result.message ? { message: result.message } : {}),
|
|
42
|
+
...(result.errorCode ? { errorCode: result.errorCode } : {}),
|
|
43
|
+
...(result.relation ? { relation: result.relation } : {}),
|
|
44
|
+
...(result.requiredBy ? { requiredBy: result.requiredBy } : {}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function publicConfigApplyResult(apply) {
|
|
48
|
+
if (apply.state === 'skipped')
|
|
49
|
+
return apply;
|
|
50
|
+
return {
|
|
51
|
+
...apply,
|
|
52
|
+
targetResults: apply.targetResults.map(publicConfigApplyTargetResult),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function configWriteStateForError(error) {
|
|
56
|
+
return error?.configWrite === 'failed'
|
|
57
|
+
? 'failed'
|
|
58
|
+
: 'notStarted';
|
|
59
|
+
}
|
|
60
|
+
function markConfigWriteFailed(error) {
|
|
61
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
62
|
+
return Object.assign(failure, { configWrite: 'failed' });
|
|
63
|
+
}
|
|
64
|
+
function skippedApply(reason) {
|
|
65
|
+
return { state: 'skipped', reason, targetResults: [] };
|
|
66
|
+
}
|
|
67
|
+
function unavailableApply(reason, stage, targetResults = [], commandPackages = []) {
|
|
68
|
+
const messages = {
|
|
69
|
+
invalidConfig: 'The effective config is invalid for every visible target.',
|
|
70
|
+
schemaUnavailable: 'The config schema is unavailable after the config commit.',
|
|
71
|
+
sourceUnavailable: 'The plugin source is unavailable after the config commit.',
|
|
72
|
+
effectiveConfigUnavailable: 'The effective config cannot be read after the config commit.',
|
|
73
|
+
targetDiscoveryFailed: 'Visible config apply targets cannot be discovered after the config commit.',
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
state: 'unavailable',
|
|
77
|
+
reason,
|
|
78
|
+
targetResults,
|
|
79
|
+
...(commandPackages.length > 0 ? { commandResults: commandPackages.map((target) => ({
|
|
80
|
+
producer: target.producer, state: 'failed', commandIds: [], removedCommandIds: [],
|
|
81
|
+
errors: [{ code: reason, message: messages[reason] }],
|
|
82
|
+
recoveryActions: [`aw command package sync ${target.producer.sourceId}/${target.producer.pluginName} ${target.packageKey} --scope ${target.producer.scope} --yes`,
|
|
83
|
+
`aw command package remove ${target.packageId} --yes`],
|
|
84
|
+
})) } : {}),
|
|
85
|
+
error: { stage, code: reason, message: messages[reason] },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function overallStateForApply(apply) {
|
|
89
|
+
return apply.state === 'succeeded' || apply.state === 'skipped' ? 'succeeded' : 'partial';
|
|
90
|
+
}
|
|
14
91
|
function uniqueInOrder(values) {
|
|
15
92
|
return [...new Set(values)];
|
|
16
93
|
}
|
|
@@ -18,7 +95,7 @@ function collectRemovedConfigKeys(values) {
|
|
|
18
95
|
return uniqueInOrder(Object.keys(values));
|
|
19
96
|
}
|
|
20
97
|
function targetKey(target) {
|
|
21
|
-
return `${target.platform}:${target.scope}:${target.projectKey ?? '-'}`;
|
|
98
|
+
return `${target.pluginName}:${target.platform}:${target.scope}:${target.projectKey ?? '-'}`;
|
|
22
99
|
}
|
|
23
100
|
function dedupeTargets(targets) {
|
|
24
101
|
const deduped = new Map();
|
|
@@ -27,9 +104,9 @@ function dedupeTargets(targets) {
|
|
|
27
104
|
return [...deduped.values()];
|
|
28
105
|
}
|
|
29
106
|
async function resolveProjectKey(platform, cwd) {
|
|
30
|
-
return platform === 'codex'
|
|
31
|
-
?
|
|
32
|
-
|
|
107
|
+
return platform === 'codex' ? resolveCodexProjectKey(cwd)
|
|
108
|
+
: platform === 'claude' ? resolveClaudeProjectKey(cwd)
|
|
109
|
+
: createProjectLocationKey(await resolveRequiredCanonicalRepoRoot(cwd));
|
|
33
110
|
}
|
|
34
111
|
async function createCandidateTarget(options) {
|
|
35
112
|
return {
|
|
@@ -44,154 +121,601 @@ async function createCandidateTarget(options) {
|
|
|
44
121
|
async function discoverVisibleTargets(options) {
|
|
45
122
|
const targets = [];
|
|
46
123
|
const failures = [];
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
124
|
+
const selector = options.plugin.pluginId ?? options.pluginName;
|
|
125
|
+
const consumers = await resolvePluginConfigReferenceConsumers({ plugin: options.plugin, env: options.env,
|
|
126
|
+
plugins: options.rebuildRuntime?.referencePlugins });
|
|
127
|
+
const selectors = consumers.map((plugin) => plugin.pluginId ?? plugin.manifest.name);
|
|
128
|
+
const status = await readScopedRecoveryStatus({ scope: options.scope,
|
|
129
|
+
cwd: options.cwd, env: options.env,
|
|
130
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
131
|
+
catalogOperationContext: options.rebuildRuntime?.catalogOperationContext,
|
|
132
|
+
codexObservationSession: options.rebuildRuntime?.codexObservationSession,
|
|
133
|
+
});
|
|
134
|
+
for (const statusTarget of status.existingTargets ?? []) {
|
|
135
|
+
if (statusTarget.agent === 'generic' || statusTarget.scope !== options.scope)
|
|
136
|
+
continue;
|
|
137
|
+
const identity = parsePluginId(statusTarget.pluginId);
|
|
138
|
+
if (!selectors.includes(statusTarget.pluginId) && statusTarget.pluginId !== selector
|
|
139
|
+
&& !selectors.some((entry) => !entry.includes('/') && entry === identity.pluginName))
|
|
140
|
+
continue;
|
|
141
|
+
// Existing targets already require this scope's observed activation or owned directory.
|
|
142
|
+
const plugin = consumers.find((entry) => entry.pluginId === statusTarget.pluginId);
|
|
143
|
+
targets.push({ ...await createCandidateTarget({ pluginName: identity.pluginName,
|
|
144
|
+
platform: statusTarget.agent, scope: statusTarget.scope, cwd: options.cwd }),
|
|
145
|
+
pluginId: statusTarget.pluginId, sourceId: identity.sourceId,
|
|
146
|
+
...(plugin?.sourceIdentity ? { sourceIdentity: plugin.sourceIdentity } : {}),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return { targets: dedupeTargets(targets), failures };
|
|
150
|
+
}
|
|
151
|
+
async function reinstallVisibleTargets(options) {
|
|
152
|
+
const nativeCliRunner = options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner ?? getDefaultNativeCliRunner();
|
|
153
|
+
const discovered = options.discovered ?? await resolveConfigApplyTargets(options);
|
|
154
|
+
const managedCommandProducerCache = options.rebuildRuntime?.managedCommandProducerCache
|
|
155
|
+
?? new Map();
|
|
156
|
+
if (discovered.targets.some((target) => target.pluginName !== options.plugin.manifest.name)
|
|
157
|
+
|| discovered.commandPackages?.some((target) => target.producer.pluginName !== options.plugin.manifest.name)) {
|
|
158
|
+
const plugins = discovered.plugins ?? await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
159
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
160
|
+
env: options.env, plugins: options.rebuildRuntime?.referencePlugins });
|
|
161
|
+
const results = [...discovered.failures];
|
|
162
|
+
const commandResults = [];
|
|
163
|
+
const failed = new Set(discovered.failures.map(({ target }) => `${target.pluginName}\0${target.platform}\0${target.scope}`));
|
|
164
|
+
const failedPackages = new Set();
|
|
165
|
+
const errors = (discovered.commandDiscoveryErrors ?? []).map((error) => ({
|
|
166
|
+
stage: 'targetDiscovery', code: error.code, message: error.message,
|
|
167
|
+
}));
|
|
168
|
+
let partial = discovered.failures.length > 0 || errors.length > 0;
|
|
169
|
+
for (const plugin of orderPluginMetasByDependencies(plugins)) {
|
|
170
|
+
const targets = discovered.targets.filter((target) => target.pluginName === plugin.manifest.name);
|
|
171
|
+
const packages = (discovered.commandPackages ?? []).filter((target) => target.producer.pluginName === plugin.manifest.name);
|
|
172
|
+
if (!targets.length && !packages.length)
|
|
56
173
|
continue;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
174
|
+
const dependencies = resolvePluginMetaDependencyClosure(plugins, [plugin.manifest.name])
|
|
175
|
+
.filter((entry) => entry.manifest.name !== plugin.manifest.name).map((entry) => entry.manifest.name);
|
|
176
|
+
const dependencyPackageFailed = (scope) => dependencies.some((dependency) => failedPackages.has(`${dependency}\0${scope}`) || (scope === 'project' && failedPackages.has(`${dependency}\0user`)));
|
|
177
|
+
const blocked = targets.filter((target) => dependencies.some((dependency) => failed.has(`${dependency}\0${target.platform}\0${target.scope}`)
|
|
178
|
+
|| (target.scope === 'project' && failed.has(`${dependency}\0${target.platform}\0user`)))
|
|
179
|
+
|| dependencyPackageFailed(target.scope));
|
|
180
|
+
if (blocked.length) {
|
|
181
|
+
partial = true;
|
|
182
|
+
for (const target of blocked)
|
|
183
|
+
failed.add(`${plugin.manifest.name}\0${target.platform}\0${target.scope}`);
|
|
184
|
+
results.push(...blocked.map((target) => ({ target, action: 'skipped',
|
|
185
|
+
state: 'skipped', errorCode: 'dependencyApplyFailed',
|
|
186
|
+
message: `A required provider failed. Run aw plugin sync ${plugin.pluginId ?? plugin.manifest.name} --context ${target.scope} --target ${target.platform} --yes.` })));
|
|
187
|
+
}
|
|
188
|
+
const blockedPackages = packages.filter((target) => {
|
|
189
|
+
const platforms = plugin.manifest.managedCommands?.packages.find((entry) => entry.key === target.packageKey
|
|
190
|
+
&& entry.scope === target.producer.scope)?.platforms ?? NATIVE_PLATFORM_TARGETS;
|
|
191
|
+
return dependencyPackageFailed(target.producer.scope) || dependencies.some((dependency) => platforms.some((platform) => failed.has(`${dependency}\0${platform}\0${target.producer.scope}`)
|
|
192
|
+
|| (target.producer.scope === 'project' && failed.has(`${dependency}\0${platform}\0user`))));
|
|
62
193
|
});
|
|
194
|
+
for (const target of blockedPackages) {
|
|
195
|
+
partial = true;
|
|
196
|
+
failedPackages.add(`${plugin.manifest.name}\0${target.producer.scope}`);
|
|
197
|
+
commandResults.push({ producer: target.producer, state: 'failed', commandIds: [], removedCommandIds: [],
|
|
198
|
+
errors: [{ code: 'dependencyApplyFailed', message: 'A required provider failed; the command package was not refreshed.' }],
|
|
199
|
+
recoveryActions: [`aw command package sync ${plugin.pluginId ?? plugin.manifest.name} ${target.packageKey} --scope ${target.producer.scope} --yes`] });
|
|
200
|
+
}
|
|
201
|
+
const available = targets.filter((target) => !blocked.includes(target));
|
|
202
|
+
const availablePackages = packages.filter((target) => !blockedPackages.includes(target));
|
|
203
|
+
if (!available.length && !availablePackages.length)
|
|
204
|
+
continue;
|
|
205
|
+
const own = plugin.manifest.name === options.plugin.manifest.name;
|
|
206
|
+
const result = await reinstallVisibleTargets({ ...options, plugin,
|
|
207
|
+
changedConfigKeys: own ? options.changedConfigKeys : [],
|
|
208
|
+
rebuildRuntime: { ...options.rebuildRuntime, referencePlugins: plugins, managedCommandProducerCache },
|
|
209
|
+
discovered: { targets: available, failures: [], commandPackages: availablePackages,
|
|
210
|
+
commandDiscoveryErrors: [] } });
|
|
211
|
+
if (result.state !== 'succeeded' && result.state !== 'skipped') {
|
|
212
|
+
partial = true;
|
|
213
|
+
for (const target of available) {
|
|
214
|
+
if (!('targetResults' in result) || !result.targetResults.some((entry) => targetKey(entry.target) === targetKey(target) && entry.state === 'completed')) {
|
|
215
|
+
failed.add(`${plugin.manifest.name}\0${target.platform}\0${target.scope}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if ('targetResults' in result)
|
|
220
|
+
results.push(...result.targetResults);
|
|
221
|
+
if ('commandResults' in result) {
|
|
222
|
+
commandResults.push(...result.commandResults ?? []);
|
|
223
|
+
for (const entry of result.commandResults ?? []) {
|
|
224
|
+
if (entry.state !== 'completed')
|
|
225
|
+
failedPackages.add(`${plugin.manifest.name}\0${entry.producer.scope}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if ('errors' in result)
|
|
229
|
+
errors.push(...result.errors ?? []);
|
|
230
|
+
}
|
|
231
|
+
return { state: partial ? 'partial' : 'succeeded', targetResults: results,
|
|
232
|
+
...(commandResults.length ? { commandResults } : {}), ...(errors.length ? { errors } : {}) };
|
|
233
|
+
}
|
|
234
|
+
const contexts = new Map();
|
|
235
|
+
const demands = new Map();
|
|
236
|
+
const failedScopes = new Set();
|
|
237
|
+
try {
|
|
238
|
+
const targetResults = [...discovered.failures];
|
|
239
|
+
const commandResults = new Map();
|
|
240
|
+
let runtimeFailed = discovered.failures.length > 0
|
|
241
|
+
|| (discovered.commandDiscoveryErrors?.length ?? 0) > 0;
|
|
242
|
+
let invalidTargets = 0;
|
|
243
|
+
let unavailableTargets = 0;
|
|
244
|
+
const errors = [];
|
|
245
|
+
for (const scope of new Set(discovered.targets.map((target) => target.scope))) {
|
|
63
246
|
try {
|
|
64
|
-
const
|
|
247
|
+
const context = await createScopeContext({ scope, cwd: options.cwd, env: options.env });
|
|
248
|
+
contexts.set(scope, context);
|
|
249
|
+
const demand = await readDemand({ scope, cwd: context.executionCwd, env: context.env });
|
|
250
|
+
demandNativeProjection(demand);
|
|
251
|
+
demands.set(scope, demand);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
failedScopes.add(scope);
|
|
255
|
+
runtimeFailed = true;
|
|
256
|
+
for (const target of discovered.targets.filter((entry) => entry.scope === scope)) {
|
|
257
|
+
targetResults.push({ target, action: 'reinstall', state: 'failed', errorCode: 'configApplyContextUnavailable',
|
|
258
|
+
message: 'The target scope or its demand cannot be read safely.' });
|
|
259
|
+
}
|
|
260
|
+
errors.push({ stage: 'targetValidation', code: 'configApplyContextUnavailable',
|
|
261
|
+
message: 'A visible target scope or its demand cannot be read safely.' });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if ((discovered.commandDiscoveryErrors?.length ?? 0) > 0) {
|
|
265
|
+
errors.push(...discovered.commandDiscoveryErrors.map((error) => ({
|
|
266
|
+
stage: 'targetDiscovery', code: error.code, message: error.message,
|
|
267
|
+
})));
|
|
268
|
+
}
|
|
269
|
+
const reinstall = options.reinstallCommandImpl ?? syncWriteCommand;
|
|
270
|
+
if (options.plugin.sourceId && !options.plugin.pluginId) {
|
|
271
|
+
throw new Error(`Plugin "${options.plugin.manifest.name}" is missing its namespaced plugin ID.`);
|
|
272
|
+
}
|
|
273
|
+
const selector = options.plugin.sourceId
|
|
274
|
+
? options.plugin.pluginId
|
|
275
|
+
: options.plugin.manifest.name;
|
|
276
|
+
const nativeFailures = [];
|
|
277
|
+
for (const target of discovered.commandPackages ?? []) {
|
|
278
|
+
try {
|
|
279
|
+
await assertManagedCommandPackageNativeToolsUnchanged({ plugin: options.plugin, producer: target.producer, env: options.env });
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
nativeFailures.push({ producer: target.producer, state: 'failed', commandIds: [], removedCommandIds: [],
|
|
283
|
+
errors: [managedCommandDiagnostic(error)],
|
|
284
|
+
recoveryActions: [`aw command package sync ${selector} ${target.packageKey} --scope ${target.producer.scope} --yes`] });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (nativeFailures.length > 0) {
|
|
288
|
+
return { state: 'partial', commandResults: nativeFailures,
|
|
289
|
+
targetResults: [...targetResults, ...discovered.targets.map((target) => ({
|
|
290
|
+
target, action: 'reinstall', state: 'failed', errorCode: 'nativeToolSyncRequired',
|
|
291
|
+
message: 'Run a reviewed producer sync or package sync before configuration apply.',
|
|
292
|
+
}))] };
|
|
293
|
+
}
|
|
294
|
+
const sanitizeFailure = async (message, target) => {
|
|
295
|
+
let sensitiveValues = [];
|
|
296
|
+
try {
|
|
297
|
+
const effective = await resolveEffectivePluginConfig({
|
|
298
|
+
...(options.plugin.sourceId ? {
|
|
299
|
+
sourceId: options.plugin.sourceId,
|
|
300
|
+
sourceIdentity: options.plugin.sourceIdentity,
|
|
301
|
+
logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
302
|
+
} : {}),
|
|
303
|
+
pluginName: options.plugin.manifest.name,
|
|
304
|
+
manifest: options.plugin.manifest,
|
|
305
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins,
|
|
306
|
+
targetScope: target.scope,
|
|
307
|
+
platform: target.platform ?? undefined,
|
|
65
308
|
cwd: options.cwd,
|
|
66
309
|
env: options.env,
|
|
67
|
-
|
|
310
|
+
});
|
|
311
|
+
sensitiveValues = collectSensitivePluginConfigValues(options.plugin.manifest, effective.values, target.platform ?? undefined);
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
// Generic credential redaction and known config paths still apply.
|
|
315
|
+
}
|
|
316
|
+
let sanitized = redactPluginScriptOutput(message, sensitiveValues);
|
|
317
|
+
for (const privatePath of [target.projectKey, options.cwd]) {
|
|
318
|
+
if (privatePath)
|
|
319
|
+
sanitized = sanitized.split(privatePath).join('<project>');
|
|
320
|
+
}
|
|
321
|
+
for (const scope of ['user', 'project']) {
|
|
322
|
+
const configPath = resolvePluginConfigStorePath({
|
|
323
|
+
sourceId: options.plugin.sourceId,
|
|
324
|
+
pluginName: options.plugin.manifest.name,
|
|
68
325
|
scope,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
marketplaceName: options.plugin.marketplaceName,
|
|
72
|
-
marketplaceRoot: options.plugin.sourceId
|
|
73
|
-
? path.join(resolveAwHome(options.env), 'marketplaces', options.plugin.sourceId)
|
|
74
|
-
: undefined,
|
|
326
|
+
cwd: options.cwd,
|
|
327
|
+
env: options.env,
|
|
75
328
|
});
|
|
76
|
-
|
|
329
|
+
const safeTarget = `${scope}/plugin-config/${[
|
|
330
|
+
options.plugin.sourceId,
|
|
331
|
+
options.plugin.manifest.name,
|
|
332
|
+
'config.json',
|
|
333
|
+
].filter(Boolean).join('/')}`;
|
|
334
|
+
sanitized = sanitized.split(configPath).join(safeTarget);
|
|
335
|
+
}
|
|
336
|
+
return sanitized;
|
|
337
|
+
};
|
|
338
|
+
const sanitizeProjection = async (value, target, freeText = false) => {
|
|
339
|
+
if (typeof value === 'string')
|
|
340
|
+
return freeText ? sanitizeFailure(value, target) : value;
|
|
341
|
+
if (value === null || typeof value !== 'object')
|
|
342
|
+
return value;
|
|
343
|
+
if (Array.isArray(value)) {
|
|
344
|
+
return Promise.all(value.map((entry) => sanitizeProjection(entry, target, freeText)));
|
|
345
|
+
}
|
|
346
|
+
return Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, entry]) => [
|
|
347
|
+
key,
|
|
348
|
+
await sanitizeProjection(entry, target, typeof entry === 'string'
|
|
349
|
+
? /^(?:message|error|stack|stdout|stderr|output|warning)$/u.test(key)
|
|
350
|
+
: Array.isArray(entry) && /^(?:messages|warnings)$/u.test(key)),
|
|
351
|
+
])));
|
|
352
|
+
};
|
|
353
|
+
const preApplyExecutionCache = new Map();
|
|
354
|
+
for (const target of discovered.targets) {
|
|
355
|
+
if (failedScopes.has(target.scope))
|
|
356
|
+
continue;
|
|
357
|
+
try {
|
|
358
|
+
const configs = await Promise.all(pluginConfigTargetRenderScopes(options.plugin, target).map((scope) => resolveEffectivePluginConfig({
|
|
359
|
+
...(options.plugin.sourceId ? {
|
|
360
|
+
sourceId: options.plugin.sourceId,
|
|
361
|
+
sourceIdentity: options.plugin.sourceIdentity,
|
|
362
|
+
logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
363
|
+
} : {}),
|
|
364
|
+
pluginName: options.plugin.manifest.name,
|
|
365
|
+
manifest: options.plugin.manifest,
|
|
366
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins,
|
|
367
|
+
targetScope: scope,
|
|
368
|
+
platform: target.platform ?? undefined,
|
|
369
|
+
cwd: options.cwd,
|
|
370
|
+
env: options.env,
|
|
371
|
+
})));
|
|
372
|
+
if (configs.some((effective) => effective.issues.length > 0)) {
|
|
373
|
+
invalidTargets += 1;
|
|
374
|
+
targetResults.push({
|
|
375
|
+
target,
|
|
376
|
+
action: 'reinstall',
|
|
377
|
+
state: 'skipped',
|
|
378
|
+
errorCode: 'invalidConfig',
|
|
379
|
+
message: 'The effective config is invalid for this target.',
|
|
380
|
+
});
|
|
77
381
|
continue;
|
|
78
|
-
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
catch {
|
|
385
|
+
runtimeFailed = true;
|
|
386
|
+
unavailableTargets += 1;
|
|
387
|
+
targetResults.push({
|
|
388
|
+
target,
|
|
389
|
+
action: 'reinstall',
|
|
390
|
+
state: 'failed',
|
|
391
|
+
errorCode: 'effectiveConfigUnavailable',
|
|
392
|
+
message: 'The effective config cannot be read for this target.',
|
|
393
|
+
});
|
|
394
|
+
errors.push({
|
|
395
|
+
stage: 'targetValidation',
|
|
396
|
+
code: 'effectiveConfigUnavailable',
|
|
397
|
+
message: 'The effective config cannot be read for a visible target.',
|
|
398
|
+
});
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
const debugLogger = options.rebuildRuntime?.debugLogger;
|
|
403
|
+
const reporter = options.rebuildRuntime?.reporter;
|
|
404
|
+
const result = await reinstall([selector], {
|
|
405
|
+
cwd: contexts.get(target.scope).executionCwd,
|
|
406
|
+
platform: target.platform,
|
|
407
|
+
scope: target.scope,
|
|
408
|
+
...(options.rebuildRuntime?.scriptTimeoutMs === undefined
|
|
409
|
+
? {}
|
|
410
|
+
: { scriptTimeoutMs: options.rebuildRuntime.scriptTimeoutMs }),
|
|
411
|
+
}, {
|
|
412
|
+
...options.rebuildRuntime,
|
|
413
|
+
env: contexts.get(target.scope).env,
|
|
414
|
+
nativeCliRunner,
|
|
415
|
+
executionInput: {
|
|
416
|
+
context: contexts.get(target.scope),
|
|
417
|
+
requirements: demandNativeProjection(demands.get(target.scope)),
|
|
418
|
+
selectedTargets: [{ pluginId: selector, platform: target.platform, scope: target.scope }],
|
|
419
|
+
preserveOtherObservedTargets: true,
|
|
420
|
+
},
|
|
421
|
+
preApplyConfirmed: options.preApplyConfirmed === true,
|
|
422
|
+
preApplyExecutionCache,
|
|
423
|
+
managedCommandProducerCache,
|
|
424
|
+
...(debugLogger ? {
|
|
425
|
+
debugLogger: {
|
|
426
|
+
...debugLogger,
|
|
427
|
+
log: async (value) => debugLogger.log(await sanitizeProjection(value, target)),
|
|
428
|
+
},
|
|
429
|
+
} : {}),
|
|
430
|
+
...(reporter ? {
|
|
431
|
+
reporter: {
|
|
432
|
+
event: async (value) => reporter.event(await sanitizeProjection(value, target)),
|
|
433
|
+
notice: async (value) => reporter.notice(await sanitizeProjection(value, target)),
|
|
434
|
+
},
|
|
435
|
+
} : {}),
|
|
436
|
+
});
|
|
437
|
+
options.rebuildRuntime?.operationDiagnosticSink?.(result.rebuildResults);
|
|
438
|
+
for (const producer of result.commandResults ?? []) {
|
|
439
|
+
commandResults.set(getCommandPackageId(producer.producer), producer);
|
|
440
|
+
if (producer.state !== 'completed')
|
|
441
|
+
runtimeFailed = true;
|
|
442
|
+
}
|
|
443
|
+
if (result.overallState !== 'succeeded')
|
|
444
|
+
runtimeFailed = true;
|
|
445
|
+
targetResults.push(...await Promise.all(result.targetResults.map(async (entry) => ({
|
|
446
|
+
...entry,
|
|
447
|
+
state: entry.action === 'skipped' ? 'skipped' : entry.state,
|
|
448
|
+
...(entry.message ? { message: await sanitizeFailure(entry.message, entry.target) } : {}),
|
|
449
|
+
}))));
|
|
79
450
|
}
|
|
80
451
|
catch (error) {
|
|
81
|
-
|
|
452
|
+
runtimeFailed = true;
|
|
453
|
+
const message = await sanitizeFailure(error instanceof Error ? error.message : String(error), target);
|
|
454
|
+
targetResults.push({
|
|
82
455
|
target,
|
|
83
456
|
action: 'reinstall',
|
|
84
457
|
state: 'failed',
|
|
85
|
-
message
|
|
458
|
+
message,
|
|
459
|
+
});
|
|
460
|
+
errors.push({
|
|
461
|
+
stage: 'apply',
|
|
462
|
+
code: 'targetApplyFailed',
|
|
463
|
+
message: 'A visible config apply target failed.',
|
|
86
464
|
});
|
|
87
465
|
}
|
|
88
466
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
? path.resolve(options.plugin.rootDir, '..', '..')
|
|
95
|
-
: options.plugin.rootDir,
|
|
96
|
-
source: 'local',
|
|
97
|
-
};
|
|
98
|
-
for (const target of namedTargets) {
|
|
99
|
-
try {
|
|
100
|
-
const inspected = await inspectRebuildTarget({
|
|
101
|
-
sourceId: options.plugin.sourceId,
|
|
102
|
-
sourceIdentity: options.plugin.sourceIdentity,
|
|
103
|
-
pluginId: options.plugin.pluginId,
|
|
104
|
-
marketplaceName: options.plugin.marketplaceName,
|
|
105
|
-
marketplaceRoot: options.plugin.sourceId
|
|
106
|
-
? path.join(resolveAwHome(options.env), 'marketplaces', options.plugin.sourceId)
|
|
107
|
-
: undefined,
|
|
108
|
-
plugin: options.plugin,
|
|
109
|
-
platform: target.platform,
|
|
110
|
-
scope: target.scope,
|
|
111
|
-
cwd: options.cwd,
|
|
112
|
-
catalog,
|
|
113
|
-
context: {
|
|
114
|
-
env: options.env,
|
|
115
|
-
nativeCliRunner: options.nativeCliRunner,
|
|
116
|
-
reporter: options.rebuildRuntime?.reporter ?? createNoopReporter(),
|
|
117
|
-
debugLogger: options.rebuildRuntime?.debugLogger ?? createNoopDebugLogger(),
|
|
118
|
-
},
|
|
467
|
+
for (const target of discovered.commandPackages ?? []) {
|
|
468
|
+
await options.rebuildRuntime?.reporter?.event({
|
|
469
|
+
type: 'managed-command:producer',
|
|
470
|
+
source: { plugin: options.plugin.manifest.name, scope: target.producer.scope },
|
|
471
|
+
data: { packageKey: target.packageKey, phase: 'start' },
|
|
119
472
|
});
|
|
120
|
-
|
|
121
|
-
|
|
473
|
+
let result;
|
|
474
|
+
if (!target.declared) {
|
|
475
|
+
result = {
|
|
476
|
+
producer: target.producer, state: 'failed', commandIds: [], removedCommandIds: [],
|
|
477
|
+
errors: [{ code: 'commandPackageDeclarationMissing',
|
|
478
|
+
message: 'The installed command package is no longer declared by this plugin.' }],
|
|
479
|
+
recoveryActions: [`aw command package remove ${target.packageId} --yes`],
|
|
480
|
+
};
|
|
122
481
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
482
|
+
else {
|
|
483
|
+
try {
|
|
484
|
+
result = await syncPluginManagedCommandPackage({
|
|
485
|
+
plugin: options.plugin, packageKey: target.packageKey, scope: target.producer.scope,
|
|
486
|
+
cwd: options.cwd, env: options.env, managedCommandProducerCache,
|
|
487
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins,
|
|
488
|
+
event: options.changedConfigKeys?.length ? 'refresh' : 'install',
|
|
489
|
+
changedConfigKeys: options.changedConfigKeys ?? [],
|
|
490
|
+
signal: options.rebuildRuntime?.signal,
|
|
491
|
+
scriptTimeoutMs: options.rebuildRuntime?.scriptTimeoutMs,
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
catch (error) {
|
|
495
|
+
if (options.rebuildRuntime?.signal?.aborted
|
|
496
|
+
|| error instanceof Error && error.name === 'AbortError'
|
|
497
|
+
|| readSafeOperationError(error))
|
|
498
|
+
throw error;
|
|
499
|
+
result = {
|
|
500
|
+
producer: target.producer, state: 'failed', commandIds: [], removedCommandIds: [],
|
|
501
|
+
errors: [{ code: 'commandPackageApplyFailed', message: 'The managed command package could not be refreshed.' }],
|
|
502
|
+
recoveryActions: [`aw command package sync ${selector} ${target.packageKey} --scope ${target.producer.scope} --yes`,
|
|
503
|
+
`aw command package remove ${target.packageId} --yes`],
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
result = { ...result, errors: await Promise.all(result.errors.map(async (error) => ({
|
|
508
|
+
...error, message: await sanitizeFailure(error.message, { scope: target.producer.scope,
|
|
509
|
+
...(target.producer.projectRoot ? { projectKey: target.producer.projectRoot } : {}) }),
|
|
510
|
+
}))) };
|
|
511
|
+
commandResults.set(getCommandPackageId(result.producer), result);
|
|
512
|
+
await options.rebuildRuntime?.reporter?.event({
|
|
513
|
+
type: 'managed-command:producer',
|
|
514
|
+
source: { plugin: options.plugin.manifest.name, scope: target.producer.scope },
|
|
515
|
+
data: { packageKey: target.packageKey, phase: result.state === 'completed' ? 'success' : 'failure' },
|
|
130
516
|
});
|
|
517
|
+
if (result.state !== 'completed')
|
|
518
|
+
runtimeFailed = true;
|
|
519
|
+
}
|
|
520
|
+
const commands = commandResults.size > 0 ? { commandResults: [...commandResults.values()] } : {};
|
|
521
|
+
const commandTargetCount = (discovered.commandPackages?.length ?? 0);
|
|
522
|
+
if (discovered.targets.length === 0 && discovered.failures.length === 0
|
|
523
|
+
&& commandTargetCount === 0 && !runtimeFailed) {
|
|
524
|
+
return skippedApply('noVisibleTarget');
|
|
525
|
+
}
|
|
526
|
+
if (discovered.targets.length > 0 && invalidTargets === discovered.targets.length && commandTargetCount === 0) {
|
|
527
|
+
return { ...unavailableApply('invalidConfig', 'targetValidation', targetResults), ...commands };
|
|
528
|
+
}
|
|
529
|
+
if (discovered.targets.length > 0 && unavailableTargets === discovered.targets.length && commandTargetCount === 0) {
|
|
530
|
+
return { ...unavailableApply('effectiveConfigUnavailable', 'targetValidation', targetResults), ...commands };
|
|
531
|
+
}
|
|
532
|
+
if (runtimeFailed
|
|
533
|
+
|| invalidTargets > 0
|
|
534
|
+
|| unavailableTargets > 0
|
|
535
|
+
|| targetResults.some((entry) => entry.state === 'failed' || entry.state === 'skipped')) {
|
|
536
|
+
return {
|
|
537
|
+
state: 'partial',
|
|
538
|
+
targetResults,
|
|
539
|
+
...commands,
|
|
540
|
+
...(errors.length > 0 ? { errors } : {}),
|
|
541
|
+
};
|
|
131
542
|
}
|
|
543
|
+
return { state: 'succeeded', targetResults, ...commands };
|
|
544
|
+
}
|
|
545
|
+
finally {
|
|
546
|
+
await Promise.all([...contexts.values()].map((context) => context.dispose()));
|
|
132
547
|
}
|
|
133
|
-
return { targets: dedupeTargets(targets), failures };
|
|
134
548
|
}
|
|
135
|
-
async function
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
549
|
+
async function resolveConfigApplyTargets(options) {
|
|
550
|
+
const platformTargets = options.applyTargets !== undefined
|
|
551
|
+
? { targets: dedupeTargets(options.applyTargets), failures: [] }
|
|
552
|
+
: await discoverVisibleTargets({
|
|
139
553
|
pluginName: options.plugin.manifest.name,
|
|
140
554
|
plugin: options.plugin,
|
|
141
555
|
scope: options.scope,
|
|
142
556
|
cwd: options.cwd,
|
|
143
557
|
env: options.env,
|
|
144
|
-
nativeCliRunner,
|
|
558
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner ?? getDefaultNativeCliRunner(),
|
|
145
559
|
rebuildRuntime: options.rebuildRuntime,
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
560
|
+
});
|
|
561
|
+
const commands = await discoverPluginConfigManagedCommandPackages({
|
|
562
|
+
plugin: options.plugin, scope: options.scope, cwd: options.cwd, env: options.env,
|
|
563
|
+
platformTargets: platformTargets.targets,
|
|
564
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins,
|
|
565
|
+
});
|
|
566
|
+
return { ...platformTargets, commandPackages: commands.packages, commandDiscoveryErrors: commands.errors };
|
|
567
|
+
}
|
|
568
|
+
async function configApplyHasValidSharedNativeTarget(options) {
|
|
569
|
+
const plugins = await resolvePluginConfigReferenceConsumers({ plugin: options.plugin, env: options.env, plugins: options.plugins });
|
|
570
|
+
for (const plugin of plugins) {
|
|
571
|
+
for (const target of options.targets.filter((target) => target.pluginName === plugin.manifest.name)) {
|
|
572
|
+
const shared = pluginSharedNativeConfigRenderUnits(plugin);
|
|
573
|
+
if (!shared.some((entry) => entry.platform === target.platform))
|
|
574
|
+
continue;
|
|
575
|
+
const effective = await resolveEffectivePluginConfig({ sourceId: plugin.sourceId,
|
|
576
|
+
sourceIdentity: plugin.sourceIdentity, logicalIdentity: plugin.catalogLogicalIdentity,
|
|
577
|
+
manifest: plugin.manifest, platform: target.platform, targetScope: 'user',
|
|
578
|
+
cwd: options.cwd, env: options.env, referencePlugins: options.plugins });
|
|
579
|
+
if (!effective.issues.length)
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
export async function resolveConfigPreApplyAuthorization(options) {
|
|
586
|
+
const applyTargets = dedupeTargets(options.applyTargets);
|
|
587
|
+
if (applyTargets.some((target) => target.pluginName !== options.plugin.manifest.name)) {
|
|
588
|
+
const plugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
589
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
590
|
+
env: options.env, plugins: options.rebuildRuntime?.referencePlugins });
|
|
591
|
+
const results = await Promise.all(plugins.map((plugin) => resolveConfigPreApplyAuthorization({ ...options, plugin,
|
|
592
|
+
applyTargets: applyTargets.filter((target) => target.pluginName === plugin.manifest.name) })));
|
|
593
|
+
return { targets: results.flatMap((result) => result.targets),
|
|
594
|
+
availableApplyTargets: results.flatMap((result) => result.availableApplyTargets),
|
|
595
|
+
unavailableTargetResults: results.flatMap((result) => result.unavailableTargetResults) };
|
|
596
|
+
}
|
|
597
|
+
if (applyTargets.length === 0 || !pluginMayRunPreApply(options.plugin)) {
|
|
598
|
+
return { targets: [], availableApplyTargets: applyTargets, unavailableTargetResults: [] };
|
|
599
|
+
}
|
|
151
600
|
if (options.plugin.sourceId && !options.plugin.pluginId) {
|
|
152
|
-
|
|
601
|
+
return {
|
|
602
|
+
targets: [],
|
|
603
|
+
availableApplyTargets: [],
|
|
604
|
+
unavailableTargetResults: applyTargets.map((target) => ({
|
|
605
|
+
target,
|
|
606
|
+
action: 'reinstall',
|
|
607
|
+
state: 'failed',
|
|
608
|
+
errorCode: 'sourceUnavailable',
|
|
609
|
+
message: 'The preApply authorization scope cannot be resolved for this target.',
|
|
610
|
+
})),
|
|
611
|
+
};
|
|
153
612
|
}
|
|
154
613
|
const selector = options.plugin.sourceId
|
|
155
614
|
? options.plugin.pluginId
|
|
156
615
|
: options.plugin.manifest.name;
|
|
157
|
-
|
|
616
|
+
const groups = new Map();
|
|
617
|
+
for (const target of applyTargets) {
|
|
618
|
+
const key = `${target.scope}\0${target.platform}`;
|
|
619
|
+
const targets = groups.get(key) ?? [];
|
|
620
|
+
targets.push(target);
|
|
621
|
+
groups.set(key, targets);
|
|
622
|
+
}
|
|
623
|
+
const authorization = [];
|
|
624
|
+
const availableApplyTargets = [];
|
|
625
|
+
const unavailableTargetResults = [];
|
|
626
|
+
const resolveGroup = async (targets) => {
|
|
627
|
+
const platform = targets[0].platform;
|
|
628
|
+
let context;
|
|
158
629
|
try {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
630
|
+
context = await createScopeContext({ scope: targets[0].scope, cwd: options.cwd, env: options.env });
|
|
631
|
+
const demand = await readDemand({ scope: targets[0].scope,
|
|
632
|
+
cwd: context.executionCwd, env: context.env });
|
|
633
|
+
const preview = await (options.reinstallCommandImpl ?? syncWriteCommand)([selector], {
|
|
634
|
+
cwd: context.executionCwd,
|
|
635
|
+
platform,
|
|
636
|
+
scope: targets[0].scope,
|
|
163
637
|
}, {
|
|
164
638
|
...options.rebuildRuntime,
|
|
165
|
-
env:
|
|
166
|
-
nativeCliRunner,
|
|
639
|
+
env: context.env,
|
|
640
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
641
|
+
previewOperationPlan: true,
|
|
642
|
+
resolvePreApplyAuthorization: true,
|
|
643
|
+
executionInput: {
|
|
644
|
+
context, requirements: demandNativeProjection(demand),
|
|
645
|
+
selectedTargets: targets.map((target) => ({ pluginId: selector,
|
|
646
|
+
platform: target.platform, scope: target.scope })),
|
|
647
|
+
preserveOtherObservedTargets: true,
|
|
648
|
+
},
|
|
167
649
|
});
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
650
|
+
if (preview.overallState !== 'succeeded' || !preview.preApplyAuthorization)
|
|
651
|
+
return false;
|
|
652
|
+
authorization.push(...preview.preApplyAuthorization);
|
|
653
|
+
availableApplyTargets.push(...targets);
|
|
654
|
+
return true;
|
|
171
655
|
}
|
|
172
|
-
catch
|
|
173
|
-
|
|
174
|
-
|
|
656
|
+
catch {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
finally {
|
|
660
|
+
await context?.dispose();
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
for (const targets of groups.values()) {
|
|
664
|
+
if (await resolveGroup(targets))
|
|
665
|
+
continue;
|
|
666
|
+
for (const target of targets) {
|
|
667
|
+
if (targets.length > 1 && await resolveGroup([target]))
|
|
668
|
+
continue;
|
|
669
|
+
unavailableTargetResults.push({
|
|
175
670
|
target,
|
|
176
671
|
action: 'reinstall',
|
|
177
672
|
state: 'failed',
|
|
178
|
-
|
|
673
|
+
errorCode: 'sourceUnavailable',
|
|
674
|
+
message: 'The preApply authorization scope cannot be resolved for this target.',
|
|
179
675
|
});
|
|
180
676
|
}
|
|
181
677
|
}
|
|
182
|
-
const overallState = runtimeFailed || targetResults.some((entry) => entry.state === 'failed')
|
|
183
|
-
? 'failed' : 'succeeded';
|
|
184
678
|
return {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
679
|
+
targets: [...new Map(authorization.map((target) => [[
|
|
680
|
+
target.pluginId,
|
|
681
|
+
target.platform,
|
|
682
|
+
target.scope,
|
|
683
|
+
].join('\0'), target])).values()],
|
|
684
|
+
availableApplyTargets: dedupeTargets(availableApplyTargets),
|
|
685
|
+
unavailableTargetResults,
|
|
190
686
|
};
|
|
191
687
|
}
|
|
688
|
+
function pluginMayRunPreApply(plugin) {
|
|
689
|
+
return plugin.manifest.scripts?.preApply !== undefined
|
|
690
|
+
|| (plugin.manifest.dependencies?.length ?? 0) > 0;
|
|
691
|
+
}
|
|
692
|
+
function throwPreApplyAuthorizationRequired(targets) {
|
|
693
|
+
const plugins = [...new Set(targets.map((target) => target.pluginId))].join(', ');
|
|
694
|
+
const error = new Error(`preApplyAuthorizationRequired: Applying this config runs plugin preApply for ${plugins}. Re-run with --yes.`);
|
|
695
|
+
error.code = 'preApplyAuthorizationRequired';
|
|
696
|
+
throw error;
|
|
697
|
+
}
|
|
698
|
+
function preApplyAuthorizationIsConfirmed(options) {
|
|
699
|
+
if (options.confirmed !== true)
|
|
700
|
+
return false;
|
|
701
|
+
if (options.authorizedTargets === undefined)
|
|
702
|
+
return true;
|
|
703
|
+
const authorized = new Set(options.authorizedTargets.map((target) => [
|
|
704
|
+
target.pluginId,
|
|
705
|
+
target.sourceIdentity,
|
|
706
|
+
target.platform,
|
|
707
|
+
target.scope,
|
|
708
|
+
].join('\0')));
|
|
709
|
+
return options.required.every((target) => authorized.has([
|
|
710
|
+
target.pluginId,
|
|
711
|
+
target.sourceIdentity,
|
|
712
|
+
target.platform,
|
|
713
|
+
target.scope,
|
|
714
|
+
].join('\0')));
|
|
715
|
+
}
|
|
192
716
|
function otherProjectsWarning(scope) {
|
|
193
717
|
return scope === 'user'
|
|
194
|
-
? ['
|
|
718
|
+
? ['其它项目不会由本次命令扫描或更新,可能需要在对应项目目录中运行 aw plugin sync --context project。']
|
|
195
719
|
: [];
|
|
196
720
|
}
|
|
197
721
|
function buildReceiptFieldEntry(options) {
|
|
@@ -202,167 +726,493 @@ function buildReceiptFieldEntry(options) {
|
|
|
202
726
|
reserved: options.reserved,
|
|
203
727
|
action: options.action,
|
|
204
728
|
scope: options.scope,
|
|
205
|
-
...(options.scope === 'project' ? { projectLayer: options.projectLayer } : {}),
|
|
206
729
|
...(options.valueState ? { valueState: options.valueState } : {}),
|
|
207
730
|
};
|
|
208
731
|
}
|
|
209
732
|
export async function replayConfigRuntimeWrites(options) {
|
|
733
|
+
if (!options.awHomeMutationToken) {
|
|
734
|
+
await prepareNativeCliExecution({ env: options.env, runner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner });
|
|
735
|
+
}
|
|
210
736
|
return withAwHomeMutationLock({
|
|
211
737
|
env: options.env,
|
|
212
738
|
token: options.awHomeMutationToken,
|
|
213
739
|
action: async (awHomeMutationToken) => {
|
|
214
|
-
const
|
|
740
|
+
const env = options.env ?? process.env;
|
|
741
|
+
const rebuildRuntime = { ...options.rebuildRuntime, awHomeMutationToken };
|
|
742
|
+
let discovered;
|
|
743
|
+
try {
|
|
744
|
+
discovered = await resolveConfigApplyTargets({
|
|
745
|
+
plugin: options.plugin,
|
|
746
|
+
scope: options.scope,
|
|
747
|
+
cwd: options.cwd,
|
|
748
|
+
env,
|
|
749
|
+
applyTargets: options.applyTargets,
|
|
750
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
751
|
+
rebuildRuntime,
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
catch {
|
|
755
|
+
const apply = unavailableApply('targetDiscoveryFailed', 'targetDiscovery');
|
|
756
|
+
return {
|
|
757
|
+
configWrite: 'succeeded',
|
|
758
|
+
overallState: 'partial',
|
|
759
|
+
apply: publicConfigApplyResult(apply),
|
|
760
|
+
otherProjectsMayRequireSync: false,
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
const preApplyAuthorization = await resolveConfigPreApplyAuthorization({
|
|
215
764
|
plugin: options.plugin,
|
|
216
765
|
scope: options.scope,
|
|
217
766
|
cwd: options.cwd,
|
|
218
|
-
env
|
|
767
|
+
env,
|
|
768
|
+
applyTargets: discovered.targets,
|
|
769
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
770
|
+
rebuildRuntime,
|
|
771
|
+
reinstallCommandImpl: options.reinstallCommandImpl,
|
|
772
|
+
});
|
|
773
|
+
if (preApplyAuthorization.targets.length > 0 && !preApplyAuthorizationIsConfirmed({
|
|
774
|
+
required: preApplyAuthorization.targets,
|
|
775
|
+
confirmed: options.preApplyConfirmed,
|
|
776
|
+
authorizedTargets: options.preApplyAuthorizedTargets,
|
|
777
|
+
})) {
|
|
778
|
+
const apply = {
|
|
779
|
+
state: 'partial',
|
|
780
|
+
targetResults: preApplyAuthorization.targets.map((target) => ({
|
|
781
|
+
target: {
|
|
782
|
+
pluginName: target.pluginName,
|
|
783
|
+
pluginId: target.pluginId,
|
|
784
|
+
platform: target.platform,
|
|
785
|
+
scope: target.scope,
|
|
786
|
+
},
|
|
787
|
+
action: 'reinstall',
|
|
788
|
+
state: 'failed',
|
|
789
|
+
errorCode: 'preApplyAuthorizationRequired',
|
|
790
|
+
message: 'Running plugin preApply requires explicit authorization.',
|
|
791
|
+
})),
|
|
792
|
+
};
|
|
793
|
+
return {
|
|
794
|
+
configWrite: 'succeeded',
|
|
795
|
+
overallState: 'partial',
|
|
796
|
+
apply: publicConfigApplyResult(apply),
|
|
797
|
+
otherProjectsMayRequireSync: false,
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
discovered = {
|
|
801
|
+
...discovered,
|
|
802
|
+
targets: preApplyAuthorization.availableApplyTargets,
|
|
803
|
+
failures: [...discovered.failures, ...preApplyAuthorization.unavailableTargetResults],
|
|
804
|
+
};
|
|
805
|
+
if (discovered.targets.length === 0
|
|
806
|
+
&& preApplyAuthorization.unavailableTargetResults.length > 0
|
|
807
|
+
&& (discovered.commandPackages?.length ?? 0) === 0) {
|
|
808
|
+
const apply = unavailableApply('sourceUnavailable', 'source', preApplyAuthorization.unavailableTargetResults);
|
|
809
|
+
return {
|
|
810
|
+
configWrite: 'succeeded',
|
|
811
|
+
overallState: 'partial',
|
|
812
|
+
apply: publicConfigApplyResult(apply),
|
|
813
|
+
otherProjectsMayRequireSync: false,
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
if (options.scope === 'user'
|
|
817
|
+
&& options.sharedNativeApplyConfirmed !== true
|
|
818
|
+
&& await configApplyHasValidSharedNativeTarget({
|
|
819
|
+
plugin: options.plugin,
|
|
820
|
+
targets: discovered.targets,
|
|
821
|
+
cwd: options.cwd,
|
|
822
|
+
env,
|
|
823
|
+
plugins: rebuildRuntime.referencePlugins,
|
|
824
|
+
})) {
|
|
825
|
+
throwSharedNativeApplyConfirmationRequired();
|
|
826
|
+
}
|
|
827
|
+
const apply = await reinstallVisibleTargets({
|
|
828
|
+
plugin: options.plugin,
|
|
829
|
+
scope: options.scope,
|
|
830
|
+
cwd: options.cwd,
|
|
831
|
+
env,
|
|
219
832
|
applyTargets: options.applyTargets,
|
|
220
|
-
nativeCliRunner: options.nativeCliRunner,
|
|
833
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
221
834
|
reinstallCommandImpl: options.reinstallCommandImpl,
|
|
222
|
-
rebuildRuntime
|
|
835
|
+
rebuildRuntime,
|
|
836
|
+
discovered,
|
|
837
|
+
preApplyConfirmed: options.preApplyConfirmed,
|
|
223
838
|
});
|
|
224
839
|
return {
|
|
225
840
|
configWrite: 'succeeded',
|
|
226
|
-
overallState:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
otherProjectsRequireReinstall: options.scope === 'user',
|
|
841
|
+
overallState: overallStateForApply(apply),
|
|
842
|
+
apply: publicConfigApplyResult(apply),
|
|
843
|
+
otherProjectsMayRequireSync: false,
|
|
230
844
|
};
|
|
231
845
|
},
|
|
232
846
|
});
|
|
233
847
|
}
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
848
|
+
function configApplyRequestedTargets(plan) {
|
|
849
|
+
const targets = plan.joint
|
|
850
|
+
? plan.joint.children.filter((child) => child.command !== 'cleanup' && child.command !== 'uninstall')
|
|
851
|
+
.flatMap((child) => configApplyRequestedTargets(child))
|
|
852
|
+
: plan.receipt.requestedTargets;
|
|
853
|
+
return targets.filter((target) => !plan.receipt.targetResults.some((result) => result.pluginId === target.pluginId && result.agent === target.agent && result.scope === target.scope
|
|
854
|
+
&& (result.satisfaction === 'unsupported' || result.satisfaction === 'excluded')));
|
|
855
|
+
}
|
|
856
|
+
async function prepareConfigApplyPackages(options, plugins, plan, referencePlugins) {
|
|
857
|
+
const env = options.env ?? process.env;
|
|
858
|
+
const context = options.context ?? options.scope;
|
|
859
|
+
const discoveries = [];
|
|
860
|
+
const scopes = context === 'project' ? ['user', 'project'] : ['user'];
|
|
861
|
+
const nativeTargets = configApplyRequestedTargets(plan).flatMap((target) => target.agent !== 'generic'
|
|
862
|
+
? [{ pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId, platform: target.agent, scope: target.scope }] : []);
|
|
863
|
+
for (const plugin of plugins) {
|
|
864
|
+
for (const scope of scopes) {
|
|
865
|
+
discoveries.push(await discoverInstalledPluginManagedCommandPackages({ plugin, scope, cwd: options.cwd, env,
|
|
866
|
+
platformTargets: nativeTargets.filter((target) => target.pluginId === (plugin.pluginId ?? plugin.manifest.name)
|
|
867
|
+
&& (scope === 'user' || target.scope === 'project')) }));
|
|
868
|
+
}
|
|
249
869
|
}
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
870
|
+
const packages = [...new Map(discoveries.flatMap((discovery) => discovery.packages).filter((target) => {
|
|
871
|
+
if (options.applyCommandPackages && !options.applyCommandPackages.includes(target.packageId))
|
|
872
|
+
return false;
|
|
873
|
+
if (options.platform)
|
|
874
|
+
return false;
|
|
875
|
+
if (!options.targets)
|
|
876
|
+
return true;
|
|
877
|
+
const plugin = plugins.find((entry) => entry.manifest.name === target.producer.pluginName);
|
|
878
|
+
const declaration = plugin?.manifest.managedCommands?.packages.find((entry) => entry.key === target.packageKey && entry.scope === target.producer.scope);
|
|
879
|
+
return declaration?.platforms.some((platform) => options.targets.includes(platform)) ?? false;
|
|
880
|
+
}).map((target) => [target.packageId, target])).values()];
|
|
881
|
+
const inventory = await listManagedCommandPackages(env);
|
|
882
|
+
const entries = await Promise.all(packages.map(async (target) => {
|
|
883
|
+
const plugin = plugins.find((entry) => entry.manifest.name === target.producer.pluginName);
|
|
884
|
+
const installed = inventory.packages.find((entry) => entry.id === target.packageId);
|
|
885
|
+
let recordDigest;
|
|
886
|
+
let blocker;
|
|
887
|
+
if (!target.installed || !installed) {
|
|
888
|
+
blocker = { code: 'configApplyRequiresExistingOutput', message: 'Configuration apply requires an existing command package. Run package sync first.' };
|
|
889
|
+
}
|
|
890
|
+
else if (!target.declared) {
|
|
891
|
+
blocker = { code: 'commandPackageDeclarationMissing', message: 'The installed command package is no longer declared by this plugin.' };
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
try {
|
|
895
|
+
const record = await readInstalledCommandProducer(installed.resourceRoot);
|
|
896
|
+
recordDigest = `sha256:${crypto.createHash('sha256').update(JSON.stringify(record)).digest('hex')}`;
|
|
897
|
+
await assertManagedCommandPackageNativeToolsUnchanged({ plugin, producer: target.producer, env });
|
|
898
|
+
}
|
|
899
|
+
catch (error) {
|
|
900
|
+
blocker = managedCommandDiagnostic(error);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
return { target, recordDigest, blocker };
|
|
904
|
+
}));
|
|
905
|
+
const errors = [...new Map(discoveries.flatMap((discovery) => discovery.errors).map((error) => [JSON.stringify(error), error])).values()];
|
|
906
|
+
const evidence = { packages: entries, errors };
|
|
907
|
+
const targets = [...new Map(entries.map(({ target }) => {
|
|
908
|
+
const plugin = plugins.find((entry) => entry.manifest.name === target.producer.pluginName);
|
|
909
|
+
const pluginId = plugin.pluginId ?? plugin.manifest.name;
|
|
910
|
+
const dependencies = resolvePluginMetaDependencyClosure(referencePlugins, [plugin.manifest.name])
|
|
911
|
+
.filter((entry) => entry.manifest.name !== plugin.manifest.name).map((entry) => entry.pluginId ?? entry.manifest.name);
|
|
912
|
+
return [`${pluginId}\0${target.producer.scope}`, { pluginId, scope: target.producer.scope, dependencies }];
|
|
913
|
+
})).values()];
|
|
914
|
+
const cache = plan.runtime.managedCommandProducerCache ??= new Map();
|
|
915
|
+
const hook = { targets, evidence,
|
|
916
|
+
blocked: (pluginId, scope, code) => {
|
|
917
|
+
const plugin = plugins.find((entry) => (entry.pluginId ?? entry.manifest.name) === pluginId);
|
|
918
|
+
return entries.filter(({ target }) => target.producer.pluginName === plugin.manifest.name && target.producer.scope === scope)
|
|
919
|
+
.map(({ target }) => ({
|
|
920
|
+
producer: target.producer, state: 'failed', commandIds: [], removedCommandIds: [],
|
|
921
|
+
errors: [{ code, message: 'A required provider failed; the command package was not refreshed.' }],
|
|
922
|
+
recoveryActions: [`aw command package sync ${pluginId} ${target.packageKey} --scope ${scope} --yes`],
|
|
923
|
+
}));
|
|
924
|
+
},
|
|
925
|
+
execute: async (pluginId, scope, token) => {
|
|
926
|
+
const plugin = plugins.find((entry) => (entry.pluginId ?? entry.manifest.name) === pluginId);
|
|
927
|
+
const selected = entries.filter(({ target }) => target.producer.pluginName === plugin.manifest.name && target.producer.scope === scope);
|
|
928
|
+
const results = [];
|
|
929
|
+
let executionContext;
|
|
930
|
+
try {
|
|
931
|
+
executionContext = await createScopeContext({ scope, cwd: options.cwd, env });
|
|
932
|
+
for (const { target, blocker } of selected) {
|
|
933
|
+
if (blocker) {
|
|
934
|
+
const result = { producer: target.producer, state: 'failed', commandIds: [], removedCommandIds: [],
|
|
935
|
+
errors: [blocker], recoveryActions: [target.declared
|
|
936
|
+
? `aw command package sync ${pluginId} ${target.packageKey} --scope ${scope} --yes`
|
|
937
|
+
: `aw command package remove ${target.packageId} --yes`] };
|
|
938
|
+
cache.set(target.packageId, Promise.resolve(result));
|
|
939
|
+
results.push(result);
|
|
940
|
+
continue;
|
|
941
|
+
}
|
|
942
|
+
const applied = await reinstallVisibleTargets({ plugin, scope, cwd: executionContext.executionCwd, env: executionContext.env,
|
|
943
|
+
changedConfigKeys: [...target.refreshKeys],
|
|
944
|
+
rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken: token, referencePlugins, managedCommandProducerCache: cache },
|
|
945
|
+
discovered: { targets: [], failures: [], commandPackages: [target], commandDiscoveryErrors: [] } });
|
|
946
|
+
results.push(...('commandResults' in applied ? applied.commandResults ?? [] : []));
|
|
947
|
+
}
|
|
948
|
+
return results;
|
|
949
|
+
}
|
|
950
|
+
finally {
|
|
951
|
+
await executionContext?.dispose();
|
|
952
|
+
}
|
|
953
|
+
} };
|
|
954
|
+
return { packages, evidence, errors, hook };
|
|
955
|
+
}
|
|
956
|
+
/** Prepare the same existing-output plan used by apply, without saving config or output. */
|
|
957
|
+
export async function preparePluginConfigApply(options) {
|
|
958
|
+
const { prepareRecovery, describeRecoveryPlan } = await import('../recovery/coordinator.js');
|
|
959
|
+
const context = options.context ?? options.scope;
|
|
960
|
+
const referencePlugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
961
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
962
|
+
env: options.env, plugins: options.rebuildRuntime?.referencePlugins });
|
|
963
|
+
const plugins = await resolvePluginConfigReferenceConsumers({ plugin: options.plugin, env: options.env,
|
|
964
|
+
plugins: referencePlugins });
|
|
965
|
+
const selectors = plugins.map((plugin) => plugin.pluginId ?? plugin.manifest.name);
|
|
966
|
+
const version = options.cliVersion
|
|
967
|
+
?? (await fs.readJson(path.join(resolveCliPackageRoot(), 'package.json'))).version;
|
|
968
|
+
let exactTargets = options.applyTargets?.map((target) => ({
|
|
969
|
+
pluginId: target.pluginId ?? plugins.find((plugin) => plugin.manifest.name === target.pluginName)?.pluginId ?? target.pluginName,
|
|
970
|
+
agent: target.platform,
|
|
971
|
+
scope: target.scope,
|
|
972
|
+
}));
|
|
973
|
+
const retainedLegacyTargets = [];
|
|
974
|
+
if (exactTargets?.length) {
|
|
975
|
+
const { readRecoveryStatus } = await import('../recovery/status.js');
|
|
976
|
+
const observed = await readRecoveryStatus({ context, cwd: options.cwd, env: options.env, cliVersion: version,
|
|
977
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
978
|
+
codexObservationSession: options.rebuildRuntime?.codexObservationSession });
|
|
979
|
+
const key = (target) => `${target.pluginId}\0${target.agent}\0${target.scope}`;
|
|
980
|
+
const live = new Set(observed.existingTargets?.map(key));
|
|
981
|
+
const owned = new Set(observed.ownedTargets?.map(key));
|
|
982
|
+
exactTargets = exactTargets.filter((target, index) => {
|
|
983
|
+
if (owned.has(key(target)) && !live.has(key(target))) {
|
|
984
|
+
retainedLegacyTargets.push(options.applyTargets[index]);
|
|
985
|
+
return false;
|
|
986
|
+
}
|
|
987
|
+
return true;
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
const plan = await prepareRecovery('sync', selectors, {
|
|
991
|
+
scope: context,
|
|
992
|
+
context,
|
|
256
993
|
cwd: options.cwd,
|
|
257
994
|
env: options.env,
|
|
995
|
+
cliVersion: version,
|
|
996
|
+
existingOnly: true,
|
|
997
|
+
...(exactTargets ? { exactTargets } : {}),
|
|
998
|
+
...(options.targets ? { targets: options.targets } : options.platform ? { targets: [options.platform] } : {}),
|
|
999
|
+
}, {
|
|
1000
|
+
...options.rebuildRuntime,
|
|
1001
|
+
referencePlugins,
|
|
1002
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
1003
|
+
awHomeMutationToken: options.awHomeMutationToken,
|
|
1004
|
+
preApplyConfirmed: options.preApplyConfirmed,
|
|
258
1005
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
1006
|
+
try {
|
|
1007
|
+
plan.warnings.push(...retainedLegacyTargets.map((target) => `${target.pluginId ?? target.pluginName}/${target.platform}/${target.scope}:保留已停用的历史输出;配置 apply 不创建激活。`));
|
|
1008
|
+
const commands = await prepareConfigApplyPackages(options, plugins, plan, referencePlugins);
|
|
1009
|
+
plan.runtime.configApplyPackages = commands.hook;
|
|
1010
|
+
const profiles = configApplyRequestedTargets(plan).map((target) => ({
|
|
1011
|
+
pluginName: target.pluginId.split('/').at(-1), scope: target.scope, platform: target.agent,
|
|
1012
|
+
}));
|
|
1013
|
+
// A package has platform=null and always consumes the public common profile.
|
|
1014
|
+
profiles.push(...commands.packages.map((target) => ({ pluginName: target.producer.pluginName,
|
|
1015
|
+
scope: target.producer.scope, platform: undefined })));
|
|
1016
|
+
const references = await collectPluginConfigReferenceEvidence({ plugin: options.plugin, plugins: referencePlugins,
|
|
1017
|
+
profiles, cwd: options.cwd, env: options.env });
|
|
1018
|
+
const authorization = await resolveConfigPreApplyAuthorization({
|
|
1019
|
+
plugin: options.plugin, scope: context, cwd: options.cwd, env: options.env,
|
|
1020
|
+
applyTargets: configApplyRequestedTargets(plan).flatMap((target) => target.agent !== 'generic'
|
|
1021
|
+
? [{ pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId, platform: target.agent, scope: target.scope }] : []),
|
|
1022
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
|
|
1023
|
+
rebuildRuntime: { ...plan.runtime, referencePlugins },
|
|
1024
|
+
});
|
|
1025
|
+
const portableAuthorization = (current) => [
|
|
1026
|
+
...current.preApplyAuthorization ?? [],
|
|
1027
|
+
...(current.joint?.children ?? []).flatMap(portableAuthorization),
|
|
1028
|
+
];
|
|
1029
|
+
const preApplyAuthorization = [...new Map([...authorization.targets, ...portableAuthorization(plan)]
|
|
1030
|
+
.map((target) => [[target.pluginId, target.platform, target.scope].join('\0'), target])).values()];
|
|
1031
|
+
return { plan, retainedLegacyTargets, commandPackages: commands.packages, commandDiscoveryErrors: commands.errors,
|
|
1032
|
+
preApplyAuthorization,
|
|
1033
|
+
evidence: { recovery: describeRecoveryPlan(plan), references, commands: commands.evidence,
|
|
1034
|
+
preApplyAuthorization, retainedLegacyTargets } };
|
|
263
1035
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
1036
|
+
catch (error) {
|
|
1037
|
+
await disposePluginConfigApply(plan);
|
|
1038
|
+
throw error;
|
|
267
1039
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
1040
|
+
}
|
|
1041
|
+
export async function disposePluginConfigApply(plan) {
|
|
1042
|
+
for (const child of plan.joint?.children ?? [])
|
|
1043
|
+
await disposePluginConfigApply(child);
|
|
1044
|
+
await plan.context.dispose();
|
|
1045
|
+
}
|
|
1046
|
+
export async function applyPluginConfig(options) {
|
|
1047
|
+
return withAwHomeMutationLock({ env: options.env, token: options.awHomeMutationToken, action: async (token) => {
|
|
1048
|
+
await options.reviewPreflight?.();
|
|
1049
|
+
let prepared;
|
|
1050
|
+
try {
|
|
1051
|
+
const { executeRecovery } = await import('../recovery/coordinator.js');
|
|
1052
|
+
prepared = await preparePluginConfigApply({ ...options, awHomeMutationToken: token });
|
|
1053
|
+
if (options.expectedEvidence !== undefined
|
|
1054
|
+
&& JSON.stringify(options.expectedEvidence) !== JSON.stringify(prepared.evidence)) {
|
|
1055
|
+
throw Object.assign(new Error('operationPlanStale: Configuration apply inputs changed. Prepare a new Review.'), { code: 'operationPlanStale' });
|
|
1056
|
+
}
|
|
1057
|
+
const authorization = prepared.preApplyAuthorization;
|
|
1058
|
+
if (authorization.length && !preApplyAuthorizationIsConfirmed({ required: authorization,
|
|
1059
|
+
confirmed: options.preApplyConfirmed, authorizedTargets: options.preApplyAuthorizedTargets })) {
|
|
1060
|
+
throwPreApplyAuthorizationRequired(authorization);
|
|
1061
|
+
}
|
|
1062
|
+
if (options.sharedNativeApplyConfirmed !== true && await configApplyHasValidSharedNativeTarget({
|
|
1063
|
+
plugin: options.plugin, cwd: options.cwd, env: options.env, plugins: options.rebuildRuntime?.referencePlugins,
|
|
1064
|
+
targets: configApplyRequestedTargets(prepared.plan).flatMap((target) => target.agent !== 'generic'
|
|
1065
|
+
? [{ pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId, platform: target.agent, scope: target.scope }] : []),
|
|
1066
|
+
}))
|
|
1067
|
+
throwSharedNativeApplyConfirmationRequired();
|
|
1068
|
+
const discoveryErrors = prepared.commandDiscoveryErrors.map((error) => ({
|
|
1069
|
+
stage: 'targetDiscovery', code: error.code, message: error.message,
|
|
1070
|
+
}));
|
|
1071
|
+
const receipt = await executeRecovery(prepared.plan, {
|
|
1072
|
+
yes: options.sharedNativeApplyConfirmed === true || options.preApplyConfirmed === true,
|
|
1073
|
+
runtime: { ...options.rebuildRuntime, awHomeMutationToken: token, preApplyConfirmed: options.preApplyConfirmed },
|
|
1074
|
+
});
|
|
1075
|
+
const retainedLegacyTargets = prepared.retainedLegacyTargets.filter((target) => !receipt.targetResults.some((result) => (target.pluginId ? result.pluginId === target.pluginId : result.pluginId.split('/').at(-1) === target.pluginName)
|
|
1076
|
+
&& result.agent === target.platform && result.scope === target.scope));
|
|
1077
|
+
prepared = undefined;
|
|
1078
|
+
const ok = receipt.ok && discoveryErrors.length === 0;
|
|
1079
|
+
const errors = [...discoveryErrors, ...receipt.blockers, ...receipt.errors].map((error) => ({
|
|
1080
|
+
stage: 'stage' in error ? error.stage : 'apply', code: error.code, message: error.message,
|
|
1081
|
+
}));
|
|
1082
|
+
const apply = {
|
|
1083
|
+
state: ok ? 'succeeded' : 'partial',
|
|
1084
|
+
targetResults: [...receipt.targetResults.filter((target) => target.satisfaction !== 'unsupported' && target.satisfaction !== 'excluded').map((target) => ({
|
|
1085
|
+
target: { pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId,
|
|
1086
|
+
platform: target.agent, scope: target.scope },
|
|
1087
|
+
action: 'refresh',
|
|
1088
|
+
state: target.execution === 'applied' || target.execution === 'no-op' ? 'completed'
|
|
1089
|
+
: target.execution === 'not-run' ? 'skipped' : 'failed',
|
|
1090
|
+
...(target.blockers.length ? { errorCode: target.blockers[0].code,
|
|
1091
|
+
message: target.blockers.map((item) => item.message).join(' ') } : {}),
|
|
1092
|
+
})), ...retainedLegacyTargets.map((target) => ({
|
|
1093
|
+
target, action: 'refresh', state: 'skipped',
|
|
1094
|
+
message: 'The inactive legacy output was preserved. Configuration apply does not create an activation.',
|
|
1095
|
+
}))],
|
|
1096
|
+
commandResults: receipt.commandResults,
|
|
1097
|
+
...(errors.length ? { errors } : {}),
|
|
1098
|
+
};
|
|
1099
|
+
return { configWrite: 'notStarted', overallState: ok ? 'succeeded' : 'partial', apply,
|
|
1100
|
+
otherProjectsMayRequireSync: true };
|
|
275
1101
|
}
|
|
1102
|
+
catch (error) {
|
|
1103
|
+
if (options.rebuildRuntime?.signal?.aborted || error instanceof Error && error.name === 'AbortError'
|
|
1104
|
+
|| readSafeOperationError(error))
|
|
1105
|
+
throw error;
|
|
1106
|
+
const apply = unavailableApply('targetDiscoveryFailed', 'targetDiscovery');
|
|
1107
|
+
const code = error?.code;
|
|
1108
|
+
if (typeof code === 'string')
|
|
1109
|
+
apply.error = { stage: 'apply', code,
|
|
1110
|
+
message: code === 'operationPlanStale' ? 'Configuration apply inputs changed. Prepare a new Review.'
|
|
1111
|
+
: 'The existing outputs cannot be refreshed with the current authorization.' };
|
|
1112
|
+
return { configWrite: 'notStarted', overallState: 'partial', apply, otherProjectsMayRequireSync: true };
|
|
1113
|
+
}
|
|
1114
|
+
finally {
|
|
1115
|
+
if (prepared)
|
|
1116
|
+
await disposePluginConfigApply(prepared.plan);
|
|
1117
|
+
}
|
|
1118
|
+
} });
|
|
1119
|
+
}
|
|
1120
|
+
function throwSharedNativeApplyConfirmationRequired() {
|
|
1121
|
+
const error = new Error('sharedNativeConfigApplyConfirmationRequired: Applying this user config changes a shared native artifact. Re-run with --yes.');
|
|
1122
|
+
error.code = 'sharedNativeConfigApplyConfirmationRequired';
|
|
1123
|
+
throw error;
|
|
1124
|
+
}
|
|
1125
|
+
async function applyPluginConfigWriteUnlocked(options) {
|
|
1126
|
+
const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.plugin?.manifest.name ?? '');
|
|
1127
|
+
const identity = options.plugin?.sourceId ? { sourceId: options.plugin.sourceId,
|
|
1128
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity } : {};
|
|
1129
|
+
const requestedUpdates = options.request.updates ?? {};
|
|
1130
|
+
const removeKeys = uniqueInOrder(options.request.removeKeys ?? []);
|
|
1131
|
+
const duplicateKeys = removeKeys.filter((key) => Object.hasOwn(requestedUpdates, key));
|
|
1132
|
+
if (duplicateKeys.length)
|
|
1133
|
+
throw new Error(`Config write cannot update and remove the same key: ${duplicateKeys.join(', ')}.`);
|
|
1134
|
+
const schemaAccess = await resolvePluginConfigSchemaAccess({ pluginName, currentPlugin: options.plugin,
|
|
1135
|
+
currentPluginError: options.pluginError, scope: options.scope, platform: options.platform, cwd: options.cwd, env: options.env });
|
|
1136
|
+
const plugin = schemaAccess.plugin;
|
|
1137
|
+
const definition = plugin?.manifest.config ? selectPluginConfigProfile(plugin.manifest.config, options.platform) : undefined;
|
|
1138
|
+
if (!plugin || !definition)
|
|
1139
|
+
throw new PluginConfigSchemaResolutionError('configSchemaUnavailable', `Plugin "${pluginName}" does not declare an AW config schema.`);
|
|
1140
|
+
const updates = await coercePluginConfigUpdates({ schema: definition.fields, updates: requestedUpdates, cwd: options.cwd });
|
|
1141
|
+
const impact = await analyzePluginConfigMutationImpact({ plugin, scope: options.scope, platform: options.platform,
|
|
1142
|
+
cwd: options.cwd, env: options.env, visibleTargets: [], commandDiscovery: { packages: [], errors: [] },
|
|
1143
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins, mutation: { kind: 'patch', updates, removeKeys } });
|
|
1144
|
+
await assertPluginConfigMutationCandidate({ ...identity, pluginName, manifest: plugin.manifest,
|
|
1145
|
+
scope: options.scope, platform: options.platform, cwd: options.cwd, env: options.env, updates, removeKeys,
|
|
1146
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins });
|
|
1147
|
+
if (impact.referenceBlockers?.length)
|
|
1148
|
+
throw Object.assign(new Error(`configReferenceInUse: ${impact.referenceBlockers.join(' ')}`), { code: 'configReferenceInUse' });
|
|
1149
|
+
if (impact.storeChanged) {
|
|
1150
|
+
try {
|
|
1151
|
+
await patchPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
|
|
1152
|
+
cwd: options.cwd, env: options.env, updates: Object.fromEntries(impact.updatedKeys.map((key) => [key, updates[key]])), removeKeys });
|
|
1153
|
+
}
|
|
1154
|
+
catch (error) {
|
|
1155
|
+
throw markConfigWriteFailed(error);
|
|
276
1156
|
}
|
|
277
1157
|
}
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
env: options.env,
|
|
285
|
-
});
|
|
286
|
-
const warnings = [];
|
|
287
|
-
if (options.scope === 'project' && projectLayer === 'shared') {
|
|
288
|
-
await assertProjectSharedConfigPathVisible({ cwd: options.cwd, targetPath: store.path });
|
|
1158
|
+
const warnings = [...impact.referenceWarnings ?? []];
|
|
1159
|
+
let effective;
|
|
1160
|
+
try {
|
|
1161
|
+
effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({ ...identity, pluginName,
|
|
1162
|
+
manifest: plugin.manifest, platform: options.platform, targetScope: options.scope, cwd: options.cwd, env: options.env,
|
|
1163
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins }));
|
|
289
1164
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (ignore.warning)
|
|
293
|
-
warnings.push(ignore.warning);
|
|
1165
|
+
catch {
|
|
1166
|
+
warnings.push('The saved configuration cannot be previewed. Check its schema and reference sources before applying it.');
|
|
294
1167
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
1168
|
+
if (impact.storeChanged)
|
|
1169
|
+
warnings.push(...otherProjectsWarning('user'));
|
|
1170
|
+
return { plugin: pluginName, scope: 'user', context: options.scope, platform: options.platform,
|
|
1171
|
+
...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}), updatedKeys: impact.updatedKeys,
|
|
1172
|
+
removedKeys: impact.removedKeys, staleRemovedKeys: impact.staleRemovedKeys, effective,
|
|
1173
|
+
configWrite: 'succeeded', overallState: 'succeeded',
|
|
1174
|
+
apply: skippedApply(impact.storeChanged ? 'notRequested' : 'noConfigChange'),
|
|
1175
|
+
otherProjectsMayRequireSync: impact.storeChanged, warnings };
|
|
1176
|
+
}
|
|
1177
|
+
async function prepareConfigMutationApplySelection(options) {
|
|
1178
|
+
if (options.apply !== true || !options.plugin)
|
|
1179
|
+
return undefined;
|
|
1180
|
+
let prepared;
|
|
1181
|
+
try {
|
|
1182
|
+
prepared = await preparePluginConfigApply({ ...options, plugin: options.plugin });
|
|
1183
|
+
const requestedTargets = configApplyRequestedTargets(prepared.plan);
|
|
1184
|
+
if (requestedTargets.some((target) => target.agent === 'generic'))
|
|
1185
|
+
return undefined;
|
|
1186
|
+
const visibleTargets = requestedTargets.map((target) => ({
|
|
1187
|
+
pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId,
|
|
1188
|
+
platform: target.agent, scope: target.scope,
|
|
1189
|
+
}));
|
|
1190
|
+
if (!visibleTargets.length && !prepared.commandPackages.length && !prepared.commandDiscoveryErrors.length) {
|
|
1191
|
+
if (prepared.plan.blockExecution || prepared.plan.receipt.blockers.length || prepared.plan.receipt.errors.length)
|
|
1192
|
+
return undefined;
|
|
1193
|
+
return { skipReason: 'noVisibleTarget' };
|
|
308
1194
|
}
|
|
1195
|
+
const impact = await analyzePluginConfigMutationImpact({ plugin: options.plugin, scope: options.context ?? options.scope,
|
|
1196
|
+
platform: options.platform, cwd: options.cwd, env: options.env, visibleTargets,
|
|
1197
|
+
commandDiscovery: { packages: prepared.commandPackages, errors: prepared.commandDiscoveryErrors },
|
|
1198
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins,
|
|
1199
|
+
mutation: 'request' in options ? { kind: 'patch', ...options.request } : { kind: 'reset' } });
|
|
1200
|
+
return { applyTargets: impact.affectedTargets,
|
|
1201
|
+
applyCommandPackages: impact.affectedCommandPackages.map((target) => target.packageId),
|
|
1202
|
+
...(impact.noEffectiveChange ? { skipReason: 'noEffectiveConfigChange' } : {}) };
|
|
309
1203
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
env: options.env,
|
|
318
|
-
updates,
|
|
319
|
-
removeKeys: requestedRemoveKeys,
|
|
320
|
-
});
|
|
1204
|
+
catch {
|
|
1205
|
+
// A failed output discovery must not prevent a valid configuration save.
|
|
1206
|
+
return undefined;
|
|
1207
|
+
}
|
|
1208
|
+
finally {
|
|
1209
|
+
if (prepared)
|
|
1210
|
+
await disposePluginConfigApply(prepared.plan);
|
|
321
1211
|
}
|
|
322
|
-
const effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
|
|
323
|
-
...configIdentity,
|
|
324
|
-
pluginName,
|
|
325
|
-
manifest: schemaPlugin.manifest,
|
|
326
|
-
cwd: options.cwd,
|
|
327
|
-
env: options.env,
|
|
328
|
-
}));
|
|
329
|
-
const applied = changedKeys.length === 0
|
|
330
|
-
? {
|
|
331
|
-
overallState: 'succeeded',
|
|
332
|
-
targetResults: [],
|
|
333
|
-
applySkippedReason: 'noConfigChange',
|
|
334
|
-
}
|
|
335
|
-
: await reinstallVisibleTargets({
|
|
336
|
-
plugin: schemaPlugin,
|
|
337
|
-
scope: options.scope,
|
|
338
|
-
cwd: options.cwd,
|
|
339
|
-
env: options.env ?? process.env,
|
|
340
|
-
applyTargets: options.applyTargets,
|
|
341
|
-
nativeCliRunner: options.nativeCliRunner,
|
|
342
|
-
reinstallCommandImpl: options.reinstallCommandImpl,
|
|
343
|
-
rebuildRuntime: options.rebuildRuntime,
|
|
344
|
-
});
|
|
345
|
-
const otherProjectsRequireReinstall = options.scope === 'user'
|
|
346
|
-
&& changedKeys.length > 0;
|
|
347
|
-
if (otherProjectsRequireReinstall)
|
|
348
|
-
warnings.push(...otherProjectsWarning(options.scope));
|
|
349
|
-
return {
|
|
350
|
-
plugin: pluginName,
|
|
351
|
-
scope: options.scope,
|
|
352
|
-
projectLayer,
|
|
353
|
-
...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
|
|
354
|
-
updatedKeys,
|
|
355
|
-
removedKeys,
|
|
356
|
-
effective,
|
|
357
|
-
configWrite: 'succeeded',
|
|
358
|
-
overallState: applied.overallState,
|
|
359
|
-
targetResults: applied.targetResults,
|
|
360
|
-
...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
|
|
361
|
-
otherProjectsRequireReinstall,
|
|
362
|
-
warnings,
|
|
363
|
-
};
|
|
364
1212
|
}
|
|
365
1213
|
export async function applyPluginConfigWrite(options) {
|
|
1214
|
+
if (options.context)
|
|
1215
|
+
await resolveWorkContext({ cwd: options.cwd, context: options.context });
|
|
366
1216
|
const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
|
|
367
1217
|
if (!requestedPluginName)
|
|
368
1218
|
throw new Error('Plugin name is required for config write.');
|
|
@@ -372,139 +1222,181 @@ export async function applyPluginConfigWrite(options) {
|
|
|
372
1222
|
token: options.awHomeMutationToken,
|
|
373
1223
|
action: async (awHomeMutationToken) => {
|
|
374
1224
|
await options.reviewPreflight?.();
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
awHomeMutationToken
|
|
378
|
-
|
|
379
|
-
|
|
1225
|
+
let configCommitted = false;
|
|
1226
|
+
try {
|
|
1227
|
+
const selection = await prepareConfigMutationApplySelection({ ...options, awHomeMutationToken });
|
|
1228
|
+
const saved = await applyPluginConfigWriteUnlocked({ ...options, scope: options.context ?? options.scope,
|
|
1229
|
+
apply: false, awHomeMutationToken, rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken } });
|
|
1230
|
+
configCommitted = true;
|
|
1231
|
+
if (options.apply !== true || !options.plugin)
|
|
1232
|
+
return saved;
|
|
1233
|
+
if (saved.apply.state === 'skipped' && saved.apply.reason === 'noConfigChange')
|
|
1234
|
+
return saved;
|
|
1235
|
+
if (selection?.skipReason)
|
|
1236
|
+
return { ...saved, apply: skippedApply(selection.skipReason) };
|
|
1237
|
+
const applied = await applyPluginConfig({ ...options, ...selection, plugin: options.plugin, awHomeMutationToken });
|
|
1238
|
+
return { ...saved, overallState: applied.overallState, apply: applied.apply };
|
|
1239
|
+
}
|
|
1240
|
+
catch (error) {
|
|
1241
|
+
let sensitiveValues = options.plugin
|
|
1242
|
+
? collectSensitivePluginConfigValues(options.plugin.manifest, (options.request.updates ?? {}), options.platform)
|
|
1243
|
+
: [];
|
|
1244
|
+
if (options.plugin) {
|
|
1245
|
+
try {
|
|
1246
|
+
const effective = await resolveEffectivePluginConfig({
|
|
1247
|
+
...(options.plugin.sourceId ? {
|
|
1248
|
+
sourceId: options.plugin.sourceId,
|
|
1249
|
+
sourceIdentity: options.plugin.sourceIdentity,
|
|
1250
|
+
logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
1251
|
+
} : {}),
|
|
1252
|
+
pluginName: options.plugin.manifest.name,
|
|
1253
|
+
manifest: options.plugin.manifest,
|
|
1254
|
+
referencePlugins: options.rebuildRuntime?.referencePlugins,
|
|
1255
|
+
targetScope: options.scope,
|
|
1256
|
+
platform: options.platform,
|
|
1257
|
+
cwd: options.cwd,
|
|
1258
|
+
env: options.env,
|
|
1259
|
+
});
|
|
1260
|
+
sensitiveValues = [
|
|
1261
|
+
...sensitiveValues,
|
|
1262
|
+
...collectSensitivePluginConfigValues(options.plugin.manifest, effective.values, options.platform),
|
|
1263
|
+
];
|
|
1264
|
+
}
|
|
1265
|
+
catch {
|
|
1266
|
+
// Requested sensitive values and generic credential redaction remain available.
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
let message = redactPluginScriptOutput(error instanceof Error ? error.message : String(error), sensitiveValues);
|
|
1270
|
+
message = message.split(options.cwd).join('<project>');
|
|
1271
|
+
for (const scope of ['user', 'project']) {
|
|
1272
|
+
const configPath = resolvePluginConfigStorePath({
|
|
1273
|
+
sourceId: options.plugin?.sourceId,
|
|
1274
|
+
pluginName: requestedPluginName,
|
|
1275
|
+
scope,
|
|
1276
|
+
cwd: options.cwd,
|
|
1277
|
+
env: options.env,
|
|
1278
|
+
});
|
|
1279
|
+
message = message.split(configPath).join(`${scope}/plugin-config/${[
|
|
1280
|
+
options.plugin?.sourceId,
|
|
1281
|
+
requestedPluginName,
|
|
1282
|
+
'config.json',
|
|
1283
|
+
].filter(Boolean).join('/')}`);
|
|
1284
|
+
}
|
|
1285
|
+
const safeError = new Error(message);
|
|
1286
|
+
const code = error.code;
|
|
1287
|
+
safeError.code = typeof code === 'string' ? code
|
|
1288
|
+
: message.startsWith('schemaVersionUnsupported:') ? 'schemaVersionUnsupported'
|
|
1289
|
+
: 'configApplyFailed';
|
|
1290
|
+
const configWrite = error.configWrite;
|
|
1291
|
+
if (configCommitted || configWrite === 'succeeded' || configWriteStateForError(error) === 'failed') {
|
|
1292
|
+
safeError.configWrite = configCommitted || configWrite === 'succeeded' ? 'succeeded' : 'failed';
|
|
1293
|
+
}
|
|
1294
|
+
if (error && typeof error === 'object' && 'operationDiagnostic' in error) {
|
|
1295
|
+
safeError.operationDiagnostic = error.operationDiagnostic;
|
|
1296
|
+
}
|
|
1297
|
+
throw safeError;
|
|
1298
|
+
}
|
|
380
1299
|
},
|
|
381
1300
|
});
|
|
382
1301
|
}
|
|
383
1302
|
async function resetPluginConfigWithHelperUnlocked(options) {
|
|
384
1303
|
const pluginName = assertSafePluginConfigSegment(options.pluginName);
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
1304
|
+
let identity = options.plugin?.sourceId ? { sourceId: options.plugin.sourceId,
|
|
1305
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity }
|
|
1306
|
+
: { sourceId: options.sourceId, sourceIdentity: options.sourceIdentity, logicalIdentity: options.logicalIdentity };
|
|
1307
|
+
if (identity.sourceId && !identity.sourceIdentity) {
|
|
1308
|
+
try {
|
|
1309
|
+
const stored = await readNamespacedPluginConfigStoreIdentity({ sourceId: identity.sourceId, pluginName,
|
|
1310
|
+
scope: 'user', platform: options.platform, cwd: options.cwd, env: options.env });
|
|
1311
|
+
if (stored)
|
|
1312
|
+
identity = { ...identity, sourceIdentity: stored.binding.sourceIdentity };
|
|
1313
|
+
}
|
|
1314
|
+
catch { /* Reset remains available for unreadable identity metadata. */ }
|
|
388
1315
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
cwd: options.cwd,
|
|
395
|
-
env: options.env,
|
|
396
|
-
});
|
|
397
|
-
if (!schemaAccess.plugin?.manifest.config?.schema) {
|
|
398
|
-
throw new Error(`configSchemaUnavailable: Plugin "${pluginName}" does not declare an AW config schema.`);
|
|
1316
|
+
let removedKeys = [];
|
|
1317
|
+
try {
|
|
1318
|
+
const store = await readPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
|
|
1319
|
+
cwd: options.cwd, env: options.env });
|
|
1320
|
+
removedKeys = collectRemovedConfigKeys(store.values);
|
|
399
1321
|
}
|
|
400
|
-
|
|
401
|
-
sourceId: options.plugin.sourceId,
|
|
402
|
-
sourceIdentity: options.plugin.sourceIdentity,
|
|
403
|
-
} : {};
|
|
404
|
-
const store = await readPluginConfigStore({
|
|
405
|
-
...configIdentity,
|
|
406
|
-
pluginName,
|
|
407
|
-
scope: options.scope,
|
|
408
|
-
projectLayer,
|
|
409
|
-
cwd: options.cwd,
|
|
410
|
-
env: options.env,
|
|
411
|
-
});
|
|
412
|
-
const removedKeys = collectRemovedConfigKeys(store.values);
|
|
1322
|
+
catch { /* Broken stores still have the path-based reset boundary. */ }
|
|
413
1323
|
const warnings = [];
|
|
414
|
-
if (options.
|
|
415
|
-
|
|
1324
|
+
if (options.plugin) {
|
|
1325
|
+
try {
|
|
1326
|
+
const impact = await analyzePluginConfigMutationImpact({ plugin: options.plugin, scope: options.scope,
|
|
1327
|
+
platform: options.platform, cwd: options.cwd, env: options.env, visibleTargets: [],
|
|
1328
|
+
commandDiscovery: { packages: [], errors: [] }, referencePlugins: options.rebuildRuntime?.referencePlugins,
|
|
1329
|
+
mutation: { kind: 'reset' } });
|
|
1330
|
+
warnings.push(...impact.referenceWarnings ?? [], ...impact.referenceBlockers ?? []);
|
|
1331
|
+
}
|
|
1332
|
+
catch {
|
|
1333
|
+
warnings.push('Configuration references could not be checked. Reset will still clear the selected layer.');
|
|
1334
|
+
}
|
|
416
1335
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
1336
|
+
let reset;
|
|
1337
|
+
try {
|
|
1338
|
+
reset = await resetPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
|
|
1339
|
+
cwd: options.cwd, env: options.env });
|
|
1340
|
+
}
|
|
1341
|
+
catch (error) {
|
|
1342
|
+
throw markConfigWriteFailed(error);
|
|
421
1343
|
}
|
|
422
|
-
const reset = await resetPluginConfigStore({
|
|
423
|
-
...configIdentity,
|
|
424
|
-
pluginName,
|
|
425
|
-
scope: options.scope,
|
|
426
|
-
projectLayer,
|
|
427
|
-
cwd: options.cwd,
|
|
428
|
-
env: options.env,
|
|
429
|
-
});
|
|
430
|
-
let applied = {
|
|
431
|
-
overallState: 'succeeded',
|
|
432
|
-
targetResults: [],
|
|
433
|
-
applySkippedReason: 'noConfigChange',
|
|
434
|
-
};
|
|
435
1344
|
let effective;
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
cwd: options.cwd,
|
|
443
|
-
env: options.env,
|
|
444
|
-
}));
|
|
1345
|
+
let schema;
|
|
1346
|
+
if (options.plugin) {
|
|
1347
|
+
try {
|
|
1348
|
+
schema = (await resolvePluginConfigSchemaAccess({ pluginName, currentPlugin: options.plugin,
|
|
1349
|
+
scope: options.scope, platform: options.platform, cwd: options.cwd, env: options.env })).schema;
|
|
1350
|
+
effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({ ...identity, pluginName,
|
|
1351
|
+
manifest: options.plugin.manifest, platform: options.platform, targetScope: options.scope, cwd: options.cwd,
|
|
1352
|
+
env: options.env, referencePlugins: options.rebuildRuntime?.referencePlugins }));
|
|
445
1353
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
plugin: schemaAccess.plugin,
|
|
449
|
-
scope: options.scope,
|
|
450
|
-
cwd: options.cwd,
|
|
451
|
-
env: options.env ?? process.env,
|
|
452
|
-
applyTargets: options.applyTargets,
|
|
453
|
-
nativeCliRunner: options.nativeCliRunner,
|
|
454
|
-
reinstallCommandImpl: options.reinstallCommandImpl,
|
|
455
|
-
rebuildRuntime: options.rebuildRuntime,
|
|
456
|
-
});
|
|
1354
|
+
catch {
|
|
1355
|
+
warnings.push('The cleared configuration cannot be previewed. Check its schema and references before applying it.');
|
|
457
1356
|
}
|
|
458
1357
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
scope: options.scope,
|
|
467
|
-
projectLayer,
|
|
468
|
-
...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
|
|
469
|
-
existed: reset.existed,
|
|
470
|
-
deleted: reset.deleted,
|
|
471
|
-
removedKeys,
|
|
472
|
-
...(effective ? { effective } : {}),
|
|
473
|
-
configWrite: 'succeeded',
|
|
474
|
-
overallState: applied.overallState,
|
|
475
|
-
targetResults: applied.targetResults,
|
|
476
|
-
...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
|
|
477
|
-
otherProjectsRequireReinstall,
|
|
478
|
-
warnings,
|
|
479
|
-
};
|
|
1358
|
+
if (reset.existed)
|
|
1359
|
+
warnings.push(...otherProjectsWarning('user'));
|
|
1360
|
+
return { plugin: pluginName, scope: 'user', context: options.scope, platform: options.platform, schema,
|
|
1361
|
+
existed: reset.existed, deleted: reset.deleted, resetDisposition: reset.resetDisposition,
|
|
1362
|
+
...(reset.quarantineBasename ? { quarantineBasename: reset.quarantineBasename } : {}), removedKeys, effective,
|
|
1363
|
+
configWrite: 'succeeded', overallState: 'succeeded', apply: skippedApply(reset.existed ? 'notRequested' : 'noConfigChange'),
|
|
1364
|
+
otherProjectsMayRequireSync: reset.existed, warnings };
|
|
480
1365
|
}
|
|
481
1366
|
export async function resetPluginConfigWithHelper(options) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
1367
|
+
if (options.context)
|
|
1368
|
+
await resolveWorkContext({ cwd: options.cwd, context: options.context });
|
|
1369
|
+
assertSafePluginConfigSegment(options.pluginName);
|
|
486
1370
|
return withAwHomeMutationLock({
|
|
487
1371
|
env: options.env,
|
|
488
1372
|
token: options.awHomeMutationToken,
|
|
489
1373
|
action: async (awHomeMutationToken) => {
|
|
490
1374
|
await options.reviewPreflight?.();
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
awHomeMutationToken,
|
|
494
|
-
|
|
495
|
-
|
|
1375
|
+
const selection = await prepareConfigMutationApplySelection({ ...options, awHomeMutationToken });
|
|
1376
|
+
const saved = await resetPluginConfigWithHelperUnlocked({ ...options, scope: options.context ?? options.scope,
|
|
1377
|
+
apply: false, awHomeMutationToken, rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken } });
|
|
1378
|
+
if (options.apply !== true)
|
|
1379
|
+
return saved;
|
|
1380
|
+
if (!options.plugin)
|
|
1381
|
+
return { ...saved, overallState: 'partial', apply: unavailableApply('sourceUnavailable', 'source') };
|
|
1382
|
+
if (saved.apply.state === 'skipped' && saved.apply.reason === 'noConfigChange')
|
|
1383
|
+
return saved;
|
|
1384
|
+
if (selection?.skipReason)
|
|
1385
|
+
return { ...saved, apply: skippedApply(selection.skipReason) };
|
|
1386
|
+
const applied = await applyPluginConfig({ ...options, ...selection, plugin: options.plugin, awHomeMutationToken });
|
|
1387
|
+
return { ...saved, overallState: applied.overallState, apply: applied.apply };
|
|
496
1388
|
},
|
|
497
1389
|
});
|
|
498
1390
|
}
|
|
499
1391
|
export async function describeResetAffectedFields(options) {
|
|
500
|
-
const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
|
|
501
1392
|
try {
|
|
502
1393
|
const resolved = await resolveConfigRead({
|
|
503
1394
|
pluginName: options.pluginName,
|
|
504
1395
|
plugin: options.plugin,
|
|
505
1396
|
...(options.pluginError ? { pluginError: options.pluginError } : {}),
|
|
506
1397
|
scope: options.scope,
|
|
507
|
-
|
|
1398
|
+
context: options.context,
|
|
1399
|
+
platform: options.platform,
|
|
508
1400
|
cwd: options.cwd,
|
|
509
1401
|
env: options.env,
|
|
510
1402
|
});
|
|
@@ -514,8 +1406,8 @@ export async function describeResetAffectedFields(options) {
|
|
|
514
1406
|
kind: field.kind,
|
|
515
1407
|
reserved: field.reserved,
|
|
516
1408
|
action: 'reset',
|
|
517
|
-
scope:
|
|
518
|
-
|
|
1409
|
+
scope: 'user',
|
|
1410
|
+
platform: options.platform,
|
|
519
1411
|
valueState: field.valueState,
|
|
520
1412
|
}));
|
|
521
1413
|
}
|
|
@@ -524,13 +1416,15 @@ export async function describeResetAffectedFields(options) {
|
|
|
524
1416
|
...(options.plugin?.sourceId ? {
|
|
525
1417
|
sourceId: options.plugin.sourceId,
|
|
526
1418
|
sourceIdentity: options.plugin.sourceIdentity,
|
|
1419
|
+
logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
527
1420
|
} : options.sourceId ? {
|
|
528
1421
|
sourceId: options.sourceId,
|
|
529
1422
|
sourceIdentity: options.sourceIdentity,
|
|
1423
|
+
logicalIdentity: options.logicalIdentity,
|
|
530
1424
|
} : {}),
|
|
531
1425
|
pluginName: options.pluginName,
|
|
532
|
-
scope:
|
|
533
|
-
|
|
1426
|
+
scope: 'user',
|
|
1427
|
+
platform: options.platform,
|
|
534
1428
|
cwd: options.cwd,
|
|
535
1429
|
env: options.env,
|
|
536
1430
|
});
|
|
@@ -540,8 +1434,8 @@ export async function describeResetAffectedFields(options) {
|
|
|
540
1434
|
kind: 'manifest',
|
|
541
1435
|
reserved: false,
|
|
542
1436
|
action: 'reset',
|
|
543
|
-
scope:
|
|
544
|
-
|
|
1437
|
+
scope: 'user',
|
|
1438
|
+
platform: options.platform,
|
|
545
1439
|
}));
|
|
546
1440
|
}
|
|
547
1441
|
}
|