@lesliechan721/aw 0.1.0-beta.10 → 0.1.0-beta.100
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.d.mts +1 -50
- package/dist/authoring/assets/aw-config.mjs +58 -928
- 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/assets/command-runtime-config.d.mts +9 -0
- package/dist/authoring/assets/command-runtime-config.mjs +134 -0
- package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.mjs +16 -39
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +43 -71
- 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 +3 -3
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +5 -8
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +408 -1748
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-skill.mjs +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +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 +11 -1
- package/dist/scripts/aw-skill-eval-materializer.js +119 -114
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
- package/dist/scripts/bundle-plugins.js +32 -7
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +1 -1
- package/dist/scripts/plugin-staging.js +5 -2
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/plugin-test-context-guard.d.mts +1 -0
- package/dist/scripts/plugin-test-context-guard.mjs +59 -0
- package/dist/scripts/plugin-test-context-guard.mjs.map +1 -0
- 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 +343 -58
- 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 +3 -0
- 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 +1 -1
- package/dist/src/commands/aw-capabilities.js +48 -19
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/catalog-dev-source.d.ts +40 -3
- package/dist/src/commands/catalog-dev-source.js +333 -42
- package/dist/src/commands/catalog-dev-source.js.map +1 -1
- package/dist/src/commands/catalog-generation.d.ts +5 -0
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/catalog-publication-inspection.d.ts +11 -3
- package/dist/src/commands/catalog-publication-inspection.js +211 -59
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
- package/dist/src/commands/catalog-publication-journal.d.ts +12 -0
- package/dist/src/commands/catalog-publication-journal.js +78 -1
- package/dist/src/commands/catalog-publication-journal.js.map +1 -1
- package/dist/src/commands/catalog-publish.d.ts +21 -1
- package/dist/src/commands/catalog-publish.js +133 -92
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +25 -5
- package/dist/src/commands/catalog-source.js +153 -27
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-status.js +2 -2
- package/dist/src/commands/catalog-status.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +31 -7
- package/dist/src/commands/catalog-store.js +379 -42
- package/dist/src/commands/catalog-store.js.map +1 -1
- package/dist/src/commands/catalog-workspace-resolution.d.ts +4 -0
- package/dist/src/commands/catalog-workspace-resolution.js +18 -3
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -1
- package/dist/src/commands/console.js +33 -20
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.d.ts +7 -0
- package/dist/src/commands/dependency-operation-plan.js +66 -30
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.d.ts +11 -0
- package/dist/src/commands/deployment-confirmation.js +101 -0
- package/dist/src/commands/deployment-confirmation.js.map +1 -0
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +34 -0
- package/dist/src/commands/intent-command.js +174 -0
- package/dist/src/commands/intent-command.js.map +1 -0
- package/dist/src/commands/lifecycle-command-package.d.ts +45 -0
- package/dist/src/commands/lifecycle-command-package.js +199 -0
- package/dist/src/commands/lifecycle-command-package.js.map +1 -0
- package/dist/src/commands/managed-commands.d.ts +41 -0
- package/dist/src/commands/managed-commands.js +404 -0
- package/dist/src/commands/managed-commands.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +12 -2
- package/dist/src/commands/offline-cleanup-evidence.js +57 -35
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +72 -2
- package/dist/src/commands/operation-plan.js +54 -3
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/operation-planner.d.ts +6 -5
- package/dist/src/commands/operation-planner.js +23 -20
- package/dist/src/commands/operation-planner.js.map +1 -1
- package/dist/src/commands/options.d.ts +11 -16
- package/dist/src/commands/options.js +31 -25
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/permission-batch.d.ts +5 -0
- package/dist/src/commands/permission-batch.js +83 -0
- package/dist/src/commands/permission-batch.js.map +1 -0
- package/dist/src/commands/plugin-capabilities.js +128 -58
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +14 -0
- package/dist/src/commands/public-config-confirmation.js +73 -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 +106 -0
- package/dist/src/commands/public-lifecycle-result.js +536 -0
- package/dist/src/commands/public-lifecycle-result.js.map +1 -0
- package/dist/src/commands/public-lifecycle.d.ts +27 -0
- package/dist/src/commands/public-lifecycle.js +569 -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 +231 -0
- package/dist/src/commands/public-plugin-query.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +177 -16
- package/dist/src/commands/rebuild-command.js +3370 -1559
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +100 -55
- package/dist/src/commands/rebuild-integration.js +866 -3275
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +68 -13
- package/dist/src/commands/rebuild-operations.js +309 -120
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +99 -0
- package/dist/src/commands/rebuild-platform-integration.js +2329 -0
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +14 -9
- package/dist/src/commands/reconcile-operation-plan.js +26 -6
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -1
- package/dist/src/commands/review-inspection.d.ts +60 -0
- package/dist/src/commands/review-inspection.js +437 -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 +5 -1
- package/dist/src/commands/runtime.js +41 -8
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +8 -0
- package/dist/src/commands/skill-eval.js +126 -73
- package/dist/src/commands/skill-eval.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +148 -35
- package/dist/src/commands/status-v6.js +1166 -307
- package/dist/src/commands/status-v6.js.map +1 -1
- 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 +7 -3
- 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 +7 -1
- package/dist/src/commands/write-commands.js +129 -38
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +2 -3
- package/dist/src/constants.js +2 -3
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +6 -3
- package/dist/src/eval/manifest-v1.js +44 -33
- package/dist/src/eval/manifest-v1.js.map +1 -1
- package/dist/src/generators/local-plugin.d.ts +4 -2
- package/dist/src/generators/local-plugin.js +319 -353
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +20 -2
- package/dist/src/generators/permissions.js +82 -15
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +2 -33
- package/dist/src/index.js +1575 -1919
- 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 +35 -0
- package/dist/src/intent/scope-context.js +179 -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 +6 -2
- package/dist/src/output/command-receipt.js +67 -32
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/component-delivery.d.ts +28 -0
- package/dist/src/output/component-delivery.js +141 -0
- package/dist/src/output/component-delivery.js.map +1 -0
- package/dist/src/output/public-result.d.ts +69 -0
- package/dist/src/output/public-result.js +403 -0
- package/dist/src/output/public-result.js.map +1 -0
- package/dist/src/output/rebuild-progress.d.ts +3 -0
- package/dist/src/output/rebuild-progress.js +34 -9
- 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 +664 -0
- package/dist/src/output/receipt-projection.js.map +1 -0
- package/dist/src/output/skill-invocation-notices.d.ts +18 -0
- package/dist/src/output/skill-invocation-notices.js +84 -0
- package/dist/src/output/skill-invocation-notices.js.map +1 -0
- package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
- package/dist/src/platforms/antigravity-permissions.js +388 -0
- package/dist/src/platforms/antigravity-permissions.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +9 -0
- package/dist/src/platforms/capabilities.js +125 -0
- package/dist/src/platforms/capabilities.js.map +1 -0
- package/dist/src/platforms/contracts.d.ts +394 -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 +100 -0
- package/dist/src/platforms/discovery.js +779 -0
- package/dist/src/platforms/discovery.js.map +1 -0
- package/dist/src/platforms/grok-permission-config.d.ts +23 -0
- package/dist/src/platforms/grok-permission-config.js +184 -0
- package/dist/src/platforms/grok-permission-config.js.map +1 -0
- package/dist/src/platforms/grok-permission-document.d.ts +4 -0
- package/dist/src/platforms/grok-permission-document.js +145 -0
- package/dist/src/platforms/grok-permission-document.js.map +1 -0
- package/dist/src/platforms/grok-permissions.d.ts +17 -0
- package/dist/src/platforms/grok-permissions.js +311 -0
- package/dist/src/platforms/grok-permissions.js.map +1 -0
- package/dist/src/platforms/host-permission-policy.d.ts +38 -0
- package/dist/src/platforms/host-permission-policy.js +86 -0
- package/dist/src/platforms/host-permission-policy.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 +380 -0
- package/dist/src/platforms/inspection-grok.js.map +1 -0
- package/dist/src/platforms/inspection-native.d.ts +8 -0
- package/dist/src/platforms/inspection-native.js +584 -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 +9 -0
- package/dist/src/platforms/inspection-pi.js +490 -0
- package/dist/src/platforms/inspection-pi.js.map +1 -0
- package/dist/src/platforms/inspection-query.d.ts +26 -0
- package/dist/src/platforms/inspection-query.js +118 -0
- package/dist/src/platforms/inspection-query.js.map +1 -0
- package/dist/src/platforms/inspection.d.ts +20 -0
- package/dist/src/platforms/inspection.js +259 -0
- package/dist/src/platforms/inspection.js.map +1 -0
- package/dist/src/platforms/layout.d.ts +35 -0
- package/dist/src/platforms/layout.js +332 -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 +213 -0
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
- package/dist/src/platforms/lifecycle-native.d.ts +14 -0
- package/dist/src/platforms/lifecycle-native.js +234 -0
- package/dist/src/platforms/lifecycle-native.js.map +1 -0
- package/dist/src/platforms/lifecycle.d.ts +29 -0
- package/dist/src/platforms/lifecycle.js +688 -0
- package/dist/src/platforms/lifecycle.js.map +1 -0
- package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
- package/dist/src/platforms/opencode-permission-config.js +253 -0
- package/dist/src/platforms/opencode-permission-config.js.map +1 -0
- package/dist/src/platforms/opencode-permissions.d.ts +39 -0
- package/dist/src/platforms/opencode-permissions.js +212 -0
- package/dist/src/platforms/opencode-permissions.js.map +1 -0
- package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
- package/dist/src/platforms/opencode-related-permissions.js +177 -0
- package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
- package/dist/src/platforms/permission-ownership.d.ts +89 -0
- package/dist/src/platforms/permission-ownership.js +543 -0
- package/dist/src/platforms/permission-ownership.js.map +1 -0
- package/dist/src/platforms/permission-sidecar.d.ts +70 -0
- package/dist/src/platforms/permission-sidecar.js +215 -0
- package/dist/src/platforms/permission-sidecar.js.map +1 -0
- package/dist/src/platforms/projection-code-extension.d.ts +8 -0
- package/dist/src/platforms/projection-code-extension.js +126 -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 +28 -0
- package/dist/src/platforms/projection-files.js +113 -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 +13 -0
- package/dist/src/platforms/projection.js +578 -0
- package/dist/src/platforms/projection.js.map +1 -0
- package/dist/src/platforms/read-only-retry-policy.d.ts +34 -0
- package/dist/src/platforms/read-only-retry-policy.js +70 -0
- package/dist/src/platforms/read-only-retry-policy.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/retirement-native.d.ts +6 -0
- package/dist/src/platforms/retirement-native.js +95 -0
- package/dist/src/platforms/retirement-native.js.map +1 -0
- package/dist/src/platforms/supplement-layout.d.ts +20 -0
- package/dist/src/platforms/supplement-layout.js +54 -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 +93 -0
- package/dist/src/platforms/supplement-state.js.map +1 -0
- package/dist/src/portable/commands.d.ts +60 -11
- package/dist/src/portable/commands.js +88 -346
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/historical-materialization.d.ts +25 -0
- package/dist/src/portable/historical-materialization.js +148 -0
- package/dist/src/portable/historical-materialization.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +46 -2
- package/dist/src/portable/materializer.js +262 -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 +177 -0
- package/dist/src/portable/recovery.js +597 -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 +175 -0
- package/dist/src/recovery/coordinator.js +1624 -0
- package/dist/src/recovery/coordinator.js.map +1 -0
- package/dist/src/recovery/demand.d.ts +53 -0
- package/dist/src/recovery/demand.js +189 -0
- package/dist/src/recovery/demand.js.map +1 -0
- package/dist/src/recovery/install-concurrency.d.ts +48 -0
- package/dist/src/recovery/install-concurrency.js +196 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -0
- package/dist/src/recovery/interruption.d.ts +19 -0
- package/dist/src/recovery/interruption.js +43 -0
- package/dist/src/recovery/interruption.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +46 -0
- package/dist/src/recovery/joint-coordinator.js +1723 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -0
- package/dist/src/recovery/joint-demand.d.ts +72 -0
- package/dist/src/recovery/joint-demand.js +332 -0
- package/dist/src/recovery/joint-demand.js.map +1 -0
- package/dist/src/recovery/joint-install-execution.d.ts +19 -0
- package/dist/src/recovery/joint-install-execution.js +308 -0
- package/dist/src/recovery/joint-install-execution.js.map +1 -0
- package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
- package/dist/src/recovery/joint-install-native-rebase.js +67 -0
- package/dist/src/recovery/joint-install-native-rebase.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 +131 -0
- package/dist/src/recovery/receipt.js +91 -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 +499 -0
- package/dist/src/recovery/retirement.js.map +1 -0
- package/dist/src/recovery/status.d.ts +143 -0
- package/dist/src/recovery/status.js +1528 -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 +44 -0
- package/dist/src/review/eval-source-input.js +213 -0
- package/dist/src/review/eval-source-input.js.map +1 -0
- package/dist/src/review/platform-profile.d.ts +5 -0
- package/dist/src/review/platform-profile.js +13 -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 +286 -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 +502 -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 +67 -0
- package/dist/src/review/skill-materialization.js +235 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +203 -0
- package/dist/src/review/source-binding.js +791 -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-generation.d.ts +9 -0
- package/dist/src/tui/catalog-generation.js +96 -6
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/catalog-sources/projection.d.ts +2 -2
- package/dist/src/tui/catalog-sources/screens.js +19 -12
- package/dist/src/tui/catalog-sources/screens.js.map +1 -1
- package/dist/src/tui/catalog-sources/session.d.ts +11 -1
- package/dist/src/tui/catalog-sources/session.js +80 -5
- package/dist/src/tui/catalog-sources/session.js.map +1 -1
- package/dist/src/tui/catalog-sources/types.d.ts +15 -2
- 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 -34
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +30 -0
- package/dist/src/tui/config-array-draft.js +51 -0
- package/dist/src/tui/config-array-draft.js.map +1 -0
- package/dist/src/tui/config-leaf-editor.d.ts +44 -0
- package/dist/src/tui/config-leaf-editor.js +227 -0
- package/dist/src/tui/config-leaf-editor.js.map +1 -0
- package/dist/src/tui/config-object-suggestions.d.ts +15 -0
- package/dist/src/tui/config-object-suggestions.js +71 -0
- package/dist/src/tui/config-object-suggestions.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-suggestions.d.ts +27 -0
- package/dist/src/tui/config-suggestions.js +62 -0
- package/dist/src/tui/config-suggestions.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +23 -0
- package/dist/src/tui/config-value-presentation.js +151 -0
- package/dist/src/tui/config-value-presentation.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +14 -5
- package/dist/src/tui/console-app-v4.js +9779 -2488
- 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 +4 -3
- package/dist/src/tui/controller-runtime.js +1610 -590
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +583 -80
- package/dist/src/tui/controller.js +3362 -263
- 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 +14 -0
- package/dist/src/tui/deployment-view.js +175 -0
- package/dist/src/tui/deployment-view.js.map +1 -0
- package/dist/src/tui/diagnostic-projection.d.ts +31 -0
- package/dist/src/tui/diagnostic-projection.js +681 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +6 -2
- 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 +56 -0
- package/dist/src/tui/entity-cards.js +327 -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 +78 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/guided-setup.d.ts +25 -0
- package/dist/src/tui/guided-setup.js +101 -0
- package/dist/src/tui/guided-setup.js.map +1 -0
- package/dist/src/tui/index.d.ts +4 -1
- package/dist/src/tui/index.js +4 -1
- 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 +141 -28
- package/dist/src/tui/model.js +968 -285
- 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 +76 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +91 -0
- package/dist/src/tui/operation-history.js +167 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +7 -0
- package/dist/src/tui/operation-review-planner.js +980 -146
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- 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 +75 -0
- package/dist/src/tui/plugin-detail.js +267 -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/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 +170 -39
- 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 +49 -0
- package/dist/src/tui/scoped-flow.js +212 -0
- package/dist/src/tui/scoped-flow.js.map +1 -0
- package/dist/src/tui/scoped-inventory.d.ts +139 -0
- package/dist/src/tui/scoped-inventory.js +295 -0
- package/dist/src/tui/scoped-inventory.js.map +1 -0
- package/dist/src/tui/screen-registry.d.ts +696 -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 +8 -0
- package/dist/src/tui/session-console-app.js +24 -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 +26 -4
- package/dist/src/tui/wizard.js.map +1 -1
- package/dist/src/types.d.ts +105 -83
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +10 -4
- package/dist/src/utils/agent-version.js +6 -8
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +18 -25
- package/dist/src/utils/artifact-plan.js +59 -445
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +64 -90
- package/dist/src/utils/artifact-renderer.js +202 -303
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +19 -14
- package/dist/src/utils/artifact-request.js +51 -36
- package/dist/src/utils/artifact-request.js.map +1 -1
- package/dist/src/utils/artifact-sources.d.ts +4 -8
- package/dist/src/utils/artifact-sources.js +15 -6
- package/dist/src/utils/artifact-sources.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.js +2 -1
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/bundle-layout.d.ts +2 -0
- package/dist/src/utils/bundle-layout.js +88 -158
- 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 -12
- package/dist/src/utils/catalog-digests.js +7 -55
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +28 -4
- package/dist/src/utils/catalog-generation-resolver.js +146 -40
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +24 -2
- package/dist/src/utils/catalog-generation-service.js +92 -48
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.js +1 -1
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +4 -0
- package/dist/src/utils/catalog-generation-store.js +68 -10
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.d.ts +61 -4
- package/dist/src/utils/catalog-operation-context.js +225 -4
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-public-error.js +4 -0
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +4 -3
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +3 -0
- package/dist/src/utils/catalog-snapshot.js +4 -1
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +3 -2
- package/dist/src/utils/catalog-source-impact.js +142 -20
- package/dist/src/utils/catalog-source-impact.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +57 -1
- package/dist/src/utils/catalog-source-references.js +755 -162
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +1 -1
- package/dist/src/utils/catalog-sources.js +21 -5
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/codex-config.d.ts +3 -0
- package/dist/src/utils/codex-config.js +7 -0
- 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 +23 -42
- package/dist/src/utils/codex-manager.js +79 -767
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +40 -1
- package/dist/src/utils/codex-native-observation.js +172 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/codex-reconciler.d.ts +2 -7
- package/dist/src/utils/codex-reconciler.js +33 -5
- package/dist/src/utils/codex-reconciler.js.map +1 -1
- package/dist/src/utils/codex-shared-native.d.ts +8 -26
- package/dist/src/utils/codex-shared-native.js +63 -83
- package/dist/src/utils/codex-shared-native.js.map +1 -1
- package/dist/src/utils/codex-skill-staging.d.ts +4 -3
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-skills-root.d.ts +4 -0
- package/dist/src/utils/codex-skills-root.js +29 -0
- package/dist/src/utils/codex-skills-root.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +6 -2
- package/dist/src/utils/codex-surface-analysis.js +31 -56
- package/dist/src/utils/codex-surface-analysis.js.map +1 -1
- package/dist/src/utils/component-agent-binding.d.ts +17 -0
- package/dist/src/utils/component-agent-binding.js +119 -0
- package/dist/src/utils/component-agent-binding.js.map +1 -0
- package/dist/src/utils/component-command-preparation.d.ts +33 -0
- package/dist/src/utils/component-command-preparation.js +129 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -0
- package/dist/src/utils/component-gap.d.ts +4 -0
- package/dist/src/utils/component-gap.js +16 -0
- package/dist/src/utils/component-gap.js.map +1 -0
- package/dist/src/utils/component-resources.d.ts +53 -0
- package/dist/src/utils/component-resources.js +340 -0
- package/dist/src/utils/component-resources.js.map +1 -0
- package/dist/src/utils/config-platforms.d.ts +21 -0
- package/dist/src/utils/config-platforms.js +51 -0
- package/dist/src/utils/config-platforms.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
- package/dist/src/utils/dynamic-skill-tree.js +33 -40
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +3 -0
- package/dist/src/utils/git-catalog-provider.js +49 -3
- 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 +19 -12
- package/dist/src/utils/local-marketplace.js +97 -194
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-cli-review.d.ts +53 -0
- package/dist/src/utils/managed-command-cli-review.js +431 -0
- package/dist/src/utils/managed-command-cli-review.js.map +1 -0
- package/dist/src/utils/managed-command-closure.d.ts +14 -0
- package/dist/src/utils/managed-command-closure.js +156 -0
- package/dist/src/utils/managed-command-closure.js.map +1 -0
- package/dist/src/utils/managed-command-errors.d.ts +5 -0
- package/dist/src/utils/managed-command-errors.js +10 -0
- package/dist/src/utils/managed-command-errors.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +90 -0
- package/dist/src/utils/managed-command-materialization.js +375 -0
- package/dist/src/utils/managed-command-materialization.js.map +1 -0
- package/dist/src/utils/managed-command-preparation.d.ts +30 -0
- package/dist/src/utils/managed-command-preparation.js +39 -0
- package/dist/src/utils/managed-command-preparation.js.map +1 -0
- package/dist/src/utils/managed-command-review.d.ts +33 -0
- package/dist/src/utils/managed-command-review.js +80 -0
- package/dist/src/utils/managed-command-review.js.map +1 -0
- package/dist/src/utils/managed-command-runtime.d.ts +36 -0
- package/dist/src/utils/managed-command-runtime.js +126 -0
- package/dist/src/utils/managed-command-runtime.js.map +1 -0
- package/dist/src/utils/managed-command-snapshots.d.ts +24 -0
- package/dist/src/utils/managed-command-snapshots.js +89 -0
- package/dist/src/utils/managed-command-snapshots.js.map +1 -0
- package/dist/src/utils/managed-command-store.d.ts +141 -0
- package/dist/src/utils/managed-command-store.js +839 -0
- package/dist/src/utils/managed-command-store.js.map +1 -0
- package/dist/src/utils/multi-source-catalog.d.ts +6 -1
- package/dist/src/utils/multi-source-catalog.js +9 -4
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli-interruption.d.ts +8 -0
- package/dist/src/utils/native-cli-interruption.js +65 -0
- package/dist/src/utils/native-cli-interruption.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +37 -6
- package/dist/src/utils/native-cli.js +523 -60
- 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 +17 -0
- package/dist/src/utils/native-tool-context.js +40 -0
- package/dist/src/utils/native-tool-context.js.map +1 -0
- package/dist/src/utils/native-tool-review.d.ts +8 -0
- package/dist/src/utils/native-tool-review.js +14 -0
- package/dist/src/utils/native-tool-review.js.map +1 -0
- package/dist/src/utils/ownership.d.ts +38 -3
- package/dist/src/utils/ownership.js +118 -11
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/package-content.d.ts +7 -0
- package/dist/src/utils/package-content.js +70 -0
- package/dist/src/utils/package-content.js.map +1 -0
- package/dist/src/utils/path-catalog-provider.js +2 -0
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -1
- package/dist/src/utils/paths.js +5 -2
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +69 -0
- package/dist/src/utils/platform-empty-state.js +249 -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-command-apply.d.ts +33 -0
- package/dist/src/utils/plugin-config-command-apply.js +142 -0
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
- package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
- package/dist/src/utils/plugin-config-diagnostics.js +44 -0
- package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
- package/dist/src/utils/plugin-config-impact.d.ts +76 -0
- package/dist/src/utils/plugin-config-impact.js +359 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-references.d.ts +116 -0
- package/dist/src/utils/plugin-config-references.js +379 -0
- package/dist/src/utils/plugin-config-references.js.map +1 -0
- package/dist/src/utils/plugin-config-suggestion-runner.d.ts +83 -0
- package/dist/src/utils/plugin-config-suggestion-runner.js +308 -0
- package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -0
- package/dist/src/utils/plugin-config-suggestions.d.ts +50 -0
- package/dist/src/utils/plugin-config-suggestions.js +322 -0
- package/dist/src/utils/plugin-config-suggestions.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +108 -19
- package/dist/src/utils/plugin-config-write.js +781 -568
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +122 -43
- package/dist/src/utils/plugin-config.js +574 -610
- 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 +41 -17
- package/dist/src/utils/plugin-scripts.js +586 -123
- 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 -1
- package/dist/src/utils/project-boundary.js +33 -11
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/rendered-contract.js +24 -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 +50 -7
- package/dist/src/utils/runtime-skill-closure.js.map +1 -1
- 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/skill-invocation-warning.d.ts +19 -0
- package/dist/src/utils/skill-invocation-warning.js +43 -0
- package/dist/src/utils/skill-invocation-warning.js.map +1 -0
- package/dist/src/utils/skill-validation.js +0 -5
- package/dist/src/utils/skill-validation.js.map +1 -1
- 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 +2 -2
- 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 +109 -9
- package/dist/vitest.config.js.map +1 -1
- package/package.json +20 -12
- package/dist/authoring/templates/aw-config-runtime.d.mts +0 -2
- package/dist/authoring/templates/aw-config-runtime.mjs +0 -407
- package/dist/authoring/templates/aw-config-runtime.mjs.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/sync-command.d.ts +0 -23
- package/dist/src/commands/sync-command.js +0 -242
- package/dist/src/commands/sync-command.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/codex-native-render-receipt.d.ts +0 -40
- package/dist/src/utils/codex-native-render-receipt.js +0 -205
- package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
- package/dist/src/utils/plugin-intent-state.d.ts +0 -34
- package/dist/src/utils/plugin-intent-state.js +0 -289
- package/dist/src/utils/plugin-intent-state.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,33 +1,76 @@
|
|
|
1
|
+
import { readAgentSettings, previewAgentSettings, saveAgentSettings } from './agent-settings.js';
|
|
2
|
+
import { observePreferences } from '../intent/deployment-preferences.js';
|
|
3
|
+
import { resolveConfigurableLayers, classifyResidualConfigLayers } from '../utils/config-platforms.js';
|
|
4
|
+
import { configObjectHasSensitiveChild } from './config-value-presentation.js';
|
|
5
|
+
import { selectPluginConfigProfile, getPluginConfigReferenceChoices, PLATFORM_TARGETS, NATIVE_PLATFORM_TARGETS, resolveSupportedPlatforms } from '@lesliechan721/aw-plugin-core';
|
|
6
|
+
import { configReferenceKey, configReferenceScalars } from './config-references.js';
|
|
7
|
+
import { preparePluginConfigSuggestions } from '../utils/plugin-config-suggestions.js';
|
|
1
8
|
import crypto from 'node:crypto';
|
|
2
9
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
10
|
+
import { managedCommandRecoveryPlanChanges } from './operation-review-planner.js';
|
|
11
|
+
import { recoveryHostPermissionEffects } from '../commands/deployment-confirmation.js';
|
|
12
|
+
import { isPermissionHost } from '../platforms/host-permission-policy.js';
|
|
13
|
+
import { resolveWorkContext } from '../intent/work-context.js';
|
|
14
|
+
import { flattenStatusTargets, statusTargetHasLiveConfigConsumer, } from '../commands/status-v6.js';
|
|
4
15
|
import { addCatalogSourceCommand, listCatalogSources, preflightCatalogSourceMutation, removeCatalogSourceCommand, setPrimaryCatalogSourceCommand, updateCatalogSourceCommand, } from '../commands/catalog-source.js';
|
|
5
|
-
import {
|
|
16
|
+
import { parseScriptTimeoutMs, SCRIPT_TIMEOUT_DEFAULT_MS, } from '../commands/options.js';
|
|
6
17
|
import { readCliPackageInfo } from '../utils/local-marketplace.js';
|
|
7
18
|
import { readCatalogSourcesConfigSnapshot, recoverInvalidCatalogSourcesConfig, } from '../utils/catalog-sources.js';
|
|
8
19
|
import { withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, formatPluginId, parsePluginId, } from '../utils/multi-source-catalog.js';
|
|
9
|
-
import { coercePluginConfigUpdates, inspectPluginConfigResetTarget, readPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, } from '../utils/plugin-config.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
20
|
+
import { coercePluginConfigUpdates, inspectPluginConfigResetTarget, listNamespacedPluginConfigStoreIdentities, readPluginConfigStore, replacePluginConfigStoreLayer, resolveConfigRead, resolveEffectivePluginConfig, resolveEffectivePluginConfigFromStores, resolvePluginConfigReferenceContext, } from '../utils/plugin-config.js';
|
|
21
|
+
import { readRecoveryStatus } from '../recovery/status.js';
|
|
22
|
+
import { readJointDemand } from '../recovery/joint-demand.js';
|
|
23
|
+
import { RecoveryInterruptedError } from '../recovery/interruption.js';
|
|
24
|
+
import { catalogSourceErrorCode, sanitizeCatalogSourceError } from '../utils/catalog-public-error.js';
|
|
25
|
+
import { activateRecoverySourcesAndReprepare, prepareRecovery, executeRecovery, } from '../recovery/coordinator.js';
|
|
26
|
+
import { prepareRetire, executeRetire } from '../recovery/retirement.js';
|
|
27
|
+
import { prepareTargetsPlan, executeTargetsPlan, prepareIntentPlan, executeIntentPlan } from './scoped-flow.js';
|
|
28
|
+
import { applyPluginConfigWrite, applyPluginConfig, ConfigApplyInterruptedError, preparePluginConfigApply, disposePluginConfigApply, resolveConfigPreApplyAuthorization, resetPluginConfigWithHelper, } from '../utils/plugin-config-write.js';
|
|
29
|
+
import { analyzePluginConfigMutationImpact, discoverPluginConfigManagedCommandPackages, pluginConfigTargetRenderScopes, pluginSharedNativeConfigRenderUnits } from '../utils/plugin-config-impact.js';
|
|
30
|
+
import { describeConfigCommandPackageReviews } from '../utils/plugin-config-command-apply.js';
|
|
31
|
+
import { collectPluginConfigReferenceEvidence, pluginConfigHasExternalReferences, resolvePluginConfigReferenceConsumers, resolvePluginConfigReferencePlugins } from '../utils/plugin-config-references.js';
|
|
12
32
|
import { inventoryCatalogSourceReferences } from '../utils/catalog-source-references.js';
|
|
13
|
-
import { operationEvidenceMatches, operationEvidenceFingerprint, TuiConfigInvalidStoreError, TuiController, TuiOperationBlockedError, } from './controller.js';
|
|
14
|
-
import {
|
|
33
|
+
import { operationEvidenceMatches, operationEvidenceFingerprint, configApplyHasCompletedWork, configSaveFailureDetail, TuiConfigInvalidStoreError, TuiController, TuiOperationBlockedError, } from './controller.js';
|
|
34
|
+
import { buildConfigPage, } from './model.js';
|
|
15
35
|
import { projectCatalogSourceLocation } from '../utils/catalog-source-presentation.js';
|
|
16
36
|
import { calculateCatalogSourceConfigFingerprint, calculateCatalogSourceIdentity, } from '../utils/catalog-source-identity.js';
|
|
17
37
|
import { checkAwCapabilitySupport, readPluginManifest } from '../utils/manifest.js';
|
|
18
38
|
import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
19
39
|
import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
|
|
20
|
-
import { calculateCatalogGenerationSetDigest, resolveActiveCatalogGeneration, } from '../utils/catalog-generation-resolver.js';
|
|
21
|
-
import { resolveCatalogOperationContext, resolvePartialCatalogOperationContext, selectCatalogOperationContext, } from '../utils/catalog-operation-context.js';
|
|
40
|
+
import { calculateCatalogGenerationSetDigest, createCatalogPreparationStoreKey, resolveActiveCatalogGeneration, } from '../utils/catalog-generation-resolver.js';
|
|
41
|
+
import { CatalogPreparationReadScope, resolveCatalogOperationContext, resolvePartialCatalogOperationContext, selectCatalogOperationContext, } from '../utils/catalog-operation-context.js';
|
|
22
42
|
import { createCatalogStoreKey, readCatalogStoreEntry, } from '../utils/catalog-generation-store.js';
|
|
23
|
-
import { activateCatalogSourceGeneration, compareCatalogGenerationFreshness, probeCatalogSourceFreshness, probeCatalogSourceGeneration, probeCatalogSourceRepairGeneration, recoverCatalogGenerationStateAndActivate, repairCatalogSourceGeneration, replaceDamagedCatalogSourceGeneration,
|
|
43
|
+
import { activateCatalogSourceGeneration, compareCatalogGenerationFreshness, probeCatalogSourceFreshness, probeCatalogSourceGeneration, probeCatalogSourceRepairGeneration, recoverCatalogGenerationStateAndActivate, repairCatalogSourceGeneration, replaceDamagedCatalogSourceGeneration, } from '../utils/catalog-generation-service.js';
|
|
24
44
|
import { calculateCatalogSourceImpactDigest, inspectCatalogSourceImpact, } from '../utils/catalog-source-impact.js';
|
|
25
45
|
import { readCatalogGenerationState } from '../utils/catalog-generation-state.js';
|
|
26
46
|
import { CatalogGenerationError } from '../utils/catalog-generation-error.js';
|
|
27
47
|
import { CatalogProviderCompatibilityError } from '../utils/catalog-public-error.js';
|
|
28
|
-
import { loadCatalogGenerationViewModels } from './catalog-generation.js';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
48
|
+
import { checkRetirementSources, loadCatalogGenerationViewModels } from './catalog-generation.js';
|
|
49
|
+
import { inventoryPluginIds } from './scoped-inventory.js';
|
|
50
|
+
import { recoveryReason } from './glossary.js';
|
|
51
|
+
import { executePortableRetry, installPortableSkills, preparePortableInstall, preparePortableRetry, PortableCommandError, recheckPortableInstall, } from '../portable/commands.js';
|
|
52
|
+
import { projectPluginContentOverview, } from './plugin-content.js';
|
|
53
|
+
import { executeCatalogStoreTask, inspectCatalogStoreTask, prepareCatalogStoreTask, } from './catalog-store-task.js';
|
|
54
|
+
function installSourceBinding(catalog, sourceId) {
|
|
55
|
+
const generation = catalog?.generationSet.sources.find((source) => source.sourceId === sourceId);
|
|
56
|
+
const resolution = catalog?.catalog.sources.find((source) => source.sourceId === sourceId)?.resolution;
|
|
57
|
+
return generation && resolution && createCatalogPreparationStoreKey({ ...generation, requestedRef: resolution.requestedRef });
|
|
58
|
+
}
|
|
59
|
+
function homeGenerationsMatch(catalog, generations, configured) {
|
|
60
|
+
if (generations.length !== catalog.catalog.sources.length)
|
|
61
|
+
return false;
|
|
62
|
+
return generations.every((view) => {
|
|
63
|
+
const bound = catalog.generationSet.sources.find((source) => source.sourceId === view.sourceId);
|
|
64
|
+
const source = catalog.catalog.sources.find((item) => item.sourceId === view.sourceId);
|
|
65
|
+
if (!bound)
|
|
66
|
+
return source?.error !== undefined && catalogSourceErrorCode(source.error)
|
|
67
|
+
=== (view.configMismatch ? 'catalogGenerationIdentityMismatch' : view.errorCode);
|
|
68
|
+
const config = configured.sources.find((item) => item.id === view.sourceId);
|
|
69
|
+
return view.state === 'ready' && view.active?.storeKey === bound.storeKey
|
|
70
|
+
&& view.active.resolvedCommit === bound.resolvedCommit && view.active.requestedRef === source?.resolution?.requestedRef
|
|
71
|
+
&& config?.sourceIdentity === bound.sourceIdentity && calculateCatalogSourceConfigFingerprint(config) === bound.sourceConfigFingerprint;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
31
74
|
function reusableCandidateEvidenceIsComplete(candidate) {
|
|
32
75
|
const evidence = candidate.probe.candidate;
|
|
33
76
|
return [
|
|
@@ -56,12 +99,12 @@ async function loadPortablePluginIds(options) {
|
|
|
56
99
|
? item.resolution.manifest.entries.flatMap((entry) => {
|
|
57
100
|
const support = checkAwCapabilitySupport(entry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
|
|
58
101
|
return support.supported
|
|
59
|
-
? [readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' }).then((plugin) => plugin.manifest.
|
|
102
|
+
? [readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' }).then((plugin) => resolveSupportedPlatforms(plugin.manifest).has('generic')
|
|
60
103
|
? formatPluginId({
|
|
61
104
|
sourceId: item.resolution.sourceId,
|
|
62
105
|
pluginName: entry.name,
|
|
63
106
|
})
|
|
64
|
-
: null)]
|
|
107
|
+
: null).catch(() => { options.signal.throwIfAborted(); return null; })]
|
|
65
108
|
: [];
|
|
66
109
|
})
|
|
67
110
|
: []))).filter((pluginId) => pluginId !== null),
|
|
@@ -74,6 +117,10 @@ export function setTuiControllerRuntimeTestHooksForTests(hooks) {
|
|
|
74
117
|
function digest(value) {
|
|
75
118
|
return `sha256:${crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex')}`;
|
|
76
119
|
}
|
|
120
|
+
function configSchemaIdentity(plugin, manifestDigest, platform) {
|
|
121
|
+
return digest({ manifestDigest, profile: platform ?? 'common',
|
|
122
|
+
definition: selectPluginConfigProfile(plugin.manifest.config, platform) });
|
|
123
|
+
}
|
|
77
124
|
export function statusTargetFingerprint(targets, revisions = []) {
|
|
78
125
|
return digest({
|
|
79
126
|
targets: targets.map((target) => ({
|
|
@@ -83,8 +130,13 @@ export function statusTargetFingerprint(targets, revisions = []) {
|
|
|
83
130
|
scope: target.scope,
|
|
84
131
|
state: target.state,
|
|
85
132
|
errors: target.reasons.map((error) => error.code).sort(),
|
|
133
|
+
sharedReasons: [...(target.sharedReasons ?? [])]
|
|
134
|
+
.sort((left, right) => `${left.code}\0${left.message}`.localeCompare(`${right.code}\0${right.message}`, 'en')),
|
|
86
135
|
components: target.components.map((component) => [component.key, component.state])
|
|
87
136
|
.sort(([left], [right]) => left.localeCompare(right, 'en')),
|
|
137
|
+
sharedComponents: (target.sharedComponents ?? [])
|
|
138
|
+
.map((component) => [component.key, component.state, component.metadata])
|
|
139
|
+
.sort(([left], [right]) => left.localeCompare(right, 'en')),
|
|
88
140
|
})).sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
89
141
|
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en')),
|
|
90
142
|
revisions: revisions.map((entry) => ({
|
|
@@ -96,40 +148,217 @@ export function statusTargetFingerprint(targets, revisions = []) {
|
|
|
96
148
|
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en')),
|
|
97
149
|
});
|
|
98
150
|
}
|
|
99
|
-
export function configAffectedStatusTargets(targets, pluginId,
|
|
151
|
+
export function configAffectedStatusTargets(targets, pluginId, configContext, consumerPluginIds = [], platform) {
|
|
100
152
|
const affected = new Map();
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (target.pluginId
|
|
153
|
+
const selected = new Set([pluginId, ...consumerPluginIds]);
|
|
154
|
+
for (const target of flattenStatusTargets(targets)) {
|
|
155
|
+
if (!selected.has(target.pluginId) || !statusTargetHasLiveConfigConsumer(target))
|
|
104
156
|
continue;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
157
|
+
if (configContext === 'user' && target.scope !== 'user')
|
|
158
|
+
continue;
|
|
159
|
+
if (platform && target.platform !== platform)
|
|
160
|
+
continue;
|
|
161
|
+
affected.set(`${target.pluginId}\0${target.platform}\0${target.scope}`, target);
|
|
110
162
|
}
|
|
111
163
|
return [...affected.values()]
|
|
112
|
-
.sort((left, right) => `${left.platform}\0${left.scope}`
|
|
113
|
-
.localeCompare(`${right.platform}\0${right.scope}`, 'en'));
|
|
164
|
+
.sort((left, right) => `${left.pluginId}\0${left.platform}\0${left.scope}`
|
|
165
|
+
.localeCompare(`${right.pluginId}\0${right.platform}\0${right.scope}`, 'en'));
|
|
166
|
+
}
|
|
167
|
+
function currentConfigTargets(status, pluginId, configContext, consumers = [], platform) {
|
|
168
|
+
const selected = new Set([pluginId, ...consumers]);
|
|
169
|
+
const observations = [...(status.observedTargets ?? []), ...(status.inventory ?? []).flatMap((root) => root.targetResults)];
|
|
170
|
+
return [...new Map((status.existingTargets ?? []).flatMap((target) => {
|
|
171
|
+
if (target.agent === 'generic' || !selected.has(target.pluginId)
|
|
172
|
+
|| configContext === 'user' && target.scope !== 'user'
|
|
173
|
+
|| platform && target.agent !== platform)
|
|
174
|
+
return [];
|
|
175
|
+
return [{ pluginId: target.pluginId, pluginName: parsePluginId(target.pluginId).pluginName,
|
|
176
|
+
platform: target.agent, scope: target.scope,
|
|
177
|
+
observation: observations.find((item) => item.pluginId === target.pluginId
|
|
178
|
+
&& item.agent === target.agent && item.scope === target.scope) }];
|
|
179
|
+
}).map((target) => [`${target.pluginId}\0${target.platform}\0${target.scope}`, target])).values()]
|
|
180
|
+
.sort((left, right) => `${left.pluginId}\0${left.platform}\0${left.scope}`.localeCompare(`${right.pluginId}\0${right.platform}\0${right.scope}`, 'en'));
|
|
181
|
+
}
|
|
182
|
+
function currentTargetFingerprint(status, targets) {
|
|
183
|
+
return digest({ intent: status.intent, selection: status.selection, targets: targets.map((target) => ({
|
|
184
|
+
pluginId: target.pluginId, platform: target.platform, scope: target.scope,
|
|
185
|
+
observation: target.observation ? { observation: target.observation.observation,
|
|
186
|
+
content: target.observation.content, blockers: target.observation.blockers,
|
|
187
|
+
expectedVersion: target.observation.expectedVersion, installedVersion: target.observation.installedVersion,
|
|
188
|
+
deployments: target.observation.deploymentObservations,
|
|
189
|
+
exclusions: target.observation.deploymentExclusions,
|
|
190
|
+
gaps: target.observation.componentGaps } : null,
|
|
191
|
+
})) });
|
|
192
|
+
}
|
|
193
|
+
function scopedCurrentStatus(status, snapshot, scope) {
|
|
194
|
+
const demand = scope === 'project' ? snapshot.project : snapshot.user;
|
|
195
|
+
const inventory = demand.roots === null ? null : demand.roots.map((root) => ({
|
|
196
|
+
pluginId: root.pluginId, source: root.sourceId, sourceState: root.sourceState,
|
|
197
|
+
blockers: root.blockers.map((code) => ({ code, message: `来源需要处理:${code}。` })),
|
|
198
|
+
targetResults: (status.inventory ?? []).filter((entry) => entry.pluginId === root.pluginId)
|
|
199
|
+
.flatMap((entry) => entry.targetResults.filter((target) => target.scope === scope)),
|
|
200
|
+
}));
|
|
201
|
+
const targets = inventory?.flatMap((root) => root.targetResults) ?? [];
|
|
202
|
+
const counts = { blocked: targets.filter((target) => target.blockers.length > 0).length,
|
|
203
|
+
pending: targets.filter((target) => target.satisfaction !== 'not-applicable' && ['absent', 'drifted'].includes(target.content ?? '')).length,
|
|
204
|
+
unconfirmed: targets.filter((target) => target.content === 'unknown').length,
|
|
205
|
+
ready: targets.filter((target) => target.content === 'satisfied').length };
|
|
206
|
+
return { ...status, scope, intent: { state: demand.intent.state,
|
|
207
|
+
...('digest' in demand.intent ? { digest: demand.intent.digest } : {}) }, inventory, counts,
|
|
208
|
+
extraObserved: status.extraObserved.filter((target) => target.scope === scope),
|
|
209
|
+
allSatisfied: counts.blocked || counts.pending ? false : counts.unconfirmed || inventory === null
|
|
210
|
+
|| !['valid', 'absent'].includes(demand.intent.state) ? null : true };
|
|
211
|
+
}
|
|
212
|
+
/** Source metadata only. Actual installation facts are supplied by RecoveryStatus. */
|
|
213
|
+
async function loadCatalogView(options) {
|
|
214
|
+
return withResolvedMultiSourceCatalog({ cliVersion: options.cliVersion, env: options.context.env,
|
|
215
|
+
signal: options.signal, operationContext: options.catalogOperationContext,
|
|
216
|
+
consume: async (catalog) => ({
|
|
217
|
+
payload: { schemaVersion: 8, catalog: { primarySourceId: catalog.primarySourceId,
|
|
218
|
+
configDigest: catalog.configDigest, compositeDigest: catalog.compositeDigest,
|
|
219
|
+
...(options.catalogOperationContext ? { generationSetDigest: options.catalogOperationContext.generationSetDigest } : {}),
|
|
220
|
+
sources: catalog.sources.map((item) => ({ id: item.sourceId,
|
|
221
|
+
identity: item.resolution?.sourceIdentity ?? '', type: item.resolution?.transport ?? 'path',
|
|
222
|
+
primary: item.sourceId === catalog.primarySourceId,
|
|
223
|
+
requestedRef: item.resolution?.requestedRef ?? 'AW channel',
|
|
224
|
+
...(item.resolution ? { resolvedCommit: item.resolution.resolvedCommit,
|
|
225
|
+
catalogVersion: item.resolution.manifest.catalogVersion, channel: item.resolution.manifest.channel,
|
|
226
|
+
freshness: 'active' } : {}),
|
|
227
|
+
...(item.error ? { error: sanitizeCatalogSourceError(item.error).message, errorCode: catalogSourceErrorCode(item.error) } : {}), })) }, filters: { plugins: [], platform: 'both', cwd: options.context.cwd }, targets: [], errors: [] },
|
|
228
|
+
pluginSummaries: (await Promise.all(catalog.sources.flatMap((item) => item.resolution
|
|
229
|
+
? item.resolution.manifest.entries.map(async (entry) => {
|
|
230
|
+
const support = checkAwCapabilitySupport(entry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
|
|
231
|
+
const metadata = { pluginName: entry.name,
|
|
232
|
+
pluginId: formatPluginId({ sourceId: item.sourceId, pluginName: entry.name }),
|
|
233
|
+
displayName: entry.interface?.displayName ?? entry.name, description: entry.description, version: entry.version };
|
|
234
|
+
// Future definitions may use a schema this CLI cannot parse. The source
|
|
235
|
+
// index is the boundary for deciding whether that definition can be read.
|
|
236
|
+
if (!support.supported)
|
|
237
|
+
return { ...metadata, missingCapabilities: support.missing };
|
|
238
|
+
try {
|
|
239
|
+
const manifest = await readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' });
|
|
240
|
+
options.signal.throwIfAborted();
|
|
241
|
+
const platforms = [...resolveSupportedPlatforms(manifest.manifest)];
|
|
242
|
+
return { ...metadata, platforms, supportedTargets: Object.fromEntries(platforms.filter((platform) => platform !== 'generic')
|
|
243
|
+
.map((platform) => [platform, ['user', 'project']])),
|
|
244
|
+
configFieldCount: new Set(manifest.manifest.config ? [undefined, ...PLATFORM_TARGETS]
|
|
245
|
+
.flatMap((platform) => Object.keys(selectPluginConfigProfile(manifest.manifest.config, platform).fields)) : []).size,
|
|
246
|
+
...(manifest.manifest.config ? { configSchema: manifest.manifest.config.fields } : {}) };
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
options.signal.throwIfAborted();
|
|
250
|
+
return { ...metadata, definitionUnavailable: true };
|
|
251
|
+
}
|
|
252
|
+
}) : []))),
|
|
253
|
+
}),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function configNeedsReferencePlugins(plugin) {
|
|
257
|
+
return pluginConfigHasExternalReferences(plugin.manifest)
|
|
258
|
+
|| (plugin.manifest.config !== undefined && [undefined, ...PLATFORM_TARGETS].some((platform) => Object.values(selectPluginConfigProfile(plugin.manifest.config, platform).fields)
|
|
259
|
+
.some((field) => field.type === 'array' && field.items.type === 'object')));
|
|
260
|
+
}
|
|
261
|
+
async function configRetrySharedNativeRenderUnits(plugin, targets, env, referencePlugins) {
|
|
262
|
+
const plugins = await resolvePluginConfigReferenceConsumers({ plugin, env, plugins: referencePlugins });
|
|
263
|
+
return plugins.flatMap((consumer) => pluginSharedNativeConfigRenderUnits(consumer).filter((shared) => targets.some((target) => (target.pluginName ?? plugin.manifest.name) === consumer.manifest.name
|
|
264
|
+
&& target.platform === shared.platform)));
|
|
265
|
+
}
|
|
266
|
+
function configPackageReviewChanges(plan, reviews) {
|
|
267
|
+
return [
|
|
268
|
+
...describeConfigCommandPackageReviews(reviews).map((description) => ({
|
|
269
|
+
kind: 'change', group: 'configImpact', title: '命令包影响', description,
|
|
270
|
+
})),
|
|
271
|
+
...managedCommandRecoveryPlanChanges(plan).map((change) => ({ ...change, group: 'configImpact' })),
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
async function reviewConfigMutationApply(options, reviewed, fresh) {
|
|
275
|
+
const mayChangeHostPermissions = options.applyTargets?.some(({ platform }) => isPermissionHost(platform) || platform === 'claude');
|
|
276
|
+
// The writer revalidates the frozen command package candidate before saving.
|
|
277
|
+
if (fresh && !mayChangeHostPermissions)
|
|
278
|
+
return {
|
|
279
|
+
commandPackageEvidence: reviewed?.commandPackageEvidence,
|
|
280
|
+
commandReviewChanges: reviewed?.commandReviewChanges,
|
|
281
|
+
};
|
|
282
|
+
if (!options.applyCommandPackages?.length && !mayChangeHostPermissions)
|
|
283
|
+
return { commandPackageEvidence: [] };
|
|
284
|
+
const prepared = await preparePluginConfigApply(options);
|
|
285
|
+
try {
|
|
286
|
+
const hostPermissionEffects = recoveryHostPermissionEffects(prepared.plan);
|
|
287
|
+
return { commandPackageEvidence: prepared.commandPackageEvidence,
|
|
288
|
+
commandReviewChanges: configPackageReviewChanges(prepared.plan, prepared.commandPackageReviews),
|
|
289
|
+
...(hostPermissionEffects.length ? { hostPermissionEffects } : {}) };
|
|
290
|
+
}
|
|
291
|
+
finally {
|
|
292
|
+
await disposePluginConfigApply(prepared.plan);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async function configRetryStoreDigest(options) {
|
|
296
|
+
const plugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
297
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
298
|
+
env: options.env, plugins: options.plugins });
|
|
299
|
+
const byName = new Map([...plugins, options.plugin].map((plugin) => [plugin.manifest.name, plugin]));
|
|
300
|
+
const profiles = [{ pluginName: options.plugin.manifest.name, scope: options.scope, platform: options.platform },
|
|
301
|
+
...options.targets.flatMap((target) => {
|
|
302
|
+
const plugin = byName.get(target.pluginName);
|
|
303
|
+
if (!plugin)
|
|
304
|
+
throw operationReviewStale('重试目标的插件定义已变化。');
|
|
305
|
+
return pluginConfigTargetRenderScopes(plugin, target).map((scope) => ({ pluginName: target.pluginName, scope, platform: target.platform }));
|
|
306
|
+
}),
|
|
307
|
+
...options.commandPackages.flatMap(({ producer, runtimeConfigPlatforms }) => [undefined, ...runtimeConfigPlatforms]
|
|
308
|
+
.map((platform) => ({ pluginName: producer.pluginName, scope: 'user', platform }))),
|
|
309
|
+
...options.preApplyAuthorization.map(({ pluginName, scope }) => ({ pluginName, scope, platform: options.platform }))];
|
|
310
|
+
return digest(await collectPluginConfigReferenceEvidence({ ...options, profiles, plugins }));
|
|
114
311
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
&& target.refreshKeys.some((key) => changed.has(key))
|
|
122
|
-
? [{ id: target.id, skillKey: target.skillKey, refreshKeys: [...target.refreshKeys] }]
|
|
123
|
-
: []);
|
|
312
|
+
function configImpactVisibleTargets(pluginName, targets) {
|
|
313
|
+
return targets.map((target) => ({
|
|
314
|
+
pluginName: target.pluginName ?? pluginName,
|
|
315
|
+
platform: target.platform,
|
|
316
|
+
scope: target.scope,
|
|
317
|
+
}));
|
|
124
318
|
}
|
|
125
|
-
function
|
|
126
|
-
|
|
319
|
+
function configIntentRequestsApply(intent) {
|
|
320
|
+
if (!intent.apply)
|
|
321
|
+
return false;
|
|
322
|
+
if (intent.retryApply === true)
|
|
323
|
+
return true;
|
|
324
|
+
if (intent.changes)
|
|
325
|
+
return intent.changes.length > 0;
|
|
326
|
+
return Object.keys(intent.updates ?? {}).length > 0
|
|
327
|
+
|| (intent.removeKeys?.length ?? 0) > 0;
|
|
328
|
+
}
|
|
329
|
+
function configSaveBatchGroupIntent(intent, group) {
|
|
330
|
+
return {
|
|
331
|
+
kind: 'configSave',
|
|
332
|
+
pluginId: intent.pluginId,
|
|
333
|
+
scope: 'user',
|
|
334
|
+
platform: group.platform,
|
|
335
|
+
context: intent.context ?? 'user',
|
|
336
|
+
apply: intent.apply,
|
|
337
|
+
...(intent.scriptTimeoutMs === undefined ? {} : { scriptTimeoutMs: intent.scriptTimeoutMs }),
|
|
338
|
+
...(group.updates ? { updates: group.updates } : {}),
|
|
339
|
+
...(group.removeKeys ? { removeKeys: group.removeKeys } : {}),
|
|
340
|
+
...(group.sensitiveKeys ? { sensitiveKeys: group.sensitiveKeys } : {}),
|
|
341
|
+
...(group.privateKeys ? { privateKeys: group.privateKeys } : {}),
|
|
342
|
+
...(group.changes ? { changes: group.changes } : {}),
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function assertConfigSaveBatchIntent(intent) {
|
|
346
|
+
if (intent.groups.length === 0 || intent.groups.length > PLATFORM_TARGETS.length + 1
|
|
347
|
+
|| new Set(intent.groups.map((group) => group.platform ?? 'common')).size !== intent.groups.length
|
|
348
|
+
|| intent.groups.some((group) => Object.keys(group.updates ?? {}).length === 0
|
|
349
|
+
&& (group.removeKeys?.length ?? 0) === 0)) {
|
|
350
|
+
throw new TuiOperationBlockedError('configBatchInvalid', '设置批次必须包含唯一且非空的公共或平台配置。');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function operationReviewStale(message, diagnostics) {
|
|
354
|
+
return new TuiOperationBlockedError('operationReviewStale', `operationReviewStale: ${message}`, diagnostics);
|
|
127
355
|
}
|
|
128
356
|
function sourceEvidenceForPlugin(source, pluginName) {
|
|
129
357
|
const entry = source.manifest.entries.find((candidate) => candidate.name === pluginName);
|
|
130
358
|
return {
|
|
131
359
|
sourceId: source.sourceId,
|
|
132
360
|
sourceIdentity: source.sourceIdentity,
|
|
361
|
+
logicalIdentity: source.logicalIdentity,
|
|
133
362
|
requestedRef: source.requestedRef,
|
|
134
363
|
resolvedCommit: source.resolvedCommit,
|
|
135
364
|
manifestDigest: source.manifestDigest,
|
|
@@ -140,9 +369,28 @@ function sourceEvidenceForPlugin(source, pluginName) {
|
|
|
140
369
|
channel: source.manifest.channel,
|
|
141
370
|
};
|
|
142
371
|
}
|
|
372
|
+
async function configLayerStoreDigest(options) {
|
|
373
|
+
const store = await readPluginConfigStore({
|
|
374
|
+
sourceId: options.source.sourceId,
|
|
375
|
+
sourceIdentity: options.source.sourceIdentity,
|
|
376
|
+
...('logicalIdentity' in options.source
|
|
377
|
+
? { logicalIdentity: options.source.logicalIdentity }
|
|
378
|
+
: {}),
|
|
379
|
+
pluginName: options.pluginName,
|
|
380
|
+
scope: 'user',
|
|
381
|
+
platform: options.platform,
|
|
382
|
+
cwd: options.cwd,
|
|
383
|
+
env: options.env,
|
|
384
|
+
});
|
|
385
|
+
return options.profileOnly
|
|
386
|
+
? digest({ profile: options.platform ?? 'common', state: store.state === 'invalid' ? 'invalid' : 'ready',
|
|
387
|
+
values: store.values, ...(store.state === 'invalid' ? { rawDigest: store.rawDigest } : {}) })
|
|
388
|
+
: digest({ exists: store.exists, rawDigest: store.rawDigest });
|
|
389
|
+
}
|
|
143
390
|
function assertSourceEvidenceMatches(expected, actual) {
|
|
144
391
|
if (actual.sourceId !== expected.sourceId
|
|
145
392
|
|| actual.sourceIdentity !== expected.sourceIdentity
|
|
393
|
+
|| actual.logicalIdentity !== expected.logicalIdentity
|
|
146
394
|
|| actual.resolvedCommit !== expected.resolvedCommit
|
|
147
395
|
|| actual.manifestDigest !== expected.manifestDigest
|
|
148
396
|
|| actual.snapshotDigest !== expected.snapshotDigest
|
|
@@ -150,18 +398,22 @@ function assertSourceEvidenceMatches(expected, actual) {
|
|
|
150
398
|
throw operationReviewStale('确认后来源内容发生变化。');
|
|
151
399
|
}
|
|
152
400
|
}
|
|
153
|
-
function throwIfWriteReviewStale(result) {
|
|
154
|
-
const stale = result.targetResults.find((target) => target.errorCode === 'operationReviewStale'
|
|
155
|
-
|| target.errorCode === 'operationPlanStale');
|
|
156
|
-
if (stale) {
|
|
157
|
-
throw operationReviewStale('确认后实际写入计划发生变化。');
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
401
|
const SOURCE_PROGRESS_PHASES = {
|
|
161
402
|
savingConfig: '保存来源配置',
|
|
162
403
|
};
|
|
163
|
-
function
|
|
164
|
-
|
|
404
|
+
function reviewedScriptTimeoutMs(intent) {
|
|
405
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
406
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
407
|
+
}
|
|
408
|
+
if ((intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch')
|
|
409
|
+
&& (intent.action === 'install' || intent.action === 'refreshAndSync'
|
|
410
|
+
|| intent.action === 'reinstall' || intent.action === 'sync')) {
|
|
411
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
412
|
+
}
|
|
413
|
+
if ((intent.kind === 'configSave' || intent.kind === 'configSaveBatch') && intent.apply) {
|
|
414
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
415
|
+
}
|
|
416
|
+
return undefined;
|
|
165
417
|
}
|
|
166
418
|
async function loadDependencyOverviews(options) {
|
|
167
419
|
const graph = await withResolvedMultiSourceCatalog({
|
|
@@ -178,6 +430,7 @@ async function loadDependencyOverviews(options) {
|
|
|
178
430
|
sourceId: item.resolution.sourceId,
|
|
179
431
|
pluginName: entry.name,
|
|
180
432
|
}),
|
|
433
|
+
sourceIdentity: item.resolution.sourceIdentity,
|
|
181
434
|
displayName: entry.interface?.displayName ?? entry.name,
|
|
182
435
|
dependencies: entry.dependencies.map((pluginName) => formatPluginId({ sourceId: item.resolution.sourceId, pluginName })),
|
|
183
436
|
}))
|
|
@@ -188,7 +441,7 @@ async function loadDependencyOverviews(options) {
|
|
|
188
441
|
}),
|
|
189
442
|
});
|
|
190
443
|
const nodes = new Map(graph.nodes.map((node) => [node.pluginId, node]));
|
|
191
|
-
const summaryById = new Map(options.
|
|
444
|
+
const summaryById = new Map(options.pluginSummaries.map((summary) => [summary.pluginId, summary]));
|
|
192
445
|
const displayName = (pluginId) => nodes.get(pluginId)?.displayName
|
|
193
446
|
?? parsePluginId(pluginId).pluginName;
|
|
194
447
|
const reverse = new Map();
|
|
@@ -198,56 +451,52 @@ async function loadDependencyOverviews(options) {
|
|
|
198
451
|
}
|
|
199
452
|
}
|
|
200
453
|
const targetsByPlugin = new Map();
|
|
201
|
-
for (const target of options.status.
|
|
454
|
+
for (const target of options.status.observedTargets ?? []) {
|
|
202
455
|
targetsByPlugin.set(target.pluginId, [...(targetsByPlugin.get(target.pluginId) ?? []), target]);
|
|
203
456
|
}
|
|
204
|
-
const unsupportedPluginIds = new Set(options.
|
|
205
|
-
.filter((summary) => (summary.missingCapabilities?.length ?? 0) > 0)
|
|
457
|
+
const unsupportedPluginIds = new Set(options.pluginSummaries.filter((summary) => (summary.missingCapabilities?.length ?? 0) > 0)
|
|
206
458
|
.map((summary) => summary.pluginId));
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
pluginId
|
|
226
|
-
|
|
227
|
-
scope: consumer.scope,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
pluginId: dependencyPluginId,
|
|
232
|
-
platform: consumer.platform,
|
|
233
|
-
scope: dependencyScope,
|
|
234
|
-
project: dependencyScope === 'project' ? 'current' : null,
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
const key = `${consumer.pluginId}\0${dependencyPluginId}`;
|
|
238
|
-
placementReferences.set(key, [...(placementReferences.get(key) ?? []), reference]);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
const placementsFor = (pluginId) => {
|
|
242
|
-
const targets = targetsByPlugin.get(pluginId) ?? [];
|
|
243
|
-
if (targets.length > 0) {
|
|
244
|
-
return ['codex', 'claude'].flatMap((platform) => {
|
|
245
|
-
const selected = targets.filter((target) => target.platform === platform);
|
|
246
|
-
return selected.length > 0 ? [projectPlatformPlacement(platform, selected)] : [];
|
|
459
|
+
const availableReferencesFor = (rootId, dependencyId) => {
|
|
460
|
+
const references = (targetsByPlugin.get(dependencyId) ?? []).flatMap((dependency) => {
|
|
461
|
+
if (dependency.agent === 'generic' || dependency.content !== 'satisfied' || dependency.observation !== 'verified'
|
|
462
|
+
|| dependency.providerScope !== dependency.scope
|
|
463
|
+
|| !options.status.existingTargets?.some((item) => item.pluginId === dependencyId
|
|
464
|
+
&& item.agent === dependency.agent && item.scope === dependency.scope))
|
|
465
|
+
return [];
|
|
466
|
+
return (dependency.contributions ?? []).flatMap((contribution) => {
|
|
467
|
+
if (contribution.root !== rootId || contribution.path.at(-1) !== dependencyId || contribution.path.length < 2)
|
|
468
|
+
return [];
|
|
469
|
+
const parentId = contribution.path.at(-2);
|
|
470
|
+
if (!nodes.get(parentId)?.dependencies.includes(dependencyId)
|
|
471
|
+
|| nodes.get(parentId)?.sourceIdentity !== nodes.get(dependencyId)?.sourceIdentity)
|
|
472
|
+
return [];
|
|
473
|
+
return (targetsByPlugin.get(parentId) ?? []).filter((consumer) => consumer.agent === dependency.agent
|
|
474
|
+
&& consumer.providerScope === consumer.scope
|
|
475
|
+
&& consumer.contributions?.some((entry) => entry.root === contribution.root && entry.scope === contribution.scope
|
|
476
|
+
&& JSON.stringify(entry.path) === JSON.stringify(contribution.path.slice(0, -1)))
|
|
477
|
+
&& options.status.existingTargets?.some((item) => item.pluginId === parentId && item.agent === consumer.agent && item.scope === consumer.scope))
|
|
478
|
+
.map((consumer) => ({ requirementScope: contribution.scope,
|
|
479
|
+
consumer: { pluginId: parentId, platform: dependency.agent, scope: consumer.scope,
|
|
480
|
+
project: consumer.scope === 'project' ? 'current' : null },
|
|
481
|
+
dependency: { pluginId: dependencyId, platform: dependency.agent, scope: dependency.scope,
|
|
482
|
+
project: dependency.scope === 'project' ? 'current' : null } }));
|
|
247
483
|
});
|
|
248
|
-
}
|
|
249
|
-
return [];
|
|
484
|
+
});
|
|
485
|
+
return [...new Map(references.map((reference) => [JSON.stringify(reference), reference])).values()];
|
|
250
486
|
};
|
|
487
|
+
const placementsFor = (pluginId) => (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => {
|
|
488
|
+
if (target.agent === 'generic')
|
|
489
|
+
return [];
|
|
490
|
+
const exists = options.status.existingTargets?.some((item) => item.pluginId === pluginId
|
|
491
|
+
&& item.agent === target.agent && item.scope === target.scope);
|
|
492
|
+
if (!exists)
|
|
493
|
+
return [{ platform: target.agent, state: 'notInstalled', supportedScopes: ['user', 'project'] }];
|
|
494
|
+
return [{ platform: target.agent, state: 'installed', scope: target.scope,
|
|
495
|
+
health: target.content === 'satisfied' && !target.blockers.length ? 'ready'
|
|
496
|
+
: target.blockers.length || target.content === 'conflict' ? 'error' : 'incomplete',
|
|
497
|
+
revision: { state: 'unknown', ...(target.expectedVersion ? { availableVersion: target.expectedVersion } : {}),
|
|
498
|
+
...(target.installedVersion ? { installedVersion: target.installedVersion } : {}) }, relation: target.relation === 'dependency' ? 'dependency' : 'root' }];
|
|
499
|
+
});
|
|
251
500
|
const aggregateFor = (pluginId, placements) => {
|
|
252
501
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
253
502
|
if (graph.sourceErrors.some((error) => error.sourceId === sourceId)
|
|
@@ -309,7 +558,8 @@ async function loadDependencyOverviews(options) {
|
|
|
309
558
|
})),
|
|
310
559
|
placements,
|
|
311
560
|
aggregateStatus: aggregateFor(dependency.pluginId, placements),
|
|
312
|
-
placementReferences:
|
|
561
|
+
placementReferences: [],
|
|
562
|
+
availablePlacementReferences: availableReferencesFor(pluginId, dependency.pluginId),
|
|
313
563
|
};
|
|
314
564
|
});
|
|
315
565
|
const dependentIds = [...new Set(reverse.get(pluginId) ?? [])].sort();
|
|
@@ -323,10 +573,11 @@ async function loadDependencyOverviews(options) {
|
|
|
323
573
|
requiredBy: [],
|
|
324
574
|
placements,
|
|
325
575
|
aggregateStatus: aggregateFor(dependentId, placements),
|
|
326
|
-
placementReferences:
|
|
576
|
+
placementReferences: [],
|
|
577
|
+
availablePlacementReferences: availableReferencesFor(dependentId, pluginId),
|
|
327
578
|
};
|
|
328
579
|
});
|
|
329
|
-
const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.
|
|
580
|
+
const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.blockers.filter((error) => error.code.startsWith('dependency') || error.code === 'sourceChanged')
|
|
330
581
|
.map((error) => ({
|
|
331
582
|
code: error.code,
|
|
332
583
|
title: '依赖关系需要处理',
|
|
@@ -337,7 +588,7 @@ async function loadDependencyOverviews(options) {
|
|
|
337
588
|
const dependencyTargets = summaryById.get(dependency.pluginId)?.supportedTargets;
|
|
338
589
|
if (!consumerTargets || !dependencyTargets)
|
|
339
590
|
return true;
|
|
340
|
-
return
|
|
591
|
+
return NATIVE_PLATFORM_TARGETS.some((platform) => (consumerTargets[platform]?.length ?? 0) > 0 && (dependencyTargets[platform]?.length ?? 0) === 0);
|
|
341
592
|
});
|
|
342
593
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
343
594
|
const blockers = [
|
|
@@ -405,13 +656,15 @@ function createReviewStageReporter(options) {
|
|
|
405
656
|
export function createTuiControllerDependencies(context, progressFeed, options = {}) {
|
|
406
657
|
const readInventory = options.inventoryCatalogSourceReferences
|
|
407
658
|
?? inventoryCatalogSourceReferences;
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
const loadCatalogGenerations = async () => {
|
|
659
|
+
let validatedStoreEntries = new Map();
|
|
660
|
+
let validatingStoreEntries = new Map();
|
|
661
|
+
const loadCatalogGenerations = async (entries, signal, preparation) => {
|
|
411
662
|
const generations = await loadCatalogGenerationViewModels({
|
|
412
663
|
env: context.env,
|
|
413
|
-
|
|
414
|
-
|
|
664
|
+
signal,
|
|
665
|
+
preparation,
|
|
666
|
+
validatedStoreEntries: entries,
|
|
667
|
+
validatingStoreEntries: new Map(),
|
|
415
668
|
onStage: (event) => context.debugLogger.log({
|
|
416
669
|
type: 'performance:stage',
|
|
417
670
|
level: 'debug',
|
|
@@ -423,9 +676,9 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
423
676
|
const retained = new Set(generations.flatMap((source) => [
|
|
424
677
|
source.active?.storeKey,
|
|
425
678
|
].filter((value) => value !== undefined)));
|
|
426
|
-
for (const storeKey of
|
|
679
|
+
for (const storeKey of entries.keys()) {
|
|
427
680
|
if (!retained.has(storeKey))
|
|
428
|
-
|
|
681
|
+
entries.delete(storeKey);
|
|
429
682
|
}
|
|
430
683
|
return generations;
|
|
431
684
|
};
|
|
@@ -439,6 +692,9 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
439
692
|
const catalogOperationByEvidence = new WeakMap();
|
|
440
693
|
let sessionCatalogOperationContext;
|
|
441
694
|
let sessionStatusResult;
|
|
695
|
+
let sessionRecoveryStatus;
|
|
696
|
+
let latestStatusRead = 0;
|
|
697
|
+
let bindNewCatalog = true;
|
|
442
698
|
const sessionContextForPlugin = (pluginId) => {
|
|
443
699
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
444
700
|
if (!sourceId || !sessionCatalogOperationContext)
|
|
@@ -446,43 +702,53 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
446
702
|
return selectCatalogOperationContext(sessionCatalogOperationContext, [sourceId]);
|
|
447
703
|
};
|
|
448
704
|
const readConfigStoresForTui = async (config) => {
|
|
449
|
-
const
|
|
450
|
-
const stores = await Promise.all(scopes.map((scope) => readPluginConfigStore({
|
|
705
|
+
const user = await readPluginConfigStore({
|
|
451
706
|
sourceId: config.sourceId,
|
|
452
707
|
sourceIdentity: config.sourceIdentity,
|
|
708
|
+
logicalIdentity: config.logicalIdentity,
|
|
453
709
|
pluginName: config.pluginName,
|
|
454
|
-
scope,
|
|
710
|
+
scope: 'user',
|
|
711
|
+
platform: config.platform,
|
|
455
712
|
cwd: context.cwd,
|
|
456
713
|
env: context.env,
|
|
457
714
|
schema: config.schema,
|
|
458
|
-
})
|
|
459
|
-
const user = stores[0];
|
|
460
|
-
const project = config.scope === 'user' ? undefined : stores[1];
|
|
715
|
+
});
|
|
461
716
|
config.signal.throwIfAborted();
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
if (
|
|
473
|
-
throw
|
|
474
|
-
|
|
717
|
+
if (user.state === 'invalid')
|
|
718
|
+
throw new TuiConfigInvalidStoreError([{
|
|
719
|
+
scope: 'user', code: user.invalidCode,
|
|
720
|
+
pathSummary: `AW_HOME/plugin-config/${config.sourceId ?? '<source>'}/${config.pluginName}/config.json`,
|
|
721
|
+
}]);
|
|
722
|
+
return { user };
|
|
723
|
+
};
|
|
724
|
+
const assertConfigEditEvidence = async (intent, evidence) => {
|
|
725
|
+
if (!intent.editEvidence)
|
|
726
|
+
return;
|
|
727
|
+
if (!evidence.source || !evidence.config)
|
|
728
|
+
throw operationReviewStale('设置编辑缺少当前证据。');
|
|
729
|
+
const currentDigest = await configLayerStoreDigest({ source: evidence.source,
|
|
730
|
+
pluginName: parsePluginId(intent.pluginId).pluginName, scope: 'user', platform: intent.platform,
|
|
731
|
+
cwd: context.cwd, env: context.env });
|
|
732
|
+
for (const expected of Object.values(intent.editEvidence)) {
|
|
733
|
+
if (expected.sourceIdentity !== evidence.source.sourceIdentity
|
|
734
|
+
|| expected.schemaIdentity !== evidence.config.schemaIdentity
|
|
735
|
+
|| expected.platform !== intent.platform
|
|
736
|
+
|| (expected.context ?? 'user') !== (intent.context ?? 'user')
|
|
737
|
+
|| expected.storeDigests.user !== undefined && expected.storeDigests.user !== currentDigest) {
|
|
738
|
+
throw operationReviewStale('编辑期间设置、来源或定义已变化。请重新打开设置。');
|
|
739
|
+
}
|
|
740
|
+
}
|
|
475
741
|
};
|
|
476
742
|
const loadStatus = async (signal) => {
|
|
477
743
|
signal.throwIfAborted();
|
|
744
|
+
const read = ++latestStatusRead;
|
|
745
|
+
const pinnedContext = bindNewCatalog ? undefined : sessionCatalogOperationContext;
|
|
746
|
+
const sessionStoreEntries = validatedStoreEntries;
|
|
478
747
|
const packageInfo = await readCliPackageInfo();
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
signal
|
|
483
|
-
validatedStoreEntries,
|
|
484
|
-
validatingStoreEntries,
|
|
485
|
-
}).catch(async (error) => {
|
|
748
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
749
|
+
const catalogReadScope = pinnedContext ? undefined : new CatalogPreparationReadScope({ env: context.env, signal });
|
|
750
|
+
const catalogOperationContext = pinnedContext ?? await catalogReadScope?.resolve({}).catch(async (error) => {
|
|
751
|
+
signal.throwIfAborted();
|
|
486
752
|
if (!(error instanceof CatalogGenerationError)
|
|
487
753
|
|| error.code !== 'catalogGenerationStateInvalid')
|
|
488
754
|
return undefined;
|
|
@@ -508,27 +774,21 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
508
774
|
},
|
|
509
775
|
};
|
|
510
776
|
});
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
verbose: context.diagnostics.verbose,
|
|
519
|
-
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
520
|
-
inventoryCatalogSourceReferences: readInventory,
|
|
777
|
+
const result = await loadCatalogView({ context, cliVersion: packageInfo.version, signal,
|
|
778
|
+
...(catalogOperationContext ? { catalogOperationContext } : {}) });
|
|
779
|
+
const snapshot = await readJointDemand({ cwd: context.cwd, env: context.env, signal, catalogOperationContext, catalogReadScope,
|
|
780
|
+
...(catalogOperationContext ? { resolveCatalog: async () => ({
|
|
781
|
+
context: catalogOperationContext,
|
|
782
|
+
configured: new Set(catalogOperationContext.catalog.sources.map((source) => source.sourceId)),
|
|
783
|
+
}) } : {}),
|
|
521
784
|
});
|
|
522
|
-
signal
|
|
523
|
-
|
|
524
|
-
signal.throwIfAborted();
|
|
525
|
-
if (result.payload.catalog.configDigest !== configured.configDigest)
|
|
526
|
-
continue;
|
|
527
|
-
sessionStatusResult = result;
|
|
785
|
+
const current = await readRecoveryStatus({ cwd: context.cwd, env: context.env, signal,
|
|
786
|
+
cliVersion: packageInfo.version, nativeCliRunner: context.nativeCliRunner, catalogOperationContext, catalogReadScope }, snapshot);
|
|
528
787
|
const dependencyOverviews = await loadDependencyOverviews({
|
|
529
788
|
context,
|
|
530
789
|
cliVersion: packageInfo.version,
|
|
531
|
-
status:
|
|
790
|
+
status: current,
|
|
791
|
+
pluginSummaries: result.pluginSummaries,
|
|
532
792
|
signal,
|
|
533
793
|
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
534
794
|
});
|
|
@@ -539,16 +799,56 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
539
799
|
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
540
800
|
});
|
|
541
801
|
signal.throwIfAborted();
|
|
542
|
-
const
|
|
802
|
+
const configStoreInventory = (await Promise.all(['user'].map(async (scope) => {
|
|
803
|
+
try {
|
|
804
|
+
return (await listNamespacedPluginConfigStoreIdentities({
|
|
805
|
+
cwd: context.cwd,
|
|
806
|
+
env: context.env,
|
|
807
|
+
scope,
|
|
808
|
+
})).map(({ pluginId, sourceId, pluginName }) => ({
|
|
809
|
+
pluginId, sourceId, pluginName, scope,
|
|
810
|
+
}));
|
|
811
|
+
}
|
|
812
|
+
catch {
|
|
813
|
+
await context.debugLogger.log({
|
|
814
|
+
type: 'tui:config-inventory-error',
|
|
815
|
+
level: 'debug',
|
|
816
|
+
target: 'debugLog',
|
|
817
|
+
message: 'TUI saved config inventory could not be read.',
|
|
818
|
+
data: { scope },
|
|
819
|
+
});
|
|
820
|
+
return [];
|
|
821
|
+
}
|
|
822
|
+
}))).flat();
|
|
823
|
+
const scopedRecovery = { user: { ...scopedCurrentStatus(current, snapshot, 'user'), dependencyOverviews },
|
|
824
|
+
...(snapshot.project ? { project: { ...scopedCurrentStatus(current, snapshot, 'project'), dependencyOverviews } } : {}) };
|
|
825
|
+
const retirementSourceChecks = await checkRetirementSources(catalogOperationContext, [
|
|
826
|
+
...Object.values(scopedRecovery).flatMap(inventoryPluginIds),
|
|
827
|
+
...configStoreInventory.map((store) => store.pluginId),
|
|
828
|
+
], signal, catalogReadScope);
|
|
829
|
+
const storeEntries = new Map(catalogReadScope ? undefined : sessionStoreEntries);
|
|
830
|
+
const catalogGenerations = await loadCatalogGenerations(storeEntries, signal, catalogReadScope
|
|
831
|
+
? { scope: catalogReadScope, context: catalogOperationContext } : undefined);
|
|
832
|
+
const configured = await listCatalogSources({ env: context.env });
|
|
543
833
|
signal.throwIfAborted();
|
|
834
|
+
if (result.payload.catalog.configDigest !== configured.configDigest
|
|
835
|
+
|| catalogOperationContext && !homeGenerationsMatch(catalogOperationContext, catalogGenerations, configured)) {
|
|
836
|
+
if (pinnedContext)
|
|
837
|
+
break;
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
544
840
|
const statusById = new Map(result.payload.catalog.sources.map((source) => [source.id, source]));
|
|
545
|
-
|
|
841
|
+
const status = {
|
|
546
842
|
cliChannel: packageInfo.version.includes('-') ? 'beta' : 'latest',
|
|
843
|
+
...(current.coverage.projectRoot ? { projectRoot: current.coverage.projectRoot } : {}),
|
|
844
|
+
scopedRecovery,
|
|
845
|
+
retirementSourceChecks,
|
|
846
|
+
configuredSources: structuredClone(configured.sources),
|
|
547
847
|
payload: result.payload,
|
|
548
848
|
pluginSummaries: result.pluginSummaries,
|
|
549
|
-
targetRevisions: result.targetRevisions,
|
|
550
849
|
dependencyOverviews,
|
|
551
850
|
portablePluginIds,
|
|
851
|
+
configStoreInventory,
|
|
552
852
|
catalogGenerations,
|
|
553
853
|
sessionGenerationKeys: Object.fromEntries((catalogOperationContext?.generationSet.sources ?? [])
|
|
554
854
|
.map((source) => [source.sourceId, source.storeKey])),
|
|
@@ -577,10 +877,147 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
577
877
|
};
|
|
578
878
|
}),
|
|
579
879
|
};
|
|
880
|
+
// Details and Review consume the same accepted read as the home view.
|
|
881
|
+
if (read === latestStatusRead) {
|
|
882
|
+
bindNewCatalog = false;
|
|
883
|
+
sessionCatalogOperationContext = catalogOperationContext;
|
|
884
|
+
sessionStatusResult = result;
|
|
885
|
+
sessionRecoveryStatus = current;
|
|
886
|
+
validatedStoreEntries = storeEntries;
|
|
887
|
+
validatingStoreEntries = new Map();
|
|
888
|
+
}
|
|
889
|
+
return status;
|
|
890
|
+
}
|
|
891
|
+
throw new TuiOperationBlockedError('operationReviewStale', '状态读取期间 Catalog 持续变化。请按 H 重新加载。');
|
|
892
|
+
};
|
|
893
|
+
const loadPluginContent = async (pluginId, signal) => {
|
|
894
|
+
signal.throwIfAborted();
|
|
895
|
+
try {
|
|
896
|
+
const packageInfo = await readCliPackageInfo();
|
|
897
|
+
const catalogOperation = sessionContextForPlugin(pluginId);
|
|
898
|
+
return await withResolvedCatalogPlugin({
|
|
899
|
+
selector: pluginId,
|
|
900
|
+
cliVersion: packageInfo.version,
|
|
901
|
+
env: context.env,
|
|
902
|
+
signal,
|
|
903
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
904
|
+
consume: ({ plugin, source }) => projectPluginContentOverview({
|
|
905
|
+
pluginId,
|
|
906
|
+
catalogVersion: source.manifest.catalogVersion,
|
|
907
|
+
plugin,
|
|
908
|
+
}),
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
catch {
|
|
912
|
+
signal.throwIfAborted();
|
|
913
|
+
const summary = sessionStatusResult?.pluginSummaries.find((entry) => entry.pluginId === pluginId);
|
|
914
|
+
let sourceId;
|
|
915
|
+
try {
|
|
916
|
+
sourceId = parsePluginId(pluginId).sourceId;
|
|
917
|
+
}
|
|
918
|
+
catch {
|
|
919
|
+
// The fixed unavailable result below does not repeat an unsafe selector.
|
|
920
|
+
}
|
|
921
|
+
const catalogVersion = sessionStatusResult?.payload.catalog.sources
|
|
922
|
+
.find((source) => source.id === sourceId)?.catalogVersion;
|
|
923
|
+
return {
|
|
924
|
+
pluginId,
|
|
925
|
+
pluginVersion: summary?.version ?? '待确认',
|
|
926
|
+
catalogVersion: catalogVersion ?? '待确认',
|
|
927
|
+
evidence: 'unavailable',
|
|
928
|
+
items: [],
|
|
929
|
+
notices: ['当前无法安全读取这个插件的目录内容。请检查来源状态后重试。'],
|
|
930
|
+
coverage: 'unavailable',
|
|
931
|
+
coverageIssue: {
|
|
932
|
+
code: 'unreadable',
|
|
933
|
+
message: '当前无法安全读取这个插件的目录内容。请检查来源状态后重试。',
|
|
934
|
+
},
|
|
935
|
+
};
|
|
580
936
|
}
|
|
581
|
-
throw new TuiOperationBlockedError('operationReviewStale', '状态读取期间来源配置持续变化。请重试。');
|
|
582
937
|
};
|
|
583
|
-
const captureEvidence = async (intent, signal, preparation, operationInventory = createOperationInventoryReader(), freshCatalog = false, reusableCandidate) => {
|
|
938
|
+
const captureEvidence = async (intent, signal, preparation, operationInventory = createOperationInventoryReader(), freshCatalog = false, reusableCandidate, reviewedEvidence) => {
|
|
939
|
+
if (intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch'
|
|
940
|
+
|| intent.kind === 'pluginWriteTask') {
|
|
941
|
+
throw new TuiOperationBlockedError('useScopedRecovery', '请使用统一范围恢复任务。');
|
|
942
|
+
}
|
|
943
|
+
reviewedScriptTimeoutMs(intent);
|
|
944
|
+
if ((intent.kind === 'configSave' || intent.kind === 'configSaveBatch' || intent.kind === 'configReset')
|
|
945
|
+
&& intent.context === 'project') {
|
|
946
|
+
await resolveWorkContext({ cwd: context.cwd, context: 'project' });
|
|
947
|
+
signal?.throwIfAborted();
|
|
948
|
+
}
|
|
949
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
950
|
+
signal?.throwIfAborted();
|
|
951
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
952
|
+
const catalogStore = await prepareCatalogStoreTask({ env: context.env });
|
|
953
|
+
signal?.throwIfAborted();
|
|
954
|
+
return {
|
|
955
|
+
catalog: { configDigest: config.digest, compositeDigest: config.digest },
|
|
956
|
+
catalogStore,
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
if (intent.kind === 'configSaveBatch') {
|
|
960
|
+
assertConfigSaveBatchIntent(intent);
|
|
961
|
+
const groupEvidence = [];
|
|
962
|
+
let batchBase;
|
|
963
|
+
let batchCatalogOperation;
|
|
964
|
+
for (const group of intent.groups) {
|
|
965
|
+
const current = await captureEvidence(configSaveBatchGroupIntent(intent, group), signal, preparation, operationInventory, freshCatalog, reusableCandidate, { config: reviewedEvidence?.configBatch?.groups.find((item) => item.platform === group.platform)?.config });
|
|
966
|
+
if (!current.config || !current.source || !current.targetFingerprint) {
|
|
967
|
+
throw operationReviewStale('设置批次缺少单层证据。');
|
|
968
|
+
}
|
|
969
|
+
if (batchBase && (JSON.stringify(batchBase.catalog) !== JSON.stringify(current.catalog)
|
|
970
|
+
|| JSON.stringify(batchBase.source) !== JSON.stringify(current.source))) {
|
|
971
|
+
throw operationReviewStale('准备设置批次期间 Catalog 或来源发生变化。');
|
|
972
|
+
}
|
|
973
|
+
for (const expected of Object.values(group.editEvidence ?? {})) {
|
|
974
|
+
if (expected.sourceIdentity !== current.source.sourceIdentity
|
|
975
|
+
|| expected.schemaIdentity !== current.config.schemaIdentity
|
|
976
|
+
|| expected.platform !== group.platform
|
|
977
|
+
|| (expected.context ?? 'user') !== (intent.context ?? 'user')) {
|
|
978
|
+
throw operationReviewStale('编辑期间插件来源或设置定义已变化,请重新打开列表。');
|
|
979
|
+
}
|
|
980
|
+
for (const scope of ['user']) {
|
|
981
|
+
if (expected.storeDigests[scope] === undefined)
|
|
982
|
+
continue;
|
|
983
|
+
const currentDigest = await configLayerStoreDigest({
|
|
984
|
+
source: current.source, pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
985
|
+
scope, cwd: context.cwd, env: context.env,
|
|
986
|
+
});
|
|
987
|
+
if (expected.storeDigests[scope] !== currentDigest) {
|
|
988
|
+
throw operationReviewStale('编辑期间设置已被外部修改,请重新打开列表。');
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
batchBase ??= current;
|
|
993
|
+
batchCatalogOperation ??= catalogOperationByEvidence.get(current);
|
|
994
|
+
groupEvidence.push({
|
|
995
|
+
scope: 'user',
|
|
996
|
+
platform: group.platform,
|
|
997
|
+
config: {
|
|
998
|
+
...current.config,
|
|
999
|
+
storeDigest: await configLayerStoreDigest({
|
|
1000
|
+
source: current.source,
|
|
1001
|
+
pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
1002
|
+
scope: 'user',
|
|
1003
|
+
platform: group.platform,
|
|
1004
|
+
profileOnly: true,
|
|
1005
|
+
cwd: context.cwd,
|
|
1006
|
+
env: context.env,
|
|
1007
|
+
}),
|
|
1008
|
+
},
|
|
1009
|
+
targetFingerprint: current.targetFingerprint,
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
const evidence = {
|
|
1013
|
+
catalog: batchBase.catalog,
|
|
1014
|
+
source: batchBase.source,
|
|
1015
|
+
configBatch: { groups: groupEvidence },
|
|
1016
|
+
};
|
|
1017
|
+
if (batchCatalogOperation)
|
|
1018
|
+
catalogOperationByEvidence.set(evidence, batchCatalogOperation);
|
|
1019
|
+
return evidence;
|
|
1020
|
+
}
|
|
584
1021
|
if (intent.kind === 'configReset') {
|
|
585
1022
|
const parsed = parsePluginId(intent.pluginId);
|
|
586
1023
|
if (!parsed.sourceId || !parsed.pluginName) {
|
|
@@ -590,7 +1027,7 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
590
1027
|
const target = await inspectPluginConfigResetTarget({
|
|
591
1028
|
sourceId: parsed.sourceId,
|
|
592
1029
|
pluginName: parsed.pluginName,
|
|
593
|
-
scope:
|
|
1030
|
+
scope: 'user',
|
|
594
1031
|
cwd: context.cwd,
|
|
595
1032
|
env: context.env,
|
|
596
1033
|
});
|
|
@@ -598,10 +1035,13 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
598
1035
|
if (target.kind === 'special') {
|
|
599
1036
|
throw new TuiOperationBlockedError('configResetTargetUnsupported', '设置目标是特殊文件系统节点,不能自动重置。请手动移动后重试。');
|
|
600
1037
|
}
|
|
601
|
-
|
|
1038
|
+
const relevantTargets = sessionRecoveryStatus
|
|
1039
|
+
? currentConfigTargets(sessionRecoveryStatus, intent.pluginId, intent.context ?? 'user', [], intent.platform)
|
|
1040
|
+
: [];
|
|
1041
|
+
let selected;
|
|
602
1042
|
try {
|
|
603
1043
|
const packageInfo = await readCliPackageInfo();
|
|
604
|
-
|
|
1044
|
+
selected = await withResolvedCatalogPlugin({
|
|
605
1045
|
selector: intent.pluginId,
|
|
606
1046
|
cliVersion: packageInfo.version,
|
|
607
1047
|
env: context.env,
|
|
@@ -609,16 +1049,25 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
609
1049
|
? { operationContext: sessionContextForPlugin(intent.pluginId) }
|
|
610
1050
|
: {}),
|
|
611
1051
|
...(signal ? { signal } : {}),
|
|
612
|
-
consume: async ({ plugin, source: resolvedSource }) =>
|
|
1052
|
+
consume: async ({ plugin, source: resolvedSource }) => ({
|
|
1053
|
+
source: sourceEvidenceForPlugin(resolvedSource, plugin.manifest.name),
|
|
1054
|
+
impact: await analyzePluginConfigMutationImpact({
|
|
1055
|
+
plugin,
|
|
1056
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1057
|
+
cwd: context.cwd,
|
|
1058
|
+
env: context.env,
|
|
1059
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, relevantTargets),
|
|
1060
|
+
mutation: { kind: 'reset' },
|
|
1061
|
+
}),
|
|
1062
|
+
}),
|
|
613
1063
|
});
|
|
614
1064
|
}
|
|
615
|
-
catch {
|
|
616
|
-
|
|
1065
|
+
catch (error) {
|
|
1066
|
+
if (error?.code === 'configValidationMemoryExhausted')
|
|
1067
|
+
throw error;
|
|
1068
|
+
selected = undefined;
|
|
617
1069
|
}
|
|
618
1070
|
signal?.throwIfAborted();
|
|
619
|
-
const relevantTargets = sessionStatusResult
|
|
620
|
-
? configAffectedStatusTargets(sessionStatusResult.payload.targets, intent.pluginId, intent.scope)
|
|
621
|
-
: [];
|
|
622
1071
|
await preparation?.reporter.emit('evidence');
|
|
623
1072
|
return {
|
|
624
1073
|
catalog: sessionStatusResult ? {
|
|
@@ -628,16 +1077,27 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
628
1077
|
configDigest: 'config-reset-offline',
|
|
629
1078
|
compositeDigest: 'config-reset-target',
|
|
630
1079
|
},
|
|
631
|
-
...(
|
|
1080
|
+
...(selected ? { source: selected.source } : {}),
|
|
1081
|
+
...(sessionStatusResult ? {
|
|
1082
|
+
targetFingerprint: currentTargetFingerprint(sessionRecoveryStatus, relevantTargets),
|
|
1083
|
+
} : {}),
|
|
632
1084
|
config: {
|
|
633
|
-
scope: intent.
|
|
634
|
-
storeDigest: target.fingerprint,
|
|
635
|
-
|
|
1085
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
1086
|
+
storeDigest: selected?.impact.storeDigest ?? target.fingerprint,
|
|
1087
|
+
impactState: selected?.impact.impactState ?? 'unknown',
|
|
1088
|
+
...(selected?.impact.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
1089
|
+
...(selected?.impact.affectedCommandPackages.length
|
|
1090
|
+
? { commandPackages: selected.impact.affectedCommandPackages } : {}),
|
|
1091
|
+
affectedTargets: (selected?.impact.affectedTargets
|
|
1092
|
+
?? relevantTargets).map(({ platform, scope }) => ({ platform, scope })),
|
|
1093
|
+
...((selected?.impact.sharedNativeRenderUnits.length ?? 0) > 0
|
|
1094
|
+
? { sharedNativeRenderUnits: selected.impact.sharedNativeRenderUnits }
|
|
1095
|
+
: {}),
|
|
636
1096
|
},
|
|
637
1097
|
resetTarget: {
|
|
638
1098
|
sourceId: parsed.sourceId,
|
|
639
1099
|
pluginName: parsed.pluginName,
|
|
640
|
-
scope: intent.
|
|
1100
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
641
1101
|
kind: target.kind,
|
|
642
1102
|
fingerprint: target.fingerprint,
|
|
643
1103
|
},
|
|
@@ -684,12 +1144,16 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
684
1144
|
&& (preview.identityChanged || sourceFingerprintChanged);
|
|
685
1145
|
if (preview.identityChanged)
|
|
686
1146
|
sourceIdentityChangeImpact = {
|
|
687
|
-
impactSchemaVersion:
|
|
1147
|
+
impactSchemaVersion: 3,
|
|
688
1148
|
sourceId: preview.sourceId,
|
|
1149
|
+
primaryChange: preview.references.primaryChange,
|
|
689
1150
|
inventoryComplete: preview.references.inventoryComplete,
|
|
690
1151
|
references: preview.references.references,
|
|
691
1152
|
affectedReferences: preview.references.references,
|
|
692
|
-
changes: {
|
|
1153
|
+
changes: {
|
|
1154
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1155
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1156
|
+
},
|
|
693
1157
|
errors: preview.references.errors,
|
|
694
1158
|
};
|
|
695
1159
|
if (!explicitSourceChange) {
|
|
@@ -828,7 +1292,7 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
828
1292
|
if (intent.action !== 'replaceDamaged' && !explicitSourceChange && candidateRelation === 'rollbackDetected') {
|
|
829
1293
|
throw new TuiOperationBlockedError('catalogRollbackDetected', '候选 Catalog 版本低于当前 Active。普通更新已阻止。');
|
|
830
1294
|
}
|
|
831
|
-
const impact =
|
|
1295
|
+
const impact = exactRepair ? undefined
|
|
832
1296
|
: sourceIdentityChangeImpact ?? await inspectCatalogSourceImpact({
|
|
833
1297
|
sourceId: intent.sourceId,
|
|
834
1298
|
cwd: context.cwd,
|
|
@@ -837,6 +1301,29 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
837
1301
|
mode: 'generation',
|
|
838
1302
|
candidateManifest: probe.manifest,
|
|
839
1303
|
});
|
|
1304
|
+
const primaryPreview = intent.setPrimaryAfterActivation
|
|
1305
|
+
? await preflightCatalogSourceMutation({
|
|
1306
|
+
request: { action: 'setPrimary', sourceId: intent.sourceId },
|
|
1307
|
+
cwd: context.cwd,
|
|
1308
|
+
env: context.env,
|
|
1309
|
+
})
|
|
1310
|
+
: undefined;
|
|
1311
|
+
if (primaryPreview && primaryPreview.configDigest !== config.digest) {
|
|
1312
|
+
throw operationReviewStale('准备主来源切换期间来源配置发生变化。');
|
|
1313
|
+
}
|
|
1314
|
+
const primaryImpact = primaryPreview ? {
|
|
1315
|
+
impactSchemaVersion: 3,
|
|
1316
|
+
sourceId: primaryPreview.sourceId,
|
|
1317
|
+
primaryChange: primaryPreview.references.primaryChange,
|
|
1318
|
+
inventoryComplete: primaryPreview.references.inventoryComplete,
|
|
1319
|
+
references: primaryPreview.references.references,
|
|
1320
|
+
affectedReferences: primaryPreview.references.references,
|
|
1321
|
+
changes: {
|
|
1322
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1323
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1324
|
+
},
|
|
1325
|
+
errors: primaryPreview.references.errors,
|
|
1326
|
+
} : undefined;
|
|
840
1327
|
return {
|
|
841
1328
|
catalog: {
|
|
842
1329
|
configDigest: config.digest,
|
|
@@ -857,6 +1344,11 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
857
1344
|
impactDigest: calculateCatalogSourceImpactDigest(impact),
|
|
858
1345
|
impactMode: sourceIdentityChangeImpact ? 'identityChange' : 'generation',
|
|
859
1346
|
} : {}),
|
|
1347
|
+
...(primaryPreview && primaryImpact ? {
|
|
1348
|
+
primaryImpact,
|
|
1349
|
+
primaryImpactDigest: primaryPreview.impactDigest,
|
|
1350
|
+
primaryConfigDigest: primaryPreview.configDigest,
|
|
1351
|
+
} : {}),
|
|
860
1352
|
configDigest: config.digest,
|
|
861
1353
|
...(proposedConfigDigest ? { proposedConfigDigest } : {}),
|
|
862
1354
|
...(proposedSource ? { proposedSource } : {}),
|
|
@@ -890,18 +1382,23 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
890
1382
|
sourceWrite: {
|
|
891
1383
|
configDigest: preview.configDigest,
|
|
892
1384
|
proposedConfigDigest: preview.proposedConfigDigest,
|
|
1385
|
+
...(preview.identityChanged ? { identityChanged: true } : {}),
|
|
893
1386
|
...(preview.sourceIdentity ? { sourceIdentity: preview.sourceIdentity } : {}),
|
|
894
1387
|
inventoryDigest: digest({ references: preview.references.references, errors: preview.references.errors }),
|
|
895
1388
|
impactDigest: preview.impactDigest,
|
|
896
1389
|
referenceCount: preview.references.references.length,
|
|
897
1390
|
inventoryComplete: preview.references.inventoryComplete,
|
|
898
1391
|
impact: {
|
|
899
|
-
impactSchemaVersion:
|
|
1392
|
+
impactSchemaVersion: 3,
|
|
900
1393
|
sourceId: preview.sourceId,
|
|
1394
|
+
primaryChange: preview.references.primaryChange,
|
|
901
1395
|
inventoryComplete: preview.references.inventoryComplete,
|
|
902
1396
|
references: preview.references.references,
|
|
903
1397
|
affectedReferences: preview.references.references,
|
|
904
|
-
changes: {
|
|
1398
|
+
changes: {
|
|
1399
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1400
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1401
|
+
},
|
|
905
1402
|
errors: preview.references.errors,
|
|
906
1403
|
},
|
|
907
1404
|
},
|
|
@@ -912,21 +1409,15 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
912
1409
|
}
|
|
913
1410
|
return evidence;
|
|
914
1411
|
}
|
|
915
|
-
if (
|
|
1412
|
+
if (intent.kind !== 'configSave'
|
|
1413
|
+
&& intent.kind !== 'portableInstall') {
|
|
916
1414
|
throw new TuiOperationBlockedError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
|
|
917
1415
|
}
|
|
918
1416
|
signal?.throwIfAborted();
|
|
919
1417
|
const packageInfo = await readCliPackageInfo();
|
|
920
|
-
const offlineCleanupReason = intent.kind === 'pluginWrite'
|
|
921
|
-
&& intent.action === 'cleanup'
|
|
922
|
-
&& intent.originIssue?.actionId === 'cleanup'
|
|
923
|
-
&& (intent.originIssue?.category === 'sourceMissing'
|
|
924
|
-
|| intent.originIssue?.category === 'sourceUnavailable')
|
|
925
|
-
? intent.originIssue.category === 'sourceMissing' ? 'sourceMissing' : 'bundleUnavailable'
|
|
926
|
-
: undefined;
|
|
927
1418
|
let catalogOperation;
|
|
928
1419
|
let catalogOperationError;
|
|
929
|
-
if (
|
|
1420
|
+
if (intent.kind !== 'portableInstall') {
|
|
930
1421
|
try {
|
|
931
1422
|
const sourceIds = [parsePluginId(intent.pluginId).sourceId];
|
|
932
1423
|
catalogOperation = !freshCatalog && sessionCatalogOperationContext
|
|
@@ -944,23 +1435,39 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
944
1435
|
}
|
|
945
1436
|
if (intent.kind === 'portableInstall') {
|
|
946
1437
|
await preparation?.reporter.emit('portable');
|
|
1438
|
+
if (intent.retry
|
|
1439
|
+
&& (intent.retry.receipt.plugin.id !== intent.pluginId
|
|
1440
|
+
|| intent.retry.receipt.scope !== intent.scope)) {
|
|
1441
|
+
throw operationReviewStale('Portable 重试结果与当前插件或范围不匹配。');
|
|
1442
|
+
}
|
|
947
1443
|
const portableSourceId = parsePluginId(intent.pluginId).sourceId;
|
|
948
1444
|
const portableCatalogOperation = sessionCatalogOperationContext
|
|
949
1445
|
? selectCatalogOperationContext(sessionCatalogOperationContext, [portableSourceId])
|
|
950
1446
|
: undefined;
|
|
951
|
-
const portable =
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1447
|
+
const portable = intent.retry
|
|
1448
|
+
? await preparePortableRetry({
|
|
1449
|
+
receipt: intent.retry.receipt,
|
|
1450
|
+
cwd: context.cwd,
|
|
1451
|
+
env: context.env,
|
|
1452
|
+
cliVersion: packageInfo.version,
|
|
1453
|
+
signal,
|
|
1454
|
+
...(portableCatalogOperation
|
|
1455
|
+
? { catalogOperationContext: portableCatalogOperation }
|
|
1456
|
+
: {}),
|
|
1457
|
+
})
|
|
1458
|
+
: await preparePortableInstall({
|
|
1459
|
+
selector: intent.pluginId,
|
|
1460
|
+
scope: intent.scope,
|
|
1461
|
+
...(intent.selectedSkills.length > 0 ? { requestedSkills: intent.selectedSkills } : {}),
|
|
1462
|
+
...(intent.requestedAgents ? { requestedAgents: intent.requestedAgents } : {}),
|
|
1463
|
+
cwd: context.cwd,
|
|
1464
|
+
env: context.env,
|
|
1465
|
+
cliVersion: packageInfo.version,
|
|
1466
|
+
signal,
|
|
1467
|
+
...(portableCatalogOperation
|
|
1468
|
+
? { catalogOperationContext: portableCatalogOperation }
|
|
1469
|
+
: {}),
|
|
1470
|
+
});
|
|
964
1471
|
signal?.throwIfAborted();
|
|
965
1472
|
await preparation?.reporter.emit('evidence');
|
|
966
1473
|
signal?.throwIfAborted();
|
|
@@ -978,8 +1485,107 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
978
1485
|
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
979
1486
|
return evidence;
|
|
980
1487
|
}
|
|
981
|
-
if (
|
|
982
|
-
|
|
1488
|
+
if (intent.kind === 'configSave' && intent.retryApply) {
|
|
1489
|
+
await preparation?.reporter.emit('config');
|
|
1490
|
+
if (!catalogOperation)
|
|
1491
|
+
throw catalogOperationError ?? operationReviewStale('无法取得设置应用所需的 Catalog。');
|
|
1492
|
+
const selectedCatalogOperation = catalogOperation;
|
|
1493
|
+
const evidence = await withResolvedCatalogPlugin({
|
|
1494
|
+
selector: intent.pluginId, cliVersion: packageInfo.version, env: context.env,
|
|
1495
|
+
...(selectedCatalogOperation ? { operationContext: selectedCatalogOperation } : {}),
|
|
1496
|
+
...(signal ? { signal } : {}),
|
|
1497
|
+
consume: async ({ plugin, source }) => {
|
|
1498
|
+
const referencePlugins = await resolvePluginConfigReferencePlugins({
|
|
1499
|
+
sourceId: plugin.sourceId, sourceIdentity: plugin.sourceIdentity,
|
|
1500
|
+
logicalIdentity: plugin.catalogLogicalIdentity, env: context.env,
|
|
1501
|
+
operationContext: selectedCatalogOperation,
|
|
1502
|
+
});
|
|
1503
|
+
const prepared = await preparePluginConfigApply({
|
|
1504
|
+
plugin, scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1505
|
+
...(intent.targets ? { targets: intent.targets } : {}),
|
|
1506
|
+
cwd: context.cwd, env: context.env, cliVersion: packageInfo.version,
|
|
1507
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
1508
|
+
expectedCommandPackageEvidence: reviewedEvidence?.config?.commandPackageEvidence,
|
|
1509
|
+
rebuildRuntime: {
|
|
1510
|
+
...context,
|
|
1511
|
+
referencePlugins,
|
|
1512
|
+
...(selectedCatalogOperation ? { catalogOperationContext: selectedCatalogOperation,
|
|
1513
|
+
expectedGenerationSetDigest: selectedCatalogOperation.generationSetDigest } : {}),
|
|
1514
|
+
...(reviewedScriptTimeoutMs(intent) === undefined ? {} : { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
1515
|
+
},
|
|
1516
|
+
});
|
|
1517
|
+
try {
|
|
1518
|
+
signal?.throwIfAborted();
|
|
1519
|
+
const targets = prepared.plan.receipt.requestedTargets
|
|
1520
|
+
.filter((target) => !prepared.plan.receipt.targetResults.some((result) => result.pluginId === target.pluginId && result.agent === target.agent && result.scope === target.scope
|
|
1521
|
+
&& (result.satisfaction === 'unsupported' || result.satisfaction === 'excluded')))
|
|
1522
|
+
.map((target) => ({
|
|
1523
|
+
pluginName: parsePluginId(target.pluginId).pluginName, platform: target.agent, scope: target.scope,
|
|
1524
|
+
}));
|
|
1525
|
+
return {
|
|
1526
|
+
catalog: {
|
|
1527
|
+
configDigest: selectedCatalogOperation.catalog.configDigest,
|
|
1528
|
+
compositeDigest: selectedCatalogOperation.catalog.compositeDigest,
|
|
1529
|
+
...(selectedCatalogOperation ? { generationSetDigest: selectedCatalogOperation.generationSetDigest } : {}),
|
|
1530
|
+
},
|
|
1531
|
+
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
1532
|
+
config: {
|
|
1533
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1534
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, intent.platform),
|
|
1535
|
+
storeDigest: digest(prepared.evidence),
|
|
1536
|
+
impactState: 'known', affectedTargets: targets,
|
|
1537
|
+
commandPackages: prepared.commandPackages,
|
|
1538
|
+
applyEvidence: prepared.evidence, applyChanges: prepared.plan.changes,
|
|
1539
|
+
commandPackageEvidence: prepared.commandPackageEvidence,
|
|
1540
|
+
commandReviewChanges: configPackageReviewChanges(prepared.plan, prepared.commandPackageReviews),
|
|
1541
|
+
hostPermissionEffects: recoveryHostPermissionEffects(prepared.plan),
|
|
1542
|
+
applyWarnings: prepared.plan.warnings,
|
|
1543
|
+
applyBlockers: [...new Map([
|
|
1544
|
+
...prepared.commandPackageEvidence.flatMap(({ blocker }) => blocker ? [blocker] : []),
|
|
1545
|
+
...prepared.plan.receipt.blockers, ...prepared.plan.receipt.errors,
|
|
1546
|
+
...prepared.plan.receipt.targetResults.flatMap((target) => target.blockers),
|
|
1547
|
+
].map((item) => [`${item.code}\0${item.message}`, item])).values()],
|
|
1548
|
+
preApplyAuthorization: prepared.preApplyAuthorization,
|
|
1549
|
+
sharedNativeRenderUnits: await configRetrySharedNativeRenderUnits(plugin, targets.filter((target) => NATIVE_PLATFORM_TARGETS.includes(target.platform)), context.env, referencePlugins),
|
|
1550
|
+
},
|
|
1551
|
+
};
|
|
1552
|
+
}
|
|
1553
|
+
finally {
|
|
1554
|
+
await disposePluginConfigApply(prepared.plan);
|
|
1555
|
+
}
|
|
1556
|
+
},
|
|
1557
|
+
});
|
|
1558
|
+
if (catalogOperation)
|
|
1559
|
+
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
1560
|
+
return evidence;
|
|
1561
|
+
}
|
|
1562
|
+
const needsReferencePlugins = intent.kind === 'configSave'
|
|
1563
|
+
&& await withResolvedCatalogPlugin({
|
|
1564
|
+
selector: intent.pluginId, cliVersion: packageInfo.version, env: context.env,
|
|
1565
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1566
|
+
...(signal ? { signal } : {}),
|
|
1567
|
+
consume: ({ plugin }) => configNeedsReferencePlugins(plugin),
|
|
1568
|
+
});
|
|
1569
|
+
const referencePlugins = needsReferencePlugins
|
|
1570
|
+
? await resolvePluginConfigReferencePlugins({
|
|
1571
|
+
sourceId: parsePluginId(intent.pluginId).sourceId,
|
|
1572
|
+
env: context.env,
|
|
1573
|
+
operationContext: catalogOperation,
|
|
1574
|
+
})
|
|
1575
|
+
: undefined;
|
|
1576
|
+
const configReferencePluginIds = intent.kind === 'configSave' && needsReferencePlugins
|
|
1577
|
+
? await withResolvedCatalogPlugin({
|
|
1578
|
+
selector: intent.pluginId, cliVersion: packageInfo.version, env: context.env,
|
|
1579
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1580
|
+
...(signal ? { signal } : {}),
|
|
1581
|
+
consume: async ({ plugin }) => (await resolvePluginConfigReferenceConsumers({
|
|
1582
|
+
plugin, env: context.env, plugins: referencePlugins,
|
|
1583
|
+
})).map((entry) => entry.pluginId ?? `${entry.sourceId}/${entry.manifest.name}`),
|
|
1584
|
+
})
|
|
1585
|
+
: [];
|
|
1586
|
+
if (preparation && intent.kind === 'configSave'
|
|
1587
|
+
&& sessionRecoveryStatus?.scope === (intent.context ?? 'user')) {
|
|
1588
|
+
if (!sessionStatusResult || !sessionRecoveryStatus || !catalogOperation) {
|
|
983
1589
|
throw operationReviewStale('当前 TUI session 没有可复用的设置证据。');
|
|
984
1590
|
}
|
|
985
1591
|
await preparation.reporter.emit('config');
|
|
@@ -988,106 +1594,139 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
988
1594
|
if (configSnapshot.digest !== sessionStatusResult.payload.catalog.configDigest) {
|
|
989
1595
|
throw operationReviewStale('准备设置确认期间来源配置发生变化。');
|
|
990
1596
|
}
|
|
1597
|
+
const relevantTargets = currentConfigTargets(sessionRecoveryStatus, intent.pluginId, intent.context ?? 'user', configReferencePluginIds, intent.platform);
|
|
1598
|
+
const preparedCatalogOperation = catalogOperation;
|
|
991
1599
|
const selected = await withResolvedCatalogPlugin({
|
|
992
1600
|
selector: intent.pluginId,
|
|
993
1601
|
cliVersion: packageInfo.version,
|
|
994
1602
|
configSnapshot,
|
|
995
1603
|
env: context.env,
|
|
996
|
-
|
|
1604
|
+
operationContext: preparedCatalogOperation,
|
|
997
1605
|
...(signal ? { signal } : {}),
|
|
998
1606
|
consume: async ({ plugin, source }) => {
|
|
999
1607
|
if (!plugin.manifest.config) {
|
|
1000
1608
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1001
1609
|
}
|
|
1610
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, intent.platform);
|
|
1002
1611
|
if (intent.kind === 'configSave') {
|
|
1003
1612
|
await coercePluginConfigUpdates({
|
|
1004
|
-
schema:
|
|
1613
|
+
schema: definition.fields,
|
|
1005
1614
|
updates: intent.updates ?? {},
|
|
1006
1615
|
cwd: context.cwd,
|
|
1007
1616
|
});
|
|
1008
|
-
for (const key of intent.removeKeys ?? []) {
|
|
1009
|
-
if (!plugin.manifest.config.fields[key]) {
|
|
1010
|
-
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
1617
|
}
|
|
1618
|
+
const impact = intent.retryApply ? undefined : await analyzePluginConfigMutationImpact({
|
|
1619
|
+
plugin,
|
|
1620
|
+
referencePlugins,
|
|
1621
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1622
|
+
cwd: context.cwd,
|
|
1623
|
+
env: context.env,
|
|
1624
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, relevantTargets),
|
|
1625
|
+
mutation: {
|
|
1626
|
+
kind: 'patch',
|
|
1627
|
+
updates: intent.updates,
|
|
1628
|
+
removeKeys: intent.removeKeys,
|
|
1629
|
+
},
|
|
1630
|
+
});
|
|
1631
|
+
const affectedTargets = intent.retryApply
|
|
1632
|
+
? configImpactVisibleTargets(plugin.manifest.name, relevantTargets)
|
|
1633
|
+
: impact.affectedTargets;
|
|
1634
|
+
const commandPackages = impact?.affectedCommandPackages
|
|
1635
|
+
?? (await discoverPluginConfigManagedCommandPackages({ plugin, scope: intent.context ?? 'user',
|
|
1636
|
+
cwd: context.cwd, env: context.env ?? process.env, platformTargets: affectedTargets, referencePlugins })).packages;
|
|
1637
|
+
const preApplyAuthorization = configIntentRequestsApply(intent)
|
|
1638
|
+
? (await resolveConfigPreApplyAuthorization({
|
|
1639
|
+
plugin,
|
|
1640
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1641
|
+
cwd: context.cwd,
|
|
1642
|
+
env: context.env,
|
|
1643
|
+
applyTargets: affectedTargets,
|
|
1644
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
1645
|
+
rebuildRuntime: {
|
|
1646
|
+
referencePlugins,
|
|
1647
|
+
catalogOperationContext: preparedCatalogOperation,
|
|
1648
|
+
expectedGenerationSetDigest: preparedCatalogOperation.generationSetDigest,
|
|
1649
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1650
|
+
},
|
|
1651
|
+
})).targets
|
|
1652
|
+
: [];
|
|
1653
|
+
const commandReview = configIntentRequestsApply(intent) ? await reviewConfigMutationApply({
|
|
1654
|
+
plugin, scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1655
|
+
cwd: context.cwd, env: context.env, cliVersion: packageInfo.version, nativeCliRunner: context.nativeCliRunner,
|
|
1656
|
+
applyTargets: affectedTargets, applyCommandPackages: commandPackages.map(({ packageId }) => packageId),
|
|
1657
|
+
mutation: { kind: 'patch', updates: intent.updates, removeKeys: intent.removeKeys },
|
|
1658
|
+
rebuildRuntime: { ...context, signal, referencePlugins, catalogOperationContext: preparedCatalogOperation,
|
|
1659
|
+
expectedGenerationSetDigest: preparedCatalogOperation.generationSetDigest,
|
|
1660
|
+
scriptTimeoutMs: reviewedScriptTimeoutMs(intent), inventoryCatalogSourceReferences: operationInventory },
|
|
1661
|
+
}, reviewedEvidence?.config, freshCatalog) : {};
|
|
1014
1662
|
return {
|
|
1015
1663
|
pluginName: plugin.manifest.name,
|
|
1016
1664
|
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1665
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, intent.platform),
|
|
1666
|
+
impact,
|
|
1667
|
+
commandPackages,
|
|
1668
|
+
commandReview,
|
|
1669
|
+
preApplyAuthorization,
|
|
1670
|
+
retryStoreDigest: intent.retryApply ? await configRetryStoreDigest({ plugin, scope: intent.context ?? 'user', platform: intent.platform,
|
|
1671
|
+
targets: affectedTargets, commandPackages, preApplyAuthorization, cwd: context.cwd, env: context.env, plugins: referencePlugins }) : undefined,
|
|
1672
|
+
sharedNativeRenderUnits: intent.retryApply
|
|
1673
|
+
? await configRetrySharedNativeRenderUnits(plugin, affectedTargets, context.env, referencePlugins)
|
|
1674
|
+
: impact.sharedNativeRenderUnits,
|
|
1023
1675
|
};
|
|
1024
1676
|
},
|
|
1025
1677
|
});
|
|
1026
|
-
const store = await readPluginConfigStore({
|
|
1027
|
-
sourceId: selected.source?.sourceId ?? parsePluginId(intent.pluginId).sourceId,
|
|
1028
|
-
...(selected.source?.sourceIdentity
|
|
1029
|
-
? { sourceIdentity: selected.source.sourceIdentity }
|
|
1030
|
-
: {}),
|
|
1031
|
-
pluginName: selected.pluginName,
|
|
1032
|
-
scope: intent.scope,
|
|
1033
|
-
cwd: context.cwd,
|
|
1034
|
-
env: context.env,
|
|
1035
|
-
});
|
|
1036
1678
|
signal?.throwIfAborted();
|
|
1037
|
-
const relevantTargets = configAffectedStatusTargets(sessionStatusResult.payload.targets, intent.pluginId, intent.scope);
|
|
1038
|
-
const relevantRevisions = (sessionStatusResult.targetRevisions ?? []).filter((revision) => relevantTargets.some((target) => target.platform === revision.platform
|
|
1039
|
-
&& target.scope === revision.scope
|
|
1040
|
-
&& target.pluginId === revision.pluginId));
|
|
1041
1679
|
await preparation.reporter.emit('evidence');
|
|
1042
1680
|
const evidence = {
|
|
1043
1681
|
catalog: {
|
|
1044
1682
|
configDigest: sessionStatusResult.payload.catalog.configDigest,
|
|
1045
|
-
compositeDigest:
|
|
1683
|
+
compositeDigest: preparedCatalogOperation.catalog.compositeDigest,
|
|
1046
1684
|
...(catalogOperation ? { generationSetDigest: catalogOperation.generationSetDigest } : {}),
|
|
1047
1685
|
},
|
|
1048
1686
|
...(selected.source ? { source: selected.source } : {}),
|
|
1049
|
-
targetFingerprint:
|
|
1687
|
+
targetFingerprint: currentTargetFingerprint(sessionRecoveryStatus, relevantTargets),
|
|
1050
1688
|
config: {
|
|
1051
|
-
scope: intent.
|
|
1052
|
-
|
|
1053
|
-
storeDigest:
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1689
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1690
|
+
schemaIdentity: selected.schemaIdentity,
|
|
1691
|
+
storeDigest: selected.impact?.storeDigest
|
|
1692
|
+
?? selected.retryStoreDigest,
|
|
1693
|
+
impactState: selected.impact?.impactState ?? 'known',
|
|
1694
|
+
...(selected.impact?.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
1695
|
+
...(selected.commandPackages.length ? { commandPackages: selected.commandPackages } : {}),
|
|
1696
|
+
...selected.commandReview,
|
|
1697
|
+
affectedTargets: (selected.impact?.affectedTargets
|
|
1698
|
+
?? relevantTargets).map(({ pluginName, platform, scope }) => ({ pluginName, platform, scope })),
|
|
1699
|
+
...(selected.preApplyAuthorization.length > 0
|
|
1700
|
+
? { preApplyAuthorization: selected.preApplyAuthorization }
|
|
1701
|
+
: {}),
|
|
1702
|
+
...(selected.sharedNativeRenderUnits.length > 0
|
|
1703
|
+
? { sharedNativeRenderUnits: selected.sharedNativeRenderUnits }
|
|
1057
1704
|
: {}),
|
|
1058
1705
|
},
|
|
1059
1706
|
};
|
|
1707
|
+
await assertConfigEditEvidence(intent, evidence);
|
|
1060
1708
|
if (catalogOperation)
|
|
1061
1709
|
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
1062
1710
|
return evidence;
|
|
1063
1711
|
}
|
|
1064
1712
|
await preparation?.reporter.emit('status');
|
|
1065
|
-
const statusCatalogOperation =
|
|
1066
|
-
? undefined
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
? [intent.originIssue.consumerPluginId] : [])])],
|
|
1072
|
-
...('platform' in intent ? { platform: intent.platform } : {}),
|
|
1073
|
-
...(intent.kind !== 'pluginWrite' && intent.scope === 'project'
|
|
1074
|
-
? { scope: intent.scope }
|
|
1075
|
-
: {}),
|
|
1076
|
-
cwd: context.cwd,
|
|
1077
|
-
env: context.env,
|
|
1078
|
-
cliVersion: packageInfo.version,
|
|
1713
|
+
const statusCatalogOperation = catalogOperation
|
|
1714
|
+
?? (!freshCatalog ? sessionCatalogOperationContext : undefined);
|
|
1715
|
+
const status = await readRecoveryStatus({
|
|
1716
|
+
context: intent.context ?? 'user', cwd: context.cwd, env: context.env,
|
|
1717
|
+
nativeCliRunner: context.nativeCliRunner, cliVersion: packageInfo.version,
|
|
1718
|
+
...(signal ? { signal } : {}),
|
|
1079
1719
|
...(statusCatalogOperation ? { catalogOperationContext: statusCatalogOperation } : {}),
|
|
1080
|
-
inventoryCatalogSourceReferences: operationInventory,
|
|
1081
1720
|
});
|
|
1082
1721
|
signal?.throwIfAborted();
|
|
1083
1722
|
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
1084
1723
|
signal?.throwIfAborted();
|
|
1085
|
-
if (configSnapshot.digest !==
|
|
1724
|
+
if (statusCatalogOperation && configSnapshot.digest !== statusCatalogOperation.catalog.configDigest) {
|
|
1086
1725
|
throw operationReviewStale('准备确认信息期间来源配置发生变化。');
|
|
1087
1726
|
}
|
|
1088
1727
|
if (catalogOperationError)
|
|
1089
1728
|
throw catalogOperationError;
|
|
1090
|
-
if (!
|
|
1729
|
+
if (!catalogOperation) {
|
|
1091
1730
|
catalogOperation = await resolveCatalogOperationContext({
|
|
1092
1731
|
sourceIds: [parsePluginId(intent.pluginId).sourceId],
|
|
1093
1732
|
configSnapshot,
|
|
@@ -1096,217 +1735,283 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1096
1735
|
...(signal ? { signal } : {}),
|
|
1097
1736
|
});
|
|
1098
1737
|
}
|
|
1099
|
-
let dependencyPlan;
|
|
1100
|
-
let codexReconcilePlans;
|
|
1101
|
-
let operationPlan;
|
|
1102
1738
|
await preparation?.reporter.emit('catalog');
|
|
1103
|
-
const
|
|
1104
|
-
? status.
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
:
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
:
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
});
|
|
1119
|
-
signal?.throwIfAborted();
|
|
1120
|
-
offlineCleanup = offlineCleanupEvidenceFromInventory({
|
|
1121
|
-
reason: offlineCleanupReason,
|
|
1122
|
-
pluginId: offlineCleanupTarget.pluginId,
|
|
1123
|
-
pluginName: offlineCleanupTarget.pluginName,
|
|
1124
|
-
sourceId: offlineCleanupTarget.sourceId,
|
|
1125
|
-
sourceIdentity: offlineCleanupTarget.sourceIdentity,
|
|
1126
|
-
platform: offlineCleanupTarget.platform,
|
|
1127
|
-
scope: offlineCleanupTarget.scope,
|
|
1128
|
-
inventory,
|
|
1129
|
-
}) ?? undefined;
|
|
1130
|
-
if (!offlineCleanup) {
|
|
1131
|
-
throw operationReviewStale('离线清理现场证据已消失或无法验证。');
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
const selected = offlineCleanupTarget
|
|
1135
|
-
? {
|
|
1136
|
-
pluginName: offlineCleanupTarget.pluginName,
|
|
1137
|
-
source: {
|
|
1138
|
-
sourceId: offlineCleanupTarget.sourceId,
|
|
1139
|
-
sourceIdentity: offlineCleanupTarget.sourceIdentity,
|
|
1140
|
-
...(catalogSource?.requestedRef ? { requestedRef: catalogSource.requestedRef } : {}),
|
|
1141
|
-
...(catalogSource?.resolvedCommit ? { resolvedCommit: catalogSource.resolvedCommit } : {}),
|
|
1142
|
-
},
|
|
1143
|
-
}
|
|
1144
|
-
: await withResolvedCatalogPlugin({
|
|
1145
|
-
selector: intent.pluginId,
|
|
1146
|
-
cliVersion: packageInfo.version,
|
|
1147
|
-
configSnapshot,
|
|
1148
|
-
env: context.env,
|
|
1149
|
-
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1150
|
-
...(signal ? { signal } : {}),
|
|
1151
|
-
consume: async ({ plugin, source }) => {
|
|
1152
|
-
if (preparation?.validateIntent && intent.kind === 'configSave') {
|
|
1153
|
-
await preparation.reporter.emit('config');
|
|
1154
|
-
if (!plugin.manifest.config) {
|
|
1155
|
-
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1156
|
-
}
|
|
1157
|
-
await coercePluginConfigUpdates({
|
|
1158
|
-
schema: plugin.manifest.config.fields,
|
|
1159
|
-
updates: intent.updates ?? {},
|
|
1160
|
-
cwd: context.cwd,
|
|
1161
|
-
});
|
|
1162
|
-
for (const key of intent.removeKeys ?? []) {
|
|
1163
|
-
if (!plugin.manifest.config.fields[key]) {
|
|
1164
|
-
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1739
|
+
const configVisibleTargets = intent.kind === 'configSave'
|
|
1740
|
+
? currentConfigTargets(status, intent.pluginId, intent.context ?? 'user', configReferencePluginIds, intent.platform)
|
|
1741
|
+
: [];
|
|
1742
|
+
const selected = await withResolvedCatalogPlugin({
|
|
1743
|
+
selector: intent.pluginId,
|
|
1744
|
+
cliVersion: packageInfo.version,
|
|
1745
|
+
configSnapshot,
|
|
1746
|
+
env: context.env,
|
|
1747
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1748
|
+
...(signal ? { signal } : {}),
|
|
1749
|
+
consume: async ({ plugin, source }) => {
|
|
1750
|
+
if (preparation?.validateIntent && intent.kind === 'configSave') {
|
|
1751
|
+
await preparation.reporter.emit('config');
|
|
1752
|
+
if (!plugin.manifest.config) {
|
|
1753
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1167
1754
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
...(intent.removeKeys ?? []),
|
|
1175
|
-
])
|
|
1176
|
-
: [],
|
|
1177
|
-
};
|
|
1178
|
-
},
|
|
1179
|
-
});
|
|
1180
|
-
let codexManager;
|
|
1181
|
-
const hasDeclaredDependencies = (status.pluginSummaries.find((summary) => summary.pluginId === intent.pluginId)?.dependencyTotalCount ?? 0) > 0;
|
|
1182
|
-
if (intent.kind === 'pluginWrite') {
|
|
1183
|
-
const command = {
|
|
1184
|
-
install: installWriteCommand,
|
|
1185
|
-
refreshAndSync: syncWriteCommand,
|
|
1186
|
-
reinstall: reinstallWriteCommand,
|
|
1187
|
-
uninstall: uninstallWriteCommand,
|
|
1188
|
-
cleanup: cleanupWriteCommand,
|
|
1189
|
-
sync: syncWriteCommand,
|
|
1190
|
-
}[intent.action];
|
|
1191
|
-
const preview = await command([intent.pluginId], {
|
|
1192
|
-
cwd: context.cwd,
|
|
1193
|
-
platform: intent.platform,
|
|
1194
|
-
scope: intent.scope,
|
|
1195
|
-
...(intent.action === 'install' && intent.dependencyScopeOverrides
|
|
1196
|
-
? { dependencyScopeOverrides: intent.dependencyScopeOverrides }
|
|
1197
|
-
: {}),
|
|
1198
|
-
...(intent.action === 'cleanup' ? { force: intent.force === true } : {}),
|
|
1199
|
-
}, {
|
|
1200
|
-
...context,
|
|
1201
|
-
inventoryCatalogSourceReferences: operationInventory,
|
|
1202
|
-
expectedCatalogConfigDigest: status.payload.catalog.configDigest,
|
|
1203
|
-
...(catalogOperation ? {
|
|
1204
|
-
catalogOperationContext: catalogOperation,
|
|
1205
|
-
expectedGenerationSetDigest: catalogOperation.generationSetDigest,
|
|
1206
|
-
} : {}),
|
|
1207
|
-
previewOperationPlan: true,
|
|
1208
|
-
...(preparation ? {
|
|
1209
|
-
onPreviewStage: (stage) => stage === 'catalog' ? undefined : preparation.reporter.emit(stage),
|
|
1210
|
-
} : {}),
|
|
1211
|
-
});
|
|
1212
|
-
signal?.throwIfAborted();
|
|
1213
|
-
codexReconcilePlans = preview?.codexReconcilePlans;
|
|
1214
|
-
operationPlan = preview?.operationPlan;
|
|
1215
|
-
if (hasDeclaredDependencies
|
|
1216
|
-
&& (intent.action === 'install'
|
|
1217
|
-
|| intent.action === 'refreshAndSync'
|
|
1218
|
-
|| intent.action === 'reinstall'
|
|
1219
|
-
|| intent.action === 'sync')) {
|
|
1220
|
-
dependencyPlan = preview.dependencyPlan;
|
|
1221
|
-
if (!dependencyPlan) {
|
|
1222
|
-
throw new TuiOperationBlockedError('dependencyGraphInvalid', '无法建立可信的依赖安装计划。');
|
|
1223
|
-
}
|
|
1224
|
-
const blocker = dependencyPlan.targets.find((target) => target.action === 'block');
|
|
1225
|
-
if (blocker) {
|
|
1226
|
-
throw new TuiOperationBlockedError(blocker.errorCode ?? 'dependencyNotReady', `${blocker.errorCode ?? 'dependencyNotReady'}: 依赖安装计划被阻止。`);
|
|
1755
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, intent.platform);
|
|
1756
|
+
await coercePluginConfigUpdates({
|
|
1757
|
+
schema: definition.fields,
|
|
1758
|
+
updates: intent.updates ?? {},
|
|
1759
|
+
cwd: context.cwd,
|
|
1760
|
+
});
|
|
1227
1761
|
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1762
|
+
const impact = intent.kind === 'configSave' && !intent.retryApply
|
|
1763
|
+
? await analyzePluginConfigMutationImpact({
|
|
1764
|
+
plugin,
|
|
1765
|
+
referencePlugins,
|
|
1766
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1767
|
+
cwd: context.cwd,
|
|
1768
|
+
env: context.env,
|
|
1769
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets),
|
|
1770
|
+
mutation: {
|
|
1771
|
+
kind: 'patch',
|
|
1772
|
+
updates: intent.updates,
|
|
1773
|
+
removeKeys: intent.removeKeys,
|
|
1774
|
+
},
|
|
1775
|
+
})
|
|
1776
|
+
: undefined;
|
|
1777
|
+
const affectedTargets = intent.kind === 'configSave'
|
|
1778
|
+
? intent.retryApply ? configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets) : impact.affectedTargets
|
|
1779
|
+
: [];
|
|
1780
|
+
const commandPackages = impact?.affectedCommandPackages
|
|
1781
|
+
?? (intent.kind === 'configSave' ? (await discoverPluginConfigManagedCommandPackages({
|
|
1782
|
+
plugin, scope: intent.context ?? 'user', cwd: context.cwd, env: context.env ?? process.env,
|
|
1783
|
+
platformTargets: configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets),
|
|
1784
|
+
referencePlugins,
|
|
1785
|
+
})).packages : []);
|
|
1786
|
+
const preApplyAuthorization = intent.kind === 'configSave'
|
|
1787
|
+
&& configIntentRequestsApply(intent)
|
|
1788
|
+
? (await resolveConfigPreApplyAuthorization({
|
|
1789
|
+
plugin,
|
|
1790
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1791
|
+
cwd: context.cwd,
|
|
1792
|
+
env: context.env,
|
|
1793
|
+
applyTargets: intent.retryApply
|
|
1794
|
+
? configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets)
|
|
1795
|
+
: impact.affectedTargets,
|
|
1796
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
1797
|
+
rebuildRuntime: {
|
|
1798
|
+
referencePlugins,
|
|
1799
|
+
...(catalogOperation ? { catalogOperationContext: catalogOperation } : {}),
|
|
1800
|
+
...(catalogOperation?.generationSetDigest
|
|
1801
|
+
? { expectedGenerationSetDigest: catalogOperation.generationSetDigest }
|
|
1802
|
+
: {}),
|
|
1803
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1804
|
+
},
|
|
1805
|
+
})).targets
|
|
1806
|
+
: [];
|
|
1807
|
+
const commandReview = intent.kind === 'configSave' && configIntentRequestsApply(intent) ? await reviewConfigMutationApply({
|
|
1808
|
+
plugin, scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1809
|
+
cwd: context.cwd, env: context.env, cliVersion: packageInfo.version, nativeCliRunner: context.nativeCliRunner,
|
|
1810
|
+
applyTargets: affectedTargets, applyCommandPackages: commandPackages.map(({ packageId }) => packageId),
|
|
1811
|
+
mutation: { kind: 'patch', updates: intent.updates, removeKeys: intent.removeKeys },
|
|
1812
|
+
rebuildRuntime: { ...context, signal, referencePlugins, catalogOperationContext: catalogOperation,
|
|
1813
|
+
expectedGenerationSetDigest: catalogOperation?.generationSetDigest,
|
|
1814
|
+
scriptTimeoutMs: reviewedScriptTimeoutMs(intent), inventoryCatalogSourceReferences: operationInventory },
|
|
1815
|
+
}, reviewedEvidence?.config, freshCatalog) : {};
|
|
1816
|
+
return {
|
|
1817
|
+
pluginName: plugin.manifest.name,
|
|
1818
|
+
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
1819
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, intent.platform),
|
|
1820
|
+
impact,
|
|
1821
|
+
commandPackages,
|
|
1822
|
+
commandReview,
|
|
1823
|
+
preApplyAuthorization,
|
|
1824
|
+
retryStoreDigest: intent.kind === 'configSave' && intent.retryApply
|
|
1825
|
+
? await configRetryStoreDigest({ plugin, scope: intent.context ?? 'user', platform: intent.platform, targets: affectedTargets,
|
|
1826
|
+
commandPackages, preApplyAuthorization, cwd: context.cwd, env: context.env, plugins: referencePlugins }) : undefined,
|
|
1827
|
+
sharedNativeRenderUnits: intent.kind === 'configSave'
|
|
1828
|
+
? intent.retryApply
|
|
1829
|
+
? await configRetrySharedNativeRenderUnits(plugin, configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets), context.env, referencePlugins)
|
|
1830
|
+
: impact.sharedNativeRenderUnits
|
|
1831
|
+
: [],
|
|
1243
1832
|
};
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1833
|
+
},
|
|
1834
|
+
});
|
|
1246
1835
|
await preparation?.reporter.emit('evidence');
|
|
1247
1836
|
signal?.throwIfAborted();
|
|
1248
|
-
const evidenceTargets =
|
|
1249
|
-
? configAffectedStatusTargets(status.payload.targets, intent.pluginId, intent.scope)
|
|
1250
|
-
: status.payload.targets;
|
|
1251
|
-
const evidenceRevisions = intent.kind === 'configSave'
|
|
1252
|
-
? (status.targetRevisions ?? []).filter((revision) => evidenceTargets.some((target) => target.platform === revision.platform
|
|
1253
|
-
&& target.scope === revision.scope
|
|
1254
|
-
&& target.pluginId === revision.pluginId))
|
|
1255
|
-
: (status.targetRevisions ?? []);
|
|
1837
|
+
const evidenceTargets = configVisibleTargets;
|
|
1256
1838
|
const evidence = {
|
|
1257
1839
|
catalog: {
|
|
1258
|
-
configDigest:
|
|
1259
|
-
compositeDigest:
|
|
1840
|
+
configDigest: configSnapshot.digest,
|
|
1841
|
+
compositeDigest: catalogOperation.catalog.compositeDigest,
|
|
1260
1842
|
...(catalogOperation
|
|
1261
1843
|
? { generationSetDigest: catalogOperation.generationSetDigest }
|
|
1262
1844
|
: {}),
|
|
1263
1845
|
},
|
|
1264
1846
|
source: selected.source,
|
|
1265
|
-
|
|
1266
|
-
...(dependencyPlan ? { dependencyPlan } : {}),
|
|
1267
|
-
...(codexReconcilePlans ? { codexReconcilePlans } : {}),
|
|
1268
|
-
...(operationPlan ? { operationPlan } : {}),
|
|
1269
|
-
...(codexManager ? { codexManager } : {}),
|
|
1270
|
-
targetFingerprint: statusTargetFingerprint(evidenceTargets, evidenceRevisions),
|
|
1847
|
+
targetFingerprint: currentTargetFingerprint(status, evidenceTargets),
|
|
1271
1848
|
};
|
|
1272
1849
|
if (intent.kind === 'configSave') {
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
scope: intent.scope,
|
|
1278
|
-
cwd: context.cwd,
|
|
1279
|
-
env: context.env,
|
|
1280
|
-
});
|
|
1850
|
+
const impact = 'impact' in selected ? selected.impact : undefined;
|
|
1851
|
+
const storeDigest = impact?.storeDigest ?? ('retryStoreDigest' in selected ? selected.retryStoreDigest : undefined);
|
|
1852
|
+
if (!storeDigest)
|
|
1853
|
+
throw operationReviewStale('设置操作缺少实际配置输入证据。');
|
|
1281
1854
|
signal?.throwIfAborted();
|
|
1282
1855
|
evidence.config = {
|
|
1283
|
-
scope: intent.
|
|
1284
|
-
|
|
1285
|
-
|
|
1856
|
+
scope: 'user', context: intent.context ?? 'user', platform: intent.platform,
|
|
1857
|
+
schemaIdentity: selected.schemaIdentity,
|
|
1858
|
+
storeDigest,
|
|
1859
|
+
impactState: impact?.impactState ?? 'known',
|
|
1860
|
+
...(impact?.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
1861
|
+
...('commandPackages' in selected && selected.commandPackages.length
|
|
1862
|
+
? { commandPackages: selected.commandPackages } : {}),
|
|
1863
|
+
...('commandReview' in selected ? selected.commandReview : {}),
|
|
1864
|
+
affectedTargets: (impact?.affectedTargets
|
|
1865
|
+
?? evidenceTargets).map(({ pluginName, platform, scope }) => ({ pluginName, platform, scope })),
|
|
1866
|
+
...('sharedNativeRenderUnits' in selected
|
|
1867
|
+
&& selected.sharedNativeRenderUnits.length > 0
|
|
1868
|
+
? { sharedNativeRenderUnits: selected.sharedNativeRenderUnits }
|
|
1286
1869
|
: {}),
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
&& selected.sharedNativeRenderTargets.length > 0
|
|
1291
|
-
? { sharedNativeRenderTargets: selected.sharedNativeRenderTargets }
|
|
1870
|
+
...('preApplyAuthorization' in selected
|
|
1871
|
+
&& selected.preApplyAuthorization.length > 0
|
|
1872
|
+
? { preApplyAuthorization: selected.preApplyAuthorization }
|
|
1292
1873
|
: {}),
|
|
1293
1874
|
};
|
|
1294
1875
|
}
|
|
1876
|
+
await assertConfigEditEvidence(intent, evidence);
|
|
1295
1877
|
if (catalogOperation)
|
|
1296
1878
|
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
1297
1879
|
return evidence;
|
|
1298
1880
|
};
|
|
1299
1881
|
const dependencies = {
|
|
1882
|
+
readAgentSettings: () => readAgentSettings(context),
|
|
1883
|
+
previewAgentSettings: (preferences, pluginId) => previewAgentSettings(context, preferences, pluginId),
|
|
1884
|
+
saveAgentSettings: (request) => saveAgentSettings(context, request),
|
|
1300
1885
|
beginCatalogSession(sessionOptions) {
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1886
|
+
latestStatusRead += 1;
|
|
1887
|
+
bindNewCatalog = true;
|
|
1888
|
+
validatedStoreEntries = sessionOptions?.reuseValidatedGenerations === true
|
|
1889
|
+
? new Map(validatedStoreEntries) : new Map();
|
|
1890
|
+
validatingStoreEntries = new Map();
|
|
1306
1891
|
},
|
|
1307
1892
|
loadStatus,
|
|
1893
|
+
async loadScopedStatus(scope, signal) {
|
|
1894
|
+
signal.throwIfAborted();
|
|
1895
|
+
const read = latestStatusRead;
|
|
1896
|
+
const pinnedContext = sessionCatalogOperationContext;
|
|
1897
|
+
const catalogView = sessionStatusResult;
|
|
1898
|
+
const storeEntries = { validatedStoreEntries, validatingStoreEntries };
|
|
1899
|
+
const packageInfo = await readCliPackageInfo();
|
|
1900
|
+
const currentCatalog = await resolvePartialCatalogOperationContext({
|
|
1901
|
+
env: context.env, signal, ...storeEntries,
|
|
1902
|
+
});
|
|
1903
|
+
signal.throwIfAborted();
|
|
1904
|
+
if (pinnedContext && currentCatalog.generationSetDigest !== pinnedContext.generationSetDigest) {
|
|
1905
|
+
throw new TuiOperationBlockedError('catalogSessionReloadRequired', 'Catalog 已变化。请按 H 重新加载,再检查清单。');
|
|
1906
|
+
}
|
|
1907
|
+
const catalogOperationContext = pinnedContext ?? currentCatalog;
|
|
1908
|
+
const snapshot = await readJointDemand({ scope, cwd: context.cwd, env: context.env, signal, catalogOperationContext });
|
|
1909
|
+
const status = await readRecoveryStatus({ scope, cwd: context.cwd, env: context.env, cliVersion: packageInfo.version,
|
|
1910
|
+
nativeCliRunner: context.nativeCliRunner, catalogOperationContext, signal }, snapshot);
|
|
1911
|
+
signal.throwIfAborted();
|
|
1912
|
+
const source = catalogView ?? await loadCatalogView({ context, cliVersion: packageInfo.version, signal, catalogOperationContext });
|
|
1913
|
+
const dependencyOverviews = await loadDependencyOverviews({ context, cliVersion: packageInfo.version, status,
|
|
1914
|
+
pluginSummaries: source.pluginSummaries, signal, catalogOperationContext });
|
|
1915
|
+
const recovery = scopedCurrentStatus(status, snapshot, scope);
|
|
1916
|
+
const retirementSourceChecks = await checkRetirementSources(catalogOperationContext, inventoryPluginIds(recovery), signal);
|
|
1917
|
+
signal.throwIfAborted();
|
|
1918
|
+
if (read === latestStatusRead)
|
|
1919
|
+
sessionRecoveryStatus = status;
|
|
1920
|
+
return { ...recovery, dependencyOverviews, retirementSourceChecks };
|
|
1921
|
+
},
|
|
1922
|
+
async prepareScopedTask(request, signal) {
|
|
1923
|
+
signal.throwIfAborted();
|
|
1924
|
+
if (request.kind === 'targets') {
|
|
1925
|
+
return prepareTargetsPlan({ scope: request.scope, cwd: context.cwd, env: context.env }, request.action, request.agents);
|
|
1926
|
+
}
|
|
1927
|
+
if (request.kind === 'intent') {
|
|
1928
|
+
return prepareIntentPlan({ scope: request.scope, cwd: context.cwd, env: context.env }, request.action, request.selector);
|
|
1929
|
+
}
|
|
1930
|
+
if (request.kind === 'retire') {
|
|
1931
|
+
const packageInfo = await readCliPackageInfo();
|
|
1932
|
+
signal.throwIfAborted();
|
|
1933
|
+
const plan = await prepareRetire({ scope: request.scope, cwd: context.cwd, env: context.env,
|
|
1934
|
+
signal,
|
|
1935
|
+
selector: request.selector, cliVersion: packageInfo.version,
|
|
1936
|
+
...(request.targets ? { targets: request.targets } : {}),
|
|
1937
|
+
deleteConfig: request.deleteConfig === true,
|
|
1938
|
+
}, context);
|
|
1939
|
+
if (signal.aborted) {
|
|
1940
|
+
await plan.context.dispose();
|
|
1941
|
+
signal.throwIfAborted();
|
|
1942
|
+
}
|
|
1943
|
+
return { kind: 'retire', scope: request.scope, plan };
|
|
1944
|
+
}
|
|
1945
|
+
const packageInfo = await readCliPackageInfo();
|
|
1946
|
+
signal.throwIfAborted();
|
|
1947
|
+
const pinned = sessionCatalogOperationContext;
|
|
1948
|
+
const plan = await prepareRecovery(request.command ?? 'sync', request.selectors, {
|
|
1949
|
+
signal,
|
|
1950
|
+
scope: request.scope, cwd: context.cwd, env: context.env,
|
|
1951
|
+
cliVersion: packageInfo.version,
|
|
1952
|
+
all: request.selectors.length === 0,
|
|
1953
|
+
...(request.allowDependencySelectors ? { allowDependencySelectors: true } : {}),
|
|
1954
|
+
...(request.targets ? { targets: request.targets } : {}),
|
|
1955
|
+
...(request.force ? { force: true } : {}),
|
|
1956
|
+
...(request.refresh ? { refresh: true } : {}),
|
|
1957
|
+
...(request.command === 'install' && !request.refresh && pinned ? {
|
|
1958
|
+
checkInstallCatalog(current, roots) {
|
|
1959
|
+
for (const sourceId of new Set(roots.map((id) => parsePluginId(id).sourceId))) {
|
|
1960
|
+
if (!sourceId)
|
|
1961
|
+
continue;
|
|
1962
|
+
if (installSourceBinding(pinned, sourceId) !== installSourceBinding(current, sourceId)
|
|
1963
|
+
|| (pinned.generationSet.primarySourceId === sourceId) !== (current?.generationSet.primarySourceId === sourceId)) {
|
|
1964
|
+
throw new TuiOperationBlockedError('catalogSessionReloadRequired', recoveryReason('catalogSessionReloadRequired'));
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
},
|
|
1968
|
+
} : {}),
|
|
1969
|
+
...(request.retireUnselectedTargets ? { retireUnselectedTargets: true } : {}),
|
|
1970
|
+
...(request.scriptTimeoutMs !== undefined ? { scriptTimeoutMs: request.scriptTimeoutMs } : {}),
|
|
1971
|
+
...(request.dependencyScopeOverrides?.length
|
|
1972
|
+
? { dependencyScopeOverrides: request.dependencyScopeOverrides } : {}),
|
|
1973
|
+
...(request.exactTargets ? { exactTargets: request.exactTargets } : {}),
|
|
1974
|
+
...(request.saveDependencyScopeOverrides ? { saveDependencyScopeOverrides: true } : {}),
|
|
1975
|
+
}, context);
|
|
1976
|
+
if (signal.aborted) {
|
|
1977
|
+
await plan.context.dispose();
|
|
1978
|
+
signal.throwIfAborted();
|
|
1979
|
+
}
|
|
1980
|
+
return { kind: 'recovery', scope: request.scope, plan };
|
|
1981
|
+
},
|
|
1982
|
+
async executeScopedTask(plan) {
|
|
1983
|
+
if (plan.kind === 'targets') {
|
|
1984
|
+
const result = await executeTargetsPlan({ scope: plan.scope, cwd: context.cwd, env: context.env }, plan);
|
|
1985
|
+
return { kind: 'targets', ...result };
|
|
1986
|
+
}
|
|
1987
|
+
if (plan.kind === 'intent') {
|
|
1988
|
+
const receipt = await executeIntentPlan({ scope: plan.scope, cwd: context.cwd, env: context.env }, plan);
|
|
1989
|
+
return { kind: 'recovery', receipt };
|
|
1990
|
+
}
|
|
1991
|
+
if (plan.kind === 'retire') {
|
|
1992
|
+
const receipt = await executeRetire(plan.plan, { yes: true, runtime: context });
|
|
1993
|
+
return { kind: 'recovery', receipt };
|
|
1994
|
+
}
|
|
1995
|
+
if ((plan.plan.sourceRefreshes?.length ?? 0) > 0) {
|
|
1996
|
+
const refreshed = await activateRecoverySourcesAndReprepare(plan.plan, { runtime: context });
|
|
1997
|
+
return { kind: 'recoveryReview', plan: { kind: 'recovery', scope: plan.scope, plan: refreshed } };
|
|
1998
|
+
}
|
|
1999
|
+
const receipt = await executeRecovery(plan.plan, {
|
|
2000
|
+
yes: true,
|
|
2001
|
+
runtime: progressFeed ? { ...context, onInstallProgress: progressFeed.setInstallProgress } : context,
|
|
2002
|
+
}).catch((error) => {
|
|
2003
|
+
if (!(error instanceof RecoveryInterruptedError))
|
|
2004
|
+
throw error;
|
|
2005
|
+
if (context.interruption && error.code === 'processCleanupUnconfirmed')
|
|
2006
|
+
context.interruption.cleanupFailed = true;
|
|
2007
|
+
return error.receipt;
|
|
2008
|
+
});
|
|
2009
|
+
return { kind: 'recovery', receipt };
|
|
2010
|
+
},
|
|
2011
|
+
loadPluginContent,
|
|
1308
2012
|
async probeCatalogFreshness(sourceId, freshnessOptions, signal) {
|
|
1309
2013
|
signal.throwIfAborted();
|
|
2014
|
+
const storeEntries = { validatedStoreEntries, validatingStoreEntries };
|
|
1310
2015
|
const packageInfo = await readCliPackageInfo();
|
|
1311
2016
|
return probeCatalogSourceFreshness({
|
|
1312
2017
|
sourceId,
|
|
@@ -1316,8 +2021,7 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1316
2021
|
fullValidation: freshnessOptions.fullValidation,
|
|
1317
2022
|
runtime: {
|
|
1318
2023
|
...options.catalogGenerationRuntime,
|
|
1319
|
-
|
|
1320
|
-
validatingStoreEntries,
|
|
2024
|
+
...storeEntries,
|
|
1321
2025
|
},
|
|
1322
2026
|
});
|
|
1323
2027
|
},
|
|
@@ -1352,41 +2056,42 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1352
2056
|
now: options.now ?? Date.now,
|
|
1353
2057
|
});
|
|
1354
2058
|
try {
|
|
1355
|
-
|
|
1356
|
-
if (intent.kind === 'pluginWrite' && intent.action === 'refreshAndSync') {
|
|
1357
|
-
await reporter.emit('refresh');
|
|
1358
|
-
const packageInfo = await readCliPackageInfo();
|
|
1359
|
-
const sourceId = parsePluginId(intent.pluginId).sourceId;
|
|
1360
|
-
await syncCatalogSourceGeneration({
|
|
1361
|
-
sourceId,
|
|
1362
|
-
cliVersion: packageInfo.version,
|
|
1363
|
-
cwd: context.cwd,
|
|
1364
|
-
env: context.env,
|
|
1365
|
-
signal,
|
|
1366
|
-
}).catch((error) => {
|
|
1367
|
-
preparationWarnings.push(`catalogSourceRefreshFailed: ${sourceId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1368
|
-
});
|
|
1369
|
-
sessionCatalogOperationContext = undefined;
|
|
1370
|
-
sessionStatusResult = undefined;
|
|
1371
|
-
validatedStoreEntries.clear();
|
|
1372
|
-
validatingStoreEntries.clear();
|
|
1373
|
-
}
|
|
1374
|
-
const evidence = await captureEvidence(intent, signal, {
|
|
2059
|
+
return await captureEvidence(intent, signal, {
|
|
1375
2060
|
reporter,
|
|
1376
2061
|
validateIntent: true,
|
|
1377
|
-
}, createOperationInventoryReader(),
|
|
1378
|
-
&& intent.action === 'refreshAndSync', reusableCandidate);
|
|
1379
|
-
if (preparationWarnings.length > 0)
|
|
1380
|
-
evidence.preparationWarnings = preparationWarnings;
|
|
1381
|
-
return evidence;
|
|
2062
|
+
}, createOperationInventoryReader(), false, reusableCandidate);
|
|
1382
2063
|
}
|
|
1383
2064
|
finally {
|
|
1384
2065
|
await reporter.finish();
|
|
1385
2066
|
}
|
|
1386
2067
|
},
|
|
1387
2068
|
async previewDependencyPlacement(intent, signal) {
|
|
1388
|
-
const
|
|
1389
|
-
|
|
2069
|
+
const targets = intent.platform === 'both' ? ['codex', 'claude']
|
|
2070
|
+
: [intent.platform === 'claude' ? 'claude' : 'codex'];
|
|
2071
|
+
const prepared = await dependencies.prepareScopedTask({
|
|
2072
|
+
kind: 'recovery', command: 'install', scope: intent.scope,
|
|
2073
|
+
selectors: [intent.pluginId], targets: [...targets],
|
|
2074
|
+
dependencyScopeOverrides: intent.dependencyScopeOverrides,
|
|
2075
|
+
}, signal);
|
|
2076
|
+
if (prepared.kind !== 'recovery')
|
|
2077
|
+
throw new Error('dependencyPlacementUnavailable');
|
|
2078
|
+
try {
|
|
2079
|
+
const plans = prepared.plan.nativeGroups.flatMap((group) => group.preview.dependencyPlan ? [group.preview.dependencyPlan] : []);
|
|
2080
|
+
if (plans.length === 0) {
|
|
2081
|
+
throw new Error(prepared.plan.receipt.blockers[0]?.code
|
|
2082
|
+
?? prepared.plan.receipt.targetResults[0]?.blockers[0]?.code ?? 'dependencyPlacementUnavailable');
|
|
2083
|
+
}
|
|
2084
|
+
return {
|
|
2085
|
+
requestedPluginIds: [...new Set(plans.flatMap((plan) => plan.requestedPluginIds))],
|
|
2086
|
+
resolvedPluginIds: [...new Set(plans.flatMap((plan) => plan.resolvedPluginIds))],
|
|
2087
|
+
dependencyEdges: plans.flatMap((plan) => plan.dependencyEdges),
|
|
2088
|
+
scopeOverrides: plans.flatMap((plan) => plan.scopeOverrides),
|
|
2089
|
+
targets: plans.flatMap((plan) => plan.targets),
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
finally {
|
|
2093
|
+
await prepared.plan.context.dispose();
|
|
2094
|
+
}
|
|
1390
2095
|
},
|
|
1391
2096
|
async validateIntent(intent, signal) {
|
|
1392
2097
|
if (intent.kind === 'catalogSourcesRecovery') {
|
|
@@ -1404,6 +2109,13 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1404
2109
|
}
|
|
1405
2110
|
return;
|
|
1406
2111
|
}
|
|
2112
|
+
if (intent.kind === 'configSaveBatch') {
|
|
2113
|
+
assertConfigSaveBatchIntent(intent);
|
|
2114
|
+
for (const group of intent.groups) {
|
|
2115
|
+
await dependencies.validateIntent(configSaveBatchGroupIntent(intent, group), signal);
|
|
2116
|
+
}
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
1407
2119
|
if (intent.kind === 'configSave') {
|
|
1408
2120
|
const packageInfo = await readCliPackageInfo();
|
|
1409
2121
|
await withResolvedCatalogPlugin({
|
|
@@ -1418,16 +2130,12 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1418
2130
|
if (!plugin.manifest.config) {
|
|
1419
2131
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1420
2132
|
}
|
|
2133
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, intent.platform);
|
|
1421
2134
|
await coercePluginConfigUpdates({
|
|
1422
|
-
schema:
|
|
2135
|
+
schema: definition.fields,
|
|
1423
2136
|
updates: intent.updates ?? {},
|
|
1424
2137
|
cwd: context.cwd,
|
|
1425
2138
|
});
|
|
1426
|
-
for (const key of intent.removeKeys ?? []) {
|
|
1427
|
-
if (!plugin.manifest.config.fields[key]) {
|
|
1428
|
-
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
2139
|
},
|
|
1432
2140
|
});
|
|
1433
2141
|
return;
|
|
@@ -1441,6 +2149,18 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1441
2149
|
}
|
|
1442
2150
|
},
|
|
1443
2151
|
captureEvidence,
|
|
2152
|
+
inspectCatalogStore(signal) {
|
|
2153
|
+
signal.throwIfAborted();
|
|
2154
|
+
return inspectCatalogStoreTask({ env: context.env });
|
|
2155
|
+
},
|
|
2156
|
+
recheckPortableInstall(receipt, signal) {
|
|
2157
|
+
return recheckPortableInstall({
|
|
2158
|
+
receipt,
|
|
2159
|
+
cwd: context.cwd,
|
|
2160
|
+
env: context.env,
|
|
2161
|
+
signal,
|
|
2162
|
+
});
|
|
2163
|
+
},
|
|
1444
2164
|
logError(_error, code, logContext) {
|
|
1445
2165
|
return context.debugLogger.log({
|
|
1446
2166
|
type: 'tui:controller-error',
|
|
@@ -1452,39 +2172,12 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1452
2172
|
data: { code },
|
|
1453
2173
|
});
|
|
1454
2174
|
},
|
|
1455
|
-
async getConfigGroups(pluginId,
|
|
1456
|
-
|
|
1457
|
-
return withResolvedCatalogPlugin({
|
|
1458
|
-
selector: pluginId,
|
|
1459
|
-
cliVersion: packageInfo.version,
|
|
1460
|
-
env: context.env,
|
|
1461
|
-
signal,
|
|
1462
|
-
...(sessionContextForPlugin(pluginId)
|
|
1463
|
-
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
1464
|
-
: {}),
|
|
1465
|
-
consume: async ({ plugin }) => {
|
|
1466
|
-
if (!plugin.manifest.config) {
|
|
1467
|
-
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1468
|
-
}
|
|
1469
|
-
const read = await resolveConfigRead({
|
|
1470
|
-
pluginName: plugin.manifest.name,
|
|
1471
|
-
plugin,
|
|
1472
|
-
scope: layer.scope,
|
|
1473
|
-
cwd: context.cwd,
|
|
1474
|
-
env: context.env,
|
|
1475
|
-
});
|
|
1476
|
-
const effectiveRead = await resolveConfigRead({
|
|
1477
|
-
pluginName: plugin.manifest.name,
|
|
1478
|
-
plugin,
|
|
1479
|
-
scope: 'effective',
|
|
1480
|
-
cwd: context.cwd,
|
|
1481
|
-
env: context.env,
|
|
1482
|
-
});
|
|
1483
|
-
return buildConfigGroups({ schema: plugin.manifest.config, read, effectiveRead });
|
|
1484
|
-
},
|
|
1485
|
-
});
|
|
2175
|
+
async getConfigGroups(pluginId, config, signal) {
|
|
2176
|
+
return (await dependencies.getConfigPage(pluginId, config, signal)).groups;
|
|
1486
2177
|
},
|
|
1487
|
-
async getConfigPage(pluginId,
|
|
2178
|
+
async getConfigPage(pluginId, config, signal) {
|
|
2179
|
+
if (config.context === 'project')
|
|
2180
|
+
await resolveWorkContext({ cwd: context.cwd, context: 'project' });
|
|
1488
2181
|
const packageInfo = await readCliPackageInfo();
|
|
1489
2182
|
return withResolvedCatalogPlugin({
|
|
1490
2183
|
selector: pluginId,
|
|
@@ -1494,84 +2187,175 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1494
2187
|
...(sessionContextForPlugin(pluginId)
|
|
1495
2188
|
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
1496
2189
|
: {}),
|
|
1497
|
-
consume: async ({ plugin }) => {
|
|
2190
|
+
consume: async ({ plugin, source }) => {
|
|
1498
2191
|
if (!plugin.manifest.config) {
|
|
1499
2192
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
1500
2193
|
}
|
|
2194
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, config.platform);
|
|
1501
2195
|
const stores = await readConfigStoresForTui({
|
|
1502
2196
|
sourceId: plugin.sourceId,
|
|
1503
2197
|
sourceIdentity: plugin.sourceIdentity,
|
|
2198
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
1504
2199
|
pluginName: plugin.manifest.name,
|
|
1505
|
-
schema:
|
|
1506
|
-
|
|
2200
|
+
schema: definition.fields,
|
|
2201
|
+
platform: config.platform,
|
|
1507
2202
|
signal,
|
|
1508
2203
|
});
|
|
1509
2204
|
const userStore = stores.user;
|
|
1510
|
-
const
|
|
2205
|
+
const preferences = await observePreferences({ scope: 'user', cwd: context.cwd, env: context.env });
|
|
2206
|
+
const configurableLayers = resolveConfigurableLayers(pluginId, plugin.manifest, preferences);
|
|
2207
|
+
const residualLayers = classifyResidualConfigLayers(userStore, configurableLayers).map(({ layer }) => {
|
|
2208
|
+
const fields = selectPluginConfigProfile(plugin.manifest.config, layer === 'common' ? undefined : layer).fields;
|
|
2209
|
+
const stored = layer === 'common' ? userStore.common : userStore.platforms?.[layer];
|
|
2210
|
+
return { profile: layer, keys: Object.keys(stored ?? {}).sort().map((key) => {
|
|
2211
|
+
const field = Object.hasOwn(fields, key) ? fields[key] : undefined;
|
|
2212
|
+
return field && !field.sensitive && !configObjectHasSensitiveChild(field) ? key : '[redacted]';
|
|
2213
|
+
}) };
|
|
2214
|
+
});
|
|
1511
2215
|
const read = await resolveConfigRead({
|
|
1512
2216
|
pluginName: plugin.manifest.name,
|
|
1513
2217
|
plugin,
|
|
1514
|
-
scope:
|
|
2218
|
+
scope: config.view === 'effective' ? 'effective' : 'user',
|
|
2219
|
+
platform: config.platform,
|
|
2220
|
+
context: config.context ?? 'user',
|
|
1515
2221
|
cwd: context.cwd,
|
|
1516
2222
|
env: context.env,
|
|
1517
2223
|
});
|
|
1518
|
-
const effectiveRead =
|
|
2224
|
+
const effectiveRead = config.view === 'effective' ? read : await resolveConfigRead({
|
|
1519
2225
|
pluginName: plugin.manifest.name,
|
|
1520
2226
|
plugin,
|
|
1521
2227
|
scope: 'effective',
|
|
2228
|
+
platform: config.platform,
|
|
2229
|
+
context: config.context ?? 'user',
|
|
1522
2230
|
cwd: context.cwd,
|
|
1523
2231
|
env: context.env,
|
|
1524
2232
|
});
|
|
1525
|
-
const layerReads = layer.scope === 'effective' ? undefined : {
|
|
1526
|
-
user: layer.scope === 'user' ? read : await resolveConfigRead({
|
|
1527
|
-
pluginName: plugin.manifest.name,
|
|
1528
|
-
plugin,
|
|
1529
|
-
scope: 'user',
|
|
1530
|
-
cwd: context.cwd,
|
|
1531
|
-
env: context.env,
|
|
1532
|
-
}),
|
|
1533
|
-
...(layer.scope === 'user' ? {} : { project: read }),
|
|
1534
|
-
};
|
|
1535
2233
|
const effectiveRaw = await resolveEffectivePluginConfig({
|
|
1536
2234
|
sourceId: plugin.sourceId,
|
|
1537
2235
|
sourceIdentity: plugin.sourceIdentity,
|
|
2236
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
1538
2237
|
pluginName: plugin.manifest.name,
|
|
1539
2238
|
manifest: plugin.manifest,
|
|
1540
|
-
|
|
2239
|
+
platform: config.platform,
|
|
2240
|
+
context: config.context ?? 'user',
|
|
1541
2241
|
cwd: context.cwd,
|
|
1542
2242
|
env: context.env,
|
|
1543
2243
|
});
|
|
1544
|
-
const
|
|
1545
|
-
? undefined
|
|
1546
|
-
: layer.scope === 'user' ? userStore : projectStore;
|
|
1547
|
-
return buildConfigPage({
|
|
2244
|
+
const page = buildConfigPage({
|
|
1548
2245
|
pluginId,
|
|
1549
|
-
|
|
2246
|
+
context: config.context ?? 'user',
|
|
2247
|
+
schema: definition,
|
|
1550
2248
|
read,
|
|
1551
2249
|
effectiveRead,
|
|
1552
|
-
...(
|
|
1553
|
-
...(layerStore ? { rawValues: layerStore.values } : {}),
|
|
2250
|
+
...(config.view === 'effective' ? {} : { rawValues: userStore.values }),
|
|
1554
2251
|
rawLayerValues: {
|
|
1555
|
-
|
|
1556
|
-
...(
|
|
2252
|
+
common: userStore.common ?? {},
|
|
2253
|
+
...(userStore.platforms ?? {}),
|
|
1557
2254
|
},
|
|
1558
2255
|
effectiveRawValues: effectiveRaw.values,
|
|
1559
|
-
sharedNativeRefreshKeys: new Set(
|
|
1560
|
-
? target.refreshKeys
|
|
1561
|
-
: [])),
|
|
2256
|
+
sharedNativeRefreshKeys: new Set(plugin.manifest.artifacts?.configKeys ?? []),
|
|
1562
2257
|
});
|
|
2258
|
+
return { ...page, configurableLayers, residualLayers, editEvidence: {
|
|
2259
|
+
platform: config.platform,
|
|
2260
|
+
context: config.context ?? 'user',
|
|
2261
|
+
sourceIdentity: source.sourceIdentity,
|
|
2262
|
+
schemaIdentity: configSchemaIdentity(plugin, source.manifestDigest, config.platform),
|
|
2263
|
+
storeDigests: {
|
|
2264
|
+
user: digest({ exists: userStore.exists, rawDigest: userStore.rawDigest }),
|
|
2265
|
+
},
|
|
2266
|
+
} };
|
|
1563
2267
|
},
|
|
1564
2268
|
});
|
|
1565
2269
|
},
|
|
1566
|
-
async
|
|
2270
|
+
async getConfigReferenceContext(pluginId, config, draft, signal) {
|
|
2271
|
+
const workContext = await resolveWorkContext({ cwd: context.cwd, context: config.context ?? 'user' });
|
|
2272
|
+
const packageInfo = await readCliPackageInfo();
|
|
2273
|
+
return withResolvedCatalogPlugin({
|
|
2274
|
+
selector: pluginId, cliVersion: packageInfo.version, env: context.env, signal,
|
|
2275
|
+
...(sessionContextForPlugin(pluginId) ? { operationContext: sessionContextForPlugin(pluginId) } : {}),
|
|
2276
|
+
consume: async ({ plugin }) => {
|
|
2277
|
+
if (!plugin.manifest.config)
|
|
2278
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
2279
|
+
const definition = selectPluginConfigProfile(plugin.manifest.config, config.platform);
|
|
2280
|
+
const scalars = Object.values(definition.fields).flatMap(configReferenceScalars);
|
|
2281
|
+
if (!scalars.length)
|
|
2282
|
+
return { platform: config.platform, selections: {} };
|
|
2283
|
+
const stores = await readConfigStoresForTui({
|
|
2284
|
+
sourceId: plugin.sourceId, sourceIdentity: plugin.sourceIdentity,
|
|
2285
|
+
logicalIdentity: plugin.catalogLogicalIdentity, pluginName: plugin.manifest.name,
|
|
2286
|
+
schema: definition.fields, platform: config.platform, signal,
|
|
2287
|
+
});
|
|
2288
|
+
const edited = stores.user;
|
|
2289
|
+
const values = { ...edited.values };
|
|
2290
|
+
for (const key of draft.removes)
|
|
2291
|
+
delete values[key];
|
|
2292
|
+
Object.assign(values, draft.updates);
|
|
2293
|
+
const candidateStores = { user: replacePluginConfigStoreLayer(edited, values, config.platform) };
|
|
2294
|
+
const references = await resolvePluginConfigReferenceContext({
|
|
2295
|
+
sourceId: plugin.sourceId, sourceIdentity: plugin.sourceIdentity,
|
|
2296
|
+
logicalIdentity: plugin.catalogLogicalIdentity, manifest: plugin.manifest,
|
|
2297
|
+
scope: 'user', context: config.context ?? 'user', platform: config.platform, cwd: context.cwd, env: context.env,
|
|
2298
|
+
});
|
|
2299
|
+
const effective = await resolveEffectivePluginConfigFromStores({
|
|
2300
|
+
manifest: plugin.manifest, context: config.context ?? 'user', platform: config.platform,
|
|
2301
|
+
projectRoot: workContext.projectRoot ?? '', stores: candidateStores,
|
|
2302
|
+
referenceContext: references.context,
|
|
2303
|
+
});
|
|
2304
|
+
// Keep invalid raw sources for Core validation; effective.values omits them.
|
|
2305
|
+
// Preserve active branches in other references that reserve source values.
|
|
2306
|
+
// Only source choices and entry digests leave this boundary.
|
|
2307
|
+
const candidate = {};
|
|
2308
|
+
for (const key of Object.keys(definition.fields)) {
|
|
2309
|
+
const source = effective.sources[key];
|
|
2310
|
+
if (source === 'default')
|
|
2311
|
+
candidate[key] = definition.fields[key].default;
|
|
2312
|
+
else if (source === 'common')
|
|
2313
|
+
candidate[key] = candidateStores.user.common?.[key];
|
|
2314
|
+
else if (source === 'platform' && config.platform)
|
|
2315
|
+
candidate[key] = candidateStores.user.platforms?.[config.platform]?.[key];
|
|
2316
|
+
}
|
|
2317
|
+
const result = { platform: config.platform, selections: {} };
|
|
2318
|
+
for (const scalar of scalars) {
|
|
2319
|
+
const ref = scalar.valueRef;
|
|
2320
|
+
const selection = getPluginConfigReferenceChoices(definition, scalar, candidate, references.context);
|
|
2321
|
+
const entries = ref.plugin ? references.context.plugins[ref.plugin]?.values?.[ref.field] : candidate[ref.field];
|
|
2322
|
+
result.selections[configReferenceKey(scalar, config.platform)] = {
|
|
2323
|
+
...selection, source: (ref.plugin
|
|
2324
|
+
? references.evidence.find((entry) => entry.plugin === ref.plugin)?.sources[ref.field]
|
|
2325
|
+
: effective.sources[ref.field]) ?? 'missing',
|
|
2326
|
+
entries: Array.isArray(entries) ? Object.fromEntries(entries.flatMap((entry) => entry && typeof entry === 'object' && Object.hasOwn(entry, ref.key)
|
|
2327
|
+
? [[JSON.stringify(entry[ref.key]), digest(entry)]] : [])) : {},
|
|
2328
|
+
};
|
|
2329
|
+
}
|
|
2330
|
+
return result;
|
|
2331
|
+
},
|
|
2332
|
+
});
|
|
2333
|
+
},
|
|
2334
|
+
async getConfigSuggestions(lookup, run, signal) {
|
|
2335
|
+
const { pluginId, options: config, ...request } = lookup;
|
|
2336
|
+
const packageInfo = await readCliPackageInfo();
|
|
2337
|
+
const operationContext = sessionContextForPlugin(pluginId);
|
|
2338
|
+
return withResolvedCatalogPlugin({
|
|
2339
|
+
selector: pluginId, cliVersion: packageInfo.version, env: context.env, signal,
|
|
2340
|
+
...(operationContext ? { operationContext } : {}),
|
|
2341
|
+
consume: async ({ plugin }) => run(await preparePluginConfigSuggestions({
|
|
2342
|
+
plugin, platform: config.platform, context: config.context ?? 'user',
|
|
2343
|
+
cwd: context.cwd, env: context.env, signal, ...request,
|
|
2344
|
+
})),
|
|
2345
|
+
});
|
|
2346
|
+
},
|
|
2347
|
+
async getConfigResetAvailability(pluginId, config, signal) {
|
|
2348
|
+
if (config.context === 'project')
|
|
2349
|
+
await resolveWorkContext({ cwd: context.cwd, context: 'project' });
|
|
1567
2350
|
const parsed = parsePluginId(pluginId);
|
|
1568
2351
|
if (!parsed.sourceId || !parsed.pluginName) {
|
|
1569
2352
|
throw new TuiOperationBlockedError('invalidPluginId', '设置目标必须使用 canonical pluginId。');
|
|
1570
2353
|
}
|
|
1571
2354
|
let sourceIdentity;
|
|
2355
|
+
let logicalIdentity;
|
|
1572
2356
|
try {
|
|
1573
2357
|
const packageInfo = await readCliPackageInfo();
|
|
1574
|
-
|
|
2358
|
+
const source = await withResolvedCatalogPlugin({
|
|
1575
2359
|
selector: pluginId,
|
|
1576
2360
|
cliVersion: packageInfo.version,
|
|
1577
2361
|
env: context.env,
|
|
@@ -1579,17 +2363,23 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1579
2363
|
...(sessionContextForPlugin(pluginId)
|
|
1580
2364
|
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
1581
2365
|
: {}),
|
|
1582
|
-
consume: async ({ source }) =>
|
|
2366
|
+
consume: async ({ source }) => ({
|
|
2367
|
+
sourceIdentity: source.sourceIdentity,
|
|
2368
|
+
logicalIdentity: source.logicalIdentity,
|
|
2369
|
+
}),
|
|
1583
2370
|
});
|
|
2371
|
+
sourceIdentity = source.sourceIdentity;
|
|
2372
|
+
logicalIdentity = source.logicalIdentity;
|
|
1584
2373
|
}
|
|
1585
2374
|
catch {
|
|
1586
2375
|
sourceIdentity = undefined;
|
|
2376
|
+
logicalIdentity = undefined;
|
|
1587
2377
|
}
|
|
1588
2378
|
signal.throwIfAborted();
|
|
1589
2379
|
const target = await inspectPluginConfigResetTarget({
|
|
1590
2380
|
sourceId: parsed.sourceId,
|
|
1591
2381
|
pluginName: parsed.pluginName,
|
|
1592
|
-
scope:
|
|
2382
|
+
scope: 'user',
|
|
1593
2383
|
cwd: context.cwd,
|
|
1594
2384
|
env: context.env,
|
|
1595
2385
|
});
|
|
@@ -1598,8 +2388,10 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1598
2388
|
const store = await readPluginConfigStore({
|
|
1599
2389
|
sourceId: parsed.sourceId,
|
|
1600
2390
|
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
2391
|
+
...(logicalIdentity ? { logicalIdentity } : {}),
|
|
1601
2392
|
pluginName: parsed.pluginName,
|
|
1602
|
-
scope:
|
|
2393
|
+
scope: 'user',
|
|
2394
|
+
platform: config.platform,
|
|
1603
2395
|
cwd: context.cwd,
|
|
1604
2396
|
env: context.env,
|
|
1605
2397
|
});
|
|
@@ -1626,6 +2418,20 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1626
2418
|
};
|
|
1627
2419
|
},
|
|
1628
2420
|
async executeIntent(intent, expectedEvidence, signal) {
|
|
2421
|
+
if (intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch'
|
|
2422
|
+
|| intent.kind === 'pluginWriteTask') {
|
|
2423
|
+
throw new TuiOperationBlockedError('useScopedRecovery', '请使用统一范围恢复任务。');
|
|
2424
|
+
}
|
|
2425
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
2426
|
+
signal?.throwIfAborted();
|
|
2427
|
+
if (!expectedEvidence.catalogStore) {
|
|
2428
|
+
throw new TuiOperationBlockedError('catalogStoreReviewStale', '确认信息缺少精确清理目标。');
|
|
2429
|
+
}
|
|
2430
|
+
return executeCatalogStoreTask({
|
|
2431
|
+
env: context.env,
|
|
2432
|
+
authorizedItems: expectedEvidence.catalogStore.authorizedItems,
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
1629
2435
|
if (intent.kind === 'catalogSourcesRecovery') {
|
|
1630
2436
|
signal?.throwIfAborted();
|
|
1631
2437
|
return recoverInvalidCatalogSourcesConfig({ env: context.env });
|
|
@@ -1645,13 +2451,21 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1645
2451
|
expectedConfigDigest: expected.configDigest,
|
|
1646
2452
|
};
|
|
1647
2453
|
if (intent.sourceMutation.action === 'add') {
|
|
1648
|
-
await addCatalogSourceCommand({
|
|
2454
|
+
await addCatalogSourceCommand({
|
|
2455
|
+
...common,
|
|
2456
|
+
source: intent.sourceMutation.source,
|
|
2457
|
+
expectedProposedConfigDigest: expected.proposedConfigDigest,
|
|
2458
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2459
|
+
requireImpactConfirmation: true,
|
|
2460
|
+
confirmImpact: true,
|
|
2461
|
+
});
|
|
1649
2462
|
}
|
|
1650
2463
|
else {
|
|
1651
2464
|
await updateCatalogSourceCommand({
|
|
1652
2465
|
...common,
|
|
1653
2466
|
sourceId: intent.sourceId,
|
|
1654
2467
|
update: intent.sourceMutation.update,
|
|
2468
|
+
expectedProposedConfigDigest: expected.proposedConfigDigest,
|
|
1655
2469
|
expectedImpactDigest: expected.impactDigest,
|
|
1656
2470
|
requireIdentityChangeConfirmation: true,
|
|
1657
2471
|
confirmIdentityChange: true,
|
|
@@ -1751,6 +2565,10 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1751
2565
|
sourceId: intent.sourceId,
|
|
1752
2566
|
cwd: context.cwd,
|
|
1753
2567
|
env: context.env,
|
|
2568
|
+
expectedConfigDigest: expected.primaryConfigDigest,
|
|
2569
|
+
expectedImpactDigest: expected.primaryImpactDigest,
|
|
2570
|
+
requireImpactConfirmation: true,
|
|
2571
|
+
confirmImpact: true,
|
|
1754
2572
|
});
|
|
1755
2573
|
primaryChanged = true;
|
|
1756
2574
|
}
|
|
@@ -1761,7 +2579,10 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1761
2579
|
configSaved,
|
|
1762
2580
|
generation,
|
|
1763
2581
|
activeAvailable: true,
|
|
1764
|
-
errorCode: error
|
|
2582
|
+
errorCode: typeof error === 'object' && error !== null
|
|
2583
|
+
&& 'code' in error && typeof error.code === 'string'
|
|
2584
|
+
? error.code
|
|
2585
|
+
: error instanceof Error ? error.name : 'catalogSourcePrimaryFailed',
|
|
1765
2586
|
};
|
|
1766
2587
|
}
|
|
1767
2588
|
}
|
|
@@ -1784,6 +2605,25 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1784
2605
|
}
|
|
1785
2606
|
const packageInfo = await readCliPackageInfo();
|
|
1786
2607
|
try {
|
|
2608
|
+
if (intent.retry) {
|
|
2609
|
+
if (!('retryPairs' in expectedEvidence.portable)) {
|
|
2610
|
+
throw operationReviewStale('确认信息缺少 Portable 重试目标。');
|
|
2611
|
+
}
|
|
2612
|
+
return await executePortableRetry({
|
|
2613
|
+
receipt: intent.retry.receipt,
|
|
2614
|
+
review: expectedEvidence.portable,
|
|
2615
|
+
expectedEvidenceDigest: expectedEvidence.portable.evidenceDigest,
|
|
2616
|
+
cwd: context.cwd,
|
|
2617
|
+
env: context.env,
|
|
2618
|
+
cliVersion: packageInfo.version,
|
|
2619
|
+
signal,
|
|
2620
|
+
onProgress(stage) {
|
|
2621
|
+
const phase = stage === 'prepare' ? '重新检查失败目标'
|
|
2622
|
+
: stage === 'add' ? '重试缺失的 Skills' : '验证重试结果';
|
|
2623
|
+
progressFeed?.setCurrent({ target: 'Skills CLI', phase }, `Portable Skills:${phase}`);
|
|
2624
|
+
},
|
|
2625
|
+
});
|
|
2626
|
+
}
|
|
1787
2627
|
return await installPortableSkills({
|
|
1788
2628
|
selector: intent.pluginId,
|
|
1789
2629
|
scope: intent.scope,
|
|
@@ -1827,11 +2667,18 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1827
2667
|
cwd: context.cwd,
|
|
1828
2668
|
env: context.env,
|
|
1829
2669
|
expectedConfigDigest: expectedEvidence.sourceWrite?.configDigest,
|
|
2670
|
+
expectedProposedConfigDigest: expectedEvidence.sourceWrite?.proposedConfigDigest,
|
|
1830
2671
|
expectedImpactDigest: expectedEvidence.sourceWrite?.impactDigest,
|
|
1831
2672
|
runtime,
|
|
1832
2673
|
};
|
|
1833
2674
|
if (intent.action === 'add' && intent.source) {
|
|
1834
|
-
return addCatalogSourceCommand({
|
|
2675
|
+
return addCatalogSourceCommand({
|
|
2676
|
+
...common,
|
|
2677
|
+
source: intent.source,
|
|
2678
|
+
cliVersion: packageInfo.version,
|
|
2679
|
+
requireImpactConfirmation: true,
|
|
2680
|
+
confirmImpact: true,
|
|
2681
|
+
});
|
|
1835
2682
|
}
|
|
1836
2683
|
if (intent.action === 'update' && intent.update) {
|
|
1837
2684
|
return updateCatalogSourceCommand({
|
|
@@ -1844,7 +2691,12 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1844
2691
|
});
|
|
1845
2692
|
}
|
|
1846
2693
|
if (intent.action === 'setPrimary') {
|
|
1847
|
-
return setPrimaryCatalogSourceCommand({
|
|
2694
|
+
return setPrimaryCatalogSourceCommand({
|
|
2695
|
+
...common,
|
|
2696
|
+
sourceId: intent.sourceId,
|
|
2697
|
+
requireImpactConfirmation: true,
|
|
2698
|
+
confirmImpact: true,
|
|
2699
|
+
});
|
|
1848
2700
|
}
|
|
1849
2701
|
if (intent.action === 'remove') {
|
|
1850
2702
|
return removeCatalogSourceCommand({
|
|
@@ -1861,9 +2713,8 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1861
2713
|
action: async (awHomeMutationToken) => {
|
|
1862
2714
|
await tuiControllerRuntimeTestHooks?.beforeMutationEvidenceCapture?.();
|
|
1863
2715
|
const operationInventory = createOperationInventoryReader();
|
|
1864
|
-
const currentEvidence = await captureEvidence(intent, undefined, undefined, operationInventory, true);
|
|
1865
|
-
if (
|
|
1866
|
-
&& !operationEvidenceMatches(expectedEvidence, currentEvidence)) {
|
|
2716
|
+
const currentEvidence = await captureEvidence(intent, undefined, undefined, operationInventory, true, undefined, expectedEvidence);
|
|
2717
|
+
if (!operationEvidenceMatches(expectedEvidence, currentEvidence)) {
|
|
1867
2718
|
throw new TuiOperationBlockedError('operationReviewStale', '确认后状态发生变化。');
|
|
1868
2719
|
}
|
|
1869
2720
|
const catalogOperation = catalogOperationByEvidence.get(currentEvidence);
|
|
@@ -1872,55 +2723,187 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1872
2723
|
throw operationReviewStale('确认后 Active Catalog generation 发生变化。');
|
|
1873
2724
|
}
|
|
1874
2725
|
await tuiControllerRuntimeTestHooks?.afterMutationEvidenceCapture?.();
|
|
1875
|
-
if (intent.kind === '
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
...(intent.action === 'install' && intent.dependencyScopeOverrides
|
|
1881
|
-
? { dependencyScopeOverrides: intent.dependencyScopeOverrides }
|
|
1882
|
-
: {}),
|
|
1883
|
-
...(expectedEvidence.codexManager?.state === 'requires-install'
|
|
1884
|
-
? { allowManagedCodexInstall: true }
|
|
1885
|
-
: {}),
|
|
1886
|
-
...(intent.action === 'cleanup' ? { force: intent.force === true } : {}),
|
|
1887
|
-
};
|
|
1888
|
-
const command = {
|
|
1889
|
-
install: installWriteCommand,
|
|
1890
|
-
refreshAndSync: syncWriteCommand,
|
|
1891
|
-
reinstall: reinstallWriteCommand,
|
|
1892
|
-
uninstall: uninstallWriteCommand,
|
|
1893
|
-
cleanup: cleanupWriteCommand,
|
|
1894
|
-
sync: syncWriteCommand,
|
|
1895
|
-
}[intent.action];
|
|
1896
|
-
const currentSource = currentEvidence.source;
|
|
1897
|
-
const offlineCleanup = currentEvidence.offlineCleanup;
|
|
1898
|
-
if (!offlineCleanup && (!expectedEvidence.source || !currentSource)) {
|
|
1899
|
-
throw new TuiOperationBlockedError('operationReviewStale', '确认信息缺少来源身份。');
|
|
2726
|
+
if (intent.kind === 'configSaveBatch') {
|
|
2727
|
+
assertConfigSaveBatchIntent(intent);
|
|
2728
|
+
const reviewedBatch = expectedEvidence.configBatch;
|
|
2729
|
+
if (!reviewedBatch || !currentEvidence.configBatch || !currentEvidence.source) {
|
|
2730
|
+
throw operationReviewStale('确认信息缺少设置批次证据。');
|
|
1900
2731
|
}
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2732
|
+
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}`)));
|
|
2733
|
+
const approvedCommandPackages = new Set(reviewedBatch.groups.flatMap((group) => (group.config.commandPackages ?? []).map((target) => target.packageId)));
|
|
2734
|
+
const approvedPreApplyTargets = reviewedBatch.groups.flatMap((group) => group.config.preApplyAuthorization ?? []);
|
|
2735
|
+
const results = [];
|
|
2736
|
+
const packageInfo = await readCliPackageInfo();
|
|
2737
|
+
let interrupted = false;
|
|
2738
|
+
for (const group of intent.groups) {
|
|
2739
|
+
if (interrupted) {
|
|
2740
|
+
results.push({
|
|
2741
|
+
scope: 'user', platform: group.platform, status: 'notStarted',
|
|
2742
|
+
configSaved: false, applyRequested: intent.apply, applyStatus: intent.apply ? 'notStarted' : 'notRequested',
|
|
2743
|
+
});
|
|
2744
|
+
continue;
|
|
2745
|
+
}
|
|
2746
|
+
const groupIntent = configSaveBatchGroupIntent(intent, group);
|
|
2747
|
+
const reviewedGroup = reviewedBatch.groups.find((item) => item.platform === group.platform);
|
|
2748
|
+
if (!reviewedGroup) {
|
|
2749
|
+
throw operationReviewStale('确认信息缺少设置层基线。');
|
|
2750
|
+
}
|
|
2751
|
+
let configSaved = false;
|
|
2752
|
+
const operationRebuildResults = [];
|
|
2753
|
+
try {
|
|
2754
|
+
const freshEvidence = await captureEvidence(groupIntent, undefined, undefined, operationInventory, true);
|
|
2755
|
+
const freshSource = freshEvidence.source;
|
|
2756
|
+
const freshConfig = freshEvidence.config;
|
|
2757
|
+
if (!freshSource || !freshConfig) {
|
|
2758
|
+
throw operationReviewStale('设置目标缺少最新证据。');
|
|
2759
|
+
}
|
|
2760
|
+
assertSourceEvidenceMatches(currentEvidence.source, freshSource);
|
|
2761
|
+
const freshLayerStoreDigest = await configLayerStoreDigest({
|
|
2762
|
+
source: freshSource,
|
|
2763
|
+
pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
2764
|
+
scope: 'user', platform: group.platform, profileOnly: true,
|
|
2765
|
+
cwd: context.cwd,
|
|
2766
|
+
env: context.env,
|
|
2767
|
+
});
|
|
2768
|
+
if (freshLayerStoreDigest !== reviewedGroup.config.storeDigest) {
|
|
2769
|
+
throw operationReviewStale('保存设置期间此设置层的原始内容发生变化。');
|
|
2770
|
+
}
|
|
2771
|
+
if (freshConfig.affectedTargets.some((target) => !approvedApplyTargets.has(`${target.pluginName ?? parsePluginId(intent.pluginId).pluginName}\0${target.platform}\0${target.scope}`))
|
|
2772
|
+
|| freshConfig.commandPackages?.some((target) => !approvedCommandPackages.has(target.packageId))) {
|
|
2773
|
+
throw operationReviewStale('同批前一层变更扩大了未经确认的应用目标。');
|
|
2774
|
+
}
|
|
2775
|
+
const groupCatalogOperation = catalogOperationByEvidence.get(freshEvidence);
|
|
2776
|
+
if (expectedEvidence.catalog.generationSetDigest
|
|
2777
|
+
&& groupCatalogOperation?.generationSetDigest
|
|
2778
|
+
!== expectedEvidence.catalog.generationSetDigest) {
|
|
2779
|
+
throw operationReviewStale('保存设置期间 Active Catalog generation 发生变化。');
|
|
2780
|
+
}
|
|
2781
|
+
const result = await withResolvedCatalogPlugin({
|
|
2782
|
+
selector: intent.pluginId,
|
|
2783
|
+
cliVersion: packageInfo.version,
|
|
2784
|
+
env: context.env,
|
|
2785
|
+
...(groupCatalogOperation ? { operationContext: groupCatalogOperation } : {}),
|
|
2786
|
+
consume: async ({ plugin, source }) => {
|
|
2787
|
+
assertSourceEvidenceMatches(freshSource, sourceEvidenceForPlugin(source, plugin.manifest.name));
|
|
2788
|
+
const referencePlugins = configNeedsReferencePlugins(plugin) ? await resolvePluginConfigReferencePlugins({
|
|
2789
|
+
sourceId: plugin.sourceId,
|
|
2790
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2791
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2792
|
+
env: context.env,
|
|
2793
|
+
operationContext: groupCatalogOperation,
|
|
2794
|
+
}) : undefined;
|
|
2795
|
+
const applyTargets = intent.apply
|
|
2796
|
+
? freshConfig.affectedTargets.filter((target) => NATIVE_PLATFORM_TARGETS.includes(target.platform)).map((target) => ({
|
|
2797
|
+
pluginName: target.pluginName ?? plugin.manifest.name,
|
|
2798
|
+
platform: target.platform,
|
|
2799
|
+
scope: target.scope,
|
|
2800
|
+
}))
|
|
2801
|
+
: [];
|
|
2802
|
+
return applyPluginConfigWrite({
|
|
2803
|
+
plugin,
|
|
2804
|
+
pluginName: plugin.manifest.name,
|
|
2805
|
+
scope: 'user', platform: group.platform, context: intent.context ?? 'user',
|
|
2806
|
+
apply: intent.apply,
|
|
2807
|
+
cwd: context.cwd,
|
|
2808
|
+
env: context.env,
|
|
2809
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
2810
|
+
rebuildRuntime: {
|
|
2811
|
+
...context,
|
|
2812
|
+
referencePlugins,
|
|
2813
|
+
awHomeMutationToken,
|
|
2814
|
+
operationDiagnosticSink: (entries) => {
|
|
2815
|
+
operationRebuildResults.push(...structuredClone(entries));
|
|
2816
|
+
},
|
|
2817
|
+
...(reviewedScriptTimeoutMs(intent) === undefined ? {} : {
|
|
2818
|
+
scriptTimeoutMs: reviewedScriptTimeoutMs(intent),
|
|
2819
|
+
}),
|
|
2820
|
+
...(groupCatalogOperation ? {
|
|
2821
|
+
catalogOperationContext: groupCatalogOperation,
|
|
2822
|
+
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
2823
|
+
} : {}),
|
|
2824
|
+
},
|
|
2825
|
+
awHomeMutationToken,
|
|
2826
|
+
...(applyTargets.length ? { applyTargets } : {}),
|
|
2827
|
+
request: { updates: group.updates, removeKeys: group.removeKeys },
|
|
2828
|
+
sharedNativeApplyConfirmed: true,
|
|
2829
|
+
expectedCommandPackageEvidence: reviewedGroup.config.commandPackageEvidence,
|
|
2830
|
+
expectedHostPermissionEffects: reviewedGroup.config.hostPermissionEffects,
|
|
2831
|
+
preApplyConfirmed: true,
|
|
2832
|
+
preApplyAuthorizedTargets: approvedPreApplyTargets,
|
|
2833
|
+
});
|
|
2834
|
+
},
|
|
2835
|
+
});
|
|
2836
|
+
configSaved = result.configWrite === 'succeeded';
|
|
2837
|
+
const applyStatus = !intent.apply
|
|
2838
|
+
? 'notRequested'
|
|
2839
|
+
: result.apply.state === 'succeeded'
|
|
2840
|
+
? 'succeeded'
|
|
2841
|
+
: result.apply.state === 'skipped'
|
|
2842
|
+
? 'notNeeded'
|
|
2843
|
+
: configApplyHasCompletedWork(result.apply) ? 'partial' : 'failed';
|
|
2844
|
+
const applyIncomplete = applyStatus === 'failed' || applyStatus === 'partial';
|
|
2845
|
+
results.push({
|
|
2846
|
+
scope: 'user', platform: group.platform,
|
|
2847
|
+
status: applyIncomplete ? 'failed' : 'succeeded',
|
|
2848
|
+
configSaved,
|
|
2849
|
+
applyRequested: intent.apply,
|
|
2850
|
+
applyStatus,
|
|
2851
|
+
execution: { ...result, operationRebuildResults },
|
|
2852
|
+
...(applyIncomplete ? {
|
|
2853
|
+
errorCode: result.apply.state === 'unavailable'
|
|
2854
|
+
? result.apply.error?.code ?? result.apply.reason
|
|
2855
|
+
: result.apply.targetResults.find((target) => target.errorCode)?.errorCode
|
|
2856
|
+
?? 'runtimeApplyFailed',
|
|
2857
|
+
} : {}),
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
catch (error) {
|
|
2861
|
+
const interruption = error instanceof ConfigApplyInterruptedError ? error : undefined;
|
|
2862
|
+
if (interruption) {
|
|
2863
|
+
interrupted = true;
|
|
2864
|
+
if (context.interruption && interruption.code === 'processCleanupUnconfirmed') {
|
|
2865
|
+
context.interruption.cleanupFailed = true;
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
configSaved = error?.configWrite === 'succeeded';
|
|
2869
|
+
const errorCode = typeof error === 'object' && error !== null
|
|
2870
|
+
&& 'code' in error && typeof error.code === 'string'
|
|
2871
|
+
? error.code
|
|
2872
|
+
: configSaved ? 'runtimeApplyFailed' : 'configWriteFailed';
|
|
2873
|
+
const failureDetail = configSaved ? undefined : configSaveFailureDetail(error);
|
|
2874
|
+
results.push({
|
|
2875
|
+
scope: 'user', platform: group.platform,
|
|
2876
|
+
status: 'failed',
|
|
2877
|
+
configSaved,
|
|
2878
|
+
applyRequested: intent.apply,
|
|
2879
|
+
applyStatus: !intent.apply ? 'notRequested'
|
|
2880
|
+
: configApplyHasCompletedWork(interruption?.apply) ? 'partial' : 'failed',
|
|
2881
|
+
errorCode,
|
|
2882
|
+
...(failureDetail ? { failureDetail } : {}),
|
|
2883
|
+
...(interruption || operationRebuildResults.length > 0
|
|
2884
|
+
? { execution: {
|
|
2885
|
+
operationRebuildResults,
|
|
2886
|
+
...(interruption ? { apply: interruption.apply, operationDiagnostic: interruption.operationDiagnostic } : {}),
|
|
2887
|
+
} }
|
|
2888
|
+
: {}),
|
|
2889
|
+
});
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
const succeeded = results.filter((result) => result.status === 'succeeded').length;
|
|
2893
|
+
return {
|
|
2894
|
+
status: succeeded === results.length
|
|
2895
|
+
? 'succeeded'
|
|
2896
|
+
: succeeded > 0 || results.some((result) => result.configSaved)
|
|
2897
|
+
? 'partial'
|
|
2898
|
+
: 'failed',
|
|
2899
|
+
groups: results,
|
|
2900
|
+
};
|
|
1922
2901
|
}
|
|
1923
2902
|
if (intent.kind === 'configSave' || intent.kind === 'configReset') {
|
|
2903
|
+
const operationRebuildResults = [];
|
|
2904
|
+
const operationDiagnosticSink = (results) => {
|
|
2905
|
+
operationRebuildResults.push(...structuredClone(results));
|
|
2906
|
+
};
|
|
1924
2907
|
const currentSource = currentEvidence.source;
|
|
1925
2908
|
if (intent.kind === 'configReset') {
|
|
1926
2909
|
const parsed = parsePluginId(intent.pluginId);
|
|
@@ -1930,13 +2913,14 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1930
2913
|
return resetPluginConfigWithHelper({
|
|
1931
2914
|
sourceId: parsed.sourceId,
|
|
1932
2915
|
pluginName: parsed.pluginName,
|
|
1933
|
-
scope: intent.
|
|
2916
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
1934
2917
|
cwd: context.cwd,
|
|
1935
2918
|
env: context.env,
|
|
1936
2919
|
nativeCliRunner: context.nativeCliRunner,
|
|
1937
2920
|
rebuildRuntime: { ...context, awHomeMutationToken },
|
|
1938
2921
|
awHomeMutationToken,
|
|
1939
2922
|
apply: false,
|
|
2923
|
+
sharedNativeApplyConfirmed: false,
|
|
1940
2924
|
});
|
|
1941
2925
|
}
|
|
1942
2926
|
if (!currentSource) {
|
|
@@ -1950,52 +2934,88 @@ export function createTuiControllerDependencies(context, progressFeed, options =
|
|
|
1950
2934
|
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
1951
2935
|
consume: async ({ plugin, source }) => {
|
|
1952
2936
|
assertSourceEvidenceMatches(currentSource, sourceEvidenceForPlugin(source, plugin.manifest.name));
|
|
1953
|
-
const
|
|
1954
|
-
|
|
1955
|
-
|
|
2937
|
+
const referencePlugins = configNeedsReferencePlugins(plugin) ? await resolvePluginConfigReferencePlugins({
|
|
2938
|
+
sourceId: plugin.sourceId,
|
|
2939
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2940
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2941
|
+
env: context.env,
|
|
2942
|
+
operationContext: catalogOperation,
|
|
2943
|
+
}) : undefined;
|
|
2944
|
+
const applyTargets = intent.retryApply || intent.apply
|
|
2945
|
+
? currentEvidence.config?.affectedTargets.filter((target) => NATIVE_PLATFORM_TARGETS.includes(target.platform)).map((target) => ({
|
|
2946
|
+
pluginName: target.pluginName ?? plugin.manifest.name,
|
|
1956
2947
|
platform: target.platform,
|
|
1957
2948
|
scope: target.scope,
|
|
1958
2949
|
})) ?? []
|
|
1959
2950
|
: [];
|
|
1960
2951
|
const result = intent.retryApply
|
|
1961
|
-
? await
|
|
2952
|
+
? await applyPluginConfig({
|
|
1962
2953
|
plugin,
|
|
1963
|
-
scope: intent.
|
|
2954
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
2955
|
+
...(intent.targets ? { targets: intent.targets } : {}),
|
|
2956
|
+
cliVersion: packageInfo.version,
|
|
1964
2957
|
cwd: context.cwd,
|
|
1965
2958
|
env: context.env,
|
|
1966
2959
|
nativeCliRunner: context.nativeCliRunner,
|
|
1967
2960
|
rebuildRuntime: {
|
|
1968
2961
|
...context,
|
|
2962
|
+
referencePlugins,
|
|
1969
2963
|
awHomeMutationToken,
|
|
2964
|
+
operationDiagnosticSink,
|
|
2965
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
2966
|
+
? {}
|
|
2967
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
1970
2968
|
...(catalogOperation ? {
|
|
1971
2969
|
catalogOperationContext: catalogOperation,
|
|
1972
2970
|
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
1973
2971
|
} : {}),
|
|
1974
2972
|
},
|
|
1975
2973
|
awHomeMutationToken,
|
|
1976
|
-
|
|
2974
|
+
expectedEvidence: expectedEvidence.config?.applyEvidence,
|
|
2975
|
+
expectedCommandPackageEvidence: expectedEvidence.config?.commandPackageEvidence,
|
|
2976
|
+
expectedHostPermissionEffects: expectedEvidence.config?.hostPermissionEffects,
|
|
2977
|
+
sharedNativeApplyConfirmed: true,
|
|
2978
|
+
preApplyConfirmed: true,
|
|
2979
|
+
preApplyAuthorizedTargets: expectedEvidence.config?.preApplyAuthorization ?? [],
|
|
1977
2980
|
})
|
|
1978
2981
|
: await applyPluginConfigWrite({
|
|
1979
2982
|
plugin,
|
|
1980
2983
|
pluginName: plugin.manifest.name,
|
|
1981
|
-
scope: intent.
|
|
2984
|
+
scope: 'user', platform: intent.platform, context: intent.context ?? 'user',
|
|
2985
|
+
apply: intent.apply,
|
|
1982
2986
|
cwd: context.cwd,
|
|
1983
2987
|
env: context.env,
|
|
1984
2988
|
nativeCliRunner: context.nativeCliRunner,
|
|
1985
2989
|
rebuildRuntime: {
|
|
1986
2990
|
...context,
|
|
2991
|
+
referencePlugins,
|
|
1987
2992
|
awHomeMutationToken,
|
|
2993
|
+
operationDiagnosticSink,
|
|
2994
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
2995
|
+
? {}
|
|
2996
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
1988
2997
|
...(catalogOperation ? {
|
|
1989
2998
|
catalogOperationContext: catalogOperation,
|
|
1990
2999
|
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
1991
3000
|
} : {}),
|
|
1992
3001
|
},
|
|
1993
3002
|
awHomeMutationToken,
|
|
1994
|
-
applyTargets,
|
|
3003
|
+
...(applyTargets.length ? { applyTargets } : {}),
|
|
1995
3004
|
request: { updates: intent.updates, removeKeys: intent.removeKeys },
|
|
3005
|
+
sharedNativeApplyConfirmed: true,
|
|
3006
|
+
expectedCommandPackageEvidence: expectedEvidence.config?.commandPackageEvidence,
|
|
3007
|
+
expectedHostPermissionEffects: expectedEvidence.config?.hostPermissionEffects,
|
|
3008
|
+
preApplyConfirmed: true,
|
|
3009
|
+
preApplyAuthorizedTargets: expectedEvidence.config?.preApplyAuthorization ?? [],
|
|
1996
3010
|
});
|
|
1997
|
-
return result;
|
|
3011
|
+
return { ...result, operationRebuildResults };
|
|
1998
3012
|
},
|
|
3013
|
+
}).catch((error) => {
|
|
3014
|
+
if (error instanceof ConfigApplyInterruptedError && context.interruption
|
|
3015
|
+
&& error.code === 'processCleanupUnconfirmed') {
|
|
3016
|
+
context.interruption.cleanupFailed = true;
|
|
3017
|
+
}
|
|
3018
|
+
throw error;
|
|
1999
3019
|
});
|
|
2000
3020
|
}
|
|
2001
3021
|
throw new TuiOperationBlockedError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
|