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