@lesliechan721/aw 0.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-config.d.mts +2 -0
- package/dist/authoring/assets/aw-config.mjs +556 -0
- package/dist/authoring/assets/aw-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.d.mts +2 -0
- package/dist/authoring/scripts/add-skill.mjs +355 -0
- package/dist/authoring/scripts/add-skill.mjs.map +1 -0
- package/dist/authoring/scripts/check-plugin-versions.d.mts +2 -0
- package/dist/authoring/scripts/check-plugin-versions.mjs +5 -0
- package/dist/authoring/scripts/check-plugin-versions.mjs.map +1 -0
- package/dist/authoring/scripts/init-plugin.d.mts +2 -0
- package/dist/authoring/scripts/init-plugin.mjs +512 -0
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.d.mts +4 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs +261 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-root.d.mts +26 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs +125 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +55 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +777 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -0
- package/dist/authoring/scripts/lib/semver.d.mts +9 -0
- package/dist/authoring/scripts/lib/semver.mjs +63 -0
- package/dist/authoring/scripts/lib/semver.mjs.map +1 -0
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +124 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +374 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -0
- package/dist/authoring/scripts/plugin-status.d.mts +2 -0
- package/dist/authoring/scripts/plugin-status.mjs +96 -0
- package/dist/authoring/scripts/plugin-status.mjs.map +1 -0
- package/dist/authoring/scripts/validate-plugin.d.mts +2 -0
- package/dist/authoring/scripts/validate-plugin.mjs +4442 -0
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-skill.d.mts +2 -0
- package/dist/authoring/scripts/validate-skill.mjs +126 -0
- package/dist/authoring/scripts/validate-skill.mjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/aw-skill-eval-engine.d.ts +13 -0
- package/dist/scripts/aw-skill-eval-engine.js +31 -0
- package/dist/scripts/aw-skill-eval-engine.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +18 -0
- package/dist/scripts/bundle-plugins.js +123 -0
- package/dist/scripts/bundle-plugins.js.map +1 -0
- package/dist/scripts/codex-eval-app-server.d.ts +89 -0
- package/dist/scripts/codex-eval-app-server.js +1228 -0
- package/dist/scripts/codex-eval-app-server.js.map +1 -0
- package/dist/scripts/codex-eval-isolation.d.ts +61 -0
- package/dist/scripts/codex-eval-isolation.js +318 -0
- package/dist/scripts/codex-eval-isolation.js.map +1 -0
- package/dist/scripts/codex-eval-process-management.d.ts +8 -0
- package/dist/scripts/codex-eval-process-management.js +69 -0
- package/dist/scripts/codex-eval-process-management.js.map +1 -0
- package/dist/scripts/codex-eval-process-tree.d.ts +38 -0
- package/dist/scripts/codex-eval-process-tree.js +803 -0
- package/dist/scripts/codex-eval-process-tree.js.map +1 -0
- package/dist/scripts/codex-eval-runtime-config.d.ts +62 -0
- package/dist/scripts/codex-eval-runtime-config.js +843 -0
- package/dist/scripts/codex-eval-runtime-config.js.map +1 -0
- package/dist/scripts/codex-trigger-eval.d.ts +84 -0
- package/dist/scripts/codex-trigger-eval.js +968 -0
- package/dist/scripts/codex-trigger-eval.js.map +1 -0
- package/dist/scripts/eval-plugin-skills-audited.d.ts +6 -0
- package/dist/scripts/eval-plugin-skills-audited.js +261 -0
- package/dist/scripts/eval-plugin-skills-audited.js.map +1 -0
- package/dist/scripts/eval-plugin-skills.d.ts +45 -0
- package/dist/scripts/eval-plugin-skills.js +1586 -0
- package/dist/scripts/eval-plugin-skills.js.map +1 -0
- package/dist/scripts/eval-run-layout.d.ts +17 -0
- package/dist/scripts/eval-run-layout.js +26 -0
- package/dist/scripts/eval-run-layout.js.map +1 -0
- package/dist/scripts/plugin-eval-contract.d.ts +185 -0
- package/dist/scripts/plugin-eval-contract.js +695 -0
- package/dist/scripts/plugin-eval-contract.js.map +1 -0
- package/dist/scripts/plugin-eval-materializer.d.ts +13 -0
- package/dist/scripts/plugin-eval-materializer.js +421 -0
- package/dist/scripts/plugin-eval-materializer.js.map +1 -0
- package/dist/scripts/plugin-staging.d.ts +43 -0
- package/dist/scripts/plugin-staging.js +196 -0
- package/dist/scripts/plugin-staging.js.map +1 -0
- package/dist/scripts/skill-reporting.d.ts +212 -0
- package/dist/scripts/skill-reporting.js +922 -0
- package/dist/scripts/skill-reporting.js.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +7 -0
- package/dist/scripts/test-plugin-scripts.js +674 -0
- package/dist/scripts/test-plugin-scripts.js.map +1 -0
- package/dist/src/adapters/helpers.d.ts +44 -0
- package/dist/src/adapters/helpers.js +95 -0
- package/dist/src/adapters/helpers.js.map +1 -0
- package/dist/src/authoring/workspace-commands.d.ts +46 -0
- package/dist/src/authoring/workspace-commands.js +133 -0
- package/dist/src/authoring/workspace-commands.js.map +1 -0
- package/dist/src/commands/catalog-publish.d.ts +33 -0
- package/dist/src/commands/catalog-publish.js +374 -0
- package/dist/src/commands/catalog-publish.js.map +1 -0
- package/dist/src/commands/catalog-source.d.ts +111 -0
- package/dist/src/commands/catalog-source.js +266 -0
- package/dist/src/commands/catalog-source.js.map +1 -0
- package/dist/src/commands/console.d.ts +3 -0
- package/dist/src/commands/console.js +44 -0
- package/dist/src/commands/console.js.map +1 -0
- package/dist/src/commands/dependency-operation-plan.d.ts +28 -0
- package/dist/src/commands/dependency-operation-plan.js +15 -0
- package/dist/src/commands/dependency-operation-plan.js.map +1 -0
- package/dist/src/commands/init.d.ts +31 -0
- package/dist/src/commands/init.js +63 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/options.d.ts +68 -0
- package/dist/src/commands/options.js +146 -0
- package/dist/src/commands/options.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +77 -0
- package/dist/src/commands/rebuild-command.js +1681 -0
- package/dist/src/commands/rebuild-command.js.map +1 -0
- package/dist/src/commands/rebuild-integration.d.ts +94 -0
- package/dist/src/commands/rebuild-integration.js +3289 -0
- package/dist/src/commands/rebuild-integration.js.map +1 -0
- package/dist/src/commands/rebuild-operations.d.ts +110 -0
- package/dist/src/commands/rebuild-operations.js +791 -0
- package/dist/src/commands/rebuild-operations.js.map +1 -0
- package/dist/src/commands/review-publication.d.ts +99 -0
- package/dist/src/commands/review-publication.js +904 -0
- package/dist/src/commands/review-publication.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +176 -0
- package/dist/src/commands/runtime.js +746 -0
- package/dist/src/commands/runtime.js.map +1 -0
- package/dist/src/commands/status-v4.d.ts +102 -0
- package/dist/src/commands/status-v4.js +844 -0
- package/dist/src/commands/status-v4.js.map +1 -0
- package/dist/src/commands/status.d.ts +93 -0
- package/dist/src/commands/status.js +442 -0
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +57 -0
- package/dist/src/commands/wizard.js +58 -0
- package/dist/src/commands/wizard.js.map +1 -0
- package/dist/src/commands/write-commands.d.ts +7 -0
- package/dist/src/commands/write-commands.js +167 -0
- package/dist/src/commands/write-commands.js.map +1 -0
- package/dist/src/constants.d.ts +25 -0
- package/dist/src/constants.js +26 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/generators/agents.d.ts +3 -0
- package/dist/src/generators/agents.js +46 -0
- package/dist/src/generators/agents.js.map +1 -0
- package/dist/src/generators/hooks.d.ts +15 -0
- package/dist/src/generators/hooks.js +76 -0
- package/dist/src/generators/hooks.js.map +1 -0
- package/dist/src/generators/instructions.d.ts +13 -0
- package/dist/src/generators/instructions.js +66 -0
- package/dist/src/generators/instructions.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +53 -0
- package/dist/src/generators/local-plugin.js +1268 -0
- package/dist/src/generators/local-plugin.js.map +1 -0
- package/dist/src/generators/permissions.d.ts +10 -0
- package/dist/src/generators/permissions.js +37 -0
- package/dist/src/generators/permissions.js.map +1 -0
- package/dist/src/generators/shared.d.ts +2 -0
- package/dist/src/generators/shared.js +15 -0
- package/dist/src/generators/shared.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.js +2344 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +90 -0
- package/dist/src/output/command-receipt.js +129 -0
- package/dist/src/output/command-receipt.js.map +1 -0
- package/dist/src/output/debug-log.d.ts +4 -0
- package/dist/src/output/debug-log.js +97 -0
- package/dist/src/output/debug-log.js.map +1 -0
- package/dist/src/output/equivalent-command.d.ts +9 -0
- package/dist/src/output/equivalent-command.js +39 -0
- package/dist/src/output/equivalent-command.js.map +1 -0
- package/dist/src/output/model.d.ts +117 -0
- package/dist/src/output/model.js +145 -0
- package/dist/src/output/model.js.map +1 -0
- package/dist/src/output/rebuild-progress.d.ts +21 -0
- package/dist/src/output/rebuild-progress.js +138 -0
- package/dist/src/output/rebuild-progress.js.map +1 -0
- package/dist/src/output/redact.d.ts +3 -0
- package/dist/src/output/redact.js +39 -0
- package/dist/src/output/redact.js.map +1 -0
- package/dist/src/output/reporter.d.ts +9 -0
- package/dist/src/output/reporter.js +133 -0
- package/dist/src/output/reporter.js.map +1 -0
- package/dist/src/portable/commands.d.ts +120 -0
- package/dist/src/portable/commands.js +506 -0
- package/dist/src/portable/commands.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +50 -0
- package/dist/src/portable/materializer.js +408 -0
- package/dist/src/portable/materializer.js.map +1 -0
- package/dist/src/portable/skills-cli.d.ts +43 -0
- package/dist/src/portable/skills-cli.js +148 -0
- package/dist/src/portable/skills-cli.js.map +1 -0
- package/dist/src/tui/components.d.ts +32 -0
- package/dist/src/tui/components.js +42 -0
- package/dist/src/tui/components.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +20 -0
- package/dist/src/tui/console-app-v4.js +2613 -0
- package/dist/src/tui/console-app-v4.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +11 -0
- package/dist/src/tui/controller-runtime.js +902 -0
- package/dist/src/tui/controller-runtime.js.map +1 -0
- package/dist/src/tui/controller.d.ts +367 -0
- package/dist/src/tui/controller.js +1724 -0
- package/dist/src/tui/controller.js.map +1 -0
- package/dist/src/tui/index.d.ts +13 -0
- package/dist/src/tui/index.js +14 -0
- package/dist/src/tui/index.js.map +1 -0
- package/dist/src/tui/keys.d.ts +12 -0
- package/dist/src/tui/keys.js +22 -0
- package/dist/src/tui/keys.js.map +1 -0
- package/dist/src/tui/layout.d.ts +12 -0
- package/dist/src/tui/layout.js +19 -0
- package/dist/src/tui/layout.js.map +1 -0
- package/dist/src/tui/model.d.ts +279 -0
- package/dist/src/tui/model.js +652 -0
- package/dist/src/tui/model.js.map +1 -0
- package/dist/src/tui/prompt.d.ts +8 -0
- package/dist/src/tui/prompt.js +242 -0
- package/dist/src/tui/prompt.js.map +1 -0
- package/dist/src/tui/router.d.ts +153 -0
- package/dist/src/tui/router.js +102 -0
- package/dist/src/tui/router.js.map +1 -0
- package/dist/src/tui/runner.d.ts +11 -0
- package/dist/src/tui/runner.js +71 -0
- package/dist/src/tui/runner.js.map +1 -0
- package/dist/src/tui/theme.d.ts +18 -0
- package/dist/src/tui/theme.js +20 -0
- package/dist/src/tui/theme.js.map +1 -0
- package/dist/src/tui/views.d.ts +57 -0
- package/dist/src/tui/views.js +173 -0
- package/dist/src/tui/views.js.map +1 -0
- package/dist/src/tui/wizard.d.ts +11 -0
- package/dist/src/tui/wizard.js +321 -0
- package/dist/src/tui/wizard.js.map +1 -0
- package/dist/src/types.d.ts +313 -0
- package/dist/src/types.js +33 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/active-marketplace-runtime-lock.d.ts +12 -0
- package/dist/src/utils/active-marketplace-runtime-lock.js +133 -0
- package/dist/src/utils/active-marketplace-runtime-lock.js.map +1 -0
- package/dist/src/utils/agent-version.d.ts +13 -0
- package/dist/src/utils/agent-version.js +172 -0
- package/dist/src/utils/agent-version.js.map +1 -0
- package/dist/src/utils/artifact-plan.d.ts +26 -0
- package/dist/src/utils/artifact-plan.js +444 -0
- package/dist/src/utils/artifact-plan.js.map +1 -0
- package/dist/src/utils/artifact-renderer.d.ts +124 -0
- package/dist/src/utils/artifact-renderer.js +442 -0
- package/dist/src/utils/artifact-renderer.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +8 -0
- package/dist/src/utils/artifact-sources.js +10 -0
- package/dist/src/utils/artifact-sources.js.map +1 -0
- package/dist/src/utils/aw-home-mutation-lock.d.ts +10 -0
- package/dist/src/utils/aw-home-mutation-lock.js +55 -0
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -0
- package/dist/src/utils/bundle-integrity.d.ts +3 -0
- package/dist/src/utils/bundle-integrity.js +88 -0
- package/dist/src/utils/bundle-integrity.js.map +1 -0
- package/dist/src/utils/bundle-layout.d.ts +4 -0
- package/dist/src/utils/bundle-layout.js +546 -0
- package/dist/src/utils/bundle-layout.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +8 -0
- package/dist/src/utils/catalog-digests.js +108 -0
- package/dist/src/utils/catalog-digests.js.map +1 -0
- package/dist/src/utils/catalog-manifest-v3.d.ts +2 -0
- package/dist/src/utils/catalog-manifest-v3.js +3 -0
- package/dist/src/utils/catalog-manifest-v3.js.map +1 -0
- package/dist/src/utils/catalog-manifest-v4.d.ts +5 -0
- package/dist/src/utils/catalog-manifest-v4.js +106 -0
- package/dist/src/utils/catalog-manifest-v4.js.map +1 -0
- package/dist/src/utils/catalog-public-error.d.ts +15 -0
- package/dist/src/utils/catalog-public-error.js +84 -0
- package/dist/src/utils/catalog-public-error.js.map +1 -0
- package/dist/src/utils/catalog-runtime-projection.d.ts +36 -0
- package/dist/src/utils/catalog-runtime-projection.js +172 -0
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -0
- package/dist/src/utils/catalog-snapshot.d.ts +8 -0
- package/dist/src/utils/catalog-snapshot.js +12 -0
- package/dist/src/utils/catalog-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-source-cache.d.ts +61 -0
- package/dist/src/utils/catalog-source-cache.js +276 -0
- package/dist/src/utils/catalog-source-cache.js.map +1 -0
- package/dist/src/utils/catalog-source-identity.d.ts +4 -0
- package/dist/src/utils/catalog-source-identity.js +118 -0
- package/dist/src/utils/catalog-source-identity.js.map +1 -0
- package/dist/src/utils/catalog-source-presentation.d.ts +1 -0
- package/dist/src/utils/catalog-source-presentation.js +32 -0
- package/dist/src/utils/catalog-source-presentation.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +65 -0
- package/dist/src/utils/catalog-source-references.js +1418 -0
- package/dist/src/utils/catalog-source-references.js.map +1 -0
- package/dist/src/utils/catalog-sources.d.ts +39 -0
- package/dist/src/utils/catalog-sources.js +293 -0
- package/dist/src/utils/catalog-sources.js.map +1 -0
- package/dist/src/utils/codex-config.d.ts +124 -0
- package/dist/src/utils/codex-config.js +1011 -0
- package/dist/src/utils/codex-config.js.map +1 -0
- package/dist/src/utils/codex-project-surface.d.ts +3 -0
- package/dist/src/utils/codex-project-surface.js +49 -0
- package/dist/src/utils/codex-project-surface.js.map +1 -0
- package/dist/src/utils/codex-roles.d.ts +71 -0
- package/dist/src/utils/codex-roles.js +257 -0
- package/dist/src/utils/codex-roles.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +9 -0
- package/dist/src/utils/codex-skill-staging.js +8 -0
- package/dist/src/utils/codex-skill-staging.js.map +1 -0
- package/dist/src/utils/config-value.d.ts +3 -0
- package/dist/src/utils/config-value.js +23 -0
- package/dist/src/utils/config-value.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +32 -0
- package/dist/src/utils/dynamic-skill-tree.js +436 -0
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -0
- package/dist/src/utils/file-rules.d.ts +1 -0
- package/dist/src/utils/file-rules.js +2 -0
- package/dist/src/utils/file-rules.js.map +1 -0
- package/dist/src/utils/git-catalog-provider.d.ts +7 -0
- package/dist/src/utils/git-catalog-provider.js +510 -0
- package/dist/src/utils/git-catalog-provider.js.map +1 -0
- package/dist/src/utils/hooks-contract.d.ts +1 -0
- package/dist/src/utils/hooks-contract.js +2 -0
- package/dist/src/utils/hooks-contract.js.map +1 -0
- package/dist/src/utils/json.d.ts +4 -0
- package/dist/src/utils/json.js +29 -0
- package/dist/src/utils/json.js.map +1 -0
- package/dist/src/utils/lifecycle-active-store.d.ts +175 -0
- package/dist/src/utils/lifecycle-active-store.js +1276 -0
- package/dist/src/utils/lifecycle-active-store.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +41 -0
- package/dist/src/utils/local-marketplace.js +317 -0
- package/dist/src/utils/local-marketplace.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +14 -0
- package/dist/src/utils/manifest.js +36 -0
- package/dist/src/utils/manifest.js.map +1 -0
- package/dist/src/utils/marketplace.d.ts +3 -0
- package/dist/src/utils/marketplace.js +76 -0
- package/dist/src/utils/marketplace.js.map +1 -0
- package/dist/src/utils/multi-source-catalog.d.ts +72 -0
- package/dist/src/utils/multi-source-catalog.js +402 -0
- package/dist/src/utils/multi-source-catalog.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +75 -0
- package/dist/src/utils/native-cli.js +435 -0
- package/dist/src/utils/native-cli.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.d.ts +18 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +202 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -0
- package/dist/src/utils/ownership.d.ts +130 -0
- package/dist/src/utils/ownership.js +766 -0
- package/dist/src/utils/ownership.js.map +1 -0
- package/dist/src/utils/path-catalog-provider.d.ts +7 -0
- package/dist/src/utils/path-catalog-provider.js +87 -0
- package/dist/src/utils/path-catalog-provider.js.map +1 -0
- package/dist/src/utils/paths.d.ts +41 -0
- package/dist/src/utils/paths.js +138 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/platform-entries.d.ts +1 -0
- package/dist/src/utils/platform-entries.js +2 -0
- package/dist/src/utils/platform-entries.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -0
- package/dist/src/utils/platform-support.js +2 -0
- package/dist/src/utils/platform-support.js.map +1 -0
- package/dist/src/utils/plugin-authoring-capabilities.d.ts +23 -0
- package/dist/src/utils/plugin-authoring-capabilities.js +37 -0
- package/dist/src/utils/plugin-authoring-capabilities.js.map +1 -0
- package/dist/src/utils/plugin-authoring-capabilities.json +92 -0
- package/dist/src/utils/plugin-config-write.d.ts +107 -0
- package/dist/src/utils/plugin-config-write.js +565 -0
- package/dist/src/utils/plugin-config-write.js.map +1 -0
- package/dist/src/utils/plugin-config.d.ts +396 -0
- package/dist/src/utils/plugin-config.js +1898 -0
- package/dist/src/utils/plugin-config.js.map +1 -0
- package/dist/src/utils/plugin-dependencies.d.ts +12 -0
- package/dist/src/utils/plugin-dependencies.js +162 -0
- package/dist/src/utils/plugin-dependencies.js.map +1 -0
- package/dist/src/utils/plugin-release.d.ts +2 -0
- package/dist/src/utils/plugin-release.js +2 -0
- package/dist/src/utils/plugin-release.js.map +1 -0
- package/dist/src/utils/plugin-script-contract.d.ts +1 -0
- package/dist/src/utils/plugin-script-contract.js +2 -0
- package/dist/src/utils/plugin-script-contract.js.map +1 -0
- package/dist/src/utils/plugin-scripts.d.ts +172 -0
- package/dist/src/utils/plugin-scripts.js +585 -0
- package/dist/src/utils/plugin-scripts.js.map +1 -0
- package/dist/src/utils/process-lock.d.ts +47 -0
- package/dist/src/utils/process-lock.js +532 -0
- package/dist/src/utils/process-lock.js.map +1 -0
- package/dist/src/utils/process-tree.d.ts +2 -0
- package/dist/src/utils/process-tree.js +2 -0
- package/dist/src/utils/process-tree.js.map +1 -0
- package/dist/src/utils/project-boundary.d.ts +21 -0
- package/dist/src/utils/project-boundary.js +95 -0
- package/dist/src/utils/project-boundary.js.map +1 -0
- package/dist/src/utils/rendered-contract.d.ts +8 -0
- package/dist/src/utils/rendered-contract.js +134 -0
- package/dist/src/utils/rendered-contract.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +13 -0
- package/dist/src/utils/runtime-skill-closure.js +863 -0
- package/dist/src/utils/runtime-skill-closure.js.map +1 -0
- package/dist/src/utils/skill-authoring.d.ts +1 -0
- package/dist/src/utils/skill-authoring.js +2 -0
- package/dist/src/utils/skill-authoring.js.map +1 -0
- package/dist/src/utils/skill-frontmatter-capabilities.d.ts +201 -0
- package/dist/src/utils/skill-frontmatter-capabilities.js +5 -0
- package/dist/src/utils/skill-frontmatter-capabilities.js.map +1 -0
- package/dist/src/utils/skill-frontmatter-capabilities.json +200 -0
- package/dist/src/utils/skill-validation.d.ts +37 -0
- package/dist/src/utils/skill-validation.js +326 -0
- package/dist/src/utils/skill-validation.js.map +1 -0
- package/dist/src/utils/slash-commands.d.ts +1 -0
- package/dist/src/utils/slash-commands.js +2 -0
- package/dist/src/utils/slash-commands.js.map +1 -0
- package/dist/src/utils/state-paths.d.ts +13 -0
- package/dist/src/utils/state-paths.js +129 -0
- package/dist/src/utils/state-paths.js.map +1 -0
- package/dist/src/utils/target-eligibility.d.ts +7 -0
- package/dist/src/utils/target-eligibility.js +26 -0
- package/dist/src/utils/target-eligibility.js.map +1 -0
- package/dist/src/utils/target-order.d.ts +7 -0
- package/dist/src/utils/target-order.js +10 -0
- package/dist/src/utils/target-order.js.map +1 -0
- package/dist/src/utils/template-engine.d.ts +1 -0
- package/dist/src/utils/template-engine.js +2 -0
- package/dist/src/utils/template-engine.js.map +1 -0
- package/dist/src/utils/test-path-fence.d.ts +12 -0
- package/dist/src/utils/test-path-fence.js +31 -0
- package/dist/src/utils/test-path-fence.js.map +1 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +16 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,902 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { statusCommandV4 } from '../commands/status-v4.js';
|
|
3
|
+
import { addCatalogSourceCommand, listCatalogSources, preflightCatalogSourceMutation, removeCatalogSourceCommand, setPrimaryCatalogSourceCommand, updateCatalogSourceCommand, } from '../commands/catalog-source.js';
|
|
4
|
+
import { cleanupWriteCommand, installWriteCommand, reinstallWriteCommand, uninstallWriteCommand, upgradeWriteCommand, } from '../commands/write-commands.js';
|
|
5
|
+
import { readCliPackageInfo } from '../utils/local-marketplace.js';
|
|
6
|
+
import { readCatalogSourcesConfigSnapshot, } from '../utils/catalog-sources.js';
|
|
7
|
+
import { withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, formatPluginId, parsePluginId, } from '../utils/multi-source-catalog.js';
|
|
8
|
+
import { coercePluginConfigUpdates, readNamespacedPluginConfigStoreIdentity, readPluginConfigStore, resolveConfigRead, } from '../utils/plugin-config.js';
|
|
9
|
+
import { applyPluginConfigWrite, resetPluginConfigWithHelper, } from '../utils/plugin-config-write.js';
|
|
10
|
+
import { operationEvidenceFingerprint, TuiController, TuiOperationBlockedError, } from './controller.js';
|
|
11
|
+
import { buildConfigGroups, buildConfigPage, projectPlatformPlacement, } from './model.js';
|
|
12
|
+
import { projectCatalogSourceLocation } from '../utils/catalog-source-presentation.js';
|
|
13
|
+
import { targetCanBeUninstalled } from '../utils/target-eligibility.js';
|
|
14
|
+
import { calculateCatalogSourceIdentity } from '../utils/catalog-source-identity.js';
|
|
15
|
+
import { resolvePluginsFromCatalog } from '../utils/manifest.js';
|
|
16
|
+
import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
17
|
+
import { installPortableSkills, preparePortableInstall, PortableCommandError, } from '../portable/commands.js';
|
|
18
|
+
async function loadPortablePluginIds(options) {
|
|
19
|
+
return withResolvedMultiSourceCatalog({
|
|
20
|
+
cliVersion: options.cliVersion,
|
|
21
|
+
freshnessPolicy: 'cacheFirst',
|
|
22
|
+
env: options.context.env,
|
|
23
|
+
signal: options.signal,
|
|
24
|
+
consume: async (catalog) => (await Promise.all(catalog.sources.flatMap((item) => item.resolution
|
|
25
|
+
? [resolvePluginsFromCatalog(item.resolution.rootDir, undefined).then((plugins) => plugins
|
|
26
|
+
.filter((plugin) => plugin.manifest.distributions?.agentSkills)
|
|
27
|
+
.map((plugin) => formatPluginId({
|
|
28
|
+
sourceId: item.resolution.sourceId,
|
|
29
|
+
pluginName: plugin.manifest.name,
|
|
30
|
+
})))]
|
|
31
|
+
: []))).flat(),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
let tuiControllerRuntimeTestHooks;
|
|
35
|
+
export function setTuiControllerRuntimeTestHooksForTests(hooks) {
|
|
36
|
+
tuiControllerRuntimeTestHooks = hooks;
|
|
37
|
+
}
|
|
38
|
+
function digest(value) {
|
|
39
|
+
return `sha256:${crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex')}`;
|
|
40
|
+
}
|
|
41
|
+
function operationReviewStale(message) {
|
|
42
|
+
return new TuiOperationBlockedError('operationReviewStale', `operationReviewStale: ${message}`);
|
|
43
|
+
}
|
|
44
|
+
function sourceEvidenceForPlugin(source, pluginName) {
|
|
45
|
+
const entry = source.manifest.entries.find((candidate) => candidate.name === pluginName);
|
|
46
|
+
return {
|
|
47
|
+
sourceId: source.sourceId,
|
|
48
|
+
sourceIdentity: source.sourceIdentity,
|
|
49
|
+
requestedRef: source.requestedRef,
|
|
50
|
+
resolvedCommit: source.resolvedCommit,
|
|
51
|
+
manifestDigest: source.manifestDigest,
|
|
52
|
+
snapshotDigest: source.snapshotDigest,
|
|
53
|
+
contentDigest: entry.contentDigest,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function assertSourceEvidenceMatches(expected, actual) {
|
|
57
|
+
if (actual.sourceId !== expected.sourceId
|
|
58
|
+
|| actual.sourceIdentity !== expected.sourceIdentity
|
|
59
|
+
|| actual.resolvedCommit !== expected.resolvedCommit
|
|
60
|
+
|| actual.manifestDigest !== expected.manifestDigest
|
|
61
|
+
|| actual.snapshotDigest !== expected.snapshotDigest
|
|
62
|
+
|| actual.contentDigest !== expected.contentDigest) {
|
|
63
|
+
throw operationReviewStale('确认后来源内容发生变化。');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function throwIfWriteReviewStale(result) {
|
|
67
|
+
const stale = result.targetResults.find((target) => target.errorCode === 'operationReviewStale');
|
|
68
|
+
if (stale) {
|
|
69
|
+
throw operationReviewStale('确认后实际写入计划发生变化。');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const SOURCE_PROGRESS_PHASES = {
|
|
73
|
+
refreshingCatalog: '刷新 Catalog 缓存',
|
|
74
|
+
catalogReady: 'Catalog 已读取,索引已刷新',
|
|
75
|
+
savingConfig: '保存来源配置',
|
|
76
|
+
};
|
|
77
|
+
function pluginIntent(intent) {
|
|
78
|
+
return 'pluginId' in intent;
|
|
79
|
+
}
|
|
80
|
+
function assertIntentIsLegal(intent, targets) {
|
|
81
|
+
const platforms = intent.platform === 'both'
|
|
82
|
+
? ['codex', 'claude']
|
|
83
|
+
: [intent.platform];
|
|
84
|
+
for (const platform of platforms) {
|
|
85
|
+
const selected = targets.find((target) => target.platform === platform && target.scope === intent.scope);
|
|
86
|
+
if (!selected || selected.errors.some((error) => error.code === 'unsupportedTarget')) {
|
|
87
|
+
throw new TuiOperationBlockedError('unsupportedTarget', '所选插件不支持这个平台和使用位置。');
|
|
88
|
+
}
|
|
89
|
+
const otherScopeInstalled = targets.some((target) => target.platform === platform
|
|
90
|
+
&& target.scope !== intent.scope
|
|
91
|
+
&& (target.state === 'present' || target.state === 'partial'));
|
|
92
|
+
if (intent.action === 'install' && otherScopeInstalled) {
|
|
93
|
+
throw new TuiOperationBlockedError('scopeConflict', '这个平台已安装在另一个使用位置。请先移除原位置。');
|
|
94
|
+
}
|
|
95
|
+
if (intent.action === 'install' && selected.state !== 'absent') {
|
|
96
|
+
throw new TuiOperationBlockedError('targetAlreadyInstalled', '所选位置已经安装。');
|
|
97
|
+
}
|
|
98
|
+
if (intent.action === 'upgrade' && selected.state !== 'present') {
|
|
99
|
+
throw new TuiOperationBlockedError('targetStateChanged', '当前安装状态不允许执行这个操作。');
|
|
100
|
+
}
|
|
101
|
+
if (intent.action === 'uninstall' && !targetCanBeUninstalled(selected.state)) {
|
|
102
|
+
throw new TuiOperationBlockedError('targetStateChanged', '当前安装状态不允许执行这个操作。');
|
|
103
|
+
}
|
|
104
|
+
if ((intent.action === 'reinstall' || intent.action === 'cleanup') && selected.state === 'absent') {
|
|
105
|
+
throw new TuiOperationBlockedError('targetAbsent', '所选位置没有可处理的 AW 安装。');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function assertTypedIssueOrigin(intent, targets) {
|
|
110
|
+
if (!intent.originIssue)
|
|
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
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (intent.originIssue.category === 'dependencyNotReady') {
|
|
125
|
+
if (intent.originIssue.actionId !== 'reinstallDependency'
|
|
126
|
+
|| intent.action !== 'reinstall' || !selected
|
|
127
|
+
|| (selected.state !== 'partial' && selected.state !== 'error')) {
|
|
128
|
+
stale('原依赖安装问题已变化。');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (intent.originIssue.category === 'incompleteInstallation') {
|
|
132
|
+
if (!selected || !targetCanBeUninstalled(selected.state) || selected.state !== 'partial'
|
|
133
|
+
|| !((intent.originIssue.actionId === 'reinstall' && intent.action === 'reinstall')
|
|
134
|
+
|| (intent.originIssue.actionId === 'remove' && intent.action === 'uninstall'))) {
|
|
135
|
+
stale('原安装问题已变化。');
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
else if (intent.originIssue.category === 'scopeConflict') {
|
|
140
|
+
const installedScopes = new Set(targets.filter((target) => target.pluginId === intent.pluginId
|
|
141
|
+
&& target.platform === intent.platform
|
|
142
|
+
&& (target.state === 'present' || target.state === 'partial')).map((target) => target.scope));
|
|
143
|
+
const correctBranch = intent.action === 'uninstall'
|
|
144
|
+
&& ((intent.originIssue.actionId === 'keepUserScope' && intent.scope === 'project')
|
|
145
|
+
|| (intent.originIssue.actionId === 'keepProjectScope' && intent.scope === 'user'));
|
|
146
|
+
if (!correctBranch || !installedScopes.has('user') || !installedScopes.has('project')) {
|
|
147
|
+
stale('原位置冲突已变化。');
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
else
|
|
152
|
+
stale('这个问题没有安全的自动写入动作。');
|
|
153
|
+
const origin = intent.originIssue;
|
|
154
|
+
if (!origin.consumerPluginId || !origin.consumerSourceIdentity || !origin.consumerPlatform
|
|
155
|
+
|| !origin.consumerScope || !origin.dependencyPluginId || !origin.dependencyPlatform
|
|
156
|
+
|| !origin.dependencyScope || origin.dependencyProject === undefined
|
|
157
|
+
|| origin.dependencyPluginId !== intent.pluginId
|
|
158
|
+
|| origin.dependencyPlatform !== intent.platform || origin.dependencyScope !== intent.scope) {
|
|
159
|
+
stale('依赖问题来源缺少稳定目标证据。');
|
|
160
|
+
}
|
|
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
|
+
}
|
|
169
|
+
async function loadDependencyOverviews(options) {
|
|
170
|
+
const graph = await withResolvedMultiSourceCatalog({
|
|
171
|
+
cliVersion: options.cliVersion,
|
|
172
|
+
freshnessPolicy: 'cacheFirst',
|
|
173
|
+
env: options.context.env,
|
|
174
|
+
signal: options.signal,
|
|
175
|
+
consume: async (catalog) => ({
|
|
176
|
+
nodes: (await Promise.all(catalog.sources.flatMap((item) => item.resolution
|
|
177
|
+
? [resolvePluginsFromCatalog(item.resolution.rootDir, undefined).then((plugins) => plugins.map((plugin) => ({
|
|
178
|
+
pluginId: formatPluginId({
|
|
179
|
+
sourceId: item.resolution.sourceId,
|
|
180
|
+
pluginName: plugin.manifest.name,
|
|
181
|
+
}),
|
|
182
|
+
displayName: plugin.manifest.interface?.displayName ?? plugin.manifest.name,
|
|
183
|
+
dependencies: (plugin.manifest.dependencies ?? []).map((pluginName) => formatPluginId({ sourceId: item.resolution.sourceId, pluginName })),
|
|
184
|
+
})))] : []))).flat(),
|
|
185
|
+
sourceErrors: catalog.sources.flatMap((item) => item.error
|
|
186
|
+
? [{ sourceId: item.sourceId, code: 'dependencyGraphInvalid' }]
|
|
187
|
+
: []),
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
const nodes = new Map(graph.nodes.map((node) => [node.pluginId, node]));
|
|
191
|
+
const displayName = (pluginId) => nodes.get(pluginId)?.displayName
|
|
192
|
+
?? parsePluginId(pluginId).pluginName;
|
|
193
|
+
const reverse = new Map();
|
|
194
|
+
for (const node of graph.nodes) {
|
|
195
|
+
for (const dependency of node.dependencies) {
|
|
196
|
+
reverse.set(dependency, [...(reverse.get(dependency) ?? []), node.pluginId]);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const targetsByPlugin = new Map();
|
|
200
|
+
for (const target of options.status.payload.targets) {
|
|
201
|
+
targetsByPlugin.set(target.pluginId, [...(targetsByPlugin.get(target.pluginId) ?? []), target]);
|
|
202
|
+
}
|
|
203
|
+
const placementReferences = new Map();
|
|
204
|
+
for (const consumer of options.status.payload.targets.filter((target) => target.state !== 'absent')) {
|
|
205
|
+
const consumerNode = nodes.get(consumer.pluginId);
|
|
206
|
+
if (!consumerNode)
|
|
207
|
+
continue;
|
|
208
|
+
for (const dependencyPluginId of consumerNode.dependencies) {
|
|
209
|
+
const dependencyTargets = (targetsByPlugin.get(dependencyPluginId) ?? [])
|
|
210
|
+
.filter((target) => target.platform === consumer.platform);
|
|
211
|
+
const projectTarget = dependencyTargets.find((target) => target.scope === 'project');
|
|
212
|
+
const userTarget = dependencyTargets.find((target) => target.scope === 'user');
|
|
213
|
+
const dependencyScope = consumer.scope === 'user'
|
|
214
|
+
? 'user'
|
|
215
|
+
: userTarget && (!projectTarget
|
|
216
|
+
|| (userTarget.state !== 'absent' && projectTarget.state === 'absent'))
|
|
217
|
+
? 'user'
|
|
218
|
+
: 'project';
|
|
219
|
+
const reference = {
|
|
220
|
+
consumer: {
|
|
221
|
+
pluginId: consumer.pluginId,
|
|
222
|
+
platform: consumer.platform,
|
|
223
|
+
scope: consumer.scope,
|
|
224
|
+
project: consumer.scope === 'project' ? 'current' : null,
|
|
225
|
+
},
|
|
226
|
+
dependency: {
|
|
227
|
+
pluginId: dependencyPluginId,
|
|
228
|
+
platform: consumer.platform,
|
|
229
|
+
scope: dependencyScope,
|
|
230
|
+
project: dependencyScope === 'project' ? 'current' : null,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
const key = `${consumer.pluginId}\0${dependencyPluginId}`;
|
|
234
|
+
placementReferences.set(key, [...(placementReferences.get(key) ?? []), reference]);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const placementsFor = (pluginId) => {
|
|
238
|
+
const targets = targetsByPlugin.get(pluginId) ?? [];
|
|
239
|
+
if (targets.length > 0) {
|
|
240
|
+
return ['codex', 'claude'].flatMap((platform) => {
|
|
241
|
+
const selected = targets.filter((target) => target.platform === platform);
|
|
242
|
+
return selected.length > 0 ? [projectPlatformPlacement(platform, selected)] : [];
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return [];
|
|
246
|
+
};
|
|
247
|
+
const aggregateFor = (pluginId, placements) => {
|
|
248
|
+
const sourceId = parsePluginId(pluginId).sourceId;
|
|
249
|
+
if (graph.sourceErrors.some((error) => error.sourceId === sourceId))
|
|
250
|
+
return 'unavailable';
|
|
251
|
+
if (placements.length === 0 || placements.every((placement) => placement.state === 'notInstalled')) {
|
|
252
|
+
return 'notInstalled';
|
|
253
|
+
}
|
|
254
|
+
return placements.some((placement) => placement.state === 'scopeConflict'
|
|
255
|
+
|| (placement.state === 'installed' && placement.health !== 'ready'))
|
|
256
|
+
? 'needsAttention'
|
|
257
|
+
: 'ready';
|
|
258
|
+
};
|
|
259
|
+
const allPluginIds = new Set([
|
|
260
|
+
...nodes.keys(),
|
|
261
|
+
...reverse.keys(),
|
|
262
|
+
...targetsByPlugin.keys(),
|
|
263
|
+
]);
|
|
264
|
+
return [...allPluginIds].sort().map((pluginId) => {
|
|
265
|
+
const dependencies = [];
|
|
266
|
+
const seen = new Set([pluginId]);
|
|
267
|
+
let frontier = [pluginId];
|
|
268
|
+
let depth = 0;
|
|
269
|
+
let graphInvalid = false;
|
|
270
|
+
while (frontier.length > 0) {
|
|
271
|
+
depth += 1;
|
|
272
|
+
const next = [];
|
|
273
|
+
const requiredBy = new Map();
|
|
274
|
+
for (const parent of frontier) {
|
|
275
|
+
for (const dependency of nodes.get(parent)?.dependencies ?? []) {
|
|
276
|
+
const parents = requiredBy.get(dependency) ?? new Set();
|
|
277
|
+
parents.add(parent);
|
|
278
|
+
requiredBy.set(dependency, parents);
|
|
279
|
+
if (seen.has(dependency)) {
|
|
280
|
+
if (dependency === pluginId)
|
|
281
|
+
graphInvalid = true;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
seen.add(dependency);
|
|
285
|
+
next.push(dependency);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
for (const dependency of next) {
|
|
289
|
+
dependencies.push({ pluginId: dependency, depth, requiredBy: [...(requiredBy.get(dependency) ?? [])] });
|
|
290
|
+
}
|
|
291
|
+
frontier = next;
|
|
292
|
+
}
|
|
293
|
+
const dependencyItems = dependencies.map((dependency) => {
|
|
294
|
+
const placements = placementsFor(dependency.pluginId);
|
|
295
|
+
return {
|
|
296
|
+
pluginId: dependency.pluginId,
|
|
297
|
+
displayName: displayName(dependency.pluginId),
|
|
298
|
+
relation: dependency.depth === 1 ? 'direct' : 'transitive',
|
|
299
|
+
depth: dependency.depth,
|
|
300
|
+
requiredBy: dependency.requiredBy.map((requiredBy) => ({
|
|
301
|
+
pluginId: requiredBy,
|
|
302
|
+
displayName: displayName(requiredBy),
|
|
303
|
+
})),
|
|
304
|
+
placements,
|
|
305
|
+
aggregateStatus: aggregateFor(dependency.pluginId, placements),
|
|
306
|
+
placementReferences: placementReferences.get(`${pluginId}\0${dependency.pluginId}`) ?? [],
|
|
307
|
+
};
|
|
308
|
+
});
|
|
309
|
+
const dependentIds = [...new Set(reverse.get(pluginId) ?? [])].sort();
|
|
310
|
+
const dependents = dependentIds.map((dependentId) => {
|
|
311
|
+
const placements = placementsFor(dependentId);
|
|
312
|
+
return {
|
|
313
|
+
pluginId: dependentId,
|
|
314
|
+
displayName: displayName(dependentId),
|
|
315
|
+
relation: 'dependent',
|
|
316
|
+
depth: 1,
|
|
317
|
+
requiredBy: [],
|
|
318
|
+
placements,
|
|
319
|
+
aggregateStatus: aggregateFor(dependentId, placements),
|
|
320
|
+
placementReferences: placementReferences.get(`${dependentId}\0${pluginId}`) ?? [],
|
|
321
|
+
};
|
|
322
|
+
});
|
|
323
|
+
const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.errors.filter((error) => error.code.startsWith('dependency') || error.code === 'sourceChanged')
|
|
324
|
+
.map((error) => ({
|
|
325
|
+
code: error.code,
|
|
326
|
+
title: '依赖关系需要处理',
|
|
327
|
+
explanation: '当前目标的依赖证据不能安全通过检查。',
|
|
328
|
+
})));
|
|
329
|
+
const sourceId = parsePluginId(pluginId).sourceId;
|
|
330
|
+
const blockers = [
|
|
331
|
+
...graph.sourceErrors.filter((error) => error.sourceId === sourceId).map((error) => ({
|
|
332
|
+
code: error.code,
|
|
333
|
+
title: '来源依赖关系不可用',
|
|
334
|
+
explanation: '当前来源快照不能安全读取。反向安装记录仍可显示。',
|
|
335
|
+
})),
|
|
336
|
+
...(graphInvalid ? [{
|
|
337
|
+
code: 'dependencyGraphInvalid',
|
|
338
|
+
title: '依赖关系无效',
|
|
339
|
+
explanation: '依赖关系形成环。',
|
|
340
|
+
}] : []),
|
|
341
|
+
...targetBlockers,
|
|
342
|
+
];
|
|
343
|
+
const directCount = dependencyItems.filter((item) => item.relation === 'direct').length;
|
|
344
|
+
const readyCount = dependencyItems.filter((item) => item.aggregateStatus === 'ready').length;
|
|
345
|
+
const missingCount = dependencyItems.filter((item) => item.aggregateStatus === 'notInstalled').length;
|
|
346
|
+
const issueCount = dependencyItems.length - readyCount - missingCount + blockers.length;
|
|
347
|
+
return {
|
|
348
|
+
pluginId,
|
|
349
|
+
summary: {
|
|
350
|
+
directCount,
|
|
351
|
+
transitiveCount: dependencyItems.length - directCount,
|
|
352
|
+
totalCount: dependencyItems.length,
|
|
353
|
+
readyCount,
|
|
354
|
+
missingCount,
|
|
355
|
+
issueCount,
|
|
356
|
+
},
|
|
357
|
+
dependencies: dependencyItems,
|
|
358
|
+
dependents,
|
|
359
|
+
blockers,
|
|
360
|
+
};
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
export function createTuiControllerDependencies(context, progressFeed) {
|
|
364
|
+
const loadStatus = async (signal) => {
|
|
365
|
+
signal.throwIfAborted();
|
|
366
|
+
const packageInfo = await readCliPackageInfo();
|
|
367
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
368
|
+
const result = await statusCommandV4({
|
|
369
|
+
cwd: context.cwd,
|
|
370
|
+
env: context.env,
|
|
371
|
+
cliVersion: packageInfo.version,
|
|
372
|
+
verbose: context.diagnostics.verbose,
|
|
373
|
+
});
|
|
374
|
+
signal.throwIfAborted();
|
|
375
|
+
const configured = await listCatalogSources({ env: context.env });
|
|
376
|
+
signal.throwIfAborted();
|
|
377
|
+
if (result.payload.catalog.configDigest !== configured.configDigest)
|
|
378
|
+
continue;
|
|
379
|
+
const dependencyOverviews = await loadDependencyOverviews({
|
|
380
|
+
context,
|
|
381
|
+
cliVersion: packageInfo.version,
|
|
382
|
+
status: result,
|
|
383
|
+
signal,
|
|
384
|
+
});
|
|
385
|
+
const portablePluginIds = await loadPortablePluginIds({
|
|
386
|
+
context,
|
|
387
|
+
cliVersion: packageInfo.version,
|
|
388
|
+
signal,
|
|
389
|
+
});
|
|
390
|
+
signal.throwIfAborted();
|
|
391
|
+
const statusById = new Map(result.payload.catalog.sources.map((source) => [source.id, source]));
|
|
392
|
+
return {
|
|
393
|
+
payload: result.payload,
|
|
394
|
+
pluginSummaries: result.pluginSummaries,
|
|
395
|
+
dependencyOverviews,
|
|
396
|
+
portablePluginIds,
|
|
397
|
+
sourceDetails: configured.sources.map((source) => {
|
|
398
|
+
const status = statusById.get(source.id);
|
|
399
|
+
return {
|
|
400
|
+
id: source.id,
|
|
401
|
+
type: source.type,
|
|
402
|
+
primary: source.primary,
|
|
403
|
+
locationSummary: projectCatalogSourceLocation(source.type === 'git' ? source.url : source.path),
|
|
404
|
+
...(source.type === 'git' ? {
|
|
405
|
+
refPolicy: source.refPolicy.type,
|
|
406
|
+
...(source.refPolicy.type === 'explicit' ? { explicitRef: source.refPolicy.ref } : {}),
|
|
407
|
+
...(source.subdir ? { subdir: source.subdir } : {}),
|
|
408
|
+
} : {}),
|
|
409
|
+
pluginCount: 0,
|
|
410
|
+
sourceIdentity: source.sourceIdentity,
|
|
411
|
+
requestedRef: status?.requestedRef ?? (source.type === 'path' ? 'path' : 'AW channel'),
|
|
412
|
+
...(status?.resolvedCommit ? { resolvedCommit: status.resolvedCommit } : {}),
|
|
413
|
+
...(status?.catalogVersion ? { catalogVersion: status.catalogVersion } : {}),
|
|
414
|
+
...(status?.channel ? { channel: status.channel } : {}),
|
|
415
|
+
...(status?.freshness ? { freshness: status.freshness } : {}),
|
|
416
|
+
configDigest: configured.configDigest,
|
|
417
|
+
};
|
|
418
|
+
}),
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
throw new TuiOperationBlockedError('operationReviewStale', '状态读取期间来源配置持续变化。请重试。');
|
|
422
|
+
};
|
|
423
|
+
const captureEvidence = async (intent, signal, freshnessPolicy = 'cacheFirst') => {
|
|
424
|
+
if (intent.kind === 'sourceMutation') {
|
|
425
|
+
signal?.throwIfAborted();
|
|
426
|
+
if (intent.action === 'add' && !intent.source
|
|
427
|
+
|| intent.action === 'update' && !intent.update) {
|
|
428
|
+
throw new TuiOperationBlockedError('invalidSourceMutation', '来源操作缺少候选输入。');
|
|
429
|
+
}
|
|
430
|
+
const request = intent.action === 'add'
|
|
431
|
+
? { action: 'add', source: intent.source }
|
|
432
|
+
: intent.action === 'update'
|
|
433
|
+
? { action: 'update', sourceId: intent.sourceId, update: intent.update }
|
|
434
|
+
: { action: intent.action, sourceId: intent.sourceId };
|
|
435
|
+
const preview = await preflightCatalogSourceMutation({
|
|
436
|
+
request,
|
|
437
|
+
cwd: context.cwd,
|
|
438
|
+
env: context.env,
|
|
439
|
+
});
|
|
440
|
+
return {
|
|
441
|
+
catalog: { configDigest: preview.configDigest, compositeDigest: preview.candidateDigest },
|
|
442
|
+
sourceWrite: {
|
|
443
|
+
configDigest: preview.configDigest,
|
|
444
|
+
candidateDigest: preview.candidateDigest,
|
|
445
|
+
...(preview.sourceIdentity ? { sourceIdentity: preview.sourceIdentity } : {}),
|
|
446
|
+
inventoryDigest: digest({ references: preview.references.references, errors: preview.references.errors }),
|
|
447
|
+
referenceCount: preview.references.references.length,
|
|
448
|
+
inventoryComplete: preview.references.errors.length === 0,
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
if (!pluginIntent(intent)) {
|
|
453
|
+
throw new TuiOperationBlockedError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
|
|
454
|
+
}
|
|
455
|
+
signal?.throwIfAborted();
|
|
456
|
+
const packageInfo = await readCliPackageInfo();
|
|
457
|
+
if (intent.kind === 'portableInstall') {
|
|
458
|
+
const portable = await preparePortableInstall({
|
|
459
|
+
selector: intent.pluginId,
|
|
460
|
+
scope: intent.scope,
|
|
461
|
+
...(intent.selectedSkills.length > 0 ? { requestedSkills: intent.selectedSkills } : {}),
|
|
462
|
+
...(intent.requestedAgents ? { requestedAgents: intent.requestedAgents } : {}),
|
|
463
|
+
cwd: context.cwd,
|
|
464
|
+
env: context.env,
|
|
465
|
+
cliVersion: packageInfo.version,
|
|
466
|
+
signal,
|
|
467
|
+
});
|
|
468
|
+
return {
|
|
469
|
+
catalog: {
|
|
470
|
+
configDigest: portable.configDigest,
|
|
471
|
+
compositeDigest: portable.evidenceDigest,
|
|
472
|
+
},
|
|
473
|
+
portable,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
const status = await statusCommandV4({
|
|
477
|
+
plugins: [...new Set([intent.pluginId,
|
|
478
|
+
...(intent.kind === 'pluginWrite' && intent.originIssue?.consumerPluginId
|
|
479
|
+
? [intent.originIssue.consumerPluginId] : [])])],
|
|
480
|
+
...('platform' in intent ? { platform: intent.platform } : {}),
|
|
481
|
+
...(intent.kind !== 'pluginWrite' && intent.scope === 'project'
|
|
482
|
+
? { scope: intent.scope }
|
|
483
|
+
: {}),
|
|
484
|
+
cwd: context.cwd,
|
|
485
|
+
env: context.env,
|
|
486
|
+
cliVersion: packageInfo.version,
|
|
487
|
+
});
|
|
488
|
+
signal?.throwIfAborted();
|
|
489
|
+
if (intent.kind === 'pluginWrite') {
|
|
490
|
+
await assertTypedIssueOrigin(intent, status.payload.targets);
|
|
491
|
+
}
|
|
492
|
+
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
493
|
+
let dependencyPlan;
|
|
494
|
+
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')) {
|
|
498
|
+
const command = {
|
|
499
|
+
install: installWriteCommand,
|
|
500
|
+
upgrade: upgradeWriteCommand,
|
|
501
|
+
reinstall: reinstallWriteCommand,
|
|
502
|
+
}[intent.action];
|
|
503
|
+
const preview = await command([intent.pluginId], {
|
|
504
|
+
cwd: context.cwd,
|
|
505
|
+
platform: intent.platform,
|
|
506
|
+
scope: intent.scope,
|
|
507
|
+
}, {
|
|
508
|
+
...context,
|
|
509
|
+
expectedCatalogConfigDigest: status.payload.catalog.configDigest,
|
|
510
|
+
previewDependencyPlanOnly: true,
|
|
511
|
+
});
|
|
512
|
+
dependencyPlan = preview.dependencyPlan;
|
|
513
|
+
if (!dependencyPlan) {
|
|
514
|
+
throw new TuiOperationBlockedError('dependencyGraphInvalid', '无法建立可信的依赖安装计划。');
|
|
515
|
+
}
|
|
516
|
+
const blocker = dependencyPlan.targets.find((target) => target.action === 'block');
|
|
517
|
+
if (blocker) {
|
|
518
|
+
throw new TuiOperationBlockedError(blocker.errorCode ?? 'dependencyNotReady', `${blocker.errorCode ?? 'dependencyNotReady'}: 依赖安装计划被阻止。`);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const selected = await withResolvedCatalogPlugin({
|
|
522
|
+
selector: intent.pluginId,
|
|
523
|
+
cliVersion: packageInfo.version,
|
|
524
|
+
freshnessPolicy,
|
|
525
|
+
configSnapshot,
|
|
526
|
+
env: context.env,
|
|
527
|
+
...(signal ? { signal } : {}),
|
|
528
|
+
consume: ({ plugin, source }) => ({
|
|
529
|
+
pluginName: plugin.manifest.name,
|
|
530
|
+
source: sourceEvidenceForPlugin(source, plugin.manifest.name),
|
|
531
|
+
}),
|
|
532
|
+
});
|
|
533
|
+
const evidence = {
|
|
534
|
+
catalog: {
|
|
535
|
+
configDigest: status.payload.catalog.configDigest,
|
|
536
|
+
compositeDigest: status.payload.catalog.compositeDigest,
|
|
537
|
+
},
|
|
538
|
+
source: selected.source,
|
|
539
|
+
...(dependencyPlan ? { dependencyPlan } : {}),
|
|
540
|
+
targetFingerprint: digest(status.payload.targets.map((target) => ({
|
|
541
|
+
pluginId: target.pluginId,
|
|
542
|
+
sourceIdentity: target.sourceIdentity,
|
|
543
|
+
platform: target.platform,
|
|
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'))),
|
|
551
|
+
};
|
|
552
|
+
if (intent.kind === 'configSave' || intent.kind === 'configReset') {
|
|
553
|
+
const store = await readPluginConfigStore({
|
|
554
|
+
sourceId: selected.source.sourceId,
|
|
555
|
+
sourceIdentity: selected.source.sourceIdentity,
|
|
556
|
+
pluginName: selected.pluginName,
|
|
557
|
+
scope: intent.scope,
|
|
558
|
+
projectLayer: intent.projectLayer,
|
|
559
|
+
cwd: context.cwd,
|
|
560
|
+
env: context.env,
|
|
561
|
+
});
|
|
562
|
+
evidence.config = {
|
|
563
|
+
scope: intent.scope,
|
|
564
|
+
projectLayer: intent.projectLayer,
|
|
565
|
+
schemaIdentity: selected.source.manifestDigest,
|
|
566
|
+
storeDigest: digest({ exists: store.exists, values: store.values }),
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
return evidence;
|
|
570
|
+
};
|
|
571
|
+
const dependencies = {
|
|
572
|
+
loadStatus,
|
|
573
|
+
async inspectSourceRemoval(_sourceId, signal) {
|
|
574
|
+
signal.throwIfAborted();
|
|
575
|
+
return {
|
|
576
|
+
blocked: false,
|
|
577
|
+
inventoryComplete: true,
|
|
578
|
+
installationCount: 0,
|
|
579
|
+
configCount: 0,
|
|
580
|
+
lifecycleCount: 0,
|
|
581
|
+
marketplaceCount: 0,
|
|
582
|
+
dependencies: [],
|
|
583
|
+
};
|
|
584
|
+
},
|
|
585
|
+
async validateIntent(intent, signal) {
|
|
586
|
+
if (intent.kind === 'sourceMutation') {
|
|
587
|
+
const evidence = await captureEvidence(intent, signal);
|
|
588
|
+
if (evidence.sourceWrite?.configDigest === evidence.sourceWrite?.candidateDigest) {
|
|
589
|
+
throw new TuiOperationBlockedError('sourceNoChanges', '来源没有变化。');
|
|
590
|
+
}
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (intent.kind === 'configSave') {
|
|
594
|
+
const packageInfo = await readCliPackageInfo();
|
|
595
|
+
await withResolvedCatalogPlugin({
|
|
596
|
+
selector: intent.pluginId,
|
|
597
|
+
cliVersion: packageInfo.version,
|
|
598
|
+
freshnessPolicy: 'cacheFirst',
|
|
599
|
+
env: context.env,
|
|
600
|
+
signal,
|
|
601
|
+
consume: async ({ plugin }) => {
|
|
602
|
+
if (!plugin.manifest.config) {
|
|
603
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
604
|
+
}
|
|
605
|
+
await coercePluginConfigUpdates({
|
|
606
|
+
schema: plugin.manifest.config.schema,
|
|
607
|
+
updates: intent.updates ?? {},
|
|
608
|
+
cwd: context.cwd,
|
|
609
|
+
});
|
|
610
|
+
for (const key of intent.removeKeys ?? []) {
|
|
611
|
+
if (!plugin.manifest.config.schema[key]) {
|
|
612
|
+
throw new TuiOperationBlockedError('unknownConfigKey', '设置字段已变化,请重新检查。');
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
});
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
if (intent.kind !== 'pluginWrite')
|
|
620
|
+
return;
|
|
621
|
+
signal.throwIfAborted();
|
|
622
|
+
const packageInfo = await readCliPackageInfo();
|
|
623
|
+
const status = await statusCommandV4({
|
|
624
|
+
plugins: [...new Set([intent.pluginId,
|
|
625
|
+
...(intent.originIssue?.consumerPluginId ? [intent.originIssue.consumerPluginId] : [])])],
|
|
626
|
+
platform: intent.platform,
|
|
627
|
+
cwd: context.cwd,
|
|
628
|
+
env: context.env,
|
|
629
|
+
cliVersion: packageInfo.version,
|
|
630
|
+
});
|
|
631
|
+
signal.throwIfAborted();
|
|
632
|
+
await assertTypedIssueOrigin(intent, status.payload.targets);
|
|
633
|
+
assertIntentIsLegal(intent, status.payload.targets);
|
|
634
|
+
},
|
|
635
|
+
async checkSource(sourceId, signal) {
|
|
636
|
+
const packageInfo = await readCliPackageInfo();
|
|
637
|
+
const configSnapshot = await readCatalogSourcesConfigSnapshot(context.env);
|
|
638
|
+
return withResolvedMultiSourceCatalog({
|
|
639
|
+
cliVersion: packageInfo.version,
|
|
640
|
+
freshnessPolicy: 'forceRemote',
|
|
641
|
+
sourceIds: [sourceId],
|
|
642
|
+
configSnapshot,
|
|
643
|
+
env: context.env,
|
|
644
|
+
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
|
+
});
|
|
655
|
+
},
|
|
656
|
+
captureEvidence,
|
|
657
|
+
logError(_error, code, logContext) {
|
|
658
|
+
return context.debugLogger.log({
|
|
659
|
+
type: 'tui:controller-error',
|
|
660
|
+
level: 'debug',
|
|
661
|
+
target: 'debugLog',
|
|
662
|
+
message: logContext?.privateConfigOperation
|
|
663
|
+
? 'TUI config operation failed.'
|
|
664
|
+
: 'TUI controller operation failed.',
|
|
665
|
+
data: { code },
|
|
666
|
+
});
|
|
667
|
+
},
|
|
668
|
+
async getConfigGroups(pluginId, layer, signal) {
|
|
669
|
+
const packageInfo = await readCliPackageInfo();
|
|
670
|
+
return withResolvedCatalogPlugin({
|
|
671
|
+
selector: pluginId,
|
|
672
|
+
cliVersion: packageInfo.version,
|
|
673
|
+
freshnessPolicy: 'cacheFirst',
|
|
674
|
+
env: context.env,
|
|
675
|
+
signal,
|
|
676
|
+
consume: async ({ plugin }) => {
|
|
677
|
+
if (!plugin.manifest.config) {
|
|
678
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
679
|
+
}
|
|
680
|
+
const read = await resolveConfigRead({
|
|
681
|
+
pluginName: plugin.manifest.name,
|
|
682
|
+
plugin,
|
|
683
|
+
scope: layer.scope,
|
|
684
|
+
projectLayer: layer.projectLayer,
|
|
685
|
+
cwd: context.cwd,
|
|
686
|
+
env: context.env,
|
|
687
|
+
});
|
|
688
|
+
return buildConfigGroups({ schema: plugin.manifest.config, read });
|
|
689
|
+
},
|
|
690
|
+
});
|
|
691
|
+
},
|
|
692
|
+
async getConfigPage(pluginId, layer, signal) {
|
|
693
|
+
const packageInfo = await readCliPackageInfo();
|
|
694
|
+
return withResolvedCatalogPlugin({
|
|
695
|
+
selector: pluginId,
|
|
696
|
+
cliVersion: packageInfo.version,
|
|
697
|
+
freshnessPolicy: 'cacheFirst',
|
|
698
|
+
env: context.env,
|
|
699
|
+
signal,
|
|
700
|
+
consume: async ({ plugin }) => {
|
|
701
|
+
if (!plugin.manifest.config) {
|
|
702
|
+
throw new TuiOperationBlockedError('configSchemaUnavailable', '这个插件没有设置 schema。');
|
|
703
|
+
}
|
|
704
|
+
const read = await resolveConfigRead({
|
|
705
|
+
pluginName: plugin.manifest.name,
|
|
706
|
+
plugin,
|
|
707
|
+
scope: layer.scope,
|
|
708
|
+
projectLayer: layer.projectLayer,
|
|
709
|
+
cwd: context.cwd,
|
|
710
|
+
env: context.env,
|
|
711
|
+
});
|
|
712
|
+
return buildConfigPage({ pluginId, schema: plugin.manifest.config, read });
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
},
|
|
716
|
+
async getConfigResetAvailability(pluginId, layer, signal) {
|
|
717
|
+
signal.throwIfAborted();
|
|
718
|
+
const { sourceId, pluginName } = parsePluginId(pluginId);
|
|
719
|
+
if (!sourceId)
|
|
720
|
+
return { exists: false, sourceIdentityPresent: false };
|
|
721
|
+
const identity = await readNamespacedPluginConfigStoreIdentity({
|
|
722
|
+
sourceId,
|
|
723
|
+
pluginName,
|
|
724
|
+
scope: layer.scope,
|
|
725
|
+
projectLayer: layer.projectLayer,
|
|
726
|
+
cwd: context.cwd,
|
|
727
|
+
env: context.env,
|
|
728
|
+
});
|
|
729
|
+
signal.throwIfAborted();
|
|
730
|
+
if (!identity)
|
|
731
|
+
return { exists: false, sourceIdentityPresent: false };
|
|
732
|
+
const configured = await readCatalogSourcesConfigSnapshot(context.env);
|
|
733
|
+
const source = configured.config.sources.find((entry) => entry.id === sourceId);
|
|
734
|
+
const configuredIdentity = source
|
|
735
|
+
? await calculateCatalogSourceIdentity(source)
|
|
736
|
+
: undefined;
|
|
737
|
+
if (identity.sourceIdentity !== configuredIdentity) {
|
|
738
|
+
return {
|
|
739
|
+
exists: true,
|
|
740
|
+
sourceIdentityPresent: false,
|
|
741
|
+
sourceIdentity: identity.sourceIdentity,
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
return {
|
|
745
|
+
exists: true,
|
|
746
|
+
sourceIdentityPresent: true,
|
|
747
|
+
sourceIdentity: identity.sourceIdentity,
|
|
748
|
+
storeDigest: digest({
|
|
749
|
+
exists: identity.store.exists,
|
|
750
|
+
sourceIdentity: identity.sourceIdentity,
|
|
751
|
+
values: identity.store.values,
|
|
752
|
+
}),
|
|
753
|
+
};
|
|
754
|
+
},
|
|
755
|
+
async executeIntent(intent, expectedEvidence) {
|
|
756
|
+
if (intent.kind === 'portableInstall') {
|
|
757
|
+
if (!expectedEvidence.portable) {
|
|
758
|
+
throw operationReviewStale('确认信息缺少 Portable evidence。');
|
|
759
|
+
}
|
|
760
|
+
const packageInfo = await readCliPackageInfo();
|
|
761
|
+
try {
|
|
762
|
+
return await installPortableSkills({
|
|
763
|
+
selector: intent.pluginId,
|
|
764
|
+
scope: intent.scope,
|
|
765
|
+
requestedSkills: intent.selectedSkills,
|
|
766
|
+
...(intent.requestedAgents ? { requestedAgents: intent.requestedAgents } : {}),
|
|
767
|
+
yes: true,
|
|
768
|
+
cwd: context.cwd,
|
|
769
|
+
env: context.env,
|
|
770
|
+
cliVersion: packageInfo.version,
|
|
771
|
+
expectedEvidenceDigest: expectedEvidence.portable.evidenceDigest,
|
|
772
|
+
onProgress(stage) {
|
|
773
|
+
const phase = stage === 'prepare' ? '检查插件依赖并生成候选'
|
|
774
|
+
: stage === 'add' ? '安装已选择的 Skills' : '验证安装结果';
|
|
775
|
+
progressFeed?.setCurrent({ target: 'Skills CLI', phase }, `Portable Skills:${phase}`);
|
|
776
|
+
},
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
catch (error) {
|
|
780
|
+
if (error instanceof PortableCommandError && error.code === 'reviewStale') {
|
|
781
|
+
throw operationReviewStale('确认后 Portable 安装证据发生变化。');
|
|
782
|
+
}
|
|
783
|
+
throw error;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return withAwHomeMutationLock({
|
|
787
|
+
env: context.env,
|
|
788
|
+
action: async (awHomeMutationToken) => {
|
|
789
|
+
const currentEvidence = await captureEvidence(intent, undefined, 'requireRemote');
|
|
790
|
+
if (operationEvidenceFingerprint(currentEvidence) !== operationEvidenceFingerprint(expectedEvidence)) {
|
|
791
|
+
throw new TuiOperationBlockedError('operationReviewStale', '确认后状态发生变化。');
|
|
792
|
+
}
|
|
793
|
+
await tuiControllerRuntimeTestHooks?.afterMutationEvidenceCapture?.();
|
|
794
|
+
if (intent.kind === 'sourceMutation') {
|
|
795
|
+
const packageInfo = await readCliPackageInfo();
|
|
796
|
+
const runtime = {
|
|
797
|
+
awHomeMutationToken,
|
|
798
|
+
onProgress: async (event) => {
|
|
799
|
+
const phase = SOURCE_PROGRESS_PHASES[event.stage];
|
|
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 });
|
|
812
|
+
}
|
|
813
|
+
if (intent.action === 'update' && intent.update) {
|
|
814
|
+
return updateCatalogSourceCommand({ ...common, sourceId: intent.sourceId, update: intent.update, cliVersion: packageInfo.version });
|
|
815
|
+
}
|
|
816
|
+
if (intent.action === 'setPrimary') {
|
|
817
|
+
return setPrimaryCatalogSourceCommand({ ...common, sourceId: intent.sourceId });
|
|
818
|
+
}
|
|
819
|
+
if (intent.action === 'remove') {
|
|
820
|
+
return removeCatalogSourceCommand({ ...common, sourceId: intent.sourceId });
|
|
821
|
+
}
|
|
822
|
+
throw new TuiOperationBlockedError('invalidSourceMutation', '来源操作缺少候选输入。');
|
|
823
|
+
}
|
|
824
|
+
if (intent.kind === 'pluginWrite') {
|
|
825
|
+
const options = {
|
|
826
|
+
cwd: context.cwd,
|
|
827
|
+
platform: intent.platform,
|
|
828
|
+
scope: intent.scope,
|
|
829
|
+
...(intent.action === 'cleanup' ? { force: intent.force === true } : {}),
|
|
830
|
+
};
|
|
831
|
+
const command = {
|
|
832
|
+
install: installWriteCommand,
|
|
833
|
+
upgrade: upgradeWriteCommand,
|
|
834
|
+
reinstall: reinstallWriteCommand,
|
|
835
|
+
uninstall: uninstallWriteCommand,
|
|
836
|
+
cleanup: cleanupWriteCommand,
|
|
837
|
+
}[intent.action];
|
|
838
|
+
const currentSource = currentEvidence.source;
|
|
839
|
+
if (!expectedEvidence.source || !currentSource) {
|
|
840
|
+
throw new TuiOperationBlockedError('operationReviewStale', '确认信息缺少来源身份。');
|
|
841
|
+
}
|
|
842
|
+
const result = await command([intent.pluginId], options, {
|
|
843
|
+
...context,
|
|
844
|
+
awHomeMutationToken,
|
|
845
|
+
expectedCatalogConfigDigest: expectedEvidence.catalog.configDigest,
|
|
846
|
+
reviewPreflight: (actual) => assertSourceEvidenceMatches(currentSource, actual),
|
|
847
|
+
});
|
|
848
|
+
throwIfWriteReviewStale(result);
|
|
849
|
+
return result;
|
|
850
|
+
}
|
|
851
|
+
if (intent.kind === 'configSave' || intent.kind === 'configReset') {
|
|
852
|
+
const currentSource = currentEvidence.source;
|
|
853
|
+
if (!currentSource) {
|
|
854
|
+
throw operationReviewStale('确认信息缺少来源身份。');
|
|
855
|
+
}
|
|
856
|
+
const packageInfo = await readCliPackageInfo();
|
|
857
|
+
return withResolvedCatalogPlugin({
|
|
858
|
+
selector: intent.pluginId,
|
|
859
|
+
cliVersion: packageInfo.version,
|
|
860
|
+
freshnessPolicy: 'requireRemote',
|
|
861
|
+
env: context.env,
|
|
862
|
+
consume: async ({ plugin, source }) => {
|
|
863
|
+
assertSourceEvidenceMatches(currentSource, sourceEvidenceForPlugin(source, plugin.manifest.name));
|
|
864
|
+
const result = intent.kind === 'configSave'
|
|
865
|
+
? await applyPluginConfigWrite({
|
|
866
|
+
plugin,
|
|
867
|
+
pluginName: plugin.manifest.name,
|
|
868
|
+
scope: intent.scope,
|
|
869
|
+
projectLayer: intent.projectLayer,
|
|
870
|
+
cwd: context.cwd,
|
|
871
|
+
env: context.env,
|
|
872
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
873
|
+
rebuildRuntime: { ...context, awHomeMutationToken },
|
|
874
|
+
awHomeMutationToken,
|
|
875
|
+
request: { updates: intent.updates, removeKeys: intent.removeKeys },
|
|
876
|
+
})
|
|
877
|
+
: await resetPluginConfigWithHelper({
|
|
878
|
+
plugin,
|
|
879
|
+
pluginName: plugin.manifest.name,
|
|
880
|
+
scope: intent.scope,
|
|
881
|
+
projectLayer: intent.projectLayer,
|
|
882
|
+
cwd: context.cwd,
|
|
883
|
+
env: context.env,
|
|
884
|
+
nativeCliRunner: context.nativeCliRunner,
|
|
885
|
+
rebuildRuntime: { ...context, awHomeMutationToken },
|
|
886
|
+
awHomeMutationToken,
|
|
887
|
+
});
|
|
888
|
+
return result;
|
|
889
|
+
},
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
throw new TuiOperationBlockedError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
|
|
893
|
+
},
|
|
894
|
+
});
|
|
895
|
+
},
|
|
896
|
+
};
|
|
897
|
+
return dependencies;
|
|
898
|
+
}
|
|
899
|
+
export function createConsoleTuiV4Controller(context, progressFeed) {
|
|
900
|
+
return new TuiController(createTuiControllerDependencies(context, progressFeed), progressFeed);
|
|
901
|
+
}
|
|
902
|
+
//# sourceMappingURL=controller-runtime.js.map
|