@lesliechan721/aw 0.1.0-beta.4 → 0.1.0-beta.41
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 +4 -4
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +67 -97
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +15 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +239 -232
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +77 -90
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +99 -120
- 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 +367 -0
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-plugin.mjs +353 -1175
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/aw-skill-eval-materializer.d.ts +26 -0
- package/dist/scripts/aw-skill-eval-materializer.js +306 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +1 -2
- package/dist/scripts/bundle-plugins.js +24 -7
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +7 -24
- package/dist/scripts/plugin-staging.js +22 -142
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/test-plugin-scripts.d.ts +2 -0
- package/dist/scripts/test-plugin-scripts.js +30 -75
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- 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 +26 -2
- package/dist/src/authoring/workspace-commands.js +44 -19
- 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 +263 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -0
- package/dist/src/commands/catalog-dev-source.d.ts +154 -0
- package/dist/src/commands/catalog-dev-source.js +655 -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 +138 -0
- package/dist/src/commands/catalog-publication-inspection.js +757 -0
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
- 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 +77 -7
- package/dist/src/commands/catalog-publish.js +746 -316
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +60 -22
- package/dist/src/commands/catalog-source.js +311 -91
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-status.d.ts +56 -0
- package/dist/src/commands/catalog-status.js +217 -0
- package/dist/src/commands/catalog-status.js.map +1 -0
- 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 +13 -0
- package/dist/src/commands/catalog-workspace-resolution.js +42 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.js +28 -17
- 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/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 +146 -0
- package/dist/src/commands/operation-plan.js +71 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +46 -0
- package/dist/src/commands/operation-planner.js +141 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +9 -7
- package/dist/src/commands/options.js +83 -21
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.d.ts +22 -0
- package/dist/src/commands/plugin-capabilities.js +163 -0
- package/dist/src/commands/plugin-capabilities.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +78 -30
- package/dist/src/commands/rebuild-command.js +4877 -713
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +132 -21
- package/dist/src/commands/rebuild-integration.js +2853 -1327
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +58 -30
- package/dist/src/commands/rebuild-operations.js +260 -319
- 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 +228 -0
- package/dist/src/commands/review-inspection.js +1341 -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 +427 -0
- package/dist/src/commands/review-preparation.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +1 -5
- package/dist/src/commands/runtime.js +24 -50
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +39 -0
- package/dist/src/commands/skill-eval.js +400 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +279 -0
- package/dist/src/commands/status-v6.js +2787 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/sync-command.d.ts +40 -0
- package/dist/src/commands/sync-command.js +250 -0
- package/dist/src/commands/sync-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 +127 -31
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +7 -1
- package/dist/src/constants.js +7 -1
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +71 -0
- package/dist/src/eval/manifest-v1.js +370 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +5 -1
- package/dist/src/generators/local-plugin.js +228 -104
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/index.d.ts +10 -4
- package/dist/src/index.js +1835 -469
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +43 -46
- package/dist/src/output/command-receipt.js +256 -80
- 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/rebuild-progress.js +1 -13
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/portable/commands.d.ts +46 -7
- package/dist/src/portable/commands.js +349 -37
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +17 -4
- package/dist/src/portable/materializer.js +179 -41
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/skills-cli.d.ts +15 -7
- package/dist/src/portable/skills-cli.js +66 -19
- package/dist/src/portable/skills-cli.js.map +1 -1
- 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 +17 -0
- package/dist/src/review/review-profile.js +234 -0
- package/dist/src/review/review-profile.js.map +1 -0
- package/dist/src/review/review-selection.d.ts +30 -0
- package/dist/src/review/review-selection.js +527 -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 +13 -0
- package/dist/src/review/skill-materialization.js +75 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +183 -0
- package/dist/src/review/source-binding.js +708 -0
- package/dist/src/review/source-binding.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 +177 -0
- package/dist/src/tui/components.js +297 -7
- 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 +16 -0
- package/dist/src/tui/config-leaf-editor.js +206 -0
- package/dist/src/tui/config-leaf-editor.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 +14 -4
- package/dist/src/tui/console-app-v4.js +9659 -1558
- 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 +13 -1
- package/dist/src/tui/controller-runtime.js +3323 -349
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +643 -40
- package/dist/src/tui/controller.js +3756 -705
- 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 +567 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +31 -0
- package/dist/src/tui/diagnostics.js +83 -0
- package/dist/src/tui/diagnostics.js.map +1 -0
- package/dist/src/tui/entity-cards.d.ts +55 -0
- package/dist/src/tui/entity-cards.js +220 -0
- package/dist/src/tui/entity-cards.js.map +1 -0
- package/dist/src/tui/glossary.d.ts +23 -0
- package/dist/src/tui/glossary.js +42 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/index.d.ts +11 -4
- package/dist/src/tui/index.js +8 -2
- 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 +248 -27
- package/dist/src/tui/model.js +1662 -314
- 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 +21 -0
- package/dist/src/tui/operation-review-planner.js +1295 -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 +680 -0
- package/dist/src/tui/plugin-content.js.map +1 -0
- package/dist/src/tui/plugin-detail.d.ts +52 -0
- package/dist/src/tui/plugin-detail.js +165 -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/project-inventory.d.ts +68 -0
- package/dist/src/tui/project-inventory.js +203 -0
- package/dist/src/tui/project-inventory.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 +37 -0
- package/dist/src/tui/reader.js +47 -0
- package/dist/src/tui/reader.js.map +1 -0
- package/dist/src/tui/router.d.ts +207 -14
- package/dist/src/tui/router.js +352 -29
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/screen-registry.d.ts +701 -0
- package/dist/src/tui/screen-registry.js +230 -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 +209 -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 +30 -10
- package/dist/src/tui/theme.js +30 -10
- package/dist/src/tui/theme.js.map +1 -1
- package/dist/src/tui/viewport.d.ts +21 -0
- package/dist/src/tui/viewport.js +52 -0
- package/dist/src/tui/viewport.js.map +1 -0
- 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 +244 -20
- 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 +41 -8
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +5 -4
- package/dist/src/utils/artifact-plan.js +18 -7
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +17 -7
- package/dist/src/utils/artifact-renderer.js +214 -216
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +21 -0
- package/dist/src/utils/artifact-request.js +78 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- 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 +22 -29
- 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 +50 -2
- 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 +172 -0
- package/dist/src/utils/catalog-generation-service.js +1271 -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 +4 -7
- package/dist/src/utils/catalog-runtime-projection.js +7 -102
- 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 +3 -2
- package/dist/src/utils/catalog-source-references.js +195 -347
- 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/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-manager.d.ts +79 -0
- package/dist/src/utils/codex-manager.js +745 -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 +154 -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 +126 -0
- package/dist/src/utils/codex-reconciler.js +298 -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-surface-analysis.d.ts +46 -0
- package/dist/src/utils/codex-surface-analysis.js +247 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +4 -0
- package/dist/src/utils/dynamic-skill-tree.js +36 -6
- 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 +169 -144
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +17 -1
- package/dist/src/utils/local-marketplace.js +301 -84
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/manifest.d.ts +1 -4
- package/dist/src/utils/manifest.js +1 -4
- 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 +55 -7
- package/dist/src/utils/native-cli.js +386 -57
- package/dist/src/utils/native-cli.js.map +1 -1
- 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 +84 -20
- package/dist/src/utils/ownership.js +179 -222
- 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 +0 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +33 -0
- package/dist/src/utils/plugin-config-impact.js +298 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +52 -27
- package/dist/src/utils/plugin-config-write.js +1000 -296
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +153 -93
- package/dist/src/utils/plugin-config.js +1163 -1017
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-intent-state.d.ts +49 -0
- package/dist/src/utils/plugin-intent-state.js +320 -0
- package/dist/src/utils/plugin-intent-state.js.map +1 -0
- package/dist/src/utils/plugin-scripts.d.ts +65 -125
- package/dist/src/utils/plugin-scripts.js +482 -524
- package/dist/src/utils/plugin-scripts.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/runtime-config.d.ts +20 -0
- package/dist/src/utils/runtime-config.js +75 -0
- package/dist/src/utils/runtime-config.js.map +1 -0
- 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/skill-validation.d.ts +1 -1
- package/dist/src/utils/skill-validation.js +1 -1
- package/dist/src/utils/skill-validation.js.map +1 -1
- package/dist/src/utils/state-paths.d.ts +1 -0
- package/dist/src/utils/state-paths.js +12 -2
- 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 +9 -0
- package/dist/src/utils/windows-claude-shim.js +141 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/vitest.config.js +91 -10
- package/dist/vitest.config.js.map +1 -1
- package/package.json +22 -19
- 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/status-v4.d.ts +0 -102
- package/dist/src/commands/status-v4.js +0 -844
- 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/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 -61
- package/dist/src/utils/catalog-source-cache.js +0 -276
- 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-authoring-capabilities.d.ts +0 -23
- package/dist/src/utils/plugin-authoring-capabilities.js +0 -37
- package/dist/src/utils/plugin-authoring-capabilities.js.map +0 -1
- package/dist/src/utils/plugin-authoring-capabilities.json +0 -92
- package/dist/src/utils/plugin-release.d.ts +0 -2
- package/dist/src/utils/plugin-release.js +0 -2
- package/dist/src/utils/plugin-release.js.map +0 -1
- package/dist/src/utils/skill-frontmatter-capabilities.d.ts +0 -201
- package/dist/src/utils/skill-frontmatter-capabilities.js +0 -5
- package/dist/src/utils/skill-frontmatter-capabilities.js.map +0 -1
- package/dist/src/utils/skill-frontmatter-capabilities.json +0 -200
- /package/dist/authoring/scripts/{check-plugin-versions.d.mts → remove-plugin.d.mts} +0 -0
|
@@ -1,34 +1,80 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
|
-
import
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { flattenStatusTargets, statusCommandV8, statusTargetActivation, statusTargetIntent, statusTargetOwnershipState, } from '../commands/status-v6.js';
|
|
3
4
|
import { addCatalogSourceCommand, listCatalogSources, preflightCatalogSourceMutation, removeCatalogSourceCommand, setPrimaryCatalogSourceCommand, updateCatalogSourceCommand, } from '../commands/catalog-source.js';
|
|
4
|
-
import { cleanupWriteCommand, installWriteCommand, reinstallWriteCommand,
|
|
5
|
+
import { cleanupWriteCommand, failedWriteCommandResult, installWriteCommand, mergeWriteCommandResults, reinstallWriteCommand, syncWriteCommand, taskWriteCommand, uninstallWriteCommand, } from '../commands/write-commands.js';
|
|
6
|
+
import { resolveSyncIntentSelection } from '../commands/sync-command.js';
|
|
7
|
+
import { parseScriptTimeoutMs, SCRIPT_TIMEOUT_DEFAULT_MS, } from '../commands/options.js';
|
|
5
8
|
import { readCliPackageInfo } from '../utils/local-marketplace.js';
|
|
6
|
-
import {
|
|
9
|
+
import { createCodexNativeObservationSession, } from '../utils/codex-native-observation.js';
|
|
10
|
+
import { readCatalogSourcesConfigSnapshot, recoverInvalidCatalogSourcesConfig, } from '../utils/catalog-sources.js';
|
|
7
11
|
import { withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, formatPluginId, parsePluginId, } from '../utils/multi-source-catalog.js';
|
|
8
|
-
import { coercePluginConfigUpdates,
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
+
import { coercePluginConfigUpdates, inspectPluginConfigResetTarget, listNamespacedPluginConfigStoreIdentities, readPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigStorePath, } from '../utils/plugin-config.js';
|
|
13
|
+
import { assertProjectSharedConfigPathVisible } from '../utils/project-boundary.js';
|
|
14
|
+
import { calculatePluginIntentDigest, readPluginIntentState, } from '../utils/plugin-intent-state.js';
|
|
15
|
+
import { applyPluginConfigWrite, replayConfigRuntimeWrites, resolveConfigPreApplyAuthorization, resetPluginConfigWithHelper, } from '../utils/plugin-config-write.js';
|
|
16
|
+
import { analyzePluginConfigMutationImpact } from '../utils/plugin-config-impact.js';
|
|
17
|
+
import { createBatchIntentCompatiblePlanFingerprint } from '../commands/operation-plan.js';
|
|
18
|
+
import { inventoryCatalogSourceReferences } from '../utils/catalog-source-references.js';
|
|
19
|
+
import { operationEvidenceMatches, operationEvidenceFingerprint, TuiConfigInvalidStoreError, TuiController, TuiOperationBlockedError, } from './controller.js';
|
|
20
|
+
import { buildConfigGroups, buildConfigPage, buildTuiViewModel, hasActualScopeEvidence, isDirectCodexVersionUpgrade, projectPlatformPlacement, } from './model.js';
|
|
21
|
+
import { buildPluginWriteTaskCandidates, buildPluginWriteTaskDraft, evaluatePluginWriteTaskRestoreVersion, pluginWriteTaskTargetKey, } from './plugin-write-task.js';
|
|
22
|
+
import { projectExecutionDiagnostics, projectThrownOperationDiagnostic } from './diagnostic-projection.js';
|
|
12
23
|
import { projectCatalogSourceLocation } from '../utils/catalog-source-presentation.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { resolvePluginsFromCatalog } from '../utils/manifest.js';
|
|
24
|
+
import { calculateCatalogSourceConfigFingerprint, calculateCatalogSourceIdentity, } from '../utils/catalog-source-identity.js';
|
|
25
|
+
import { checkAwCapabilitySupport, readPluginManifest } from '../utils/manifest.js';
|
|
16
26
|
import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
17
|
-
import {
|
|
27
|
+
import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
|
|
28
|
+
import { calculateCatalogGenerationSetDigest, resolveActiveCatalogGeneration, } from '../utils/catalog-generation-resolver.js';
|
|
29
|
+
import { resolveCatalogOperationContext, resolvePartialCatalogOperationContext, selectCatalogOperationContext, } from '../utils/catalog-operation-context.js';
|
|
30
|
+
import { createCatalogStoreKey, readCatalogStoreEntry, } from '../utils/catalog-generation-store.js';
|
|
31
|
+
import { activateCatalogSourceGeneration, compareCatalogGenerationFreshness, probeCatalogSourceFreshness, probeCatalogSourceGeneration, probeCatalogSourceRepairGeneration, recoverCatalogGenerationStateAndActivate, repairCatalogSourceGeneration, replaceDamagedCatalogSourceGeneration, syncCatalogSourceGeneration, } from '../utils/catalog-generation-service.js';
|
|
32
|
+
import { calculateCatalogSourceImpactDigest, inspectCatalogSourceImpact, } from '../utils/catalog-source-impact.js';
|
|
33
|
+
import { readCatalogGenerationState } from '../utils/catalog-generation-state.js';
|
|
34
|
+
import { CatalogGenerationError } from '../utils/catalog-generation-error.js';
|
|
35
|
+
import { CatalogProviderCompatibilityError } from '../utils/catalog-public-error.js';
|
|
36
|
+
import { loadCatalogGenerationViewModels } from './catalog-generation.js';
|
|
37
|
+
import { executePortableRetry, installPortableSkills, preparePortableInstall, preparePortableRetry, PortableCommandError, recheckPortableInstall, } from '../portable/commands.js';
|
|
38
|
+
import { MANAGED_CODEX_PACKAGE_NAME, MANAGED_CODEX_VERSION, } from '../utils/codex-manager.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) => plugin.manifest.distributions?.agentSkills
|
|
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,24 +84,154 @@ export function setTuiControllerRuntimeTestHooksForTests(hooks) {
|
|
|
38
84
|
function digest(value) {
|
|
39
85
|
return `sha256:${crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex')}`;
|
|
40
86
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
87
|
+
export function statusTargetFingerprint(targets, revisions = []) {
|
|
88
|
+
return digest({
|
|
89
|
+
targets: targets.map((target) => ({
|
|
90
|
+
pluginId: target.pluginId,
|
|
91
|
+
sourceIdentity: target.sourceIdentity,
|
|
92
|
+
platform: target.platform,
|
|
93
|
+
scope: target.scope,
|
|
94
|
+
state: target.state,
|
|
95
|
+
errors: target.reasons.map((error) => error.code).sort(),
|
|
96
|
+
sharedReasons: [...(target.sharedReasons ?? [])]
|
|
97
|
+
.sort((left, right) => `${left.code}\0${left.message}`.localeCompare(`${right.code}\0${right.message}`, 'en')),
|
|
98
|
+
components: target.components.map((component) => [component.key, component.state])
|
|
99
|
+
.sort(([left], [right]) => left.localeCompare(right, 'en')),
|
|
100
|
+
sharedComponents: (target.sharedComponents ?? [])
|
|
101
|
+
.map((component) => [component.key, component.state, component.metadata])
|
|
102
|
+
.sort(([left], [right]) => left.localeCompare(right, 'en')),
|
|
103
|
+
})).sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
104
|
+
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en')),
|
|
105
|
+
revisions: revisions.map((entry) => ({
|
|
106
|
+
pluginId: entry.pluginId,
|
|
107
|
+
platform: entry.platform,
|
|
108
|
+
scope: entry.scope,
|
|
109
|
+
revision: entry.revision,
|
|
110
|
+
})).sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
111
|
+
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en')),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export function configAffectedStatusTargets(targets, pluginId, configScope) {
|
|
115
|
+
const affected = new Map();
|
|
116
|
+
for (const target of flattenStatusTargets(targets)) {
|
|
117
|
+
const intent = statusTargetIntent(target);
|
|
118
|
+
if (target.pluginId !== pluginId || !intent.enabled)
|
|
119
|
+
continue;
|
|
120
|
+
for (const scope of intent.scopes) {
|
|
121
|
+
if (configScope === 'project' && scope !== 'project')
|
|
122
|
+
continue;
|
|
123
|
+
affected.set(`${target.platform}\0${scope}`, { ...target, scope });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return [...affected.values()]
|
|
127
|
+
.sort((left, right) => `${left.platform}\0${left.scope}`
|
|
128
|
+
.localeCompare(`${right.platform}\0${right.scope}`, 'en'));
|
|
129
|
+
}
|
|
130
|
+
function configRetrySharedNativeRenderTargets(plugin) {
|
|
131
|
+
return (plugin.manifest.artifacts?.targets ?? []).flatMap((target) => target.platform === 'codex'
|
|
132
|
+
&& target.target === 'codex.skill'
|
|
133
|
+
&& target.delivery.mode === 'codex-native'
|
|
134
|
+
&& target.skillKey
|
|
135
|
+
&& target.refreshKeys.length > 0
|
|
136
|
+
? [{ id: target.id, skillKey: target.skillKey, refreshKeys: [...target.refreshKeys] }]
|
|
137
|
+
: []);
|
|
138
|
+
}
|
|
139
|
+
function configImpactVisibleTargets(pluginName, targets) {
|
|
140
|
+
return targets.map((target) => ({
|
|
141
|
+
pluginName,
|
|
142
|
+
platform: target.platform,
|
|
143
|
+
scope: target.scope,
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
function configIntentRequestsApply(intent) {
|
|
147
|
+
if (!intent.apply)
|
|
148
|
+
return false;
|
|
149
|
+
if (intent.retryApply === true)
|
|
150
|
+
return true;
|
|
151
|
+
if (intent.changes)
|
|
152
|
+
return intent.changes.length > 0;
|
|
153
|
+
return Object.keys(intent.updates ?? {}).length > 0
|
|
154
|
+
|| (intent.removeKeys?.length ?? 0) > 0;
|
|
155
|
+
}
|
|
156
|
+
function configSaveBatchGroupIntent(intent, group) {
|
|
157
|
+
return {
|
|
158
|
+
kind: 'configSave',
|
|
159
|
+
pluginId: intent.pluginId,
|
|
160
|
+
scope: group.scope,
|
|
161
|
+
apply: intent.apply,
|
|
162
|
+
...(intent.scriptTimeoutMs === undefined ? {} : { scriptTimeoutMs: intent.scriptTimeoutMs }),
|
|
163
|
+
...(group.updates ? { updates: group.updates } : {}),
|
|
164
|
+
...(group.removeKeys ? { removeKeys: group.removeKeys } : {}),
|
|
165
|
+
...(group.sensitiveKeys ? { sensitiveKeys: group.sensitiveKeys } : {}),
|
|
166
|
+
...(group.privateKeys ? { privateKeys: group.privateKeys } : {}),
|
|
167
|
+
...(group.changes ? { changes: group.changes } : {}),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function assertConfigSaveBatchIntent(intent) {
|
|
171
|
+
const order = { project: 0, user: 1 };
|
|
172
|
+
if (intent.groups.length === 0 || intent.groups.length > 2
|
|
173
|
+
|| new Set(intent.groups.map((group) => group.scope)).size !== intent.groups.length
|
|
174
|
+
|| intent.groups.some((group, index) => index > 0
|
|
175
|
+
&& order[intent.groups[index - 1].scope] >= order[group.scope])
|
|
176
|
+
|| intent.groups.some((group) => Object.keys(group.updates ?? {}).length === 0
|
|
177
|
+
&& (group.removeKeys?.length ?? 0) === 0)) {
|
|
178
|
+
throw new TuiOperationBlockedError('configBatchInvalid', '设置批次必须包含按当前项目、个人默认排序的唯一非空目标。');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function operationReviewStale(message, diagnostics) {
|
|
182
|
+
return new TuiOperationBlockedError('operationReviewStale', `operationReviewStale: ${message}`, diagnostics);
|
|
43
183
|
}
|
|
44
184
|
function sourceEvidenceForPlugin(source, pluginName) {
|
|
45
185
|
const entry = source.manifest.entries.find((candidate) => candidate.name === pluginName);
|
|
46
186
|
return {
|
|
47
187
|
sourceId: source.sourceId,
|
|
48
188
|
sourceIdentity: source.sourceIdentity,
|
|
189
|
+
logicalIdentity: source.logicalIdentity,
|
|
49
190
|
requestedRef: source.requestedRef,
|
|
50
191
|
resolvedCommit: source.resolvedCommit,
|
|
51
192
|
manifestDigest: source.manifestDigest,
|
|
52
193
|
snapshotDigest: source.snapshotDigest,
|
|
53
194
|
contentDigest: entry.contentDigest,
|
|
195
|
+
pluginVersion: entry.version,
|
|
196
|
+
catalogVersion: source.manifest.catalogVersion,
|
|
197
|
+
channel: source.manifest.channel,
|
|
54
198
|
};
|
|
55
199
|
}
|
|
200
|
+
async function configLayerStoreDigest(options) {
|
|
201
|
+
const store = await readPluginConfigStore({
|
|
202
|
+
sourceId: options.source.sourceId,
|
|
203
|
+
sourceIdentity: options.source.sourceIdentity,
|
|
204
|
+
...('logicalIdentity' in options.source
|
|
205
|
+
? { logicalIdentity: options.source.logicalIdentity }
|
|
206
|
+
: {}),
|
|
207
|
+
pluginName: options.pluginName,
|
|
208
|
+
scope: options.scope,
|
|
209
|
+
cwd: options.cwd,
|
|
210
|
+
env: options.env,
|
|
211
|
+
});
|
|
212
|
+
return digest({ exists: store.exists, rawDigest: store.rawDigest });
|
|
213
|
+
}
|
|
214
|
+
async function inspectConfigShareability(options) {
|
|
215
|
+
if (options.scope !== 'project')
|
|
216
|
+
return undefined;
|
|
217
|
+
const targetPath = resolvePluginConfigStorePath({
|
|
218
|
+
sourceId: options.sourceId,
|
|
219
|
+
pluginName: options.pluginName,
|
|
220
|
+
scope: 'project',
|
|
221
|
+
cwd: options.cwd,
|
|
222
|
+
env: options.env,
|
|
223
|
+
});
|
|
224
|
+
const visibility = await assertProjectSharedConfigPathVisible({
|
|
225
|
+
cwd: options.cwd,
|
|
226
|
+
targetPath,
|
|
227
|
+
env: options.env,
|
|
228
|
+
});
|
|
229
|
+
return visibility.state === 'unverified' ? 'unverified' : 'verified';
|
|
230
|
+
}
|
|
56
231
|
function assertSourceEvidenceMatches(expected, actual) {
|
|
57
232
|
if (actual.sourceId !== expected.sourceId
|
|
58
233
|
|| actual.sourceIdentity !== expected.sourceIdentity
|
|
234
|
+
|| actual.logicalIdentity !== expected.logicalIdentity
|
|
59
235
|
|| actual.resolvedCommit !== expected.resolvedCommit
|
|
60
236
|
|| actual.manifestDigest !== expected.manifestDigest
|
|
61
237
|
|| actual.snapshotDigest !== expected.snapshotDigest
|
|
@@ -63,131 +239,194 @@ function assertSourceEvidenceMatches(expected, actual) {
|
|
|
63
239
|
throw operationReviewStale('确认后来源内容发生变化。');
|
|
64
240
|
}
|
|
65
241
|
}
|
|
242
|
+
function writeReviewIsStale(result) {
|
|
243
|
+
return result.targetResults.some((target) => target.errorCode === 'operationReviewStale'
|
|
244
|
+
|| target.errorCode === 'operationPlanStale');
|
|
245
|
+
}
|
|
66
246
|
function throwIfWriteReviewStale(result) {
|
|
67
|
-
|
|
68
|
-
if (stale) {
|
|
247
|
+
if (writeReviewIsStale(result)) {
|
|
69
248
|
throw operationReviewStale('确认后实际写入计划发生变化。');
|
|
70
249
|
}
|
|
71
250
|
}
|
|
72
251
|
const SOURCE_PROGRESS_PHASES = {
|
|
73
|
-
refreshingCatalog: '刷新 Catalog 缓存',
|
|
74
|
-
catalogReady: 'Catalog 已读取,索引已刷新',
|
|
75
252
|
savingConfig: '保存来源配置',
|
|
76
253
|
};
|
|
77
254
|
function pluginIntent(intent) {
|
|
78
255
|
return 'pluginId' in intent;
|
|
79
256
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
257
|
+
function reviewedScriptTimeoutMs(intent) {
|
|
258
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
259
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
260
|
+
}
|
|
261
|
+
if ((intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch')
|
|
262
|
+
&& (intent.action === 'install' || intent.action === 'refreshAndSync'
|
|
263
|
+
|| intent.action === 'reinstall' || intent.action === 'sync')) {
|
|
264
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
265
|
+
}
|
|
266
|
+
if ((intent.kind === 'configSave' || intent.kind === 'configSaveBatch') && intent.apply) {
|
|
267
|
+
return parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
|
|
268
|
+
}
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
function selectedBatchGroups(intent) {
|
|
272
|
+
if (intent.selection.kind !== 'selected' && intent.selection.kind !== 'targets') {
|
|
273
|
+
throw new TuiOperationBlockedError('syncSelectionRequired', '当前项目全部同步必须从项目 intent roots 解析。');
|
|
274
|
+
}
|
|
275
|
+
const rawTargets = intent.selection.kind === 'targets'
|
|
276
|
+
? intent.selection.targets
|
|
277
|
+
: intent.selection.pluginIds.map((pluginId) => ({
|
|
278
|
+
pluginId, platform: intent.platform, scope: intent.scope,
|
|
279
|
+
}));
|
|
280
|
+
const normalizedTargets = rawTargets.map((target) => {
|
|
281
|
+
if ((target.platform !== 'codex' && target.platform !== 'claude' && target.platform !== 'both')
|
|
282
|
+
|| (target.scope !== 'project' && target.scope !== 'user')
|
|
283
|
+
|| (intent.selection.kind === 'targets' && target.platform === 'both')) {
|
|
284
|
+
throw new TuiOperationBlockedError('batchTargetInvalid', '批量精确目标必须使用有效 scope 和单个平台。');
|
|
100
285
|
}
|
|
101
|
-
|
|
102
|
-
|
|
286
|
+
const pluginId = target.pluginId;
|
|
287
|
+
const parsed = parsePluginId(pluginId);
|
|
288
|
+
if (!parsed.sourceId) {
|
|
289
|
+
throw new TuiOperationBlockedError('invalidPluginId', '批量操作必须使用 canonical pluginId。');
|
|
103
290
|
}
|
|
104
|
-
|
|
105
|
-
|
|
291
|
+
const canonicalPluginId = formatPluginId({ sourceId: parsed.sourceId, pluginName: parsed.pluginName });
|
|
292
|
+
if (intent.selection.kind === 'targets' && canonicalPluginId !== pluginId) {
|
|
293
|
+
throw new TuiOperationBlockedError('invalidPluginId', '批量精确目标必须使用 canonical pluginId。');
|
|
106
294
|
}
|
|
295
|
+
return {
|
|
296
|
+
pluginId: canonicalPluginId,
|
|
297
|
+
platform: target.platform,
|
|
298
|
+
scope: target.scope,
|
|
299
|
+
};
|
|
300
|
+
}).sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
301
|
+
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en'));
|
|
302
|
+
const uniqueTargets = [...new Map(normalizedTargets.map((target) => [
|
|
303
|
+
[target.pluginId, target.platform, target.scope].join('\0'), target,
|
|
304
|
+
])).values()];
|
|
305
|
+
const requestedPluginIds = [...new Set(uniqueTargets.map((target) => target.pluginId))];
|
|
306
|
+
if (requestedPluginIds.length === 0) {
|
|
307
|
+
throw new TuiOperationBlockedError('syncSelectionRequired', '批量操作至少需要一个插件。');
|
|
308
|
+
}
|
|
309
|
+
const groups = new Map();
|
|
310
|
+
for (const target of uniqueTargets) {
|
|
311
|
+
const pluginId = target.pluginId;
|
|
312
|
+
const sourceId = parsePluginId(pluginId).sourceId;
|
|
313
|
+
const groupKey = intent.action === 'cleanup'
|
|
314
|
+
? ['cleanup', target.platform, target.scope].join('\0')
|
|
315
|
+
: [sourceId, target.platform, target.scope].join('\0');
|
|
316
|
+
const group = groups.get(groupKey) ?? {
|
|
317
|
+
groupId: groupKey,
|
|
318
|
+
sourceId: intent.action === 'cleanup' ? 'offline' : sourceId,
|
|
319
|
+
platform: target.platform,
|
|
320
|
+
scope: target.scope,
|
|
321
|
+
requestedPluginIds: [],
|
|
322
|
+
};
|
|
323
|
+
group.requestedPluginIds.push(pluginId);
|
|
324
|
+
groups.set(groupKey, group);
|
|
107
325
|
}
|
|
326
|
+
return { requestedPluginIds, groups: [...groups.values()] };
|
|
108
327
|
}
|
|
109
|
-
async function
|
|
110
|
-
if (
|
|
111
|
-
return;
|
|
112
|
-
const stale = (message) => {
|
|
113
|
-
throw new TuiOperationBlockedError('operationReviewStale', `operationReviewStale: ${message}`);
|
|
114
|
-
};
|
|
115
|
-
const selected = targets.find((target) => target.pluginId === intent.pluginId
|
|
116
|
-
&& target.platform === intent.platform
|
|
117
|
-
&& target.scope === intent.scope);
|
|
118
|
-
if (intent.originIssue.category === 'dependencyMissing') {
|
|
119
|
-
if (intent.originIssue.actionId !== 'installDependency'
|
|
120
|
-
|| intent.action !== 'install' || !selected || selected.state !== 'absent') {
|
|
121
|
-
stale('原缺失依赖问题已变化。');
|
|
122
|
-
}
|
|
328
|
+
async function resolveBatchGroups(intent, env, cwd, frozenRequestedPluginIds) {
|
|
329
|
+
if (intent.selection.kind === 'selected' || intent.selection.kind === 'targets') {
|
|
330
|
+
return selectedBatchGroups(intent);
|
|
123
331
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|| intent.action !== 'reinstall' || !selected
|
|
127
|
-
|| (selected.state !== 'partial' && selected.state !== 'error')) {
|
|
128
|
-
stale('原依赖安装问题已变化。');
|
|
129
|
-
}
|
|
332
|
+
if (intent.action !== 'sync' || intent.scope !== 'project') {
|
|
333
|
+
throw new TuiOperationBlockedError('syncSelectionRequired', '当前项目全部操作只支持 project scope sync。');
|
|
130
334
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
335
|
+
const state = await readPluginIntentState({ scope: 'project', cwd, env });
|
|
336
|
+
const projectIntentDigest = calculatePluginIntentDigest(state);
|
|
337
|
+
if (intent.selection.kind === 'currentProjectIntentTargets') {
|
|
338
|
+
if (intent.selection.targets.length === 0
|
|
339
|
+
|| intent.selection.targets.some((target) => target.scope !== 'project')) {
|
|
340
|
+
throw new TuiOperationBlockedError('batchTargetInvalid', '当前项目精确同步目标必须是非空 project targets。');
|
|
341
|
+
}
|
|
342
|
+
const exact = selectedBatchGroups({
|
|
343
|
+
...intent,
|
|
344
|
+
selection: { kind: 'targets', targets: intent.selection.targets },
|
|
345
|
+
});
|
|
346
|
+
const declaredPlatforms = new Map(state.roots.map((root) => [
|
|
347
|
+
root.pluginId,
|
|
348
|
+
new Set(root.platforms),
|
|
349
|
+
]));
|
|
350
|
+
if (intent.selection.targets.some((target) => !declaredPlatforms.get(target.pluginId)?.has(target.platform))) {
|
|
351
|
+
throw new TuiOperationBlockedError('batchTargetInvalid', '当前项目精确同步目标必须属于完整 project intent roots 声明。');
|
|
136
352
|
}
|
|
137
|
-
return;
|
|
353
|
+
return { ...exact, projectIntentDigest };
|
|
138
354
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
stale('原位置冲突已变化。');
|
|
148
|
-
}
|
|
149
|
-
return;
|
|
355
|
+
const selection = resolveSyncIntentSelection({
|
|
356
|
+
roots: state.roots,
|
|
357
|
+
selectors: frozenRequestedPluginIds ?? [],
|
|
358
|
+
all: frozenRequestedPluginIds === undefined,
|
|
359
|
+
platform: intent.platform,
|
|
360
|
+
});
|
|
361
|
+
if (selection.requestedPluginIds.length === 0) {
|
|
362
|
+
throw new TuiOperationBlockedError('syncSelectionRequired', '当前项目没有可同步的 intent roots。');
|
|
150
363
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
364
|
+
return {
|
|
365
|
+
requestedPluginIds: selection.requestedPluginIds,
|
|
366
|
+
projectIntentDigest,
|
|
367
|
+
groups: selection.groups.map((group) => ({
|
|
368
|
+
groupId: `${group.sourceId}\0${group.platform}\0${intent.scope}`,
|
|
369
|
+
sourceId: group.sourceId,
|
|
370
|
+
platform: group.platform,
|
|
371
|
+
scope: intent.scope,
|
|
372
|
+
requestedPluginIds: group.pluginIds,
|
|
373
|
+
})),
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
async function runBatchWriteGroup(options) {
|
|
377
|
+
const dependencyScopeOverrides = options.intent.action === 'install'
|
|
378
|
+
? options.intent.dependencyScopeOverrides?.filter((override) => parsePluginId(override.pluginId).sourceId === options.group.sourceId
|
|
379
|
+
&& (options.group.platform === 'both' || override.platform === options.group.platform))
|
|
380
|
+
: undefined;
|
|
381
|
+
const commandOptions = {
|
|
382
|
+
cwd: options.cwd,
|
|
383
|
+
...(dependencyScopeOverrides?.length ? { dependencyScopeOverrides } : {}),
|
|
384
|
+
platform: options.group.platform,
|
|
385
|
+
scope: options.group.scope,
|
|
386
|
+
...(reviewedScriptTimeoutMs(options.intent) === undefined
|
|
387
|
+
? {}
|
|
388
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(options.intent) }),
|
|
389
|
+
};
|
|
390
|
+
switch (options.intent.action) {
|
|
391
|
+
case 'install':
|
|
392
|
+
return installWriteCommand(options.group.requestedPluginIds, commandOptions, options.runtime);
|
|
393
|
+
case 'sync':
|
|
394
|
+
return syncWriteCommand(options.group.requestedPluginIds, commandOptions, options.runtime);
|
|
395
|
+
case 'reinstall':
|
|
396
|
+
return reinstallWriteCommand(options.group.requestedPluginIds, commandOptions, options.runtime);
|
|
397
|
+
case 'uninstall':
|
|
398
|
+
return uninstallWriteCommand(options.group.requestedPluginIds, commandOptions, options.runtime);
|
|
399
|
+
case 'cleanup':
|
|
400
|
+
return cleanupWriteCommand(options.group.requestedPluginIds, commandOptions, options.runtime);
|
|
160
401
|
}
|
|
161
|
-
const consumer = targets.find((target) => target.pluginId === origin.consumerPluginId
|
|
162
|
-
&& target.sourceIdentity === origin.consumerSourceIdentity
|
|
163
|
-
&& target.platform === origin.consumerPlatform
|
|
164
|
-
&& target.scope === origin.consumerScope);
|
|
165
|
-
const consumerError = consumer?.errors.some((error) => error.code === origin.category && error.message.includes(origin.dependencyPluginId));
|
|
166
|
-
if (!consumer || !consumerError)
|
|
167
|
-
stale('原 consumer 依赖问题已消失或变化。');
|
|
168
402
|
}
|
|
169
403
|
async function loadDependencyOverviews(options) {
|
|
170
404
|
const graph = await withResolvedMultiSourceCatalog({
|
|
171
405
|
cliVersion: options.cliVersion,
|
|
172
|
-
freshnessPolicy: 'cacheFirst',
|
|
173
406
|
env: options.context.env,
|
|
174
407
|
signal: options.signal,
|
|
408
|
+
...(options.catalogOperationContext
|
|
409
|
+
? { operationContext: options.catalogOperationContext }
|
|
410
|
+
: {}),
|
|
175
411
|
consume: async (catalog) => ({
|
|
176
|
-
nodes:
|
|
177
|
-
?
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
412
|
+
nodes: catalog.sources.flatMap((item) => item.resolution
|
|
413
|
+
? item.resolution.manifest.entries.map((entry) => ({
|
|
414
|
+
pluginId: formatPluginId({
|
|
415
|
+
sourceId: item.resolution.sourceId,
|
|
416
|
+
pluginName: entry.name,
|
|
417
|
+
}),
|
|
418
|
+
sourceIdentity: item.resolution.sourceIdentity,
|
|
419
|
+
displayName: entry.interface?.displayName ?? entry.name,
|
|
420
|
+
dependencies: entry.dependencies.map((pluginName) => formatPluginId({ sourceId: item.resolution.sourceId, pluginName })),
|
|
421
|
+
}))
|
|
422
|
+
: []),
|
|
185
423
|
sourceErrors: catalog.sources.flatMap((item) => item.error
|
|
186
424
|
? [{ sourceId: item.sourceId, code: 'dependencyGraphInvalid' }]
|
|
187
425
|
: []),
|
|
188
426
|
}),
|
|
189
427
|
});
|
|
190
428
|
const nodes = new Map(graph.nodes.map((node) => [node.pluginId, node]));
|
|
429
|
+
const summaryById = new Map(options.status.pluginSummaries.map((summary) => [summary.pluginId, summary]));
|
|
191
430
|
const displayName = (pluginId) => nodes.get(pluginId)?.displayName
|
|
192
431
|
?? parsePluginId(pluginId).pluginName;
|
|
193
432
|
const reverse = new Map();
|
|
@@ -197,43 +436,61 @@ async function loadDependencyOverviews(options) {
|
|
|
197
436
|
}
|
|
198
437
|
}
|
|
199
438
|
const targetsByPlugin = new Map();
|
|
200
|
-
for (const target of options.status.payload.targets) {
|
|
439
|
+
for (const target of flattenStatusTargets(options.status.payload.targets)) {
|
|
201
440
|
targetsByPlugin.set(target.pluginId, [...(targetsByPlugin.get(target.pluginId) ?? []), target]);
|
|
202
441
|
}
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
scope:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
442
|
+
const unsupportedPluginIds = new Set(options.status.pluginSummaries
|
|
443
|
+
.filter((summary) => (summary.missingCapabilities?.length ?? 0) > 0)
|
|
444
|
+
.map((summary) => summary.pluginId));
|
|
445
|
+
const availableReferencesFor = (consumerPluginId, dependencyPluginId) => {
|
|
446
|
+
const consumerSourceId = parsePluginId(consumerPluginId).sourceId;
|
|
447
|
+
const dependencySourceId = parsePluginId(dependencyPluginId).sourceId;
|
|
448
|
+
const consumerNode = nodes.get(consumerPluginId);
|
|
449
|
+
const dependencyNode = nodes.get(dependencyPluginId);
|
|
450
|
+
if (consumerSourceId !== dependencySourceId
|
|
451
|
+
|| !nodes.get(consumerPluginId)?.dependencies.includes(dependencyPluginId))
|
|
452
|
+
return [];
|
|
453
|
+
return (targetsByPlugin.get(consumerPluginId) ?? []).flatMap((consumer) => {
|
|
454
|
+
if (!hasActualScopeEvidence(consumer)
|
|
455
|
+
|| consumer.sourceId !== consumerSourceId
|
|
456
|
+
|| consumer.sourceIdentity !== consumerNode?.sourceIdentity)
|
|
457
|
+
return [];
|
|
458
|
+
return [...consumer.components, ...(consumer.sharedComponents ?? [])].flatMap((component) => {
|
|
459
|
+
if (component.kind !== 'dependency'
|
|
460
|
+
|| component.key !== dependencyPluginId
|
|
461
|
+
|| component.state !== 'ready')
|
|
462
|
+
return [];
|
|
463
|
+
const platform = component.metadata?.platform;
|
|
464
|
+
const scope = component.metadata?.scope;
|
|
465
|
+
const project = component.metadata?.project;
|
|
466
|
+
if ((platform !== 'codex' && platform !== 'claude')
|
|
467
|
+
|| (scope !== 'user' && scope !== 'project')
|
|
468
|
+
|| project !== (scope === 'project' ? 'current' : 'none'))
|
|
469
|
+
return [];
|
|
470
|
+
const dependency = (targetsByPlugin.get(dependencyPluginId) ?? []).find((target) => target.platform === platform
|
|
471
|
+
&& target.scope === scope
|
|
472
|
+
&& target.sourceId === dependencySourceId
|
|
473
|
+
&& target.sourceIdentity === dependencyNode?.sourceIdentity
|
|
474
|
+
&& target.sourceIdentity === consumer.sourceIdentity);
|
|
475
|
+
if (!dependency)
|
|
476
|
+
return [];
|
|
477
|
+
return [{
|
|
478
|
+
consumer: {
|
|
479
|
+
pluginId: consumerPluginId,
|
|
480
|
+
platform: consumer.platform,
|
|
481
|
+
scope: consumer.scope,
|
|
482
|
+
project: consumer.scope === 'project' ? 'current' : null,
|
|
483
|
+
},
|
|
484
|
+
dependency: {
|
|
485
|
+
pluginId: dependencyPluginId,
|
|
486
|
+
platform,
|
|
487
|
+
scope,
|
|
488
|
+
project: scope === 'project' ? 'current' : null,
|
|
489
|
+
},
|
|
490
|
+
}];
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
};
|
|
237
494
|
const placementsFor = (pluginId) => {
|
|
238
495
|
const targets = targetsByPlugin.get(pluginId) ?? [];
|
|
239
496
|
if (targets.length > 0) {
|
|
@@ -246,13 +503,15 @@ async function loadDependencyOverviews(options) {
|
|
|
246
503
|
};
|
|
247
504
|
const aggregateFor = (pluginId, placements) => {
|
|
248
505
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
249
|
-
if (graph.sourceErrors.some((error) => error.sourceId === sourceId)
|
|
506
|
+
if (graph.sourceErrors.some((error) => error.sourceId === sourceId)
|
|
507
|
+
|| unsupportedPluginIds.has(pluginId))
|
|
250
508
|
return 'unavailable';
|
|
251
509
|
if (placements.length === 0 || placements.every((placement) => placement.state === 'notInstalled')) {
|
|
252
510
|
return 'notInstalled';
|
|
253
511
|
}
|
|
254
512
|
return placements.some((placement) => placement.state === 'scopeConflict'
|
|
255
|
-
|| (placement.state === 'installed'
|
|
513
|
+
|| (placement.state === 'installed'
|
|
514
|
+
&& (placement.health !== 'ready' || placement.blockingReason !== undefined)))
|
|
256
515
|
? 'needsAttention'
|
|
257
516
|
: 'ready';
|
|
258
517
|
};
|
|
@@ -303,7 +562,8 @@ async function loadDependencyOverviews(options) {
|
|
|
303
562
|
})),
|
|
304
563
|
placements,
|
|
305
564
|
aggregateStatus: aggregateFor(dependency.pluginId, placements),
|
|
306
|
-
placementReferences:
|
|
565
|
+
placementReferences: [],
|
|
566
|
+
availablePlacementReferences: availableReferencesFor(pluginId, dependency.pluginId),
|
|
307
567
|
};
|
|
308
568
|
});
|
|
309
569
|
const dependentIds = [...new Set(reverse.get(pluginId) ?? [])].sort();
|
|
@@ -317,15 +577,23 @@ async function loadDependencyOverviews(options) {
|
|
|
317
577
|
requiredBy: [],
|
|
318
578
|
placements,
|
|
319
579
|
aggregateStatus: aggregateFor(dependentId, placements),
|
|
320
|
-
placementReferences:
|
|
580
|
+
placementReferences: [],
|
|
581
|
+
availablePlacementReferences: availableReferencesFor(dependentId, pluginId),
|
|
321
582
|
};
|
|
322
583
|
});
|
|
323
|
-
const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.
|
|
584
|
+
const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.reasons.filter((error) => error.code.startsWith('dependency') || error.code === 'sourceChanged')
|
|
324
585
|
.map((error) => ({
|
|
325
586
|
code: error.code,
|
|
326
587
|
title: '依赖关系需要处理',
|
|
327
588
|
explanation: '当前目标的依赖证据不能安全通过检查。',
|
|
328
589
|
})));
|
|
590
|
+
const consumerTargets = summaryById.get(pluginId)?.supportedTargets;
|
|
591
|
+
const unsupportedDependency = dependencyItems.find((dependency) => {
|
|
592
|
+
const dependencyTargets = summaryById.get(dependency.pluginId)?.supportedTargets;
|
|
593
|
+
if (!consumerTargets || !dependencyTargets)
|
|
594
|
+
return true;
|
|
595
|
+
return ['codex', 'claude'].some((platform) => consumerTargets[platform].length > 0 && dependencyTargets[platform].length === 0);
|
|
596
|
+
});
|
|
329
597
|
const sourceId = parsePluginId(pluginId).sourceId;
|
|
330
598
|
const blockers = [
|
|
331
599
|
...graph.sourceErrors.filter((error) => error.sourceId === sourceId).map((error) => ({
|
|
@@ -338,6 +606,11 @@ async function loadDependencyOverviews(options) {
|
|
|
338
606
|
title: '依赖关系无效',
|
|
339
607
|
explanation: '依赖关系形成环。',
|
|
340
608
|
}] : []),
|
|
609
|
+
...(unsupportedDependency ? [{
|
|
610
|
+
code: 'dependencyTargetUnsupported',
|
|
611
|
+
title: '依赖目标不兼容',
|
|
612
|
+
explanation: `${unsupportedDependency.displayName} 不支持根插件所需的平台。`,
|
|
613
|
+
}] : []),
|
|
341
614
|
...targetBlockers,
|
|
342
615
|
];
|
|
343
616
|
const directCount = dependencyItems.filter((item) => item.relation === 'direct').length;
|
|
@@ -360,46 +633,231 @@ async function loadDependencyOverviews(options) {
|
|
|
360
633
|
};
|
|
361
634
|
});
|
|
362
635
|
}
|
|
363
|
-
|
|
636
|
+
function createReviewStageReporter(options) {
|
|
637
|
+
let active;
|
|
638
|
+
const finish = async () => {
|
|
639
|
+
if (!active)
|
|
640
|
+
return;
|
|
641
|
+
const completed = active;
|
|
642
|
+
active = undefined;
|
|
643
|
+
await Promise.allSettled([Promise.resolve().then(() => options.context.debugLogger.log({
|
|
644
|
+
type: `review.prepare.${completed.stage}`,
|
|
645
|
+
level: 'debug',
|
|
646
|
+
target: 'debugLog',
|
|
647
|
+
message: 'TUI review preparation stage completed.',
|
|
648
|
+
data: { durationMs: Math.max(0, options.now() - completed.startedAt) },
|
|
649
|
+
}))]);
|
|
650
|
+
};
|
|
651
|
+
return {
|
|
652
|
+
async emit(stage) {
|
|
653
|
+
await finish();
|
|
654
|
+
active = { stage, startedAt: options.now() };
|
|
655
|
+
await options.onStage(stage);
|
|
656
|
+
},
|
|
657
|
+
finish,
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
export function createTuiControllerDependencies(context, progressFeed, options = {}) {
|
|
661
|
+
const readInventory = options.inventoryCatalogSourceReferences
|
|
662
|
+
?? inventoryCatalogSourceReferences;
|
|
663
|
+
const validatedStoreEntries = new Map();
|
|
664
|
+
const validatingStoreEntries = new Map();
|
|
665
|
+
const loadCatalogGenerations = async () => {
|
|
666
|
+
const generations = await loadCatalogGenerationViewModels({
|
|
667
|
+
env: context.env,
|
|
668
|
+
validatedStoreEntries,
|
|
669
|
+
validatingStoreEntries,
|
|
670
|
+
onStage: (event) => context.debugLogger.log({
|
|
671
|
+
type: 'performance:stage',
|
|
672
|
+
level: 'debug',
|
|
673
|
+
target: 'debugLog',
|
|
674
|
+
message: 'Catalog generation load stage completed.',
|
|
675
|
+
data: event,
|
|
676
|
+
}),
|
|
677
|
+
});
|
|
678
|
+
const retained = new Set(generations.flatMap((source) => [
|
|
679
|
+
source.active?.storeKey,
|
|
680
|
+
].filter((value) => value !== undefined)));
|
|
681
|
+
for (const storeKey of validatedStoreEntries.keys()) {
|
|
682
|
+
if (!retained.has(storeKey))
|
|
683
|
+
validatedStoreEntries.delete(storeKey);
|
|
684
|
+
}
|
|
685
|
+
return generations;
|
|
686
|
+
};
|
|
687
|
+
const createOperationInventoryReader = () => {
|
|
688
|
+
let ordinaryInventory;
|
|
689
|
+
return (inventoryOptions) => {
|
|
690
|
+
ordinaryInventory ??= readInventory(inventoryOptions);
|
|
691
|
+
return ordinaryInventory;
|
|
692
|
+
};
|
|
693
|
+
};
|
|
694
|
+
const catalogOperationByEvidence = new WeakMap();
|
|
695
|
+
const taskCatalogOperationsByEvidence = new WeakMap();
|
|
696
|
+
const codexManagerByEvidence = new WeakMap();
|
|
697
|
+
let sessionCatalogOperationContext;
|
|
698
|
+
let sessionStatusResult;
|
|
699
|
+
const sessionContextForPlugin = (pluginId) => {
|
|
700
|
+
const sourceId = parsePluginId(pluginId).sourceId;
|
|
701
|
+
if (!sourceId || !sessionCatalogOperationContext)
|
|
702
|
+
return undefined;
|
|
703
|
+
return selectCatalogOperationContext(sessionCatalogOperationContext, [sourceId]);
|
|
704
|
+
};
|
|
705
|
+
const readConfigStoresForTui = async (config) => {
|
|
706
|
+
const scopes = config.scope === 'user' ? ['user'] : ['user', 'project'];
|
|
707
|
+
const stores = await Promise.all(scopes.map((scope) => readPluginConfigStore({
|
|
708
|
+
sourceId: config.sourceId,
|
|
709
|
+
sourceIdentity: config.sourceIdentity,
|
|
710
|
+
logicalIdentity: config.logicalIdentity,
|
|
711
|
+
pluginName: config.pluginName,
|
|
712
|
+
scope,
|
|
713
|
+
cwd: context.cwd,
|
|
714
|
+
env: context.env,
|
|
715
|
+
schema: config.schema,
|
|
716
|
+
})));
|
|
717
|
+
const user = stores[0];
|
|
718
|
+
const project = config.scope === 'user' ? undefined : stores[1];
|
|
719
|
+
config.signal.throwIfAborted();
|
|
720
|
+
const invalidStores = ([
|
|
721
|
+
{ scope: 'user', store: user },
|
|
722
|
+
...(project ? [{ scope: 'project', store: project }] : []),
|
|
723
|
+
]).flatMap(({ scope, store }) => store.state === 'invalid' ? [{
|
|
724
|
+
scope,
|
|
725
|
+
code: store.invalidCode,
|
|
726
|
+
pathSummary: scope === 'user'
|
|
727
|
+
? `AW_HOME/plugin-config/${config.sourceId ?? '<source>'}/${config.pluginName}/config.json`
|
|
728
|
+
: `<project>/.agent-workflows/plugin-config/${config.sourceId ?? '<source>'}/${config.pluginName}/config.json`,
|
|
729
|
+
}] : []);
|
|
730
|
+
if (invalidStores.length > 0)
|
|
731
|
+
throw new TuiConfigInvalidStoreError(invalidStores);
|
|
732
|
+
return { user, ...(project ? { project } : {}) };
|
|
733
|
+
};
|
|
364
734
|
const loadStatus = async (signal) => {
|
|
365
735
|
signal.throwIfAborted();
|
|
366
736
|
const packageInfo = await readCliPackageInfo();
|
|
737
|
+
const catalogOperationContext = sessionCatalogOperationContext
|
|
738
|
+
?? await resolvePartialCatalogOperationContext({
|
|
739
|
+
env: context.env,
|
|
740
|
+
signal,
|
|
741
|
+
validatedStoreEntries,
|
|
742
|
+
validatingStoreEntries,
|
|
743
|
+
}).catch(async (error) => {
|
|
744
|
+
if (!(error instanceof CatalogGenerationError)
|
|
745
|
+
|| error.code !== 'catalogGenerationStateInvalid')
|
|
746
|
+
return undefined;
|
|
747
|
+
const snapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
748
|
+
const primarySourceId = snapshot.config.sources.find((source) => source.primary).id;
|
|
749
|
+
const generationSetDigest = calculateCatalogGenerationSetDigest(snapshot.digest, primarySourceId, []);
|
|
750
|
+
return {
|
|
751
|
+
generationSet: {
|
|
752
|
+
generationSetDigest,
|
|
753
|
+
configDigest: snapshot.digest,
|
|
754
|
+
primarySourceId,
|
|
755
|
+
sources: [],
|
|
756
|
+
},
|
|
757
|
+
generationSetDigest,
|
|
758
|
+
catalog: {
|
|
759
|
+
sources: snapshot.config.sources.map((source) => ({
|
|
760
|
+
sourceId: source.id,
|
|
761
|
+
error,
|
|
762
|
+
})),
|
|
763
|
+
primarySourceId,
|
|
764
|
+
configDigest: snapshot.digest,
|
|
765
|
+
compositeDigest: generationSetDigest,
|
|
766
|
+
},
|
|
767
|
+
};
|
|
768
|
+
});
|
|
769
|
+
if (catalogOperationContext)
|
|
770
|
+
sessionCatalogOperationContext = catalogOperationContext;
|
|
367
771
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
368
|
-
const result = await
|
|
772
|
+
const result = await statusCommandV8({
|
|
369
773
|
cwd: context.cwd,
|
|
370
774
|
env: context.env,
|
|
775
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
371
776
|
cliVersion: packageInfo.version,
|
|
372
777
|
verbose: context.diagnostics.verbose,
|
|
778
|
+
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
779
|
+
inventoryCatalogSourceReferences: readInventory,
|
|
373
780
|
});
|
|
374
781
|
signal.throwIfAborted();
|
|
375
782
|
const configured = await listCatalogSources({ env: context.env });
|
|
376
783
|
signal.throwIfAborted();
|
|
377
784
|
if (result.payload.catalog.configDigest !== configured.configDigest)
|
|
378
785
|
continue;
|
|
786
|
+
sessionStatusResult = result;
|
|
379
787
|
const dependencyOverviews = await loadDependencyOverviews({
|
|
380
788
|
context,
|
|
381
789
|
cliVersion: packageInfo.version,
|
|
382
790
|
status: result,
|
|
383
791
|
signal,
|
|
792
|
+
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
384
793
|
});
|
|
385
794
|
const portablePluginIds = await loadPortablePluginIds({
|
|
386
795
|
context,
|
|
387
796
|
cliVersion: packageInfo.version,
|
|
388
797
|
signal,
|
|
798
|
+
...(catalogOperationContext ? { catalogOperationContext } : {}),
|
|
389
799
|
});
|
|
390
800
|
signal.throwIfAborted();
|
|
801
|
+
const catalogGenerations = await loadCatalogGenerations();
|
|
802
|
+
signal.throwIfAborted();
|
|
803
|
+
const configStoreInventory = (await Promise.all(['user', 'project'].map(async (scope) => {
|
|
804
|
+
try {
|
|
805
|
+
return (await listNamespacedPluginConfigStoreIdentities({
|
|
806
|
+
cwd: context.cwd,
|
|
807
|
+
env: context.env,
|
|
808
|
+
scope,
|
|
809
|
+
})).map(({ pluginId, sourceId, pluginName }) => ({
|
|
810
|
+
pluginId, sourceId, pluginName, scope,
|
|
811
|
+
}));
|
|
812
|
+
}
|
|
813
|
+
catch {
|
|
814
|
+
await context.debugLogger.log({
|
|
815
|
+
type: 'tui:config-inventory-error',
|
|
816
|
+
level: 'debug',
|
|
817
|
+
target: 'debugLog',
|
|
818
|
+
message: 'TUI saved config inventory could not be read.',
|
|
819
|
+
data: { scope },
|
|
820
|
+
});
|
|
821
|
+
return [];
|
|
822
|
+
}
|
|
823
|
+
}))).flat();
|
|
824
|
+
signal.throwIfAborted();
|
|
391
825
|
const statusById = new Map(result.payload.catalog.sources.map((source) => [source.id, source]));
|
|
826
|
+
const projectIntentObservation = result.projectIntentObservation;
|
|
827
|
+
const projectIntent = projectIntentObservation.state === 'ready' ? {
|
|
828
|
+
state: 'ready',
|
|
829
|
+
roots: structuredClone(projectIntentObservation.value.roots),
|
|
830
|
+
} : projectIntentObservation.state === 'absent' ? {
|
|
831
|
+
state: 'absent',
|
|
832
|
+
} : {
|
|
833
|
+
state: projectIntentObservation.state,
|
|
834
|
+
code: projectIntentObservation.code,
|
|
835
|
+
message: projectIntentObservation.message,
|
|
836
|
+
};
|
|
392
837
|
return {
|
|
838
|
+
cliChannel: packageInfo.version.includes('-') ? 'beta' : 'latest',
|
|
839
|
+
...(result.projectRoot ? { projectRoot: result.projectRoot } : {}),
|
|
840
|
+
projectIntent,
|
|
841
|
+
...(projectIntent.state === 'ready'
|
|
842
|
+
? { projectIntentRoots: structuredClone(projectIntent.roots) }
|
|
843
|
+
: {}),
|
|
844
|
+
configuredSources: structuredClone(configured.sources),
|
|
393
845
|
payload: result.payload,
|
|
394
846
|
pluginSummaries: result.pluginSummaries,
|
|
847
|
+
targetRevisions: result.targetRevisions,
|
|
395
848
|
dependencyOverviews,
|
|
396
849
|
portablePluginIds,
|
|
850
|
+
configStoreInventory,
|
|
851
|
+
catalogGenerations,
|
|
852
|
+
sessionGenerationKeys: Object.fromEntries((catalogOperationContext?.generationSet.sources ?? [])
|
|
853
|
+
.map((source) => [source.sourceId, source.storeKey])),
|
|
397
854
|
sourceDetails: configured.sources.map((source) => {
|
|
398
855
|
const status = statusById.get(source.id);
|
|
399
856
|
return {
|
|
400
857
|
id: source.id,
|
|
401
858
|
type: source.type,
|
|
402
859
|
primary: source.primary,
|
|
860
|
+
autoCheck: source.autoCheck,
|
|
403
861
|
locationSummary: projectCatalogSourceLocation(source.type === 'git' ? source.url : source.path),
|
|
404
862
|
...(source.type === 'git' ? {
|
|
405
863
|
refPolicy: source.refPolicy.type,
|
|
@@ -413,6 +871,7 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
413
871
|
...(status?.catalogVersion ? { catalogVersion: status.catalogVersion } : {}),
|
|
414
872
|
...(status?.channel ? { channel: status.channel } : {}),
|
|
415
873
|
...(status?.freshness ? { freshness: status.freshness } : {}),
|
|
874
|
+
...(status?.errorCode ? { errorCode: status.errorCode } : {}),
|
|
416
875
|
configDigest: configured.configDigest,
|
|
417
876
|
};
|
|
418
877
|
}),
|
|
@@ -420,7 +879,475 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
420
879
|
}
|
|
421
880
|
throw new TuiOperationBlockedError('operationReviewStale', '状态读取期间来源配置持续变化。请重试。');
|
|
422
881
|
};
|
|
423
|
-
const
|
|
882
|
+
const loadPluginContent = async (pluginId, signal) => {
|
|
883
|
+
signal.throwIfAborted();
|
|
884
|
+
try {
|
|
885
|
+
const packageInfo = await readCliPackageInfo();
|
|
886
|
+
const catalogOperation = sessionContextForPlugin(pluginId);
|
|
887
|
+
return await withResolvedCatalogPlugin({
|
|
888
|
+
selector: pluginId,
|
|
889
|
+
cliVersion: packageInfo.version,
|
|
890
|
+
env: context.env,
|
|
891
|
+
signal,
|
|
892
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
893
|
+
consume: ({ plugin, source }) => projectPluginContentOverview({
|
|
894
|
+
pluginId,
|
|
895
|
+
catalogVersion: source.manifest.catalogVersion,
|
|
896
|
+
plugin,
|
|
897
|
+
}),
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
catch {
|
|
901
|
+
signal.throwIfAborted();
|
|
902
|
+
const summary = sessionStatusResult?.pluginSummaries.find((entry) => entry.pluginId === pluginId);
|
|
903
|
+
let sourceId;
|
|
904
|
+
try {
|
|
905
|
+
sourceId = parsePluginId(pluginId).sourceId;
|
|
906
|
+
}
|
|
907
|
+
catch {
|
|
908
|
+
// The fixed unavailable result below does not repeat an unsafe selector.
|
|
909
|
+
}
|
|
910
|
+
const catalogVersion = sessionStatusResult?.payload.catalog.sources
|
|
911
|
+
.find((source) => source.id === sourceId)?.catalogVersion;
|
|
912
|
+
return {
|
|
913
|
+
pluginId,
|
|
914
|
+
pluginVersion: summary?.version ?? '待确认',
|
|
915
|
+
catalogVersion: catalogVersion ?? '待确认',
|
|
916
|
+
evidence: 'unavailable',
|
|
917
|
+
items: [],
|
|
918
|
+
notices: ['当前无法安全读取这个插件的目录内容。请检查来源状态后重试。'],
|
|
919
|
+
coverage: 'unavailable',
|
|
920
|
+
coverageIssue: {
|
|
921
|
+
code: 'unreadable',
|
|
922
|
+
message: '当前无法安全读取这个插件的目录内容。请检查来源状态后重试。',
|
|
923
|
+
},
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
const captureEvidence = async (intent, signal, preparation, operationInventory = createOperationInventoryReader(), freshCatalog = false, reusableCandidate, codexObservationSession, frozenBatchEvidence) => {
|
|
928
|
+
reviewedScriptTimeoutMs(intent);
|
|
929
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
930
|
+
signal?.throwIfAborted();
|
|
931
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
932
|
+
const catalogStore = await prepareCatalogStoreTask({ env: context.env });
|
|
933
|
+
signal?.throwIfAborted();
|
|
934
|
+
return {
|
|
935
|
+
catalog: { configDigest: config.digest, compositeDigest: config.digest },
|
|
936
|
+
catalogStore,
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
if (intent.kind === 'configSaveBatch') {
|
|
940
|
+
assertConfigSaveBatchIntent(intent);
|
|
941
|
+
const groupEvidence = [];
|
|
942
|
+
let batchBase;
|
|
943
|
+
let batchCatalogOperation;
|
|
944
|
+
for (const group of intent.groups) {
|
|
945
|
+
const current = await captureEvidence(configSaveBatchGroupIntent(intent, group), signal, preparation, operationInventory, freshCatalog, reusableCandidate, codexObservationSession);
|
|
946
|
+
if (!current.config || !current.source || !current.targetFingerprint) {
|
|
947
|
+
throw operationReviewStale('设置批次缺少单层证据。');
|
|
948
|
+
}
|
|
949
|
+
if (batchBase && (JSON.stringify(batchBase.catalog) !== JSON.stringify(current.catalog)
|
|
950
|
+
|| JSON.stringify(batchBase.source) !== JSON.stringify(current.source))) {
|
|
951
|
+
throw operationReviewStale('准备设置批次期间 Catalog 或来源发生变化。');
|
|
952
|
+
}
|
|
953
|
+
for (const expected of Object.values(group.editEvidence ?? {})) {
|
|
954
|
+
if (expected.sourceIdentity !== current.source.sourceIdentity
|
|
955
|
+
|| expected.schemaIdentity !== current.config.schemaIdentity) {
|
|
956
|
+
throw operationReviewStale('编辑期间插件来源或设置定义已变化,请重新打开列表。');
|
|
957
|
+
}
|
|
958
|
+
for (const scope of ['user', 'project']) {
|
|
959
|
+
if (expected.storeDigests[scope] === undefined)
|
|
960
|
+
continue;
|
|
961
|
+
const currentDigest = await configLayerStoreDigest({
|
|
962
|
+
source: current.source, pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
963
|
+
scope, cwd: context.cwd, env: context.env,
|
|
964
|
+
});
|
|
965
|
+
if (expected.storeDigests[scope] !== currentDigest) {
|
|
966
|
+
throw operationReviewStale('编辑期间设置已被外部修改,请重新打开列表。');
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
batchBase ??= current;
|
|
971
|
+
batchCatalogOperation ??= catalogOperationByEvidence.get(current);
|
|
972
|
+
groupEvidence.push({
|
|
973
|
+
scope: group.scope,
|
|
974
|
+
config: {
|
|
975
|
+
...current.config,
|
|
976
|
+
storeDigest: await configLayerStoreDigest({
|
|
977
|
+
source: current.source,
|
|
978
|
+
pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
979
|
+
scope: group.scope,
|
|
980
|
+
cwd: context.cwd,
|
|
981
|
+
env: context.env,
|
|
982
|
+
}),
|
|
983
|
+
},
|
|
984
|
+
targetFingerprint: current.targetFingerprint,
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
const evidence = {
|
|
988
|
+
catalog: batchBase.catalog,
|
|
989
|
+
source: batchBase.source,
|
|
990
|
+
configBatch: { groups: groupEvidence },
|
|
991
|
+
};
|
|
992
|
+
if (batchCatalogOperation)
|
|
993
|
+
catalogOperationByEvidence.set(evidence, batchCatalogOperation);
|
|
994
|
+
return evidence;
|
|
995
|
+
}
|
|
996
|
+
if ((intent.kind === 'pluginWrite'
|
|
997
|
+
&& (intent.platform === 'codex' || intent.platform === 'both')
|
|
998
|
+
|| intent.kind === 'pluginWriteTask'
|
|
999
|
+
&& intent.targets.some((target) => target.platform === 'codex'))
|
|
1000
|
+
&& !codexObservationSession) {
|
|
1001
|
+
const observationSession = await createCodexNativeObservationSession({
|
|
1002
|
+
exactCwd: context.cwd,
|
|
1003
|
+
env: context.env,
|
|
1004
|
+
runner: context.nativeCliRunner,
|
|
1005
|
+
});
|
|
1006
|
+
try {
|
|
1007
|
+
return await captureEvidence(intent, signal, preparation, operationInventory, freshCatalog, reusableCandidate, observationSession, frozenBatchEvidence);
|
|
1008
|
+
}
|
|
1009
|
+
finally {
|
|
1010
|
+
await observationSession.dispose();
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (intent.kind === 'configReset') {
|
|
1014
|
+
const parsed = parsePluginId(intent.pluginId);
|
|
1015
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
1016
|
+
throw new TuiOperationBlockedError('invalidPluginId', '设置目标必须使用 canonical pluginId。');
|
|
1017
|
+
}
|
|
1018
|
+
await preparation?.reporter.emit('config');
|
|
1019
|
+
const target = await inspectPluginConfigResetTarget({
|
|
1020
|
+
sourceId: parsed.sourceId,
|
|
1021
|
+
pluginName: parsed.pluginName,
|
|
1022
|
+
scope: intent.scope,
|
|
1023
|
+
cwd: context.cwd,
|
|
1024
|
+
env: context.env,
|
|
1025
|
+
});
|
|
1026
|
+
signal?.throwIfAborted();
|
|
1027
|
+
if (target.kind === 'special') {
|
|
1028
|
+
throw new TuiOperationBlockedError('configResetTargetUnsupported', '设置目标是特殊文件系统节点,不能自动重置。请手动移动后重试。');
|
|
1029
|
+
}
|
|
1030
|
+
const relevantTargets = sessionStatusResult
|
|
1031
|
+
? configAffectedStatusTargets(sessionStatusResult.payload.targets, intent.pluginId, intent.scope)
|
|
1032
|
+
: [];
|
|
1033
|
+
const relevantRevisions = (sessionStatusResult?.targetRevisions ?? []).filter((revision) => relevantTargets.some((statusTarget) => statusTarget.platform === revision.platform
|
|
1034
|
+
&& statusTarget.scope === revision.scope
|
|
1035
|
+
&& statusTarget.pluginId === revision.pluginId));
|
|
1036
|
+
let selected;
|
|
1037
|
+
try {
|
|
1038
|
+
const packageInfo = await readCliPackageInfo();
|
|
1039
|
+
selected = await withResolvedCatalogPlugin({
|
|
1040
|
+
selector: intent.pluginId,
|
|
1041
|
+
cliVersion: packageInfo.version,
|
|
1042
|
+
env: context.env,
|
|
1043
|
+
...(preparation && sessionContextForPlugin(intent.pluginId)
|
|
1044
|
+
? { operationContext: sessionContextForPlugin(intent.pluginId) }
|
|
1045
|
+
: {}),
|
|
1046
|
+
...(signal ? { signal } : {}),
|
|
1047
|
+
consume: async ({ plugin, source: resolvedSource }) => ({
|
|
1048
|
+
source: sourceEvidenceForPlugin(resolvedSource, plugin.manifest.name),
|
|
1049
|
+
impact: await analyzePluginConfigMutationImpact({
|
|
1050
|
+
plugin,
|
|
1051
|
+
scope: intent.scope,
|
|
1052
|
+
cwd: context.cwd,
|
|
1053
|
+
env: context.env,
|
|
1054
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, relevantTargets),
|
|
1055
|
+
mutation: { kind: 'reset' },
|
|
1056
|
+
}),
|
|
1057
|
+
}),
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
catch {
|
|
1061
|
+
selected = undefined;
|
|
1062
|
+
}
|
|
1063
|
+
signal?.throwIfAborted();
|
|
1064
|
+
await preparation?.reporter.emit('evidence');
|
|
1065
|
+
return {
|
|
1066
|
+
catalog: sessionStatusResult ? {
|
|
1067
|
+
configDigest: sessionStatusResult.payload.catalog.configDigest,
|
|
1068
|
+
compositeDigest: sessionStatusResult.payload.catalog.compositeDigest,
|
|
1069
|
+
} : {
|
|
1070
|
+
configDigest: 'config-reset-offline',
|
|
1071
|
+
compositeDigest: 'config-reset-target',
|
|
1072
|
+
},
|
|
1073
|
+
...(selected ? { source: selected.source } : {}),
|
|
1074
|
+
...(sessionStatusResult ? {
|
|
1075
|
+
targetFingerprint: statusTargetFingerprint(relevantTargets, relevantRevisions),
|
|
1076
|
+
} : {}),
|
|
1077
|
+
config: {
|
|
1078
|
+
scope: intent.scope,
|
|
1079
|
+
storeDigest: selected?.impact.storeDigest ?? target.fingerprint,
|
|
1080
|
+
impactState: selected?.impact.impactState ?? 'unknown',
|
|
1081
|
+
...(selected?.impact.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
1082
|
+
affectedTargets: (selected?.impact.affectedTargets
|
|
1083
|
+
?? relevantTargets).map(({ platform, scope }) => ({ platform, scope })),
|
|
1084
|
+
...((selected?.impact.sharedNativeRenderTargets.length ?? 0) > 0
|
|
1085
|
+
? { sharedNativeRenderTargets: selected.impact.sharedNativeRenderTargets }
|
|
1086
|
+
: {}),
|
|
1087
|
+
},
|
|
1088
|
+
resetTarget: {
|
|
1089
|
+
sourceId: parsed.sourceId,
|
|
1090
|
+
pluginName: parsed.pluginName,
|
|
1091
|
+
scope: intent.scope,
|
|
1092
|
+
kind: target.kind,
|
|
1093
|
+
fingerprint: target.fingerprint,
|
|
1094
|
+
},
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
if (intent.kind === 'catalogSourcesRecovery') {
|
|
1098
|
+
signal?.throwIfAborted();
|
|
1099
|
+
await preparation?.reporter.emit('validate');
|
|
1100
|
+
await preparation?.reporter.emit('evidence');
|
|
1101
|
+
return {
|
|
1102
|
+
catalog: {
|
|
1103
|
+
configDigest: 'invalid-catalog-sources-config',
|
|
1104
|
+
compositeDigest: 'bootstrap-recovery',
|
|
1105
|
+
},
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
if (intent.kind === 'catalogGeneration') {
|
|
1109
|
+
signal?.throwIfAborted();
|
|
1110
|
+
await preparation?.reporter.emit('validate');
|
|
1111
|
+
const packageInfo = await readCliPackageInfo();
|
|
1112
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
1113
|
+
const configuredSource = config.config.sources.find((source) => source.id === intent.sourceId);
|
|
1114
|
+
let proposedSource;
|
|
1115
|
+
let proposedConfigDigest;
|
|
1116
|
+
let explicitSourceChange = false;
|
|
1117
|
+
let sourceIdentityChangeImpact;
|
|
1118
|
+
if (intent.sourceMutation) {
|
|
1119
|
+
const preview = await preflightCatalogSourceMutation({
|
|
1120
|
+
request: intent.sourceMutation.action === 'add'
|
|
1121
|
+
? intent.sourceMutation
|
|
1122
|
+
: { action: 'update', sourceId: intent.sourceId, update: intent.sourceMutation.update },
|
|
1123
|
+
cwd: context.cwd,
|
|
1124
|
+
env: context.env,
|
|
1125
|
+
});
|
|
1126
|
+
proposedSource = preview.proposedSource;
|
|
1127
|
+
proposedConfigDigest = preview.proposedConfigDigest;
|
|
1128
|
+
if (preview.configDigest !== config.digest) {
|
|
1129
|
+
throw operationReviewStale('准备 Catalog 候选期间来源配置发生变化。');
|
|
1130
|
+
}
|
|
1131
|
+
const sourceFingerprintChanged = Boolean(proposedSource && (!configuredSource
|
|
1132
|
+
|| calculateCatalogSourceConfigFingerprint(proposedSource)
|
|
1133
|
+
!== calculateCatalogSourceConfigFingerprint(configuredSource)));
|
|
1134
|
+
explicitSourceChange = preview.proposedConfigDigest !== preview.configDigest
|
|
1135
|
+
&& (preview.identityChanged || sourceFingerprintChanged);
|
|
1136
|
+
if (preview.identityChanged)
|
|
1137
|
+
sourceIdentityChangeImpact = {
|
|
1138
|
+
impactSchemaVersion: 3,
|
|
1139
|
+
sourceId: preview.sourceId,
|
|
1140
|
+
primaryChange: preview.references.primaryChange,
|
|
1141
|
+
inventoryComplete: preview.references.inventoryComplete,
|
|
1142
|
+
references: preview.references.references,
|
|
1143
|
+
affectedReferences: preview.references.references,
|
|
1144
|
+
changes: {
|
|
1145
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1146
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1147
|
+
},
|
|
1148
|
+
errors: preview.references.errors,
|
|
1149
|
+
};
|
|
1150
|
+
if (!explicitSourceChange) {
|
|
1151
|
+
throw new TuiOperationBlockedError('sourceNoChanges', '来源没有变化。');
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
let previousActive;
|
|
1155
|
+
let healthyActive;
|
|
1156
|
+
let previousActiveVersion;
|
|
1157
|
+
let previousStoreReady = false;
|
|
1158
|
+
try {
|
|
1159
|
+
previousActive = (await readCatalogGenerationState(context.env))
|
|
1160
|
+
.sources[intent.sourceId]?.active;
|
|
1161
|
+
}
|
|
1162
|
+
catch (error) {
|
|
1163
|
+
if (intent.action !== 'recoverState'
|
|
1164
|
+
|| !(error instanceof CatalogGenerationError)
|
|
1165
|
+
|| error.code !== 'catalogGenerationStateInvalid')
|
|
1166
|
+
throw error;
|
|
1167
|
+
}
|
|
1168
|
+
const activeStoreKey = previousActive
|
|
1169
|
+
? createCatalogStoreKey(previousActive.logicalIdentity, previousActive.snapshotDigest)
|
|
1170
|
+
: null;
|
|
1171
|
+
const configuredFingerprint = configuredSource
|
|
1172
|
+
? calculateCatalogSourceConfigFingerprint(configuredSource)
|
|
1173
|
+
: undefined;
|
|
1174
|
+
const canReuseCandidate = Boolean(reusableCandidate
|
|
1175
|
+
&& !intent.sourceMutation
|
|
1176
|
+
&& (intent.action === 'activate' || intent.action === 'update')
|
|
1177
|
+
&& configuredFingerprint
|
|
1178
|
+
&& reusableCandidate.sourceId === intent.sourceId
|
|
1179
|
+
&& reusableCandidate.sourceConfigFingerprint === configuredFingerprint
|
|
1180
|
+
&& reusableCandidate.probe.candidate.sourceConfigFingerprint === configuredFingerprint
|
|
1181
|
+
&& reusableCandidate.activeStoreKey === activeStoreKey
|
|
1182
|
+
&& reusableCandidate.probe.sourceId === intent.sourceId
|
|
1183
|
+
&& reusableCandidateEvidenceIsComplete(reusableCandidate));
|
|
1184
|
+
const probe = intent.action === 'repair'
|
|
1185
|
+
? await probeCatalogSourceRepairGeneration({
|
|
1186
|
+
sourceId: intent.sourceId,
|
|
1187
|
+
cliVersion: packageInfo.version,
|
|
1188
|
+
...(previousActive ? { expectedActive: previousActive } : {}),
|
|
1189
|
+
expectedConfigDigest: config.digest,
|
|
1190
|
+
env: context.env,
|
|
1191
|
+
signal,
|
|
1192
|
+
runtime: options.catalogGenerationRuntime,
|
|
1193
|
+
})
|
|
1194
|
+
: canReuseCandidate
|
|
1195
|
+
? structuredClone(reusableCandidate.probe)
|
|
1196
|
+
: await probeCatalogSourceGeneration({
|
|
1197
|
+
sourceId: intent.sourceId,
|
|
1198
|
+
...(proposedSource ? { source: proposedSource } : {}),
|
|
1199
|
+
cliVersion: packageInfo.version,
|
|
1200
|
+
env: context.env,
|
|
1201
|
+
signal,
|
|
1202
|
+
runtime: options.catalogGenerationRuntime,
|
|
1203
|
+
});
|
|
1204
|
+
signal?.throwIfAborted();
|
|
1205
|
+
await preparation?.reporter.emit('evidence');
|
|
1206
|
+
if (intent.action === 'activate' || intent.action === 'update') {
|
|
1207
|
+
try {
|
|
1208
|
+
healthyActive = await resolveActiveCatalogGeneration({ sourceId: intent.sourceId, env: context.env });
|
|
1209
|
+
}
|
|
1210
|
+
catch (error) {
|
|
1211
|
+
if (!(error instanceof CatalogGenerationError)
|
|
1212
|
+
&& !(error instanceof CatalogProviderCompatibilityError))
|
|
1213
|
+
throw error;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
const comparisonSource = proposedSource
|
|
1217
|
+
?? configuredSource;
|
|
1218
|
+
if (previousActive) {
|
|
1219
|
+
const store = await readCatalogStoreEntry({
|
|
1220
|
+
logicalIdentity: previousActive.logicalIdentity,
|
|
1221
|
+
snapshotDigest: previousActive.snapshotDigest,
|
|
1222
|
+
env: context.env,
|
|
1223
|
+
}).catch(() => undefined);
|
|
1224
|
+
previousStoreReady = Boolean(store);
|
|
1225
|
+
previousActiveVersion = healthyActive?.catalogVersion
|
|
1226
|
+
?? store?.metadata.catalogVersion;
|
|
1227
|
+
}
|
|
1228
|
+
if (intent.action === 'update' && !intent.sourceMutation && previousActive && comparisonSource) {
|
|
1229
|
+
explicitSourceChange = previousActive.sourceConfigFingerprint
|
|
1230
|
+
!== calculateCatalogSourceConfigFingerprint(comparisonSource)
|
|
1231
|
+
|| previousActive.sourceIdentity !== await calculateCatalogSourceIdentity(comparisonSource);
|
|
1232
|
+
}
|
|
1233
|
+
const comparisonActive = healthyActive
|
|
1234
|
+
? {
|
|
1235
|
+
logicalIdentity: healthyActive.logicalIdentity,
|
|
1236
|
+
catalogVersion: healthyActive.catalogVersion,
|
|
1237
|
+
snapshotDigest: healthyActive.snapshotDigest,
|
|
1238
|
+
resolvedCommit: healthyActive.resolvedCommit,
|
|
1239
|
+
}
|
|
1240
|
+
: previousActive && previousActiveVersion
|
|
1241
|
+
? {
|
|
1242
|
+
logicalIdentity: previousActive.logicalIdentity,
|
|
1243
|
+
catalogVersion: previousActiveVersion,
|
|
1244
|
+
snapshotDigest: previousActive.snapshotDigest,
|
|
1245
|
+
resolvedCommit: previousActive.resolvedCommit,
|
|
1246
|
+
}
|
|
1247
|
+
: undefined;
|
|
1248
|
+
const candidateRelation = comparisonActive && comparisonSource
|
|
1249
|
+
? compareCatalogGenerationFreshness({
|
|
1250
|
+
sourceType: comparisonSource.type,
|
|
1251
|
+
active: comparisonActive,
|
|
1252
|
+
candidate: probe.candidate,
|
|
1253
|
+
}).state
|
|
1254
|
+
: undefined;
|
|
1255
|
+
const exactStoreTarget = Boolean(previousActive)
|
|
1256
|
+
&& createCatalogStoreKey(previousActive.logicalIdentity, previousActive.snapshotDigest)
|
|
1257
|
+
=== createCatalogStoreKey(probe.candidate.logicalIdentity, probe.candidate.snapshotDigest);
|
|
1258
|
+
if (intent.action === 'repair' && !exactStoreTarget) {
|
|
1259
|
+
throw new CatalogGenerationError({
|
|
1260
|
+
code: 'catalogReplaceDamagedRequired', sourceId: intent.sourceId,
|
|
1261
|
+
message: `Catalog source "${intent.sourceId}" cannot reproduce the damaged Active entry. Use the current candidate replacement Review.`,
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
const exactRepair = (intent.action === 'repair' || intent.action === 'update')
|
|
1265
|
+
&& exactStoreTarget && !previousStoreReady;
|
|
1266
|
+
if (previousActive && !previousStoreReady && !exactStoreTarget
|
|
1267
|
+
&& !intent.sourceMutation && intent.action !== 'replaceDamaged') {
|
|
1268
|
+
throw new CatalogGenerationError({
|
|
1269
|
+
code: 'catalogReplaceDamagedRequired',
|
|
1270
|
+
sourceId: intent.sourceId,
|
|
1271
|
+
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.`,
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
if (intent.action !== 'replaceDamaged' && !explicitSourceChange && candidateRelation === 'incompatible') {
|
|
1275
|
+
throw new CatalogGenerationError({
|
|
1276
|
+
code: 'catalogLogicalIdentityChanged', sourceId: intent.sourceId,
|
|
1277
|
+
message: `Catalog source "${intent.sourceId}" changed logical identity. Edit or remove and re-add the source.`,
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
if (intent.action !== 'replaceDamaged' && !explicitSourceChange && candidateRelation === 'versionConflict') {
|
|
1281
|
+
throw new TuiOperationBlockedError('catalogVersionConflict', '候选 Catalog 与当前 Active 版本相同,但内容摘要不同。普通更新已阻止。');
|
|
1282
|
+
}
|
|
1283
|
+
if (intent.action !== 'replaceDamaged' && !explicitSourceChange && candidateRelation === 'rollbackDetected') {
|
|
1284
|
+
throw new TuiOperationBlockedError('catalogRollbackDetected', '候选 Catalog 版本低于当前 Active。普通更新已阻止。');
|
|
1285
|
+
}
|
|
1286
|
+
const impact = exactRepair ? undefined
|
|
1287
|
+
: sourceIdentityChangeImpact ?? await inspectCatalogSourceImpact({
|
|
1288
|
+
sourceId: intent.sourceId,
|
|
1289
|
+
cwd: context.cwd,
|
|
1290
|
+
env: context.env,
|
|
1291
|
+
sourcePrimary: comparisonSource?.primary === true,
|
|
1292
|
+
mode: 'generation',
|
|
1293
|
+
candidateManifest: probe.manifest,
|
|
1294
|
+
});
|
|
1295
|
+
const primaryPreview = intent.setPrimaryAfterActivation
|
|
1296
|
+
? await preflightCatalogSourceMutation({
|
|
1297
|
+
request: { action: 'setPrimary', sourceId: intent.sourceId },
|
|
1298
|
+
cwd: context.cwd,
|
|
1299
|
+
env: context.env,
|
|
1300
|
+
})
|
|
1301
|
+
: undefined;
|
|
1302
|
+
if (primaryPreview && primaryPreview.configDigest !== config.digest) {
|
|
1303
|
+
throw operationReviewStale('准备主来源切换期间来源配置发生变化。');
|
|
1304
|
+
}
|
|
1305
|
+
const primaryImpact = primaryPreview ? {
|
|
1306
|
+
impactSchemaVersion: 3,
|
|
1307
|
+
sourceId: primaryPreview.sourceId,
|
|
1308
|
+
primaryChange: primaryPreview.references.primaryChange,
|
|
1309
|
+
inventoryComplete: primaryPreview.references.inventoryComplete,
|
|
1310
|
+
references: primaryPreview.references.references,
|
|
1311
|
+
affectedReferences: primaryPreview.references.references,
|
|
1312
|
+
changes: {
|
|
1313
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1314
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1315
|
+
},
|
|
1316
|
+
errors: primaryPreview.references.errors,
|
|
1317
|
+
} : undefined;
|
|
1318
|
+
return {
|
|
1319
|
+
catalog: {
|
|
1320
|
+
configDigest: config.digest,
|
|
1321
|
+
compositeDigest: probe.candidate.snapshotDigest,
|
|
1322
|
+
},
|
|
1323
|
+
catalogGeneration: {
|
|
1324
|
+
action: intent.action,
|
|
1325
|
+
...(previousActive ? { previousActive } : {}),
|
|
1326
|
+
...(previousActiveVersion ? { previousActiveVersion } : {}),
|
|
1327
|
+
candidate: probe.candidate,
|
|
1328
|
+
...(candidateRelation ? { candidateRelation } : {}),
|
|
1329
|
+
...(explicitSourceChange ? { explicitSourceChange: true } : {}),
|
|
1330
|
+
...(exactRepair ? { exactRepair: true } : {}),
|
|
1331
|
+
activationMode: intent.action === 'replaceDamaged' ? 'replaceDamaged'
|
|
1332
|
+
: explicitSourceChange ? 'explicitSourceChange' : 'normal',
|
|
1333
|
+
...(impact ? {
|
|
1334
|
+
impact,
|
|
1335
|
+
impactDigest: calculateCatalogSourceImpactDigest(impact),
|
|
1336
|
+
impactMode: sourceIdentityChangeImpact ? 'identityChange' : 'generation',
|
|
1337
|
+
} : {}),
|
|
1338
|
+
...(primaryPreview && primaryImpact ? {
|
|
1339
|
+
primaryImpact,
|
|
1340
|
+
primaryImpactDigest: primaryPreview.impactDigest,
|
|
1341
|
+
primaryConfigDigest: primaryPreview.configDigest,
|
|
1342
|
+
} : {}),
|
|
1343
|
+
configDigest: config.digest,
|
|
1344
|
+
...(proposedConfigDigest ? { proposedConfigDigest } : {}),
|
|
1345
|
+
...(proposedSource ? { proposedSource } : {}),
|
|
1346
|
+
...(intent.sourceMutation ? { sourceMutation: intent.sourceMutation } : {}),
|
|
1347
|
+
...(intent.setPrimaryAfterActivation ? { setPrimaryAfterActivation: true } : {}),
|
|
1348
|
+
},
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
424
1351
|
if (intent.kind === 'sourceMutation') {
|
|
425
1352
|
signal?.throwIfAborted();
|
|
426
1353
|
if (intent.action === 'add' && !intent.source
|
|
@@ -432,183 +1359,1339 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
432
1359
|
: intent.action === 'update'
|
|
433
1360
|
? { action: 'update', sourceId: intent.sourceId, update: intent.update }
|
|
434
1361
|
: { action: intent.action, sourceId: intent.sourceId };
|
|
1362
|
+
await preparation?.reporter.emit('validate');
|
|
435
1363
|
const preview = await preflightCatalogSourceMutation({
|
|
436
1364
|
request,
|
|
437
1365
|
cwd: context.cwd,
|
|
438
1366
|
env: context.env,
|
|
439
1367
|
});
|
|
440
|
-
|
|
441
|
-
|
|
1368
|
+
signal?.throwIfAborted();
|
|
1369
|
+
await preparation?.reporter.emit('evidence');
|
|
1370
|
+
signal?.throwIfAborted();
|
|
1371
|
+
const evidence = {
|
|
1372
|
+
catalog: { configDigest: preview.configDigest, compositeDigest: preview.proposedConfigDigest },
|
|
442
1373
|
sourceWrite: {
|
|
443
1374
|
configDigest: preview.configDigest,
|
|
444
|
-
|
|
1375
|
+
proposedConfigDigest: preview.proposedConfigDigest,
|
|
445
1376
|
...(preview.sourceIdentity ? { sourceIdentity: preview.sourceIdentity } : {}),
|
|
446
1377
|
inventoryDigest: digest({ references: preview.references.references, errors: preview.references.errors }),
|
|
1378
|
+
impactDigest: preview.impactDigest,
|
|
447
1379
|
referenceCount: preview.references.references.length,
|
|
448
|
-
inventoryComplete: preview.references.
|
|
1380
|
+
inventoryComplete: preview.references.inventoryComplete,
|
|
1381
|
+
impact: {
|
|
1382
|
+
impactSchemaVersion: 3,
|
|
1383
|
+
sourceId: preview.sourceId,
|
|
1384
|
+
primaryChange: preview.references.primaryChange,
|
|
1385
|
+
inventoryComplete: preview.references.inventoryComplete,
|
|
1386
|
+
references: preview.references.references,
|
|
1387
|
+
affectedReferences: preview.references.references,
|
|
1388
|
+
changes: {
|
|
1389
|
+
added: [], removed: [], changed: [], newlyIncompatible: [],
|
|
1390
|
+
dependencyChanged: [], platformSupportChanged: [],
|
|
1391
|
+
},
|
|
1392
|
+
errors: preview.references.errors,
|
|
1393
|
+
},
|
|
449
1394
|
},
|
|
450
1395
|
};
|
|
1396
|
+
if (preparation?.validateIntent
|
|
1397
|
+
&& evidence.sourceWrite?.configDigest === evidence.sourceWrite?.proposedConfigDigest) {
|
|
1398
|
+
throw new TuiOperationBlockedError('sourceNoChanges', '来源没有变化。');
|
|
1399
|
+
}
|
|
1400
|
+
return evidence;
|
|
451
1401
|
}
|
|
452
|
-
if (!pluginIntent(intent)
|
|
1402
|
+
if (!pluginIntent(intent) && intent.kind !== 'pluginWriteBatch'
|
|
1403
|
+
&& intent.kind !== 'pluginWriteTask') {
|
|
453
1404
|
throw new TuiOperationBlockedError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
|
|
454
1405
|
}
|
|
455
1406
|
signal?.throwIfAborted();
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
1407
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
1408
|
+
await preparation?.reporter.emit('status');
|
|
1409
|
+
const packageInfo = await readCliPackageInfo();
|
|
1410
|
+
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
1411
|
+
const requestedBySource = new Map();
|
|
1412
|
+
for (const target of intent.targets) {
|
|
1413
|
+
const parsed = parsePluginId(target.pluginId);
|
|
1414
|
+
if (!parsed.sourceId || formatPluginId({
|
|
1415
|
+
sourceId: parsed.sourceId,
|
|
1416
|
+
pluginName: parsed.pluginName,
|
|
1417
|
+
}) !== target.pluginId) {
|
|
1418
|
+
throw new TuiOperationBlockedError('invalidPluginId', '任务目标必须使用 canonical pluginId。');
|
|
1419
|
+
}
|
|
1420
|
+
requestedBySource.set(parsed.sourceId, [
|
|
1421
|
+
...(requestedBySource.get(parsed.sourceId) ?? []),
|
|
1422
|
+
target,
|
|
1423
|
+
]);
|
|
1424
|
+
}
|
|
1425
|
+
const sources = [];
|
|
1426
|
+
const executableTargets = [];
|
|
1427
|
+
const causes = [];
|
|
1428
|
+
const blockedTargets = [];
|
|
1429
|
+
const observedTargets = [];
|
|
1430
|
+
const observedRevisions = [];
|
|
1431
|
+
const operationContexts = new Map();
|
|
1432
|
+
await preparation?.reporter.emit('catalog');
|
|
1433
|
+
for (const [sourceId, requestedTargets] of [...requestedBySource.entries()]
|
|
1434
|
+
.sort(([left], [right]) => left.localeCompare(right, 'en'))) {
|
|
1435
|
+
signal?.throwIfAborted();
|
|
1436
|
+
let catalogOperation;
|
|
1437
|
+
try {
|
|
1438
|
+
catalogOperation = !freshCatalog && sessionCatalogOperationContext
|
|
1439
|
+
? selectCatalogOperationContext(sessionCatalogOperationContext, [sourceId])
|
|
1440
|
+
: await resolveCatalogOperationContext({
|
|
1441
|
+
sourceIds: [sourceId],
|
|
1442
|
+
env: context.env,
|
|
1443
|
+
...(!freshCatalog ? { validatedStoreEntries, validatingStoreEntries } : {}),
|
|
1444
|
+
...(signal ? { signal } : {}),
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
catch (error) {
|
|
1448
|
+
if (error instanceof Error && error.name === 'AbortError')
|
|
1449
|
+
throw error;
|
|
1450
|
+
blockedTargets.push(...requestedTargets.map((target, index) => {
|
|
1451
|
+
const diagnostic = error instanceof CatalogGenerationError ? {
|
|
1452
|
+
id: `task-source:${sourceId}:${index}`,
|
|
1453
|
+
code: error.code,
|
|
1454
|
+
stage: 'source',
|
|
1455
|
+
sourceId,
|
|
1456
|
+
safeMessage: 'The Catalog source could not be prepared safely.',
|
|
1457
|
+
target: { pluginId: target.pluginId, platform: target.platform, scope: target.scope },
|
|
1458
|
+
causes: [],
|
|
1459
|
+
detailLines: [],
|
|
1460
|
+
} : projectThrownOperationDiagnostic({
|
|
1461
|
+
error,
|
|
1462
|
+
id: `task-source:${sourceId}:${index}`,
|
|
1463
|
+
stage: 'source',
|
|
1464
|
+
fallbackCode: 'catalogSourceResolutionFailed',
|
|
1465
|
+
sourceId,
|
|
1466
|
+
target,
|
|
1467
|
+
});
|
|
1468
|
+
return {
|
|
1469
|
+
target,
|
|
1470
|
+
reason: 'targetUnavailable',
|
|
1471
|
+
issueIds: [],
|
|
1472
|
+
errorCodes: [diagnostic.code],
|
|
1473
|
+
diagnostics: [diagnostic],
|
|
1474
|
+
};
|
|
1475
|
+
}));
|
|
1476
|
+
continue;
|
|
1477
|
+
}
|
|
1478
|
+
operationContexts.set(sourceId, catalogOperation);
|
|
1479
|
+
const status = await statusCommandV8({
|
|
1480
|
+
plugins: [...new Set(requestedTargets.map((target) => target.pluginId))],
|
|
1481
|
+
cwd: context.cwd,
|
|
1482
|
+
env: context.env,
|
|
1483
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
1484
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
1485
|
+
cliVersion: packageInfo.version,
|
|
1486
|
+
catalogOperationContext: catalogOperation,
|
|
1487
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1488
|
+
});
|
|
1489
|
+
observedTargets.push(...flattenStatusTargets(status.payload.targets));
|
|
1490
|
+
observedRevisions.push(...status.targetRevisions);
|
|
1491
|
+
const model = buildTuiViewModel({
|
|
1492
|
+
status: status.payload,
|
|
1493
|
+
pluginSummaries: status.pluginSummaries,
|
|
1494
|
+
targetRevisions: status.targetRevisions,
|
|
1495
|
+
});
|
|
1496
|
+
const runtimeCandidates = intent.goal === 'restore'
|
|
1497
|
+
? buildPluginWriteTaskCandidates(model, 'restore')
|
|
1498
|
+
: requestedTargets.map((target) => {
|
|
1499
|
+
const expected = target.expectedUpdate;
|
|
1500
|
+
const revision = status.targetRevisions.find((entry) => entry.pluginId === target.pluginId && entry.platform === target.platform
|
|
1501
|
+
&& entry.scope === target.scope);
|
|
1502
|
+
const live = flattenStatusTargets(status.payload.targets).find((entry) => {
|
|
1503
|
+
if (entry.pluginId !== target.pluginId || entry.platform !== target.platform)
|
|
1504
|
+
return false;
|
|
1505
|
+
const desired = statusTargetIntent(entry);
|
|
1506
|
+
return entry.scope === target.scope || desired.scopes.includes(target.scope);
|
|
1507
|
+
});
|
|
1508
|
+
const generation = catalogOperation.generationSet.sources.find((entry) => entry.sourceId === sourceId);
|
|
1509
|
+
const eligible = Boolean(expected && live && revision
|
|
1510
|
+
&& live.sourceIdentity === expected.sourceIdentity
|
|
1511
|
+
&& generation?.storeKey === expected.generationKey
|
|
1512
|
+
&& revision.revision.installedVersion === expected.installedVersion
|
|
1513
|
+
&& revision.revision.availableVersion === expected.activeVersion
|
|
1514
|
+
&& revision.revision.state === 'upgradeAvailable');
|
|
1515
|
+
const directVersionUpgrade = live !== undefined && revision !== undefined
|
|
1516
|
+
&& isDirectCodexVersionUpgrade(live, revision.revision);
|
|
1517
|
+
return {
|
|
1518
|
+
target,
|
|
1519
|
+
displayName: model.plugins.find((plugin) => plugin.pluginId === target.pluginId)
|
|
1520
|
+
?.displayName ?? parsePluginId(target.pluginId).pluginName,
|
|
1521
|
+
sourceId,
|
|
1522
|
+
eligible,
|
|
1523
|
+
...(!eligible ? { blockReason: 'updateEvidenceIncomplete' } : {}),
|
|
1524
|
+
recommendedMethod: live?.state === 'ready' || directVersionUpgrade
|
|
1525
|
+
? 'sync' : 'reinstall',
|
|
1526
|
+
issueIds: [],
|
|
1527
|
+
};
|
|
1528
|
+
});
|
|
1529
|
+
const draft = buildPluginWriteTaskDraft({ ...intent, targets: requestedTargets }, model, runtimeCandidates);
|
|
1530
|
+
blockedTargets.push(...draft.blockedTargets);
|
|
1531
|
+
if (draft.executableTargets.length === 0)
|
|
1532
|
+
continue;
|
|
1533
|
+
const methodsByTarget = new Map();
|
|
1534
|
+
for (const cause of draft.causes) {
|
|
1535
|
+
const key = pluginWriteTaskTargetKey(cause.repairTarget);
|
|
1536
|
+
const methods = methodsByTarget.get(key) ?? new Set();
|
|
1537
|
+
methods.add(cause.method);
|
|
1538
|
+
methodsByTarget.set(key, methods);
|
|
1539
|
+
}
|
|
1540
|
+
const conflicted = new Set([...methodsByTarget].filter(([, methods]) => methods.size > 1)
|
|
1541
|
+
.map(([key]) => key));
|
|
1542
|
+
if (conflicted.size > 0) {
|
|
1543
|
+
const blockedKeys = new Set(draft.causes.filter((cause) => conflicted.has(pluginWriteTaskTargetKey(cause.repairTarget)))
|
|
1544
|
+
.flatMap((cause) => cause.consumers.map(pluginWriteTaskTargetKey)));
|
|
1545
|
+
blockedTargets.push(...draft.executableTargets.filter((target) => blockedKeys.has(pluginWriteTaskTargetKey(target))).map((target) => ({
|
|
1546
|
+
target,
|
|
1547
|
+
reason: 'taskActionConflict',
|
|
1548
|
+
issueIds: draft.causes.filter((cause) => cause.consumers.some((consumer) => pluginWriteTaskTargetKey(consumer) === pluginWriteTaskTargetKey(target)))
|
|
1549
|
+
.map((cause) => cause.issueId),
|
|
1550
|
+
})));
|
|
1551
|
+
draft.executableTargets = draft.executableTargets.filter((target) => !blockedKeys.has(pluginWriteTaskTargetKey(target)));
|
|
1552
|
+
draft.causes = draft.causes.filter((cause) => cause.consumers.some((consumer) => !blockedKeys.has(pluginWriteTaskTargetKey(consumer))));
|
|
1553
|
+
}
|
|
1554
|
+
if (draft.executableTargets.length === 0)
|
|
1555
|
+
continue;
|
|
1556
|
+
const taskTargets = () => draft.executableTargets.map((target) => {
|
|
1557
|
+
const direct = draft.causes.filter((cause) => pluginWriteTaskTargetKey(cause.repairTarget) === pluginWriteTaskTargetKey(target));
|
|
1558
|
+
return {
|
|
1559
|
+
pluginId: target.pluginId,
|
|
1560
|
+
platform: target.platform,
|
|
1561
|
+
scope: target.scope,
|
|
1562
|
+
method: direct.some((cause) => cause.method === 'reinstall')
|
|
1563
|
+
? 'reinstall' : 'sync',
|
|
1564
|
+
};
|
|
1565
|
+
});
|
|
1566
|
+
const repairTargets = () => [...new Map(draft.causes.map((cause) => [
|
|
1567
|
+
pluginWriteTaskTargetKey(cause.repairTarget),
|
|
1568
|
+
{ ...cause.repairTarget, method: cause.method },
|
|
1569
|
+
])).values()];
|
|
1570
|
+
let preview;
|
|
1571
|
+
while (draft.executableTargets.length > 0) {
|
|
1572
|
+
preview = await taskWriteCommand(taskTargets(), {
|
|
1573
|
+
cwd: context.cwd,
|
|
1574
|
+
repairTargets: repairTargets(),
|
|
1575
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
1576
|
+
? {} : { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
1577
|
+
}, {
|
|
1578
|
+
...context,
|
|
1579
|
+
catalogOperationContext: catalogOperation,
|
|
1580
|
+
expectedGenerationSetDigest: catalogOperation.generationSetDigest,
|
|
1581
|
+
expectedCatalogConfigDigest: configSnapshot.digest,
|
|
1582
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1583
|
+
previewOperationPlan: true,
|
|
1584
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
1585
|
+
...(preparation ? {
|
|
1586
|
+
onPreviewStage: (stage) => stage === 'catalog' ? undefined : preparation.reporter.emit(stage),
|
|
1587
|
+
} : {}),
|
|
1588
|
+
});
|
|
1589
|
+
if (!preview.operationPlan) {
|
|
1590
|
+
const projected = projectExecutionDiagnostics(preview, `task-preview:${sourceId}`, [], 'pluginWrite');
|
|
1591
|
+
const sourceDiagnostics = projected.diagnostics.filter((diagnostic) => !diagnostic.target)
|
|
1592
|
+
.map((diagnostic) => ({ ...diagnostic, sourceId, target: undefined }));
|
|
1593
|
+
blockedTargets.push(...draft.executableTargets.map((target, targetIndex) => {
|
|
1594
|
+
const matchingDiagnostics = projected.diagnostics.filter((diagnostic) => diagnostic.target?.pluginId === target.pluginId
|
|
1595
|
+
&& diagnostic.target.platform === target.platform
|
|
1596
|
+
&& diagnostic.target.scope === target.scope);
|
|
1597
|
+
const preparedDiagnostics = [
|
|
1598
|
+
...matchingDiagnostics,
|
|
1599
|
+
...(targetIndex === 0 ? sourceDiagnostics : []),
|
|
1600
|
+
];
|
|
1601
|
+
const targetDiagnostics = preparedDiagnostics.length > 0
|
|
1602
|
+
? preparedDiagnostics
|
|
1603
|
+
: [projectThrownOperationDiagnostic({
|
|
1604
|
+
error: undefined,
|
|
1605
|
+
id: `task-preview:${sourceId}:${targetIndex}`,
|
|
1606
|
+
stage: 'dependencyPlan',
|
|
1607
|
+
fallbackCode: 'taskOperationPlanMissing',
|
|
1608
|
+
sourceId,
|
|
1609
|
+
target,
|
|
1610
|
+
})];
|
|
1611
|
+
const diagnostics = targetDiagnostics.map((diagnostic, diagnosticIndex) => ({
|
|
1612
|
+
...structuredClone(diagnostic),
|
|
1613
|
+
id: `task-preview:${sourceId}:${targetIndex}:${diagnosticIndex}`,
|
|
1614
|
+
sourceId,
|
|
1615
|
+
}));
|
|
1616
|
+
return {
|
|
1617
|
+
target,
|
|
1618
|
+
reason: 'targetUnavailable',
|
|
1619
|
+
issueIds: draft.causes.filter((cause) => cause.consumers.some((consumer) => pluginWriteTaskTargetKey(consumer) === pluginWriteTaskTargetKey(target)))
|
|
1620
|
+
.map((cause) => cause.issueId),
|
|
1621
|
+
errorCodes: [...new Set(diagnostics.map((diagnostic) => diagnostic.code))],
|
|
1622
|
+
diagnostics,
|
|
1623
|
+
};
|
|
1624
|
+
}));
|
|
1625
|
+
draft.executableTargets = [];
|
|
1626
|
+
draft.causes = [];
|
|
1627
|
+
break;
|
|
1628
|
+
}
|
|
1629
|
+
if (intent.goal === 'restore') {
|
|
1630
|
+
const grouped = new Map();
|
|
1631
|
+
const blockedByVersion = new Map();
|
|
1632
|
+
for (const cause of draft.causes) {
|
|
1633
|
+
const placements = (preview.dependencyPlan?.targets ?? []).filter((target) => target.pluginId === cause.repairTarget.pluginId
|
|
1634
|
+
&& target.platform === cause.repairTarget.platform);
|
|
1635
|
+
const placement = placements.find((target) => target.requestedScope === cause.repairTarget.scope)
|
|
1636
|
+
?? (placements.length === 1 ? placements[0] : undefined);
|
|
1637
|
+
if (!placement) {
|
|
1638
|
+
throw new TuiOperationBlockedError('taskRepairPlacementMissing', '任务修复目标无法绑定到依赖位置。');
|
|
1639
|
+
}
|
|
1640
|
+
const repairTarget = {
|
|
1641
|
+
pluginId: cause.repairTarget.pluginId,
|
|
1642
|
+
platform: cause.repairTarget.platform,
|
|
1643
|
+
scope: placement.requestedScope ?? placement.resolvedScope,
|
|
1644
|
+
};
|
|
1645
|
+
const version = evaluatePluginWriteTaskRestoreVersion(repairTarget, cause.restoreVersionEvidence?.state === 'absent', model);
|
|
1646
|
+
if (!version.evidence || version.blockReason) {
|
|
1647
|
+
for (const consumer of cause.consumers) {
|
|
1648
|
+
const key = pluginWriteTaskTargetKey(consumer);
|
|
1649
|
+
const current = blockedByVersion.get(key) ?? {
|
|
1650
|
+
reason: version.blockReason ?? 'restoreVersionUnverified',
|
|
1651
|
+
issueIds: new Set(),
|
|
1652
|
+
};
|
|
1653
|
+
if (version.blockReason === 'restoreVersionChanged') {
|
|
1654
|
+
current.reason = version.blockReason;
|
|
1655
|
+
}
|
|
1656
|
+
current.issueIds.add(cause.issueId);
|
|
1657
|
+
blockedByVersion.set(key, current);
|
|
1658
|
+
}
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1661
|
+
const causeKey = ['restore', cause.sourceIdentity,
|
|
1662
|
+
pluginWriteTaskTargetKey(repairTarget)].join('\0');
|
|
1663
|
+
const current = grouped.get(causeKey);
|
|
1664
|
+
grouped.set(causeKey, {
|
|
1665
|
+
cause: {
|
|
1666
|
+
...cause,
|
|
1667
|
+
causeKey,
|
|
1668
|
+
issueId: [cause.issueId, ...(current?.issueIds ?? [])]
|
|
1669
|
+
.sort((left, right) => left.localeCompare(right, 'en'))[0],
|
|
1670
|
+
repairTarget,
|
|
1671
|
+
consumers: [...new Map([
|
|
1672
|
+
...(current?.cause.consumers ?? []),
|
|
1673
|
+
...cause.consumers,
|
|
1674
|
+
].map((consumer) => [pluginWriteTaskTargetKey(consumer), consumer])).values()]
|
|
1675
|
+
.sort((left, right) => pluginWriteTaskTargetKey(left)
|
|
1676
|
+
.localeCompare(pluginWriteTaskTargetKey(right), 'en')),
|
|
1677
|
+
restoreVersionEvidence: version.evidence,
|
|
1678
|
+
},
|
|
1679
|
+
issueIds: new Set([...(current?.issueIds ?? []), cause.issueId]),
|
|
1680
|
+
methods: new Set([...(current?.methods ?? []), cause.method]),
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
for (const group of grouped.values()) {
|
|
1684
|
+
if (group.methods.size < 2)
|
|
1685
|
+
continue;
|
|
1686
|
+
for (const consumer of group.cause.consumers) {
|
|
1687
|
+
const key = pluginWriteTaskTargetKey(consumer);
|
|
1688
|
+
const current = blockedByVersion.get(key) ?? {
|
|
1689
|
+
reason: 'taskActionConflict',
|
|
1690
|
+
issueIds: new Set(),
|
|
1691
|
+
};
|
|
1692
|
+
group.issueIds.forEach((issueId) => current.issueIds.add(issueId));
|
|
1693
|
+
blockedByVersion.set(key, current);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
const newlyBlockedKeys = new Set(blockedByVersion.keys());
|
|
1697
|
+
blockedTargets.push(...draft.executableTargets.flatMap((target) => {
|
|
1698
|
+
const blocked = blockedByVersion.get(pluginWriteTaskTargetKey(target));
|
|
1699
|
+
return blocked ? [{
|
|
1700
|
+
target,
|
|
1701
|
+
reason: blocked.reason,
|
|
1702
|
+
issueIds: [...blocked.issueIds].sort((left, right) => left.localeCompare(right, 'en')),
|
|
1703
|
+
}] : [];
|
|
1704
|
+
}));
|
|
1705
|
+
const normalizedCauses = [...grouped.values()]
|
|
1706
|
+
.filter((group) => group.methods.size === 1)
|
|
1707
|
+
.map((group) => ({
|
|
1708
|
+
...group.cause,
|
|
1709
|
+
consumers: group.cause.consumers.filter((consumer) => !newlyBlockedKeys.has(pluginWriteTaskTargetKey(consumer))),
|
|
1710
|
+
}))
|
|
1711
|
+
.filter((cause) => cause.consumers.length > 0)
|
|
1712
|
+
.sort((left, right) => left.causeKey.localeCompare(right.causeKey, 'en'));
|
|
1713
|
+
const normalizedTargets = draft.executableTargets.filter((target) => !newlyBlockedKeys.has(pluginWriteTaskTargetKey(target)));
|
|
1714
|
+
const changed = JSON.stringify(normalizedCauses) !== JSON.stringify(draft.causes)
|
|
1715
|
+
|| JSON.stringify(normalizedTargets) !== JSON.stringify(draft.executableTargets);
|
|
1716
|
+
draft.causes = normalizedCauses;
|
|
1717
|
+
draft.executableTargets = normalizedTargets;
|
|
1718
|
+
if (changed)
|
|
1719
|
+
continue;
|
|
1720
|
+
}
|
|
1721
|
+
const blockedPlanTargets = (preview.dependencyPlan?.targets ?? []).filter((target) => target.action === 'block' || target.errorCode !== undefined);
|
|
1722
|
+
if (blockedPlanTargets.length === 0)
|
|
1723
|
+
break;
|
|
1724
|
+
const requestedKeys = new Set(draft.executableTargets.map(pluginWriteTaskTargetKey));
|
|
1725
|
+
const blockedPlansByRoot = new Map();
|
|
1726
|
+
for (const blockedPlanTarget of blockedPlanTargets) {
|
|
1727
|
+
const pending = [blockedPlanTarget];
|
|
1728
|
+
const visited = new Set();
|
|
1729
|
+
const mappedRoots = new Set();
|
|
1730
|
+
const repairKey = pluginWriteTaskTargetKey({
|
|
1731
|
+
pluginId: blockedPlanTarget.pluginId,
|
|
1732
|
+
platform: blockedPlanTarget.platform,
|
|
1733
|
+
scope: blockedPlanTarget.requestedScope ?? blockedPlanTarget.resolvedScope,
|
|
1734
|
+
});
|
|
1735
|
+
for (const cause of draft.causes) {
|
|
1736
|
+
if (pluginWriteTaskTargetKey(cause.repairTarget) !== repairKey)
|
|
1737
|
+
continue;
|
|
1738
|
+
cause.consumers.forEach((consumer) => mappedRoots.add(pluginWriteTaskTargetKey(consumer)));
|
|
1739
|
+
}
|
|
1740
|
+
while (pending.length > 0) {
|
|
1741
|
+
const current = pending.shift();
|
|
1742
|
+
const currentKey = pluginWriteTaskTargetKey({
|
|
1743
|
+
pluginId: current.pluginId,
|
|
1744
|
+
platform: current.platform,
|
|
1745
|
+
scope: current.requestedScope ?? current.resolvedScope,
|
|
1746
|
+
});
|
|
1747
|
+
if (visited.has(currentKey))
|
|
1748
|
+
continue;
|
|
1749
|
+
visited.add(currentKey);
|
|
1750
|
+
if (current.relation === 'requested' && requestedKeys.has(currentKey)) {
|
|
1751
|
+
mappedRoots.add(currentKey);
|
|
1752
|
+
}
|
|
1753
|
+
for (const consumer of current.requiredByTargets ?? []) {
|
|
1754
|
+
const consumerKey = pluginWriteTaskTargetKey(consumer);
|
|
1755
|
+
if (requestedKeys.has(consumerKey)) {
|
|
1756
|
+
mappedRoots.add(consumerKey);
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
const placement = preview.dependencyPlan?.targets.find((target) => target.pluginId === consumer.pluginId && target.platform === consumer.platform
|
|
1760
|
+
&& (target.requestedScope ?? target.resolvedScope) === consumer.scope);
|
|
1761
|
+
if (placement)
|
|
1762
|
+
pending.push(placement);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
if (mappedRoots.size === 0) {
|
|
1766
|
+
throw new TuiOperationBlockedError('taskPlanConsumerMissing', '任务计划中的阻止项无法映射到请求目标。');
|
|
1767
|
+
}
|
|
1768
|
+
for (const key of mappedRoots) {
|
|
1769
|
+
const plans = blockedPlansByRoot.get(key) ?? [];
|
|
1770
|
+
plans.push(blockedPlanTarget);
|
|
1771
|
+
blockedPlansByRoot.set(key, plans);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
blockedTargets.push(...draft.executableTargets.flatMap((target) => {
|
|
1775
|
+
const plans = blockedPlansByRoot.get(pluginWriteTaskTargetKey(target));
|
|
1776
|
+
return plans ? [{
|
|
1777
|
+
target,
|
|
1778
|
+
reason: 'targetUnavailable',
|
|
1779
|
+
issueIds: draft.causes.filter((cause) => cause.consumers.some((consumer) => pluginWriteTaskTargetKey(consumer) === pluginWriteTaskTargetKey(target)))
|
|
1780
|
+
.map((cause) => cause.issueId),
|
|
1781
|
+
errorCodes: [...new Set(plans.map((plan) => plan.errorCode ?? 'writePlanBlocked'))]
|
|
1782
|
+
.sort((left, right) => left.localeCompare(right, 'en')),
|
|
1783
|
+
diagnostics: plans.map((plan, index) => ({
|
|
1784
|
+
id: `task-plan:${sourceId}:${target.pluginId}:${target.platform}:${target.scope}:${index}`,
|
|
1785
|
+
code: plan.errorCode ?? 'writePlanBlocked',
|
|
1786
|
+
stage: 'dependencyPlan',
|
|
1787
|
+
sourceId,
|
|
1788
|
+
target: {
|
|
1789
|
+
pluginId: plan.pluginId, platform: plan.platform,
|
|
1790
|
+
scope: plan.requestedScope ?? plan.resolvedScope,
|
|
1791
|
+
},
|
|
1792
|
+
causes: [],
|
|
1793
|
+
detailLines: [],
|
|
1794
|
+
safeMessage: plan.errorCode === 'artifactCollision'
|
|
1795
|
+
? '输出位置存在外来内容,无法覆盖。'
|
|
1796
|
+
: plan.errorCode === 'exclusiveOwnerEvidenceInvalid'
|
|
1797
|
+
? '独立扩展的归属标记缺失或损坏。'
|
|
1798
|
+
: plan.errorCode === 'dependencyNotReady'
|
|
1799
|
+
? '依赖安装状态无法读取。'
|
|
1800
|
+
: '依赖计划阻止了此目标。',
|
|
1801
|
+
})),
|
|
1802
|
+
}] : [];
|
|
1803
|
+
}));
|
|
1804
|
+
draft.executableTargets = draft.executableTargets.filter((target) => !blockedPlansByRoot.has(pluginWriteTaskTargetKey(target)));
|
|
1805
|
+
draft.causes = draft.causes.map((cause) => ({
|
|
1806
|
+
...cause,
|
|
1807
|
+
consumers: cause.consumers.filter((consumer) => !blockedPlansByRoot.has(pluginWriteTaskTargetKey(consumer))),
|
|
1808
|
+
})).filter((cause) => cause.consumers.length > 0);
|
|
1809
|
+
}
|
|
1810
|
+
if (!preview?.operationPlan || draft.executableTargets.length === 0)
|
|
1811
|
+
continue;
|
|
1812
|
+
const sourceIdentity = draft.causes[0]?.sourceIdentity
|
|
1813
|
+
?? status.payload.catalog.sources.find((source) => source.id === sourceId)?.identity;
|
|
1814
|
+
if (!sourceIdentity) {
|
|
1815
|
+
throw new TuiOperationBlockedError('taskSourceIdentityMissing', '任务来源身份不可验证。');
|
|
1816
|
+
}
|
|
1817
|
+
const sourceEvidence = {
|
|
1818
|
+
sourceId,
|
|
1819
|
+
sourceIdentity,
|
|
1820
|
+
requestedTargets: draft.executableTargets,
|
|
1821
|
+
causes: draft.causes,
|
|
1822
|
+
preview,
|
|
1823
|
+
executable: true,
|
|
1824
|
+
};
|
|
1825
|
+
sources.push(sourceEvidence);
|
|
1826
|
+
executableTargets.push(...draft.executableTargets);
|
|
1827
|
+
causes.push(...draft.causes);
|
|
1828
|
+
}
|
|
1829
|
+
const canonicalBlocked = [...new Map(blockedTargets.map((target) => [
|
|
1830
|
+
pluginWriteTaskTargetKey(target.target), target,
|
|
1831
|
+
])).values()].sort((left, right) => pluginWriteTaskTargetKey(left.target)
|
|
1832
|
+
.localeCompare(pluginWriteTaskTargetKey(right.target), 'en'));
|
|
1833
|
+
if (executableTargets.length === 0) {
|
|
1834
|
+
throw new TuiOperationBlockedError('taskNoExecutableTargets', '任务没有可安全执行的目标。', canonicalBlocked.flatMap((target) => target.diagnostics ?? []));
|
|
1835
|
+
}
|
|
1836
|
+
if (intent.executionPolicy === 'all' && canonicalBlocked.length > 0) {
|
|
1837
|
+
throw new TuiOperationBlockedError('taskHasBlockedTargets', '部分目标需要先处理。请调整选择。', canonicalBlocked.flatMap((target) => target.diagnostics ?? []));
|
|
1838
|
+
}
|
|
1839
|
+
await preparation?.reporter.emit('evidence');
|
|
1840
|
+
const evidence = {
|
|
1841
|
+
catalog: {
|
|
1842
|
+
configDigest: configSnapshot.digest,
|
|
1843
|
+
compositeDigest: digest(sources.map((source) => [
|
|
1844
|
+
source.sourceId,
|
|
1845
|
+
source.sourceIdentity,
|
|
1846
|
+
source.preview.operationPlan?.planFingerprint,
|
|
1847
|
+
])),
|
|
1848
|
+
},
|
|
1849
|
+
taskPlan: {
|
|
1850
|
+
goal: intent.goal,
|
|
1851
|
+
requestedTargets: intent.targets,
|
|
1852
|
+
executableTargets: [...executableTargets].sort((left, right) => pluginWriteTaskTargetKey(left).localeCompare(pluginWriteTaskTargetKey(right), 'en')),
|
|
1853
|
+
causes: [...new Map(causes.map((cause) => [cause.causeKey, cause])).values()]
|
|
1854
|
+
.sort((left, right) => left.causeKey.localeCompare(right.causeKey, 'en')),
|
|
1855
|
+
blockedTargets: canonicalBlocked,
|
|
1856
|
+
sources,
|
|
1857
|
+
targetFingerprint: statusTargetFingerprint(observedTargets, observedRevisions),
|
|
1858
|
+
planFingerprint: '',
|
|
1859
|
+
},
|
|
1860
|
+
};
|
|
1861
|
+
evidence.taskPlan.planFingerprint = operationEvidenceFingerprint(evidence);
|
|
1862
|
+
taskCatalogOperationsByEvidence.set(evidence, operationContexts);
|
|
1863
|
+
return evidence;
|
|
1864
|
+
}
|
|
1865
|
+
if (intent.kind === 'pluginWriteBatch') {
|
|
1866
|
+
await preparation?.reporter.emit('status');
|
|
1867
|
+
const selection = await resolveBatchGroups(intent, context.env, context.cwd, frozenBatchEvidence?.requestedPluginIds);
|
|
1868
|
+
signal?.throwIfAborted();
|
|
1869
|
+
if (intent.action === 'cleanup') {
|
|
1870
|
+
const groups = [];
|
|
1871
|
+
const reviewedRemovedPlugins = new Set();
|
|
1872
|
+
for (const group of selection.groups) {
|
|
1873
|
+
signal?.throwIfAborted();
|
|
1874
|
+
const requestedPluginIds = group.requestedPluginIds.filter((pluginId) => !reviewedRemovedPlugins.has(pluginId));
|
|
1875
|
+
if (requestedPluginIds.length === 0)
|
|
1876
|
+
continue;
|
|
1877
|
+
const preview = await runBatchWriteGroup({
|
|
1878
|
+
intent,
|
|
1879
|
+
group: { ...group, requestedPluginIds },
|
|
1880
|
+
cwd: context.cwd,
|
|
1881
|
+
runtime: {
|
|
1882
|
+
...context,
|
|
1883
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1884
|
+
previewOperationPlan: true,
|
|
1885
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
1886
|
+
...(preparation ? {
|
|
1887
|
+
onPreviewStage: (stage) => stage === 'catalog' ? undefined : preparation.reporter.emit(stage),
|
|
1888
|
+
} : {}),
|
|
1889
|
+
},
|
|
1890
|
+
});
|
|
1891
|
+
for (const pluginId of preview.removedPluginCleanupIds ?? []) {
|
|
1892
|
+
reviewedRemovedPlugins.add(pluginId);
|
|
1893
|
+
}
|
|
1894
|
+
groups.push({ ...group, requestedPluginIds, preview,
|
|
1895
|
+
executable: preview.operationPlan !== undefined });
|
|
1896
|
+
}
|
|
1897
|
+
await preparation?.reporter.emit('evidence');
|
|
1898
|
+
signal?.throwIfAborted();
|
|
1899
|
+
const evidence = {
|
|
1900
|
+
catalog: {
|
|
1901
|
+
configDigest: 'cleanup-offline',
|
|
1902
|
+
compositeDigest: digest(groups.map((group) => [
|
|
1903
|
+
group.groupId,
|
|
1904
|
+
group.preview.operationPlan?.planFingerprint,
|
|
1905
|
+
])),
|
|
1906
|
+
},
|
|
1907
|
+
requestedPluginIds: selection.requestedPluginIds,
|
|
1908
|
+
groups,
|
|
1909
|
+
};
|
|
1910
|
+
return evidence;
|
|
1911
|
+
}
|
|
1912
|
+
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
1913
|
+
const groups = [];
|
|
1914
|
+
const ownsObservationSession = !codexObservationSession
|
|
1915
|
+
&& selection.groups.some((group) => {
|
|
1916
|
+
const reviewed = frozenBatchEvidence?.groups.find((candidate) => candidate.groupId === group.groupId);
|
|
1917
|
+
return reviewed?.executable !== false
|
|
1918
|
+
&& (group.platform === 'codex' || group.platform === 'both');
|
|
1919
|
+
});
|
|
1920
|
+
const observationSession = codexObservationSession ?? (ownsObservationSession
|
|
1921
|
+
? await createCodexNativeObservationSession({
|
|
1922
|
+
exactCwd: context.cwd,
|
|
1923
|
+
env: context.env,
|
|
1924
|
+
runner: context.nativeCliRunner,
|
|
1925
|
+
})
|
|
1926
|
+
: undefined);
|
|
1927
|
+
try {
|
|
1928
|
+
await preparation?.reporter.emit('catalog');
|
|
1929
|
+
for (const group of selection.groups) {
|
|
1930
|
+
signal?.throwIfAborted();
|
|
1931
|
+
const reviewed = frozenBatchEvidence?.groups.find((candidate) => candidate.groupId === group.groupId);
|
|
1932
|
+
if (reviewed?.executable === false) {
|
|
1933
|
+
groups.push({ ...group, preview: reviewed.preview, executable: false });
|
|
1934
|
+
continue;
|
|
1935
|
+
}
|
|
1936
|
+
let catalogOperation;
|
|
1937
|
+
try {
|
|
1938
|
+
catalogOperation = !freshCatalog && sessionCatalogOperationContext
|
|
1939
|
+
? selectCatalogOperationContext(sessionCatalogOperationContext, [group.sourceId])
|
|
1940
|
+
: await resolveCatalogOperationContext({
|
|
1941
|
+
sourceIds: [group.sourceId],
|
|
1942
|
+
env: context.env,
|
|
1943
|
+
...(!freshCatalog ? { validatedStoreEntries, validatingStoreEntries } : {}),
|
|
1944
|
+
...(signal ? { signal } : {}),
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
catch {
|
|
1948
|
+
catalogOperation = undefined;
|
|
1949
|
+
}
|
|
1950
|
+
const preview = await runBatchWriteGroup({
|
|
1951
|
+
intent,
|
|
1952
|
+
group,
|
|
1953
|
+
cwd: context.cwd,
|
|
1954
|
+
runtime: {
|
|
1955
|
+
...context,
|
|
1956
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
1957
|
+
expectedCatalogConfigDigest: configSnapshot.digest,
|
|
1958
|
+
...(catalogOperation ? {
|
|
1959
|
+
catalogOperationContext: catalogOperation,
|
|
1960
|
+
expectedGenerationSetDigest: catalogOperation.generationSetDigest,
|
|
1961
|
+
} : {}),
|
|
1962
|
+
previewOperationPlan: true,
|
|
1963
|
+
...(observationSession ? { codexObservationSession: observationSession } : {}),
|
|
1964
|
+
...(preparation ? {
|
|
1965
|
+
onPreviewStage: (stage) => stage === 'catalog' ? undefined : preparation.reporter.emit(stage),
|
|
1966
|
+
} : {}),
|
|
1967
|
+
},
|
|
1968
|
+
});
|
|
1969
|
+
groups.push({ ...group, preview, executable: preview.operationPlan !== undefined });
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
finally {
|
|
1973
|
+
if (ownsObservationSession)
|
|
1974
|
+
await observationSession?.dispose();
|
|
1975
|
+
}
|
|
1976
|
+
await preparation?.reporter.emit('evidence');
|
|
1977
|
+
signal?.throwIfAborted();
|
|
1978
|
+
const merged = mergeWriteCommandResults(groups.map((group) => group.preview));
|
|
1979
|
+
const targetVersions = groups.flatMap((group) => {
|
|
1980
|
+
if (group.platform === 'both')
|
|
1981
|
+
return [];
|
|
1982
|
+
const platform = group.platform;
|
|
1983
|
+
return group.requestedPluginIds.map((pluginId) => {
|
|
1984
|
+
const live = flattenStatusTargets(sessionStatusResult?.payload.targets ?? []).find((target) => target.pluginId === pluginId && target.platform === platform
|
|
1985
|
+
&& (target.scope === group.scope || statusTargetIntent(target).scopes.includes(group.scope)
|
|
1986
|
+
|| platform === 'codex' && statusTargetActivation(target)?.[group.scope] === true));
|
|
1987
|
+
const revision = sessionStatusResult?.targetRevisions?.find((target) => target.pluginId === pluginId && target.platform === platform
|
|
1988
|
+
&& target.scope === group.scope)?.revision;
|
|
1989
|
+
const activation = live ? statusTargetActivation(live) : undefined;
|
|
1990
|
+
const ownership = live && live.scope === group.scope
|
|
1991
|
+
? statusTargetOwnershipState(live) : 'absent';
|
|
1992
|
+
const present = ownership === 'present' || ownership === 'partial'
|
|
1993
|
+
|| platform === 'codex' && activation?.[group.scope] === true;
|
|
1994
|
+
const planned = live ? statusTargetIntent(live).scopes.includes(group.scope) : false;
|
|
1995
|
+
return {
|
|
1996
|
+
pluginId,
|
|
1997
|
+
platform,
|
|
1998
|
+
scope: group.scope,
|
|
1999
|
+
presence: present ? 'installed'
|
|
2000
|
+
: ownership === 'absent' && planned ? 'new' : 'unknown',
|
|
2001
|
+
...(revision?.installedVersion ? { installedVersion: revision.installedVersion } : {}),
|
|
2002
|
+
...(revision?.availableVersion ? { availableVersion: revision.availableVersion } : {}),
|
|
2003
|
+
};
|
|
2004
|
+
});
|
|
2005
|
+
});
|
|
2006
|
+
const evidence = {
|
|
2007
|
+
catalog: {
|
|
2008
|
+
configDigest: configSnapshot.digest,
|
|
2009
|
+
compositeDigest: sessionStatusResult?.payload.catalog.compositeDigest
|
|
2010
|
+
?? digest(groups.map((group) => [group.groupId, group.preview.operationPlan?.planFingerprint])),
|
|
2011
|
+
},
|
|
2012
|
+
requestedPluginIds: selection.requestedPluginIds,
|
|
2013
|
+
...(selection.projectIntentDigest
|
|
2014
|
+
? { projectIntentDigest: selection.projectIntentDigest }
|
|
2015
|
+
: {}),
|
|
2016
|
+
groups,
|
|
2017
|
+
targetVersions: [...new Map(targetVersions.map((target) => [[
|
|
2018
|
+
target.pluginId, target.platform, target.scope,
|
|
2019
|
+
].join('\0'), target])).values()].sort((left, right) => [
|
|
2020
|
+
left.pluginId, left.platform, left.scope,
|
|
2021
|
+
].join('\0').localeCompare([
|
|
2022
|
+
right.pluginId, right.platform, right.scope,
|
|
2023
|
+
].join('\0'), 'en')),
|
|
2024
|
+
...(merged.dependencyPlan ? { dependencyPlan: merged.dependencyPlan } : {}),
|
|
2025
|
+
...(merged.codexReconcilePlans ? { codexReconcilePlans: merged.codexReconcilePlans } : {}),
|
|
2026
|
+
...(merged.operationPlan ? { operationPlan: merged.operationPlan } : {}),
|
|
2027
|
+
};
|
|
2028
|
+
return evidence;
|
|
2029
|
+
}
|
|
2030
|
+
if (intent.kind === 'pluginWrite' && intent.action === 'cleanup') {
|
|
2031
|
+
const preview = await cleanupWriteCommand([intent.pluginId], {
|
|
2032
|
+
cwd: context.cwd,
|
|
2033
|
+
platform: intent.platform,
|
|
2034
|
+
scope: intent.scope,
|
|
2035
|
+
force: intent.force === true,
|
|
2036
|
+
}, {
|
|
2037
|
+
...context,
|
|
2038
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
2039
|
+
previewOperationPlan: true,
|
|
2040
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
2041
|
+
...(preparation ? {
|
|
2042
|
+
onPreviewStage: (stage) => stage === 'catalog' ? undefined : preparation.reporter.emit(stage),
|
|
2043
|
+
} : {}),
|
|
2044
|
+
});
|
|
2045
|
+
signal?.throwIfAborted();
|
|
2046
|
+
if (!preview.operationPlan) {
|
|
2047
|
+
throw new TuiOperationBlockedError('cleanupPlanUnavailable', '无法建立可信的清理计划。');
|
|
2048
|
+
}
|
|
2049
|
+
const offlineCleanupPlans = preview.offlineCleanupPlans ?? [];
|
|
2050
|
+
await preparation?.reporter.emit('evidence');
|
|
2051
|
+
return {
|
|
2052
|
+
catalog: {
|
|
2053
|
+
configDigest: 'cleanup-offline',
|
|
2054
|
+
compositeDigest: preview.operationPlan.planFingerprint,
|
|
2055
|
+
},
|
|
2056
|
+
operationPlan: preview.operationPlan,
|
|
2057
|
+
offlineCleanupPlans,
|
|
2058
|
+
...(preview.removedPluginCleanupIds
|
|
2059
|
+
? { removedPluginCleanupIds: preview.removedPluginCleanupIds }
|
|
2060
|
+
: {}),
|
|
2061
|
+
...(offlineCleanupPlans.length === 1
|
|
2062
|
+
? { offlineCleanup: offlineCleanupPlans[0] }
|
|
2063
|
+
: {}),
|
|
2064
|
+
targetFingerprint: preview.operationPlan.planFingerprint,
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
const packageInfo = await readCliPackageInfo();
|
|
2068
|
+
let catalogOperation;
|
|
2069
|
+
let catalogOperationError;
|
|
2070
|
+
if (intent.kind !== 'portableInstall') {
|
|
2071
|
+
try {
|
|
2072
|
+
const sourceIds = [parsePluginId(intent.pluginId).sourceId];
|
|
2073
|
+
catalogOperation = !freshCatalog && sessionCatalogOperationContext
|
|
2074
|
+
? selectCatalogOperationContext(sessionCatalogOperationContext, sourceIds)
|
|
2075
|
+
: await resolveCatalogOperationContext({
|
|
2076
|
+
sourceIds,
|
|
2077
|
+
env: context.env,
|
|
2078
|
+
...(!freshCatalog ? { validatedStoreEntries, validatingStoreEntries } : {}),
|
|
2079
|
+
...(signal ? { signal } : {}),
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
catch (error) {
|
|
2083
|
+
catalogOperationError = error;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
if (intent.kind === 'portableInstall') {
|
|
2087
|
+
await preparation?.reporter.emit('portable');
|
|
2088
|
+
if (intent.retry
|
|
2089
|
+
&& (intent.retry.receipt.plugin.id !== intent.pluginId
|
|
2090
|
+
|| intent.retry.receipt.scope !== intent.scope)) {
|
|
2091
|
+
throw operationReviewStale('Portable 重试结果与当前插件或范围不匹配。');
|
|
2092
|
+
}
|
|
2093
|
+
const portableSourceId = parsePluginId(intent.pluginId).sourceId;
|
|
2094
|
+
const portableCatalogOperation = sessionCatalogOperationContext
|
|
2095
|
+
? selectCatalogOperationContext(sessionCatalogOperationContext, [portableSourceId])
|
|
2096
|
+
: undefined;
|
|
2097
|
+
const portable = intent.retry
|
|
2098
|
+
? await preparePortableRetry({
|
|
2099
|
+
receipt: intent.retry.receipt,
|
|
2100
|
+
cwd: context.cwd,
|
|
2101
|
+
env: context.env,
|
|
2102
|
+
cliVersion: packageInfo.version,
|
|
2103
|
+
signal,
|
|
2104
|
+
...(portableCatalogOperation
|
|
2105
|
+
? { catalogOperationContext: portableCatalogOperation }
|
|
2106
|
+
: {}),
|
|
2107
|
+
})
|
|
2108
|
+
: await preparePortableInstall({
|
|
2109
|
+
selector: intent.pluginId,
|
|
2110
|
+
scope: intent.scope,
|
|
2111
|
+
...(intent.selectedSkills.length > 0 ? { requestedSkills: intent.selectedSkills } : {}),
|
|
2112
|
+
...(intent.requestedAgents ? { requestedAgents: intent.requestedAgents } : {}),
|
|
2113
|
+
cwd: context.cwd,
|
|
2114
|
+
env: context.env,
|
|
2115
|
+
cliVersion: packageInfo.version,
|
|
2116
|
+
signal,
|
|
2117
|
+
...(portableCatalogOperation
|
|
2118
|
+
? { catalogOperationContext: portableCatalogOperation }
|
|
2119
|
+
: {}),
|
|
2120
|
+
});
|
|
2121
|
+
signal?.throwIfAborted();
|
|
2122
|
+
await preparation?.reporter.emit('evidence');
|
|
2123
|
+
signal?.throwIfAborted();
|
|
2124
|
+
const evidence = {
|
|
2125
|
+
catalog: {
|
|
2126
|
+
configDigest: portable.configDigest,
|
|
2127
|
+
compositeDigest: portable.evidenceDigest,
|
|
2128
|
+
...(portable.generationSetDigest
|
|
2129
|
+
? { generationSetDigest: portable.generationSetDigest }
|
|
2130
|
+
: {}),
|
|
2131
|
+
},
|
|
2132
|
+
portable,
|
|
2133
|
+
};
|
|
2134
|
+
if (catalogOperation)
|
|
2135
|
+
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
2136
|
+
return evidence;
|
|
2137
|
+
}
|
|
2138
|
+
if (preparation && intent.kind === 'configSave') {
|
|
2139
|
+
if (!sessionStatusResult || !catalogOperation) {
|
|
2140
|
+
throw operationReviewStale('当前 TUI session 没有可复用的设置证据。');
|
|
2141
|
+
}
|
|
2142
|
+
await preparation.reporter.emit('config');
|
|
2143
|
+
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
2144
|
+
signal?.throwIfAborted();
|
|
2145
|
+
if (configSnapshot.digest !== sessionStatusResult.payload.catalog.configDigest) {
|
|
2146
|
+
throw operationReviewStale('准备设置确认期间来源配置发生变化。');
|
|
2147
|
+
}
|
|
2148
|
+
const relevantTargets = configAffectedStatusTargets(sessionStatusResult.payload.targets, intent.pluginId, intent.scope);
|
|
2149
|
+
const preparedCatalogOperation = catalogOperation;
|
|
2150
|
+
const selected = await withResolvedCatalogPlugin({
|
|
2151
|
+
selector: intent.pluginId,
|
|
2152
|
+
cliVersion: packageInfo.version,
|
|
2153
|
+
configSnapshot,
|
|
2154
|
+
env: context.env,
|
|
2155
|
+
operationContext: preparedCatalogOperation,
|
|
2156
|
+
...(signal ? { signal } : {}),
|
|
2157
|
+
consume: async ({ plugin, source }) => {
|
|
2158
|
+
if (!plugin.manifest.config) {
|
|
2159
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
2160
|
+
}
|
|
2161
|
+
if (intent.kind === 'configSave') {
|
|
2162
|
+
await coercePluginConfigUpdates({
|
|
2163
|
+
schema: plugin.manifest.config.fields,
|
|
2164
|
+
updates: intent.updates ?? {},
|
|
2165
|
+
cwd: context.cwd,
|
|
2166
|
+
});
|
|
2167
|
+
for (const key of intent.removeKeys ?? []) {
|
|
2168
|
+
if (!plugin.manifest.config.fields[key]) {
|
|
2169
|
+
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
const impact = intent.retryApply ? undefined : await analyzePluginConfigMutationImpact({
|
|
2174
|
+
plugin,
|
|
2175
|
+
scope: intent.scope,
|
|
2176
|
+
cwd: context.cwd,
|
|
2177
|
+
env: context.env,
|
|
2178
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, relevantTargets),
|
|
2179
|
+
mutation: {
|
|
2180
|
+
kind: 'patch',
|
|
2181
|
+
updates: intent.updates,
|
|
2182
|
+
removeKeys: intent.removeKeys,
|
|
2183
|
+
},
|
|
2184
|
+
});
|
|
2185
|
+
const affectedTargets = intent.retryApply
|
|
2186
|
+
? configImpactVisibleTargets(plugin.manifest.name, relevantTargets)
|
|
2187
|
+
: impact.affectedTargets;
|
|
2188
|
+
return {
|
|
2189
|
+
pluginName: plugin.manifest.name,
|
|
2190
|
+
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
2191
|
+
impact,
|
|
2192
|
+
preApplyAuthorization: configIntentRequestsApply(intent)
|
|
2193
|
+
? (await resolveConfigPreApplyAuthorization({
|
|
2194
|
+
plugin,
|
|
2195
|
+
scope: intent.scope,
|
|
2196
|
+
cwd: context.cwd,
|
|
2197
|
+
env: context.env,
|
|
2198
|
+
applyTargets: affectedTargets,
|
|
2199
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
2200
|
+
rebuildRuntime: {
|
|
2201
|
+
catalogOperationContext: preparedCatalogOperation,
|
|
2202
|
+
expectedGenerationSetDigest: preparedCatalogOperation.generationSetDigest,
|
|
2203
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
2204
|
+
},
|
|
2205
|
+
})).targets
|
|
2206
|
+
: [],
|
|
2207
|
+
sharedNativeRenderTargets: intent.retryApply
|
|
2208
|
+
? configRetrySharedNativeRenderTargets(plugin)
|
|
2209
|
+
: impact.sharedNativeRenderTargets,
|
|
2210
|
+
};
|
|
2211
|
+
},
|
|
2212
|
+
});
|
|
2213
|
+
const retryStore = intent.retryApply ? await readPluginConfigStore({
|
|
2214
|
+
sourceId: selected.source.sourceId,
|
|
2215
|
+
sourceIdentity: selected.source.sourceIdentity,
|
|
2216
|
+
logicalIdentity: selected.source.logicalIdentity,
|
|
2217
|
+
pluginName: selected.pluginName,
|
|
2218
|
+
scope: intent.scope,
|
|
2219
|
+
cwd: context.cwd,
|
|
2220
|
+
env: context.env,
|
|
2221
|
+
}) : undefined;
|
|
2222
|
+
signal?.throwIfAborted();
|
|
2223
|
+
const relevantRevisions = (sessionStatusResult.targetRevisions ?? []).filter((revision) => relevantTargets.some((target) => target.platform === revision.platform
|
|
2224
|
+
&& target.scope === revision.scope
|
|
2225
|
+
&& target.pluginId === revision.pluginId));
|
|
2226
|
+
await preparation.reporter.emit('evidence');
|
|
2227
|
+
const evidence = {
|
|
2228
|
+
catalog: {
|
|
2229
|
+
configDigest: sessionStatusResult.payload.catalog.configDigest,
|
|
2230
|
+
compositeDigest: sessionStatusResult.payload.catalog.compositeDigest,
|
|
2231
|
+
...(catalogOperation ? { generationSetDigest: catalogOperation.generationSetDigest } : {}),
|
|
2232
|
+
},
|
|
2233
|
+
...(selected.source ? { source: selected.source } : {}),
|
|
2234
|
+
targetFingerprint: statusTargetFingerprint(relevantTargets, relevantRevisions),
|
|
2235
|
+
config: {
|
|
2236
|
+
scope: intent.scope,
|
|
2237
|
+
...(selected.source?.manifestDigest ? { schemaIdentity: selected.source.manifestDigest } : {}),
|
|
2238
|
+
storeDigest: selected.impact?.storeDigest
|
|
2239
|
+
?? digest({ exists: retryStore?.exists, rawDigest: retryStore?.rawDigest }),
|
|
2240
|
+
impactState: selected.impact?.impactState ?? 'known',
|
|
2241
|
+
...(selected.impact?.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
2242
|
+
affectedTargets: (selected.impact?.affectedTargets
|
|
2243
|
+
?? relevantTargets).map(({ platform, scope }) => ({ platform, scope })),
|
|
2244
|
+
...(selected.preApplyAuthorization.length > 0
|
|
2245
|
+
? { preApplyAuthorization: selected.preApplyAuthorization }
|
|
2246
|
+
: {}),
|
|
2247
|
+
...(selected.sharedNativeRenderTargets.length > 0
|
|
2248
|
+
? { sharedNativeRenderTargets: selected.sharedNativeRenderTargets }
|
|
2249
|
+
: {}),
|
|
2250
|
+
},
|
|
2251
|
+
};
|
|
2252
|
+
if (catalogOperation)
|
|
2253
|
+
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
2254
|
+
return evidence;
|
|
2255
|
+
}
|
|
2256
|
+
await preparation?.reporter.emit('status');
|
|
2257
|
+
const statusCatalogOperation = catalogOperation
|
|
2258
|
+
?? (!freshCatalog ? sessionCatalogOperationContext : undefined);
|
|
2259
|
+
const status = await statusCommandV8({
|
|
2260
|
+
plugins: [...new Set([intent.pluginId,
|
|
2261
|
+
...(intent.kind === 'pluginWrite' && intent.originIssue?.consumerPluginId
|
|
2262
|
+
? [intent.originIssue.consumerPluginId] : [])])],
|
|
2263
|
+
...('platform' in intent ? { platform: intent.platform } : {}),
|
|
2264
|
+
...(intent.kind !== 'pluginWrite' && intent.scope === 'project'
|
|
2265
|
+
? { scope: intent.scope }
|
|
2266
|
+
: {}),
|
|
2267
|
+
cwd: context.cwd,
|
|
485
2268
|
env: context.env,
|
|
2269
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
2270
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
486
2271
|
cliVersion: packageInfo.version,
|
|
2272
|
+
...(statusCatalogOperation ? { catalogOperationContext: statusCatalogOperation } : {}),
|
|
2273
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
487
2274
|
});
|
|
488
2275
|
signal?.throwIfAborted();
|
|
489
|
-
if (intent.kind === 'pluginWrite') {
|
|
490
|
-
await assertTypedIssueOrigin(intent, status.payload.targets);
|
|
491
|
-
}
|
|
492
2276
|
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
2277
|
+
signal?.throwIfAborted();
|
|
2278
|
+
if (configSnapshot.digest !== status.payload.catalog.configDigest) {
|
|
2279
|
+
throw operationReviewStale('准备确认信息期间来源配置发生变化。');
|
|
2280
|
+
}
|
|
2281
|
+
if (catalogOperationError)
|
|
2282
|
+
throw catalogOperationError;
|
|
2283
|
+
if (!catalogOperation) {
|
|
2284
|
+
catalogOperation = await resolveCatalogOperationContext({
|
|
2285
|
+
sourceIds: [parsePluginId(intent.pluginId).sourceId],
|
|
2286
|
+
configSnapshot,
|
|
2287
|
+
env: context.env,
|
|
2288
|
+
...(!freshCatalog ? { validatedStoreEntries, validatingStoreEntries } : {}),
|
|
2289
|
+
...(signal ? { signal } : {}),
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
493
2292
|
let dependencyPlan;
|
|
2293
|
+
let codexReconcilePlans;
|
|
2294
|
+
let operationPlan;
|
|
2295
|
+
await preparation?.reporter.emit('catalog');
|
|
2296
|
+
const configVisibleTargets = intent.kind === 'configSave'
|
|
2297
|
+
? configAffectedStatusTargets(status.payload.targets, intent.pluginId, intent.scope)
|
|
2298
|
+
: [];
|
|
2299
|
+
const selected = await withResolvedCatalogPlugin({
|
|
2300
|
+
selector: intent.pluginId,
|
|
2301
|
+
cliVersion: packageInfo.version,
|
|
2302
|
+
configSnapshot,
|
|
2303
|
+
env: context.env,
|
|
2304
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
2305
|
+
...(signal ? { signal } : {}),
|
|
2306
|
+
consume: async ({ plugin, source }) => {
|
|
2307
|
+
if (preparation?.validateIntent && intent.kind === 'configSave') {
|
|
2308
|
+
await preparation.reporter.emit('config');
|
|
2309
|
+
if (!plugin.manifest.config) {
|
|
2310
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
2311
|
+
}
|
|
2312
|
+
await coercePluginConfigUpdates({
|
|
2313
|
+
schema: plugin.manifest.config.fields,
|
|
2314
|
+
updates: intent.updates ?? {},
|
|
2315
|
+
cwd: context.cwd,
|
|
2316
|
+
});
|
|
2317
|
+
for (const key of intent.removeKeys ?? []) {
|
|
2318
|
+
if (!plugin.manifest.config.fields[key]) {
|
|
2319
|
+
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
const impact = intent.kind === 'configSave' && !intent.retryApply
|
|
2324
|
+
? await analyzePluginConfigMutationImpact({
|
|
2325
|
+
plugin,
|
|
2326
|
+
scope: intent.scope,
|
|
2327
|
+
cwd: context.cwd,
|
|
2328
|
+
env: context.env,
|
|
2329
|
+
visibleTargets: configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets),
|
|
2330
|
+
mutation: {
|
|
2331
|
+
kind: 'patch',
|
|
2332
|
+
updates: intent.updates,
|
|
2333
|
+
removeKeys: intent.removeKeys,
|
|
2334
|
+
},
|
|
2335
|
+
})
|
|
2336
|
+
: undefined;
|
|
2337
|
+
return {
|
|
2338
|
+
pluginName: plugin.manifest.name,
|
|
2339
|
+
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
2340
|
+
impact,
|
|
2341
|
+
preApplyAuthorization: intent.kind === 'configSave'
|
|
2342
|
+
&& configIntentRequestsApply(intent)
|
|
2343
|
+
? (await resolveConfigPreApplyAuthorization({
|
|
2344
|
+
plugin,
|
|
2345
|
+
scope: intent.scope,
|
|
2346
|
+
cwd: context.cwd,
|
|
2347
|
+
env: context.env,
|
|
2348
|
+
applyTargets: intent.retryApply
|
|
2349
|
+
? configImpactVisibleTargets(plugin.manifest.name, configVisibleTargets)
|
|
2350
|
+
: impact.affectedTargets,
|
|
2351
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
2352
|
+
rebuildRuntime: {
|
|
2353
|
+
...(catalogOperation ? { catalogOperationContext: catalogOperation } : {}),
|
|
2354
|
+
...(catalogOperation?.generationSetDigest
|
|
2355
|
+
? { expectedGenerationSetDigest: catalogOperation.generationSetDigest }
|
|
2356
|
+
: {}),
|
|
2357
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
2358
|
+
},
|
|
2359
|
+
})).targets
|
|
2360
|
+
: [],
|
|
2361
|
+
sharedNativeRenderTargets: intent.kind === 'configSave'
|
|
2362
|
+
? intent.retryApply
|
|
2363
|
+
? configRetrySharedNativeRenderTargets(plugin)
|
|
2364
|
+
: impact.sharedNativeRenderTargets
|
|
2365
|
+
: [],
|
|
2366
|
+
};
|
|
2367
|
+
},
|
|
2368
|
+
});
|
|
2369
|
+
if (intent.kind === 'pluginWrite' && intent.expectedUpdate) {
|
|
2370
|
+
const revision = status.targetRevisions.find((entry) => entry.pluginId === intent.pluginId && entry.platform === intent.platform
|
|
2371
|
+
&& entry.scope === intent.scope);
|
|
2372
|
+
const generation = catalogOperation?.generationSet.sources.find((entry) => entry.sourceId === selected.source.sourceId);
|
|
2373
|
+
if (intent.action !== 'sync'
|
|
2374
|
+
|| !('pluginVersion' in selected.source)
|
|
2375
|
+
|| selected.source.sourceIdentity !== intent.expectedUpdate.sourceIdentity
|
|
2376
|
+
|| selected.source.pluginVersion !== intent.expectedUpdate.activeVersion
|
|
2377
|
+
|| generation?.storeKey !== intent.expectedUpdate.generationKey
|
|
2378
|
+
|| revision?.revision.installedVersion !== intent.expectedUpdate.installedVersion
|
|
2379
|
+
|| revision?.revision.availableVersion !== intent.expectedUpdate.activeVersion
|
|
2380
|
+
|| revision.revision.state !== 'upgradeAvailable') {
|
|
2381
|
+
throw operationReviewStale('插件更新版本或 Active Catalog 证据已变化。');
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
let codexManager;
|
|
2385
|
+
let resolvedCodexManager;
|
|
494
2386
|
const hasDeclaredDependencies = (status.pluginSummaries.find((summary) => summary.pluginId === intent.pluginId)?.dependencyTotalCount ?? 0) > 0;
|
|
495
|
-
if (intent.kind === 'pluginWrite'
|
|
496
|
-
&& hasDeclaredDependencies
|
|
497
|
-
&& (intent.action === 'install' || intent.action === 'upgrade' || intent.action === 'reinstall')) {
|
|
2387
|
+
if (intent.kind === 'pluginWrite') {
|
|
498
2388
|
const command = {
|
|
499
2389
|
install: installWriteCommand,
|
|
500
|
-
|
|
2390
|
+
refreshAndSync: syncWriteCommand,
|
|
501
2391
|
reinstall: reinstallWriteCommand,
|
|
2392
|
+
uninstall: uninstallWriteCommand,
|
|
2393
|
+
cleanup: cleanupWriteCommand,
|
|
2394
|
+
sync: syncWriteCommand,
|
|
502
2395
|
}[intent.action];
|
|
503
2396
|
const preview = await command([intent.pluginId], {
|
|
504
2397
|
cwd: context.cwd,
|
|
505
2398
|
platform: intent.platform,
|
|
506
2399
|
scope: intent.scope,
|
|
2400
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
2401
|
+
? {}
|
|
2402
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
2403
|
+
...(intent.action === 'install' && intent.dependencyScopeOverrides
|
|
2404
|
+
? { dependencyScopeOverrides: intent.dependencyScopeOverrides }
|
|
2405
|
+
: {}),
|
|
2406
|
+
...(intent.action === 'cleanup' ? { force: intent.force === true } : {}),
|
|
507
2407
|
}, {
|
|
508
2408
|
...context,
|
|
2409
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
509
2410
|
expectedCatalogConfigDigest: status.payload.catalog.configDigest,
|
|
510
|
-
|
|
2411
|
+
...(catalogOperation ? {
|
|
2412
|
+
catalogOperationContext: catalogOperation,
|
|
2413
|
+
expectedGenerationSetDigest: catalogOperation.generationSetDigest,
|
|
2414
|
+
} : {}),
|
|
2415
|
+
previewOperationPlan: true,
|
|
2416
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
2417
|
+
...(preparation ? {
|
|
2418
|
+
onPreviewStage: (stage) => stage === 'catalog' ? undefined : preparation.reporter.emit(stage),
|
|
2419
|
+
} : {}),
|
|
511
2420
|
});
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
2421
|
+
signal?.throwIfAborted();
|
|
2422
|
+
codexReconcilePlans = preview?.codexReconcilePlans;
|
|
2423
|
+
operationPlan = preview?.operationPlan;
|
|
2424
|
+
if (hasDeclaredDependencies
|
|
2425
|
+
&& (intent.action === 'install'
|
|
2426
|
+
|| intent.action === 'refreshAndSync'
|
|
2427
|
+
|| intent.action === 'reinstall'
|
|
2428
|
+
|| intent.action === 'sync')) {
|
|
2429
|
+
dependencyPlan = preview.dependencyPlan;
|
|
2430
|
+
if (!dependencyPlan) {
|
|
2431
|
+
throw new TuiOperationBlockedError('dependencyGraphInvalid', '无法建立可信的依赖安装计划。');
|
|
2432
|
+
}
|
|
2433
|
+
const blocker = dependencyPlan.targets.find((target) => target.action === 'block');
|
|
2434
|
+
if (blocker) {
|
|
2435
|
+
const code = blocker.errorCode ?? 'dependencyNotReady';
|
|
2436
|
+
const reason = code === 'dependencyScopeConflict' || code === 'codexExtensionScopeConflict'
|
|
2437
|
+
? '这个依赖的安装位置存在冲突,需要先选择保留的位置。'
|
|
2438
|
+
: code === 'artifactCollision' || code === 'exclusiveOwnerEvidenceInvalid'
|
|
2439
|
+
? '这个依赖的安装位置被其他内容占用,需要先检查并处理冲突。'
|
|
2440
|
+
: '这个依赖尚不可用,需要先检查并恢复后再安装。';
|
|
2441
|
+
throw new TuiOperationBlockedError(code, `${blocker.pluginId}:${reason}`, [{
|
|
2442
|
+
id: `dependency:${blocker.pluginId}:${blocker.platform}:${blocker.resolvedScope}`,
|
|
2443
|
+
code, stage: 'dependencyPlan', safeMessage: reason,
|
|
2444
|
+
target: { pluginId: blocker.pluginId, platform: blocker.platform, scope: blocker.resolvedScope },
|
|
2445
|
+
causes: [], detailLines: [],
|
|
2446
|
+
}]);
|
|
2447
|
+
}
|
|
515
2448
|
}
|
|
516
|
-
const
|
|
517
|
-
if (
|
|
518
|
-
|
|
2449
|
+
const managerPreview = preview?.codexManagerPreview;
|
|
2450
|
+
if (managerPreview?.state === 'blocked') {
|
|
2451
|
+
const message = managerPreview.code === 'codexSystemCliUnsupported'
|
|
2452
|
+
? '系统 Codex CLI 版本不受支持。请升级官方 Codex CLI 后重试。'
|
|
2453
|
+
: 'AW-managed Codex runtime 当前不可用。请重试、升级 AW,或安装官方 Codex CLI。';
|
|
2454
|
+
throw new TuiOperationBlockedError(managerPreview.code, `${managerPreview.code}: ${message}`);
|
|
2455
|
+
}
|
|
2456
|
+
if (managerPreview) {
|
|
2457
|
+
if (managerPreview.state === 'system' || managerPreview.state === 'cached') {
|
|
2458
|
+
resolvedCodexManager = managerPreview.manager;
|
|
2459
|
+
}
|
|
2460
|
+
codexManager = {
|
|
2461
|
+
state: managerPreview.state,
|
|
2462
|
+
packageName: MANAGED_CODEX_PACKAGE_NAME,
|
|
2463
|
+
version: managerPreview.state === 'requires-install'
|
|
2464
|
+
? MANAGED_CODEX_VERSION
|
|
2465
|
+
: managerPreview.manager.version,
|
|
2466
|
+
};
|
|
519
2467
|
}
|
|
520
2468
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}),
|
|
532
|
-
});
|
|
2469
|
+
await preparation?.reporter.emit('evidence');
|
|
2470
|
+
signal?.throwIfAborted();
|
|
2471
|
+
const evidenceTargets = intent.kind === 'configSave'
|
|
2472
|
+
? configVisibleTargets
|
|
2473
|
+
: flattenStatusTargets(status.payload.targets);
|
|
2474
|
+
const evidenceRevisions = intent.kind === 'configSave'
|
|
2475
|
+
? (status.targetRevisions ?? []).filter((revision) => evidenceTargets.some((target) => target.platform === revision.platform
|
|
2476
|
+
&& target.scope === revision.scope
|
|
2477
|
+
&& target.pluginId === revision.pluginId))
|
|
2478
|
+
: (status.targetRevisions ?? []);
|
|
533
2479
|
const evidence = {
|
|
534
2480
|
catalog: {
|
|
535
2481
|
configDigest: status.payload.catalog.configDigest,
|
|
536
2482
|
compositeDigest: status.payload.catalog.compositeDigest,
|
|
2483
|
+
...(catalogOperation
|
|
2484
|
+
? { generationSetDigest: catalogOperation.generationSetDigest }
|
|
2485
|
+
: {}),
|
|
537
2486
|
},
|
|
538
2487
|
source: selected.source,
|
|
539
2488
|
...(dependencyPlan ? { dependencyPlan } : {}),
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
scope: target.scope,
|
|
545
|
-
state: target.state,
|
|
546
|
-
errors: target.errors.map((error) => error.code).sort(),
|
|
547
|
-
components: target.components.map((component) => [component.key, component.state])
|
|
548
|
-
.sort(([left], [right]) => left.localeCompare(right, 'en')),
|
|
549
|
-
})).sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
550
|
-
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en'))),
|
|
2489
|
+
...(codexReconcilePlans ? { codexReconcilePlans } : {}),
|
|
2490
|
+
...(operationPlan ? { operationPlan } : {}),
|
|
2491
|
+
...(codexManager ? { codexManager } : {}),
|
|
2492
|
+
targetFingerprint: statusTargetFingerprint(evidenceTargets, evidenceRevisions),
|
|
551
2493
|
};
|
|
552
|
-
if (intent.kind === 'configSave'
|
|
553
|
-
const
|
|
2494
|
+
if (intent.kind === 'configSave') {
|
|
2495
|
+
const impact = 'impact' in selected ? selected.impact : undefined;
|
|
2496
|
+
const retryStore = intent.retryApply ? await readPluginConfigStore({
|
|
554
2497
|
sourceId: selected.source.sourceId,
|
|
555
2498
|
sourceIdentity: selected.source.sourceIdentity,
|
|
2499
|
+
...('logicalIdentity' in selected.source
|
|
2500
|
+
? { logicalIdentity: selected.source.logicalIdentity }
|
|
2501
|
+
: {}),
|
|
556
2502
|
pluginName: selected.pluginName,
|
|
557
2503
|
scope: intent.scope,
|
|
558
|
-
projectLayer: intent.projectLayer,
|
|
559
2504
|
cwd: context.cwd,
|
|
560
2505
|
env: context.env,
|
|
561
|
-
});
|
|
2506
|
+
}) : undefined;
|
|
2507
|
+
signal?.throwIfAborted();
|
|
562
2508
|
evidence.config = {
|
|
563
2509
|
scope: intent.scope,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
2510
|
+
...('manifestDigest' in selected.source
|
|
2511
|
+
? { schemaIdentity: selected.source.manifestDigest }
|
|
2512
|
+
: {}),
|
|
2513
|
+
storeDigest: impact?.storeDigest
|
|
2514
|
+
?? digest({ exists: retryStore?.exists, rawDigest: retryStore?.rawDigest }),
|
|
2515
|
+
impactState: impact?.impactState ?? 'known',
|
|
2516
|
+
...(impact?.noEffectiveChange ? { noEffectiveChange: true } : {}),
|
|
2517
|
+
affectedTargets: (impact?.affectedTargets
|
|
2518
|
+
?? evidenceTargets).map(({ platform, scope }) => ({ platform, scope })),
|
|
2519
|
+
...(intent.scope === 'project' ? {
|
|
2520
|
+
shareability: await inspectConfigShareability({
|
|
2521
|
+
sourceId: selected.source.sourceId,
|
|
2522
|
+
pluginName: selected.pluginName,
|
|
2523
|
+
scope: intent.scope,
|
|
2524
|
+
cwd: context.cwd,
|
|
2525
|
+
env: context.env,
|
|
2526
|
+
}),
|
|
2527
|
+
} : {}),
|
|
2528
|
+
...('sharedNativeRenderTargets' in selected
|
|
2529
|
+
&& selected.sharedNativeRenderTargets.length > 0
|
|
2530
|
+
? { sharedNativeRenderTargets: selected.sharedNativeRenderTargets }
|
|
2531
|
+
: {}),
|
|
2532
|
+
...('preApplyAuthorization' in selected
|
|
2533
|
+
&& selected.preApplyAuthorization.length > 0
|
|
2534
|
+
? { preApplyAuthorization: selected.preApplyAuthorization }
|
|
2535
|
+
: {}),
|
|
567
2536
|
};
|
|
568
2537
|
}
|
|
2538
|
+
if (catalogOperation)
|
|
2539
|
+
catalogOperationByEvidence.set(evidence, catalogOperation);
|
|
2540
|
+
if (resolvedCodexManager)
|
|
2541
|
+
codexManagerByEvidence.set(evidence, resolvedCodexManager);
|
|
569
2542
|
return evidence;
|
|
570
2543
|
};
|
|
571
2544
|
const dependencies = {
|
|
2545
|
+
beginCatalogSession(sessionOptions) {
|
|
2546
|
+
sessionCatalogOperationContext = undefined;
|
|
2547
|
+
if (sessionOptions?.reuseValidatedGenerations !== true) {
|
|
2548
|
+
validatedStoreEntries.clear();
|
|
2549
|
+
validatingStoreEntries.clear();
|
|
2550
|
+
}
|
|
2551
|
+
},
|
|
572
2552
|
loadStatus,
|
|
573
|
-
|
|
2553
|
+
loadPluginContent,
|
|
2554
|
+
async probeCatalogFreshness(sourceId, freshnessOptions, signal) {
|
|
574
2555
|
signal.throwIfAborted();
|
|
2556
|
+
const packageInfo = await readCliPackageInfo();
|
|
2557
|
+
return probeCatalogSourceFreshness({
|
|
2558
|
+
sourceId,
|
|
2559
|
+
cliVersion: packageInfo.version,
|
|
2560
|
+
env: context.env,
|
|
2561
|
+
signal,
|
|
2562
|
+
fullValidation: freshnessOptions.fullValidation,
|
|
2563
|
+
runtime: {
|
|
2564
|
+
...options.catalogGenerationRuntime,
|
|
2565
|
+
validatedStoreEntries,
|
|
2566
|
+
validatingStoreEntries,
|
|
2567
|
+
},
|
|
2568
|
+
});
|
|
2569
|
+
},
|
|
2570
|
+
async inspectSourceRemoval(sourceId, signal) {
|
|
2571
|
+
signal.throwIfAborted();
|
|
2572
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
2573
|
+
const source = config.config.sources.find((entry) => entry.id === sourceId);
|
|
2574
|
+
if (!source)
|
|
2575
|
+
throw new TuiOperationBlockedError('catalogGenerationSourceMissing', '来源不存在。');
|
|
2576
|
+
const impact = await inspectCatalogSourceImpact({
|
|
2577
|
+
sourceId,
|
|
2578
|
+
cwd: context.cwd,
|
|
2579
|
+
env: context.env,
|
|
2580
|
+
sourcePrimary: source.primary,
|
|
2581
|
+
mode: 'remove',
|
|
2582
|
+
});
|
|
2583
|
+
const counts = (category) => impact.affectedReferences.filter((reference) => reference.category === category).length;
|
|
575
2584
|
return {
|
|
576
|
-
blocked:
|
|
577
|
-
inventoryComplete:
|
|
578
|
-
installationCount:
|
|
579
|
-
configCount:
|
|
580
|
-
lifecycleCount:
|
|
581
|
-
marketplaceCount:
|
|
582
|
-
dependencies:
|
|
2585
|
+
blocked: impact.affectedReferences.length > 0 || !impact.inventoryComplete,
|
|
2586
|
+
inventoryComplete: impact.inventoryComplete,
|
|
2587
|
+
installationCount: counts('installation'),
|
|
2588
|
+
configCount: counts('config'),
|
|
2589
|
+
lifecycleCount: counts('lifecycle'),
|
|
2590
|
+
marketplaceCount: counts('marketplace'),
|
|
2591
|
+
dependencies: impact.affectedReferences,
|
|
583
2592
|
};
|
|
584
2593
|
},
|
|
2594
|
+
async prepareReviewEvidence(intent, signal, onStage, reusableCandidate) {
|
|
2595
|
+
const reporter = createReviewStageReporter({
|
|
2596
|
+
context,
|
|
2597
|
+
onStage,
|
|
2598
|
+
now: options.now ?? Date.now,
|
|
2599
|
+
});
|
|
2600
|
+
try {
|
|
2601
|
+
const preparationWarnings = [];
|
|
2602
|
+
if (intent.kind === 'pluginWrite' && intent.action === 'refreshAndSync') {
|
|
2603
|
+
await reporter.emit('refresh');
|
|
2604
|
+
const packageInfo = await readCliPackageInfo();
|
|
2605
|
+
const sourceId = parsePluginId(intent.pluginId).sourceId;
|
|
2606
|
+
await syncCatalogSourceGeneration({
|
|
2607
|
+
sourceId,
|
|
2608
|
+
cliVersion: packageInfo.version,
|
|
2609
|
+
cwd: context.cwd,
|
|
2610
|
+
env: context.env,
|
|
2611
|
+
signal,
|
|
2612
|
+
}).catch((error) => {
|
|
2613
|
+
preparationWarnings.push(`catalogSourceRefreshFailed: ${sourceId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
2614
|
+
});
|
|
2615
|
+
sessionCatalogOperationContext = undefined;
|
|
2616
|
+
sessionStatusResult = undefined;
|
|
2617
|
+
validatedStoreEntries.clear();
|
|
2618
|
+
validatingStoreEntries.clear();
|
|
2619
|
+
}
|
|
2620
|
+
const taskObservationSession = intent.kind === 'pluginWriteTask'
|
|
2621
|
+
&& intent.targets.some((target) => target.platform === 'codex')
|
|
2622
|
+
? await createCodexNativeObservationSession({
|
|
2623
|
+
exactCwd: context.cwd,
|
|
2624
|
+
env: context.env,
|
|
2625
|
+
runner: context.nativeCliRunner,
|
|
2626
|
+
})
|
|
2627
|
+
: undefined;
|
|
2628
|
+
let evidence;
|
|
2629
|
+
try {
|
|
2630
|
+
evidence = await captureEvidence(intent, signal, {
|
|
2631
|
+
reporter,
|
|
2632
|
+
validateIntent: true,
|
|
2633
|
+
}, createOperationInventoryReader(), intent.kind === 'pluginWrite'
|
|
2634
|
+
&& intent.action === 'refreshAndSync', reusableCandidate, taskObservationSession);
|
|
2635
|
+
}
|
|
2636
|
+
finally {
|
|
2637
|
+
await taskObservationSession?.dispose();
|
|
2638
|
+
}
|
|
2639
|
+
if (preparationWarnings.length > 0)
|
|
2640
|
+
evidence.preparationWarnings = preparationWarnings;
|
|
2641
|
+
return evidence;
|
|
2642
|
+
}
|
|
2643
|
+
finally {
|
|
2644
|
+
await reporter.finish();
|
|
2645
|
+
}
|
|
2646
|
+
},
|
|
2647
|
+
async previewDependencyPlacement(intent, signal) {
|
|
2648
|
+
const evidence = await captureEvidence(intent, signal);
|
|
2649
|
+
return evidence.dependencyPlan;
|
|
2650
|
+
},
|
|
585
2651
|
async validateIntent(intent, signal) {
|
|
2652
|
+
if (intent.kind === 'catalogSourcesRecovery') {
|
|
2653
|
+
signal.throwIfAborted();
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
if (intent.kind === 'catalogGeneration') {
|
|
2657
|
+
signal.throwIfAborted();
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
586
2660
|
if (intent.kind === 'sourceMutation') {
|
|
587
2661
|
const evidence = await captureEvidence(intent, signal);
|
|
588
|
-
if (evidence.sourceWrite?.configDigest === evidence.sourceWrite?.
|
|
2662
|
+
if (evidence.sourceWrite?.configDigest === evidence.sourceWrite?.proposedConfigDigest) {
|
|
589
2663
|
throw new TuiOperationBlockedError('sourceNoChanges', '来源没有变化。');
|
|
590
2664
|
}
|
|
591
2665
|
return;
|
|
592
2666
|
}
|
|
2667
|
+
if (intent.kind === 'configSaveBatch') {
|
|
2668
|
+
assertConfigSaveBatchIntent(intent);
|
|
2669
|
+
for (const group of intent.groups) {
|
|
2670
|
+
await dependencies.validateIntent(configSaveBatchGroupIntent(intent, group), signal);
|
|
2671
|
+
}
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
593
2674
|
if (intent.kind === 'configSave') {
|
|
594
2675
|
const packageInfo = await readCliPackageInfo();
|
|
595
2676
|
await withResolvedCatalogPlugin({
|
|
596
2677
|
selector: intent.pluginId,
|
|
597
2678
|
cliVersion: packageInfo.version,
|
|
598
|
-
freshnessPolicy: 'cacheFirst',
|
|
599
2679
|
env: context.env,
|
|
600
2680
|
signal,
|
|
2681
|
+
...(sessionContextForPlugin(intent.pluginId)
|
|
2682
|
+
? { operationContext: sessionContextForPlugin(intent.pluginId) }
|
|
2683
|
+
: {}),
|
|
601
2684
|
consume: async ({ plugin }) => {
|
|
602
2685
|
if (!plugin.manifest.config) {
|
|
603
2686
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
604
2687
|
}
|
|
605
2688
|
await coercePluginConfigUpdates({
|
|
606
|
-
schema: plugin.manifest.config.
|
|
2689
|
+
schema: plugin.manifest.config.fields,
|
|
607
2690
|
updates: intent.updates ?? {},
|
|
608
2691
|
cwd: context.cwd,
|
|
609
2692
|
});
|
|
610
2693
|
for (const key of intent.removeKeys ?? []) {
|
|
611
|
-
if (!plugin.manifest.config.
|
|
2694
|
+
if (!plugin.manifest.config.fields[key]) {
|
|
612
2695
|
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
613
2696
|
}
|
|
614
2697
|
}
|
|
@@ -619,41 +2702,24 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
619
2702
|
if (intent.kind !== 'pluginWrite')
|
|
620
2703
|
return;
|
|
621
2704
|
signal.throwIfAborted();
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
cliVersion: packageInfo.version,
|
|
630
|
-
});
|
|
2705
|
+
const parsed = parsePluginId(intent.pluginId);
|
|
2706
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
2707
|
+
throw new TuiOperationBlockedError('invalidPluginId', '操作必须使用 canonical pluginId。');
|
|
2708
|
+
}
|
|
2709
|
+
},
|
|
2710
|
+
captureEvidence,
|
|
2711
|
+
inspectCatalogStore(signal) {
|
|
631
2712
|
signal.throwIfAborted();
|
|
632
|
-
|
|
633
|
-
assertIntentIsLegal(intent, status.payload.targets);
|
|
2713
|
+
return inspectCatalogStoreTask({ env: context.env });
|
|
634
2714
|
},
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
cliVersion: packageInfo.version,
|
|
640
|
-
freshnessPolicy: 'forceRemote',
|
|
641
|
-
sourceIds: [sourceId],
|
|
642
|
-
configSnapshot,
|
|
2715
|
+
recheckPortableInstall(receipt, signal) {
|
|
2716
|
+
return recheckPortableInstall({
|
|
2717
|
+
receipt,
|
|
2718
|
+
cwd: context.cwd,
|
|
643
2719
|
env: context.env,
|
|
644
2720
|
signal,
|
|
645
|
-
consume: (catalog) => {
|
|
646
|
-
const item = catalog.sources[0];
|
|
647
|
-
if (item.error)
|
|
648
|
-
throw item.error;
|
|
649
|
-
return {
|
|
650
|
-
sourceIdentity: item.resolution.sourceIdentity,
|
|
651
|
-
requestedRef: item.resolution.requestedRef,
|
|
652
|
-
};
|
|
653
|
-
},
|
|
654
2721
|
});
|
|
655
2722
|
},
|
|
656
|
-
captureEvidence,
|
|
657
2723
|
logError(_error, code, logContext) {
|
|
658
2724
|
return context.debugLogger.log({
|
|
659
2725
|
type: 'tui:controller-error',
|
|
@@ -670,9 +2736,11 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
670
2736
|
return withResolvedCatalogPlugin({
|
|
671
2737
|
selector: pluginId,
|
|
672
2738
|
cliVersion: packageInfo.version,
|
|
673
|
-
freshnessPolicy: 'cacheFirst',
|
|
674
2739
|
env: context.env,
|
|
675
2740
|
signal,
|
|
2741
|
+
...(sessionContextForPlugin(pluginId)
|
|
2742
|
+
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
2743
|
+
: {}),
|
|
676
2744
|
consume: async ({ plugin }) => {
|
|
677
2745
|
if (!plugin.manifest.config) {
|
|
678
2746
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
@@ -681,11 +2749,17 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
681
2749
|
pluginName: plugin.manifest.name,
|
|
682
2750
|
plugin,
|
|
683
2751
|
scope: layer.scope,
|
|
684
|
-
projectLayer: layer.projectLayer,
|
|
685
2752
|
cwd: context.cwd,
|
|
686
2753
|
env: context.env,
|
|
687
2754
|
});
|
|
688
|
-
|
|
2755
|
+
const effectiveRead = await resolveConfigRead({
|
|
2756
|
+
pluginName: plugin.manifest.name,
|
|
2757
|
+
plugin,
|
|
2758
|
+
scope: 'effective',
|
|
2759
|
+
cwd: context.cwd,
|
|
2760
|
+
env: context.env,
|
|
2761
|
+
});
|
|
2762
|
+
return buildConfigGroups({ schema: plugin.manifest.config, read, effectiveRead });
|
|
689
2763
|
},
|
|
690
2764
|
});
|
|
691
2765
|
},
|
|
@@ -694,71 +2768,363 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
694
2768
|
return withResolvedCatalogPlugin({
|
|
695
2769
|
selector: pluginId,
|
|
696
2770
|
cliVersion: packageInfo.version,
|
|
697
|
-
freshnessPolicy: 'cacheFirst',
|
|
698
2771
|
env: context.env,
|
|
699
2772
|
signal,
|
|
700
|
-
|
|
2773
|
+
...(sessionContextForPlugin(pluginId)
|
|
2774
|
+
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
2775
|
+
: {}),
|
|
2776
|
+
consume: async ({ plugin, source }) => {
|
|
701
2777
|
if (!plugin.manifest.config) {
|
|
702
2778
|
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
703
2779
|
}
|
|
2780
|
+
const stores = await readConfigStoresForTui({
|
|
2781
|
+
sourceId: plugin.sourceId,
|
|
2782
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2783
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2784
|
+
pluginName: plugin.manifest.name,
|
|
2785
|
+
schema: plugin.manifest.config.fields,
|
|
2786
|
+
scope: layer.scope,
|
|
2787
|
+
signal,
|
|
2788
|
+
});
|
|
2789
|
+
const userStore = stores.user;
|
|
2790
|
+
const projectStore = stores.project;
|
|
704
2791
|
const read = await resolveConfigRead({
|
|
705
2792
|
pluginName: plugin.manifest.name,
|
|
706
2793
|
plugin,
|
|
707
2794
|
scope: layer.scope,
|
|
708
|
-
projectLayer: layer.projectLayer,
|
|
709
2795
|
cwd: context.cwd,
|
|
710
2796
|
env: context.env,
|
|
711
2797
|
});
|
|
712
|
-
|
|
2798
|
+
const effectiveRead = layer.scope === 'effective' ? read : await resolveConfigRead({
|
|
2799
|
+
pluginName: plugin.manifest.name,
|
|
2800
|
+
plugin,
|
|
2801
|
+
scope: 'effective',
|
|
2802
|
+
cwd: context.cwd,
|
|
2803
|
+
env: context.env,
|
|
2804
|
+
});
|
|
2805
|
+
const layerReads = layer.scope === 'effective' ? undefined : {
|
|
2806
|
+
user: layer.scope === 'user' ? read : await resolveConfigRead({
|
|
2807
|
+
pluginName: plugin.manifest.name,
|
|
2808
|
+
plugin,
|
|
2809
|
+
scope: 'user',
|
|
2810
|
+
cwd: context.cwd,
|
|
2811
|
+
env: context.env,
|
|
2812
|
+
}),
|
|
2813
|
+
...(layer.scope === 'user' ? {} : { project: read }),
|
|
2814
|
+
};
|
|
2815
|
+
const effectiveRaw = await resolveEffectivePluginConfig({
|
|
2816
|
+
sourceId: plugin.sourceId,
|
|
2817
|
+
sourceIdentity: plugin.sourceIdentity,
|
|
2818
|
+
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
2819
|
+
pluginName: plugin.manifest.name,
|
|
2820
|
+
manifest: plugin.manifest,
|
|
2821
|
+
targetScope: layer.scope === 'user' ? 'user' : 'project',
|
|
2822
|
+
cwd: context.cwd,
|
|
2823
|
+
env: context.env,
|
|
2824
|
+
});
|
|
2825
|
+
const layerStore = layer.scope === 'effective'
|
|
2826
|
+
? undefined
|
|
2827
|
+
: layer.scope === 'user' ? userStore : projectStore;
|
|
2828
|
+
const page = buildConfigPage({
|
|
2829
|
+
pluginId,
|
|
2830
|
+
schema: plugin.manifest.config,
|
|
2831
|
+
read,
|
|
2832
|
+
effectiveRead,
|
|
2833
|
+
...(layerReads ? { layerReads } : {}),
|
|
2834
|
+
...(layerStore ? { rawValues: layerStore.values } : {}),
|
|
2835
|
+
rawLayerValues: {
|
|
2836
|
+
user: userStore.values,
|
|
2837
|
+
...(projectStore ? { project: projectStore.values } : {}),
|
|
2838
|
+
},
|
|
2839
|
+
effectiveRawValues: effectiveRaw.values,
|
|
2840
|
+
sharedNativeRefreshKeys: new Set((plugin.manifest.artifacts?.targets ?? []).flatMap((target) => target.target === 'codex.skill' && target.delivery.mode === 'codex-native'
|
|
2841
|
+
? target.refreshKeys
|
|
2842
|
+
: [])),
|
|
2843
|
+
});
|
|
2844
|
+
return { ...page, editEvidence: {
|
|
2845
|
+
sourceIdentity: source.sourceIdentity,
|
|
2846
|
+
schemaIdentity: source.manifestDigest,
|
|
2847
|
+
storeDigests: {
|
|
2848
|
+
user: digest({ exists: userStore.exists, rawDigest: userStore.rawDigest }),
|
|
2849
|
+
...(projectStore ? { project: digest({ exists: projectStore.exists, rawDigest: projectStore.rawDigest }) } : {}),
|
|
2850
|
+
},
|
|
2851
|
+
} };
|
|
713
2852
|
},
|
|
714
2853
|
});
|
|
715
2854
|
},
|
|
716
2855
|
async getConfigResetAvailability(pluginId, layer, signal) {
|
|
2856
|
+
const parsed = parsePluginId(pluginId);
|
|
2857
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
2858
|
+
throw new TuiOperationBlockedError('invalidPluginId', '设置目标必须使用 canonical pluginId。');
|
|
2859
|
+
}
|
|
2860
|
+
let sourceIdentity;
|
|
2861
|
+
let logicalIdentity;
|
|
2862
|
+
try {
|
|
2863
|
+
const packageInfo = await readCliPackageInfo();
|
|
2864
|
+
const source = await withResolvedCatalogPlugin({
|
|
2865
|
+
selector: pluginId,
|
|
2866
|
+
cliVersion: packageInfo.version,
|
|
2867
|
+
env: context.env,
|
|
2868
|
+
signal,
|
|
2869
|
+
...(sessionContextForPlugin(pluginId)
|
|
2870
|
+
? { operationContext: sessionContextForPlugin(pluginId) }
|
|
2871
|
+
: {}),
|
|
2872
|
+
consume: async ({ source }) => ({
|
|
2873
|
+
sourceIdentity: source.sourceIdentity,
|
|
2874
|
+
logicalIdentity: source.logicalIdentity,
|
|
2875
|
+
}),
|
|
2876
|
+
});
|
|
2877
|
+
sourceIdentity = source.sourceIdentity;
|
|
2878
|
+
logicalIdentity = source.logicalIdentity;
|
|
2879
|
+
}
|
|
2880
|
+
catch {
|
|
2881
|
+
sourceIdentity = undefined;
|
|
2882
|
+
logicalIdentity = undefined;
|
|
2883
|
+
}
|
|
717
2884
|
signal.throwIfAborted();
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
const identity = await readNamespacedPluginConfigStoreIdentity({
|
|
722
|
-
sourceId,
|
|
723
|
-
pluginName,
|
|
2885
|
+
const target = await inspectPluginConfigResetTarget({
|
|
2886
|
+
sourceId: parsed.sourceId,
|
|
2887
|
+
pluginName: parsed.pluginName,
|
|
724
2888
|
scope: layer.scope,
|
|
725
|
-
projectLayer: layer.projectLayer,
|
|
726
2889
|
cwd: context.cwd,
|
|
727
2890
|
env: context.env,
|
|
728
2891
|
});
|
|
729
2892
|
signal.throwIfAborted();
|
|
730
|
-
if (
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
2893
|
+
if (target.kind === 'regularFile') {
|
|
2894
|
+
const store = await readPluginConfigStore({
|
|
2895
|
+
sourceId: parsed.sourceId,
|
|
2896
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
2897
|
+
...(logicalIdentity ? { logicalIdentity } : {}),
|
|
2898
|
+
pluginName: parsed.pluginName,
|
|
2899
|
+
scope: layer.scope,
|
|
2900
|
+
cwd: context.cwd,
|
|
2901
|
+
env: context.env,
|
|
2902
|
+
});
|
|
2903
|
+
signal.throwIfAborted();
|
|
738
2904
|
return {
|
|
739
|
-
exists:
|
|
740
|
-
|
|
741
|
-
|
|
2905
|
+
exists: store.exists,
|
|
2906
|
+
state: store.state,
|
|
2907
|
+
...(store.invalidCode ? { invalidCode: store.invalidCode } : {}),
|
|
2908
|
+
sourceIdentityPresent: sourceIdentity !== undefined,
|
|
2909
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
2910
|
+
targetKind: target.kind,
|
|
2911
|
+
resettable: target.resettable,
|
|
2912
|
+
storeDigest: target.fingerprint,
|
|
742
2913
|
};
|
|
743
2914
|
}
|
|
744
2915
|
return {
|
|
745
|
-
exists:
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
}),
|
|
2916
|
+
exists: target.exists,
|
|
2917
|
+
state: target.kind === 'absent' ? 'missing' : 'invalid',
|
|
2918
|
+
sourceIdentityPresent: sourceIdentity !== undefined,
|
|
2919
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
2920
|
+
targetKind: target.kind,
|
|
2921
|
+
resettable: target.resettable,
|
|
2922
|
+
storeDigest: target.fingerprint,
|
|
753
2923
|
};
|
|
754
2924
|
},
|
|
755
|
-
async executeIntent(intent, expectedEvidence) {
|
|
2925
|
+
async executeIntent(intent, expectedEvidence, signal) {
|
|
2926
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
2927
|
+
signal?.throwIfAborted();
|
|
2928
|
+
if (!expectedEvidence.catalogStore) {
|
|
2929
|
+
throw new TuiOperationBlockedError('catalogStoreReviewStale', '确认信息缺少精确清理目标。');
|
|
2930
|
+
}
|
|
2931
|
+
return executeCatalogStoreTask({
|
|
2932
|
+
env: context.env,
|
|
2933
|
+
authorizedItems: expectedEvidence.catalogStore.authorizedItems,
|
|
2934
|
+
});
|
|
2935
|
+
}
|
|
2936
|
+
if (intent.kind === 'catalogSourcesRecovery') {
|
|
2937
|
+
signal?.throwIfAborted();
|
|
2938
|
+
return recoverInvalidCatalogSourcesConfig({ env: context.env });
|
|
2939
|
+
}
|
|
2940
|
+
if (intent.kind === 'catalogGeneration') {
|
|
2941
|
+
signal?.throwIfAborted();
|
|
2942
|
+
const expected = expectedEvidence.catalogGeneration;
|
|
2943
|
+
if (!expected)
|
|
2944
|
+
throw new TuiOperationBlockedError('catalogGenerationReviewStale', '确认信息缺少 Catalog candidate。');
|
|
2945
|
+
const packageInfo = await readCliPackageInfo();
|
|
2946
|
+
let configSaved = false;
|
|
2947
|
+
if (intent.sourceMutation) {
|
|
2948
|
+
const common = {
|
|
2949
|
+
cwd: context.cwd,
|
|
2950
|
+
env: context.env,
|
|
2951
|
+
cliVersion: packageInfo.version,
|
|
2952
|
+
expectedConfigDigest: expected.configDigest,
|
|
2953
|
+
};
|
|
2954
|
+
if (intent.sourceMutation.action === 'add') {
|
|
2955
|
+
await addCatalogSourceCommand({
|
|
2956
|
+
...common,
|
|
2957
|
+
source: intent.sourceMutation.source,
|
|
2958
|
+
expectedProposedConfigDigest: expected.proposedConfigDigest,
|
|
2959
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2960
|
+
requireImpactConfirmation: true,
|
|
2961
|
+
confirmImpact: true,
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2964
|
+
else {
|
|
2965
|
+
await updateCatalogSourceCommand({
|
|
2966
|
+
...common,
|
|
2967
|
+
sourceId: intent.sourceId,
|
|
2968
|
+
update: intent.sourceMutation.update,
|
|
2969
|
+
expectedProposedConfigDigest: expected.proposedConfigDigest,
|
|
2970
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2971
|
+
requireIdentityChangeConfirmation: true,
|
|
2972
|
+
confirmIdentityChange: true,
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2975
|
+
configSaved = true;
|
|
2976
|
+
await tuiControllerRuntimeTestHooks?.afterCatalogSourceConfigCommit?.();
|
|
2977
|
+
}
|
|
2978
|
+
try {
|
|
2979
|
+
let generation;
|
|
2980
|
+
if (intent.action === 'recoverState') {
|
|
2981
|
+
generation = await recoverCatalogGenerationStateAndActivate({
|
|
2982
|
+
sourceId: intent.sourceId,
|
|
2983
|
+
cliVersion: packageInfo.version,
|
|
2984
|
+
cwd: context.cwd,
|
|
2985
|
+
impactConfirmed: true,
|
|
2986
|
+
expectedImpactDigest: expected.impactDigest,
|
|
2987
|
+
expectedCandidate: expected.candidate,
|
|
2988
|
+
env: context.env,
|
|
2989
|
+
signal,
|
|
2990
|
+
runtime: options.catalogGenerationRuntime,
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
else if (intent.action === 'repair') {
|
|
2994
|
+
generation = await repairCatalogSourceGeneration({
|
|
2995
|
+
sourceId: intent.sourceId,
|
|
2996
|
+
cliVersion: packageInfo.version,
|
|
2997
|
+
cwd: context.cwd,
|
|
2998
|
+
expectedCandidate: expected.candidate,
|
|
2999
|
+
expectedActive: expected.previousActive ?? null,
|
|
3000
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
3001
|
+
env: context.env,
|
|
3002
|
+
signal,
|
|
3003
|
+
runtime: {
|
|
3004
|
+
...options.catalogGenerationRuntime,
|
|
3005
|
+
afterCandidateResolved: tuiControllerRuntimeTestHooks
|
|
3006
|
+
?.afterCatalogGenerationCandidateResolved,
|
|
3007
|
+
},
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
else if (intent.action === 'update' && expected.exactRepair) {
|
|
3011
|
+
generation = await repairCatalogSourceGeneration({
|
|
3012
|
+
sourceId: intent.sourceId,
|
|
3013
|
+
cliVersion: packageInfo.version,
|
|
3014
|
+
cwd: context.cwd,
|
|
3015
|
+
expectedActive: expected.previousActive ?? null,
|
|
3016
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
3017
|
+
env: context.env,
|
|
3018
|
+
signal,
|
|
3019
|
+
runtime: options.catalogGenerationRuntime,
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
else if (intent.action === 'replaceDamaged') {
|
|
3023
|
+
generation = await replaceDamagedCatalogSourceGeneration({
|
|
3024
|
+
sourceId: intent.sourceId,
|
|
3025
|
+
cliVersion: packageInfo.version,
|
|
3026
|
+
cwd: context.cwd,
|
|
3027
|
+
expectedCandidate: expected.candidate,
|
|
3028
|
+
expectedActive: expected.previousActive,
|
|
3029
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
3030
|
+
impactConfirmed: true,
|
|
3031
|
+
expectedImpactDigest: expected.impactDigest,
|
|
3032
|
+
env: context.env,
|
|
3033
|
+
signal,
|
|
3034
|
+
runtime: {
|
|
3035
|
+
...options.catalogGenerationRuntime,
|
|
3036
|
+
afterCandidateResolved: tuiControllerRuntimeTestHooks
|
|
3037
|
+
?.afterCatalogGenerationCandidateResolved,
|
|
3038
|
+
},
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
else {
|
|
3042
|
+
generation = await activateCatalogSourceGeneration({
|
|
3043
|
+
sourceId: intent.sourceId,
|
|
3044
|
+
cliVersion: packageInfo.version,
|
|
3045
|
+
cwd: context.cwd,
|
|
3046
|
+
activationMode: expected.activationMode,
|
|
3047
|
+
impactConfirmed: true,
|
|
3048
|
+
expectedImpactDigest: expected.impactDigest,
|
|
3049
|
+
impactMode: expected.impactMode,
|
|
3050
|
+
expectedCandidate: expected.candidate,
|
|
3051
|
+
expectedActive: expected.previousActive ?? null,
|
|
3052
|
+
expectedConfigDigest: expected.proposedConfigDigest ?? expected.configDigest,
|
|
3053
|
+
env: context.env,
|
|
3054
|
+
signal,
|
|
3055
|
+
runtime: {
|
|
3056
|
+
...options.catalogGenerationRuntime,
|
|
3057
|
+
afterCandidateResolved: tuiControllerRuntimeTestHooks
|
|
3058
|
+
?.afterCatalogGenerationCandidateResolved,
|
|
3059
|
+
},
|
|
3060
|
+
});
|
|
3061
|
+
}
|
|
3062
|
+
let primaryChanged = false;
|
|
3063
|
+
if (intent.setPrimaryAfterActivation) {
|
|
3064
|
+
try {
|
|
3065
|
+
await setPrimaryCatalogSourceCommand({
|
|
3066
|
+
sourceId: intent.sourceId,
|
|
3067
|
+
cwd: context.cwd,
|
|
3068
|
+
env: context.env,
|
|
3069
|
+
expectedConfigDigest: expected.primaryConfigDigest,
|
|
3070
|
+
expectedImpactDigest: expected.primaryImpactDigest,
|
|
3071
|
+
requireImpactConfirmation: true,
|
|
3072
|
+
confirmImpact: true,
|
|
3073
|
+
});
|
|
3074
|
+
primaryChanged = true;
|
|
3075
|
+
}
|
|
3076
|
+
catch (error) {
|
|
3077
|
+
return {
|
|
3078
|
+
status: 'partial',
|
|
3079
|
+
partialReason: 'primary',
|
|
3080
|
+
configSaved,
|
|
3081
|
+
generation,
|
|
3082
|
+
activeAvailable: true,
|
|
3083
|
+
errorCode: typeof error === 'object' && error !== null
|
|
3084
|
+
&& 'code' in error && typeof error.code === 'string'
|
|
3085
|
+
? error.code
|
|
3086
|
+
: error instanceof Error ? error.name : 'catalogSourcePrimaryFailed',
|
|
3087
|
+
};
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
return { status: 'succeeded', generation, configSaved, primaryChanged };
|
|
3091
|
+
}
|
|
3092
|
+
catch (error) {
|
|
3093
|
+
if (!configSaved)
|
|
3094
|
+
throw error;
|
|
3095
|
+
return {
|
|
3096
|
+
status: 'partial',
|
|
3097
|
+
partialReason: 'activation',
|
|
3098
|
+
configSaved: true,
|
|
3099
|
+
errorCode: error instanceof CatalogGenerationError ? error.code : 'catalogGenerationRefreshFailed',
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
756
3103
|
if (intent.kind === 'portableInstall') {
|
|
757
3104
|
if (!expectedEvidence.portable) {
|
|
758
3105
|
throw operationReviewStale('确认信息缺少 Portable evidence。');
|
|
759
3106
|
}
|
|
760
3107
|
const packageInfo = await readCliPackageInfo();
|
|
761
3108
|
try {
|
|
3109
|
+
if (intent.retry) {
|
|
3110
|
+
if (!('retryPairs' in expectedEvidence.portable)) {
|
|
3111
|
+
throw operationReviewStale('确认信息缺少 Portable 重试目标。');
|
|
3112
|
+
}
|
|
3113
|
+
return await executePortableRetry({
|
|
3114
|
+
receipt: intent.retry.receipt,
|
|
3115
|
+
review: expectedEvidence.portable,
|
|
3116
|
+
expectedEvidenceDigest: expectedEvidence.portable.evidenceDigest,
|
|
3117
|
+
cwd: context.cwd,
|
|
3118
|
+
env: context.env,
|
|
3119
|
+
cliVersion: packageInfo.version,
|
|
3120
|
+
signal,
|
|
3121
|
+
onProgress(stage) {
|
|
3122
|
+
const phase = stage === 'prepare' ? '重新检查失败目标'
|
|
3123
|
+
: stage === 'add' ? '重试缺失的 Skills' : '验证重试结果';
|
|
3124
|
+
progressFeed?.setCurrent({ target: 'Skills CLI', phase }, `Portable Skills:${phase}`);
|
|
3125
|
+
},
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
762
3128
|
return await installPortableSkills({
|
|
763
3129
|
selector: intent.pluginId,
|
|
764
3130
|
scope: intent.scope,
|
|
@@ -769,6 +3135,7 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
769
3135
|
env: context.env,
|
|
770
3136
|
cliVersion: packageInfo.version,
|
|
771
3137
|
expectedEvidenceDigest: expectedEvidence.portable.evidenceDigest,
|
|
3138
|
+
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
772
3139
|
onProgress(stage) {
|
|
773
3140
|
const phase = stage === 'prepare' ? '检查插件依赖并生成候选'
|
|
774
3141
|
: stage === 'add' ? '安装已选择的 Skills' : '验证安装结果';
|
|
@@ -783,73 +3150,644 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
783
3150
|
throw error;
|
|
784
3151
|
}
|
|
785
3152
|
}
|
|
3153
|
+
if (intent.kind === 'sourceMutation') {
|
|
3154
|
+
const currentEvidence = await captureEvidence(intent);
|
|
3155
|
+
if (operationEvidenceFingerprint(currentEvidence) !== operationEvidenceFingerprint(expectedEvidence)) {
|
|
3156
|
+
throw new TuiOperationBlockedError('operationReviewStale', '确认后状态发生变化。');
|
|
3157
|
+
}
|
|
3158
|
+
await tuiControllerRuntimeTestHooks?.afterMutationEvidenceCapture?.();
|
|
3159
|
+
const packageInfo = await readCliPackageInfo();
|
|
3160
|
+
const runtime = {
|
|
3161
|
+
onProgress: async (event) => {
|
|
3162
|
+
const phase = SOURCE_PROGRESS_PHASES[event.stage];
|
|
3163
|
+
progressFeed?.setCurrent({ target: 'Catalog 来源配置', phase }, `来源操作:${phase}`);
|
|
3164
|
+
await tuiControllerRuntimeTestHooks?.onCatalogSourceProgress?.(event);
|
|
3165
|
+
},
|
|
3166
|
+
};
|
|
3167
|
+
const common = {
|
|
3168
|
+
cwd: context.cwd,
|
|
3169
|
+
env: context.env,
|
|
3170
|
+
expectedConfigDigest: expectedEvidence.sourceWrite?.configDigest,
|
|
3171
|
+
expectedProposedConfigDigest: expectedEvidence.sourceWrite?.proposedConfigDigest,
|
|
3172
|
+
expectedImpactDigest: expectedEvidence.sourceWrite?.impactDigest,
|
|
3173
|
+
runtime,
|
|
3174
|
+
};
|
|
3175
|
+
if (intent.action === 'add' && intent.source) {
|
|
3176
|
+
return addCatalogSourceCommand({
|
|
3177
|
+
...common,
|
|
3178
|
+
source: intent.source,
|
|
3179
|
+
cliVersion: packageInfo.version,
|
|
3180
|
+
requireImpactConfirmation: true,
|
|
3181
|
+
confirmImpact: true,
|
|
3182
|
+
});
|
|
3183
|
+
}
|
|
3184
|
+
if (intent.action === 'update' && intent.update) {
|
|
3185
|
+
return updateCatalogSourceCommand({
|
|
3186
|
+
...common,
|
|
3187
|
+
sourceId: intent.sourceId,
|
|
3188
|
+
update: intent.update,
|
|
3189
|
+
cliVersion: packageInfo.version,
|
|
3190
|
+
requireIdentityChangeConfirmation: true,
|
|
3191
|
+
confirmIdentityChange: true,
|
|
3192
|
+
});
|
|
3193
|
+
}
|
|
3194
|
+
if (intent.action === 'setPrimary') {
|
|
3195
|
+
return setPrimaryCatalogSourceCommand({
|
|
3196
|
+
...common,
|
|
3197
|
+
sourceId: intent.sourceId,
|
|
3198
|
+
requireImpactConfirmation: true,
|
|
3199
|
+
confirmImpact: true,
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
if (intent.action === 'remove') {
|
|
3203
|
+
return removeCatalogSourceCommand({
|
|
3204
|
+
...common,
|
|
3205
|
+
sourceId: intent.sourceId,
|
|
3206
|
+
requireImpactConfirmation: true,
|
|
3207
|
+
confirmImpact: true,
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
throw new TuiOperationBlockedError('invalidSourceMutation', '来源操作缺少候选输入。');
|
|
3211
|
+
}
|
|
3212
|
+
const codexObservationSession = intent.kind === 'pluginWrite'
|
|
3213
|
+
|| intent.kind === 'pluginWriteBatch'
|
|
3214
|
+
|| intent.kind === 'pluginWriteTask'
|
|
3215
|
+
? await createCodexNativeObservationSession({
|
|
3216
|
+
exactCwd: context.cwd,
|
|
3217
|
+
env: context.env,
|
|
3218
|
+
runner: context.nativeCliRunner,
|
|
3219
|
+
manager: codexManagerByEvidence.get(expectedEvidence),
|
|
3220
|
+
})
|
|
3221
|
+
: undefined;
|
|
786
3222
|
return withAwHomeMutationLock({
|
|
787
3223
|
env: context.env,
|
|
788
3224
|
action: async (awHomeMutationToken) => {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
3225
|
+
await tuiControllerRuntimeTestHooks?.beforeMutationEvidenceCapture?.();
|
|
3226
|
+
const operationInventory = createOperationInventoryReader();
|
|
3227
|
+
let currentEvidence;
|
|
3228
|
+
try {
|
|
3229
|
+
currentEvidence = await captureEvidence(intent, undefined, undefined, operationInventory, true, undefined, codexObservationSession, intent.kind === 'pluginWriteBatch'
|
|
3230
|
+
? expectedEvidence
|
|
3231
|
+
: undefined);
|
|
792
3232
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
progressFeed?.setCurrent({ target: 'Catalog 来源配置', phase }, `来源操作:${phase}`);
|
|
801
|
-
await tuiControllerRuntimeTestHooks?.onCatalogSourceProgress?.(event);
|
|
802
|
-
},
|
|
803
|
-
};
|
|
804
|
-
const common = {
|
|
805
|
-
cwd: context.cwd,
|
|
806
|
-
env: context.env,
|
|
807
|
-
expectedConfigDigest: expectedEvidence.sourceWrite?.configDigest,
|
|
808
|
-
runtime,
|
|
809
|
-
};
|
|
810
|
-
if (intent.action === 'add' && intent.source) {
|
|
811
|
-
return addCatalogSourceCommand({ ...common, source: intent.source, cliVersion: packageInfo.version });
|
|
3233
|
+
catch (error) {
|
|
3234
|
+
const code = error instanceof TuiOperationBlockedError ? error.code : undefined;
|
|
3235
|
+
if (intent.kind === 'pluginWriteBatch'
|
|
3236
|
+
&& (intent.selection.kind === 'currentProjectIntentRoots'
|
|
3237
|
+
|| intent.selection.kind === 'currentProjectIntentTargets')
|
|
3238
|
+
&& error instanceof TuiOperationBlockedError) {
|
|
3239
|
+
throw operationReviewStale('确认后完整项目 Intent 声明发生变化。');
|
|
812
3240
|
}
|
|
813
|
-
if (intent.
|
|
814
|
-
|
|
3241
|
+
if (intent.kind === 'pluginWriteTask'
|
|
3242
|
+
&& (code === 'taskHasBlockedTargets' || code === 'taskNoExecutableTargets')) {
|
|
3243
|
+
throw operationReviewStale('确认后任务可执行目标发生变化。', error instanceof TuiOperationBlockedError ? error.diagnostics : undefined);
|
|
815
3244
|
}
|
|
816
|
-
|
|
817
|
-
|
|
3245
|
+
throw error;
|
|
3246
|
+
}
|
|
3247
|
+
if (intent.kind === 'pluginWriteBatch') {
|
|
3248
|
+
const expectedBatch = expectedEvidence;
|
|
3249
|
+
const currentBatch = currentEvidence;
|
|
3250
|
+
if ((intent.selection.kind === 'currentProjectIntentRoots'
|
|
3251
|
+
|| intent.selection.kind === 'currentProjectIntentTargets')
|
|
3252
|
+
&& (!expectedBatch.projectIntentDigest
|
|
3253
|
+
|| expectedBatch.projectIntentDigest !== currentBatch.projectIntentDigest)) {
|
|
3254
|
+
throw operationReviewStale('确认后完整项目 Intent 声明发生变化。');
|
|
3255
|
+
}
|
|
3256
|
+
const reviewedGroups = expectedBatch.groups.map((group) => ({
|
|
3257
|
+
groupId: group.groupId,
|
|
3258
|
+
sourceId: group.sourceId,
|
|
3259
|
+
platform: group.platform,
|
|
3260
|
+
scope: group.scope,
|
|
3261
|
+
requestedPluginIds: group.requestedPluginIds,
|
|
3262
|
+
executable: group.executable,
|
|
3263
|
+
planFingerprint: group.preview.operationPlan
|
|
3264
|
+
? intent.action === 'cleanup'
|
|
3265
|
+
? group.preview.operationPlan.planFingerprint
|
|
3266
|
+
: createBatchIntentCompatiblePlanFingerprint(group.preview.operationPlan)
|
|
3267
|
+
: undefined,
|
|
3268
|
+
}));
|
|
3269
|
+
const currentGroups = currentBatch.groups.map((group) => ({
|
|
3270
|
+
groupId: group.groupId,
|
|
3271
|
+
sourceId: group.sourceId,
|
|
3272
|
+
platform: group.platform,
|
|
3273
|
+
scope: group.scope,
|
|
3274
|
+
requestedPluginIds: group.requestedPluginIds,
|
|
3275
|
+
executable: expectedBatch.groups.find((reviewed) => reviewed.groupId === group.groupId)
|
|
3276
|
+
?.executable === false ? false : group.executable,
|
|
3277
|
+
planFingerprint: expectedBatch.groups.find((reviewed) => reviewed.groupId === group.groupId)
|
|
3278
|
+
?.executable === false
|
|
3279
|
+
? undefined
|
|
3280
|
+
: group.preview.operationPlan
|
|
3281
|
+
? intent.action === 'cleanup'
|
|
3282
|
+
? group.preview.operationPlan.planFingerprint
|
|
3283
|
+
: createBatchIntentCompatiblePlanFingerprint(group.preview.operationPlan)
|
|
3284
|
+
: undefined,
|
|
3285
|
+
}));
|
|
3286
|
+
if (expectedBatch.catalog.configDigest !== currentBatch.catalog.configDigest
|
|
3287
|
+
|| JSON.stringify(expectedBatch.requestedPluginIds)
|
|
3288
|
+
!== JSON.stringify(currentBatch.requestedPluginIds)
|
|
3289
|
+
|| JSON.stringify(reviewedGroups) !== JSON.stringify(currentGroups)) {
|
|
3290
|
+
throw operationReviewStale('确认后批量目标或写入计划发生变化。');
|
|
818
3291
|
}
|
|
819
|
-
|
|
820
|
-
|
|
3292
|
+
await tuiControllerRuntimeTestHooks?.afterMutationEvidenceCapture?.();
|
|
3293
|
+
const groupResults = [];
|
|
3294
|
+
const completedTargetKeys = new Set();
|
|
3295
|
+
const expectedIntentDigests = new Map();
|
|
3296
|
+
for (const group of expectedBatch.groups) {
|
|
3297
|
+
for (const intentDigest of group.preview.operationPlan?.evidence.intentDigests ?? []) {
|
|
3298
|
+
expectedIntentDigests.set(intentDigest.scope, intentDigest.digest);
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
let executedGroupCount = 0;
|
|
3302
|
+
const appendStoppedGroups = (startIndex, staleMessage) => {
|
|
3303
|
+
for (const [offset, stopped] of expectedBatch.groups.slice(startIndex).entries()) {
|
|
3304
|
+
groupResults.push({
|
|
3305
|
+
groupId: stopped.groupId,
|
|
3306
|
+
sourceId: stopped.sourceId,
|
|
3307
|
+
platform: stopped.platform,
|
|
3308
|
+
scope: stopped.scope,
|
|
3309
|
+
requestedPluginIds: stopped.requestedPluginIds,
|
|
3310
|
+
result: !stopped.executable ? stopped.preview : failedWriteCommandResult(intent.action, stopped.requestedPluginIds, { cwd: context.cwd, platform: stopped.platform, scope: stopped.scope }, offset === 0
|
|
3311
|
+
? new TuiOperationBlockedError('operationReviewStale', staleMessage)
|
|
3312
|
+
: new TuiOperationBlockedError('batchNotStarted', '前一个批量组的写入计划已变化,因此这个组没有开始。')),
|
|
3313
|
+
});
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
for (const [groupIndex, reviewed] of expectedBatch.groups.entries()) {
|
|
3317
|
+
const current = currentBatch.groups.find((group) => group.groupId === reviewed.groupId);
|
|
3318
|
+
if (!reviewed.executable) {
|
|
3319
|
+
groupResults.push({
|
|
3320
|
+
groupId: reviewed.groupId,
|
|
3321
|
+
sourceId: reviewed.sourceId,
|
|
3322
|
+
platform: reviewed.platform,
|
|
3323
|
+
scope: reviewed.scope,
|
|
3324
|
+
requestedPluginIds: reviewed.requestedPluginIds,
|
|
3325
|
+
result: reviewed.preview,
|
|
3326
|
+
});
|
|
3327
|
+
continue;
|
|
3328
|
+
}
|
|
3329
|
+
const groupInventory = groupResults.length === 0
|
|
3330
|
+
? operationInventory
|
|
3331
|
+
: createOperationInventoryReader();
|
|
3332
|
+
let executionPreview = current.preview;
|
|
3333
|
+
if (completedTargetKeys.size > 0
|
|
3334
|
+
|| (intent.action === 'cleanup' && executedGroupCount > 0)) {
|
|
3335
|
+
executionPreview = await runBatchWriteGroup({
|
|
3336
|
+
intent,
|
|
3337
|
+
group: current,
|
|
3338
|
+
cwd: context.cwd,
|
|
3339
|
+
runtime: {
|
|
3340
|
+
...context,
|
|
3341
|
+
awHomeMutationToken,
|
|
3342
|
+
inventoryCatalogSourceReferences: groupInventory,
|
|
3343
|
+
...(intent.action === 'cleanup' ? {} : {
|
|
3344
|
+
expectedCatalogConfigDigest: expectedBatch.catalog.configDigest,
|
|
3345
|
+
}),
|
|
3346
|
+
previewOperationPlan: true,
|
|
3347
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
3348
|
+
},
|
|
3349
|
+
});
|
|
3350
|
+
const cleanupIntentDigestChanged = intent.action === 'cleanup'
|
|
3351
|
+
&& executionPreview.operationPlan?.evidence.intentDigests.find((entry) => entry.scope === current.scope)?.digest !== expectedIntentDigests.get(current.scope);
|
|
3352
|
+
if (cleanupIntentDigestChanged
|
|
3353
|
+
|| !reviewed.preview.operationPlan || !executionPreview.operationPlan
|
|
3354
|
+
|| createBatchIntentCompatiblePlanFingerprint(reviewed.preview.operationPlan, completedTargetKeys) !== createBatchIntentCompatiblePlanFingerprint(executionPreview.operationPlan, completedTargetKeys)) {
|
|
3355
|
+
appendStoppedGroups(groupIndex, '前序批量结果改变了这个组的实际写入计划。');
|
|
3356
|
+
break;
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
const requiresManagedCodex = reviewed.preview.codexManagerPreview?.state === 'requires-install';
|
|
3360
|
+
const result = await runBatchWriteGroup({
|
|
3361
|
+
intent,
|
|
3362
|
+
group: current,
|
|
3363
|
+
cwd: context.cwd,
|
|
3364
|
+
runtime: {
|
|
3365
|
+
...context,
|
|
3366
|
+
awHomeMutationToken,
|
|
3367
|
+
preApplyConfirmed: true,
|
|
3368
|
+
inventoryCatalogSourceReferences: groupInventory,
|
|
3369
|
+
...(intent.action === 'cleanup' ? {} : {
|
|
3370
|
+
expectedCatalogConfigDigest: expectedBatch.catalog.configDigest,
|
|
3371
|
+
}),
|
|
3372
|
+
...(executionPreview.operationPlan ? {
|
|
3373
|
+
expectedPlanFingerprint: executionPreview.operationPlan.planFingerprint,
|
|
3374
|
+
} : {}),
|
|
3375
|
+
...(requiresManagedCodex ? {
|
|
3376
|
+
managedCodexAuthorizer: async () => true,
|
|
3377
|
+
} : {}),
|
|
3378
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
3379
|
+
},
|
|
3380
|
+
});
|
|
3381
|
+
if (writeReviewIsStale(result)) {
|
|
3382
|
+
if (executedGroupCount === 0)
|
|
3383
|
+
throwIfWriteReviewStale(result);
|
|
3384
|
+
appendStoppedGroups(groupIndex, '这个组的实际写入计划发生变化。');
|
|
3385
|
+
break;
|
|
3386
|
+
}
|
|
3387
|
+
if (intent.action === 'cleanup') {
|
|
3388
|
+
for (const change of result.operationPlan?.intentChanges ?? []) {
|
|
3389
|
+
expectedIntentDigests.set(change.scope, change.afterDigest);
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
executedGroupCount += 1;
|
|
3393
|
+
for (const target of result.targetResults) {
|
|
3394
|
+
if (target.state === 'completed') {
|
|
3395
|
+
completedTargetKeys.add([
|
|
3396
|
+
target.target.pluginId,
|
|
3397
|
+
target.target.platform,
|
|
3398
|
+
target.target.scope,
|
|
3399
|
+
].join('\0'));
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
groupResults.push({
|
|
3403
|
+
groupId: reviewed.groupId,
|
|
3404
|
+
sourceId: reviewed.sourceId,
|
|
3405
|
+
platform: reviewed.platform,
|
|
3406
|
+
scope: reviewed.scope,
|
|
3407
|
+
requestedPluginIds: reviewed.requestedPluginIds,
|
|
3408
|
+
result,
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
const merged = mergeWriteCommandResults(groupResults.map((group) => group.result));
|
|
3412
|
+
return {
|
|
3413
|
+
...merged,
|
|
3414
|
+
requestedPluginIds: expectedBatch.requestedPluginIds,
|
|
3415
|
+
groupResults,
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
3419
|
+
const expectedTask = expectedEvidence;
|
|
3420
|
+
const currentTask = currentEvidence;
|
|
3421
|
+
if (!operationEvidenceMatches(expectedTask, currentTask)) {
|
|
3422
|
+
throw operationReviewStale('确认后任务目标、根因、版本或写入计划发生变化。');
|
|
3423
|
+
}
|
|
3424
|
+
await tuiControllerRuntimeTestHooks?.afterMutationEvidenceCapture?.();
|
|
3425
|
+
const operationContexts = taskCatalogOperationsByEvidence.get(currentEvidence)
|
|
3426
|
+
?? new Map();
|
|
3427
|
+
const sourceResults = [];
|
|
3428
|
+
const completedTargetKeys = new Set();
|
|
3429
|
+
const preApplyExecutionCache = new Map();
|
|
3430
|
+
const commandTargets = (source) => source.requestedTargets.map((target) => {
|
|
3431
|
+
const direct = source.causes.filter((cause) => pluginWriteTaskTargetKey(cause.repairTarget) === pluginWriteTaskTargetKey(target));
|
|
3432
|
+
return {
|
|
3433
|
+
pluginId: target.pluginId,
|
|
3434
|
+
platform: target.platform,
|
|
3435
|
+
scope: target.scope,
|
|
3436
|
+
method: direct.some((cause) => cause.method === 'reinstall')
|
|
3437
|
+
? 'reinstall' : 'sync',
|
|
3438
|
+
};
|
|
3439
|
+
});
|
|
3440
|
+
const repairTargets = (source) => [...new Map(source.causes.map((cause) => [
|
|
3441
|
+
pluginWriteTaskTargetKey(cause.repairTarget),
|
|
3442
|
+
{ ...cause.repairTarget, method: cause.method },
|
|
3443
|
+
])).values()];
|
|
3444
|
+
const stoppedResult = (source, error) => mergeWriteCommandResults(source.requestedTargets.map((target) => failedWriteCommandResult('sync', [target.pluginId], {
|
|
3445
|
+
cwd: context.cwd,
|
|
3446
|
+
platform: target.platform,
|
|
3447
|
+
scope: target.scope,
|
|
3448
|
+
}, error)));
|
|
3449
|
+
const appendStoppedSources = (startIndex, message) => {
|
|
3450
|
+
for (const [offset, source] of expectedTask.taskPlan.sources.slice(startIndex).entries()) {
|
|
3451
|
+
sourceResults.push({
|
|
3452
|
+
sourceId: source.sourceId,
|
|
3453
|
+
sourceIdentity: source.sourceIdentity,
|
|
3454
|
+
requestedTargets: source.requestedTargets,
|
|
3455
|
+
result: stoppedResult(source, offset === 0
|
|
3456
|
+
? new TuiOperationBlockedError('operationReviewStale', message)
|
|
3457
|
+
: new TuiOperationBlockedError('taskNotStarted', '前一个来源计划已变化,因此这个来源没有开始。')),
|
|
3458
|
+
});
|
|
3459
|
+
}
|
|
3460
|
+
};
|
|
3461
|
+
for (const [sourceIndex, reviewed] of expectedTask.taskPlan.sources.entries()) {
|
|
3462
|
+
const current = currentTask.taskPlan.sources.find((source) => source.sourceId === reviewed.sourceId);
|
|
3463
|
+
const catalogOperation = operationContexts.get(reviewed.sourceId);
|
|
3464
|
+
if (!current || !catalogOperation || current.sourceIdentity !== reviewed.sourceIdentity) {
|
|
3465
|
+
if (sourceResults.length === 0) {
|
|
3466
|
+
throw operationReviewStale('确认后任务来源身份发生变化。');
|
|
3467
|
+
}
|
|
3468
|
+
appendStoppedSources(sourceIndex, '确认后任务来源身份发生变化。');
|
|
3469
|
+
break;
|
|
3470
|
+
}
|
|
3471
|
+
const sourceInventory = sourceResults.length === 0
|
|
3472
|
+
? operationInventory : createOperationInventoryReader();
|
|
3473
|
+
let executionPreview = current.preview;
|
|
3474
|
+
if (completedTargetKeys.size > 0) {
|
|
3475
|
+
executionPreview = await taskWriteCommand(commandTargets(current), {
|
|
3476
|
+
cwd: context.cwd,
|
|
3477
|
+
repairTargets: repairTargets(current),
|
|
3478
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
3479
|
+
? {} : { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
3480
|
+
}, {
|
|
3481
|
+
...context,
|
|
3482
|
+
awHomeMutationToken,
|
|
3483
|
+
catalogOperationContext: catalogOperation,
|
|
3484
|
+
expectedGenerationSetDigest: catalogOperation.generationSetDigest,
|
|
3485
|
+
expectedCatalogConfigDigest: expectedTask.catalog.configDigest,
|
|
3486
|
+
inventoryCatalogSourceReferences: sourceInventory,
|
|
3487
|
+
previewOperationPlan: true,
|
|
3488
|
+
preApplyExecutionCache,
|
|
3489
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
3490
|
+
});
|
|
3491
|
+
if (!reviewed.preview.operationPlan || !executionPreview.operationPlan
|
|
3492
|
+
|| createBatchIntentCompatiblePlanFingerprint(reviewed.preview.operationPlan, completedTargetKeys) !== createBatchIntentCompatiblePlanFingerprint(executionPreview.operationPlan, completedTargetKeys)) {
|
|
3493
|
+
appendStoppedSources(sourceIndex, '前序结果改变了这个来源的实际写入计划。');
|
|
3494
|
+
break;
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
const requiresManagedCodex = reviewed.preview.codexManagerPreview?.state === 'requires-install';
|
|
3498
|
+
const result = await taskWriteCommand(commandTargets(current), {
|
|
3499
|
+
cwd: context.cwd,
|
|
3500
|
+
repairTargets: repairTargets(current),
|
|
3501
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
3502
|
+
? {} : { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
3503
|
+
}, {
|
|
3504
|
+
...context,
|
|
3505
|
+
awHomeMutationToken,
|
|
3506
|
+
catalogOperationContext: catalogOperation,
|
|
3507
|
+
expectedGenerationSetDigest: catalogOperation.generationSetDigest,
|
|
3508
|
+
expectedCatalogConfigDigest: expectedTask.catalog.configDigest,
|
|
3509
|
+
inventoryCatalogSourceReferences: sourceInventory,
|
|
3510
|
+
preApplyConfirmed: true,
|
|
3511
|
+
preApplyExecutionCache,
|
|
3512
|
+
...(executionPreview.operationPlan
|
|
3513
|
+
? { expectedPlanFingerprint: executionPreview.operationPlan.planFingerprint } : {}),
|
|
3514
|
+
...(requiresManagedCodex ? { managedCodexAuthorizer: async () => true } : {}),
|
|
3515
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
3516
|
+
});
|
|
3517
|
+
if (writeReviewIsStale(result)) {
|
|
3518
|
+
if (sourceResults.length === 0)
|
|
3519
|
+
throwIfWriteReviewStale(result);
|
|
3520
|
+
appendStoppedSources(sourceIndex, '这个来源的实际写入计划发生变化。');
|
|
3521
|
+
break;
|
|
3522
|
+
}
|
|
3523
|
+
for (const target of result.targetResults) {
|
|
3524
|
+
if (target.state === 'completed') {
|
|
3525
|
+
completedTargetKeys.add([
|
|
3526
|
+
target.target.pluginId,
|
|
3527
|
+
target.target.platform,
|
|
3528
|
+
target.target.scope,
|
|
3529
|
+
].join('\0'));
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
sourceResults.push({
|
|
3533
|
+
sourceId: reviewed.sourceId,
|
|
3534
|
+
sourceIdentity: reviewed.sourceIdentity,
|
|
3535
|
+
requestedTargets: reviewed.requestedTargets,
|
|
3536
|
+
result,
|
|
3537
|
+
});
|
|
821
3538
|
}
|
|
822
|
-
|
|
3539
|
+
const merged = mergeWriteCommandResults(sourceResults.map((source) => source.result));
|
|
3540
|
+
return {
|
|
3541
|
+
...merged,
|
|
3542
|
+
taskPlan: expectedTask.taskPlan,
|
|
3543
|
+
sourceResults,
|
|
3544
|
+
};
|
|
823
3545
|
}
|
|
3546
|
+
if (intent.kind !== 'pluginWrite'
|
|
3547
|
+
&& !operationEvidenceMatches(expectedEvidence, currentEvidence)) {
|
|
3548
|
+
throw new TuiOperationBlockedError('operationReviewStale', '确认后状态发生变化。');
|
|
3549
|
+
}
|
|
3550
|
+
const catalogOperation = catalogOperationByEvidence.get(currentEvidence);
|
|
3551
|
+
if (expectedEvidence.catalog.generationSetDigest
|
|
3552
|
+
&& catalogOperation?.generationSetDigest !== expectedEvidence.catalog.generationSetDigest) {
|
|
3553
|
+
throw operationReviewStale('确认后 Active Catalog generation 发生变化。');
|
|
3554
|
+
}
|
|
3555
|
+
await tuiControllerRuntimeTestHooks?.afterMutationEvidenceCapture?.();
|
|
824
3556
|
if (intent.kind === 'pluginWrite') {
|
|
825
3557
|
const options = {
|
|
826
3558
|
cwd: context.cwd,
|
|
827
3559
|
platform: intent.platform,
|
|
828
3560
|
scope: intent.scope,
|
|
3561
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
3562
|
+
? {}
|
|
3563
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
3564
|
+
...(intent.action === 'install' && intent.dependencyScopeOverrides
|
|
3565
|
+
? { dependencyScopeOverrides: intent.dependencyScopeOverrides }
|
|
3566
|
+
: {}),
|
|
3567
|
+
...(expectedEvidence.codexManager?.state === 'requires-install'
|
|
3568
|
+
? { allowManagedCodexInstall: true }
|
|
3569
|
+
: {}),
|
|
829
3570
|
...(intent.action === 'cleanup' ? { force: intent.force === true } : {}),
|
|
830
3571
|
};
|
|
831
3572
|
const command = {
|
|
832
3573
|
install: installWriteCommand,
|
|
833
|
-
|
|
3574
|
+
refreshAndSync: syncWriteCommand,
|
|
834
3575
|
reinstall: reinstallWriteCommand,
|
|
835
3576
|
uninstall: uninstallWriteCommand,
|
|
836
3577
|
cleanup: cleanupWriteCommand,
|
|
3578
|
+
sync: syncWriteCommand,
|
|
837
3579
|
}[intent.action];
|
|
3580
|
+
if (intent.action === 'cleanup') {
|
|
3581
|
+
if (!expectedEvidence.operationPlan || !currentEvidence.operationPlan
|
|
3582
|
+
|| expectedEvidence.operationPlan.planFingerprint
|
|
3583
|
+
!== currentEvidence.operationPlan.planFingerprint) {
|
|
3584
|
+
throw operationReviewStale('确认后清理计划发生变化。');
|
|
3585
|
+
}
|
|
3586
|
+
const result = await command([intent.pluginId], options, {
|
|
3587
|
+
...context,
|
|
3588
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
3589
|
+
awHomeMutationToken,
|
|
3590
|
+
preApplyConfirmed: true,
|
|
3591
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
3592
|
+
expectedPlanFingerprint: expectedEvidence.operationPlan.planFingerprint,
|
|
3593
|
+
...(expectedEvidence.codexManager?.state === 'requires-install'
|
|
3594
|
+
? { managedCodexAuthorizer: async () => true }
|
|
3595
|
+
: {}),
|
|
3596
|
+
});
|
|
3597
|
+
throwIfWriteReviewStale(result);
|
|
3598
|
+
return result;
|
|
3599
|
+
}
|
|
838
3600
|
const currentSource = currentEvidence.source;
|
|
839
3601
|
if (!expectedEvidence.source || !currentSource) {
|
|
840
3602
|
throw new TuiOperationBlockedError('operationReviewStale', '确认信息缺少来源身份。');
|
|
841
3603
|
}
|
|
842
3604
|
const result = await command([intent.pluginId], options, {
|
|
843
3605
|
...context,
|
|
3606
|
+
...(codexObservationSession ? { codexObservationSession } : {}),
|
|
844
3607
|
awHomeMutationToken,
|
|
3608
|
+
preApplyConfirmed: true,
|
|
3609
|
+
inventoryCatalogSourceReferences: operationInventory,
|
|
3610
|
+
...(expectedEvidence.operationPlan
|
|
3611
|
+
? { expectedPlanFingerprint: expectedEvidence.operationPlan.planFingerprint }
|
|
3612
|
+
: {}),
|
|
845
3613
|
expectedCatalogConfigDigest: expectedEvidence.catalog.configDigest,
|
|
3614
|
+
...(catalogOperation ? {
|
|
3615
|
+
catalogOperationContext: catalogOperation,
|
|
3616
|
+
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
3617
|
+
} : {}),
|
|
3618
|
+
...(expectedEvidence.codexManager?.state === 'requires-install'
|
|
3619
|
+
? { managedCodexAuthorizer: async () => true }
|
|
3620
|
+
: {}),
|
|
846
3621
|
reviewPreflight: (actual) => assertSourceEvidenceMatches(currentSource, actual),
|
|
847
3622
|
});
|
|
848
3623
|
throwIfWriteReviewStale(result);
|
|
849
3624
|
return result;
|
|
850
3625
|
}
|
|
3626
|
+
if (intent.kind === 'configSaveBatch') {
|
|
3627
|
+
assertConfigSaveBatchIntent(intent);
|
|
3628
|
+
const reviewedBatch = expectedEvidence.configBatch;
|
|
3629
|
+
if (!reviewedBatch || !currentEvidence.configBatch || !currentEvidence.source) {
|
|
3630
|
+
throw operationReviewStale('确认信息缺少设置批次证据。');
|
|
3631
|
+
}
|
|
3632
|
+
const approvedApplyTargets = new Set(reviewedBatch.groups.flatMap((group) => group.config.affectedTargets.map((target) => `${target.platform}\0${target.scope}`)));
|
|
3633
|
+
const approvedPreApplyTargets = reviewedBatch.groups.flatMap((group) => group.config.preApplyAuthorization ?? []);
|
|
3634
|
+
const results = [];
|
|
3635
|
+
const packageInfo = await readCliPackageInfo();
|
|
3636
|
+
for (const group of intent.groups) {
|
|
3637
|
+
const groupIntent = configSaveBatchGroupIntent(intent, group);
|
|
3638
|
+
const reviewedGroup = reviewedBatch.groups.find((item) => item.scope === group.scope);
|
|
3639
|
+
if (!reviewedGroup) {
|
|
3640
|
+
throw operationReviewStale('确认信息缺少设置层基线。');
|
|
3641
|
+
}
|
|
3642
|
+
let configSaved = false;
|
|
3643
|
+
const operationRebuildResults = [];
|
|
3644
|
+
try {
|
|
3645
|
+
const freshEvidence = await captureEvidence(groupIntent, undefined, undefined, operationInventory, true);
|
|
3646
|
+
const freshSource = freshEvidence.source;
|
|
3647
|
+
const freshConfig = freshEvidence.config;
|
|
3648
|
+
if (!freshSource || !freshConfig) {
|
|
3649
|
+
throw operationReviewStale('设置目标缺少最新证据。');
|
|
3650
|
+
}
|
|
3651
|
+
assertSourceEvidenceMatches(currentEvidence.source, freshSource);
|
|
3652
|
+
const freshLayerStoreDigest = await configLayerStoreDigest({
|
|
3653
|
+
source: freshSource,
|
|
3654
|
+
pluginName: parsePluginId(intent.pluginId).pluginName,
|
|
3655
|
+
scope: group.scope,
|
|
3656
|
+
cwd: context.cwd,
|
|
3657
|
+
env: context.env,
|
|
3658
|
+
});
|
|
3659
|
+
if (freshLayerStoreDigest !== reviewedGroup.config.storeDigest) {
|
|
3660
|
+
throw operationReviewStale('保存设置期间此设置层的原始内容发生变化。');
|
|
3661
|
+
}
|
|
3662
|
+
if (freshConfig.affectedTargets.some((target) => !approvedApplyTargets.has(`${target.platform}\0${target.scope}`))) {
|
|
3663
|
+
throw operationReviewStale('同批前一层变更扩大了未经确认的应用目标。');
|
|
3664
|
+
}
|
|
3665
|
+
const groupCatalogOperation = catalogOperationByEvidence.get(freshEvidence);
|
|
3666
|
+
if (expectedEvidence.catalog.generationSetDigest
|
|
3667
|
+
&& groupCatalogOperation?.generationSetDigest
|
|
3668
|
+
!== expectedEvidence.catalog.generationSetDigest) {
|
|
3669
|
+
throw operationReviewStale('保存设置期间 Active Catalog generation 发生变化。');
|
|
3670
|
+
}
|
|
3671
|
+
const result = await withResolvedCatalogPlugin({
|
|
3672
|
+
selector: intent.pluginId,
|
|
3673
|
+
cliVersion: packageInfo.version,
|
|
3674
|
+
env: context.env,
|
|
3675
|
+
...(groupCatalogOperation ? { operationContext: groupCatalogOperation } : {}),
|
|
3676
|
+
consume: async ({ plugin, source }) => {
|
|
3677
|
+
assertSourceEvidenceMatches(freshSource, sourceEvidenceForPlugin(source, plugin.manifest.name));
|
|
3678
|
+
const applyTargets = intent.apply
|
|
3679
|
+
? freshConfig.affectedTargets.map((target) => ({
|
|
3680
|
+
pluginName: plugin.manifest.name,
|
|
3681
|
+
platform: target.platform,
|
|
3682
|
+
scope: target.scope,
|
|
3683
|
+
}))
|
|
3684
|
+
: [];
|
|
3685
|
+
return applyPluginConfigWrite({
|
|
3686
|
+
plugin,
|
|
3687
|
+
pluginName: plugin.manifest.name,
|
|
3688
|
+
scope: group.scope,
|
|
3689
|
+
cwd: context.cwd,
|
|
3690
|
+
env: context.env,
|
|
3691
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
3692
|
+
rebuildRuntime: {
|
|
3693
|
+
...context,
|
|
3694
|
+
awHomeMutationToken,
|
|
3695
|
+
operationDiagnosticSink: (entries) => {
|
|
3696
|
+
operationRebuildResults.push(...structuredClone(entries));
|
|
3697
|
+
},
|
|
3698
|
+
...(reviewedScriptTimeoutMs(intent) === undefined ? {} : {
|
|
3699
|
+
scriptTimeoutMs: reviewedScriptTimeoutMs(intent),
|
|
3700
|
+
}),
|
|
3701
|
+
...(groupCatalogOperation ? {
|
|
3702
|
+
catalogOperationContext: groupCatalogOperation,
|
|
3703
|
+
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
3704
|
+
} : {}),
|
|
3705
|
+
},
|
|
3706
|
+
awHomeMutationToken,
|
|
3707
|
+
applyTargets,
|
|
3708
|
+
request: { updates: group.updates, removeKeys: group.removeKeys },
|
|
3709
|
+
sharedNativeApplyConfirmed: true,
|
|
3710
|
+
preApplyConfirmed: true,
|
|
3711
|
+
preApplyAuthorizedTargets: approvedPreApplyTargets,
|
|
3712
|
+
});
|
|
3713
|
+
},
|
|
3714
|
+
});
|
|
3715
|
+
configSaved = result.configWrite === 'succeeded';
|
|
3716
|
+
const applyStatus = !intent.apply
|
|
3717
|
+
? 'notRequested'
|
|
3718
|
+
: result.apply.state === 'succeeded'
|
|
3719
|
+
? 'succeeded'
|
|
3720
|
+
: result.apply.state === 'skipped'
|
|
3721
|
+
? 'notNeeded'
|
|
3722
|
+
: 'failed';
|
|
3723
|
+
results.push({
|
|
3724
|
+
scope: group.scope,
|
|
3725
|
+
status: applyStatus === 'failed' ? 'failed' : 'succeeded',
|
|
3726
|
+
configSaved,
|
|
3727
|
+
applyRequested: intent.apply,
|
|
3728
|
+
applyStatus,
|
|
3729
|
+
execution: { ...result, operationRebuildResults },
|
|
3730
|
+
...(applyStatus === 'failed' ? {
|
|
3731
|
+
errorCode: result.apply.state === 'unavailable'
|
|
3732
|
+
? result.apply.error?.code ?? result.apply.reason
|
|
3733
|
+
: result.apply.targetResults.find((target) => target.errorCode)?.errorCode
|
|
3734
|
+
?? 'runtimeApplyFailed',
|
|
3735
|
+
} : {}),
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3738
|
+
catch (error) {
|
|
3739
|
+
configSaved = error?.configWrite === 'succeeded';
|
|
3740
|
+
const errorCode = typeof error === 'object' && error !== null
|
|
3741
|
+
&& 'code' in error && typeof error.code === 'string'
|
|
3742
|
+
? error.code
|
|
3743
|
+
: configSaved ? 'runtimeApplyFailed' : 'configWriteFailed';
|
|
3744
|
+
results.push({
|
|
3745
|
+
scope: group.scope,
|
|
3746
|
+
status: 'failed',
|
|
3747
|
+
configSaved,
|
|
3748
|
+
applyRequested: intent.apply,
|
|
3749
|
+
applyStatus: intent.apply ? 'failed' : 'notRequested',
|
|
3750
|
+
errorCode,
|
|
3751
|
+
...(operationRebuildResults.length > 0
|
|
3752
|
+
? { execution: { operationRebuildResults } }
|
|
3753
|
+
: {}),
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
const succeeded = results.filter((result) => result.status === 'succeeded').length;
|
|
3758
|
+
return {
|
|
3759
|
+
status: succeeded === results.length
|
|
3760
|
+
? 'succeeded'
|
|
3761
|
+
: succeeded > 0 || results.some((result) => result.configSaved)
|
|
3762
|
+
? 'partial'
|
|
3763
|
+
: 'failed',
|
|
3764
|
+
groups: results,
|
|
3765
|
+
};
|
|
3766
|
+
}
|
|
851
3767
|
if (intent.kind === 'configSave' || intent.kind === 'configReset') {
|
|
3768
|
+
const operationRebuildResults = [];
|
|
3769
|
+
const operationDiagnosticSink = (results) => {
|
|
3770
|
+
operationRebuildResults.push(...structuredClone(results));
|
|
3771
|
+
};
|
|
852
3772
|
const currentSource = currentEvidence.source;
|
|
3773
|
+
if (intent.kind === 'configReset') {
|
|
3774
|
+
const parsed = parsePluginId(intent.pluginId);
|
|
3775
|
+
if (!parsed.sourceId || !parsed.pluginName) {
|
|
3776
|
+
throw operationReviewStale('确认信息缺少 qualified 设置目标。');
|
|
3777
|
+
}
|
|
3778
|
+
return resetPluginConfigWithHelper({
|
|
3779
|
+
sourceId: parsed.sourceId,
|
|
3780
|
+
pluginName: parsed.pluginName,
|
|
3781
|
+
scope: intent.scope,
|
|
3782
|
+
cwd: context.cwd,
|
|
3783
|
+
env: context.env,
|
|
3784
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
3785
|
+
rebuildRuntime: { ...context, awHomeMutationToken },
|
|
3786
|
+
awHomeMutationToken,
|
|
3787
|
+
apply: false,
|
|
3788
|
+
sharedNativeApplyConfirmed: false,
|
|
3789
|
+
});
|
|
3790
|
+
}
|
|
853
3791
|
if (!currentSource) {
|
|
854
3792
|
throw operationReviewStale('确认信息缺少来源身份。');
|
|
855
3793
|
}
|
|
@@ -857,40 +3795,76 @@ export function createTuiControllerDependencies(context, progressFeed) {
|
|
|
857
3795
|
return withResolvedCatalogPlugin({
|
|
858
3796
|
selector: intent.pluginId,
|
|
859
3797
|
cliVersion: packageInfo.version,
|
|
860
|
-
freshnessPolicy: 'requireRemote',
|
|
861
3798
|
env: context.env,
|
|
3799
|
+
...(catalogOperation ? { operationContext: catalogOperation } : {}),
|
|
862
3800
|
consume: async ({ plugin, source }) => {
|
|
863
3801
|
assertSourceEvidenceMatches(currentSource, sourceEvidenceForPlugin(source, plugin.manifest.name));
|
|
864
|
-
const
|
|
865
|
-
?
|
|
866
|
-
plugin,
|
|
3802
|
+
const applyTargets = intent.retryApply || intent.apply
|
|
3803
|
+
? currentEvidence.config?.affectedTargets.map((target) => ({
|
|
867
3804
|
pluginName: plugin.manifest.name,
|
|
3805
|
+
platform: target.platform,
|
|
3806
|
+
scope: target.scope,
|
|
3807
|
+
})) ?? []
|
|
3808
|
+
: [];
|
|
3809
|
+
const result = intent.retryApply
|
|
3810
|
+
? await replayConfigRuntimeWrites({
|
|
3811
|
+
plugin,
|
|
868
3812
|
scope: intent.scope,
|
|
869
|
-
projectLayer: intent.projectLayer,
|
|
870
3813
|
cwd: context.cwd,
|
|
871
3814
|
env: context.env,
|
|
872
3815
|
nativeCliRunner: context.nativeCliRunner,
|
|
873
|
-
rebuildRuntime: {
|
|
3816
|
+
rebuildRuntime: {
|
|
3817
|
+
...context,
|
|
3818
|
+
awHomeMutationToken,
|
|
3819
|
+
operationDiagnosticSink,
|
|
3820
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
3821
|
+
? {}
|
|
3822
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
3823
|
+
...(catalogOperation ? {
|
|
3824
|
+
catalogOperationContext: catalogOperation,
|
|
3825
|
+
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
3826
|
+
} : {}),
|
|
3827
|
+
},
|
|
874
3828
|
awHomeMutationToken,
|
|
875
|
-
|
|
3829
|
+
applyTargets,
|
|
3830
|
+
sharedNativeApplyConfirmed: true,
|
|
3831
|
+
preApplyConfirmed: true,
|
|
3832
|
+
preApplyAuthorizedTargets: expectedEvidence.config?.preApplyAuthorization ?? [],
|
|
876
3833
|
})
|
|
877
|
-
: await
|
|
3834
|
+
: await applyPluginConfigWrite({
|
|
878
3835
|
plugin,
|
|
879
3836
|
pluginName: plugin.manifest.name,
|
|
880
3837
|
scope: intent.scope,
|
|
881
|
-
projectLayer: intent.projectLayer,
|
|
882
3838
|
cwd: context.cwd,
|
|
883
3839
|
env: context.env,
|
|
884
3840
|
nativeCliRunner: context.nativeCliRunner,
|
|
885
|
-
rebuildRuntime: {
|
|
3841
|
+
rebuildRuntime: {
|
|
3842
|
+
...context,
|
|
3843
|
+
awHomeMutationToken,
|
|
3844
|
+
operationDiagnosticSink,
|
|
3845
|
+
...(reviewedScriptTimeoutMs(intent) === undefined
|
|
3846
|
+
? {}
|
|
3847
|
+
: { scriptTimeoutMs: reviewedScriptTimeoutMs(intent) }),
|
|
3848
|
+
...(catalogOperation ? {
|
|
3849
|
+
catalogOperationContext: catalogOperation,
|
|
3850
|
+
expectedGenerationSetDigest: expectedEvidence.catalog.generationSetDigest,
|
|
3851
|
+
} : {}),
|
|
3852
|
+
},
|
|
886
3853
|
awHomeMutationToken,
|
|
3854
|
+
applyTargets,
|
|
3855
|
+
request: { updates: intent.updates, removeKeys: intent.removeKeys },
|
|
3856
|
+
sharedNativeApplyConfirmed: true,
|
|
3857
|
+
preApplyConfirmed: true,
|
|
3858
|
+
preApplyAuthorizedTargets: expectedEvidence.config?.preApplyAuthorization ?? [],
|
|
887
3859
|
});
|
|
888
|
-
return result;
|
|
3860
|
+
return { ...result, operationRebuildResults };
|
|
889
3861
|
},
|
|
890
3862
|
});
|
|
891
3863
|
}
|
|
892
3864
|
throw new TuiOperationBlockedError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
|
|
893
3865
|
},
|
|
3866
|
+
}).finally(async () => {
|
|
3867
|
+
await codexObservationSession?.dispose();
|
|
894
3868
|
});
|
|
895
3869
|
},
|
|
896
3870
|
};
|