@draht/coding-agent 2026.5.12 → 2026.7.7
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 +41 -0
- package/README.md +1 -4
- package/bin/draht-tools.cjs +3756 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +4 -2
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/register-bedrock.js +1 -1
- package/dist/bun/register-bedrock.js.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +36 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +9 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +91 -38
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +5 -3
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +13 -26
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +7 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/session-picker.d.ts +3 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +5 -4
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +20 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +184 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -4
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +27 -13
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +284 -63
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +45 -9
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +100 -33
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +6 -4
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +7 -4
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +55 -33
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +560 -492
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +21 -13
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +48 -28
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -15
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +10 -24
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +1 -2
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +9 -5
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +10 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +8 -7
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +56 -47
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +3 -3
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +1 -1
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +13 -11
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.css +69 -4
- package/dist/core/export-html/template.js +231 -57
- package/dist/core/export-html/tool-renderer.d.ts +0 -6
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +15 -2
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/export-html/vendor/marked.min.js +75 -3
- package/dist/core/extensions/index.d.ts +8 -8
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -6
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +98 -43
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +31 -12
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +248 -33
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +191 -36
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +2 -2
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +7 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +78 -54
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +91 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +9 -8
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +67 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +59 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +24 -5
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +188 -51
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +12 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +84 -39
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/output-guard.d.ts +1 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +52 -22
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +22 -4
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +455 -157
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +59 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +13 -11
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +67 -76
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +72 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +36 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +13 -6
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +143 -22
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +36 -15
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +178 -79
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +34 -18
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +47 -16
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +32 -14
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +366 -209
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +62 -6
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +230 -40
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +10 -10
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +13 -35
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +7 -4
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +4 -4
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -16
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +4 -2
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +24 -14
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts +11 -16
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +187 -178
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +26 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +110 -23
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +22 -24
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +201 -113
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +27 -12
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +7 -18
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +148 -101
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +11 -30
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +23 -12
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +26 -101
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +78 -52
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +6 -15
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +12 -17
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +2 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +40 -22
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts +7 -18
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +103 -52
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +5 -2
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +18 -2
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +12 -2
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +5 -14
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +27 -46
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts +36 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +202 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/index.d.ts +33 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +5 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +208 -93
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +2 -2
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -4
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +5 -5
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +5 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +37 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +3 -3
- 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 +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +36 -5
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +318 -36
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +2 -2
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +2 -2
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +2 -2
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +26 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +8 -3
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +103 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +4 -3
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +27 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +33 -31
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +2 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +5 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +19 -5
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +12 -2
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +45 -11
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +10 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +18 -6
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +93 -25
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +5 -12
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +49 -31
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -2
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +33 -14
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +17 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +301 -20
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +6 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +57 -14
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +137 -13
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +91 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +2 -2
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +8 -7
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +6 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +22 -8
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +76 -19
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1294 -494
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +5 -4
- package/dist/modes/interactive/theme/light.json +5 -4
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +102 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +2 -1
- package/dist/modes/interactive/theme/theme.d.ts +41 -3
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +183 -106
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +40 -20
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +30 -5
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +87 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +113 -31
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +42 -4
- 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 +6 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +504 -25
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/brainstorm.md +148 -0
- package/dist/prompts/commands/map-codebase.md +14 -0
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +2 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +78 -0
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +12 -5
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +33 -5
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -2
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +3 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js +14 -8
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +84 -45
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +54 -22
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +21 -15
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +7 -27
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +75 -115
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +100 -16
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +25 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +75 -2
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +11 -6
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +42 -26
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +86 -10
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +15 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +59 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +12 -12
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +187 -47
- package/docs/development.md +5 -5
- package/docs/docs.json +156 -0
- package/docs/extensions.md +520 -79
- package/docs/index.md +82 -0
- package/docs/json.md +4 -4
- package/docs/keybindings.md +24 -2
- package/docs/models.md +119 -17
- package/docs/packages.md +19 -11
- package/docs/prompt-templates.md +30 -2
- package/docs/providers.md +85 -23
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +99 -10
- package/docs/sdk.md +118 -50
- package/docs/security.md +55 -0
- package/docs/{session.md → session-format.md} +29 -19
- package/docs/sessions.md +145 -0
- package/docs/settings.md +71 -11
- package/docs/skills.md +16 -17
- package/docs/terminal-setup.md +44 -2
- package/docs/termux.md +4 -4
- package/docs/themes.md +3 -3
- package/docs/tmux.md +4 -2
- package/docs/tui.md +44 -4
- package/docs/usage.md +305 -0
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/border-status-editor.ts +145 -0
- package/examples/extensions/built-in-tool-renderer.ts +3 -0
- package/examples/extensions/custom-compaction.ts +2 -1
- package/examples/extensions/custom-header.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +2 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +63 -8
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +2 -2
- package/examples/extensions/doom-overlay/doom-component.ts +2 -2
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/dynamic-tools.ts +2 -2
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +52 -14
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/notify.ts +2 -9
- package/examples/extensions/overlay-qa-tests.ts +240 -138
- package/examples/extensions/overlay-test.ts +7 -4
- package/examples/extensions/plan-mode/index.ts +87 -37
- package/examples/extensions/plan-mode/utils.ts +1 -1
- package/examples/extensions/preset.ts +46 -7
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/provider-payload.ts +8 -4
- package/examples/extensions/qna.ts +3 -3
- package/examples/extensions/question.ts +34 -20
- package/examples/extensions/questionnaire.ts +43 -30
- package/examples/extensions/reload-runtime.ts +1 -1
- package/examples/extensions/sandbox/index.ts +6 -6
- package/examples/extensions/sandbox/package-lock.json +5 -5
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/shutdown-command.ts +1 -1
- package/examples/extensions/snake.ts +1 -1
- package/examples/extensions/space-invaders.ts +1 -1
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/agents.ts +2 -2
- package/examples/extensions/subagent/index.ts +58 -29
- package/examples/extensions/summarize.ts +3 -2
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/titlebar-spinner.ts +2 -2
- package/examples/extensions/todo.ts +2 -2
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.ts +5 -0
- package/examples/extensions/truncated-tool.ts +1 -1
- package/examples/extensions/with-deps/index.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +3 -3
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/sdk/01-minimal.ts +14 -10
- package/examples/sdk/02-custom-model.ts +13 -9
- package/examples/sdk/03-custom-prompt.ts +32 -17
- package/examples/sdk/04-skills.ts +5 -2
- package/examples/sdk/05-tools.ts +23 -31
- package/examples/sdk/06-extensions.ts +14 -8
- package/examples/sdk/07-context-files.ts +5 -3
- package/examples/sdk/08-prompt-templates.ts +5 -2
- package/examples/sdk/09-api-keys-and-oauth.ts +8 -4
- package/examples/sdk/10-settings.ts +8 -6
- package/examples/sdk/11-sessions.ts +4 -0
- package/examples/sdk/12-full-control.ts +15 -19
- package/package.json +22 -16
- package/prompts/commands/brainstorm.md +148 -0
- package/prompts/commands/map-codebase.md +14 -0
|
@@ -1,22 +1,50 @@
|
|
|
1
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
2
1
|
import { createHash } from "node:crypto";
|
|
3
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { homedir
|
|
2
|
+
import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
function getEnv() {
|
|
5
|
+
if (process.platform !== "linux" || Object.keys(process.env).length > 0) {
|
|
6
|
+
return process.env;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const data = readFileSync("/proc/self/environ", "utf-8");
|
|
10
|
+
const env = {};
|
|
11
|
+
for (const entry of data.split("\0")) {
|
|
12
|
+
const idx = entry.indexOf("=");
|
|
13
|
+
if (idx > 0) {
|
|
14
|
+
env[entry.slice(0, idx)] = entry.slice(idx + 1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return env;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return process.env;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
5
23
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
24
|
+
import { globSync } from "glob";
|
|
6
25
|
import ignore from "ignore";
|
|
7
26
|
import { minimatch } from "minimatch";
|
|
27
|
+
import { maxSatisfying, rcompare, satisfies, valid, validRange } from "semver";
|
|
8
28
|
import { CONFIG_DIR_NAME } from "../config.js";
|
|
29
|
+
import { spawnProcess, spawnProcessSync } from "../utils/child-process.js";
|
|
9
30
|
import { parseGitUrl } from "../utils/git.js";
|
|
10
|
-
import { isLocalPath } from "../utils/paths.js";
|
|
31
|
+
import { canonicalizePath, isLocalPath, markPathIgnoredByCloudSync, resolvePath } from "../utils/paths.js";
|
|
11
32
|
import { isStdoutTakenOver } from "./output-guard.js";
|
|
12
33
|
const NETWORK_TIMEOUT_MS = 10000;
|
|
13
34
|
const UPDATE_CHECK_CONCURRENCY = 4;
|
|
35
|
+
const GIT_UPDATE_CONCURRENCY = 4;
|
|
14
36
|
function isOfflineModeEnabled() {
|
|
15
|
-
const value = process.env.
|
|
37
|
+
const value = process.env.DRAHT_OFFLINE;
|
|
16
38
|
if (!value)
|
|
17
39
|
return false;
|
|
18
40
|
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
19
41
|
}
|
|
42
|
+
function isExactNpmVersion(version) {
|
|
43
|
+
return valid(version ?? "") !== null;
|
|
44
|
+
}
|
|
45
|
+
function getNpmVersionRange(version) {
|
|
46
|
+
return version ? (validRange(version) ?? undefined) : undefined;
|
|
47
|
+
}
|
|
20
48
|
/**
|
|
21
49
|
* Compute a numeric precedence rank for a resource based on its metadata.
|
|
22
50
|
* Lower rank = higher precedence. Used to sort resolved resources so that
|
|
@@ -49,6 +77,12 @@ function toPosixPath(p) {
|
|
|
49
77
|
function getHomeDir() {
|
|
50
78
|
return process.env.HOME || homedir();
|
|
51
79
|
}
|
|
80
|
+
export function getExtensionTempFolder(agentDir) {
|
|
81
|
+
const tempFolder = join(agentDir, "tmp", "extensions");
|
|
82
|
+
mkdirSync(tempFolder, { recursive: true, mode: 0o700 });
|
|
83
|
+
chmodSync(tempFolder, 0o700);
|
|
84
|
+
return tempFolder;
|
|
85
|
+
}
|
|
52
86
|
function prefixIgnorePattern(line, prefix) {
|
|
53
87
|
const trimmed = line.trim();
|
|
54
88
|
if (!trimmed)
|
|
@@ -93,6 +127,12 @@ function addIgnoreRules(ig, dir, rootDir) {
|
|
|
93
127
|
function isPattern(s) {
|
|
94
128
|
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-") || s.includes("*") || s.includes("?");
|
|
95
129
|
}
|
|
130
|
+
function isOverridePattern(s) {
|
|
131
|
+
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-");
|
|
132
|
+
}
|
|
133
|
+
function hasGlobPattern(s) {
|
|
134
|
+
return s.includes("*") || s.includes("?");
|
|
135
|
+
}
|
|
96
136
|
function splitPatterns(entries) {
|
|
97
137
|
const plain = [];
|
|
98
138
|
const patterns = [];
|
|
@@ -198,7 +238,7 @@ function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
|
198
238
|
}
|
|
199
239
|
}
|
|
200
240
|
const relPath = toPosixPath(relative(root, fullPath));
|
|
201
|
-
if (mode === "
|
|
241
|
+
if (mode === "pi" && dir === root && isFile && entry.name.endsWith(".md") && !ig.ignores(relPath)) {
|
|
202
242
|
entries.push(fullPath);
|
|
203
243
|
continue;
|
|
204
244
|
}
|
|
@@ -415,7 +455,7 @@ function collectAutoExtensionEntries(dir) {
|
|
|
415
455
|
*/
|
|
416
456
|
function collectResourceFiles(dir, resourceType) {
|
|
417
457
|
if (resourceType === "skills") {
|
|
418
|
-
return collectSkillEntries(dir, "
|
|
458
|
+
return collectSkillEntries(dir, "pi");
|
|
419
459
|
}
|
|
420
460
|
if (resourceType === "extensions") {
|
|
421
461
|
return collectAutoExtensionEntries(dir);
|
|
@@ -542,6 +582,20 @@ function applyPatterns(allPaths, patterns, baseDir) {
|
|
|
542
582
|
}
|
|
543
583
|
return new Set(result);
|
|
544
584
|
}
|
|
585
|
+
function applyAutoloadDisabledPatterns(allPaths, patterns, baseDir) {
|
|
586
|
+
const result = new Map();
|
|
587
|
+
for (const pattern of patterns) {
|
|
588
|
+
const target = pattern.slice(pattern.startsWith("+") || pattern.startsWith("-") || pattern.startsWith("!") ? 1 : 0);
|
|
589
|
+
const enabled = !pattern.startsWith("-") && !pattern.startsWith("!");
|
|
590
|
+
const exact = pattern.startsWith("+") || pattern.startsWith("-");
|
|
591
|
+
for (const filePath of allPaths) {
|
|
592
|
+
if (exact ? matchesAnyExactPattern(filePath, [target], baseDir) : matchesAnyPattern(filePath, [target], baseDir)) {
|
|
593
|
+
result.set(filePath, enabled);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return result;
|
|
598
|
+
}
|
|
545
599
|
export class DefaultPackageManager {
|
|
546
600
|
cwd;
|
|
547
601
|
agentDir;
|
|
@@ -550,8 +604,8 @@ export class DefaultPackageManager {
|
|
|
550
604
|
globalNpmRootCommandKey;
|
|
551
605
|
progressCallback;
|
|
552
606
|
constructor(options) {
|
|
553
|
-
this.cwd = options.cwd;
|
|
554
|
-
this.agentDir = options.agentDir;
|
|
607
|
+
this.cwd = resolvePath(options.cwd);
|
|
608
|
+
this.agentDir = resolvePath(options.agentDir);
|
|
555
609
|
this.settingsManager = options.settingsManager;
|
|
556
610
|
}
|
|
557
611
|
setProgressCallback(callback) {
|
|
@@ -562,9 +616,22 @@ export class DefaultPackageManager {
|
|
|
562
616
|
const currentSettings = scope === "project" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();
|
|
563
617
|
const currentPackages = currentSettings.packages ?? [];
|
|
564
618
|
const normalizedSource = this.normalizePackageSourceForSettings(source, scope);
|
|
565
|
-
const
|
|
566
|
-
if (
|
|
567
|
-
|
|
619
|
+
const matchIndex = currentPackages.findIndex((existing) => this.packageSourcesMatch(existing, source, scope));
|
|
620
|
+
if (matchIndex !== -1) {
|
|
621
|
+
const existing = currentPackages[matchIndex];
|
|
622
|
+
if (this.getPackageSourceString(existing) === normalizedSource) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
const nextPackages = [...currentPackages];
|
|
626
|
+
nextPackages[matchIndex] =
|
|
627
|
+
typeof existing === "string" ? normalizedSource : { ...existing, source: normalizedSource };
|
|
628
|
+
if (scope === "project") {
|
|
629
|
+
this.settingsManager.setProjectPackages(nextPackages);
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
this.settingsManager.setPackages(nextPackages);
|
|
633
|
+
}
|
|
634
|
+
return true;
|
|
568
635
|
}
|
|
569
636
|
const nextPackages = [...currentPackages, normalizedSource];
|
|
570
637
|
if (scope === "project") {
|
|
@@ -693,6 +760,7 @@ export class DefaultPackageManager {
|
|
|
693
760
|
async install(source, options) {
|
|
694
761
|
const parsed = this.parseSource(source);
|
|
695
762
|
const scope = options?.local ? "project" : "user";
|
|
763
|
+
this.assertProjectTrustedForScope(scope);
|
|
696
764
|
await this.withProgress("install", source, `Installing ${source}...`, async () => {
|
|
697
765
|
if (parsed.type === "npm") {
|
|
698
766
|
await this.installNpm(parsed, scope, false);
|
|
@@ -719,6 +787,7 @@ export class DefaultPackageManager {
|
|
|
719
787
|
async remove(source, options) {
|
|
720
788
|
const parsed = this.parseSource(source);
|
|
721
789
|
const scope = options?.local ? "project" : "user";
|
|
790
|
+
this.assertProjectTrustedForScope(scope);
|
|
722
791
|
await this.withProgress("remove", source, `Removing ${source}...`, async () => {
|
|
723
792
|
if (parsed.type === "npm") {
|
|
724
793
|
await this.uninstallNpm(parsed, scope);
|
|
@@ -743,19 +812,20 @@ export class DefaultPackageManager {
|
|
|
743
812
|
const projectSettings = this.settingsManager.getProjectSettings();
|
|
744
813
|
const identity = source ? this.getPackageIdentity(source) : undefined;
|
|
745
814
|
let matched = false;
|
|
815
|
+
const updateSources = [];
|
|
746
816
|
for (const pkg of globalSettings.packages ?? []) {
|
|
747
817
|
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
748
818
|
if (identity && this.getPackageIdentity(sourceStr, "user") !== identity)
|
|
749
819
|
continue;
|
|
750
820
|
matched = true;
|
|
751
|
-
|
|
821
|
+
updateSources.push({ source: sourceStr, scope: "user" });
|
|
752
822
|
}
|
|
753
823
|
for (const pkg of projectSettings.packages ?? []) {
|
|
754
824
|
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
755
825
|
if (identity && this.getPackageIdentity(sourceStr, "project") !== identity)
|
|
756
826
|
continue;
|
|
757
827
|
matched = true;
|
|
758
|
-
|
|
828
|
+
updateSources.push({ source: sourceStr, scope: "project" });
|
|
759
829
|
}
|
|
760
830
|
if (source && !matched) {
|
|
761
831
|
throw new Error(this.buildNoMatchingPackageMessage(source, [
|
|
@@ -763,31 +833,90 @@ export class DefaultPackageManager {
|
|
|
763
833
|
...(projectSettings.packages ?? []),
|
|
764
834
|
]));
|
|
765
835
|
}
|
|
836
|
+
await this.updateConfiguredSources(updateSources);
|
|
766
837
|
}
|
|
767
|
-
async
|
|
768
|
-
if (isOfflineModeEnabled()) {
|
|
838
|
+
async updateConfiguredSources(sources) {
|
|
839
|
+
if (isOfflineModeEnabled() || sources.length === 0) {
|
|
769
840
|
return;
|
|
770
841
|
}
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
842
|
+
const npmCandidates = [];
|
|
843
|
+
const gitCandidates = [];
|
|
844
|
+
for (const entry of sources) {
|
|
845
|
+
const parsed = this.parseSource(entry.source);
|
|
846
|
+
// Pinned npm versions are fixed. Pinned git refs are configured checkout targets,
|
|
847
|
+
// so include them to reconcile an existing clone when the configured ref changes.
|
|
848
|
+
if (parsed.type === "npm") {
|
|
849
|
+
if (!parsed.pinned) {
|
|
850
|
+
npmCandidates.push({ ...entry, parsed });
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
else if (parsed.type === "git") {
|
|
854
|
+
gitCandidates.push({ ...entry, parsed });
|
|
855
|
+
}
|
|
782
856
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
857
|
+
const npmCheckTasks = npmCandidates.map((entry) => async () => ({
|
|
858
|
+
entry,
|
|
859
|
+
shouldUpdate: await this.shouldUpdateNpmSource(entry.parsed, entry.scope),
|
|
860
|
+
}));
|
|
861
|
+
const npmCheckResults = await this.runWithConcurrency(npmCheckTasks, UPDATE_CHECK_CONCURRENCY);
|
|
862
|
+
const userNpmUpdates = [];
|
|
863
|
+
const projectNpmUpdates = [];
|
|
864
|
+
for (const result of npmCheckResults) {
|
|
865
|
+
if (!result.shouldUpdate) {
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
if (result.entry.scope === "user") {
|
|
869
|
+
userNpmUpdates.push(result.entry);
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
projectNpmUpdates.push(result.entry);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
const tasks = [];
|
|
876
|
+
if (userNpmUpdates.length > 0) {
|
|
877
|
+
tasks.push(this.updateNpmBatch(userNpmUpdates, "user"));
|
|
878
|
+
}
|
|
879
|
+
if (projectNpmUpdates.length > 0) {
|
|
880
|
+
tasks.push(this.updateNpmBatch(projectNpmUpdates, "project"));
|
|
881
|
+
}
|
|
882
|
+
if (gitCandidates.length > 0) {
|
|
883
|
+
const gitTasks = gitCandidates.map((entry) => async () => this.withProgress("update", entry.source, `Updating ${entry.source}...`, async () => {
|
|
884
|
+
await this.updateGit(entry.parsed, entry.scope);
|
|
885
|
+
}));
|
|
886
|
+
tasks.push(this.runWithConcurrency(gitTasks, GIT_UPDATE_CONCURRENCY).then(() => { }));
|
|
887
|
+
}
|
|
888
|
+
await Promise.all(tasks);
|
|
889
|
+
}
|
|
890
|
+
async shouldUpdateNpmSource(source, scope) {
|
|
891
|
+
const installedPath = this.getManagedNpmInstallPath(source, scope);
|
|
892
|
+
const installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;
|
|
893
|
+
if (!installedVersion) {
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
try {
|
|
897
|
+
const targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);
|
|
898
|
+
return targetVersion !== installedVersion;
|
|
899
|
+
}
|
|
900
|
+
catch {
|
|
901
|
+
// Preserve existing update behavior when version lookup fails.
|
|
902
|
+
return true;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
async updateNpmBatch(sources, scope) {
|
|
906
|
+
if (sources.length === 0) {
|
|
789
907
|
return;
|
|
790
908
|
}
|
|
909
|
+
const sourceLabel = sources.length === 1 ? sources[0].source : `${scope} npm packages`;
|
|
910
|
+
const message = sources.length === 1 ? `Updating ${sources[0].source}...` : `Updating ${scope} npm packages...`;
|
|
911
|
+
const specs = sources.map((entry) => (entry.parsed.version ? entry.parsed.spec : `${entry.parsed.name}@latest`));
|
|
912
|
+
await this.withProgress("update", sourceLabel, message, async () => {
|
|
913
|
+
await this.installNpmBatch(specs, scope);
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
async installNpmBatch(specs, scope) {
|
|
917
|
+
const installRoot = this.getNpmInstallRoot(scope, false);
|
|
918
|
+
this.ensureNpmProject(installRoot);
|
|
919
|
+
await this.runNpmCommand(this.getNpmInstallArgs(specs, installRoot));
|
|
791
920
|
}
|
|
792
921
|
async checkForAvailableUpdates() {
|
|
793
922
|
if (isOfflineModeEnabled()) {
|
|
@@ -849,57 +978,67 @@ export class DefaultPackageManager {
|
|
|
849
978
|
for (const { pkg, scope } of sources) {
|
|
850
979
|
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
851
980
|
const filter = typeof pkg === "object" ? pkg : undefined;
|
|
852
|
-
const
|
|
981
|
+
const deltaBase = this.findAutoloadDeltaBase(pkg, scope, sources);
|
|
982
|
+
const resolvedSource = deltaBase?.source ?? sourceStr;
|
|
983
|
+
const resolvedScope = deltaBase?.scope ?? scope;
|
|
984
|
+
const parsed = this.parseSource(resolvedSource);
|
|
853
985
|
const metadata = { source: sourceStr, scope, origin: "package" };
|
|
854
986
|
if (parsed.type === "local") {
|
|
855
|
-
const baseDir = this.getBaseDirForScope(
|
|
987
|
+
const baseDir = this.getBaseDirForScope(resolvedScope);
|
|
856
988
|
this.resolveLocalExtensionSource(parsed, accumulator, filter, metadata, baseDir);
|
|
857
989
|
continue;
|
|
858
990
|
}
|
|
859
991
|
const installMissing = async () => {
|
|
860
|
-
if (isOfflineModeEnabled())
|
|
992
|
+
if (isOfflineModeEnabled())
|
|
861
993
|
return false;
|
|
862
|
-
}
|
|
863
994
|
if (!onMissing) {
|
|
864
|
-
await this.installParsedSource(parsed,
|
|
995
|
+
await this.installParsedSource(parsed, resolvedScope);
|
|
865
996
|
return true;
|
|
866
997
|
}
|
|
867
|
-
const action = await onMissing(
|
|
998
|
+
const action = await onMissing(resolvedSource);
|
|
868
999
|
if (action === "skip")
|
|
869
1000
|
return false;
|
|
870
1001
|
if (action === "error")
|
|
871
|
-
throw new Error(`Missing source: ${
|
|
872
|
-
await this.installParsedSource(parsed,
|
|
1002
|
+
throw new Error(`Missing source: ${resolvedSource}`);
|
|
1003
|
+
await this.installParsedSource(parsed, resolvedScope);
|
|
873
1004
|
return true;
|
|
874
1005
|
};
|
|
875
1006
|
if (parsed.type === "npm") {
|
|
876
|
-
|
|
877
|
-
const needsInstall = !existsSync(installedPath) ||
|
|
878
|
-
(parsed.pinned && !(await this.installedNpmMatchesPinnedVersion(parsed, installedPath)));
|
|
1007
|
+
let installedPath = this.getNpmInstallPath(parsed, resolvedScope);
|
|
1008
|
+
const needsInstall = !existsSync(installedPath) || !(await this.installedNpmMatchesConfiguredVersion(parsed, installedPath));
|
|
879
1009
|
if (needsInstall) {
|
|
880
1010
|
const installed = await installMissing();
|
|
881
1011
|
if (!installed)
|
|
882
1012
|
continue;
|
|
1013
|
+
installedPath = this.getNpmInstallPath(parsed, resolvedScope);
|
|
883
1014
|
}
|
|
884
1015
|
metadata.baseDir = installedPath;
|
|
885
1016
|
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
|
886
1017
|
continue;
|
|
887
1018
|
}
|
|
888
1019
|
if (parsed.type === "git") {
|
|
889
|
-
const installedPath = this.getGitInstallPath(parsed,
|
|
1020
|
+
const installedPath = this.getGitInstallPath(parsed, resolvedScope);
|
|
890
1021
|
if (!existsSync(installedPath)) {
|
|
891
1022
|
const installed = await installMissing();
|
|
892
1023
|
if (!installed)
|
|
893
1024
|
continue;
|
|
894
1025
|
}
|
|
895
|
-
else if (
|
|
896
|
-
await this.refreshTemporaryGitSource(parsed,
|
|
1026
|
+
else if (resolvedScope === "temporary" && !parsed.pinned && !isOfflineModeEnabled()) {
|
|
1027
|
+
await this.refreshTemporaryGitSource(parsed, resolvedSource);
|
|
897
1028
|
}
|
|
898
1029
|
metadata.baseDir = installedPath;
|
|
899
1030
|
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
|
900
1031
|
}
|
|
901
1032
|
}
|
|
902
1033
|
}
|
|
1034
|
+
findAutoloadDeltaBase(pkg, scope, sources) {
|
|
1035
|
+
if (scope !== "project" || typeof pkg !== "object" || pkg.autoload !== false)
|
|
1036
|
+
return undefined;
|
|
1037
|
+
const identity = this.getPackageIdentity(pkg.source, scope);
|
|
1038
|
+
const userEntry = sources.find((entry) => entry.scope === "user" &&
|
|
1039
|
+
this.getPackageIdentity(this.getPackageSourceString(entry.pkg), "user") === identity);
|
|
1040
|
+
return userEntry ? { source: this.getPackageSourceString(userEntry.pkg), scope: "user" } : undefined;
|
|
1041
|
+
}
|
|
903
1042
|
resolveLocalExtensionSource(source, accumulator, filter, metadata, baseDir) {
|
|
904
1043
|
const resolved = this.resolvePathFromBase(source.path, baseDir);
|
|
905
1044
|
if (!existsSync(resolved)) {
|
|
@@ -1010,7 +1149,9 @@ export class DefaultPackageManager {
|
|
|
1010
1149
|
type: "npm",
|
|
1011
1150
|
spec,
|
|
1012
1151
|
name,
|
|
1013
|
-
|
|
1152
|
+
version,
|
|
1153
|
+
range: getNpmVersionRange(version),
|
|
1154
|
+
pinned: isExactNpmVersion(version),
|
|
1014
1155
|
};
|
|
1015
1156
|
}
|
|
1016
1157
|
if (isLocalPath(source)) {
|
|
@@ -1023,16 +1164,12 @@ export class DefaultPackageManager {
|
|
|
1023
1164
|
}
|
|
1024
1165
|
return { type: "local", path: source };
|
|
1025
1166
|
}
|
|
1026
|
-
async
|
|
1167
|
+
async installedNpmMatchesConfiguredVersion(source, installedPath) {
|
|
1027
1168
|
const installedVersion = this.getInstalledNpmVersion(installedPath);
|
|
1028
1169
|
if (!installedVersion) {
|
|
1029
1170
|
return false;
|
|
1030
1171
|
}
|
|
1031
|
-
|
|
1032
|
-
if (!pinnedVersion) {
|
|
1033
|
-
return true;
|
|
1034
|
-
}
|
|
1035
|
-
return installedVersion === pinnedVersion;
|
|
1172
|
+
return source.range ? satisfies(installedVersion, source.range) : true;
|
|
1036
1173
|
}
|
|
1037
1174
|
async npmHasAvailableUpdate(source, installedPath) {
|
|
1038
1175
|
if (isOfflineModeEnabled()) {
|
|
@@ -1043,8 +1180,8 @@ export class DefaultPackageManager {
|
|
|
1043
1180
|
return false;
|
|
1044
1181
|
}
|
|
1045
1182
|
try {
|
|
1046
|
-
const
|
|
1047
|
-
return
|
|
1183
|
+
const targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);
|
|
1184
|
+
return targetVersion !== installedVersion;
|
|
1048
1185
|
}
|
|
1049
1186
|
catch {
|
|
1050
1187
|
return false;
|
|
@@ -1063,14 +1200,23 @@ export class DefaultPackageManager {
|
|
|
1063
1200
|
return undefined;
|
|
1064
1201
|
}
|
|
1065
1202
|
}
|
|
1066
|
-
async getLatestNpmVersion(
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
if (!
|
|
1071
|
-
throw new Error(
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1203
|
+
async getLatestNpmVersion(packageSpec, range) {
|
|
1204
|
+
const npmCommand = this.getNpmCommand();
|
|
1205
|
+
const stdout = await this.runCommandCapture(npmCommand.command, [...npmCommand.args, "view", packageSpec, "version", "--json"], { cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS });
|
|
1206
|
+
const raw = stdout.trim();
|
|
1207
|
+
if (!raw)
|
|
1208
|
+
throw new Error("Empty response from npm view");
|
|
1209
|
+
const parsed = JSON.parse(raw);
|
|
1210
|
+
if (typeof parsed === "string") {
|
|
1211
|
+
return parsed;
|
|
1212
|
+
}
|
|
1213
|
+
if (Array.isArray(parsed)) {
|
|
1214
|
+
const versions = parsed.filter((value) => typeof value === "string" && value.length > 0);
|
|
1215
|
+
const latest = range ? maxSatisfying(versions, range) : [...versions].sort(rcompare)[0];
|
|
1216
|
+
if (latest)
|
|
1217
|
+
return latest;
|
|
1218
|
+
}
|
|
1219
|
+
throw new Error("Unexpected response from npm view");
|
|
1074
1220
|
}
|
|
1075
1221
|
async gitHasAvailableUpdate(installedPath) {
|
|
1076
1222
|
if (isOfflineModeEnabled()) {
|
|
@@ -1234,25 +1380,30 @@ export class DefaultPackageManager {
|
|
|
1234
1380
|
}
|
|
1235
1381
|
/**
|
|
1236
1382
|
* Dedupe packages: if same package identity appears in both global and project,
|
|
1237
|
-
* keep only the project one (project wins).
|
|
1383
|
+
* keep only the project one (project wins). A project entry with autoload=false
|
|
1384
|
+
* is a delta over the global entry, so both are kept (delta first).
|
|
1238
1385
|
*/
|
|
1239
1386
|
dedupePackages(packages) {
|
|
1387
|
+
const result = [];
|
|
1240
1388
|
const seen = new Map();
|
|
1241
1389
|
for (const entry of packages) {
|
|
1242
|
-
const
|
|
1243
|
-
const
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1390
|
+
const identity = this.getPackageIdentity(this.getPackageSourceString(entry.pkg), entry.scope);
|
|
1391
|
+
const index = seen.get(identity);
|
|
1392
|
+
if (index === undefined) {
|
|
1393
|
+
seen.set(identity, result.length);
|
|
1394
|
+
result.push(entry);
|
|
1395
|
+
continue;
|
|
1247
1396
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1397
|
+
const existing = result[index];
|
|
1398
|
+
if (existing?.scope === "project" && entry.scope === "user") {
|
|
1399
|
+
if (typeof existing.pkg === "object" && existing.pkg.autoload === false)
|
|
1400
|
+
result.push(entry);
|
|
1401
|
+
}
|
|
1402
|
+
else if (entry.scope === "project") {
|
|
1403
|
+
result[index] = entry;
|
|
1251
1404
|
}
|
|
1252
|
-
// If existing is project and new is global, keep existing (project)
|
|
1253
|
-
// If both are same scope, keep first one
|
|
1254
1405
|
}
|
|
1255
|
-
return
|
|
1406
|
+
return result;
|
|
1256
1407
|
}
|
|
1257
1408
|
parseNpmSpec(spec) {
|
|
1258
1409
|
const match = spec.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);
|
|
@@ -1263,6 +1414,11 @@ export class DefaultPackageManager {
|
|
|
1263
1414
|
const version = match[2];
|
|
1264
1415
|
return { name, version };
|
|
1265
1416
|
}
|
|
1417
|
+
assertProjectTrustedForScope(scope) {
|
|
1418
|
+
if (scope === "project" && !this.settingsManager.isProjectTrusted()) {
|
|
1419
|
+
throw new Error("Project is not trusted; refusing to access project package storage");
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1266
1422
|
getNpmCommand() {
|
|
1267
1423
|
const configuredCommand = this.settingsManager.getNpmCommand();
|
|
1268
1424
|
if (!configuredCommand || configuredCommand.length === 0) {
|
|
@@ -1274,37 +1430,75 @@ export class DefaultPackageManager {
|
|
|
1274
1430
|
}
|
|
1275
1431
|
return { command, args };
|
|
1276
1432
|
}
|
|
1433
|
+
getPackageManagerName() {
|
|
1434
|
+
const npmCommand = this.getNpmCommand();
|
|
1435
|
+
const commandParts = [npmCommand.command, ...npmCommand.args];
|
|
1436
|
+
const separatorIndex = commandParts.lastIndexOf("--");
|
|
1437
|
+
const packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;
|
|
1438
|
+
return packageManagerCommand ? basename(packageManagerCommand).replace(/\.(cmd|exe)$/i, "") : "";
|
|
1439
|
+
}
|
|
1277
1440
|
async runNpmCommand(args, options) {
|
|
1278
1441
|
const npmCommand = this.getNpmCommand();
|
|
1279
1442
|
await this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);
|
|
1280
1443
|
}
|
|
1444
|
+
getGitDependencyInstallArgs() {
|
|
1445
|
+
const configuredCommand = this.settingsManager.getNpmCommand();
|
|
1446
|
+
if (configuredCommand && configuredCommand.length > 0) {
|
|
1447
|
+
return ["install"];
|
|
1448
|
+
}
|
|
1449
|
+
return ["install", "--omit=dev"];
|
|
1450
|
+
}
|
|
1281
1451
|
runNpmCommandSync(args) {
|
|
1282
1452
|
const npmCommand = this.getNpmCommand();
|
|
1283
1453
|
return this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);
|
|
1284
1454
|
}
|
|
1455
|
+
getNpmInstallArgs(specs, installRoot) {
|
|
1456
|
+
const packageManagerName = this.getPackageManagerName();
|
|
1457
|
+
// Extension packages run inside pi and resolve pi APIs through loader aliases/virtual modules.
|
|
1458
|
+
// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and
|
|
1459
|
+
// equivalent bun/pnpm settings) so package managers do not install or solve host-provided
|
|
1460
|
+
// @draht/* peers. Stale auto-installed pi peers can otherwise block updates.
|
|
1461
|
+
if (packageManagerName === "bun") {
|
|
1462
|
+
return ["install", ...specs, "--cwd", installRoot, "--omit=peer"];
|
|
1463
|
+
}
|
|
1464
|
+
if (packageManagerName === "pnpm") {
|
|
1465
|
+
return [
|
|
1466
|
+
"install",
|
|
1467
|
+
...specs,
|
|
1468
|
+
"--prefix",
|
|
1469
|
+
installRoot,
|
|
1470
|
+
"--config.auto-install-peers=false",
|
|
1471
|
+
"--config.strict-peer-dependencies=false",
|
|
1472
|
+
"--config.strict-dep-builds=false",
|
|
1473
|
+
];
|
|
1474
|
+
}
|
|
1475
|
+
return ["install", ...specs, "--prefix", installRoot, "--legacy-peer-deps"];
|
|
1476
|
+
}
|
|
1285
1477
|
async installNpm(source, scope, temporary) {
|
|
1286
|
-
if (scope === "user" && !temporary) {
|
|
1287
|
-
await this.runNpmCommand(["install", "-g", source.spec]);
|
|
1288
|
-
return;
|
|
1289
|
-
}
|
|
1290
1478
|
const installRoot = this.getNpmInstallRoot(scope, temporary);
|
|
1291
1479
|
this.ensureNpmProject(installRoot);
|
|
1292
|
-
await this.runNpmCommand([
|
|
1480
|
+
await this.runNpmCommand(this.getNpmInstallArgs([source.spec], installRoot));
|
|
1293
1481
|
}
|
|
1294
1482
|
async uninstallNpm(source, scope) {
|
|
1295
|
-
if (scope === "user") {
|
|
1296
|
-
await this.runNpmCommand(["uninstall", "-g", source.name]);
|
|
1297
|
-
return;
|
|
1298
|
-
}
|
|
1299
1483
|
const installRoot = this.getNpmInstallRoot(scope, false);
|
|
1300
1484
|
if (!existsSync(installRoot)) {
|
|
1301
1485
|
return;
|
|
1302
1486
|
}
|
|
1487
|
+
if (this.getPackageManagerName() === "bun") {
|
|
1488
|
+
await this.runNpmCommand(["uninstall", source.name, "--cwd", installRoot]);
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1303
1491
|
await this.runNpmCommand(["uninstall", source.name, "--prefix", installRoot]);
|
|
1304
1492
|
}
|
|
1305
1493
|
async installGit(source, scope) {
|
|
1306
1494
|
const targetDir = this.getGitInstallPath(source, scope);
|
|
1307
1495
|
if (existsSync(targetDir)) {
|
|
1496
|
+
if (source.ref) {
|
|
1497
|
+
await this.ensureGitRef(targetDir, ["fetch", "origin", source.ref], "FETCH_HEAD");
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
const target = await this.getLocalGitUpdateTarget(targetDir);
|
|
1501
|
+
await this.ensureGitRef(targetDir, target.fetchArgs, target.ref);
|
|
1308
1502
|
return;
|
|
1309
1503
|
}
|
|
1310
1504
|
const gitRoot = this.getGitInstallRoot(scope);
|
|
@@ -1318,7 +1512,7 @@ export class DefaultPackageManager {
|
|
|
1318
1512
|
}
|
|
1319
1513
|
const packageJsonPath = join(targetDir, "package.json");
|
|
1320
1514
|
if (existsSync(packageJsonPath)) {
|
|
1321
|
-
await this.runNpmCommand(
|
|
1515
|
+
await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
|
|
1322
1516
|
}
|
|
1323
1517
|
}
|
|
1324
1518
|
async updateGit(source, scope) {
|
|
@@ -1327,26 +1521,34 @@ export class DefaultPackageManager {
|
|
|
1327
1521
|
await this.installGit(source, scope);
|
|
1328
1522
|
return;
|
|
1329
1523
|
}
|
|
1524
|
+
if (source.ref) {
|
|
1525
|
+
await this.ensureGitRef(targetDir, ["fetch", "origin", source.ref], "FETCH_HEAD");
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1330
1528
|
const target = await this.getLocalGitUpdateTarget(targetDir);
|
|
1529
|
+
await this.ensureGitRef(targetDir, target.fetchArgs, target.ref);
|
|
1530
|
+
}
|
|
1531
|
+
async ensureGitRef(targetDir, fetchArgs, ref) {
|
|
1331
1532
|
// Fetch only the ref we will reset to, avoiding unrelated branch/tag noise.
|
|
1332
|
-
await this.runCommand("git",
|
|
1533
|
+
await this.runCommand("git", fetchArgs, { cwd: targetDir });
|
|
1333
1534
|
const localHead = await this.runCommandCapture("git", ["rev-parse", "HEAD"], {
|
|
1334
1535
|
cwd: targetDir,
|
|
1335
1536
|
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1336
1537
|
});
|
|
1337
|
-
const
|
|
1538
|
+
const commitRef = `${ref}^{commit}`;
|
|
1539
|
+
const targetHead = await this.runCommandCapture("git", ["rev-parse", commitRef], {
|
|
1338
1540
|
cwd: targetDir,
|
|
1339
1541
|
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1340
1542
|
});
|
|
1341
|
-
if (localHead.trim() ===
|
|
1543
|
+
if (localHead.trim() === targetHead.trim()) {
|
|
1342
1544
|
return;
|
|
1343
1545
|
}
|
|
1344
|
-
await this.runCommand("git", ["reset", "--hard",
|
|
1546
|
+
await this.runCommand("git", ["reset", "--hard", commitRef], { cwd: targetDir });
|
|
1345
1547
|
// Clean untracked files (extensions should be pristine)
|
|
1346
1548
|
await this.runCommand("git", ["clean", "-fdx"], { cwd: targetDir });
|
|
1347
1549
|
const packageJsonPath = join(targetDir, "package.json");
|
|
1348
1550
|
if (existsSync(packageJsonPath)) {
|
|
1349
|
-
await this.runNpmCommand(
|
|
1551
|
+
await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
|
|
1350
1552
|
}
|
|
1351
1553
|
}
|
|
1352
1554
|
async refreshTemporaryGitSource(source, sourceStr) {
|
|
@@ -1396,6 +1598,7 @@ export class DefaultPackageManager {
|
|
|
1396
1598
|
if (!existsSync(installRoot)) {
|
|
1397
1599
|
mkdirSync(installRoot, { recursive: true });
|
|
1398
1600
|
}
|
|
1601
|
+
markPathIgnoredByCloudSync(installRoot);
|
|
1399
1602
|
this.ensureGitIgnore(installRoot);
|
|
1400
1603
|
const packageJsonPath = join(installRoot, "package.json");
|
|
1401
1604
|
if (!existsSync(packageJsonPath)) {
|
|
@@ -1417,9 +1620,10 @@ export class DefaultPackageManager {
|
|
|
1417
1620
|
return this.getTemporaryDir("npm");
|
|
1418
1621
|
}
|
|
1419
1622
|
if (scope === "project") {
|
|
1623
|
+
this.assertProjectTrustedForScope(scope);
|
|
1420
1624
|
return join(this.cwd, CONFIG_DIR_NAME, "npm");
|
|
1421
1625
|
}
|
|
1422
|
-
return join(this.
|
|
1626
|
+
return join(this.agentDir, "npm");
|
|
1423
1627
|
}
|
|
1424
1628
|
getGlobalNpmRoot() {
|
|
1425
1629
|
const npmCommand = this.getNpmCommand();
|
|
@@ -1427,47 +1631,94 @@ export class DefaultPackageManager {
|
|
|
1427
1631
|
if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
|
|
1428
1632
|
return this.globalNpmRoot;
|
|
1429
1633
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1634
|
+
if (this.getPackageManagerName() === "bun") {
|
|
1635
|
+
const binDir = this.runNpmCommandSync(["pm", "bin", "-g"]).trim();
|
|
1636
|
+
this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
|
|
1637
|
+
}
|
|
1638
|
+
else {
|
|
1639
|
+
this.globalNpmRoot = this.runNpmCommandSync(["root", "-g"]).trim();
|
|
1640
|
+
}
|
|
1432
1641
|
this.globalNpmRootCommandKey = commandKey;
|
|
1433
1642
|
return this.globalNpmRoot;
|
|
1434
1643
|
}
|
|
1435
|
-
|
|
1644
|
+
getPnpmGlobalPackagePath(packageName) {
|
|
1645
|
+
if (this.getPackageManagerName() !== "pnpm") {
|
|
1646
|
+
return undefined;
|
|
1647
|
+
}
|
|
1648
|
+
const output = this.runNpmCommandSync(["list", "-g", "--depth", "0", "--json"]);
|
|
1649
|
+
const entries = JSON.parse(output);
|
|
1650
|
+
for (const entry of entries) {
|
|
1651
|
+
const path = entry.dependencies?.[packageName]?.path;
|
|
1652
|
+
if (path)
|
|
1653
|
+
return path;
|
|
1654
|
+
}
|
|
1655
|
+
return undefined;
|
|
1656
|
+
}
|
|
1657
|
+
getManagedNpmInstallPath(source, scope) {
|
|
1436
1658
|
if (scope === "temporary") {
|
|
1437
1659
|
return join(this.getTemporaryDir("npm"), "node_modules", source.name);
|
|
1438
1660
|
}
|
|
1439
1661
|
if (scope === "project") {
|
|
1662
|
+
this.assertProjectTrustedForScope(scope);
|
|
1440
1663
|
return join(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
|
|
1441
1664
|
}
|
|
1442
|
-
return join(this.
|
|
1665
|
+
return join(this.agentDir, "npm", "node_modules", source.name);
|
|
1666
|
+
}
|
|
1667
|
+
getLegacyGlobalNpmInstallPath(source) {
|
|
1668
|
+
try {
|
|
1669
|
+
return this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);
|
|
1670
|
+
}
|
|
1671
|
+
catch {
|
|
1672
|
+
return undefined;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
getNpmInstallPath(source, scope) {
|
|
1676
|
+
const managedPath = this.getManagedNpmInstallPath(source, scope);
|
|
1677
|
+
if (scope !== "user" || existsSync(managedPath)) {
|
|
1678
|
+
return managedPath;
|
|
1679
|
+
}
|
|
1680
|
+
const legacyPath = this.getLegacyGlobalNpmInstallPath(source);
|
|
1681
|
+
return legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;
|
|
1443
1682
|
}
|
|
1444
1683
|
getGitInstallPath(source, scope) {
|
|
1445
1684
|
if (scope === "temporary") {
|
|
1446
1685
|
return this.getTemporaryDir(`git-${source.host}`, source.path);
|
|
1447
1686
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1687
|
+
const installRoot = this.getGitInstallRoot(scope);
|
|
1688
|
+
if (!installRoot) {
|
|
1689
|
+
throw new Error("Missing git install root");
|
|
1450
1690
|
}
|
|
1451
|
-
return
|
|
1691
|
+
return this.resolveManagedPath(installRoot, source.host, source.path);
|
|
1452
1692
|
}
|
|
1453
1693
|
getGitInstallRoot(scope) {
|
|
1454
1694
|
if (scope === "temporary") {
|
|
1455
1695
|
return undefined;
|
|
1456
1696
|
}
|
|
1457
1697
|
if (scope === "project") {
|
|
1698
|
+
this.assertProjectTrustedForScope(scope);
|
|
1458
1699
|
return join(this.cwd, CONFIG_DIR_NAME, "git");
|
|
1459
1700
|
}
|
|
1460
1701
|
return join(this.agentDir, "git");
|
|
1461
1702
|
}
|
|
1462
1703
|
getTemporaryDir(prefix, suffix) {
|
|
1704
|
+
const root = this.resolveManagedPath(getExtensionTempFolder(this.agentDir), prefix);
|
|
1463
1705
|
const hash = createHash("sha256")
|
|
1464
1706
|
.update(`${prefix}-${suffix ?? ""}`)
|
|
1465
1707
|
.digest("hex")
|
|
1466
1708
|
.slice(0, 8);
|
|
1467
|
-
return
|
|
1709
|
+
return this.resolveManagedPath(root, hash, suffix ?? "");
|
|
1710
|
+
}
|
|
1711
|
+
resolveManagedPath(root, ...parts) {
|
|
1712
|
+
const resolvedRoot = resolve(root);
|
|
1713
|
+
const resolvedPath = resolve(resolvedRoot, ...parts);
|
|
1714
|
+
if (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`)) {
|
|
1715
|
+
throw new Error(`Refusing to use path outside package install root: ${resolvedPath}`);
|
|
1716
|
+
}
|
|
1717
|
+
return resolvedPath;
|
|
1468
1718
|
}
|
|
1469
1719
|
getBaseDirForScope(scope) {
|
|
1470
1720
|
if (scope === "project") {
|
|
1721
|
+
this.assertProjectTrustedForScope(scope);
|
|
1471
1722
|
return join(this.cwd, CONFIG_DIR_NAME);
|
|
1472
1723
|
}
|
|
1473
1724
|
if (scope === "user") {
|
|
@@ -1476,31 +1727,20 @@ export class DefaultPackageManager {
|
|
|
1476
1727
|
return this.cwd;
|
|
1477
1728
|
}
|
|
1478
1729
|
resolvePath(input) {
|
|
1479
|
-
|
|
1480
|
-
if (trimmed === "~")
|
|
1481
|
-
return getHomeDir();
|
|
1482
|
-
if (trimmed.startsWith("~/"))
|
|
1483
|
-
return join(getHomeDir(), trimmed.slice(2));
|
|
1484
|
-
if (trimmed.startsWith("~"))
|
|
1485
|
-
return join(getHomeDir(), trimmed.slice(1));
|
|
1486
|
-
return resolve(this.cwd, trimmed);
|
|
1730
|
+
return resolvePath(input, this.cwd, { homeDir: getHomeDir(), trim: true });
|
|
1487
1731
|
}
|
|
1488
1732
|
resolvePathFromBase(input, baseDir) {
|
|
1489
|
-
|
|
1490
|
-
if (trimmed === "~")
|
|
1491
|
-
return getHomeDir();
|
|
1492
|
-
if (trimmed.startsWith("~/"))
|
|
1493
|
-
return join(getHomeDir(), trimmed.slice(2));
|
|
1494
|
-
if (trimmed.startsWith("~"))
|
|
1495
|
-
return join(getHomeDir(), trimmed.slice(1));
|
|
1496
|
-
return resolve(baseDir, trimmed);
|
|
1733
|
+
return resolvePath(input, baseDir, { homeDir: getHomeDir(), trim: true });
|
|
1497
1734
|
}
|
|
1498
1735
|
collectPackageResources(packageRoot, accumulator, filter, metadata) {
|
|
1499
1736
|
if (filter) {
|
|
1500
1737
|
for (const resourceType of RESOURCE_TYPES) {
|
|
1501
1738
|
const patterns = filter[resourceType];
|
|
1502
1739
|
const target = this.getTargetMap(accumulator, resourceType);
|
|
1503
|
-
if (
|
|
1740
|
+
if (filter.autoload === false) {
|
|
1741
|
+
this.applyPackageDeltaFilter(packageRoot, patterns ?? [], resourceType, target, metadata);
|
|
1742
|
+
}
|
|
1743
|
+
else if (patterns !== undefined) {
|
|
1504
1744
|
this.applyPackageFilter(packageRoot, patterns, resourceType, target, metadata);
|
|
1505
1745
|
}
|
|
1506
1746
|
else {
|
|
@@ -1563,6 +1803,16 @@ export class DefaultPackageManager {
|
|
|
1563
1803
|
this.addResource(target, f, metadata, enabled);
|
|
1564
1804
|
}
|
|
1565
1805
|
}
|
|
1806
|
+
applyPackageDeltaFilter(packageRoot, userPatterns, resourceType, target, metadata) {
|
|
1807
|
+
if (userPatterns.length === 0) {
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
const { allFiles } = this.collectManifestFiles(packageRoot, resourceType);
|
|
1811
|
+
const enabledByUser = applyAutoloadDisabledPatterns(allFiles, userPatterns, packageRoot);
|
|
1812
|
+
for (const [filePath, enabled] of enabledByUser) {
|
|
1813
|
+
this.addResource(target, filePath, metadata, enabled);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1566
1816
|
/**
|
|
1567
1817
|
* Collect all files from a package for a resource type, applying manifest patterns.
|
|
1568
1818
|
* Returns { allFiles, enabledByManifest } where enabledByManifest is the set of files
|
|
@@ -1573,7 +1823,7 @@ export class DefaultPackageManager {
|
|
|
1573
1823
|
const entries = manifest?.[resourceType];
|
|
1574
1824
|
if (entries && entries.length > 0) {
|
|
1575
1825
|
const allFiles = this.collectFilesFromManifestEntries(entries, packageRoot, resourceType);
|
|
1576
|
-
const manifestPatterns = entries.filter(
|
|
1826
|
+
const manifestPatterns = entries.filter(isOverridePattern);
|
|
1577
1827
|
const enabledByManifest = manifestPatterns.length > 0 ? applyPatterns(allFiles, manifestPatterns, packageRoot) : new Set(allFiles);
|
|
1578
1828
|
return { allFiles: Array.from(enabledByManifest), enabledByManifest };
|
|
1579
1829
|
}
|
|
@@ -1602,7 +1852,7 @@ export class DefaultPackageManager {
|
|
|
1602
1852
|
if (!entries)
|
|
1603
1853
|
return;
|
|
1604
1854
|
const allFiles = this.collectFilesFromManifestEntries(entries, root, resourceType);
|
|
1605
|
-
const patterns = entries.filter(
|
|
1855
|
+
const patterns = entries.filter(isOverridePattern);
|
|
1606
1856
|
const enabledPaths = applyPatterns(allFiles, patterns, root);
|
|
1607
1857
|
for (const f of allFiles) {
|
|
1608
1858
|
if (enabledPaths.has(f)) {
|
|
@@ -1611,8 +1861,18 @@ export class DefaultPackageManager {
|
|
|
1611
1861
|
}
|
|
1612
1862
|
}
|
|
1613
1863
|
collectFilesFromManifestEntries(entries, root, resourceType) {
|
|
1614
|
-
const
|
|
1615
|
-
const resolved =
|
|
1864
|
+
const sourceEntries = entries.filter((entry) => !isOverridePattern(entry));
|
|
1865
|
+
const resolved = sourceEntries.flatMap((entry) => {
|
|
1866
|
+
if (!hasGlobPattern(entry)) {
|
|
1867
|
+
return [resolve(root, entry)];
|
|
1868
|
+
}
|
|
1869
|
+
return globSync(entry, {
|
|
1870
|
+
cwd: root,
|
|
1871
|
+
absolute: true,
|
|
1872
|
+
dot: false,
|
|
1873
|
+
nodir: false,
|
|
1874
|
+
}).map((match) => resolve(match));
|
|
1875
|
+
});
|
|
1616
1876
|
return this.collectFilesFromPaths(resolved, resourceType);
|
|
1617
1877
|
}
|
|
1618
1878
|
resolveLocalEntries(entries, resourceType, target, metadata, baseDir) {
|
|
@@ -1667,7 +1927,10 @@ export class DefaultPackageManager {
|
|
|
1667
1927
|
themes: join(projectBaseDir, "themes"),
|
|
1668
1928
|
};
|
|
1669
1929
|
const userAgentsSkillsDir = join(getHomeDir(), ".agents", "skills");
|
|
1670
|
-
const
|
|
1930
|
+
const projectTrusted = this.settingsManager.isProjectTrusted();
|
|
1931
|
+
const projectAgentsSkillDirs = projectTrusted
|
|
1932
|
+
? collectAncestorAgentsSkillDirs(this.cwd).filter((dir) => resolve(dir) !== resolve(userAgentsSkillsDir))
|
|
1933
|
+
: [];
|
|
1671
1934
|
const addResources = (resourceType, paths, metadata, overrides, baseDir) => {
|
|
1672
1935
|
const target = this.getTargetMap(accumulator, resourceType);
|
|
1673
1936
|
for (const path of paths) {
|
|
@@ -1675,18 +1938,36 @@ export class DefaultPackageManager {
|
|
|
1675
1938
|
this.addResource(target, path, metadata, enabled);
|
|
1676
1939
|
}
|
|
1677
1940
|
};
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1941
|
+
if (projectTrusted) {
|
|
1942
|
+
// Project extensions from .pi/
|
|
1943
|
+
addResources("extensions", collectAutoExtensionEntries(projectDirs.extensions), projectMetadata, projectOverrides.extensions, projectBaseDir);
|
|
1944
|
+
// Project skills from .pi/
|
|
1945
|
+
addResources("skills", collectAutoSkillEntries(projectDirs.skills, "pi"), projectMetadata, projectOverrides.skills, projectBaseDir);
|
|
1946
|
+
}
|
|
1947
|
+
// Project skills from .agents/ (each with its own baseDir)
|
|
1948
|
+
for (const agentsSkillsDir of projectAgentsSkillDirs) {
|
|
1949
|
+
const agentsBaseDir = dirname(agentsSkillsDir); // the .agents directory
|
|
1950
|
+
const agentsMetadata = {
|
|
1951
|
+
...projectMetadata,
|
|
1952
|
+
baseDir: agentsBaseDir,
|
|
1953
|
+
};
|
|
1954
|
+
addResources("skills", collectAutoSkillEntries(agentsSkillsDir, "agents"), agentsMetadata, projectOverrides.skills, agentsBaseDir);
|
|
1955
|
+
}
|
|
1956
|
+
if (projectTrusted) {
|
|
1957
|
+
addResources("prompts", collectAutoPromptEntries(projectDirs.prompts), projectMetadata, projectOverrides.prompts, projectBaseDir);
|
|
1958
|
+
addResources("themes", collectAutoThemeEntries(projectDirs.themes), projectMetadata, projectOverrides.themes, projectBaseDir);
|
|
1959
|
+
}
|
|
1960
|
+
// User extensions from ~/.pi/agent/
|
|
1685
1961
|
addResources("extensions", collectAutoExtensionEntries(userDirs.extensions), userMetadata, userOverrides.extensions, globalBaseDir);
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1962
|
+
// User skills from ~/.pi/agent/
|
|
1963
|
+
addResources("skills", collectAutoSkillEntries(userDirs.skills, "pi"), userMetadata, userOverrides.skills, globalBaseDir);
|
|
1964
|
+
// User skills from ~/.agents/ (with its own baseDir)
|
|
1965
|
+
const userAgentsBaseDir = dirname(userAgentsSkillsDir);
|
|
1966
|
+
const userAgentsMetadata = {
|
|
1967
|
+
...userMetadata,
|
|
1968
|
+
baseDir: userAgentsBaseDir,
|
|
1969
|
+
};
|
|
1970
|
+
addResources("skills", collectAutoSkillEntries(userAgentsSkillsDir, "agents"), userAgentsMetadata, userOverrides.skills, userAgentsBaseDir);
|
|
1690
1971
|
addResources("prompts", collectAutoPromptEntries(userDirs.prompts), userMetadata, userOverrides.prompts, globalBaseDir);
|
|
1691
1972
|
addResources("themes", collectAutoThemeEntries(userDirs.themes), userMetadata, userOverrides.themes, globalBaseDir);
|
|
1692
1973
|
}
|
|
@@ -1740,30 +2021,49 @@ export class DefaultPackageManager {
|
|
|
1740
2021
|
};
|
|
1741
2022
|
}
|
|
1742
2023
|
toResolvedPaths(accumulator) {
|
|
1743
|
-
const
|
|
2024
|
+
const mapToResolved = (entries) => {
|
|
1744
2025
|
const resolved = Array.from(entries.entries()).map(([path, { metadata, enabled }]) => ({
|
|
1745
2026
|
path,
|
|
1746
2027
|
enabled,
|
|
1747
2028
|
metadata,
|
|
1748
2029
|
}));
|
|
1749
2030
|
resolved.sort((a, b) => resourcePrecedenceRank(a.metadata) - resourcePrecedenceRank(b.metadata));
|
|
1750
|
-
|
|
2031
|
+
const seen = new Set();
|
|
2032
|
+
return resolved.filter((entry) => {
|
|
2033
|
+
const canonicalPath = canonicalizePath(entry.path);
|
|
2034
|
+
if (seen.has(canonicalPath))
|
|
2035
|
+
return false;
|
|
2036
|
+
seen.add(canonicalPath);
|
|
2037
|
+
return true;
|
|
2038
|
+
});
|
|
1751
2039
|
};
|
|
1752
2040
|
return {
|
|
1753
|
-
extensions:
|
|
1754
|
-
skills:
|
|
1755
|
-
prompts:
|
|
1756
|
-
themes:
|
|
2041
|
+
extensions: mapToResolved(accumulator.extensions),
|
|
2042
|
+
skills: mapToResolved(accumulator.skills),
|
|
2043
|
+
prompts: mapToResolved(accumulator.prompts),
|
|
2044
|
+
themes: mapToResolved(accumulator.themes),
|
|
1757
2045
|
};
|
|
1758
2046
|
}
|
|
2047
|
+
spawnCommand(command, args, options) {
|
|
2048
|
+
const env = getEnv();
|
|
2049
|
+
return spawnProcess(command, args, {
|
|
2050
|
+
cwd: options?.cwd,
|
|
2051
|
+
stdio: isStdoutTakenOver() ? ["ignore", 2, 2] : "inherit",
|
|
2052
|
+
env,
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
spawnCaptureCommand(command, args, options) {
|
|
2056
|
+
const baseEnv = getEnv();
|
|
2057
|
+
const env = options?.env ? { ...baseEnv, ...options.env } : baseEnv;
|
|
2058
|
+
return spawnProcess(command, args, {
|
|
2059
|
+
cwd: options?.cwd,
|
|
2060
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
2061
|
+
env,
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
1759
2064
|
runCommandCapture(command, args, options) {
|
|
1760
2065
|
return new Promise((resolvePromise, reject) => {
|
|
1761
|
-
const child =
|
|
1762
|
-
cwd: options?.cwd,
|
|
1763
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
1764
|
-
shell: process.platform === "win32",
|
|
1765
|
-
env: options?.env ? { ...process.env, ...options.env } : process.env,
|
|
1766
|
-
});
|
|
2066
|
+
const child = this.spawnCaptureCommand(command, args, options);
|
|
1767
2067
|
let stdout = "";
|
|
1768
2068
|
let stderr = "";
|
|
1769
2069
|
let timedOut = false;
|
|
@@ -1779,12 +2079,12 @@ export class DefaultPackageManager {
|
|
|
1779
2079
|
child.stderr?.on("data", (data) => {
|
|
1780
2080
|
stderr += data.toString();
|
|
1781
2081
|
});
|
|
1782
|
-
child.
|
|
2082
|
+
child.once("error", (error) => {
|
|
1783
2083
|
if (timeout)
|
|
1784
2084
|
clearTimeout(timeout);
|
|
1785
2085
|
reject(error);
|
|
1786
2086
|
});
|
|
1787
|
-
child.
|
|
2087
|
+
child.once("close", (code, signal) => {
|
|
1788
2088
|
if (timeout)
|
|
1789
2089
|
clearTimeout(timeout);
|
|
1790
2090
|
if (timedOut) {
|
|
@@ -1795,17 +2095,14 @@ export class DefaultPackageManager {
|
|
|
1795
2095
|
resolvePromise(stdout.trim());
|
|
1796
2096
|
return;
|
|
1797
2097
|
}
|
|
1798
|
-
|
|
2098
|
+
const exitStatus = code === null ? `signal ${signal ?? "unknown"}` : `code ${code}`;
|
|
2099
|
+
reject(new Error(`${command} ${args.join(" ")} failed with ${exitStatus}: ${stderr || stdout}`));
|
|
1799
2100
|
});
|
|
1800
2101
|
});
|
|
1801
2102
|
}
|
|
1802
2103
|
runCommand(command, args, options) {
|
|
1803
2104
|
return new Promise((resolvePromise, reject) => {
|
|
1804
|
-
const child =
|
|
1805
|
-
cwd: options?.cwd,
|
|
1806
|
-
stdio: isStdoutTakenOver() ? ["ignore", 2, 2] : "inherit",
|
|
1807
|
-
shell: process.platform === "win32",
|
|
1808
|
-
});
|
|
2105
|
+
const child = this.spawnCommand(command, args, options);
|
|
1809
2106
|
child.on("error", reject);
|
|
1810
2107
|
child.on("exit", (code) => {
|
|
1811
2108
|
if (code === 0) {
|
|
@@ -1818,13 +2115,14 @@ export class DefaultPackageManager {
|
|
|
1818
2115
|
});
|
|
1819
2116
|
}
|
|
1820
2117
|
runCommandSync(command, args) {
|
|
1821
|
-
const
|
|
2118
|
+
const env = getEnv();
|
|
2119
|
+
const result = spawnProcessSync(command, args, {
|
|
1822
2120
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1823
2121
|
encoding: "utf-8",
|
|
1824
|
-
|
|
2122
|
+
env,
|
|
1825
2123
|
});
|
|
1826
|
-
if (result.status !== 0) {
|
|
1827
|
-
throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.stderr || result.stdout}`);
|
|
2124
|
+
if (result.error || result.status !== 0) {
|
|
2125
|
+
throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.error?.message || result.stderr || result.stdout}`);
|
|
1828
2126
|
}
|
|
1829
2127
|
return (result.stdout || result.stderr || "").trim();
|
|
1830
2128
|
}
|