@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
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
|
+
import { resolveWorkContext } from '../intent/work-context.js';
|
|
2
3
|
import * as nodeFs from 'node:fs/promises';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import fs from 'fs-extra';
|
|
5
|
-
import {
|
|
6
|
+
import { canonicalizePluginConfigValues, selectPluginConfigProfile, PLATFORM_TARGETS, formatPluginConfigIssue, getPluginConfigDependencyKeys, getPluginConfigDependencyFields, matchPluginConfigPreset, redactPluginConfigValue, stablePluginConfigStringify, validatePluginConfigCandidate, validatePluginConfigDocument, validatePluginConfigValue as validateCorePluginConfigValue, } from '@lesliechan721/aw-plugin-core/manifest';
|
|
6
7
|
import { canonicalizePathThroughExistingAncestor, resolveAwHome, resolveRepoRootSync, } from './paths.js';
|
|
8
|
+
import { assertRealFileParentWithinRoot, assertSafeFileMutationPath, atomicReplaceSafeFile, } from './safe-fs.js';
|
|
9
|
+
import { pluginConfigHasExternalReferences, resolvePluginConfigReferenceContext, } from './plugin-config-references.js';
|
|
10
|
+
export { resolvePluginConfigReferenceContext } from './plugin-config-references.js';
|
|
11
|
+
function readPluginConfigBinding(value) {
|
|
12
|
+
return isRecord(value) && value.kind === 'source'
|
|
13
|
+
&& typeof value.sourceIdentity === 'string'
|
|
14
|
+
&& /^sha256:[0-9a-f]{64}$/u.test(value.sourceIdentity)
|
|
15
|
+
&& Object.keys(value).every((key) => ['kind', 'sourceIdentity'].includes(key))
|
|
16
|
+
? { kind: 'source', sourceIdentity: value.sourceIdentity } : null;
|
|
17
|
+
}
|
|
18
|
+
function readPluginConfigEnvelopeV6(value, _scope) {
|
|
19
|
+
if (!isRecord(value) || value.schemaVersion !== 6
|
|
20
|
+
|| typeof value.sourceId !== 'string' || typeof value.pluginName !== 'string'
|
|
21
|
+
|| !isRecord(value.common) || !isRecord(value.platforms)
|
|
22
|
+
|| Object.keys(value).some((key) => !['schemaVersion', 'sourceId', 'pluginName', 'binding', 'common', 'platforms'].includes(key))
|
|
23
|
+
|| Object.keys(value.platforms).some((key) => !PLATFORM_TARGETS.includes(key)))
|
|
24
|
+
return null;
|
|
25
|
+
const binding = readPluginConfigBinding(value.binding);
|
|
26
|
+
return binding ? { schemaVersion: 6, sourceId: value.sourceId, pluginName: value.pluginName,
|
|
27
|
+
binding, common: value.common,
|
|
28
|
+
platforms: value.platforms } : null;
|
|
29
|
+
}
|
|
30
|
+
export class PluginConfigResetError extends Error {
|
|
31
|
+
code;
|
|
32
|
+
osCode;
|
|
33
|
+
constructor(code, message, osCode) {
|
|
34
|
+
super(`${code}: ${message}`);
|
|
35
|
+
this.name = 'PluginConfigResetError';
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.osCode = osCode;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
7
40
|
export class PluginConfigSchemaResolutionError extends Error {
|
|
8
41
|
code;
|
|
9
42
|
details;
|
|
@@ -97,28 +130,6 @@ async function inspectConfigInventoryStoreRoot(boundaryRoot, storeRoot) {
|
|
|
97
130
|
}
|
|
98
131
|
return true;
|
|
99
132
|
}
|
|
100
|
-
async function readConfigDirectoryIdentity(directoryPath) {
|
|
101
|
-
const stats = await fs.lstat(directoryPath);
|
|
102
|
-
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
103
|
-
throw new Error(`Config parent must be a real directory: ${directoryPath}`);
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
dev: stats.dev,
|
|
107
|
-
ino: stats.ino,
|
|
108
|
-
realPath: await fs.realpath(directoryPath),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function assertConfigDirectoryStable(label, before, after) {
|
|
112
|
-
if (before.dev !== after.dev || before.ino !== after.ino || before.realPath !== after.realPath) {
|
|
113
|
-
throw new Error(`${label} identity changed before atomic config replacement.`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function assertRealConfigBoundary(root, parent) {
|
|
117
|
-
const relative = path.relative(root.realPath, parent.realPath);
|
|
118
|
-
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
119
|
-
throw new Error('Config parent realpath escapes its allowed root.');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
133
|
async function prepareConfigFileParent(filePath, allowedRoot) {
|
|
123
134
|
assertConfigPathBoundary(allowedRoot, filePath);
|
|
124
135
|
await assertNoConfigSymlink(allowedRoot, filePath);
|
|
@@ -131,66 +142,28 @@ export async function withConfigFileMutation(options) {
|
|
|
131
142
|
return options.action();
|
|
132
143
|
}
|
|
133
144
|
export async function atomicReplaceConfigFile(options) {
|
|
134
|
-
await
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
const temporaryPath = path.join(parentPath, `.${path.basename(options.filePath)}.tmp-${process.pid}-${crypto.randomUUID()}`);
|
|
145
|
-
assertConfigPathBoundary(options.allowedRoot, temporaryPath);
|
|
146
|
-
let handle;
|
|
147
|
-
try {
|
|
148
|
-
handle = await nodeFs.open(temporaryPath, 'wx', options.mode ?? (currentTarget ? currentTarget.mode & 0o777 : 0o600));
|
|
149
|
-
await handle.writeFile(options.content, 'utf8');
|
|
150
|
-
await handle.sync();
|
|
151
|
-
await handle.close();
|
|
152
|
-
handle = undefined;
|
|
153
|
-
await atomicConfigBeforeRenameHookForTests?.(options.filePath, temporaryPath);
|
|
154
|
-
await assertNoConfigSymlink(options.allowedRoot, options.filePath);
|
|
155
|
-
const currentRootIdentity = await readConfigDirectoryIdentity(rootPath);
|
|
156
|
-
const currentParentIdentity = await readConfigDirectoryIdentity(parentPath);
|
|
157
|
-
assertRealConfigBoundary(currentRootIdentity, currentParentIdentity);
|
|
158
|
-
assertConfigDirectoryStable('Config allowed root', rootIdentity, currentRootIdentity);
|
|
159
|
-
assertConfigDirectoryStable('Config parent', parentIdentity, currentParentIdentity);
|
|
160
|
-
const targetBeforeRename = await lstatIfExists(options.filePath);
|
|
161
|
-
if (targetBeforeRename && (!targetBeforeRename.isFile() || targetBeforeRename.isSymbolicLink())) {
|
|
162
|
-
throw new Error(`Config target must be a regular file: ${options.filePath}`);
|
|
163
|
-
}
|
|
164
|
-
await nodeFs.rename(temporaryPath, options.filePath);
|
|
165
|
-
// rename is the commit point. Diagnostics and durability work after it are best effort,
|
|
166
|
-
// because reporting failure here would leave the new generation on disk without giving
|
|
167
|
-
// the caller a safe way to restore the old generation.
|
|
168
|
-
await atomicConfigAfterRenameHookForTests?.(options.filePath).catch(() => undefined);
|
|
169
|
-
await (async () => {
|
|
170
|
-
const finalTarget = await fs.lstat(options.filePath);
|
|
171
|
-
if (!finalTarget.isFile() || finalTarget.isSymbolicLink()) {
|
|
172
|
-
throw new Error('Atomic config replacement produced an invalid target.');
|
|
173
|
-
}
|
|
174
|
-
if (await fs.readFile(options.filePath, 'utf8') !== options.content) {
|
|
175
|
-
throw new Error('Atomic config replacement content differs from the committed content.');
|
|
176
|
-
}
|
|
177
|
-
})().catch(() => undefined);
|
|
178
|
-
const directoryHandle = await nodeFs.open(parentPath, 'r').catch(() => null);
|
|
179
|
-
await directoryHandle?.sync().catch(() => undefined);
|
|
180
|
-
await directoryHandle?.close().catch(() => undefined);
|
|
181
|
-
}
|
|
182
|
-
finally {
|
|
183
|
-
await handle?.close().catch(() => undefined);
|
|
184
|
-
await nodeFs.rm(temporaryPath, { force: true }).catch(() => undefined);
|
|
185
|
-
}
|
|
145
|
+
await atomicReplaceSafeFile({
|
|
146
|
+
...options,
|
|
147
|
+
label: 'Config path',
|
|
148
|
+
temporaryTag: 'tmp',
|
|
149
|
+
beforeRename: atomicConfigBeforeRenameHookForTests,
|
|
150
|
+
afterRename: async (targetPath) => {
|
|
151
|
+
await atomicConfigAfterRenameHookForTests?.(targetPath).catch(() => undefined);
|
|
152
|
+
},
|
|
153
|
+
});
|
|
186
154
|
}
|
|
187
155
|
export async function atomicRemoveConfigFile(options) {
|
|
188
156
|
await prepareConfigFileParent(options.filePath, options.allowedRoot);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
157
|
+
await assertSafeFileMutationPath({
|
|
158
|
+
filePath: options.filePath,
|
|
159
|
+
allowedRoot: options.allowedRoot,
|
|
160
|
+
label: 'Config path',
|
|
161
|
+
});
|
|
162
|
+
await assertRealFileParentWithinRoot({
|
|
163
|
+
filePath: options.filePath,
|
|
164
|
+
allowedRoot: options.allowedRoot,
|
|
165
|
+
label: 'Config path',
|
|
166
|
+
});
|
|
194
167
|
const currentTarget = await lstatIfExists(options.filePath);
|
|
195
168
|
if (!currentTarget)
|
|
196
169
|
return false;
|
|
@@ -198,12 +171,16 @@ export async function atomicRemoveConfigFile(options) {
|
|
|
198
171
|
throw new Error(`Config target must be a regular file: ${options.filePath}`);
|
|
199
172
|
}
|
|
200
173
|
await atomicConfigBeforeRenameHookForTests?.(options.filePath, options.filePath);
|
|
201
|
-
await
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
174
|
+
await assertSafeFileMutationPath({
|
|
175
|
+
filePath: options.filePath,
|
|
176
|
+
allowedRoot: options.allowedRoot,
|
|
177
|
+
label: 'Config path',
|
|
178
|
+
});
|
|
179
|
+
await assertRealFileParentWithinRoot({
|
|
180
|
+
filePath: options.filePath,
|
|
181
|
+
allowedRoot: options.allowedRoot,
|
|
182
|
+
label: 'Config path',
|
|
183
|
+
});
|
|
207
184
|
const targetBeforeRemove = await lstatIfExists(options.filePath);
|
|
208
185
|
if (!targetBeforeRemove)
|
|
209
186
|
return false;
|
|
@@ -212,16 +189,21 @@ export async function atomicRemoveConfigFile(options) {
|
|
|
212
189
|
}
|
|
213
190
|
await nodeFs.unlink(options.filePath);
|
|
214
191
|
await atomicConfigAfterRenameHookForTests?.(options.filePath).catch(() => undefined);
|
|
215
|
-
const directoryHandle = await nodeFs.open(parentPath, 'r').catch(() => null);
|
|
216
|
-
await directoryHandle?.sync().catch(() => undefined);
|
|
217
|
-
await directoryHandle?.close().catch(() => undefined);
|
|
218
192
|
return true;
|
|
219
193
|
}
|
|
220
194
|
function isRecord(value) {
|
|
221
195
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
222
196
|
}
|
|
223
197
|
function formatValue(value) {
|
|
224
|
-
|
|
198
|
+
if (typeof value === 'string')
|
|
199
|
+
return value;
|
|
200
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
201
|
+
return stablePluginConfigStringify(value);
|
|
202
|
+
}
|
|
203
|
+
if (isRecord(value) || Array.isArray(value)) {
|
|
204
|
+
return stablePluginConfigStringify(value);
|
|
205
|
+
}
|
|
206
|
+
return JSON.stringify(value);
|
|
225
207
|
}
|
|
226
208
|
async function calculateConfigManifestDigest(filePath) {
|
|
227
209
|
const hash = crypto.createHash('sha256');
|
|
@@ -236,16 +218,17 @@ async function calculateConfigSchemaManifestDigestForPlugin(plugin) {
|
|
|
236
218
|
hash.update(JSON.stringify(plugin.manifest));
|
|
237
219
|
return `sha256:${hash.digest('hex')}`;
|
|
238
220
|
}
|
|
239
|
-
function createConfigSchemaEvidenceFromCurrentCatalog(plugin, manifestDigest) {
|
|
221
|
+
function createConfigSchemaEvidenceFromCurrentCatalog(plugin, manifestDigest, platform) {
|
|
240
222
|
return {
|
|
241
223
|
source: 'currentCatalog',
|
|
242
|
-
identity: createPluginConfigSchemaIdentity(plugin.manifest),
|
|
224
|
+
identity: createPluginConfigSchemaIdentity(plugin.manifest, platform),
|
|
225
|
+
platform,
|
|
243
226
|
pluginVersion: plugin.manifest.version,
|
|
244
227
|
manifestDigest,
|
|
245
228
|
};
|
|
246
229
|
}
|
|
247
230
|
function getStoreEntries(values) {
|
|
248
|
-
return
|
|
231
|
+
return Object.fromEntries(Object.entries(values));
|
|
249
232
|
}
|
|
250
233
|
export function assertSafePluginConfigSegment(pluginName) {
|
|
251
234
|
if (typeof pluginName !== 'string' || pluginName.trim() === '') {
|
|
@@ -267,111 +250,184 @@ export function resolveAwProjectRoot(cwd) {
|
|
|
267
250
|
return path.resolve(resolveRepoRootSync(cwd));
|
|
268
251
|
}
|
|
269
252
|
function resolvePluginConfigAllowedRoot(options) {
|
|
270
|
-
return options.
|
|
271
|
-
? resolveAwHome(options.env)
|
|
272
|
-
: path.join(resolveAwProjectRoot(options.cwd), '.agent-workflows');
|
|
253
|
+
return resolveAwHome(options.env);
|
|
273
254
|
}
|
|
255
|
+
/** Scope selects source context. All config values belong to the user document. */
|
|
274
256
|
export function resolvePluginConfigStorePath(options) {
|
|
275
257
|
const pluginName = assertSafePluginConfigSegment(options.pluginName);
|
|
276
|
-
const sourceId = options.sourceId === undefined
|
|
277
|
-
|
|
278
|
-
: assertSafePluginConfigSegment(options.sourceId);
|
|
279
|
-
const root = options.scope === 'user'
|
|
280
|
-
? resolveAwHome(options.env)
|
|
281
|
-
: path.join(resolveAwProjectRoot(options.cwd), '.agent-workflows');
|
|
282
|
-
const configDir = options.scope === 'project' && options.projectLayer === 'local'
|
|
283
|
-
? 'plugin-config.local'
|
|
284
|
-
: CONFIG_DIR;
|
|
285
|
-
const filePath = path.join(root, configDir, ...(sourceId ? [sourceId] : []), pluginName, CONFIG_FILE);
|
|
286
|
-
if (options.scope !== 'project') {
|
|
287
|
-
return filePath;
|
|
288
|
-
}
|
|
289
|
-
if (options.access === 'read') {
|
|
290
|
-
return assertTestReadablePath(filePath, options.projectLayer === 'local'
|
|
291
|
-
? 'project local plugin config store (.agent-workflows/plugin-config.local)'
|
|
292
|
-
: 'project shared plugin config store (.agent-workflows/plugin-config)', '用 registerReadonlyFixtureRoot() 或 runWithRepositoryCwdAsReadOnly() 登记只读 project fixture 根;需要写入时改用 withSafeTestCwd() 或 registerWritableStateRoot()。');
|
|
293
|
-
}
|
|
294
|
-
if (options.access === 'write') {
|
|
295
|
-
return assertTestWritablePath(filePath, options.projectLayer === 'local'
|
|
296
|
-
? 'project local plugin config store (.agent-workflows/plugin-config.local)'
|
|
297
|
-
: 'project shared plugin config store (.agent-workflows/plugin-config)', '用 withSafeTestCwd() 切到测试可写 cwd,或通过 registerWritableStateRoot() 登记 project fixture 根。');
|
|
298
|
-
}
|
|
299
|
-
return filePath;
|
|
258
|
+
const sourceId = options.sourceId === undefined ? undefined : assertSafePluginConfigSegment(options.sourceId);
|
|
259
|
+
return path.join(resolveAwHome(options.env), CONFIG_DIR, ...(sourceId ? [sourceId] : []), pluginName, CONFIG_FILE);
|
|
300
260
|
}
|
|
301
261
|
export function resolvePluginConfigStoreTargets(options) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
},
|
|
325
|
-
];
|
|
262
|
+
return [{ storeKind: 'user', path: resolvePluginConfigStorePath(options) }];
|
|
263
|
+
}
|
|
264
|
+
function isPluginConfigScalar(value) {
|
|
265
|
+
if (typeof value === 'string' || typeof value === 'boolean')
|
|
266
|
+
return true;
|
|
267
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
268
|
+
}
|
|
269
|
+
function isPluginConfigObject(value) {
|
|
270
|
+
if (!isRecord(value))
|
|
271
|
+
return false;
|
|
272
|
+
return Object.values(value).every((property) => {
|
|
273
|
+
if (isPluginConfigScalar(property))
|
|
274
|
+
return true;
|
|
275
|
+
if (Array.isArray(property)) {
|
|
276
|
+
const elementType = typeof property[0];
|
|
277
|
+
return Object.keys(property).length === property.length
|
|
278
|
+
&& property.every((item, index) => Object.hasOwn(property, index)
|
|
279
|
+
&& typeof item === elementType
|
|
280
|
+
&& isPluginConfigScalar(item));
|
|
281
|
+
}
|
|
282
|
+
return isRecord(property) && Object.values(property).every(isPluginConfigScalar);
|
|
283
|
+
});
|
|
326
284
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
285
|
+
function isPluginConfigValue(value) {
|
|
286
|
+
if (isPluginConfigScalar(value))
|
|
287
|
+
return true;
|
|
288
|
+
if (Array.isArray(value)) {
|
|
289
|
+
if (Object.keys(value).length !== value.length)
|
|
290
|
+
return false;
|
|
291
|
+
const first = value[0];
|
|
292
|
+
const elementType = isRecord(first) ? 'object' : typeof first;
|
|
293
|
+
return value.every((item, index) => Object.hasOwn(value, index)
|
|
294
|
+
&& (isRecord(item) ? 'object' : typeof item) === elementType
|
|
295
|
+
&& (isPluginConfigScalar(item) || isPluginConfigObject(item)));
|
|
331
296
|
}
|
|
332
|
-
return value;
|
|
297
|
+
return isPluginConfigObject(value);
|
|
333
298
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
299
|
+
function invalidStore(filePath, code, message, rawDigest) {
|
|
300
|
+
return {
|
|
301
|
+
path: filePath,
|
|
302
|
+
exists: true,
|
|
303
|
+
state: 'invalid',
|
|
304
|
+
values: {},
|
|
305
|
+
...(rawDigest ? { rawDigest } : {}),
|
|
306
|
+
invalidCode: code,
|
|
307
|
+
issues: [message],
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function readyStore(filePath, values, rawDigest) {
|
|
311
|
+
return {
|
|
312
|
+
path: filePath,
|
|
313
|
+
exists: true,
|
|
314
|
+
state: 'ready',
|
|
315
|
+
values: canonicalizePluginConfigValues(values),
|
|
316
|
+
...(rawDigest ? { rawDigest } : {}),
|
|
317
|
+
issues: [],
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
export function assertReadyPluginConfigStore(store) {
|
|
321
|
+
if (store.state !== 'invalid')
|
|
322
|
+
return;
|
|
323
|
+
throw new Error(`${store.invalidCode}: Invalid plugin config store "${store.path}". ${store.issues.join(' ')}`);
|
|
324
|
+
}
|
|
325
|
+
async function parseStoreJson(filePath) {
|
|
326
|
+
const content = await fs.readFile(filePath);
|
|
327
|
+
const rawDigest = `sha256:${crypto.createHash('sha256').update(content).digest('hex')}`;
|
|
328
|
+
try {
|
|
329
|
+
return {
|
|
330
|
+
state: 'parsed',
|
|
331
|
+
value: JSON.parse(content.toString('utf8')),
|
|
332
|
+
rawDigest,
|
|
333
|
+
};
|
|
338
334
|
}
|
|
339
|
-
|
|
340
|
-
|
|
335
|
+
catch (error) {
|
|
336
|
+
if (error instanceof SyntaxError) {
|
|
337
|
+
return {
|
|
338
|
+
state: 'invalidJson',
|
|
339
|
+
store: invalidStore(filePath, 'invalidJson', 'The store is not valid JSON.', rawDigest),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
throw error;
|
|
341
343
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
+
}
|
|
345
|
+
function validateStoreValues(options) {
|
|
346
|
+
if (!isRecord(options.values)) {
|
|
347
|
+
return invalidStore(options.filePath, 'invalidValues', 'The values field must be an object.', options.rawDigest);
|
|
344
348
|
}
|
|
345
|
-
|
|
349
|
+
const values = Object.create(null);
|
|
350
|
+
const issues = [];
|
|
351
|
+
for (const [key, value] of Object.entries(options.values)) {
|
|
352
|
+
if (!isPluginConfigValue(value)) {
|
|
353
|
+
issues.push(`Config "${key}" is not a supported config value.`);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
values[key] = value;
|
|
357
|
+
}
|
|
358
|
+
return issues.length > 0
|
|
359
|
+
? invalidStore(options.filePath, 'invalidValues', issues.join(' '), options.rawDigest)
|
|
360
|
+
: readyStore(options.filePath, values, options.rawDigest);
|
|
361
|
+
}
|
|
362
|
+
function documentStore(options) {
|
|
363
|
+
const common = validateStoreValues({ filePath: options.filePath, values: options.common, rawDigest: options.rawDigest });
|
|
364
|
+
if (common.state === 'invalid')
|
|
365
|
+
return common;
|
|
366
|
+
if (!isRecord(options.platforms) || Object.keys(options.platforms).some((key) => !PLATFORM_TARGETS.includes(key))) {
|
|
367
|
+
return invalidStore(options.filePath, 'invalidValues', 'The platforms field must contain known platform objects.', options.rawDigest);
|
|
368
|
+
}
|
|
369
|
+
const platforms = {};
|
|
370
|
+
for (const [platform, values] of Object.entries(options.platforms)) {
|
|
371
|
+
const store = validateStoreValues({ filePath: options.filePath, values, rawDigest: options.rawDigest });
|
|
372
|
+
if (store.state === 'invalid')
|
|
373
|
+
return store;
|
|
374
|
+
platforms[platform] = store.values;
|
|
375
|
+
}
|
|
376
|
+
return { ...common, common: common.values, platforms, ...(options.platform ? { platform: options.platform } : {}),
|
|
377
|
+
values: options.platform ? platforms[options.platform] ?? {} : common.values };
|
|
378
|
+
}
|
|
379
|
+
export function pluginConfigStoreForProfile(store, platform) {
|
|
380
|
+
return { ...store, platform, values: platform ? store.platforms?.[platform] ?? {} : store.common ?? store.values };
|
|
381
|
+
}
|
|
382
|
+
/** Replace one layer in memory without changing any other profile. */
|
|
383
|
+
export function replacePluginConfigStoreLayer(store, values, platform) {
|
|
384
|
+
const common = platform ? store.common ?? store.values : canonicalizePluginConfigValues(values);
|
|
385
|
+
const platforms = { ...store.platforms };
|
|
386
|
+
if (platform) {
|
|
387
|
+
if (Object.keys(values).length)
|
|
388
|
+
platforms[platform] = canonicalizePluginConfigValues(values);
|
|
389
|
+
else
|
|
390
|
+
delete platforms[platform];
|
|
391
|
+
}
|
|
392
|
+
const exists = Object.keys(common).length > 0 || Object.keys(platforms).length > 0;
|
|
393
|
+
return { ...store, common, platforms, platform, values: platform ? platforms[platform] ?? {} : common,
|
|
394
|
+
exists, state: exists ? 'ready' : 'missing', issues: [], rawDigest: undefined };
|
|
395
|
+
}
|
|
396
|
+
async function readStoreFile(filePath, platform) {
|
|
397
|
+
const parsed = await parseStoreJson(filePath);
|
|
398
|
+
if (parsed.state === 'invalidJson')
|
|
399
|
+
return parsed.store;
|
|
400
|
+
const raw = parsed.value;
|
|
401
|
+
if (!isRecord(raw) || raw.schemaVersion !== 6
|
|
402
|
+
|| Object.keys(raw).some((key) => !['schemaVersion', 'common', 'platforms'].includes(key))) {
|
|
403
|
+
return invalidStore(filePath, 'schemaVersionUnsupported', 'Only plugin config store schemaVersion 6 is supported. Reset the old document, then save the required values.', parsed.rawDigest);
|
|
404
|
+
}
|
|
405
|
+
return documentStore({ filePath, common: raw.common, platforms: raw.platforms, rawDigest: parsed.rawDigest, platform });
|
|
406
|
+
}
|
|
407
|
+
async function readNamespacedStoreFile(options) {
|
|
408
|
+
const parsed = await parseStoreJson(options.filePath);
|
|
409
|
+
if (parsed.state === 'invalidJson')
|
|
410
|
+
return parsed.store;
|
|
411
|
+
const envelope = readPluginConfigEnvelopeV6(parsed.value);
|
|
412
|
+
if (!envelope)
|
|
413
|
+
return invalidStore(options.filePath, 'schemaVersionUnsupported', 'Only a valid plugin config store schemaVersion 6 is supported. Reset the old document, then save the required values.', parsed.rawDigest);
|
|
414
|
+
if (envelope.sourceId !== options.sourceId || envelope.pluginName !== options.pluginName
|
|
415
|
+
|| !options.sourceIdentity || envelope.binding.sourceIdentity !== options.sourceIdentity) {
|
|
416
|
+
return invalidStore(options.filePath, 'identityMismatch', 'The user store is not bound to the requested source and plugin identity.', parsed.rawDigest);
|
|
417
|
+
}
|
|
418
|
+
return documentStore({ filePath: options.filePath, common: envelope.common, platforms: envelope.platforms,
|
|
419
|
+
rawDigest: parsed.rawDigest, platform: options.platform });
|
|
346
420
|
}
|
|
347
421
|
function namespacedConfigContent(options) {
|
|
422
|
+
const document = { schemaVersion: 6, common: canonicalizePluginConfigValues(options.common),
|
|
423
|
+
platforms: Object.fromEntries(Object.entries(options.platforms).sort(([a], [b]) => a.localeCompare(b, 'en'))
|
|
424
|
+
.map(([platform, values]) => [platform, canonicalizePluginConfigValues(values)])) };
|
|
348
425
|
if (!options.sourceId)
|
|
349
|
-
return `${JSON.stringify(
|
|
426
|
+
return `${JSON.stringify(document, null, 2)}\n`;
|
|
350
427
|
if (!options.sourceIdentity)
|
|
351
|
-
throw new Error('
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
sourceId: options.sourceId,
|
|
355
|
-
sourceIdentity: options.sourceIdentity,
|
|
356
|
-
pluginName: options.pluginName,
|
|
357
|
-
values: options.values,
|
|
358
|
-
};
|
|
359
|
-
return `${JSON.stringify(envelope, null, 2)}\n`;
|
|
360
|
-
}
|
|
361
|
-
async function assertNoLegacyConfigCoexistence(options) {
|
|
362
|
-
if (!options.sourceId)
|
|
363
|
-
return;
|
|
364
|
-
const legacyPath = resolvePluginConfigStorePath({
|
|
365
|
-
pluginName: options.pluginName,
|
|
366
|
-
scope: options.scope,
|
|
367
|
-
cwd: options.cwd,
|
|
368
|
-
env: options.env,
|
|
369
|
-
projectLayer: options.projectLayer,
|
|
370
|
-
...(options.scope === 'project' ? { access: 'read' } : {}),
|
|
371
|
-
});
|
|
372
|
-
if (await lstatIfExists(legacyPath)) {
|
|
373
|
-
throw new Error('legacyStateUnsupported: legacy and namespaced plugin config stores cannot coexist.');
|
|
374
|
-
}
|
|
428
|
+
throw new Error('sourceChanged: user plugin config requires a source identity.');
|
|
429
|
+
return `${JSON.stringify({ ...document, sourceId: options.sourceId, pluginName: options.pluginName,
|
|
430
|
+
binding: { kind: 'source', sourceIdentity: options.sourceIdentity } }, null, 2)}\n`;
|
|
375
431
|
}
|
|
376
432
|
export async function readPluginConfigStore(options) {
|
|
377
433
|
const filePath = resolvePluginConfigStorePath({
|
|
@@ -380,14 +436,11 @@ export async function readPluginConfigStore(options) {
|
|
|
380
436
|
});
|
|
381
437
|
const allowedRoot = resolvePluginConfigAllowedRoot(options);
|
|
382
438
|
if (options.sourceId) {
|
|
383
|
-
if (!options.sourceIdentity)
|
|
384
|
-
throw new Error('sourceIdentity is required for namespaced plugin config.');
|
|
385
439
|
const legacyPath = resolvePluginConfigStorePath({
|
|
386
440
|
pluginName: options.pluginName,
|
|
387
441
|
scope: options.scope,
|
|
388
442
|
cwd: options.cwd,
|
|
389
443
|
env: options.env,
|
|
390
|
-
projectLayer: options.projectLayer,
|
|
391
444
|
...(options.scope === 'project' ? { access: 'read' } : {}),
|
|
392
445
|
});
|
|
393
446
|
if (await inspectConfigReadTarget(allowedRoot, legacyPath)) {
|
|
@@ -398,21 +451,22 @@ export async function readPluginConfigStore(options) {
|
|
|
398
451
|
return {
|
|
399
452
|
path: filePath,
|
|
400
453
|
exists: false,
|
|
454
|
+
state: 'missing',
|
|
401
455
|
values: {},
|
|
456
|
+
issues: [],
|
|
402
457
|
};
|
|
403
458
|
}
|
|
404
|
-
return
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
};
|
|
459
|
+
return options.sourceId
|
|
460
|
+
? readNamespacedStoreFile({
|
|
461
|
+
filePath,
|
|
462
|
+
sourceId: options.sourceId,
|
|
463
|
+
scope: options.scope,
|
|
464
|
+
sourceIdentity: options.sourceIdentity,
|
|
465
|
+
logicalIdentity: options.logicalIdentity,
|
|
466
|
+
pluginName: options.pluginName,
|
|
467
|
+
platform: options.platform,
|
|
468
|
+
})
|
|
469
|
+
: readStoreFile(filePath, options.platform);
|
|
416
470
|
}
|
|
417
471
|
export async function readNamespacedPluginConfigStoreIdentity(options) {
|
|
418
472
|
const filePath = resolvePluginConfigStorePath({
|
|
@@ -421,15 +475,21 @@ export async function readNamespacedPluginConfigStoreIdentity(options) {
|
|
|
421
475
|
});
|
|
422
476
|
if (!await inspectConfigReadTarget(resolvePluginConfigAllowedRoot(options), filePath))
|
|
423
477
|
return null;
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
478
|
+
const parsed = await parseStoreJson(filePath);
|
|
479
|
+
if (parsed.state === 'invalidJson') {
|
|
480
|
+
throw new Error(`${parsed.store.invalidCode}: invalid namespaced plugin config store.`);
|
|
481
|
+
}
|
|
482
|
+
const envelope = readPluginConfigEnvelopeV6(parsed.value, options.scope);
|
|
483
|
+
if (!envelope
|
|
484
|
+
|| envelope.sourceId !== options.sourceId
|
|
485
|
+
|| envelope.pluginName !== options.pluginName) {
|
|
486
|
+
throw new Error('schemaVersionUnsupported: invalid namespaced plugin config store.');
|
|
487
|
+
}
|
|
488
|
+
const store = documentStore({ filePath, common: envelope.common, platforms: envelope.platforms, platform: options.platform });
|
|
489
|
+
assertReadyPluginConfigStore(store);
|
|
430
490
|
return {
|
|
431
|
-
|
|
432
|
-
store
|
|
491
|
+
binding: envelope.binding,
|
|
492
|
+
store,
|
|
433
493
|
};
|
|
434
494
|
}
|
|
435
495
|
async function listConfigStoreDirectoryPluginNames(storeRoot) {
|
|
@@ -456,32 +516,75 @@ async function listConfigStoreDirectoryPluginNames(storeRoot) {
|
|
|
456
516
|
return pluginNames;
|
|
457
517
|
}
|
|
458
518
|
export async function listPluginConfigStorePluginNames(options) {
|
|
459
|
-
const
|
|
460
|
-
const storeRoots = options.scope === 'user'
|
|
461
|
-
? [path.join(resolveAwHome(options.env), CONFIG_DIR)]
|
|
462
|
-
: options.scope === 'project'
|
|
463
|
-
? [path.join(projectRoot, '.agent-workflows', options.projectLayer === 'local' ? 'plugin-config.local' : CONFIG_DIR)]
|
|
464
|
-
: [
|
|
465
|
-
path.join(resolveAwHome(options.env), CONFIG_DIR),
|
|
466
|
-
path.join(projectRoot, '.agent-workflows', CONFIG_DIR),
|
|
467
|
-
path.join(projectRoot, '.agent-workflows', 'plugin-config.local'),
|
|
468
|
-
];
|
|
519
|
+
const storeRoots = [path.join(resolveAwHome(options.env), CONFIG_DIR)];
|
|
469
520
|
const pluginNames = (await Promise.all(storeRoots.map((storeRoot) => listConfigStoreDirectoryPluginNames(storeRoot)))).flat();
|
|
470
521
|
return [...new Set(pluginNames)].sort((left, right) => left.localeCompare(right));
|
|
471
522
|
}
|
|
523
|
+
export async function listNamespacedPluginConfigStoreIdentities(options) {
|
|
524
|
+
const boundaryRoot = resolveAwHome(options.env);
|
|
525
|
+
if (options.scope === 'user') {
|
|
526
|
+
await canonicalizePathThroughExistingAncestor(boundaryRoot);
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
await fs.realpath(boundaryRoot);
|
|
530
|
+
}
|
|
531
|
+
const storeRoot = path.join(boundaryRoot, CONFIG_DIR);
|
|
532
|
+
if (!await inspectConfigInventoryStoreRoot(boundaryRoot, storeRoot))
|
|
533
|
+
return [];
|
|
534
|
+
const output = [];
|
|
535
|
+
for (const sourceEntry of await fs.readdir(storeRoot, { withFileTypes: true })) {
|
|
536
|
+
if (!sourceEntry.isDirectory() || sourceEntry.isSymbolicLink())
|
|
537
|
+
continue;
|
|
538
|
+
let sourceId;
|
|
539
|
+
try {
|
|
540
|
+
sourceId = assertSafePluginConfigSegment(sourceEntry.name);
|
|
541
|
+
}
|
|
542
|
+
catch {
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
const sourceRoot = path.join(storeRoot, sourceId);
|
|
546
|
+
let pluginEntries;
|
|
547
|
+
try {
|
|
548
|
+
await assertNoConfigSymlink(boundaryRoot, sourceRoot);
|
|
549
|
+
pluginEntries = await fs.readdir(sourceRoot, { withFileTypes: true });
|
|
550
|
+
}
|
|
551
|
+
catch {
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
for (const pluginEntry of pluginEntries) {
|
|
555
|
+
if (!pluginEntry.isDirectory() || pluginEntry.isSymbolicLink())
|
|
556
|
+
continue;
|
|
557
|
+
let pluginName;
|
|
558
|
+
try {
|
|
559
|
+
pluginName = assertSafePluginConfigSegment(pluginEntry.name);
|
|
560
|
+
await assertNoConfigSymlink(boundaryRoot, path.join(sourceRoot, pluginName));
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
let target;
|
|
566
|
+
try {
|
|
567
|
+
target = await lstatIfExists(path.join(sourceRoot, pluginName, CONFIG_FILE));
|
|
568
|
+
}
|
|
569
|
+
catch {
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if (!target)
|
|
573
|
+
continue;
|
|
574
|
+
output.push({ sourceId, pluginName, pluginId: `${sourceId}/${pluginName}` });
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return output.sort((left, right) => left.pluginId.localeCompare(right.pluginId));
|
|
578
|
+
}
|
|
472
579
|
export async function listNamespacedPluginConfigStores(options) {
|
|
473
|
-
const boundaryRoot = options.
|
|
474
|
-
? resolveAwHome(options.env)
|
|
475
|
-
: resolveAwProjectRoot(options.cwd);
|
|
580
|
+
const boundaryRoot = resolveAwHome(options.env);
|
|
476
581
|
if (options.scope === 'user') {
|
|
477
582
|
await canonicalizePathThroughExistingAncestor(boundaryRoot);
|
|
478
583
|
}
|
|
479
584
|
else {
|
|
480
585
|
await fs.realpath(boundaryRoot);
|
|
481
586
|
}
|
|
482
|
-
const storeRoot = path.join(boundaryRoot,
|
|
483
|
-
? 'plugin-config.local'
|
|
484
|
-
: CONFIG_DIR);
|
|
587
|
+
const storeRoot = path.join(boundaryRoot, CONFIG_DIR);
|
|
485
588
|
const output = [];
|
|
486
589
|
if (!await inspectConfigInventoryStoreRoot(boundaryRoot, storeRoot))
|
|
487
590
|
return output;
|
|
@@ -503,362 +606,330 @@ export async function listNamespacedPluginConfigStores(options) {
|
|
|
503
606
|
const filePath = path.join(storeRoot, sourceId, pluginName, CONFIG_FILE);
|
|
504
607
|
if (!await inspectConfigReadTarget(storeRoot, filePath))
|
|
505
608
|
continue;
|
|
506
|
-
const
|
|
507
|
-
if (
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
609
|
+
const parsed = await parseStoreJson(filePath);
|
|
610
|
+
if (parsed.state === 'invalidJson') {
|
|
611
|
+
throw new Error(`${parsed.store.invalidCode}: invalid namespaced plugin config store "${filePath}".`);
|
|
612
|
+
}
|
|
613
|
+
const envelope = readPluginConfigEnvelopeV6(parsed.value, options.scope);
|
|
614
|
+
if (!envelope
|
|
615
|
+
|| envelope.sourceId !== sourceId
|
|
616
|
+
|| envelope.pluginName !== pluginName) {
|
|
617
|
+
throw new Error(`schemaVersionUnsupported: invalid namespaced plugin config store "${filePath}".`);
|
|
511
618
|
}
|
|
619
|
+
const store = documentStore({ filePath, common: envelope.common, platforms: envelope.platforms });
|
|
620
|
+
assertReadyPluginConfigStore(store);
|
|
512
621
|
output.push({
|
|
513
622
|
sourceId,
|
|
514
|
-
|
|
623
|
+
binding: envelope.binding,
|
|
515
624
|
pluginName,
|
|
516
625
|
pluginId: `${sourceId}/${pluginName}`,
|
|
517
|
-
values:
|
|
626
|
+
values: store.values,
|
|
518
627
|
});
|
|
519
628
|
}
|
|
520
629
|
}
|
|
521
630
|
return output.sort((left, right) => left.pluginId.localeCompare(right.pluginId));
|
|
522
631
|
}
|
|
523
632
|
export async function writePluginConfigStore(options) {
|
|
524
|
-
await
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
633
|
+
const current = await readPluginConfigStore(options);
|
|
634
|
+
assertReadyPluginConfigStore(current);
|
|
635
|
+
const validated = validateStoreValues({ filePath: current.path, values: options.values });
|
|
636
|
+
assertReadyPluginConfigStore(validated);
|
|
637
|
+
return commitPluginConfigLayer(options, current, validated.values);
|
|
638
|
+
}
|
|
639
|
+
async function commitPluginConfigLayer(options, current, values) {
|
|
640
|
+
const next = replacePluginConfigStoreLayer(current, values, options.platform);
|
|
529
641
|
const allowedRoot = resolvePluginConfigAllowedRoot(options);
|
|
530
|
-
await withConfigFileMutation({
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}),
|
|
539
|
-
});
|
|
540
|
-
return {
|
|
541
|
-
pluginName: options.pluginName,
|
|
542
|
-
scope: options.scope,
|
|
543
|
-
path: filePath,
|
|
544
|
-
};
|
|
642
|
+
await withConfigFileMutation({ filePath: current.path, allowedRoot, action: async () => {
|
|
643
|
+
if (!next.exists)
|
|
644
|
+
await atomicRemoveConfigFile({ filePath: current.path, allowedRoot });
|
|
645
|
+
else
|
|
646
|
+
await atomicReplaceConfigFile({ filePath: current.path, allowedRoot,
|
|
647
|
+
content: namespacedConfigContent({ ...options, common: next.common, platforms: next.platforms }), mode: 0o600 });
|
|
648
|
+
} });
|
|
649
|
+
return { pluginName: options.pluginName, scope: 'user', platform: options.platform, path: current.path, warnings: [] };
|
|
545
650
|
}
|
|
546
651
|
export async function patchPluginConfigStore(options) {
|
|
547
|
-
await
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
...(options.scope === 'project' ? { access: 'write' } : {}),
|
|
551
|
-
});
|
|
552
|
-
const allowedRoot = resolvePluginConfigAllowedRoot(options);
|
|
652
|
+
await options.reviewPreflight?.();
|
|
653
|
+
const current = await readPluginConfigStore(options);
|
|
654
|
+
assertReadyPluginConfigStore(current);
|
|
553
655
|
const removedKeys = options.removeKeys ?? [];
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
: await readStoreFile(filePath)
|
|
568
|
-
: {};
|
|
569
|
-
if (options.requireExistingRemoveKeys) {
|
|
570
|
-
const missingKey = removedKeys.find((key) => !Object.hasOwn(current, key));
|
|
571
|
-
if (missingKey)
|
|
572
|
-
throw new Error(`Unknown config key "${missingKey}".`);
|
|
573
|
-
}
|
|
574
|
-
const next = { ...current };
|
|
575
|
-
for (const key of removedKeys) {
|
|
576
|
-
delete next[key];
|
|
577
|
-
}
|
|
578
|
-
for (const [key, value] of Object.entries(options.updates)) {
|
|
579
|
-
next[key] = value;
|
|
580
|
-
}
|
|
581
|
-
await atomicReplaceConfigFile({
|
|
582
|
-
filePath,
|
|
583
|
-
allowedRoot,
|
|
584
|
-
content: namespacedConfigContent({ ...options, values: next }),
|
|
585
|
-
mode: 0o600,
|
|
586
|
-
});
|
|
587
|
-
},
|
|
588
|
-
});
|
|
589
|
-
return {
|
|
590
|
-
pluginName: options.pluginName,
|
|
591
|
-
scope: options.scope,
|
|
592
|
-
path: filePath,
|
|
593
|
-
updatedKeys: Object.keys(options.updates),
|
|
594
|
-
removedKeys,
|
|
595
|
-
};
|
|
656
|
+
if (options.requireExistingRemoveKeys) {
|
|
657
|
+
const missing = removedKeys.find((key) => !Object.hasOwn(current.values, key));
|
|
658
|
+
if (missing)
|
|
659
|
+
throw new Error(`Unknown config key "${missing}".`);
|
|
660
|
+
}
|
|
661
|
+
const next = Object.assign(Object.create(null), current.values);
|
|
662
|
+
for (const key of removedKeys)
|
|
663
|
+
delete next[key];
|
|
664
|
+
for (const [key, value] of Object.entries(options.updates))
|
|
665
|
+
next[key] = value;
|
|
666
|
+
const validated = validateStoreValues({ filePath: current.path, values: next });
|
|
667
|
+
assertReadyPluginConfigStore(validated);
|
|
668
|
+
return { ...await commitPluginConfigLayer(options, current, validated.values), updatedKeys: Object.keys(options.updates), removedKeys };
|
|
596
669
|
}
|
|
597
670
|
export async function resetPluginConfigStore(options) {
|
|
598
|
-
|
|
671
|
+
return resetPluginConfigStoreTarget(options, false);
|
|
672
|
+
}
|
|
673
|
+
/** Delete the plugin's complete user document, including every platform profile. */
|
|
674
|
+
export async function deletePluginConfigStore(options) {
|
|
675
|
+
return resetPluginConfigStoreTarget(options, true);
|
|
676
|
+
}
|
|
677
|
+
async function resetPluginConfigStoreTarget(options, wholeDocument) {
|
|
599
678
|
const filePath = resolvePluginConfigStorePath({
|
|
600
679
|
...options,
|
|
601
680
|
...(options.scope === 'project' ? { access: 'write' } : {}),
|
|
602
681
|
});
|
|
603
682
|
const allowedRoot = resolvePluginConfigAllowedRoot(options);
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
if (!options.sourceIdentity) {
|
|
617
|
-
throw new Error('sourceIdentity is required for namespaced plugin config.');
|
|
618
|
-
}
|
|
619
|
-
await readNamespacedStoreFile({
|
|
620
|
-
filePath,
|
|
621
|
-
sourceId: options.sourceId,
|
|
622
|
-
sourceIdentity: options.sourceIdentity,
|
|
683
|
+
const publicTarget = `${options.scope}/plugin-config/${[
|
|
684
|
+
options.sourceId,
|
|
685
|
+
options.pluginName,
|
|
686
|
+
CONFIG_FILE,
|
|
687
|
+
].filter(Boolean).join('/')}`;
|
|
688
|
+
const { root, candidate } = assertConfigPathBoundary(allowedRoot, filePath);
|
|
689
|
+
let current = root;
|
|
690
|
+
try {
|
|
691
|
+
for (const segment of path.relative(root, path.dirname(candidate)).split(path.sep).filter(Boolean)) {
|
|
692
|
+
const stats = await lstatIfExists(current);
|
|
693
|
+
if (!stats) {
|
|
694
|
+
return {
|
|
623
695
|
pluginName: options.pluginName,
|
|
624
|
-
|
|
696
|
+
scope: 'user',
|
|
697
|
+
storeKind: 'user',
|
|
698
|
+
path: filePath,
|
|
699
|
+
existed: false,
|
|
700
|
+
deleted: false,
|
|
701
|
+
resetDisposition: 'absent',
|
|
702
|
+
};
|
|
625
703
|
}
|
|
626
|
-
|
|
627
|
-
|
|
704
|
+
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
705
|
+
throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
|
|
628
706
|
}
|
|
629
|
-
|
|
630
|
-
},
|
|
631
|
-
});
|
|
632
|
-
return {
|
|
633
|
-
pluginName: options.pluginName,
|
|
634
|
-
scope: options.scope,
|
|
635
|
-
storeKind: options.scope === 'user'
|
|
636
|
-
? 'user'
|
|
637
|
-
: options.projectLayer === 'local'
|
|
638
|
-
? 'projectLocal'
|
|
639
|
-
: 'projectShared',
|
|
640
|
-
path: filePath,
|
|
641
|
-
existed,
|
|
642
|
-
deleted: existed,
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
export async function resetPluginConfigStores(options) {
|
|
646
|
-
await assertNoLegacyConfigCoexistence(options);
|
|
647
|
-
const targets = resolvePluginConfigStoreTargets({
|
|
648
|
-
...options,
|
|
649
|
-
...(options.scope === 'project' ? { access: 'write' } : {}),
|
|
650
|
-
});
|
|
651
|
-
const allowedRoot = resolvePluginConfigAllowedRoot(options);
|
|
652
|
-
const receipts = [];
|
|
653
|
-
const existing = [];
|
|
654
|
-
for (const target of targets) {
|
|
655
|
-
await prepareConfigFileParent(target.path, allowedRoot);
|
|
656
|
-
await assertNoConfigSymlink(allowedRoot, target.path);
|
|
657
|
-
const stats = await lstatIfExists(target.path);
|
|
658
|
-
existing.push(stats !== null);
|
|
659
|
-
if (!stats)
|
|
660
|
-
continue;
|
|
661
|
-
if (!stats.isFile() || stats.isSymbolicLink()) {
|
|
662
|
-
throw new Error(`Config target must be a regular file: ${target.path}`);
|
|
707
|
+
current = path.join(current, segment);
|
|
663
708
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
await readNamespacedStoreFile({
|
|
669
|
-
filePath: target.path,
|
|
670
|
-
sourceId: options.sourceId,
|
|
671
|
-
sourceIdentity: options.sourceIdentity,
|
|
709
|
+
const parentStats = await lstatIfExists(current);
|
|
710
|
+
if (!parentStats) {
|
|
711
|
+
return {
|
|
672
712
|
pluginName: options.pluginName,
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
const deleted = await atomicRemoveConfigFile({
|
|
681
|
-
filePath: target.path,
|
|
682
|
-
allowedRoot,
|
|
683
|
-
});
|
|
684
|
-
receipts.push({
|
|
685
|
-
pluginName: options.pluginName,
|
|
686
|
-
scope: options.scope,
|
|
687
|
-
storeKind: target.storeKind,
|
|
688
|
-
path: target.path,
|
|
689
|
-
existed: existing[index],
|
|
690
|
-
deleted,
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
return receipts;
|
|
694
|
-
}
|
|
695
|
-
function coercePrimitiveValue(key, field, value) {
|
|
696
|
-
if (field.type === 'string') {
|
|
697
|
-
if (typeof value !== 'string') {
|
|
698
|
-
throw new Error(`Config "${key}" must be a string.`);
|
|
699
|
-
}
|
|
700
|
-
return value;
|
|
701
|
-
}
|
|
702
|
-
if (field.type === 'number') {
|
|
703
|
-
const numberValue = typeof value === 'number'
|
|
704
|
-
? value
|
|
705
|
-
: typeof value === 'string' && value.trim() !== ''
|
|
706
|
-
? Number(value)
|
|
707
|
-
: Number.NaN;
|
|
708
|
-
if (!Number.isFinite(numberValue)) {
|
|
709
|
-
throw new Error(`Config "${key}" must be a number.`);
|
|
710
|
-
}
|
|
711
|
-
if (field.min !== undefined && numberValue < field.min) {
|
|
712
|
-
throw new Error(`Config "${key}" must be greater than or equal to ${field.min}.`);
|
|
713
|
+
scope: 'user',
|
|
714
|
+
storeKind: 'user',
|
|
715
|
+
path: filePath,
|
|
716
|
+
existed: false,
|
|
717
|
+
deleted: false,
|
|
718
|
+
resetDisposition: 'absent',
|
|
719
|
+
};
|
|
713
720
|
}
|
|
714
|
-
if (
|
|
715
|
-
throw new
|
|
721
|
+
if (parentStats.isSymbolicLink() || !parentStats.isDirectory()) {
|
|
722
|
+
throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
|
|
716
723
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
724
|
+
await options.reviewPreflight?.();
|
|
725
|
+
const target = await lstatIfExists(filePath);
|
|
726
|
+
if (!target) {
|
|
727
|
+
return {
|
|
728
|
+
pluginName: options.pluginName,
|
|
729
|
+
scope: 'user',
|
|
730
|
+
storeKind: 'user',
|
|
731
|
+
path: filePath,
|
|
732
|
+
existed: false,
|
|
733
|
+
deleted: false,
|
|
734
|
+
resetDisposition: 'absent',
|
|
735
|
+
};
|
|
722
736
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
737
|
+
let store;
|
|
738
|
+
if (target.isFile()) {
|
|
739
|
+
try {
|
|
740
|
+
store = await readPluginConfigStore(options);
|
|
727
741
|
}
|
|
728
|
-
|
|
729
|
-
|
|
742
|
+
catch {
|
|
743
|
+
// A broken document still has the schema-independent reset recovery below.
|
|
730
744
|
}
|
|
731
745
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
746
|
+
if (!wholeDocument && store && store.state !== 'invalid' && replacePluginConfigStoreLayer(store, {}, options.platform).exists) {
|
|
747
|
+
await commitPluginConfigLayer(options, store, {});
|
|
748
|
+
return { pluginName: options.pluginName, scope: 'user', platform: options.platform, storeKind: 'user',
|
|
749
|
+
path: filePath, existed: true, deleted: false, resetDisposition: 'clearedLayer' };
|
|
750
|
+
}
|
|
751
|
+
if (target.isFile() || target.isSymbolicLink()) {
|
|
752
|
+
await assertNoConfigSymlink(allowedRoot, path.dirname(filePath));
|
|
753
|
+
await nodeFs.unlink(filePath);
|
|
754
|
+
return {
|
|
755
|
+
pluginName: options.pluginName,
|
|
756
|
+
scope: 'user',
|
|
757
|
+
storeKind: 'user',
|
|
758
|
+
path: filePath,
|
|
759
|
+
existed: true,
|
|
760
|
+
deleted: true,
|
|
761
|
+
resetDisposition: target.isSymbolicLink() ? 'unlinkedSymlink' : 'deletedFile',
|
|
762
|
+
};
|
|
737
763
|
}
|
|
738
|
-
if (
|
|
739
|
-
|
|
764
|
+
if (target.isDirectory()) {
|
|
765
|
+
const timestamp = new Date().toISOString().replace(/[-:]/gu, '').replace(/\..*$/u, '');
|
|
766
|
+
const quarantineBasename = `config.broken-${timestamp}-${crypto.randomUUID()}.json`;
|
|
767
|
+
await assertNoConfigSymlink(allowedRoot, path.dirname(filePath));
|
|
768
|
+
await nodeFs.rename(filePath, path.join(path.dirname(filePath), quarantineBasename));
|
|
769
|
+
return {
|
|
770
|
+
pluginName: options.pluginName,
|
|
771
|
+
scope: 'user',
|
|
772
|
+
storeKind: 'user',
|
|
773
|
+
path: filePath,
|
|
774
|
+
existed: true,
|
|
775
|
+
deleted: true,
|
|
776
|
+
resetDisposition: 'quarantinedDirectory',
|
|
777
|
+
quarantineBasename,
|
|
778
|
+
};
|
|
740
779
|
}
|
|
741
|
-
|
|
780
|
+
throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} is a special filesystem node. Move it manually, then retry config reset.`);
|
|
742
781
|
}
|
|
743
|
-
|
|
744
|
-
if (
|
|
745
|
-
throw
|
|
782
|
+
catch (error) {
|
|
783
|
+
if (error instanceof PluginConfigResetError)
|
|
784
|
+
throw error;
|
|
785
|
+
const osCode = error.code;
|
|
786
|
+
throw new PluginConfigResetError('configResetFailed', `Cannot reset ${publicTarget}${osCode ? ` (${osCode})` : ''}. Fix filesystem access, then retry config reset.`, osCode);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
export async function inspectPluginConfigResetTarget(options) {
|
|
790
|
+
const filePath = resolvePluginConfigStorePath({
|
|
791
|
+
...options,
|
|
792
|
+
...(options.scope === 'project' ? { access: 'write' } : {}),
|
|
793
|
+
});
|
|
794
|
+
const allowedRoot = resolvePluginConfigAllowedRoot(options);
|
|
795
|
+
const publicTarget = `${options.scope}/plugin-config/${[
|
|
796
|
+
options.sourceId,
|
|
797
|
+
options.pluginName,
|
|
798
|
+
CONFIG_FILE,
|
|
799
|
+
].filter(Boolean).join('/')}`;
|
|
800
|
+
const { root, candidate } = assertConfigPathBoundary(allowedRoot, filePath);
|
|
801
|
+
let current = root;
|
|
802
|
+
for (const segment of path.relative(root, path.dirname(candidate)).split(path.sep).filter(Boolean)) {
|
|
803
|
+
const stats = await lstatIfExists(current);
|
|
804
|
+
if (!stats)
|
|
805
|
+
return resetTargetInspection('absent');
|
|
806
|
+
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
807
|
+
throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
|
|
746
808
|
}
|
|
747
|
-
|
|
809
|
+
current = path.join(current, segment);
|
|
748
810
|
}
|
|
749
|
-
|
|
811
|
+
const parentStats = await lstatIfExists(current);
|
|
812
|
+
if (!parentStats)
|
|
813
|
+
return resetTargetInspection('absent');
|
|
814
|
+
if (parentStats.isSymbolicLink() || !parentStats.isDirectory()) {
|
|
815
|
+
throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
|
|
816
|
+
}
|
|
817
|
+
const target = await lstatIfExists(filePath);
|
|
818
|
+
if (!target)
|
|
819
|
+
return resetTargetInspection('absent');
|
|
820
|
+
const kind = target.isSymbolicLink() ? 'symbolicLink'
|
|
821
|
+
: target.isFile() ? 'regularFile'
|
|
822
|
+
: target.isDirectory() ? 'directory'
|
|
823
|
+
: 'special';
|
|
824
|
+
return resetTargetInspection(kind, target);
|
|
825
|
+
}
|
|
826
|
+
function resetTargetInspection(kind, stats) {
|
|
827
|
+
const fingerprint = `sha256:${crypto.createHash('sha256').update(JSON.stringify({
|
|
828
|
+
kind,
|
|
829
|
+
...(stats ? {
|
|
830
|
+
dev: stats.dev,
|
|
831
|
+
ino: stats.ino,
|
|
832
|
+
mode: stats.mode,
|
|
833
|
+
size: stats.size,
|
|
834
|
+
mtimeMs: stats.mtimeMs,
|
|
835
|
+
ctimeMs: stats.ctimeMs,
|
|
836
|
+
} : {}),
|
|
837
|
+
})).digest('hex')}`;
|
|
838
|
+
return {
|
|
839
|
+
exists: kind !== 'absent',
|
|
840
|
+
kind,
|
|
841
|
+
resettable: kind !== 'special',
|
|
842
|
+
fingerprint,
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
export async function resetPluginConfigStores(options) {
|
|
846
|
+
return [await resetPluginConfigStore(options)];
|
|
750
847
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
848
|
+
function coerceConfigValue(key, field, value) {
|
|
849
|
+
let coerced = value;
|
|
850
|
+
if (field.type === 'number' && typeof value === 'string' && value.trim() !== '') {
|
|
851
|
+
coerced = Number(value);
|
|
754
852
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
if (options.field.type === 'file' && !stats.isFile()) {
|
|
762
|
-
throw new Error(`Config "${options.key}" must point to an existing file.`);
|
|
853
|
+
else if (field.type === 'boolean' && typeof value === 'string') {
|
|
854
|
+
const normalized = value.trim().toLowerCase();
|
|
855
|
+
if (['true', '1', 'yes', 'y'].includes(normalized))
|
|
856
|
+
coerced = true;
|
|
857
|
+
if (['false', '0', 'no', 'n'].includes(normalized))
|
|
858
|
+
coerced = false;
|
|
763
859
|
}
|
|
764
|
-
|
|
765
|
-
|
|
860
|
+
const issues = validateCorePluginConfigValue(field, coerced, key);
|
|
861
|
+
if (issues.length > 0) {
|
|
862
|
+
throw new Error(formatPluginConfigIssue(issues[0]));
|
|
766
863
|
}
|
|
767
|
-
return
|
|
864
|
+
return coerced;
|
|
768
865
|
}
|
|
769
866
|
export async function coercePluginConfigValue(options) {
|
|
770
|
-
|
|
771
|
-
if (options.field.type === 'file' || options.field.type === 'directory') {
|
|
772
|
-
return resolvePathConfigValue({
|
|
773
|
-
key: options.key,
|
|
774
|
-
field: options.field,
|
|
775
|
-
value: primitive,
|
|
776
|
-
projectRoot: options.projectRoot,
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
return primitive;
|
|
867
|
+
return coerceConfigValue(options.key, options.field, options.value);
|
|
780
868
|
}
|
|
781
869
|
function redactValue(field, value) {
|
|
782
|
-
return field
|
|
783
|
-
}
|
|
784
|
-
function sourceForStoreLayer(scope, projectLayer = 'shared') {
|
|
785
|
-
if (scope === 'user') {
|
|
786
|
-
return 'user';
|
|
787
|
-
}
|
|
788
|
-
return projectLayer === 'local' ? 'projectLocal' : 'project';
|
|
789
|
-
}
|
|
790
|
-
function isPathTypeField(field) {
|
|
791
|
-
return field.type === 'file' || field.type === 'directory';
|
|
870
|
+
return redactPluginConfigValue(field, value);
|
|
792
871
|
}
|
|
793
872
|
async function applyConfigLayer(options) {
|
|
794
873
|
for (const [key, field] of Object.entries(options.schema)) {
|
|
795
874
|
if (!Object.hasOwn(options.entries, key)) {
|
|
796
875
|
continue;
|
|
797
876
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
});
|
|
805
|
-
options.values[key] = coerced;
|
|
806
|
-
options.redactedValues[key] = redactValue(field, coerced);
|
|
877
|
+
const value = options.entries[key];
|
|
878
|
+
const validationIssues = validateCorePluginConfigValue(field, value, key);
|
|
879
|
+
if (validationIssues.length === 0) {
|
|
880
|
+
const redactedValue = redactValue(field, value);
|
|
881
|
+
options.values[key] = value;
|
|
882
|
+
options.redactedValues[key] = redactedValue;
|
|
807
883
|
options.sources[key] = options.source;
|
|
808
|
-
options.
|
|
884
|
+
options.fieldStates[key] = {
|
|
885
|
+
effective: { value, redactedValue, source: options.source },
|
|
886
|
+
};
|
|
809
887
|
}
|
|
810
|
-
|
|
888
|
+
else {
|
|
889
|
+
const fallback = options.fieldStates[key]?.effective;
|
|
811
890
|
delete options.values[key];
|
|
812
891
|
delete options.redactedValues[key];
|
|
813
892
|
options.sources[key] = options.source;
|
|
814
|
-
|
|
893
|
+
const issues = validationIssues.map((issue) => ({
|
|
815
894
|
type: 'invalid-config',
|
|
816
895
|
key,
|
|
817
896
|
source: options.source,
|
|
818
|
-
message:
|
|
819
|
-
});
|
|
897
|
+
message: formatPluginConfigIssue(issue),
|
|
898
|
+
}));
|
|
899
|
+
options.fieldStates[key] = {
|
|
900
|
+
invalidOverride: { source: options.source, issues },
|
|
901
|
+
...(fallback ? { fallback } : {}),
|
|
902
|
+
};
|
|
820
903
|
}
|
|
821
904
|
}
|
|
822
905
|
}
|
|
823
906
|
export async function resolveEffectivePluginConfig(options) {
|
|
907
|
+
const workContext = options.context ? await resolveWorkContext({ cwd: options.cwd, context: options.context }) : undefined;
|
|
824
908
|
const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.manifest.name);
|
|
825
|
-
const
|
|
909
|
+
const user = await readPluginConfigStore({ ...options, pluginName, scope: 'user' });
|
|
910
|
+
assertReadyPluginConfigStore(user);
|
|
911
|
+
const references = !options.referenceContext && pluginConfigHasExternalReferences(options.manifest)
|
|
912
|
+
? await resolvePluginConfigReferenceContext({ ...options, scope: options.context ?? options.targetScope ?? 'user', plugins: options.referencePlugins }) : undefined;
|
|
913
|
+
return resolveEffectivePluginConfigFromStores({ ...options, pluginName, projectRoot: workContext?.projectRoot ?? ((options.context ?? options.targetScope) === 'project' ? resolveAwProjectRoot(options.cwd) : ''),
|
|
914
|
+
referenceContext: options.referenceContext ?? references?.context, referenceEvidence: references?.evidence,
|
|
915
|
+
stores: { user } });
|
|
916
|
+
}
|
|
917
|
+
export async function resolveEffectivePluginConfigFromStores(options) {
|
|
918
|
+
const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.manifest.name);
|
|
919
|
+
const definition = options.manifest.config ? selectPluginConfigProfile(options.manifest.config, options.platform) : undefined;
|
|
920
|
+
const schema = definition?.fields;
|
|
826
921
|
if (!schema) {
|
|
827
|
-
throw new
|
|
922
|
+
throw new PluginConfigSchemaResolutionError('configSchemaUnavailable', `Plugin "${pluginName}" does not declare an AW config schema.`);
|
|
828
923
|
}
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
readPluginConfigStore({
|
|
832
|
-
sourceId: options.sourceId,
|
|
833
|
-
sourceIdentity: options.sourceIdentity,
|
|
834
|
-
pluginName,
|
|
835
|
-
scope: 'user',
|
|
836
|
-
cwd: options.cwd,
|
|
837
|
-
env: options.env,
|
|
838
|
-
}),
|
|
839
|
-
readPluginConfigStore({
|
|
840
|
-
sourceId: options.sourceId,
|
|
841
|
-
sourceIdentity: options.sourceIdentity,
|
|
842
|
-
pluginName,
|
|
843
|
-
scope: 'project',
|
|
844
|
-
cwd: options.cwd,
|
|
845
|
-
env: options.env,
|
|
846
|
-
}),
|
|
847
|
-
readPluginConfigStore({
|
|
848
|
-
sourceId: options.sourceId,
|
|
849
|
-
sourceIdentity: options.sourceIdentity,
|
|
850
|
-
pluginName,
|
|
851
|
-
scope: 'project',
|
|
852
|
-
cwd: options.cwd,
|
|
853
|
-
env: options.env,
|
|
854
|
-
projectLayer: 'local',
|
|
855
|
-
}),
|
|
856
|
-
]);
|
|
924
|
+
const userStore = options.stores.user;
|
|
925
|
+
assertReadyPluginConfigStore(userStore);
|
|
857
926
|
const values = {};
|
|
858
927
|
const redactedValues = {};
|
|
859
928
|
const sources = {};
|
|
860
|
-
const
|
|
929
|
+
const fieldStates = {};
|
|
861
930
|
const ignoredUnknownKeys = [];
|
|
931
|
+
const unsupportedLayerOverrides = [];
|
|
932
|
+
const dangerousKeyIssues = [];
|
|
862
933
|
const schemaKeys = new Set(Object.keys(schema));
|
|
863
934
|
for (const key of schemaKeys) {
|
|
864
935
|
sources[key] = 'missing';
|
|
@@ -871,43 +942,140 @@ export async function resolveEffectivePluginConfig(options) {
|
|
|
871
942
|
values,
|
|
872
943
|
redactedValues,
|
|
873
944
|
sources,
|
|
874
|
-
|
|
945
|
+
fieldStates,
|
|
875
946
|
schema: { [key]: field },
|
|
876
947
|
entries: { [key]: field.default },
|
|
877
948
|
source: 'default',
|
|
878
|
-
projectRoot,
|
|
879
949
|
});
|
|
880
950
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
[
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
const plainEntries = getStoreEntries(
|
|
951
|
+
const layers = [
|
|
952
|
+
{ entries: userStore.common ?? userStore.values, source: 'common' },
|
|
953
|
+
...(options.platform ? [{ entries: userStore.platforms?.[options.platform] ?? {}, source: 'platform' }] : []),
|
|
954
|
+
];
|
|
955
|
+
for (const { entries, source } of layers) {
|
|
956
|
+
const plainEntries = getStoreEntries(entries);
|
|
957
|
+
const dangerousIssues = new Map(validatePluginConfigDocument(definition, plainEntries)
|
|
958
|
+
.filter((issue) => issue.code === 'dangerousKey').map((issue) => [issue.path.field, issue]));
|
|
887
959
|
for (const key of Object.keys(plainEntries)) {
|
|
888
|
-
if (
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
key,
|
|
894
|
-
|
|
895
|
-
|
|
960
|
+
if (schemaKeys.has(key))
|
|
961
|
+
continue;
|
|
962
|
+
const dangerousIssue = dangerousIssues.get(key);
|
|
963
|
+
if (dangerousIssue)
|
|
964
|
+
dangerousKeyIssues.push({ type: 'invalid-config', code: dangerousIssue.code,
|
|
965
|
+
key, source, message: formatPluginConfigIssue(dangerousIssue) });
|
|
966
|
+
else
|
|
967
|
+
ignoredUnknownKeys.push({ scope: 'user', source, key });
|
|
896
968
|
}
|
|
897
969
|
await applyConfigLayer({
|
|
898
970
|
values,
|
|
899
971
|
redactedValues,
|
|
900
972
|
sources,
|
|
901
|
-
|
|
973
|
+
fieldStates,
|
|
902
974
|
schema,
|
|
903
975
|
entries: plainEntries,
|
|
904
|
-
source
|
|
905
|
-
projectRoot,
|
|
976
|
+
source,
|
|
906
977
|
});
|
|
907
978
|
}
|
|
908
|
-
const
|
|
979
|
+
const candidateValues = {};
|
|
980
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
981
|
+
const source = sources[key];
|
|
982
|
+
if (source === 'default')
|
|
983
|
+
candidateValues[key] = field.default;
|
|
984
|
+
if (source === 'common')
|
|
985
|
+
candidateValues[key] = ownStoreValue(userStore.common ?? userStore.values, key);
|
|
986
|
+
if (source === 'platform' && options.platform)
|
|
987
|
+
candidateValues[key] = ownStoreValue(userStore.platforms?.[options.platform] ?? {}, key);
|
|
988
|
+
}
|
|
989
|
+
const candidateIssues = validatePluginConfigCandidate(definition, candidateValues, undefined, options.referenceContext);
|
|
990
|
+
const referenceIssues = candidateIssues.filter((issue) => issue.code.startsWith('valueRef')
|
|
991
|
+
&& (!issue.path.plugin || issue.path.plugin === pluginName));
|
|
992
|
+
const missingReferenceIssues = [];
|
|
993
|
+
for (const issue of referenceIssues) {
|
|
994
|
+
const key = issue.path.field;
|
|
995
|
+
const source = sources[key];
|
|
996
|
+
const state = fieldStates[key];
|
|
997
|
+
const configIssue = {
|
|
998
|
+
type: 'invalid-config', code: issue.code, key, source,
|
|
999
|
+
message: formatPluginConfigIssue(issue),
|
|
1000
|
+
};
|
|
1001
|
+
if (source === 'missing') {
|
|
1002
|
+
missingReferenceIssues.push(configIssue);
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
delete values[key];
|
|
1006
|
+
delete redactedValues[key];
|
|
1007
|
+
fieldStates[key] = {
|
|
1008
|
+
invalidOverride: { source, issues: [...(state?.invalidOverride?.issues ?? []), configIssue] },
|
|
1009
|
+
...(state?.fallback ? { fallback: state.fallback } : {}),
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
// Provider errors stay private, while each field that reads them remains unusable.
|
|
1013
|
+
if (options.referenceContext) {
|
|
1014
|
+
for (const foreign of candidateIssues.filter((issue) => issue.code.startsWith('valueRef')
|
|
1015
|
+
&& issue.path.plugin && issue.path.plugin !== pluginName)) {
|
|
1016
|
+
for (const key of schemaKeys) {
|
|
1017
|
+
let dependencies;
|
|
1018
|
+
try {
|
|
1019
|
+
dependencies = getPluginConfigDependencyFields(definition, [key], options.referenceContext);
|
|
1020
|
+
}
|
|
1021
|
+
catch {
|
|
1022
|
+
continue; // The local association issue already reports the invalid schema.
|
|
1023
|
+
}
|
|
1024
|
+
if (!dependencies.some((entry) => entry.plugin === foreign.path.plugin && entry.field === foreign.path.field))
|
|
1025
|
+
continue;
|
|
1026
|
+
const source = sources[key];
|
|
1027
|
+
const state = fieldStates[key];
|
|
1028
|
+
const configIssue = { type: 'invalid-config', code: 'valueRefSource', key, source,
|
|
1029
|
+
message: `Config "${key}" depends on invalid config "${foreign.path.plugin}/${foreign.path.field}". Fix the dependency before using this field.` };
|
|
1030
|
+
if (state?.invalidOverride?.issues.some((issue) => issue.code === configIssue.code && issue.message === configIssue.message))
|
|
1031
|
+
continue;
|
|
1032
|
+
delete values[key];
|
|
1033
|
+
delete redactedValues[key];
|
|
1034
|
+
if (source === 'missing')
|
|
1035
|
+
missingReferenceIssues.push(configIssue);
|
|
1036
|
+
else
|
|
1037
|
+
fieldStates[key] = { invalidOverride: { source, issues: [...(state?.invalidOverride?.issues ?? []), configIssue] },
|
|
1038
|
+
...(state?.fallback ? { fallback: state.fallback } : {}) };
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
// Consumers must retain dependency failures after invalid source values are omitted.
|
|
1043
|
+
const invalidKeys = new Set([
|
|
1044
|
+
...Object.entries(fieldStates).filter(([, state]) => state.invalidOverride !== undefined).map(([key]) => key),
|
|
1045
|
+
...missingReferenceIssues.map((issue) => issue.key),
|
|
1046
|
+
]);
|
|
1047
|
+
for (const key of schemaKeys) {
|
|
1048
|
+
if (invalidKeys.has(key))
|
|
1049
|
+
continue;
|
|
1050
|
+
const dependency = getPluginConfigDependencyKeys(definition, [key])
|
|
1051
|
+
.find((dependencyKey) => dependencyKey !== key && invalidKeys.has(dependencyKey));
|
|
1052
|
+
if (dependency === undefined)
|
|
1053
|
+
continue;
|
|
1054
|
+
const source = sources[key];
|
|
1055
|
+
const configIssue = {
|
|
1056
|
+
type: 'invalid-config', code: 'valueRefSource', key, source,
|
|
1057
|
+
message: `Config "${key}" depends on invalid config "${dependency}". Fix the dependency before using this field.`,
|
|
1058
|
+
};
|
|
1059
|
+
delete values[key];
|
|
1060
|
+
delete redactedValues[key];
|
|
1061
|
+
if (source === 'missing') {
|
|
1062
|
+
missingReferenceIssues.push(configIssue);
|
|
1063
|
+
}
|
|
1064
|
+
else {
|
|
1065
|
+
const state = fieldStates[key];
|
|
1066
|
+
fieldStates[key] = {
|
|
1067
|
+
invalidOverride: { source, issues: [configIssue] },
|
|
1068
|
+
...(state?.fallback ? { fallback: state.fallback } : {}),
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
const issues = [
|
|
1073
|
+
...Object.values(fieldStates).flatMap((state) => state.invalidOverride?.issues ?? []),
|
|
1074
|
+
...dangerousKeyIssues,
|
|
1075
|
+
...missingReferenceIssues,
|
|
1076
|
+
];
|
|
909
1077
|
for (const [key, field] of Object.entries(schema)) {
|
|
910
|
-
if (field.required && values[key] === undefined) {
|
|
1078
|
+
if (field.required && values[key] === undefined && !fieldStates[key]?.invalidOverride) {
|
|
911
1079
|
issues.push({
|
|
912
1080
|
type: 'missing-required',
|
|
913
1081
|
key,
|
|
@@ -918,650 +1086,204 @@ export async function resolveEffectivePluginConfig(options) {
|
|
|
918
1086
|
}
|
|
919
1087
|
return {
|
|
920
1088
|
pluginName,
|
|
921
|
-
|
|
1089
|
+
platform: options.platform,
|
|
1090
|
+
context: options.context ?? options.targetScope ?? 'user',
|
|
1091
|
+
definition: definition,
|
|
1092
|
+
projectRoot: options.projectRoot,
|
|
922
1093
|
values,
|
|
923
1094
|
redactedValues,
|
|
924
1095
|
sources,
|
|
1096
|
+
fieldStates,
|
|
925
1097
|
issues,
|
|
1098
|
+
unsupportedLayerOverrides,
|
|
926
1099
|
ignoredUnknownKeys,
|
|
927
1100
|
schema,
|
|
928
1101
|
stores: {
|
|
929
1102
|
user: userStore,
|
|
930
|
-
project: projectStore,
|
|
931
|
-
projectLocal: projectLocalStore,
|
|
932
1103
|
},
|
|
1104
|
+
...(options.referenceContext ? { referenceContext: options.referenceContext } : {}),
|
|
1105
|
+
...(options.referenceEvidence ? { referenceEvidence: options.referenceEvidence } : {}),
|
|
933
1106
|
};
|
|
934
1107
|
}
|
|
1108
|
+
function ownStoreValue(values, key) {
|
|
1109
|
+
return Object.hasOwn(values, key) ? values[key] : undefined;
|
|
1110
|
+
}
|
|
1111
|
+
/** Check cross-field relations before saving one complete layer candidate. */
|
|
1112
|
+
export async function assertPluginConfigMutationCandidate(options) {
|
|
1113
|
+
const user = await readPluginConfigStore({ ...options, scope: 'user' });
|
|
1114
|
+
assertReadyPluginConfigStore(user);
|
|
1115
|
+
const values = { ...user.values };
|
|
1116
|
+
for (const key of options.removeKeys)
|
|
1117
|
+
delete values[key];
|
|
1118
|
+
for (const [key, value] of Object.entries(options.updates))
|
|
1119
|
+
values[key] = value;
|
|
1120
|
+
const candidate = replacePluginConfigStoreLayer(user, values, options.platform);
|
|
1121
|
+
const profiles = options.platform ? [options.platform] : [undefined, ...PLATFORM_TARGETS];
|
|
1122
|
+
for (const platform of profiles) {
|
|
1123
|
+
const references = pluginConfigHasExternalReferences(options.manifest)
|
|
1124
|
+
? await resolvePluginConfigReferenceContext({ ...options, platform, plugins: options.referencePlugins }) : undefined;
|
|
1125
|
+
const resolve = (store) => resolveEffectivePluginConfigFromStores({ ...options, platform,
|
|
1126
|
+
targetScope: options.scope, projectRoot: options.scope === 'project' ? resolveAwProjectRoot(options.cwd) : '', stores: { user: store }, referenceContext: references?.context });
|
|
1127
|
+
const [before, after] = await Promise.all([resolve(user), resolve(candidate)]);
|
|
1128
|
+
const existing = new Set(before.issues.map((issue) => `${issue.key}\0${issue.code}\0${issue.message}`));
|
|
1129
|
+
const editedKeys = new Set([...Object.keys(options.updates), ...options.removeKeys]);
|
|
1130
|
+
const issues = after.issues.filter((issue) => (editedKeys.has(issue.key) && Object.hasOwn(options.updates, issue.key))
|
|
1131
|
+
|| !existing.has(`${issue.key}\0${issue.code}\0${issue.message}`));
|
|
1132
|
+
if (issues.length)
|
|
1133
|
+
throw Object.assign(new Error(`configReferenceInvalid: ${platform ?? 'common'}: ${issues.map((issue) => issue.message).join(' ')}`), { code: 'configReferenceInvalid' });
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
935
1136
|
export async function coercePluginConfigUpdates(options) {
|
|
936
|
-
const projectRoot = resolveAwProjectRoot(options.cwd);
|
|
937
1137
|
const output = {};
|
|
938
1138
|
for (const [key, value] of Object.entries(options.updates)) {
|
|
939
1139
|
const field = options.schema[key];
|
|
940
1140
|
if (!field) {
|
|
941
1141
|
throw new Error(`Unknown config key "${key}".`);
|
|
942
1142
|
}
|
|
943
|
-
|
|
1143
|
+
const coerced = await coercePluginConfigValue({
|
|
944
1144
|
key,
|
|
945
1145
|
field,
|
|
946
1146
|
value,
|
|
947
|
-
projectRoot,
|
|
948
1147
|
});
|
|
1148
|
+
output[key] = coerced;
|
|
949
1149
|
}
|
|
950
1150
|
return output;
|
|
951
1151
|
}
|
|
952
|
-
function createProjectArtifactBoundaryIssue(options) {
|
|
953
|
-
if (options.reason === 'pathTypeDefault') {
|
|
954
|
-
return {
|
|
955
|
-
key: options.key,
|
|
956
|
-
source: options.source,
|
|
957
|
-
reason: options.reason,
|
|
958
|
-
message: `Config "${options.key}" uses file/directory default value, ` +
|
|
959
|
-
'which cannot participate in repo-visible project artifact truth.',
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
if (options.reason === 'pathTypeRequired') {
|
|
963
|
-
return {
|
|
964
|
-
key: options.key,
|
|
965
|
-
source: options.source,
|
|
966
|
-
reason: options.reason,
|
|
967
|
-
message: `Config "${options.key}" is a required file/directory key, ` +
|
|
968
|
-
'which is not portable enough for repo-visible project artifacts.',
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
if (options.reason === 'sharedPathValue') {
|
|
972
|
-
return {
|
|
973
|
-
key: options.key,
|
|
974
|
-
source: options.source,
|
|
975
|
-
reason: options.reason,
|
|
976
|
-
message: `Config "${options.key}" is stored in project shared config as a file/directory path. ` +
|
|
977
|
-
'Use user or project local config for machine-local paths.',
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
return {
|
|
981
|
-
key: options.key,
|
|
982
|
-
source: options.source,
|
|
983
|
-
reason: options.reason,
|
|
984
|
-
message: `Config "${options.key}" is declared as a refresh key for repo-visible project artifacts, ` +
|
|
985
|
-
'but file/directory config is machine-local and cannot drive shared artifact refresh.',
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
export function collectProjectArtifactConfigBoundaryIssues(options) {
|
|
989
|
-
const issues = [];
|
|
990
|
-
const refreshKeySet = new Set(options.refreshKeys ?? []);
|
|
991
|
-
for (const [key, field] of Object.entries(options.schema)) {
|
|
992
|
-
if (!isPathTypeField(field)) {
|
|
993
|
-
continue;
|
|
994
|
-
}
|
|
995
|
-
if (field.default !== undefined) {
|
|
996
|
-
issues.push(createProjectArtifactBoundaryIssue({
|
|
997
|
-
key,
|
|
998
|
-
source: 'default',
|
|
999
|
-
reason: 'pathTypeDefault',
|
|
1000
|
-
}));
|
|
1001
|
-
}
|
|
1002
|
-
if (field.required) {
|
|
1003
|
-
issues.push(createProjectArtifactBoundaryIssue({
|
|
1004
|
-
key,
|
|
1005
|
-
source: 'missing',
|
|
1006
|
-
reason: 'pathTypeRequired',
|
|
1007
|
-
}));
|
|
1008
|
-
}
|
|
1009
|
-
if (options.sharedEntries && Object.hasOwn(options.sharedEntries, key)) {
|
|
1010
|
-
issues.push(createProjectArtifactBoundaryIssue({
|
|
1011
|
-
key,
|
|
1012
|
-
source: 'project',
|
|
1013
|
-
reason: 'sharedPathValue',
|
|
1014
|
-
}));
|
|
1015
|
-
}
|
|
1016
|
-
if (refreshKeySet.has(key)) {
|
|
1017
|
-
issues.push(createProjectArtifactBoundaryIssue({
|
|
1018
|
-
key,
|
|
1019
|
-
source: 'project',
|
|
1020
|
-
reason: 'pathTypeRefreshKey',
|
|
1021
|
-
}));
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
return issues;
|
|
1025
|
-
}
|
|
1026
1152
|
export async function resolveProjectArtifactRenderConfig(options) {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
sourceIdentity: options.sourceIdentity,
|
|
1042
|
-
pluginName,
|
|
1043
|
-
scope: 'project',
|
|
1044
|
-
cwd: options.cwd,
|
|
1045
|
-
env: options.env,
|
|
1046
|
-
}),
|
|
1047
|
-
readPluginConfigStore({
|
|
1048
|
-
sourceId: options.sourceId,
|
|
1049
|
-
sourceIdentity: options.sourceIdentity,
|
|
1050
|
-
pluginName,
|
|
1051
|
-
scope: 'project',
|
|
1052
|
-
cwd: options.cwd,
|
|
1053
|
-
env: options.env,
|
|
1054
|
-
projectLayer: 'local',
|
|
1055
|
-
}),
|
|
1056
|
-
]);
|
|
1057
|
-
if (!schema) {
|
|
1153
|
+
if (!options.manifest.config?.fields) {
|
|
1154
|
+
const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.manifest.name);
|
|
1155
|
+
const [userStore] = await Promise.all([
|
|
1156
|
+
readPluginConfigStore({
|
|
1157
|
+
sourceId: options.sourceId,
|
|
1158
|
+
sourceIdentity: options.sourceIdentity,
|
|
1159
|
+
logicalIdentity: options.logicalIdentity,
|
|
1160
|
+
pluginName,
|
|
1161
|
+
scope: 'user',
|
|
1162
|
+
cwd: options.cwd,
|
|
1163
|
+
env: options.env,
|
|
1164
|
+
}),
|
|
1165
|
+
]);
|
|
1166
|
+
assertReadyPluginConfigStore(userStore);
|
|
1058
1167
|
return {
|
|
1059
1168
|
pluginName,
|
|
1060
|
-
projectRoot,
|
|
1169
|
+
projectRoot: resolveAwProjectRoot(options.cwd),
|
|
1061
1170
|
values: {},
|
|
1062
1171
|
sources: {},
|
|
1063
1172
|
issues: [],
|
|
1173
|
+
unsupportedLayerOverrides: [],
|
|
1064
1174
|
ignoredUnknownKeys: [],
|
|
1065
|
-
boundaryIssues: [],
|
|
1066
1175
|
schema: {},
|
|
1067
|
-
stores: {
|
|
1068
|
-
user: userStore,
|
|
1069
|
-
project: projectStore,
|
|
1070
|
-
projectLocal: projectLocalStore,
|
|
1071
|
-
},
|
|
1176
|
+
stores: { user: userStore },
|
|
1072
1177
|
};
|
|
1073
1178
|
}
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
const ignoredUnknownKeys = [];
|
|
1078
|
-
const schemaKeys = new Set(Object.keys(schema));
|
|
1079
|
-
const boundaryIssues = collectProjectArtifactConfigBoundaryIssues({
|
|
1080
|
-
schema,
|
|
1081
|
-
sharedEntries: projectStore.values,
|
|
1082
|
-
refreshKeys: options.refreshKeys,
|
|
1083
|
-
});
|
|
1084
|
-
for (const key of Object.keys(schema)) {
|
|
1085
|
-
sources[key] = 'missing';
|
|
1086
|
-
}
|
|
1087
|
-
const projectPlainEntries = getStoreEntries(projectStore.values);
|
|
1088
|
-
const userPlainEntries = getStoreEntries(userStore.values);
|
|
1089
|
-
const projectLocalPlainEntries = getStoreEntries(projectLocalStore.values);
|
|
1090
|
-
for (const key of Object.keys(projectPlainEntries)) {
|
|
1091
|
-
if (!schemaKeys.has(key)) {
|
|
1092
|
-
ignoredUnknownKeys.push({ scope: 'project', projectLayer: 'shared', source: 'project', key });
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
for (const key of Object.keys(userPlainEntries)) {
|
|
1096
|
-
if (!schemaKeys.has(key)) {
|
|
1097
|
-
ignoredUnknownKeys.push({ scope: 'user', projectLayer: 'shared', source: 'user', key });
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
for (const key of Object.keys(projectLocalPlainEntries)) {
|
|
1101
|
-
if (!schemaKeys.has(key)) {
|
|
1102
|
-
ignoredUnknownKeys.push({ scope: 'project', projectLayer: 'local', source: 'projectLocal', key });
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
for (const [key, field] of Object.entries(schema)) {
|
|
1106
|
-
if (!isPathTypeField(field) && field.default !== undefined) {
|
|
1107
|
-
await applyConfigLayer({
|
|
1108
|
-
values,
|
|
1109
|
-
redactedValues: {},
|
|
1110
|
-
sources,
|
|
1111
|
-
invalidIssues,
|
|
1112
|
-
schema: { [key]: field },
|
|
1113
|
-
entries: { [key]: field.default },
|
|
1114
|
-
source: 'default',
|
|
1115
|
-
projectRoot,
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
const sharedSchema = Object.fromEntries(Object.entries(schema).filter(([, field]) => !isPathTypeField(field)));
|
|
1120
|
-
await applyConfigLayer({
|
|
1121
|
-
values,
|
|
1122
|
-
redactedValues: {},
|
|
1123
|
-
sources,
|
|
1124
|
-
invalidIssues,
|
|
1125
|
-
schema: sharedSchema,
|
|
1126
|
-
entries: projectPlainEntries,
|
|
1127
|
-
source: 'project',
|
|
1128
|
-
projectRoot,
|
|
1179
|
+
const effective = await resolveEffectivePluginConfig({
|
|
1180
|
+
...options,
|
|
1181
|
+
targetScope: 'project',
|
|
1129
1182
|
});
|
|
1130
|
-
const issues = [
|
|
1131
|
-
...invalidIssues.values(),
|
|
1132
|
-
...boundaryIssues.map((issue) => ({
|
|
1133
|
-
type: 'invalid-config',
|
|
1134
|
-
key: issue.key,
|
|
1135
|
-
source: issue.source,
|
|
1136
|
-
message: issue.message,
|
|
1137
|
-
})),
|
|
1138
|
-
];
|
|
1139
|
-
for (const [key, field] of Object.entries(schema)) {
|
|
1140
|
-
if (isPathTypeField(field)) {
|
|
1141
|
-
continue;
|
|
1142
|
-
}
|
|
1143
|
-
if (field.required && values[key] === undefined) {
|
|
1144
|
-
issues.push({
|
|
1145
|
-
type: 'missing-required',
|
|
1146
|
-
key,
|
|
1147
|
-
source: sources[key],
|
|
1148
|
-
message: `Config "${key}" is required.`,
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
return {
|
|
1153
|
-
pluginName,
|
|
1154
|
-
projectRoot,
|
|
1155
|
-
values,
|
|
1156
|
-
sources,
|
|
1157
|
-
issues,
|
|
1158
|
-
ignoredUnknownKeys,
|
|
1159
|
-
boundaryIssues,
|
|
1160
|
-
schema,
|
|
1161
|
-
stores: {
|
|
1162
|
-
user: userStore,
|
|
1163
|
-
project: projectStore,
|
|
1164
|
-
projectLocal: projectLocalStore,
|
|
1165
|
-
},
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
export async function resolveProjectLocalPluginConfigView(options) {
|
|
1169
|
-
const effective = await resolveEffectivePluginConfig(options);
|
|
1170
|
-
const artifactConfig = await resolveProjectArtifactRenderConfig(options);
|
|
1171
|
-
const values = {};
|
|
1172
|
-
const redactedValues = {};
|
|
1173
|
-
const sources = {};
|
|
1174
|
-
const issues = [];
|
|
1175
|
-
for (const [key, field] of Object.entries(effective.schema)) {
|
|
1176
|
-
sources[key] = 'missing';
|
|
1177
|
-
const localPlainEntries = getStoreEntries(effective.stores.projectLocal.values);
|
|
1178
|
-
if (!Object.hasOwn(localPlainEntries, key)) {
|
|
1179
|
-
continue;
|
|
1180
|
-
}
|
|
1181
|
-
sources[key] = 'projectLocal';
|
|
1182
|
-
try {
|
|
1183
|
-
const coerced = await coercePluginConfigValue({
|
|
1184
|
-
key,
|
|
1185
|
-
field,
|
|
1186
|
-
value: localPlainEntries[key],
|
|
1187
|
-
projectRoot: effective.projectRoot,
|
|
1188
|
-
});
|
|
1189
|
-
values[key] = coerced;
|
|
1190
|
-
redactedValues[key] = redactValue(field, coerced);
|
|
1191
|
-
}
|
|
1192
|
-
catch (error) {
|
|
1193
|
-
issues.push({
|
|
1194
|
-
type: 'invalid-config',
|
|
1195
|
-
key,
|
|
1196
|
-
source: 'projectLocal',
|
|
1197
|
-
message: error instanceof Error ? error.message : String(error),
|
|
1198
|
-
});
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
return {
|
|
1202
|
-
pluginName: effective.pluginName,
|
|
1203
|
-
projectRoot: effective.projectRoot,
|
|
1204
|
-
schema: effective.schema,
|
|
1205
|
-
localStore: effective.stores.projectLocal,
|
|
1206
|
-
values,
|
|
1207
|
-
redactedValues,
|
|
1208
|
-
sources,
|
|
1209
|
-
issues,
|
|
1210
|
-
ignoredUnknownKeys: effective.ignoredUnknownKeys.filter((entry) => entry.source === 'projectLocal'),
|
|
1211
|
-
repoVisibleArtifactConfig: {
|
|
1212
|
-
values: artifactConfig.values,
|
|
1213
|
-
sources: artifactConfig.sources,
|
|
1214
|
-
issues: artifactConfig.issues,
|
|
1215
|
-
boundaryIssues: artifactConfig.boundaryIssues,
|
|
1216
|
-
},
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
async function resolveRedactedLayerValue(options) {
|
|
1220
|
-
try {
|
|
1221
|
-
const coerced = await coercePluginConfigValue({
|
|
1222
|
-
key: options.key,
|
|
1223
|
-
field: options.field,
|
|
1224
|
-
value: options.value,
|
|
1225
|
-
projectRoot: options.projectRoot,
|
|
1226
|
-
});
|
|
1227
|
-
return {
|
|
1228
|
-
value: redactValue(options.field, coerced),
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
catch (error) {
|
|
1232
|
-
return {
|
|
1233
|
-
issue: {
|
|
1234
|
-
type: 'invalid-config',
|
|
1235
|
-
key: options.key,
|
|
1236
|
-
source: options.source,
|
|
1237
|
-
message: error instanceof Error ? error.message : String(error),
|
|
1238
|
-
},
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
export async function resolveProjectScopedPluginConfigView(options) {
|
|
1243
|
-
const effective = await resolveEffectivePluginConfig(options);
|
|
1244
|
-
const artifactConfig = await resolveProjectArtifactRenderConfig(options);
|
|
1245
|
-
const entries = {};
|
|
1246
|
-
for (const [key, field] of Object.entries(effective.schema)) {
|
|
1247
|
-
const entry = {
|
|
1248
|
-
key,
|
|
1249
|
-
effectiveValue: effective.redactedValues[key],
|
|
1250
|
-
effectiveSource: effective.sources[key] ?? 'missing',
|
|
1251
|
-
repoVisibleArtifactValue: artifactConfig.values[key] === undefined
|
|
1252
|
-
? undefined
|
|
1253
|
-
: redactValue(field, artifactConfig.values[key]),
|
|
1254
|
-
repoVisibleArtifactSource: artifactConfig.sources[key] ?? 'missing',
|
|
1255
|
-
repoVisibleArtifactUsesSharedTruth: true,
|
|
1256
|
-
};
|
|
1257
|
-
if (field.default !== undefined) {
|
|
1258
|
-
const resolvedDefault = await resolveRedactedLayerValue({
|
|
1259
|
-
key,
|
|
1260
|
-
field,
|
|
1261
|
-
projectRoot: effective.projectRoot,
|
|
1262
|
-
source: 'default',
|
|
1263
|
-
value: field.default,
|
|
1264
|
-
});
|
|
1265
|
-
if (resolvedDefault.value !== undefined) {
|
|
1266
|
-
entry.defaultValue = resolvedDefault.value;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
const userPlainEntries = getStoreEntries(effective.stores.user.values);
|
|
1270
|
-
if (Object.hasOwn(userPlainEntries, key)) {
|
|
1271
|
-
const resolvedUser = await resolveRedactedLayerValue({
|
|
1272
|
-
key,
|
|
1273
|
-
field,
|
|
1274
|
-
projectRoot: effective.projectRoot,
|
|
1275
|
-
source: 'user',
|
|
1276
|
-
value: userPlainEntries[key],
|
|
1277
|
-
});
|
|
1278
|
-
if (resolvedUser.value !== undefined) {
|
|
1279
|
-
entry.userValue = resolvedUser.value;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
const projectPlainEntries = getStoreEntries(effective.stores.project.values);
|
|
1283
|
-
if (Object.hasOwn(projectPlainEntries, key)) {
|
|
1284
|
-
const resolvedProject = await resolveRedactedLayerValue({
|
|
1285
|
-
key,
|
|
1286
|
-
field,
|
|
1287
|
-
projectRoot: effective.projectRoot,
|
|
1288
|
-
source: 'project',
|
|
1289
|
-
value: projectPlainEntries[key],
|
|
1290
|
-
});
|
|
1291
|
-
if (resolvedProject.value !== undefined) {
|
|
1292
|
-
entry.projectSharedValue = resolvedProject.value;
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
const localPlainEntries = getStoreEntries(effective.stores.projectLocal.values);
|
|
1296
|
-
if (Object.hasOwn(localPlainEntries, key)) {
|
|
1297
|
-
const resolvedLocal = await resolveRedactedLayerValue({
|
|
1298
|
-
key,
|
|
1299
|
-
field,
|
|
1300
|
-
projectRoot: effective.projectRoot,
|
|
1301
|
-
source: 'projectLocal',
|
|
1302
|
-
value: localPlainEntries[key],
|
|
1303
|
-
});
|
|
1304
|
-
if (resolvedLocal.value !== undefined) {
|
|
1305
|
-
entry.projectLocalValue = resolvedLocal.value;
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
entries[key] = entry;
|
|
1309
|
-
}
|
|
1310
1183
|
return {
|
|
1311
1184
|
pluginName: effective.pluginName,
|
|
1312
1185
|
projectRoot: effective.projectRoot,
|
|
1313
|
-
|
|
1314
|
-
stores: effective.stores,
|
|
1315
|
-
redactedValues: effective.redactedValues,
|
|
1186
|
+
values: effective.values,
|
|
1316
1187
|
sources: effective.sources,
|
|
1317
|
-
entries,
|
|
1318
1188
|
issues: effective.issues,
|
|
1189
|
+
unsupportedLayerOverrides: effective.unsupportedLayerOverrides,
|
|
1319
1190
|
ignoredUnknownKeys: effective.ignoredUnknownKeys,
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
issues: artifactConfig.issues,
|
|
1324
|
-
boundaryIssues: artifactConfig.boundaryIssues,
|
|
1191
|
+
schema: effective.schema,
|
|
1192
|
+
stores: {
|
|
1193
|
+
user: effective.stores.user,
|
|
1325
1194
|
},
|
|
1326
1195
|
};
|
|
1327
1196
|
}
|
|
1328
1197
|
function toConfigSourceLayer(source) {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1198
|
+
return source === undefined || source === 'missing' ? null : source;
|
|
1199
|
+
}
|
|
1200
|
+
function configFieldProjection(options) {
|
|
1201
|
+
const source = options.source ?? 'missing';
|
|
1202
|
+
const issues = options.issues ?? [];
|
|
1203
|
+
const presetSensitive = options.field.sensitive === true
|
|
1204
|
+
|| (options.field.type === 'object'
|
|
1205
|
+
&& (Object.values(options.field.properties ?? {}).some((child) => child.sensitive === true)
|
|
1206
|
+
|| (options.field.additionalProperties !== false
|
|
1207
|
+
&& options.field.additionalProperties?.sensitive === true)));
|
|
1208
|
+
return {
|
|
1209
|
+
value: options.value === undefined ? null : redactValue(options.field, options.value),
|
|
1210
|
+
source,
|
|
1211
|
+
matchedPreset: options.value === undefined || presetSensitive
|
|
1212
|
+
? null
|
|
1213
|
+
: matchPluginConfigPreset(options.field, options.value)?.id ?? null,
|
|
1214
|
+
valid: issues.length === 0,
|
|
1215
|
+
issues,
|
|
1216
|
+
};
|
|
1342
1217
|
}
|
|
1343
1218
|
async function buildManifestFieldEntries(options) {
|
|
1344
|
-
const schema = options.plugin.manifest.config?.schema;
|
|
1345
|
-
if (!schema) {
|
|
1346
|
-
return [];
|
|
1347
|
-
}
|
|
1348
|
-
const projectRoot = resolveAwProjectRoot(options.cwd);
|
|
1349
|
-
const [userStore, projectStore, projectLocalStore] = await Promise.all([
|
|
1350
|
-
readPluginConfigStore({
|
|
1351
|
-
sourceId: options.plugin.sourceId,
|
|
1352
|
-
sourceIdentity: options.plugin.sourceIdentity,
|
|
1353
|
-
pluginName: options.plugin.manifest.name,
|
|
1354
|
-
scope: 'user',
|
|
1355
|
-
cwd: options.cwd,
|
|
1356
|
-
env: options.env,
|
|
1357
|
-
}),
|
|
1358
|
-
readPluginConfigStore({
|
|
1359
|
-
sourceId: options.plugin.sourceId,
|
|
1360
|
-
sourceIdentity: options.plugin.sourceIdentity,
|
|
1361
|
-
pluginName: options.plugin.manifest.name,
|
|
1362
|
-
scope: 'project',
|
|
1363
|
-
projectLayer: 'shared',
|
|
1364
|
-
cwd: options.cwd,
|
|
1365
|
-
env: options.env,
|
|
1366
|
-
}),
|
|
1367
|
-
readPluginConfigStore({
|
|
1368
|
-
sourceId: options.plugin.sourceId,
|
|
1369
|
-
sourceIdentity: options.plugin.sourceIdentity,
|
|
1370
|
-
pluginName: options.plugin.manifest.name,
|
|
1371
|
-
scope: 'project',
|
|
1372
|
-
projectLayer: 'local',
|
|
1373
|
-
cwd: options.cwd,
|
|
1374
|
-
env: options.env,
|
|
1375
|
-
}),
|
|
1376
|
-
]);
|
|
1377
|
-
const userPlainEntries = getStoreEntries(userStore.values);
|
|
1378
|
-
const projectPlainEntries = getStoreEntries(projectStore.values);
|
|
1379
|
-
const localPlainEntries = getStoreEntries(projectLocalStore.values);
|
|
1380
1219
|
const effective = await resolveEffectivePluginConfig({
|
|
1381
1220
|
sourceId: options.plugin.sourceId,
|
|
1382
1221
|
sourceIdentity: options.plugin.sourceIdentity,
|
|
1383
|
-
|
|
1222
|
+
logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
1384
1223
|
manifest: options.plugin.manifest,
|
|
1224
|
+
platform: options.platform,
|
|
1225
|
+
targetScope: options.context ?? (options.scope === 'project' ? 'project' : 'user'),
|
|
1385
1226
|
cwd: options.cwd,
|
|
1386
1227
|
env: options.env,
|
|
1387
1228
|
});
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1390
|
-
const
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
-
|
|
1229
|
+
const stored = pluginConfigStoreForProfile(effective.stores.user, options.platform).values;
|
|
1230
|
+
const fields = await Promise.all(Object.entries(effective.schema).map(async ([key, field]) => {
|
|
1231
|
+
const state = effective.fieldStates[key];
|
|
1232
|
+
const source = effective.sources[key] ?? 'missing';
|
|
1233
|
+
const issues = effective.issues.filter((issue) => issue.key === key);
|
|
1234
|
+
const hasStored = Object.hasOwn(stored, key);
|
|
1235
|
+
const storedSourceLayer = options.platform ? 'platform' : 'common';
|
|
1236
|
+
let fallback;
|
|
1237
|
+
if (hasStored) {
|
|
1238
|
+
const inherited = { ...stored };
|
|
1239
|
+
delete inherited[key];
|
|
1240
|
+
const withoutOverride = await resolveEffectivePluginConfigFromStores({
|
|
1241
|
+
manifest: options.plugin.manifest,
|
|
1242
|
+
platform: options.platform,
|
|
1243
|
+
projectRoot: effective.projectRoot,
|
|
1244
|
+
stores: { user: replacePluginConfigStoreLayer(effective.stores.user, inherited, options.platform) },
|
|
1245
|
+
referenceContext: effective.referenceContext,
|
|
1246
|
+
});
|
|
1247
|
+
const fallbackIssues = withoutOverride.issues.filter((issue) => issue.key === key);
|
|
1248
|
+
const fallbackSource = withoutOverride.sources[key];
|
|
1249
|
+
fallback = fallbackSource === 'missing' || fallbackSource === undefined
|
|
1250
|
+
? { state: 'missing' }
|
|
1251
|
+
: fallbackIssues.length
|
|
1252
|
+
? { state: 'invalid', sourceLayer: fallbackSource, issues: fallbackIssues }
|
|
1253
|
+
: { state: 'valid', sourceLayer: fallbackSource, effectiveValue: withoutOverride.redactedValues[key] };
|
|
1394
1254
|
}
|
|
1395
|
-
const issue = effective.issues.find((entry) => entry.key === key && entry.source === source);
|
|
1396
1255
|
return {
|
|
1397
|
-
valueState: issue ? 'invalid' : source === 'default' ? 'default' : 'configured',
|
|
1398
|
-
effectiveValue: issue
|
|
1399
|
-
? null
|
|
1400
|
-
: isPathTypeField(field) && effective.redactedValues[key] !== undefined
|
|
1401
|
-
? '[redacted]'
|
|
1402
|
-
: effective.redactedValues[key] ?? null,
|
|
1403
|
-
sourceLayer,
|
|
1404
|
-
};
|
|
1405
|
-
};
|
|
1406
|
-
const fields = [];
|
|
1407
|
-
for (const [key, field] of Object.entries(schema)) {
|
|
1408
|
-
const base = {
|
|
1409
1256
|
key,
|
|
1410
1257
|
title: field.title ?? key,
|
|
1411
1258
|
kind: 'manifest',
|
|
1412
1259
|
reserved: false,
|
|
1413
1260
|
writable: true,
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1261
|
+
canSet: true,
|
|
1262
|
+
canUnset: hasStored,
|
|
1263
|
+
valueState: issues.length ? 'invalid' : source === 'default' || source === 'missing' ? 'default' : 'configured',
|
|
1264
|
+
effectiveValue: effective.redactedValues[key] ?? null,
|
|
1265
|
+
sourceLayer: toConfigSourceLayer(source),
|
|
1266
|
+
...(hasStored ? { storedSourceLayer, ...(validateCorePluginConfigValue(field, stored[key], key).length
|
|
1267
|
+
? {} : { storedValue: redactValue(field, stored[key]) }) } : {}),
|
|
1268
|
+
...(state?.invalidOverride ? { invalidOverride: { sourceLayer: state.invalidOverride.source, issues: state.invalidOverride.issues } } : {}),
|
|
1269
|
+
...(fallback ? { fallback } : {}),
|
|
1270
|
+
...configFieldProjection({ field, value: effective.values[key], source, issues }),
|
|
1417
1271
|
};
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
value: userPlainEntries[key],
|
|
1425
|
-
projectRoot,
|
|
1426
|
-
});
|
|
1427
|
-
fields.push({
|
|
1428
|
-
...base,
|
|
1429
|
-
valueState: 'configured',
|
|
1430
|
-
effectiveValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
|
|
1431
|
-
sourceLayer: 'user',
|
|
1432
|
-
storedValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
|
|
1433
|
-
storedSourceLayer: 'user',
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
catch {
|
|
1437
|
-
fields.push({
|
|
1438
|
-
...base,
|
|
1439
|
-
valueState: 'invalid',
|
|
1440
|
-
sourceLayer: 'user',
|
|
1441
|
-
storedSourceLayer: 'user',
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
continue;
|
|
1445
|
-
}
|
|
1446
|
-
if (field.default !== undefined) {
|
|
1447
|
-
try {
|
|
1448
|
-
const value = await coercePluginConfigValue({
|
|
1449
|
-
key,
|
|
1450
|
-
field,
|
|
1451
|
-
value: field.default,
|
|
1452
|
-
projectRoot,
|
|
1453
|
-
});
|
|
1454
|
-
fields.push({
|
|
1455
|
-
...base,
|
|
1456
|
-
effectiveValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
|
|
1457
|
-
sourceLayer: 'default',
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
catch {
|
|
1461
|
-
fields.push({
|
|
1462
|
-
...base,
|
|
1463
|
-
valueState: 'invalid',
|
|
1464
|
-
sourceLayer: 'default',
|
|
1465
|
-
});
|
|
1466
|
-
}
|
|
1467
|
-
continue;
|
|
1468
|
-
}
|
|
1469
|
-
fields.push(base);
|
|
1470
|
-
continue;
|
|
1471
|
-
}
|
|
1472
|
-
if (options.projectLayer === 'local') {
|
|
1473
|
-
if (Object.hasOwn(localPlainEntries, key)) {
|
|
1474
|
-
try {
|
|
1475
|
-
const value = await coercePluginConfigValue({
|
|
1476
|
-
key,
|
|
1477
|
-
field,
|
|
1478
|
-
value: localPlainEntries[key],
|
|
1479
|
-
projectRoot,
|
|
1480
|
-
});
|
|
1481
|
-
fields.push({
|
|
1482
|
-
...base,
|
|
1483
|
-
valueState: 'configured',
|
|
1484
|
-
effectiveValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
|
|
1485
|
-
sourceLayer: 'local',
|
|
1486
|
-
storedValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
|
|
1487
|
-
storedSourceLayer: 'local',
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
catch {
|
|
1491
|
-
fields.push({
|
|
1492
|
-
...base,
|
|
1493
|
-
valueState: 'invalid',
|
|
1494
|
-
sourceLayer: 'local',
|
|
1495
|
-
storedSourceLayer: 'local',
|
|
1496
|
-
});
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
else {
|
|
1500
|
-
fields.push(base);
|
|
1501
|
-
}
|
|
1502
|
-
continue;
|
|
1503
|
-
}
|
|
1504
|
-
let storedProjectValue;
|
|
1505
|
-
if (options.scope === 'project' && Object.hasOwn(projectPlainEntries, key)) {
|
|
1506
|
-
try {
|
|
1507
|
-
const value = await coercePluginConfigValue({
|
|
1508
|
-
key,
|
|
1509
|
-
field,
|
|
1510
|
-
value: projectPlainEntries[key],
|
|
1511
|
-
projectRoot,
|
|
1512
|
-
});
|
|
1513
|
-
storedProjectValue = {
|
|
1514
|
-
storedValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
|
|
1515
|
-
storedSourceLayer: 'project',
|
|
1516
|
-
};
|
|
1517
|
-
}
|
|
1518
|
-
catch {
|
|
1519
|
-
storedProjectValue = { storedSourceLayer: 'project' };
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
fields.push({ ...base, ...effectiveFieldState(key), ...storedProjectValue });
|
|
1272
|
+
}));
|
|
1273
|
+
for (const key of Object.keys(stored).filter((key) => !Object.hasOwn(effective.schema, key)).sort()) {
|
|
1274
|
+
const source = options.platform ? 'platform' : 'common';
|
|
1275
|
+
fields.push({ key, title: key, kind: 'manifest', reserved: false, writable: false, canSet: false, canUnset: true,
|
|
1276
|
+
valueState: 'configured', effectiveValue: '[redacted]', sourceLayer: source, storedSourceLayer: source,
|
|
1277
|
+
value: '[redacted]', source, matchedPreset: null, valid: false, issues: [] });
|
|
1523
1278
|
}
|
|
1524
1279
|
return fields;
|
|
1525
1280
|
}
|
|
1526
1281
|
async function buildLegacyStoreFieldEntries(options) {
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
]
|
|
1533
|
-
: [{
|
|
1534
|
-
scope: options.scope,
|
|
1535
|
-
projectLayer: options.projectLayer,
|
|
1536
|
-
sourceLayer: options.scope === 'user'
|
|
1537
|
-
? 'user'
|
|
1538
|
-
: options.projectLayer === 'local' ? 'local' : 'project',
|
|
1539
|
-
}];
|
|
1540
|
-
const fields = new Map();
|
|
1541
|
-
for (const location of locations) {
|
|
1542
|
-
const store = await readPluginConfigStore({
|
|
1543
|
-
sourceId: options.sourceId,
|
|
1544
|
-
sourceIdentity: options.sourceIdentity,
|
|
1545
|
-
pluginName: options.pluginName,
|
|
1546
|
-
scope: location.scope,
|
|
1547
|
-
...(location.scope === 'project' ? { projectLayer: location.projectLayer } : {}),
|
|
1548
|
-
cwd: options.cwd,
|
|
1549
|
-
env: options.env,
|
|
1550
|
-
});
|
|
1551
|
-
for (const key of Object.keys(store.values)) {
|
|
1552
|
-
fields.set(key, {
|
|
1553
|
-
key,
|
|
1554
|
-
title: key,
|
|
1555
|
-
kind: 'manifest',
|
|
1556
|
-
reserved: false,
|
|
1557
|
-
writable: false,
|
|
1558
|
-
valueState: 'configured',
|
|
1559
|
-
effectiveValue: '[redacted]',
|
|
1560
|
-
sourceLayer: location.sourceLayer,
|
|
1561
|
-
});
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
return [...fields.values()].sort((left, right) => left.key.localeCompare(right.key));
|
|
1282
|
+
const store = await readPluginConfigStore({ ...options, scope: 'user' });
|
|
1283
|
+
const source = options.platform ? 'platform' : 'common';
|
|
1284
|
+
return Object.keys(store.values).sort().map((key) => ({ key, title: key, kind: 'manifest', reserved: false,
|
|
1285
|
+
writable: false, canSet: false, canUnset: true, valueState: 'configured', effectiveValue: '[redacted]',
|
|
1286
|
+
sourceLayer: source, value: '[redacted]', source, matchedPreset: null, valid: true, issues: [] }));
|
|
1565
1287
|
}
|
|
1566
1288
|
export async function resolvePluginConfigSchemaAccess(options) {
|
|
1567
1289
|
const pluginName = assertSafePluginConfigSegment(options.pluginName);
|
|
@@ -1577,42 +1299,50 @@ export async function resolvePluginConfigSchemaAccess(options) {
|
|
|
1577
1299
|
return {
|
|
1578
1300
|
pluginName,
|
|
1579
1301
|
plugin: options.currentPlugin,
|
|
1580
|
-
schema: createConfigSchemaEvidenceFromCurrentCatalog(options.currentPlugin, await calculateConfigSchemaManifestDigestForPlugin(options.currentPlugin)),
|
|
1302
|
+
schema: createConfigSchemaEvidenceFromCurrentCatalog(options.currentPlugin, await calculateConfigSchemaManifestDigestForPlugin(options.currentPlugin), options.platform),
|
|
1581
1303
|
};
|
|
1582
1304
|
}
|
|
1583
1305
|
export async function resolveConfigRead(options) {
|
|
1306
|
+
if (options.context)
|
|
1307
|
+
await resolveWorkContext({ cwd: options.cwd, context: options.context });
|
|
1584
1308
|
const pluginName = assertSafePluginConfigSegment(options.pluginName);
|
|
1585
1309
|
const schemaAccess = await resolvePluginConfigSchemaAccess({
|
|
1586
1310
|
pluginName,
|
|
1587
1311
|
currentPlugin: options.plugin,
|
|
1588
1312
|
currentPluginError: options.pluginError,
|
|
1313
|
+
platform: options.platform,
|
|
1589
1314
|
scope: options.scope,
|
|
1590
|
-
projectLayer: options.projectLayer,
|
|
1591
1315
|
cwd: options.cwd,
|
|
1592
1316
|
env: options.env,
|
|
1593
1317
|
});
|
|
1594
1318
|
const manifestFields = schemaAccess.plugin
|
|
1595
1319
|
? await buildManifestFieldEntries({
|
|
1596
1320
|
plugin: schemaAccess.plugin,
|
|
1321
|
+
context: options.context,
|
|
1322
|
+
platform: options.platform,
|
|
1597
1323
|
scope: options.scope,
|
|
1598
|
-
projectLayer: options.projectLayer,
|
|
1599
1324
|
cwd: options.cwd,
|
|
1600
1325
|
env: options.env,
|
|
1601
1326
|
})
|
|
1602
1327
|
: await buildLegacyStoreFieldEntries({
|
|
1603
1328
|
sourceId: options.sourceId,
|
|
1604
1329
|
sourceIdentity: options.sourceIdentity,
|
|
1330
|
+
logicalIdentity: options.logicalIdentity,
|
|
1605
1331
|
pluginName,
|
|
1606
1332
|
scope: options.scope,
|
|
1607
|
-
|
|
1333
|
+
platform: options.platform,
|
|
1608
1334
|
cwd: options.cwd,
|
|
1609
1335
|
env: options.env,
|
|
1610
1336
|
});
|
|
1611
1337
|
return {
|
|
1612
1338
|
pluginName,
|
|
1339
|
+
platform: options.platform,
|
|
1340
|
+
context: options.context ?? 'user',
|
|
1613
1341
|
scope: options.scope,
|
|
1614
|
-
projectLayer: options.projectLayer,
|
|
1615
1342
|
...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
|
|
1343
|
+
...(schemaAccess.plugin?.manifest.config?.fields
|
|
1344
|
+
? { fieldDefinitions: selectPluginConfigProfile(schemaAccess.plugin.manifest.config, options.platform).fields }
|
|
1345
|
+
: {}),
|
|
1616
1346
|
fields: manifestFields,
|
|
1617
1347
|
};
|
|
1618
1348
|
}
|
|
@@ -1626,67 +1356,100 @@ export function summarizeEffectivePluginConfig(config) {
|
|
|
1626
1356
|
return {
|
|
1627
1357
|
values: config.redactedValues,
|
|
1628
1358
|
sources: config.sources,
|
|
1359
|
+
fieldStates: Object.fromEntries(Object.entries(config.fieldStates).map(([key, state]) => [key, {
|
|
1360
|
+
...(state.effective ? {
|
|
1361
|
+
effective: { value: state.effective.redactedValue, source: state.effective.source },
|
|
1362
|
+
} : {}),
|
|
1363
|
+
...(state.invalidOverride ? { invalidOverride: state.invalidOverride } : {}),
|
|
1364
|
+
...(state.fallback ? {
|
|
1365
|
+
fallback: { value: state.fallback.redactedValue, source: state.fallback.source },
|
|
1366
|
+
} : {}),
|
|
1367
|
+
}])),
|
|
1629
1368
|
issues: config.issues,
|
|
1630
1369
|
ignoredUnknownKeys: config.ignoredUnknownKeys,
|
|
1631
1370
|
};
|
|
1632
1371
|
}
|
|
1633
|
-
export function createPluginConfigSchemaIdentity(manifest) {
|
|
1372
|
+
export function createPluginConfigSchemaIdentity(manifest, platform) {
|
|
1634
1373
|
const hash = crypto
|
|
1635
1374
|
.createHash('sha256')
|
|
1636
1375
|
.update(JSON.stringify({
|
|
1637
1376
|
name: manifest.name,
|
|
1638
1377
|
version: manifest.version,
|
|
1639
|
-
|
|
1378
|
+
platform: platform ?? null,
|
|
1379
|
+
config: manifest.config ? selectPluginConfigProfile(manifest.config, platform) : null,
|
|
1640
1380
|
}))
|
|
1641
1381
|
.digest('hex');
|
|
1642
1382
|
return `${manifest.name}:${hash}`;
|
|
1643
1383
|
}
|
|
1384
|
+
function cliConfigPromptEnumValues(field) {
|
|
1385
|
+
if (!field.choices)
|
|
1386
|
+
return undefined;
|
|
1387
|
+
const values = field.choices.presets
|
|
1388
|
+
.map((preset) => preset.value);
|
|
1389
|
+
if (field.type !== 'boolean') {
|
|
1390
|
+
return field.choices.allowCustom ? undefined : values;
|
|
1391
|
+
}
|
|
1392
|
+
if (field.choices.allowCustom) {
|
|
1393
|
+
for (const value of [true, false]) {
|
|
1394
|
+
if (!values.includes(value))
|
|
1395
|
+
values.push(value);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
return values;
|
|
1399
|
+
}
|
|
1644
1400
|
export function toCliConfigPromptSchema(schema) {
|
|
1645
1401
|
const promptSchema = {};
|
|
1646
1402
|
for (const [key, field] of Object.entries(schema)) {
|
|
1403
|
+
if (field.type === 'object' || field.type === 'array')
|
|
1404
|
+
continue;
|
|
1647
1405
|
promptSchema[key] = {
|
|
1648
|
-
type: field.type
|
|
1406
|
+
type: field.type,
|
|
1649
1407
|
label: field.title ?? key,
|
|
1650
1408
|
description: field.description,
|
|
1651
1409
|
required: field.required,
|
|
1652
1410
|
sensitive: field.sensitive,
|
|
1653
1411
|
default: field.default,
|
|
1654
|
-
enum: field
|
|
1655
|
-
min: field.
|
|
1656
|
-
max: field.
|
|
1412
|
+
enum: cliConfigPromptEnumValues(field),
|
|
1413
|
+
min: field.type === 'number' ? field.validation?.minimum : undefined,
|
|
1414
|
+
max: field.type === 'number' ? field.validation?.maximum : undefined,
|
|
1657
1415
|
};
|
|
1658
1416
|
}
|
|
1659
1417
|
return promptSchema;
|
|
1660
1418
|
}
|
|
1661
1419
|
export function createPluginConfigFormModel(options) {
|
|
1662
|
-
const schema = options.
|
|
1420
|
+
const schema = options.effective.schema;
|
|
1663
1421
|
if (!schema) {
|
|
1664
|
-
throw new
|
|
1422
|
+
throw new PluginConfigSchemaResolutionError('configSchemaUnavailable', `Plugin "${options.pluginName ?? options.manifest.name}" does not declare an AW config schema.`);
|
|
1665
1423
|
}
|
|
1666
1424
|
const requiredKeys = [...new Set(options.effective.issues
|
|
1667
1425
|
.filter((issue) => issue.type === 'missing-required' || issue.type === 'invalid-config')
|
|
1668
1426
|
.map((issue) => issue.key))];
|
|
1427
|
+
const fields = Object.entries(schema).flatMap(([key, field]) => {
|
|
1428
|
+
if (field.type === 'object' || field.type === 'array')
|
|
1429
|
+
return [];
|
|
1430
|
+
return [{
|
|
1431
|
+
key,
|
|
1432
|
+
type: field.type,
|
|
1433
|
+
label: field.title ?? key,
|
|
1434
|
+
description: field.description,
|
|
1435
|
+
required: field.required === true,
|
|
1436
|
+
sensitive: field.sensitive === true,
|
|
1437
|
+
defaultValue: field.default,
|
|
1438
|
+
enumValues: cliConfigPromptEnumValues(field),
|
|
1439
|
+
min: field.type === 'number' ? field.validation?.minimum : undefined,
|
|
1440
|
+
max: field.type === 'number' ? field.validation?.maximum : undefined,
|
|
1441
|
+
configured: options.effective.values[key] !== undefined,
|
|
1442
|
+
currentValue: field.sensitive
|
|
1443
|
+
? undefined
|
|
1444
|
+
: options.effective.values[key],
|
|
1445
|
+
}];
|
|
1446
|
+
});
|
|
1669
1447
|
return {
|
|
1670
1448
|
pluginName: options.pluginName ?? options.manifest.name,
|
|
1671
|
-
allowedScopes:
|
|
1672
|
-
initialScope:
|
|
1449
|
+
allowedScopes: ['user'],
|
|
1450
|
+
initialScope: 'user',
|
|
1673
1451
|
requiredKeys,
|
|
1674
|
-
fields
|
|
1675
|
-
key,
|
|
1676
|
-
type: field.type,
|
|
1677
|
-
label: field.title ?? key,
|
|
1678
|
-
description: field.description,
|
|
1679
|
-
required: field.required === true,
|
|
1680
|
-
sensitive: field.sensitive === true,
|
|
1681
|
-
defaultValue: field.default,
|
|
1682
|
-
enumValues: field.type === 'enum' ? field.values : undefined,
|
|
1683
|
-
min: field.min,
|
|
1684
|
-
max: field.max,
|
|
1685
|
-
configured: options.effective.values[key] !== undefined,
|
|
1686
|
-
currentValue: field.sensitive || isPathTypeField(field)
|
|
1687
|
-
? undefined
|
|
1688
|
-
: options.effective.values[key],
|
|
1689
|
-
})),
|
|
1452
|
+
fields,
|
|
1690
1453
|
};
|
|
1691
1454
|
}
|
|
1692
1455
|
export function toCliConfigPromptOptions(model) {
|
|
@@ -1705,7 +1468,7 @@ export function toCliConfigPromptOptions(model) {
|
|
|
1705
1468
|
schema: Object.fromEntries(model.fields.map((field) => [
|
|
1706
1469
|
field.key,
|
|
1707
1470
|
{
|
|
1708
|
-
type: field.type
|
|
1471
|
+
type: field.type,
|
|
1709
1472
|
label: field.label,
|
|
1710
1473
|
description: field.description,
|
|
1711
1474
|
required: field.required,
|
|
@@ -1723,13 +1486,17 @@ export function toCliConfigPromptOptions(model) {
|
|
|
1723
1486
|
requiredKeys: [...model.requiredKeys],
|
|
1724
1487
|
};
|
|
1725
1488
|
}
|
|
1726
|
-
function
|
|
1489
|
+
export function formatPluginConfigSetRecoveryCommand(pluginName, key, field, context, platform) {
|
|
1490
|
+
const command = `aw plugin config set ${pluginName} ${key} --context ${context}`
|
|
1491
|
+
+ (platform ? ` --platform ${platform}` : '');
|
|
1492
|
+
return field.sensitive === true ? `${command} --value-stdin` : `${command} --value-json '<json>'`;
|
|
1493
|
+
}
|
|
1494
|
+
function formatRequiredConfigSetCommands(pluginName, issues, context, schema, platform) {
|
|
1727
1495
|
const commands = new Set();
|
|
1728
1496
|
for (const issue of issues) {
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
commands.add(`aw config set ${pluginName} ${issue.key} <value> -s ${scope}`);
|
|
1497
|
+
const field = schema[issue.key];
|
|
1498
|
+
if (field)
|
|
1499
|
+
commands.add(formatPluginConfigSetRecoveryCommand(pluginName, issue.key, field, context, platform));
|
|
1733
1500
|
}
|
|
1734
1501
|
return [...commands].map((command) => `\`${command}\``).join(' 或 ');
|
|
1735
1502
|
}
|
|
@@ -1742,21 +1509,23 @@ export async function preflightRequiredPluginConfigs(options) {
|
|
|
1742
1509
|
};
|
|
1743
1510
|
for (const target of options.targets) {
|
|
1744
1511
|
const pluginName = target.pluginName ?? target.manifest.name;
|
|
1745
|
-
const identity = target.schemaSourceIdentity ?? createPluginConfigSchemaIdentity(target.manifest);
|
|
1746
|
-
const dedupeKey = `${pluginName}\0${identity}`;
|
|
1512
|
+
const identity = target.schemaSourceIdentity ?? createPluginConfigSchemaIdentity(target.manifest, target.platform);
|
|
1513
|
+
const dedupeKey = `${pluginName}\0${target.platform ?? 'common'}\0${identity}`;
|
|
1747
1514
|
if (visited.has(dedupeKey)) {
|
|
1748
1515
|
continue;
|
|
1749
1516
|
}
|
|
1750
1517
|
visited.add(dedupeKey);
|
|
1751
1518
|
result.checked += 1;
|
|
1752
|
-
if (!target.manifest.config?.
|
|
1519
|
+
if (!target.manifest.config?.fields) {
|
|
1753
1520
|
continue;
|
|
1754
1521
|
}
|
|
1755
|
-
|
|
1522
|
+
const effective = await resolveEffectivePluginConfig({
|
|
1756
1523
|
sourceId: target.sourceId,
|
|
1757
1524
|
sourceIdentity: target.sourceIdentity,
|
|
1525
|
+
logicalIdentity: target.logicalIdentity,
|
|
1758
1526
|
pluginName,
|
|
1759
1527
|
manifest: target.manifest,
|
|
1528
|
+
platform: target.platform,
|
|
1760
1529
|
cwd: options.cwd,
|
|
1761
1530
|
env: options.context.env,
|
|
1762
1531
|
});
|
|
@@ -1765,7 +1534,7 @@ export async function preflightRequiredPluginConfigs(options) {
|
|
|
1765
1534
|
continue;
|
|
1766
1535
|
}
|
|
1767
1536
|
const details = blockingIssues.map((issue) => issue.key).join(', ');
|
|
1768
|
-
const setCommands = formatRequiredConfigSetCommands(pluginName, blockingIssues, options.defaultScope);
|
|
1537
|
+
const setCommands = formatRequiredConfigSetCommands(target.sourceId ? `${target.sourceId}/${pluginName}` : pluginName, blockingIssues, options.defaultScope, effective.schema, target.platform);
|
|
1769
1538
|
throw new Error(`${pluginName} requires valid AW config before install/upgrade: ${details}. ` +
|
|
1770
1539
|
`Run ${setCommands}, or open \`aw\` to complete setup.`);
|
|
1771
1540
|
}
|