@lesliechan721/aw 0.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-config.d.mts +51 -0
- package/dist/authoring/assets/aw-config.mjs +1025 -0
- package/dist/authoring/assets/aw-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.d.mts +2 -0
- package/dist/authoring/scripts/add-skill.mjs +355 -0
- package/dist/authoring/scripts/add-skill.mjs.map +1 -0
- package/dist/authoring/scripts/init-plugin.d.mts +2 -0
- package/dist/authoring/scripts/init-plugin.mjs +487 -0
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.d.mts +4 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs +261 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-root.d.mts +26 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs +125 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +69 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +563 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -0
- package/dist/authoring/scripts/lib/semver.d.mts +9 -0
- package/dist/authoring/scripts/lib/semver.mjs +63 -0
- package/dist/authoring/scripts/lib/semver.mjs.map +1 -0
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +111 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +353 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -0
- package/dist/authoring/scripts/plugin-status.d.mts +2 -0
- package/dist/authoring/scripts/plugin-status.mjs +93 -0
- package/dist/authoring/scripts/plugin-status.mjs.map +1 -0
- package/dist/authoring/scripts/remove-plugin.d.mts +2 -0
- package/dist/authoring/scripts/remove-plugin.mjs +367 -0
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-plugin.d.mts +2 -0
- package/dist/authoring/scripts/validate-plugin.mjs +3465 -0
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-skill.d.mts +2 -0
- package/dist/authoring/scripts/validate-skill.mjs +126 -0
- package/dist/authoring/scripts/validate-skill.mjs.map +1 -0
- package/dist/authoring/templates/aw-config-runtime.d.mts +2 -0
- package/dist/authoring/templates/aw-config-runtime.mjs +407 -0
- package/dist/authoring/templates/aw-config-runtime.mjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +24 -0
- package/dist/scripts/aw-skill-eval-materializer.js +309 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +17 -0
- package/dist/scripts/bundle-plugins.js +126 -0
- package/dist/scripts/bundle-plugins.js.map +1 -0
- package/dist/scripts/plugin-staging.d.ts +26 -0
- package/dist/scripts/plugin-staging.js +76 -0
- package/dist/scripts/plugin-staging.js.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +7 -0
- package/dist/scripts/test-plugin-scripts.js +610 -0
- package/dist/scripts/test-plugin-scripts.js.map +1 -0
- package/dist/src/adapters/helpers.d.ts +44 -0
- package/dist/src/adapters/helpers.js +95 -0
- package/dist/src/adapters/helpers.js.map +1 -0
- package/dist/src/authoring/workspace-commands.d.ts +70 -0
- package/dist/src/authoring/workspace-commands.js +158 -0
- package/dist/src/authoring/workspace-commands.js.map +1 -0
- package/dist/src/commands/aw-capabilities.d.ts +78 -0
- package/dist/src/commands/aw-capabilities.js +254 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -0
- package/dist/src/commands/catalog-dev-source.d.ts +120 -0
- package/dist/src/commands/catalog-dev-source.js +434 -0
- package/dist/src/commands/catalog-dev-source.js.map +1 -0
- package/dist/src/commands/catalog-generation.d.ts +16 -0
- package/dist/src/commands/catalog-generation.js +9 -0
- package/dist/src/commands/catalog-generation.js.map +1 -0
- package/dist/src/commands/catalog-publication-inspection.d.ts +138 -0
- package/dist/src/commands/catalog-publication-inspection.js +711 -0
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
- package/dist/src/commands/catalog-publication-journal.d.ts +56 -0
- package/dist/src/commands/catalog-publication-journal.js +215 -0
- package/dist/src/commands/catalog-publication-journal.js.map +1 -0
- package/dist/src/commands/catalog-publication-target.d.ts +18 -0
- package/dist/src/commands/catalog-publication-target.js +95 -0
- package/dist/src/commands/catalog-publication-target.js.map +1 -0
- package/dist/src/commands/catalog-publish.d.ts +103 -0
- package/dist/src/commands/catalog-publish.js +804 -0
- package/dist/src/commands/catalog-publish.js.map +1 -0
- package/dist/src/commands/catalog-source.d.ts +134 -0
- package/dist/src/commands/catalog-source.js +377 -0
- package/dist/src/commands/catalog-source.js.map +1 -0
- package/dist/src/commands/catalog-status.d.ts +56 -0
- package/dist/src/commands/catalog-status.js +217 -0
- package/dist/src/commands/catalog-status.js.map +1 -0
- package/dist/src/commands/catalog-store.d.ts +80 -0
- package/dist/src/commands/catalog-store.js +348 -0
- package/dist/src/commands/catalog-store.js.map +1 -0
- package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
- package/dist/src/commands/catalog-workspace-resolution.js +42 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.d.ts +3 -0
- package/dist/src/commands/console.js +44 -0
- package/dist/src/commands/console.js.map +1 -0
- package/dist/src/commands/dependency-operation-plan.d.ts +58 -0
- package/dist/src/commands/dependency-operation-plan.js +261 -0
- package/dist/src/commands/dependency-operation-plan.js.map +1 -0
- package/dist/src/commands/init.d.ts +25 -0
- package/dist/src/commands/init.js +42 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +59 -0
- package/dist/src/commands/offline-cleanup-evidence.js +163 -0
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
- package/dist/src/commands/operation-plan.d.ts +126 -0
- package/dist/src/commands/operation-plan.js +47 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +46 -0
- package/dist/src/commands/operation-planner.js +139 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +70 -0
- package/dist/src/commands/options.js +194 -0
- package/dist/src/commands/options.js.map +1 -0
- package/dist/src/commands/plugin-capabilities.d.ts +22 -0
- package/dist/src/commands/plugin-capabilities.js +159 -0
- package/dist/src/commands/plugin-capabilities.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +88 -0
- package/dist/src/commands/rebuild-command.js +3626 -0
- package/dist/src/commands/rebuild-command.js.map +1 -0
- package/dist/src/commands/rebuild-integration.d.ts +190 -0
- package/dist/src/commands/rebuild-integration.js +4439 -0
- package/dist/src/commands/rebuild-integration.js.map +1 -0
- package/dist/src/commands/rebuild-operations.d.ts +100 -0
- package/dist/src/commands/rebuild-operations.js +625 -0
- package/dist/src/commands/rebuild-operations.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +26 -0
- package/dist/src/commands/reconcile-operation-plan.js +28 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-publication.d.ts +99 -0
- package/dist/src/commands/review-publication.js +904 -0
- package/dist/src/commands/review-publication.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +172 -0
- package/dist/src/commands/runtime.js +720 -0
- package/dist/src/commands/runtime.js.map +1 -0
- package/dist/src/commands/skill-eval.d.ts +33 -0
- package/dist/src/commands/skill-eval.js +363 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +206 -0
- package/dist/src/commands/status-v6.js +2175 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/sync-command.d.ts +23 -0
- package/dist/src/commands/sync-command.js +242 -0
- package/dist/src/commands/sync-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +56 -0
- package/dist/src/commands/wizard.js +58 -0
- package/dist/src/commands/wizard.js.map +1 -0
- package/dist/src/commands/write-commands.d.ts +7 -0
- package/dist/src/commands/write-commands.js +190 -0
- package/dist/src/commands/write-commands.js.map +1 -0
- package/dist/src/constants.d.ts +31 -0
- package/dist/src/constants.js +32 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/eval/manifest-v1.d.ts +67 -0
- package/dist/src/eval/manifest-v1.js +347 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/agents.d.ts +3 -0
- package/dist/src/generators/agents.js +46 -0
- package/dist/src/generators/agents.js.map +1 -0
- package/dist/src/generators/hooks.d.ts +15 -0
- package/dist/src/generators/hooks.js +76 -0
- package/dist/src/generators/hooks.js.map +1 -0
- package/dist/src/generators/instructions.d.ts +13 -0
- package/dist/src/generators/instructions.js +66 -0
- package/dist/src/generators/instructions.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +56 -0
- package/dist/src/generators/local-plugin.js +1373 -0
- package/dist/src/generators/local-plugin.js.map +1 -0
- package/dist/src/generators/permissions.d.ts +10 -0
- package/dist/src/generators/permissions.js +37 -0
- package/dist/src/generators/permissions.js.map +1 -0
- package/dist/src/generators/shared.d.ts +2 -0
- package/dist/src/generators/shared.js +15 -0
- package/dist/src/generators/shared.js.map +1 -0
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.js +3327 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +87 -0
- package/dist/src/output/command-receipt.js +302 -0
- package/dist/src/output/command-receipt.js.map +1 -0
- package/dist/src/output/debug-log.d.ts +4 -0
- package/dist/src/output/debug-log.js +97 -0
- package/dist/src/output/debug-log.js.map +1 -0
- package/dist/src/output/equivalent-command.d.ts +9 -0
- package/dist/src/output/equivalent-command.js +39 -0
- package/dist/src/output/equivalent-command.js.map +1 -0
- package/dist/src/output/model.d.ts +76 -0
- package/dist/src/output/model.js +2 -0
- package/dist/src/output/model.js.map +1 -0
- package/dist/src/output/rebuild-progress.d.ts +21 -0
- package/dist/src/output/rebuild-progress.js +128 -0
- package/dist/src/output/rebuild-progress.js.map +1 -0
- package/dist/src/output/redact.d.ts +3 -0
- package/dist/src/output/redact.js +39 -0
- package/dist/src/output/redact.js.map +1 -0
- package/dist/src/output/reporter.d.ts +9 -0
- package/dist/src/output/reporter.js +133 -0
- package/dist/src/output/reporter.js.map +1 -0
- package/dist/src/portable/commands.d.ts +124 -0
- package/dist/src/portable/commands.js +557 -0
- package/dist/src/portable/commands.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +50 -0
- package/dist/src/portable/materializer.js +462 -0
- package/dist/src/portable/materializer.js.map +1 -0
- package/dist/src/portable/skills-cli.d.ts +43 -0
- package/dist/src/portable/skills-cli.js +148 -0
- package/dist/src/portable/skills-cli.js.map +1 -0
- package/dist/src/tui/catalog-freshness.d.ts +1 -0
- package/dist/src/tui/catalog-freshness.js +2 -0
- package/dist/src/tui/catalog-freshness.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +21 -0
- package/dist/src/tui/catalog-generation.js +116 -0
- package/dist/src/tui/catalog-generation.js.map +1 -0
- package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
- package/dist/src/tui/catalog-sources/projection.js +17 -0
- package/dist/src/tui/catalog-sources/projection.js.map +1 -0
- package/dist/src/tui/catalog-sources/review.d.ts +3 -0
- package/dist/src/tui/catalog-sources/review.js +13 -0
- package/dist/src/tui/catalog-sources/review.js.map +1 -0
- package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
- package/dist/src/tui/catalog-sources/screens.js +33 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +22 -0
- package/dist/src/tui/catalog-sources/session.js +225 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +41 -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/components.d.ts +102 -0
- package/dist/src/tui/components.js +184 -0
- package/dist/src/tui/components.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +20 -0
- package/dist/src/tui/console-app-v4.js +5066 -0
- package/dist/src/tui/console-app-v4.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +23 -0
- package/dist/src/tui/controller-runtime.js +2011 -0
- package/dist/src/tui/controller-runtime.js.map +1 -0
- package/dist/src/tui/controller.d.ts +557 -0
- package/dist/src/tui/controller.js +2120 -0
- package/dist/src/tui/controller.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +30 -0
- package/dist/src/tui/diagnostics.js +71 -0
- package/dist/src/tui/diagnostics.js.map +1 -0
- package/dist/src/tui/index.d.ts +17 -0
- package/dist/src/tui/index.js +17 -0
- package/dist/src/tui/index.js.map +1 -0
- package/dist/src/tui/input-display.d.ts +8 -0
- package/dist/src/tui/input-display.js +36 -0
- package/dist/src/tui/input-display.js.map +1 -0
- package/dist/src/tui/keys.d.ts +12 -0
- package/dist/src/tui/keys.js +22 -0
- package/dist/src/tui/keys.js.map +1 -0
- package/dist/src/tui/layout.d.ts +12 -0
- package/dist/src/tui/layout.js +19 -0
- package/dist/src/tui/layout.js.map +1 -0
- package/dist/src/tui/model.d.ts +424 -0
- package/dist/src/tui/model.js +1493 -0
- package/dist/src/tui/model.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +21 -0
- package/dist/src/tui/operation-review-planner.js +622 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/prompt.d.ts +8 -0
- package/dist/src/tui/prompt.js +231 -0
- package/dist/src/tui/prompt.js.map +1 -0
- package/dist/src/tui/router.d.ts +206 -0
- package/dist/src/tui/router.js +137 -0
- package/dist/src/tui/router.js.map +1 -0
- package/dist/src/tui/runner.d.ts +11 -0
- package/dist/src/tui/runner.js +71 -0
- package/dist/src/tui/runner.js.map +1 -0
- package/dist/src/tui/source-ref-presets.d.ts +3 -0
- package/dist/src/tui/source-ref-presets.js +11 -0
- package/dist/src/tui/source-ref-presets.js.map +1 -0
- package/dist/src/tui/theme.d.ts +26 -0
- package/dist/src/tui/theme.js +28 -0
- package/dist/src/tui/theme.js.map +1 -0
- package/dist/src/tui/viewport.d.ts +20 -0
- package/dist/src/tui/viewport.js +29 -0
- package/dist/src/tui/viewport.js.map +1 -0
- package/dist/src/tui/views.d.ts +57 -0
- package/dist/src/tui/views.js +201 -0
- package/dist/src/tui/views.js.map +1 -0
- package/dist/src/tui/wizard.d.ts +11 -0
- package/dist/src/tui/wizard.js +323 -0
- package/dist/src/tui/wizard.js.map +1 -0
- package/dist/src/types.d.ts +474 -0
- package/dist/src/types.js +34 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/agent-version.d.ts +19 -0
- package/dist/src/utils/agent-version.js +205 -0
- package/dist/src/utils/agent-version.js.map +1 -0
- package/dist/src/utils/artifact-plan.d.ts +27 -0
- package/dist/src/utils/artifact-plan.js +453 -0
- package/dist/src/utils/artifact-plan.js.map +1 -0
- package/dist/src/utils/artifact-renderer.d.ts +129 -0
- package/dist/src/utils/artifact-renderer.js +400 -0
- package/dist/src/utils/artifact-renderer.js.map +1 -0
- package/dist/src/utils/artifact-request.d.ts +16 -0
- package/dist/src/utils/artifact-request.js +42 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +8 -0
- package/dist/src/utils/artifact-sources.js +10 -0
- package/dist/src/utils/artifact-sources.js.map +1 -0
- package/dist/src/utils/aw-home-mutation-lock.d.ts +11 -0
- package/dist/src/utils/aw-home-mutation-lock.js +83 -0
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -0
- package/dist/src/utils/bundle-integrity.d.ts +2 -0
- package/dist/src/utils/bundle-integrity.js +63 -0
- package/dist/src/utils/bundle-integrity.js.map +1 -0
- package/dist/src/utils/bundle-layout.d.ts +4 -0
- package/dist/src/utils/bundle-layout.js +531 -0
- package/dist/src/utils/bundle-layout.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +18 -0
- package/dist/src/utils/catalog-digests.js +156 -0
- package/dist/src/utils/catalog-digests.js.map +1 -0
- package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-generation-error.d.ts +16 -0
- package/dist/src/utils/catalog-generation-error.js +30 -0
- package/dist/src/utils/catalog-generation-error.js.map +1 -0
- package/dist/src/utils/catalog-generation-resolver.d.ts +32 -0
- package/dist/src/utils/catalog-generation-resolver.js +251 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
- package/dist/src/utils/catalog-generation-service.d.ts +161 -0
- package/dist/src/utils/catalog-generation-service.js +1237 -0
- package/dist/src/utils/catalog-generation-service.js.map +1 -0
- package/dist/src/utils/catalog-generation-state.d.ts +22 -0
- package/dist/src/utils/catalog-generation-state.js +192 -0
- package/dist/src/utils/catalog-generation-state.js.map +1 -0
- package/dist/src/utils/catalog-generation-store.d.ts +57 -0
- package/dist/src/utils/catalog-generation-store.js +397 -0
- package/dist/src/utils/catalog-generation-store.js.map +1 -0
- package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
- package/dist/src/utils/catalog-manifest-v7.js +98 -0
- package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
- package/dist/src/utils/catalog-operation-context.d.ts +20 -0
- package/dist/src/utils/catalog-operation-context.js +141 -0
- package/dist/src/utils/catalog-operation-context.js.map +1 -0
- package/dist/src/utils/catalog-public-error.d.ts +19 -0
- package/dist/src/utils/catalog-public-error.js +100 -0
- package/dist/src/utils/catalog-public-error.js.map +1 -0
- package/dist/src/utils/catalog-runtime-projection.d.ts +33 -0
- package/dist/src/utils/catalog-runtime-projection.js +77 -0
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -0
- package/dist/src/utils/catalog-snapshot.d.ts +10 -0
- package/dist/src/utils/catalog-snapshot.js +20 -0
- package/dist/src/utils/catalog-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-source-identity.d.ts +5 -0
- package/dist/src/utils/catalog-source-identity.js +137 -0
- package/dist/src/utils/catalog-source-identity.js.map +1 -0
- package/dist/src/utils/catalog-source-impact.d.ts +20 -0
- package/dist/src/utils/catalog-source-impact.js +222 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-presentation.d.ts +1 -0
- package/dist/src/utils/catalog-source-presentation.js +32 -0
- package/dist/src/utils/catalog-source-presentation.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +66 -0
- package/dist/src/utils/catalog-source-references.js +1180 -0
- package/dist/src/utils/catalog-source-references.js.map +1 -0
- package/dist/src/utils/catalog-sources.d.ts +53 -0
- package/dist/src/utils/catalog-sources.js +456 -0
- package/dist/src/utils/catalog-sources.js.map +1 -0
- package/dist/src/utils/codex-config.d.ts +126 -0
- package/dist/src/utils/codex-config.js +1032 -0
- package/dist/src/utils/codex-config.js.map +1 -0
- package/dist/src/utils/codex-manager.d.ts +81 -0
- package/dist/src/utils/codex-manager.js +810 -0
- package/dist/src/utils/codex-manager.js.map +1 -0
- package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
- package/dist/src/utils/codex-marketplace-path.js +45 -0
- package/dist/src/utils/codex-marketplace-path.js.map +1 -0
- package/dist/src/utils/codex-native-observation.d.ts +16 -0
- package/dist/src/utils/codex-native-observation.js +22 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -0
- package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
- package/dist/src/utils/codex-native-render-receipt.js +205 -0
- package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
- package/dist/src/utils/codex-reconciler.d.ts +128 -0
- package/dist/src/utils/codex-reconciler.js +294 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-roles.d.ts +71 -0
- package/dist/src/utils/codex-roles.js +257 -0
- package/dist/src/utils/codex-roles.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +63 -0
- package/dist/src/utils/codex-shared-native.js +142 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +11 -0
- package/dist/src/utils/codex-skill-staging.js +8 -0
- package/dist/src/utils/codex-skill-staging.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +45 -0
- package/dist/src/utils/codex-surface-analysis.js +245 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/config-value.d.ts +3 -0
- package/dist/src/utils/config-value.js +23 -0
- package/dist/src/utils/config-value.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +36 -0
- package/dist/src/utils/dynamic-skill-tree.js +466 -0
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -0
- package/dist/src/utils/file-rules.d.ts +1 -0
- package/dist/src/utils/file-rules.js +2 -0
- package/dist/src/utils/file-rules.js.map +1 -0
- package/dist/src/utils/git-catalog-provider.d.ts +22 -0
- package/dist/src/utils/git-catalog-provider.js +497 -0
- package/dist/src/utils/git-catalog-provider.js.map +1 -0
- package/dist/src/utils/hooks-contract.d.ts +1 -0
- package/dist/src/utils/hooks-contract.js +2 -0
- package/dist/src/utils/hooks-contract.js.map +1 -0
- package/dist/src/utils/json.d.ts +4 -0
- package/dist/src/utils/json.js +29 -0
- package/dist/src/utils/json.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +41 -0
- package/dist/src/utils/local-marketplace.js +316 -0
- package/dist/src/utils/local-marketplace.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +11 -0
- package/dist/src/utils/manifest.js +33 -0
- package/dist/src/utils/manifest.js.map +1 -0
- package/dist/src/utils/marketplace.d.ts +3 -0
- package/dist/src/utils/marketplace.js +76 -0
- package/dist/src/utils/marketplace.js.map +1 -0
- package/dist/src/utils/multi-source-catalog.d.ts +66 -0
- package/dist/src/utils/multi-source-catalog.js +345 -0
- package/dist/src/utils/multi-source-catalog.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +118 -0
- package/dist/src/utils/native-cli.js +518 -0
- package/dist/src/utils/native-cli.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.d.ts +18 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +198 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -0
- package/dist/src/utils/ownership.d.ts +194 -0
- package/dist/src/utils/ownership.js +723 -0
- package/dist/src/utils/ownership.js.map +1 -0
- package/dist/src/utils/path-catalog-provider.d.ts +7 -0
- package/dist/src/utils/path-catalog-provider.js +74 -0
- package/dist/src/utils/path-catalog-provider.js.map +1 -0
- package/dist/src/utils/paths.d.ts +40 -0
- package/dist/src/utils/paths.js +137 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/platform-entries.d.ts +1 -0
- package/dist/src/utils/platform-entries.js +2 -0
- package/dist/src/utils/platform-entries.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -0
- package/dist/src/utils/platform-support.js +2 -0
- package/dist/src/utils/platform-support.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +110 -0
- package/dist/src/utils/plugin-config-write.js +773 -0
- package/dist/src/utils/plugin-config-write.js.map +1 -0
- package/dist/src/utils/plugin-config.d.ts +389 -0
- package/dist/src/utils/plugin-config.js +1642 -0
- package/dist/src/utils/plugin-config.js.map +1 -0
- package/dist/src/utils/plugin-dependencies.d.ts +12 -0
- package/dist/src/utils/plugin-dependencies.js +162 -0
- package/dist/src/utils/plugin-dependencies.js.map +1 -0
- package/dist/src/utils/plugin-intent-state.d.ts +34 -0
- package/dist/src/utils/plugin-intent-state.js +289 -0
- package/dist/src/utils/plugin-intent-state.js.map +1 -0
- package/dist/src/utils/plugin-script-contract.d.ts +1 -0
- package/dist/src/utils/plugin-script-contract.js +2 -0
- package/dist/src/utils/plugin-script-contract.js.map +1 -0
- package/dist/src/utils/plugin-scripts.d.ts +101 -0
- package/dist/src/utils/plugin-scripts.js +253 -0
- package/dist/src/utils/plugin-scripts.js.map +1 -0
- package/dist/src/utils/process-lock.d.ts +47 -0
- package/dist/src/utils/process-lock.js +532 -0
- package/dist/src/utils/process-lock.js.map +1 -0
- package/dist/src/utils/process-tree.d.ts +2 -0
- package/dist/src/utils/process-tree.js +2 -0
- package/dist/src/utils/process-tree.js.map +1 -0
- package/dist/src/utils/project-boundary.d.ts +9 -0
- package/dist/src/utils/project-boundary.js +67 -0
- package/dist/src/utils/project-boundary.js.map +1 -0
- package/dist/src/utils/rendered-contract.d.ts +8 -0
- package/dist/src/utils/rendered-contract.js +134 -0
- package/dist/src/utils/rendered-contract.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +13 -0
- package/dist/src/utils/runtime-skill-closure.js +863 -0
- package/dist/src/utils/runtime-skill-closure.js.map +1 -0
- package/dist/src/utils/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/skill-authoring.d.ts +1 -0
- package/dist/src/utils/skill-authoring.js +2 -0
- package/dist/src/utils/skill-authoring.js.map +1 -0
- package/dist/src/utils/skill-validation.d.ts +37 -0
- package/dist/src/utils/skill-validation.js +326 -0
- package/dist/src/utils/skill-validation.js.map +1 -0
- package/dist/src/utils/slash-commands.d.ts +1 -0
- package/dist/src/utils/slash-commands.js +2 -0
- package/dist/src/utils/slash-commands.js.map +1 -0
- package/dist/src/utils/state-paths.d.ts +14 -0
- package/dist/src/utils/state-paths.js +139 -0
- package/dist/src/utils/state-paths.js.map +1 -0
- package/dist/src/utils/target-eligibility.d.ts +13 -0
- package/dist/src/utils/target-eligibility.js +35 -0
- package/dist/src/utils/target-eligibility.js.map +1 -0
- package/dist/src/utils/target-order.d.ts +7 -0
- package/dist/src/utils/target-order.js +10 -0
- package/dist/src/utils/target-order.js.map +1 -0
- package/dist/src/utils/template-engine.d.ts +1 -0
- package/dist/src/utils/template-engine.js +2 -0
- package/dist/src/utils/template-engine.js.map +1 -0
- package/dist/src/utils/test-path-fence.d.ts +12 -0
- package/dist/src/utils/test-path-fence.js +31 -0
- package/dist/src/utils/test-path-fence.js.map +1 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +16 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createInterface } from 'node:readline/promises';
|
|
4
|
+
import { Writable } from 'node:stream';
|
|
5
|
+
import { createFileDebugLogger } from '../output/debug-log.js';
|
|
6
|
+
import { createIoReporter, createNoopReporter, } from '../output/reporter.js';
|
|
7
|
+
import { NativeCliError, getDefaultNativeCliRunner } from '../utils/native-cli.js';
|
|
8
|
+
import { resolveAwHome } from '../utils/paths.js';
|
|
9
|
+
import { assertTestWritablePath } from '../utils/test-path-fence.js';
|
|
10
|
+
import { createInkPrompt } from '../tui/prompt.js';
|
|
11
|
+
import { createInkTuiRunner } from '../tui/runner.js';
|
|
12
|
+
const reporterRoutes = new WeakMap();
|
|
13
|
+
function createSessionAwareReporter(defaultReporter) {
|
|
14
|
+
const route = { current: defaultReporter };
|
|
15
|
+
const reporter = {
|
|
16
|
+
event: (event) => route.current.event(event),
|
|
17
|
+
notice: (notice) => route.current.notice(notice),
|
|
18
|
+
};
|
|
19
|
+
reporterRoutes.set(reporter, route);
|
|
20
|
+
return reporter;
|
|
21
|
+
}
|
|
22
|
+
export async function withCommandReporterSession(reporter, sessionReporter, task) {
|
|
23
|
+
const route = reporterRoutes.get(reporter);
|
|
24
|
+
if (!route)
|
|
25
|
+
return task();
|
|
26
|
+
const previous = route.current;
|
|
27
|
+
route.current = sessionReporter;
|
|
28
|
+
try {
|
|
29
|
+
return await task();
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
route.current = previous;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function createDefaultIo() {
|
|
36
|
+
return {
|
|
37
|
+
stdout: (text) => process.stdout.write(text),
|
|
38
|
+
stderr: (text) => process.stderr.write(text),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function isTruthy(value) {
|
|
42
|
+
return value === '1' || value === 'true' || value === 'yes';
|
|
43
|
+
}
|
|
44
|
+
function createRunId() {
|
|
45
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
46
|
+
}
|
|
47
|
+
function createTimestampForPath() {
|
|
48
|
+
return new Date().toISOString().replace(/[:.]/g, '-');
|
|
49
|
+
}
|
|
50
|
+
function assertDebugLogPathForTests(logFile, source, commandName) {
|
|
51
|
+
return assertTestWritablePath(logFile, source === 'explicit'
|
|
52
|
+
? '--log-file'
|
|
53
|
+
: commandName === 'status'
|
|
54
|
+
? 'AW_DEBUG default status log file'
|
|
55
|
+
: 'AW_DEBUG default log file', source === 'explicit'
|
|
56
|
+
? '用 createIsolatedTestEnv() 提供安全 cwd/TMPDIR/AW_HOME,或通过 registerWritableStateRoot() 登记 --log-file 目标路径。'
|
|
57
|
+
: '用 createIsolatedTestEnv() 生成默认 TMPDIR/AW_HOME,或通过 registerWritableStateRoot() 登记调试日志目录。');
|
|
58
|
+
}
|
|
59
|
+
function defaultLogFile(commandName, env) {
|
|
60
|
+
const fileName = `aw-${createTimestampForPath()}-${commandName}.log`;
|
|
61
|
+
if (commandName === 'status') {
|
|
62
|
+
return assertDebugLogPathForTests(path.join(os.tmpdir(), 'agent-workflows', fileName), 'default', commandName);
|
|
63
|
+
}
|
|
64
|
+
return assertDebugLogPathForTests(path.join(resolveAwHome(env), 'logs', fileName), 'default', commandName);
|
|
65
|
+
}
|
|
66
|
+
export function createCommandDiagnostics(input = {}, env = process.env) {
|
|
67
|
+
const commandName = input.commandName ?? 'command';
|
|
68
|
+
const envDebug = isTruthy(env.AW_DEBUG);
|
|
69
|
+
const debug = input.debug === true || envDebug;
|
|
70
|
+
const hasLogFile = Boolean(input.logFile || debug);
|
|
71
|
+
return {
|
|
72
|
+
verbose: input.verbose === true || debug,
|
|
73
|
+
debug,
|
|
74
|
+
commandName,
|
|
75
|
+
runId: input.runId ?? createRunId(),
|
|
76
|
+
metadata: input.metadata,
|
|
77
|
+
...(hasLogFile
|
|
78
|
+
? {
|
|
79
|
+
logFile: input.logFile
|
|
80
|
+
? assertDebugLogPathForTests(input.logFile, 'explicit', commandName)
|
|
81
|
+
: defaultLogFile(commandName, env),
|
|
82
|
+
logFileSource: input.logFile ? input.logFileSource ?? 'explicit' : 'default',
|
|
83
|
+
}
|
|
84
|
+
: {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function validateCliConfigPromptResult(options, result) {
|
|
88
|
+
if (!options.allowedScopes.includes(result.selectedScope)) {
|
|
89
|
+
throw new Error(`Unsupported config scope "${result.selectedScope}". Expected one of: ${options.allowedScopes.join(', ')}.`);
|
|
90
|
+
}
|
|
91
|
+
const schemaKeys = new Set(Object.keys(options.schema));
|
|
92
|
+
const updateKeys = Object.keys(result.updates);
|
|
93
|
+
const removeKeys = result.removeKeys ?? [];
|
|
94
|
+
for (const key of [...result.updatedKeys, ...updateKeys, ...removeKeys]) {
|
|
95
|
+
if (!schemaKeys.has(key)) {
|
|
96
|
+
throw new Error(`Unsupported config key "${key}".`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const updatedKeySet = new Set(result.updatedKeys);
|
|
100
|
+
for (const key of updateKeys) {
|
|
101
|
+
if (!updatedKeySet.has(key)) {
|
|
102
|
+
throw new Error(`Config prompt result update "${key}" is missing from updatedKeys.`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const key of result.updatedKeys) {
|
|
106
|
+
if (!Object.hasOwn(result.updates, key)) {
|
|
107
|
+
throw new Error(`Config prompt result updatedKeys contains "${key}" without an update value.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const key of removeKeys) {
|
|
111
|
+
if (Object.hasOwn(result.updates, key)) {
|
|
112
|
+
throw new Error(`Config prompt result cannot update and remove "${key}" in the same submission.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
function createUnavailablePrompt() {
|
|
118
|
+
const unavailable = async () => {
|
|
119
|
+
throw new Error('Interactive prompt is not available in this runtime.');
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
select: unavailable,
|
|
123
|
+
multiSelect: unavailable,
|
|
124
|
+
confirm: unavailable,
|
|
125
|
+
input: unavailable,
|
|
126
|
+
password: unavailable,
|
|
127
|
+
selectPlatform: unavailable,
|
|
128
|
+
selectScope: unavailable,
|
|
129
|
+
selectPlugins: unavailable,
|
|
130
|
+
configurePlugin: unavailable,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function formatChoice(choice, index, defaultValues) {
|
|
134
|
+
const marker = defaultValues.has(choice.value) ? ' (默认)' : '';
|
|
135
|
+
const disabled = choice.disabled
|
|
136
|
+
? ` - ${typeof choice.disabled === 'string' ? choice.disabled : '不可选'}`
|
|
137
|
+
: '';
|
|
138
|
+
return `${index + 1}. ${choice.label}${marker}${disabled}`;
|
|
139
|
+
}
|
|
140
|
+
function parseSelectionInput(answer, choices, defaults, allowMultiple) {
|
|
141
|
+
const trimmed = answer.trim();
|
|
142
|
+
if (!trimmed) {
|
|
143
|
+
return defaults;
|
|
144
|
+
}
|
|
145
|
+
const tokens = allowMultiple
|
|
146
|
+
? trimmed.split(',').map((entry) => entry.trim()).filter(Boolean)
|
|
147
|
+
: [trimmed];
|
|
148
|
+
const selected = [];
|
|
149
|
+
for (const token of tokens) {
|
|
150
|
+
const numericIndex = Number(token);
|
|
151
|
+
const choice = Number.isInteger(numericIndex)
|
|
152
|
+
? choices[numericIndex - 1]
|
|
153
|
+
: choices.find((entry) => entry.value === token);
|
|
154
|
+
if (!choice) {
|
|
155
|
+
throw new Error(`无效选择:${token}`);
|
|
156
|
+
}
|
|
157
|
+
if (choice.disabled) {
|
|
158
|
+
throw new Error(`不可选择 ${choice.label}:${typeof choice.disabled === 'string' ? choice.disabled : '已禁用'}`);
|
|
159
|
+
}
|
|
160
|
+
selected.push(choice.value);
|
|
161
|
+
}
|
|
162
|
+
return [...new Set(selected)];
|
|
163
|
+
}
|
|
164
|
+
function createPromptWritable(outputSink) {
|
|
165
|
+
const writable = new Writable({
|
|
166
|
+
write(chunk, _encoding, callback) {
|
|
167
|
+
outputSink.write(typeof chunk === 'string' ? chunk : chunk.toString('utf8'));
|
|
168
|
+
callback();
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
writable.isTTY = outputSink.isTTY;
|
|
172
|
+
return writable;
|
|
173
|
+
}
|
|
174
|
+
function createPromptResult(value) {
|
|
175
|
+
return {
|
|
176
|
+
action: 'select',
|
|
177
|
+
cancelled: false,
|
|
178
|
+
value,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function createPromptActionResult(action) {
|
|
182
|
+
return {
|
|
183
|
+
action,
|
|
184
|
+
cancelled: action === 'cancel',
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function unwrapPromptResult(result, message = 'Interactive prompt cancelled.') {
|
|
188
|
+
if (result.action !== 'select' || result.value === undefined) {
|
|
189
|
+
throw new Error(message);
|
|
190
|
+
}
|
|
191
|
+
return result.value;
|
|
192
|
+
}
|
|
193
|
+
function shouldPromptConfigKey(key, definition, options) {
|
|
194
|
+
const currentValue = options.currentValues?.[key];
|
|
195
|
+
const configured = currentValue !== undefined || options.configuredKeys?.includes(key) === true;
|
|
196
|
+
return Boolean(definition.required ||
|
|
197
|
+
options.requiredKeys?.includes(key) ||
|
|
198
|
+
!configured);
|
|
199
|
+
}
|
|
200
|
+
function formatConfigKeyChoiceLabel(key, definition, options) {
|
|
201
|
+
const label = definition.label ?? key;
|
|
202
|
+
const currentValue = options.currentValues?.[key];
|
|
203
|
+
const configured = currentValue !== undefined || options.configuredKeys?.includes(key) === true;
|
|
204
|
+
if (!configured) {
|
|
205
|
+
return label;
|
|
206
|
+
}
|
|
207
|
+
if (definition.sensitive) {
|
|
208
|
+
return `${label}(当前:已配置)`;
|
|
209
|
+
}
|
|
210
|
+
return `${label}(当前:${String(currentValue)})`;
|
|
211
|
+
}
|
|
212
|
+
function parsePromptedConfigValue(key, definition, answer) {
|
|
213
|
+
const trimmed = answer.trim();
|
|
214
|
+
if (!trimmed) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
if (definition.type === 'number') {
|
|
218
|
+
const parsed = Number(trimmed);
|
|
219
|
+
if (!Number.isFinite(parsed)) {
|
|
220
|
+
throw new Error(`配置项 ${key} 需要数字。`);
|
|
221
|
+
}
|
|
222
|
+
return parsed;
|
|
223
|
+
}
|
|
224
|
+
if (definition.type === 'boolean') {
|
|
225
|
+
const normalized = trimmed.toLowerCase();
|
|
226
|
+
if (['true', '1', 'yes', 'y'].includes(normalized)) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
if (['false', '0', 'no', 'n'].includes(normalized)) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
throw new Error(`配置项 ${key} 需要布尔值。`);
|
|
233
|
+
}
|
|
234
|
+
return answer;
|
|
235
|
+
}
|
|
236
|
+
function normalizePromptInput(value) {
|
|
237
|
+
return value.trim();
|
|
238
|
+
}
|
|
239
|
+
function resolveTypedPromptAction(answer, options = {}) {
|
|
240
|
+
const mode = options.mode ?? 'text';
|
|
241
|
+
const normalized = normalizePromptInput(answer);
|
|
242
|
+
if (normalized === '\u0003') {
|
|
243
|
+
return 'exit';
|
|
244
|
+
}
|
|
245
|
+
if (normalized === '\u001B') {
|
|
246
|
+
if (mode === 'menu') {
|
|
247
|
+
return options.allowBack ? 'back' : 'exit';
|
|
248
|
+
}
|
|
249
|
+
return 'cancel';
|
|
250
|
+
}
|
|
251
|
+
if (mode !== 'menu') {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
if (options.allowBack && ['b', 'B'].includes(normalized)) {
|
|
255
|
+
return 'back';
|
|
256
|
+
}
|
|
257
|
+
if ((options.allowExit ?? true) && ['q', 'Q'].includes(normalized)) {
|
|
258
|
+
return 'exit';
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
function resolveChoiceResult(value, choices) {
|
|
263
|
+
const choice = choices.find((entry) => entry.value === value);
|
|
264
|
+
if (choice?.role === 'back') {
|
|
265
|
+
return createPromptActionResult('back');
|
|
266
|
+
}
|
|
267
|
+
if (choice?.role === 'exit') {
|
|
268
|
+
return createPromptActionResult('exit');
|
|
269
|
+
}
|
|
270
|
+
return createPromptResult(value);
|
|
271
|
+
}
|
|
272
|
+
function createMutedOutput(outputSink) {
|
|
273
|
+
const mutedOutput = new Writable({
|
|
274
|
+
write(_chunk, _encoding, callback) {
|
|
275
|
+
callback();
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
mutedOutput.isTTY = outputSink.isTTY;
|
|
279
|
+
return mutedOutput;
|
|
280
|
+
}
|
|
281
|
+
export function createReadlinePrompt(options = {}) {
|
|
282
|
+
const input = options.input ?? process.stdin;
|
|
283
|
+
const outputSink = options.outputSink ?? process.stderr;
|
|
284
|
+
const output = createPromptWritable(outputSink);
|
|
285
|
+
async function ask(message, askOptions = {}) {
|
|
286
|
+
const hidden = askOptions.hidden === true;
|
|
287
|
+
if (hidden) {
|
|
288
|
+
outputSink.write(message);
|
|
289
|
+
}
|
|
290
|
+
const rl = createInterface({
|
|
291
|
+
input,
|
|
292
|
+
output: hidden ? createMutedOutput(outputSink) : output,
|
|
293
|
+
terminal: Boolean(input.isTTY && outputSink.isTTY),
|
|
294
|
+
});
|
|
295
|
+
const promptText = hidden ? '' : message;
|
|
296
|
+
try {
|
|
297
|
+
const result = await new Promise((resolve, reject) => {
|
|
298
|
+
const handleSigint = () => {
|
|
299
|
+
resolve(createPromptActionResult('exit'));
|
|
300
|
+
};
|
|
301
|
+
rl.once('SIGINT', handleSigint);
|
|
302
|
+
rl.question(promptText)
|
|
303
|
+
.then((answer) => {
|
|
304
|
+
const action = resolveTypedPromptAction(answer, askOptions);
|
|
305
|
+
resolve(action ? createPromptActionResult(action) : createPromptResult(answer));
|
|
306
|
+
})
|
|
307
|
+
.catch(reject)
|
|
308
|
+
.finally(() => {
|
|
309
|
+
rl.off('SIGINT', handleSigint);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
if (hidden) {
|
|
313
|
+
outputSink.write('\n');
|
|
314
|
+
}
|
|
315
|
+
return result;
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
rl.close();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const select = async ({ message, choices, defaultValue }) => {
|
|
322
|
+
const enabledChoices = choices.filter((choice) => !choice.disabled);
|
|
323
|
+
if (enabledChoices.length === 0) {
|
|
324
|
+
throw new Error('没有可选择的候选项。');
|
|
325
|
+
}
|
|
326
|
+
const defaultValues = [defaultValue ?? enabledChoices[0].value];
|
|
327
|
+
const body = choices
|
|
328
|
+
.map((choice, index) => formatChoice(choice, index, new Set(defaultValues)))
|
|
329
|
+
.join('\n');
|
|
330
|
+
const answer = await ask(`${message}\n${body}\n选择编号:`, {
|
|
331
|
+
mode: 'menu',
|
|
332
|
+
allowBack: choices.some((choice) => choice.role === 'back'),
|
|
333
|
+
allowExit: true,
|
|
334
|
+
});
|
|
335
|
+
if (answer.action !== 'select') {
|
|
336
|
+
return answer;
|
|
337
|
+
}
|
|
338
|
+
const selected = parseSelectionInput(answer.value, choices, defaultValues, false);
|
|
339
|
+
return resolveChoiceResult(selected[0], choices);
|
|
340
|
+
};
|
|
341
|
+
const multiSelect = async ({ message, choices, defaultValues, }) => {
|
|
342
|
+
const enabledChoices = choices.filter((choice) => !choice.disabled);
|
|
343
|
+
if (enabledChoices.length === 0) {
|
|
344
|
+
throw new Error('没有可选择的候选项。');
|
|
345
|
+
}
|
|
346
|
+
const defaults = defaultValues && defaultValues.length > 0
|
|
347
|
+
? defaultValues
|
|
348
|
+
: [enabledChoices[0].value];
|
|
349
|
+
const body = choices
|
|
350
|
+
.map((choice, index) => formatChoice(choice, index, new Set(defaults)))
|
|
351
|
+
.join('\n');
|
|
352
|
+
const answer = await ask(`${message}\n${body}\n选择编号,可用逗号分隔多个:`, {
|
|
353
|
+
mode: 'menu',
|
|
354
|
+
allowBack: choices.some((choice) => choice.role === 'back'),
|
|
355
|
+
allowExit: true,
|
|
356
|
+
});
|
|
357
|
+
if (answer.action !== 'select') {
|
|
358
|
+
return createPromptActionResult(answer.action);
|
|
359
|
+
}
|
|
360
|
+
return createPromptResult(parseSelectionInput(answer.value, choices, defaults, true));
|
|
361
|
+
};
|
|
362
|
+
const confirm = async ({ message, defaultValue = true }) => {
|
|
363
|
+
const suffix = defaultValue ? 'Y/n' : 'y/N';
|
|
364
|
+
const answer = await ask(`${message} [${suffix}] `, { mode: 'confirm' });
|
|
365
|
+
if (answer.action !== 'select') {
|
|
366
|
+
return createPromptActionResult(answer.action);
|
|
367
|
+
}
|
|
368
|
+
const normalized = answer.value.trim().toLowerCase();
|
|
369
|
+
if (!normalized) {
|
|
370
|
+
return createPromptResult(defaultValue);
|
|
371
|
+
}
|
|
372
|
+
return createPromptResult(normalized === 'y' || normalized === 'yes');
|
|
373
|
+
};
|
|
374
|
+
const inputPrompt = async ({ message, defaultValue }) => {
|
|
375
|
+
const answer = await ask(defaultValue === undefined
|
|
376
|
+
? `${message}: `
|
|
377
|
+
: `${message}(默认:${defaultValue}): `, { mode: 'text' });
|
|
378
|
+
if (answer.action !== 'select') {
|
|
379
|
+
return answer;
|
|
380
|
+
}
|
|
381
|
+
return createPromptResult(answer.value.trim() === '' && defaultValue !== undefined ? defaultValue : answer.value);
|
|
382
|
+
};
|
|
383
|
+
const passwordPrompt = async ({ message }) => {
|
|
384
|
+
const answer = await ask(`${message}: `, { hidden: true, mode: 'text' });
|
|
385
|
+
if (answer.action !== 'select') {
|
|
386
|
+
return answer;
|
|
387
|
+
}
|
|
388
|
+
return createPromptResult(answer.value);
|
|
389
|
+
};
|
|
390
|
+
return {
|
|
391
|
+
select,
|
|
392
|
+
multiSelect,
|
|
393
|
+
confirm,
|
|
394
|
+
input: inputPrompt,
|
|
395
|
+
password: passwordPrompt,
|
|
396
|
+
selectPlatform: async ({ available, defaultValue, message }) => unwrapPromptResult(await select({
|
|
397
|
+
message: message ?? '选择目标平台',
|
|
398
|
+
choices: available.map((value) => ({
|
|
399
|
+
value,
|
|
400
|
+
label: value === 'both' ? '全部支持平台' : value === 'codex' ? 'Codex' : 'Claude Code',
|
|
401
|
+
})),
|
|
402
|
+
defaultValue,
|
|
403
|
+
})),
|
|
404
|
+
selectScope: async ({ defaultValue = 'user' }) => unwrapPromptResult(await select({
|
|
405
|
+
message: '选择安装范围',
|
|
406
|
+
choices: [
|
|
407
|
+
{ value: 'user', label: 'user' },
|
|
408
|
+
{ value: 'project', label: 'project' },
|
|
409
|
+
],
|
|
410
|
+
defaultValue,
|
|
411
|
+
})),
|
|
412
|
+
selectPlugins: async ({ command, candidates, defaultValues, allowMultiple }) => {
|
|
413
|
+
const choices = candidates.map((candidate) => ({
|
|
414
|
+
value: candidate.id,
|
|
415
|
+
label: `${candidate.pluginName}${candidate.platform ? ` / ${candidate.platform}` : ''}${candidate.scope ? ` / ${candidate.scope}` : ''}`,
|
|
416
|
+
disabled: candidate.selectable ? undefined : candidate.disabledReason ?? true,
|
|
417
|
+
}));
|
|
418
|
+
return allowMultiple
|
|
419
|
+
? unwrapPromptResult(await multiSelect({
|
|
420
|
+
message: `选择要${command === 'install' ? '安装' : '卸载'}的插件`,
|
|
421
|
+
choices,
|
|
422
|
+
defaultValues,
|
|
423
|
+
}))
|
|
424
|
+
: [unwrapPromptResult(await select({
|
|
425
|
+
message: `选择要${command === 'install' ? '安装' : '卸载'}的插件`,
|
|
426
|
+
choices,
|
|
427
|
+
defaultValue: defaultValues?.[0],
|
|
428
|
+
}))];
|
|
429
|
+
},
|
|
430
|
+
configurePlugin: async (configOptions) => {
|
|
431
|
+
const selectedScope = configOptions.allowedScopes.length > 1
|
|
432
|
+
? unwrapPromptResult(await select({
|
|
433
|
+
message: `选择 ${configOptions.pluginName} 配置写入范围`,
|
|
434
|
+
choices: configOptions.allowedScopes.map((value) => ({ value, label: value })),
|
|
435
|
+
defaultValue: configOptions.initialScope,
|
|
436
|
+
}))
|
|
437
|
+
: configOptions.initialScope;
|
|
438
|
+
const updates = {};
|
|
439
|
+
const removeKeys = [];
|
|
440
|
+
const keysToPrompt = new Set();
|
|
441
|
+
const optionalConfiguredChoices = [];
|
|
442
|
+
for (const [key, definition] of Object.entries(configOptions.schema)) {
|
|
443
|
+
if (shouldPromptConfigKey(key, definition, configOptions)) {
|
|
444
|
+
keysToPrompt.add(key);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
optionalConfiguredChoices.push({
|
|
448
|
+
value: key,
|
|
449
|
+
label: formatConfigKeyChoiceLabel(key, definition, configOptions),
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
if (optionalConfiguredChoices.length > 0) {
|
|
453
|
+
const body = optionalConfiguredChoices
|
|
454
|
+
.map((choice, index) => formatChoice(choice, index, new Set()))
|
|
455
|
+
.join('\n');
|
|
456
|
+
const selectedKeysAnswer = await ask(`选择要更新的 ${configOptions.pluginName} 配置项\n${body}\n选择编号,可用逗号分隔多个,直接回车跳过:`, { mode: 'menu', allowExit: true });
|
|
457
|
+
if (selectedKeysAnswer.action !== 'select') {
|
|
458
|
+
return {
|
|
459
|
+
selectedScope,
|
|
460
|
+
updates: {},
|
|
461
|
+
updatedKeys: [],
|
|
462
|
+
removeKeys: [],
|
|
463
|
+
cancelled: true,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
const selectedKeys = parseSelectionInput(selectedKeysAnswer.value, optionalConfiguredChoices, [], true);
|
|
467
|
+
for (const key of selectedKeys) {
|
|
468
|
+
keysToPrompt.add(key);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
for (const [key, definition] of Object.entries(configOptions.schema)) {
|
|
472
|
+
if (!keysToPrompt.has(key)) {
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
const label = definition.label ?? key;
|
|
476
|
+
if (definition.enum && definition.enum.length > 0) {
|
|
477
|
+
const selected = unwrapPromptResult(await select({
|
|
478
|
+
message: label,
|
|
479
|
+
choices: definition.enum.map((value) => ({
|
|
480
|
+
value: String(value),
|
|
481
|
+
label: String(value),
|
|
482
|
+
})),
|
|
483
|
+
defaultValue: configOptions.currentValues?.[key] === undefined
|
|
484
|
+
? undefined
|
|
485
|
+
: String(configOptions.currentValues[key]),
|
|
486
|
+
}));
|
|
487
|
+
updates[key] = definition.enum.find((value) => String(value) === selected);
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (definition.type === 'boolean') {
|
|
491
|
+
updates[key] = await (async () => {
|
|
492
|
+
const current = configOptions.currentValues?.[key];
|
|
493
|
+
return unwrapPromptResult(current === undefined
|
|
494
|
+
? await confirm({ message: label, defaultValue: Boolean(definition.default) })
|
|
495
|
+
: await confirm({ message: label, defaultValue: Boolean(current) }));
|
|
496
|
+
})();
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const current = configOptions.currentValues?.[key];
|
|
500
|
+
const configured = current !== undefined || configOptions.configuredKeys?.includes(key) === true;
|
|
501
|
+
const suffix = !configured || definition.sensitive
|
|
502
|
+
? definition.sensitive && configured
|
|
503
|
+
? '(当前:已配置)'
|
|
504
|
+
: ''
|
|
505
|
+
: `(当前:${String(current)})`;
|
|
506
|
+
const answer = await ask(`${label}${suffix}: `, {
|
|
507
|
+
hidden: definition.sensitive && definition.type === 'string',
|
|
508
|
+
mode: 'text',
|
|
509
|
+
});
|
|
510
|
+
if (answer.action !== 'select') {
|
|
511
|
+
return {
|
|
512
|
+
selectedScope,
|
|
513
|
+
updates,
|
|
514
|
+
updatedKeys: Object.keys(updates),
|
|
515
|
+
removeKeys,
|
|
516
|
+
cancelled: true,
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
const parsed = parsePromptedConfigValue(key, definition, answer.value);
|
|
520
|
+
if (parsed !== undefined) {
|
|
521
|
+
updates[key] = parsed;
|
|
522
|
+
}
|
|
523
|
+
else if (!definition.required && configured) {
|
|
524
|
+
removeKeys.push(key);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const result = {
|
|
528
|
+
selectedScope,
|
|
529
|
+
updates,
|
|
530
|
+
updatedKeys: Object.keys(updates),
|
|
531
|
+
removeKeys,
|
|
532
|
+
cancelled: false,
|
|
533
|
+
};
|
|
534
|
+
return validateCliConfigPromptResult(configOptions, result);
|
|
535
|
+
},
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function nativeEventIdentity(invocation) {
|
|
539
|
+
const executable = path.basename(invocation.command).toLowerCase().replace(/\.exe$/u, '');
|
|
540
|
+
const agent = executable === 'codex' || executable === 'claude' || executable === 'skills'
|
|
541
|
+
? executable
|
|
542
|
+
: 'unknown';
|
|
543
|
+
const args = new Set(invocation.args.map((arg) => arg.toLowerCase()));
|
|
544
|
+
const operation = args.has('--version') || args.has('version')
|
|
545
|
+
? 'version'
|
|
546
|
+
: args.has('marketplace') ? 'marketplace'
|
|
547
|
+
: args.has('plugin') || args.has('plugins') ? 'plugin'
|
|
548
|
+
: agent === 'skills' ? 'skill'
|
|
549
|
+
: 'other';
|
|
550
|
+
return { agent, operation };
|
|
551
|
+
}
|
|
552
|
+
function serializeNativeError(error) {
|
|
553
|
+
if (error instanceof NativeCliError) {
|
|
554
|
+
return {
|
|
555
|
+
exitCode: error.exitCode,
|
|
556
|
+
reason: error.reason,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
return { reason: 'runnerFailure' };
|
|
560
|
+
}
|
|
561
|
+
function createInstrumentedNativeCliRunner(options) {
|
|
562
|
+
return async (invocation) => {
|
|
563
|
+
const startedAt = Date.now();
|
|
564
|
+
const identity = nativeEventIdentity(invocation);
|
|
565
|
+
await emitRuntimeEvent(options, {
|
|
566
|
+
type: 'native:start',
|
|
567
|
+
commandName: options.diagnostics.commandName,
|
|
568
|
+
data: identity,
|
|
569
|
+
});
|
|
570
|
+
try {
|
|
571
|
+
const result = await options.baseRunner(invocation);
|
|
572
|
+
await emitRuntimeEvent(options, {
|
|
573
|
+
type: 'native:success',
|
|
574
|
+
commandName: options.diagnostics.commandName,
|
|
575
|
+
data: {
|
|
576
|
+
...identity,
|
|
577
|
+
exitCode: result.exitCode,
|
|
578
|
+
durationMs: Date.now() - startedAt,
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
return result;
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
await emitRuntimeEvent(options, {
|
|
585
|
+
type: 'native:error',
|
|
586
|
+
commandName: options.diagnostics.commandName,
|
|
587
|
+
data: {
|
|
588
|
+
...identity,
|
|
589
|
+
...serializeNativeError(error),
|
|
590
|
+
durationMs: Date.now() - startedAt,
|
|
591
|
+
},
|
|
592
|
+
});
|
|
593
|
+
throw error;
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
async function emitRuntimeEvent(runtime, event) {
|
|
598
|
+
await Promise.allSettled([
|
|
599
|
+
Promise.resolve().then(() => runtime.reporter.event(event)),
|
|
600
|
+
Promise.resolve().then(() => runtime.debugLogger.log(event)),
|
|
601
|
+
]);
|
|
602
|
+
}
|
|
603
|
+
export async function emitCommandEvent(context, event) {
|
|
604
|
+
await emitRuntimeEvent(context, {
|
|
605
|
+
commandName: context.diagnostics.commandName,
|
|
606
|
+
...event,
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
export async function emitCommandNotice(context, notice) {
|
|
610
|
+
await Promise.allSettled([
|
|
611
|
+
Promise.resolve().then(() => context.reporter.notice(notice)),
|
|
612
|
+
Promise.resolve().then(() => context.debugLogger.log({
|
|
613
|
+
type: `notice:${notice.level}`,
|
|
614
|
+
commandName: context.diagnostics.commandName,
|
|
615
|
+
message: notice.message,
|
|
616
|
+
data: notice.identity ? { identity: notice.identity } : undefined,
|
|
617
|
+
})),
|
|
618
|
+
]);
|
|
619
|
+
}
|
|
620
|
+
export function isCommandExecutionContext(input) {
|
|
621
|
+
return Boolean(input &&
|
|
622
|
+
typeof input.env === 'object' &&
|
|
623
|
+
typeof input.nativeCliRunner === 'function' &&
|
|
624
|
+
typeof input.reporter?.event === 'function' &&
|
|
625
|
+
typeof input.debugLogger?.log === 'function' &&
|
|
626
|
+
typeof input.diagnostics?.commandName === 'string');
|
|
627
|
+
}
|
|
628
|
+
export function createCommandExecutionContext(input = {}) {
|
|
629
|
+
if (isCommandExecutionContext(input)) {
|
|
630
|
+
return input;
|
|
631
|
+
}
|
|
632
|
+
const env = input.env ?? process.env;
|
|
633
|
+
const diagnostics = createCommandDiagnostics(input.diagnostics, env);
|
|
634
|
+
const reporter = input.reporter ?? createNoopReporter();
|
|
635
|
+
const debugLogger = input.debugLogger ?? createFileDebugLogger(diagnostics);
|
|
636
|
+
const baseRunner = input.nativeCliRunner ?? getDefaultNativeCliRunner();
|
|
637
|
+
const contextShell = {
|
|
638
|
+
reporter,
|
|
639
|
+
debugLogger,
|
|
640
|
+
};
|
|
641
|
+
return {
|
|
642
|
+
env,
|
|
643
|
+
nativeCliRunner: createInstrumentedNativeCliRunner({
|
|
644
|
+
baseRunner,
|
|
645
|
+
diagnostics,
|
|
646
|
+
...contextShell,
|
|
647
|
+
}),
|
|
648
|
+
interactive: input.interactive ?? false,
|
|
649
|
+
prompt: input.prompt ?? createUnavailablePrompt(),
|
|
650
|
+
reporter,
|
|
651
|
+
debugLogger,
|
|
652
|
+
diagnostics,
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
export function createCliExecutionContext(input = {}) {
|
|
656
|
+
const cwd = input.cwd ?? process.cwd();
|
|
657
|
+
const env = input.env ?? process.env;
|
|
658
|
+
const io = {
|
|
659
|
+
...createDefaultIo(),
|
|
660
|
+
...input.io,
|
|
661
|
+
};
|
|
662
|
+
const stdin = input.stdin ?? process.stdin;
|
|
663
|
+
const stdout = input.stdout ?? process.stdout;
|
|
664
|
+
const promptOutputSink = input.promptOutputSink ?? process.stderr;
|
|
665
|
+
const stdinIsTty = Boolean(stdin.isTTY);
|
|
666
|
+
const stdoutIsTty = Boolean(stdout.isTTY);
|
|
667
|
+
const promptOutputIsTty = Boolean(promptOutputSink.isTTY);
|
|
668
|
+
const isTty = stdinIsTty && stdoutIsTty && promptOutputIsTty;
|
|
669
|
+
const isCi = isTruthy(env.CI);
|
|
670
|
+
const hasInjectedPrompt = Boolean(input.prompt);
|
|
671
|
+
const hasInjectedTuiRunner = Boolean(input.tuiRunner);
|
|
672
|
+
const requestedInteractive = input.interactive ?? (hasInjectedPrompt || hasInjectedTuiRunner ? true : isTty);
|
|
673
|
+
const interactive = requestedInteractive
|
|
674
|
+
&& !isCi
|
|
675
|
+
&& (isTty || hasInjectedPrompt || hasInjectedTuiRunner);
|
|
676
|
+
const diagnostics = createCommandDiagnostics({
|
|
677
|
+
...input.diagnostics,
|
|
678
|
+
metadata: {
|
|
679
|
+
...input.diagnostics?.metadata,
|
|
680
|
+
cwd,
|
|
681
|
+
awHome: resolveAwHome(env),
|
|
682
|
+
isTty,
|
|
683
|
+
isCi,
|
|
684
|
+
stdinIsTty,
|
|
685
|
+
stdoutIsTty,
|
|
686
|
+
promptOutputIsTty,
|
|
687
|
+
interactiveRequested: requestedInteractive,
|
|
688
|
+
interactiveEnabled: interactive,
|
|
689
|
+
},
|
|
690
|
+
}, env);
|
|
691
|
+
const reporter = createSessionAwareReporter(input.reporter ?? createIoReporter(io, diagnostics));
|
|
692
|
+
const debugLogger = input.debugLogger ?? createFileDebugLogger(diagnostics);
|
|
693
|
+
const prompt = input.prompt ?? (interactive
|
|
694
|
+
? createInkPrompt({
|
|
695
|
+
input: stdin,
|
|
696
|
+
outputSink: promptOutputSink,
|
|
697
|
+
})
|
|
698
|
+
: createUnavailablePrompt());
|
|
699
|
+
const tuiRunner = input.tuiRunner ?? createInkTuiRunner();
|
|
700
|
+
const commandContext = createCommandExecutionContext({
|
|
701
|
+
...input,
|
|
702
|
+
env,
|
|
703
|
+
interactive,
|
|
704
|
+
prompt,
|
|
705
|
+
reporter,
|
|
706
|
+
debugLogger,
|
|
707
|
+
diagnostics,
|
|
708
|
+
});
|
|
709
|
+
return {
|
|
710
|
+
...commandContext,
|
|
711
|
+
cwd,
|
|
712
|
+
io,
|
|
713
|
+
stdin,
|
|
714
|
+
isTty,
|
|
715
|
+
isCi,
|
|
716
|
+
tuiRunner,
|
|
717
|
+
tuiOutput: promptOutputSink,
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
//# sourceMappingURL=runtime.js.map
|