@lesliechan721/aw 0.1.0-beta.8 → 0.1.0-beta.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-config.mjs +100 -501
- package/dist/authoring/assets/aw-config.mjs.map +1 -1
- package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
- package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.mjs +17 -40
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +74 -98
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +79 -92
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +103 -127
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs +2 -2
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +490 -2841
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-skill.mjs +1 -1
- package/dist/native-runtime/reader-runtime.mjs +34 -0
- package/dist/native-runtime/reader.d.mts +6 -0
- package/dist/native-runtime/reader.mjs +11 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +30 -0
- package/dist/scripts/aw-skill-eval-materializer.js +278 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +1 -0
- package/dist/scripts/bundle-plugins.js +27 -8
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +7 -8
- package/dist/scripts/plugin-staging.js +16 -15
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/plugin-test-reporter.d.mts +2 -0
- package/dist/scripts/plugin-test-reporter.mjs +21 -0
- package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +5 -0
- package/dist/scripts/test-plugin-scripts.js +273 -78
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/scripts/test-workers.d.mts +24 -0
- package/dist/scripts/test-workers.mjs +59 -0
- package/dist/scripts/test-workers.mjs.map +1 -0
- package/dist/src/adapters/helpers.d.ts +7 -0
- package/dist/src/adapters/helpers.js.map +1 -1
- package/dist/src/authoring/workspace-commands.d.ts +5 -1
- package/dist/src/authoring/workspace-commands.js +7 -2
- package/dist/src/authoring/workspace-commands.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +2 -2
- package/dist/src/commands/aw-capabilities.js +41 -29
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/catalog-dev-source.d.ts +58 -13
- package/dist/src/commands/catalog-dev-source.js +549 -305
- package/dist/src/commands/catalog-dev-source.js.map +1 -1
- package/dist/src/commands/catalog-generation.d.ts +14 -19
- package/dist/src/commands/catalog-generation.js +5 -10
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/catalog-publication-inspection.d.ts +70 -30
- package/dist/src/commands/catalog-publication-inspection.js +511 -91
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
- package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
- package/dist/src/commands/catalog-publication-journal.js +292 -0
- package/dist/src/commands/catalog-publication-journal.js.map +1 -0
- package/dist/src/commands/catalog-publication-target.d.ts +2 -1
- package/dist/src/commands/catalog-publication-target.js +37 -2
- package/dist/src/commands/catalog-publication-target.js.map +1 -1
- package/dist/src/commands/catalog-publish.d.ts +82 -15
- package/dist/src/commands/catalog-publish.js +722 -219
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +55 -35
- package/dist/src/commands/catalog-source.js +298 -148
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-status.d.ts +6 -26
- package/dist/src/commands/catalog-status.js +9 -147
- package/dist/src/commands/catalog-status.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +104 -0
- package/dist/src/commands/catalog-store.js +685 -0
- package/dist/src/commands/catalog-store.js.map +1 -0
- package/dist/src/commands/catalog-workspace-resolution.d.ts +17 -0
- package/dist/src/commands/catalog-workspace-resolution.js +57 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.js +32 -20
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
- package/dist/src/commands/dependency-operation-plan.js +289 -7
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.d.ts +4 -0
- package/dist/src/commands/deployment-confirmation.js +20 -0
- package/dist/src/commands/deployment-confirmation.js.map +1 -0
- package/dist/src/commands/init.d.ts +5 -11
- package/dist/src/commands/init.js +30 -51
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +32 -0
- package/dist/src/commands/intent-command.js +171 -0
- package/dist/src/commands/intent-command.js.map +1 -0
- package/dist/src/commands/managed-commands.d.ts +35 -0
- package/dist/src/commands/managed-commands.js +361 -0
- package/dist/src/commands/managed-commands.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +46 -0
- package/dist/src/commands/offline-cleanup-evidence.js +158 -10
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +190 -0
- package/dist/src/commands/operation-plan.js +99 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +47 -0
- package/dist/src/commands/operation-planner.js +142 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +16 -20
- package/dist/src/commands/options.js +94 -41
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +88 -45
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +8 -0
- package/dist/src/commands/public-config-confirmation.js +56 -0
- package/dist/src/commands/public-config-confirmation.js.map +1 -0
- package/dist/src/commands/public-interruption.d.ts +9 -0
- package/dist/src/commands/public-interruption.js +23 -0
- package/dist/src/commands/public-interruption.js.map +1 -0
- package/dist/src/commands/public-lifecycle-result.d.ts +102 -0
- package/dist/src/commands/public-lifecycle-result.js +307 -0
- package/dist/src/commands/public-lifecycle-result.js.map +1 -0
- package/dist/src/commands/public-lifecycle.d.ts +28 -0
- package/dist/src/commands/public-lifecycle.js +492 -0
- package/dist/src/commands/public-lifecycle.js.map +1 -0
- package/dist/src/commands/public-plugin-query.d.ts +16 -0
- package/dist/src/commands/public-plugin-query.js +193 -0
- package/dist/src/commands/public-plugin-query.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +166 -28
- package/dist/src/commands/rebuild-command.js +3745 -813
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +137 -25
- package/dist/src/commands/rebuild-integration.js +1343 -2535
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +73 -22
- package/dist/src/commands/rebuild-operations.js +313 -216
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +62 -0
- package/dist/src/commands/rebuild-platform-integration.js +1317 -0
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
- package/dist/src/commands/reconcile-operation-plan.js +47 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-inspection.d.ts +60 -0
- package/dist/src/commands/review-inspection.js +436 -0
- package/dist/src/commands/review-inspection.js.map +1 -0
- package/dist/src/commands/review-preparation.d.ts +51 -0
- package/dist/src/commands/review-preparation.js +400 -0
- package/dist/src/commands/review-preparation.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +6 -6
- package/dist/src/commands/runtime.js +44 -24
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +41 -0
- package/dist/src/commands/skill-eval.js +407 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +319 -0
- package/dist/src/commands/status-v6.js +2979 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/targets-command.d.ts +38 -0
- package/dist/src/commands/targets-command.js +182 -0
- package/dist/src/commands/targets-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +8 -5
- package/dist/src/commands/wizard.js +7 -4
- package/dist/src/commands/wizard.js.map +1 -1
- package/dist/src/commands/write-commands.d.ts +9 -3
- package/dist/src/commands/write-commands.js +143 -85
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +6 -6
- package/dist/src/constants.js +6 -6
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +70 -0
- package/dist/src/eval/manifest-v1.js +358 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +7 -2
- package/dist/src/generators/local-plugin.js +313 -389
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +5 -2
- package/dist/src/generators/permissions.js +28 -15
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +2 -31
- package/dist/src/index.js +1666 -1827
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.d.ts +63 -0
- package/dist/src/intent/deployment-preferences.js +170 -0
- package/dist/src/intent/deployment-preferences.js.map +1 -0
- package/dist/src/intent/diagnostics.d.ts +11 -0
- package/dist/src/intent/diagnostics.js +14 -0
- package/dist/src/intent/diagnostics.js.map +1 -0
- package/dist/src/intent/intent-codec.d.ts +19 -0
- package/dist/src/intent/intent-codec.js +117 -0
- package/dist/src/intent/intent-codec.js.map +1 -0
- package/dist/src/intent/intent-store.d.ts +43 -0
- package/dist/src/intent/intent-store.js +118 -0
- package/dist/src/intent/intent-store.js.map +1 -0
- package/dist/src/intent/scope-context.d.ts +33 -0
- package/dist/src/intent/scope-context.js +149 -0
- package/dist/src/intent/scope-context.js.map +1 -0
- package/dist/src/intent/work-context.d.ts +13 -0
- package/dist/src/intent/work-context.js +22 -0
- package/dist/src/intent/work-context.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +47 -46
- package/dist/src/output/command-receipt.js +286 -79
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/model.d.ts +3 -11
- package/dist/src/output/native-consent.d.ts +2 -0
- package/dist/src/output/native-consent.js +5 -0
- package/dist/src/output/native-consent.js.map +1 -0
- package/dist/src/output/public-result.d.ts +49 -0
- package/dist/src/output/public-result.js +240 -0
- package/dist/src/output/public-result.js.map +1 -0
- package/dist/src/output/rebuild-progress.js +20 -15
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.d.ts +7 -0
- package/dist/src/output/receipt-projection.js +592 -0
- package/dist/src/output/receipt-projection.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +12 -0
- package/dist/src/platforms/capabilities.js +205 -0
- package/dist/src/platforms/capabilities.js.map +1 -0
- package/dist/src/platforms/contracts.d.ts +358 -0
- package/dist/src/platforms/contracts.js +2 -0
- package/dist/src/platforms/contracts.js.map +1 -0
- package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
- package/dist/src/platforms/cursor-workspace-hook.js +198 -0
- package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
- package/dist/src/platforms/discovery.d.ts +91 -0
- package/dist/src/platforms/discovery.js +653 -0
- package/dist/src/platforms/discovery.js.map +1 -0
- package/dist/src/platforms/gemini-activation.d.ts +36 -0
- package/dist/src/platforms/gemini-activation.js +331 -0
- package/dist/src/platforms/gemini-activation.js.map +1 -0
- package/dist/src/platforms/gemini-consent.d.ts +8 -0
- package/dist/src/platforms/gemini-consent.js +81 -0
- package/dist/src/platforms/gemini-consent.js.map +1 -0
- package/dist/src/platforms/identity.d.ts +4 -0
- package/dist/src/platforms/identity.js +22 -0
- package/dist/src/platforms/identity.js.map +1 -0
- package/dist/src/platforms/inspection-grok.d.ts +4 -0
- package/dist/src/platforms/inspection-grok.js +212 -0
- package/dist/src/platforms/inspection-grok.js.map +1 -0
- package/dist/src/platforms/inspection-native.d.ts +6 -0
- package/dist/src/platforms/inspection-native.js +406 -0
- package/dist/src/platforms/inspection-native.js.map +1 -0
- package/dist/src/platforms/inspection-opencode.d.ts +4 -0
- package/dist/src/platforms/inspection-opencode.js +98 -0
- package/dist/src/platforms/inspection-opencode.js.map +1 -0
- package/dist/src/platforms/inspection-pi.d.ts +3 -0
- package/dist/src/platforms/inspection-pi.js +282 -0
- package/dist/src/platforms/inspection-pi.js.map +1 -0
- package/dist/src/platforms/inspection-query.d.ts +12 -0
- package/dist/src/platforms/inspection-query.js +96 -0
- package/dist/src/platforms/inspection-query.js.map +1 -0
- package/dist/src/platforms/inspection.d.ts +17 -0
- package/dist/src/platforms/inspection.js +227 -0
- package/dist/src/platforms/inspection.js.map +1 -0
- package/dist/src/platforms/layout.d.ts +21 -0
- package/dist/src/platforms/layout.js +239 -0
- package/dist/src/platforms/layout.js.map +1 -0
- package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
- package/dist/src/platforms/lifecycle-native-services.js +147 -0
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
- package/dist/src/platforms/lifecycle-native.d.ts +13 -0
- package/dist/src/platforms/lifecycle-native.js +283 -0
- package/dist/src/platforms/lifecycle-native.js.map +1 -0
- package/dist/src/platforms/lifecycle.d.ts +25 -0
- package/dist/src/platforms/lifecycle.js +494 -0
- package/dist/src/platforms/lifecycle.js.map +1 -0
- package/dist/src/platforms/managed-command-placement.d.ts +8 -0
- package/dist/src/platforms/managed-command-placement.js +79 -0
- package/dist/src/platforms/managed-command-placement.js.map +1 -0
- package/dist/src/platforms/projection-code-extension.d.ts +8 -0
- package/dist/src/platforms/projection-code-extension.js +121 -0
- package/dist/src/platforms/projection-code-extension.js.map +1 -0
- package/dist/src/platforms/projection-command-resources.d.ts +7 -0
- package/dist/src/platforms/projection-command-resources.js +74 -0
- package/dist/src/platforms/projection-command-resources.js.map +1 -0
- package/dist/src/platforms/projection-files.d.ts +27 -0
- package/dist/src/platforms/projection-files.js +111 -0
- package/dist/src/platforms/projection-files.js.map +1 -0
- package/dist/src/platforms/projection-marketplace.d.ts +19 -0
- package/dist/src/platforms/projection-marketplace.js +42 -0
- package/dist/src/platforms/projection-marketplace.js.map +1 -0
- package/dist/src/platforms/projection.d.ts +10 -0
- package/dist/src/platforms/projection.js +446 -0
- package/dist/src/platforms/projection.js.map +1 -0
- package/dist/src/platforms/registry.d.ts +4 -0
- package/dist/src/platforms/registry.js +30 -0
- package/dist/src/platforms/registry.js.map +1 -0
- package/dist/src/platforms/supplement-layout.d.ts +16 -0
- package/dist/src/platforms/supplement-layout.js +31 -0
- package/dist/src/platforms/supplement-layout.js.map +1 -0
- package/dist/src/platforms/supplement-state.d.ts +13 -0
- package/dist/src/platforms/supplement-state.js +82 -0
- package/dist/src/platforms/supplement-state.js.map +1 -0
- package/dist/src/portable/commands.d.ts +58 -11
- package/dist/src/portable/commands.js +94 -350
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/historical-materialization.d.ts +22 -0
- package/dist/src/portable/historical-materialization.js +124 -0
- package/dist/src/portable/historical-materialization.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +24 -4
- package/dist/src/portable/materializer.js +189 -259
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery-layout.d.ts +17 -0
- package/dist/src/portable/recovery-layout.js +42 -0
- package/dist/src/portable/recovery-layout.js.map +1 -0
- package/dist/src/portable/recovery.d.ts +153 -0
- package/dist/src/portable/recovery.js +367 -0
- package/dist/src/portable/recovery.js.map +1 -0
- package/dist/src/portable/writer.d.ts +67 -0
- package/dist/src/portable/writer.js +321 -0
- package/dist/src/portable/writer.js.map +1 -0
- package/dist/src/recovery/coordinator.d.ts +141 -0
- package/dist/src/recovery/coordinator.js +1254 -0
- package/dist/src/recovery/coordinator.js.map +1 -0
- package/dist/src/recovery/demand.d.ts +51 -0
- package/dist/src/recovery/demand.js +159 -0
- package/dist/src/recovery/demand.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +25 -0
- package/dist/src/recovery/joint-coordinator.js +991 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -0
- package/dist/src/recovery/joint-demand.d.ts +50 -0
- package/dist/src/recovery/joint-demand.js +197 -0
- package/dist/src/recovery/joint-demand.js.map +1 -0
- package/dist/src/recovery/performance.d.ts +4 -0
- package/dist/src/recovery/performance.js +26 -0
- package/dist/src/recovery/performance.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +98 -0
- package/dist/src/recovery/receipt.js +2 -0
- package/dist/src/recovery/receipt.js.map +1 -0
- package/dist/src/recovery/retirement.d.ts +47 -0
- package/dist/src/recovery/retirement.js +469 -0
- package/dist/src/recovery/retirement.js.map +1 -0
- package/dist/src/recovery/status.d.ts +126 -0
- package/dist/src/recovery/status.js +1073 -0
- package/dist/src/recovery/status.js.map +1 -0
- package/dist/src/recovery/types.d.ts +85 -0
- package/dist/src/recovery/types.js +2 -0
- package/dist/src/recovery/types.js.map +1 -0
- package/dist/src/review/eval-source-input.d.ts +43 -0
- package/dist/src/review/eval-source-input.js +207 -0
- package/dist/src/review/eval-source-input.js.map +1 -0
- package/dist/src/review/platform-profile.d.ts +3 -0
- package/dist/src/review/platform-profile.js +14 -0
- package/dist/src/review/platform-profile.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +20 -0
- package/dist/src/review/review-profile.js +276 -0
- package/dist/src/review/review-profile.js.map +1 -0
- package/dist/src/review/review-selection.d.ts +20 -0
- package/dist/src/review/review-selection.js +495 -0
- package/dist/src/review/review-selection.js.map +1 -0
- package/dist/src/review/review-types.d.ts +71 -0
- package/dist/src/review/review-types.js +16 -0
- package/dist/src/review/review-types.js.map +1 -0
- package/dist/src/review/skill-materialization.d.ts +62 -0
- package/dist/src/review/skill-materialization.js +205 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +201 -0
- package/dist/src/review/source-binding.js +773 -0
- package/dist/src/review/source-binding.js.map +1 -0
- package/dist/src/tui/agent-management.d.ts +23 -0
- package/dist/src/tui/agent-management.js +319 -0
- package/dist/src/tui/agent-management.js.map +1 -0
- package/dist/src/tui/agent-settings.d.ts +47 -0
- package/dist/src/tui/agent-settings.js +97 -0
- package/dist/src/tui/agent-settings.js.map +1 -0
- package/dist/src/tui/catalog-freshness.d.ts +1 -0
- package/dist/src/tui/catalog-freshness.js +2 -0
- package/dist/src/tui/catalog-freshness.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +18 -53
- package/dist/src/tui/catalog-generation.js +136 -224
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
- package/dist/src/tui/catalog-sources/projection.js +17 -0
- package/dist/src/tui/catalog-sources/projection.js.map +1 -0
- package/dist/src/tui/catalog-sources/review.d.ts +3 -0
- package/dist/src/tui/catalog-sources/review.js +13 -0
- package/dist/src/tui/catalog-sources/review.js.map +1 -0
- package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
- package/dist/src/tui/catalog-sources/screens.js +40 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +32 -0
- package/dist/src/tui/catalog-sources/session.js +300 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +54 -0
- package/dist/src/tui/catalog-sources/types.js +2 -0
- package/dist/src/tui/catalog-sources/types.js.map +1 -0
- package/dist/src/tui/catalog-store-task.d.ts +16 -0
- package/dist/src/tui/catalog-store-task.js +19 -0
- package/dist/src/tui/catalog-store-task.js.map +1 -0
- package/dist/src/tui/clipboard.d.ts +13 -0
- package/dist/src/tui/clipboard.js +95 -0
- package/dist/src/tui/clipboard.js.map +1 -0
- package/dist/src/tui/components.d.ts +113 -3
- package/dist/src/tui/components.js +201 -36
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +29 -0
- package/dist/src/tui/config-array-draft.js +48 -0
- package/dist/src/tui/config-array-draft.js.map +1 -0
- package/dist/src/tui/config-leaf-editor.d.ts +43 -0
- package/dist/src/tui/config-leaf-editor.js +224 -0
- package/dist/src/tui/config-leaf-editor.js.map +1 -0
- package/dist/src/tui/config-references.d.ts +38 -0
- package/dist/src/tui/config-references.js +82 -0
- package/dist/src/tui/config-references.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +20 -0
- package/dist/src/tui/config-value-presentation.js +104 -0
- package/dist/src/tui/config-value-presentation.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +13 -4
- package/dist/src/tui/console-app-v4.js +9764 -2210
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.d.ts +13 -0
- package/dist/src/tui/content-item-card.js +51 -0
- package/dist/src/tui/content-item-card.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +7 -4
- package/dist/src/tui/controller-runtime.js +2064 -779
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +669 -106
- package/dist/src/tui/controller.js +3617 -971
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/dependency-graph-view.d.ts +39 -0
- package/dist/src/tui/dependency-graph-view.js +121 -0
- package/dist/src/tui/dependency-graph-view.js.map +1 -0
- package/dist/src/tui/dependency-graph.d.ts +81 -0
- package/dist/src/tui/dependency-graph.js +452 -0
- package/dist/src/tui/dependency-graph.js.map +1 -0
- package/dist/src/tui/deployment-view.d.ts +10 -0
- package/dist/src/tui/deployment-view.js +108 -0
- package/dist/src/tui/deployment-view.js.map +1 -0
- package/dist/src/tui/diagnostic-projection.d.ts +23 -0
- package/dist/src/tui/diagnostic-projection.js +595 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +6 -3
- package/dist/src/tui/diagnostics.js +14 -2
- package/dist/src/tui/diagnostics.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +55 -0
- package/dist/src/tui/entity-cards.js +298 -0
- package/dist/src/tui/entity-cards.js.map +1 -0
- package/dist/src/tui/glossary.d.ts +25 -0
- package/dist/src/tui/glossary.js +72 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/index.d.ts +6 -2
- package/dist/src/tui/index.js +5 -2
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/input-display.d.ts +1 -0
- package/dist/src/tui/input-display.js +23 -1
- package/dist/src/tui/input-display.js.map +1 -1
- package/dist/src/tui/keys.d.ts +44 -0
- package/dist/src/tui/keys.js +43 -15
- package/dist/src/tui/keys.js.map +1 -1
- package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
- package/dist/src/tui/lifecycle-action-view.js +36 -0
- package/dist/src/tui/lifecycle-action-view.js.map +1 -0
- package/dist/src/tui/model.d.ts +243 -45
- package/dist/src/tui/model.js +1402 -415
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
- package/dist/src/tui/operation-diagnostic-screens.js +72 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +82 -0
- package/dist/src/tui/operation-history.js +136 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +28 -0
- package/dist/src/tui/operation-review-planner.js +1396 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/plugin-content.d.ts +33 -0
- package/dist/src/tui/plugin-content.js +245 -0
- package/dist/src/tui/plugin-content.js.map +1 -0
- package/dist/src/tui/plugin-detail.d.ts +72 -0
- package/dist/src/tui/plugin-detail.js +260 -0
- package/dist/src/tui/plugin-detail.js.map +1 -0
- package/dist/src/tui/plugin-write-task.d.ts +69 -0
- package/dist/src/tui/plugin-write-task.js +286 -0
- package/dist/src/tui/plugin-write-task.js.map +1 -0
- package/dist/src/tui/prompt.js +4 -15
- package/dist/src/tui/prompt.js.map +1 -1
- package/dist/src/tui/query-header.d.ts +30 -0
- package/dist/src/tui/query-header.js +40 -0
- package/dist/src/tui/query-header.js.map +1 -0
- package/dist/src/tui/reader.d.ts +38 -0
- package/dist/src/tui/reader.js +49 -0
- package/dist/src/tui/reader.js.map +1 -0
- package/dist/src/tui/router.d.ts +186 -35
- package/dist/src/tui/router.js +338 -50
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +45 -0
- package/dist/src/tui/scoped-flow.js +96 -0
- package/dist/src/tui/scoped-flow.js.map +1 -0
- package/dist/src/tui/scoped-inventory.d.ts +126 -0
- package/dist/src/tui/scoped-inventory.js +258 -0
- package/dist/src/tui/scoped-inventory.js.map +1 -0
- package/dist/src/tui/screen-registry.d.ts +701 -0
- package/dist/src/tui/screen-registry.js +226 -0
- package/dist/src/tui/screen-registry.js.map +1 -0
- package/dist/src/tui/session-console-app.d.ts +6 -0
- package/dist/src/tui/session-console-app.js +13 -0
- package/dist/src/tui/session-console-app.js.map +1 -0
- package/dist/src/tui/session-host.d.ts +45 -0
- package/dist/src/tui/session-host.js +219 -0
- package/dist/src/tui/session-host.js.map +1 -0
- package/dist/src/tui/source-detail-card.d.ts +29 -0
- package/dist/src/tui/source-detail-card.js +45 -0
- package/dist/src/tui/source-detail-card.js.map +1 -0
- package/dist/src/tui/theme.d.ts +12 -0
- package/dist/src/tui/theme.js +12 -0
- package/dist/src/tui/theme.js.map +1 -1
- package/dist/src/tui/viewport.d.ts +1 -0
- package/dist/src/tui/viewport.js +23 -0
- package/dist/src/tui/viewport.js.map +1 -1
- package/dist/src/tui/wizard.js +37 -13
- package/dist/src/tui/wizard.js.map +1 -1
- package/dist/src/types.d.ts +220 -118
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +13 -4
- package/dist/src/utils/agent-version.js +27 -4
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +33 -7
- package/dist/src/utils/artifact-plan.js +115 -430
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +114 -83
- package/dist/src/utils/artifact-renderer.js +213 -364
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +44 -0
- package/dist/src/utils/artifact-request.js +80 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +6 -2
- package/dist/src/utils/artifact-sources.js +17 -0
- package/dist/src/utils/artifact-sources.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +57 -173
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
- package/dist/src/utils/catalog-capability-projection.js +14 -0
- package/dist/src/utils/catalog-capability-projection.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +2 -2
- package/dist/src/utils/catalog-digests.js +7 -18
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-generation-error.d.ts +5 -1
- package/dist/src/utils/catalog-generation-error.js +14 -0
- package/dist/src/utils/catalog-generation-error.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +36 -5
- package/dist/src/utils/catalog-generation-resolver.js +221 -77
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +159 -28
- package/dist/src/utils/catalog-generation-service.js +1186 -525
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.d.ts +9 -0
- package/dist/src/utils/catalog-generation-state.js +97 -106
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +38 -24
- package/dist/src/utils/catalog-generation-store.js +337 -272
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
- package/dist/src/utils/{catalog-manifest-v5.js → catalog-manifest-v7.js} +23 -35
- package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
- package/dist/src/utils/catalog-operation-context.d.ts +6 -14
- package/dist/src/utils/catalog-operation-context.js +69 -169
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-public-error.js +8 -4
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +7 -3
- package/dist/src/utils/catalog-runtime-projection.js +5 -40
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +2 -2
- package/dist/src/utils/catalog-source-impact.d.ts +21 -0
- package/dist/src/utils/catalog-source-impact.js +344 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +23 -2
- package/dist/src/utils/catalog-source-references.js +456 -382
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +14 -1
- package/dist/src/utils/catalog-sources.js +178 -18
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/codex-config.d.ts +2 -0
- package/dist/src/utils/codex-config.js +22 -1
- package/dist/src/utils/codex-config.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
- package/dist/src/utils/codex-executable-discovery.js +431 -0
- package/dist/src/utils/codex-executable-discovery.js.map +1 -0
- package/dist/src/utils/codex-manager.d.ts +47 -18
- package/dist/src/utils/codex-manager.js +88 -622
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
- package/dist/src/utils/codex-marketplace-path.js +45 -0
- package/dist/src/utils/codex-marketplace-path.js.map +1 -0
- package/dist/src/utils/codex-native-observation.d.ts +49 -0
- package/dist/src/utils/codex-native-observation.js +169 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -0
- package/dist/src/utils/codex-reconciler.d.ts +123 -0
- package/dist/src/utils/codex-reconciler.js +322 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +45 -0
- package/dist/src/utils/codex-shared-native.js +122 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +4 -3
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-skills-root.d.ts +4 -0
- package/dist/src/utils/codex-skills-root.js +25 -0
- package/dist/src/utils/codex-skills-root.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +49 -0
- package/dist/src/utils/codex-surface-analysis.js +220 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/component-command-preparation.d.ts +34 -0
- package/dist/src/utils/component-command-preparation.js +228 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -0
- package/dist/src/utils/component-resources.d.ts +51 -0
- package/dist/src/utils/component-resources.js +322 -0
- package/dist/src/utils/component-resources.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
- package/dist/src/utils/dynamic-skill-tree.js +32 -9
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +16 -0
- package/dist/src/utils/git-catalog-provider.js +167 -120
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +17 -12
- package/dist/src/utils/local-marketplace.js +85 -195
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-closure.d.ts +3 -0
- package/dist/src/utils/managed-command-closure.js +35 -0
- package/dist/src/utils/managed-command-closure.js.map +1 -0
- package/dist/src/utils/managed-command-evidence.d.ts +7 -0
- package/dist/src/utils/managed-command-evidence.js +10 -0
- package/dist/src/utils/managed-command-evidence.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +124 -0
- package/dist/src/utils/managed-command-materialization.js +369 -0
- package/dist/src/utils/managed-command-materialization.js.map +1 -0
- package/dist/src/utils/managed-command-preparation.d.ts +67 -0
- package/dist/src/utils/managed-command-preparation.js +146 -0
- package/dist/src/utils/managed-command-preparation.js.map +1 -0
- package/dist/src/utils/managed-command-review.d.ts +26 -0
- package/dist/src/utils/managed-command-review.js +68 -0
- package/dist/src/utils/managed-command-review.js.map +1 -0
- package/dist/src/utils/managed-command-runtime.d.ts +33 -0
- package/dist/src/utils/managed-command-runtime.js +121 -0
- package/dist/src/utils/managed-command-runtime.js.map +1 -0
- package/dist/src/utils/managed-command-store.d.ts +143 -0
- package/dist/src/utils/managed-command-store.js +665 -0
- package/dist/src/utils/managed-command-store.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +1 -3
- package/dist/src/utils/manifest.js +1 -3
- package/dist/src/utils/manifest.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +1 -10
- package/dist/src/utils/multi-source-catalog.js +9 -175
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +74 -5
- package/dist/src/utils/native-cli.js +479 -31
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-demand.d.ts +29 -0
- package/dist/src/utils/native-demand.js +4 -0
- package/dist/src/utils/native-demand.js.map +1 -0
- package/dist/src/utils/native-tool-context.d.ts +14 -0
- package/dist/src/utils/native-tool-context.js +38 -0
- package/dist/src/utils/native-tool-context.js.map +1 -0
- package/dist/src/utils/native-tool-review.d.ts +18 -0
- package/dist/src/utils/native-tool-review.js +116 -0
- package/dist/src/utils/native-tool-review.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +0 -1
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +103 -21
- package/dist/src/utils/ownership.js +232 -210
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/path-catalog-provider.d.ts +1 -1
- package/dist/src/utils/path-catalog-provider.js +47 -62
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -2
- package/dist/src/utils/paths.js +5 -3
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +45 -0
- package/dist/src/utils/platform-empty-state.js +159 -0
- package/dist/src/utils/platform-empty-state.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -1
- package/dist/src/utils/platform-support.js +1 -1
- package/dist/src/utils/platform-support.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +64 -0
- package/dist/src/utils/plugin-config-impact.js +307 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-references.d.ts +89 -0
- package/dist/src/utils/plugin-config-references.js +335 -0
- package/dist/src/utils/plugin-config-references.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +109 -27
- package/dist/src/utils/plugin-config-write.js +1242 -348
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +187 -109
- package/dist/src/utils/plugin-config.js +916 -1147
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-dependencies.d.ts +1 -1
- package/dist/src/utils/plugin-dependencies.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +78 -127
- package/dist/src/utils/plugin-scripts.js +566 -524
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-lock.js +14 -5
- package/dist/src/utils/process-lock.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +2 -2
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/project-boundary.d.ts +11 -13
- package/dist/src/utils/project-boundary.js +28 -34
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/rendered-contract.js +18 -1
- package/dist/src/utils/rendered-contract.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +18 -0
- package/dist/src/utils/runtime-config.js +64 -0
- package/dist/src/utils/runtime-config.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
- package/dist/src/utils/runtime-skill-closure.js +47 -6
- package/dist/src/utils/runtime-skill-closure.js.map +1 -1
- package/dist/src/utils/safe-fs.d.ts +21 -0
- package/dist/src/utils/safe-fs.js +111 -0
- package/dist/src/utils/safe-fs.js.map +1 -0
- package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
- package/dist/src/utils/safe-operation-diagnostic.js +33 -0
- package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
- package/dist/src/utils/sensitive-content.d.ts +4 -0
- package/dist/src/utils/sensitive-content.js +36 -0
- package/dist/src/utils/sensitive-content.js.map +1 -0
- package/dist/src/utils/state-paths.d.ts +8 -3
- package/dist/src/utils/state-paths.js +53 -16
- package/dist/src/utils/state-paths.js.map +1 -1
- package/dist/src/utils/target-eligibility.d.ts +4 -3
- package/dist/src/utils/target-eligibility.js +12 -6
- package/dist/src/utils/target-eligibility.js.map +1 -1
- package/dist/src/utils/windows-claude-shim.d.ts +7 -0
- package/dist/src/utils/windows-claude-shim.js +10 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/src/utils/windows-npm-shim.d.ts +16 -0
- package/dist/src/utils/windows-npm-shim.js +155 -0
- package/dist/src/utils/windows-npm-shim.js.map +1 -0
- package/dist/vitest.config.js +105 -9
- package/dist/vitest.config.js.map +1 -1
- package/package.json +30 -21
- package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
- package/dist/scripts/aw-skill-eval-engine.js +0 -31
- package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
- package/dist/scripts/codex-eval-app-server.d.ts +0 -91
- package/dist/scripts/codex-eval-app-server.js +0 -1334
- package/dist/scripts/codex-eval-app-server.js.map +0 -1
- package/dist/scripts/codex-eval-isolation.d.ts +0 -61
- package/dist/scripts/codex-eval-isolation.js +0 -318
- package/dist/scripts/codex-eval-isolation.js.map +0 -1
- package/dist/scripts/codex-eval-process-management.d.ts +0 -8
- package/dist/scripts/codex-eval-process-management.js +0 -69
- package/dist/scripts/codex-eval-process-management.js.map +0 -1
- package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
- package/dist/scripts/codex-eval-process-tree.js +0 -803
- package/dist/scripts/codex-eval-process-tree.js.map +0 -1
- package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
- package/dist/scripts/codex-eval-runtime-config.js +0 -843
- package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
- package/dist/scripts/codex-trigger-eval.d.ts +0 -84
- package/dist/scripts/codex-trigger-eval.js +0 -968
- package/dist/scripts/codex-trigger-eval.js.map +0 -1
- package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
- package/dist/scripts/eval-plugin-skills-audited.js +0 -261
- package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
- package/dist/scripts/eval-plugin-skills.d.ts +0 -45
- package/dist/scripts/eval-plugin-skills.js +0 -1589
- package/dist/scripts/eval-plugin-skills.js.map +0 -1
- package/dist/scripts/eval-run-layout.d.ts +0 -17
- package/dist/scripts/eval-run-layout.js +0 -26
- package/dist/scripts/eval-run-layout.js.map +0 -1
- package/dist/scripts/plugin-eval-contract.d.ts +0 -189
- package/dist/scripts/plugin-eval-contract.js +0 -745
- package/dist/scripts/plugin-eval-contract.js.map +0 -1
- package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
- package/dist/scripts/plugin-eval-materializer.js +0 -421
- package/dist/scripts/plugin-eval-materializer.js.map +0 -1
- package/dist/scripts/skill-reporting.d.ts +0 -212
- package/dist/scripts/skill-reporting.js +0 -922
- package/dist/scripts/skill-reporting.js.map +0 -1
- package/dist/src/commands/catalog-context.d.ts +0 -52
- package/dist/src/commands/catalog-context.js +0 -156
- package/dist/src/commands/catalog-context.js.map +0 -1
- package/dist/src/commands/review-publication.d.ts +0 -99
- package/dist/src/commands/review-publication.js +0 -904
- package/dist/src/commands/review-publication.js.map +0 -1
- package/dist/src/commands/status-v5.d.ts +0 -169
- package/dist/src/commands/status-v5.js +0 -1135
- package/dist/src/commands/status-v5.js.map +0 -1
- package/dist/src/portable/skills-cli.d.ts +0 -43
- package/dist/src/portable/skills-cli.js +0 -148
- package/dist/src/portable/skills-cli.js.map +0 -1
- package/dist/src/utils/catalog-manifest-v5.d.ts +0 -5
- package/dist/src/utils/catalog-manifest-v5.js.map +0 -1
- package/dist/src/utils/catalog-source-cache.d.ts +0 -62
- package/dist/src/utils/catalog-source-cache.js +0 -321
- package/dist/src/utils/catalog-source-cache.js.map +0 -1
- package/dist/src/utils/codex-project-surface.d.ts +0 -3
- package/dist/src/utils/codex-project-surface.js +0 -49
- package/dist/src/utils/codex-project-surface.js.map +0 -1
- package/dist/src/utils/lifecycle-active-store.d.ts +0 -147
- package/dist/src/utils/lifecycle-active-store.js +0 -1064
- package/dist/src/utils/lifecycle-active-store.js.map +0 -1
- package/dist/src/utils/plugin-release.d.ts +0 -2
- package/dist/src/utils/plugin-release.js +0 -2
- package/dist/src/utils/plugin-release.js.map +0 -1
- package/dist/src/utils/slash-commands.d.ts +0 -1
- package/dist/src/utils/slash-commands.js +0 -2
- package/dist/src/utils/slash-commands.js.map +0 -1
package/dist/src/index.js
CHANGED
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { describeNativeToolClosure } from './utils/native-tool-review.js';
|
|
3
|
+
import { preparePublicConfigConfirmation } from './commands/public-config-confirmation.js';
|
|
4
|
+
import { createPublicCommandInterruption } from './commands/public-interruption.js';
|
|
5
|
+
import { CLI_OUTPUT_SCHEMA_VERSION, commandResult, publicExitCode, renderPublicResult, safePublicMessage } from './output/public-result.js';
|
|
6
|
+
import { projectReceipt } from './output/receipt-projection.js';
|
|
7
|
+
import { geminiNativeConsentDiagnostic } from './output/native-consent.js';
|
|
8
|
+
import { runPublicLifecycle } from './commands/public-lifecycle.js';
|
|
9
|
+
import { runPublicPluginList, runPublicPluginShow, runPublicPluginStatus } from './commands/public-plugin-query.js';
|
|
2
10
|
import fs from 'node:fs';
|
|
3
11
|
import path from 'node:path';
|
|
4
|
-
import {
|
|
12
|
+
import { defaultPluginProcessRunner } from './utils/plugin-scripts.js';
|
|
5
13
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { Command, CommanderError, Option } from 'commander';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
+
import { Command, CommanderError, InvalidArgumentError, Option } from 'commander';
|
|
15
|
+
import { doctorEvalProviders } from '@lesliechan721/agent-skill-eval';
|
|
16
|
+
import { compilePluginConfigDefinition, selectPluginConfigProfile, PLATFORM_TARGETS } from '@lesliechan721/aw-plugin-core/manifest';
|
|
17
|
+
import { CatalogWorkspaceMissingError, resolveCatalogWorkspaceRoot } from './commands/catalog-workspace-resolution.js';
|
|
18
|
+
import { addCatalogSourceCommand, preflightCatalogSourceMutation, explicitRefPolicy, listCatalogSources, removeCatalogSourceCommand, updateCatalogSourceCommand, } from './commands/catalog-source.js';
|
|
19
|
+
import { catalogSourceStatusCommand, syncCatalogSourceCommand, } from './commands/catalog-generation.js';
|
|
20
|
+
import { catalogStoreErrorCode, catalogStorePrune, catalogStoreStatus, } from './commands/catalog-store.js';
|
|
21
|
+
import { WizardExecutionError, } from './commands/wizard.js';
|
|
14
22
|
import { createCliExecutionContext, emitCommandEvent, } from './commands/runtime.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { isCommandWarningError, } from './types.js';
|
|
18
|
-
import { formatWarnings } from './output/reporter.js';
|
|
23
|
+
import { parseContextValue, parsePlatformTargetValue, parseScopeValue, resolveScriptTimeoutMs, } from './commands/options.js';
|
|
24
|
+
import { createNoopReporter, formatWarnings } from './output/reporter.js';
|
|
19
25
|
import { redactString, redactValue } from './output/redact.js';
|
|
20
|
-
import { renderShellCommand, } from './output/equivalent-command.js';
|
|
21
|
-
import { buildRebuildReceiptJson, buildInitReceiptJson, renderRebuildReceipt, renderInitReceipt, } from './output/command-receipt.js';
|
|
22
26
|
import { resolveCliPackageRoot } from './utils/paths.js';
|
|
23
|
-
import { coercePluginConfigUpdates, findConfigFieldEntry,
|
|
24
|
-
import { applyPluginConfigWrite,
|
|
27
|
+
import { coercePluginConfigUpdates, assertPluginConfigMutationCandidate, findConfigFieldEntry, formatPluginConfigSetRecoveryCommand, listNamespacedPluginConfigStores, readPluginConfigStore, renderPluginConfigValueForDisplay, resolveConfigRead, } from './utils/plugin-config.js';
|
|
28
|
+
import { applyPluginConfigWrite, applyPluginConfig, buildConfigMutationReceipt, configWriteStateForError, resetPluginConfigWithHelper, } from './utils/plugin-config-write.js';
|
|
25
29
|
import { assertStrictSemVer } from './utils/manifest.js';
|
|
26
|
-
import { writeCandidateEligibility } from './utils/target-eligibility.js';
|
|
27
30
|
import { assertCatalogSourceReferencesSupported, inventoryLegacyConfigReferences, } from './utils/catalog-source-references.js';
|
|
28
31
|
import { parsePluginId, withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, } from './utils/multi-source-catalog.js';
|
|
29
|
-
import { sanitizeCatalogSourceError } from './utils/catalog-public-error.js';
|
|
32
|
+
import { sanitizeCatalogSourceError, sanitizeCatalogSourceErrorMessage, } from './utils/catalog-public-error.js';
|
|
30
33
|
import { catalogGenerationErrorCode } from './utils/catalog-generation-error.js';
|
|
31
|
-
import {
|
|
32
|
-
import { formatConfigCommandValue, parseConfigValue, } from './utils/config-value.js';
|
|
34
|
+
import { resolveCatalogOperationContext, } from './utils/catalog-operation-context.js';
|
|
33
35
|
import { withAwHomeMutationLock, } from './utils/aw-home-mutation-lock.js';
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import { resolveRepoRoot } from './utils/state-paths.js';
|
|
36
|
+
import { materializePortableSkillsToDirectory, PortableCommandError } from './portable/commands.js';
|
|
37
|
+
import { createReviewInspectionFailure, getReviewInspectionExitCode, inspectReviewTarget, } from './commands/review-inspection.js';
|
|
38
|
+
import { prepareReviewTarget, } from './commands/review-preparation.js';
|
|
38
39
|
import { runCatalogBuildCommand, runCatalogInitCommand, runCatalogValidateCommand, runCatalogVersionCommand, runPluginBuildCommand, runPluginTestCommand, } from './authoring/workspace-commands.js';
|
|
39
|
-
import {
|
|
40
|
+
import { CatalogPublicationApplyFailure, runCatalogPublishApplyCommand, runCatalogPublishPlanCommand, } from './commands/catalog-publish.js';
|
|
41
|
+
import { catalogPublicationFailure, } from './commands/catalog-publication-inspection.js';
|
|
40
42
|
import { getCatalogStatus, renderCatalogStatus } from './commands/catalog-status.js';
|
|
41
|
-
import { getCatalogContext } from './commands/catalog-context.js';
|
|
42
43
|
import { activateCatalogDevSource, catalogDevSourceError, createCatalogDevFailureReceipt, deactivateCatalogDevSource, getCatalogDevSourceStatus, } from './commands/catalog-dev-source.js';
|
|
43
44
|
import { getPluginCapabilitiesResult, parsePluginCapabilitySurface, renderPluginCapabilities, } from './commands/plugin-capabilities.js';
|
|
44
|
-
import { AwCapabilityUnsupportedError, checkCurrentAw, describeCurrentAw, inspectPluginRequirements,
|
|
45
|
+
import { AwCapabilityUnsupportedError, checkCurrentAw, describeCurrentAw, inspectPluginRequirements, } from './commands/aw-capabilities.js';
|
|
46
|
+
import { prepareSkillEval } from './commands/skill-eval.js';
|
|
47
|
+
import { targetsSet, targetsList, targetsChangeExclusion } from './commands/targets-command.js';
|
|
48
|
+
import { runCursorWorkspaceHookCli } from './platforms/cursor-workspace-hook.js';
|
|
49
|
+
import { normalizeAgents } from './intent/deployment-preferences.js';
|
|
50
|
+
import { resolveWorkContext } from './intent/work-context.js';
|
|
51
|
+
import { registerManagedCommandCli, runManagedCommandCli } from './commands/managed-commands.js';
|
|
52
|
+
const receiptSinks = new WeakMap();
|
|
45
53
|
function createDefaultIo() {
|
|
46
54
|
return {
|
|
47
55
|
stdout: (text) => process.stdout.write(text),
|
|
@@ -51,6 +59,41 @@ function createDefaultIo() {
|
|
|
51
59
|
function writeLine(write, line) {
|
|
52
60
|
write(`${line}\n`);
|
|
53
61
|
}
|
|
62
|
+
function strictValueOption(flags, description, choices) {
|
|
63
|
+
let seen = false;
|
|
64
|
+
const option = new Option(flags, description);
|
|
65
|
+
if (choices)
|
|
66
|
+
option.choices([...choices]);
|
|
67
|
+
return option.argParser((value) => {
|
|
68
|
+
if (seen)
|
|
69
|
+
throw new InvalidArgumentError(`${option.long} can be specified only once.`);
|
|
70
|
+
if (choices && !choices.includes(value)) {
|
|
71
|
+
throw new InvalidArgumentError(`${option.long} must be one of: ${choices.join(', ')}.`);
|
|
72
|
+
}
|
|
73
|
+
seen = true;
|
|
74
|
+
return value;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function collectUniqueOption(value, previous = []) {
|
|
78
|
+
return previous.includes(value) ? previous : [...previous, value];
|
|
79
|
+
}
|
|
80
|
+
function renderReviewSkills(write, skills, issues) {
|
|
81
|
+
for (const skill of skills) {
|
|
82
|
+
writeLine(write, `${skill.skill}\t${skill.profile.platform}/${skill.profile.scope}\t${skill.state}\t${skill.finalPath ?? '-'}`);
|
|
83
|
+
}
|
|
84
|
+
for (const issue of issues)
|
|
85
|
+
writeLine(write, `${issue.code}: ${issue.message}`);
|
|
86
|
+
}
|
|
87
|
+
function renderReviewInspection(write, receipt) {
|
|
88
|
+
writeLine(write, `Review inspection (${receipt.view}): ${receipt.ok ? 'ok' : 'failed'}`);
|
|
89
|
+
renderReviewSkills(write, receipt.skills, receipt.issues);
|
|
90
|
+
}
|
|
91
|
+
function renderReviewPreparation(write, receipt) {
|
|
92
|
+
writeLine(write, `Review preparation: ${receipt.ok ? 'complete' : 'failed'}`);
|
|
93
|
+
if (receipt.sourceBindingPath)
|
|
94
|
+
writeLine(write, `Source binding: ${receipt.sourceBindingPath}`);
|
|
95
|
+
renderReviewSkills(write, receipt.skills, receipt.issues);
|
|
96
|
+
}
|
|
54
97
|
function writeWarnings(write, warnings, options = {}) {
|
|
55
98
|
for (const warning of formatWarnings(warnings, options)) {
|
|
56
99
|
writeLine(write, warning);
|
|
@@ -61,31 +104,95 @@ function resolveCliVersion() {
|
|
|
61
104
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
62
105
|
return assertStrictSemVer(packageJson.version, 'packages/cli/package.json version');
|
|
63
106
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
107
|
+
class WriteCommandRequestError extends Error {
|
|
108
|
+
code = 'invalidArguments';
|
|
109
|
+
}
|
|
110
|
+
function normalizeWriteRequest(normalize) {
|
|
111
|
+
try {
|
|
112
|
+
return normalize();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw new WriteCommandRequestError(error instanceof Error ? error.message : String(error));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function configMutationFailure(error, env, cwd) {
|
|
119
|
+
const configWrite = error?.configWrite === 'succeeded' ? 'succeeded' : configWriteStateForError(error);
|
|
120
|
+
if (error instanceof CommanderError) {
|
|
121
|
+
return {
|
|
122
|
+
code: 'invalidArguments',
|
|
123
|
+
message: 'error: invalid config mutation arguments',
|
|
124
|
+
configWrite,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const message = catalogPublicationFailure({
|
|
128
|
+
error,
|
|
129
|
+
env,
|
|
130
|
+
sensitiveRoots: [cwd],
|
|
131
|
+
}).message;
|
|
132
|
+
if (message.includes('Usage:'))
|
|
133
|
+
return { code: 'invalidArguments', message, configWrite };
|
|
134
|
+
const generationCode = catalogGenerationErrorCode(error);
|
|
135
|
+
if (generationCode === 'catalogGenerationUnavailable'
|
|
136
|
+
|| generationCode === 'catalogGenerationSourceMissing') {
|
|
137
|
+
return { code: 'catalogSourceUnavailable', message, configWrite };
|
|
138
|
+
}
|
|
139
|
+
if (generationCode !== 'catalogGenerationFailed')
|
|
140
|
+
return { code: generationCode, message, configWrite };
|
|
141
|
+
const explicitCode = error?.code;
|
|
142
|
+
if (typeof explicitCode === 'string' && /^[A-Za-z][A-Za-z0-9]*$/u.test(explicitCode)) {
|
|
143
|
+
return { code: explicitCode, message, configWrite };
|
|
144
|
+
}
|
|
145
|
+
if (message.includes('legacyStateUnsupported'))
|
|
146
|
+
return { code: 'legacyStateUnsupported', message, configWrite };
|
|
147
|
+
if (message.includes('sourceChanged'))
|
|
148
|
+
return { code: 'sourceChanged', message, configWrite };
|
|
149
|
+
if (message.includes('sourceMissing'))
|
|
150
|
+
return { code: 'sourceMissing', message, configWrite };
|
|
151
|
+
if (message.startsWith('Cannot resolve required catalog sources:')) {
|
|
152
|
+
return { code: 'catalogSourceUnavailable', message, configWrite };
|
|
153
|
+
}
|
|
154
|
+
const prefix = message.match(/^([A-Za-z][A-Za-z0-9]*):/u)?.[1];
|
|
155
|
+
return { code: prefix ?? 'configMutationFailed', message, configWrite };
|
|
156
|
+
}
|
|
157
|
+
function writeConfigMutationFailureReceipt(write, request, failure) {
|
|
158
|
+
let plugin;
|
|
159
|
+
try {
|
|
160
|
+
if (request.plugin) {
|
|
161
|
+
parsePluginId(request.plugin);
|
|
162
|
+
plugin = request.plugin;
|
|
163
|
+
}
|
|
67
164
|
}
|
|
68
|
-
|
|
165
|
+
catch {
|
|
166
|
+
// Do not echo an invalid selector from raw argv in an early failure receipt.
|
|
167
|
+
}
|
|
168
|
+
writeJsonReceipt(write, buildConfigMutationReceipt(request.command, {
|
|
169
|
+
ok: false,
|
|
170
|
+
overallState: 'failed',
|
|
171
|
+
configWrite: failure.configWrite,
|
|
172
|
+
...(plugin ? { plugin } : {}),
|
|
173
|
+
errors: [failure],
|
|
174
|
+
}));
|
|
69
175
|
}
|
|
70
176
|
async function runAuthoringScript(options) {
|
|
71
177
|
const scriptPath = path.join(resolveCliPackageRoot(), 'dist', 'authoring', 'scripts', options.scriptName);
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
78
|
-
child.stdout.on('data', (chunk) => options.io.stdout(String(chunk)));
|
|
79
|
-
child.stderr.on('data', (chunk) => options.io.stderr(String(chunk)));
|
|
80
|
-
child.once('error', reject);
|
|
81
|
-
child.once('close', (code, signal) => {
|
|
82
|
-
if (signal) {
|
|
83
|
-
reject(new Error(`Plugin authoring command terminated by signal ${signal}.`));
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
resolve(code ?? 1);
|
|
178
|
+
try {
|
|
179
|
+
const result = await defaultPluginProcessRunner.run({ command: process.execPath, args: [scriptPath, ...options.args], cwd: options.cwd, env: options.env }, {
|
|
180
|
+
// Authoring has no CLI timeout option. Keep the largest Node timer while
|
|
181
|
+
// using the existing process-tree cleanup contract for interruption.
|
|
182
|
+
timeoutMs: 2_147_483_647, signal: options.interruption?.signal, maxStdoutBytes: 32 * 1024 * 1024,
|
|
87
183
|
});
|
|
88
|
-
|
|
184
|
+
options.io.stdout(result.stdout);
|
|
185
|
+
options.io.stderr(result.stderr);
|
|
186
|
+
return result.exitCode ?? 1;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (options.interruption?.signal.aborted && error !== options.interruption.signal.reason)
|
|
190
|
+
options.interruption.cleanupFailed = true;
|
|
191
|
+
if (options.interruption?.signal.aborted && ['init-plugin.mjs', 'add-skill.mjs', 'remove-plugin.mjs'].includes(options.scriptName)) {
|
|
192
|
+
throw Object.assign(new Error('The authoring command was interrupted after execution started.'), { code: 'operationInterrupted', authoringChanges: 'unknown' });
|
|
193
|
+
}
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
89
196
|
}
|
|
90
197
|
function toCliDiagnosticsOptions(commandName, rawOptions, runtimeDiagnostics) {
|
|
91
198
|
return {
|
|
@@ -99,261 +206,104 @@ function toCliDiagnosticsOptions(commandName, rawOptions, runtimeDiagnostics) {
|
|
|
99
206
|
function isWizardAvailable(context, rawOptions) {
|
|
100
207
|
return context.interactive && context.isTty && !context.isCi && rawOptions.json !== true;
|
|
101
208
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return value === undefined ? [] : [flag, value];
|
|
107
|
-
}
|
|
108
|
-
function writeCommandUsage(command) {
|
|
109
|
-
const cardinality = command === 'reinstall' || command === 'cleanup' ? '<plugin>' : '<plugin...>';
|
|
110
|
-
const scope = command === 'cleanup' ? ' --scope <project|user>' : ' [--scope <project|user>]';
|
|
111
|
-
const all = command === 'upgrade' ? ' 或 aw upgrade --all --platform both --scope user' : '';
|
|
112
|
-
return [
|
|
113
|
-
`${command} 命令缺少必要参数。`,
|
|
114
|
-
`Usage: aw ${command} ${cardinality} --platform <codex|claude|both>${scope}`,
|
|
115
|
-
`Example: aw ${command} example-plugin --platform codex --scope user${all}`,
|
|
116
|
-
].join('\n');
|
|
117
|
-
}
|
|
118
|
-
function configCommandUsage(command) {
|
|
119
|
-
const argumentsByCommand = {
|
|
120
|
-
list: '<plugin>',
|
|
121
|
-
get: '<plugin> [key]',
|
|
122
|
-
set: '<plugin> <key> <value>',
|
|
123
|
-
unset: '<plugin> <key>',
|
|
124
|
-
reset: '<plugin> --scope <project|user> --yes',
|
|
125
|
-
};
|
|
126
|
-
return [
|
|
127
|
-
`config ${command} 命令缺少必要参数。`,
|
|
128
|
-
`Usage: aw config ${command} ${argumentsByCommand[command]}`,
|
|
129
|
-
`Example: aw config ${command} example-plugin${command === 'set' ? ' key value' : command === 'unset' ? ' key' : command === 'reset' ? ' --scope user --yes' : ''}`,
|
|
130
|
-
].join('\n');
|
|
131
|
-
}
|
|
132
|
-
function assertUpgradeAllConflict(pluginNames, all) {
|
|
133
|
-
if (all && pluginNames.length > 0) {
|
|
134
|
-
throw new Error('upgrade 命令不能同时使用插件名和 `--all`。');
|
|
209
|
+
async function readUtf8Stdin(stdin) {
|
|
210
|
+
const chunks = [];
|
|
211
|
+
for await (const chunk of stdin) {
|
|
212
|
+
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk, 'utf8') : Buffer.from(chunk));
|
|
135
213
|
}
|
|
214
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
136
215
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
...(all ? ['--all'] : []),
|
|
146
|
-
'--platform',
|
|
147
|
-
selection.platform ?? 'both',
|
|
148
|
-
'--scope',
|
|
149
|
-
selection.scope ?? 'user',
|
|
150
|
-
...(rawOptions.allowManagedCodexInstall === true
|
|
151
|
-
? ['--allow-managed-codex-install']
|
|
152
|
-
: []),
|
|
153
|
-
...(command === 'cleanup' ? [] : optionTokens('--script-timeout', rawOptions.scriptTimeout)),
|
|
154
|
-
...(!all && selection.plugins.length > 0 ? ['--', ...selection.plugins] : []),
|
|
155
|
-
];
|
|
156
|
-
}
|
|
157
|
-
function equivalentConfigCommand(options) {
|
|
158
|
-
return shellCommand(buildEquivalentConfigCommandTokens(options));
|
|
159
|
-
}
|
|
160
|
-
function equivalentConfigCommandProjection(resolve) {
|
|
161
|
-
return {
|
|
162
|
-
equivalentCommand: (selection) => equivalentConfigCommand(resolve(selection)),
|
|
163
|
-
equivalentCommandTokens: (selection) => buildEquivalentConfigCommandTokens(resolve(selection)),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function configSetEquivalentOptions(selection, candidates, rawOptions) {
|
|
167
|
-
const field = candidates.find((entry) => entry.pluginName === selection.plugins[0])
|
|
168
|
-
?.configSchema?.[selection.key ?? ''];
|
|
169
|
-
const placeholder = configFieldPlaceholder(field);
|
|
170
|
-
return {
|
|
171
|
-
command: 'set',
|
|
172
|
-
plugin: selection.plugins[0],
|
|
173
|
-
key: selection.key,
|
|
174
|
-
value: placeholder
|
|
175
|
-
? rawOptions.valueJson ? JSON.stringify(placeholder) : placeholder
|
|
176
|
-
: formatConfigCommandValue(selection.value, rawOptions.valueJson === true),
|
|
177
|
-
scope: selection.scope ?? 'user',
|
|
178
|
-
projectLayer: selection.projectLayer,
|
|
179
|
-
valueJson: rawOptions.valueJson,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function configFieldPlaceholder(field) {
|
|
183
|
-
if (field?.sensitive)
|
|
184
|
-
return '<sensitive-value>';
|
|
185
|
-
if (field?.type === 'file')
|
|
186
|
-
return '<file-path>';
|
|
187
|
-
if (field?.type === 'directory')
|
|
188
|
-
return '<directory-path>';
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
export function buildEquivalentConfigCommandTokens(options) {
|
|
192
|
-
return [
|
|
193
|
-
'aw',
|
|
194
|
-
'config',
|
|
195
|
-
options.command,
|
|
196
|
-
...optionTokens('--scope', options.scope),
|
|
197
|
-
...(options.projectLayer === 'local' ? ['--local'] : []),
|
|
198
|
-
...(options.valueJson ? ['--value-json'] : []),
|
|
199
|
-
...(options.confirmed ? ['--yes'] : []),
|
|
200
|
-
'--',
|
|
201
|
-
options.plugin,
|
|
202
|
-
...(options.key === undefined ? [] : [options.key]),
|
|
203
|
-
...(options.value === undefined ? [] : [options.value]),
|
|
204
|
-
];
|
|
205
|
-
}
|
|
206
|
-
function hasSelectableWriteCandidate(command, candidates, selection, options) {
|
|
207
|
-
const platforms = options.missingPlatform
|
|
208
|
-
? ['codex', 'claude', 'both']
|
|
209
|
-
: [selection.platform ?? 'both'];
|
|
210
|
-
const scopes = options.missingScope ? ['user', 'project'] : [selection.scope ?? 'user'];
|
|
211
|
-
return candidates.some((candidate) => platforms.some((platform) => scopes.some((scope) => writeCandidateEligibility(command, candidate, { ...selection, platform, scope }).selectable)));
|
|
212
|
-
}
|
|
213
|
-
function hasConfigSchemaKeys(candidate) {
|
|
214
|
-
return candidate.configSchema !== undefined && Object.keys(candidate.configSchema).length > 0;
|
|
215
|
-
}
|
|
216
|
-
async function loadWizardCandidates(context, rawOptions) {
|
|
217
|
-
const loaded = await loadConsoleItemsResult({
|
|
218
|
-
cwd: context.cwd,
|
|
219
|
-
scope: rawOptions.scope,
|
|
220
|
-
platform: rawOptions.platform,
|
|
221
|
-
}, context);
|
|
222
|
-
return toWizardCandidates(loaded.items);
|
|
223
|
-
}
|
|
224
|
-
function mergeWizardCandidates(current, stored) {
|
|
225
|
-
const merged = new Map(current.map((candidate) => [candidate.pluginName, candidate]));
|
|
226
|
-
for (const candidate of stored) {
|
|
227
|
-
const existing = merged.get(candidate.pluginName);
|
|
228
|
-
if (!existing) {
|
|
229
|
-
merged.set(candidate.pluginName, candidate);
|
|
230
|
-
}
|
|
231
|
-
else if (!existing.configSchema) {
|
|
232
|
-
merged.set(candidate.pluginName, { ...candidate, ...existing });
|
|
233
|
-
}
|
|
216
|
+
async function resolveStoredConfigResetIdentity(options) {
|
|
217
|
+
const parsed = parsePluginId(options.selector);
|
|
218
|
+
if (parsed.sourceId) {
|
|
219
|
+
return {
|
|
220
|
+
pluginName: parsed.pluginName,
|
|
221
|
+
pluginId: options.selector,
|
|
222
|
+
sourceId: parsed.sourceId,
|
|
223
|
+
};
|
|
234
224
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
225
|
+
const matches = (await listNamespacedPluginConfigStores({
|
|
226
|
+
cwd: options.context.cwd,
|
|
227
|
+
env: options.context.env,
|
|
228
|
+
scope: options.scope,
|
|
229
|
+
})).filter((store) => store.pluginName === parsed.pluginName);
|
|
230
|
+
if (matches.length === 0) {
|
|
231
|
+
throw new Error(`configStoreMissing: ${options.selector} has no config in the selected store.`);
|
|
241
232
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const stores = await listNamespacedPluginConfigStores({
|
|
245
|
-
cwd: context.cwd,
|
|
246
|
-
env: context.env,
|
|
247
|
-
scope: location.scope,
|
|
248
|
-
...(location.scope === 'project' ? { projectLayer: location.projectLayer } : {}),
|
|
249
|
-
});
|
|
250
|
-
for (const store of stores) {
|
|
251
|
-
const keys = Object.keys(store.values);
|
|
252
|
-
if (keys.length === 0 && options.includeEmptyStores !== true)
|
|
253
|
-
continue;
|
|
254
|
-
const existing = storesByPlugin.get(store.pluginId) ?? {
|
|
255
|
-
sourceId: store.sourceId,
|
|
256
|
-
sourceIdentity: store.sourceIdentity,
|
|
257
|
-
keys: new Set(),
|
|
258
|
-
};
|
|
259
|
-
if (existing.sourceIdentity !== store.sourceIdentity) {
|
|
260
|
-
throw new Error(`sourceChanged: ${store.pluginId} config stores have different source identities.`);
|
|
261
|
-
}
|
|
262
|
-
for (const key of keys)
|
|
263
|
-
existing.keys.add(key);
|
|
264
|
-
storesByPlugin.set(store.pluginId, existing);
|
|
265
|
-
}
|
|
233
|
+
if (matches.length > 1) {
|
|
234
|
+
throw new Error(`configTargetAmbiguous: ${options.selector} exists in multiple source namespaces: ${matches.map((store) => store.pluginId).join(', ')}. Use a full pluginId.`);
|
|
266
235
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
targets: [],
|
|
275
|
-
configKeys: [...store.keys].sort((left, right) => left.localeCompare(right)),
|
|
276
|
-
}));
|
|
277
|
-
}
|
|
278
|
-
function configReadStoreLocations(rawOptions) {
|
|
279
|
-
if (rawOptions.local)
|
|
280
|
-
return [{ scope: 'project', projectLayer: 'local' }];
|
|
281
|
-
if (rawOptions.scope === 'user')
|
|
282
|
-
return [{ scope: 'user', projectLayer: 'shared' }];
|
|
283
|
-
if (rawOptions.scope === 'project')
|
|
284
|
-
return [{ scope: 'project', projectLayer: 'shared' }];
|
|
285
|
-
return [
|
|
286
|
-
{ scope: 'user', projectLayer: 'shared' },
|
|
287
|
-
{ scope: 'project', projectLayer: 'shared' },
|
|
288
|
-
{ scope: 'project', projectLayer: 'local' },
|
|
289
|
-
];
|
|
290
|
-
}
|
|
291
|
-
function overallResultState(value) {
|
|
292
|
-
return value.overallState;
|
|
236
|
+
const [match] = matches;
|
|
237
|
+
return {
|
|
238
|
+
pluginName: match.pluginName,
|
|
239
|
+
pluginId: match.pluginId,
|
|
240
|
+
sourceId: match.sourceId,
|
|
241
|
+
sourceIdentity: match.binding.sourceIdentity,
|
|
242
|
+
};
|
|
293
243
|
}
|
|
294
244
|
async function resolveStoredOnlyConfigIdentity(options) {
|
|
295
245
|
const parsed = parsePluginId(options.selector);
|
|
296
246
|
if (!parsed.sourceId)
|
|
297
247
|
throw new Error(`Plugin "${options.selector}" is not a qualified stored config target.`);
|
|
298
|
-
const stores = (await
|
|
299
|
-
cwd: options.context.cwd,
|
|
300
|
-
|
|
301
|
-
scope: location.scope,
|
|
302
|
-
...(location.scope === 'project' ? { projectLayer: location.projectLayer } : {}),
|
|
303
|
-
})))).flat().filter((store) => store.pluginId === options.selector);
|
|
248
|
+
const stores = (await listNamespacedPluginConfigStores({
|
|
249
|
+
cwd: options.context.cwd, env: options.context.env, scope: 'user',
|
|
250
|
+
})).filter((store) => store.pluginId === options.selector);
|
|
304
251
|
if (stores.length === 0)
|
|
305
252
|
throw new Error(`Plugin "${options.selector}" does not have a namespaced config store.`);
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
253
|
+
const sourceBindings = stores.flatMap((store) => store.binding.kind === 'source'
|
|
254
|
+
? [store.binding.sourceIdentity] : []);
|
|
255
|
+
if (new Set(sourceBindings).size > 1) {
|
|
256
|
+
throw new Error(`identityMismatch: ${options.selector} config stores have different bindings.`);
|
|
257
|
+
}
|
|
258
|
+
const currentSource = await withResolvedMultiSourceCatalog({
|
|
311
259
|
cliVersion: resolveCliVersion(),
|
|
312
|
-
freshnessPolicy: 'cacheFirst',
|
|
313
260
|
sourceIds: [parsed.sourceId],
|
|
314
261
|
env: options.context.env,
|
|
315
262
|
consume: async (catalog) => {
|
|
316
263
|
const source = catalog.sources.find((entry) => entry.sourceId === parsed.sourceId);
|
|
317
|
-
if (!source?.resolution)
|
|
264
|
+
if (!source?.resolution) {
|
|
318
265
|
throw source?.error ?? new Error(`Catalog source "${parsed.sourceId}" is unavailable.`);
|
|
319
|
-
if (source.resolution.sourceIdentity !== sourceIdentity) {
|
|
320
|
-
throw new Error(`sourceChanged: ${options.selector} config source identity does not match the current source.`);
|
|
321
266
|
}
|
|
267
|
+
return {
|
|
268
|
+
sourceIdentity: source.resolution.sourceIdentity,
|
|
269
|
+
logicalIdentity: source.resolution.logicalIdentity,
|
|
270
|
+
};
|
|
322
271
|
},
|
|
323
272
|
});
|
|
273
|
+
if (sourceBindings[0] && sourceBindings[0] !== currentSource.sourceIdentity) {
|
|
274
|
+
throw new Error(`identityMismatch: ${options.selector} user config does not match the current source identity.`);
|
|
275
|
+
}
|
|
324
276
|
return {
|
|
325
277
|
pluginName: parsed.pluginName,
|
|
326
278
|
pluginId: options.selector,
|
|
327
279
|
sourceId: parsed.sourceId,
|
|
328
|
-
sourceIdentity,
|
|
280
|
+
sourceIdentity: currentSource.sourceIdentity,
|
|
281
|
+
logicalIdentity: currentSource.logicalIdentity,
|
|
329
282
|
};
|
|
330
283
|
}
|
|
331
284
|
async function resolveMultiSourceConfigRead(options) {
|
|
332
285
|
const inventory = await inventoryLegacyConfigReferences({
|
|
333
286
|
cwd: options.context.cwd,
|
|
334
287
|
env: options.context.env,
|
|
288
|
+
scope: options.rawOptions.context === 'project' ? 'project' : 'user',
|
|
335
289
|
});
|
|
336
290
|
assertCatalogSourceReferencesSupported(inventory);
|
|
337
|
-
const projectLayer = resolveConfigProjectLayer(options.rawOptions);
|
|
338
291
|
return withResolvedCatalogPlugin({
|
|
339
292
|
selector: options.selector,
|
|
340
293
|
cliVersion: resolveCliVersion(),
|
|
341
|
-
freshnessPolicy: 'cacheFirst',
|
|
342
294
|
env: options.context.env,
|
|
343
295
|
consume: async ({ pluginId, source, plugin }) => {
|
|
344
296
|
const result = await resolveConfigRead({
|
|
345
297
|
pluginName: plugin.manifest.name,
|
|
346
298
|
plugin,
|
|
347
|
-
scope: options.rawOptions.
|
|
348
|
-
|
|
349
|
-
: resolveConfigReadResolution(options.rawOptions.scope),
|
|
350
|
-
projectLayer,
|
|
299
|
+
scope: options.rawOptions.context === 'project' ? 'project' : 'user',
|
|
300
|
+
platform: options.rawOptions.platform,
|
|
351
301
|
cwd: options.context.cwd,
|
|
352
302
|
env: options.context.env,
|
|
353
303
|
});
|
|
354
304
|
if (options.key !== undefined) {
|
|
355
305
|
const field = findConfigFieldEntry(result.fields, options.key);
|
|
356
|
-
if (!field && plugin.manifest.config
|
|
306
|
+
if (!field && compilePluginConfigDefinition(plugin.manifest.config, options.rawOptions.platform).fields[options.key] === undefined) {
|
|
357
307
|
throw new Error(`Unknown config key "${options.key}".`);
|
|
358
308
|
}
|
|
359
309
|
if (field)
|
|
@@ -374,17 +324,15 @@ async function resolveMultiSourceConfigRead(options) {
|
|
|
374
324
|
const stored = await resolveStoredOnlyConfigIdentity({
|
|
375
325
|
selector: options.selector,
|
|
376
326
|
context: options.context,
|
|
377
|
-
locations: configReadStoreLocations(options.rawOptions),
|
|
378
327
|
});
|
|
379
328
|
const result = await resolveConfigRead({
|
|
380
329
|
sourceId: stored.sourceId,
|
|
381
330
|
sourceIdentity: stored.sourceIdentity,
|
|
331
|
+
logicalIdentity: stored.logicalIdentity,
|
|
382
332
|
pluginName: stored.pluginName,
|
|
383
333
|
plugin: null,
|
|
384
|
-
scope: options.rawOptions.
|
|
385
|
-
|
|
386
|
-
: resolveConfigReadResolution(options.rawOptions.scope),
|
|
387
|
-
projectLayer,
|
|
334
|
+
scope: options.rawOptions.context === 'project' ? 'project' : 'user',
|
|
335
|
+
platform: options.rawOptions.platform,
|
|
388
336
|
cwd: options.context.cwd,
|
|
389
337
|
env: options.context.env,
|
|
390
338
|
});
|
|
@@ -397,118 +345,42 @@ async function resolveMultiSourceConfigRead(options) {
|
|
|
397
345
|
return { ...stored, result };
|
|
398
346
|
});
|
|
399
347
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const response = await context.prompt.confirm({
|
|
408
|
-
message: '系统中没有可用的 Codex CLI。是否获取本次操作所需的 AW-managed Codex runtime?',
|
|
409
|
-
defaultValue: false,
|
|
410
|
-
});
|
|
411
|
-
return !response.cancelled && response.value === true;
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
async function executeWriteCommand(command, pluginNames, rawOptions, context) {
|
|
415
|
-
const raw = { cwd: context.cwd, ...rawOptions };
|
|
416
|
-
const commandOptions = command === 'install'
|
|
417
|
-
? normalizeInstallCommandOptions(raw)
|
|
418
|
-
: command === 'upgrade'
|
|
419
|
-
? normalizeUpgradeCommandOptions(raw)
|
|
420
|
-
: command === 'uninstall'
|
|
421
|
-
? normalizeUninstallCommandOptions(raw)
|
|
422
|
-
: command === 'cleanup'
|
|
423
|
-
? normalizeCleanupCommandOptions(raw)
|
|
424
|
-
: normalizeReinstallCommandOptions(raw);
|
|
425
|
-
await emitCommandEvent(context, {
|
|
426
|
-
type: 'options:normalized',
|
|
427
|
-
data: { plugins: pluginNames, options: commandOptions },
|
|
428
|
-
});
|
|
429
|
-
const managedCodexAuthorizer = createManagedCodexAuthorizer(rawOptions, context);
|
|
430
|
-
const runtime = {
|
|
431
|
-
...context,
|
|
432
|
-
...(managedCodexAuthorizer ? { managedCodexAuthorizer } : {}),
|
|
433
|
-
};
|
|
434
|
-
switch (command) {
|
|
435
|
-
case 'install': return installCommand(pluginNames, commandOptions, runtime);
|
|
436
|
-
case 'upgrade': return upgradeCommand(pluginNames, commandOptions, runtime);
|
|
437
|
-
case 'uninstall': return uninstallCommand(pluginNames, commandOptions, runtime);
|
|
438
|
-
case 'cleanup': return cleanupCommand(pluginNames, commandOptions, runtime);
|
|
439
|
-
case 'reinstall': return reinstallCommand(pluginNames, commandOptions, runtime);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
async function runWriteCommandAction(command, pluginNames, rawOptions, context) {
|
|
443
|
-
if ((command === 'cleanup' || command === 'reinstall') && pluginNames.length > 1) {
|
|
444
|
-
throw new Error(`${command} 命令当前只支持单个插件目标。`);
|
|
445
|
-
}
|
|
446
|
-
if (command === 'upgrade')
|
|
447
|
-
assertUpgradeAllConflict(pluginNames, rawOptions.all === true);
|
|
448
|
-
const missingPlugin = pluginNames.length === 0 && !(command === 'upgrade' && rawOptions.all === true);
|
|
449
|
-
const missingPlatform = rawOptions.platform === undefined;
|
|
450
|
-
const missingScope = command === 'cleanup' && rawOptions.scope === undefined;
|
|
451
|
-
const missing = missingPlugin || missingPlatform || missingScope;
|
|
452
|
-
// Validate every value already supplied by the caller before opening the TUI.
|
|
453
|
-
const validationOptions = {
|
|
454
|
-
cwd: context.cwd,
|
|
455
|
-
...rawOptions,
|
|
456
|
-
platform: rawOptions.platform ?? 'both',
|
|
457
|
-
...(command === 'cleanup' ? { scope: rawOptions.scope ?? 'user' } : {}),
|
|
458
|
-
};
|
|
459
|
-
void validationOptions;
|
|
460
|
-
if (!missing) {
|
|
461
|
-
return {
|
|
462
|
-
cancelled: false,
|
|
463
|
-
result: await executeWriteCommand(command, pluginNames, rawOptions, context),
|
|
464
|
-
};
|
|
348
|
+
function renderRecoveryReceipt(write, value) {
|
|
349
|
+
writeLine(write, `${value.command} [${value.scope}]: ${value.ok ? 'ok' : 'failed'}`);
|
|
350
|
+
writeLine(write, `需求:${value.intent.roots?.join('、') || (value.intent.roots === null ? '不可读' : '无')}`);
|
|
351
|
+
writeLine(write, `本机工具:${value.selection.agents.join('、') || '未配置'}`);
|
|
352
|
+
writeLine(write, `变化:声明 ${value.declarationChanged ? '已保存' : '无'};偏好 ${value.preferencesChanged ? '已保存' : '无'};配置 ${value.configChanged ? '已保存' : '无'};输出 ${value.outputsMayHaveChanged ? '可能已变更' : '无'}`);
|
|
353
|
+
for (const target of value.targetResults) {
|
|
354
|
+
writeLine(write, `${target.pluginId} / ${target.agent} [${target.scope}]: ${target.execution}; ${target.content ?? target.observation}`);
|
|
465
355
|
}
|
|
466
|
-
|
|
467
|
-
|
|
356
|
+
for (const result of value.commandResults ?? []) {
|
|
357
|
+
const producer = result.producer;
|
|
358
|
+
writeLine(write, `托管命令 ${producer.sourceId}/${producer.pluginName}/${producer.key} [${producer.scope}]: ${result.state}`);
|
|
468
359
|
}
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
360
|
+
for (const change of value.nativeToolChanges ?? []) {
|
|
361
|
+
for (const phase of ['before', 'after']) {
|
|
362
|
+
const closure = change[phase];
|
|
363
|
+
if (closure)
|
|
364
|
+
for (const description of describeNativeToolClosure(closure)) {
|
|
365
|
+
writeLine(write, `原生工具 ${change.producer.sourceId}/${change.producer.pluginName} ${phase}: ${description}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
476
368
|
}
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
369
|
+
const diagnostics = new Map([...value.blockers, ...value.errors,
|
|
370
|
+
...value.targetResults.flatMap((target) => target.blockers),
|
|
371
|
+
...(value.commandResults ?? []).flatMap((result) => result.errors),
|
|
372
|
+
].map((item) => [`${item.code}:${item.message}`, item]));
|
|
373
|
+
for (const item of diagnostics.values())
|
|
374
|
+
writeLine(write, `${item.code}: ${item.message}`);
|
|
375
|
+
for (const action of value.recoveryActions)
|
|
376
|
+
writeLine(write, action);
|
|
377
|
+
}
|
|
378
|
+
function recoveryRuntime(context, rawOptions, directCli) {
|
|
379
|
+
return {
|
|
380
|
+
...context,
|
|
381
|
+
directCli,
|
|
382
|
+
preApplyConfirmed: rawOptions.yes === true,
|
|
482
383
|
};
|
|
483
|
-
if (missingPlugin && !hasSelectableWriteCandidate(command, candidates, initialSelection, {
|
|
484
|
-
missingPlatform,
|
|
485
|
-
missingScope,
|
|
486
|
-
})) {
|
|
487
|
-
throw new Error('没有可执行此操作的目标。请运行 `aw status` 检查当前状态。');
|
|
488
|
-
}
|
|
489
|
-
const result = await runCommandWizard(context, {
|
|
490
|
-
command,
|
|
491
|
-
candidates,
|
|
492
|
-
initial: initialSelection,
|
|
493
|
-
pluginMode: missingPlugin
|
|
494
|
-
? command === 'cleanup' || command === 'reinstall' ? 'single' : 'multiple'
|
|
495
|
-
: 'none',
|
|
496
|
-
promptForPlatform: missingPlatform,
|
|
497
|
-
promptForScope: missingScope,
|
|
498
|
-
destructive: command === 'uninstall' || command === 'cleanup',
|
|
499
|
-
equivalentCommand: (selection) => equivalentWriteCommand(command, selection, rawOptions),
|
|
500
|
-
equivalentCommandTokens: (selection) => buildEquivalentWriteCommandTokens(command, selection, rawOptions),
|
|
501
|
-
isPluginSelectable: (candidate, selection) => writeCandidateEligibility(command, candidate, selection),
|
|
502
|
-
resultState: overallResultState,
|
|
503
|
-
execute: (selection) => executeWriteCommand(command, selection.plugins, {
|
|
504
|
-
...rawOptions,
|
|
505
|
-
platform: selection.platform,
|
|
506
|
-
scope: selection.scope,
|
|
507
|
-
}, context),
|
|
508
|
-
});
|
|
509
|
-
if (result.cancelled)
|
|
510
|
-
return { cancelled: true };
|
|
511
|
-
return { cancelled: false, result: result.value };
|
|
512
384
|
}
|
|
513
385
|
function parseBareConsoleOptions(argv) {
|
|
514
386
|
if (argv.length === 0) {
|
|
@@ -567,7 +439,7 @@ async function runActionWithContext(context, action) {
|
|
|
567
439
|
Promise.resolve().then(() => context.debugLogger.flush?.()),
|
|
568
440
|
]);
|
|
569
441
|
if (context.diagnostics.debug && context.debugLogger.logFile) {
|
|
570
|
-
writeLine(context.io.stderr,
|
|
442
|
+
writeLine(context.io.stderr, `Debug log: ${context.debugLogger.logFile}`);
|
|
571
443
|
}
|
|
572
444
|
return result;
|
|
573
445
|
}
|
|
@@ -607,42 +479,86 @@ async function runActionWithContext(context, action) {
|
|
|
607
479
|
Promise.resolve().then(() => context.debugLogger.flush?.()),
|
|
608
480
|
]);
|
|
609
481
|
if (context.diagnostics.debug && context.debugLogger.logFile) {
|
|
610
|
-
writeLine(context.io.stderr,
|
|
482
|
+
writeLine(context.io.stderr, `Debug log: ${context.debugLogger.logFile}`);
|
|
611
483
|
}
|
|
612
484
|
throw error;
|
|
613
485
|
}
|
|
614
486
|
}
|
|
615
487
|
function writeJsonReceipt(write, payload) {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
}
|
|
622
|
-
return projectLayer === 'local' ? '当前项目(本机私有覆盖)' : '当前项目';
|
|
488
|
+
const sink = receiptSinks.get(write);
|
|
489
|
+
if (sink)
|
|
490
|
+
sink(payload);
|
|
491
|
+
else
|
|
492
|
+
writeLine(write, JSON.stringify(payload, null, 2));
|
|
623
493
|
}
|
|
624
494
|
function writeConfigApplyNotice(write, receipt) {
|
|
625
|
-
if (receipt.
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
495
|
+
if (receipt.nativeConsent)
|
|
496
|
+
writeLine(write, geminiNativeConsentDiagnostic().message);
|
|
497
|
+
const sanitizeMessage = (message) => redactString(message)
|
|
498
|
+
.replace(/https?:\/\/\S+/giu, '[REDACTED URL]')
|
|
499
|
+
.replace(/file:\/\/\S+/giu, '[REDACTED PATH]')
|
|
500
|
+
.replace(/(?:file:\/\/)?(?:\/[\w.@+-]+){2,}/gu, '[REDACTED PATH]')
|
|
501
|
+
.replace(/[A-Za-z]:\\(?:[^\s\\]+\\)+[^\s\\]*/gu, '[REDACTED PATH]');
|
|
502
|
+
const writeTargetFailures = () => {
|
|
503
|
+
for (const entry of receipt.apply.targetResults.filter((target) => target.state === 'failed' || target.state === 'skipped')) {
|
|
504
|
+
const reason = entry.message
|
|
505
|
+
? `${entry.errorCode ? `[${entry.errorCode}] ` : ''}${sanitizeMessage(entry.message)}`
|
|
506
|
+
: entry.errorCode
|
|
507
|
+
? `失败原因:${entry.errorCode}。`
|
|
508
|
+
: '未提供安全失败原因。';
|
|
509
|
+
const command = `aw plugin sync ${receipt.plugin} --rebuild --target ${entry.target.platform} --context ${entry.target.scope}`;
|
|
510
|
+
const recovery = entry.errorCode === 'invalidConfig'
|
|
511
|
+
? ` 请修复无效配置后运行 ${command}。`
|
|
512
|
+
: entry.errorCode === 'preApplyAuthorizationRequired'
|
|
513
|
+
|| entry.errorCode === 'sharedNativeConfigApplyConfirmationRequired'
|
|
514
|
+
|| entry.errorCode === 'sharedNativeImpactAuthorizationRequired'
|
|
515
|
+
? ` 请运行 ${command} --yes 重试。`
|
|
516
|
+
: entry.state === 'failed'
|
|
517
|
+
? ` 请在解决失败原因后运行 ${command}。`
|
|
518
|
+
: '';
|
|
519
|
+
writeLine(write, `${entry.target.platform}/${entry.target.scope}:${reason}${recovery}`);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
const targetResults = receipt.apply.targetResults;
|
|
523
|
+
if (receipt.apply.state === 'skipped') {
|
|
524
|
+
const message = receipt.apply.reason === 'noConfigChange'
|
|
525
|
+
? '配置内容没有变化,因此没有刷新输出。'
|
|
526
|
+
: receipt.apply.reason === 'noEffectiveConfigChange'
|
|
527
|
+
? '配置存储已更新,但有效配置没有变化,因此没有刷新输出。'
|
|
528
|
+
: receipt.apply.reason === 'notRequested'
|
|
529
|
+
? '配置已保存,但未请求应用配置。'
|
|
530
|
+
: '配置已保存。当前没有可见的 AW 安装目标,因此没有应用配置。';
|
|
629
531
|
writeLine(write, message);
|
|
630
532
|
}
|
|
631
|
-
else {
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
533
|
+
else if (receipt.apply.state === 'unavailable') {
|
|
534
|
+
const fallbackMessages = {
|
|
535
|
+
invalidConfig: '可见目标的有效配置无效。',
|
|
536
|
+
schemaUnavailable: '配置 schema 不可用。',
|
|
537
|
+
sourceUnavailable: '插件来源不可用。',
|
|
538
|
+
effectiveConfigUnavailable: '无法读取有效配置。',
|
|
539
|
+
targetDiscoveryFailed: '无法发现可应用配置的目标。',
|
|
540
|
+
};
|
|
541
|
+
const detail = receipt.apply.error
|
|
542
|
+
? `${receipt.apply.error.code}:${sanitizeMessage(receipt.apply.error.message)}`
|
|
543
|
+
: `${receipt.apply.reason}:${fallbackMessages[receipt.apply.reason]}`;
|
|
544
|
+
const recovery = receipt.apply.reason === 'invalidConfig'
|
|
545
|
+
? '请修复无效配置,再运行 aw plugin sync <source/plugin>。'
|
|
546
|
+
: receipt.apply.reason === 'effectiveConfigUnavailable'
|
|
547
|
+
? '请修复配置,再运行 aw plugin sync <source/plugin>。'
|
|
548
|
+
: receipt.apply.reason === 'schemaUnavailable' || receipt.apply.reason === 'sourceUnavailable'
|
|
549
|
+
? '请修复插件来源或配置,再运行 aw plugin sync <source/plugin>。'
|
|
550
|
+
: '请修复来源或配置,再运行 aw plugin sync <source/plugin>。';
|
|
551
|
+
writeLine(write, `配置已保存,但当前无法应用配置。${detail} ${recovery}`);
|
|
552
|
+
writeTargetFailures();
|
|
639
553
|
}
|
|
640
|
-
|
|
641
|
-
|
|
554
|
+
else {
|
|
555
|
+
const completed = targetResults.filter((entry) => entry.state === 'completed').length;
|
|
556
|
+
const failed = targetResults.filter((entry) => entry.state === 'failed').length;
|
|
557
|
+
const skipped = targetResults.filter((entry) => entry.state === 'skipped').length;
|
|
558
|
+
writeLine(write, `配置已保存。已刷新 ${completed} 个当前可见目标;失败 ${failed} 个;跳过 ${skipped} 个。`);
|
|
559
|
+
writeTargetFailures();
|
|
642
560
|
}
|
|
643
|
-
|
|
644
|
-
function writeProjectLocalConfigNotice(write) {
|
|
645
|
-
writeLine(write, '当前显示的是当前项目的本机私有覆盖层,不作为 repo-visible artifact 渲染输入。');
|
|
561
|
+
writeWarnings(write, receipt.warnings);
|
|
646
562
|
}
|
|
647
563
|
function renderConfigFieldState(field) {
|
|
648
564
|
if (field.valueState === 'invalid') {
|
|
@@ -661,14 +577,14 @@ function writeConfigReadHuman(write, resolved, pluginName) {
|
|
|
661
577
|
writeLine(write, ` stored=${field.storedSourceLayer} ${renderPluginConfigValueForDisplay(field.storedValue)}`);
|
|
662
578
|
}
|
|
663
579
|
if (field.kind === 'manifest' && field.valueState === 'invalid') {
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
writeLine(write, ` aw config unset ${pluginName} ${field.key}${
|
|
671
|
-
writeLine(write, ` aw config reset ${pluginName}${
|
|
580
|
+
const context = resolved.context ?? 'user';
|
|
581
|
+
const definition = resolved.fieldDefinitions?.[field.key];
|
|
582
|
+
if (definition) {
|
|
583
|
+
writeLine(write, ` ${formatPluginConfigSetRecoveryCommand(pluginName, field.key, definition, context, resolved.platform)}`);
|
|
584
|
+
}
|
|
585
|
+
const profileOptions = ` --context ${context}${resolved.platform ? ` --platform ${resolved.platform}` : ''}`;
|
|
586
|
+
writeLine(write, ` aw plugin config unset ${pluginName} ${field.key}${profileOptions}`);
|
|
587
|
+
writeLine(write, ` aw plugin config reset ${pluginName}${profileOptions} --yes`);
|
|
672
588
|
}
|
|
673
589
|
}
|
|
674
590
|
}
|
|
@@ -685,10 +601,13 @@ export function buildProgram(options = {}) {
|
|
|
685
601
|
cwd,
|
|
686
602
|
env,
|
|
687
603
|
io,
|
|
688
|
-
interactive:
|
|
604
|
+
interactive: false,
|
|
605
|
+
reporter: options.reporter ?? createNoopReporter(),
|
|
689
606
|
diagnostics: toCliDiagnosticsOptions(commandName, rawOptions, options.diagnostics),
|
|
690
607
|
});
|
|
691
|
-
|
|
608
|
+
if (io.result)
|
|
609
|
+
receiptSinks.set(io.stdout, io.result);
|
|
610
|
+
const program = new Command().enablePositionalOptions();
|
|
692
611
|
program
|
|
693
612
|
.name('aw')
|
|
694
613
|
.description('Agent workflow marketplace installer')
|
|
@@ -699,9 +618,15 @@ export function buildProgram(options = {}) {
|
|
|
699
618
|
writeErr: (text) => io.stderr(text),
|
|
700
619
|
outputError: (text, write) => write(text),
|
|
701
620
|
});
|
|
621
|
+
const dev = program.command('dev').description('Create, validate, build, and publish author sources');
|
|
622
|
+
const devPlugin = dev.command('plugin').description('Manage plugin source code');
|
|
702
623
|
const plugin = program
|
|
703
624
|
.command('plugin')
|
|
704
|
-
.description('
|
|
625
|
+
.description('Manage plugin demand, outputs, configuration, and author sources');
|
|
626
|
+
registerManagedCommandCli(program, (rawOptions = {}) => createActionContext('command', rawOptions), {
|
|
627
|
+
cliEntry: fileURLToPath(import.meta.url),
|
|
628
|
+
cliVersion: resolveCliVersion(),
|
|
629
|
+
}, (code) => { commandExitState.exitCode = code; });
|
|
705
630
|
const self = program
|
|
706
631
|
.command('self')
|
|
707
632
|
.description('Describe and check this AW executable');
|
|
@@ -725,10 +650,10 @@ export function buildProgram(options = {}) {
|
|
|
725
650
|
writeJsonReceipt(io.stdout, result);
|
|
726
651
|
commandExitState.exitCode = result.ok ? 0 : 1;
|
|
727
652
|
});
|
|
728
|
-
|
|
653
|
+
devPlugin
|
|
729
654
|
.command('capabilities')
|
|
730
655
|
.description('Show the current plugin manifest authoring surface')
|
|
731
|
-
.option('--surface <surface>', 'manifest | build-config | extensions |
|
|
656
|
+
.option('--surface <surface>', 'manifest | build-config | extensions | mcp | config | pre-apply | artifacts | platform-components | platform-capabilities | hook-handlers | managed-commands | native-tools')
|
|
732
657
|
.option('--json', 'emit one machine-readable JSON object', false)
|
|
733
658
|
.action((rawOptions) => {
|
|
734
659
|
try {
|
|
@@ -750,7 +675,7 @@ export function buildProgram(options = {}) {
|
|
|
750
675
|
commandExitState.exitCode = 1;
|
|
751
676
|
}
|
|
752
677
|
});
|
|
753
|
-
|
|
678
|
+
devPlugin
|
|
754
679
|
.command('requirements')
|
|
755
680
|
.description('Inspect or update effective AW capabilities required by a plugin')
|
|
756
681
|
.argument('<plugin-directory>', 'plugin source directory')
|
|
@@ -773,6 +698,8 @@ export function buildProgram(options = {}) {
|
|
|
773
698
|
}
|
|
774
699
|
}
|
|
775
700
|
catch (error) {
|
|
701
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
702
|
+
throw error;
|
|
776
703
|
writeJsonReceipt(io.stdout, {
|
|
777
704
|
schemaVersion: 1,
|
|
778
705
|
command: 'plugin:requirements',
|
|
@@ -782,279 +709,195 @@ export function buildProgram(options = {}) {
|
|
|
782
709
|
commandExitState.exitCode = 1;
|
|
783
710
|
}
|
|
784
711
|
});
|
|
785
|
-
const skill =
|
|
712
|
+
const skill = dev
|
|
786
713
|
.command('skill')
|
|
787
714
|
.description('Install, materialize, or validate Agent Skills');
|
|
788
|
-
const
|
|
789
|
-
.command('
|
|
790
|
-
.description('
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
.option('--json', 'emit one component digest JSON object', false)
|
|
801
|
-
.action(async (componentPath, rawOptions) => {
|
|
802
|
-
const repoRoot = await resolveRepoRoot(cwd);
|
|
803
|
-
const result = await computeReviewComponentDigest({ repoRoot, path: componentPath });
|
|
804
|
-
if (rawOptions.json) {
|
|
805
|
-
writeJsonReceipt(io.stdout, {
|
|
806
|
-
schemaVersion: 1,
|
|
807
|
-
command: 'review:digest',
|
|
808
|
-
ok: true,
|
|
809
|
-
...result,
|
|
810
|
-
});
|
|
811
|
-
return;
|
|
715
|
+
const skillEval = dev
|
|
716
|
+
.command('eval')
|
|
717
|
+
.description('Prepare or diagnose deterministic Agent Skill Eval inputs');
|
|
718
|
+
skillEval
|
|
719
|
+
.command('check')
|
|
720
|
+
.description('Inspect Agent Skill Eval provider readiness without model execution')
|
|
721
|
+
.requiredOption('--json', 'emit one provider doctor JSON object')
|
|
722
|
+
.action(async () => {
|
|
723
|
+
try {
|
|
724
|
+
writeJsonReceipt(io.stdout, await doctorEvalProviders({
|
|
725
|
+
sourceEnv: env,
|
|
726
|
+
}));
|
|
812
727
|
}
|
|
813
|
-
|
|
814
|
-
});
|
|
815
|
-
review
|
|
816
|
-
.command('publish')
|
|
817
|
-
.description('Publish one immutable review record')
|
|
818
|
-
.requiredOption('--kind <skill|workflow|aw-plugin|aw-workflow>', 'review target kind')
|
|
819
|
-
.requiredOption('--target <path-or-id>', 'review target path or ID')
|
|
820
|
-
.requiredOption('--report <report.md>', 'review report Markdown file')
|
|
821
|
-
.option('--scope <scope.json>', 'workflow scope JSON file')
|
|
822
|
-
.option('--result <review-result.json>', 'review result JSON file')
|
|
823
|
-
.option('--check <kind=path>', 'archive one JSON check attachment', (value, previous) => [
|
|
824
|
-
...previous,
|
|
825
|
-
parseReviewAttachment(value, 'Check'),
|
|
826
|
-
], [])
|
|
827
|
-
.option('--evidence <kind=path>', 'archive one JSON evidence attachment', (value, previous) => [
|
|
828
|
-
...previous,
|
|
829
|
-
parseReviewAttachment(value, 'Evidence'),
|
|
830
|
-
], [])
|
|
831
|
-
.option('--release-check <release-check.json>', 'release check JSON file')
|
|
832
|
-
.option('--supersedes <review-id>', 'review ID that this record supersedes')
|
|
833
|
-
.option('--json', 'emit one review record JSON object', false)
|
|
834
|
-
.action(async (rawOptions) => {
|
|
835
|
-
const repoRoot = await resolveRepoRoot(cwd);
|
|
836
|
-
const record = await publishReviewRecord({
|
|
837
|
-
repoRoot,
|
|
838
|
-
kind: rawOptions.kind,
|
|
839
|
-
target: rawOptions.target,
|
|
840
|
-
report: rawOptions.report,
|
|
841
|
-
...(rawOptions.scope === undefined ? {} : { scope: rawOptions.scope }),
|
|
842
|
-
...(rawOptions.result === undefined ? {} : { result: rawOptions.result }),
|
|
843
|
-
...(rawOptions.check.length === 0 ? {} : { checks: rawOptions.check }),
|
|
844
|
-
...(rawOptions.evidence.length === 0 ? {} : { evidence: rawOptions.evidence }),
|
|
845
|
-
...(rawOptions.releaseCheck === undefined ? {} : { releaseCheck: rawOptions.releaseCheck }),
|
|
846
|
-
...(rawOptions.supersedes === undefined ? {} : { supersedes: rawOptions.supersedes }),
|
|
847
|
-
});
|
|
848
|
-
const recordDir = reviewRecordDir(repoRoot, record);
|
|
849
|
-
if (rawOptions.json) {
|
|
728
|
+
catch (error) {
|
|
850
729
|
writeJsonReceipt(io.stdout, {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
ok: true,
|
|
854
|
-
...reviewJsonRecord(repoRoot, record),
|
|
855
|
-
existing: record.existing,
|
|
730
|
+
ok: false,
|
|
731
|
+
error: redactString(error instanceof Error ? error.message : String(error)),
|
|
856
732
|
});
|
|
857
|
-
|
|
733
|
+
commandExitState.exitCode = 1;
|
|
858
734
|
}
|
|
859
|
-
writeLine(io.stdout, `${record.existing ? 'Existing' : 'Published'} review ${record.manifest.reviewId}: ${recordDir}`);
|
|
860
735
|
});
|
|
861
|
-
|
|
862
|
-
.command('
|
|
863
|
-
.description('
|
|
864
|
-
.argument('<
|
|
865
|
-
.
|
|
866
|
-
.
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
736
|
+
skillEval
|
|
737
|
+
.command('prepare')
|
|
738
|
+
.description('Prepare one complete Agent Skill Eval input directory')
|
|
739
|
+
.argument('<plugin>', 'canonical Workspace plugin name')
|
|
740
|
+
.argument('<skill>', 'owner Skill name')
|
|
741
|
+
.option('--suite <suite>', 'Eval suite ID')
|
|
742
|
+
.option('--profile <profile>', 'Eval profile ID')
|
|
743
|
+
.option('--config-file <path>', 'non-sensitive plugin config overrides for the Eval profile')
|
|
744
|
+
.option('--workspace-root <root>', 'Catalog Workspace root')
|
|
745
|
+
.option('--split <split>', 'case split filter')
|
|
746
|
+
.option('--case <id>', 'case ID filter')
|
|
747
|
+
.option('--runs <count>', 'runs per selected case')
|
|
748
|
+
.option('--timeout-ms <milliseconds>', 'timeout for each provider attempt')
|
|
749
|
+
.option('--baseline <mode>', 'append without-skill comparison')
|
|
750
|
+
.option('--previous-version <runtime-skill-root>', 'append a previous-version comparison')
|
|
751
|
+
.option('--keep-workspace', 'retain the preparation materialization workspace', false)
|
|
752
|
+
.requiredOption('--output <spec-directory>', 'new EvalSpec directory')
|
|
753
|
+
.requiredOption('--json', 'emit one preparation receipt JSON object')
|
|
754
|
+
.action(async (pluginName, skillName, rawOptions) => {
|
|
755
|
+
try {
|
|
756
|
+
const workspace = await resolveCatalogWorkspaceRoot({
|
|
757
|
+
cwd,
|
|
758
|
+
...(rawOptions.workspaceRoot === undefined ? {} : { explicitRoot: rawOptions.workspaceRoot }),
|
|
759
|
+
mode: 'existing',
|
|
760
|
+
env,
|
|
876
761
|
});
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
762
|
+
const runs = rawOptions.runs === undefined
|
|
763
|
+
? undefined
|
|
764
|
+
: (/^[1-9][0-9]*$/u.test(rawOptions.runs) ? Number(rawOptions.runs) : Number.NaN);
|
|
765
|
+
const timeoutMs = rawOptions.timeoutMs === undefined
|
|
766
|
+
? undefined
|
|
767
|
+
: (/^[1-9][0-9]*$/u.test(rawOptions.timeoutMs) ? Number(rawOptions.timeoutMs) : Number.NaN);
|
|
768
|
+
const receipt = await prepareSkillEval({
|
|
769
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
770
|
+
workspaceRootResolvedFrom: workspace.workspaceRootResolvedFrom,
|
|
771
|
+
pluginName,
|
|
772
|
+
skillName,
|
|
773
|
+
...(rawOptions.suite === undefined ? {} : { suiteId: rawOptions.suite }),
|
|
774
|
+
...(rawOptions.profile === undefined ? {} : { profileId: rawOptions.profile }),
|
|
775
|
+
...(rawOptions.configFile === undefined ? {} : { configFile: path.resolve(cwd, rawOptions.configFile) }),
|
|
776
|
+
output: rawOptions.output,
|
|
777
|
+
cwd,
|
|
778
|
+
env,
|
|
779
|
+
...(rawOptions.split === undefined ? {} : { split: rawOptions.split }),
|
|
780
|
+
...(rawOptions.case === undefined ? {} : { caseId: rawOptions.case }),
|
|
781
|
+
...(runs === undefined ? {} : { runs }),
|
|
782
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
783
|
+
...(rawOptions.baseline === undefined ? {} : {
|
|
784
|
+
baseline: rawOptions.baseline,
|
|
785
|
+
}),
|
|
786
|
+
...(rawOptions.previousVersion === undefined ? {} : {
|
|
787
|
+
previousVersion: rawOptions.previousVersion,
|
|
788
|
+
}),
|
|
789
|
+
...(rawOptions.keepWorkspace === true ? { keepWorkspace: true } : {}),
|
|
900
790
|
});
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
for (const record of records) {
|
|
904
|
-
writeLine(io.stdout, [
|
|
905
|
-
record.manifest.reviewId,
|
|
906
|
-
record.manifest.target.kind,
|
|
907
|
-
record.manifest.target.id,
|
|
908
|
-
record.manifest.publishedAt,
|
|
909
|
-
].join(' '));
|
|
791
|
+
writeJsonReceipt(io.stdout, receipt);
|
|
910
792
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
.description('Show one immutable review record')
|
|
915
|
-
.argument('<review-id>', 'review record ID')
|
|
916
|
-
.option('--json', 'emit one review record JSON object', false)
|
|
917
|
-
.action(async (reviewId, rawOptions) => {
|
|
918
|
-
const repoRoot = await resolveRepoRoot(cwd);
|
|
919
|
-
const record = await showReviewRecord({ repoRoot, reviewId });
|
|
920
|
-
if (rawOptions.json) {
|
|
793
|
+
catch (error) {
|
|
794
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
795
|
+
throw error;
|
|
921
796
|
writeJsonReceipt(io.stdout, {
|
|
922
797
|
schemaVersion: 1,
|
|
923
|
-
command: '
|
|
924
|
-
ok: true,
|
|
925
|
-
...reviewJsonRecord(repoRoot, record),
|
|
926
|
-
});
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
const manifest = record.manifest;
|
|
930
|
-
writeLine(io.stdout, `Review: ${manifest.reviewId}`);
|
|
931
|
-
writeLine(io.stdout, `Target: ${manifest.target.kind} ${manifest.target.id}`);
|
|
932
|
-
writeLine(io.stdout, `Published: ${manifest.publishedAt}`);
|
|
933
|
-
writeLine(io.stdout, `Report: ${manifest.report.path}`);
|
|
934
|
-
writeLine(io.stdout, `Result: ${manifest.result?.path ?? 'none'}`);
|
|
935
|
-
writeLine(io.stdout, `Checks: ${manifest.checks.map((entry) => entry.kind).join(', ') || 'none'}`);
|
|
936
|
-
writeLine(io.stdout, `Evidence: ${manifest.evidence.map((entry) => entry.kind).join(', ') || 'none'}`);
|
|
937
|
-
writeLine(io.stdout, `Release check: ${manifest.releaseCheck?.path ?? 'none'}`);
|
|
938
|
-
writeLine(io.stdout, `Supersedes: ${manifest.supersedes ?? 'none'}`);
|
|
939
|
-
});
|
|
940
|
-
skill
|
|
941
|
-
.command('install')
|
|
942
|
-
.description('Install portable Skills through the skills CLI')
|
|
943
|
-
.argument('<plugin>', 'plugin or source/plugin selector')
|
|
944
|
-
.requiredOption('-s, --scope <scope>', 'project or user')
|
|
945
|
-
.option('--skill <name...>', 'install only selected Skill names')
|
|
946
|
-
.option('--agent <id...>', 'install to explicit Agent IDs')
|
|
947
|
-
.option('-y, --yes', 'confirm the reviewed install', false)
|
|
948
|
-
.option('-j, --json', 'emit one receipt v4 JSON object', false)
|
|
949
|
-
.action(async (selector, rawOptions) => {
|
|
950
|
-
const context = createActionContext('skill:install', {});
|
|
951
|
-
const writeFailure = (error) => {
|
|
952
|
-
const capabilityError = error instanceof AwCapabilityUnsupportedError ? error : undefined;
|
|
953
|
-
const code = capabilityError?.code
|
|
954
|
-
?? (error instanceof PortableCommandError || error instanceof SkillsCliError
|
|
955
|
-
? error.code
|
|
956
|
-
: 'portableInstallFailed');
|
|
957
|
-
writeJsonReceipt(io.stdout, {
|
|
958
|
-
receiptSchemaVersion: 4,
|
|
959
|
-
command: 'skill:install',
|
|
798
|
+
command: 'skill:eval:prepare',
|
|
960
799
|
ok: false,
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
selectedSkills: [],
|
|
965
|
-
...(rawOptions.skill ? { requestedSkills: rawOptions.skill } : {}),
|
|
966
|
-
agentMode: rawOptions.agent ? 'explicit' : 'automatic',
|
|
967
|
-
requestedAgents: rawOptions.agent ?? [],
|
|
968
|
-
skillsCliVersion: null,
|
|
969
|
-
collisions: [],
|
|
970
|
-
dependencies: [],
|
|
971
|
-
materializationDigest: null,
|
|
972
|
-
verification: { records: [], missing: [] },
|
|
973
|
-
warnings: [],
|
|
974
|
-
failures: [{
|
|
975
|
-
code,
|
|
976
|
-
message: capabilityError?.message ?? `${code}: portable Skill 安装未执行。`,
|
|
977
|
-
...(capabilityError ? {
|
|
978
|
-
plugin: capabilityError.plugin,
|
|
979
|
-
missingCapabilities: capabilityError.missingCapabilities,
|
|
980
|
-
availableCapabilities: capabilityError.availableCapabilities,
|
|
981
|
-
} : {}),
|
|
800
|
+
errors: [{
|
|
801
|
+
code: 'evalPreparationFailed',
|
|
802
|
+
message: redactString(error instanceof Error ? error.message : String(error)),
|
|
982
803
|
}],
|
|
983
804
|
});
|
|
984
|
-
};
|
|
985
|
-
if (rawOptions.json && !rawOptions.yes) {
|
|
986
|
-
writeFailure(new PortableCommandError('confirmationRequired', '写入型 --json 必须同时使用 --yes。'));
|
|
987
805
|
commandExitState.exitCode = 1;
|
|
988
|
-
return;
|
|
989
806
|
}
|
|
807
|
+
});
|
|
808
|
+
const review = dev
|
|
809
|
+
.command('review')
|
|
810
|
+
.description('Inspect and prepare Skill review materializations');
|
|
811
|
+
review
|
|
812
|
+
.command('inspect')
|
|
813
|
+
.description('Inspect current AW Review source and materialization facts')
|
|
814
|
+
.argument('<target>', 'Catalog Workspace, Plugin, or source Skill path')
|
|
815
|
+
.addOption(strictValueOption('--workspace-root <root>', 'explicit Catalog Workspace root'))
|
|
816
|
+
.option('--skill <name>', 'select one declared Skill', collectUniqueOption, [])
|
|
817
|
+
.addOption(strictValueOption('--platform <platform>', 'select a canonical platform target', PLATFORM_TARGETS))
|
|
818
|
+
.addOption(strictValueOption('--scope <scope>', 'select user or project scope', ['user', 'project']))
|
|
819
|
+
.addOption(strictValueOption('--config <file>', 'review config JSON file'))
|
|
820
|
+
.option('--materialization <receipt>', 'validate one aw-source-binding receipt', collectUniqueOption, [])
|
|
821
|
+
.addOption(strictValueOption('--view <view>', 'select the review navigation view', ['review']).default('review'))
|
|
822
|
+
.option('--json', 'emit one Review inspection JSON object', false)
|
|
823
|
+
.action(async (target, rawOptions) => {
|
|
990
824
|
try {
|
|
991
|
-
const receipt = await
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
...(rawOptions.
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
...(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
...(!rawOptions.json ? {
|
|
1007
|
-
onReview: (review) => {
|
|
1008
|
-
for (const line of renderPortableReview(review))
|
|
1009
|
-
writeLine(io.stdout, line);
|
|
1010
|
-
},
|
|
1011
|
-
} : {}),
|
|
1012
|
-
}));
|
|
825
|
+
const receipt = await inspectReviewTarget({
|
|
826
|
+
cwd,
|
|
827
|
+
target,
|
|
828
|
+
...(rawOptions.workspaceRoot === undefined
|
|
829
|
+
? {}
|
|
830
|
+
: { workspaceRoot: rawOptions.workspaceRoot }),
|
|
831
|
+
skills: rawOptions.skill,
|
|
832
|
+
...(rawOptions.platform === undefined ? {} : { platform: rawOptions.platform }),
|
|
833
|
+
...(rawOptions.scope === undefined ? {} : { scope: rawOptions.scope }),
|
|
834
|
+
...(rawOptions.config === undefined ? {} : { configFile: rawOptions.config }),
|
|
835
|
+
materializations: [...new Set(rawOptions.materialization
|
|
836
|
+
.map((entry) => path.resolve(cwd, entry)))],
|
|
837
|
+
view: rawOptions.view,
|
|
838
|
+
env,
|
|
839
|
+
});
|
|
1013
840
|
if (rawOptions.json)
|
|
1014
841
|
writeJsonReceipt(io.stdout, receipt);
|
|
1015
|
-
else
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
const sanitize = (value) => redactString(value)
|
|
1019
|
-
.replace(/https?:\/\/\S+/giu, '[REDACTED URL]')
|
|
1020
|
-
.replace(/(?:file:\/\/)?(?:\/[\w.@+-]+){2,}/gu, '[REDACTED PATH]')
|
|
1021
|
-
.replace(/[A-Za-z]:\\(?:[^\s\\]+\\)+[^\s\\]*/gu, '[REDACTED PATH]');
|
|
1022
|
-
const lines = new Set();
|
|
1023
|
-
for (const failure of receipt.failures) {
|
|
1024
|
-
lines.add(`${failure.code}: ${sanitize(failure.message)}`);
|
|
1025
|
-
}
|
|
1026
|
-
for (const warning of receipt.warnings)
|
|
1027
|
-
lines.add(`警告:${sanitize(warning)}`);
|
|
1028
|
-
const recoveries = receipt.failures.map((failure) => failure.recovery).filter(Boolean);
|
|
1029
|
-
const recovery = recoveries.find((entry) => entry.includes('aw skill install')
|
|
1030
|
-
&& entry.includes('skills remove'))
|
|
1031
|
-
?? '重新运行 aw skill install;如需清理外部写入,请使用 skills remove。';
|
|
1032
|
-
lines.add(`恢复:${sanitize(recovery)}`);
|
|
1033
|
-
for (const line of lines)
|
|
1034
|
-
writeLine(io.stderr, line);
|
|
1035
|
-
}
|
|
1036
|
-
commandExitState.exitCode = receipt.ok ? 0 : 1;
|
|
842
|
+
else
|
|
843
|
+
renderReviewInspection(io.stdout, receipt);
|
|
844
|
+
commandExitState.exitCode = 0;
|
|
1037
845
|
}
|
|
1038
846
|
catch (error) {
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
847
|
+
const receipt = createReviewInspectionFailure(error);
|
|
848
|
+
if (rawOptions.json)
|
|
849
|
+
writeJsonReceipt(io.stdout, receipt);
|
|
850
|
+
else
|
|
851
|
+
renderReviewInspection(io.stdout, receipt);
|
|
852
|
+
commandExitState.exitCode = getReviewInspectionExitCode(error);
|
|
1043
853
|
}
|
|
1044
854
|
});
|
|
855
|
+
review
|
|
856
|
+
.command('prepare')
|
|
857
|
+
.description('Prepare deterministic Skill finals for AW Review')
|
|
858
|
+
.argument('<target>', 'Plugin or source Skill path')
|
|
859
|
+
.addOption(strictValueOption('--workspace-root <root>', 'explicit Catalog Workspace root'))
|
|
860
|
+
.option('--skill <name>', 'select one declared Skill', collectUniqueOption, [])
|
|
861
|
+
.addOption(strictValueOption('--platform <platform>', 'select a canonical platform target', PLATFORM_TARGETS).makeOptionMandatory())
|
|
862
|
+
.addOption(strictValueOption('--scope <scope>', 'select user or project scope', ['user', 'project']).makeOptionMandatory())
|
|
863
|
+
.addOption(strictValueOption('--config <file>', 'review config JSON file'))
|
|
864
|
+
.addOption(strictValueOption('--out <new-dir>', 'new output directory').makeOptionMandatory())
|
|
865
|
+
.option('--json', 'emit one Review preparation JSON object', false)
|
|
866
|
+
.action(async (target, rawOptions) => {
|
|
867
|
+
const result = await prepareReviewTarget({
|
|
868
|
+
cwd,
|
|
869
|
+
target,
|
|
870
|
+
...(rawOptions.workspaceRoot === undefined
|
|
871
|
+
? {}
|
|
872
|
+
: { workspaceRoot: rawOptions.workspaceRoot }),
|
|
873
|
+
skills: rawOptions.skill,
|
|
874
|
+
platform: rawOptions.platform,
|
|
875
|
+
scope: rawOptions.scope,
|
|
876
|
+
...(rawOptions.config === undefined ? {} : { configFile: rawOptions.config }),
|
|
877
|
+
out: rawOptions.out,
|
|
878
|
+
env,
|
|
879
|
+
});
|
|
880
|
+
if (rawOptions.json)
|
|
881
|
+
writeJsonReceipt(io.stdout, result.receipt);
|
|
882
|
+
else
|
|
883
|
+
renderReviewPreparation(io.stdout, result.receipt);
|
|
884
|
+
commandExitState.exitCode = result.exitCode;
|
|
885
|
+
});
|
|
1045
886
|
skill
|
|
1046
|
-
.command('
|
|
887
|
+
.command('export')
|
|
1047
888
|
.description('Write portable Skills to a safe output directory')
|
|
1048
889
|
.argument('<plugin>', 'plugin or source/plugin selector')
|
|
1049
|
-
.
|
|
890
|
+
.addOption(strictValueOption('--platform <target>', 'Platform target profile', PLATFORM_TARGETS).makeOptionMandatory())
|
|
891
|
+
.addOption(strictValueOption('-s, --scope <scope>', 'artifact scope', ['user', 'project']).makeOptionMandatory())
|
|
1050
892
|
.requiredOption('--out <dir>', 'output directory')
|
|
1051
893
|
.option('--skill <name...>', 'write only selected Skill names')
|
|
1052
|
-
.option('-j, --json', 'emit one receipt
|
|
894
|
+
.option('-j, --json', 'emit one receipt v5 JSON object', false)
|
|
1053
895
|
.action(async (selector, rawOptions) => {
|
|
1054
896
|
const context = createActionContext('skill:materialize', {});
|
|
1055
897
|
try {
|
|
1056
898
|
const receipt = await runActionWithContext(context, () => materializePortableSkillsToDirectory({
|
|
1057
899
|
selector,
|
|
900
|
+
platform: rawOptions.platform,
|
|
1058
901
|
scope: rawOptions.scope,
|
|
1059
902
|
out: rawOptions.out,
|
|
1060
903
|
...(rawOptions.skill ? { requestedSkills: rawOptions.skill } : {}),
|
|
@@ -1072,15 +915,16 @@ export function buildProgram(options = {}) {
|
|
|
1072
915
|
throw error;
|
|
1073
916
|
const capabilityError = error instanceof AwCapabilityUnsupportedError ? error : undefined;
|
|
1074
917
|
const code = capabilityError?.code
|
|
1075
|
-
?? (error instanceof PortableCommandError
|
|
918
|
+
?? (error instanceof PortableCommandError
|
|
1076
919
|
? error.code
|
|
1077
920
|
: 'portableMaterializeFailed');
|
|
1078
921
|
writeJsonReceipt(io.stdout, {
|
|
1079
|
-
receiptSchemaVersion:
|
|
922
|
+
receiptSchemaVersion: 5,
|
|
1080
923
|
command: 'skill:materialize',
|
|
1081
924
|
ok: false,
|
|
1082
925
|
plugin: { id: selector },
|
|
1083
926
|
scope: rawOptions.scope,
|
|
927
|
+
platform: rawOptions.platform,
|
|
1084
928
|
out: path.resolve(context.cwd, rawOptions.out),
|
|
1085
929
|
selectedSkills: [],
|
|
1086
930
|
...(rawOptions.skill ? { requestedSkills: rawOptions.skill } : {}),
|
|
@@ -1101,14 +945,14 @@ export function buildProgram(options = {}) {
|
|
|
1101
945
|
commandExitState.exitCode = 1;
|
|
1102
946
|
}
|
|
1103
947
|
});
|
|
1104
|
-
|
|
1105
|
-
.command('
|
|
948
|
+
devPlugin
|
|
949
|
+
.command('create')
|
|
1106
950
|
.description('Create a new deterministic plugin scaffold')
|
|
1107
951
|
.addHelpText('after', [
|
|
1108
952
|
'',
|
|
1109
953
|
'During development, keep the current stable target when production content changes.',
|
|
1110
|
-
'Next, run `aw plugin validate`, `aw plugin test`, `aw plugin build`, and `aw catalog build`.',
|
|
1111
|
-
'Publish only as an explicit later step; inspect `aw catalog publish --help` first.',
|
|
954
|
+
'Next, run `aw dev plugin validate`, `aw dev plugin test`, `aw dev plugin build`, and `aw dev catalog build`.',
|
|
955
|
+
'Publish only as an explicit later step; inspect `aw dev catalog publish plan --help` first.',
|
|
1112
956
|
'',
|
|
1113
957
|
].join('\n'))
|
|
1114
958
|
.argument('<plugin-name>', 'lowercase hyphen-case plugin name')
|
|
@@ -1123,46 +967,40 @@ export function buildProgram(options = {}) {
|
|
|
1123
967
|
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from current directory)')
|
|
1124
968
|
.option('--no-skills', 'create the plugin without a skills directory')
|
|
1125
969
|
.option('--with-mcp', 'add a minimal .mcp.json', false)
|
|
1126
|
-
.option('--with-apps', 'add a minimal .app.json', false)
|
|
1127
970
|
.option('--with-config-api', 'add AW config schema and helper', false)
|
|
1128
|
-
.option('--with-
|
|
1129
|
-
|
|
1130
|
-
.command('
|
|
971
|
+
.option('--with-pre-apply', 'add an idempotent Node preApply environment check', false);
|
|
972
|
+
skill
|
|
973
|
+
.command('create')
|
|
1131
974
|
.description('Add one static Skill scaffold to an existing plugin')
|
|
1132
975
|
.addHelpText('after', [
|
|
1133
976
|
'',
|
|
1134
977
|
'During development, keep the current stable target when production content changes.',
|
|
1135
|
-
'Next, run `aw plugin validate`, `aw plugin test`, `aw plugin build`, and `aw catalog build`.',
|
|
1136
|
-
'Publish only as an explicit later step; inspect `aw catalog publish --help` first.',
|
|
978
|
+
'Next, run `aw dev plugin validate`, `aw dev plugin test`, `aw dev plugin build`, and `aw dev catalog build`.',
|
|
979
|
+
'Publish only as an explicit later step; inspect `aw dev catalog publish plan --help` first.',
|
|
1137
980
|
'',
|
|
1138
981
|
].join('\n'))
|
|
1139
|
-
.
|
|
982
|
+
.requiredOption('--plugin <name>', 'Plugin that owns the Skill')
|
|
1140
983
|
.option('--skill-name <name>', 'new static Skill name (required)')
|
|
1141
984
|
.option('--skill-description <text>', 'Skill goal and discovery description (required)')
|
|
1142
985
|
.option('--skill-short-description <text>', 'Skill UI summary (25-64 characters)')
|
|
1143
986
|
.option('--skill-invocation <mode>', 'model | manual | claude-model-only (default: model)')
|
|
1144
987
|
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from current directory)');
|
|
1145
|
-
|
|
1146
|
-
.command('remove')
|
|
1147
|
-
.description('Remove one committed and unchanged canonical plugin source tree')
|
|
1148
|
-
.argument('<plugin-name>', 'existing lowercase hyphen-case plugin name')
|
|
1149
|
-
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from current directory)')
|
|
1150
|
-
.option('--yes', 'confirm plugin source deletion', false)
|
|
1151
|
-
.option('--json', 'emit one schema 1 JSON object', false);
|
|
1152
|
-
plugin
|
|
988
|
+
devPlugin
|
|
1153
989
|
.command('validate')
|
|
1154
990
|
.description('Validate one source plugin directory')
|
|
1155
991
|
.argument('<plugin-directory>', 'source plugin directory')
|
|
1156
992
|
.option('--strict-agent-skills', 'allow only Agent Skills portable core frontmatter', false)
|
|
1157
|
-
.option('--claude-skill-profile <profile>', '
|
|
993
|
+
.option('--claude-skill-profile <profile>', 'current (default) | minimum (Claude 2.1.88 fields)')
|
|
1158
994
|
.option('--version-base <git-ref>', 'production bundle comparison base (default: HEAD)')
|
|
1159
995
|
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from plugin directory)')
|
|
1160
996
|
.option('--json', 'emit one machine-readable JSON result', false);
|
|
1161
|
-
|
|
997
|
+
devPlugin
|
|
1162
998
|
.command('test')
|
|
1163
999
|
.description('Run deterministic Node tests declared by one source plugin')
|
|
1164
1000
|
.argument('<plugin-directory>', 'source plugin directory')
|
|
1165
1001
|
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from plugin directory)')
|
|
1002
|
+
.option('--native-mode <mode>', 'fixture | installed | source-candidate (default: fixture)')
|
|
1003
|
+
.option('--native-context <path>', 'explicit tool context JSON for fixture or source-candidate mode')
|
|
1166
1004
|
.option('--json', 'emit one machine-readable JSON result', false)
|
|
1167
1005
|
.action(async (pluginDirectory, rawOptions) => {
|
|
1168
1006
|
try {
|
|
@@ -1174,11 +1012,15 @@ export function buildProgram(options = {}) {
|
|
|
1174
1012
|
commandExitState.exitCode = await runPluginTestCommand({
|
|
1175
1013
|
...workspace,
|
|
1176
1014
|
pluginDirectory: path.resolve(cwd, pluginDirectory),
|
|
1015
|
+
nativeMode: rawOptions.nativeMode,
|
|
1016
|
+
nativeContext: rawOptions.nativeContext ? path.resolve(cwd, rawOptions.nativeContext) : undefined,
|
|
1177
1017
|
json: rawOptions.json,
|
|
1178
1018
|
io,
|
|
1179
1019
|
});
|
|
1180
1020
|
}
|
|
1181
1021
|
catch (error) {
|
|
1022
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1023
|
+
throw error;
|
|
1182
1024
|
const message = error instanceof Error ? error.message : String(error);
|
|
1183
1025
|
if (rawOptions.json)
|
|
1184
1026
|
writeJsonReceipt(io.stdout, { command: 'plugin:test', ok: false, errors: [{ message }] });
|
|
@@ -1186,7 +1028,7 @@ export function buildProgram(options = {}) {
|
|
|
1186
1028
|
commandExitState.exitCode = 1;
|
|
1187
1029
|
}
|
|
1188
1030
|
});
|
|
1189
|
-
|
|
1031
|
+
devPlugin
|
|
1190
1032
|
.command('build')
|
|
1191
1033
|
.description('Build and inspect one source plugin bundle')
|
|
1192
1034
|
.argument('<plugin-directory>', 'source plugin directory')
|
|
@@ -1211,6 +1053,8 @@ export function buildProgram(options = {}) {
|
|
|
1211
1053
|
});
|
|
1212
1054
|
}
|
|
1213
1055
|
catch (error) {
|
|
1056
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1057
|
+
throw error;
|
|
1214
1058
|
const message = error instanceof Error ? error.message : String(error);
|
|
1215
1059
|
if (rawOptions.json)
|
|
1216
1060
|
writeJsonReceipt(io.stdout, { command: 'plugin:build', ok: false, errors: [{ message }] });
|
|
@@ -1218,14 +1062,6 @@ export function buildProgram(options = {}) {
|
|
|
1218
1062
|
commandExitState.exitCode = 1;
|
|
1219
1063
|
}
|
|
1220
1064
|
});
|
|
1221
|
-
plugin
|
|
1222
|
-
.command('status')
|
|
1223
|
-
.description('Show current plugin status or compare against an explicit Git base')
|
|
1224
|
-
.argument('[plugin-name]', 'one explicit plugin name')
|
|
1225
|
-
.option('--all', 'check every current Catalog Workspace plugin', false)
|
|
1226
|
-
.option('--base <git-ref>', 'explicit Git comparison base')
|
|
1227
|
-
.option('--json', 'emit one schema v3 JSON document', false)
|
|
1228
|
-
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from current directory)');
|
|
1229
1065
|
skill
|
|
1230
1066
|
.command('validate')
|
|
1231
1067
|
.description('Validate one Agent Skill directory')
|
|
@@ -1233,11 +1069,11 @@ export function buildProgram(options = {}) {
|
|
|
1233
1069
|
.option('--frontmatter-profile <profile>', 'portable-agent-skills | claude-2.1.88 | claude-current (default: portable-agent-skills)')
|
|
1234
1070
|
.option('--codex-metadata <policy>', 'required | optional | ignore (default: optional)')
|
|
1235
1071
|
.option('--json', 'emit one machine-readable JSON result', false);
|
|
1236
|
-
const catalog =
|
|
1072
|
+
const catalog = dev
|
|
1237
1073
|
.command('catalog')
|
|
1238
1074
|
.description('Build and manage catalogs');
|
|
1239
1075
|
catalog
|
|
1240
|
-
.command('
|
|
1076
|
+
.command('create')
|
|
1241
1077
|
.description('Initialize a local AW Catalog Workspace')
|
|
1242
1078
|
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor, then Git worktree root, then current directory)')
|
|
1243
1079
|
.option('--owner-name <name>', 'catalog owner name')
|
|
@@ -1252,6 +1088,7 @@ export function buildProgram(options = {}) {
|
|
|
1252
1088
|
cwd,
|
|
1253
1089
|
...(rawOptions.workspaceRoot === undefined ? {} : { explicitRoot: rawOptions.workspaceRoot }),
|
|
1254
1090
|
mode: 'initialize',
|
|
1091
|
+
env,
|
|
1255
1092
|
});
|
|
1256
1093
|
await runCatalogInitCommand({
|
|
1257
1094
|
...rawOptions,
|
|
@@ -1267,27 +1104,6 @@ export function buildProgram(options = {}) {
|
|
|
1267
1104
|
commandExitState.exitCode = 1;
|
|
1268
1105
|
}
|
|
1269
1106
|
});
|
|
1270
|
-
catalog
|
|
1271
|
-
.command('context')
|
|
1272
|
-
.description('Inspect resolved Catalog Workspace and publication context without network access')
|
|
1273
|
-
.option('--workspace-root <path>', 'explicit Catalog Workspace root')
|
|
1274
|
-
.option('--remote <name>', 'Git remote (default: origin, otherwise sole remote; explicit if ambiguous)')
|
|
1275
|
-
.option('--branch <name>', 'explicit Catalog publication branch')
|
|
1276
|
-
.requiredOption('--json', 'emit one schema 1 JSON object')
|
|
1277
|
-
.action(async (rawOptions) => {
|
|
1278
|
-
const receipt = await getCatalogContext({
|
|
1279
|
-
cwd,
|
|
1280
|
-
workspaceRoot: rawOptions.workspaceRoot,
|
|
1281
|
-
remote: rawOptions.remote,
|
|
1282
|
-
branch: rawOptions.branch,
|
|
1283
|
-
env,
|
|
1284
|
-
awVersion: resolveCliVersion(),
|
|
1285
|
-
capabilities: IMPLEMENTED_AW_CAPABILITIES,
|
|
1286
|
-
});
|
|
1287
|
-
writeJsonReceipt(io.stdout, receipt);
|
|
1288
|
-
if (receipt.issues.some((issue) => issue.blocking))
|
|
1289
|
-
commandExitState.exitCode = 1;
|
|
1290
|
-
});
|
|
1291
1107
|
catalog
|
|
1292
1108
|
.command('version')
|
|
1293
1109
|
.description('Read or set the Catalog version')
|
|
@@ -1311,6 +1127,8 @@ export function buildProgram(options = {}) {
|
|
|
1311
1127
|
});
|
|
1312
1128
|
}
|
|
1313
1129
|
catch (error) {
|
|
1130
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1131
|
+
throw error;
|
|
1314
1132
|
const message = error instanceof Error ? error.message : String(error);
|
|
1315
1133
|
if (rawOptions.json)
|
|
1316
1134
|
writeJsonReceipt(io.stdout, { command: 'catalog:version', ok: false, errors: [{ message }] });
|
|
@@ -1341,6 +1159,8 @@ export function buildProgram(options = {}) {
|
|
|
1341
1159
|
});
|
|
1342
1160
|
}
|
|
1343
1161
|
catch (error) {
|
|
1162
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1163
|
+
throw error;
|
|
1344
1164
|
const message = error instanceof Error ? error.message : String(error);
|
|
1345
1165
|
if (rawOptions.json)
|
|
1346
1166
|
writeJsonReceipt(io.stdout, { command: 'catalog:build', ok: false, errors: [{ message }] });
|
|
@@ -1350,7 +1170,7 @@ export function buildProgram(options = {}) {
|
|
|
1350
1170
|
});
|
|
1351
1171
|
catalog
|
|
1352
1172
|
.command('validate')
|
|
1353
|
-
.description('Validate a schema
|
|
1173
|
+
.description('Validate a schema 7 Catalog snapshot')
|
|
1354
1174
|
.argument('<snapshot-directory>', 'Catalog snapshot directory')
|
|
1355
1175
|
.option('--json', 'emit one machine-readable JSON result', false)
|
|
1356
1176
|
.action(async (snapshotDirectory, rawOptions) => {
|
|
@@ -1371,19 +1191,13 @@ export function buildProgram(options = {}) {
|
|
|
1371
1191
|
});
|
|
1372
1192
|
catalog
|
|
1373
1193
|
.command('status')
|
|
1374
|
-
.description('Inspect
|
|
1194
|
+
.description('Inspect static Catalog Workspace, snapshot, and Git facts')
|
|
1375
1195
|
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from current directory)')
|
|
1376
|
-
.option('--remote <name>', 'Git remote for preflight (default: origin, otherwise sole remote; explicit if ambiguous)')
|
|
1377
|
-
.option('--branch <name>', 'dedicated Catalog branch for preflight (default: catalog)')
|
|
1378
|
-
.option('--preflight', 'run publication validation and temporary plugin builds (executes plugin code)', false)
|
|
1379
1196
|
.option('--json', 'emit one machine-readable JSON status object', false)
|
|
1380
1197
|
.action(async (rawOptions) => {
|
|
1381
1198
|
const receipt = await getCatalogStatus({
|
|
1382
1199
|
cwd,
|
|
1383
1200
|
workspaceRoot: rawOptions.workspaceRoot,
|
|
1384
|
-
remote: rawOptions.remote,
|
|
1385
|
-
branch: rawOptions.branch,
|
|
1386
|
-
preflight: rawOptions.preflight,
|
|
1387
1201
|
env,
|
|
1388
1202
|
});
|
|
1389
1203
|
if (rawOptions.json)
|
|
@@ -1392,33 +1206,85 @@ export function buildProgram(options = {}) {
|
|
|
1392
1206
|
io.stdout(renderCatalogStatus(receipt));
|
|
1393
1207
|
commandExitState.exitCode = receipt.ok ? 0 : 1;
|
|
1394
1208
|
});
|
|
1395
|
-
catalog
|
|
1209
|
+
const catalogPublish = catalog
|
|
1396
1210
|
.command('publish')
|
|
1397
|
-
.description('
|
|
1211
|
+
.description('Plan or apply a versioned Catalog publication');
|
|
1212
|
+
catalogPublish
|
|
1213
|
+
.command('plan')
|
|
1214
|
+
.description('Prepare and inspect the exact Catalog publication plan')
|
|
1398
1215
|
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from current directory)')
|
|
1399
1216
|
.option('--remote <name>', 'Git remote (default: origin, otherwise sole remote; explicit if ambiguous)')
|
|
1400
1217
|
.option('--branch <name>', 'dedicated Catalog branch (default: catalog)')
|
|
1401
|
-
.option('--expected-descriptor-digest <digest>', 'required exact descriptor returned by publication preflight')
|
|
1402
|
-
.option('-y, --yes', 'confirm publication without a prompt', false)
|
|
1403
1218
|
.option('--json', 'emit one machine-readable JSON result', false)
|
|
1404
1219
|
.action(async (rawOptions) => {
|
|
1405
1220
|
try {
|
|
1406
|
-
const
|
|
1407
|
-
const result = await runCatalogPublishCommand({
|
|
1221
|
+
const result = await runCatalogPublishPlanCommand({
|
|
1408
1222
|
cwd,
|
|
1409
1223
|
workspaceRoot: rawOptions.workspaceRoot,
|
|
1410
1224
|
remote: rawOptions.remote,
|
|
1411
1225
|
branch: rawOptions.branch,
|
|
1412
|
-
expectedDescriptorDigest: rawOptions.expectedDescriptorDigest,
|
|
1413
|
-
yes: rawOptions.yes,
|
|
1414
|
-
json: rawOptions.json,
|
|
1415
1226
|
env,
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1227
|
+
io,
|
|
1228
|
+
});
|
|
1229
|
+
if (rawOptions.json)
|
|
1230
|
+
writeJsonReceipt(io.stdout, result);
|
|
1231
|
+
else {
|
|
1232
|
+
writeLine(io.stdout, `Workspace identity: ${result.workspaceIdentity}`);
|
|
1233
|
+
writeLine(io.stdout, `Source HEAD: ${result.sourceHead}`);
|
|
1234
|
+
writeLine(io.stdout, `Remote identity: ${result.descriptor.remote.identityDigest}`);
|
|
1235
|
+
writeLine(io.stdout, `Remote: ${result.remote} (${result.remoteUrl})`);
|
|
1236
|
+
writeLine(io.stdout, `Branch: refs/heads/${result.branch}`);
|
|
1237
|
+
writeLine(io.stdout, `Parent: ${result.parent ?? '<root>'}`);
|
|
1238
|
+
writeLine(io.stdout, `Tag: refs/tags/${result.tag}`);
|
|
1239
|
+
writeLine(io.stdout, `Snapshot digest: ${result.snapshotDigest}`);
|
|
1240
|
+
writeLine(io.stdout, `Expected commit: ${result.expectedCommit}`);
|
|
1241
|
+
writeLine(io.stdout, `Plan digest: ${result.planDigest}`);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
catch (error) {
|
|
1245
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1246
|
+
throw error;
|
|
1247
|
+
const failure = catalogPublicationFailure({
|
|
1248
|
+
error,
|
|
1249
|
+
env,
|
|
1250
|
+
sensitiveRoots: [
|
|
1251
|
+
cwd,
|
|
1252
|
+
...(rawOptions.workspaceRoot ? [path.resolve(cwd, rawOptions.workspaceRoot)] : []),
|
|
1253
|
+
],
|
|
1254
|
+
});
|
|
1255
|
+
if (rawOptions.json)
|
|
1256
|
+
writeJsonReceipt(io.stdout, failure);
|
|
1257
|
+
writeLine(io.stderr, failure.message);
|
|
1258
|
+
commandExitState.exitCode = 1;
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
catalogPublish
|
|
1262
|
+
.command('apply')
|
|
1263
|
+
.description('Apply an authorized Catalog publication plan')
|
|
1264
|
+
.option('--workspace-root <path>', 'Catalog Workspace root (default: nearest ancestor from current directory)')
|
|
1265
|
+
.option('--remote <name>', 'Git remote (default: origin, otherwise sole remote; explicit if ambiguous)')
|
|
1266
|
+
.option('--branch <name>', 'dedicated Catalog branch (default: catalog)')
|
|
1267
|
+
.requiredOption('--expected-plan-digest <sha256>', 'exact plan digest returned by catalog publish plan')
|
|
1268
|
+
.option('-y, --yes', 'confirm publication without a prompt', false)
|
|
1269
|
+
.option('--json', 'emit one machine-readable JSON result', false)
|
|
1270
|
+
.action(async (rawOptions) => {
|
|
1271
|
+
try {
|
|
1272
|
+
const context = createActionContext('catalog:publish:apply', {});
|
|
1273
|
+
const result = await runCatalogPublishApplyCommand({
|
|
1274
|
+
cwd,
|
|
1275
|
+
workspaceRoot: rawOptions.workspaceRoot,
|
|
1276
|
+
remote: rawOptions.remote,
|
|
1277
|
+
branch: rawOptions.branch,
|
|
1278
|
+
expectedPlanDigest: rawOptions.expectedPlanDigest,
|
|
1279
|
+
yes: rawOptions.yes,
|
|
1280
|
+
json: rawOptions.json,
|
|
1281
|
+
env,
|
|
1282
|
+
interactive: context.interactive,
|
|
1283
|
+
...(context.prompt.confirm ? {
|
|
1284
|
+
confirm: async (message) => {
|
|
1285
|
+
const response = await context.prompt.confirm({ message, defaultValue: false });
|
|
1286
|
+
return !response.cancelled && response.value === true;
|
|
1287
|
+
},
|
|
1422
1288
|
} : {}),
|
|
1423
1289
|
io,
|
|
1424
1290
|
});
|
|
@@ -1431,23 +1297,28 @@ export function buildProgram(options = {}) {
|
|
|
1431
1297
|
writeLine(io.stdout, `Branch: refs/heads/${result.branch}`);
|
|
1432
1298
|
writeLine(io.stdout, `Tag: refs/tags/${result.tag}`);
|
|
1433
1299
|
writeLine(io.stdout, `Commit: ${result.commit}`);
|
|
1434
|
-
writeLine(io.stdout, `Add it as a source: aw
|
|
1300
|
+
writeLine(io.stdout, `Add it as a source: aw source add <id> --git ${result.fetchUrl} --ref refs/heads/${result.branch}`);
|
|
1435
1301
|
}
|
|
1436
1302
|
}
|
|
1437
1303
|
catch (error) {
|
|
1438
|
-
|
|
1304
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1305
|
+
throw error;
|
|
1306
|
+
const failure = catalogPublicationFailure({
|
|
1307
|
+
error,
|
|
1308
|
+
env,
|
|
1309
|
+
sensitiveRoots: [
|
|
1310
|
+
cwd,
|
|
1311
|
+
...(rawOptions.workspaceRoot ? [path.resolve(cwd, rawOptions.workspaceRoot)] : []),
|
|
1312
|
+
],
|
|
1313
|
+
});
|
|
1439
1314
|
if (rawOptions.json)
|
|
1440
|
-
writeJsonReceipt(io.stdout, {
|
|
1441
|
-
|
|
1442
|
-
ok: false,
|
|
1443
|
-
errors: [{ message }],
|
|
1444
|
-
});
|
|
1445
|
-
writeLine(io.stderr, message);
|
|
1315
|
+
writeJsonReceipt(io.stdout, { ...failure, ...(error instanceof CatalogPublicationApplyFailure ? { overallState: 'partial', ...error.outcome } : {}) });
|
|
1316
|
+
writeLine(io.stderr, failure.message);
|
|
1446
1317
|
commandExitState.exitCode = 1;
|
|
1447
1318
|
}
|
|
1448
1319
|
});
|
|
1449
|
-
const catalogDev =
|
|
1450
|
-
.command('
|
|
1320
|
+
const catalogDev = dev
|
|
1321
|
+
.command('source')
|
|
1451
1322
|
.description('Manage the current Catalog Workspace development source');
|
|
1452
1323
|
catalogDev
|
|
1453
1324
|
.command('activate')
|
|
@@ -1455,7 +1326,8 @@ export function buildProgram(options = {}) {
|
|
|
1455
1326
|
.option('--source-id <id>', 'explicit managed source ID')
|
|
1456
1327
|
.option('--primary', 'make the development source primary', false)
|
|
1457
1328
|
.option('--force-build', 'rebuild a current snapshot', false)
|
|
1458
|
-
.
|
|
1329
|
+
.option('-y, --yes', 'confirm affected or unknown source references', false)
|
|
1330
|
+
.requiredOption('--json', 'emit one schema 2 JSON receipt')
|
|
1459
1331
|
.action(async (rawOptions) => {
|
|
1460
1332
|
try {
|
|
1461
1333
|
const receipt = await activateCatalogDevSource({
|
|
@@ -1464,6 +1336,7 @@ export function buildProgram(options = {}) {
|
|
|
1464
1336
|
sourceId: rawOptions.sourceId,
|
|
1465
1337
|
primary: rawOptions.primary,
|
|
1466
1338
|
forceBuild: rawOptions.forceBuild,
|
|
1339
|
+
yes: rawOptions.yes,
|
|
1467
1340
|
cliVersion: resolveCliVersion(),
|
|
1468
1341
|
env,
|
|
1469
1342
|
});
|
|
@@ -1471,6 +1344,8 @@ export function buildProgram(options = {}) {
|
|
|
1471
1344
|
commandExitState.exitCode = receipt.ok ? 0 : 1;
|
|
1472
1345
|
}
|
|
1473
1346
|
catch (error) {
|
|
1347
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1348
|
+
throw error;
|
|
1474
1349
|
const failure = catalogDevSourceError(error);
|
|
1475
1350
|
writeJsonReceipt(io.stdout, createCatalogDevFailureReceipt({
|
|
1476
1351
|
command: 'activate', cwd, workspaceRoot: rawOptions.workspaceRoot,
|
|
@@ -1482,7 +1357,7 @@ export function buildProgram(options = {}) {
|
|
|
1482
1357
|
catalogDev
|
|
1483
1358
|
.command('status')
|
|
1484
1359
|
.option('--workspace-root <path>', 'explicit Catalog Workspace root')
|
|
1485
|
-
.requiredOption('--json', 'emit one schema
|
|
1360
|
+
.requiredOption('--json', 'emit one schema 4 JSON receipt')
|
|
1486
1361
|
.action(async (rawOptions) => {
|
|
1487
1362
|
const receipt = await getCatalogDevSourceStatus({
|
|
1488
1363
|
cwd,
|
|
@@ -1496,26 +1371,35 @@ export function buildProgram(options = {}) {
|
|
|
1496
1371
|
catalogDev
|
|
1497
1372
|
.command('deactivate')
|
|
1498
1373
|
.option('--workspace-root <path>', 'explicit Catalog Workspace root')
|
|
1499
|
-
.
|
|
1374
|
+
.option('--source-id <id>', 'recover one managed source by exact ID')
|
|
1375
|
+
.option('--replacement-primary <id>', 'replacement when the target source is primary')
|
|
1376
|
+
.option('-y, --yes', 'confirm source impact or recovery by source ID', false)
|
|
1377
|
+
.requiredOption('--json', 'emit one schema 4 JSON receipt')
|
|
1500
1378
|
.action(async (rawOptions) => {
|
|
1501
1379
|
try {
|
|
1502
1380
|
const receipt = await deactivateCatalogDevSource({
|
|
1503
1381
|
cwd,
|
|
1504
1382
|
workspaceRoot: rawOptions.workspaceRoot,
|
|
1383
|
+
sourceId: rawOptions.sourceId,
|
|
1384
|
+
replacementPrimary: rawOptions.replacementPrimary,
|
|
1385
|
+
yes: rawOptions.yes,
|
|
1505
1386
|
env,
|
|
1506
1387
|
});
|
|
1507
1388
|
writeJsonReceipt(io.stdout, receipt);
|
|
1508
1389
|
commandExitState.exitCode = receipt.ok ? 0 : 1;
|
|
1509
1390
|
}
|
|
1510
1391
|
catch (error) {
|
|
1392
|
+
if (error instanceof CatalogWorkspaceMissingError)
|
|
1393
|
+
throw error;
|
|
1511
1394
|
const failure = catalogDevSourceError(error);
|
|
1512
1395
|
writeJsonReceipt(io.stdout, createCatalogDevFailureReceipt({
|
|
1513
|
-
command: 'deactivate', cwd, workspaceRoot: rawOptions.workspaceRoot,
|
|
1396
|
+
command: 'deactivate', cwd, workspaceRoot: rawOptions.workspaceRoot,
|
|
1397
|
+
sourceId: rawOptions.sourceId, ...failure,
|
|
1514
1398
|
}));
|
|
1515
1399
|
commandExitState.exitCode = 1;
|
|
1516
1400
|
}
|
|
1517
1401
|
});
|
|
1518
|
-
const catalogSource =
|
|
1402
|
+
const catalogSource = program
|
|
1519
1403
|
.command('source')
|
|
1520
1404
|
.description('Manage catalog sources');
|
|
1521
1405
|
const writeCatalogSourceFailure = async (command, sourceId, json, error, sensitiveRoots = []) => {
|
|
@@ -1523,12 +1407,14 @@ export function buildProgram(options = {}) {
|
|
|
1523
1407
|
const message = failure instanceof Error ? failure.message : String(error);
|
|
1524
1408
|
if (json) {
|
|
1525
1409
|
writeJsonReceipt(io.stdout, {
|
|
1526
|
-
receiptSchemaVersion:
|
|
1410
|
+
receiptSchemaVersion: 6,
|
|
1527
1411
|
command,
|
|
1528
1412
|
ok: false,
|
|
1529
1413
|
changed: false,
|
|
1530
1414
|
sourceId,
|
|
1531
|
-
|
|
1415
|
+
primaryChange: failure.impact?.primaryChange ?? null,
|
|
1416
|
+
references: failure.impact?.references ?? failure.inventory?.references ?? [],
|
|
1417
|
+
impact: failure.impact ?? failure.inventory ?? null,
|
|
1532
1418
|
errors: [{ code: failure.code ?? failure.name ?? 'catalogSourceMutationFailed', message }],
|
|
1533
1419
|
});
|
|
1534
1420
|
}
|
|
@@ -1540,10 +1426,13 @@ export function buildProgram(options = {}) {
|
|
|
1540
1426
|
const message = redactString(failure.message);
|
|
1541
1427
|
if (json) {
|
|
1542
1428
|
writeJsonReceipt(io.stdout, {
|
|
1543
|
-
|
|
1429
|
+
...(command === 'catalog:source:sync'
|
|
1430
|
+
? { catalogGenerationSchemaVersion: 1 }
|
|
1431
|
+
: { catalogGenerationStatusSchemaVersion: 2 }),
|
|
1544
1432
|
command,
|
|
1545
1433
|
ok: false,
|
|
1546
1434
|
...(sourceId ? { sourceId } : {}),
|
|
1435
|
+
...(failure.impact ? { impact: failure.impact } : {}),
|
|
1547
1436
|
errors: [{ code: catalogGenerationErrorCode(error), message }],
|
|
1548
1437
|
});
|
|
1549
1438
|
}
|
|
@@ -1551,55 +1440,37 @@ export function buildProgram(options = {}) {
|
|
|
1551
1440
|
commandExitState.exitCode = 1;
|
|
1552
1441
|
};
|
|
1553
1442
|
const writeConfigMutationFailure = (command, plugin, json, error) => {
|
|
1554
|
-
const
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
: message.includes('sourceChanged')
|
|
1564
|
-
? 'sourceChanged'
|
|
1565
|
-
: message.includes('sourceMissing')
|
|
1566
|
-
? 'sourceMissing'
|
|
1567
|
-
: message.startsWith('Cannot resolve required catalog sources:')
|
|
1568
|
-
? 'catalogSourceUnavailable'
|
|
1569
|
-
: message.split(':', 1)[0] || 'configMutationFailed';
|
|
1570
|
-
if (json && !message.includes('Usage:')) {
|
|
1571
|
-
writeJsonReceipt(io.stdout, {
|
|
1572
|
-
receiptSchemaVersion: 4,
|
|
1443
|
+
const failure = configMutationFailure(error, env, cwd);
|
|
1444
|
+
const confirmation = error?.confirmation;
|
|
1445
|
+
if (confirmation) {
|
|
1446
|
+
writeJsonReceipt(io.stdout, { command, ok: false, pluginId: plugin, configWrite: 'notStarted', confirmation, errors: [failure] });
|
|
1447
|
+
commandExitState.exitCode = 3;
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
if (json) {
|
|
1451
|
+
writeConfigMutationFailureReceipt(io.stdout, {
|
|
1573
1452
|
command,
|
|
1574
|
-
ok: false,
|
|
1575
|
-
overallState: 'failed',
|
|
1576
1453
|
...(plugin ? { plugin } : {}),
|
|
1577
|
-
|
|
1578
|
-
});
|
|
1454
|
+
}, failure);
|
|
1579
1455
|
}
|
|
1456
|
+
const message = json
|
|
1457
|
+
? failure.message
|
|
1458
|
+
: redactString(sanitizeCatalogSourceErrorMessage(error instanceof Error ? error.message : String(error), env, [cwd]));
|
|
1580
1459
|
writeLine(io.stderr, message);
|
|
1581
|
-
commandExitState.exitCode = 1;
|
|
1460
|
+
commandExitState.exitCode = failure.code === 'invalidArguments' ? 2 : 1;
|
|
1582
1461
|
};
|
|
1583
|
-
const withResolvedConfigMutationPlugin = (context, selector, consume) => (async () => {
|
|
1462
|
+
const withResolvedConfigMutationPlugin = (context, selector, consume, _apply = false) => (async () => {
|
|
1584
1463
|
const parsed = parsePluginId(selector);
|
|
1585
|
-
await bootstrapCatalogOperationSources({
|
|
1586
|
-
cliVersion: resolveCliVersion(),
|
|
1587
|
-
...(parsed.sourceId ? { sourceIds: [parsed.sourceId] } : {}),
|
|
1588
|
-
env: context.env,
|
|
1589
|
-
});
|
|
1590
1464
|
return withAwHomeMutationLock({
|
|
1591
1465
|
env: context.env,
|
|
1592
1466
|
action: async (awHomeMutationToken) => {
|
|
1593
1467
|
const catalogOperationContext = await resolveCatalogOperationContext({
|
|
1594
|
-
cliVersion: resolveCliVersion(),
|
|
1595
1468
|
...(parsed.sourceId ? { sourceIds: [parsed.sourceId] } : {}),
|
|
1596
1469
|
env: context.env,
|
|
1597
|
-
bootstrapMissingActive: false,
|
|
1598
1470
|
});
|
|
1599
1471
|
return withResolvedCatalogPlugin({
|
|
1600
1472
|
selector,
|
|
1601
1473
|
cliVersion: resolveCliVersion(),
|
|
1602
|
-
freshnessPolicy: 'cacheFirst',
|
|
1603
1474
|
operationContext: catalogOperationContext,
|
|
1604
1475
|
env: context.env,
|
|
1605
1476
|
consume: (resolution) => consume(resolution, awHomeMutationToken, catalogOperationContext),
|
|
@@ -1608,120 +1479,66 @@ export function buildProgram(options = {}) {
|
|
|
1608
1479
|
});
|
|
1609
1480
|
})();
|
|
1610
1481
|
catalogSource
|
|
1611
|
-
.command('
|
|
1612
|
-
.option('-j, --json', 'print catalog sources as JSON', false)
|
|
1613
|
-
.action(async (rawOptions) => {
|
|
1614
|
-
const payload = await listCatalogSources({ env });
|
|
1615
|
-
if (rawOptions.json) {
|
|
1616
|
-
writeJsonReceipt(io.stdout, payload);
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
writeLine(io.stdout, `Primary source: ${payload.primarySourceId}`);
|
|
1620
|
-
for (const source of payload.sources) {
|
|
1621
|
-
writeLine(io.stdout, `${source.primary ? '*' : '-'} ${source.id} ${source.type} ${source.sourceIdentity}`);
|
|
1622
|
-
}
|
|
1623
|
-
});
|
|
1624
|
-
catalogSource
|
|
1625
|
-
.command('refresh')
|
|
1482
|
+
.command('sync')
|
|
1626
1483
|
.argument('<id>')
|
|
1627
|
-
.option('-
|
|
1484
|
+
.option('--replace-damaged', 'replace a damaged Active entry with the current candidate', false)
|
|
1485
|
+
.option('-y, --yes', 'confirm affected, unknown, or damaged Active replacement impact', false)
|
|
1486
|
+
.option('-j, --json', 'print the source sync result as JSON', false)
|
|
1628
1487
|
.action(async (id, rawOptions) => {
|
|
1629
1488
|
try {
|
|
1630
|
-
|
|
1489
|
+
if (rawOptions.check && rawOptions.replaceDamaged) {
|
|
1490
|
+
throw new Error('catalog source sync --check cannot use --replace-damaged.');
|
|
1491
|
+
}
|
|
1492
|
+
const result = await syncCatalogSourceCommand({
|
|
1631
1493
|
sourceId: id,
|
|
1632
1494
|
cliVersion: resolveCliVersion(),
|
|
1495
|
+
cwd,
|
|
1496
|
+
check: rawOptions.check === true,
|
|
1497
|
+
impactConfirmed: rawOptions.yes === true,
|
|
1498
|
+
replaceDamaged: rawOptions.replaceDamaged === true,
|
|
1633
1499
|
env,
|
|
1634
1500
|
});
|
|
1635
1501
|
if (rawOptions.json) {
|
|
1636
1502
|
writeJsonReceipt(io.stdout, {
|
|
1637
1503
|
...result,
|
|
1638
|
-
command: 'catalog:source:
|
|
1639
|
-
ok: true,
|
|
1640
|
-
});
|
|
1641
|
-
}
|
|
1642
|
-
else {
|
|
1643
|
-
writeLine(io.stdout, `Catalog source ${id}: ${result.outcome}.`);
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
catch (error) {
|
|
1647
|
-
writeCatalogGenerationFailure('catalog:source:refresh', id, rawOptions.json === true, error);
|
|
1648
|
-
}
|
|
1649
|
-
});
|
|
1650
|
-
catalogSource
|
|
1651
|
-
.command('activate-candidate')
|
|
1652
|
-
.argument('<id>')
|
|
1653
|
-
.option('-j, --json', 'print the generation activation result as JSON', false)
|
|
1654
|
-
.action(async (id, rawOptions) => {
|
|
1655
|
-
try {
|
|
1656
|
-
const result = await activateCatalogSourceCandidateCommand({ sourceId: id, env });
|
|
1657
|
-
if (rawOptions.json) {
|
|
1658
|
-
writeJsonReceipt(io.stdout, {
|
|
1659
|
-
...result,
|
|
1660
|
-
command: 'catalog:source:activate-candidate',
|
|
1504
|
+
command: 'catalog:source:sync',
|
|
1661
1505
|
ok: true,
|
|
1662
1506
|
});
|
|
1663
1507
|
}
|
|
1664
1508
|
else {
|
|
1665
|
-
writeLine(io.stdout,
|
|
1509
|
+
writeLine(io.stdout, rawOptions.check
|
|
1510
|
+
? `Catalog source ${id} is valid.`
|
|
1511
|
+
: `Catalog source ${id}: ${result.outcome}.`);
|
|
1666
1512
|
}
|
|
1667
1513
|
}
|
|
1668
1514
|
catch (error) {
|
|
1669
|
-
writeCatalogGenerationFailure('catalog:source:
|
|
1515
|
+
writeCatalogGenerationFailure('catalog:source:sync', id, rawOptions.json === true, error);
|
|
1670
1516
|
}
|
|
1671
1517
|
});
|
|
1672
1518
|
catalogSource
|
|
1673
|
-
.command('
|
|
1519
|
+
.command('status')
|
|
1674
1520
|
.argument('[id]')
|
|
1675
|
-
.option('-j, --json', 'print Catalog
|
|
1521
|
+
.option('-j, --json', 'print offline Catalog source status schema 2 as JSON', false)
|
|
1676
1522
|
.action(async (id, rawOptions) => {
|
|
1677
1523
|
try {
|
|
1678
|
-
const result = await
|
|
1524
|
+
const result = await catalogSourceStatusCommand({ sourceId: id, env });
|
|
1679
1525
|
if (rawOptions.json) {
|
|
1680
1526
|
writeJsonReceipt(io.stdout, result);
|
|
1681
1527
|
}
|
|
1682
1528
|
else {
|
|
1683
1529
|
for (const source of result.sources) {
|
|
1684
|
-
const active = source.active
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1530
|
+
const active = source.active
|
|
1531
|
+
? `Active ${source.active.snapshotDigest}`
|
|
1532
|
+
: 'no Active';
|
|
1533
|
+
const readiness = source.compatibility?.state === 'unsupported'
|
|
1534
|
+
? `incompatible (required: ${source.compatibility.requiredCapabilities.join(', ')}; missing: ${source.compatibility.missingCapabilities.join(', ')})`
|
|
1535
|
+
: source.activeReady ? 'ready' : 'not ready';
|
|
1536
|
+
writeLine(io.stdout, `${source.sourceId}: ${active}, ${readiness}`);
|
|
1689
1537
|
}
|
|
1690
1538
|
}
|
|
1691
1539
|
}
|
|
1692
1540
|
catch (error) {
|
|
1693
|
-
writeCatalogGenerationFailure('catalog:source:
|
|
1694
|
-
}
|
|
1695
|
-
});
|
|
1696
|
-
catalogSource
|
|
1697
|
-
.command('refresh-policy')
|
|
1698
|
-
.argument('<id>')
|
|
1699
|
-
.argument('<policy>', 'startup or manual')
|
|
1700
|
-
.option('-j, --json', 'print Catalog refresh policy result as JSON', false)
|
|
1701
|
-
.action(async (id, policy, rawOptions) => {
|
|
1702
|
-
try {
|
|
1703
|
-
if (policy !== 'startup' && policy !== 'manual') {
|
|
1704
|
-
throw new Error('Catalog refresh policy must be startup or manual.');
|
|
1705
|
-
}
|
|
1706
|
-
const result = await setCatalogSourceRefreshPolicyCommand({
|
|
1707
|
-
sourceId: id,
|
|
1708
|
-
refreshPolicy: policy,
|
|
1709
|
-
env,
|
|
1710
|
-
});
|
|
1711
|
-
if (rawOptions.json) {
|
|
1712
|
-
writeJsonReceipt(io.stdout, {
|
|
1713
|
-
catalogGenerationSchemaVersion: 1,
|
|
1714
|
-
command: 'catalog:source:refresh-policy',
|
|
1715
|
-
ok: true,
|
|
1716
|
-
...result,
|
|
1717
|
-
});
|
|
1718
|
-
}
|
|
1719
|
-
else {
|
|
1720
|
-
writeLine(io.stdout, `Catalog source ${id} refresh policy: ${result.refreshPolicy}.`);
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
catch (error) {
|
|
1724
|
-
writeCatalogGenerationFailure('catalog:source:refresh-policy', id, rawOptions.json === true, error);
|
|
1541
|
+
writeCatalogGenerationFailure('catalog:source:status', id, rawOptions.json === true, error);
|
|
1725
1542
|
}
|
|
1726
1543
|
});
|
|
1727
1544
|
catalogSource
|
|
@@ -1732,18 +1549,20 @@ export function buildProgram(options = {}) {
|
|
|
1732
1549
|
.addOption(new Option('--ref <ref>', 'use an explicit Git ref'))
|
|
1733
1550
|
.addOption(new Option('--default-ref', 'select the Git ref from the CLI release channel'))
|
|
1734
1551
|
.option('--subdir <path>', 'use a catalog snapshot below the Git repository root')
|
|
1552
|
+
.option('--no-auto-check', 'disable automatic update checks for this source')
|
|
1735
1553
|
.option('--primary', 'make this source primary', false)
|
|
1554
|
+
.option('-y, --yes', 'confirm affected or unknown primary source references', false)
|
|
1736
1555
|
.option('-j, --json', 'print mutation receipt as JSON', false)
|
|
1737
1556
|
.action(async (id, rawOptions) => {
|
|
1738
1557
|
try {
|
|
1739
1558
|
if ((rawOptions.git === undefined) === (rawOptions.path === undefined)) {
|
|
1740
|
-
throw new
|
|
1559
|
+
throw new WriteCommandRequestError('catalog source add requires exactly one of `--git` or `--path`.');
|
|
1741
1560
|
}
|
|
1742
1561
|
if (rawOptions.git !== undefined && ((rawOptions.ref === undefined) === (rawOptions.defaultRef !== true))) {
|
|
1743
|
-
throw new
|
|
1562
|
+
throw new WriteCommandRequestError('Git catalog source add requires exactly one of `--ref` or `--default-ref`.');
|
|
1744
1563
|
}
|
|
1745
1564
|
if (rawOptions.path !== undefined && (rawOptions.ref !== undefined || rawOptions.defaultRef === true || rawOptions.subdir !== undefined)) {
|
|
1746
|
-
throw new
|
|
1565
|
+
throw new WriteCommandRequestError('Path catalog source add only accepts `--path`, `--primary`, `--no-auto-check`, and `--yes`.');
|
|
1747
1566
|
}
|
|
1748
1567
|
const source = rawOptions.git !== undefined
|
|
1749
1568
|
? {
|
|
@@ -1753,21 +1572,35 @@ export function buildProgram(options = {}) {
|
|
|
1753
1572
|
url: rawOptions.git,
|
|
1754
1573
|
refPolicy: explicitRefPolicy(rawOptions.ref, rawOptions.defaultRef === true),
|
|
1755
1574
|
...(rawOptions.subdir ? { subdir: rawOptions.subdir } : {}),
|
|
1575
|
+
...(rawOptions.autoCheck === false ? { autoCheck: false } : {}),
|
|
1756
1576
|
}
|
|
1757
1577
|
: {
|
|
1758
1578
|
id,
|
|
1759
1579
|
type: 'path',
|
|
1760
1580
|
primary: rawOptions.primary === true,
|
|
1761
1581
|
path: rawOptions.path,
|
|
1582
|
+
...(rawOptions.autoCheck === false ? { autoCheck: false } : {}),
|
|
1762
1583
|
};
|
|
1584
|
+
const preview = source.primary
|
|
1585
|
+
? await preflightCatalogSourceMutation({
|
|
1586
|
+
request: { action: 'add', source }, cwd, env,
|
|
1587
|
+
})
|
|
1588
|
+
: undefined;
|
|
1763
1589
|
const receipt = await addCatalogSourceCommand({
|
|
1764
1590
|
source,
|
|
1765
1591
|
cliVersion: resolveCliVersion(),
|
|
1766
1592
|
cwd,
|
|
1767
1593
|
env,
|
|
1594
|
+
...(preview ? {
|
|
1595
|
+
expectedConfigDigest: preview.configDigest,
|
|
1596
|
+
expectedProposedConfigDigest: preview.proposedConfigDigest,
|
|
1597
|
+
expectedImpactDigest: preview.impactDigest,
|
|
1598
|
+
} : {}),
|
|
1599
|
+
requireImpactConfirmation: true,
|
|
1600
|
+
confirmImpact: rawOptions.yes === true,
|
|
1768
1601
|
});
|
|
1769
1602
|
if (rawOptions.json)
|
|
1770
|
-
writeJsonReceipt(io.stdout, receipt);
|
|
1603
|
+
writeJsonReceipt(io.stdout, { ...receipt, impact: preview?.references ?? null, confirmation: sourceConfirmation(id, rawOptions.yes, preview) });
|
|
1771
1604
|
else
|
|
1772
1605
|
writeLine(io.stdout, `Catalog source ${id} added.`);
|
|
1773
1606
|
for (const diagnostic of receipt.errors)
|
|
@@ -1786,28 +1619,41 @@ export function buildProgram(options = {}) {
|
|
|
1786
1619
|
.addOption(new Option('--default-ref', 'select the Git ref from the CLI release channel'))
|
|
1787
1620
|
.addOption(new Option('--subdir <path>', 'update the Git catalog subdirectory'))
|
|
1788
1621
|
.addOption(new Option('--no-subdir', 'remove the Git catalog subdirectory'))
|
|
1622
|
+
.addOption(new Option('--auto-check', 'enable automatic update checks for this source'))
|
|
1623
|
+
.addOption(new Option('--no-auto-check', 'disable automatic update checks for this source'))
|
|
1624
|
+
.option('-y, --yes', 'confirm a source identity change', false)
|
|
1789
1625
|
.option('-j, --json', 'print mutation receipt as JSON', false)
|
|
1790
1626
|
.action(async (id, rawOptions) => {
|
|
1791
1627
|
try {
|
|
1792
1628
|
if (rawOptions.git !== undefined && rawOptions.path !== undefined) {
|
|
1793
|
-
throw new
|
|
1629
|
+
throw new WriteCommandRequestError('catalog source update cannot combine `--git` and `--path`.');
|
|
1794
1630
|
}
|
|
1795
1631
|
if (rawOptions.ref !== undefined && rawOptions.defaultRef === true) {
|
|
1796
|
-
throw new
|
|
1632
|
+
throw new WriteCommandRequestError('catalog source update cannot combine `--ref` and `--default-ref`.');
|
|
1797
1633
|
}
|
|
1798
|
-
const hasUpdate = rawOptions.git !== undefined
|
|
1634
|
+
const hasUpdate = rawOptions.primary === true || rawOptions.git !== undefined
|
|
1799
1635
|
|| rawOptions.path !== undefined
|
|
1800
1636
|
|| rawOptions.ref !== undefined
|
|
1801
1637
|
|| rawOptions.defaultRef === true
|
|
1802
|
-
|| rawOptions.subdir !== undefined
|
|
1638
|
+
|| rawOptions.subdir !== undefined
|
|
1639
|
+
|| rawOptions.autoCheck !== undefined;
|
|
1803
1640
|
if (!hasUpdate)
|
|
1804
|
-
throw new
|
|
1641
|
+
throw new WriteCommandRequestError('catalog source update requires at least one update option.');
|
|
1805
1642
|
if (rawOptions.path !== undefined && (rawOptions.ref !== undefined || rawOptions.defaultRef === true || rawOptions.subdir !== undefined))
|
|
1806
|
-
throw new
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
|
|
1643
|
+
throw new WriteCommandRequestError('Path catalog source update only accepts `--path` and auto-check options.');
|
|
1644
|
+
const hasGitUpdate = rawOptions.git !== undefined
|
|
1645
|
+
|| rawOptions.ref !== undefined
|
|
1646
|
+
|| rawOptions.defaultRef === true
|
|
1647
|
+
|| rawOptions.subdir !== undefined;
|
|
1648
|
+
const transportUpdate = rawOptions.path !== undefined
|
|
1649
|
+
? {
|
|
1650
|
+
type: 'path',
|
|
1651
|
+
path: rawOptions.path,
|
|
1652
|
+
...(rawOptions.autoCheck !== undefined ? { autoCheck: rawOptions.autoCheck } : {}),
|
|
1653
|
+
}
|
|
1654
|
+
: hasGitUpdate ? {
|
|
1810
1655
|
type: 'git',
|
|
1656
|
+
...(rawOptions.autoCheck !== undefined ? { autoCheck: rawOptions.autoCheck } : {}),
|
|
1811
1657
|
...(rawOptions.git !== undefined ? { url: rawOptions.git } : {}),
|
|
1812
1658
|
...(rawOptions.ref !== undefined || rawOptions.defaultRef === true
|
|
1813
1659
|
? { refPolicy: explicitRefPolicy(rawOptions.ref, rawOptions.defaultRef === true) }
|
|
@@ -1815,16 +1661,29 @@ export function buildProgram(options = {}) {
|
|
|
1815
1661
|
...(rawOptions.subdir !== undefined
|
|
1816
1662
|
? { subdir: rawOptions.subdir === false ? null : rawOptions.subdir }
|
|
1817
1663
|
: {}),
|
|
1818
|
-
}
|
|
1664
|
+
}
|
|
1665
|
+
: { autoCheck: rawOptions.autoCheck };
|
|
1666
|
+
const update = transportUpdate;
|
|
1667
|
+
const preview = await preflightCatalogSourceMutation({
|
|
1668
|
+
request: { action: 'update', sourceId: id, update, ...(rawOptions.primary ? { primary: true } : {}) }, cwd, env,
|
|
1669
|
+
});
|
|
1819
1670
|
const receipt = await updateCatalogSourceCommand({
|
|
1820
1671
|
sourceId: id,
|
|
1821
1672
|
update,
|
|
1673
|
+
...(rawOptions.primary ? { primary: true } : {}),
|
|
1674
|
+
requireImpactConfirmation: true,
|
|
1675
|
+
confirmImpact: rawOptions.yes === true,
|
|
1822
1676
|
cliVersion: resolveCliVersion(),
|
|
1823
1677
|
cwd,
|
|
1824
1678
|
env,
|
|
1679
|
+
expectedConfigDigest: preview.configDigest,
|
|
1680
|
+
expectedProposedConfigDigest: preview.proposedConfigDigest,
|
|
1681
|
+
expectedImpactDigest: preview.impactDigest,
|
|
1682
|
+
requireIdentityChangeConfirmation: true,
|
|
1683
|
+
confirmIdentityChange: rawOptions.yes === true,
|
|
1825
1684
|
});
|
|
1826
1685
|
if (rawOptions.json)
|
|
1827
|
-
writeJsonReceipt(io.stdout, receipt);
|
|
1686
|
+
writeJsonReceipt(io.stdout, { ...receipt, impact: preview.references, confirmation: sourceConfirmation(id, rawOptions.yes, preview) });
|
|
1828
1687
|
else
|
|
1829
1688
|
writeLine(io.stdout, `Catalog source ${id} updated.`);
|
|
1830
1689
|
for (const diagnostic of receipt.errors)
|
|
@@ -1834,31 +1693,23 @@ export function buildProgram(options = {}) {
|
|
|
1834
1693
|
await writeCatalogSourceFailure('catalog:source:update', id, rawOptions.json === true, error, rawOptions.path === undefined ? [] : [rawOptions.path, path.resolve(cwd, rawOptions.path)]);
|
|
1835
1694
|
}
|
|
1836
1695
|
});
|
|
1837
|
-
catalogSource
|
|
1838
|
-
.command('set-primary')
|
|
1839
|
-
.argument('<id>')
|
|
1840
|
-
.option('-j, --json', 'print mutation receipt as JSON', false)
|
|
1841
|
-
.action(async (id, rawOptions) => {
|
|
1842
|
-
try {
|
|
1843
|
-
const receipt = await setPrimaryCatalogSourceCommand({ sourceId: id, cwd, env });
|
|
1844
|
-
if (rawOptions.json)
|
|
1845
|
-
writeJsonReceipt(io.stdout, receipt);
|
|
1846
|
-
else
|
|
1847
|
-
writeLine(io.stdout, `Primary catalog source set to ${id}.`);
|
|
1848
|
-
}
|
|
1849
|
-
catch (error) {
|
|
1850
|
-
await writeCatalogSourceFailure('catalog:source:set-primary', id, rawOptions.json === true, error);
|
|
1851
|
-
}
|
|
1852
|
-
});
|
|
1853
1696
|
catalogSource
|
|
1854
1697
|
.command('remove')
|
|
1855
1698
|
.argument('<id>')
|
|
1699
|
+
.option('-y, --yes', 'confirm affected or unknown source references', false)
|
|
1856
1700
|
.option('-j, --json', 'print mutation receipt as JSON', false)
|
|
1857
1701
|
.action(async (id, rawOptions) => {
|
|
1858
1702
|
try {
|
|
1859
|
-
const
|
|
1703
|
+
const preview = await preflightCatalogSourceMutation({ request: { action: 'remove', sourceId: id }, cwd, env });
|
|
1704
|
+
const receipt = await removeCatalogSourceCommand({
|
|
1705
|
+
sourceId: id,
|
|
1706
|
+
cwd,
|
|
1707
|
+
env,
|
|
1708
|
+
requireImpactConfirmation: true,
|
|
1709
|
+
confirmImpact: rawOptions.yes === true,
|
|
1710
|
+
});
|
|
1860
1711
|
if (rawOptions.json)
|
|
1861
|
-
writeJsonReceipt(io.stdout, receipt);
|
|
1712
|
+
writeJsonReceipt(io.stdout, { ...receipt, impact: preview.references, confirmation: sourceConfirmation(id, rawOptions.yes, preview) });
|
|
1862
1713
|
else
|
|
1863
1714
|
writeLine(io.stdout, `Catalog source ${id} removed.`);
|
|
1864
1715
|
}
|
|
@@ -1866,1005 +1717,993 @@ export function buildProgram(options = {}) {
|
|
|
1866
1717
|
await writeCatalogSourceFailure('catalog:source:remove', id, rawOptions.json === true, error);
|
|
1867
1718
|
}
|
|
1868
1719
|
});
|
|
1869
|
-
program
|
|
1870
|
-
.command('
|
|
1871
|
-
.
|
|
1872
|
-
|
|
1873
|
-
.
|
|
1874
|
-
.option('-
|
|
1875
|
-
.option('--log-file <path>', 'write debug diagnostics to the specified file')
|
|
1720
|
+
const catalogStore = program
|
|
1721
|
+
.command('cache')
|
|
1722
|
+
.description('Inspect or prune the immutable Catalog store');
|
|
1723
|
+
catalogStore
|
|
1724
|
+
.command('status')
|
|
1725
|
+
.option('-j, --json', 'print Catalog store status as JSON', false)
|
|
1876
1726
|
.action(async (rawOptions) => {
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
writeJsonReceipt(io.stdout, buildInitReceiptJson(result));
|
|
1885
|
-
}
|
|
1886
|
-
else {
|
|
1887
|
-
for (const line of renderInitReceipt(result)) {
|
|
1888
|
-
writeLine(io.stdout, line);
|
|
1727
|
+
try {
|
|
1728
|
+
const result = await catalogStoreStatus({ env });
|
|
1729
|
+
if (rawOptions.json) {
|
|
1730
|
+
writeJsonReceipt(io.stdout, result);
|
|
1731
|
+
}
|
|
1732
|
+
else if (result.entries.length === 0) {
|
|
1733
|
+
writeLine(io.stdout, 'Catalog store is empty.');
|
|
1889
1734
|
}
|
|
1735
|
+
else {
|
|
1736
|
+
for (const entry of result.entries) {
|
|
1737
|
+
const bytes = entry.reclaimableBytes === null ? 'unknown bytes' : `${entry.reclaimableBytes} bytes`;
|
|
1738
|
+
writeLine(io.stdout, `${entry.storeKey}: ${entry.category}, ${entry.status}, ${entry.reason}, ${bytes}`);
|
|
1739
|
+
}
|
|
1740
|
+
writeLine(io.stdout, `Reclaimable: ${result.totals.reclaimableEntries} item(s).`);
|
|
1741
|
+
if (result.errors.length > 0) {
|
|
1742
|
+
writeLine(io.stderr, `${result.errors.length} item(s) could not be fully inspected and were retained.`);
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
commandExitState.exitCode = result.ok ? 0 : 1;
|
|
1890
1746
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1747
|
+
catch (error) {
|
|
1748
|
+
const failure = sanitizeCatalogSourceError(error, env);
|
|
1749
|
+
const message = redactString(failure.message);
|
|
1750
|
+
if (rawOptions.json)
|
|
1751
|
+
writeJsonReceipt(io.stdout, {
|
|
1752
|
+
catalogStoreSchemaVersion: 2,
|
|
1753
|
+
command: 'catalog:store:status',
|
|
1754
|
+
ok: false,
|
|
1755
|
+
entries: [],
|
|
1756
|
+
errors: [{ code: catalogStoreErrorCode(error), message }],
|
|
1757
|
+
});
|
|
1758
|
+
writeLine(io.stderr, message);
|
|
1759
|
+
commandExitState.exitCode = 1;
|
|
1895
1760
|
}
|
|
1896
|
-
commandExitState.exitCode = result.ok ? 0 : 1;
|
|
1897
1761
|
});
|
|
1898
|
-
|
|
1899
|
-
.command('
|
|
1900
|
-
.
|
|
1901
|
-
.option('-
|
|
1902
|
-
.option('-
|
|
1903
|
-
.
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
const context = createActionContext('install', rawOptions);
|
|
1911
|
-
const outcome = await runActionWithContext(context, () => runWriteCommandAction('install', plugins ?? [], rawOptions, context));
|
|
1912
|
-
if (outcome.cancelled)
|
|
1913
|
-
return;
|
|
1914
|
-
const receipt = outcome.result;
|
|
1915
|
-
if (rawOptions.json) {
|
|
1916
|
-
writeJsonReceipt(io.stdout, buildRebuildReceiptJson('install', receipt));
|
|
1917
|
-
}
|
|
1918
|
-
else {
|
|
1919
|
-
for (const line of renderRebuildReceipt('install', receipt)) {
|
|
1920
|
-
writeLine(io.stdout, line);
|
|
1762
|
+
catalogStore
|
|
1763
|
+
.command('prune')
|
|
1764
|
+
.option('--dry-run', 'inspect reclaimable items without deleting them', false)
|
|
1765
|
+
.option('-y, --yes', 'delete items classified as safely reclaimable', false)
|
|
1766
|
+
.option('-j, --json', 'print the prune receipt as JSON', false)
|
|
1767
|
+
.action(async (rawOptions) => {
|
|
1768
|
+
const dryRun = rawOptions.yes !== true;
|
|
1769
|
+
try {
|
|
1770
|
+
if (rawOptions.dryRun === true && rawOptions.yes === true) {
|
|
1771
|
+
throw Object.assign(new Error('catalog store prune cannot combine `--dry-run` and `--yes`.'), {
|
|
1772
|
+
code: 'invalidArguments',
|
|
1773
|
+
});
|
|
1921
1774
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
});
|
|
1926
|
-
program
|
|
1927
|
-
.command('uninstall')
|
|
1928
|
-
.argument('[plugins...]')
|
|
1929
|
-
.option('-s, --scope <scope>', 'project or user')
|
|
1930
|
-
.option('-p, --platform <platform>', 'codex | claude | both')
|
|
1931
|
-
.option('--script-timeout <ms>', 'override plugin lifecycle script timeout in milliseconds')
|
|
1932
|
-
.option('--allow-managed-codex-install', 'allow this command to acquire or rebuild the pinned AW-managed Codex runtime', false)
|
|
1933
|
-
.option('-j, --json', 'print receipt as JSON', false)
|
|
1934
|
-
.option('-v, --verbose', 'show command diagnostics', false)
|
|
1935
|
-
.option('-D, --debug', 'write debug diagnostics to a log file', false)
|
|
1936
|
-
.option('--log-file <path>', 'write debug diagnostics to the specified file')
|
|
1937
|
-
.action(async (plugins, rawOptions) => {
|
|
1938
|
-
const context = createActionContext('uninstall', rawOptions);
|
|
1939
|
-
const outcome = await runActionWithContext(context, () => runWriteCommandAction('uninstall', plugins ?? [], rawOptions, context));
|
|
1940
|
-
if (outcome.cancelled)
|
|
1941
|
-
return;
|
|
1942
|
-
const receipt = outcome.result;
|
|
1943
|
-
if (rawOptions.json) {
|
|
1944
|
-
writeJsonReceipt(io.stdout, buildRebuildReceiptJson('uninstall', receipt));
|
|
1945
|
-
}
|
|
1946
|
-
else {
|
|
1947
|
-
for (const line of renderRebuildReceipt('uninstall', receipt)) {
|
|
1948
|
-
writeLine(io.stdout, line);
|
|
1775
|
+
const result = await catalogStorePrune({ dryRun, env });
|
|
1776
|
+
if (rawOptions.json) {
|
|
1777
|
+
writeJsonReceipt(io.stdout, result);
|
|
1949
1778
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
.command('upgrade')
|
|
1956
|
-
.argument('[plugins...]')
|
|
1957
|
-
.option('-a, --all', 'upgrade all plugins', false)
|
|
1958
|
-
.option('-s, --scope <scope>', 'project or user')
|
|
1959
|
-
.option('-p, --platform <platform>', 'codex | claude | both')
|
|
1960
|
-
.option('--script-timeout <ms>', 'override plugin lifecycle script timeout in milliseconds')
|
|
1961
|
-
.option('--allow-managed-codex-install', 'allow this command to acquire or rebuild the pinned AW-managed Codex runtime', false)
|
|
1962
|
-
.option('-j, --json', 'print receipt as JSON', false)
|
|
1963
|
-
.option('-v, --verbose', 'show command diagnostics', false)
|
|
1964
|
-
.option('-D, --debug', 'write debug diagnostics to a log file', false)
|
|
1965
|
-
.option('--log-file <path>', 'write debug diagnostics to the specified file')
|
|
1966
|
-
.action(async (plugins, rawOptions) => {
|
|
1967
|
-
const context = createActionContext('upgrade', rawOptions);
|
|
1968
|
-
const outcome = await runActionWithContext(context, () => runWriteCommandAction('upgrade', plugins ?? [], rawOptions, context));
|
|
1969
|
-
if (outcome.cancelled)
|
|
1970
|
-
return;
|
|
1971
|
-
const receipt = outcome.result;
|
|
1972
|
-
if (rawOptions.json) {
|
|
1973
|
-
writeJsonReceipt(io.stdout, buildRebuildReceiptJson('upgrade', receipt));
|
|
1974
|
-
}
|
|
1975
|
-
else {
|
|
1976
|
-
for (const line of renderRebuildReceipt('upgrade', receipt)) {
|
|
1977
|
-
writeLine(io.stdout, line);
|
|
1779
|
+
else if (dryRun) {
|
|
1780
|
+
writeLine(io.stdout, `Dry run: ${result.entries.filter((entry) => entry.status === 'reclaimable').length} item(s) are reclaimable.`);
|
|
1781
|
+
writeLine(io.stdout, 'Run `aw cache prune --yes` to delete them.');
|
|
1782
|
+
if (result.errors.length > 0)
|
|
1783
|
+
writeLine(io.stderr, `${result.errors.length} item(s) could not be fully inspected and were retained.`);
|
|
1978
1784
|
}
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
program
|
|
1984
|
-
.command('cleanup')
|
|
1985
|
-
.argument('[plugins...]')
|
|
1986
|
-
.option('-s, --scope <scope>', 'project or user')
|
|
1987
|
-
.option('-p, --platform <platform>', 'codex | claude | both')
|
|
1988
|
-
.option('-j, --json', 'print cleanup result as JSON', false)
|
|
1989
|
-
.option('--force', 'remove exclusively owned plugin output without dependency protection', false)
|
|
1990
|
-
.option('--allow-managed-codex-install', 'allow this command to acquire or rebuild the pinned AW-managed Codex runtime', false)
|
|
1991
|
-
.option('-v, --verbose', 'show command diagnostics', false)
|
|
1992
|
-
.option('-D, --debug', 'write debug diagnostics to a log file', false)
|
|
1993
|
-
.option('--log-file <path>', 'write debug diagnostics to the specified file')
|
|
1994
|
-
.action(async (plugins, rawOptions) => {
|
|
1995
|
-
const context = createActionContext('cleanup', rawOptions);
|
|
1996
|
-
const outcome = await runActionWithContext(context, () => runWriteCommandAction('cleanup', plugins ?? [], rawOptions, context));
|
|
1997
|
-
if (outcome.cancelled)
|
|
1998
|
-
return;
|
|
1999
|
-
const result = outcome.result;
|
|
2000
|
-
if (rawOptions.json) {
|
|
2001
|
-
writeJsonReceipt(io.stdout, buildRebuildReceiptJson('cleanup', result));
|
|
2002
|
-
}
|
|
2003
|
-
else {
|
|
2004
|
-
for (const line of renderRebuildReceipt('cleanup', result)) {
|
|
2005
|
-
writeLine(io.stdout, line);
|
|
1785
|
+
else {
|
|
1786
|
+
writeLine(io.stdout, `Deleted ${result.deleted.length} Catalog store item(s) (${result.deletedBytes} bytes).`);
|
|
1787
|
+
if (result.errors.length > 0)
|
|
1788
|
+
writeLine(io.stderr, `${result.errors.length} item(s) could not be fully inspected or deleted and were retained.`);
|
|
2006
1789
|
}
|
|
1790
|
+
commandExitState.exitCode = result.ok ? 0 : 1;
|
|
2007
1791
|
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
if (rawOptions.json) {
|
|
2029
|
-
writeJsonReceipt(io.stdout, buildRebuildReceiptJson('reinstall', receipt));
|
|
2030
|
-
}
|
|
2031
|
-
else {
|
|
2032
|
-
const lines = renderRebuildReceipt('reinstall', receipt);
|
|
2033
|
-
for (const line of lines) {
|
|
2034
|
-
writeLine(io.stdout, line);
|
|
2035
|
-
}
|
|
1792
|
+
catch (error) {
|
|
1793
|
+
const failure = sanitizeCatalogSourceError(error, env);
|
|
1794
|
+
const message = redactString(failure.message);
|
|
1795
|
+
const code = catalogStoreErrorCode(error);
|
|
1796
|
+
if (rawOptions.json)
|
|
1797
|
+
writeJsonReceipt(io.stdout, {
|
|
1798
|
+
catalogStoreSchemaVersion: 2,
|
|
1799
|
+
command: 'catalog:store:prune',
|
|
1800
|
+
ok: false,
|
|
1801
|
+
overallState: 'failed',
|
|
1802
|
+
dryRun,
|
|
1803
|
+
entries: [],
|
|
1804
|
+
deleted: [],
|
|
1805
|
+
retained: [],
|
|
1806
|
+
errors: [{ code, message }],
|
|
1807
|
+
reclaimableBytes: null,
|
|
1808
|
+
deletedBytes: 0,
|
|
1809
|
+
});
|
|
1810
|
+
writeLine(io.stderr, message);
|
|
1811
|
+
commandExitState.exitCode = 1;
|
|
2036
1812
|
}
|
|
2037
|
-
writeWarnings(io.stderr, receipt.warnings, { actionableOnly: true });
|
|
2038
|
-
commandExitState.exitCode = resolveCommandReceiptExitCode(receipt);
|
|
2039
1813
|
});
|
|
2040
|
-
const
|
|
2041
|
-
.
|
|
2042
|
-
.description('Manage AW plugin configuration');
|
|
2043
|
-
config
|
|
2044
|
-
.command('list')
|
|
2045
|
-
.argument('[plugin]')
|
|
2046
|
-
.option('-s, --scope <scope>', 'read only project or user config')
|
|
2047
|
-
.option('--local', 'read only the current project local override layer', false)
|
|
2048
|
-
.option('-j, --json', 'print config as JSON', false)
|
|
1814
|
+
const recoveryCommand = (command) => command
|
|
1815
|
+
.option('-j, --json', 'print one recovery receipt as JSON', false)
|
|
2049
1816
|
.option('-v, --verbose', 'show command diagnostics', false)
|
|
2050
1817
|
.option('-D, --debug', 'write debug diagnostics to a log file', false)
|
|
2051
|
-
.option('--log-file <path>', 'write debug diagnostics to the specified file')
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
1818
|
+
.option('--log-file <path>', 'write debug diagnostics to the specified file');
|
|
1819
|
+
const contextualCommand = (command) => recoveryCommand(command)
|
|
1820
|
+
.addOption(strictValueOption('--context <context>', 'user only, or user and current project', ['user', 'project']));
|
|
1821
|
+
const recoveryScope = (rawOptions) => normalizeWriteRequest(() => parseScopeValue(rawOptions.scope));
|
|
1822
|
+
const recoveryContext = (rawOptions) => rawOptions.context === undefined
|
|
1823
|
+
? undefined : normalizeWriteRequest(() => parseContextValue(rawOptions.context));
|
|
1824
|
+
const runRecoveryAction = async (command, rawOptions, action) => {
|
|
1825
|
+
const context = createActionContext(command, rawOptions);
|
|
1826
|
+
const result = await runActionWithContext(context, () => action(context));
|
|
1827
|
+
if (rawOptions.json)
|
|
1828
|
+
writeJsonReceipt(io.stdout, result);
|
|
1829
|
+
else
|
|
1830
|
+
renderRecoveryReceipt(io.stdout, result);
|
|
1831
|
+
commandExitState.exitCode = result.ok ? 0
|
|
1832
|
+
: result.errors.some((error) => error.code === 'invalidArguments') ? 2 : 1;
|
|
1833
|
+
};
|
|
1834
|
+
const showWorkContext = async (context, rawOptions) => {
|
|
1835
|
+
if (rawOptions.scope === 'project' && rawOptions.context === 'user') {
|
|
1836
|
+
throw new WriteCommandRequestError('--scope project cannot be combined with --context user.');
|
|
1837
|
+
}
|
|
1838
|
+
const work = await resolveWorkContext({ cwd: context.cwd, context: recoveryContext(rawOptions),
|
|
1839
|
+
...(rawOptions.scope === undefined ? {} : { scope: recoveryScope(rawOptions) }) });
|
|
1840
|
+
if (!rawOptions.json)
|
|
1841
|
+
writeLine(io.stdout, work.projectRoot
|
|
1842
|
+
? `工作上下文:用户与当前项目 ${work.projectRoot}` : '工作上下文:仅用户');
|
|
1843
|
+
return work;
|
|
1844
|
+
};
|
|
1845
|
+
const targets = program.command('target').description('Manage the local platform policy');
|
|
1846
|
+
program.command('internal', { hidden: true }).description('AW host integration protocols')
|
|
1847
|
+
.command('cursor-workspace-open').description('Return current Cursor workspace plugin paths')
|
|
1848
|
+
.requiredOption('--scope <scope>', 'user or project scope')
|
|
1849
|
+
.option('--project-root <path>', 'the exact project workspace root')
|
|
1850
|
+
.option('--plugin-id <source/plugin>', 'return only the exact required plugin package')
|
|
1851
|
+
.action(async (rawOptions) => {
|
|
1852
|
+
commandExitState.exitCode = await runCursorWorkspaceHookCli(['--scope', rawOptions.scope,
|
|
1853
|
+
...(rawOptions.projectRoot ? ['--project-root', rawOptions.projectRoot] : []),
|
|
1854
|
+
...(rawOptions.pluginId ? ['--plugin-id', rawOptions.pluginId] : [])], { cwd, env, stdin: options.stdin ?? process.stdin, stdout: io.stdout, stderr: io.stderr });
|
|
1855
|
+
});
|
|
1856
|
+
contextualCommand(targets.command('set').argument('[targets...]'))
|
|
1857
|
+
.option('--none', 'save an empty target set', false)
|
|
1858
|
+
.option('--force', 'save newly selected unavailable targets without bypassing installation requirements', false)
|
|
1859
|
+
.option('--apply', 'apply the saved target policy in this work context', false)
|
|
1860
|
+
.option('-y, --yes', 'confirm reviewed output changes', false)
|
|
1861
|
+
.action(async (agents, rawOptions) => {
|
|
1862
|
+
if (rawOptions.none ? agents.length > 0 : agents.length === 0) {
|
|
1863
|
+
throw new WriteCommandRequestError('Use target IDs or --none, but not both.');
|
|
1864
|
+
}
|
|
1865
|
+
const normalized = normalizeWriteRequest(() => normalizeAgents(agents));
|
|
1866
|
+
await runRecoveryAction('targets:set', rawOptions, async (context) => {
|
|
1867
|
+
await showWorkContext(context, rawOptions);
|
|
1868
|
+
return targetsSet({ cwd: context.cwd, env: context.env, targets: normalized,
|
|
1869
|
+
context: recoveryContext(rawOptions), apply: rawOptions.apply, yes: rawOptions.yes,
|
|
1870
|
+
force: rawOptions.force,
|
|
1871
|
+
cliVersion: resolveCliVersion(), runtime: recoveryRuntime(context, rawOptions, true) });
|
|
2089
1872
|
});
|
|
2090
|
-
if (outcome.cancelled)
|
|
2091
|
-
return;
|
|
2092
|
-
const resolved = outcome.value;
|
|
2093
|
-
const selectedPluginName = resolved.pluginName;
|
|
2094
|
-
if (rawOptions.json) {
|
|
2095
|
-
writeJsonReceipt(io.stdout, {
|
|
2096
|
-
ok: true,
|
|
2097
|
-
configSchemaVersion: 4,
|
|
2098
|
-
command: 'config:list',
|
|
2099
|
-
plugin: selectedPluginName,
|
|
2100
|
-
pluginName: selectedPluginName,
|
|
2101
|
-
pluginId: resolved.pluginId,
|
|
2102
|
-
sourceId: resolved.sourceId,
|
|
2103
|
-
sourceIdentity: resolved.sourceIdentity,
|
|
2104
|
-
scope: rawOptions.local ? 'project' : rawOptions.scope ?? 'effective',
|
|
2105
|
-
projectLayer: rawOptions.local ? 'local' : 'shared',
|
|
2106
|
-
...(resolved.result.schema ? { schema: resolved.result.schema } : {}),
|
|
2107
|
-
fields: resolved.result.fields,
|
|
2108
|
-
});
|
|
2109
|
-
}
|
|
2110
|
-
else {
|
|
2111
|
-
writeConfigReadHuman(io.stdout, resolved.result, resolved.pluginId);
|
|
2112
|
-
}
|
|
2113
1873
|
});
|
|
2114
|
-
|
|
2115
|
-
.
|
|
2116
|
-
.
|
|
2117
|
-
|
|
2118
|
-
.
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
if (!rawOptions.local)
|
|
2129
|
-
resolveConfigReadResolution(rawOptions.scope);
|
|
2130
|
-
const execute = async (selectedPlugin) => resolveMultiSourceConfigRead({
|
|
2131
|
-
selector: selectedPlugin,
|
|
2132
|
-
...(key === undefined ? {} : { key }),
|
|
2133
|
-
rawOptions,
|
|
2134
|
-
context,
|
|
1874
|
+
contextualCommand(targets.command('list'))
|
|
1875
|
+
.action(async (rawOptions) => runRecoveryAction('targets:list', rawOptions, (context) => targetsList({ cwd: context.cwd, env: context.env, context: recoveryContext(rawOptions),
|
|
1876
|
+
runtime: { nativeCliRunner: context.nativeCliRunner } })));
|
|
1877
|
+
for (const action of ['exclude', 'include']) {
|
|
1878
|
+
contextualCommand(targets.command(action).argument('<plugin>'))
|
|
1879
|
+
.addOption(strictValueOption('--target <target>', 'one canonical platform target', PLATFORM_TARGETS).makeOptionMandatory())
|
|
1880
|
+
.option('--apply', 'apply the saved exclusion policy in this work context', false)
|
|
1881
|
+
.option('-y, --yes', 'confirm reviewed output changes', false)
|
|
1882
|
+
.action(async (selector, rawOptions) => {
|
|
1883
|
+
await runRecoveryAction(`targets:${action}`, rawOptions, async (context) => {
|
|
1884
|
+
await showWorkContext(context, rawOptions);
|
|
1885
|
+
return targetsChangeExclusion({ cwd: context.cwd, env: context.env, context: recoveryContext(rawOptions),
|
|
1886
|
+
selector, target: rawOptions.target, excluded: action === 'exclude', apply: rawOptions.apply,
|
|
1887
|
+
yes: rawOptions.yes, cliVersion: resolveCliVersion(), runtime: recoveryRuntime(context, rawOptions, true) });
|
|
2135
1888
|
});
|
|
2136
|
-
if (pluginName)
|
|
2137
|
-
return { cancelled: false, pluginName, value: await execute(pluginName) };
|
|
2138
|
-
if (!isWizardAvailable(context, rawOptions))
|
|
2139
|
-
throw new Error(configCommandUsage('get'));
|
|
2140
|
-
const currentCandidates = await loadWizardCandidates(context, {});
|
|
2141
|
-
const storedCandidates = await loadStoredConfigWizardCandidates(context, configReadStoreLocations(rawOptions));
|
|
2142
|
-
const candidates = mergeWizardCandidates(currentCandidates, storedCandidates);
|
|
2143
|
-
if (candidates.length === 0) {
|
|
2144
|
-
throw new Error('No plugin config candidates exist in the selected location.');
|
|
2145
|
-
}
|
|
2146
|
-
const result = await runCommandWizard(context, {
|
|
2147
|
-
command: 'config:get',
|
|
2148
|
-
candidates,
|
|
2149
|
-
initial: { plugins: [], key, scope: rawOptions.scope },
|
|
2150
|
-
pluginMode: 'single',
|
|
2151
|
-
...equivalentConfigCommandProjection((selection) => ({
|
|
2152
|
-
command: 'get',
|
|
2153
|
-
plugin: selection.plugins[0],
|
|
2154
|
-
key,
|
|
2155
|
-
scope: rawOptions.scope,
|
|
2156
|
-
projectLayer: rawOptions.local ? 'local' : 'shared',
|
|
2157
|
-
})),
|
|
2158
|
-
execute: (selection) => execute(selection.plugins[0]),
|
|
2159
|
-
});
|
|
2160
|
-
return result.cancelled
|
|
2161
|
-
? { cancelled: true }
|
|
2162
|
-
: { cancelled: false, pluginName: result.selection.plugins[0], value: result.value };
|
|
2163
1889
|
});
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
ok: true,
|
|
2171
|
-
configSchemaVersion: 4,
|
|
2172
|
-
command: 'config:get',
|
|
2173
|
-
plugin: selectedPluginName,
|
|
2174
|
-
pluginName: selectedPluginName,
|
|
2175
|
-
pluginId: resolved.pluginId,
|
|
2176
|
-
sourceId: resolved.sourceId,
|
|
2177
|
-
sourceIdentity: resolved.sourceIdentity,
|
|
2178
|
-
key,
|
|
2179
|
-
scope: rawOptions.local ? 'project' : rawOptions.scope ?? 'effective',
|
|
2180
|
-
projectLayer: rawOptions.local ? 'local' : 'shared',
|
|
2181
|
-
...(resolved.result.schema ? { schema: resolved.result.schema } : {}),
|
|
2182
|
-
fields: resolved.result.fields,
|
|
2183
|
-
});
|
|
2184
|
-
}
|
|
2185
|
-
else {
|
|
2186
|
-
writeConfigReadHuman(io.stdout, resolved.result, resolved.pluginId);
|
|
2187
|
-
}
|
|
2188
|
-
});
|
|
2189
|
-
config
|
|
2190
|
-
.command('set')
|
|
2191
|
-
.argument('[plugin]')
|
|
2192
|
-
.argument('[key]')
|
|
2193
|
-
.argument('[value]')
|
|
2194
|
-
.option('-s, --scope <scope>', 'project or user')
|
|
2195
|
-
.option('--local', 'write only the current project local override layer', false)
|
|
2196
|
-
.option('--value-json', 'parse value as a JSON literal', false)
|
|
2197
|
-
.option('-j, --json', 'print receipt as JSON', false)
|
|
1890
|
+
}
|
|
1891
|
+
const config = plugin.command('config').description('Manage user common and platform configuration');
|
|
1892
|
+
const configCommand = (command) => command
|
|
1893
|
+
.addOption(strictValueOption('--platform <target>', 'configuration platform; omitted means common', PLATFORM_TARGETS))
|
|
1894
|
+
.addOption(strictValueOption('--context <context>', 'definition and reference context', ['user', 'project']))
|
|
1895
|
+
.option('-j, --json', 'print one JSON object', false)
|
|
2198
1896
|
.option('-v, --verbose', 'show command diagnostics', false)
|
|
2199
1897
|
.option('-D, --debug', 'write debug diagnostics to a log file', false)
|
|
2200
|
-
.option('--log-file <path>', 'write debug diagnostics to the specified file')
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
1898
|
+
.option('--log-file <path>', 'write debug diagnostics to the specified file');
|
|
1899
|
+
const configMutation = (command) => configCommand(command)
|
|
1900
|
+
.option('--apply', 'refresh existing affected outputs after saving', false)
|
|
1901
|
+
.option('--native-consent', 'authorize this Gemini operation; may persist source-folder and current-workspace trust', false)
|
|
1902
|
+
.option('--script-timeout <ms>', 'override plugin preApply timeout in milliseconds')
|
|
1903
|
+
.option('-y, --yes', 'confirm reviewed output changes', false);
|
|
1904
|
+
const configContext = async (context, rawOptions, apply = rawOptions.apply === true) => {
|
|
1905
|
+
if (rawOptions.nativeConsent && !apply)
|
|
1906
|
+
throw new WriteCommandRequestError('--native-consent requires --apply or config apply.');
|
|
1907
|
+
const requested = rawOptions.context === undefined ? apply ? undefined : 'user'
|
|
1908
|
+
: normalizeWriteRequest(() => parseContextValue(rawOptions.context));
|
|
1909
|
+
const work = await resolveWorkContext({ cwd: context.cwd, context: requested });
|
|
1910
|
+
if (apply && !rawOptions.json)
|
|
1911
|
+
writeLine(io.stdout, work.projectRoot
|
|
1912
|
+
? `工作上下文:用户与当前项目 ${work.projectRoot}` : '工作上下文:仅用户');
|
|
1913
|
+
return work;
|
|
1914
|
+
};
|
|
1915
|
+
const configPlatform = (rawOptions) => rawOptions.platform === undefined
|
|
1916
|
+
? undefined : normalizeWriteRequest(() => parsePlatformTargetValue(rawOptions.platform));
|
|
1917
|
+
for (const command of ['schema', 'list', 'get']) {
|
|
1918
|
+
const entry = configCommand((command === 'list' ? new Command(command) : config.command(command)).argument('<plugin>'));
|
|
1919
|
+
if (command === 'get')
|
|
1920
|
+
entry.argument('[key]');
|
|
1921
|
+
entry.action(async (...args) => {
|
|
1922
|
+
const selector = args[0];
|
|
1923
|
+
const key = command === 'get' ? args[1] : undefined;
|
|
1924
|
+
const rawOptions = args[command === 'get' ? 2 : 1];
|
|
1925
|
+
const context = createActionContext(`config:${command}`, rawOptions);
|
|
1926
|
+
const work = await configContext(context, rawOptions);
|
|
1927
|
+
const resolved = await runActionWithContext(context, () => resolveMultiSourceConfigRead({
|
|
1928
|
+
selector, key, rawOptions: { ...rawOptions, context: work.context }, context,
|
|
1929
|
+
}));
|
|
1930
|
+
if (rawOptions.json) {
|
|
1931
|
+
const result = projectReceipt(`plugin.config.${command}`, {
|
|
1932
|
+
ok: true, configSchemaVersion: 5, command: `config:${command}`,
|
|
1933
|
+
plugin: resolved.pluginName, pluginName: resolved.pluginName, pluginId: resolved.pluginId,
|
|
1934
|
+
sourceId: resolved.sourceId, sourceIdentity: resolved.sourceIdentity,
|
|
1935
|
+
context: work, platform: configPlatform(rawOptions) ?? 'common',
|
|
1936
|
+
...(resolved.result.schema ? { schema: resolved.result.schema } : {}),
|
|
1937
|
+
fields: command === 'schema' ? resolved.result.fieldDefinitions ?? {} : resolved.result.fields,
|
|
1938
|
+
...(key === undefined ? {} : { key }),
|
|
1939
|
+
});
|
|
1940
|
+
if (command === 'get')
|
|
1941
|
+
for (const field of resolved.result.fields) {
|
|
1942
|
+
const definition = resolved.result.fieldDefinitions?.[field.key];
|
|
1943
|
+
if (field.kind !== 'manifest' || field.valueState !== 'invalid' || !definition?.sensitive)
|
|
1944
|
+
continue;
|
|
1945
|
+
result.nextActions.push({ kind: 'command',
|
|
1946
|
+
argv: ['aw', 'plugin', 'config', 'set', resolved.pluginId, field.key,
|
|
1947
|
+
'--context', work.context, ...(resolved.result.platform ? ['--platform', resolved.result.platform] : []), '--value-stdin'],
|
|
1948
|
+
reason: 'Replace the invalid sensitive configuration value through stdin.', requiresConfirmation: false });
|
|
1949
|
+
}
|
|
1950
|
+
writeJsonReceipt(io.stdout, result);
|
|
1951
|
+
}
|
|
1952
|
+
else if (command === 'schema')
|
|
1953
|
+
writeJsonReceipt(io.stdout, resolved.result.fieldDefinitions ?? {});
|
|
1954
|
+
else
|
|
1955
|
+
writeConfigReadHuman(io.stdout, resolved.result, resolved.pluginId);
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
for (const command of ['set', 'edit', 'unset']) {
|
|
1959
|
+
const entry = configMutation((command === 'edit' ? new Command(command) : config.command(command)).argument('<plugin>'));
|
|
1960
|
+
if (command !== 'edit')
|
|
1961
|
+
entry.argument('<field>');
|
|
1962
|
+
if (command === 'set')
|
|
1963
|
+
entry
|
|
1964
|
+
.option('--value-json <json>', 'set an exact JSON value')
|
|
1965
|
+
.option('--value-stdin', 'read the exact string value until stdin EOF', false)
|
|
1966
|
+
.option('--preset <id>', 'use a declared preset');
|
|
1967
|
+
entry.action(async (...args) => {
|
|
1968
|
+
const selector = args[0];
|
|
1969
|
+
const rawOptions = args[command === 'edit' ? 1 : 2];
|
|
1970
|
+
let key = command === 'edit' ? undefined : args[1];
|
|
1971
|
+
const context = createActionContext(`config:${command}`, rawOptions);
|
|
1972
|
+
try {
|
|
1973
|
+
const work = await configContext(context, rawOptions);
|
|
1974
|
+
const platform = configPlatform(rawOptions);
|
|
1975
|
+
const scriptTimeoutMs = normalizeWriteRequest(() => resolveScriptTimeoutMs(rawOptions));
|
|
1976
|
+
if (command === 'edit' && (!isWizardAvailable(context, rawOptions) || !context.prompt.select || !context.prompt.input)) {
|
|
1977
|
+
throw new WriteCommandRequestError('config edit requires an interactive terminal. Use config set for scripts.');
|
|
1978
|
+
}
|
|
1979
|
+
const explicitValueCount = [rawOptions.valueJson !== undefined, rawOptions.valueStdin === true,
|
|
1980
|
+
rawOptions.preset !== undefined].filter(Boolean).length;
|
|
1981
|
+
if (command === 'set' && (explicitValueCount > 1 || explicitValueCount === 0
|
|
1982
|
+
&& !(context.interactive && context.isTty && !context.isCi && !rawOptions.json))) {
|
|
1983
|
+
throw new WriteCommandRequestError('Use exactly one of --value-json, --value-stdin, or --preset.');
|
|
1984
|
+
}
|
|
1985
|
+
const receipt = await runActionWithContext(context, () => withResolvedConfigMutationPlugin(context, selector, async ({ pluginId, source, plugin }, awHomeMutationToken, catalogOperationContext) => {
|
|
1986
|
+
if (!plugin.manifest.config)
|
|
1987
|
+
throw Object.assign(new Error(`configSchemaUnavailable: Plugin "${plugin.manifest.name}" does not declare an AW config schema.`), { code: 'configSchemaUnavailable' });
|
|
1988
|
+
const fields = selectPluginConfigProfile(plugin.manifest.config, platform).fields;
|
|
1989
|
+
if (command === 'edit') {
|
|
1990
|
+
const selected = await context.prompt.select({ message: `编辑用户${platform ?? 'common'}配置`,
|
|
1991
|
+
choices: Object.entries(fields).map(([value, field]) => ({ value, label: field.title ?? value })) });
|
|
1992
|
+
if (selected.cancelled || selected.action !== 'select' || selected.value === undefined)
|
|
1993
|
+
return undefined;
|
|
1994
|
+
key = selected.value;
|
|
1995
|
+
}
|
|
1996
|
+
const field = fields[key];
|
|
1997
|
+
const store = await readPluginConfigStore({ sourceId: source.sourceId,
|
|
1998
|
+
sourceIdentity: source.sourceIdentity, logicalIdentity: source.logicalIdentity,
|
|
1999
|
+
pluginName: plugin.manifest.name, scope: 'user', platform, cwd: context.cwd, env: context.env,
|
|
2000
|
+
schema: fields });
|
|
2001
|
+
if (command === 'unset') {
|
|
2002
|
+
if (!Object.hasOwn(store.values, key))
|
|
2003
|
+
throw new WriteCommandRequestError(`Unknown config key "${key}" in the selected layer.`);
|
|
2211
2004
|
}
|
|
2212
|
-
if (!
|
|
2213
|
-
throw new
|
|
2005
|
+
else if (!field)
|
|
2006
|
+
throw new WriteCommandRequestError(`Unknown config key "${key}".`);
|
|
2007
|
+
let inputValue;
|
|
2008
|
+
if (command !== 'unset') {
|
|
2009
|
+
const sensitive = field.sensitive === true;
|
|
2010
|
+
if (sensitive && (rawOptions.valueJson !== undefined || rawOptions.preset !== undefined)) {
|
|
2011
|
+
throw Object.assign(new WriteCommandRequestError('Sensitive config requires --value-stdin.'), { code: 'sensitiveConfigInputUnsupported' });
|
|
2012
|
+
}
|
|
2013
|
+
if (rawOptions.valueStdin)
|
|
2014
|
+
inputValue = await readUtf8Stdin(context.stdin);
|
|
2015
|
+
else if (sensitive) {
|
|
2016
|
+
if (!context.interactive || !context.isTty || context.isCi || rawOptions.json || !context.prompt.password) {
|
|
2017
|
+
throw new Error('sensitiveConfigStdinRequired: Use --value-stdin outside an interactive terminal.');
|
|
2018
|
+
}
|
|
2019
|
+
const response = await context.prompt.password({ message: `输入 ${field.title ?? key}`, mask: true });
|
|
2020
|
+
if (response.cancelled || response.action !== 'select' || response.value === undefined)
|
|
2021
|
+
return undefined;
|
|
2022
|
+
inputValue = response.value;
|
|
2023
|
+
}
|
|
2024
|
+
else if (command === 'edit' || explicitValueCount === 0) {
|
|
2025
|
+
if (!context.prompt.input)
|
|
2026
|
+
throw new WriteCommandRequestError('Use --value-json, --value-stdin, or --preset.');
|
|
2027
|
+
const response = await context.prompt.input({ message: `输入 ${field.title ?? key} 的 JSON 值`,
|
|
2028
|
+
defaultValue: JSON.stringify(store.values[key]) });
|
|
2029
|
+
if (response.cancelled || response.action !== 'select' || response.value === undefined)
|
|
2030
|
+
return undefined;
|
|
2031
|
+
try {
|
|
2032
|
+
inputValue = JSON.parse(response.value);
|
|
2033
|
+
}
|
|
2034
|
+
catch {
|
|
2035
|
+
throw new WriteCommandRequestError('Enter a valid JSON value.');
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
else if (rawOptions.valueJson !== undefined) {
|
|
2039
|
+
try {
|
|
2040
|
+
inputValue = JSON.parse(rawOptions.valueJson);
|
|
2041
|
+
}
|
|
2042
|
+
catch {
|
|
2043
|
+
throw new WriteCommandRequestError('--value-json must contain valid JSON.');
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
else {
|
|
2047
|
+
const preset = field.choices?.presets.find((candidate) => candidate.id === rawOptions.preset);
|
|
2048
|
+
if (!preset)
|
|
2049
|
+
throw new WriteCommandRequestError(`Unknown preset "${rawOptions.preset}".`);
|
|
2050
|
+
inputValue = structuredClone(preset.value);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
if (command !== 'unset') {
|
|
2054
|
+
try {
|
|
2055
|
+
inputValue = (await coercePluginConfigUpdates({ schema: fields, updates: { [key]: inputValue }, cwd: context.cwd }))[key];
|
|
2056
|
+
}
|
|
2057
|
+
catch {
|
|
2058
|
+
throw new WriteCommandRequestError(`Invalid value for configuration field "${key}".`);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
try {
|
|
2062
|
+
await assertPluginConfigMutationCandidate({ sourceId: source.sourceId, sourceIdentity: source.sourceIdentity,
|
|
2063
|
+
logicalIdentity: source.logicalIdentity, pluginName: plugin.manifest.name, manifest: plugin.manifest,
|
|
2064
|
+
scope: work.context, platform, cwd: context.cwd, env: context.env,
|
|
2065
|
+
updates: command === 'unset' ? {} : { [key]: inputValue }, removeKeys: command === 'unset' ? [key] : [] });
|
|
2066
|
+
}
|
|
2067
|
+
catch (error) {
|
|
2068
|
+
if (error?.code === 'configReferenceInvalid')
|
|
2069
|
+
throw new WriteCommandRequestError(`Invalid value or reference for configuration field "${key}".`);
|
|
2070
|
+
throw error;
|
|
2214
2071
|
}
|
|
2215
|
-
const
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
catalogOperationContext,
|
|
2072
|
+
const mutation = command === 'unset' ? { kind: 'patch', removeKeys: [key] } : { kind: 'patch', updates: { [key]: inputValue } };
|
|
2073
|
+
const confirmation = rawOptions.apply ? await preparePublicConfigConfirmation({ plugin, scope: work.context,
|
|
2074
|
+
context: work.context, platform, cwd: context.cwd, env: context.env, cliVersion: resolveCliVersion(),
|
|
2075
|
+
nativeCliRunner: context.nativeCliRunner, awHomeMutationToken, yes: rawOptions.yes, mutation,
|
|
2076
|
+
rebuildRuntime: { ...context, nativeConsent: rawOptions.nativeConsent === true, awHomeMutationToken, catalogOperationContext,
|
|
2077
|
+
expectedGenerationSetDigest: catalogOperationContext.generationSetDigest } })
|
|
2078
|
+
: { required: false, provided: rawOptions.yes === true, effects: [] };
|
|
2079
|
+
const writeReceipt = await applyPluginConfigWrite({ plugin, pluginName: plugin.manifest.name,
|
|
2080
|
+
scope: work.context, context: work.context, platform, cliVersion: resolveCliVersion(),
|
|
2081
|
+
cwd: context.cwd, env: context.env, nativeCliRunner: context.nativeCliRunner,
|
|
2082
|
+
rebuildRuntime: { ...context, nativeConsent: rawOptions.nativeConsent === true, awHomeMutationToken, catalogOperationContext,
|
|
2227
2083
|
expectedGenerationSetDigest: catalogOperationContext.generationSetDigest,
|
|
2228
|
-
|
|
2229
|
-
awHomeMutationToken,
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2084
|
+
...(scriptTimeoutMs === undefined ? {} : { scriptTimeoutMs }) },
|
|
2085
|
+
awHomeMutationToken, request: command === 'unset' ? { removeKeys: [key] } : { updates: { [key]: inputValue } },
|
|
2086
|
+
apply: rawOptions.apply === true, sharedNativeApplyConfirmed: rawOptions.yes === true,
|
|
2087
|
+
preApplyConfirmed: rawOptions.yes === true });
|
|
2088
|
+
return buildConfigMutationReceipt(`config:${command}`, {
|
|
2089
|
+
...writeReceipt, confirmation, nativeConsent: rawOptions.nativeConsent === true, ok: writeReceipt.overallState === 'succeeded', plugin: plugin.manifest.name,
|
|
2090
|
+
pluginName: plugin.manifest.name, pluginId, sourceId: source.sourceId, sourceIdentity: source.sourceIdentity,
|
|
2091
|
+
context: work, platform: platform ?? 'common',
|
|
2092
|
+
...(command === 'unset' ? { removedKey: key, existed: true } : {}),
|
|
2093
|
+
affectedFields: [{ key: key, title: field?.title ?? key, kind: 'manifest', reserved: false,
|
|
2094
|
+
action: command === 'unset' ? 'unset' : 'set', scope: 'user',
|
|
2095
|
+
...(writeReceipt.staleRemovedKeys?.includes(key) ? { stale: true } : {}) }],
|
|
2233
2096
|
});
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
sourceId: source.sourceId,
|
|
2243
|
-
sourceIdentity: source.sourceIdentity,
|
|
2244
|
-
affectedFields: [{
|
|
2245
|
-
key: selectedKey,
|
|
2246
|
-
title: plugin?.manifest.config?.schema?.[selectedKey]?.title ?? selectedKey,
|
|
2247
|
-
kind: 'manifest',
|
|
2248
|
-
reserved: false,
|
|
2249
|
-
action: 'set',
|
|
2250
|
-
scope,
|
|
2251
|
-
...(scope === 'project' ? { projectLayer } : {}),
|
|
2252
|
-
}],
|
|
2253
|
-
};
|
|
2254
|
-
});
|
|
2255
|
-
if (pluginName && key && rawValue !== undefined) {
|
|
2256
|
-
const inputValue = parseConfigValue(rawValue, rawOptions.valueJson === true);
|
|
2257
|
-
return {
|
|
2258
|
-
cancelled: false,
|
|
2259
|
-
key,
|
|
2260
|
-
value: await execute(pluginName, key, inputValue),
|
|
2261
|
-
};
|
|
2097
|
+
}, rawOptions.apply === true));
|
|
2098
|
+
if (!receipt)
|
|
2099
|
+
return;
|
|
2100
|
+
if (rawOptions.json)
|
|
2101
|
+
writeJsonReceipt(io.stdout, receipt);
|
|
2102
|
+
else {
|
|
2103
|
+
writeLine(io.stdout, `已保存 ${receipt.plugin}.${key}(用户 ${platform ?? 'common'} 配置)。`);
|
|
2104
|
+
writeConfigApplyNotice(io.stderr, receipt);
|
|
2262
2105
|
}
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2106
|
+
commandExitState.exitCode = receipt.overallState === 'succeeded' ? 0 : 1;
|
|
2107
|
+
}
|
|
2108
|
+
catch (error) {
|
|
2109
|
+
writeConfigMutationFailure(`config:${command}`, selector, rawOptions.json === true, error);
|
|
2110
|
+
}
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2113
|
+
configMutation(config.command('reset').argument('<plugin>'))
|
|
2114
|
+
.action(async (selector, rawOptions) => {
|
|
2115
|
+
const context = createActionContext('config:reset', rawOptions);
|
|
2116
|
+
try {
|
|
2117
|
+
const work = await configContext(context, rawOptions);
|
|
2118
|
+
const platform = configPlatform(rawOptions);
|
|
2119
|
+
if (!rawOptions.yes) {
|
|
2120
|
+
if (!isWizardAvailable(context, rawOptions) || !context.prompt.confirm)
|
|
2121
|
+
throw new WriteCommandRequestError('config reset requires --yes.');
|
|
2122
|
+
const confirmed = await context.prompt.confirm({ message: `删除 ${selector} 的用户 ${platform ?? 'common'} 覆盖?`, defaultValue: false });
|
|
2123
|
+
if (confirmed.cancelled || confirmed.value !== true)
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
const located = await resolveStoredConfigResetIdentity({ selector, context, scope: 'user' });
|
|
2127
|
+
const resetStore = async (plugin, pluginError) => withAwHomeMutationLock({ env: context.env, action: async (awHomeMutationToken) => {
|
|
2128
|
+
const confirmation = plugin && rawOptions.apply ? await preparePublicConfigConfirmation({ plugin,
|
|
2129
|
+
scope: work.context, context: work.context, platform, cwd: context.cwd, env: context.env,
|
|
2130
|
+
cliVersion: resolveCliVersion(), nativeCliRunner: context.nativeCliRunner, awHomeMutationToken,
|
|
2131
|
+
yes: rawOptions.yes, mutation: { kind: 'reset' }, rebuildRuntime: context }) : null;
|
|
2132
|
+
const receipt = await resetPluginConfigWithHelper({ ...located, plugin, pluginError, platform, scope: work.context,
|
|
2133
|
+
context: work.context, cliVersion: resolveCliVersion(), cwd: context.cwd, env: context.env, awHomeMutationToken,
|
|
2134
|
+
nativeCliRunner: context.nativeCliRunner, apply: rawOptions.apply === true,
|
|
2135
|
+
rebuildRuntime: { ...context, nativeConsent: rawOptions.nativeConsent === true, awHomeMutationToken, scriptTimeoutMs: resolveScriptTimeoutMs(rawOptions) },
|
|
2136
|
+
sharedNativeApplyConfirmed: true, preApplyConfirmed: rawOptions.yes === true });
|
|
2137
|
+
return { ...receipt, confirmation };
|
|
2138
|
+
} });
|
|
2139
|
+
let started = false;
|
|
2140
|
+
const resetReceipt = await runActionWithContext(context, async () => {
|
|
2141
|
+
try {
|
|
2142
|
+
return await withResolvedCatalogPlugin({ selector: located.pluginId, cliVersion: resolveCliVersion(), env: context.env,
|
|
2143
|
+
consume: ({ plugin }) => { started = true; return resetStore(plugin, null); } });
|
|
2275
2144
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2145
|
+
catch (error) {
|
|
2146
|
+
if (started)
|
|
2147
|
+
throw error;
|
|
2148
|
+
return resetStore(null, error instanceof Error ? error : new Error(String(error)));
|
|
2279
2149
|
}
|
|
2280
|
-
const result = await runCommandWizard(context, {
|
|
2281
|
-
command: 'config:set',
|
|
2282
|
-
candidates: configurableCandidates,
|
|
2283
|
-
initial: {
|
|
2284
|
-
plugins: pluginName ? [pluginName] : [],
|
|
2285
|
-
key,
|
|
2286
|
-
...(rawValue !== undefined ? { value: rawValue } : {}),
|
|
2287
|
-
scope,
|
|
2288
|
-
projectLayer,
|
|
2289
|
-
},
|
|
2290
|
-
pluginMode: pluginName ? 'none' : 'single',
|
|
2291
|
-
valueJson: rawOptions.valueJson === true,
|
|
2292
|
-
promptForKey: key === undefined,
|
|
2293
|
-
promptForValue: rawValue === undefined,
|
|
2294
|
-
...equivalentConfigCommandProjection((selection) => configSetEquivalentOptions(selection, candidates, rawOptions)),
|
|
2295
|
-
commandIsTemplate: (selection) => candidates.find((entry) => entry.pluginName === selection.plugins[0])?.configSchema?.[selection.key ?? ''] !== undefined
|
|
2296
|
-
&& configFieldPlaceholder(candidates.find((entry) => entry.pluginName === selection.plugins[0])?.configSchema?.[selection.key ?? '']) !== undefined,
|
|
2297
|
-
resultState: overallResultState,
|
|
2298
|
-
execute: async (selection) => {
|
|
2299
|
-
const selectedPlugin = selection.plugins[0];
|
|
2300
|
-
const selectedKey = selection.key;
|
|
2301
|
-
const schema = candidates.find((entry) => entry.pluginName === selectedPlugin).configSchema;
|
|
2302
|
-
const updates = await coercePluginConfigUpdates({
|
|
2303
|
-
schema,
|
|
2304
|
-
updates: {
|
|
2305
|
-
[selectedKey]: parseConfigValue(selection.value, rawOptions.valueJson === true),
|
|
2306
|
-
},
|
|
2307
|
-
cwd: context.cwd,
|
|
2308
|
-
});
|
|
2309
|
-
return execute(selectedPlugin, selectedKey, updates[selectedKey]);
|
|
2310
|
-
},
|
|
2311
|
-
});
|
|
2312
|
-
return result.cancelled
|
|
2313
|
-
? { cancelled: true }
|
|
2314
|
-
: { cancelled: false, key: result.selection.key, value: result.value };
|
|
2315
2150
|
});
|
|
2151
|
+
const receipt = buildConfigMutationReceipt('config:reset', { ...resetReceipt, nativeConsent: rawOptions.nativeConsent === true,
|
|
2152
|
+
ok: resetReceipt.overallState === 'succeeded', ...located, plugin: located.pluginName,
|
|
2153
|
+
context: work, platform: platform ?? 'common' });
|
|
2154
|
+
if (rawOptions.json)
|
|
2155
|
+
writeJsonReceipt(io.stdout, receipt);
|
|
2156
|
+
else {
|
|
2157
|
+
writeLine(io.stdout, `已恢复 ${receipt.plugin} 的用户 ${platform ?? 'common'} 默认配置。`);
|
|
2158
|
+
writeConfigApplyNotice(io.stderr, receipt);
|
|
2159
|
+
}
|
|
2160
|
+
commandExitState.exitCode = receipt.overallState === 'succeeded' ? 0 : 1;
|
|
2316
2161
|
}
|
|
2317
2162
|
catch (error) {
|
|
2318
|
-
writeConfigMutationFailure('config:
|
|
2319
|
-
return;
|
|
2320
|
-
}
|
|
2321
|
-
if (outcome.cancelled)
|
|
2322
|
-
return;
|
|
2323
|
-
const receipt = outcome.value;
|
|
2324
|
-
const selectedKey = outcome.key;
|
|
2325
|
-
if (rawOptions.json) {
|
|
2326
|
-
writeJsonReceipt(io.stdout, receipt);
|
|
2163
|
+
writeConfigMutationFailure('config:reset', selector, rawOptions.json === true, error);
|
|
2327
2164
|
}
|
|
2165
|
+
});
|
|
2166
|
+
contextualCommand(config.command('apply').argument('<plugin>'))
|
|
2167
|
+
.option('--target <target>', 'limit existing-output refresh to this platform target', collectUniqueOption)
|
|
2168
|
+
.option('--native-consent', 'authorize this Gemini operation; may persist source-folder and current-workspace trust', false)
|
|
2169
|
+
.option('-y, --yes', 'confirm reviewed output changes', false)
|
|
2170
|
+
.option('--script-timeout <ms>', 'override plugin preApply timeout in milliseconds')
|
|
2171
|
+
.action(async (selector, rawOptions) => {
|
|
2172
|
+
const context = createActionContext('config:apply', rawOptions);
|
|
2173
|
+
const work = await configContext(context, rawOptions, true);
|
|
2174
|
+
const targets = rawOptions.target?.map((target) => normalizeWriteRequest(() => parsePlatformTargetValue(target)));
|
|
2175
|
+
const receipt = await runActionWithContext(context, () => withResolvedConfigMutationPlugin(context, selector, async ({ plugin, pluginId, source }, awHomeMutationToken) => {
|
|
2176
|
+
const confirmation = await preparePublicConfigConfirmation({ plugin, scope: work.context, context: work.context, targets, cwd: context.cwd, env: context.env, cliVersion: resolveCliVersion(), nativeCliRunner: context.nativeCliRunner, awHomeMutationToken, yes: rawOptions.yes, rebuildRuntime: context });
|
|
2177
|
+
return { confirmation, ...await applyPluginConfig({ plugin, scope: work.context, context: work.context, targets,
|
|
2178
|
+
cliVersion: resolveCliVersion(), cwd: context.cwd, env: context.env, awHomeMutationToken,
|
|
2179
|
+
nativeCliRunner: context.nativeCliRunner, sharedNativeApplyConfirmed: rawOptions.yes === true,
|
|
2180
|
+
preApplyConfirmed: rawOptions.yes === true, rebuildRuntime: { ...context, nativeConsent: rawOptions.nativeConsent === true, scriptTimeoutMs: resolveScriptTimeoutMs(rawOptions) } }),
|
|
2181
|
+
command: 'config:apply', plugin: plugin.manifest.name, pluginId, sourceId: source.sourceId,
|
|
2182
|
+
context: work,
|
|
2183
|
+
};
|
|
2184
|
+
}, true));
|
|
2185
|
+
const result = buildConfigMutationReceipt('config:apply', { ...receipt, nativeConsent: rawOptions.nativeConsent === true,
|
|
2186
|
+
ok: receipt.overallState === 'succeeded' });
|
|
2187
|
+
if (rawOptions.json)
|
|
2188
|
+
writeJsonReceipt(io.stdout, result);
|
|
2328
2189
|
else {
|
|
2329
|
-
writeLine(io.stdout,
|
|
2330
|
-
|
|
2331
|
-
writeProjectLocalConfigNotice(io.stdout);
|
|
2332
|
-
}
|
|
2333
|
-
writeConfigApplyNotice(io.stderr, receipt);
|
|
2190
|
+
writeLine(io.stdout, `配置应用:${result.ok ? '完成' : '部分失败'}。`);
|
|
2191
|
+
writeConfigApplyNotice(io.stderr, { ...result, warnings: [] });
|
|
2334
2192
|
}
|
|
2335
|
-
commandExitState.exitCode =
|
|
2193
|
+
commandExitState.exitCode = result.ok ? 0 : 1;
|
|
2336
2194
|
});
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
.
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2195
|
+
configurePublicCommands(program, options, io, commandExitState);
|
|
2196
|
+
Object.assign(program, { __awCommandExitState: commandExitState });
|
|
2197
|
+
return program;
|
|
2198
|
+
}
|
|
2199
|
+
/** Invoke the packaged author tool. Its JSON remains an internal child-process protocol. */
|
|
2200
|
+
async function runAuthoringCliAdapter(argv, options) {
|
|
2201
|
+
const io = { ...createDefaultIo(), ...options.io };
|
|
2202
|
+
const authoringPluginCommand = argv[0] === 'plugin';
|
|
2203
|
+
const explicitWorkspace = argv.some((token) => token === '--workspace-root' || token.startsWith('--workspace-root='));
|
|
2204
|
+
const authoringScriptByCommand = {
|
|
2205
|
+
init: 'init-plugin.mjs',
|
|
2206
|
+
'add-skill': 'add-skill.mjs',
|
|
2207
|
+
remove: 'remove-plugin.mjs',
|
|
2208
|
+
validate: 'validate-plugin.mjs',
|
|
2209
|
+
status: 'plugin-status.mjs',
|
|
2210
|
+
};
|
|
2211
|
+
const authoringScript = authoringPluginCommand
|
|
2212
|
+
? authoringScriptByCommand[argv[1] ?? '']
|
|
2213
|
+
: argv[0] === 'skill' && argv[1] === 'validate'
|
|
2214
|
+
? 'validate-skill.mjs'
|
|
2215
|
+
: undefined;
|
|
2216
|
+
if (authoringScript && ((!argv.includes('--help') && !argv.includes('-h'))
|
|
2217
|
+
|| explicitWorkspace && ['remove', 'status'].includes(argv[1] ?? ''))) {
|
|
2218
|
+
const authoringArgs = argv.slice(2);
|
|
2219
|
+
let authoringEnv = options.env ?? process.env;
|
|
2220
|
+
if (argv[0] === 'plugin'
|
|
2221
|
+
&& !authoringArgs.some((token) => token === '--plugin-root' || token.startsWith('--plugin-root='))) {
|
|
2222
|
+
let explicitRoot;
|
|
2223
|
+
for (let index = 0; index < authoringArgs.length; index += 1) {
|
|
2224
|
+
const token = authoringArgs[index];
|
|
2225
|
+
if (token.startsWith('--workspace-root='))
|
|
2226
|
+
explicitRoot = token.slice('--workspace-root='.length);
|
|
2227
|
+
if (token === '--workspace-root')
|
|
2228
|
+
explicitRoot = authoringArgs[index + 1];
|
|
2229
|
+
}
|
|
2230
|
+
const originalCwd = options.cwd ?? process.cwd();
|
|
2231
|
+
let discoveryCwd = originalCwd;
|
|
2232
|
+
if (argv[1] === 'validate') {
|
|
2233
|
+
const valueOptions = new Set(['--workspace-root', '--claude-skill-profile', '--version-base']);
|
|
2234
|
+
for (let index = 0; index < authoringArgs.length; index += 1) {
|
|
2235
|
+
const token = authoringArgs[index];
|
|
2236
|
+
if (valueOptions.has(token)) {
|
|
2237
|
+
index += 1;
|
|
2238
|
+
continue;
|
|
2239
|
+
}
|
|
2240
|
+
if (!token.startsWith('-')) {
|
|
2241
|
+
discoveryCwd = path.resolve(originalCwd, token);
|
|
2242
|
+
authoringArgs[index] = discoveryCwd;
|
|
2243
|
+
break;
|
|
2357
2244
|
}
|
|
2358
|
-
const store = await readPluginConfigStore({
|
|
2359
|
-
sourceId: source.sourceId,
|
|
2360
|
-
sourceIdentity: source.sourceIdentity,
|
|
2361
|
-
pluginName: plugin.manifest.name,
|
|
2362
|
-
scope,
|
|
2363
|
-
...(scope === 'project' ? { projectLayer } : {}),
|
|
2364
|
-
cwd: context.cwd,
|
|
2365
|
-
env: context.env,
|
|
2366
|
-
});
|
|
2367
|
-
const existed = Object.hasOwn(store.values, selectedKey);
|
|
2368
|
-
if (!existed)
|
|
2369
|
-
throw new Error(`Unknown config key "${selectedKey}".`);
|
|
2370
|
-
const writeReceipt = await applyPluginConfigWrite({
|
|
2371
|
-
plugin,
|
|
2372
|
-
pluginName: plugin.manifest.name,
|
|
2373
|
-
scope,
|
|
2374
|
-
projectLayer,
|
|
2375
|
-
cwd: context.cwd,
|
|
2376
|
-
env: context.env,
|
|
2377
|
-
nativeCliRunner: context.nativeCliRunner,
|
|
2378
|
-
rebuildRuntime: {
|
|
2379
|
-
...context,
|
|
2380
|
-
awHomeMutationToken,
|
|
2381
|
-
catalogOperationContext,
|
|
2382
|
-
expectedGenerationSetDigest: catalogOperationContext.generationSetDigest,
|
|
2383
|
-
},
|
|
2384
|
-
awHomeMutationToken,
|
|
2385
|
-
request: {
|
|
2386
|
-
removeKeys: [selectedKey],
|
|
2387
|
-
},
|
|
2388
|
-
});
|
|
2389
|
-
return {
|
|
2390
|
-
ok: writeReceipt.overallState === 'succeeded',
|
|
2391
|
-
receiptSchemaVersion: 4,
|
|
2392
|
-
command: 'config:unset',
|
|
2393
|
-
...writeReceipt,
|
|
2394
|
-
plugin: plugin.manifest.name,
|
|
2395
|
-
pluginName: plugin.manifest.name,
|
|
2396
|
-
pluginId,
|
|
2397
|
-
sourceId: source.sourceId,
|
|
2398
|
-
sourceIdentity: source.sourceIdentity,
|
|
2399
|
-
removedKey: selectedKey,
|
|
2400
|
-
existed,
|
|
2401
|
-
affectedFields: [{
|
|
2402
|
-
key: selectedKey,
|
|
2403
|
-
title: plugin?.manifest.config?.schema?.[selectedKey]?.title ?? selectedKey,
|
|
2404
|
-
kind: 'manifest',
|
|
2405
|
-
reserved: false,
|
|
2406
|
-
action: 'unset',
|
|
2407
|
-
scope,
|
|
2408
|
-
...(scope === 'project' ? { projectLayer } : {}),
|
|
2409
|
-
}],
|
|
2410
|
-
};
|
|
2411
|
-
});
|
|
2412
|
-
if (pluginName && key) {
|
|
2413
|
-
return { cancelled: false, value: await execute(pluginName, key) };
|
|
2414
|
-
}
|
|
2415
|
-
if (!isWizardAvailable(context, rawOptions))
|
|
2416
|
-
throw new Error(configCommandUsage('unset'));
|
|
2417
|
-
const loadedCurrentCandidates = await loadWizardCandidates(context, {});
|
|
2418
|
-
const currentCandidates = loadedCurrentCandidates.filter(hasConfigSchemaKeys);
|
|
2419
|
-
const candidates = currentCandidates;
|
|
2420
|
-
if (pluginName && !candidates.some((entry) => entry.pluginName === pluginName)) {
|
|
2421
|
-
throw new Error(`Unknown plugin "${pluginName}".`);
|
|
2422
|
-
}
|
|
2423
|
-
if (candidates.length === 0) {
|
|
2424
|
-
throw new Error('No plugin config candidates exist in the selected location.');
|
|
2425
2245
|
}
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
promptForKey: key === undefined,
|
|
2432
|
-
destructive: true,
|
|
2433
|
-
...equivalentConfigCommandProjection((selection) => ({
|
|
2434
|
-
command: 'unset',
|
|
2435
|
-
plugin: selection.plugins[0],
|
|
2436
|
-
key: selection.key,
|
|
2437
|
-
scope: selection.scope ?? 'user',
|
|
2438
|
-
projectLayer: selection.projectLayer,
|
|
2439
|
-
})),
|
|
2440
|
-
resultState: overallResultState,
|
|
2441
|
-
execute: (selection) => execute(selection.plugins[0], selection.key),
|
|
2442
|
-
});
|
|
2443
|
-
return result.cancelled
|
|
2444
|
-
? { cancelled: true }
|
|
2445
|
-
: { cancelled: false, value: result.value };
|
|
2246
|
+
}
|
|
2247
|
+
const workspace = await resolveCatalogWorkspaceRoot({
|
|
2248
|
+
cwd: discoveryCwd,
|
|
2249
|
+
...(explicitRoot === undefined ? {} : { explicitRoot: path.resolve(options.cwd ?? process.cwd(), explicitRoot) }),
|
|
2250
|
+
mode: 'existing',
|
|
2446
2251
|
});
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2252
|
+
authoringEnv = {
|
|
2253
|
+
...authoringEnv,
|
|
2254
|
+
AW_AUTHORING_WORKSPACE_ROOT: workspace.workspaceRoot,
|
|
2255
|
+
AW_AUTHORING_WORKSPACE_ROOT_RESOLVED_FROM: workspace.workspaceRootResolvedFrom,
|
|
2256
|
+
};
|
|
2257
|
+
if (explicitRoot === undefined)
|
|
2258
|
+
authoringArgs.push('--workspace-root', workspace.workspaceRoot);
|
|
2259
|
+
}
|
|
2260
|
+
return runAuthoringScript({
|
|
2261
|
+
scriptName: authoringScript,
|
|
2262
|
+
args: authoringArgs,
|
|
2263
|
+
cwd: options.cwd ?? process.cwd(),
|
|
2264
|
+
env: authoringEnv,
|
|
2265
|
+
io,
|
|
2266
|
+
interruption: options.interruption,
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
throw new Error('No authoring script is registered for this operation.');
|
|
2270
|
+
}
|
|
2271
|
+
function sourceConfirmation(sourceId, yes, preview) {
|
|
2272
|
+
const required = preview !== undefined && (preview.identityChanged || !preview.references.inventoryComplete || preview.references.references.length > 0);
|
|
2273
|
+
return { required, provided: yes === true, effects: required ? [{ code: 'changeSource', message: 'Change the source used by the affected or unobserved plugin references.', subject: { sourceId }, impact: preview?.references.inventoryComplete ? 'shared' : 'unknown' }] : [] };
|
|
2274
|
+
}
|
|
2275
|
+
function commandId(command) {
|
|
2276
|
+
const names = [];
|
|
2277
|
+
for (let current = command; current?.parent; current = current.parent)
|
|
2278
|
+
names.unshift(current.name());
|
|
2279
|
+
return names.join('.');
|
|
2280
|
+
}
|
|
2281
|
+
function configurePublicCommands(program, options, io, exit) {
|
|
2282
|
+
const find = (parent, name) => {
|
|
2283
|
+
const result = parent.commands.find((entry) => entry.name() === name);
|
|
2284
|
+
if (!result)
|
|
2285
|
+
throw new Error(`Missing registered command: ${name}`);
|
|
2286
|
+
return result;
|
|
2287
|
+
};
|
|
2288
|
+
const plugin = find(program, 'plugin');
|
|
2289
|
+
const dev = find(program, 'dev');
|
|
2290
|
+
const devPlugin = find(dev, 'plugin');
|
|
2291
|
+
const catalog = find(dev, 'catalog');
|
|
2292
|
+
const source = find(program, 'source');
|
|
2293
|
+
const sourceUpdate = find(source, 'update');
|
|
2294
|
+
sourceUpdate.option('--primary', 'Make this source primary');
|
|
2295
|
+
const sourceStatus = find(source, 'status');
|
|
2296
|
+
sourceStatus.option('--remote', 'Check remote candidates without changing stored state');
|
|
2297
|
+
sourceStatus.action(async (id, raw) => {
|
|
2298
|
+
const env = options.env ?? process.env;
|
|
2299
|
+
const [observed, configured] = await Promise.all([catalogSourceStatusCommand({ sourceId: id, env }), listCatalogSources({ env })]);
|
|
2300
|
+
const result = { ...observed, primarySourceId: configured.primarySourceId, sources: observed.sources.map((source) => ({ ...source, configuration: configured.sources.find((entry) => entry.id === source.sourceId) ?? null })) };
|
|
2301
|
+
if (!raw.remote) {
|
|
2302
|
+
io.result?.(result);
|
|
2453
2303
|
return;
|
|
2454
|
-
const receipt = outcome.value;
|
|
2455
|
-
if (rawOptions.json) {
|
|
2456
|
-
writeJsonReceipt(io.stdout, receipt);
|
|
2457
2304
|
}
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
:
|
|
2462
|
-
if (receipt.projectLayer === 'local') {
|
|
2463
|
-
writeProjectLocalConfigNotice(io.stdout);
|
|
2305
|
+
const remote = await Promise.all(result.sources.map(async (source) => {
|
|
2306
|
+
try {
|
|
2307
|
+
const probe = await syncCatalogSourceCommand({ sourceId: source.sourceId, cliVersion: resolveCliVersion(), cwd: options.cwd, check: true, env });
|
|
2308
|
+
return { sourceId: source.sourceId, checked: true, candidate: probe.resolution, outcome: probe.outcome };
|
|
2464
2309
|
}
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2310
|
+
catch (error) {
|
|
2311
|
+
const safe = sanitizeCatalogSourceError(error, env);
|
|
2312
|
+
return { sourceId: source.sourceId, checked: false, error: { code: catalogGenerationErrorCode(error), message: safe.message } };
|
|
2313
|
+
}
|
|
2314
|
+
}));
|
|
2315
|
+
const failures = remote.filter((entry) => !entry.checked);
|
|
2316
|
+
const projected = projectReceipt('source.status', { ...result, remote, complete: failures.length === 0 });
|
|
2317
|
+
projected.diagnostics.push(...failures.map((entry) => ({ code: entry.error.code, severity: 'error', message: safePublicMessage(entry.error.message), subject: { sourceId: entry.sourceId } })));
|
|
2318
|
+
io.result?.(projected);
|
|
2468
2319
|
});
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
.argument('[
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
.
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2320
|
+
const context = (name, raw = {}) => createCliExecutionContext({ ...options, io, interactive: false, reporter: options.reporter ?? createNoopReporter(), diagnostics: toCliDiagnosticsOptions(name, raw, options.diagnostics) });
|
|
2321
|
+
for (const name of ['install', 'remove', 'sync']) {
|
|
2322
|
+
const cmd = plugin.command(name).argument(name === 'sync' ? '[plugins...]' : '<plugins...>');
|
|
2323
|
+
if (name !== 'sync')
|
|
2324
|
+
cmd.addOption(strictValueOption('--scope <scope>', 'Requirement or physical scope', ['user', 'project']).makeOptionMandatory());
|
|
2325
|
+
cmd.addOption(strictValueOption('--context <context>', 'User or current project context', ['user', 'project']))
|
|
2326
|
+
.option('--target <target>', 'Select an execution target', collectUniqueOption)
|
|
2327
|
+
.option('-y, --yes', 'Confirm the listed effects');
|
|
2328
|
+
if (name !== 'sync')
|
|
2329
|
+
cmd.addOption(strictValueOption('--only <mode>', 'Limit the effects', name === 'install' ? ['requirements'] : ['requirements', 'outputs']));
|
|
2330
|
+
if (name === 'remove')
|
|
2331
|
+
cmd.description('Remove requirements and owned output, including orphan dependencies')
|
|
2332
|
+
.option('--delete-config', 'Delete all local plugin configuration')
|
|
2333
|
+
.option('--keep-dependencies', 'Keep orphan dependency output during normal removal')
|
|
2334
|
+
.option('--force', 'Bypass the dependency guard; with --only outputs, recover provably owned damaged output');
|
|
2335
|
+
if (name !== 'remove')
|
|
2336
|
+
cmd.option('--script-timeout <ms>', 'Plugin script timeout')
|
|
2337
|
+
.option('--native-consent', 'Authorize this Gemini operation; may persist source-folder and current-workspace trust');
|
|
2338
|
+
if (name === 'sync')
|
|
2339
|
+
cmd.option('--rebuild', 'Rebuild selected owned output').option('--refresh', 'Refresh required Catalog sources');
|
|
2340
|
+
cmd.action(async (plugins, raw) => {
|
|
2341
|
+
io.result?.(await runPublicLifecycle(name, plugins, { ...raw, cwd: options.cwd ?? process.cwd(), env: options.env, cliVersion: resolveCliVersion() }, context(`plugin.${name}`, raw)));
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
plugin.command('list').description('List available plugins or direct requirements')
|
|
2345
|
+
.option('--requested', 'List direct requirement roots')
|
|
2346
|
+
.addOption(strictValueOption('--scope <scope>', 'Requirement scope', ['user', 'project']))
|
|
2347
|
+
.action(async (raw) => { io.result?.(await runPublicPluginList({ ...raw, cwd: options.cwd ?? process.cwd(), env: options.env, cliVersion: resolveCliVersion() }, context('plugin.list', raw))); });
|
|
2348
|
+
plugin.command('show').description('Show one plugin').argument('<plugin>')
|
|
2349
|
+
.action(async (selector) => { io.result?.(await runPublicPluginShow(selector, { cwd: options.cwd ?? process.cwd(), env: options.env, cliVersion: resolveCliVersion() }, context('plugin.show'))); });
|
|
2350
|
+
plugin.command('status').description('Inspect requirements, outputs, and coverage').argument('[plugins...]')
|
|
2351
|
+
.addOption(strictValueOption('--context <context>', 'Observation context', ['user', 'project']))
|
|
2352
|
+
.option('--observe-native', 'Start OpenCode when selected to observe plugin loading')
|
|
2353
|
+
.action(async (plugins, raw) => { io.result?.(await runPublicPluginStatus(plugins, { ...raw, cwd: options.cwd ?? process.cwd(), env: options.env, cliVersion: resolveCliVersion() }, context('plugin.status', raw))); });
|
|
2354
|
+
devPlugin.command('remove').description('Delete one owned plugin source tree').argument('<plugin>')
|
|
2355
|
+
.option('--workspace-root <path>', 'Catalog Workspace root').option('-y, --yes', 'Confirm source deletion');
|
|
2356
|
+
devPlugin.command('status').description('Check source plugin version policy').argument('[plugin]')
|
|
2357
|
+
.option('--all', 'Check all source plugins').option('--base <ref>', 'Git comparison base').option('--workspace-root <path>', 'Catalog Workspace root');
|
|
2358
|
+
find(devPlugin, 'build').option('-y, --yes', 'Confirm replacement of generated output');
|
|
2359
|
+
find(catalog, 'build').option('-y, --yes', 'Confirm replacement of generated output');
|
|
2360
|
+
const scriptRoutes = {
|
|
2361
|
+
'dev.plugin.create': ['plugin', 'init'], 'dev.plugin.validate': ['plugin', 'validate'],
|
|
2362
|
+
'dev.plugin.remove': ['plugin', 'remove'], 'dev.plugin.status': ['plugin', 'status'],
|
|
2363
|
+
'dev.skill.create': ['plugin', 'add-skill'], 'dev.skill.validate': ['skill', 'validate'],
|
|
2364
|
+
};
|
|
2365
|
+
const attach = (parent) => {
|
|
2366
|
+
for (const cmd of parent.commands) {
|
|
2367
|
+
const id = commandId(cmd);
|
|
2368
|
+
if (scriptRoutes[id])
|
|
2369
|
+
cmd.action(async (...args) => {
|
|
2370
|
+
const selected = args.at(-1);
|
|
2371
|
+
const raw = selected.opts();
|
|
2372
|
+
const tokens = [...scriptRoutes[id], ...(id === 'dev.skill.create' ? [String(raw.plugin)] : selected.args)];
|
|
2373
|
+
for (const option of selected.options) {
|
|
2374
|
+
const value = selected.getOptionValue(option.attributeName());
|
|
2375
|
+
if (['json', 'plugin', 'verbose', 'debug', 'logFile'].includes(option.attributeName()) || value === undefined || value === false && !option.negate || value === true && option.negate)
|
|
2376
|
+
continue;
|
|
2377
|
+
tokens.push(option.long);
|
|
2378
|
+
if (value !== true && !option.negate)
|
|
2379
|
+
tokens.push(String(value));
|
|
2487
2380
|
}
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
...context,
|
|
2506
|
-
awHomeMutationToken,
|
|
2507
|
-
catalogOperationContext,
|
|
2508
|
-
expectedGenerationSetDigest: catalogOperationContext.generationSetDigest,
|
|
2509
|
-
},
|
|
2510
|
-
awHomeMutationToken,
|
|
2511
|
-
plugin,
|
|
2512
|
-
});
|
|
2513
|
-
return {
|
|
2514
|
-
ok: resetReceipt.overallState === 'succeeded',
|
|
2515
|
-
receiptSchemaVersion: 4,
|
|
2516
|
-
command: 'config:reset',
|
|
2517
|
-
...resetReceipt,
|
|
2518
|
-
plugin: plugin.manifest.name,
|
|
2519
|
-
pluginName: plugin.manifest.name,
|
|
2520
|
-
pluginId,
|
|
2521
|
-
sourceId: source.sourceId,
|
|
2522
|
-
sourceIdentity: source.sourceIdentity,
|
|
2523
|
-
affectedFields,
|
|
2524
|
-
};
|
|
2525
|
-
}).catch((error) => {
|
|
2526
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
2527
|
-
if (message.includes('Catalog source')
|
|
2528
|
-
|| message.startsWith('Cannot resolve required catalog sources:')) {
|
|
2529
|
-
throw new Error(`sourceMissing: ${selectedPlugin} source is unavailable; config store was not changed.`);
|
|
2381
|
+
const hasProtocol = !['dev.plugin.create', 'dev.skill.create'].includes(id);
|
|
2382
|
+
if (hasProtocol)
|
|
2383
|
+
tokens.push('--json');
|
|
2384
|
+
if (['dev.plugin.remove', 'dev.plugin.status'].includes(id) && !raw.workspaceRoot) {
|
|
2385
|
+
const workspace = await resolveCatalogWorkspaceRoot({ cwd: options.cwd ?? process.cwd(), mode: 'existing', env: options.env });
|
|
2386
|
+
tokens.push('--workspace-root', workspace.workspaceRoot);
|
|
2387
|
+
}
|
|
2388
|
+
let protocol = '';
|
|
2389
|
+
let scriptDiagnostics = '';
|
|
2390
|
+
exit.exitCode = await runAuthoringCliAdapter(tokens, { ...options, interactive: false, io: { stdout: (text) => { if (hasProtocol)
|
|
2391
|
+
protocol += text;
|
|
2392
|
+
else
|
|
2393
|
+
io.stderr(text); }, stderr: (text) => { scriptDiagnostics += text; io.stderr(text); } } });
|
|
2394
|
+
if (hasProtocol && protocol.trim()) {
|
|
2395
|
+
let value;
|
|
2396
|
+
try {
|
|
2397
|
+
value = JSON.parse(protocol);
|
|
2530
2398
|
}
|
|
2531
|
-
|
|
2532
|
-
throw new Error(
|
|
2399
|
+
catch {
|
|
2400
|
+
throw new Error('The authoring tool returned invalid structured output.');
|
|
2533
2401
|
}
|
|
2534
|
-
|
|
2535
|
-
}
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
const projectLayer = resolveConfigProjectLayer(rawOptions);
|
|
2539
|
-
const needsWizard = pluginName === undefined || rawOptions.yes !== true;
|
|
2540
|
-
if (!needsWizard) {
|
|
2541
|
-
return {
|
|
2542
|
-
cancelled: false,
|
|
2543
|
-
value: await execute(pluginName, scope, projectLayer, true),
|
|
2544
|
-
};
|
|
2545
|
-
}
|
|
2546
|
-
if (!isWizardAvailable(context, rawOptions)) {
|
|
2547
|
-
if (!pluginName)
|
|
2548
|
-
throw new Error(configCommandUsage('reset'));
|
|
2549
|
-
return {
|
|
2550
|
-
cancelled: false,
|
|
2551
|
-
value: await execute(pluginName, scope, projectLayer, false),
|
|
2552
|
-
};
|
|
2553
|
-
}
|
|
2554
|
-
const currentCandidates = pluginName ? [] : await loadWizardCandidates(context, {});
|
|
2555
|
-
const candidatesByScope = new Map();
|
|
2556
|
-
if (!pluginName && (rawOptions.scope === undefined || scope === 'user')) {
|
|
2557
|
-
candidatesByScope.set('user', mergeWizardCandidates(currentCandidates, await loadStoredConfigWizardCandidates(context, [{ scope: 'user', projectLayer: 'shared' }], { includeEmptyStores: true })));
|
|
2558
|
-
}
|
|
2559
|
-
if (!pluginName && (rawOptions.scope === undefined || scope === 'project')) {
|
|
2560
|
-
candidatesByScope.set('project', mergeWizardCandidates(currentCandidates, await loadStoredConfigWizardCandidates(context, [{ scope: 'project', projectLayer }], { includeEmptyStores: true })));
|
|
2561
|
-
}
|
|
2562
|
-
const candidates = mergeWizardCandidates(candidatesByScope.get('user') ?? [], candidatesByScope.get('project') ?? []);
|
|
2563
|
-
if (!pluginName && candidates.length === 0) {
|
|
2564
|
-
throw new Error('No plugin config candidates exist in the selected location.');
|
|
2565
|
-
}
|
|
2566
|
-
const result = await runCommandWizard(context, {
|
|
2567
|
-
command: 'config:reset',
|
|
2568
|
-
candidates,
|
|
2569
|
-
initial: { plugins: pluginName ? [pluginName] : [], scope, projectLayer },
|
|
2570
|
-
pluginMode: pluginName ? 'none' : 'single',
|
|
2571
|
-
promptForScope: rawOptions.scope === undefined,
|
|
2572
|
-
destructive: true,
|
|
2573
|
-
isPluginVisible: (candidate, selection) => candidatesByScope
|
|
2574
|
-
.get(selection.scope ?? 'user')
|
|
2575
|
-
?.some((entry) => entry.pluginName === candidate.pluginName) !== false,
|
|
2576
|
-
...equivalentConfigCommandProjection((selection) => ({
|
|
2577
|
-
command: 'reset',
|
|
2578
|
-
plugin: selection.plugins[0],
|
|
2579
|
-
scope: selection.scope ?? 'user',
|
|
2580
|
-
projectLayer: selection.projectLayer,
|
|
2581
|
-
confirmed: true,
|
|
2582
|
-
})),
|
|
2583
|
-
resultState: overallResultState,
|
|
2584
|
-
execute: (selection) => execute(selection.plugins[0], selection.scope ?? 'user', selection.projectLayer ?? 'shared', true),
|
|
2402
|
+
io.result?.(value);
|
|
2403
|
+
}
|
|
2404
|
+
else
|
|
2405
|
+
io.result?.({ ok: exit.exitCode === 0, pluginName: raw.plugin ?? selected.args[0], workspaceRoot: raw.workspaceRoot ?? options.cwd, ...(exit.exitCode ? { errors: [{ code: 'authoringFailed', message: scriptDiagnostics.trim() || 'The authoring tool did not complete.' }] } : {}) });
|
|
2585
2406
|
});
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2407
|
+
if (!cmd.options.some((option) => option.long === '--json'))
|
|
2408
|
+
cmd.option('-j, --json', 'Output one JSON result');
|
|
2409
|
+
const json = cmd.options.find((option) => option.long === '--json');
|
|
2410
|
+
json.makeOptionMandatory(false);
|
|
2411
|
+
if (!json.short)
|
|
2412
|
+
json.short = '-j';
|
|
2413
|
+
if (!cmd.options.some((option) => option.long === '--verbose'))
|
|
2414
|
+
cmd.option('-v, --verbose', 'Show additional details');
|
|
2415
|
+
if (!cmd.options.some((option) => option.long === '--debug'))
|
|
2416
|
+
cmd.option('-D, --debug', 'Write diagnostic logs');
|
|
2417
|
+
if (!cmd.options.some((option) => option.long === '--log-file'))
|
|
2418
|
+
cmd.option('--log-file <path>', 'Diagnostic log path');
|
|
2419
|
+
attach(cmd);
|
|
2590
2420
|
}
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2421
|
+
};
|
|
2422
|
+
program.option('-j, --json', 'Output one JSON result').option('-v, --verbose', 'Show additional details').option('-D, --debug', 'Write diagnostic logs').option('--log-file <path>', 'Diagnostic log path');
|
|
2423
|
+
program.command('tui').description('Open the interactive console').action(() => undefined);
|
|
2424
|
+
attach(program);
|
|
2425
|
+
program.hook('preAction', (_root, action) => { action.setOptionValue('json', true); });
|
|
2426
|
+
}
|
|
2427
|
+
function resolveRegisteredCommand(program, argv) {
|
|
2428
|
+
let current = program;
|
|
2429
|
+
let commandIndex = -1;
|
|
2430
|
+
for (let index = 0; index < argv.length; index++) {
|
|
2431
|
+
const token = argv[index];
|
|
2432
|
+
if (token === '--')
|
|
2433
|
+
break;
|
|
2434
|
+
if (token.startsWith('-')) {
|
|
2435
|
+
const option = [...current.options, ...program.options].find((candidate) => candidate.long === token.split('=')[0] || candidate.short === token);
|
|
2436
|
+
if (option?.required && !token.includes('='))
|
|
2437
|
+
index++;
|
|
2438
|
+
continue;
|
|
2600
2439
|
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
if (receipt.projectLayer === 'local') {
|
|
2606
|
-
writeProjectLocalConfigNotice(io.stdout);
|
|
2607
|
-
}
|
|
2608
|
-
writeConfigApplyNotice(io.stderr, receipt);
|
|
2440
|
+
const child = current.commands.find((entry) => entry.name() === token);
|
|
2441
|
+
if (child) {
|
|
2442
|
+
current = child;
|
|
2443
|
+
commandIndex = index;
|
|
2609
2444
|
}
|
|
2610
|
-
|
|
2445
|
+
else if (current.commands.length === 0 || current.registeredArguments.length > 0)
|
|
2446
|
+
break;
|
|
2447
|
+
else
|
|
2448
|
+
return { command: null, index: commandIndex };
|
|
2449
|
+
}
|
|
2450
|
+
return { command: current, index: commandIndex };
|
|
2451
|
+
}
|
|
2452
|
+
function helpResult(program, selected) {
|
|
2453
|
+
return commandResult('help', {
|
|
2454
|
+
command: commandId(selected) || 'aw', description: selected.description(),
|
|
2455
|
+
arguments: selected.registeredArguments.map((argument) => ({ name: argument.name(), required: argument.required, variadic: argument.variadic, description: argument.description })),
|
|
2456
|
+
options: [...selected.options, ...(selected === program ? [] : program.options)].map((option) => ({ flags: option.flags, description: option.description, required: option.mandatory, choices: option.argChoices ?? null, conflicts: [] })),
|
|
2457
|
+
commands: selected.commands.map((command) => ({ command: commandId(command), description: command.description() })),
|
|
2458
|
+
resultSchema: { schemaVersion: CLI_OUTPUT_SCHEMA_VERSION, statuses: ['success', 'partial', 'blocked', 'failed'] },
|
|
2459
|
+
rules: commandId(selected) === 'plugin.install' ? ['--scope is required.', '--only requirements cannot use --target or --script-timeout.'] : commandId(selected) === 'plugin.remove' ? ['--scope is required.', '--only outputs requires --target.', '--force cannot use --only requirements.', '--keep-dependencies cannot use --only.', '--delete-config cannot use --only.'] : [],
|
|
2460
|
+
effects: selected.options.some((option) => option.long === '--yes') ? ['Important effects require --yes.'] : [],
|
|
2461
|
+
examples: [selected === program ? ['aw', 'plugin', 'list'] : ['aw', ...commandId(selected).split('.'), '--help']],
|
|
2611
2462
|
});
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
.
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2463
|
+
}
|
|
2464
|
+
function scanPresentation(program, argv) {
|
|
2465
|
+
const result = { json: false, help: false, version: false };
|
|
2466
|
+
let command = program;
|
|
2467
|
+
for (let index = 0; index < argv.length; index++) {
|
|
2468
|
+
const token = argv[index];
|
|
2469
|
+
if (token === '--')
|
|
2470
|
+
break;
|
|
2471
|
+
if (!token.startsWith('-')) {
|
|
2472
|
+
command = command.commands.find((entry) => entry.name() === token) ?? command;
|
|
2473
|
+
continue;
|
|
2474
|
+
}
|
|
2475
|
+
const available = [...command.options, ...program.options];
|
|
2476
|
+
if (token.startsWith('--')) {
|
|
2477
|
+
const flag = token.split('=')[0];
|
|
2478
|
+
const option = available.find((entry) => entry.long === flag);
|
|
2479
|
+
if (flag === '--json')
|
|
2480
|
+
result.json = true;
|
|
2481
|
+
if (flag === '--help')
|
|
2482
|
+
result.help = true;
|
|
2483
|
+
if (flag === '--version' && !option?.required)
|
|
2484
|
+
result.version = true;
|
|
2485
|
+
if (option?.required && !token.includes('='))
|
|
2486
|
+
index++;
|
|
2487
|
+
}
|
|
2488
|
+
else {
|
|
2489
|
+
for (let offset = 1; offset < token.length; offset++) {
|
|
2490
|
+
const flag = `-${token[offset]}`;
|
|
2491
|
+
const option = available.find((entry) => entry.short === flag);
|
|
2492
|
+
if (flag === '-j')
|
|
2493
|
+
result.json = true;
|
|
2494
|
+
if (flag === '-h')
|
|
2495
|
+
result.help = true;
|
|
2496
|
+
if (flag === '-V')
|
|
2497
|
+
result.version = true;
|
|
2498
|
+
if (option?.required) {
|
|
2499
|
+
if (offset === token.length - 1)
|
|
2500
|
+
index++;
|
|
2501
|
+
break;
|
|
2502
|
+
}
|
|
2642
2503
|
}
|
|
2643
2504
|
}
|
|
2644
|
-
});
|
|
2645
|
-
Object.assign(program, { __awCommandExitState: commandExitState });
|
|
2646
|
-
return program;
|
|
2647
|
-
}
|
|
2648
|
-
function handleCliError(error, writeError) {
|
|
2649
|
-
if (error instanceof CommanderError) {
|
|
2650
|
-
return error.exitCode;
|
|
2651
|
-
}
|
|
2652
|
-
if (isCommandWarningError(error)) {
|
|
2653
|
-
writeWarnings(writeError, error.warnings);
|
|
2654
|
-
writeLine(writeError, error.message);
|
|
2655
|
-
return error.exitCode;
|
|
2656
2505
|
}
|
|
2657
|
-
|
|
2658
|
-
return 1;
|
|
2506
|
+
return result;
|
|
2659
2507
|
}
|
|
2660
2508
|
export async function runCli(argv, options = {}) {
|
|
2661
|
-
const
|
|
2662
|
-
|
|
2663
|
-
|
|
2509
|
+
const interruption = createPublicCommandInterruption();
|
|
2510
|
+
const io = { ...createDefaultIo(), ...options.io };
|
|
2511
|
+
if (argv[0] === 'internal' && argv[1] === 'cursor-workspace-open') {
|
|
2512
|
+
return runCursorWorkspaceHookCli(argv.slice(2), { cwd: options.cwd ?? process.cwd(), env: options.env,
|
|
2513
|
+
stdin: options.stdin ?? process.stdin, stdout: io.stdout, stderr: io.stderr });
|
|
2514
|
+
}
|
|
2515
|
+
const delimiter = argv.indexOf('--');
|
|
2516
|
+
const awArgs = delimiter < 0 ? argv : argv.slice(0, delimiter);
|
|
2517
|
+
const context = createCliExecutionContext({ ...options, io });
|
|
2518
|
+
let receipt;
|
|
2519
|
+
const stderr = [];
|
|
2520
|
+
const commandOptions = { ...options, interactive: false, io: {
|
|
2521
|
+
stdout: (text) => { stderr.push(text); }, stderr: (text) => { stderr.push(text); }, result: (value) => { receipt = value; },
|
|
2522
|
+
} };
|
|
2523
|
+
const program = buildProgram(commandOptions);
|
|
2524
|
+
const presentation = scanPresentation(program, awArgs);
|
|
2525
|
+
const json = presentation.json;
|
|
2526
|
+
const resolvedCommand = resolveRegisteredCommand(program, awArgs);
|
|
2527
|
+
const selected = resolvedCommand.command;
|
|
2528
|
+
const id = selected && selected !== program ? commandId(selected) : null;
|
|
2529
|
+
const controlledInterrupt = ['plugin.install', 'plugin.remove', 'plugin.sync',
|
|
2530
|
+
'dev.plugin.create', 'dev.plugin.validate', 'dev.plugin.remove', 'dev.plugin.status',
|
|
2531
|
+
'dev.skill.create', 'dev.skill.validate'].includes(id ?? '');
|
|
2532
|
+
if (controlledInterrupt) {
|
|
2533
|
+
commandOptions.interruption = interruption;
|
|
2534
|
+
commandOptions.signal = interruption.signal;
|
|
2535
|
+
}
|
|
2536
|
+
if (id === 'command.run' && !presentation.help)
|
|
2537
|
+
return runManagedCommandCli(['run', ...argv.slice(resolvedCommand.index + 1)], { ...context, interactive: false }, { cliEntry: fileURLToPath(import.meta.url), cliVersion: resolveCliVersion() });
|
|
2538
|
+
let confirmation = null;
|
|
2539
|
+
const emit = (result, invalid = false) => {
|
|
2540
|
+
if (result.diagnostics.some((diagnostic) => diagnostic.code === 'catalogWorkspaceMissing')) {
|
|
2541
|
+
const workspaceRoot = selected?.getOptionValue('workspaceRoot');
|
|
2542
|
+
result.nextActions = result.nextActions.filter((action) => action.kind !== 'command'
|
|
2543
|
+
|| action.argv.slice(0, 4).join(' ') !== 'aw dev catalog create');
|
|
2544
|
+
result.nextActions.push({ kind: 'command',
|
|
2545
|
+
argv: ['aw', 'dev', 'catalog', 'create', ...(typeof workspaceRoot === 'string' ? ['--workspace-root', workspaceRoot] : [])],
|
|
2546
|
+
reason: 'Create a Catalog Workspace explicitly before running authoring commands.', requiresConfirmation: false });
|
|
2547
|
+
}
|
|
2548
|
+
io.stdout(json ? `${JSON.stringify(result)}\n` : renderPublicResult(result, awArgs.includes('--verbose') || awArgs.includes('-v')));
|
|
2549
|
+
for (const diagnostic of result.diagnostics)
|
|
2550
|
+
io.stderr(`${diagnostic.code}: ${diagnostic.message}\n`);
|
|
2551
|
+
if (options.diagnostics?.verbose || awArgs.includes('--verbose'))
|
|
2552
|
+
for (const line of stderr)
|
|
2553
|
+
io.stderr(`${safePublicMessage(line.trim())}\n`);
|
|
2554
|
+
return interruption.exitCode ? interruption.cleanupFailed ? 1 : interruption.exitCode : publicExitCode(result, invalid);
|
|
2664
2555
|
};
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2556
|
+
if (presentation.version)
|
|
2557
|
+
return emit(commandResult('version', { version: resolveCliVersion(), resultSchemaVersion: CLI_OUTPUT_SCHEMA_VERSION }));
|
|
2558
|
+
if (selected && presentation.help || argv.length === 0 && !context.interactive || selected === program && json) {
|
|
2559
|
+
const target = selected ?? program;
|
|
2560
|
+
if (!json) {
|
|
2561
|
+
target.configureOutput({ writeOut: io.stdout });
|
|
2562
|
+
target.outputHelp();
|
|
2563
|
+
return 0;
|
|
2564
|
+
}
|
|
2565
|
+
return emit(helpResult(program, target));
|
|
2566
|
+
}
|
|
2567
|
+
let bareOptions;
|
|
2676
2568
|
try {
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
: argv[0] === 'skill' && argv[1] === 'validate'
|
|
2687
|
-
? 'validate-skill.mjs'
|
|
2688
|
-
: undefined;
|
|
2689
|
-
if (authoringScript && !argv.includes('--help') && !argv.includes('-h')) {
|
|
2690
|
-
const authoringArgs = argv.slice(2);
|
|
2691
|
-
let authoringEnv = options.env ?? process.env;
|
|
2692
|
-
if (argv[0] === 'plugin'
|
|
2693
|
-
&& !authoringArgs.some((token) => token === '--plugin-root' || token.startsWith('--plugin-root='))) {
|
|
2694
|
-
let explicitRoot;
|
|
2695
|
-
for (let index = 0; index < authoringArgs.length; index += 1) {
|
|
2696
|
-
const token = authoringArgs[index];
|
|
2697
|
-
if (token.startsWith('--workspace-root='))
|
|
2698
|
-
explicitRoot = token.slice('--workspace-root='.length);
|
|
2699
|
-
if (token === '--workspace-root')
|
|
2700
|
-
explicitRoot = authoringArgs[index + 1];
|
|
2701
|
-
}
|
|
2702
|
-
const originalCwd = options.cwd ?? process.cwd();
|
|
2703
|
-
let discoveryCwd = originalCwd;
|
|
2704
|
-
if (argv[1] === 'validate') {
|
|
2705
|
-
const valueOptions = new Set(['--workspace-root', '--claude-skill-profile', '--version-base']);
|
|
2706
|
-
for (let index = 0; index < authoringArgs.length; index += 1) {
|
|
2707
|
-
const token = authoringArgs[index];
|
|
2708
|
-
if (valueOptions.has(token)) {
|
|
2709
|
-
index += 1;
|
|
2710
|
-
continue;
|
|
2711
|
-
}
|
|
2712
|
-
if (!token.startsWith('-')) {
|
|
2713
|
-
discoveryCwd = path.resolve(originalCwd, token);
|
|
2714
|
-
authoringArgs[index] = discoveryCwd;
|
|
2715
|
-
break;
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
}
|
|
2719
|
-
const workspace = await resolveCatalogWorkspaceRoot({
|
|
2720
|
-
cwd: discoveryCwd,
|
|
2721
|
-
...(explicitRoot === undefined ? {} : { explicitRoot: path.resolve(options.cwd ?? process.cwd(), explicitRoot) }),
|
|
2722
|
-
mode: 'existing',
|
|
2723
|
-
});
|
|
2724
|
-
authoringEnv = {
|
|
2725
|
-
...authoringEnv,
|
|
2726
|
-
AW_AUTHORING_WORKSPACE_ROOT: workspace.workspaceRoot,
|
|
2727
|
-
AW_AUTHORING_WORKSPACE_ROOT_RESOLVED_FROM: workspace.workspaceRootResolvedFrom,
|
|
2728
|
-
};
|
|
2729
|
-
if (explicitRoot === undefined)
|
|
2730
|
-
authoringArgs.push('--workspace-root', workspace.workspaceRoot);
|
|
2569
|
+
bareOptions = parseBareConsoleOptions(argv);
|
|
2570
|
+
}
|
|
2571
|
+
catch {
|
|
2572
|
+
return emit(commandResult(null, {}, { status: 'failed', diagnostics: [{ code: 'invalidArguments', severity: 'error', message: 'A diagnostic option requires a value.' }] }), true);
|
|
2573
|
+
}
|
|
2574
|
+
if (bareOptions !== null || id === 'tui') {
|
|
2575
|
+
if (id === 'tui') {
|
|
2576
|
+
try {
|
|
2577
|
+
await program.parseAsync(['node', 'aw', ...argv]);
|
|
2731
2578
|
}
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
args: authoringArgs,
|
|
2735
|
-
cwd: options.cwd ?? process.cwd(),
|
|
2736
|
-
env: authoringEnv,
|
|
2737
|
-
io,
|
|
2738
|
-
});
|
|
2739
|
-
}
|
|
2740
|
-
if (argv.some((token) => token === '--subdir' || token.startsWith('--subdir='))
|
|
2741
|
-
&& argv.includes('--no-subdir')) {
|
|
2742
|
-
const message = 'option --subdir cannot be used with option --no-subdir';
|
|
2743
|
-
if (argv.includes('--json') && argv[0] === 'catalog' && argv[1] === 'source' && argv[2] === 'update') {
|
|
2744
|
-
writeJsonReceipt(io.stdout, {
|
|
2745
|
-
receiptSchemaVersion: 4,
|
|
2746
|
-
command: 'catalog:source:update',
|
|
2747
|
-
ok: false,
|
|
2748
|
-
changed: false,
|
|
2749
|
-
sourceId: argv[3] ?? '',
|
|
2750
|
-
references: [],
|
|
2751
|
-
errors: [{ code: 'catalogSourceOptionConflict', message }],
|
|
2752
|
-
});
|
|
2579
|
+
catch {
|
|
2580
|
+
return emit(commandResult('tui', {}, { status: 'failed', diagnostics: [{ code: 'invalidArguments', severity: 'error', message: 'Invalid TUI arguments.' }] }), true);
|
|
2753
2581
|
}
|
|
2754
|
-
writeLine(io.stderr, `error: ${message}`);
|
|
2755
|
-
return 1;
|
|
2756
2582
|
}
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
...options.diagnostics?.metadata,
|
|
2767
|
-
argCount: argv.length,
|
|
2768
|
-
},
|
|
2769
|
-
},
|
|
2583
|
+
if (json)
|
|
2584
|
+
return emit(commandResult('tui', {}, { status: 'failed', diagnostics: [{ code: 'invalidOptionCombination', severity: 'error', message: 'tui cannot use --json.' }] }), true);
|
|
2585
|
+
if (!context.interactive)
|
|
2586
|
+
return emit(commandResult('tui', {}, { status: 'blocked', diagnostics: [{ code: 'interactiveTerminalRequired', severity: 'error', message: 'The TUI requires an interactive terminal.' }] }));
|
|
2587
|
+
const tuiContext = createCliExecutionContext({ ...options, io, diagnostics: toCliDiagnosticsOptions('console', bareOptions ?? {}, options.diagnostics) });
|
|
2588
|
+
try {
|
|
2589
|
+
return await runActionWithContext(tuiContext, async () => {
|
|
2590
|
+
const { runConsoleController } = await import('./commands/console.js');
|
|
2591
|
+
return runConsoleController(tuiContext);
|
|
2770
2592
|
});
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2593
|
+
}
|
|
2594
|
+
catch (error) {
|
|
2595
|
+
return emit(commandResult('tui', {}, { status: 'failed', diagnostics: [{ code: 'tuiFailed', severity: 'error', message: safePublicMessage(error instanceof Error ? error.message : String(error)) }] }));
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
// Only these adapters carry cancellation through every long-running child.
|
|
2599
|
+
// Other routes retain Node's normal signal termination until their domain
|
|
2600
|
+
// runner provides the same cleanup contract. Managed run and TUI exited above.
|
|
2601
|
+
const stopListening = controlledInterrupt ? interruption.listen() : () => undefined;
|
|
2602
|
+
try {
|
|
2603
|
+
program.hook('preAction', (_root, command) => {
|
|
2604
|
+
interruption.signal.throwIfAborted();
|
|
2605
|
+
const raw = command.opts();
|
|
2606
|
+
const current = commandId(command);
|
|
2607
|
+
if (current === 'dev.eval.prepare')
|
|
2608
|
+
for (const field of ['runs', 'timeoutMs'])
|
|
2609
|
+
if (raw[field] !== undefined && (!/^[1-9][0-9]*$/u.test(raw[field]) || !Number.isSafeInteger(Number(raw[field]))))
|
|
2610
|
+
throw new WriteCommandRequestError(`${field} must be a positive safe integer.`);
|
|
2611
|
+
if (current === 'dev.plugin.capabilities' && raw.surface !== undefined)
|
|
2612
|
+
normalizeWriteRequest(() => parsePluginCapabilitySurface(raw.surface));
|
|
2613
|
+
if (current === 'dev.catalog.version') {
|
|
2614
|
+
const version = command.args[0];
|
|
2615
|
+
if (version && raw.bump)
|
|
2616
|
+
throw new WriteCommandRequestError('Choose an exact version or --bump, not both.');
|
|
2617
|
+
if (raw.bump && !['patch', 'minor', 'major'].includes(raw.bump))
|
|
2618
|
+
throw new WriteCommandRequestError('--bump must be patch, minor, or major.');
|
|
2619
|
+
if (version && !/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-beta\.(0|[1-9][0-9]*))?$/u.test(version))
|
|
2620
|
+
throw new WriteCommandRequestError('Use a stable version or x.y.z-beta.N.');
|
|
2621
|
+
}
|
|
2622
|
+
if (current === 'source.add' && ((raw.git === undefined) === (raw.path === undefined)))
|
|
2623
|
+
throw new WriteCommandRequestError('Choose exactly one of --git or --path.');
|
|
2624
|
+
if (current === 'source.update' && awArgs.includes('--auto-check') && awArgs.includes('--no-auto-check'))
|
|
2625
|
+
throw new WriteCommandRequestError('--auto-check cannot use --no-auto-check.');
|
|
2626
|
+
if (current === 'source.update' && raw.subdir !== undefined && awArgs.includes('--no-subdir') && awArgs.some((arg) => arg === '--subdir' || arg.startsWith('--subdir=')))
|
|
2627
|
+
throw new WriteCommandRequestError('--subdir cannot use --no-subdir.');
|
|
2628
|
+
if (current === 'plugin.config.set' && [raw.valueJson !== undefined, raw.valueStdin === true, raw.preset !== undefined].filter(Boolean).length !== 1)
|
|
2629
|
+
throw new WriteCommandRequestError('Choose exactly one of --value-json, --value-stdin, or --preset.');
|
|
2630
|
+
let effect;
|
|
2631
|
+
if (current === 'plugin.config.reset')
|
|
2632
|
+
effect = { code: 'deletePluginConfig', message: 'Delete the selected local plugin configuration.', subject: { pluginId: command.args[0], scope: 'user' }, impact: 'user-wide' };
|
|
2633
|
+
if (current === 'dev.plugin.remove')
|
|
2634
|
+
effect = { code: 'deletePluginSource', message: 'Delete the selected plugin source tree.', subject: { pluginId: command.args[0] }, impact: 'selected-scope' };
|
|
2635
|
+
if (current === 'dev.catalog.publish.apply' && !/^sha256:[0-9a-f]{64}$/u.test(raw.expectedPlanDigest ?? ''))
|
|
2636
|
+
throw new WriteCommandRequestError('Use the exact --expected-plan-digest returned by dev catalog publish plan.');
|
|
2637
|
+
if (current === 'dev.catalog.publish.apply')
|
|
2638
|
+
effect = { code: 'publishRemote', message: 'Publish the prepared Catalog to the remote.', impact: 'shared' };
|
|
2639
|
+
if ((current === 'dev.catalog.build' || current === 'dev.plugin.build') && raw.force)
|
|
2640
|
+
effect = { code: 'removeOwnedOutput', message: 'Replace existing generated output.', impact: 'selected-scope' };
|
|
2641
|
+
if (effect) {
|
|
2642
|
+
confirmation = { required: true, provided: raw.yes === true, effects: [effect] };
|
|
2643
|
+
if (!raw.yes)
|
|
2644
|
+
throw Object.assign(new Error('Repeat the command with --yes to confirm the listed effects.'), { code: 'confirmationRequired' });
|
|
2774
2645
|
}
|
|
2775
|
-
return await runActionWithContext(context, () => runConsoleController(context));
|
|
2776
|
-
}
|
|
2777
|
-
const program = buildProgram({
|
|
2778
|
-
...options,
|
|
2779
|
-
io: jsonCatalogDevCommand ? { ...io, stderr: () => undefined } : io,
|
|
2780
|
-
diagnostics: {
|
|
2781
|
-
...options.diagnostics,
|
|
2782
|
-
metadata: {
|
|
2783
|
-
...options.diagnostics?.metadata,
|
|
2784
|
-
argCount: argv.length,
|
|
2785
|
-
},
|
|
2786
|
-
},
|
|
2787
2646
|
});
|
|
2788
2647
|
await program.parseAsync(['node', 'aw', ...argv]);
|
|
2789
|
-
|
|
2648
|
+
const exitCode = program.__awCommandExitState.exitCode;
|
|
2649
|
+
if (receipt === undefined) {
|
|
2650
|
+
if (selected?.commands.length)
|
|
2651
|
+
return emit(helpResult(program, selected));
|
|
2652
|
+
throw new Error('The command did not return a result.');
|
|
2653
|
+
}
|
|
2654
|
+
if (id === 'dev.plugin.test' && receipt && typeof receipt === 'object') {
|
|
2655
|
+
const logs = receipt;
|
|
2656
|
+
if (typeof logs.stdout === 'string')
|
|
2657
|
+
io.stderr(redactString(logs.stdout));
|
|
2658
|
+
if (typeof logs.stderr === 'string')
|
|
2659
|
+
io.stderr(redactString(logs.stderr));
|
|
2660
|
+
}
|
|
2661
|
+
const result = projectReceipt(id, receipt, { yes: awArgs.includes('--yes') || awArgs.includes('-y'), exitCode, confirmation });
|
|
2662
|
+
if (interruption.exitCode)
|
|
2663
|
+
result.diagnostics.push({ code: interruption.cleanupFailed ? 'processCleanupUnconfirmed' : 'operationInterrupted', severity: 'error', message: interruption.cleanupFailed ? 'Process cleanup could not be confirmed after interruption.' : 'The command was interrupted. Completed changes are retained in the result.' });
|
|
2664
|
+
if (result.status === 'success' && ['dev.plugin.create', 'dev.skill.create'].includes(id)) {
|
|
2665
|
+
const data = result.data;
|
|
2666
|
+
const name = typeof data.pluginName === 'string' ? data.pluginName : selected?.args[0];
|
|
2667
|
+
if (name)
|
|
2668
|
+
for (const action of ['validate', 'test', 'build'])
|
|
2669
|
+
result.nextActions.push({ kind: 'command', argv: ['aw', 'dev', 'plugin', action, `plugins/${name}`], reason: 'Check and build the new source.', requiresConfirmation: false });
|
|
2670
|
+
result.nextActions.push({ kind: 'command', argv: ['aw', 'dev', 'catalog', 'build'], reason: 'Build the Catalog after checking the source.', requiresConfirmation: false });
|
|
2671
|
+
}
|
|
2672
|
+
const invalid = result.diagnostics.some((diagnostic) => /invalidArguments|invalidOption|missingArgument|sensitiveConfigInputUnsupported/u.test(diagnostic.code));
|
|
2673
|
+
if (invalid && result.status !== 'partial') {
|
|
2674
|
+
result.status = 'failed';
|
|
2675
|
+
result.data = {};
|
|
2676
|
+
}
|
|
2677
|
+
return emit(result, invalid);
|
|
2790
2678
|
}
|
|
2791
2679
|
catch (error) {
|
|
2792
|
-
if (
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
warnings: [],
|
|
2820
|
-
errors: [message],
|
|
2821
|
-
});
|
|
2822
|
-
}
|
|
2823
|
-
else if (jsonAuthoringCommand === 'plugin:status') {
|
|
2824
|
-
writeJsonReceipt(io.stdout, {
|
|
2825
|
-
schemaVersion: 3,
|
|
2826
|
-
policy: 'development',
|
|
2827
|
-
ok: false,
|
|
2828
|
-
base: null,
|
|
2829
|
-
requestedBase: null,
|
|
2830
|
-
baseCommit: null,
|
|
2831
|
-
checkedPlugins: 0,
|
|
2832
|
-
checks: [],
|
|
2833
|
-
workspaceRoot: null,
|
|
2834
|
-
workspaceRootResolvedFrom: null,
|
|
2835
|
-
errors: [{ code: 'workspaceResolutionFailed', message }],
|
|
2836
|
-
});
|
|
2837
|
-
}
|
|
2838
|
-
else if (jsonAuthoringCommand === 'plugin:remove') {
|
|
2839
|
-
writeJsonReceipt(io.stdout, {
|
|
2840
|
-
schemaVersion: 1,
|
|
2841
|
-
command: 'plugin:remove',
|
|
2842
|
-
ok: false,
|
|
2843
|
-
workspaceRoot: null,
|
|
2844
|
-
workspaceRootResolvedFrom: null,
|
|
2845
|
-
baseCommit: null,
|
|
2846
|
-
plugin: null,
|
|
2847
|
-
removed: false,
|
|
2848
|
-
errors: [{ code: 'workspaceResolutionFailed', message }],
|
|
2849
|
-
});
|
|
2850
|
-
}
|
|
2851
|
-
else {
|
|
2852
|
-
writeJsonReceipt(io.stdout, {
|
|
2853
|
-
command: jsonAuthoringCommand,
|
|
2854
|
-
ok: false,
|
|
2855
|
-
errors: [{ code: 'workspaceResolutionFailed', message }],
|
|
2856
|
-
});
|
|
2857
|
-
}
|
|
2858
|
-
return 1;
|
|
2859
|
-
}
|
|
2860
|
-
if (jsonAuthoringCommand && error instanceof CommanderError) {
|
|
2861
|
-
writeJsonReceipt(io.stdout, {
|
|
2862
|
-
command: jsonAuthoringCommand,
|
|
2863
|
-
ok: false,
|
|
2864
|
-
errors: [{ code: 'invalidArguments', message: error.message }],
|
|
2865
|
-
});
|
|
2866
|
-
}
|
|
2867
|
-
return handleCliError(error, io.stderr);
|
|
2680
|
+
if (error instanceof CommanderError && error.exitCode === 0)
|
|
2681
|
+
return emit(helpResult(program, selected ?? program));
|
|
2682
|
+
const argumentError = error instanceof CommanderError || error instanceof WriteCommandRequestError;
|
|
2683
|
+
const raw = id?.startsWith('plugin.config.') && !(error instanceof CommanderError) && !(error instanceof WriteCommandRequestError)
|
|
2684
|
+
? configMutationFailure(error, options.env ?? process.env, options.cwd ?? process.cwd())
|
|
2685
|
+
: error;
|
|
2686
|
+
const code = argumentError ? error instanceof InvalidArgumentError || error instanceof CommanderError && error.code === 'commander.invalidArgument' ? 'invalidOptionValue' : 'invalidArguments' : raw.code ?? catalogGenerationErrorCode(error);
|
|
2687
|
+
const blocked = code === 'confirmationRequired' || /unavailable|missing|stale|conflict|unsupported|identityMismatch/iu.test(code);
|
|
2688
|
+
let message = raw.message ?? 'The operation failed.';
|
|
2689
|
+
if (error instanceof CommanderError) {
|
|
2690
|
+
const field = raw.message?.match(/--([a-z][a-z-]*)/u)?.[1];
|
|
2691
|
+
if (error.code === 'commander.unknownOption')
|
|
2692
|
+
message = field ? `Unknown option --${field}.` : 'Unknown option.';
|
|
2693
|
+
else if (error.code === 'commander.unknownCommand')
|
|
2694
|
+
message = 'Unknown command.';
|
|
2695
|
+
else if (error.code === 'commander.invalidArgument')
|
|
2696
|
+
message = field ? `Invalid value for --${field}.` : 'Invalid argument value.';
|
|
2697
|
+
else if (error.code === 'commander.excessArguments')
|
|
2698
|
+
message = 'Too many positional arguments.';
|
|
2699
|
+
}
|
|
2700
|
+
const preparedConfirmation = error?.confirmation ?? confirmation;
|
|
2701
|
+
const unknownAuthoringChanges = error?.authoringChanges === 'unknown';
|
|
2702
|
+
const data = { ...(preparedConfirmation ? { confirmation: preparedConfirmation } : {}), ...(unknownAuthoringChanges ? { changes: 'unknown' } : {}) };
|
|
2703
|
+
return emit(commandResult(id, data, { status: unknownAuthoringChanges ? 'partial' : blocked ? 'blocked' : 'failed', diagnostics: [{ code, severity: 'error', message: safePublicMessage(message, code), ...(code === 'invalidOptionValue' ? { subject: { field: raw.message?.match(/--([a-z][a-z-]*)/u)?.[1] ?? 'option' } } : {}) }], nextActions: code === 'confirmationRequired' ? [{ kind: 'manual', message: 'Review the effects and repeat the command with --yes.' }] : [] }), argumentError);
|
|
2704
|
+
}
|
|
2705
|
+
finally {
|
|
2706
|
+
stopListening();
|
|
2868
2707
|
}
|
|
2869
2708
|
}
|
|
2870
2709
|
export async function main(argv = process.argv.slice(2), options = {}) {
|