@ai-agent-forge/agent-forge 0.86.7 → 0.88.0
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/CHANGELOG.md +45 -0
- package/README.md +10 -11
- package/dist/artifacts/artifact-store.d.ts.map +1 -1
- package/dist/artifacts/artifact-store.js +9 -5
- package/dist/artifacts/artifact-store.js.map +1 -1
- package/dist/bundle/.build-manifest.json +430 -413
- package/dist/bundle/chunks/{chunk-A7GUOX2H.js → chunk-6ZKDNZHA.js} +5 -1
- package/dist/bundle/chunks/chunk-HLJEVRWP.js +13 -0
- package/dist/bundle/chunks/chunk-YGHQME4V.js +1456 -0
- package/dist/bundle/chunks/image-resize-worker.js +12 -1
- package/dist/bundle/chunks/{virtual-modules-3IZ4MYSQ.js → virtual-modules-KZ5DRH7Q.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +2 -2
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +231 -185
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +17 -4
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +15 -9
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +14 -7
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/experimental/command.d.ts.map +1 -1
- package/dist/cli/experimental/command.js +6 -5
- package/dist/cli/experimental/command.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +9 -8
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/plugin-manager-controller.d.ts.map +1 -1
- package/dist/cli/plugin-manager-controller.js +2 -1
- package/dist/cli/plugin-manager-controller.js.map +1 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +8 -5
- package/dist/cli/serve.js.map +1 -1
- package/dist/client/remote-session.d.ts.map +1 -1
- package/dist/client/remote-session.js +16 -9
- package/dist/client/remote-session.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-capability-contract.d.ts +0 -7
- package/dist/core/agent-capability-contract.d.ts.map +1 -1
- package/dist/core/agent-capability-contract.js +72 -68
- package/dist/core/agent-capability-contract.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +5 -4
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +6 -10
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +35 -133
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-context.d.ts.map +1 -1
- package/dist/core/agent-session-context.js +18 -13
- package/dist/core/agent-session-context.js.map +1 -1
- package/dist/core/agent-session-internal.d.ts +0 -6
- package/dist/core/agent-session-internal.d.ts.map +1 -1
- package/dist/core/agent-session-internal.js.map +1 -1
- package/dist/core/agent-session-model.d.ts.map +1 -1
- package/dist/core/agent-session-model.js +2 -1
- package/dist/core/agent-session-model.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +3 -3
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +7 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +3 -2
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +40 -22
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +147 -67
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js +11 -5
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +9 -6
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +2 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/embedded-sdk.d.ts.map +1 -1
- package/dist/core/embedded-sdk.js +10 -6
- package/dist/core/embedded-sdk.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +9 -4
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/extensions/agent-composition.d.ts.map +1 -1
- package/dist/core/extensions/agent-composition.js +26 -19
- package/dist/core/extensions/agent-composition.js.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.js +3 -2
- package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-compaction-policy.js +0 -34
- package/dist/core/extensions/bootstrap-compaction-policy.js.map +1 -1
- package/dist/core/extensions/bootstrap-lifecycle.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-lifecycle.js +20 -17
- package/dist/core/extensions/bootstrap-lifecycle.js.map +1 -1
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-overflow-policy.js +2 -1
- package/dist/core/extensions/bootstrap-overflow-policy.js.map +1 -1
- package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-retry-policy.js +4 -3
- package/dist/core/extensions/bootstrap-retry-policy.js.map +1 -1
- package/dist/core/extensions/bootstrap-skills.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-skills.js +7 -6
- package/dist/core/extensions/bootstrap-skills.js.map +1 -1
- package/dist/core/extensions/bootstrap-tools.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-tools.js +2 -1
- package/dist/core/extensions/bootstrap-tools.js.map +1 -1
- package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
- package/dist/core/extensions/capability-plugin.js +37 -13
- package/dist/core/extensions/capability-plugin.js.map +1 -1
- package/dist/core/extensions/capability-runtime-events.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-events.js +17 -13
- package/dist/core/extensions/capability-runtime-events.js.map +1 -1
- package/dist/core/extensions/capability-runtime-guards.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-guards.js +16 -15
- package/dist/core/extensions/capability-runtime-guards.js.map +1 -1
- package/dist/core/extensions/capability-runtime-manifest.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-manifest.js +52 -30
- package/dist/core/extensions/capability-runtime-manifest.js.map +1 -1
- package/dist/core/extensions/capability-runtime-validation.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-validation.js +66 -65
- package/dist/core/extensions/capability-runtime-validation.js.map +1 -1
- package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime.js +147 -127
- package/dist/core/extensions/capability-runtime.js.map +1 -1
- package/dist/core/extensions/compaction-memory-failure-mode.d.ts.map +1 -1
- package/dist/core/extensions/compaction-memory-failure-mode.js +3 -2
- package/dist/core/extensions/compaction-memory-failure-mode.js.map +1 -1
- package/dist/core/extensions/context-strategy-binding.d.ts.map +1 -1
- package/dist/core/extensions/context-strategy-binding.js +7 -4
- package/dist/core/extensions/context-strategy-binding.js.map +1 -1
- package/dist/core/extensions/lifecycle-catalog.d.ts.map +1 -1
- package/dist/core/extensions/lifecycle-catalog.js +290 -279
- package/dist/core/extensions/lifecycle-catalog.js.map +1 -1
- package/dist/core/extensions/lifecycle-delivery-queue.d.ts.map +1 -1
- package/dist/core/extensions/lifecycle-delivery-queue.js +3 -2
- package/dist/core/extensions/lifecycle-delivery-queue.js.map +1 -1
- package/dist/core/extensions/provider-failover.d.ts +7 -3
- package/dist/core/extensions/provider-failover.d.ts.map +1 -1
- package/dist/core/extensions/provider-failover.js +9 -8
- package/dist/core/extensions/provider-failover.js.map +1 -1
- package/dist/core/facade/coding-agent-facade.d.ts +6 -6
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-facade.js +2 -3
- package/dist/core/facade/coding-agent-facade.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/i18n/index.d.ts +14 -0
- package/dist/core/i18n/index.d.ts.map +1 -0
- package/dist/core/i18n/index.js +67 -0
- package/dist/core/i18n/index.js.map +1 -0
- package/dist/core/i18n/locales/en/example.d.ts +7 -0
- package/dist/core/i18n/locales/en/example.d.ts.map +1 -0
- package/dist/core/i18n/locales/en/example.js +7 -0
- package/dist/core/i18n/locales/en/example.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/cli.d.ts +8 -0
- package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/cli.js +229 -0
- package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/common.d.ts +6 -0
- package/dist/core/i18n/locales/zh-cn/common.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/common.js +6 -0
- package/dist/core/i18n/locales/zh-cn/common.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +13 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js +173 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts +12 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +582 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +9 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js +55 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts +11 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +455 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts +9 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.js +191 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/example.d.ts +7 -0
- package/dist/core/i18n/locales/zh-cn/example.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/example.js +10 -0
- package/dist/core/i18n/locales/zh-cn/example.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/index.d.ts +2 -0
- package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/index.js +41 -0
- package/dist/core/i18n/locales/zh-cn/index.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts +10 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js +267 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.d.ts +11 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.js +67 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts +7 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.js +39 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts +10 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.js +15 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts +13 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +102 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts +12 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +286 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts +9 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js +79 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts +8 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.js +72 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.js.map +1 -0
- package/dist/core/keybindings.d.ts +15 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +18 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +5 -1
- package/dist/core/logger.js.map +1 -1
- package/dist/core/model-config.d.ts +0 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +9 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +11 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-install-host.d.ts.map +1 -1
- package/dist/core/package-install-host.js +4 -3
- package/dist/core/package-install-host.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +15 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/package-resource-collection.d.ts.map +1 -1
- package/dist/core/package-resource-collection.js +2 -1
- package/dist/core/package-resource-collection.js.map +1 -1
- package/dist/core/package-source.d.ts.map +1 -1
- package/dist/core/package-source.js +3 -2
- package/dist/core/package-source.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +29 -21
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +6 -2
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +15 -5
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/sdk.d.ts +27 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +80 -55
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +5 -2
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-export.d.ts.map +1 -1
- package/dist/core/session-export.js +2 -1
- package/dist/core/session-export.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +39 -29
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-storage.d.ts.map +1 -1
- package/dist/core/session-storage.js +3 -3
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/settings-manager.d.ts +20 -20
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +47 -59
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +53 -32
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +25 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +11 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +9 -4
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +4 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +3 -2
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +2 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +6 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/durable/durable-service.d.ts.map +1 -1
- package/dist/durable/durable-service.js +25 -18
- package/dist/durable/durable-service.js.map +1 -1
- package/dist/host/checkpoint-commit.d.ts.map +1 -1
- package/dist/host/checkpoint-commit.js +2 -1
- package/dist/host/checkpoint-commit.js.map +1 -1
- package/dist/host/manual-compaction.d.ts.map +1 -1
- package/dist/host/manual-compaction.js +2 -1
- package/dist/host/manual-compaction.js.map +1 -1
- package/dist/host/output-projection.d.ts +0 -13
- package/dist/host/output-projection.d.ts.map +1 -1
- package/dist/host/output-projection.js +16 -2
- package/dist/host/output-projection.js.map +1 -1
- package/dist/host/summary-retry.d.ts.map +1 -1
- package/dist/host/summary-retry.js +3 -2
- package/dist/host/summary-retry.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +97 -60
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/agents-view.js +18 -15
- package/dist/modes/interactive/components/agents-view.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +6 -5
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +12 -7
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +2 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +6 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +9 -5
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +18 -15
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +2 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.js +5 -4
- package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
- package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-input.js +2 -1
- package/dist/modes/interactive/components/dialog-input.js.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.js +4 -3
- package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +11 -10
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +0 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -10
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +3 -2
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +12 -11
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +6 -2
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +28 -16
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +10 -9
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.js +22 -13
- package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.js +27 -12
- package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.d.ts +60 -0
- package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/queue-manager-selector.js +166 -0
- package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +16 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +43 -31
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -6
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +115 -120
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +5 -4
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +3 -2
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +4 -3
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +14 -5
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +11 -4
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +8 -3
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-list.js +7 -6
- package/dist/modes/interactive/components/tree-list.js.map +1 -1
- package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-render.js +28 -23
- package/dist/modes/interactive/components/tree-render.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +9 -7
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +5 -4
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/workflow-view.js +36 -21
- package/dist/modes/interactive/components/workflow-view.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth.js +71 -40
- package/dist/modes/interactive/interactive-auth.js.map +1 -1
- package/dist/modes/interactive/interactive-commands.d.ts +1 -0
- package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-commands.js +3 -0
- package/dist/modes/interactive/interactive-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-dialog-ui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-dialog-ui.js +5 -5
- package/dist/modes/interactive/interactive-dialog-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-format.js +34 -18
- package/dist/modes/interactive/interactive-format.js.map +1 -1
- package/dist/modes/interactive/interactive-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-helpers.js +7 -2
- package/dist/modes/interactive/interactive-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +350 -279
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.d.ts +9 -0
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +79 -25
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +5 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +26 -23
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +3 -2
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +3 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +3 -14
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +0 -9
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +0 -19
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +28 -13
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/plugins/ecosystem/catalog.d.ts.map +1 -1
- package/dist/plugins/ecosystem/catalog.js +3 -2
- package/dist/plugins/ecosystem/catalog.js.map +1 -1
- package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +2 -1
- package/dist/plugins/ecosystem/cli.js.map +1 -1
- package/dist/plugins/ecosystem/default-plugin-market.d.ts.map +1 -1
- package/dist/plugins/ecosystem/default-plugin-market.js +3 -2
- package/dist/plugins/ecosystem/default-plugin-market.js.map +1 -1
- package/dist/plugins/ecosystem/distribution.d.ts.map +1 -1
- package/dist/plugins/ecosystem/distribution.js +2 -1
- package/dist/plugins/ecosystem/distribution.js.map +1 -1
- package/dist/plugins/ecosystem/installer.d.ts.map +1 -1
- package/dist/plugins/ecosystem/installer.js +3 -2
- package/dist/plugins/ecosystem/installer.js.map +1 -1
- package/dist/plugins/ecosystem/node-disk-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-disk-registry-source.js +20 -17
- package/dist/plugins/ecosystem/node-disk-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-distribution-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-distribution-host.js +35 -34
- package/dist/plugins/ecosystem/node-distribution-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.js +35 -34
- package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.js +9 -8
- package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-persistence.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-persistence.js +4 -3
- package/dist/plugins/ecosystem/node-package-install-persistence.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +9 -2
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +44 -5
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-trust-root.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-trust-root.js +10 -9
- package/dist/plugins/ecosystem/node-plugin-trust-root.js.map +1 -1
- package/dist/plugins/ecosystem/node-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-registry-source.js +31 -30
- package/dist/plugins/ecosystem/node-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-release-package-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-release-package-source.js +30 -29
- package/dist/plugins/ecosystem/node-release-package-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-tar-writer.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-tar-writer.js +11 -10
- package/dist/plugins/ecosystem/node-tar-writer.js.map +1 -1
- package/dist/plugins/ecosystem/node-url-package-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-url-package-source.js +21 -20
- package/dist/plugins/ecosystem/node-url-package-source.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-acquisition.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-acquisition.js +3 -2
- package/dist/plugins/ecosystem/plugin-acquisition.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +9 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +5 -0
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/registry-cli-adapter.d.ts.map +1 -1
- package/dist/plugins/ecosystem/registry-cli-adapter.js +2 -1
- package/dist/plugins/ecosystem/registry-cli-adapter.js.map +1 -1
- package/dist/plugins/ecosystem/registry.d.ts.map +1 -1
- package/dist/plugins/ecosystem/registry.js +35 -32
- package/dist/plugins/ecosystem/registry.js.map +1 -1
- package/dist/plugins/ecosystem/resolver.d.ts.map +1 -1
- package/dist/plugins/ecosystem/resolver.js +3 -2
- package/dist/plugins/ecosystem/resolver.js.map +1 -1
- package/dist/plugins/ecosystem/selection-store.d.ts.map +1 -1
- package/dist/plugins/ecosystem/selection-store.js +11 -10
- package/dist/plugins/ecosystem/selection-store.js.map +1 -1
- package/dist/plugins/ecosystem/selection.d.ts.map +1 -1
- package/dist/plugins/ecosystem/selection.js +8 -7
- package/dist/plugins/ecosystem/selection.js.map +1 -1
- package/dist/plugins/ecosystem/state.d.ts.map +1 -1
- package/dist/plugins/ecosystem/state.js +24 -23
- package/dist/plugins/ecosystem/state.js.map +1 -1
- package/dist/plugins/ecosystem/updates.d.ts.map +1 -1
- package/dist/plugins/ecosystem/updates.js +5 -4
- package/dist/plugins/ecosystem/updates.js.map +1 -1
- package/dist/plugins/mcp-http.d.ts +0 -17
- package/dist/plugins/mcp-http.d.ts.map +1 -1
- package/dist/plugins/mcp-http.js +30 -7
- package/dist/plugins/mcp-http.js.map +1 -1
- package/dist/plugins/plugin-supervisor.d.ts.map +1 -1
- package/dist/plugins/plugin-supervisor.js +19 -1
- package/dist/plugins/plugin-supervisor.js.map +1 -1
- package/dist/profile/first-roles.d.ts.map +1 -1
- package/dist/profile/first-roles.js +10 -1
- package/dist/profile/first-roles.js.map +1 -1
- package/dist/profile/goal-plugin.d.ts.map +1 -1
- package/dist/profile/goal-plugin.js +24 -5
- package/dist/profile/goal-plugin.js.map +1 -1
- package/dist/profile/identity.d.ts.map +1 -1
- package/dist/profile/identity.js +7 -6
- package/dist/profile/identity.js.map +1 -1
- package/dist/profile/lock.d.ts.map +1 -1
- package/dist/profile/lock.js +15 -1
- package/dist/profile/lock.js.map +1 -1
- package/dist/profile/plan-plugin.d.ts.map +1 -1
- package/dist/profile/plan-plugin.js +26 -13
- package/dist/profile/plan-plugin.js.map +1 -1
- package/dist/profile/plugin-profiles.d.ts.map +1 -1
- package/dist/profile/plugin-profiles.js +2 -1
- package/dist/profile/plugin-profiles.js.map +1 -1
- package/dist/profile/policy-manifest.d.ts.map +1 -1
- package/dist/profile/policy-manifest.js +5 -4
- package/dist/profile/policy-manifest.js.map +1 -1
- package/dist/profile/profile-registry.d.ts +0 -12
- package/dist/profile/profile-registry.d.ts.map +1 -1
- package/dist/profile/profile-registry.js +14 -1
- package/dist/profile/profile-registry.js.map +1 -1
- package/dist/profile/role-catalog.d.ts +0 -1
- package/dist/profile/role-catalog.d.ts.map +1 -1
- package/dist/profile/role-catalog.js +17 -15
- package/dist/profile/role-catalog.js.map +1 -1
- package/dist/profile/role-orchestrator.d.ts.map +1 -1
- package/dist/profile/role-orchestrator.js +8 -7
- package/dist/profile/role-orchestrator.js.map +1 -1
- package/dist/profile/role-runner.d.ts.map +1 -1
- package/dist/profile/role-runner.js +3 -2
- package/dist/profile/role-runner.js.map +1 -1
- package/dist/profile/root-facade.d.ts.map +1 -1
- package/dist/profile/root-facade.js +2 -1
- package/dist/profile/root-facade.js.map +1 -1
- package/dist/profile/skill-discovery-wiring.d.ts.map +1 -1
- package/dist/profile/skill-discovery-wiring.js +7 -2
- package/dist/profile/skill-discovery-wiring.js.map +1 -1
- package/dist/profile/state-store.d.ts.map +1 -1
- package/dist/profile/state-store.js +13 -9
- package/dist/profile/state-store.js.map +1 -1
- package/dist/profile/todo-plugin.d.ts.map +1 -1
- package/dist/profile/todo-plugin.js +9 -4
- package/dist/profile/todo-plugin.js.map +1 -1
- package/dist/profiles/builtin-suites.d.ts +13 -6
- package/dist/profiles/builtin-suites.d.ts.map +1 -1
- package/dist/profiles/builtin-suites.js +15 -6
- package/dist/profiles/builtin-suites.js.map +1 -1
- package/dist/profiles/suite-loader.d.ts +25 -1
- package/dist/profiles/suite-loader.d.ts.map +1 -1
- package/dist/profiles/suite-loader.js +34 -9
- package/dist/profiles/suite-loader.js.map +1 -1
- package/dist/remote/server-entry.d.ts.map +1 -1
- package/dist/remote/server-entry.js +3 -2
- package/dist/remote/server-entry.js.map +1 -1
- package/dist/remote/session-source.d.ts.map +1 -1
- package/dist/remote/session-source.js +8 -4
- package/dist/remote/session-source.js.map +1 -1
- package/dist/share/session-share.d.ts.map +1 -1
- package/dist/share/session-share.js +14 -2
- package/dist/share/session-share.js.map +1 -1
- package/dist/testing/plugin-testkit.d.ts.map +1 -1
- package/dist/testing/plugin-testkit.js +4 -3
- package/dist/testing/plugin-testkit.js.map +1 -1
- package/dist/testing/runtime-delivery-queue.d.ts.map +1 -1
- package/dist/testing/runtime-delivery-queue.js +2 -1
- package/dist/testing/runtime-delivery-queue.js.map +1 -1
- package/dist/testing/session-plugin-testkit.d.ts.map +1 -1
- package/dist/testing/session-plugin-testkit.js +10 -7
- package/dist/testing/session-plugin-testkit.js.map +1 -1
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +2 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +7 -6
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -2
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js +2 -2
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +9 -8
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +23 -13
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +5 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +1 -3
- package/docs/docs.json +4 -0
- package/docs/index.md +1 -0
- package/docs/keybindings.md +3 -0
- package/docs/mcp.md +103 -0
- package/docs/models.md +14 -22
- package/docs/providers.md +0 -1
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +1 -26
- package/docs/sdk.md +4 -6
- package/docs/settings.md +10 -12
- package/docs/skills.md +1 -9
- package/docs/terminal-setup.md +2 -3
- package/docs/usage.md +7 -6
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/with-deps/plugin.json +1 -1
- package/examples/sdk/10-settings.ts +2 -4
- package/examples/sdk/12-full-control.ts +1 -2
- package/package.json +1 -3
- package/dist/bundle/chunks/chunk-EALJ5DDX.js +0 -1452
- package/dist/core/extensions/microcompact.d.ts +0 -80
- package/dist/core/extensions/microcompact.d.ts.map +0 -1
- package/dist/core/extensions/microcompact.js +0 -134
- package/dist/core/extensions/microcompact.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -26
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -106
- package/dist/server/create-harness.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-install-host.d.ts","sourceRoot":"","sources":["../../src/core/package-install-host.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEzF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,M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AED,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAMtG;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAmBpE;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAoB7F","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { satisfies } from \"semver\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport type { GitSource } from \"../utils/git.ts\";\nimport { markPathIgnoredByCloudSync } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport type { NpmSource, PackageManagerContext, SourceScope } from \"./package-source.ts\";\n\nexport function getPackageTempFolder(agentDir: string): string {\n\tconst tempFolder = join(agentDir, \"tmp\", \"packages\");\n\tmkdirSync(tempFolder, { recursive: true, mode: 0o700 });\n\tchmodSync(tempFolder, 0o700);\n\treturn tempFolder;\n}\n\nexport function getNpmCommand(ctx: PackageManagerContext): { command: string; args: string[] } {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (!configuredCommand || configuredCommand.length === 0) {\n\t\treturn { command: \"npm\", args: [] };\n\t}\n\tconst [command, ...args] = configuredCommand;\n\tif (!command) {\n\t\tthrow new Error(\"Invalid npmCommand: first array entry must be a non-empty command\");\n\t}\n\treturn { command, args };\n}\n\nexport function getPackageManagerName(ctx: PackageManagerContext): string {\n\tconst npmCommand = getNpmCommand(ctx);\n\tconst commandParts = [npmCommand.command, ...npmCommand.args];\n\tconst separatorIndex = commandParts.lastIndexOf(\"--\");\n\tconst packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;\n\treturn packageManagerCommand ? basename(packageManagerCommand).replace(/\\.(cmd|exe)$/i, \"\") : \"\";\n}\n\nexport function getGitDependencyInstallArgs(ctx: PackageManagerContext): string[] {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (configuredCommand && configuredCommand.length > 0) {\n\t\treturn [\"install\"];\n\t}\n\treturn [\"install\", \"--omit=dev\"];\n}\n\nexport function getNpmInstallArgs(ctx: PackageManagerContext, specs: string[], installRoot: string): string[] {\n\tconst packageManagerName = getPackageManagerName(ctx);\n\t// Extension packages run inside Agent Forge and resolve its APIs through loader aliases/virtual modules.\n\t// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and\n\t// equivalent bun/pnpm settings) so package managers do not install or solve host-provided\n\t// @agent-forge/* peers. Stale auto-installed host peers can otherwise block updates.\n\tif (packageManagerName === \"bun\") {\n\t\treturn [\"install\", ...specs, \"--cwd\", installRoot, \"--omit=peer\"];\n\t}\n\tif (packageManagerName === \"pnpm\") {\n\t\treturn [\n\t\t\t\"install\",\n\t\t\t...specs,\n\t\t\t\"--prefix\",\n\t\t\tinstallRoot,\n\t\t\t\"--config.auto-install-peers=false\",\n\t\t\t\"--config.strict-peer-dependencies=false\",\n\t\t\t\"--config.strict-dep-builds=false\",\n\t\t];\n\t}\n\treturn [\"install\", ...specs, \"--prefix\", installRoot, \"--legacy-peer-deps\"];\n}\n\nexport function getNpmInstallRoot(ctx: PackageManagerContext, scope: SourceScope, temporary: boolean): string {\n\tif (temporary) {\n\t\treturn getTemporaryDir(ctx, \"npm\");\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\");\n\t}\n\treturn join(ctx.agentDir, \"npm\");\n}\n\nexport function getGitInstallRoot(ctx: PackageManagerContext, scope: SourceScope): string | undefined {\n\tif (scope === \"temporary\") {\n\t\treturn undefined;\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"git\");\n\t}\n\treturn join(ctx.agentDir, \"git\");\n}\n\nexport function getManagedNpmInstallPath(ctx: PackageManagerContext, source: NpmSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\treturn join(getTemporaryDir(ctx, \"npm\"), \"node_modules\", source.name);\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\", \"node_modules\", source.name);\n\t}\n\treturn join(ctx.agentDir, \"npm\", \"node_modules\", source.name);\n}\n\nexport function getGitInstallPath(ctx: PackageManagerContext, source: GitSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\t// Include the ref in the hash so each pinned ref gets its own checkout.\n\t\treturn getTemporaryDir(ctx, `git-${source.host}`, source.path, source.ref);\n\t}\n\tconst installRoot = getGitInstallRoot(ctx, scope);\n\tif (!installRoot) {\n\t\tthrow new Error(\"Missing git install root\");\n\t}\n\treturn resolveManagedPath(installRoot, source.host, source.path);\n}\n\nexport function getTemporaryDir(ctx: PackageManagerContext, prefix: string, suffix?: string, ref?: string): string {\n\tconst root = resolveManagedPath(getPackageTempFolder(ctx.agentDir), prefix);\n\tconst hash = createHash(\"sha256\")\n\t\t.update(`${prefix}-${suffix ?? \"\"}${ref ? `@${ref}` : \"\"}`)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 8);\n\treturn resolveManagedPath(root, hash, suffix ?? \"\");\n}\n\nfunction resolveManagedPath(root: string, ...parts: string[]): string {\n\tconst resolvedRoot = resolve(root);\n\tconst resolvedPath = resolve(resolvedRoot, ...parts);\n\tif (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`)) {\n\t\tthrow new Error(`Refusing to use path outside package install root: ${resolvedPath}`);\n\t}\n\treturn resolvedPath;\n}\n\nexport function ensureNpmProject(installRoot: string): void {\n\tif (!existsSync(installRoot)) {\n\t\tmkdirSync(installRoot, { recursive: true });\n\t}\n\tmarkPathIgnoredByCloudSync(installRoot);\n\tensureGitIgnore(installRoot);\n\tconst packageJsonPath = join(installRoot, \"package.json\");\n\tif (!existsSync(packageJsonPath)) {\n\t\tconst pkgJson = { name: \"agent-forge-extensions\", private: true };\n\t\twriteFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), \"utf-8\");\n\t}\n}\n\nexport function ensureGitIgnore(dir: string): void {\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true });\n\t}\n\tconst ignorePath = join(dir, \".gitignore\");\n\tif (!existsSync(ignorePath)) {\n\t\twriteFileSync(ignorePath, \"*\\n!.gitignore\\n\", \"utf-8\");\n\t}\n}\n\nexport function getInstalledNpmVersion(installedPath: string): string | undefined {\n\tconst packageJsonPath = join(installedPath, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return undefined;\n\ttry {\n\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\tconst pkg = JSON.parse(stripBom(content)) as { version?: string };\n\t\treturn pkg.version;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function installedNpmMatchesConfiguredVersion(source: NpmSource, installedPath: string): boolean {\n\tconst installedVersion = getInstalledNpmVersion(installedPath);\n\tif (!installedVersion) {\n\t\treturn false;\n\t}\n\treturn source.range ? satisfies(installedVersion, source.range) : true;\n}\n\nexport function hasMissingGitDependencies(targetDir: string): boolean {\n\tconst packageJsonPath = join(targetDir, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return false;\n\n\ttry {\n\t\tconst manifest = JSON.parse(stripBom(readFileSync(packageJsonPath, \"utf-8\"))) as { dependencies?: unknown };\n\t\tif (!manifest.dependencies || typeof manifest.dependencies !== \"object\" || Array.isArray(manifest.dependencies)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst nodeModulesDir = resolve(targetDir, \"node_modules\");\n\t\treturn Object.keys(manifest.dependencies).some((name) => {\n\t\t\tconst dependencyPath = resolve(nodeModulesDir, name);\n\t\t\tif (!dependencyPath.startsWith(`${nodeModulesDir}${sep}`)) return false;\n\t\t\treturn !existsSync(dependencyPath);\n\t\t});\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function getGitUpdateMarkerPath(targetDir: string): string {\n\treturn join(dirname(targetDir), `.${basename(targetDir)}.agent-forge-update-incomplete`);\n}\n\nexport function pruneEmptyGitParents(targetDir: string, installRoot: string | undefined): void {\n\tif (!installRoot) return;\n\tconst resolvedRoot = resolve(installRoot);\n\tlet current = dirname(targetDir);\n\twhile (current.startsWith(resolvedRoot) && current !== resolvedRoot) {\n\t\tif (!existsSync(current)) {\n\t\t\tcurrent = dirname(current);\n\t\t\tcontinue;\n\t\t}\n\t\tconst entries = readdirSync(current);\n\t\tif (entries.length > 0) {\n\t\t\tbreak;\n\t\t}\n\t\ttry {\n\t\t\trmSync(current, { recursive: true, force: true });\n\t\t} catch {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = dirname(current);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package-install-host.d.ts","sourceRoot":"","sources":["../../src/core/package-install-host.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEzF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,qBAAqB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAU7F;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,CAMxE;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAMhF;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAA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ync, rmSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { satisfies } from \"semver\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport type { GitSource } from \"../utils/git.ts\";\nimport { markPathIgnoredByCloudSync } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { t } from \"./i18n/index.ts\";\nimport type { NpmSource, PackageManagerContext, SourceScope } from \"./package-source.ts\";\n\nexport function getPackageTempFolder(agentDir: string): string {\n\tconst tempFolder = join(agentDir, \"tmp\", \"packages\");\n\tmkdirSync(tempFolder, { recursive: true, mode: 0o700 });\n\tchmodSync(tempFolder, 0o700);\n\treturn tempFolder;\n}\n\nexport function getNpmCommand(ctx: PackageManagerContext): { command: string; args: string[] } {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (!configuredCommand || configuredCommand.length === 0) {\n\t\treturn { command: \"npm\", args: [] };\n\t}\n\tconst [command, ...args] = configuredCommand;\n\tif (!command) {\n\t\tthrow new Error(t(\"Invalid npmCommand: first array entry must be a non-empty command\"));\n\t}\n\treturn { command, args };\n}\n\nexport function getPackageManagerName(ctx: PackageManagerContext): string {\n\tconst npmCommand = getNpmCommand(ctx);\n\tconst commandParts = [npmCommand.command, ...npmCommand.args];\n\tconst separatorIndex = commandParts.lastIndexOf(\"--\");\n\tconst packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;\n\treturn packageManagerCommand ? basename(packageManagerCommand).replace(/\\.(cmd|exe)$/i, \"\") : \"\";\n}\n\nexport function getGitDependencyInstallArgs(ctx: PackageManagerContext): string[] {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (configuredCommand && configuredCommand.length > 0) {\n\t\treturn [\"install\"];\n\t}\n\treturn [\"install\", \"--omit=dev\"];\n}\n\nexport function getNpmInstallArgs(ctx: PackageManagerContext, specs: string[], installRoot: string): string[] {\n\tconst packageManagerName = getPackageManagerName(ctx);\n\t// Extension packages run inside Agent Forge and resolve its APIs through loader aliases/virtual modules.\n\t// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and\n\t// equivalent bun/pnpm settings) so package managers do not install or solve host-provided\n\t// @agent-forge/* peers. Stale auto-installed host peers can otherwise block updates.\n\tif (packageManagerName === \"bun\") {\n\t\treturn [\"install\", ...specs, \"--cwd\", installRoot, \"--omit=peer\"];\n\t}\n\tif (packageManagerName === \"pnpm\") {\n\t\treturn [\n\t\t\t\"install\",\n\t\t\t...specs,\n\t\t\t\"--prefix\",\n\t\t\tinstallRoot,\n\t\t\t\"--config.auto-install-peers=false\",\n\t\t\t\"--config.strict-peer-dependencies=false\",\n\t\t\t\"--config.strict-dep-builds=false\",\n\t\t];\n\t}\n\treturn [\"install\", ...specs, \"--prefix\", installRoot, \"--legacy-peer-deps\"];\n}\n\nexport function getNpmInstallRoot(ctx: PackageManagerContext, scope: SourceScope, temporary: boolean): string {\n\tif (temporary) {\n\t\treturn getTemporaryDir(ctx, \"npm\");\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\");\n\t}\n\treturn join(ctx.agentDir, \"npm\");\n}\n\nexport function getGitInstallRoot(ctx: PackageManagerContext, scope: SourceScope): string | undefined {\n\tif (scope === \"temporary\") {\n\t\treturn undefined;\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"git\");\n\t}\n\treturn join(ctx.agentDir, \"git\");\n}\n\nexport function getManagedNpmInstallPath(ctx: PackageManagerContext, source: NpmSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\treturn join(getTemporaryDir(ctx, \"npm\"), \"node_modules\", source.name);\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\", \"node_modules\", source.name);\n\t}\n\treturn join(ctx.agentDir, \"npm\", \"node_modules\", source.name);\n}\n\nexport function getGitInstallPath(ctx: PackageManagerContext, source: GitSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\t// Include the ref in the hash so each pinned ref gets its own checkout.\n\t\treturn getTemporaryDir(ctx, `git-${source.host}`, source.path, source.ref);\n\t}\n\tconst installRoot = getGitInstallRoot(ctx, scope);\n\tif (!installRoot) {\n\t\tthrow new Error(t(\"Missing git install root\"));\n\t}\n\treturn resolveManagedPath(installRoot, source.host, source.path);\n}\n\nexport function getTemporaryDir(ctx: PackageManagerContext, prefix: string, suffix?: string, ref?: string): string {\n\tconst root = resolveManagedPath(getPackageTempFolder(ctx.agentDir), prefix);\n\tconst hash = createHash(\"sha256\")\n\t\t.update(`${prefix}-${suffix ?? \"\"}${ref ? `@${ref}` : \"\"}`)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 8);\n\treturn resolveManagedPath(root, hash, suffix ?? \"\");\n}\n\nfunction resolveManagedPath(root: string, ...parts: string[]): string {\n\tconst resolvedRoot = resolve(root);\n\tconst resolvedPath = resolve(resolvedRoot, ...parts);\n\tif (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`)) {\n\t\tthrow new Error(t(\"Refusing to use path outside package install root: {path}\", { path: resolvedPath }));\n\t}\n\treturn resolvedPath;\n}\n\nexport function ensureNpmProject(installRoot: string): void {\n\tif (!existsSync(installRoot)) {\n\t\tmkdirSync(installRoot, { recursive: true });\n\t}\n\tmarkPathIgnoredByCloudSync(installRoot);\n\tensureGitIgnore(installRoot);\n\tconst packageJsonPath = join(installRoot, \"package.json\");\n\tif (!existsSync(packageJsonPath)) {\n\t\tconst pkgJson = { name: \"agent-forge-extensions\", private: true };\n\t\twriteFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), \"utf-8\");\n\t}\n}\n\nexport function ensureGitIgnore(dir: string): void {\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true });\n\t}\n\tconst ignorePath = join(dir, \".gitignore\");\n\tif (!existsSync(ignorePath)) {\n\t\twriteFileSync(ignorePath, \"*\\n!.gitignore\\n\", \"utf-8\");\n\t}\n}\n\nexport function getInstalledNpmVersion(installedPath: string): string | undefined {\n\tconst packageJsonPath = join(installedPath, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return undefined;\n\ttry {\n\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\tconst pkg = JSON.parse(stripBom(content)) as { version?: string };\n\t\treturn pkg.version;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function installedNpmMatchesConfiguredVersion(source: NpmSource, installedPath: string): boolean {\n\tconst installedVersion = getInstalledNpmVersion(installedPath);\n\tif (!installedVersion) {\n\t\treturn false;\n\t}\n\treturn source.range ? satisfies(installedVersion, source.range) : true;\n}\n\nexport function hasMissingGitDependencies(targetDir: string): boolean {\n\tconst packageJsonPath = join(targetDir, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return false;\n\n\ttry {\n\t\tconst manifest = JSON.parse(stripBom(readFileSync(packageJsonPath, \"utf-8\"))) as { dependencies?: unknown };\n\t\tif (!manifest.dependencies || typeof manifest.dependencies !== \"object\" || Array.isArray(manifest.dependencies)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst nodeModulesDir = resolve(targetDir, \"node_modules\");\n\t\treturn Object.keys(manifest.dependencies).some((name) => {\n\t\t\tconst dependencyPath = resolve(nodeModulesDir, name);\n\t\t\tif (!dependencyPath.startsWith(`${nodeModulesDir}${sep}`)) return false;\n\t\t\treturn !existsSync(dependencyPath);\n\t\t});\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function getGitUpdateMarkerPath(targetDir: string): string {\n\treturn join(dirname(targetDir), `.${basename(targetDir)}.agent-forge-update-incomplete`);\n}\n\nexport function pruneEmptyGitParents(targetDir: string, installRoot: string | undefined): void {\n\tif (!installRoot) return;\n\tconst resolvedRoot = resolve(installRoot);\n\tlet current = dirname(targetDir);\n\twhile (current.startsWith(resolvedRoot) && current !== resolvedRoot) {\n\t\tif (!existsSync(current)) {\n\t\t\tcurrent = dirname(current);\n\t\t\tcontinue;\n\t\t}\n\t\tconst entries = readdirSync(current);\n\t\tif (entries.length > 0) {\n\t\t\tbreak;\n\t\t}\n\t\ttry {\n\t\t\trmSync(current, { recursive: true, force: true });\n\t\t} catch {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = dirname(current);\n\t}\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import { satisfies } from "semver";
|
|
|
5
5
|
import { CONFIG_DIR_NAME } from "../config.js";
|
|
6
6
|
import { markPathIgnoredByCloudSync } from "../utils/paths.js";
|
|
7
7
|
import { stripBom } from "../utils/text.js";
|
|
8
|
+
import { t } from "./i18n/index.js";
|
|
8
9
|
export function getPackageTempFolder(agentDir) {
|
|
9
10
|
const tempFolder = join(agentDir, "tmp", "packages");
|
|
10
11
|
mkdirSync(tempFolder, { recursive: true, mode: 0o700 });
|
|
@@ -18,7 +19,7 @@ export function getNpmCommand(ctx) {
|
|
|
18
19
|
}
|
|
19
20
|
const [command, ...args] = configuredCommand;
|
|
20
21
|
if (!command) {
|
|
21
|
-
throw new Error("Invalid npmCommand: first array entry must be a non-empty command");
|
|
22
|
+
throw new Error(t("Invalid npmCommand: first array entry must be a non-empty command"));
|
|
22
23
|
}
|
|
23
24
|
return { command, args };
|
|
24
25
|
}
|
|
@@ -92,7 +93,7 @@ export function getGitInstallPath(ctx, source, scope) {
|
|
|
92
93
|
}
|
|
93
94
|
const installRoot = getGitInstallRoot(ctx, scope);
|
|
94
95
|
if (!installRoot) {
|
|
95
|
-
throw new Error("Missing git install root");
|
|
96
|
+
throw new Error(t("Missing git install root"));
|
|
96
97
|
}
|
|
97
98
|
return resolveManagedPath(installRoot, source.host, source.path);
|
|
98
99
|
}
|
|
@@ -108,7 +109,7 @@ function resolveManagedPath(root, ...parts) {
|
|
|
108
109
|
const resolvedRoot = resolve(root);
|
|
109
110
|
const resolvedPath = resolve(resolvedRoot, ...parts);
|
|
110
111
|
if (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`)) {
|
|
111
|
-
throw new Error(
|
|
112
|
+
throw new Error(t("Refusing to use path outside package install root: {path}", { path: resolvedPath }));
|
|
112
113
|
}
|
|
113
114
|
return resolvedPath;
|
|
114
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-install-host.js","sourceRoot":"","sources":["../../src/core/package-install-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7G,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAU;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IACrD,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACxD,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC7B,OAAO,UAAU,CAAC;AAAA,CAClB;AAED,MAAM,UAAU,aAAa,CAAC,GAA0B,EAAuC;IAC9F,MAAM,iBAAiB,GAAG,GAAG,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;IAC9D,IAAI,CAAC,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,C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AC,SAAS,CAAC,gCAAgC,CAAC,CAAC;AAAA,CACzF;AAED,MAAM,UAAU,oBAAoB,CAAC,SAAiB,EAAE,WAA+B,EAAQ;IAC9F,IAAI,CAAC,WAAW;QAAE,OAAO;IACzB,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1C,IAAI,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QACrE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;YAC3B,SAAS;QACV,CAAC;QACD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM;QACP,CAAC;QACD,IAAI,CAAC;YACJ,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACR,MAAM;QACP,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;AAAA,CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { satisfies } from \"semver\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport type { GitSource } from \"../utils/git.ts\";\nimport { markPathIgnoredByCloudSync } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport type { NpmSource, PackageManagerContext, SourceScope } from \"./package-source.ts\";\n\nexport function getPackageTempFolder(agentDir: string): string {\n\tconst tempFolder = join(agentDir, \"tmp\", \"packages\");\n\tmkdirSync(tempFolder, { recursive: true, mode: 0o700 });\n\tchmodSync(tempFolder, 0o700);\n\treturn tempFolder;\n}\n\nexport function getNpmCommand(ctx: PackageManagerContext): { command: string; args: string[] } {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (!configuredCommand || configuredCommand.length === 0) {\n\t\treturn { command: \"npm\", args: [] };\n\t}\n\tconst [command, ...args] = configuredCommand;\n\tif (!command) {\n\t\tthrow new Error(\"Invalid npmCommand: first array entry must be a non-empty command\");\n\t}\n\treturn { command, args };\n}\n\nexport function getPackageManagerName(ctx: PackageManagerContext): string {\n\tconst npmCommand = getNpmCommand(ctx);\n\tconst commandParts = [npmCommand.command, ...npmCommand.args];\n\tconst separatorIndex = commandParts.lastIndexOf(\"--\");\n\tconst packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;\n\treturn packageManagerCommand ? basename(packageManagerCommand).replace(/\\.(cmd|exe)$/i, \"\") : \"\";\n}\n\nexport function getGitDependencyInstallArgs(ctx: PackageManagerContext): string[] {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (configuredCommand && configuredCommand.length > 0) {\n\t\treturn [\"install\"];\n\t}\n\treturn [\"install\", \"--omit=dev\"];\n}\n\nexport function getNpmInstallArgs(ctx: PackageManagerContext, specs: string[], installRoot: string): string[] {\n\tconst packageManagerName = getPackageManagerName(ctx);\n\t// Extension packages run inside Agent Forge and resolve its APIs through loader aliases/virtual modules.\n\t// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and\n\t// equivalent bun/pnpm settings) so package managers do not install or solve host-provided\n\t// @agent-forge/* peers. Stale auto-installed host peers can otherwise block updates.\n\tif (packageManagerName === \"bun\") {\n\t\treturn [\"install\", ...specs, \"--cwd\", installRoot, \"--omit=peer\"];\n\t}\n\tif (packageManagerName === \"pnpm\") {\n\t\treturn [\n\t\t\t\"install\",\n\t\t\t...specs,\n\t\t\t\"--prefix\",\n\t\t\tinstallRoot,\n\t\t\t\"--config.auto-install-peers=false\",\n\t\t\t\"--config.strict-peer-dependencies=false\",\n\t\t\t\"--config.strict-dep-builds=false\",\n\t\t];\n\t}\n\treturn [\"install\", ...specs, \"--prefix\", installRoot, \"--legacy-peer-deps\"];\n}\n\nexport function getNpmInstallRoot(ctx: PackageManagerContext, scope: SourceScope, temporary: boolean): string {\n\tif (temporary) {\n\t\treturn getTemporaryDir(ctx, \"npm\");\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\");\n\t}\n\treturn join(ctx.agentDir, \"npm\");\n}\n\nexport function getGitInstallRoot(ctx: PackageManagerContext, scope: SourceScope): string | undefined {\n\tif (scope === \"temporary\") {\n\t\treturn undefined;\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"git\");\n\t}\n\treturn join(ctx.agentDir, \"git\");\n}\n\nexport function getManagedNpmInstallPath(ctx: PackageManagerContext, source: NpmSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\treturn join(getTemporaryDir(ctx, \"npm\"), \"node_modules\", source.name);\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\", \"node_modules\", source.name);\n\t}\n\treturn join(ctx.agentDir, \"npm\", \"node_modules\", source.name);\n}\n\nexport function getGitInstallPath(ctx: PackageManagerContext, source: GitSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\t// Include the ref in the hash so each pinned ref gets its own checkout.\n\t\treturn getTemporaryDir(ctx, `git-${source.host}`, source.path, source.ref);\n\t}\n\tconst installRoot = getGitInstallRoot(ctx, scope);\n\tif (!installRoot) {\n\t\tthrow new Error(\"Missing git install root\");\n\t}\n\treturn resolveManagedPath(installRoot, source.host, source.path);\n}\n\nexport function getTemporaryDir(ctx: PackageManagerContext, prefix: string, suffix?: string, ref?: string): string {\n\tconst root = resolveManagedPath(getPackageTempFolder(ctx.agentDir), prefix);\n\tconst hash = createHash(\"sha256\")\n\t\t.update(`${prefix}-${suffix ?? \"\"}${ref ? `@${ref}` : \"\"}`)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 8);\n\treturn resolveManagedPath(root, hash, suffix ?? \"\");\n}\n\nfunction resolveManagedPath(root: string, ...parts: string[]): string {\n\tconst resolvedRoot = resolve(root);\n\tconst resolvedPath = resolve(resolvedRoot, ...parts);\n\tif (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`)) {\n\t\tthrow new Error(`Refusing to use path outside package install root: ${resolvedPath}`);\n\t}\n\treturn resolvedPath;\n}\n\nexport function ensureNpmProject(installRoot: string): void {\n\tif (!existsSync(installRoot)) {\n\t\tmkdirSync(installRoot, { recursive: true });\n\t}\n\tmarkPathIgnoredByCloudSync(installRoot);\n\tensureGitIgnore(installRoot);\n\tconst packageJsonPath = join(installRoot, \"package.json\");\n\tif (!existsSync(packageJsonPath)) {\n\t\tconst pkgJson = { name: \"agent-forge-extensions\", private: true };\n\t\twriteFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), \"utf-8\");\n\t}\n}\n\nexport function ensureGitIgnore(dir: string): void {\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true });\n\t}\n\tconst ignorePath = join(dir, \".gitignore\");\n\tif (!existsSync(ignorePath)) {\n\t\twriteFileSync(ignorePath, \"*\\n!.gitignore\\n\", \"utf-8\");\n\t}\n}\n\nexport function getInstalledNpmVersion(installedPath: string): string | undefined {\n\tconst packageJsonPath = join(installedPath, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return undefined;\n\ttry {\n\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\tconst pkg = JSON.parse(stripBom(content)) as { version?: string };\n\t\treturn pkg.version;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function installedNpmMatchesConfiguredVersion(source: NpmSource, installedPath: string): boolean {\n\tconst installedVersion = getInstalledNpmVersion(installedPath);\n\tif (!installedVersion) {\n\t\treturn false;\n\t}\n\treturn source.range ? satisfies(installedVersion, source.range) : true;\n}\n\nexport function hasMissingGitDependencies(targetDir: string): boolean {\n\tconst packageJsonPath = join(targetDir, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return false;\n\n\ttry {\n\t\tconst manifest = JSON.parse(stripBom(readFileSync(packageJsonPath, \"utf-8\"))) as { dependencies?: unknown };\n\t\tif (!manifest.dependencies || typeof manifest.dependencies !== \"object\" || Array.isArray(manifest.dependencies)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst nodeModulesDir = resolve(targetDir, \"node_modules\");\n\t\treturn Object.keys(manifest.dependencies).some((name) => {\n\t\t\tconst dependencyPath = resolve(nodeModulesDir, name);\n\t\t\tif (!dependencyPath.startsWith(`${nodeModulesDir}${sep}`)) return false;\n\t\t\treturn !existsSync(dependencyPath);\n\t\t});\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function getGitUpdateMarkerPath(targetDir: string): string {\n\treturn join(dirname(targetDir), `.${basename(targetDir)}.agent-forge-update-incomplete`);\n}\n\nexport function pruneEmptyGitParents(targetDir: string, installRoot: string | undefined): void {\n\tif (!installRoot) return;\n\tconst resolvedRoot = resolve(installRoot);\n\tlet current = dirname(targetDir);\n\twhile (current.startsWith(resolvedRoot) && current !== resolvedRoot) {\n\t\tif (!existsSync(current)) {\n\t\t\tcurrent = dirname(current);\n\t\t\tcontinue;\n\t\t}\n\t\tconst entries = readdirSync(current);\n\t\tif (entries.length > 0) {\n\t\t\tbreak;\n\t\t}\n\t\ttry {\n\t\t\trmSync(current, { recursive: true, force: true });\n\t\t} catch {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = dirname(current);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package-install-host.js","sourceRoot":"","sources":["../../src/core/package-install-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SA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,IAAI,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QACrE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;YAC3B,SAAS;QACV,CAAC;QACD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM;QACP,CAAC;QACD,IAAI,CAAC;YACJ,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACR,MAAM;QACP,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;AAAA,CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { satisfies } from \"semver\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport type { GitSource } from \"../utils/git.ts\";\nimport { markPathIgnoredByCloudSync } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { t } from \"./i18n/index.ts\";\nimport type { NpmSource, PackageManagerContext, SourceScope } from \"./package-source.ts\";\n\nexport function getPackageTempFolder(agentDir: string): string {\n\tconst tempFolder = join(agentDir, \"tmp\", \"packages\");\n\tmkdirSync(tempFolder, { recursive: true, mode: 0o700 });\n\tchmodSync(tempFolder, 0o700);\n\treturn tempFolder;\n}\n\nexport function getNpmCommand(ctx: PackageManagerContext): { command: string; args: string[] } {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (!configuredCommand || configuredCommand.length === 0) {\n\t\treturn { command: \"npm\", args: [] };\n\t}\n\tconst [command, ...args] = configuredCommand;\n\tif (!command) {\n\t\tthrow new Error(t(\"Invalid npmCommand: first array entry must be a non-empty command\"));\n\t}\n\treturn { command, args };\n}\n\nexport function getPackageManagerName(ctx: PackageManagerContext): string {\n\tconst npmCommand = getNpmCommand(ctx);\n\tconst commandParts = [npmCommand.command, ...npmCommand.args];\n\tconst separatorIndex = commandParts.lastIndexOf(\"--\");\n\tconst packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;\n\treturn packageManagerCommand ? basename(packageManagerCommand).replace(/\\.(cmd|exe)$/i, \"\") : \"\";\n}\n\nexport function getGitDependencyInstallArgs(ctx: PackageManagerContext): string[] {\n\tconst configuredCommand = ctx.settingsManager.getNpmCommand();\n\tif (configuredCommand && configuredCommand.length > 0) {\n\t\treturn [\"install\"];\n\t}\n\treturn [\"install\", \"--omit=dev\"];\n}\n\nexport function getNpmInstallArgs(ctx: PackageManagerContext, specs: string[], installRoot: string): string[] {\n\tconst packageManagerName = getPackageManagerName(ctx);\n\t// Extension packages run inside Agent Forge and resolve its APIs through loader aliases/virtual modules.\n\t// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and\n\t// equivalent bun/pnpm settings) so package managers do not install or solve host-provided\n\t// @agent-forge/* peers. Stale auto-installed host peers can otherwise block updates.\n\tif (packageManagerName === \"bun\") {\n\t\treturn [\"install\", ...specs, \"--cwd\", installRoot, \"--omit=peer\"];\n\t}\n\tif (packageManagerName === \"pnpm\") {\n\t\treturn [\n\t\t\t\"install\",\n\t\t\t...specs,\n\t\t\t\"--prefix\",\n\t\t\tinstallRoot,\n\t\t\t\"--config.auto-install-peers=false\",\n\t\t\t\"--config.strict-peer-dependencies=false\",\n\t\t\t\"--config.strict-dep-builds=false\",\n\t\t];\n\t}\n\treturn [\"install\", ...specs, \"--prefix\", installRoot, \"--legacy-peer-deps\"];\n}\n\nexport function getNpmInstallRoot(ctx: PackageManagerContext, scope: SourceScope, temporary: boolean): string {\n\tif (temporary) {\n\t\treturn getTemporaryDir(ctx, \"npm\");\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\");\n\t}\n\treturn join(ctx.agentDir, \"npm\");\n}\n\nexport function getGitInstallRoot(ctx: PackageManagerContext, scope: SourceScope): string | undefined {\n\tif (scope === \"temporary\") {\n\t\treturn undefined;\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"git\");\n\t}\n\treturn join(ctx.agentDir, \"git\");\n}\n\nexport function getManagedNpmInstallPath(ctx: PackageManagerContext, source: NpmSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\treturn join(getTemporaryDir(ctx, \"npm\"), \"node_modules\", source.name);\n\t}\n\tif (scope === \"project\") {\n\t\treturn join(ctx.cwd, CONFIG_DIR_NAME, \"npm\", \"node_modules\", source.name);\n\t}\n\treturn join(ctx.agentDir, \"npm\", \"node_modules\", source.name);\n}\n\nexport function getGitInstallPath(ctx: PackageManagerContext, source: GitSource, scope: SourceScope): string {\n\tif (scope === \"temporary\") {\n\t\t// Include the ref in the hash so each pinned ref gets its own checkout.\n\t\treturn getTemporaryDir(ctx, `git-${source.host}`, source.path, source.ref);\n\t}\n\tconst installRoot = getGitInstallRoot(ctx, scope);\n\tif (!installRoot) {\n\t\tthrow new Error(t(\"Missing git install root\"));\n\t}\n\treturn resolveManagedPath(installRoot, source.host, source.path);\n}\n\nexport function getTemporaryDir(ctx: PackageManagerContext, prefix: string, suffix?: string, ref?: string): string {\n\tconst root = resolveManagedPath(getPackageTempFolder(ctx.agentDir), prefix);\n\tconst hash = createHash(\"sha256\")\n\t\t.update(`${prefix}-${suffix ?? \"\"}${ref ? `@${ref}` : \"\"}`)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 8);\n\treturn resolveManagedPath(root, hash, suffix ?? \"\");\n}\n\nfunction resolveManagedPath(root: string, ...parts: string[]): string {\n\tconst resolvedRoot = resolve(root);\n\tconst resolvedPath = resolve(resolvedRoot, ...parts);\n\tif (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`)) {\n\t\tthrow new Error(t(\"Refusing to use path outside package install root: {path}\", { path: resolvedPath }));\n\t}\n\treturn resolvedPath;\n}\n\nexport function ensureNpmProject(installRoot: string): void {\n\tif (!existsSync(installRoot)) {\n\t\tmkdirSync(installRoot, { recursive: true });\n\t}\n\tmarkPathIgnoredByCloudSync(installRoot);\n\tensureGitIgnore(installRoot);\n\tconst packageJsonPath = join(installRoot, \"package.json\");\n\tif (!existsSync(packageJsonPath)) {\n\t\tconst pkgJson = { name: \"agent-forge-extensions\", private: true };\n\t\twriteFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), \"utf-8\");\n\t}\n}\n\nexport function ensureGitIgnore(dir: string): void {\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true });\n\t}\n\tconst ignorePath = join(dir, \".gitignore\");\n\tif (!existsSync(ignorePath)) {\n\t\twriteFileSync(ignorePath, \"*\\n!.gitignore\\n\", \"utf-8\");\n\t}\n}\n\nexport function getInstalledNpmVersion(installedPath: string): string | undefined {\n\tconst packageJsonPath = join(installedPath, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return undefined;\n\ttry {\n\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\tconst pkg = JSON.parse(stripBom(content)) as { version?: string };\n\t\treturn pkg.version;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function installedNpmMatchesConfiguredVersion(source: NpmSource, installedPath: string): boolean {\n\tconst installedVersion = getInstalledNpmVersion(installedPath);\n\tif (!installedVersion) {\n\t\treturn false;\n\t}\n\treturn source.range ? satisfies(installedVersion, source.range) : true;\n}\n\nexport function hasMissingGitDependencies(targetDir: string): boolean {\n\tconst packageJsonPath = join(targetDir, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return false;\n\n\ttry {\n\t\tconst manifest = JSON.parse(stripBom(readFileSync(packageJsonPath, \"utf-8\"))) as { dependencies?: unknown };\n\t\tif (!manifest.dependencies || typeof manifest.dependencies !== \"object\" || Array.isArray(manifest.dependencies)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst nodeModulesDir = resolve(targetDir, \"node_modules\");\n\t\treturn Object.keys(manifest.dependencies).some((name) => {\n\t\t\tconst dependencyPath = resolve(nodeModulesDir, name);\n\t\t\tif (!dependencyPath.startsWith(`${nodeModulesDir}${sep}`)) return false;\n\t\t\treturn !existsSync(dependencyPath);\n\t\t});\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function getGitUpdateMarkerPath(targetDir: string): string {\n\treturn join(dirname(targetDir), `.${basename(targetDir)}.agent-forge-update-incomplete`);\n}\n\nexport function pruneEmptyGitParents(targetDir: string, installRoot: string | undefined): void {\n\tif (!installRoot) return;\n\tconst resolvedRoot = resolve(installRoot);\n\tlet current = dirname(targetDir);\n\twhile (current.startsWith(resolvedRoot) && current !== resolvedRoot) {\n\t\tif (!existsSync(current)) {\n\t\t\tcurrent = dirname(current);\n\t\t\tcontinue;\n\t\t}\n\t\tconst entries = readdirSync(current);\n\t\tif (entries.length > 0) {\n\t\t\tbreak;\n\t\t}\n\t\ttry {\n\t\t\trmSync(current, { recursive: true, force: true });\n\t\t} catch {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = dirname(current);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/core/package-manager.ts"],"names":[],"mappings":"AAqCA,OAAO,EAEN,KAAK,iBAAiB,EAUtB,KAAK,mBAAmB,EAIxB,KAAK,cAAc,EAEnB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAGlB,KAAK,gBAAgB,EAGrB,KAAK,aAAa,EAKlB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,oBAA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Aa;IAIrB,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,iBAAiB;YAIX,qBAAqB;YAkBrB,mBAAmB;YAqBnB,qBAAqB;YAiBrB,gBAAgB;YAkBhB,uBAAuB;YA+DvB,iBAAiB;IAiB/B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,6BAA6B;IAUrC,OAAO,CAAC,iBAAiB;YASX,UAAU;YAMV,YAAY;YAiBZ,UAAU;YAkCV,SAAS;YAgBT,4BAA4B;YAK5B,8BAA8B;YAiB9B,YAAY;YA4BZ,yBAAyB;YAazB,SAAS;YAOT,aAAa;IAK3B,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,iBAAiB;IA4CzB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,cAAc;CActB","sourcesContent":["import type { ChildProcess, ChildProcessByStdio } from \"node:child_process\";\nimport { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport { gt, maxSatisfying, rcompare } from \"semver\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport { spawnProcess, spawnProcessSync } from \"../utils/child-process.ts\";\nimport type { GitSource } from \"../utils/git.ts\";\nimport { resolvePath as resolvePathWithBase } from \"../utils/paths.ts\";\nimport { isStdoutTakenOver } from \"./output-guard.ts\";\nimport {\n\tensureGitIgnore,\n\tensureNpmProject,\n\tgetGitDependencyInstallArgs,\n\tgetGitInstallPath,\n\tgetGitInstallRoot,\n\tgetGitUpdateMarkerPath,\n\tgetInstalledNpmVersion,\n\tgetManagedNpmInstallPath,\n\tgetNpmCommand,\n\tgetNpmInstallArgs,\n\tgetNpmInstallRoot,\n\tgetPackageManagerName,\n\thasMissingGitDependencies,\n\tinstalledNpmMatchesConfiguredVersion,\n\tpruneEmptyGitParents,\n} from \"./package-install-host.ts\";\nimport { getEnv, isOfflineModeEnabled, runWithConcurrency } from \"./package-process-runner.ts\";\nimport {\n\taddAutoDiscoveredResources,\n\tcollectPackageResources,\n\tcreateAccumulator,\n\tgetTargetMap,\n\tresolveLocalEntries,\n\ttoResolvedPaths,\n} from \"./package-resource-collection.ts\";\nimport { RESOURCE_TYPES } from \"./package-resource-discovery.ts\";\nimport {\n\tbuildNoMatchingPackageMessage,\n\ttype ConfiguredPackage,\n\ttype ConfiguredUpdateSource,\n\tdedupePackages,\n\ttype GitUpdateTarget,\n\tgetBaseDirForScope,\n\tgetPackageIdentity,\n\tgetPackageSourceString,\n\tgetSourceMatchKeyForInput,\n\tgetSourceMatchKeyForSettings,\n\ttype InstalledSourceScope,\n\ttype MissingSourceAction,\n\ttype NpmSource,\n\ttype NpmUpdateTarget,\n\tnormalizePackageSourceForSettings,\n\ttype PackageManager,\n\ttype PackageManagerContext,\n\ttype PackageManagerOptions,\n\ttype PackageUpdate,\n\ttype ParsedSource,\n\ttype PathMetadata,\n\ttype ProgressCallback,\n\ttype ProgressEvent,\n\tparseSource,\n\ttype ResolvedPaths,\n\ttype ResourceAccumulator,\n\tresolvePath,\n\tresolvePathFromBase,\n\ttype SourceScope,\n} from \"./package-source.ts\";\nimport type { PackageSource, SettingsManager } from \"./settings-manager.ts\";\n\nexport { getPackageTempFolder } from \"./package-install-host.ts\";\nexport type {\n\tConfiguredPackage,\n\tMissingSourceAction,\n\tPackageManager,\n\tPackageUpdate,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./package-source.ts\";\n\nconst NETWORK_TIMEOUT_MS = 10000;\nconst UPDATE_CHECK_CONCURRENCY = 4;\nconst GIT_UPDATE_CONCURRENCY = 4;\n\nexport class DefaultPackageManager implements PackageManager {\n\tprivate cwd: string;\n\tprivate agentDir: string;\n\tprivate settingsManager: SettingsManager;\n\tprivate globalNpmRoot: string | undefined;\n\tprivate globalNpmRootCommandKey: string | undefined;\n\tprivate progressCallback: ProgressCallback | undefined;\n\n\tconstructor(options: PackageManagerOptions) {\n\t\tthis.cwd = resolvePathWithBase(options.cwd);\n\t\tthis.agentDir = resolvePathWithBase(options.agentDir);\n\t\tthis.settingsManager = options.settingsManager;\n\t}\n\n\tprivate get context(): PackageManagerContext {\n\t\treturn { cwd: this.cwd, agentDir: this.agentDir, settingsManager: this.settingsManager };\n\t}\n\n\tsetProgressCallback(callback: ProgressCallback | undefined): void {\n\t\tthis.progressCallback = callback;\n\t}\n\n\taddSourceToSettings(source: string, options?: { local?: boolean }): boolean {\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tconst currentSettings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\t\tconst currentPackages = currentSettings.packages ?? [];\n\t\tconst normalizedSource = this.normalizePackageSourceForSettings(source, scope);\n\t\tconst matchIndex = currentPackages.findIndex((existing) => this.packageSourcesMatch(existing, source, scope));\n\t\tif (matchIndex !== -1) {\n\t\t\tconst existing = currentPackages[matchIndex];\n\t\t\tif (this.getPackageSourceString(existing) === normalizedSource) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst nextPackages = [...currentPackages];\n\t\t\tnextPackages[matchIndex] =\n\t\t\t\ttypeof existing === \"string\" ? normalizedSource : { ...existing, source: normalizedSource };\n\t\t\tif (scope === \"project\") {\n\t\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t\t} else {\n\t\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tconst nextPackages = [...currentPackages, normalizedSource];\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t}\n\t\treturn true;\n\t}\n\n\tremoveSourceFromSettings(source: string, options?: { local?: boolean }): boolean {\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tconst currentSettings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\t\tconst currentPackages = currentSettings.packages ?? [];\n\t\tconst nextPackages = currentPackages.filter((existing) => !this.packageSourcesMatch(existing, source, scope));\n\t\tconst changed = nextPackages.length !== currentPackages.length;\n\t\tif (!changed) {\n\t\t\treturn false;\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t}\n\t\treturn true;\n\t}\n\n\tgetInstalledPath(source: string, scope: \"user\" | \"project\"): string | undefined {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type === \"npm\") {\n\t\t\tconst path = this.getNpmInstallPath(parsed, scope);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\tconst path = this.getGitInstallPath(parsed, scope);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\tif (parsed.type === \"local\") {\n\t\t\tconst baseDir = this.getBaseDirForScope(scope);\n\t\t\tconst path = this.resolvePathFromBase(parsed.path, baseDir);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate emitProgress(event: ProgressEvent): void {\n\t\tthis.progressCallback?.(event);\n\t}\n\n\tprivate async withProgress(\n\t\taction: ProgressEvent[\"action\"],\n\t\tsource: string,\n\t\tmessage: string,\n\t\toperation: () => Promise<void>,\n\t): Promise<void> {\n\t\tthis.emitProgress({ type: \"start\", action, source, message });\n\t\ttry {\n\t\t\tawait operation();\n\t\t\tthis.emitProgress({ type: \"complete\", action, source });\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\tthis.emitProgress({ type: \"error\", action, source, message: errorMessage });\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync resolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths> {\n\t\tconst accumulator = createAccumulator();\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\n\t\t// Collect all packages with scope (project first so cwd resources win collisions)\n\t\tconst allPackages: Array<{ pkg: PackageSource; scope: SourceScope }> = [];\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"project\" });\n\t\t}\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"user\" });\n\t\t}\n\n\t\t// Dedupe: project scope wins over global for same package identity\n\t\tconst packageSources = this.dedupePackages(allPackages);\n\t\tawait this.resolvePackageSources(packageSources, accumulator, onMissing);\n\n\t\tconst globalBaseDir = this.agentDir;\n\t\tconst projectBaseDir = join(this.cwd, CONFIG_DIR_NAME);\n\n\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\tconst target = getTargetMap(accumulator, resourceType);\n\t\t\tconst globalEntries = (globalSettings[resourceType] ?? []) as string[];\n\t\t\tconst projectEntries = (projectSettings[resourceType] ?? []) as string[];\n\t\t\tresolveLocalEntries(\n\t\t\t\tprojectEntries,\n\t\t\t\tresourceType,\n\t\t\t\ttarget,\n\t\t\t\t{\n\t\t\t\t\tsource: \"local\",\n\t\t\t\t\tscope: \"project\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t},\n\t\t\t\tprojectBaseDir,\n\t\t\t);\n\t\t\tresolveLocalEntries(\n\t\t\t\tglobalEntries,\n\t\t\t\tresourceType,\n\t\t\t\ttarget,\n\t\t\t\t{\n\t\t\t\t\tsource: \"local\",\n\t\t\t\t\tscope: \"user\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t},\n\t\t\t\tglobalBaseDir,\n\t\t\t);\n\t\t}\n\n\t\taddAutoDiscoveredResources(this.cwd, accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir);\n\n\t\treturn toResolvedPaths(accumulator);\n\t}\n\n\tasync resolveSourceResources(\n\t\tsources: string[],\n\t\toptions?: { local?: boolean; temporary?: boolean },\n\t): Promise<ResolvedPaths> {\n\t\tconst accumulator = createAccumulator();\n\t\tconst scope: SourceScope = options?.temporary ? \"temporary\" : options?.local ? \"project\" : \"user\";\n\t\tconst packageSources = sources.map((source) => ({ pkg: source as PackageSource, scope }));\n\t\tawait this.resolvePackageSources(packageSources, accumulator);\n\t\treturn toResolvedPaths(accumulator);\n\t}\n\n\tlistConfiguredPackages(): ConfiguredPackage[] {\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst configuredPackages: ConfiguredPackage[] = [];\n\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconfiguredPackages.push({\n\t\t\t\tsource,\n\t\t\t\tscope: \"user\",\n\t\t\t\tfiltered: typeof pkg === \"object\",\n\t\t\t\tinstalledPath: this.getInstalledPath(source, \"user\"),\n\t\t\t});\n\t\t}\n\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconfiguredPackages.push({\n\t\t\t\tsource,\n\t\t\t\tscope: \"project\",\n\t\t\t\tfiltered: typeof pkg === \"object\",\n\t\t\t\tinstalledPath: this.getInstalledPath(source, \"project\"),\n\t\t\t});\n\t\t}\n\n\t\treturn configuredPackages;\n\t}\n\n\tasync install(source: string, options?: { local?: boolean }): Promise<void> {\n\t\tconst parsed = this.parseSource(source);\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tawait this.withProgress(\"install\", source, `Installing ${source}...`, async () => {\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tawait this.installNpm(parsed, scope, false);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tawait this.installGit(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\tconst resolved = this.resolvePath(parsed.path);\n\t\t\t\tif (!existsSync(resolved)) {\n\t\t\t\t\tthrow new Error(`Path does not exist: ${resolved}`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(`Unsupported install source: ${source}`);\n\t\t});\n\t}\n\n\tasync installAndPersist(source: string, options?: { local?: boolean }): Promise<void> {\n\t\tawait this.install(source, options);\n\t\tthis.addSourceToSettings(source, options);\n\t}\n\n\tasync remove(source: string, options?: { local?: boolean }): Promise<void> {\n\t\tconst parsed = this.parseSource(source);\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tawait this.withProgress(\"remove\", source, `Removing ${source}...`, async () => {\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tawait this.uninstallNpm(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tawait this.removeGit(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(`Unsupported remove source: ${source}`);\n\t\t});\n\t}\n\n\tasync removeAndPersist(source: string, options?: { local?: boolean }): Promise<boolean> {\n\t\tawait this.remove(source, options);\n\t\treturn this.removeSourceFromSettings(source, options);\n\t}\n\n\tasync update(source?: string): Promise<void> {\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst identity = source ? this.getPackageIdentity(source) : undefined;\n\t\tlet matched = false;\n\t\tconst updateSources: ConfiguredUpdateSource[] = [];\n\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tconst sourceStr = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tif (identity && this.getPackageIdentity(sourceStr, \"user\") !== identity) continue;\n\t\t\tmatched = true;\n\t\t\tupdateSources.push({ source: sourceStr, scope: \"user\" });\n\t\t}\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tconst sourceStr = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tif (identity && this.getPackageIdentity(sourceStr, \"project\") !== identity) continue;\n\t\t\tmatched = true;\n\t\t\tupdateSources.push({ source: sourceStr, scope: \"project\" });\n\t\t}\n\n\t\tif (source && !matched) {\n\t\t\tthrow new Error(\n\t\t\t\tthis.buildNoMatchingPackageMessage(source, [\n\t\t\t\t\t...(globalSettings.packages ?? []),\n\t\t\t\t\t...(projectSettings.packages ?? []),\n\t\t\t\t]),\n\t\t\t);\n\t\t}\n\n\t\tawait this.updateConfiguredSources(updateSources);\n\t}\n\n\tprivate async updateConfiguredSources(sources: ConfiguredUpdateSource[]): Promise<void> {\n\t\tif (isOfflineModeEnabled() || sources.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst npmCandidates: NpmUpdateTarget[] = [];\n\t\tconst gitCandidates: GitUpdateTarget[] = [];\n\n\t\tfor (const entry of sources) {\n\t\t\tconst parsed = this.parseSource(entry.source);\n\t\t\t// Pinned npm versions are fixed. Pinned git refs are configured checkout targets,\n\t\t\t// so include them to reconcile an existing clone when the configured ref changes.\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tif (!parsed.pinned) {\n\t\t\t\t\tnpmCandidates.push({ ...entry, parsed });\n\t\t\t\t}\n\t\t\t} else if (parsed.type === \"git\") {\n\t\t\t\tgitCandidates.push({ ...entry, parsed });\n\t\t\t}\n\t\t}\n\n\t\tconst npmCheckTasks = npmCandidates.map((entry) => async () => ({\n\t\t\tentry,\n\t\t\tshouldUpdate: await this.shouldUpdateNpmSource(entry.parsed, entry.scope),\n\t\t}));\n\t\tconst npmCheckResults = await runWithConcurrency(npmCheckTasks, UPDATE_CHECK_CONCURRENCY);\n\t\tconst userNpmUpdates: NpmUpdateTarget[] = [];\n\t\tconst projectNpmUpdates: NpmUpdateTarget[] = [];\n\t\tfor (const result of npmCheckResults) {\n\t\t\tif (!result.shouldUpdate) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (result.entry.scope === \"user\") {\n\t\t\t\tuserNpmUpdates.push(result.entry);\n\t\t\t} else {\n\t\t\t\tprojectNpmUpdates.push(result.entry);\n\t\t\t}\n\t\t}\n\n\t\tconst tasks: Promise<void>[] = [];\n\t\tif (userNpmUpdates.length > 0) {\n\t\t\ttasks.push(this.updateNpmBatch(userNpmUpdates, \"user\"));\n\t\t}\n\t\tif (projectNpmUpdates.length > 0) {\n\t\t\ttasks.push(this.updateNpmBatch(projectNpmUpdates, \"project\"));\n\t\t}\n\t\tif (gitCandidates.length > 0) {\n\t\t\tconst gitTasks = gitCandidates.map(\n\t\t\t\t(entry) => async () =>\n\t\t\t\t\tthis.withProgress(\"update\", entry.source, `Updating ${entry.source}...`, async () => {\n\t\t\t\t\t\tawait this.updateGit(entry.parsed, entry.scope);\n\t\t\t\t\t}),\n\t\t\t);\n\t\t\ttasks.push(runWithConcurrency(gitTasks, GIT_UPDATE_CONCURRENCY).then(() => {}));\n\t\t}\n\n\t\tawait Promise.all(tasks);\n\t}\n\n\tprivate async shouldUpdateNpmSource(source: NpmSource, scope: InstalledSourceScope): Promise<boolean> {\n\t\tconst installedPath = getManagedNpmInstallPath(this.context, source, scope);\n\t\tconst installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;\n\t\tif (!installedVersion) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);\n\t\treturn gt(targetVersion, installedVersion);\n\t}\n\n\tprivate async updateNpmBatch(sources: NpmUpdateTarget[], scope: InstalledSourceScope): Promise<void> {\n\t\tif (sources.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst sourceLabel = sources.length === 1 ? sources[0].source : `${scope} npm packages`;\n\t\tconst message = sources.length === 1 ? `Updating ${sources[0].source}...` : `Updating ${scope} npm packages...`;\n\t\tconst specs = sources.map((entry) => (entry.parsed.version ? entry.parsed.spec : `${entry.parsed.name}@latest`));\n\n\t\tawait this.withProgress(\"update\", sourceLabel, message, async () => {\n\t\t\tawait this.installNpmBatch(specs, scope);\n\t\t});\n\t}\n\n\tprivate async installNpmBatch(specs: string[], scope: InstalledSourceScope): Promise<void> {\n\t\tconst installRoot = getNpmInstallRoot(this.context, scope, false);\n\t\tensureNpmProject(installRoot);\n\t\tawait this.runNpmCommand(getNpmInstallArgs(this.context, specs, installRoot));\n\t}\n\n\tasync checkForAvailableUpdates(): Promise<PackageUpdate[]> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst allPackages: Array<{ pkg: PackageSource; scope: SourceScope }> = [];\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"project\" });\n\t\t}\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"user\" });\n\t\t}\n\n\t\tconst packageSources = this.dedupePackages(allPackages);\n\t\tconst checks = packageSources\n\t\t\t.filter(\n\t\t\t\t(entry): entry is { pkg: PackageSource; scope: Exclude<SourceScope, \"temporary\"> } =>\n\t\t\t\t\tentry.scope !== \"temporary\",\n\t\t\t)\n\t\t\t.map((entry) => async (): Promise<PackageUpdate | undefined> => {\n\t\t\t\tconst source = typeof entry.pkg === \"string\" ? entry.pkg : entry.pkg.source;\n\t\t\t\tconst parsed = this.parseSource(source);\n\t\t\t\tif (parsed.type === \"local\" || parsed.pinned) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\t\tconst installedPath = this.getNpmInstallPath(parsed, entry.scope);\n\t\t\t\t\tif (!existsSync(installedPath)) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tconst hasUpdate = await this.npmHasAvailableUpdate(parsed, installedPath);\n\t\t\t\t\tif (!hasUpdate) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tdisplayName: parsed.name,\n\t\t\t\t\t\ttype: \"npm\",\n\t\t\t\t\t\tscope: entry.scope,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst installedPath = this.getGitInstallPath(parsed, entry.scope);\n\t\t\t\tif (!existsSync(installedPath)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tconst hasUpdate = await this.gitHasAvailableUpdate(installedPath);\n\t\t\t\tif (!hasUpdate) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsource,\n\t\t\t\t\tdisplayName: `${parsed.host}/${parsed.path}`,\n\t\t\t\t\ttype: \"git\",\n\t\t\t\t\tscope: entry.scope,\n\t\t\t\t};\n\t\t\t});\n\n\t\tconst results = await runWithConcurrency(checks, UPDATE_CHECK_CONCURRENCY);\n\t\treturn results.filter((result): result is PackageUpdate => result !== undefined);\n\t}\n\n\tprivate async resolvePackageSources(\n\t\tsources: Array<{ pkg: PackageSource; scope: SourceScope }>,\n\t\taccumulator: ResourceAccumulator,\n\t\tonMissing?: (source: string) => Promise<MissingSourceAction>,\n\t): Promise<void> {\n\t\tfor (const { pkg, scope } of sources) {\n\t\t\tconst sourceStr = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconst filter = typeof pkg === \"object\" ? pkg : undefined;\n\t\t\tconst deltaBase = this.findAutoloadDeltaBase(pkg, scope, sources);\n\t\t\tconst resolvedSource = deltaBase?.source ?? sourceStr;\n\t\t\tconst resolvedScope = deltaBase?.scope ?? scope;\n\t\t\tconst parsed = this.parseSource(resolvedSource);\n\t\t\tconst metadata: PathMetadata = { source: sourceStr, scope, origin: \"package\" };\n\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\tconst baseDir = this.getBaseDirForScope(resolvedScope);\n\t\t\t\tconst resolvedLocal = this.resolvePathFromBase(parsed.path, baseDir);\n\t\t\t\tif (existsSync(resolvedLocal)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (statSync(resolvedLocal).isDirectory()) {\n\t\t\t\t\t\t\tmetadata.baseDir = resolvedLocal;\n\t\t\t\t\t\t\tcollectPackageResources(resolvedLocal, accumulator, filter, metadata);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Unreadable local path: skip the source.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst installMissing = async (): Promise<boolean> => {\n\t\t\t\tif (isOfflineModeEnabled()) return false;\n\t\t\t\tif (!onMissing) {\n\t\t\t\t\tawait this.installParsedSource(parsed, resolvedScope);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst action = await onMissing(resolvedSource);\n\t\t\t\tif (action === \"skip\") return false;\n\t\t\t\tif (action === \"error\") throw new Error(`Missing source: ${resolvedSource}`);\n\t\t\t\tawait this.installParsedSource(parsed, resolvedScope);\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tlet installedPath = this.getNpmInstallPath(parsed, resolvedScope);\n\t\t\t\tconst needsInstall =\n\t\t\t\t\t!existsSync(installedPath) || !(await installedNpmMatchesConfiguredVersion(parsed, installedPath));\n\t\t\t\tif (needsInstall) {\n\t\t\t\t\tconst installed = await installMissing();\n\t\t\t\t\tif (!installed) continue;\n\t\t\t\t\tinstalledPath = this.getNpmInstallPath(parsed, resolvedScope);\n\t\t\t\t}\n\t\t\t\tmetadata.baseDir = installedPath;\n\t\t\t\tcollectPackageResources(installedPath, accumulator, filter, metadata);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tconst installedPath = this.getGitInstallPath(parsed, resolvedScope);\n\t\t\t\tif (!existsSync(installedPath)) {\n\t\t\t\t\tconst installed = await installMissing();\n\t\t\t\t\tif (!installed) continue;\n\t\t\t\t} else if (resolvedScope === \"temporary\" && !parsed.pinned && !isOfflineModeEnabled()) {\n\t\t\t\t\tawait this.refreshTemporaryGitSource(parsed, resolvedSource);\n\t\t\t\t}\n\t\t\t\tmetadata.baseDir = installedPath;\n\t\t\t\tcollectPackageResources(installedPath, accumulator, filter, metadata);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate findAutoloadDeltaBase(\n\t\tpkg: PackageSource,\n\t\tscope: SourceScope,\n\t\tsources: Array<{ pkg: PackageSource; scope: SourceScope }>,\n\t): { source: string; scope: SourceScope } | undefined {\n\t\tif (scope !== \"project\" || typeof pkg !== \"object\" || pkg.autoload !== false) return undefined;\n\t\tconst identity = this.getPackageIdentity(pkg.source, scope);\n\t\tconst userEntry = sources.find(\n\t\t\t(entry) =>\n\t\t\t\tentry.scope === \"user\" &&\n\t\t\t\tthis.getPackageIdentity(this.getPackageSourceString(entry.pkg), \"user\") === identity,\n\t\t);\n\t\treturn userEntry ? { source: this.getPackageSourceString(userEntry.pkg), scope: \"user\" } : undefined;\n\t}\n\n\tprivate async installParsedSource(parsed: ParsedSource, scope: SourceScope): Promise<void> {\n\t\tif (parsed.type === \"npm\") {\n\t\t\tawait this.installNpm(parsed, scope, scope === \"temporary\");\n\t\t\treturn;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\tawait this.installGit(parsed, scope);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate parseSource(source: string): ParsedSource {\n\t\treturn parseSource(source);\n\t}\n\n\tprivate getBaseDirForScope(scope: SourceScope): string {\n\t\treturn getBaseDirForScope(this.context, scope);\n\t}\n\n\tprivate resolvePath(input: string): string {\n\t\treturn resolvePath(this.context, input);\n\t}\n\n\tprivate resolvePathFromBase(input: string, baseDir: string): string {\n\t\treturn resolvePathFromBase(input, baseDir);\n\t}\n\n\tprivate getPackageSourceString(pkg: PackageSource): string {\n\t\treturn getPackageSourceString(pkg);\n\t}\n\n\tprivate getSourceMatchKeyForInput(source: string): string {\n\t\treturn getSourceMatchKeyForInput(this.context, source);\n\t}\n\n\tprivate getSourceMatchKeyForSettings(source: string, scope: SourceScope): string {\n\t\treturn getSourceMatchKeyForSettings(this.context, source, scope);\n\t}\n\n\tprivate packageSourcesMatch(existing: PackageSource, inputSource: string, scope: SourceScope): boolean {\n\t\tconst left = this.getSourceMatchKeyForSettings(this.getPackageSourceString(existing), scope);\n\t\tconst right = this.getSourceMatchKeyForInput(inputSource);\n\t\treturn left === right;\n\t}\n\n\tprivate normalizePackageSourceForSettings(source: string, scope: SourceScope): string {\n\t\treturn normalizePackageSourceForSettings(this.context, source, scope);\n\t}\n\n\tprivate getPackageIdentity(source: string, scope?: SourceScope): string {\n\t\treturn getPackageIdentity(this.context, source, scope);\n\t}\n\n\tprivate dedupePackages(\n\t\tpackages: Array<{ pkg: PackageSource; scope: SourceScope }>,\n\t): Array<{ pkg: PackageSource; scope: SourceScope }> {\n\t\treturn dedupePackages(this.context, packages);\n\t}\n\n\tprivate buildNoMatchingPackageMessage(source: string, configuredPackages: PackageSource[]): string {\n\t\treturn buildNoMatchingPackageMessage(source, configuredPackages);\n\t}\n\n\tprivate getNpmCommand(): { command: string; args: string[] } {\n\t\treturn getNpmCommand(this.context);\n\t}\n\n\tprivate getInstalledNpmVersion(installedPath: string): string | undefined {\n\t\treturn getInstalledNpmVersion(installedPath);\n\t}\n\n\tprivate getGitInstallPath(source: GitSource, scope: SourceScope): string {\n\t\treturn getGitInstallPath(this.context, source, scope);\n\t}\n\n\tprivate async npmHasAvailableUpdate(source: NpmSource, installedPath: string): Promise<boolean> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst installedVersion = this.getInstalledNpmVersion(installedPath);\n\t\tif (!installedVersion) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);\n\t\t\treturn gt(targetVersion, installedVersion);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate async getLatestNpmVersion(packageSpec: string, range?: string): Promise<string> {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tconst stdout = await this.runCommandCapture(\n\t\t\tnpmCommand.command,\n\t\t\t[...npmCommand.args, \"view\", packageSpec, \"version\", \"--json\"],\n\t\t\t{ cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS },\n\t\t);\n\t\tconst raw = stdout.trim();\n\t\tif (!raw) throw new Error(\"Empty response from npm view\");\n\t\tconst parsed = JSON.parse(raw) as unknown;\n\t\tif (typeof parsed === \"string\") {\n\t\t\treturn parsed;\n\t\t}\n\t\tif (Array.isArray(parsed)) {\n\t\t\tconst versions = parsed.filter((value): value is string => typeof value === \"string\" && value.length > 0);\n\t\t\tconst latest = range ? maxSatisfying(versions, range) : [...versions].sort(rcompare)[0];\n\t\t\tif (latest) return latest;\n\t\t}\n\t\tthrow new Error(\"Unexpected response from npm view\");\n\t}\n\n\tprivate async gitHasAvailableUpdate(installedPath: string): Promise<boolean> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst localHead = await this.runCommandCapture(\"git\", [\"rev-parse\", \"HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst remoteHead = await this.getRemoteGitHead(installedPath);\n\t\t\treturn localHead.trim() !== remoteHead.trim();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate async getRemoteGitHead(installedPath: string): Promise<string> {\n\t\tconst upstreamRef = await this.getGitUpstreamRef(installedPath);\n\t\tif (upstreamRef) {\n\t\t\tconst remoteHead = await this.runGitRemoteCommand(installedPath, [\"ls-remote\", \"origin\", upstreamRef]);\n\t\t\tconst match = remoteHead.match(/^([0-9a-f]{40})\\s+/m);\n\t\t\tif (match?.[1]) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\n\t\tconst remoteHead = await this.runGitRemoteCommand(installedPath, [\"ls-remote\", \"origin\", \"HEAD\"]);\n\t\tconst match = remoteHead.match(/^([0-9a-f]{40})\\s+HEAD$/m);\n\t\tif (!match?.[1]) {\n\t\t\tthrow new Error(\"Failed to determine remote HEAD\");\n\t\t}\n\t\treturn match[1];\n\t}\n\n\tprivate async getLocalGitUpdateTarget(\n\t\tinstalledPath: string,\n\t): Promise<{ ref: string; head: string; fetchArgs: string[] }> {\n\t\ttry {\n\t\t\tconst upstream = await this.runCommandCapture(\"git\", [\"rev-parse\", \"--abbrev-ref\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst trimmedUpstream = upstream.trim();\n\t\t\tif (!trimmedUpstream.startsWith(\"origin/\")) {\n\t\t\t\tthrow new Error(`Unsupported upstream remote: ${trimmedUpstream}`);\n\t\t\t}\n\t\t\tconst branch = trimmedUpstream.slice(\"origin/\".length);\n\t\t\tif (!branch) {\n\t\t\t\tthrow new Error(\"Missing upstream branch name\");\n\t\t\t}\n\t\t\tconst head = await this.runCommandCapture(\"git\", [\"rev-parse\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tref: \"@{upstream}\",\n\t\t\t\thead,\n\t\t\t\tfetchArgs: [\n\t\t\t\t\t\"fetch\",\n\t\t\t\t\t\"--prune\",\n\t\t\t\t\t\"--no-tags\",\n\t\t\t\t\t\"origin\",\n\t\t\t\t\t`+refs/heads/${branch}:refs/remotes/origin/${branch}`,\n\t\t\t\t],\n\t\t\t};\n\t\t} catch {\n\t\t\tawait this.runCommand(\"git\", [\"remote\", \"set-head\", \"origin\", \"-a\"], { cwd: installedPath }).catch(() => {});\n\t\t\tconst head = await this.runCommandCapture(\"git\", [\"rev-parse\", \"origin/HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst originHeadRef = await this.runCommandCapture(\"git\", [\"symbolic-ref\", \"refs/remotes/origin/HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t}).catch(() => \"\");\n\t\t\tconst branch = originHeadRef.trim().replace(/^refs\\/remotes\\/origin\\//, \"\");\n\t\t\tif (branch) {\n\t\t\t\treturn {\n\t\t\t\t\tref: \"origin/HEAD\",\n\t\t\t\t\thead,\n\t\t\t\t\tfetchArgs: [\n\t\t\t\t\t\t\"fetch\",\n\t\t\t\t\t\t\"--prune\",\n\t\t\t\t\t\t\"--no-tags\",\n\t\t\t\t\t\t\"origin\",\n\t\t\t\t\t\t`+refs/heads/${branch}:refs/remotes/origin/${branch}`,\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tref: \"origin/HEAD\",\n\t\t\t\thead,\n\t\t\t\tfetchArgs: [\"fetch\", \"--prune\", \"--no-tags\", \"origin\", \"+HEAD:refs/remotes/origin/HEAD\"],\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate async getGitUpstreamRef(installedPath: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst upstream = await this.runCommandCapture(\"git\", [\"rev-parse\", \"--abbrev-ref\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst trimmed = upstream.trim();\n\t\t\tif (!trimmed.startsWith(\"origin/\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst branch = trimmed.slice(\"origin/\".length);\n\t\t\treturn branch ? `refs/heads/${branch}` : undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate runGitRemoteCommand(installedPath: string, args: string[]): Promise<string> {\n\t\treturn this.runCommandCapture(\"git\", args, {\n\t\t\tcwd: installedPath,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\tenv: {\n\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate getGlobalNpmRoot(): string {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tconst commandKey = [npmCommand.command, ...npmCommand.args].join(\"\\0\");\n\t\tif (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {\n\t\t\treturn this.globalNpmRoot;\n\t\t}\n\t\tif (getPackageManagerName(this.context) === \"bun\") {\n\t\t\tconst binDir = this.runNpmCommandSync([\"pm\", \"bin\", \"-g\"]).trim();\n\t\t\tthis.globalNpmRoot = join(dirname(binDir), \"install\", \"global\", \"node_modules\");\n\t\t} else {\n\t\t\tthis.globalNpmRoot = this.runNpmCommandSync([\"root\", \"-g\"]).trim();\n\t\t}\n\t\tthis.globalNpmRootCommandKey = commandKey;\n\t\treturn this.globalNpmRoot;\n\t}\n\n\tprivate getPnpmGlobalPackagePath(packageName: string): string | undefined {\n\t\tif (getPackageManagerName(this.context) !== \"pnpm\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = this.runNpmCommandSync([\"list\", \"-g\", \"--depth\", \"0\", \"--json\"]);\n\t\tconst entries = JSON.parse(output) as Array<{ dependencies?: Record<string, { path?: string }> }>;\n\t\tfor (const entry of entries) {\n\t\t\tconst path = entry.dependencies?.[packageName]?.path;\n\t\t\tif (path) return path;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate getLegacyGlobalNpmInstallPath(source: NpmSource): string | undefined {\n\t\t// Read-only migration compatibility for pre-managed global installs. New installs\n\t\t// always target the Agent Forge-managed root; this lookup never substitutes a package.\n\t\ttry {\n\t\t\treturn this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate getNpmInstallPath(source: NpmSource, scope: SourceScope): string {\n\t\tconst managedPath = getManagedNpmInstallPath(this.context, source, scope);\n\t\tif (scope !== \"user\" || existsSync(managedPath)) {\n\t\t\treturn managedPath;\n\t\t}\n\t\tconst legacyPath = this.getLegacyGlobalNpmInstallPath(source);\n\t\treturn legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;\n\t}\n\n\tprivate async installNpm(source: NpmSource, scope: SourceScope, temporary: boolean): Promise<void> {\n\t\tconst installRoot = getNpmInstallRoot(this.context, scope, temporary);\n\t\tensureNpmProject(installRoot);\n\t\tawait this.runNpmCommand(getNpmInstallArgs(this.context, [source.spec], installRoot));\n\t}\n\n\tprivate async uninstallNpm(source: NpmSource, scope: SourceScope): Promise<void> {\n\t\tconst installRoot = getNpmInstallRoot(this.context, scope, false);\n\t\tif (!existsSync(installRoot)) {\n\t\t\treturn;\n\t\t}\n\t\tconst packageManagerName = getPackageManagerName(this.context);\n\t\tif (packageManagerName === \"bun\") {\n\t\t\tawait this.runNpmCommand([\"uninstall\", source.name, \"--cwd\", installRoot]);\n\t\t\treturn;\n\t\t}\n\t\tconst args = [\"uninstall\", source.name, \"--prefix\", installRoot];\n\t\tif (packageManagerName !== \"pnpm\") {\n\t\t\targs.push(\"--legacy-peer-deps\");\n\t\t}\n\t\tawait this.runNpmCommand(args);\n\t}\n\n\tprivate async installGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\tif (existsSync(targetDir)) {\n\t\t\tif (source.ref) {\n\t\t\t\tawait this.ensureGitRef(targetDir, [\"fetch\", \"origin\", source.ref], \"FETCH_HEAD\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst target = await this.getLocalGitUpdateTarget(targetDir);\n\t\t\tawait this.ensureGitRef(targetDir, target.fetchArgs, target.ref);\n\t\t\treturn;\n\t\t}\n\t\tconst gitRoot = getGitInstallRoot(this.context, scope);\n\t\tif (gitRoot) {\n\t\t\tensureGitIgnore(gitRoot);\n\t\t}\n\t\tmkdirSync(dirname(targetDir), { recursive: true });\n\t\trmSync(getGitUpdateMarkerPath(targetDir), { force: true });\n\n\t\ttry {\n\t\t\tawait this.runCommand(\"git\", [\"clone\", source.repo, targetDir]);\n\t\t\tif (source.ref) {\n\t\t\t\tawait this.runCommand(\"git\", [\"checkout\", source.ref], { cwd: targetDir });\n\t\t\t}\n\t\t\tconst packageJsonPath = join(targetDir, \"package.json\");\n\t\t\tif (existsSync(packageJsonPath)) {\n\t\t\t\tawait this.runNpmCommand(getGitDependencyInstallArgs(this.context), { cwd: targetDir });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\trmSync(targetDir, { recursive: true, force: true });\n\t\t\tpruneEmptyGitParents(targetDir, gitRoot);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate async updateGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\tif (!existsSync(targetDir)) {\n\t\t\tawait this.installGit(source, scope);\n\t\t\treturn;\n\t\t}\n\n\t\tif (source.ref) {\n\t\t\tawait this.ensureGitRef(targetDir, [\"fetch\", \"origin\", source.ref], \"FETCH_HEAD\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst target = await this.getLocalGitUpdateTarget(targetDir);\n\t\tawait this.ensureGitRef(targetDir, target.fetchArgs, target.ref);\n\t}\n\n\tprivate async repairMissingGitDependencies(targetDir: string): Promise<void> {\n\t\tif (!hasMissingGitDependencies(targetDir)) return;\n\t\tawait this.runNpmCommand(getGitDependencyInstallArgs(this.context), { cwd: targetDir });\n\t}\n\n\tprivate async cleanAndInstallGitDependencies(targetDir: string, markerPath: string): Promise<void> {\n\t\t// Clean untracked files (extensions should be pristine). If this fails after\n\t\t// deleting dependencies, repair them so the existing extension still loads.\n\t\ttry {\n\t\t\tawait this.runCommand(\"git\", [\"clean\", \"-fdx\"], { cwd: targetDir });\n\t\t} catch (error) {\n\t\t\tawait this.repairMissingGitDependencies(targetDir).catch(() => {});\n\t\t\tthrow error;\n\t\t}\n\n\t\tconst packageJsonPath = join(targetDir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tawait this.runNpmCommand(getGitDependencyInstallArgs(this.context), { cwd: targetDir });\n\t\t}\n\t\trmSync(markerPath, { force: true });\n\t}\n\n\tprivate async ensureGitRef(targetDir: string, fetchArgs: string[], ref: string): Promise<void> {\n\t\t// Fetch only the ref we will reset to, avoiding unrelated branch/tag noise.\n\t\tawait this.runCommand(\"git\", fetchArgs, { cwd: targetDir });\n\n\t\tconst localHead = await this.runCommandCapture(\"git\", [\"rev-parse\", \"HEAD\"], {\n\t\t\tcwd: targetDir,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t});\n\t\tconst commitRef = `${ref}^{commit}`;\n\t\tconst targetHead = await this.runCommandCapture(\"git\", [\"rev-parse\", commitRef], {\n\t\t\tcwd: targetDir,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t});\n\t\tconst markerPath = getGitUpdateMarkerPath(targetDir);\n\t\tif (localHead.trim() === targetHead.trim()) {\n\t\t\tif (existsSync(markerPath)) {\n\t\t\t\tawait this.cleanAndInstallGitDependencies(targetDir, markerPath);\n\t\t\t} else {\n\t\t\t\tawait this.repairMissingGitDependencies(targetDir);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\twriteFileSync(markerPath, \"\", \"utf-8\");\n\t\tawait this.runCommand(\"git\", [\"reset\", \"--hard\", commitRef], { cwd: targetDir });\n\t\tawait this.cleanAndInstallGitDependencies(targetDir, markerPath);\n\t}\n\n\tprivate async refreshTemporaryGitSource(source: GitSource, sourceStr: string): Promise<void> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait this.withProgress(\"pull\", sourceStr, `Refreshing ${sourceStr}...`, async () => {\n\t\t\t\tawait this.updateGit(source, \"temporary\");\n\t\t\t});\n\t\t} catch {\n\t\t\t// Keep cached temporary checkout if refresh fails.\n\t\t}\n\t}\n\n\tprivate async removeGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\trmSync(targetDir, { recursive: true, force: true });\n\t\trmSync(getGitUpdateMarkerPath(targetDir), { force: true });\n\t\tpruneEmptyGitParents(targetDir, getGitInstallRoot(this.context, scope));\n\t}\n\n\tprivate async runNpmCommand(args: string[], options?: { cwd?: string }): Promise<void> {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tawait this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);\n\t}\n\n\tprivate runNpmCommandSync(args: string[]): string {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\treturn this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);\n\t}\n\n\tprivate spawnCommand(command: string, args: string[], options?: { cwd?: string }): ChildProcess {\n\t\tconst env = getEnv();\n\t\treturn spawnProcess(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tstdio: isStdoutTakenOver() ? [\"ignore\", 2, 2] : \"inherit\",\n\t\t\tenv,\n\t\t});\n\t}\n\n\tprivate spawnCaptureCommand(\n\t\tcommand: string,\n\t\targs: string[],\n\t\toptions?: { cwd?: string; env?: Record<string, string> },\n\t): ChildProcessByStdio<null, Readable, Readable> {\n\t\tconst baseEnv = getEnv();\n\t\tconst env = options?.env ? { ...baseEnv, ...options.env } : baseEnv;\n\t\treturn spawnProcess(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tenv,\n\t\t});\n\t}\n\n\tprivate runCommandCapture(\n\t\tcommand: string,\n\t\targs: string[],\n\t\toptions?: { cwd?: string; timeoutMs?: number; env?: Record<string, string> },\n\t): Promise<string> {\n\t\treturn new Promise((resolvePromise, reject) => {\n\t\t\tconst child = this.spawnCaptureCommand(command, args, options);\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tlet timedOut = false;\n\t\t\tconst timeout =\n\t\t\t\ttypeof options?.timeoutMs === \"number\"\n\t\t\t\t\t? setTimeout(() => {\n\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t}, options.timeoutMs)\n\t\t\t\t\t: undefined;\n\n\t\t\tchild.stdout?.on(\"data\", (data) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\t\t\tchild.stderr?.on(\"data\", (data) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t\tchild.once(\"error\", (error) => {\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\treject(error);\n\t\t\t});\n\t\t\tchild.once(\"close\", (code, signal) => {\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\tif (timedOut) {\n\t\t\t\t\treject(new Error(`${command} ${args.join(\" \")} timed out after ${options?.timeoutMs}ms`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolvePromise(stdout.trim());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst exitStatus = code === null ? `signal ${signal ?? \"unknown\"}` : `code ${code}`;\n\t\t\t\treject(new Error(`${command} ${args.join(\" \")} failed with ${exitStatus}: ${stderr || stdout}`));\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate runCommand(command: string, args: string[], options?: { cwd?: string }): Promise<void> {\n\t\treturn new Promise((resolvePromise, reject) => {\n\t\t\tconst child = this.spawnCommand(command, args, options);\n\t\t\tchild.on(\"error\", reject);\n\t\t\tchild.on(\"exit\", (code) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolvePromise();\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error(`${command} ${args.join(\" \")} failed with code ${code}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate runCommandSync(command: string, args: string[]): string {\n\t\tconst env = getEnv();\n\t\tconst result = spawnProcessSync(command, args, {\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tencoding: \"utf-8\",\n\t\t\tenv,\n\t\t});\n\t\tif (result.error || result.status !== 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to run ${command} ${args.join(\" \")}: ${result.error?.message || result.stderr || result.stdout}`,\n\t\t\t);\n\t\t}\n\t\treturn (result.stdout || result.stderr || \"\").trim();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/core/package-manager.ts"],"names":[],"mappings":"AAsCA,OAAO,EAEN,KAAK,iBAAiB,EAUtB,KAAK,mBAAmB,EAIxB,KAAK,cAAc,EAEnB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAGlB,KAAK,gBAAgB,EAGrB,KAAK,aAAa,EAKlB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EACX,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAM7B,qBAAa,qBAAsB,YAAW,cAAc;IAC3D,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,uBAAuB,CAAqB;IACpD,OAAO,CAAC,gBAAgB,CAA+B;IAEvD,YAAY,OAAO,EAAE,qBAAqB,EAIzC;IAED,OAAO,KAA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KzB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,iBAAiB;IA4CzB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,cAAc;CAkBtB","sourcesContent":["import type { ChildProcess, ChildProcessByStdio } from \"node:child_process\";\nimport { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport { gt, maxSatisfying, rcompare } from \"semver\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport { spawnProcess, spawnProcessSync } from \"../utils/child-process.ts\";\nimport type { GitSource } from \"../utils/git.ts\";\nimport { resolvePath as resolvePathWithBase } from \"../utils/paths.ts\";\nimport { t } from \"./i18n/index.ts\";\nimport { isStdoutTakenOver } from \"./output-guard.ts\";\nimport {\n\tensureGitIgnore,\n\tensureNpmProject,\n\tgetGitDependencyInstallArgs,\n\tgetGitInstallPath,\n\tgetGitInstallRoot,\n\tgetGitUpdateMarkerPath,\n\tgetInstalledNpmVersion,\n\tgetManagedNpmInstallPath,\n\tgetNpmCommand,\n\tgetNpmInstallArgs,\n\tgetNpmInstallRoot,\n\tgetPackageManagerName,\n\thasMissingGitDependencies,\n\tinstalledNpmMatchesConfiguredVersion,\n\tpruneEmptyGitParents,\n} from \"./package-install-host.ts\";\nimport { getEnv, isOfflineModeEnabled, runWithConcurrency } from \"./package-process-runner.ts\";\nimport {\n\taddAutoDiscoveredResources,\n\tcollectPackageResources,\n\tcreateAccumulator,\n\tgetTargetMap,\n\tresolveLocalEntries,\n\ttoResolvedPaths,\n} from \"./package-resource-collection.ts\";\nimport { RESOURCE_TYPES } from \"./package-resource-discovery.ts\";\nimport {\n\tbuildNoMatchingPackageMessage,\n\ttype ConfiguredPackage,\n\ttype ConfiguredUpdateSource,\n\tdedupePackages,\n\ttype GitUpdateTarget,\n\tgetBaseDirForScope,\n\tgetPackageIdentity,\n\tgetPackageSourceString,\n\tgetSourceMatchKeyForInput,\n\tgetSourceMatchKeyForSettings,\n\ttype InstalledSourceScope,\n\ttype MissingSourceAction,\n\ttype NpmSource,\n\ttype NpmUpdateTarget,\n\tnormalizePackageSourceForSettings,\n\ttype PackageManager,\n\ttype PackageManagerContext,\n\ttype PackageManagerOptions,\n\ttype PackageUpdate,\n\ttype ParsedSource,\n\ttype PathMetadata,\n\ttype ProgressCallback,\n\ttype ProgressEvent,\n\tparseSource,\n\ttype ResolvedPaths,\n\ttype ResourceAccumulator,\n\tresolvePath,\n\tresolvePathFromBase,\n\ttype SourceScope,\n} from \"./package-source.ts\";\nimport type { PackageSource, SettingsManager } from \"./settings-manager.ts\";\n\nexport { getPackageTempFolder } from \"./package-install-host.ts\";\nexport type {\n\tConfiguredPackage,\n\tMissingSourceAction,\n\tPackageManager,\n\tPackageUpdate,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./package-source.ts\";\n\nconst NETWORK_TIMEOUT_MS = 10000;\nconst UPDATE_CHECK_CONCURRENCY = 4;\nconst GIT_UPDATE_CONCURRENCY = 4;\n\nexport class DefaultPackageManager implements PackageManager {\n\tprivate cwd: string;\n\tprivate agentDir: string;\n\tprivate settingsManager: SettingsManager;\n\tprivate globalNpmRoot: string | undefined;\n\tprivate globalNpmRootCommandKey: string | undefined;\n\tprivate progressCallback: ProgressCallback | undefined;\n\n\tconstructor(options: PackageManagerOptions) {\n\t\tthis.cwd = resolvePathWithBase(options.cwd);\n\t\tthis.agentDir = resolvePathWithBase(options.agentDir);\n\t\tthis.settingsManager = options.settingsManager;\n\t}\n\n\tprivate get context(): PackageManagerContext {\n\t\treturn { cwd: this.cwd, agentDir: this.agentDir, settingsManager: this.settingsManager };\n\t}\n\n\tsetProgressCallback(callback: ProgressCallback | undefined): void {\n\t\tthis.progressCallback = callback;\n\t}\n\n\taddSourceToSettings(source: string, options?: { local?: boolean }): boolean {\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tconst currentSettings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\t\tconst currentPackages = currentSettings.packages ?? [];\n\t\tconst normalizedSource = this.normalizePackageSourceForSettings(source, scope);\n\t\tconst matchIndex = currentPackages.findIndex((existing) => this.packageSourcesMatch(existing, source, scope));\n\t\tif (matchIndex !== -1) {\n\t\t\tconst existing = currentPackages[matchIndex];\n\t\t\tif (this.getPackageSourceString(existing) === normalizedSource) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst nextPackages = [...currentPackages];\n\t\t\tnextPackages[matchIndex] =\n\t\t\t\ttypeof existing === \"string\" ? normalizedSource : { ...existing, source: normalizedSource };\n\t\t\tif (scope === \"project\") {\n\t\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t\t} else {\n\t\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tconst nextPackages = [...currentPackages, normalizedSource];\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t}\n\t\treturn true;\n\t}\n\n\tremoveSourceFromSettings(source: string, options?: { local?: boolean }): boolean {\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tconst currentSettings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\t\tconst currentPackages = currentSettings.packages ?? [];\n\t\tconst nextPackages = currentPackages.filter((existing) => !this.packageSourcesMatch(existing, source, scope));\n\t\tconst changed = nextPackages.length !== currentPackages.length;\n\t\tif (!changed) {\n\t\t\treturn false;\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t}\n\t\treturn true;\n\t}\n\n\tgetInstalledPath(source: string, scope: \"user\" | \"project\"): string | undefined {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type === \"npm\") {\n\t\t\tconst path = this.getNpmInstallPath(parsed, scope);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\tconst path = this.getGitInstallPath(parsed, scope);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\tif (parsed.type === \"local\") {\n\t\t\tconst baseDir = this.getBaseDirForScope(scope);\n\t\t\tconst path = this.resolvePathFromBase(parsed.path, baseDir);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate emitProgress(event: ProgressEvent): void {\n\t\tthis.progressCallback?.(event);\n\t}\n\n\tprivate async withProgress(\n\t\taction: ProgressEvent[\"action\"],\n\t\tsource: string,\n\t\tmessage: string,\n\t\toperation: () => Promise<void>,\n\t): Promise<void> {\n\t\tthis.emitProgress({ type: \"start\", action, source, message });\n\t\ttry {\n\t\t\tawait operation();\n\t\t\tthis.emitProgress({ type: \"complete\", action, source });\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\tthis.emitProgress({ type: \"error\", action, source, message: errorMessage });\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync resolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths> {\n\t\tconst accumulator = createAccumulator();\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\n\t\t// Collect all packages with scope (project first so cwd resources win collisions)\n\t\tconst allPackages: Array<{ pkg: PackageSource; scope: SourceScope }> = [];\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"project\" });\n\t\t}\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"user\" });\n\t\t}\n\n\t\t// Dedupe: project scope wins over global for same package identity\n\t\tconst packageSources = this.dedupePackages(allPackages);\n\t\tawait this.resolvePackageSources(packageSources, accumulator, onMissing);\n\n\t\tconst globalBaseDir = this.agentDir;\n\t\tconst projectBaseDir = join(this.cwd, CONFIG_DIR_NAME);\n\n\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\tconst target = getTargetMap(accumulator, resourceType);\n\t\t\tconst globalEntries = (globalSettings[resourceType] ?? []) as string[];\n\t\t\tconst projectEntries = (projectSettings[resourceType] ?? []) as string[];\n\t\t\tresolveLocalEntries(\n\t\t\t\tprojectEntries,\n\t\t\t\tresourceType,\n\t\t\t\ttarget,\n\t\t\t\t{\n\t\t\t\t\tsource: \"local\",\n\t\t\t\t\tscope: \"project\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t},\n\t\t\t\tprojectBaseDir,\n\t\t\t);\n\t\t\tresolveLocalEntries(\n\t\t\t\tglobalEntries,\n\t\t\t\tresourceType,\n\t\t\t\ttarget,\n\t\t\t\t{\n\t\t\t\t\tsource: \"local\",\n\t\t\t\t\tscope: \"user\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t},\n\t\t\t\tglobalBaseDir,\n\t\t\t);\n\t\t}\n\n\t\taddAutoDiscoveredResources(this.cwd, accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir);\n\n\t\treturn toResolvedPaths(accumulator);\n\t}\n\n\tasync resolveSourceResources(\n\t\tsources: string[],\n\t\toptions?: { local?: boolean; temporary?: boolean },\n\t): Promise<ResolvedPaths> {\n\t\tconst accumulator = createAccumulator();\n\t\tconst scope: SourceScope = options?.temporary ? \"temporary\" : options?.local ? \"project\" : \"user\";\n\t\tconst packageSources = sources.map((source) => ({ pkg: source as PackageSource, scope }));\n\t\tawait this.resolvePackageSources(packageSources, accumulator);\n\t\treturn toResolvedPaths(accumulator);\n\t}\n\n\tlistConfiguredPackages(): ConfiguredPackage[] {\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst configuredPackages: ConfiguredPackage[] = [];\n\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconfiguredPackages.push({\n\t\t\t\tsource,\n\t\t\t\tscope: \"user\",\n\t\t\t\tfiltered: typeof pkg === \"object\",\n\t\t\t\tinstalledPath: this.getInstalledPath(source, \"user\"),\n\t\t\t});\n\t\t}\n\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconfiguredPackages.push({\n\t\t\t\tsource,\n\t\t\t\tscope: \"project\",\n\t\t\t\tfiltered: typeof pkg === \"object\",\n\t\t\t\tinstalledPath: this.getInstalledPath(source, \"project\"),\n\t\t\t});\n\t\t}\n\n\t\treturn configuredPackages;\n\t}\n\n\tasync install(source: string, options?: { local?: boolean }): Promise<void> {\n\t\tconst parsed = this.parseSource(source);\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tawait this.withProgress(\"install\", source, `Installing ${source}...`, async () => {\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tawait this.installNpm(parsed, scope, false);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tawait this.installGit(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\tconst resolved = this.resolvePath(parsed.path);\n\t\t\t\tif (!existsSync(resolved)) {\n\t\t\t\t\tthrow new Error(t(\"Path does not exist: {path}\", { path: resolved }));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(t(\"Unsupported install source: {source}\", { source }));\n\t\t});\n\t}\n\n\tasync installAndPersist(source: string, options?: { local?: boolean }): Promise<void> {\n\t\tawait this.install(source, options);\n\t\tthis.addSourceToSettings(source, options);\n\t}\n\n\tasync remove(source: string, options?: { local?: boolean }): Promise<void> {\n\t\tconst parsed = this.parseSource(source);\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tawait this.withProgress(\"remove\", source, `Removing ${source}...`, async () => {\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tawait this.uninstallNpm(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tawait this.removeGit(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(t(\"Unsupported remove source: {source}\", { source }));\n\t\t});\n\t}\n\n\tasync removeAndPersist(source: string, options?: { local?: boolean }): Promise<boolean> {\n\t\tawait this.remove(source, options);\n\t\treturn this.removeSourceFromSettings(source, options);\n\t}\n\n\tasync update(source?: string): Promise<void> {\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst identity = source ? this.getPackageIdentity(source) : undefined;\n\t\tlet matched = false;\n\t\tconst updateSources: ConfiguredUpdateSource[] = [];\n\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tconst sourceStr = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tif (identity && this.getPackageIdentity(sourceStr, \"user\") !== identity) continue;\n\t\t\tmatched = true;\n\t\t\tupdateSources.push({ source: sourceStr, scope: \"user\" });\n\t\t}\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tconst sourceStr = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tif (identity && this.getPackageIdentity(sourceStr, \"project\") !== identity) continue;\n\t\t\tmatched = true;\n\t\t\tupdateSources.push({ source: sourceStr, scope: \"project\" });\n\t\t}\n\n\t\tif (source && !matched) {\n\t\t\tthrow new Error(\n\t\t\t\tthis.buildNoMatchingPackageMessage(source, [\n\t\t\t\t\t...(globalSettings.packages ?? []),\n\t\t\t\t\t...(projectSettings.packages ?? []),\n\t\t\t\t]),\n\t\t\t);\n\t\t}\n\n\t\tawait this.updateConfiguredSources(updateSources);\n\t}\n\n\tprivate async updateConfiguredSources(sources: ConfiguredUpdateSource[]): Promise<void> {\n\t\tif (isOfflineModeEnabled() || sources.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst npmCandidates: NpmUpdateTarget[] = [];\n\t\tconst gitCandidates: GitUpdateTarget[] = [];\n\n\t\tfor (const entry of sources) {\n\t\t\tconst parsed = this.parseSource(entry.source);\n\t\t\t// Pinned npm versions are fixed. Pinned git refs are configured checkout targets,\n\t\t\t// so include them to reconcile an existing clone when the configured ref changes.\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tif (!parsed.pinned) {\n\t\t\t\t\tnpmCandidates.push({ ...entry, parsed });\n\t\t\t\t}\n\t\t\t} else if (parsed.type === \"git\") {\n\t\t\t\tgitCandidates.push({ ...entry, parsed });\n\t\t\t}\n\t\t}\n\n\t\tconst npmCheckTasks = npmCandidates.map((entry) => async () => ({\n\t\t\tentry,\n\t\t\tshouldUpdate: await this.shouldUpdateNpmSource(entry.parsed, entry.scope),\n\t\t}));\n\t\tconst npmCheckResults = await runWithConcurrency(npmCheckTasks, UPDATE_CHECK_CONCURRENCY);\n\t\tconst userNpmUpdates: NpmUpdateTarget[] = [];\n\t\tconst projectNpmUpdates: NpmUpdateTarget[] = [];\n\t\tfor (const result of npmCheckResults) {\n\t\t\tif (!result.shouldUpdate) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (result.entry.scope === \"user\") {\n\t\t\t\tuserNpmUpdates.push(result.entry);\n\t\t\t} else {\n\t\t\t\tprojectNpmUpdates.push(result.entry);\n\t\t\t}\n\t\t}\n\n\t\tconst tasks: Promise<void>[] = [];\n\t\tif (userNpmUpdates.length > 0) {\n\t\t\ttasks.push(this.updateNpmBatch(userNpmUpdates, \"user\"));\n\t\t}\n\t\tif (projectNpmUpdates.length > 0) {\n\t\t\ttasks.push(this.updateNpmBatch(projectNpmUpdates, \"project\"));\n\t\t}\n\t\tif (gitCandidates.length > 0) {\n\t\t\tconst gitTasks = gitCandidates.map(\n\t\t\t\t(entry) => async () =>\n\t\t\t\t\tthis.withProgress(\"update\", entry.source, `Updating ${entry.source}...`, async () => {\n\t\t\t\t\t\tawait this.updateGit(entry.parsed, entry.scope);\n\t\t\t\t\t}),\n\t\t\t);\n\t\t\ttasks.push(runWithConcurrency(gitTasks, GIT_UPDATE_CONCURRENCY).then(() => {}));\n\t\t}\n\n\t\tawait Promise.all(tasks);\n\t}\n\n\tprivate async shouldUpdateNpmSource(source: NpmSource, scope: InstalledSourceScope): Promise<boolean> {\n\t\tconst installedPath = getManagedNpmInstallPath(this.context, source, scope);\n\t\tconst installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;\n\t\tif (!installedVersion) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);\n\t\treturn gt(targetVersion, installedVersion);\n\t}\n\n\tprivate async updateNpmBatch(sources: NpmUpdateTarget[], scope: InstalledSourceScope): Promise<void> {\n\t\tif (sources.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst sourceLabel = sources.length === 1 ? sources[0].source : `${scope} npm packages`;\n\t\tconst message = sources.length === 1 ? `Updating ${sources[0].source}...` : `Updating ${scope} npm packages...`;\n\t\tconst specs = sources.map((entry) => (entry.parsed.version ? entry.parsed.spec : `${entry.parsed.name}@latest`));\n\n\t\tawait this.withProgress(\"update\", sourceLabel, message, async () => {\n\t\t\tawait this.installNpmBatch(specs, scope);\n\t\t});\n\t}\n\n\tprivate async installNpmBatch(specs: string[], scope: InstalledSourceScope): Promise<void> {\n\t\tconst installRoot = getNpmInstallRoot(this.context, scope, false);\n\t\tensureNpmProject(installRoot);\n\t\tawait this.runNpmCommand(getNpmInstallArgs(this.context, specs, installRoot));\n\t}\n\n\tasync checkForAvailableUpdates(): Promise<PackageUpdate[]> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst allPackages: Array<{ pkg: PackageSource; scope: SourceScope }> = [];\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"project\" });\n\t\t}\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"user\" });\n\t\t}\n\n\t\tconst packageSources = this.dedupePackages(allPackages);\n\t\tconst checks = packageSources\n\t\t\t.filter(\n\t\t\t\t(entry): entry is { pkg: PackageSource; scope: Exclude<SourceScope, \"temporary\"> } =>\n\t\t\t\t\tentry.scope !== \"temporary\",\n\t\t\t)\n\t\t\t.map((entry) => async (): Promise<PackageUpdate | undefined> => {\n\t\t\t\tconst source = typeof entry.pkg === \"string\" ? entry.pkg : entry.pkg.source;\n\t\t\t\tconst parsed = this.parseSource(source);\n\t\t\t\tif (parsed.type === \"local\" || parsed.pinned) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\t\tconst installedPath = this.getNpmInstallPath(parsed, entry.scope);\n\t\t\t\t\tif (!existsSync(installedPath)) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tconst hasUpdate = await this.npmHasAvailableUpdate(parsed, installedPath);\n\t\t\t\t\tif (!hasUpdate) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tdisplayName: parsed.name,\n\t\t\t\t\t\ttype: \"npm\",\n\t\t\t\t\t\tscope: entry.scope,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst installedPath = this.getGitInstallPath(parsed, entry.scope);\n\t\t\t\tif (!existsSync(installedPath)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tconst hasUpdate = await this.gitHasAvailableUpdate(installedPath);\n\t\t\t\tif (!hasUpdate) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsource,\n\t\t\t\t\tdisplayName: `${parsed.host}/${parsed.path}`,\n\t\t\t\t\ttype: \"git\",\n\t\t\t\t\tscope: entry.scope,\n\t\t\t\t};\n\t\t\t});\n\n\t\tconst results = await runWithConcurrency(checks, UPDATE_CHECK_CONCURRENCY);\n\t\treturn results.filter((result): result is PackageUpdate => result !== undefined);\n\t}\n\n\tprivate async resolvePackageSources(\n\t\tsources: Array<{ pkg: PackageSource; scope: SourceScope }>,\n\t\taccumulator: ResourceAccumulator,\n\t\tonMissing?: (source: string) => Promise<MissingSourceAction>,\n\t): Promise<void> {\n\t\tfor (const { pkg, scope } of sources) {\n\t\t\tconst sourceStr = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconst filter = typeof pkg === \"object\" ? pkg : undefined;\n\t\t\tconst deltaBase = this.findAutoloadDeltaBase(pkg, scope, sources);\n\t\t\tconst resolvedSource = deltaBase?.source ?? sourceStr;\n\t\t\tconst resolvedScope = deltaBase?.scope ?? scope;\n\t\t\tconst parsed = this.parseSource(resolvedSource);\n\t\t\tconst metadata: PathMetadata = { source: sourceStr, scope, origin: \"package\" };\n\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\tconst baseDir = this.getBaseDirForScope(resolvedScope);\n\t\t\t\tconst resolvedLocal = this.resolvePathFromBase(parsed.path, baseDir);\n\t\t\t\tif (existsSync(resolvedLocal)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (statSync(resolvedLocal).isDirectory()) {\n\t\t\t\t\t\t\tmetadata.baseDir = resolvedLocal;\n\t\t\t\t\t\t\tcollectPackageResources(resolvedLocal, accumulator, filter, metadata);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Unreadable local path: skip the source.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst installMissing = async (): Promise<boolean> => {\n\t\t\t\tif (isOfflineModeEnabled()) return false;\n\t\t\t\tif (!onMissing) {\n\t\t\t\t\tawait this.installParsedSource(parsed, resolvedScope);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst action = await onMissing(resolvedSource);\n\t\t\t\tif (action === \"skip\") return false;\n\t\t\t\tif (action === \"error\") throw new Error(t(\"Missing source: {source}\", { source: resolvedSource }));\n\t\t\t\tawait this.installParsedSource(parsed, resolvedScope);\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tlet installedPath = this.getNpmInstallPath(parsed, resolvedScope);\n\t\t\t\tconst needsInstall =\n\t\t\t\t\t!existsSync(installedPath) || !(await installedNpmMatchesConfiguredVersion(parsed, installedPath));\n\t\t\t\tif (needsInstall) {\n\t\t\t\t\tconst installed = await installMissing();\n\t\t\t\t\tif (!installed) continue;\n\t\t\t\t\tinstalledPath = this.getNpmInstallPath(parsed, resolvedScope);\n\t\t\t\t}\n\t\t\t\tmetadata.baseDir = installedPath;\n\t\t\t\tcollectPackageResources(installedPath, accumulator, filter, metadata);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tconst installedPath = this.getGitInstallPath(parsed, resolvedScope);\n\t\t\t\tif (!existsSync(installedPath)) {\n\t\t\t\t\tconst installed = await installMissing();\n\t\t\t\t\tif (!installed) continue;\n\t\t\t\t} else if (resolvedScope === \"temporary\" && !parsed.pinned && !isOfflineModeEnabled()) {\n\t\t\t\t\tawait this.refreshTemporaryGitSource(parsed, resolvedSource);\n\t\t\t\t}\n\t\t\t\tmetadata.baseDir = installedPath;\n\t\t\t\tcollectPackageResources(installedPath, accumulator, filter, metadata);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate findAutoloadDeltaBase(\n\t\tpkg: PackageSource,\n\t\tscope: SourceScope,\n\t\tsources: Array<{ pkg: PackageSource; scope: SourceScope }>,\n\t): { source: string; scope: SourceScope } | undefined {\n\t\tif (scope !== \"project\" || typeof pkg !== \"object\" || pkg.autoload !== false) return undefined;\n\t\tconst identity = this.getPackageIdentity(pkg.source, scope);\n\t\tconst userEntry = sources.find(\n\t\t\t(entry) =>\n\t\t\t\tentry.scope === \"user\" &&\n\t\t\t\tthis.getPackageIdentity(this.getPackageSourceString(entry.pkg), \"user\") === identity,\n\t\t);\n\t\treturn userEntry ? { source: this.getPackageSourceString(userEntry.pkg), scope: \"user\" } : undefined;\n\t}\n\n\tprivate async installParsedSource(parsed: ParsedSource, scope: SourceScope): Promise<void> {\n\t\tif (parsed.type === \"npm\") {\n\t\t\tawait this.installNpm(parsed, scope, scope === \"temporary\");\n\t\t\treturn;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\tawait this.installGit(parsed, scope);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate parseSource(source: string): ParsedSource {\n\t\treturn parseSource(source);\n\t}\n\n\tprivate getBaseDirForScope(scope: SourceScope): string {\n\t\treturn getBaseDirForScope(this.context, scope);\n\t}\n\n\tprivate resolvePath(input: string): string {\n\t\treturn resolvePath(this.context, input);\n\t}\n\n\tprivate resolvePathFromBase(input: string, baseDir: string): string {\n\t\treturn resolvePathFromBase(input, baseDir);\n\t}\n\n\tprivate getPackageSourceString(pkg: PackageSource): string {\n\t\treturn getPackageSourceString(pkg);\n\t}\n\n\tprivate getSourceMatchKeyForInput(source: string): string {\n\t\treturn getSourceMatchKeyForInput(this.context, source);\n\t}\n\n\tprivate getSourceMatchKeyForSettings(source: string, scope: SourceScope): string {\n\t\treturn getSourceMatchKeyForSettings(this.context, source, scope);\n\t}\n\n\tprivate packageSourcesMatch(existing: PackageSource, inputSource: string, scope: SourceScope): boolean {\n\t\tconst left = this.getSourceMatchKeyForSettings(this.getPackageSourceString(existing), scope);\n\t\tconst right = this.getSourceMatchKeyForInput(inputSource);\n\t\treturn left === right;\n\t}\n\n\tprivate normalizePackageSourceForSettings(source: string, scope: SourceScope): string {\n\t\treturn normalizePackageSourceForSettings(this.context, source, scope);\n\t}\n\n\tprivate getPackageIdentity(source: string, scope?: SourceScope): string {\n\t\treturn getPackageIdentity(this.context, source, scope);\n\t}\n\n\tprivate dedupePackages(\n\t\tpackages: Array<{ pkg: PackageSource; scope: SourceScope }>,\n\t): Array<{ pkg: PackageSource; scope: SourceScope }> {\n\t\treturn dedupePackages(this.context, packages);\n\t}\n\n\tprivate buildNoMatchingPackageMessage(source: string, configuredPackages: PackageSource[]): string {\n\t\treturn buildNoMatchingPackageMessage(source, configuredPackages);\n\t}\n\n\tprivate getNpmCommand(): { command: string; args: string[] } {\n\t\treturn getNpmCommand(this.context);\n\t}\n\n\tprivate getInstalledNpmVersion(installedPath: string): string | undefined {\n\t\treturn getInstalledNpmVersion(installedPath);\n\t}\n\n\tprivate getGitInstallPath(source: GitSource, scope: SourceScope): string {\n\t\treturn getGitInstallPath(this.context, source, scope);\n\t}\n\n\tprivate async npmHasAvailableUpdate(source: NpmSource, installedPath: string): Promise<boolean> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst installedVersion = this.getInstalledNpmVersion(installedPath);\n\t\tif (!installedVersion) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);\n\t\t\treturn gt(targetVersion, installedVersion);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate async getLatestNpmVersion(packageSpec: string, range?: string): Promise<string> {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tconst stdout = await this.runCommandCapture(\n\t\t\tnpmCommand.command,\n\t\t\t[...npmCommand.args, \"view\", packageSpec, \"version\", \"--json\"],\n\t\t\t{ cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS },\n\t\t);\n\t\tconst raw = stdout.trim();\n\t\tif (!raw) throw new Error(t(\"Empty response from npm view\"));\n\t\tconst parsed = JSON.parse(raw) as unknown;\n\t\tif (typeof parsed === \"string\") {\n\t\t\treturn parsed;\n\t\t}\n\t\tif (Array.isArray(parsed)) {\n\t\t\tconst versions = parsed.filter((value): value is string => typeof value === \"string\" && value.length > 0);\n\t\t\tconst latest = range ? maxSatisfying(versions, range) : [...versions].sort(rcompare)[0];\n\t\t\tif (latest) return latest;\n\t\t}\n\t\tthrow new Error(t(\"Unexpected response from npm view\"));\n\t}\n\n\tprivate async gitHasAvailableUpdate(installedPath: string): Promise<boolean> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst localHead = await this.runCommandCapture(\"git\", [\"rev-parse\", \"HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst remoteHead = await this.getRemoteGitHead(installedPath);\n\t\t\treturn localHead.trim() !== remoteHead.trim();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate async getRemoteGitHead(installedPath: string): Promise<string> {\n\t\tconst upstreamRef = await this.getGitUpstreamRef(installedPath);\n\t\tif (upstreamRef) {\n\t\t\tconst remoteHead = await this.runGitRemoteCommand(installedPath, [\"ls-remote\", \"origin\", upstreamRef]);\n\t\t\tconst match = remoteHead.match(/^([0-9a-f]{40})\\s+/m);\n\t\t\tif (match?.[1]) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\n\t\tconst remoteHead = await this.runGitRemoteCommand(installedPath, [\"ls-remote\", \"origin\", \"HEAD\"]);\n\t\tconst match = remoteHead.match(/^([0-9a-f]{40})\\s+HEAD$/m);\n\t\tif (!match?.[1]) {\n\t\t\tthrow new Error(t(\"Failed to determine remote HEAD\"));\n\t\t}\n\t\treturn match[1];\n\t}\n\n\tprivate async getLocalGitUpdateTarget(\n\t\tinstalledPath: string,\n\t): Promise<{ ref: string; head: string; fetchArgs: string[] }> {\n\t\ttry {\n\t\t\tconst upstream = await this.runCommandCapture(\"git\", [\"rev-parse\", \"--abbrev-ref\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst trimmedUpstream = upstream.trim();\n\t\t\tif (!trimmedUpstream.startsWith(\"origin/\")) {\n\t\t\t\tthrow new Error(t(\"Unsupported upstream remote: {upstream}\", { upstream: trimmedUpstream }));\n\t\t\t}\n\t\t\tconst branch = trimmedUpstream.slice(\"origin/\".length);\n\t\t\tif (!branch) {\n\t\t\t\tthrow new Error(t(\"Missing upstream branch name\"));\n\t\t\t}\n\t\t\tconst head = await this.runCommandCapture(\"git\", [\"rev-parse\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tref: \"@{upstream}\",\n\t\t\t\thead,\n\t\t\t\tfetchArgs: [\n\t\t\t\t\t\"fetch\",\n\t\t\t\t\t\"--prune\",\n\t\t\t\t\t\"--no-tags\",\n\t\t\t\t\t\"origin\",\n\t\t\t\t\t`+refs/heads/${branch}:refs/remotes/origin/${branch}`,\n\t\t\t\t],\n\t\t\t};\n\t\t} catch {\n\t\t\tawait this.runCommand(\"git\", [\"remote\", \"set-head\", \"origin\", \"-a\"], { cwd: installedPath }).catch(() => {});\n\t\t\tconst head = await this.runCommandCapture(\"git\", [\"rev-parse\", \"origin/HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst originHeadRef = await this.runCommandCapture(\"git\", [\"symbolic-ref\", \"refs/remotes/origin/HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t}).catch(() => \"\");\n\t\t\tconst branch = originHeadRef.trim().replace(/^refs\\/remotes\\/origin\\//, \"\");\n\t\t\tif (branch) {\n\t\t\t\treturn {\n\t\t\t\t\tref: \"origin/HEAD\",\n\t\t\t\t\thead,\n\t\t\t\t\tfetchArgs: [\n\t\t\t\t\t\t\"fetch\",\n\t\t\t\t\t\t\"--prune\",\n\t\t\t\t\t\t\"--no-tags\",\n\t\t\t\t\t\t\"origin\",\n\t\t\t\t\t\t`+refs/heads/${branch}:refs/remotes/origin/${branch}`,\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tref: \"origin/HEAD\",\n\t\t\t\thead,\n\t\t\t\tfetchArgs: [\"fetch\", \"--prune\", \"--no-tags\", \"origin\", \"+HEAD:refs/remotes/origin/HEAD\"],\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate async getGitUpstreamRef(installedPath: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst upstream = await this.runCommandCapture(\"git\", [\"rev-parse\", \"--abbrev-ref\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst trimmed = upstream.trim();\n\t\t\tif (!trimmed.startsWith(\"origin/\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst branch = trimmed.slice(\"origin/\".length);\n\t\t\treturn branch ? `refs/heads/${branch}` : undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate runGitRemoteCommand(installedPath: string, args: string[]): Promise<string> {\n\t\treturn this.runCommandCapture(\"git\", args, {\n\t\t\tcwd: installedPath,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\tenv: {\n\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate getGlobalNpmRoot(): string {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tconst commandKey = [npmCommand.command, ...npmCommand.args].join(\"\\0\");\n\t\tif (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {\n\t\t\treturn this.globalNpmRoot;\n\t\t}\n\t\tif (getPackageManagerName(this.context) === \"bun\") {\n\t\t\tconst binDir = this.runNpmCommandSync([\"pm\", \"bin\", \"-g\"]).trim();\n\t\t\tthis.globalNpmRoot = join(dirname(binDir), \"install\", \"global\", \"node_modules\");\n\t\t} else {\n\t\t\tthis.globalNpmRoot = this.runNpmCommandSync([\"root\", \"-g\"]).trim();\n\t\t}\n\t\tthis.globalNpmRootCommandKey = commandKey;\n\t\treturn this.globalNpmRoot;\n\t}\n\n\tprivate getPnpmGlobalPackagePath(packageName: string): string | undefined {\n\t\tif (getPackageManagerName(this.context) !== \"pnpm\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = this.runNpmCommandSync([\"list\", \"-g\", \"--depth\", \"0\", \"--json\"]);\n\t\tconst entries = JSON.parse(output) as Array<{ dependencies?: Record<string, { path?: string }> }>;\n\t\tfor (const entry of entries) {\n\t\t\tconst path = entry.dependencies?.[packageName]?.path;\n\t\t\tif (path) return path;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate getLegacyGlobalNpmInstallPath(source: NpmSource): string | undefined {\n\t\t// Read-only migration compatibility for pre-managed global installs. New installs\n\t\t// always target the Agent Forge-managed root; this lookup never substitutes a package.\n\t\ttry {\n\t\t\treturn this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate getNpmInstallPath(source: NpmSource, scope: SourceScope): string {\n\t\tconst managedPath = getManagedNpmInstallPath(this.context, source, scope);\n\t\tif (scope !== \"user\" || existsSync(managedPath)) {\n\t\t\treturn managedPath;\n\t\t}\n\t\tconst legacyPath = this.getLegacyGlobalNpmInstallPath(source);\n\t\treturn legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;\n\t}\n\n\tprivate async installNpm(source: NpmSource, scope: SourceScope, temporary: boolean): Promise<void> {\n\t\tconst installRoot = getNpmInstallRoot(this.context, scope, temporary);\n\t\tensureNpmProject(installRoot);\n\t\tawait this.runNpmCommand(getNpmInstallArgs(this.context, [source.spec], installRoot));\n\t}\n\n\tprivate async uninstallNpm(source: NpmSource, scope: SourceScope): Promise<void> {\n\t\tconst installRoot = getNpmInstallRoot(this.context, scope, false);\n\t\tif (!existsSync(installRoot)) {\n\t\t\treturn;\n\t\t}\n\t\tconst packageManagerName = getPackageManagerName(this.context);\n\t\tif (packageManagerName === \"bun\") {\n\t\t\tawait this.runNpmCommand([\"uninstall\", source.name, \"--cwd\", installRoot]);\n\t\t\treturn;\n\t\t}\n\t\tconst args = [\"uninstall\", source.name, \"--prefix\", installRoot];\n\t\tif (packageManagerName !== \"pnpm\") {\n\t\t\targs.push(\"--legacy-peer-deps\");\n\t\t}\n\t\tawait this.runNpmCommand(args);\n\t}\n\n\tprivate async installGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\tif (existsSync(targetDir)) {\n\t\t\tif (source.ref) {\n\t\t\t\tawait this.ensureGitRef(targetDir, [\"fetch\", \"origin\", source.ref], \"FETCH_HEAD\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst target = await this.getLocalGitUpdateTarget(targetDir);\n\t\t\tawait this.ensureGitRef(targetDir, target.fetchArgs, target.ref);\n\t\t\treturn;\n\t\t}\n\t\tconst gitRoot = getGitInstallRoot(this.context, scope);\n\t\tif (gitRoot) {\n\t\t\tensureGitIgnore(gitRoot);\n\t\t}\n\t\tmkdirSync(dirname(targetDir), { recursive: true });\n\t\trmSync(getGitUpdateMarkerPath(targetDir), { force: true });\n\n\t\ttry {\n\t\t\tawait this.runCommand(\"git\", [\"clone\", source.repo, targetDir]);\n\t\t\tif (source.ref) {\n\t\t\t\tawait this.runCommand(\"git\", [\"checkout\", source.ref], { cwd: targetDir });\n\t\t\t}\n\t\t\tconst packageJsonPath = join(targetDir, \"package.json\");\n\t\t\tif (existsSync(packageJsonPath)) {\n\t\t\t\tawait this.runNpmCommand(getGitDependencyInstallArgs(this.context), { cwd: targetDir });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\trmSync(targetDir, { recursive: true, force: true });\n\t\t\tpruneEmptyGitParents(targetDir, gitRoot);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate async updateGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\tif (!existsSync(targetDir)) {\n\t\t\tawait this.installGit(source, scope);\n\t\t\treturn;\n\t\t}\n\n\t\tif (source.ref) {\n\t\t\tawait this.ensureGitRef(targetDir, [\"fetch\", \"origin\", source.ref], \"FETCH_HEAD\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst target = await this.getLocalGitUpdateTarget(targetDir);\n\t\tawait this.ensureGitRef(targetDir, target.fetchArgs, target.ref);\n\t}\n\n\tprivate async repairMissingGitDependencies(targetDir: string): Promise<void> {\n\t\tif (!hasMissingGitDependencies(targetDir)) return;\n\t\tawait this.runNpmCommand(getGitDependencyInstallArgs(this.context), { cwd: targetDir });\n\t}\n\n\tprivate async cleanAndInstallGitDependencies(targetDir: string, markerPath: string): Promise<void> {\n\t\t// Clean untracked files (extensions should be pristine). If this fails after\n\t\t// deleting dependencies, repair them so the existing extension still loads.\n\t\ttry {\n\t\t\tawait this.runCommand(\"git\", [\"clean\", \"-fdx\"], { cwd: targetDir });\n\t\t} catch (error) {\n\t\t\tawait this.repairMissingGitDependencies(targetDir).catch(() => {});\n\t\t\tthrow error;\n\t\t}\n\n\t\tconst packageJsonPath = join(targetDir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tawait this.runNpmCommand(getGitDependencyInstallArgs(this.context), { cwd: targetDir });\n\t\t}\n\t\trmSync(markerPath, { force: true });\n\t}\n\n\tprivate async ensureGitRef(targetDir: string, fetchArgs: string[], ref: string): Promise<void> {\n\t\t// Fetch only the ref we will reset to, avoiding unrelated branch/tag noise.\n\t\tawait this.runCommand(\"git\", fetchArgs, { cwd: targetDir });\n\n\t\tconst localHead = await this.runCommandCapture(\"git\", [\"rev-parse\", \"HEAD\"], {\n\t\t\tcwd: targetDir,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t});\n\t\tconst commitRef = `${ref}^{commit}`;\n\t\tconst targetHead = await this.runCommandCapture(\"git\", [\"rev-parse\", commitRef], {\n\t\t\tcwd: targetDir,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t});\n\t\tconst markerPath = getGitUpdateMarkerPath(targetDir);\n\t\tif (localHead.trim() === targetHead.trim()) {\n\t\t\tif (existsSync(markerPath)) {\n\t\t\t\tawait this.cleanAndInstallGitDependencies(targetDir, markerPath);\n\t\t\t} else {\n\t\t\t\tawait this.repairMissingGitDependencies(targetDir);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\twriteFileSync(markerPath, \"\", \"utf-8\");\n\t\tawait this.runCommand(\"git\", [\"reset\", \"--hard\", commitRef], { cwd: targetDir });\n\t\tawait this.cleanAndInstallGitDependencies(targetDir, markerPath);\n\t}\n\n\tprivate async refreshTemporaryGitSource(source: GitSource, sourceStr: string): Promise<void> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait this.withProgress(\"pull\", sourceStr, `Refreshing ${sourceStr}...`, async () => {\n\t\t\t\tawait this.updateGit(source, \"temporary\");\n\t\t\t});\n\t\t} catch {\n\t\t\t// Keep cached temporary checkout if refresh fails.\n\t\t}\n\t}\n\n\tprivate async removeGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\trmSync(targetDir, { recursive: true, force: true });\n\t\trmSync(getGitUpdateMarkerPath(targetDir), { force: true });\n\t\tpruneEmptyGitParents(targetDir, getGitInstallRoot(this.context, scope));\n\t}\n\n\tprivate async runNpmCommand(args: string[], options?: { cwd?: string }): Promise<void> {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tawait this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);\n\t}\n\n\tprivate runNpmCommandSync(args: string[]): string {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\treturn this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);\n\t}\n\n\tprivate spawnCommand(command: string, args: string[], options?: { cwd?: string }): ChildProcess {\n\t\tconst env = getEnv();\n\t\treturn spawnProcess(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tstdio: isStdoutTakenOver() ? [\"ignore\", 2, 2] : \"inherit\",\n\t\t\tenv,\n\t\t});\n\t}\n\n\tprivate spawnCaptureCommand(\n\t\tcommand: string,\n\t\targs: string[],\n\t\toptions?: { cwd?: string; env?: Record<string, string> },\n\t): ChildProcessByStdio<null, Readable, Readable> {\n\t\tconst baseEnv = getEnv();\n\t\tconst env = options?.env ? { ...baseEnv, ...options.env } : baseEnv;\n\t\treturn spawnProcess(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tenv,\n\t\t});\n\t}\n\n\tprivate runCommandCapture(\n\t\tcommand: string,\n\t\targs: string[],\n\t\toptions?: { cwd?: string; timeoutMs?: number; env?: Record<string, string> },\n\t): Promise<string> {\n\t\treturn new Promise((resolvePromise, reject) => {\n\t\t\tconst child = this.spawnCaptureCommand(command, args, options);\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tlet timedOut = false;\n\t\t\tconst timeout =\n\t\t\t\ttypeof options?.timeoutMs === \"number\"\n\t\t\t\t\t? setTimeout(() => {\n\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t}, options.timeoutMs)\n\t\t\t\t\t: undefined;\n\n\t\t\tchild.stdout?.on(\"data\", (data) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\t\t\tchild.stderr?.on(\"data\", (data) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t\tchild.once(\"error\", (error) => {\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\treject(error);\n\t\t\t});\n\t\t\tchild.once(\"close\", (code, signal) => {\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\tif (timedOut) {\n\t\t\t\t\treject(new Error(`${command} ${args.join(\" \")} timed out after ${options?.timeoutMs}ms`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolvePromise(stdout.trim());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst exitStatus = code === null ? `signal ${signal ?? \"unknown\"}` : `code ${code}`;\n\t\t\t\treject(new Error(`${command} ${args.join(\" \")} failed with ${exitStatus}: ${stderr || stdout}`));\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate runCommand(command: string, args: string[], options?: { cwd?: string }): Promise<void> {\n\t\treturn new Promise((resolvePromise, reject) => {\n\t\t\tconst child = this.spawnCommand(command, args, options);\n\t\t\tchild.on(\"error\", reject);\n\t\t\tchild.on(\"exit\", (code) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolvePromise();\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error(`${command} ${args.join(\" \")} failed with code ${code}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate runCommandSync(command: string, args: string[]): string {\n\t\tconst env = getEnv();\n\t\tconst result = spawnProcessSync(command, args, {\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tencoding: \"utf-8\",\n\t\t\tenv,\n\t\t});\n\t\tif (result.error || result.status !== 0) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Failed to run {command} {args}: {reason}\", {\n\t\t\t\t\tcommand,\n\t\t\t\t\targs: args.join(\" \"),\n\t\t\t\t\treason: result.error?.message || result.stderr || result.stdout,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\treturn (result.stdout || result.stderr || \"\").trim();\n\t}\n}\n"]}
|
|
@@ -4,6 +4,7 @@ import { gt, maxSatisfying, rcompare } from "semver";
|
|
|
4
4
|
import { CONFIG_DIR_NAME } from "../config.js";
|
|
5
5
|
import { spawnProcess, spawnProcessSync } from "../utils/child-process.js";
|
|
6
6
|
import { resolvePath as resolvePathWithBase } from "../utils/paths.js";
|
|
7
|
+
import { t } from "./i18n/index.js";
|
|
7
8
|
import { isStdoutTakenOver } from "./output-guard.js";
|
|
8
9
|
import { ensureGitIgnore, ensureNpmProject, getGitDependencyInstallArgs, getGitInstallPath, getGitInstallRoot, getGitUpdateMarkerPath, getInstalledNpmVersion, getManagedNpmInstallPath, getNpmCommand, getNpmInstallArgs, getNpmInstallRoot, getPackageManagerName, hasMissingGitDependencies, installedNpmMatchesConfiguredVersion, pruneEmptyGitParents, } from "./package-install-host.js";
|
|
9
10
|
import { getEnv, isOfflineModeEnabled, runWithConcurrency } from "./package-process-runner.js";
|
|
@@ -193,11 +194,11 @@ export class DefaultPackageManager {
|
|
|
193
194
|
if (parsed.type === "local") {
|
|
194
195
|
const resolved = this.resolvePath(parsed.path);
|
|
195
196
|
if (!existsSync(resolved)) {
|
|
196
|
-
throw new Error(
|
|
197
|
+
throw new Error(t("Path does not exist: {path}", { path: resolved }));
|
|
197
198
|
}
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
200
|
-
throw new Error(
|
|
201
|
+
throw new Error(t("Unsupported install source: {source}", { source }));
|
|
201
202
|
});
|
|
202
203
|
}
|
|
203
204
|
async installAndPersist(source, options) {
|
|
@@ -219,7 +220,7 @@ export class DefaultPackageManager {
|
|
|
219
220
|
if (parsed.type === "local") {
|
|
220
221
|
return;
|
|
221
222
|
}
|
|
222
|
-
throw new Error(
|
|
223
|
+
throw new Error(t("Unsupported remove source: {source}", { source }));
|
|
223
224
|
});
|
|
224
225
|
}
|
|
225
226
|
async removeAndPersist(source, options) {
|
|
@@ -423,7 +424,7 @@ export class DefaultPackageManager {
|
|
|
423
424
|
if (action === "skip")
|
|
424
425
|
return false;
|
|
425
426
|
if (action === "error")
|
|
426
|
-
throw new Error(
|
|
427
|
+
throw new Error(t("Missing source: {source}", { source: resolvedSource }));
|
|
427
428
|
await this.installParsedSource(parsed, resolvedScope);
|
|
428
429
|
return true;
|
|
429
430
|
};
|
|
@@ -541,7 +542,7 @@ export class DefaultPackageManager {
|
|
|
541
542
|
const stdout = await this.runCommandCapture(npmCommand.command, [...npmCommand.args, "view", packageSpec, "version", "--json"], { cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS });
|
|
542
543
|
const raw = stdout.trim();
|
|
543
544
|
if (!raw)
|
|
544
|
-
throw new Error("Empty response from npm view");
|
|
545
|
+
throw new Error(t("Empty response from npm view"));
|
|
545
546
|
const parsed = JSON.parse(raw);
|
|
546
547
|
if (typeof parsed === "string") {
|
|
547
548
|
return parsed;
|
|
@@ -552,7 +553,7 @@ export class DefaultPackageManager {
|
|
|
552
553
|
if (latest)
|
|
553
554
|
return latest;
|
|
554
555
|
}
|
|
555
|
-
throw new Error("Unexpected response from npm view");
|
|
556
|
+
throw new Error(t("Unexpected response from npm view"));
|
|
556
557
|
}
|
|
557
558
|
async gitHasAvailableUpdate(installedPath) {
|
|
558
559
|
if (isOfflineModeEnabled()) {
|
|
@@ -582,7 +583,7 @@ export class DefaultPackageManager {
|
|
|
582
583
|
const remoteHead = await this.runGitRemoteCommand(installedPath, ["ls-remote", "origin", "HEAD"]);
|
|
583
584
|
const match = remoteHead.match(/^([0-9a-f]{40})\s+HEAD$/m);
|
|
584
585
|
if (!match?.[1]) {
|
|
585
|
-
throw new Error("Failed to determine remote HEAD");
|
|
586
|
+
throw new Error(t("Failed to determine remote HEAD"));
|
|
586
587
|
}
|
|
587
588
|
return match[1];
|
|
588
589
|
}
|
|
@@ -594,11 +595,11 @@ export class DefaultPackageManager {
|
|
|
594
595
|
});
|
|
595
596
|
const trimmedUpstream = upstream.trim();
|
|
596
597
|
if (!trimmedUpstream.startsWith("origin/")) {
|
|
597
|
-
throw new Error(
|
|
598
|
+
throw new Error(t("Unsupported upstream remote: {upstream}", { upstream: trimmedUpstream }));
|
|
598
599
|
}
|
|
599
600
|
const branch = trimmedUpstream.slice("origin/".length);
|
|
600
601
|
if (!branch) {
|
|
601
|
-
throw new Error("Missing upstream branch name");
|
|
602
|
+
throw new Error(t("Missing upstream branch name"));
|
|
602
603
|
}
|
|
603
604
|
const head = await this.runCommandCapture("git", ["rev-parse", "@{upstream}"], {
|
|
604
605
|
cwd: installedPath,
|
|
@@ -939,7 +940,11 @@ export class DefaultPackageManager {
|
|
|
939
940
|
env,
|
|
940
941
|
});
|
|
941
942
|
if (result.error || result.status !== 0) {
|
|
942
|
-
throw new Error(
|
|
943
|
+
throw new Error(t("Failed to run {command} {args}: {reason}", {
|
|
944
|
+
command,
|
|
945
|
+
args: args.join(" "),
|
|
946
|
+
reason: result.error?.message || result.stderr || result.stdout,
|
|
947
|
+
}));
|
|
943
948
|
}
|
|
944
949
|
return (result.stdout || result.stderr || "").trim();
|
|
945
950
|
}
|