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