@lesliechan721/aw 0.1.0-beta.8 → 0.1.0-beta.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-config.mjs +100 -501
- package/dist/authoring/assets/aw-config.mjs.map +1 -1
- package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
- package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.mjs +17 -40
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +74 -98
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +79 -92
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +103 -127
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs +2 -2
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +490 -2841
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-skill.mjs +1 -1
- package/dist/native-runtime/reader-runtime.mjs +34 -0
- package/dist/native-runtime/reader.d.mts +6 -0
- package/dist/native-runtime/reader.mjs +11 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +30 -0
- package/dist/scripts/aw-skill-eval-materializer.js +278 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +1 -0
- package/dist/scripts/bundle-plugins.js +27 -8
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +7 -8
- package/dist/scripts/plugin-staging.js +16 -15
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/plugin-test-reporter.d.mts +2 -0
- package/dist/scripts/plugin-test-reporter.mjs +21 -0
- package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +5 -0
- package/dist/scripts/test-plugin-scripts.js +273 -78
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/scripts/test-workers.d.mts +24 -0
- package/dist/scripts/test-workers.mjs +59 -0
- package/dist/scripts/test-workers.mjs.map +1 -0
- package/dist/src/adapters/helpers.d.ts +7 -0
- package/dist/src/adapters/helpers.js.map +1 -1
- package/dist/src/authoring/workspace-commands.d.ts +5 -1
- package/dist/src/authoring/workspace-commands.js +7 -2
- package/dist/src/authoring/workspace-commands.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +2 -2
- package/dist/src/commands/aw-capabilities.js +41 -29
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/catalog-dev-source.d.ts +58 -13
- package/dist/src/commands/catalog-dev-source.js +549 -305
- package/dist/src/commands/catalog-dev-source.js.map +1 -1
- package/dist/src/commands/catalog-generation.d.ts +14 -19
- package/dist/src/commands/catalog-generation.js +5 -10
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/catalog-publication-inspection.d.ts +70 -30
- package/dist/src/commands/catalog-publication-inspection.js +511 -91
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
- package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
- package/dist/src/commands/catalog-publication-journal.js +292 -0
- package/dist/src/commands/catalog-publication-journal.js.map +1 -0
- package/dist/src/commands/catalog-publication-target.d.ts +2 -1
- package/dist/src/commands/catalog-publication-target.js +37 -2
- package/dist/src/commands/catalog-publication-target.js.map +1 -1
- package/dist/src/commands/catalog-publish.d.ts +82 -15
- package/dist/src/commands/catalog-publish.js +722 -219
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +55 -35
- package/dist/src/commands/catalog-source.js +298 -148
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-status.d.ts +6 -26
- package/dist/src/commands/catalog-status.js +9 -147
- package/dist/src/commands/catalog-status.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +104 -0
- package/dist/src/commands/catalog-store.js +685 -0
- package/dist/src/commands/catalog-store.js.map +1 -0
- package/dist/src/commands/catalog-workspace-resolution.d.ts +17 -0
- package/dist/src/commands/catalog-workspace-resolution.js +57 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.js +32 -20
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
- package/dist/src/commands/dependency-operation-plan.js +289 -7
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.d.ts +4 -0
- package/dist/src/commands/deployment-confirmation.js +20 -0
- package/dist/src/commands/deployment-confirmation.js.map +1 -0
- package/dist/src/commands/init.d.ts +5 -11
- package/dist/src/commands/init.js +30 -51
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +32 -0
- package/dist/src/commands/intent-command.js +171 -0
- package/dist/src/commands/intent-command.js.map +1 -0
- package/dist/src/commands/managed-commands.d.ts +35 -0
- package/dist/src/commands/managed-commands.js +361 -0
- package/dist/src/commands/managed-commands.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +46 -0
- package/dist/src/commands/offline-cleanup-evidence.js +158 -10
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +190 -0
- package/dist/src/commands/operation-plan.js +99 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +47 -0
- package/dist/src/commands/operation-planner.js +142 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +16 -20
- package/dist/src/commands/options.js +94 -41
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +88 -45
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +8 -0
- package/dist/src/commands/public-config-confirmation.js +56 -0
- package/dist/src/commands/public-config-confirmation.js.map +1 -0
- package/dist/src/commands/public-interruption.d.ts +9 -0
- package/dist/src/commands/public-interruption.js +23 -0
- package/dist/src/commands/public-interruption.js.map +1 -0
- package/dist/src/commands/public-lifecycle-result.d.ts +102 -0
- package/dist/src/commands/public-lifecycle-result.js +307 -0
- package/dist/src/commands/public-lifecycle-result.js.map +1 -0
- package/dist/src/commands/public-lifecycle.d.ts +28 -0
- package/dist/src/commands/public-lifecycle.js +492 -0
- package/dist/src/commands/public-lifecycle.js.map +1 -0
- package/dist/src/commands/public-plugin-query.d.ts +16 -0
- package/dist/src/commands/public-plugin-query.js +193 -0
- package/dist/src/commands/public-plugin-query.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +166 -28
- package/dist/src/commands/rebuild-command.js +3745 -813
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +137 -25
- package/dist/src/commands/rebuild-integration.js +1343 -2535
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +73 -22
- package/dist/src/commands/rebuild-operations.js +313 -216
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +62 -0
- package/dist/src/commands/rebuild-platform-integration.js +1317 -0
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
- package/dist/src/commands/reconcile-operation-plan.js +47 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-inspection.d.ts +60 -0
- package/dist/src/commands/review-inspection.js +436 -0
- package/dist/src/commands/review-inspection.js.map +1 -0
- package/dist/src/commands/review-preparation.d.ts +51 -0
- package/dist/src/commands/review-preparation.js +400 -0
- package/dist/src/commands/review-preparation.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +6 -6
- package/dist/src/commands/runtime.js +44 -24
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +41 -0
- package/dist/src/commands/skill-eval.js +407 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +319 -0
- package/dist/src/commands/status-v6.js +2979 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/targets-command.d.ts +38 -0
- package/dist/src/commands/targets-command.js +182 -0
- package/dist/src/commands/targets-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +8 -5
- package/dist/src/commands/wizard.js +7 -4
- package/dist/src/commands/wizard.js.map +1 -1
- package/dist/src/commands/write-commands.d.ts +9 -3
- package/dist/src/commands/write-commands.js +143 -85
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +6 -6
- package/dist/src/constants.js +6 -6
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +70 -0
- package/dist/src/eval/manifest-v1.js +358 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +7 -2
- package/dist/src/generators/local-plugin.js +313 -389
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +5 -2
- package/dist/src/generators/permissions.js +28 -15
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +2 -31
- package/dist/src/index.js +1666 -1827
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.d.ts +63 -0
- package/dist/src/intent/deployment-preferences.js +170 -0
- package/dist/src/intent/deployment-preferences.js.map +1 -0
- package/dist/src/intent/diagnostics.d.ts +11 -0
- package/dist/src/intent/diagnostics.js +14 -0
- package/dist/src/intent/diagnostics.js.map +1 -0
- package/dist/src/intent/intent-codec.d.ts +19 -0
- package/dist/src/intent/intent-codec.js +117 -0
- package/dist/src/intent/intent-codec.js.map +1 -0
- package/dist/src/intent/intent-store.d.ts +43 -0
- package/dist/src/intent/intent-store.js +118 -0
- package/dist/src/intent/intent-store.js.map +1 -0
- package/dist/src/intent/scope-context.d.ts +33 -0
- package/dist/src/intent/scope-context.js +149 -0
- package/dist/src/intent/scope-context.js.map +1 -0
- package/dist/src/intent/work-context.d.ts +13 -0
- package/dist/src/intent/work-context.js +22 -0
- package/dist/src/intent/work-context.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +47 -46
- package/dist/src/output/command-receipt.js +286 -79
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/model.d.ts +3 -11
- package/dist/src/output/native-consent.d.ts +2 -0
- package/dist/src/output/native-consent.js +5 -0
- package/dist/src/output/native-consent.js.map +1 -0
- package/dist/src/output/public-result.d.ts +49 -0
- package/dist/src/output/public-result.js +240 -0
- package/dist/src/output/public-result.js.map +1 -0
- package/dist/src/output/rebuild-progress.js +20 -15
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.d.ts +7 -0
- package/dist/src/output/receipt-projection.js +592 -0
- package/dist/src/output/receipt-projection.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +12 -0
- package/dist/src/platforms/capabilities.js +205 -0
- package/dist/src/platforms/capabilities.js.map +1 -0
- package/dist/src/platforms/contracts.d.ts +358 -0
- package/dist/src/platforms/contracts.js +2 -0
- package/dist/src/platforms/contracts.js.map +1 -0
- package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
- package/dist/src/platforms/cursor-workspace-hook.js +198 -0
- package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
- package/dist/src/platforms/discovery.d.ts +91 -0
- package/dist/src/platforms/discovery.js +653 -0
- package/dist/src/platforms/discovery.js.map +1 -0
- package/dist/src/platforms/gemini-activation.d.ts +36 -0
- package/dist/src/platforms/gemini-activation.js +331 -0
- package/dist/src/platforms/gemini-activation.js.map +1 -0
- package/dist/src/platforms/gemini-consent.d.ts +8 -0
- package/dist/src/platforms/gemini-consent.js +81 -0
- package/dist/src/platforms/gemini-consent.js.map +1 -0
- package/dist/src/platforms/identity.d.ts +4 -0
- package/dist/src/platforms/identity.js +22 -0
- package/dist/src/platforms/identity.js.map +1 -0
- package/dist/src/platforms/inspection-grok.d.ts +4 -0
- package/dist/src/platforms/inspection-grok.js +212 -0
- package/dist/src/platforms/inspection-grok.js.map +1 -0
- package/dist/src/platforms/inspection-native.d.ts +6 -0
- package/dist/src/platforms/inspection-native.js +406 -0
- package/dist/src/platforms/inspection-native.js.map +1 -0
- package/dist/src/platforms/inspection-opencode.d.ts +4 -0
- package/dist/src/platforms/inspection-opencode.js +98 -0
- package/dist/src/platforms/inspection-opencode.js.map +1 -0
- package/dist/src/platforms/inspection-pi.d.ts +3 -0
- package/dist/src/platforms/inspection-pi.js +282 -0
- package/dist/src/platforms/inspection-pi.js.map +1 -0
- package/dist/src/platforms/inspection-query.d.ts +12 -0
- package/dist/src/platforms/inspection-query.js +96 -0
- package/dist/src/platforms/inspection-query.js.map +1 -0
- package/dist/src/platforms/inspection.d.ts +17 -0
- package/dist/src/platforms/inspection.js +227 -0
- package/dist/src/platforms/inspection.js.map +1 -0
- package/dist/src/platforms/layout.d.ts +21 -0
- package/dist/src/platforms/layout.js +239 -0
- package/dist/src/platforms/layout.js.map +1 -0
- package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
- package/dist/src/platforms/lifecycle-native-services.js +147 -0
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
- package/dist/src/platforms/lifecycle-native.d.ts +13 -0
- package/dist/src/platforms/lifecycle-native.js +283 -0
- package/dist/src/platforms/lifecycle-native.js.map +1 -0
- package/dist/src/platforms/lifecycle.d.ts +25 -0
- package/dist/src/platforms/lifecycle.js +494 -0
- package/dist/src/platforms/lifecycle.js.map +1 -0
- package/dist/src/platforms/managed-command-placement.d.ts +8 -0
- package/dist/src/platforms/managed-command-placement.js +79 -0
- package/dist/src/platforms/managed-command-placement.js.map +1 -0
- package/dist/src/platforms/projection-code-extension.d.ts +8 -0
- package/dist/src/platforms/projection-code-extension.js +121 -0
- package/dist/src/platforms/projection-code-extension.js.map +1 -0
- package/dist/src/platforms/projection-command-resources.d.ts +7 -0
- package/dist/src/platforms/projection-command-resources.js +74 -0
- package/dist/src/platforms/projection-command-resources.js.map +1 -0
- package/dist/src/platforms/projection-files.d.ts +27 -0
- package/dist/src/platforms/projection-files.js +111 -0
- package/dist/src/platforms/projection-files.js.map +1 -0
- package/dist/src/platforms/projection-marketplace.d.ts +19 -0
- package/dist/src/platforms/projection-marketplace.js +42 -0
- package/dist/src/platforms/projection-marketplace.js.map +1 -0
- package/dist/src/platforms/projection.d.ts +10 -0
- package/dist/src/platforms/projection.js +446 -0
- package/dist/src/platforms/projection.js.map +1 -0
- package/dist/src/platforms/registry.d.ts +4 -0
- package/dist/src/platforms/registry.js +30 -0
- package/dist/src/platforms/registry.js.map +1 -0
- package/dist/src/platforms/supplement-layout.d.ts +16 -0
- package/dist/src/platforms/supplement-layout.js +31 -0
- package/dist/src/platforms/supplement-layout.js.map +1 -0
- package/dist/src/platforms/supplement-state.d.ts +13 -0
- package/dist/src/platforms/supplement-state.js +82 -0
- package/dist/src/platforms/supplement-state.js.map +1 -0
- package/dist/src/portable/commands.d.ts +58 -11
- package/dist/src/portable/commands.js +94 -350
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/historical-materialization.d.ts +22 -0
- package/dist/src/portable/historical-materialization.js +124 -0
- package/dist/src/portable/historical-materialization.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +24 -4
- package/dist/src/portable/materializer.js +189 -259
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery-layout.d.ts +17 -0
- package/dist/src/portable/recovery-layout.js +42 -0
- package/dist/src/portable/recovery-layout.js.map +1 -0
- package/dist/src/portable/recovery.d.ts +153 -0
- package/dist/src/portable/recovery.js +367 -0
- package/dist/src/portable/recovery.js.map +1 -0
- package/dist/src/portable/writer.d.ts +67 -0
- package/dist/src/portable/writer.js +321 -0
- package/dist/src/portable/writer.js.map +1 -0
- package/dist/src/recovery/coordinator.d.ts +141 -0
- package/dist/src/recovery/coordinator.js +1254 -0
- package/dist/src/recovery/coordinator.js.map +1 -0
- package/dist/src/recovery/demand.d.ts +51 -0
- package/dist/src/recovery/demand.js +159 -0
- package/dist/src/recovery/demand.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +25 -0
- package/dist/src/recovery/joint-coordinator.js +991 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -0
- package/dist/src/recovery/joint-demand.d.ts +50 -0
- package/dist/src/recovery/joint-demand.js +197 -0
- package/dist/src/recovery/joint-demand.js.map +1 -0
- package/dist/src/recovery/performance.d.ts +4 -0
- package/dist/src/recovery/performance.js +26 -0
- package/dist/src/recovery/performance.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +98 -0
- package/dist/src/recovery/receipt.js +2 -0
- package/dist/src/recovery/receipt.js.map +1 -0
- package/dist/src/recovery/retirement.d.ts +47 -0
- package/dist/src/recovery/retirement.js +469 -0
- package/dist/src/recovery/retirement.js.map +1 -0
- package/dist/src/recovery/status.d.ts +126 -0
- package/dist/src/recovery/status.js +1073 -0
- package/dist/src/recovery/status.js.map +1 -0
- package/dist/src/recovery/types.d.ts +85 -0
- package/dist/src/recovery/types.js +2 -0
- package/dist/src/recovery/types.js.map +1 -0
- package/dist/src/review/eval-source-input.d.ts +43 -0
- package/dist/src/review/eval-source-input.js +207 -0
- package/dist/src/review/eval-source-input.js.map +1 -0
- package/dist/src/review/platform-profile.d.ts +3 -0
- package/dist/src/review/platform-profile.js +14 -0
- package/dist/src/review/platform-profile.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +20 -0
- package/dist/src/review/review-profile.js +276 -0
- package/dist/src/review/review-profile.js.map +1 -0
- package/dist/src/review/review-selection.d.ts +20 -0
- package/dist/src/review/review-selection.js +495 -0
- package/dist/src/review/review-selection.js.map +1 -0
- package/dist/src/review/review-types.d.ts +71 -0
- package/dist/src/review/review-types.js +16 -0
- package/dist/src/review/review-types.js.map +1 -0
- package/dist/src/review/skill-materialization.d.ts +62 -0
- package/dist/src/review/skill-materialization.js +205 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +201 -0
- package/dist/src/review/source-binding.js +773 -0
- package/dist/src/review/source-binding.js.map +1 -0
- package/dist/src/tui/agent-management.d.ts +23 -0
- package/dist/src/tui/agent-management.js +319 -0
- package/dist/src/tui/agent-management.js.map +1 -0
- package/dist/src/tui/agent-settings.d.ts +47 -0
- package/dist/src/tui/agent-settings.js +97 -0
- package/dist/src/tui/agent-settings.js.map +1 -0
- package/dist/src/tui/catalog-freshness.d.ts +1 -0
- package/dist/src/tui/catalog-freshness.js +2 -0
- package/dist/src/tui/catalog-freshness.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +18 -53
- package/dist/src/tui/catalog-generation.js +136 -224
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
- package/dist/src/tui/catalog-sources/projection.js +17 -0
- package/dist/src/tui/catalog-sources/projection.js.map +1 -0
- package/dist/src/tui/catalog-sources/review.d.ts +3 -0
- package/dist/src/tui/catalog-sources/review.js +13 -0
- package/dist/src/tui/catalog-sources/review.js.map +1 -0
- package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
- package/dist/src/tui/catalog-sources/screens.js +40 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +32 -0
- package/dist/src/tui/catalog-sources/session.js +300 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +54 -0
- package/dist/src/tui/catalog-sources/types.js +2 -0
- package/dist/src/tui/catalog-sources/types.js.map +1 -0
- package/dist/src/tui/catalog-store-task.d.ts +16 -0
- package/dist/src/tui/catalog-store-task.js +19 -0
- package/dist/src/tui/catalog-store-task.js.map +1 -0
- package/dist/src/tui/clipboard.d.ts +13 -0
- package/dist/src/tui/clipboard.js +95 -0
- package/dist/src/tui/clipboard.js.map +1 -0
- package/dist/src/tui/components.d.ts +113 -3
- package/dist/src/tui/components.js +201 -36
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +29 -0
- package/dist/src/tui/config-array-draft.js +48 -0
- package/dist/src/tui/config-array-draft.js.map +1 -0
- package/dist/src/tui/config-leaf-editor.d.ts +43 -0
- package/dist/src/tui/config-leaf-editor.js +224 -0
- package/dist/src/tui/config-leaf-editor.js.map +1 -0
- package/dist/src/tui/config-references.d.ts +38 -0
- package/dist/src/tui/config-references.js +82 -0
- package/dist/src/tui/config-references.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +20 -0
- package/dist/src/tui/config-value-presentation.js +104 -0
- package/dist/src/tui/config-value-presentation.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +13 -4
- package/dist/src/tui/console-app-v4.js +9764 -2210
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.d.ts +13 -0
- package/dist/src/tui/content-item-card.js +51 -0
- package/dist/src/tui/content-item-card.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +7 -4
- package/dist/src/tui/controller-runtime.js +2064 -779
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +669 -106
- package/dist/src/tui/controller.js +3617 -971
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/dependency-graph-view.d.ts +39 -0
- package/dist/src/tui/dependency-graph-view.js +121 -0
- package/dist/src/tui/dependency-graph-view.js.map +1 -0
- package/dist/src/tui/dependency-graph.d.ts +81 -0
- package/dist/src/tui/dependency-graph.js +452 -0
- package/dist/src/tui/dependency-graph.js.map +1 -0
- package/dist/src/tui/deployment-view.d.ts +10 -0
- package/dist/src/tui/deployment-view.js +108 -0
- package/dist/src/tui/deployment-view.js.map +1 -0
- package/dist/src/tui/diagnostic-projection.d.ts +23 -0
- package/dist/src/tui/diagnostic-projection.js +595 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +6 -3
- package/dist/src/tui/diagnostics.js +14 -2
- package/dist/src/tui/diagnostics.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +55 -0
- package/dist/src/tui/entity-cards.js +298 -0
- package/dist/src/tui/entity-cards.js.map +1 -0
- package/dist/src/tui/glossary.d.ts +25 -0
- package/dist/src/tui/glossary.js +72 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/index.d.ts +6 -2
- package/dist/src/tui/index.js +5 -2
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/input-display.d.ts +1 -0
- package/dist/src/tui/input-display.js +23 -1
- package/dist/src/tui/input-display.js.map +1 -1
- package/dist/src/tui/keys.d.ts +44 -0
- package/dist/src/tui/keys.js +43 -15
- package/dist/src/tui/keys.js.map +1 -1
- package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
- package/dist/src/tui/lifecycle-action-view.js +36 -0
- package/dist/src/tui/lifecycle-action-view.js.map +1 -0
- package/dist/src/tui/model.d.ts +243 -45
- package/dist/src/tui/model.js +1402 -415
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
- package/dist/src/tui/operation-diagnostic-screens.js +72 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +82 -0
- package/dist/src/tui/operation-history.js +136 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +28 -0
- package/dist/src/tui/operation-review-planner.js +1396 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/plugin-content.d.ts +33 -0
- package/dist/src/tui/plugin-content.js +245 -0
- package/dist/src/tui/plugin-content.js.map +1 -0
- package/dist/src/tui/plugin-detail.d.ts +72 -0
- package/dist/src/tui/plugin-detail.js +260 -0
- package/dist/src/tui/plugin-detail.js.map +1 -0
- package/dist/src/tui/plugin-write-task.d.ts +69 -0
- package/dist/src/tui/plugin-write-task.js +286 -0
- package/dist/src/tui/plugin-write-task.js.map +1 -0
- package/dist/src/tui/prompt.js +4 -15
- package/dist/src/tui/prompt.js.map +1 -1
- package/dist/src/tui/query-header.d.ts +30 -0
- package/dist/src/tui/query-header.js +40 -0
- package/dist/src/tui/query-header.js.map +1 -0
- package/dist/src/tui/reader.d.ts +38 -0
- package/dist/src/tui/reader.js +49 -0
- package/dist/src/tui/reader.js.map +1 -0
- package/dist/src/tui/router.d.ts +186 -35
- package/dist/src/tui/router.js +338 -50
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +45 -0
- package/dist/src/tui/scoped-flow.js +96 -0
- package/dist/src/tui/scoped-flow.js.map +1 -0
- package/dist/src/tui/scoped-inventory.d.ts +126 -0
- package/dist/src/tui/scoped-inventory.js +258 -0
- package/dist/src/tui/scoped-inventory.js.map +1 -0
- package/dist/src/tui/screen-registry.d.ts +701 -0
- package/dist/src/tui/screen-registry.js +226 -0
- package/dist/src/tui/screen-registry.js.map +1 -0
- package/dist/src/tui/session-console-app.d.ts +6 -0
- package/dist/src/tui/session-console-app.js +13 -0
- package/dist/src/tui/session-console-app.js.map +1 -0
- package/dist/src/tui/session-host.d.ts +45 -0
- package/dist/src/tui/session-host.js +219 -0
- package/dist/src/tui/session-host.js.map +1 -0
- package/dist/src/tui/source-detail-card.d.ts +29 -0
- package/dist/src/tui/source-detail-card.js +45 -0
- package/dist/src/tui/source-detail-card.js.map +1 -0
- package/dist/src/tui/theme.d.ts +12 -0
- package/dist/src/tui/theme.js +12 -0
- package/dist/src/tui/theme.js.map +1 -1
- package/dist/src/tui/viewport.d.ts +1 -0
- package/dist/src/tui/viewport.js +23 -0
- package/dist/src/tui/viewport.js.map +1 -1
- package/dist/src/tui/wizard.js +37 -13
- package/dist/src/tui/wizard.js.map +1 -1
- package/dist/src/types.d.ts +220 -118
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +13 -4
- package/dist/src/utils/agent-version.js +27 -4
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +33 -7
- package/dist/src/utils/artifact-plan.js +115 -430
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +114 -83
- package/dist/src/utils/artifact-renderer.js +213 -364
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +44 -0
- package/dist/src/utils/artifact-request.js +80 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +6 -2
- package/dist/src/utils/artifact-sources.js +17 -0
- package/dist/src/utils/artifact-sources.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +57 -173
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
- package/dist/src/utils/catalog-capability-projection.js +14 -0
- package/dist/src/utils/catalog-capability-projection.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +2 -2
- package/dist/src/utils/catalog-digests.js +7 -18
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-generation-error.d.ts +5 -1
- package/dist/src/utils/catalog-generation-error.js +14 -0
- package/dist/src/utils/catalog-generation-error.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +36 -5
- package/dist/src/utils/catalog-generation-resolver.js +221 -77
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +159 -28
- package/dist/src/utils/catalog-generation-service.js +1186 -525
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.d.ts +9 -0
- package/dist/src/utils/catalog-generation-state.js +97 -106
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +38 -24
- package/dist/src/utils/catalog-generation-store.js +337 -272
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
- package/dist/src/utils/{catalog-manifest-v5.js → catalog-manifest-v7.js} +23 -35
- package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
- package/dist/src/utils/catalog-operation-context.d.ts +6 -14
- package/dist/src/utils/catalog-operation-context.js +69 -169
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-public-error.js +8 -4
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +7 -3
- package/dist/src/utils/catalog-runtime-projection.js +5 -40
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +2 -2
- package/dist/src/utils/catalog-source-impact.d.ts +21 -0
- package/dist/src/utils/catalog-source-impact.js +344 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +23 -2
- package/dist/src/utils/catalog-source-references.js +456 -382
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +14 -1
- package/dist/src/utils/catalog-sources.js +178 -18
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/codex-config.d.ts +2 -0
- package/dist/src/utils/codex-config.js +22 -1
- package/dist/src/utils/codex-config.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
- package/dist/src/utils/codex-executable-discovery.js +431 -0
- package/dist/src/utils/codex-executable-discovery.js.map +1 -0
- package/dist/src/utils/codex-manager.d.ts +47 -18
- package/dist/src/utils/codex-manager.js +88 -622
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
- package/dist/src/utils/codex-marketplace-path.js +45 -0
- package/dist/src/utils/codex-marketplace-path.js.map +1 -0
- package/dist/src/utils/codex-native-observation.d.ts +49 -0
- package/dist/src/utils/codex-native-observation.js +169 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -0
- package/dist/src/utils/codex-reconciler.d.ts +123 -0
- package/dist/src/utils/codex-reconciler.js +322 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +45 -0
- package/dist/src/utils/codex-shared-native.js +122 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +4 -3
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-skills-root.d.ts +4 -0
- package/dist/src/utils/codex-skills-root.js +25 -0
- package/dist/src/utils/codex-skills-root.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +49 -0
- package/dist/src/utils/codex-surface-analysis.js +220 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/component-command-preparation.d.ts +34 -0
- package/dist/src/utils/component-command-preparation.js +228 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -0
- package/dist/src/utils/component-resources.d.ts +51 -0
- package/dist/src/utils/component-resources.js +322 -0
- package/dist/src/utils/component-resources.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
- package/dist/src/utils/dynamic-skill-tree.js +32 -9
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +16 -0
- package/dist/src/utils/git-catalog-provider.js +167 -120
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +17 -12
- package/dist/src/utils/local-marketplace.js +85 -195
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-closure.d.ts +3 -0
- package/dist/src/utils/managed-command-closure.js +35 -0
- package/dist/src/utils/managed-command-closure.js.map +1 -0
- package/dist/src/utils/managed-command-evidence.d.ts +7 -0
- package/dist/src/utils/managed-command-evidence.js +10 -0
- package/dist/src/utils/managed-command-evidence.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +124 -0
- package/dist/src/utils/managed-command-materialization.js +369 -0
- package/dist/src/utils/managed-command-materialization.js.map +1 -0
- package/dist/src/utils/managed-command-preparation.d.ts +67 -0
- package/dist/src/utils/managed-command-preparation.js +146 -0
- package/dist/src/utils/managed-command-preparation.js.map +1 -0
- package/dist/src/utils/managed-command-review.d.ts +26 -0
- package/dist/src/utils/managed-command-review.js +68 -0
- package/dist/src/utils/managed-command-review.js.map +1 -0
- package/dist/src/utils/managed-command-runtime.d.ts +33 -0
- package/dist/src/utils/managed-command-runtime.js +121 -0
- package/dist/src/utils/managed-command-runtime.js.map +1 -0
- package/dist/src/utils/managed-command-store.d.ts +143 -0
- package/dist/src/utils/managed-command-store.js +665 -0
- package/dist/src/utils/managed-command-store.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +1 -3
- package/dist/src/utils/manifest.js +1 -3
- package/dist/src/utils/manifest.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +1 -10
- package/dist/src/utils/multi-source-catalog.js +9 -175
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +74 -5
- package/dist/src/utils/native-cli.js +479 -31
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-demand.d.ts +29 -0
- package/dist/src/utils/native-demand.js +4 -0
- package/dist/src/utils/native-demand.js.map +1 -0
- package/dist/src/utils/native-tool-context.d.ts +14 -0
- package/dist/src/utils/native-tool-context.js +38 -0
- package/dist/src/utils/native-tool-context.js.map +1 -0
- package/dist/src/utils/native-tool-review.d.ts +18 -0
- package/dist/src/utils/native-tool-review.js +116 -0
- package/dist/src/utils/native-tool-review.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +0 -1
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +103 -21
- package/dist/src/utils/ownership.js +232 -210
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/path-catalog-provider.d.ts +1 -1
- package/dist/src/utils/path-catalog-provider.js +47 -62
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -2
- package/dist/src/utils/paths.js +5 -3
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +45 -0
- package/dist/src/utils/platform-empty-state.js +159 -0
- package/dist/src/utils/platform-empty-state.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -1
- package/dist/src/utils/platform-support.js +1 -1
- package/dist/src/utils/platform-support.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +64 -0
- package/dist/src/utils/plugin-config-impact.js +307 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-references.d.ts +89 -0
- package/dist/src/utils/plugin-config-references.js +335 -0
- package/dist/src/utils/plugin-config-references.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +109 -27
- package/dist/src/utils/plugin-config-write.js +1242 -348
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +187 -109
- package/dist/src/utils/plugin-config.js +916 -1147
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-dependencies.d.ts +1 -1
- package/dist/src/utils/plugin-dependencies.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +78 -127
- package/dist/src/utils/plugin-scripts.js +566 -524
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-lock.js +14 -5
- package/dist/src/utils/process-lock.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +2 -2
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/project-boundary.d.ts +11 -13
- package/dist/src/utils/project-boundary.js +28 -34
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/rendered-contract.js +18 -1
- package/dist/src/utils/rendered-contract.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +18 -0
- package/dist/src/utils/runtime-config.js +64 -0
- package/dist/src/utils/runtime-config.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
- package/dist/src/utils/runtime-skill-closure.js +47 -6
- package/dist/src/utils/runtime-skill-closure.js.map +1 -1
- package/dist/src/utils/safe-fs.d.ts +21 -0
- package/dist/src/utils/safe-fs.js +111 -0
- package/dist/src/utils/safe-fs.js.map +1 -0
- package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
- package/dist/src/utils/safe-operation-diagnostic.js +33 -0
- package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
- package/dist/src/utils/sensitive-content.d.ts +4 -0
- package/dist/src/utils/sensitive-content.js +36 -0
- package/dist/src/utils/sensitive-content.js.map +1 -0
- package/dist/src/utils/state-paths.d.ts +8 -3
- package/dist/src/utils/state-paths.js +53 -16
- package/dist/src/utils/state-paths.js.map +1 -1
- package/dist/src/utils/target-eligibility.d.ts +4 -3
- package/dist/src/utils/target-eligibility.js +12 -6
- package/dist/src/utils/target-eligibility.js.map +1 -1
- package/dist/src/utils/windows-claude-shim.d.ts +7 -0
- package/dist/src/utils/windows-claude-shim.js +10 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/src/utils/windows-npm-shim.d.ts +16 -0
- package/dist/src/utils/windows-npm-shim.js +155 -0
- package/dist/src/utils/windows-npm-shim.js.map +1 -0
- package/dist/vitest.config.js +105 -9
- package/dist/vitest.config.js.map +1 -1
- package/package.json +30 -21
- package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
- package/dist/scripts/aw-skill-eval-engine.js +0 -31
- package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
- package/dist/scripts/codex-eval-app-server.d.ts +0 -91
- package/dist/scripts/codex-eval-app-server.js +0 -1334
- package/dist/scripts/codex-eval-app-server.js.map +0 -1
- package/dist/scripts/codex-eval-isolation.d.ts +0 -61
- package/dist/scripts/codex-eval-isolation.js +0 -318
- package/dist/scripts/codex-eval-isolation.js.map +0 -1
- package/dist/scripts/codex-eval-process-management.d.ts +0 -8
- package/dist/scripts/codex-eval-process-management.js +0 -69
- package/dist/scripts/codex-eval-process-management.js.map +0 -1
- package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
- package/dist/scripts/codex-eval-process-tree.js +0 -803
- package/dist/scripts/codex-eval-process-tree.js.map +0 -1
- package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
- package/dist/scripts/codex-eval-runtime-config.js +0 -843
- package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
- package/dist/scripts/codex-trigger-eval.d.ts +0 -84
- package/dist/scripts/codex-trigger-eval.js +0 -968
- package/dist/scripts/codex-trigger-eval.js.map +0 -1
- package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
- package/dist/scripts/eval-plugin-skills-audited.js +0 -261
- package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
- package/dist/scripts/eval-plugin-skills.d.ts +0 -45
- package/dist/scripts/eval-plugin-skills.js +0 -1589
- package/dist/scripts/eval-plugin-skills.js.map +0 -1
- package/dist/scripts/eval-run-layout.d.ts +0 -17
- package/dist/scripts/eval-run-layout.js +0 -26
- package/dist/scripts/eval-run-layout.js.map +0 -1
- package/dist/scripts/plugin-eval-contract.d.ts +0 -189
- package/dist/scripts/plugin-eval-contract.js +0 -745
- package/dist/scripts/plugin-eval-contract.js.map +0 -1
- package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
- package/dist/scripts/plugin-eval-materializer.js +0 -421
- package/dist/scripts/plugin-eval-materializer.js.map +0 -1
- package/dist/scripts/skill-reporting.d.ts +0 -212
- package/dist/scripts/skill-reporting.js +0 -922
- package/dist/scripts/skill-reporting.js.map +0 -1
- package/dist/src/commands/catalog-context.d.ts +0 -52
- package/dist/src/commands/catalog-context.js +0 -156
- package/dist/src/commands/catalog-context.js.map +0 -1
- package/dist/src/commands/review-publication.d.ts +0 -99
- package/dist/src/commands/review-publication.js +0 -904
- package/dist/src/commands/review-publication.js.map +0 -1
- package/dist/src/commands/status-v5.d.ts +0 -169
- package/dist/src/commands/status-v5.js +0 -1135
- package/dist/src/commands/status-v5.js.map +0 -1
- package/dist/src/portable/skills-cli.d.ts +0 -43
- package/dist/src/portable/skills-cli.js +0 -148
- package/dist/src/portable/skills-cli.js.map +0 -1
- package/dist/src/utils/catalog-manifest-v5.d.ts +0 -5
- package/dist/src/utils/catalog-manifest-v5.js.map +0 -1
- package/dist/src/utils/catalog-source-cache.d.ts +0 -62
- package/dist/src/utils/catalog-source-cache.js +0 -321
- package/dist/src/utils/catalog-source-cache.js.map +0 -1
- package/dist/src/utils/codex-project-surface.d.ts +0 -3
- package/dist/src/utils/codex-project-surface.js +0 -49
- package/dist/src/utils/codex-project-surface.js.map +0 -1
- package/dist/src/utils/lifecycle-active-store.d.ts +0 -147
- package/dist/src/utils/lifecycle-active-store.js +0 -1064
- package/dist/src/utils/lifecycle-active-store.js.map +0 -1
- package/dist/src/utils/plugin-release.d.ts +0 -2
- package/dist/src/utils/plugin-release.js +0 -2
- package/dist/src/utils/plugin-release.js.map +0 -1
- package/dist/src/utils/slash-commands.d.ts +0 -1
- package/dist/src/utils/slash-commands.js +0 -2
- package/dist/src/utils/slash-commands.js.map +0 -1
|
@@ -1,49 +1,80 @@
|
|
|
1
|
+
import { readAgentSettings, previewAgentSettings, saveAgentSettings } from './agent-settings.js';
|
|
2
|
+
import { selectPluginConfigProfile, getPluginConfigReferenceChoices, PLATFORM_TARGETS, NATIVE_PLATFORM_TARGETS, resolveSupportedPlatforms } from '@lesliechan721/aw-plugin-core';
|
|
3
|
+
import { configReferenceKey, configReferenceScalars } from './config-references.js';
|
|
1
4
|
import crypto from 'node:crypto';
|
|
2
5
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
6
|
+
import { managedCommandRecoveryPlanChanges } from './operation-review-planner.js';
|
|
7
|
+
import { resolveWorkContext } from '../intent/work-context.js';
|
|
8
|
+
import { flattenStatusTargets, statusTargetHasLiveConfigConsumer, } from '../commands/status-v6.js';
|
|
4
9
|
import { addCatalogSourceCommand, listCatalogSources, preflightCatalogSourceMutation, removeCatalogSourceCommand, setPrimaryCatalogSourceCommand, updateCatalogSourceCommand, } from '../commands/catalog-source.js';
|
|
5
|
-
import {
|
|
10
|
+
import { parseScriptTimeoutMs, SCRIPT_TIMEOUT_DEFAULT_MS, } from '../commands/options.js';
|
|
6
11
|
import { readCliPackageInfo } from '../utils/local-marketplace.js';
|
|
7
|
-
import {
|
|
8
|
-
import { readCatalogSourcesConfigSnapshot, } from '../utils/catalog-sources.js';
|
|
12
|
+
import { readCatalogSourcesConfigSnapshot, recoverInvalidCatalogSourcesConfig, } from '../utils/catalog-sources.js';
|
|
9
13
|
import { withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, formatPluginId, parsePluginId, } from '../utils/multi-source-catalog.js';
|
|
10
|
-
import { coercePluginConfigUpdates,
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
14
|
+
import { coercePluginConfigUpdates, inspectPluginConfigResetTarget, listNamespacedPluginConfigStoreIdentities, readPluginConfigStore, replacePluginConfigStoreLayer, resolveConfigRead, resolveEffectivePluginConfig, resolveEffectivePluginConfigFromStores, resolvePluginConfigReferenceContext, } from '../utils/plugin-config.js';
|
|
15
|
+
import { readRecoveryStatus } from '../recovery/status.js';
|
|
16
|
+
import { readJointDemand } from '../recovery/joint-demand.js';
|
|
17
|
+
import { catalogSourceErrorCode, sanitizeCatalogSourceError } from '../utils/catalog-public-error.js';
|
|
18
|
+
import { activateRecoverySourcesAndReprepare, prepareRecovery, executeRecovery, } from '../recovery/coordinator.js';
|
|
19
|
+
import { prepareRetire, executeRetire } from '../recovery/retirement.js';
|
|
20
|
+
import { prepareTargetsPlan, executeTargetsPlan, prepareIntentPlan, executeIntentPlan } from './scoped-flow.js';
|
|
21
|
+
import { applyPluginConfigWrite, applyPluginConfig, preparePluginConfigApply, disposePluginConfigApply, resolveConfigPreApplyAuthorization, resetPluginConfigWithHelper, } from '../utils/plugin-config-write.js';
|
|
22
|
+
import { analyzePluginConfigMutationImpact, discoverPluginConfigManagedCommandPackages, pluginConfigTargetRenderScopes, pluginSharedNativeConfigRenderUnits } from '../utils/plugin-config-impact.js';
|
|
23
|
+
import { collectPluginConfigReferenceEvidence, pluginConfigHasExternalReferences, resolvePluginConfigReferenceConsumers, resolvePluginConfigReferencePlugins } from '../utils/plugin-config-references.js';
|
|
13
24
|
import { inventoryCatalogSourceReferences } from '../utils/catalog-source-references.js';
|
|
14
|
-
import { operationEvidenceFingerprint, TuiController, TuiOperationBlockedError, } from './controller.js';
|
|
15
|
-
import {
|
|
25
|
+
import { operationEvidenceMatches, operationEvidenceFingerprint, TuiConfigInvalidStoreError, TuiController, TuiOperationBlockedError, } from './controller.js';
|
|
26
|
+
import { buildConfigPage, } from './model.js';
|
|
16
27
|
import { projectCatalogSourceLocation } from '../utils/catalog-source-presentation.js';
|
|
17
|
-
import {
|
|
18
|
-
import { calculateCatalogSourceIdentity } from '../utils/catalog-source-identity.js';
|
|
28
|
+
import { calculateCatalogSourceConfigFingerprint, calculateCatalogSourceIdentity, } from '../utils/catalog-source-identity.js';
|
|
19
29
|
import { checkAwCapabilitySupport, readPluginManifest } from '../utils/manifest.js';
|
|
20
30
|
import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
21
31
|
import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
|
|
32
|
+
import { calculateCatalogGenerationSetDigest, resolveActiveCatalogGeneration, } from '../utils/catalog-generation-resolver.js';
|
|
22
33
|
import { resolveCatalogOperationContext, resolvePartialCatalogOperationContext, selectCatalogOperationContext, } from '../utils/catalog-operation-context.js';
|
|
23
|
-
import {
|
|
34
|
+
import { createCatalogStoreKey, readCatalogStoreEntry, } from '../utils/catalog-generation-store.js';
|
|
35
|
+
import { activateCatalogSourceGeneration, compareCatalogGenerationFreshness, probeCatalogSourceFreshness, probeCatalogSourceGeneration, probeCatalogSourceRepairGeneration, recoverCatalogGenerationStateAndActivate, repairCatalogSourceGeneration, replaceDamagedCatalogSourceGeneration, } from '../utils/catalog-generation-service.js';
|
|
36
|
+
import { calculateCatalogSourceImpactDigest, inspectCatalogSourceImpact, } from '../utils/catalog-source-impact.js';
|
|
37
|
+
import { readCatalogGenerationState } from '../utils/catalog-generation-state.js';
|
|
38
|
+
import { CatalogGenerationError } from '../utils/catalog-generation-error.js';
|
|
39
|
+
import { CatalogProviderCompatibilityError } from '../utils/catalog-public-error.js';
|
|
24
40
|
import { loadCatalogGenerationViewModels } from './catalog-generation.js';
|
|
25
|
-
import { installPortableSkills, preparePortableInstall, PortableCommandError, } from '../portable/commands.js';
|
|
26
|
-
import {
|
|
41
|
+
import { executePortableRetry, installPortableSkills, preparePortableInstall, preparePortableRetry, PortableCommandError, recheckPortableInstall, } from '../portable/commands.js';
|
|
42
|
+
import { projectPluginContentOverview, } from './plugin-content.js';
|
|
43
|
+
import { executeCatalogStoreTask, inspectCatalogStoreTask, prepareCatalogStoreTask, } from './catalog-store-task.js';
|
|
44
|
+
function reusableCandidateEvidenceIsComplete(candidate) {
|
|
45
|
+
const evidence = candidate.probe.candidate;
|
|
46
|
+
return [
|
|
47
|
+
evidence.sourceConfigFingerprint,
|
|
48
|
+
evidence.sourceIdentity,
|
|
49
|
+
evidence.logicalIdentity,
|
|
50
|
+
evidence.requestedRef,
|
|
51
|
+
evidence.resolvedCommit,
|
|
52
|
+
evidence.catalogVersion,
|
|
53
|
+
evidence.channel,
|
|
54
|
+
evidence.manifestDigest,
|
|
55
|
+
evidence.snapshotDigest,
|
|
56
|
+
].every((value) => typeof value === 'string' && value.length > 0)
|
|
57
|
+
&& typeof candidate.probe.manifest === 'object'
|
|
58
|
+
&& candidate.probe.manifest !== null;
|
|
59
|
+
}
|
|
27
60
|
async function loadPortablePluginIds(options) {
|
|
28
61
|
return withResolvedMultiSourceCatalog({
|
|
29
62
|
cliVersion: options.cliVersion,
|
|
30
|
-
freshnessPolicy: 'cacheFirst',
|
|
31
63
|
env: options.context.env,
|
|
32
64
|
signal: options.signal,
|
|
33
65
|
...(options.catalogOperationContext
|
|
34
66
|
? { operationContext: options.catalogOperationContext }
|
|
35
67
|
: {}),
|
|
36
|
-
...(options.bootstrapMissingActive === false ? { bootstrapMissingActive: false } : {}),
|
|
37
68
|
consume: async (catalog) => (await Promise.all(catalog.sources.flatMap((item) => item.resolution
|
|
38
69
|
? item.resolution.manifest.entries.flatMap((entry) => {
|
|
39
70
|
const support = checkAwCapabilitySupport(entry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
|
|
40
71
|
return support.supported
|
|
41
|
-
? [readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' }).then((plugin) => plugin.manifest.
|
|
72
|
+
? [readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' }).then((plugin) => resolveSupportedPlatforms(plugin.manifest).has('generic')
|
|
42
73
|
? formatPluginId({
|
|
43
74
|
sourceId: item.resolution.sourceId,
|
|
44
75
|
pluginName: entry.name,
|
|
45
76
|
})
|
|
46
|
-
: null)]
|
|
77
|
+
: null).catch(() => { options.signal.throwIfAborted(); return null; })]
|
|
47
78
|
: [];
|
|
48
79
|
})
|
|
49
80
|
: []))).filter((pluginId) => pluginId !== null),
|
|
@@ -56,6 +87,10 @@ export function setTuiControllerRuntimeTestHooksForTests(hooks) {
|
|
|
56
87
|
function digest(value) {
|
|
57
88
|
return `sha256:${crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex')}`;
|
|
58
89
|
}
|
|
90
|
+
function configSchemaIdentity(plugin, manifestDigest, platform) {
|
|
91
|
+
return digest({ manifestDigest, profile: platform ?? 'common',
|
|
92
|
+
definition: selectPluginConfigProfile(plugin.manifest.config, platform) });
|
|
93
|
+
}
|
|
59
94
|
export function statusTargetFingerprint(targets, revisions = []) {
|
|
60
95
|
return digest({
|
|
61
96
|
targets: targets.map((target) => ({
|
|
@@ -64,9 +99,14 @@ export function statusTargetFingerprint(targets, revisions = []) {
|
|
|
64
99
|
platform: target.platform,
|
|
65
100
|
scope: target.scope,
|
|
66
101
|
state: target.state,
|
|
67
|
-
errors: target.
|
|
102
|
+
errors: target.reasons.map((error) => error.code).sort(),
|
|
103
|
+
sharedReasons: [...(target.sharedReasons ?? [])]
|
|
104
|
+
.sort((left, right) => `${left.code}\0${left.message}`.localeCompare(`${right.code}\0${right.message}`, 'en')),
|
|
68
105
|
components: target.components.map((component) => [component.key, component.state])
|
|
69
106
|
.sort(([left], [right]) => left.localeCompare(right, 'en')),
|
|
107
|
+
sharedComponents: (target.sharedComponents ?? [])
|
|
108
|
+
.map((component) => [component.key, component.state, component.metadata])
|
|
109
|
+
.sort(([left], [right]) => left.localeCompare(right, 'en')),
|
|
70
110
|
})).sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
71
111
|
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en')),
|
|
72
112
|
revisions: revisions.map((entry) => ({
|
|
@@ -78,33 +118,220 @@ export function statusTargetFingerprint(targets, revisions = []) {
|
|
|
78
118
|
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en')),
|
|
79
119
|
});
|
|
80
120
|
}
|
|
81
|
-
export function configAffectedStatusTargets(targets, pluginId,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
.
|
|
86
|
-
|
|
121
|
+
export function configAffectedStatusTargets(targets, pluginId, configContext, consumerPluginIds = [], platform) {
|
|
122
|
+
const affected = new Map();
|
|
123
|
+
const selected = new Set([pluginId, ...consumerPluginIds]);
|
|
124
|
+
for (const target of flattenStatusTargets(targets)) {
|
|
125
|
+
if (!selected.has(target.pluginId) || !statusTargetHasLiveConfigConsumer(target))
|
|
126
|
+
continue;
|
|
127
|
+
if (configContext === 'user' && target.scope !== 'user')
|
|
128
|
+
continue;
|
|
129
|
+
if (platform && target.platform !== platform)
|
|
130
|
+
continue;
|
|
131
|
+
affected.set(`${target.pluginId}\0${target.platform}\0${target.scope}`, target);
|
|
132
|
+
}
|
|
133
|
+
return [...affected.values()]
|
|
134
|
+
.sort((left, right) => `${left.pluginId}\0${left.platform}\0${left.scope}`
|
|
135
|
+
.localeCompare(`${right.pluginId}\0${right.platform}\0${right.scope}`, 'en'));
|
|
136
|
+
}
|
|
137
|
+
function currentConfigTargets(status, pluginId, configContext, consumers = [], platform) {
|
|
138
|
+
const selected = new Set([pluginId, ...consumers]);
|
|
139
|
+
const observations = [...(status.observedTargets ?? []), ...(status.inventory ?? []).flatMap((root) => root.targetResults)];
|
|
140
|
+
return [...new Map((status.existingTargets ?? []).flatMap((target) => {
|
|
141
|
+
if (target.agent === 'generic' || !selected.has(target.pluginId)
|
|
142
|
+
|| configContext === 'user' && target.scope !== 'user'
|
|
143
|
+
|| platform && target.agent !== platform)
|
|
144
|
+
return [];
|
|
145
|
+
return [{ pluginId: target.pluginId, pluginName: parsePluginId(target.pluginId).pluginName,
|
|
146
|
+
platform: target.agent, scope: target.scope,
|
|
147
|
+
observation: observations.find((item) => item.pluginId === target.pluginId
|
|
148
|
+
&& item.agent === target.agent && item.scope === target.scope) }];
|
|
149
|
+
}).map((target) => [`${target.pluginId}\0${target.platform}\0${target.scope}`, target])).values()]
|
|
150
|
+
.sort((left, right) => `${left.pluginId}\0${left.platform}\0${left.scope}`.localeCompare(`${right.pluginId}\0${right.platform}\0${right.scope}`, 'en'));
|
|
151
|
+
}
|
|
152
|
+
function currentTargetFingerprint(status, targets) {
|
|
153
|
+
return digest({ intent: status.intent, selection: status.selection, targets: targets.map((target) => ({
|
|
154
|
+
pluginId: target.pluginId, platform: target.platform, scope: target.scope,
|
|
155
|
+
observation: target.observation ? { observation: target.observation.observation,
|
|
156
|
+
content: target.observation.content, blockers: target.observation.blockers,
|
|
157
|
+
expectedVersion: target.observation.expectedVersion, installedVersion: target.observation.installedVersion,
|
|
158
|
+
deployments: target.observation.deploymentObservations,
|
|
159
|
+
exclusions: target.observation.deploymentExclusions,
|
|
160
|
+
gaps: target.observation.componentGaps } : null,
|
|
161
|
+
})) });
|
|
162
|
+
}
|
|
163
|
+
function scopedCurrentStatus(status, snapshot, scope) {
|
|
164
|
+
const demand = scope === 'project' ? snapshot.project : snapshot.user;
|
|
165
|
+
const inventory = demand.roots === null ? null : demand.roots.map((root) => ({
|
|
166
|
+
pluginId: root.pluginId, source: root.sourceId, sourceState: root.sourceState,
|
|
167
|
+
blockers: root.blockers.map((code) => ({ code, message: `来源需要处理:${code}。` })),
|
|
168
|
+
targetResults: (status.inventory ?? []).filter((entry) => entry.pluginId === root.pluginId)
|
|
169
|
+
.flatMap((entry) => entry.targetResults.filter((target) => target.scope === scope)),
|
|
170
|
+
}));
|
|
171
|
+
const targets = inventory?.flatMap((root) => root.targetResults) ?? [];
|
|
172
|
+
const counts = { blocked: targets.filter((target) => target.blockers.length > 0).length,
|
|
173
|
+
pending: targets.filter((target) => ['absent', 'drifted'].includes(target.content ?? '')).length,
|
|
174
|
+
unconfirmed: targets.filter((target) => target.content === 'unknown').length,
|
|
175
|
+
ready: targets.filter((target) => target.content === 'satisfied').length };
|
|
176
|
+
return { ...status, scope, intent: { state: demand.intent.state,
|
|
177
|
+
...('digest' in demand.intent ? { digest: demand.intent.digest } : {}) }, inventory, counts,
|
|
178
|
+
extraObserved: status.extraObserved.filter((target) => target.scope === scope),
|
|
179
|
+
allSatisfied: counts.blocked || counts.pending ? false : counts.unconfirmed || inventory === null
|
|
180
|
+
|| !['valid', 'absent'].includes(demand.intent.state) ? null : true };
|
|
181
|
+
}
|
|
182
|
+
/** Source metadata only. Actual installation facts are supplied by RecoveryStatus. */
|
|
183
|
+
async function loadCatalogView(options) {
|
|
184
|
+
return withResolvedMultiSourceCatalog({ cliVersion: options.cliVersion, env: options.context.env,
|
|
185
|
+
signal: options.signal, operationContext: options.catalogOperationContext,
|
|
186
|
+
consume: async (catalog) => ({
|
|
187
|
+
payload: { schemaVersion: 8, catalog: { primarySourceId: catalog.primarySourceId,
|
|
188
|
+
configDigest: catalog.configDigest, compositeDigest: catalog.compositeDigest,
|
|
189
|
+
...(options.catalogOperationContext ? { generationSetDigest: options.catalogOperationContext.generationSetDigest } : {}),
|
|
190
|
+
sources: catalog.sources.map((item) => ({ id: item.sourceId,
|
|
191
|
+
identity: item.resolution?.sourceIdentity ?? '', type: item.resolution?.transport ?? 'path',
|
|
192
|
+
primary: item.sourceId === catalog.primarySourceId,
|
|
193
|
+
requestedRef: item.resolution?.requestedRef ?? 'AW channel',
|
|
194
|
+
...(item.resolution ? { resolvedCommit: item.resolution.resolvedCommit,
|
|
195
|
+
catalogVersion: item.resolution.manifest.catalogVersion, channel: item.resolution.manifest.channel,
|
|
196
|
+
freshness: 'active' } : {}),
|
|
197
|
+
...(item.error ? { error: sanitizeCatalogSourceError(item.error).message, errorCode: catalogSourceErrorCode(item.error) } : {}), })) }, filters: { plugins: [], platform: 'both', cwd: options.context.cwd }, targets: [], errors: [] },
|
|
198
|
+
pluginSummaries: (await Promise.all(catalog.sources.flatMap((item) => item.resolution
|
|
199
|
+
? item.resolution.manifest.entries.map(async (entry) => {
|
|
200
|
+
const support = checkAwCapabilitySupport(entry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
|
|
201
|
+
const metadata = { pluginName: entry.name,
|
|
202
|
+
pluginId: formatPluginId({ sourceId: item.sourceId, pluginName: entry.name }),
|
|
203
|
+
displayName: entry.interface?.displayName ?? entry.name, description: entry.description, version: entry.version };
|
|
204
|
+
// Future definitions may use a schema this CLI cannot parse. The source
|
|
205
|
+
// index is the boundary for deciding whether that definition can be read.
|
|
206
|
+
if (!support.supported)
|
|
207
|
+
return { ...metadata, missingCapabilities: support.missing };
|
|
208
|
+
try {
|
|
209
|
+
const manifest = await readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' });
|
|
210
|
+
options.signal.throwIfAborted();
|
|
211
|
+
const platforms = [...resolveSupportedPlatforms(manifest.manifest)];
|
|
212
|
+
return { ...metadata, platforms, supportedTargets: Object.fromEntries(platforms.filter((platform) => platform !== 'generic')
|
|
213
|
+
.map((platform) => [platform, ['user', 'project']])),
|
|
214
|
+
configFieldCount: new Set(manifest.manifest.config ? [undefined, ...PLATFORM_TARGETS]
|
|
215
|
+
.flatMap((platform) => Object.keys(selectPluginConfigProfile(manifest.manifest.config, platform).fields)) : []).size,
|
|
216
|
+
...(manifest.manifest.config ? { configSchema: manifest.manifest.config.fields } : {}) };
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
options.signal.throwIfAborted();
|
|
220
|
+
return { ...metadata, definitionUnavailable: true };
|
|
221
|
+
}
|
|
222
|
+
}) : []))),
|
|
223
|
+
}),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function configNeedsReferencePlugins(plugin) {
|
|
227
|
+
return pluginConfigHasExternalReferences(plugin.manifest)
|
|
228
|
+
|| (plugin.manifest.config !== undefined && [undefined, ...PLATFORM_TARGETS].some((platform) => Object.values(selectPluginConfigProfile(plugin.manifest.config, platform).fields)
|
|
229
|
+
.some((field) => field.type === 'array' && field.items.type === 'object')));
|
|
230
|
+
}
|
|
231
|
+
async function configRetrySharedNativeRenderUnits(plugin, targets, env, referencePlugins) {
|
|
232
|
+
const plugins = await resolvePluginConfigReferenceConsumers({ plugin, env, plugins: referencePlugins });
|
|
233
|
+
return plugins.flatMap((consumer) => pluginSharedNativeConfigRenderUnits(consumer).filter((shared) => targets.some((target) => (target.pluginName ?? plugin.manifest.name) === consumer.manifest.name
|
|
234
|
+
&& target.platform === shared.platform)));
|
|
235
|
+
}
|
|
236
|
+
async function configRetryStoreDigest(options) {
|
|
237
|
+
const plugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
238
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
239
|
+
env: options.env, plugins: options.plugins });
|
|
240
|
+
const byName = new Map([...plugins, options.plugin].map((plugin) => [plugin.manifest.name, plugin]));
|
|
241
|
+
const profiles = [{ pluginName: options.plugin.manifest.name, scope: options.scope, platform: options.platform },
|
|
242
|
+
...options.targets.flatMap((target) => {
|
|
243
|
+
const plugin = byName.get(target.pluginName);
|
|
244
|
+
if (!plugin)
|
|
245
|
+
throw operationReviewStale('重试目标的插件定义已变化。');
|
|
246
|
+
return pluginConfigTargetRenderScopes(plugin, target).map((scope) => ({ pluginName: target.pluginName, scope, platform: target.platform }));
|
|
247
|
+
}),
|
|
248
|
+
...options.commandPackages.map(({ producer }) => ({ pluginName: producer.pluginName, scope: producer.scope,
|
|
249
|
+
platform: producer.platform ?? undefined })),
|
|
250
|
+
...options.preApplyAuthorization.map(({ pluginName, scope }) => ({ pluginName, scope, platform: options.platform }))];
|
|
251
|
+
return digest(await collectPluginConfigReferenceEvidence({ ...options, profiles, plugins }));
|
|
252
|
+
}
|
|
253
|
+
function configImpactVisibleTargets(pluginName, targets) {
|
|
254
|
+
return targets.map((target) => ({
|
|
255
|
+
pluginName: target.pluginName ?? pluginName,
|
|
256
|
+
platform: target.platform,
|
|
257
|
+
scope: target.scope,
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
function configIntentRequestsApply(intent) {
|
|
261
|
+
if (!intent.apply)
|
|
262
|
+
return false;
|
|
263
|
+
if (intent.retryApply === true)
|
|
264
|
+
return true;
|
|
265
|
+
if (intent.changes)
|
|
266
|
+
return intent.changes.length > 0;
|
|
267
|
+
return Object.keys(intent.updates ?? {}).length > 0
|
|
268
|
+
|| (intent.removeKeys?.length ?? 0) > 0;
|
|
87
269
|
}
|
|
88
|
-
function
|
|
89
|
-
return
|
|
270
|
+
function configSaveBatchGroupIntent(intent, group) {
|
|
271
|
+
return {
|
|
272
|
+
kind: 'configSave',
|
|
273
|
+
pluginId: intent.pluginId,
|
|
274
|
+
scope: 'user',
|
|
275
|
+
platform: group.platform,
|
|
276
|
+
context: intent.context ?? 'user',
|
|
277
|
+
apply: intent.apply,
|
|
278
|
+
...(intent.scriptTimeoutMs === undefined ? {} : { scriptTimeoutMs: intent.scriptTimeoutMs }),
|
|
279
|
+
...(group.updates ? { updates: group.updates } : {}),
|
|
280
|
+
...(group.removeKeys ? { removeKeys: group.removeKeys } : {}),
|
|
281
|
+
...(group.sensitiveKeys ? { sensitiveKeys: group.sensitiveKeys } : {}),
|
|
282
|
+
...(group.privateKeys ? { privateKeys: group.privateKeys } : {}),
|
|
283
|
+
...(group.changes ? { changes: group.changes } : {}),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function assertConfigSaveBatchIntent(intent) {
|
|
287
|
+
if (intent.groups.length === 0 || intent.groups.length > PLATFORM_TARGETS.length + 1
|
|
288
|
+
|| new Set(intent.groups.map((group) => group.platform ?? 'common')).size !== intent.groups.length
|
|
289
|
+
|| intent.groups.some((group) => Object.keys(group.updates ?? {}).length === 0
|
|
290
|
+
&& (group.removeKeys?.length ?? 0) === 0)) {
|
|
291
|
+
throw new TuiOperationBlockedError('configBatchInvalid', '设置批次必须包含唯一且非空的公共或平台配置。');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function operationReviewStale(message, diagnostics) {
|
|
295
|
+
return new TuiOperationBlockedError('operationReviewStale', `operationReviewStale: ${message}`, diagnostics);
|
|
90
296
|
}
|
|
91
297
|
function sourceEvidenceForPlugin(source, pluginName) {
|
|
92
298
|
const entry = source.manifest.entries.find((candidate) => candidate.name === pluginName);
|
|
93
299
|
return {
|
|
94
300
|
sourceId: source.sourceId,
|
|
95
301
|
sourceIdentity: source.sourceIdentity,
|
|
302
|
+
logicalIdentity: source.logicalIdentity,
|
|
96
303
|
requestedRef: source.requestedRef,
|
|
97
304
|
resolvedCommit: source.resolvedCommit,
|
|
98
305
|
manifestDigest: source.manifestDigest,
|
|
99
306
|
snapshotDigest: source.snapshotDigest,
|
|
100
307
|
contentDigest: entry.contentDigest,
|
|
308
|
+
pluginVersion: entry.version,
|
|
101
309
|
catalogVersion: source.manifest.catalogVersion,
|
|
102
310
|
channel: source.manifest.channel,
|
|
103
311
|
};
|
|
104
312
|
}
|
|
313
|
+
async function configLayerStoreDigest(options) {
|
|
314
|
+
const store = await readPluginConfigStore({
|
|
315
|
+
sourceId: options.source.sourceId,
|
|
316
|
+
sourceIdentity: options.source.sourceIdentity,
|
|
317
|
+
...('logicalIdentity' in options.source
|
|
318
|
+
? { logicalIdentity: options.source.logicalIdentity }
|
|
319
|
+
: {}),
|
|
320
|
+
pluginName: options.pluginName,
|
|
321
|
+
scope: 'user',
|
|
322
|
+
platform: options.platform,
|
|
323
|
+
cwd: options.cwd,
|
|
324
|
+
env: options.env,
|
|
325
|
+
});
|
|
326
|
+
return options.profileOnly
|
|
327
|
+
? digest({ profile: options.platform ?? 'common', state: store.state === 'invalid' ? 'invalid' : 'ready',
|
|
328
|
+
values: store.values, ...(store.state === 'invalid' ? { rawDigest: store.rawDigest } : {}) })
|
|
329
|
+
: digest({ exists: store.exists, rawDigest: store.rawDigest });
|
|
330
|
+
}
|
|
105
331
|
function assertSourceEvidenceMatches(expected, actual) {
|
|
106
332
|
if (actual.sourceId !== expected.sourceId
|
|
107
333
|
|| actual.sourceIdentity !== expected.sourceIdentity
|
|
334
|
+
|| actual.logicalIdentity !== expected.logicalIdentity
|
|
108
335
|
|| actual.resolvedCommit !== expected.resolvedCommit
|
|
109
336
|
|| actual.manifestDigest !== expected.manifestDigest
|
|
110
337
|
|| actual.snapshotDigest !== expected.snapshotDigest
|
|
@@ -112,140 +339,31 @@ function assertSourceEvidenceMatches(expected, actual) {
|
|
|
112
339
|
throw operationReviewStale('确认后来源内容发生变化。');
|
|
113
340
|
}
|
|
114
341
|
}
|
|
115
|
-
function throwIfWriteReviewStale(result) {
|
|
116
|
-
const stale = result.targetResults.find((target) => target.errorCode === 'operationReviewStale');
|
|
117
|
-
if (stale) {
|
|
118
|
-
throw operationReviewStale('确认后实际写入计划发生变化。');
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
342
|
const SOURCE_PROGRESS_PHASES = {
|
|
122
|
-
refreshingCatalog: '刷新 Catalog 缓存',
|
|
123
|
-
catalogReady: 'Catalog 已读取,索引已刷新',
|
|
124
343
|
savingConfig: '保存来源配置',
|
|
125
344
|
};
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
function assertIntentIsLegal(intent, targets, revisions = []) {
|
|
130
|
-
const platforms = intent.platform === 'both'
|
|
131
|
-
? ['codex', 'claude']
|
|
132
|
-
: [intent.platform];
|
|
133
|
-
for (const platform of platforms) {
|
|
134
|
-
const selected = targets.find((target) => target.pluginId === intent.pluginId
|
|
135
|
-
&& target.platform === platform && target.scope === intent.scope);
|
|
136
|
-
if (!selected || selected.errors.some((error) => error.code === 'unsupportedTarget')) {
|
|
137
|
-
throw new TuiOperationBlockedError('unsupportedTarget', '所选插件不支持这个平台和使用位置。');
|
|
138
|
-
}
|
|
139
|
-
const otherScopeInstalled = targets.some((target) => target.platform === platform
|
|
140
|
-
&& target.scope !== intent.scope
|
|
141
|
-
&& (target.state === 'present' || target.state === 'partial'));
|
|
142
|
-
if (intent.action === 'install' && otherScopeInstalled) {
|
|
143
|
-
throw new TuiOperationBlockedError('scopeConflict', '这个平台已安装在另一个使用位置。请先移除原位置。');
|
|
144
|
-
}
|
|
145
|
-
if (intent.action === 'install' && targetHasArtifactCollision(selected)) {
|
|
146
|
-
throw new TuiOperationBlockedError('artifactCollision', '所选位置存在输出冲突。请先移除或迁移冲突内容。');
|
|
147
|
-
}
|
|
148
|
-
if (intent.action === 'install' && selected.state !== 'absent') {
|
|
149
|
-
throw new TuiOperationBlockedError('targetAlreadyInstalled', '所选位置已经安装。');
|
|
150
|
-
}
|
|
151
|
-
const revision = revisions.find((entry) => entry.pluginId === intent.pluginId
|
|
152
|
-
&& entry.platform === platform && entry.scope === intent.scope)?.revision;
|
|
153
|
-
if (intent.action === 'upgrade'
|
|
154
|
-
&& (selected.state !== 'present' || revision?.state !== 'upgradeAvailable')) {
|
|
155
|
-
throw new TuiOperationBlockedError('targetStateChanged', '当前安装状态不允许执行这个操作。');
|
|
156
|
-
}
|
|
157
|
-
if (intent.action === 'uninstall' && !targetCanBeUninstalled(selected.state)) {
|
|
158
|
-
throw new TuiOperationBlockedError('targetStateChanged', '当前安装状态不允许执行这个操作。');
|
|
159
|
-
}
|
|
160
|
-
if ((intent.action === 'reinstall' || intent.action === 'cleanup') && selected.state === 'absent') {
|
|
161
|
-
throw new TuiOperationBlockedError('targetAbsent', '所选位置没有可处理的 AW 安装。');
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async function assertTypedIssueOrigin(intent, targets) {
|
|
166
|
-
if (!intent.originIssue)
|
|
167
|
-
return;
|
|
168
|
-
const stale = (message) => {
|
|
169
|
-
throw new TuiOperationBlockedError('operationReviewStale', `operationReviewStale: ${message}`);
|
|
170
|
-
};
|
|
171
|
-
const selected = targets.find((target) => target.pluginId === intent.pluginId
|
|
172
|
-
&& target.platform === intent.platform
|
|
173
|
-
&& target.scope === intent.scope);
|
|
174
|
-
if (intent.originIssue.category === 'dependencyMissing') {
|
|
175
|
-
if (intent.originIssue.actionId !== 'installDependency'
|
|
176
|
-
|| intent.action !== 'install' || !selected || selected.state !== 'absent') {
|
|
177
|
-
stale('原缺失依赖问题已变化。');
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else if (intent.originIssue.category === 'dependencyNotReady') {
|
|
181
|
-
if (intent.originIssue.actionId !== 'reinstallDependency'
|
|
182
|
-
|| intent.action !== 'reinstall' || !selected
|
|
183
|
-
|| (selected.state !== 'partial' && selected.state !== 'error')) {
|
|
184
|
-
stale('原依赖安装问题已变化。');
|
|
185
|
-
}
|
|
345
|
+
function reviewedScriptTimeoutMs(intent) {
|
|
346
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
347
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
186
348
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
||
|
|
190
|
-
|
|
191
|
-
stale('原安装问题已变化。');
|
|
192
|
-
}
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
else if (intent.originIssue.category === 'sourceUnavailable') {
|
|
196
|
-
if (intent.originIssue.actionId !== 'cleanup' || intent.action !== 'cleanup'
|
|
197
|
-
|| !selected || !selected.errors.some((error) => error.code === 'bundleUnavailable')) {
|
|
198
|
-
stale('原 Catalog 缺失插件问题已变化。');
|
|
199
|
-
}
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
else if (intent.originIssue.category === 'sourceMissing') {
|
|
203
|
-
if (intent.originIssue.actionId !== 'cleanup' || intent.action !== 'cleanup'
|
|
204
|
-
|| !selected || !selected.errors.some((error) => error.code === 'sourceMissing')) {
|
|
205
|
-
stale('原来源缺失问题已变化。');
|
|
206
|
-
}
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
else if (intent.originIssue.category === 'scopeConflict') {
|
|
210
|
-
const installedScopes = new Set(targets.filter((target) => target.pluginId === intent.pluginId
|
|
211
|
-
&& target.platform === intent.platform
|
|
212
|
-
&& (target.state === 'present' || target.state === 'partial')).map((target) => target.scope));
|
|
213
|
-
const correctBranch = intent.action === 'uninstall'
|
|
214
|
-
&& ((intent.originIssue.actionId === 'keepUserScope' && intent.scope === 'project')
|
|
215
|
-
|| (intent.originIssue.actionId === 'keepProjectScope' && intent.scope === 'user'));
|
|
216
|
-
if (!correctBranch || !installedScopes.has('user') || !installedScopes.has('project')) {
|
|
217
|
-
stale('原位置冲突已变化。');
|
|
218
|
-
}
|
|
219
|
-
return;
|
|
349
|
+
if ((intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch')
|
|
350
|
+
&& (intent.action === 'install' || intent.action === 'refreshAndSync'
|
|
351
|
+
|| intent.action === 'reinstall' || intent.action === 'sync')) {
|
|
352
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
220
353
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const origin = intent.originIssue;
|
|
224
|
-
if (!origin.consumerPluginId || !origin.consumerSourceIdentity || !origin.consumerPlatform
|
|
225
|
-
|| !origin.consumerScope || !origin.dependencyPluginId || !origin.dependencyPlatform
|
|
226
|
-
|| !origin.dependencyScope || origin.dependencyProject === undefined
|
|
227
|
-
|| origin.dependencyPluginId !== intent.pluginId
|
|
228
|
-
|| origin.dependencyPlatform !== intent.platform || origin.dependencyScope !== intent.scope) {
|
|
229
|
-
stale('依赖问题来源缺少稳定目标证据。');
|
|
354
|
+
if ((intent.kind === 'configSave' || intent.kind === 'configSaveBatch') && intent.apply) {
|
|
355
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
230
356
|
}
|
|
231
|
-
|
|
232
|
-
&& target.sourceIdentity === origin.consumerSourceIdentity
|
|
233
|
-
&& target.platform === origin.consumerPlatform
|
|
234
|
-
&& target.scope === origin.consumerScope);
|
|
235
|
-
const consumerError = consumer?.errors.some((error) => error.code === origin.category && error.message.includes(origin.dependencyPluginId));
|
|
236
|
-
if (!consumer || !consumerError)
|
|
237
|
-
stale('原 consumer 依赖问题已消失或变化。');
|
|
357
|
+
return undefined;
|
|
238
358
|
}
|
|
239
359
|
async function loadDependencyOverviews(options) {
|
|
240
360
|
const graph = await withResolvedMultiSourceCatalog({
|
|
241
361
|
cliVersion: options.cliVersion,
|
|
242
|
-
freshnessPolicy: 'cacheFirst',
|
|
243
362
|
env: options.context.env,
|
|
244
363
|
signal: options.signal,
|
|
245
364
|
...(options.catalogOperationContext
|
|
246
365
|
? { operationContext: options.catalogOperationContext }
|
|
247
366
|
: {}),
|
|
248
|
-
...(options.bootstrapMissingActive === false ? { bootstrapMissingActive: false } : {}),
|
|
249
367
|
consume: async (catalog) => ({
|
|
250
368
|
nodes: catalog.sources.flatMap((item) => item.resolution
|
|
251
369
|
? item.resolution.manifest.entries.map((entry) => ({
|
|
@@ -253,6 +371,7 @@ async function loadDependencyOverviews(options) {
|
|
|
253
371
|
sourceId: item.resolution.sourceId,
|
|
254
372
|
pluginName: entry.name,
|
|
255
373
|
}),
|
|
374
|
+
sourceIdentity: item.resolution.sourceIdentity,
|
|
256
375
|
displayName: entry.interface?.displayName ?? entry.name,
|
|
257
376
|
dependencies: entry.dependencies.map((pluginName) => formatPluginId({ sourceId: item.resolution.sourceId, pluginName })),
|
|
258
377
|
}))
|
|
@@ -263,7 +382,7 @@ async function loadDependencyOverviews(options) {
|
|
|
263
382
|
}),
|
|
264
383
|
});
|
|
265
384
|
const nodes = new Map(graph.nodes.map((node) => [node.pluginId, node]));
|
|
266
|
-
const summaryById = new Map(options.
|
|
385
|
+
const summaryById = new Map(options.pluginSummaries.map((summary) => [summary.pluginId, summary]));
|
|
267
386
|
const displayName = (pluginId) => nodes.get(pluginId)?.displayName
|
|
268
387
|
?? parsePluginId(pluginId).pluginName;
|
|
269
388
|
const reverse = new Map();
|
|
@@ -273,56 +392,52 @@ async function loadDependencyOverviews(options) {
|
|
|
273
392
|
}
|
|
274
393
|
}
|
|
275
394
|
const targetsByPlugin = new Map();
|
|
276
|
-
for (const target of options.status.
|
|
395
|
+
for (const target of options.status.observedTargets ?? []) {
|
|
277
396
|
targetsByPlugin.set(target.pluginId, [...(targetsByPlugin.get(target.pluginId) ?? []), target]);
|
|
278
397
|
}
|
|
279
|
-
const unsupportedPluginIds = new Set(options.
|
|
280
|
-
.filter((summary) => (summary.missingCapabilities?.length ?? 0) > 0)
|
|
398
|
+
const unsupportedPluginIds = new Set(options.pluginSummaries.filter((summary) => (summary.missingCapabilities?.length ?? 0) > 0)
|
|
281
399
|
.map((summary) => summary.pluginId));
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
pluginId
|
|
301
|
-
|
|
302
|
-
scope: consumer.scope,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
pluginId: dependencyPluginId,
|
|
307
|
-
platform: consumer.platform,
|
|
308
|
-
scope: dependencyScope,
|
|
309
|
-
project: dependencyScope === 'project' ? 'current' : null,
|
|
310
|
-
},
|
|
311
|
-
};
|
|
312
|
-
const key = `${consumer.pluginId}\0${dependencyPluginId}`;
|
|
313
|
-
placementReferences.set(key, [...(placementReferences.get(key) ?? []), reference]);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
const placementsFor = (pluginId) => {
|
|
317
|
-
const targets = targetsByPlugin.get(pluginId) ?? [];
|
|
318
|
-
if (targets.length > 0) {
|
|
319
|
-
return ['codex', 'claude'].flatMap((platform) => {
|
|
320
|
-
const selected = targets.filter((target) => target.platform === platform);
|
|
321
|
-
return selected.length > 0 ? [projectPlatformPlacement(platform, selected)] : [];
|
|
400
|
+
const availableReferencesFor = (rootId, dependencyId) => {
|
|
401
|
+
const references = (targetsByPlugin.get(dependencyId) ?? []).flatMap((dependency) => {
|
|
402
|
+
if (dependency.agent === 'generic' || dependency.content !== 'satisfied' || dependency.observation !== 'verified'
|
|
403
|
+
|| dependency.providerScope !== dependency.scope
|
|
404
|
+
|| !options.status.existingTargets?.some((item) => item.pluginId === dependencyId
|
|
405
|
+
&& item.agent === dependency.agent && item.scope === dependency.scope))
|
|
406
|
+
return [];
|
|
407
|
+
return (dependency.contributions ?? []).flatMap((contribution) => {
|
|
408
|
+
if (contribution.root !== rootId || contribution.path.at(-1) !== dependencyId || contribution.path.length < 2)
|
|
409
|
+
return [];
|
|
410
|
+
const parentId = contribution.path.at(-2);
|
|
411
|
+
if (!nodes.get(parentId)?.dependencies.includes(dependencyId)
|
|
412
|
+
|| nodes.get(parentId)?.sourceIdentity !== nodes.get(dependencyId)?.sourceIdentity)
|
|
413
|
+
return [];
|
|
414
|
+
return (targetsByPlugin.get(parentId) ?? []).filter((consumer) => consumer.agent === dependency.agent
|
|
415
|
+
&& consumer.providerScope === consumer.scope
|
|
416
|
+
&& consumer.contributions?.some((entry) => entry.root === contribution.root && entry.scope === contribution.scope
|
|
417
|
+
&& JSON.stringify(entry.path) === JSON.stringify(contribution.path.slice(0, -1)))
|
|
418
|
+
&& options.status.existingTargets?.some((item) => item.pluginId === parentId && item.agent === consumer.agent && item.scope === consumer.scope))
|
|
419
|
+
.map((consumer) => ({ requirementScope: contribution.scope,
|
|
420
|
+
consumer: { pluginId: parentId, platform: dependency.agent, scope: consumer.scope,
|
|
421
|
+
project: consumer.scope === 'project' ? 'current' : null },
|
|
422
|
+
dependency: { pluginId: dependencyId, platform: dependency.agent, scope: dependency.scope,
|
|
423
|
+
project: dependency.scope === 'project' ? 'current' : null } }));
|
|
322
424
|
});
|
|
323
|
-
}
|
|
324
|
-
return [];
|
|
425
|
+
});
|
|
426
|
+
return [...new Map(references.map((reference) => [JSON.stringify(reference), reference])).values()];
|
|
325
427
|
};
|
|
428
|
+
const placementsFor = (pluginId) => (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => {
|
|
429
|
+
if (target.agent === 'generic')
|
|
430
|
+
return [];
|
|
431
|
+
const exists = options.status.existingTargets?.some((item) => item.pluginId === pluginId
|
|
432
|
+
&& item.agent === target.agent && item.scope === target.scope);
|
|
433
|
+
if (!exists)
|
|
434
|
+
return [{ platform: target.agent, state: 'notInstalled', supportedScopes: ['user', 'project'] }];
|
|
435
|
+
return [{ platform: target.agent, state: 'installed', scope: target.scope,
|
|
436
|
+
health: target.content === 'satisfied' && !target.blockers.length ? 'ready'
|
|
437
|
+
: target.blockers.length || target.content === 'conflict' ? 'error' : 'incomplete',
|
|
438
|
+
revision: { state: 'unknown', ...(target.expectedVersion ? { availableVersion: target.expectedVersion } : {}),
|
|
439
|
+
...(target.installedVersion ? { installedVersion: target.installedVersion } : {}) }, relation: target.relation === 'dependency' ? 'dependency' : 'root' }];
|
|
440
|
+
});
|
|
326
441
|
const aggregateFor = (pluginId, placements) => {
|
|
327
442
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
328
443
|
if (graph.sourceErrors.some((error) => error.sourceId === sourceId)
|
|
@@ -332,7 +447,8 @@ async function loadDependencyOverviews(options) {
|
|
|
332
447
|
return 'notInstalled';
|
|
333
448
|
}
|
|
334
449
|
return placements.some((placement) => placement.state === 'scopeConflict'
|
|
335
|
-
|| (placement.state === 'installed'
|
|
450
|
+
|| (placement.state === 'installed'
|
|
451
|
+
&& (placement.health !== 'ready' || placement.blockingReason !== undefined)))
|
|
336
452
|
? 'needsAttention'
|
|
337
453
|
: 'ready';
|
|
338
454
|
};
|
|
@@ -383,7 +499,8 @@ async function loadDependencyOverviews(options) {
|
|
|
383
499
|
})),
|
|
384
500
|
placements,
|
|
385
501
|
aggregateStatus: aggregateFor(dependency.pluginId, placements),
|
|
386
|
-
placementReferences:
|
|
502
|
+
placementReferences: [],
|
|
503
|
+
availablePlacementReferences: availableReferencesFor(pluginId, dependency.pluginId),
|
|
387
504
|
};
|
|
388
505
|
});
|
|
389
506
|
const dependentIds = [...new Set(reverse.get(pluginId) ?? [])].sort();
|
|
@@ -397,10 +514,11 @@ async function loadDependencyOverviews(options) {
|
|
|
397
514
|
requiredBy: [],
|
|
398
515
|
placements,
|
|
399
516
|
aggregateStatus: aggregateFor(dependentId, placements),
|
|
400
|
-
placementReferences:
|
|
517
|
+
placementReferences: [],
|
|
518
|
+
availablePlacementReferences: availableReferencesFor(dependentId, pluginId),
|
|
401
519
|
};
|
|
402
520
|
});
|
|
403
|
-
const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.
|
|
521
|
+
const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.blockers.filter((error) => error.code.startsWith('dependency') || error.code === 'sourceChanged')
|
|
404
522
|
.map((error) => ({
|
|
405
523
|
code: error.code,
|
|
406
524
|
title: '依赖关系需要处理',
|
|
@@ -411,7 +529,7 @@ async function loadDependencyOverviews(options) {
|
|
|
411
529
|
const dependencyTargets = summaryById.get(dependency.pluginId)?.supportedTargets;
|
|
412
530
|
if (!consumerTargets || !dependencyTargets)
|
|
413
531
|
return true;
|
|
414
|
-
return
|
|
532
|
+
return NATIVE_PLATFORM_TARGETS.some((platform) => (consumerTargets[platform]?.length ?? 0) > 0 && (dependencyTargets[platform]?.length ?? 0) === 0);
|
|
415
533
|
});
|
|
416
534
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
417
535
|
const blockers = [
|
|
@@ -479,12 +597,33 @@ function createReviewStageReporter(options) {
|
|
|
479
597
|
export function createTuiControllerDependencies(context, progressFeed, options = {}) {
|
|
480
598
|
const readInventory = options.inventoryCatalogSourceReferences
|
|
481
599
|
?? inventoryCatalogSourceReferences;
|
|
600
|
+
const validatedStoreEntries = new Map();
|
|
601
|
+
const validatingStoreEntries = new Map();
|
|
602
|
+
const loadCatalogGenerations = async () => {
|
|
603
|
+
const generations = await loadCatalogGenerationViewModels({
|
|
604
|
+
env: context.env,
|
|
605
|
+
validatedStoreEntries,
|
|
606
|
+
validatingStoreEntries,
|
|
607
|
+
onStage: (event) => context.debugLogger.log({
|
|
608
|
+
type: 'performance:stage',
|
|
609
|
+
level: 'debug',
|
|
610
|
+
target: 'debugLog',
|
|
611
|
+
message: 'Catalog generation load stage completed.',
|
|
612
|
+
data: event,
|
|
613
|
+
}),
|
|
614
|
+
});
|
|
615
|
+
const retained = new Set(generations.flatMap((source) => [
|
|
616
|
+
source.active?.storeKey,
|
|
617
|
+
].filter((value) => value !== undefined)));
|
|
618
|
+
for (const storeKey of validatedStoreEntries.keys()) {
|
|
619
|
+
if (!retained.has(storeKey))
|
|
620
|
+
validatedStoreEntries.delete(storeKey);
|
|
621
|
+
}
|
|
622
|
+
return generations;
|
|
623
|
+
};
|
|
482
624
|
const createOperationInventoryReader = () => {
|
|
483
625
|
let ordinaryInventory;
|
|
484
626
|
return (inventoryOptions) => {
|
|
485
|
-
if (inventoryOptions.includeHistoricalProjects === true) {
|
|
486
|
-
return readInventory(inventoryOptions);
|
|
487
|
-
}
|
|
488
627
|
ordinaryInventory ??= readInventory(inventoryOptions);
|
|
489
628
|
return ordinaryInventory;
|
|
490
629
|
};
|
|
@@ -492,76 +631,162 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
492
631
|
const catalogOperationByEvidence = new WeakMap();
|
|
493
632
|
let sessionCatalogOperationContext;
|
|
494
633
|
let sessionStatusResult;
|
|
495
|
-
let
|
|
634
|
+
let sessionRecoveryStatus;
|
|
496
635
|
const sessionContextForPlugin = (pluginId) => {
|
|
497
636
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
498
637
|
if (!sourceId || !sessionCatalogOperationContext)
|
|
499
638
|
return undefined;
|
|
500
639
|
return selectCatalogOperationContext(sessionCatalogOperationContext, [sourceId]);
|
|
501
640
|
};
|
|
641
|
+
const readConfigStoresForTui = async (config) => {
|
|
642
|
+
const user = await readPluginConfigStore({
|
|
643
|
+
sourceId: config.sourceId,
|
|
644
|
+
sourceIdentity: config.sourceIdentity,
|
|
645
|
+
logicalIdentity: config.logicalIdentity,
|
|
646
|
+
pluginName: config.pluginName,
|
|
647
|
+
scope: 'user',
|
|
648
|
+
platform: config.platform,
|
|
649
|
+
cwd: context.cwd,
|
|
650
|
+
env: context.env,
|
|
651
|
+
schema: config.schema,
|
|
652
|
+
});
|
|
653
|
+
config.signal.throwIfAborted();
|
|
654
|
+
if (user.state === 'invalid')
|
|
655
|
+
throw new TuiConfigInvalidStoreError([{
|
|
656
|
+
scope: 'user', code: user.invalidCode,
|
|
657
|
+
pathSummary: `AW_HOME/plugin-config/${config.sourceId ?? '<source>'}/${config.pluginName}/config.json`,
|
|
658
|
+
}]);
|
|
659
|
+
return { user };
|
|
660
|
+
};
|
|
661
|
+
const assertConfigEditEvidence = async (intent, evidence) => {
|
|
662
|
+
if (!intent.editEvidence)
|
|
663
|
+
return;
|
|
664
|
+
if (!evidence.source || !evidence.config)
|
|
665
|
+
throw operationReviewStale('设置编辑缺少当前证据。');
|
|
666
|
+
const currentDigest = await configLayerStoreDigest({ source: evidence.source,
|
|
667
|
+
pluginName: parsePluginId(intent.pluginId).pluginName, scope: 'user', platform: intent.platform,
|
|
668
|
+
cwd: context.cwd, env: context.env });
|
|
669
|
+
for (const expected of Object.values(intent.editEvidence)) {
|
|
670
|
+
if (expected.sourceIdentity !== evidence.source.sourceIdentity
|
|
671
|
+
|| expected.schemaIdentity !== evidence.config.schemaIdentity
|
|
672
|
+
|| expected.platform !== intent.platform
|
|
673
|
+
|| (expected.context ?? 'user') !== (intent.context ?? 'user')
|
|
674
|
+
|| expected.storeDigests.user !== undefined && expected.storeDigests.user !== currentDigest) {
|
|
675
|
+
throw operationReviewStale('编辑期间设置、来源或定义已变化。请重新打开设置。');
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
};
|
|
502
679
|
const loadStatus = async (signal) => {
|
|
503
680
|
signal.throwIfAborted();
|
|
504
681
|
const packageInfo = await readCliPackageInfo();
|
|
505
682
|
const catalogOperationContext = sessionCatalogOperationContext
|
|
506
683
|
?? await resolvePartialCatalogOperationContext({
|
|
507
|
-
cliVersion: packageInfo.version,
|
|
508
684
|
env: context.env,
|
|
509
685
|
signal,
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}).catch(() =>
|
|
686
|
+
validatedStoreEntries,
|
|
687
|
+
validatingStoreEntries,
|
|
688
|
+
}).catch(async (error) => {
|
|
689
|
+
if (!(error instanceof CatalogGenerationError)
|
|
690
|
+
|| error.code !== 'catalogGenerationStateInvalid')
|
|
691
|
+
return undefined;
|
|
692
|
+
const snapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
693
|
+
const primarySourceId = snapshot.config.sources.find((source) => source.primary).id;
|
|
694
|
+
const generationSetDigest = calculateCatalogGenerationSetDigest(snapshot.digest, primarySourceId, []);
|
|
695
|
+
return {
|
|
696
|
+
generationSet: {
|
|
697
|
+
generationSetDigest,
|
|
698
|
+
configDigest: snapshot.digest,
|
|
699
|
+
primarySourceId,
|
|
700
|
+
sources: [],
|
|
701
|
+
},
|
|
702
|
+
generationSetDigest,
|
|
703
|
+
catalog: {
|
|
704
|
+
sources: snapshot.config.sources.map((source) => ({
|
|
705
|
+
sourceId: source.id,
|
|
706
|
+
error,
|
|
707
|
+
})),
|
|
708
|
+
primarySourceId,
|
|
709
|
+
configDigest: snapshot.digest,
|
|
710
|
+
compositeDigest: generationSetDigest,
|
|
711
|
+
},
|
|
712
|
+
};
|
|
713
|
+
});
|
|
513
714
|
if (catalogOperationContext)
|
|
514
715
|
sessionCatalogOperationContext = catalogOperationContext;
|
|
515
716
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
516
|
-
const result = await
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
522
|
-
...(!catalogOperationContext ? { bootstrapMissingActive: false } : {}),
|
|
523
|
-
...(options.catalogGenerationRuntime ? { catalogGenerationRuntime: options.catalogGenerationRuntime } : {}),
|
|
524
|
-
inventoryCatalogSourceReferences: readInventory,
|
|
525
|
-
});
|
|
717
|
+
const result = await loadCatalogView({ context, cliVersion: packageInfo.version, signal,
|
|
718
|
+
...(catalogOperationContext ? { catalogOperationContext } : {}) });
|
|
719
|
+
const snapshot = await readJointDemand({ cwd: context.cwd, env: context.env, signal, catalogOperationContext });
|
|
720
|
+
const current = await readRecoveryStatus({ cwd: context.cwd, env: context.env, signal,
|
|
721
|
+
cliVersion: packageInfo.version, nativeCliRunner: context.nativeCliRunner, catalogOperationContext }, snapshot);
|
|
526
722
|
signal.throwIfAborted();
|
|
527
723
|
const configured = await listCatalogSources({ env: context.env });
|
|
528
724
|
signal.throwIfAborted();
|
|
529
725
|
if (result.payload.catalog.configDigest !== configured.configDigest)
|
|
530
726
|
continue;
|
|
531
727
|
sessionStatusResult = result;
|
|
728
|
+
sessionRecoveryStatus = current;
|
|
532
729
|
const dependencyOverviews = await loadDependencyOverviews({
|
|
533
730
|
context,
|
|
534
731
|
cliVersion: packageInfo.version,
|
|
535
|
-
status:
|
|
732
|
+
status: current,
|
|
733
|
+
pluginSummaries: result.pluginSummaries,
|
|
536
734
|
signal,
|
|
537
735
|
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
538
|
-
...(!catalogOperationContext ? { bootstrapMissingActive: false } : {}),
|
|
539
736
|
});
|
|
540
737
|
const portablePluginIds = await loadPortablePluginIds({
|
|
541
738
|
context,
|
|
542
739
|
cliVersion: packageInfo.version,
|
|
543
740
|
signal,
|
|
544
741
|
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
545
|
-
...(!catalogOperationContext ? { bootstrapMissingActive: false } : {}),
|
|
546
742
|
});
|
|
547
743
|
signal.throwIfAborted();
|
|
548
|
-
const catalogGenerations = await
|
|
744
|
+
const catalogGenerations = await loadCatalogGenerations();
|
|
745
|
+
signal.throwIfAborted();
|
|
746
|
+
const configStoreInventory = (await Promise.all(['user'].map(async (scope) => {
|
|
747
|
+
try {
|
|
748
|
+
return (await listNamespacedPluginConfigStoreIdentities({
|
|
749
|
+
cwd: context.cwd,
|
|
750
|
+
env: context.env,
|
|
751
|
+
scope,
|
|
752
|
+
})).map(({ pluginId, sourceId, pluginName }) => ({
|
|
753
|
+
pluginId, sourceId, pluginName, scope,
|
|
754
|
+
}));
|
|
755
|
+
}
|
|
756
|
+
catch {
|
|
757
|
+
await context.debugLogger.log({
|
|
758
|
+
type: 'tui:config-inventory-error',
|
|
759
|
+
level: 'debug',
|
|
760
|
+
target: 'debugLog',
|
|
761
|
+
message: 'TUI saved config inventory could not be read.',
|
|
762
|
+
data: { scope },
|
|
763
|
+
});
|
|
764
|
+
return [];
|
|
765
|
+
}
|
|
766
|
+
}))).flat();
|
|
549
767
|
signal.throwIfAborted();
|
|
550
768
|
const statusById = new Map(result.payload.catalog.sources.map((source) => [source.id, source]));
|
|
551
769
|
return {
|
|
552
770
|
cliChannel: packageInfo.version.includes('-') ? 'beta' : 'latest',
|
|
771
|
+
...(current.coverage.projectRoot ? { projectRoot: current.coverage.projectRoot } : {}),
|
|
772
|
+
scopedRecovery: { user: { ...scopedCurrentStatus(current, snapshot, 'user'), dependencyOverviews },
|
|
773
|
+
...(snapshot.project ? { project: { ...scopedCurrentStatus(current, snapshot, 'project'), dependencyOverviews } } : {}) },
|
|
774
|
+
configuredSources: structuredClone(configured.sources),
|
|
553
775
|
payload: result.payload,
|
|
554
776
|
pluginSummaries: result.pluginSummaries,
|
|
555
|
-
targetRevisions: result.targetRevisions,
|
|
556
777
|
dependencyOverviews,
|
|
557
778
|
portablePluginIds,
|
|
779
|
+
configStoreInventory,
|
|
558
780
|
catalogGenerations,
|
|
781
|
+
sessionGenerationKeys: Object.fromEntries((catalogOperationContext?.generationSet.sources ?? [])
|
|
782
|
+
.map((source) => [source.sourceId, source.storeKey])),
|
|
559
783
|
sourceDetails: configured.sources.map((source) => {
|
|
560
784
|
const status = statusById.get(source.id);
|
|
561
785
|
return {
|
|
562
786
|
id: source.id,
|
|
563
787
|
type: source.type,
|
|
564
788
|
primary: source.primary,
|
|
789
|
+
autoCheck: source.autoCheck,
|
|
565
790
|
locationSummary: projectCatalogSourceLocation(source.type === 'git' ? source.url : source.path),
|
|
566
791
|
...(source.type === 'git' ? {
|
|
567
792
|
refPolicy: source.refPolicy.type,
|
|
@@ -583,35 +808,470 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
583
808
|
}
|
|
584
809
|
throw new TuiOperationBlockedError('operationReviewStale', '状态读取期间来源配置持续变化。请重试。');
|
|
585
810
|
};
|
|
586
|
-
const
|
|
587
|
-
|
|
811
|
+
const loadPluginContent = async (pluginId, signal) => {
|
|
812
|
+
signal.throwIfAborted();
|
|
813
|
+
try {
|
|
814
|
+
const packageInfo = await readCliPackageInfo();
|
|
815
|
+
const catalogOperation = sessionContextForPlugin(pluginId);
|
|
816
|
+
return await withResolvedCatalogPlugin({
|
|
817
|
+
selector: pluginId,
|
|
818
|
+
cliVersion: packageInfo.version,
|
|
819
|
+
env: context.env,
|
|
820
|
+
signal,
|
|
821
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
822
|
+
consume: ({ plugin, source }) => projectPluginContentOverview({
|
|
823
|
+
pluginId,
|
|
824
|
+
catalogVersion: source.manifest.catalogVersion,
|
|
825
|
+
plugin,
|
|
826
|
+
}),
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
catch {
|
|
830
|
+
signal.throwIfAborted();
|
|
831
|
+
const summary = sessionStatusResult?.pluginSummaries.find((entry) => entry.pluginId === pluginId);
|
|
832
|
+
let sourceId;
|
|
833
|
+
try {
|
|
834
|
+
sourceId = parsePluginId(pluginId).sourceId;
|
|
835
|
+
}
|
|
836
|
+
catch {
|
|
837
|
+
// The fixed unavailable result below does not repeat an unsafe selector.
|
|
838
|
+
}
|
|
839
|
+
const catalogVersion = sessionStatusResult?.payload.catalog.sources
|
|
840
|
+
.find((source) => source.id === sourceId)?.catalogVersion;
|
|
841
|
+
return {
|
|
842
|
+
pluginId,
|
|
843
|
+
pluginVersion: summary?.version ?? '待确认',
|
|
844
|
+
catalogVersion: catalogVersion ?? '待确认',
|
|
845
|
+
evidence: 'unavailable',
|
|
846
|
+
items: [],
|
|
847
|
+
notices: ['当前无法安全读取这个插件的目录内容。请检查来源状态后重试。'],
|
|
848
|
+
coverage: 'unavailable',
|
|
849
|
+
coverageIssue: {
|
|
850
|
+
code: 'unreadable',
|
|
851
|
+
message: '当前无法安全读取这个插件的目录内容。请检查来源状态后重试。',
|
|
852
|
+
},
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
const captureEvidence = async (intent, signal, preparation, operationInventory = createOperationInventoryReader(), freshCatalog = false, reusableCandidate) => {
|
|
857
|
+
if (intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch'
|
|
858
|
+
|| intent.kind === 'pluginWriteTask') {
|
|
859
|
+
throw new TuiOperationBlockedError('useScopedRecovery', '请使用统一范围恢复任务。');
|
|
860
|
+
}
|
|
861
|
+
reviewedScriptTimeoutMs(intent);
|
|
862
|
+
if ((intent.kind === 'configSave' || intent.kind === 'configSaveBatch' || intent.kind === 'configReset')
|
|
863
|
+
&& intent.context === 'project') {
|
|
864
|
+
await resolveWorkContext({ cwd: context.cwd, context: 'project' });
|
|
865
|
+
signal?.throwIfAborted();
|
|
866
|
+
}
|
|
867
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
868
|
+
signal?.throwIfAborted();
|
|
869
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
870
|
+
const catalogStore = await prepareCatalogStoreTask({ env: context.env });
|
|
871
|
+
signal?.throwIfAborted();
|
|
872
|
+
return {
|
|
873
|
+
catalog: { configDigest: config.digest, compositeDigest: config.digest },
|
|
874
|
+
catalogStore,
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
if (intent.kind === 'configSaveBatch') {
|
|
878
|
+
assertConfigSaveBatchIntent(intent);
|
|
879
|
+
const groupEvidence = [];
|
|
880
|
+
let batchBase;
|
|
881
|
+
let batchCatalogOperation;
|
|
882
|
+
for (const group of intent.groups) {
|
|
883
|
+
const current = await captureEvidence(configSaveBatchGroupIntent(intent, group), signal, preparation, operationInventory, freshCatalog, reusableCandidate);
|
|
884
|
+
if (!current.config || !current.source || !current.targetFingerprint) {
|
|
885
|
+
throw operationReviewStale('设置批次缺少单层证据。');
|
|
886
|
+
}
|
|
887
|
+
if (batchBase && (JSON.stringify(batchBase.catalog) !== JSON.stringify(current.catalog)
|
|
888
|
+
|| JSON.stringify(batchBase.source) !== JSON.stringify(current.source))) {
|
|
889
|
+
throw operationReviewStale('准备设置批次期间 Catalog 或来源发生变化。');
|
|
890
|
+
}
|
|
891
|
+
for (const expected of Object.values(group.editEvidence ?? {})) {
|
|
892
|
+
if (expected.sourceIdentity !== current.source.sourceIdentity
|
|
893
|
+
|| expected.schemaIdentity !== current.config.schemaIdentity
|
|
894
|
+
|| expected.platform !== group.platform
|
|
895
|
+
|| (expected.context ?? 'user') !== (intent.context ?? 'user')) {
|
|
896
|
+
throw operationReviewStale('编辑期间插件来源或设置定义已变化,请重新打开列表。');
|
|
897
|
+
}
|
|
898
|
+
for (const scope of ['user']) {
|
|
899
|
+
if (expected.storeDigests[scope] === undefined)
|
|
900
|
+
continue;
|
|
901
|
+
const currentDigest = await configLayerStoreDigest({
|
|
902
|
+
source: current.source, pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
903
|
+
scope, cwd: context.cwd, env: context.env,
|
|
904
|
+
});
|
|
905
|
+
if (expected.storeDigests[scope] !== currentDigest) {
|
|
906
|
+
throw operationReviewStale('编辑期间设置已被外部修改,请重新打开列表。');
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
batchBase ??= current;
|
|
911
|
+
batchCatalogOperation ??= catalogOperationByEvidence.get(current);
|
|
912
|
+
groupEvidence.push({
|
|
913
|
+
scope: 'user',
|
|
914
|
+
platform: group.platform,
|
|
915
|
+
config: {
|
|
916
|
+
...current.config,
|
|
917
|
+
storeDigest: await configLayerStoreDigest({
|
|
918
|
+
source: current.source,
|
|
919
|
+
pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
920
|
+
scope: 'user',
|
|
921
|
+
platform: group.platform,
|
|
922
|
+
profileOnly: true,
|
|
923
|
+
cwd: context.cwd,
|
|
924
|
+
env: context.env,
|
|
925
|
+
}),
|
|
926
|
+
},
|
|
927
|
+
targetFingerprint: current.targetFingerprint,
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
const evidence = {
|
|
931
|
+
catalog: batchBase.catalog,
|
|
932
|
+
source: batchBase.source,
|
|
933
|
+
configBatch: { groups: groupEvidence },
|
|
934
|
+
};
|
|
935
|
+
if (batchCatalogOperation)
|
|
936
|
+
catalogOperationByEvidence.set(evidence, batchCatalogOperation);
|
|
937
|
+
return evidence;
|
|
938
|
+
}
|
|
939
|
+
if (intent.kind === 'configReset') {
|
|
940
|
+
const parsed = parsePluginId(intent.pluginId);
|
|
941
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
942
|
+
throw new TuiOperationBlockedError('invalidPluginId', '设置目标必须使用 canonical pluginId。');
|
|
943
|
+
}
|
|
944
|
+
await preparation?.reporter.emit('config');
|
|
945
|
+
const target = await inspectPluginConfigResetTarget({
|
|
946
|
+
sourceId: parsed.sourceId,
|
|
947
|
+
pluginName: parsed.pluginName,
|
|
948
|
+
scope: 'user',
|
|
949
|
+
cwd: context.cwd,
|
|
950
|
+
env: context.env,
|
|
951
|
+
});
|
|
588
952
|
signal?.throwIfAborted();
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
953
|
+
if (target.kind === 'special') {
|
|
954
|
+
throw new TuiOperationBlockedError('configResetTargetUnsupported', '设置目标是特殊文件系统节点,不能自动重置。请手动移动后重试。');
|
|
955
|
+
}
|
|
956
|
+
const relevantTargets = sessionRecoveryStatus
|
|
957
|
+
? currentConfigTargets(sessionRecoveryStatus, intent.pluginId, intent.context ?? 'user', [], intent.platform)
|
|
958
|
+
: [];
|
|
959
|
+
let selected;
|
|
960
|
+
try {
|
|
961
|
+
const packageInfo = await readCliPackageInfo();
|
|
962
|
+
selected = await withResolvedCatalogPlugin({
|
|
963
|
+
selector: intent.pluginId,
|
|
964
|
+
cliVersion: packageInfo.version,
|
|
965
|
+
env: context.env,
|
|
966
|
+
...(preparation && sessionContextForPlugin(intent.pluginId)
|
|
967
|
+
? { operationContext: sessionContextForPlugin(intent.pluginId) }
|
|
968
|
+
: {}),
|
|
969
|
+
...(signal ? { signal } : {}),
|
|
970
|
+
consume: async ({ plugin, source: resolvedSource }) => ({
|
|
971
|
+
source: sourceEvidenceForPlugin(resolvedSource, plugin.manifest.name),
|
|
972
|
+
impact: await analyzePluginConfigMutationImpact({
|
|
973
|
+
plugin,
|
|
974
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
975
|
+
cwd: context.cwd,
|
|
976
|
+
env: context.env,
|
|
977
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, relevantTargets),
|
|
978
|
+
mutation: { kind: 'reset' },
|
|
979
|
+
}),
|
|
980
|
+
}),
|
|
981
|
+
});
|
|
593
982
|
}
|
|
594
|
-
|
|
595
|
-
|
|
983
|
+
catch (error) {
|
|
984
|
+
if (error?.code === 'configValidationMemoryExhausted')
|
|
985
|
+
throw error;
|
|
986
|
+
selected = undefined;
|
|
596
987
|
}
|
|
597
|
-
|
|
988
|
+
signal?.throwIfAborted();
|
|
989
|
+
await preparation?.reporter.emit('evidence');
|
|
598
990
|
return {
|
|
599
|
-
catalog: {
|
|
600
|
-
configDigest:
|
|
601
|
-
compositeDigest:
|
|
602
|
-
|
|
603
|
-
|
|
991
|
+
catalog: sessionStatusResult ? {
|
|
992
|
+
configDigest: sessionStatusResult.payload.catalog.configDigest,
|
|
993
|
+
compositeDigest: sessionStatusResult.payload.catalog.compositeDigest,
|
|
994
|
+
} : {
|
|
995
|
+
configDigest: 'config-reset-offline',
|
|
996
|
+
compositeDigest: 'config-reset-target',
|
|
997
|
+
},
|
|
998
|
+
...(selected ? { source: selected.source } : {}),
|
|
999
|
+
...(sessionStatusResult ? {
|
|
1000
|
+
targetFingerprint: currentTargetFingerprint(sessionRecoveryStatus, relevantTargets),
|
|
1001
|
+
} : {}),
|
|
1002
|
+
config: {
|
|
1003
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
1004
|
+
storeDigest: selected?.impact.storeDigest ?? target.fingerprint,
|
|
1005
|
+
impactState: selected?.impact.impactState ?? 'unknown',
|
|
1006
|
+
...(selected?.impact.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
1007
|
+
...(selected?.impact.affectedCommandPackages.length
|
|
1008
|
+
? { commandPackages: selected.impact.affectedCommandPackages } : {}),
|
|
1009
|
+
affectedTargets: (selected?.impact.affectedTargets
|
|
1010
|
+
?? relevantTargets).map(({ platform, scope }) => ({ platform, scope })),
|
|
1011
|
+
...((selected?.impact.sharedNativeRenderUnits.length ?? 0) > 0
|
|
1012
|
+
? { sharedNativeRenderUnits: selected.impact.sharedNativeRenderUnits }
|
|
604
1013
|
: {}),
|
|
605
1014
|
},
|
|
606
|
-
|
|
607
|
-
sourceId:
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
1015
|
+
resetTarget: {
|
|
1016
|
+
sourceId: parsed.sourceId,
|
|
1017
|
+
pluginName: parsed.pluginName,
|
|
1018
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
1019
|
+
kind: target.kind,
|
|
1020
|
+
fingerprint: target.fingerprint,
|
|
1021
|
+
},
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
if (intent.kind === 'catalogSourcesRecovery') {
|
|
1025
|
+
signal?.throwIfAborted();
|
|
1026
|
+
await preparation?.reporter.emit('validate');
|
|
1027
|
+
await preparation?.reporter.emit('evidence');
|
|
1028
|
+
return {
|
|
1029
|
+
catalog: {
|
|
1030
|
+
configDigest: 'invalid-catalog-sources-config',
|
|
1031
|
+
compositeDigest: 'bootstrap-recovery',
|
|
1032
|
+
},
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
if (intent.kind === 'catalogGeneration') {
|
|
1036
|
+
signal?.throwIfAborted();
|
|
1037
|
+
await preparation?.reporter.emit('validate');
|
|
1038
|
+
const packageInfo = await readCliPackageInfo();
|
|
1039
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
1040
|
+
const configuredSource = config.config.sources.find((source) => source.id === intent.sourceId);
|
|
1041
|
+
let proposedSource;
|
|
1042
|
+
let proposedConfigDigest;
|
|
1043
|
+
let explicitSourceChange = false;
|
|
1044
|
+
let sourceIdentityChangeImpact;
|
|
1045
|
+
if (intent.sourceMutation) {
|
|
1046
|
+
const preview = await preflightCatalogSourceMutation({
|
|
1047
|
+
request: intent.sourceMutation.action === 'add'
|
|
1048
|
+
? intent.sourceMutation
|
|
1049
|
+
: { action: 'update', sourceId: intent.sourceId, update: intent.sourceMutation.update },
|
|
1050
|
+
cwd: context.cwd,
|
|
1051
|
+
env: context.env,
|
|
1052
|
+
});
|
|
1053
|
+
proposedSource = preview.proposedSource;
|
|
1054
|
+
proposedConfigDigest = preview.proposedConfigDigest;
|
|
1055
|
+
if (preview.configDigest !== config.digest) {
|
|
1056
|
+
throw operationReviewStale('准备 Catalog 候选期间来源配置发生变化。');
|
|
1057
|
+
}
|
|
1058
|
+
const sourceFingerprintChanged = Boolean(proposedSource && (!configuredSource
|
|
1059
|
+
|| calculateCatalogSourceConfigFingerprint(proposedSource)
|
|
1060
|
+
!== calculateCatalogSourceConfigFingerprint(configuredSource)));
|
|
1061
|
+
explicitSourceChange = preview.proposedConfigDigest !== preview.configDigest
|
|
1062
|
+
&& (preview.identityChanged || sourceFingerprintChanged);
|
|
1063
|
+
if (preview.identityChanged)
|
|
1064
|
+
sourceIdentityChangeImpact = {
|
|
1065
|
+
impactSchemaVersion: 3,
|
|
1066
|
+
sourceId: preview.sourceId,
|
|
1067
|
+
primaryChange: preview.references.primaryChange,
|
|
1068
|
+
inventoryComplete: preview.references.inventoryComplete,
|
|
1069
|
+
references: preview.references.references,
|
|
1070
|
+
affectedReferences: preview.references.references,
|
|
1071
|
+
changes: {
|
|
1072
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1073
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1074
|
+
},
|
|
1075
|
+
errors: preview.references.errors,
|
|
1076
|
+
};
|
|
1077
|
+
if (!explicitSourceChange) {
|
|
1078
|
+
throw new TuiOperationBlockedError('sourceNoChanges', '来源没有变化。');
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
let previousActive;
|
|
1082
|
+
let healthyActive;
|
|
1083
|
+
let previousActiveVersion;
|
|
1084
|
+
let previousStoreReady = false;
|
|
1085
|
+
try {
|
|
1086
|
+
previousActive = (await readCatalogGenerationState(context.env))
|
|
1087
|
+
.sources[intent.sourceId]?.active;
|
|
1088
|
+
}
|
|
1089
|
+
catch (error) {
|
|
1090
|
+
if (intent.action !== 'recoverState'
|
|
1091
|
+
|| !(error instanceof CatalogGenerationError)
|
|
1092
|
+
|| error.code !== 'catalogGenerationStateInvalid')
|
|
1093
|
+
throw error;
|
|
1094
|
+
}
|
|
1095
|
+
const activeStoreKey = previousActive
|
|
1096
|
+
? createCatalogStoreKey(previousActive.logicalIdentity, previousActive.snapshotDigest)
|
|
1097
|
+
: null;
|
|
1098
|
+
const configuredFingerprint = configuredSource
|
|
1099
|
+
? calculateCatalogSourceConfigFingerprint(configuredSource)
|
|
1100
|
+
: undefined;
|
|
1101
|
+
const canReuseCandidate = Boolean(reusableCandidate
|
|
1102
|
+
&& !intent.sourceMutation
|
|
1103
|
+
&& (intent.action === 'activate' || intent.action === 'update')
|
|
1104
|
+
&& configuredFingerprint
|
|
1105
|
+
&& reusableCandidate.sourceId === intent.sourceId
|
|
1106
|
+
&& reusableCandidate.sourceConfigFingerprint === configuredFingerprint
|
|
1107
|
+
&& reusableCandidate.probe.candidate.sourceConfigFingerprint === configuredFingerprint
|
|
1108
|
+
&& reusableCandidate.activeStoreKey === activeStoreKey
|
|
1109
|
+
&& reusableCandidate.probe.sourceId === intent.sourceId
|
|
1110
|
+
&& reusableCandidateEvidenceIsComplete(reusableCandidate));
|
|
1111
|
+
const probe = intent.action === 'repair'
|
|
1112
|
+
? await probeCatalogSourceRepairGeneration({
|
|
1113
|
+
sourceId: intent.sourceId,
|
|
1114
|
+
cliVersion: packageInfo.version,
|
|
1115
|
+
...(previousActive ? { expectedActive: previousActive } : {}),
|
|
1116
|
+
expectedConfigDigest: config.digest,
|
|
1117
|
+
env: context.env,
|
|
1118
|
+
signal,
|
|
1119
|
+
runtime: options.catalogGenerationRuntime,
|
|
1120
|
+
})
|
|
1121
|
+
: canReuseCandidate
|
|
1122
|
+
? structuredClone(reusableCandidate.probe)
|
|
1123
|
+
: await probeCatalogSourceGeneration({
|
|
1124
|
+
sourceId: intent.sourceId,
|
|
1125
|
+
...(proposedSource ? { source: proposedSource } : {}),
|
|
1126
|
+
cliVersion: packageInfo.version,
|
|
1127
|
+
env: context.env,
|
|
1128
|
+
signal,
|
|
1129
|
+
runtime: options.catalogGenerationRuntime,
|
|
1130
|
+
});
|
|
1131
|
+
signal?.throwIfAborted();
|
|
1132
|
+
await preparation?.reporter.emit('evidence');
|
|
1133
|
+
if (intent.action === 'activate' || intent.action === 'update') {
|
|
1134
|
+
try {
|
|
1135
|
+
healthyActive = await resolveActiveCatalogGeneration({ sourceId: intent.sourceId, env: context.env });
|
|
1136
|
+
}
|
|
1137
|
+
catch (error) {
|
|
1138
|
+
if (!(error instanceof CatalogGenerationError)
|
|
1139
|
+
&& !(error instanceof CatalogProviderCompatibilityError))
|
|
1140
|
+
throw error;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const comparisonSource = proposedSource
|
|
1144
|
+
?? configuredSource;
|
|
1145
|
+
if (previousActive) {
|
|
1146
|
+
const store = await readCatalogStoreEntry({
|
|
1147
|
+
logicalIdentity: previousActive.logicalIdentity,
|
|
1148
|
+
snapshotDigest: previousActive.snapshotDigest,
|
|
1149
|
+
env: context.env,
|
|
1150
|
+
}).catch(() => undefined);
|
|
1151
|
+
previousStoreReady = Boolean(store);
|
|
1152
|
+
previousActiveVersion = healthyActive?.catalogVersion
|
|
1153
|
+
?? store?.metadata.catalogVersion;
|
|
1154
|
+
}
|
|
1155
|
+
if (intent.action === 'update' && !intent.sourceMutation && previousActive && comparisonSource) {
|
|
1156
|
+
explicitSourceChange = previousActive.sourceConfigFingerprint
|
|
1157
|
+
!== calculateCatalogSourceConfigFingerprint(comparisonSource)
|
|
1158
|
+
|| previousActive.sourceIdentity !== await calculateCatalogSourceIdentity(comparisonSource);
|
|
1159
|
+
}
|
|
1160
|
+
const comparisonActive = healthyActive
|
|
1161
|
+
? {
|
|
1162
|
+
logicalIdentity: healthyActive.logicalIdentity,
|
|
1163
|
+
catalogVersion: healthyActive.catalogVersion,
|
|
1164
|
+
snapshotDigest: healthyActive.snapshotDigest,
|
|
1165
|
+
resolvedCommit: healthyActive.resolvedCommit,
|
|
1166
|
+
}
|
|
1167
|
+
: previousActive && previousActiveVersion
|
|
1168
|
+
? {
|
|
1169
|
+
logicalIdentity: previousActive.logicalIdentity,
|
|
1170
|
+
catalogVersion: previousActiveVersion,
|
|
1171
|
+
snapshotDigest: previousActive.snapshotDigest,
|
|
1172
|
+
resolvedCommit: previousActive.resolvedCommit,
|
|
1173
|
+
}
|
|
1174
|
+
: undefined;
|
|
1175
|
+
const candidateRelation = comparisonActive && comparisonSource
|
|
1176
|
+
? compareCatalogGenerationFreshness({
|
|
1177
|
+
sourceType: comparisonSource.type,
|
|
1178
|
+
active: comparisonActive,
|
|
1179
|
+
candidate: probe.candidate,
|
|
1180
|
+
}).state
|
|
1181
|
+
: undefined;
|
|
1182
|
+
const exactStoreTarget = Boolean(previousActive)
|
|
1183
|
+
&& createCatalogStoreKey(previousActive.logicalIdentity, previousActive.snapshotDigest)
|
|
1184
|
+
=== createCatalogStoreKey(probe.candidate.logicalIdentity, probe.candidate.snapshotDigest);
|
|
1185
|
+
if (intent.action === 'repair' && !exactStoreTarget) {
|
|
1186
|
+
throw new CatalogGenerationError({
|
|
1187
|
+
code: 'catalogReplaceDamagedRequired', sourceId: intent.sourceId,
|
|
1188
|
+
message: `Catalog source "${intent.sourceId}" cannot reproduce the damaged Active entry. Use the current candidate replacement Review.`,
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
const exactRepair = (intent.action === 'repair' || intent.action === 'update')
|
|
1192
|
+
&& exactStoreTarget && !previousStoreReady;
|
|
1193
|
+
if (previousActive && !previousStoreReady && !exactStoreTarget
|
|
1194
|
+
&& !intent.sourceMutation && intent.action !== 'replaceDamaged') {
|
|
1195
|
+
throw new CatalogGenerationError({
|
|
1196
|
+
code: 'catalogReplaceDamagedRequired',
|
|
1197
|
+
sourceId: intent.sourceId,
|
|
1198
|
+
message: `Catalog source "${intent.sourceId}" has a damaged Active entry whose version cannot be compared safely. The current Active remains unchanged. Edit the source explicitly, or remove and add it again.`,
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
if (intent.action !== 'replaceDamaged' && !explicitSourceChange && candidateRelation === 'incompatible') {
|
|
1202
|
+
throw new CatalogGenerationError({
|
|
1203
|
+
code: 'catalogLogicalIdentityChanged', sourceId: intent.sourceId,
|
|
1204
|
+
message: `Catalog source "${intent.sourceId}" changed logical identity. Edit or remove and re-add the source.`,
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
if (intent.action !== 'replaceDamaged' && !explicitSourceChange && candidateRelation === 'versionConflict') {
|
|
1208
|
+
throw new TuiOperationBlockedError('catalogVersionConflict', '候选 Catalog 与当前 Active 版本相同,但内容摘要不同。普通更新已阻止。');
|
|
1209
|
+
}
|
|
1210
|
+
if (intent.action !== 'replaceDamaged' && !explicitSourceChange && candidateRelation === 'rollbackDetected') {
|
|
1211
|
+
throw new TuiOperationBlockedError('catalogRollbackDetected', '候选 Catalog 版本低于当前 Active。普通更新已阻止。');
|
|
1212
|
+
}
|
|
1213
|
+
const impact = exactRepair ? undefined
|
|
1214
|
+
: sourceIdentityChangeImpact ?? await inspectCatalogSourceImpact({
|
|
1215
|
+
sourceId: intent.sourceId,
|
|
1216
|
+
cwd: context.cwd,
|
|
1217
|
+
env: context.env,
|
|
1218
|
+
sourcePrimary: comparisonSource?.primary === true,
|
|
1219
|
+
mode: 'generation',
|
|
1220
|
+
candidateManifest: probe.manifest,
|
|
1221
|
+
});
|
|
1222
|
+
const primaryPreview = intent.setPrimaryAfterActivation
|
|
1223
|
+
? await preflightCatalogSourceMutation({
|
|
1224
|
+
request: { action: 'setPrimary', sourceId: intent.sourceId },
|
|
1225
|
+
cwd: context.cwd,
|
|
1226
|
+
env: context.env,
|
|
1227
|
+
})
|
|
1228
|
+
: undefined;
|
|
1229
|
+
if (primaryPreview && primaryPreview.configDigest !== config.digest) {
|
|
1230
|
+
throw operationReviewStale('准备主来源切换期间来源配置发生变化。');
|
|
1231
|
+
}
|
|
1232
|
+
const primaryImpact = primaryPreview ? {
|
|
1233
|
+
impactSchemaVersion: 3,
|
|
1234
|
+
sourceId: primaryPreview.sourceId,
|
|
1235
|
+
primaryChange: primaryPreview.references.primaryChange,
|
|
1236
|
+
inventoryComplete: primaryPreview.references.inventoryComplete,
|
|
1237
|
+
references: primaryPreview.references.references,
|
|
1238
|
+
affectedReferences: primaryPreview.references.references,
|
|
1239
|
+
changes: {
|
|
1240
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1241
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1242
|
+
},
|
|
1243
|
+
errors: primaryPreview.references.errors,
|
|
1244
|
+
} : undefined;
|
|
1245
|
+
return {
|
|
1246
|
+
catalog: {
|
|
1247
|
+
configDigest: config.digest,
|
|
1248
|
+
compositeDigest: probe.candidate.snapshotDigest,
|
|
1249
|
+
},
|
|
1250
|
+
catalogGeneration: {
|
|
1251
|
+
action: intent.action,
|
|
1252
|
+
...(previousActive ? { previousActive } : {}),
|
|
1253
|
+
...(previousActiveVersion ? { previousActiveVersion } : {}),
|
|
1254
|
+
candidate: probe.candidate,
|
|
1255
|
+
...(candidateRelation ? { candidateRelation } : {}),
|
|
1256
|
+
...(explicitSourceChange ? { explicitSourceChange: true } : {}),
|
|
1257
|
+
...(exactRepair ? { exactRepair: true } : {}),
|
|
1258
|
+
activationMode: intent.action === 'replaceDamaged' ? 'replaceDamaged'
|
|
1259
|
+
: explicitSourceChange ? 'explicitSourceChange' : 'normal',
|
|
1260
|
+
...(impact ? {
|
|
1261
|
+
impact,
|
|
1262
|
+
impactDigest: calculateCatalogSourceImpactDigest(impact),
|
|
1263
|
+
impactMode: sourceIdentityChangeImpact ? 'identityChange' : 'generation',
|
|
1264
|
+
} : {}),
|
|
1265
|
+
...(primaryPreview && primaryImpact ? {
|
|
1266
|
+
primaryImpact,
|
|
1267
|
+
primaryImpactDigest: primaryPreview.impactDigest,
|
|
1268
|
+
primaryConfigDigest: primaryPreview.configDigest,
|
|
1269
|
+
} : {}),
|
|
1270
|
+
configDigest: config.digest,
|
|
1271
|
+
...(proposedConfigDigest ? { proposedConfigDigest } : {}),
|
|
1272
|
+
...(proposedSource ? { proposedSource } : {}),
|
|
1273
|
+
...(intent.sourceMutation ? { sourceMutation: intent.sourceMutation } : {}),
|
|
1274
|
+
...(intent.setPrimaryAfterActivation ? { setPrimaryAfterActivation: true } : {}),
|
|
615
1275
|
},
|
|
616
1276
|
};
|
|
617
1277
|
}
|
|
@@ -636,49 +1296,54 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
636
1296
|
await preparation?.reporter.emit('evidence');
|
|
637
1297
|
signal?.throwIfAborted();
|
|
638
1298
|
const evidence = {
|
|
639
|
-
catalog: { configDigest: preview.configDigest, compositeDigest: preview.
|
|
1299
|
+
catalog: { configDigest: preview.configDigest, compositeDigest: preview.proposedConfigDigest },
|
|
640
1300
|
sourceWrite: {
|
|
641
1301
|
configDigest: preview.configDigest,
|
|
642
|
-
|
|
1302
|
+
proposedConfigDigest: preview.proposedConfigDigest,
|
|
643
1303
|
...(preview.sourceIdentity ? { sourceIdentity: preview.sourceIdentity } : {}),
|
|
644
1304
|
inventoryDigest: digest({ references: preview.references.references, errors: preview.references.errors }),
|
|
1305
|
+
impactDigest: preview.impactDigest,
|
|
645
1306
|
referenceCount: preview.references.references.length,
|
|
646
|
-
inventoryComplete: preview.references.
|
|
1307
|
+
inventoryComplete: preview.references.inventoryComplete,
|
|
1308
|
+
impact: {
|
|
1309
|
+
impactSchemaVersion: 3,
|
|
1310
|
+
sourceId: preview.sourceId,
|
|
1311
|
+
primaryChange: preview.references.primaryChange,
|
|
1312
|
+
inventoryComplete: preview.references.inventoryComplete,
|
|
1313
|
+
references: preview.references.references,
|
|
1314
|
+
affectedReferences: preview.references.references,
|
|
1315
|
+
changes: {
|
|
1316
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1317
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1318
|
+
},
|
|
1319
|
+
errors: preview.references.errors,
|
|
1320
|
+
},
|
|
647
1321
|
},
|
|
648
1322
|
};
|
|
649
1323
|
if (preparation?.validateIntent
|
|
650
|
-
&& evidence.sourceWrite?.configDigest === evidence.sourceWrite?.
|
|
1324
|
+
&& evidence.sourceWrite?.configDigest === evidence.sourceWrite?.proposedConfigDigest) {
|
|
651
1325
|
throw new TuiOperationBlockedError('sourceNoChanges', '来源没有变化。');
|
|
652
1326
|
}
|
|
653
1327
|
return evidence;
|
|
654
1328
|
}
|
|
655
|
-
if (
|
|
1329
|
+
if (intent.kind !== 'configSave'
|
|
1330
|
+
&& intent.kind !== 'portableInstall') {
|
|
656
1331
|
throw new TuiOperationBlockedError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
|
|
657
1332
|
}
|
|
658
1333
|
signal?.throwIfAborted();
|
|
659
1334
|
const packageInfo = await readCliPackageInfo();
|
|
660
|
-
const offlineCleanupReason = intent.kind === 'pluginWrite'
|
|
661
|
-
&& intent.action === 'cleanup'
|
|
662
|
-
&& intent.originIssue?.actionId === 'cleanup'
|
|
663
|
-
&& (intent.originIssue?.category === 'sourceMissing'
|
|
664
|
-
|| intent.originIssue?.category === 'sourceUnavailable')
|
|
665
|
-
? intent.originIssue.category === 'sourceMissing' ? 'sourceMissing' : 'bundleUnavailable'
|
|
666
|
-
: undefined;
|
|
667
1335
|
let catalogOperation;
|
|
668
1336
|
let catalogOperationError;
|
|
669
|
-
if (
|
|
670
|
-
&& sessionCatalogOperationContext) {
|
|
1337
|
+
if (intent.kind !== 'portableInstall') {
|
|
671
1338
|
try {
|
|
672
1339
|
const sourceIds = [parsePluginId(intent.pluginId).sourceId];
|
|
673
|
-
catalogOperation =
|
|
1340
|
+
catalogOperation = !freshCatalog && sessionCatalogOperationContext
|
|
674
1341
|
? selectCatalogOperationContext(sessionCatalogOperationContext, sourceIds)
|
|
675
1342
|
: await resolveCatalogOperationContext({
|
|
676
|
-
cliVersion: packageInfo.version,
|
|
677
1343
|
sourceIds,
|
|
678
1344
|
env: context.env,
|
|
679
|
-
...(
|
|
1345
|
+
...(!freshCatalog ? { validatedStoreEntries, validatingStoreEntries } : {}),
|
|
680
1346
|
...(signal ? { signal } : {}),
|
|
681
|
-
...(!bootstrapMissingActive ? { bootstrapMissingActive: false } : {}),
|
|
682
1347
|
});
|
|
683
1348
|
}
|
|
684
1349
|
catch (error) {
|
|
@@ -687,27 +1352,43 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
687
1352
|
}
|
|
688
1353
|
if (intent.kind === 'portableInstall') {
|
|
689
1354
|
await preparation?.reporter.emit('portable');
|
|
1355
|
+
if (intent.retry
|
|
1356
|
+
&& (intent.retry.receipt.plugin.id !== intent.pluginId
|
|
1357
|
+
|| intent.retry.receipt.scope !== intent.scope)) {
|
|
1358
|
+
throw operationReviewStale('Portable 重试结果与当前插件或范围不匹配。');
|
|
1359
|
+
}
|
|
690
1360
|
const portableSourceId = parsePluginId(intent.pluginId).sourceId;
|
|
691
1361
|
const portableCatalogOperation = sessionCatalogOperationContext
|
|
692
1362
|
? selectCatalogOperationContext(sessionCatalogOperationContext, [portableSourceId])
|
|
693
1363
|
: undefined;
|
|
694
|
-
const portable =
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1364
|
+
const portable = intent.retry
|
|
1365
|
+
? await preparePortableRetry({
|
|
1366
|
+
receipt: intent.retry.receipt,
|
|
1367
|
+
cwd: context.cwd,
|
|
1368
|
+
env: context.env,
|
|
1369
|
+
cliVersion: packageInfo.version,
|
|
1370
|
+
signal,
|
|
1371
|
+
...(portableCatalogOperation
|
|
1372
|
+
? { catalogOperationContext: portableCatalogOperation }
|
|
1373
|
+
: {}),
|
|
1374
|
+
})
|
|
1375
|
+
: await preparePortableInstall({
|
|
1376
|
+
selector: intent.pluginId,
|
|
1377
|
+
scope: intent.scope,
|
|
1378
|
+
...(intent.selectedSkills.length > 0 ? { requestedSkills: intent.selectedSkills } : {}),
|
|
1379
|
+
...(intent.requestedAgents ? { requestedAgents: intent.requestedAgents } : {}),
|
|
1380
|
+
cwd: context.cwd,
|
|
1381
|
+
env: context.env,
|
|
1382
|
+
cliVersion: packageInfo.version,
|
|
1383
|
+
signal,
|
|
1384
|
+
...(portableCatalogOperation
|
|
1385
|
+
? { catalogOperationContext: portableCatalogOperation }
|
|
1386
|
+
: {}),
|
|
1387
|
+
});
|
|
1388
|
+
signal?.throwIfAborted();
|
|
1389
|
+
await preparation?.reporter.emit('evidence');
|
|
1390
|
+
signal?.throwIfAborted();
|
|
1391
|
+
const evidence = {
|
|
711
1392
|
catalog: {
|
|
712
1393
|
configDigest: portable.configDigest,
|
|
713
1394
|
compositeDigest: portable.evidenceDigest,
|
|
@@ -721,8 +1402,103 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
721
1402
|
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
722
1403
|
return evidence;
|
|
723
1404
|
}
|
|
724
|
-
if (
|
|
725
|
-
|
|
1405
|
+
if (intent.kind === 'configSave' && intent.retryApply) {
|
|
1406
|
+
await preparation?.reporter.emit('config');
|
|
1407
|
+
if (!catalogOperation)
|
|
1408
|
+
throw catalogOperationError ?? operationReviewStale('无法取得设置应用所需的 Catalog。');
|
|
1409
|
+
const selectedCatalogOperation = catalogOperation;
|
|
1410
|
+
const evidence = await withResolvedCatalogPlugin({
|
|
1411
|
+
selector: intent.pluginId, cliVersion: packageInfo.version, env: context.env,
|
|
1412
|
+
...(selectedCatalogOperation ? { operationContext: selectedCatalogOperation } : {}),
|
|
1413
|
+
...(signal ? { signal } : {}),
|
|
1414
|
+
consume: async ({ plugin, source }) => {
|
|
1415
|
+
const referencePlugins = await resolvePluginConfigReferencePlugins({
|
|
1416
|
+
sourceId: plugin.sourceId, sourceIdentity: plugin.sourceIdentity,
|
|
1417
|
+
logicalIdentity: plugin.catalogLogicalIdentity, env: context.env,
|
|
1418
|
+
operationContext: selectedCatalogOperation,
|
|
1419
|
+
});
|
|
1420
|
+
const prepared = await preparePluginConfigApply({
|
|
1421
|
+
plugin, scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1422
|
+
...(intent.targets ? { targets: intent.targets } : {}),
|
|
1423
|
+
cwd: context.cwd, env: context.env, cliVersion: packageInfo.version,
|
|
1424
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
1425
|
+
rebuildRuntime: {
|
|
1426
|
+
...context,
|
|
1427
|
+
referencePlugins,
|
|
1428
|
+
...(selectedCatalogOperation ? { catalogOperationContext: selectedCatalogOperation,
|
|
1429
|
+
expectedGenerationSetDigest: selectedCatalogOperation.generationSetDigest } : {}),
|
|
1430
|
+
...(reviewedScriptTimeoutMs(intent) === undefined ? {} : { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
1431
|
+
},
|
|
1432
|
+
});
|
|
1433
|
+
try {
|
|
1434
|
+
signal?.throwIfAborted();
|
|
1435
|
+
const targets = prepared.plan.receipt.requestedTargets
|
|
1436
|
+
.filter((target) => !prepared.plan.receipt.targetResults.some((result) => result.pluginId === target.pluginId && result.agent === target.agent && result.scope === target.scope
|
|
1437
|
+
&& (result.satisfaction === 'unsupported' || result.satisfaction === 'excluded')))
|
|
1438
|
+
.map((target) => ({
|
|
1439
|
+
pluginName: parsePluginId(target.pluginId).pluginName, platform: target.agent, scope: target.scope,
|
|
1440
|
+
}));
|
|
1441
|
+
return {
|
|
1442
|
+
catalog: {
|
|
1443
|
+
configDigest: selectedCatalogOperation.catalog.configDigest,
|
|
1444
|
+
compositeDigest: selectedCatalogOperation.catalog.compositeDigest,
|
|
1445
|
+
...(selectedCatalogOperation ? { generationSetDigest: selectedCatalogOperation.generationSetDigest } : {}),
|
|
1446
|
+
},
|
|
1447
|
+
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
1448
|
+
config: {
|
|
1449
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1450
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, intent.platform),
|
|
1451
|
+
storeDigest: digest(prepared.evidence),
|
|
1452
|
+
impactState: 'known', affectedTargets: targets,
|
|
1453
|
+
commandPackages: prepared.commandPackages,
|
|
1454
|
+
applyEvidence: prepared.evidence, applyChanges: prepared.plan.changes,
|
|
1455
|
+
commandReviewChanges: managedCommandRecoveryPlanChanges(prepared.plan),
|
|
1456
|
+
applyWarnings: prepared.plan.warnings,
|
|
1457
|
+
applyBlockers: [...new Map([
|
|
1458
|
+
...prepared.plan.receipt.blockers, ...prepared.plan.receipt.errors,
|
|
1459
|
+
...prepared.plan.receipt.targetResults.flatMap((target) => target.blockers),
|
|
1460
|
+
].map((item) => [`${item.code}\0${item.message}`, item])).values()],
|
|
1461
|
+
preApplyAuthorization: prepared.preApplyAuthorization,
|
|
1462
|
+
sharedNativeRenderUnits: await configRetrySharedNativeRenderUnits(plugin, targets.filter((target) => NATIVE_PLATFORM_TARGETS.includes(target.platform)), context.env, referencePlugins),
|
|
1463
|
+
},
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
finally {
|
|
1467
|
+
await disposePluginConfigApply(prepared.plan);
|
|
1468
|
+
}
|
|
1469
|
+
},
|
|
1470
|
+
});
|
|
1471
|
+
if (catalogOperation)
|
|
1472
|
+
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
1473
|
+
return evidence;
|
|
1474
|
+
}
|
|
1475
|
+
const needsReferencePlugins = intent.kind === 'configSave'
|
|
1476
|
+
&& await withResolvedCatalogPlugin({
|
|
1477
|
+
selector: intent.pluginId, cliVersion: packageInfo.version, env: context.env,
|
|
1478
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1479
|
+
...(signal ? { signal } : {}),
|
|
1480
|
+
consume: ({ plugin }) => configNeedsReferencePlugins(plugin),
|
|
1481
|
+
});
|
|
1482
|
+
const referencePlugins = needsReferencePlugins
|
|
1483
|
+
? await resolvePluginConfigReferencePlugins({
|
|
1484
|
+
sourceId: parsePluginId(intent.pluginId).sourceId,
|
|
1485
|
+
env: context.env,
|
|
1486
|
+
operationContext: catalogOperation,
|
|
1487
|
+
})
|
|
1488
|
+
: undefined;
|
|
1489
|
+
const configReferencePluginIds = intent.kind === 'configSave' && needsReferencePlugins
|
|
1490
|
+
? await withResolvedCatalogPlugin({
|
|
1491
|
+
selector: intent.pluginId, cliVersion: packageInfo.version, env: context.env,
|
|
1492
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1493
|
+
...(signal ? { signal } : {}),
|
|
1494
|
+
consume: async ({ plugin }) => (await resolvePluginConfigReferenceConsumers({
|
|
1495
|
+
plugin, env: context.env, plugins: referencePlugins,
|
|
1496
|
+
})).map((entry) => entry.pluginId ?? `${entry.sourceId}/${entry.manifest.name}`),
|
|
1497
|
+
})
|
|
1498
|
+
: [];
|
|
1499
|
+
if (preparation && intent.kind === 'configSave'
|
|
1500
|
+
&& sessionRecoveryStatus?.scope === (intent.context ?? 'user')) {
|
|
1501
|
+
if (!sessionStatusResult || !sessionRecoveryStatus || !catalogOperation) {
|
|
726
1502
|
throw operationReviewStale('当前 TUI session 没有可复用的设置证据。');
|
|
727
1503
|
}
|
|
728
1504
|
await preparation.reporter.emit('config');
|
|
@@ -731,316 +1507,422 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
731
1507
|
if (configSnapshot.digest !== sessionStatusResult.payload.catalog.configDigest) {
|
|
732
1508
|
throw operationReviewStale('准备设置确认期间来源配置发生变化。');
|
|
733
1509
|
}
|
|
1510
|
+
const relevantTargets = currentConfigTargets(sessionRecoveryStatus, intent.pluginId, intent.context ?? 'user', configReferencePluginIds, intent.platform);
|
|
1511
|
+
const preparedCatalogOperation = catalogOperation;
|
|
734
1512
|
const selected = await withResolvedCatalogPlugin({
|
|
735
1513
|
selector: intent.pluginId,
|
|
736
1514
|
cliVersion: packageInfo.version,
|
|
737
|
-
freshnessPolicy: 'cacheFirst',
|
|
738
1515
|
configSnapshot,
|
|
739
1516
|
env: context.env,
|
|
740
|
-
operationContext:
|
|
1517
|
+
operationContext: preparedCatalogOperation,
|
|
741
1518
|
...(signal ? { signal } : {}),
|
|
742
1519
|
consume: async ({ plugin, source }) => {
|
|
743
1520
|
if (!plugin.manifest.config) {
|
|
744
1521
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
745
1522
|
}
|
|
1523
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, intent.platform);
|
|
746
1524
|
if (intent.kind === 'configSave') {
|
|
747
1525
|
await coercePluginConfigUpdates({
|
|
748
|
-
schema:
|
|
1526
|
+
schema: definition.fields,
|
|
749
1527
|
updates: intent.updates ?? {},
|
|
750
1528
|
cwd: context.cwd,
|
|
751
1529
|
});
|
|
752
1530
|
for (const key of intent.removeKeys ?? []) {
|
|
753
|
-
if (!
|
|
1531
|
+
if (!definition.fields[key]) {
|
|
754
1532
|
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
755
1533
|
}
|
|
756
1534
|
}
|
|
757
1535
|
}
|
|
1536
|
+
const impact = intent.retryApply ? undefined : await analyzePluginConfigMutationImpact({
|
|
1537
|
+
plugin,
|
|
1538
|
+
referencePlugins,
|
|
1539
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1540
|
+
cwd: context.cwd,
|
|
1541
|
+
env: context.env,
|
|
1542
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, relevantTargets),
|
|
1543
|
+
mutation: {
|
|
1544
|
+
kind: 'patch',
|
|
1545
|
+
updates: intent.updates,
|
|
1546
|
+
removeKeys: intent.removeKeys,
|
|
1547
|
+
},
|
|
1548
|
+
});
|
|
1549
|
+
const affectedTargets = intent.retryApply
|
|
1550
|
+
? configImpactVisibleTargets(plugin.manifest.name, relevantTargets)
|
|
1551
|
+
: impact.affectedTargets;
|
|
1552
|
+
const commandPackages = impact?.affectedCommandPackages
|
|
1553
|
+
?? (await discoverPluginConfigManagedCommandPackages({ plugin, scope: intent.context ?? 'user',
|
|
1554
|
+
cwd: context.cwd, env: context.env ?? process.env, platformTargets: affectedTargets, referencePlugins })).packages;
|
|
1555
|
+
const preApplyAuthorization = configIntentRequestsApply(intent)
|
|
1556
|
+
? (await resolveConfigPreApplyAuthorization({
|
|
1557
|
+
plugin,
|
|
1558
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1559
|
+
cwd: context.cwd,
|
|
1560
|
+
env: context.env,
|
|
1561
|
+
applyTargets: affectedTargets,
|
|
1562
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
1563
|
+
rebuildRuntime: {
|
|
1564
|
+
referencePlugins,
|
|
1565
|
+
catalogOperationContext: preparedCatalogOperation,
|
|
1566
|
+
expectedGenerationSetDigest: preparedCatalogOperation.generationSetDigest,
|
|
1567
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1568
|
+
},
|
|
1569
|
+
})).targets
|
|
1570
|
+
: [];
|
|
758
1571
|
return {
|
|
759
1572
|
pluginName: plugin.manifest.name,
|
|
760
1573
|
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
1574
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, intent.platform),
|
|
1575
|
+
impact,
|
|
1576
|
+
commandPackages,
|
|
1577
|
+
preApplyAuthorization,
|
|
1578
|
+
retryStoreDigest: intent.retryApply ? await configRetryStoreDigest({ plugin, scope: intent.context ?? 'user', platform: intent.platform,
|
|
1579
|
+
targets: affectedTargets, commandPackages, preApplyAuthorization, cwd: context.cwd, env: context.env, plugins: referencePlugins }) : undefined,
|
|
1580
|
+
sharedNativeRenderUnits: intent.retryApply
|
|
1581
|
+
? await configRetrySharedNativeRenderUnits(plugin, affectedTargets, context.env, referencePlugins)
|
|
1582
|
+
: impact.sharedNativeRenderUnits,
|
|
761
1583
|
};
|
|
762
1584
|
},
|
|
763
1585
|
});
|
|
764
|
-
const store = await readPluginConfigStore({
|
|
765
|
-
sourceId: selected.source.sourceId,
|
|
766
|
-
sourceIdentity: selected.source.sourceIdentity,
|
|
767
|
-
pluginName: selected.pluginName,
|
|
768
|
-
scope: intent.scope,
|
|
769
|
-
projectLayer: intent.projectLayer,
|
|
770
|
-
cwd: context.cwd,
|
|
771
|
-
env: context.env,
|
|
772
|
-
});
|
|
773
1586
|
signal?.throwIfAborted();
|
|
774
|
-
const relevantTargets = configAffectedStatusTargets(sessionStatusResult.payload.targets, intent.pluginId, intent.scope);
|
|
775
|
-
const relevantRevisions = (sessionStatusResult.targetRevisions ?? []).filter((revision) => relevantTargets.some((target) => target.platform === revision.platform
|
|
776
|
-
&& target.scope === revision.scope
|
|
777
|
-
&& target.pluginId === revision.pluginId));
|
|
778
1587
|
await preparation.reporter.emit('evidence');
|
|
779
1588
|
const evidence = {
|
|
780
1589
|
catalog: {
|
|
781
1590
|
configDigest: sessionStatusResult.payload.catalog.configDigest,
|
|
782
|
-
compositeDigest:
|
|
783
|
-
generationSetDigest: catalogOperation.generationSetDigest,
|
|
1591
|
+
compositeDigest: preparedCatalogOperation.catalog.compositeDigest,
|
|
1592
|
+
...(catalogOperation ? { generationSetDigest: catalogOperation.generationSetDigest } : {}),
|
|
784
1593
|
},
|
|
785
|
-
source: selected.source,
|
|
786
|
-
targetFingerprint:
|
|
1594
|
+
...(selected.source ? { source: selected.source } : {}),
|
|
1595
|
+
targetFingerprint: currentTargetFingerprint(sessionRecoveryStatus, relevantTargets),
|
|
787
1596
|
config: {
|
|
788
|
-
scope: intent.
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1597
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1598
|
+
schemaIdentity: selected.schemaIdentity,
|
|
1599
|
+
storeDigest: selected.impact?.storeDigest
|
|
1600
|
+
?? selected.retryStoreDigest,
|
|
1601
|
+
impactState: selected.impact?.impactState ?? 'known',
|
|
1602
|
+
...(selected.impact?.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
1603
|
+
...(selected.commandPackages.length ? { commandPackages: selected.commandPackages } : {}),
|
|
1604
|
+
affectedTargets: (selected.impact?.affectedTargets
|
|
1605
|
+
?? relevantTargets).map(({ pluginName, platform, scope }) => ({ pluginName, platform, scope })),
|
|
1606
|
+
...(selected.preApplyAuthorization.length > 0
|
|
1607
|
+
? { preApplyAuthorization: selected.preApplyAuthorization }
|
|
1608
|
+
: {}),
|
|
1609
|
+
...(selected.sharedNativeRenderUnits.length > 0
|
|
1610
|
+
? { sharedNativeRenderUnits: selected.sharedNativeRenderUnits }
|
|
1611
|
+
: {}),
|
|
793
1612
|
},
|
|
794
1613
|
};
|
|
795
|
-
|
|
1614
|
+
await assertConfigEditEvidence(intent, evidence);
|
|
1615
|
+
if (catalogOperation)
|
|
1616
|
+
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
796
1617
|
return evidence;
|
|
797
1618
|
}
|
|
798
1619
|
await preparation?.reporter.emit('status');
|
|
799
|
-
const statusCatalogOperation =
|
|
800
|
-
? undefined
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
? [intent.originIssue.consumerPluginId] : [])])],
|
|
806
|
-
...('platform' in intent ? { platform: intent.platform } : {}),
|
|
807
|
-
...(intent.kind !== 'pluginWrite' && intent.scope === 'project'
|
|
808
|
-
? { scope: intent.scope }
|
|
809
|
-
: {}),
|
|
810
|
-
cwd: context.cwd,
|
|
811
|
-
env: context.env,
|
|
812
|
-
cliVersion: packageInfo.version,
|
|
1620
|
+
const statusCatalogOperation = catalogOperation
|
|
1621
|
+
?? (!freshCatalog ? sessionCatalogOperationContext : undefined);
|
|
1622
|
+
const status = await readRecoveryStatus({
|
|
1623
|
+
context: intent.context ?? 'user', cwd: context.cwd, env: context.env,
|
|
1624
|
+
nativeCliRunner: context.nativeCliRunner, cliVersion: packageInfo.version,
|
|
1625
|
+
...(signal ? { signal } : {}),
|
|
813
1626
|
...(statusCatalogOperation ? { catalogOperationContext: statusCatalogOperation } : {}),
|
|
814
|
-
...(offlineCleanupReason || !bootstrapMissingActive
|
|
815
|
-
|| (!statusCatalogOperation && sessionCatalogOperationContext)
|
|
816
|
-
? { bootstrapMissingActive: false }
|
|
817
|
-
: {}),
|
|
818
|
-
inventoryCatalogSourceReferences: operationInventory,
|
|
819
1627
|
});
|
|
820
1628
|
signal?.throwIfAborted();
|
|
821
1629
|
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
822
1630
|
signal?.throwIfAborted();
|
|
823
|
-
if (configSnapshot.digest !==
|
|
1631
|
+
if (statusCatalogOperation && configSnapshot.digest !== statusCatalogOperation.catalog.configDigest) {
|
|
824
1632
|
throw operationReviewStale('准备确认信息期间来源配置发生变化。');
|
|
825
1633
|
}
|
|
826
1634
|
if (catalogOperationError)
|
|
827
1635
|
throw catalogOperationError;
|
|
828
|
-
if (
|
|
829
|
-
await assertTypedIssueOrigin(intent, status.payload.targets);
|
|
830
|
-
if (preparation?.validateIntent) {
|
|
831
|
-
assertIntentIsLegal(intent, status.payload.targets, status.targetRevisions);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
if (!offlineCleanupReason && !catalogOperation) {
|
|
1636
|
+
if (!catalogOperation) {
|
|
835
1637
|
catalogOperation = await resolveCatalogOperationContext({
|
|
836
|
-
cliVersion: packageInfo.version,
|
|
837
1638
|
sourceIds: [parsePluginId(intent.pluginId).sourceId],
|
|
838
1639
|
configSnapshot,
|
|
839
1640
|
env: context.env,
|
|
840
|
-
...(
|
|
1641
|
+
...(!freshCatalog ? { validatedStoreEntries, validatingStoreEntries } : {}),
|
|
841
1642
|
...(signal ? { signal } : {}),
|
|
842
|
-
...(!bootstrapMissingActive ? { bootstrapMissingActive: false } : {}),
|
|
843
1643
|
});
|
|
844
1644
|
}
|
|
845
|
-
let dependencyPlan;
|
|
846
1645
|
await preparation?.reporter.emit('catalog');
|
|
847
|
-
const
|
|
848
|
-
? status.
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
:
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
:
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
inventory,
|
|
873
|
-
}) ?? undefined;
|
|
874
|
-
if (!offlineCleanup) {
|
|
875
|
-
throw operationReviewStale('离线清理现场证据已消失或无法验证。');
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
const selected = offlineCleanupTarget
|
|
879
|
-
? {
|
|
880
|
-
pluginName: offlineCleanupTarget.pluginName,
|
|
881
|
-
source: {
|
|
882
|
-
sourceId: offlineCleanupTarget.sourceId,
|
|
883
|
-
sourceIdentity: offlineCleanupTarget.sourceIdentity,
|
|
884
|
-
...(catalogSource?.requestedRef ? { requestedRef: catalogSource.requestedRef } : {}),
|
|
885
|
-
...(catalogSource?.resolvedCommit ? { resolvedCommit: catalogSource.resolvedCommit } : {}),
|
|
886
|
-
},
|
|
887
|
-
}
|
|
888
|
-
: await withResolvedCatalogPlugin({
|
|
889
|
-
selector: intent.pluginId,
|
|
890
|
-
cliVersion: packageInfo.version,
|
|
891
|
-
freshnessPolicy: 'cacheFirst',
|
|
892
|
-
configSnapshot,
|
|
893
|
-
env: context.env,
|
|
894
|
-
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
895
|
-
...(signal ? { signal } : {}),
|
|
896
|
-
consume: async ({ plugin, source }) => {
|
|
897
|
-
if (preparation?.validateIntent && intent.kind === 'configSave') {
|
|
898
|
-
await preparation.reporter.emit('config');
|
|
899
|
-
if (!plugin.manifest.config) {
|
|
900
|
-
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
901
|
-
}
|
|
902
|
-
await coercePluginConfigUpdates({
|
|
903
|
-
schema: plugin.manifest.config.schema,
|
|
904
|
-
updates: intent.updates ?? {},
|
|
905
|
-
cwd: context.cwd,
|
|
906
|
-
});
|
|
907
|
-
for (const key of intent.removeKeys ?? []) {
|
|
908
|
-
if (!plugin.manifest.config.schema[key]) {
|
|
909
|
-
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
910
|
-
}
|
|
1646
|
+
const configVisibleTargets = intent.kind === 'configSave'
|
|
1647
|
+
? currentConfigTargets(status, intent.pluginId, intent.context ?? 'user', configReferencePluginIds, intent.platform)
|
|
1648
|
+
: [];
|
|
1649
|
+
const selected = await withResolvedCatalogPlugin({
|
|
1650
|
+
selector: intent.pluginId,
|
|
1651
|
+
cliVersion: packageInfo.version,
|
|
1652
|
+
configSnapshot,
|
|
1653
|
+
env: context.env,
|
|
1654
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1655
|
+
...(signal ? { signal } : {}),
|
|
1656
|
+
consume: async ({ plugin, source }) => {
|
|
1657
|
+
if (preparation?.validateIntent && intent.kind === 'configSave') {
|
|
1658
|
+
await preparation.reporter.emit('config');
|
|
1659
|
+
if (!plugin.manifest.config) {
|
|
1660
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1661
|
+
}
|
|
1662
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, intent.platform);
|
|
1663
|
+
await coercePluginConfigUpdates({
|
|
1664
|
+
schema: definition.fields,
|
|
1665
|
+
updates: intent.updates ?? {},
|
|
1666
|
+
cwd: context.cwd,
|
|
1667
|
+
});
|
|
1668
|
+
for (const key of intent.removeKeys ?? []) {
|
|
1669
|
+
if (!definition.fields[key]) {
|
|
1670
|
+
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
911
1671
|
}
|
|
912
1672
|
}
|
|
913
|
-
return {
|
|
914
|
-
pluginName: plugin.manifest.name,
|
|
915
|
-
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
916
|
-
};
|
|
917
|
-
},
|
|
918
|
-
});
|
|
919
|
-
let codexManager;
|
|
920
|
-
const hasDeclaredDependencies = (status.pluginSummaries.find((summary) => summary.pluginId === intent.pluginId)?.dependencyTotalCount ?? 0) > 0;
|
|
921
|
-
if (intent.kind === 'pluginWrite') {
|
|
922
|
-
const command = {
|
|
923
|
-
install: installWriteCommand,
|
|
924
|
-
upgrade: upgradeWriteCommand,
|
|
925
|
-
reinstall: reinstallWriteCommand,
|
|
926
|
-
uninstall: uninstallWriteCommand,
|
|
927
|
-
cleanup: cleanupWriteCommand,
|
|
928
|
-
}[intent.action];
|
|
929
|
-
const preview = await command([intent.pluginId], {
|
|
930
|
-
cwd: context.cwd,
|
|
931
|
-
platform: intent.platform,
|
|
932
|
-
scope: intent.scope,
|
|
933
|
-
...(intent.action === 'cleanup' ? { force: intent.force === true } : {}),
|
|
934
|
-
}, {
|
|
935
|
-
...context,
|
|
936
|
-
inventoryCatalogSourceReferences: operationInventory,
|
|
937
|
-
expectedCatalogConfigDigest: status.payload.catalog.configDigest,
|
|
938
|
-
...(catalogOperation ? {
|
|
939
|
-
catalogOperationContext: catalogOperation,
|
|
940
|
-
expectedGenerationSetDigest: catalogOperation.generationSetDigest,
|
|
941
|
-
} : {}),
|
|
942
|
-
previewDependencyPlanOnly: true,
|
|
943
|
-
...(preparation ? {
|
|
944
|
-
onPreviewStage: (stage) => stage === 'catalog' ? undefined : preparation.reporter.emit(stage),
|
|
945
|
-
} : {}),
|
|
946
|
-
});
|
|
947
|
-
signal?.throwIfAborted();
|
|
948
|
-
if (hasDeclaredDependencies
|
|
949
|
-
&& (intent.action === 'install'
|
|
950
|
-
|| intent.action === 'upgrade'
|
|
951
|
-
|| intent.action === 'reinstall')) {
|
|
952
|
-
dependencyPlan = preview.dependencyPlan;
|
|
953
|
-
if (!dependencyPlan) {
|
|
954
|
-
throw new TuiOperationBlockedError('dependencyGraphInvalid', '无法建立可信的依赖安装计划。');
|
|
955
|
-
}
|
|
956
|
-
const blocker = dependencyPlan.targets.find((target) => target.action === 'block');
|
|
957
|
-
if (blocker) {
|
|
958
|
-
throw new TuiOperationBlockedError(blocker.errorCode ?? 'dependencyNotReady', `${blocker.errorCode ?? 'dependencyNotReady'}: 依赖安装计划被阻止。`);
|
|
959
1673
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1674
|
+
const impact = intent.kind === 'configSave' && !intent.retryApply
|
|
1675
|
+
? await analyzePluginConfigMutationImpact({
|
|
1676
|
+
plugin,
|
|
1677
|
+
referencePlugins,
|
|
1678
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1679
|
+
cwd: context.cwd,
|
|
1680
|
+
env: context.env,
|
|
1681
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets),
|
|
1682
|
+
mutation: {
|
|
1683
|
+
kind: 'patch',
|
|
1684
|
+
updates: intent.updates,
|
|
1685
|
+
removeKeys: intent.removeKeys,
|
|
1686
|
+
},
|
|
1687
|
+
})
|
|
1688
|
+
: undefined;
|
|
1689
|
+
const affectedTargets = intent.kind === 'configSave'
|
|
1690
|
+
? intent.retryApply ? configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets) : impact.affectedTargets
|
|
1691
|
+
: [];
|
|
1692
|
+
const commandPackages = impact?.affectedCommandPackages
|
|
1693
|
+
?? (intent.kind === 'configSave' ? (await discoverPluginConfigManagedCommandPackages({
|
|
1694
|
+
plugin, scope: intent.context ?? 'user', cwd: context.cwd, env: context.env ?? process.env,
|
|
1695
|
+
platformTargets: configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets),
|
|
1696
|
+
referencePlugins,
|
|
1697
|
+
})).packages : []);
|
|
1698
|
+
const preApplyAuthorization = intent.kind === 'configSave'
|
|
1699
|
+
&& configIntentRequestsApply(intent)
|
|
1700
|
+
? (await resolveConfigPreApplyAuthorization({
|
|
1701
|
+
plugin,
|
|
1702
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1703
|
+
cwd: context.cwd,
|
|
1704
|
+
env: context.env,
|
|
1705
|
+
applyTargets: intent.retryApply
|
|
1706
|
+
? configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets)
|
|
1707
|
+
: impact.affectedTargets,
|
|
1708
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
1709
|
+
rebuildRuntime: {
|
|
1710
|
+
referencePlugins,
|
|
1711
|
+
...(catalogOperation ? { catalogOperationContext: catalogOperation } : {}),
|
|
1712
|
+
...(catalogOperation?.generationSetDigest
|
|
1713
|
+
? { expectedGenerationSetDigest: catalogOperation.generationSetDigest }
|
|
1714
|
+
: {}),
|
|
1715
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1716
|
+
},
|
|
1717
|
+
})).targets
|
|
1718
|
+
: [];
|
|
1719
|
+
return {
|
|
1720
|
+
pluginName: plugin.manifest.name,
|
|
1721
|
+
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
1722
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, intent.platform),
|
|
1723
|
+
impact,
|
|
1724
|
+
commandPackages,
|
|
1725
|
+
preApplyAuthorization,
|
|
1726
|
+
retryStoreDigest: intent.kind === 'configSave' && intent.retryApply
|
|
1727
|
+
? await configRetryStoreDigest({ plugin, scope: intent.context ?? 'user', platform: intent.platform, targets: affectedTargets,
|
|
1728
|
+
commandPackages, preApplyAuthorization, cwd: context.cwd, env: context.env, plugins: referencePlugins }) : undefined,
|
|
1729
|
+
sharedNativeRenderUnits: intent.kind === 'configSave'
|
|
1730
|
+
? intent.retryApply
|
|
1731
|
+
? await configRetrySharedNativeRenderUnits(plugin, configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets), context.env, referencePlugins)
|
|
1732
|
+
: impact.sharedNativeRenderUnits
|
|
1733
|
+
: [],
|
|
975
1734
|
};
|
|
976
|
-
}
|
|
977
|
-
}
|
|
1735
|
+
},
|
|
1736
|
+
});
|
|
978
1737
|
await preparation?.reporter.emit('evidence');
|
|
979
1738
|
signal?.throwIfAborted();
|
|
980
|
-
const evidenceTargets =
|
|
981
|
-
? configAffectedStatusTargets(status.payload.targets, intent.pluginId, intent.scope)
|
|
982
|
-
: status.payload.targets;
|
|
983
|
-
const evidenceRevisions = intent.kind === 'configSave' || intent.kind === 'configReset'
|
|
984
|
-
? (status.targetRevisions ?? []).filter((revision) => evidenceTargets.some((target) => target.platform === revision.platform
|
|
985
|
-
&& target.scope === revision.scope
|
|
986
|
-
&& target.pluginId === revision.pluginId))
|
|
987
|
-
: (status.targetRevisions ?? []);
|
|
1739
|
+
const evidenceTargets = configVisibleTargets;
|
|
988
1740
|
const evidence = {
|
|
989
1741
|
catalog: {
|
|
990
|
-
configDigest:
|
|
991
|
-
compositeDigest:
|
|
1742
|
+
configDigest: configSnapshot.digest,
|
|
1743
|
+
compositeDigest: catalogOperation.catalog.compositeDigest,
|
|
992
1744
|
...(catalogOperation
|
|
993
1745
|
? { generationSetDigest: catalogOperation.generationSetDigest }
|
|
994
1746
|
: {}),
|
|
995
1747
|
},
|
|
996
1748
|
source: selected.source,
|
|
997
|
-
|
|
998
|
-
...(dependencyPlan ? { dependencyPlan } : {}),
|
|
999
|
-
...(codexManager ? { codexManager } : {}),
|
|
1000
|
-
targetFingerprint: statusTargetFingerprint(evidenceTargets, evidenceRevisions),
|
|
1749
|
+
targetFingerprint: currentTargetFingerprint(status, evidenceTargets),
|
|
1001
1750
|
};
|
|
1002
|
-
if (intent.kind === 'configSave'
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
scope: intent.scope,
|
|
1008
|
-
projectLayer: intent.projectLayer,
|
|
1009
|
-
cwd: context.cwd,
|
|
1010
|
-
env: context.env,
|
|
1011
|
-
});
|
|
1751
|
+
if (intent.kind === 'configSave') {
|
|
1752
|
+
const impact = 'impact' in selected ? selected.impact : undefined;
|
|
1753
|
+
const storeDigest = impact?.storeDigest ?? ('retryStoreDigest' in selected ? selected.retryStoreDigest : undefined);
|
|
1754
|
+
if (!storeDigest)
|
|
1755
|
+
throw operationReviewStale('设置操作缺少实际配置输入证据。');
|
|
1012
1756
|
signal?.throwIfAborted();
|
|
1013
1757
|
evidence.config = {
|
|
1014
|
-
scope: intent.
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1758
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1759
|
+
schemaIdentity: selected.schemaIdentity,
|
|
1760
|
+
storeDigest,
|
|
1761
|
+
impactState: impact?.impactState ?? 'known',
|
|
1762
|
+
...(impact?.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
1763
|
+
...('commandPackages' in selected && selected.commandPackages.length
|
|
1764
|
+
? { commandPackages: selected.commandPackages } : {}),
|
|
1765
|
+
affectedTargets: (impact?.affectedTargets
|
|
1766
|
+
?? evidenceTargets).map(({ pluginName, platform, scope }) => ({ pluginName, platform, scope })),
|
|
1767
|
+
...('sharedNativeRenderUnits' in selected
|
|
1768
|
+
&& selected.sharedNativeRenderUnits.length > 0
|
|
1769
|
+
? { sharedNativeRenderUnits: selected.sharedNativeRenderUnits }
|
|
1770
|
+
: {}),
|
|
1771
|
+
...('preApplyAuthorization' in selected
|
|
1772
|
+
&& selected.preApplyAuthorization.length > 0
|
|
1773
|
+
? { preApplyAuthorization: selected.preApplyAuthorization }
|
|
1774
|
+
: {}),
|
|
1019
1775
|
};
|
|
1020
1776
|
}
|
|
1777
|
+
await assertConfigEditEvidence(intent, evidence);
|
|
1021
1778
|
if (catalogOperation)
|
|
1022
1779
|
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
1023
1780
|
return evidence;
|
|
1024
1781
|
};
|
|
1025
1782
|
const dependencies = {
|
|
1783
|
+
readAgentSettings: () => readAgentSettings(context),
|
|
1784
|
+
previewAgentSettings: (preferences, pluginId) => previewAgentSettings(context, preferences, pluginId),
|
|
1785
|
+
saveAgentSettings: (request) => saveAgentSettings(context, request),
|
|
1026
1786
|
beginCatalogSession(sessionOptions) {
|
|
1027
1787
|
sessionCatalogOperationContext = undefined;
|
|
1028
|
-
|
|
1788
|
+
if (sessionOptions?.reuseValidatedGenerations !== true) {
|
|
1789
|
+
validatedStoreEntries.clear();
|
|
1790
|
+
validatingStoreEntries.clear();
|
|
1791
|
+
}
|
|
1029
1792
|
},
|
|
1030
1793
|
loadStatus,
|
|
1031
|
-
async
|
|
1794
|
+
async loadScopedStatus(scope, signal) {
|
|
1795
|
+
signal.throwIfAborted();
|
|
1796
|
+
const packageInfo = await readCliPackageInfo();
|
|
1797
|
+
const currentCatalog = await resolvePartialCatalogOperationContext({
|
|
1798
|
+
env: context.env, signal, validatedStoreEntries, validatingStoreEntries,
|
|
1799
|
+
});
|
|
1800
|
+
signal.throwIfAborted();
|
|
1801
|
+
if (sessionCatalogOperationContext
|
|
1802
|
+
&& currentCatalog.generationSetDigest !== sessionCatalogOperationContext.generationSetDigest) {
|
|
1803
|
+
throw new TuiOperationBlockedError('catalogSessionReloadRequired', 'Catalog 已变化。请按 H 重新加载,再检查清单。');
|
|
1804
|
+
}
|
|
1805
|
+
const catalogOperationContext = sessionCatalogOperationContext ?? currentCatalog;
|
|
1806
|
+
const snapshot = await readJointDemand({ scope, cwd: context.cwd, env: context.env, signal, catalogOperationContext });
|
|
1807
|
+
const status = await readRecoveryStatus({ scope, cwd: context.cwd, env: context.env, cliVersion: packageInfo.version,
|
|
1808
|
+
nativeCliRunner: context.nativeCliRunner, catalogOperationContext, signal }, snapshot);
|
|
1809
|
+
signal.throwIfAborted();
|
|
1810
|
+
sessionRecoveryStatus = status;
|
|
1811
|
+
const source = sessionStatusResult ?? await loadCatalogView({ context, cliVersion: packageInfo.version, signal, catalogOperationContext });
|
|
1812
|
+
const dependencyOverviews = await loadDependencyOverviews({ context, cliVersion: packageInfo.version, status,
|
|
1813
|
+
pluginSummaries: source.pluginSummaries, signal, catalogOperationContext });
|
|
1814
|
+
signal.throwIfAborted();
|
|
1815
|
+
return { ...scopedCurrentStatus(status, snapshot, scope), dependencyOverviews };
|
|
1816
|
+
},
|
|
1817
|
+
async prepareScopedTask(request, signal) {
|
|
1818
|
+
signal.throwIfAborted();
|
|
1819
|
+
if (request.kind === 'targets') {
|
|
1820
|
+
return prepareTargetsPlan({ scope: request.scope, cwd: context.cwd, env: context.env }, request.action, request.agents);
|
|
1821
|
+
}
|
|
1822
|
+
if (request.kind === 'intent') {
|
|
1823
|
+
return prepareIntentPlan({ scope: request.scope, cwd: context.cwd, env: context.env }, request.action, request.selector);
|
|
1824
|
+
}
|
|
1825
|
+
if (request.kind === 'retire') {
|
|
1826
|
+
const packageInfo = await readCliPackageInfo();
|
|
1827
|
+
signal.throwIfAborted();
|
|
1828
|
+
const plan = await prepareRetire({ scope: request.scope, cwd: context.cwd, env: context.env,
|
|
1829
|
+
signal,
|
|
1830
|
+
selector: request.selector, cliVersion: packageInfo.version,
|
|
1831
|
+
...(request.targets ? { targets: request.targets } : {}),
|
|
1832
|
+
deleteConfig: request.deleteConfig === true,
|
|
1833
|
+
}, context);
|
|
1834
|
+
if (signal.aborted) {
|
|
1835
|
+
await plan.context.dispose();
|
|
1836
|
+
signal.throwIfAborted();
|
|
1837
|
+
}
|
|
1838
|
+
return { kind: 'retire', scope: request.scope, plan };
|
|
1839
|
+
}
|
|
1840
|
+
const packageInfo = await readCliPackageInfo();
|
|
1841
|
+
signal.throwIfAborted();
|
|
1842
|
+
const plan = await prepareRecovery(request.command ?? 'sync', request.selectors, {
|
|
1843
|
+
signal,
|
|
1844
|
+
scope: request.scope, cwd: context.cwd, env: context.env,
|
|
1845
|
+
cliVersion: packageInfo.version,
|
|
1846
|
+
all: request.selectors.length === 0,
|
|
1847
|
+
...(request.allowDependencySelectors ? { allowDependencySelectors: true } : {}),
|
|
1848
|
+
...(request.targets ? { targets: request.targets } : {}),
|
|
1849
|
+
...(request.force ? { force: true } : {}),
|
|
1850
|
+
...(request.refresh ? { refresh: true } : {}),
|
|
1851
|
+
...(request.retireUnselectedTargets ? { retireUnselectedTargets: true } : {}),
|
|
1852
|
+
...(request.scriptTimeoutMs !== undefined ? { scriptTimeoutMs: request.scriptTimeoutMs } : {}),
|
|
1853
|
+
...(request.dependencyScopeOverrides?.length
|
|
1854
|
+
? { dependencyScopeOverrides: request.dependencyScopeOverrides } : {}),
|
|
1855
|
+
...(request.exactTargets ? { exactTargets: request.exactTargets } : {}),
|
|
1856
|
+
...(request.saveDependencyScopeOverrides ? { saveDependencyScopeOverrides: true } : {}),
|
|
1857
|
+
}, context);
|
|
1858
|
+
if (signal.aborted) {
|
|
1859
|
+
await plan.context.dispose();
|
|
1860
|
+
signal.throwIfAborted();
|
|
1861
|
+
}
|
|
1862
|
+
return { kind: 'recovery', scope: request.scope, plan };
|
|
1863
|
+
},
|
|
1864
|
+
async executeScopedTask(plan) {
|
|
1865
|
+
if (plan.kind === 'targets') {
|
|
1866
|
+
const result = await executeTargetsPlan({ scope: plan.scope, cwd: context.cwd, env: context.env }, plan);
|
|
1867
|
+
return { kind: 'targets', ...result };
|
|
1868
|
+
}
|
|
1869
|
+
if (plan.kind === 'intent') {
|
|
1870
|
+
const receipt = await executeIntentPlan({ scope: plan.scope, cwd: context.cwd, env: context.env }, plan);
|
|
1871
|
+
return { kind: 'recovery', receipt };
|
|
1872
|
+
}
|
|
1873
|
+
if (plan.kind === 'retire') {
|
|
1874
|
+
const receipt = await executeRetire(plan.plan, { yes: true, runtime: context });
|
|
1875
|
+
return { kind: 'recovery', receipt };
|
|
1876
|
+
}
|
|
1877
|
+
if ((plan.plan.sourceRefreshes?.length ?? 0) > 0) {
|
|
1878
|
+
const refreshed = await activateRecoverySourcesAndReprepare(plan.plan, { runtime: context });
|
|
1879
|
+
return { kind: 'recoveryReview', plan: { kind: 'recovery', scope: plan.scope, plan: refreshed } };
|
|
1880
|
+
}
|
|
1881
|
+
const receipt = await executeRecovery(plan.plan, { yes: true, runtime: context });
|
|
1882
|
+
return { kind: 'recovery', receipt };
|
|
1883
|
+
},
|
|
1884
|
+
loadPluginContent,
|
|
1885
|
+
async probeCatalogFreshness(sourceId, freshnessOptions, signal) {
|
|
1032
1886
|
signal.throwIfAborted();
|
|
1887
|
+
const packageInfo = await readCliPackageInfo();
|
|
1888
|
+
return probeCatalogSourceFreshness({
|
|
1889
|
+
sourceId,
|
|
1890
|
+
cliVersion: packageInfo.version,
|
|
1891
|
+
env: context.env,
|
|
1892
|
+
signal,
|
|
1893
|
+
fullValidation: freshnessOptions.fullValidation,
|
|
1894
|
+
runtime: {
|
|
1895
|
+
...options.catalogGenerationRuntime,
|
|
1896
|
+
validatedStoreEntries,
|
|
1897
|
+
validatingStoreEntries,
|
|
1898
|
+
},
|
|
1899
|
+
});
|
|
1900
|
+
},
|
|
1901
|
+
async inspectSourceRemoval(sourceId, signal) {
|
|
1902
|
+
signal.throwIfAborted();
|
|
1903
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
1904
|
+
const source = config.config.sources.find((entry) => entry.id === sourceId);
|
|
1905
|
+
if (!source)
|
|
1906
|
+
throw new TuiOperationBlockedError('catalogGenerationSourceMissing', '来源不存在。');
|
|
1907
|
+
const impact = await inspectCatalogSourceImpact({
|
|
1908
|
+
sourceId,
|
|
1909
|
+
cwd: context.cwd,
|
|
1910
|
+
env: context.env,
|
|
1911
|
+
sourcePrimary: source.primary,
|
|
1912
|
+
mode: 'remove',
|
|
1913
|
+
});
|
|
1914
|
+
const counts = (category) => impact.affectedReferences.filter((reference) => reference.category === category).length;
|
|
1033
1915
|
return {
|
|
1034
|
-
blocked:
|
|
1035
|
-
inventoryComplete:
|
|
1036
|
-
installationCount:
|
|
1037
|
-
configCount:
|
|
1038
|
-
lifecycleCount:
|
|
1039
|
-
marketplaceCount:
|
|
1040
|
-
dependencies:
|
|
1916
|
+
blocked: impact.affectedReferences.length > 0 || !impact.inventoryComplete,
|
|
1917
|
+
inventoryComplete: impact.inventoryComplete,
|
|
1918
|
+
installationCount: counts('installation'),
|
|
1919
|
+
configCount: counts('config'),
|
|
1920
|
+
lifecycleCount: counts('lifecycle'),
|
|
1921
|
+
marketplaceCount: counts('marketplace'),
|
|
1922
|
+
dependencies: impact.affectedReferences,
|
|
1041
1923
|
};
|
|
1042
1924
|
},
|
|
1043
|
-
async prepareReviewEvidence(intent, signal, onStage) {
|
|
1925
|
+
async prepareReviewEvidence(intent, signal, onStage, reusableCandidate) {
|
|
1044
1926
|
const reporter = createReviewStageReporter({
|
|
1045
1927
|
context,
|
|
1046
1928
|
onStage,
|
|
@@ -1050,30 +1932,68 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1050
1932
|
return await captureEvidence(intent, signal, {
|
|
1051
1933
|
reporter,
|
|
1052
1934
|
validateIntent: true,
|
|
1053
|
-
});
|
|
1935
|
+
}, createOperationInventoryReader(), false, reusableCandidate);
|
|
1054
1936
|
}
|
|
1055
1937
|
finally {
|
|
1056
1938
|
await reporter.finish();
|
|
1057
1939
|
}
|
|
1058
1940
|
},
|
|
1941
|
+
async previewDependencyPlacement(intent, signal) {
|
|
1942
|
+
const targets = intent.platform === 'both' ? ['codex', 'claude']
|
|
1943
|
+
: [intent.platform === 'claude' ? 'claude' : 'codex'];
|
|
1944
|
+
const prepared = await dependencies.prepareScopedTask({
|
|
1945
|
+
kind: 'recovery', command: 'install', scope: intent.scope,
|
|
1946
|
+
selectors: [intent.pluginId], targets: [...targets],
|
|
1947
|
+
dependencyScopeOverrides: intent.dependencyScopeOverrides,
|
|
1948
|
+
}, signal);
|
|
1949
|
+
if (prepared.kind !== 'recovery')
|
|
1950
|
+
throw new Error('dependencyPlacementUnavailable');
|
|
1951
|
+
try {
|
|
1952
|
+
const plans = prepared.plan.nativeGroups.flatMap((group) => group.preview.dependencyPlan ? [group.preview.dependencyPlan] : []);
|
|
1953
|
+
if (plans.length === 0) {
|
|
1954
|
+
throw new Error(prepared.plan.receipt.blockers[0]?.code
|
|
1955
|
+
?? prepared.plan.receipt.targetResults[0]?.blockers[0]?.code ?? 'dependencyPlacementUnavailable');
|
|
1956
|
+
}
|
|
1957
|
+
return {
|
|
1958
|
+
requestedPluginIds: [...new Set(plans.flatMap((plan) => plan.requestedPluginIds))],
|
|
1959
|
+
resolvedPluginIds: [...new Set(plans.flatMap((plan) => plan.resolvedPluginIds))],
|
|
1960
|
+
dependencyEdges: plans.flatMap((plan) => plan.dependencyEdges),
|
|
1961
|
+
scopeOverrides: plans.flatMap((plan) => plan.scopeOverrides),
|
|
1962
|
+
targets: plans.flatMap((plan) => plan.targets),
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
finally {
|
|
1966
|
+
await prepared.plan.context.dispose();
|
|
1967
|
+
}
|
|
1968
|
+
},
|
|
1059
1969
|
async validateIntent(intent, signal) {
|
|
1060
|
-
if (intent.kind === '
|
|
1061
|
-
|
|
1970
|
+
if (intent.kind === 'catalogSourcesRecovery') {
|
|
1971
|
+
signal.throwIfAborted();
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
if (intent.kind === 'catalogGeneration') {
|
|
1975
|
+
signal.throwIfAborted();
|
|
1062
1976
|
return;
|
|
1063
1977
|
}
|
|
1064
1978
|
if (intent.kind === 'sourceMutation') {
|
|
1065
1979
|
const evidence = await captureEvidence(intent, signal);
|
|
1066
|
-
if (evidence.sourceWrite?.configDigest === evidence.sourceWrite?.
|
|
1980
|
+
if (evidence.sourceWrite?.configDigest === evidence.sourceWrite?.proposedConfigDigest) {
|
|
1067
1981
|
throw new TuiOperationBlockedError('sourceNoChanges', '来源没有变化。');
|
|
1068
1982
|
}
|
|
1069
1983
|
return;
|
|
1070
1984
|
}
|
|
1985
|
+
if (intent.kind === 'configSaveBatch') {
|
|
1986
|
+
assertConfigSaveBatchIntent(intent);
|
|
1987
|
+
for (const group of intent.groups) {
|
|
1988
|
+
await dependencies.validateIntent(configSaveBatchGroupIntent(intent, group), signal);
|
|
1989
|
+
}
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1071
1992
|
if (intent.kind === 'configSave') {
|
|
1072
1993
|
const packageInfo = await readCliPackageInfo();
|
|
1073
1994
|
await withResolvedCatalogPlugin({
|
|
1074
1995
|
selector: intent.pluginId,
|
|
1075
1996
|
cliVersion: packageInfo.version,
|
|
1076
|
-
freshnessPolicy: 'cacheFirst',
|
|
1077
1997
|
env: context.env,
|
|
1078
1998
|
signal,
|
|
1079
1999
|
...(sessionContextForPlugin(intent.pluginId)
|
|
@@ -1083,13 +2003,14 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1083
2003
|
if (!plugin.manifest.config) {
|
|
1084
2004
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1085
2005
|
}
|
|
2006
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, intent.platform);
|
|
1086
2007
|
await coercePluginConfigUpdates({
|
|
1087
|
-
schema:
|
|
2008
|
+
schema: definition.fields,
|
|
1088
2009
|
updates: intent.updates ?? {},
|
|
1089
2010
|
cwd: context.cwd,
|
|
1090
2011
|
});
|
|
1091
2012
|
for (const key of intent.removeKeys ?? []) {
|
|
1092
|
-
if (!
|
|
2013
|
+
if (!definition.fields[key]) {
|
|
1093
2014
|
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
1094
2015
|
}
|
|
1095
2016
|
}
|
|
@@ -1100,99 +2021,24 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1100
2021
|
if (intent.kind !== 'pluginWrite')
|
|
1101
2022
|
return;
|
|
1102
2023
|
signal.throwIfAborted();
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
const offlineCleanup = intent.action === 'cleanup'
|
|
1107
|
-
&& intent.originIssue?.actionId === 'cleanup'
|
|
1108
|
-
&& (intent.originIssue.category === 'sourceMissing'
|
|
1109
|
-
|| intent.originIssue.category === 'sourceUnavailable');
|
|
1110
|
-
const sourceIds = pluginIds.map((pluginId) => parsePluginId(pluginId).sourceId);
|
|
1111
|
-
const catalogOperation = offlineCleanup
|
|
1112
|
-
? undefined
|
|
1113
|
-
: sessionCatalogOperationContext
|
|
1114
|
-
? selectCatalogOperationContext(sessionCatalogOperationContext, sourceIds)
|
|
1115
|
-
: undefined;
|
|
1116
|
-
const status = await statusCommandV5({
|
|
1117
|
-
plugins: pluginIds,
|
|
1118
|
-
platform: intent.platform,
|
|
1119
|
-
cwd: context.cwd,
|
|
1120
|
-
env: context.env,
|
|
1121
|
-
cliVersion: packageInfo.version,
|
|
1122
|
-
...(catalogOperation ? { catalogOperationContext: catalogOperation } : {}),
|
|
1123
|
-
...(offlineCleanup || sessionCatalogOperationContext
|
|
1124
|
-
? { bootstrapMissingActive: false }
|
|
1125
|
-
: {}),
|
|
1126
|
-
inventoryCatalogSourceReferences: readInventory,
|
|
1127
|
-
});
|
|
1128
|
-
signal.throwIfAborted();
|
|
1129
|
-
await assertTypedIssueOrigin(intent, status.payload.targets);
|
|
1130
|
-
assertIntentIsLegal(intent, status.payload.targets, status.targetRevisions);
|
|
1131
|
-
},
|
|
1132
|
-
async checkSource(sourceId, signal) {
|
|
1133
|
-
const packageInfo = await readCliPackageInfo();
|
|
1134
|
-
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
1135
|
-
return withResolvedMultiSourceCatalog({
|
|
1136
|
-
cliVersion: packageInfo.version,
|
|
1137
|
-
freshnessPolicy: 'forceRemote',
|
|
1138
|
-
sourceIds: [sourceId],
|
|
1139
|
-
configSnapshot,
|
|
1140
|
-
env: context.env,
|
|
1141
|
-
signal,
|
|
1142
|
-
consume: (catalog) => {
|
|
1143
|
-
const item = catalog.sources[0];
|
|
1144
|
-
if (item.error)
|
|
1145
|
-
throw item.error;
|
|
1146
|
-
return {
|
|
1147
|
-
sourceIdentity: item.resolution.sourceIdentity,
|
|
1148
|
-
requestedRef: item.resolution.requestedRef,
|
|
1149
|
-
};
|
|
1150
|
-
},
|
|
1151
|
-
});
|
|
1152
|
-
},
|
|
1153
|
-
async refreshCatalogSource(sourceId, signal, onState) {
|
|
1154
|
-
let refreshError;
|
|
1155
|
-
let refreshCompleted = false;
|
|
1156
|
-
try {
|
|
1157
|
-
await refreshCatalogSourceGeneration({
|
|
1158
|
-
sourceId,
|
|
1159
|
-
cliVersion: (await readCliPackageInfo()).version,
|
|
1160
|
-
env: context.env,
|
|
1161
|
-
signal,
|
|
1162
|
-
runtime: {
|
|
1163
|
-
...options.catalogGenerationRuntime,
|
|
1164
|
-
onProgress: (event) => onState(event.state),
|
|
1165
|
-
},
|
|
1166
|
-
});
|
|
1167
|
-
refreshCompleted = true;
|
|
1168
|
-
}
|
|
1169
|
-
catch (error) {
|
|
1170
|
-
refreshError = error;
|
|
2024
|
+
const parsed = parsePluginId(intent.pluginId);
|
|
2025
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
2026
|
+
throw new TuiOperationBlockedError('invalidPluginId', '操作必须使用 canonical pluginId。');
|
|
1171
2027
|
}
|
|
2028
|
+
},
|
|
2029
|
+
captureEvidence,
|
|
2030
|
+
inspectCatalogStore(signal) {
|
|
1172
2031
|
signal.throwIfAborted();
|
|
1173
|
-
|
|
1174
|
-
.find((entry) => entry.sourceId === sourceId);
|
|
1175
|
-
if (!source)
|
|
1176
|
-
throw refreshError ?? new TuiOperationBlockedError('catalogGenerationSourceMissing', 'Catalog 来源已不存在。');
|
|
1177
|
-
if (refreshError && source.refreshState !== 'failed'
|
|
1178
|
-
&& source.refreshState !== 'immutableViolation')
|
|
1179
|
-
throw refreshError;
|
|
1180
|
-
return {
|
|
1181
|
-
source: refreshCompleted && source.refreshState === 'idle'
|
|
1182
|
-
? { ...source, refreshState: 'upToDate' }
|
|
1183
|
-
: source,
|
|
1184
|
-
};
|
|
2032
|
+
return inspectCatalogStoreTask({ env: context.env });
|
|
1185
2033
|
},
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
2034
|
+
recheckPortableInstall(receipt, signal) {
|
|
2035
|
+
return recheckPortableInstall({
|
|
2036
|
+
receipt,
|
|
2037
|
+
cwd: context.cwd,
|
|
1190
2038
|
env: context.env,
|
|
2039
|
+
signal,
|
|
1191
2040
|
});
|
|
1192
|
-
return (await loadCatalogGenerationViewModels({ env: context.env }))
|
|
1193
|
-
.find((source) => source.sourceId === sourceId);
|
|
1194
2041
|
},
|
|
1195
|
-
captureEvidence,
|
|
1196
2042
|
logError(_error, code, logContext) {
|
|
1197
2043
|
return context.debugLogger.log({
|
|
1198
2044
|
type: 'tui:controller-error',
|
|
@@ -1204,154 +2050,435 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1204
2050
|
data: { code },
|
|
1205
2051
|
});
|
|
1206
2052
|
},
|
|
1207
|
-
async getConfigGroups(pluginId,
|
|
2053
|
+
async getConfigGroups(pluginId, config, signal) {
|
|
2054
|
+
return (await dependencies.getConfigPage(pluginId, config, signal)).groups;
|
|
2055
|
+
},
|
|
2056
|
+
async getConfigPage(pluginId, config, signal) {
|
|
2057
|
+
if (config.context === 'project')
|
|
2058
|
+
await resolveWorkContext({ cwd: context.cwd, context: 'project' });
|
|
1208
2059
|
const packageInfo = await readCliPackageInfo();
|
|
1209
2060
|
return withResolvedCatalogPlugin({
|
|
1210
2061
|
selector: pluginId,
|
|
1211
2062
|
cliVersion: packageInfo.version,
|
|
1212
|
-
freshnessPolicy: 'cacheFirst',
|
|
1213
2063
|
env: context.env,
|
|
1214
2064
|
signal,
|
|
1215
2065
|
...(sessionContextForPlugin(pluginId)
|
|
1216
2066
|
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
1217
2067
|
: {}),
|
|
1218
|
-
consume: async ({ plugin }) => {
|
|
2068
|
+
consume: async ({ plugin, source }) => {
|
|
1219
2069
|
if (!plugin.manifest.config) {
|
|
1220
2070
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1221
2071
|
}
|
|
2072
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, config.platform);
|
|
2073
|
+
const stores = await readConfigStoresForTui({
|
|
2074
|
+
sourceId: plugin.sourceId,
|
|
2075
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2076
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2077
|
+
pluginName: plugin.manifest.name,
|
|
2078
|
+
schema: definition.fields,
|
|
2079
|
+
platform: config.platform,
|
|
2080
|
+
signal,
|
|
2081
|
+
});
|
|
2082
|
+
const userStore = stores.user;
|
|
1222
2083
|
const read = await resolveConfigRead({
|
|
1223
2084
|
pluginName: plugin.manifest.name,
|
|
1224
2085
|
plugin,
|
|
1225
|
-
scope:
|
|
1226
|
-
|
|
2086
|
+
scope: config.view === 'effective' ? 'effective' : 'user',
|
|
2087
|
+
platform: config.platform,
|
|
2088
|
+
context: config.context ?? 'user',
|
|
1227
2089
|
cwd: context.cwd,
|
|
1228
2090
|
env: context.env,
|
|
1229
2091
|
});
|
|
1230
|
-
const effectiveRead = await resolveConfigRead({
|
|
2092
|
+
const effectiveRead = config.view === 'effective' ? read : await resolveConfigRead({
|
|
1231
2093
|
pluginName: plugin.manifest.name,
|
|
1232
2094
|
plugin,
|
|
1233
2095
|
scope: 'effective',
|
|
1234
|
-
|
|
2096
|
+
platform: config.platform,
|
|
2097
|
+
context: config.context ?? 'user',
|
|
1235
2098
|
cwd: context.cwd,
|
|
1236
2099
|
env: context.env,
|
|
1237
2100
|
});
|
|
1238
|
-
|
|
2101
|
+
const effectiveRaw = await resolveEffectivePluginConfig({
|
|
2102
|
+
sourceId: plugin.sourceId,
|
|
2103
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2104
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2105
|
+
pluginName: plugin.manifest.name,
|
|
2106
|
+
manifest: plugin.manifest,
|
|
2107
|
+
platform: config.platform,
|
|
2108
|
+
context: config.context ?? 'user',
|
|
2109
|
+
cwd: context.cwd,
|
|
2110
|
+
env: context.env,
|
|
2111
|
+
});
|
|
2112
|
+
const page = buildConfigPage({
|
|
2113
|
+
pluginId,
|
|
2114
|
+
context: config.context ?? 'user',
|
|
2115
|
+
schema: definition,
|
|
2116
|
+
read,
|
|
2117
|
+
effectiveRead,
|
|
2118
|
+
...(config.view === 'effective' ? {} : { rawValues: userStore.values }),
|
|
2119
|
+
rawLayerValues: {
|
|
2120
|
+
common: userStore.common ?? {},
|
|
2121
|
+
...(userStore.platforms ?? {}),
|
|
2122
|
+
},
|
|
2123
|
+
effectiveRawValues: effectiveRaw.values,
|
|
2124
|
+
sharedNativeRefreshKeys: new Set(plugin.manifest.artifacts?.configKeys ?? []),
|
|
2125
|
+
});
|
|
2126
|
+
return { ...page, editEvidence: {
|
|
2127
|
+
platform: config.platform,
|
|
2128
|
+
context: config.context ?? 'user',
|
|
2129
|
+
sourceIdentity: source.sourceIdentity,
|
|
2130
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, config.platform),
|
|
2131
|
+
storeDigests: {
|
|
2132
|
+
user: digest({ exists: userStore.exists, rawDigest: userStore.rawDigest }),
|
|
2133
|
+
},
|
|
2134
|
+
} };
|
|
1239
2135
|
},
|
|
1240
2136
|
});
|
|
1241
2137
|
},
|
|
1242
|
-
async
|
|
2138
|
+
async getConfigReferenceContext(pluginId, config, draft, signal) {
|
|
2139
|
+
const workContext = await resolveWorkContext({ cwd: context.cwd, context: config.context ?? 'user' });
|
|
1243
2140
|
const packageInfo = await readCliPackageInfo();
|
|
1244
2141
|
return withResolvedCatalogPlugin({
|
|
1245
|
-
selector: pluginId,
|
|
1246
|
-
|
|
1247
|
-
freshnessPolicy: 'cacheFirst',
|
|
1248
|
-
env: context.env,
|
|
1249
|
-
signal,
|
|
1250
|
-
...(sessionContextForPlugin(pluginId)
|
|
1251
|
-
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
1252
|
-
: {}),
|
|
2142
|
+
selector: pluginId, cliVersion: packageInfo.version, env: context.env, signal,
|
|
2143
|
+
...(sessionContextForPlugin(pluginId) ? { operationContext: sessionContextForPlugin(pluginId) } : {}),
|
|
1253
2144
|
consume: async ({ plugin }) => {
|
|
1254
|
-
if (!plugin.manifest.config)
|
|
2145
|
+
if (!plugin.manifest.config)
|
|
1255
2146
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1256
|
-
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
2147
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, config.platform);
|
|
2148
|
+
const scalars = Object.values(definition.fields).flatMap(configReferenceScalars);
|
|
2149
|
+
if (!scalars.length)
|
|
2150
|
+
return { platform: config.platform, selections: {} };
|
|
2151
|
+
const stores = await readConfigStoresForTui({
|
|
2152
|
+
sourceId: plugin.sourceId, sourceIdentity: plugin.sourceIdentity,
|
|
2153
|
+
logicalIdentity: plugin.catalogLogicalIdentity, pluginName: plugin.manifest.name,
|
|
2154
|
+
schema: definition.fields, platform: config.platform, signal,
|
|
1264
2155
|
});
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
2156
|
+
const edited = stores.user;
|
|
2157
|
+
const values = { ...edited.values };
|
|
2158
|
+
for (const key of draft.removes)
|
|
2159
|
+
delete values[key];
|
|
2160
|
+
Object.assign(values, draft.updates);
|
|
2161
|
+
const candidateStores = { user: replacePluginConfigStoreLayer(edited, values, config.platform) };
|
|
2162
|
+
const references = await resolvePluginConfigReferenceContext({
|
|
2163
|
+
sourceId: plugin.sourceId, sourceIdentity: plugin.sourceIdentity,
|
|
2164
|
+
logicalIdentity: plugin.catalogLogicalIdentity, manifest: plugin.manifest,
|
|
2165
|
+
scope: 'user', context: config.context ?? 'user', platform: config.platform, cwd: context.cwd, env: context.env,
|
|
1272
2166
|
});
|
|
1273
|
-
const
|
|
1274
|
-
user:
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
scope: 'user',
|
|
1278
|
-
projectLayer: 'shared',
|
|
1279
|
-
cwd: context.cwd,
|
|
1280
|
-
env: context.env,
|
|
1281
|
-
}),
|
|
1282
|
-
project: await resolveConfigRead({
|
|
1283
|
-
pluginName: plugin.manifest.name,
|
|
1284
|
-
plugin,
|
|
1285
|
-
scope: 'project',
|
|
1286
|
-
projectLayer: 'shared',
|
|
1287
|
-
cwd: context.cwd,
|
|
1288
|
-
env: context.env,
|
|
1289
|
-
}),
|
|
1290
|
-
local: await resolveConfigRead({
|
|
1291
|
-
pluginName: plugin.manifest.name,
|
|
1292
|
-
plugin,
|
|
1293
|
-
scope: 'project',
|
|
1294
|
-
projectLayer: 'local',
|
|
1295
|
-
cwd: context.cwd,
|
|
1296
|
-
env: context.env,
|
|
1297
|
-
}),
|
|
1298
|
-
};
|
|
1299
|
-
return buildConfigPage({
|
|
1300
|
-
pluginId,
|
|
1301
|
-
schema: plugin.manifest.config,
|
|
1302
|
-
read,
|
|
1303
|
-
effectiveRead,
|
|
1304
|
-
...(layerReads ? { layerReads } : {}),
|
|
2167
|
+
const effective = await resolveEffectivePluginConfigFromStores({
|
|
2168
|
+
manifest: plugin.manifest, context: config.context ?? 'user', platform: config.platform,
|
|
2169
|
+
projectRoot: workContext.projectRoot ?? '', stores: candidateStores,
|
|
2170
|
+
referenceContext: references.context,
|
|
1305
2171
|
});
|
|
2172
|
+
// Keep invalid raw sources for Core validation; effective.values omits them.
|
|
2173
|
+
// Preserve active branches in other references that reserve source values.
|
|
2174
|
+
// Only source choices and entry digests leave this boundary.
|
|
2175
|
+
const candidate = {};
|
|
2176
|
+
for (const key of Object.keys(definition.fields)) {
|
|
2177
|
+
const source = effective.sources[key];
|
|
2178
|
+
if (source === 'default')
|
|
2179
|
+
candidate[key] = definition.fields[key].default;
|
|
2180
|
+
else if (source === 'common')
|
|
2181
|
+
candidate[key] = candidateStores.user.common?.[key];
|
|
2182
|
+
else if (source === 'platform' && config.platform)
|
|
2183
|
+
candidate[key] = candidateStores.user.platforms?.[config.platform]?.[key];
|
|
2184
|
+
}
|
|
2185
|
+
const result = { platform: config.platform, selections: {} };
|
|
2186
|
+
for (const scalar of scalars) {
|
|
2187
|
+
const ref = scalar.valueRef;
|
|
2188
|
+
const selection = getPluginConfigReferenceChoices(definition, scalar, candidate, references.context);
|
|
2189
|
+
const entries = ref.plugin ? references.context.plugins[ref.plugin]?.values?.[ref.field] : candidate[ref.field];
|
|
2190
|
+
result.selections[configReferenceKey(scalar, config.platform)] = {
|
|
2191
|
+
...selection, source: (ref.plugin
|
|
2192
|
+
? references.evidence.find((entry) => entry.plugin === ref.plugin)?.sources[ref.field]
|
|
2193
|
+
: effective.sources[ref.field]) ?? 'missing',
|
|
2194
|
+
entries: Array.isArray(entries) ? Object.fromEntries(entries.flatMap((entry) => entry && typeof entry === 'object' && Object.hasOwn(entry, ref.key)
|
|
2195
|
+
? [[JSON.stringify(entry[ref.key]), digest(entry)]] : [])) : {},
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
return result;
|
|
1306
2199
|
},
|
|
1307
2200
|
});
|
|
1308
2201
|
},
|
|
1309
|
-
async getConfigResetAvailability(pluginId,
|
|
2202
|
+
async getConfigResetAvailability(pluginId, config, signal) {
|
|
2203
|
+
if (config.context === 'project')
|
|
2204
|
+
await resolveWorkContext({ cwd: context.cwd, context: 'project' });
|
|
2205
|
+
const parsed = parsePluginId(pluginId);
|
|
2206
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
2207
|
+
throw new TuiOperationBlockedError('invalidPluginId', '设置目标必须使用 canonical pluginId。');
|
|
2208
|
+
}
|
|
2209
|
+
let sourceIdentity;
|
|
2210
|
+
let logicalIdentity;
|
|
2211
|
+
try {
|
|
2212
|
+
const packageInfo = await readCliPackageInfo();
|
|
2213
|
+
const source = await withResolvedCatalogPlugin({
|
|
2214
|
+
selector: pluginId,
|
|
2215
|
+
cliVersion: packageInfo.version,
|
|
2216
|
+
env: context.env,
|
|
2217
|
+
signal,
|
|
2218
|
+
...(sessionContextForPlugin(pluginId)
|
|
2219
|
+
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
2220
|
+
: {}),
|
|
2221
|
+
consume: async ({ source }) => ({
|
|
2222
|
+
sourceIdentity: source.sourceIdentity,
|
|
2223
|
+
logicalIdentity: source.logicalIdentity,
|
|
2224
|
+
}),
|
|
2225
|
+
});
|
|
2226
|
+
sourceIdentity = source.sourceIdentity;
|
|
2227
|
+
logicalIdentity = source.logicalIdentity;
|
|
2228
|
+
}
|
|
2229
|
+
catch {
|
|
2230
|
+
sourceIdentity = undefined;
|
|
2231
|
+
logicalIdentity = undefined;
|
|
2232
|
+
}
|
|
1310
2233
|
signal.throwIfAborted();
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
sourceId,
|
|
1316
|
-
pluginName,
|
|
1317
|
-
scope: layer.scope,
|
|
1318
|
-
projectLayer: layer.projectLayer,
|
|
2234
|
+
const target = await inspectPluginConfigResetTarget({
|
|
2235
|
+
sourceId: parsed.sourceId,
|
|
2236
|
+
pluginName: parsed.pluginName,
|
|
2237
|
+
scope: 'user',
|
|
1319
2238
|
cwd: context.cwd,
|
|
1320
2239
|
env: context.env,
|
|
1321
2240
|
});
|
|
1322
2241
|
signal.throwIfAborted();
|
|
1323
|
-
if (
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
2242
|
+
if (target.kind === 'regularFile') {
|
|
2243
|
+
const store = await readPluginConfigStore({
|
|
2244
|
+
sourceId: parsed.sourceId,
|
|
2245
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
2246
|
+
...(logicalIdentity ? { logicalIdentity } : {}),
|
|
2247
|
+
pluginName: parsed.pluginName,
|
|
2248
|
+
scope: 'user',
|
|
2249
|
+
platform: config.platform,
|
|
2250
|
+
cwd: context.cwd,
|
|
2251
|
+
env: context.env,
|
|
2252
|
+
});
|
|
2253
|
+
signal.throwIfAborted();
|
|
1331
2254
|
return {
|
|
1332
|
-
exists:
|
|
1333
|
-
|
|
1334
|
-
|
|
2255
|
+
exists: store.exists,
|
|
2256
|
+
state: store.state,
|
|
2257
|
+
...(store.invalidCode ? { invalidCode: store.invalidCode } : {}),
|
|
2258
|
+
sourceIdentityPresent: sourceIdentity !== undefined,
|
|
2259
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
2260
|
+
targetKind: target.kind,
|
|
2261
|
+
resettable: target.resettable,
|
|
2262
|
+
storeDigest: target.fingerprint,
|
|
1335
2263
|
};
|
|
1336
2264
|
}
|
|
1337
2265
|
return {
|
|
1338
|
-
exists:
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
}),
|
|
2266
|
+
exists: target.exists,
|
|
2267
|
+
state: target.kind === 'absent' ? 'missing' : 'invalid',
|
|
2268
|
+
sourceIdentityPresent: sourceIdentity !== undefined,
|
|
2269
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
2270
|
+
targetKind: target.kind,
|
|
2271
|
+
resettable: target.resettable,
|
|
2272
|
+
storeDigest: target.fingerprint,
|
|
1346
2273
|
};
|
|
1347
2274
|
},
|
|
1348
|
-
async executeIntent(intent, expectedEvidence) {
|
|
2275
|
+
async executeIntent(intent, expectedEvidence, signal) {
|
|
2276
|
+
if (intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch'
|
|
2277
|
+
|| intent.kind === 'pluginWriteTask') {
|
|
2278
|
+
throw new TuiOperationBlockedError('useScopedRecovery', '请使用统一范围恢复任务。');
|
|
2279
|
+
}
|
|
2280
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
2281
|
+
signal?.throwIfAborted();
|
|
2282
|
+
if (!expectedEvidence.catalogStore) {
|
|
2283
|
+
throw new TuiOperationBlockedError('catalogStoreReviewStale', '确认信息缺少精确清理目标。');
|
|
2284
|
+
}
|
|
2285
|
+
return executeCatalogStoreTask({
|
|
2286
|
+
env: context.env,
|
|
2287
|
+
authorizedItems: expectedEvidence.catalogStore.authorizedItems,
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
if (intent.kind === 'catalogSourcesRecovery') {
|
|
2291
|
+
signal?.throwIfAborted();
|
|
2292
|
+
return recoverInvalidCatalogSourcesConfig({ env: context.env });
|
|
2293
|
+
}
|
|
2294
|
+
if (intent.kind === 'catalogGeneration') {
|
|
2295
|
+
signal?.throwIfAborted();
|
|
2296
|
+
const expected = expectedEvidence.catalogGeneration;
|
|
2297
|
+
if (!expected)
|
|
2298
|
+
throw new TuiOperationBlockedError('catalogGenerationReviewStale', '确认信息缺少 Catalog candidate。');
|
|
2299
|
+
const packageInfo = await readCliPackageInfo();
|
|
2300
|
+
let configSaved = false;
|
|
2301
|
+
if (intent.sourceMutation) {
|
|
2302
|
+
const common = {
|
|
2303
|
+
cwd: context.cwd,
|
|
2304
|
+
env: context.env,
|
|
2305
|
+
cliVersion: packageInfo.version,
|
|
2306
|
+
expectedConfigDigest: expected.configDigest,
|
|
2307
|
+
};
|
|
2308
|
+
if (intent.sourceMutation.action === 'add') {
|
|
2309
|
+
await addCatalogSourceCommand({
|
|
2310
|
+
...common,
|
|
2311
|
+
source: intent.sourceMutation.source,
|
|
2312
|
+
expectedProposedConfigDigest: expected.proposedConfigDigest,
|
|
2313
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2314
|
+
requireImpactConfirmation: true,
|
|
2315
|
+
confirmImpact: true,
|
|
2316
|
+
});
|
|
2317
|
+
}
|
|
2318
|
+
else {
|
|
2319
|
+
await updateCatalogSourceCommand({
|
|
2320
|
+
...common,
|
|
2321
|
+
sourceId: intent.sourceId,
|
|
2322
|
+
update: intent.sourceMutation.update,
|
|
2323
|
+
expectedProposedConfigDigest: expected.proposedConfigDigest,
|
|
2324
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2325
|
+
requireIdentityChangeConfirmation: true,
|
|
2326
|
+
confirmIdentityChange: true,
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
configSaved = true;
|
|
2330
|
+
await tuiControllerRuntimeTestHooks?.afterCatalogSourceConfigCommit?.();
|
|
2331
|
+
}
|
|
2332
|
+
try {
|
|
2333
|
+
let generation;
|
|
2334
|
+
if (intent.action === 'recoverState') {
|
|
2335
|
+
generation = await recoverCatalogGenerationStateAndActivate({
|
|
2336
|
+
sourceId: intent.sourceId,
|
|
2337
|
+
cliVersion: packageInfo.version,
|
|
2338
|
+
cwd: context.cwd,
|
|
2339
|
+
impactConfirmed: true,
|
|
2340
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2341
|
+
expectedCandidate: expected.candidate,
|
|
2342
|
+
env: context.env,
|
|
2343
|
+
signal,
|
|
2344
|
+
runtime: options.catalogGenerationRuntime,
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
else if (intent.action === 'repair') {
|
|
2348
|
+
generation = await repairCatalogSourceGeneration({
|
|
2349
|
+
sourceId: intent.sourceId,
|
|
2350
|
+
cliVersion: packageInfo.version,
|
|
2351
|
+
cwd: context.cwd,
|
|
2352
|
+
expectedCandidate: expected.candidate,
|
|
2353
|
+
expectedActive: expected.previousActive ?? null,
|
|
2354
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
2355
|
+
env: context.env,
|
|
2356
|
+
signal,
|
|
2357
|
+
runtime: {
|
|
2358
|
+
...options.catalogGenerationRuntime,
|
|
2359
|
+
afterCandidateResolved: tuiControllerRuntimeTestHooks
|
|
2360
|
+
?.afterCatalogGenerationCandidateResolved,
|
|
2361
|
+
},
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
else if (intent.action === 'update' && expected.exactRepair) {
|
|
2365
|
+
generation = await repairCatalogSourceGeneration({
|
|
2366
|
+
sourceId: intent.sourceId,
|
|
2367
|
+
cliVersion: packageInfo.version,
|
|
2368
|
+
cwd: context.cwd,
|
|
2369
|
+
expectedActive: expected.previousActive ?? null,
|
|
2370
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
2371
|
+
env: context.env,
|
|
2372
|
+
signal,
|
|
2373
|
+
runtime: options.catalogGenerationRuntime,
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
else if (intent.action === 'replaceDamaged') {
|
|
2377
|
+
generation = await replaceDamagedCatalogSourceGeneration({
|
|
2378
|
+
sourceId: intent.sourceId,
|
|
2379
|
+
cliVersion: packageInfo.version,
|
|
2380
|
+
cwd: context.cwd,
|
|
2381
|
+
expectedCandidate: expected.candidate,
|
|
2382
|
+
expectedActive: expected.previousActive,
|
|
2383
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
2384
|
+
impactConfirmed: true,
|
|
2385
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2386
|
+
env: context.env,
|
|
2387
|
+
signal,
|
|
2388
|
+
runtime: {
|
|
2389
|
+
...options.catalogGenerationRuntime,
|
|
2390
|
+
afterCandidateResolved: tuiControllerRuntimeTestHooks
|
|
2391
|
+
?.afterCatalogGenerationCandidateResolved,
|
|
2392
|
+
},
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
else {
|
|
2396
|
+
generation = await activateCatalogSourceGeneration({
|
|
2397
|
+
sourceId: intent.sourceId,
|
|
2398
|
+
cliVersion: packageInfo.version,
|
|
2399
|
+
cwd: context.cwd,
|
|
2400
|
+
activationMode: expected.activationMode,
|
|
2401
|
+
impactConfirmed: true,
|
|
2402
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2403
|
+
impactMode: expected.impactMode,
|
|
2404
|
+
expectedCandidate: expected.candidate,
|
|
2405
|
+
expectedActive: expected.previousActive ?? null,
|
|
2406
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
2407
|
+
env: context.env,
|
|
2408
|
+
signal,
|
|
2409
|
+
runtime: {
|
|
2410
|
+
...options.catalogGenerationRuntime,
|
|
2411
|
+
afterCandidateResolved: tuiControllerRuntimeTestHooks
|
|
2412
|
+
?.afterCatalogGenerationCandidateResolved,
|
|
2413
|
+
},
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
let primaryChanged = false;
|
|
2417
|
+
if (intent.setPrimaryAfterActivation) {
|
|
2418
|
+
try {
|
|
2419
|
+
await setPrimaryCatalogSourceCommand({
|
|
2420
|
+
sourceId: intent.sourceId,
|
|
2421
|
+
cwd: context.cwd,
|
|
2422
|
+
env: context.env,
|
|
2423
|
+
expectedConfigDigest: expected.primaryConfigDigest,
|
|
2424
|
+
expectedImpactDigest: expected.primaryImpactDigest,
|
|
2425
|
+
requireImpactConfirmation: true,
|
|
2426
|
+
confirmImpact: true,
|
|
2427
|
+
});
|
|
2428
|
+
primaryChanged = true;
|
|
2429
|
+
}
|
|
2430
|
+
catch (error) {
|
|
2431
|
+
return {
|
|
2432
|
+
status: 'partial',
|
|
2433
|
+
partialReason: 'primary',
|
|
2434
|
+
configSaved,
|
|
2435
|
+
generation,
|
|
2436
|
+
activeAvailable: true,
|
|
2437
|
+
errorCode: typeof error === 'object' && error !== null
|
|
2438
|
+
&& 'code' in error && typeof error.code === 'string'
|
|
2439
|
+
? error.code
|
|
2440
|
+
: error instanceof Error ? error.name : 'catalogSourcePrimaryFailed',
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
return { status: 'succeeded', generation, configSaved, primaryChanged };
|
|
2445
|
+
}
|
|
2446
|
+
catch (error) {
|
|
2447
|
+
if (!configSaved)
|
|
2448
|
+
throw error;
|
|
2449
|
+
return {
|
|
2450
|
+
status: 'partial',
|
|
2451
|
+
partialReason: 'activation',
|
|
2452
|
+
configSaved: true,
|
|
2453
|
+
errorCode: error instanceof CatalogGenerationError ? error.code : 'catalogGenerationRefreshFailed',
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
1349
2457
|
if (intent.kind === 'portableInstall') {
|
|
1350
2458
|
if (!expectedEvidence.portable) {
|
|
1351
2459
|
throw operationReviewStale('确认信息缺少 Portable evidence。');
|
|
1352
2460
|
}
|
|
1353
2461
|
const packageInfo = await readCliPackageInfo();
|
|
1354
2462
|
try {
|
|
2463
|
+
if (intent.retry) {
|
|
2464
|
+
if (!('retryPairs' in expectedEvidence.portable)) {
|
|
2465
|
+
throw operationReviewStale('确认信息缺少 Portable 重试目标。');
|
|
2466
|
+
}
|
|
2467
|
+
return await executePortableRetry({
|
|
2468
|
+
receipt: intent.retry.receipt,
|
|
2469
|
+
review: expectedEvidence.portable,
|
|
2470
|
+
expectedEvidenceDigest: expectedEvidence.portable.evidenceDigest,
|
|
2471
|
+
cwd: context.cwd,
|
|
2472
|
+
env: context.env,
|
|
2473
|
+
cliVersion: packageInfo.version,
|
|
2474
|
+
signal,
|
|
2475
|
+
onProgress(stage) {
|
|
2476
|
+
const phase = stage === 'prepare' ? '重新检查失败目标'
|
|
2477
|
+
: stage === 'add' ? '重试缺失的 Skills' : '验证重试结果';
|
|
2478
|
+
progressFeed?.setCurrent({ target: 'Skills CLI', phase }, `Portable Skills:${phase}`);
|
|
2479
|
+
},
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
1355
2482
|
return await installPortableSkills({
|
|
1356
2483
|
selector: intent.pluginId,
|
|
1357
2484
|
scope: intent.scope,
|
|
@@ -1377,27 +2504,6 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1377
2504
|
throw error;
|
|
1378
2505
|
}
|
|
1379
2506
|
}
|
|
1380
|
-
if (intent.kind === 'catalogActivate') {
|
|
1381
|
-
const currentEvidence = await captureEvidence(intent, undefined, undefined, false);
|
|
1382
|
-
if (operationEvidenceFingerprint(currentEvidence) !== operationEvidenceFingerprint(expectedEvidence)) {
|
|
1383
|
-
throw operationReviewStale('确认后 Catalog Candidate 发生变化。');
|
|
1384
|
-
}
|
|
1385
|
-
try {
|
|
1386
|
-
return await activateCatalogSourceCandidate({
|
|
1387
|
-
sourceId: intent.sourceId,
|
|
1388
|
-
expectedCandidateGenerationKey: intent.candidateGenerationKey,
|
|
1389
|
-
env: context.env,
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
catch (error) {
|
|
1393
|
-
if (error instanceof CatalogGenerationError
|
|
1394
|
-
&& (error.code === 'catalogGenerationCandidateChanged'
|
|
1395
|
-
|| error.code === 'catalogGenerationCandidateUnavailable')) {
|
|
1396
|
-
throw operationReviewStale('确认后 Catalog Candidate 发生变化。');
|
|
1397
|
-
}
|
|
1398
|
-
throw error;
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
2507
|
if (intent.kind === 'sourceMutation') {
|
|
1402
2508
|
const currentEvidence = await captureEvidence(intent);
|
|
1403
2509
|
if (operationEvidenceFingerprint(currentEvidence) !== operationEvidenceFingerprint(expectedEvidence)) {
|
|
@@ -1416,19 +2522,44 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1416
2522
|
cwd: context.cwd,
|
|
1417
2523
|
env: context.env,
|
|
1418
2524
|
expectedConfigDigest: expectedEvidence.sourceWrite?.configDigest,
|
|
2525
|
+
expectedProposedConfigDigest: expectedEvidence.sourceWrite?.proposedConfigDigest,
|
|
2526
|
+
expectedImpactDigest: expectedEvidence.sourceWrite?.impactDigest,
|
|
1419
2527
|
runtime,
|
|
1420
2528
|
};
|
|
1421
2529
|
if (intent.action === 'add' && intent.source) {
|
|
1422
|
-
return addCatalogSourceCommand({
|
|
2530
|
+
return addCatalogSourceCommand({
|
|
2531
|
+
...common,
|
|
2532
|
+
source: intent.source,
|
|
2533
|
+
cliVersion: packageInfo.version,
|
|
2534
|
+
requireImpactConfirmation: true,
|
|
2535
|
+
confirmImpact: true,
|
|
2536
|
+
});
|
|
1423
2537
|
}
|
|
1424
2538
|
if (intent.action === 'update' && intent.update) {
|
|
1425
|
-
return updateCatalogSourceCommand({
|
|
2539
|
+
return updateCatalogSourceCommand({
|
|
2540
|
+
...common,
|
|
2541
|
+
sourceId: intent.sourceId,
|
|
2542
|
+
update: intent.update,
|
|
2543
|
+
cliVersion: packageInfo.version,
|
|
2544
|
+
requireIdentityChangeConfirmation: true,
|
|
2545
|
+
confirmIdentityChange: true,
|
|
2546
|
+
});
|
|
1426
2547
|
}
|
|
1427
2548
|
if (intent.action === 'setPrimary') {
|
|
1428
|
-
return setPrimaryCatalogSourceCommand({
|
|
2549
|
+
return setPrimaryCatalogSourceCommand({
|
|
2550
|
+
...common,
|
|
2551
|
+
sourceId: intent.sourceId,
|
|
2552
|
+
requireImpactConfirmation: true,
|
|
2553
|
+
confirmImpact: true,
|
|
2554
|
+
});
|
|
1429
2555
|
}
|
|
1430
2556
|
if (intent.action === 'remove') {
|
|
1431
|
-
return removeCatalogSourceCommand({
|
|
2557
|
+
return removeCatalogSourceCommand({
|
|
2558
|
+
...common,
|
|
2559
|
+
sourceId: intent.sourceId,
|
|
2560
|
+
requireImpactConfirmation: true,
|
|
2561
|
+
confirmImpact: true,
|
|
2562
|
+
});
|
|
1432
2563
|
}
|
|
1433
2564
|
throw new TuiOperationBlockedError('invalidSourceMutation', '来源操作缺少候选输入。');
|
|
1434
2565
|
}
|
|
@@ -1437,8 +2568,8 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1437
2568
|
action: async (awHomeMutationToken) => {
|
|
1438
2569
|
await tuiControllerRuntimeTestHooks?.beforeMutationEvidenceCapture?.();
|
|
1439
2570
|
const operationInventory = createOperationInventoryReader();
|
|
1440
|
-
const currentEvidence = await captureEvidence(intent, undefined, undefined,
|
|
1441
|
-
if (
|
|
2571
|
+
const currentEvidence = await captureEvidence(intent, undefined, undefined, operationInventory, true);
|
|
2572
|
+
if (!operationEvidenceMatches(expectedEvidence, currentEvidence)) {
|
|
1442
2573
|
throw new TuiOperationBlockedError('operationReviewStale', '确认后状态发生变化。');
|
|
1443
2574
|
}
|
|
1444
2575
|
const catalogOperation = catalogOperationByEvidence.get(currentEvidence);
|
|
@@ -1447,52 +2578,182 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1447
2578
|
throw operationReviewStale('确认后 Active Catalog generation 发生变化。');
|
|
1448
2579
|
}
|
|
1449
2580
|
await tuiControllerRuntimeTestHooks?.afterMutationEvidenceCapture?.();
|
|
1450
|
-
if (intent.kind === '
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
...(expectedEvidence.codexManager?.state === 'requires-install'
|
|
1456
|
-
? { allowManagedCodexInstall: true }
|
|
1457
|
-
: {}),
|
|
1458
|
-
...(intent.action === 'cleanup' ? { force: intent.force === true } : {}),
|
|
1459
|
-
};
|
|
1460
|
-
const command = {
|
|
1461
|
-
install: installWriteCommand,
|
|
1462
|
-
upgrade: upgradeWriteCommand,
|
|
1463
|
-
reinstall: reinstallWriteCommand,
|
|
1464
|
-
uninstall: uninstallWriteCommand,
|
|
1465
|
-
cleanup: cleanupWriteCommand,
|
|
1466
|
-
}[intent.action];
|
|
1467
|
-
const currentSource = currentEvidence.source;
|
|
1468
|
-
const offlineCleanup = currentEvidence.offlineCleanup;
|
|
1469
|
-
if (!offlineCleanup && (!expectedEvidence.source || !currentSource)) {
|
|
1470
|
-
throw new TuiOperationBlockedError('operationReviewStale', '确认信息缺少来源身份。');
|
|
2581
|
+
if (intent.kind === 'configSaveBatch') {
|
|
2582
|
+
assertConfigSaveBatchIntent(intent);
|
|
2583
|
+
const reviewedBatch = expectedEvidence.configBatch;
|
|
2584
|
+
if (!reviewedBatch || !currentEvidence.configBatch || !currentEvidence.source) {
|
|
2585
|
+
throw operationReviewStale('确认信息缺少设置批次证据。');
|
|
1471
2586
|
}
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
2587
|
+
const approvedApplyTargets = new Set(reviewedBatch.groups.flatMap((group) => group.config.affectedTargets.map((target) => `${target.pluginName ?? parsePluginId(intent.pluginId).pluginName}\0${target.platform}\0${target.scope}`)));
|
|
2588
|
+
const approvedCommandPackages = new Set(reviewedBatch.groups.flatMap((group) => (group.config.commandPackages ?? []).map((target) => target.packageId)));
|
|
2589
|
+
const approvedPreApplyTargets = reviewedBatch.groups.flatMap((group) => group.config.preApplyAuthorization ?? []);
|
|
2590
|
+
const results = [];
|
|
2591
|
+
const packageInfo = await readCliPackageInfo();
|
|
2592
|
+
for (const group of intent.groups) {
|
|
2593
|
+
const groupIntent = configSaveBatchGroupIntent(intent, group);
|
|
2594
|
+
const reviewedGroup = reviewedBatch.groups.find((item) => item.platform === group.platform);
|
|
2595
|
+
if (!reviewedGroup) {
|
|
2596
|
+
throw operationReviewStale('确认信息缺少设置层基线。');
|
|
2597
|
+
}
|
|
2598
|
+
let configSaved = false;
|
|
2599
|
+
const operationRebuildResults = [];
|
|
2600
|
+
try {
|
|
2601
|
+
const freshEvidence = await captureEvidence(groupIntent, undefined, undefined, operationInventory, true);
|
|
2602
|
+
const freshSource = freshEvidence.source;
|
|
2603
|
+
const freshConfig = freshEvidence.config;
|
|
2604
|
+
if (!freshSource || !freshConfig) {
|
|
2605
|
+
throw operationReviewStale('设置目标缺少最新证据。');
|
|
2606
|
+
}
|
|
2607
|
+
assertSourceEvidenceMatches(currentEvidence.source, freshSource);
|
|
2608
|
+
const freshLayerStoreDigest = await configLayerStoreDigest({
|
|
2609
|
+
source: freshSource,
|
|
2610
|
+
pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
2611
|
+
scope: 'user', platform: group.platform, profileOnly: true,
|
|
2612
|
+
cwd: context.cwd,
|
|
2613
|
+
env: context.env,
|
|
2614
|
+
});
|
|
2615
|
+
if (freshLayerStoreDigest !== reviewedGroup.config.storeDigest) {
|
|
2616
|
+
throw operationReviewStale('保存设置期间此设置层的原始内容发生变化。');
|
|
2617
|
+
}
|
|
2618
|
+
if (freshConfig.affectedTargets.some((target) => !approvedApplyTargets.has(`${target.pluginName ?? parsePluginId(intent.pluginId).pluginName}\0${target.platform}\0${target.scope}`))
|
|
2619
|
+
|| freshConfig.commandPackages?.some((target) => !approvedCommandPackages.has(target.packageId))) {
|
|
2620
|
+
throw operationReviewStale('同批前一层变更扩大了未经确认的应用目标。');
|
|
2621
|
+
}
|
|
2622
|
+
const groupCatalogOperation = catalogOperationByEvidence.get(freshEvidence);
|
|
2623
|
+
if (expectedEvidence.catalog.generationSetDigest
|
|
2624
|
+
&& groupCatalogOperation?.generationSetDigest
|
|
2625
|
+
!== expectedEvidence.catalog.generationSetDigest) {
|
|
2626
|
+
throw operationReviewStale('保存设置期间 Active Catalog generation 发生变化。');
|
|
2627
|
+
}
|
|
2628
|
+
const result = await withResolvedCatalogPlugin({
|
|
2629
|
+
selector: intent.pluginId,
|
|
2630
|
+
cliVersion: packageInfo.version,
|
|
2631
|
+
env: context.env,
|
|
2632
|
+
...(groupCatalogOperation ? { operationContext: groupCatalogOperation } : {}),
|
|
2633
|
+
consume: async ({ plugin, source }) => {
|
|
2634
|
+
assertSourceEvidenceMatches(freshSource, sourceEvidenceForPlugin(source, plugin.manifest.name));
|
|
2635
|
+
const referencePlugins = configNeedsReferencePlugins(plugin) ? await resolvePluginConfigReferencePlugins({
|
|
2636
|
+
sourceId: plugin.sourceId,
|
|
2637
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2638
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2639
|
+
env: context.env,
|
|
2640
|
+
operationContext: groupCatalogOperation,
|
|
2641
|
+
}) : undefined;
|
|
2642
|
+
const applyTargets = intent.apply
|
|
2643
|
+
? freshConfig.affectedTargets.filter((target) => NATIVE_PLATFORM_TARGETS.includes(target.platform)).map((target) => ({
|
|
2644
|
+
pluginName: target.pluginName ?? plugin.manifest.name,
|
|
2645
|
+
platform: target.platform,
|
|
2646
|
+
scope: target.scope,
|
|
2647
|
+
}))
|
|
2648
|
+
: [];
|
|
2649
|
+
return applyPluginConfigWrite({
|
|
2650
|
+
plugin,
|
|
2651
|
+
pluginName: plugin.manifest.name,
|
|
2652
|
+
scope: 'user', platform: group.platform, context: intent.context ?? 'user',
|
|
2653
|
+
apply: intent.apply,
|
|
2654
|
+
cwd: context.cwd,
|
|
2655
|
+
env: context.env,
|
|
2656
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
2657
|
+
rebuildRuntime: {
|
|
2658
|
+
...context,
|
|
2659
|
+
referencePlugins,
|
|
2660
|
+
awHomeMutationToken,
|
|
2661
|
+
operationDiagnosticSink: (entries) => {
|
|
2662
|
+
operationRebuildResults.push(...structuredClone(entries));
|
|
2663
|
+
},
|
|
2664
|
+
...(reviewedScriptTimeoutMs(intent) === undefined ? {} : {
|
|
2665
|
+
scriptTimeoutMs: reviewedScriptTimeoutMs(intent),
|
|
2666
|
+
}),
|
|
2667
|
+
...(groupCatalogOperation ? {
|
|
2668
|
+
catalogOperationContext: groupCatalogOperation,
|
|
2669
|
+
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
2670
|
+
} : {}),
|
|
2671
|
+
},
|
|
2672
|
+
awHomeMutationToken,
|
|
2673
|
+
...(applyTargets.length ? { applyTargets } : {}),
|
|
2674
|
+
request: { updates: group.updates, removeKeys: group.removeKeys },
|
|
2675
|
+
sharedNativeApplyConfirmed: true,
|
|
2676
|
+
preApplyConfirmed: true,
|
|
2677
|
+
preApplyAuthorizedTargets: approvedPreApplyTargets,
|
|
2678
|
+
});
|
|
2679
|
+
},
|
|
2680
|
+
});
|
|
2681
|
+
configSaved = result.configWrite === 'succeeded';
|
|
2682
|
+
const applyStatus = !intent.apply
|
|
2683
|
+
? 'notRequested'
|
|
2684
|
+
: result.apply.state === 'succeeded'
|
|
2685
|
+
? 'succeeded'
|
|
2686
|
+
: result.apply.state === 'skipped'
|
|
2687
|
+
? 'notNeeded'
|
|
2688
|
+
: 'failed';
|
|
2689
|
+
results.push({
|
|
2690
|
+
scope: 'user', platform: group.platform,
|
|
2691
|
+
status: applyStatus === 'failed' ? 'failed' : 'succeeded',
|
|
2692
|
+
configSaved,
|
|
2693
|
+
applyRequested: intent.apply,
|
|
2694
|
+
applyStatus,
|
|
2695
|
+
execution: { ...result, operationRebuildResults },
|
|
2696
|
+
...(applyStatus === 'failed' ? {
|
|
2697
|
+
errorCode: result.apply.state === 'unavailable'
|
|
2698
|
+
? result.apply.error?.code ?? result.apply.reason
|
|
2699
|
+
: result.apply.targetResults.find((target) => target.errorCode)?.errorCode
|
|
2700
|
+
?? 'runtimeApplyFailed',
|
|
2701
|
+
} : {}),
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
catch (error) {
|
|
2705
|
+
configSaved = error?.configWrite === 'succeeded';
|
|
2706
|
+
const errorCode = typeof error === 'object' && error !== null
|
|
2707
|
+
&& 'code' in error && typeof error.code === 'string'
|
|
2708
|
+
? error.code
|
|
2709
|
+
: configSaved ? 'runtimeApplyFailed' : 'configWriteFailed';
|
|
2710
|
+
results.push({
|
|
2711
|
+
scope: 'user', platform: group.platform,
|
|
2712
|
+
status: 'failed',
|
|
2713
|
+
configSaved,
|
|
2714
|
+
applyRequested: intent.apply,
|
|
2715
|
+
applyStatus: intent.apply ? 'failed' : 'notRequested',
|
|
2716
|
+
errorCode,
|
|
2717
|
+
...(operationRebuildResults.length > 0
|
|
2718
|
+
? { execution: { operationRebuildResults } }
|
|
2719
|
+
: {}),
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
const succeeded = results.filter((result) => result.status === 'succeeded').length;
|
|
2724
|
+
return {
|
|
2725
|
+
status: succeeded === results.length
|
|
2726
|
+
? 'succeeded'
|
|
2727
|
+
: succeeded > 0 || results.some((result) => result.configSaved)
|
|
2728
|
+
? 'partial'
|
|
2729
|
+
: 'failed',
|
|
2730
|
+
groups: results,
|
|
2731
|
+
};
|
|
1493
2732
|
}
|
|
1494
2733
|
if (intent.kind === 'configSave' || intent.kind === 'configReset') {
|
|
2734
|
+
const operationRebuildResults = [];
|
|
2735
|
+
const operationDiagnosticSink = (results) => {
|
|
2736
|
+
operationRebuildResults.push(...structuredClone(results));
|
|
2737
|
+
};
|
|
1495
2738
|
const currentSource = currentEvidence.source;
|
|
2739
|
+
if (intent.kind === 'configReset') {
|
|
2740
|
+
const parsed = parsePluginId(intent.pluginId);
|
|
2741
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
2742
|
+
throw operationReviewStale('确认信息缺少 qualified 设置目标。');
|
|
2743
|
+
}
|
|
2744
|
+
return resetPluginConfigWithHelper({
|
|
2745
|
+
sourceId: parsed.sourceId,
|
|
2746
|
+
pluginName: parsed.pluginName,
|
|
2747
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
2748
|
+
cwd: context.cwd,
|
|
2749
|
+
env: context.env,
|
|
2750
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
2751
|
+
rebuildRuntime: { ...context, awHomeMutationToken },
|
|
2752
|
+
awHomeMutationToken,
|
|
2753
|
+
apply: false,
|
|
2754
|
+
sharedNativeApplyConfirmed: false,
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
1496
2757
|
if (!currentSource) {
|
|
1497
2758
|
throw operationReviewStale('确认信息缺少来源身份。');
|
|
1498
2759
|
}
|
|
@@ -1500,57 +2761,81 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1500
2761
|
return withResolvedCatalogPlugin({
|
|
1501
2762
|
selector: intent.pluginId,
|
|
1502
2763
|
cliVersion: packageInfo.version,
|
|
1503
|
-
freshnessPolicy: 'cacheFirst',
|
|
1504
2764
|
env: context.env,
|
|
1505
2765
|
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1506
2766
|
consume: async ({ plugin, source }) => {
|
|
1507
2767
|
assertSourceEvidenceMatches(currentSource, sourceEvidenceForPlugin(source, plugin.manifest.name));
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
2768
|
+
const referencePlugins = configNeedsReferencePlugins(plugin) ? await resolvePluginConfigReferencePlugins({
|
|
2769
|
+
sourceId: plugin.sourceId,
|
|
2770
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2771
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2772
|
+
env: context.env,
|
|
2773
|
+
operationContext: catalogOperation,
|
|
2774
|
+
}) : undefined;
|
|
2775
|
+
const applyTargets = intent.retryApply || intent.apply
|
|
2776
|
+
? currentEvidence.config?.affectedTargets.filter((target) => NATIVE_PLATFORM_TARGETS.includes(target.platform)).map((target) => ({
|
|
2777
|
+
pluginName: target.pluginName ?? plugin.manifest.name,
|
|
2778
|
+
platform: target.platform,
|
|
2779
|
+
scope: target.scope,
|
|
2780
|
+
})) ?? []
|
|
2781
|
+
: [];
|
|
2782
|
+
const result = intent.retryApply
|
|
2783
|
+
? await applyPluginConfig({
|
|
1515
2784
|
plugin,
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
2785
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
2786
|
+
...(intent.targets ? { targets: intent.targets } : {}),
|
|
2787
|
+
cliVersion: packageInfo.version,
|
|
1519
2788
|
cwd: context.cwd,
|
|
1520
2789
|
env: context.env,
|
|
1521
2790
|
nativeCliRunner: context.nativeCliRunner,
|
|
1522
2791
|
rebuildRuntime: {
|
|
1523
2792
|
...context,
|
|
2793
|
+
referencePlugins,
|
|
1524
2794
|
awHomeMutationToken,
|
|
2795
|
+
operationDiagnosticSink,
|
|
2796
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
2797
|
+
? {}
|
|
2798
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
1525
2799
|
...(catalogOperation ? {
|
|
1526
2800
|
catalogOperationContext: catalogOperation,
|
|
1527
2801
|
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
1528
2802
|
} : {}),
|
|
1529
2803
|
},
|
|
1530
2804
|
awHomeMutationToken,
|
|
1531
|
-
|
|
1532
|
-
|
|
2805
|
+
expectedEvidence: expectedEvidence.config?.applyEvidence,
|
|
2806
|
+
sharedNativeApplyConfirmed: true,
|
|
2807
|
+
preApplyConfirmed: true,
|
|
2808
|
+
preApplyAuthorizedTargets: expectedEvidence.config?.preApplyAuthorization ?? [],
|
|
1533
2809
|
})
|
|
1534
|
-
: await
|
|
2810
|
+
: await applyPluginConfigWrite({
|
|
1535
2811
|
plugin,
|
|
1536
2812
|
pluginName: plugin.manifest.name,
|
|
1537
|
-
scope: intent.
|
|
1538
|
-
|
|
2813
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
2814
|
+
apply: intent.apply,
|
|
1539
2815
|
cwd: context.cwd,
|
|
1540
2816
|
env: context.env,
|
|
1541
2817
|
nativeCliRunner: context.nativeCliRunner,
|
|
1542
2818
|
rebuildRuntime: {
|
|
1543
2819
|
...context,
|
|
2820
|
+
referencePlugins,
|
|
1544
2821
|
awHomeMutationToken,
|
|
2822
|
+
operationDiagnosticSink,
|
|
2823
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
2824
|
+
? {}
|
|
2825
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
1545
2826
|
...(catalogOperation ? {
|
|
1546
2827
|
catalogOperationContext: catalogOperation,
|
|
1547
2828
|
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
1548
2829
|
} : {}),
|
|
1549
2830
|
},
|
|
1550
2831
|
awHomeMutationToken,
|
|
1551
|
-
applyTargets,
|
|
2832
|
+
...(applyTargets.length ? { applyTargets } : {}),
|
|
2833
|
+
request: { updates: intent.updates, removeKeys: intent.removeKeys },
|
|
2834
|
+
sharedNativeApplyConfirmed: true,
|
|
2835
|
+
preApplyConfirmed: true,
|
|
2836
|
+
preApplyAuthorizedTargets: expectedEvidence.config?.preApplyAuthorization ?? [],
|
|
1552
2837
|
});
|
|
1553
|
-
return result;
|
|
2838
|
+
return { ...result, operationRebuildResults };
|
|
1554
2839
|
},
|
|
1555
2840
|
});
|
|
1556
2841
|
}
|