@entelligentsia/forgecli 0.7.10 → 0.8.4

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.
Files changed (227) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/CHANGELOG-forge-plugin.md +70 -0
  3. package/dist/CHANGELOG-pi.md +63 -0
  4. package/dist/bin/argv.d.ts +2 -2
  5. package/dist/bin/argv.js +10 -0
  6. package/dist/bin/argv.js.map +1 -1
  7. package/dist/bin/env-defaults.d.ts +1 -0
  8. package/dist/bin/env-defaults.js +13 -0
  9. package/dist/bin/env-defaults.js.map +1 -0
  10. package/dist/bin/forge.js +9 -0
  11. package/dist/bin/forge.js.map +1 -1
  12. package/dist/bin/update-cli.d.ts +9 -0
  13. package/dist/bin/update-cli.js +120 -0
  14. package/dist/bin/update-cli.js.map +1 -0
  15. package/dist/extensions/forgecli/index.js +3 -3
  16. package/dist/extensions/forgecli/index.js.map +1 -1
  17. package/dist/extensions/forgecli/update-check.js +1 -1
  18. package/dist/extensions/forgecli/update-check.js.map +1 -1
  19. package/dist/extensions/forgecli/whats-new-widget.d.ts +5 -5
  20. package/dist/extensions/forgecli/whats-new-widget.js +11 -11
  21. package/dist/extensions/forgecli/whats-new-widget.js.map +1 -1
  22. package/dist/extensions/forgecli/whats-new.js +6 -5
  23. package/dist/extensions/forgecli/whats-new.js.map +1 -1
  24. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  25. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +27 -98
  26. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  27. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +62 -132
  28. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  29. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  30. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +25 -15
  31. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  32. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  33. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +1 -0
  34. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  35. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  36. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +17 -1
  37. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  38. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  39. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +8 -2
  40. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
  41. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  42. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +17 -1
  43. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
  44. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  45. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +8 -1
  46. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
  47. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  48. package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +63 -0
  49. package/node_modules/@earendil-works/pi-coding-agent/README.md +1 -1
  50. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -1
  51. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js +1 -1
  52. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js.map +1 -1
  53. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.d.ts.map +1 -1
  54. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js +6 -10
  55. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js.map +1 -1
  56. package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
  57. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +12 -3
  58. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
  59. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +1 -0
  60. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  61. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +30 -15
  62. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  63. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts +3 -3
  64. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  65. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +23 -13
  66. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  67. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts +4 -0
  68. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  69. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +58 -38
  70. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  71. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
  72. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js +0 -1
  73. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
  74. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  75. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +3 -2
  76. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  77. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +2 -2
  78. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  79. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +7 -4
  80. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -1
  81. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  82. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +6 -2
  83. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  84. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
  85. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +3 -4
  86. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
  87. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
  88. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js +2 -2
  89. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js.map +1 -1
  90. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts +7 -1
  91. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts.map +1 -1
  92. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js +60 -7
  93. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js.map +1 -1
  94. package/node_modules/@earendil-works/pi-coding-agent/docs/packages.md +2 -2
  95. package/node_modules/@earendil-works/pi-coding-agent/docs/settings.md +1 -3
  96. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
  97. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  98. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
  99. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
  100. package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -6
  101. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  102. package/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
  103. package/node_modules/@protobufjs/fetch/index.d.ts +7 -7
  104. package/node_modules/@protobufjs/fetch/index.js +4 -7
  105. package/node_modules/@protobufjs/fetch/package.json +7 -5
  106. package/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
  107. package/node_modules/@protobufjs/fetch/tests/index.js +150 -8
  108. package/node_modules/@protobufjs/fetch/util/fs.js +11 -0
  109. package/node_modules/@protobufjs/inquire/CHANGELOG.md +8 -0
  110. package/node_modules/@protobufjs/inquire/index.d.ts +1 -0
  111. package/node_modules/@protobufjs/inquire/index.js +1 -0
  112. package/node_modules/@protobufjs/inquire/package.json +1 -1
  113. package/node_modules/protobufjs/dist/light/protobuf.js +187 -153
  114. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  115. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  116. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  117. package/node_modules/protobufjs/dist/minimal/protobuf.js +14 -5
  118. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  119. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  120. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  121. package/node_modules/protobufjs/dist/protobuf.js +207 -173
  122. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  123. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  124. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  125. package/node_modules/protobufjs/package.json +6 -3
  126. package/node_modules/protobufjs/src/util/fs.js +11 -0
  127. package/node_modules/protobufjs/src/util/minimal.js +10 -2
  128. package/node_modules/protobufjs/src/util.js +1 -1
  129. package/node_modules/undici/README.md +14 -5
  130. package/node_modules/undici/docs/docs/api/Client.md +4 -2
  131. package/node_modules/undici/docs/docs/api/Dispatcher.md +62 -27
  132. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +7 -5
  133. package/node_modules/undici/docs/docs/api/H2CClient.md +1 -1
  134. package/node_modules/undici/docs/docs/api/RedirectHandler.md +14 -9
  135. package/node_modules/undici/docs/docs/api/RetryAgent.md +0 -1
  136. package/node_modules/undici/docs/docs/api/RetryHandler.md +12 -14
  137. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +23 -0
  138. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +231 -0
  139. package/node_modules/undici/index.js +4 -2
  140. package/node_modules/undici/lib/api/api-connect.js +13 -11
  141. package/node_modules/undici/lib/api/api-pipeline.js +26 -13
  142. package/node_modules/undici/lib/api/api-request.js +45 -21
  143. package/node_modules/undici/lib/api/api-stream.js +81 -20
  144. package/node_modules/undici/lib/api/api-upgrade.js +21 -11
  145. package/node_modules/undici/lib/api/readable.js +3 -2
  146. package/node_modules/undici/lib/cache/memory-cache-store.js +1 -1
  147. package/node_modules/undici/lib/cache/sqlite-cache-store.js +6 -4
  148. package/node_modules/undici/lib/core/connect.js +17 -1
  149. package/node_modules/undici/lib/core/constants.js +1 -24
  150. package/node_modules/undici/lib/core/errors.js +2 -2
  151. package/node_modules/undici/lib/core/request.js +115 -18
  152. package/node_modules/undici/lib/core/socks5-client.js +24 -9
  153. package/node_modules/undici/lib/core/socks5-utils.js +32 -23
  154. package/node_modules/undici/lib/core/symbols.js +1 -0
  155. package/node_modules/undici/lib/core/util.js +70 -43
  156. package/node_modules/undici/lib/dispatcher/agent.js +47 -33
  157. package/node_modules/undici/lib/dispatcher/balanced-pool.js +21 -26
  158. package/node_modules/undici/lib/dispatcher/client-h1.js +98 -39
  159. package/node_modules/undici/lib/dispatcher/client-h2.js +603 -272
  160. package/node_modules/undici/lib/dispatcher/client.js +12 -5
  161. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +24 -5
  162. package/node_modules/undici/lib/dispatcher/dispatcher.js +0 -4
  163. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +107 -0
  164. package/node_modules/undici/lib/dispatcher/h2c-client.js +5 -5
  165. package/node_modules/undici/lib/dispatcher/pool-base.js +28 -10
  166. package/node_modules/undici/lib/dispatcher/pool.js +31 -6
  167. package/node_modules/undici/lib/dispatcher/proxy-agent.js +38 -13
  168. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +31 -9
  169. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +95 -80
  170. package/node_modules/undici/lib/global.js +13 -1
  171. package/node_modules/undici/lib/handler/cache-handler.js +16 -8
  172. package/node_modules/undici/lib/handler/decorator-handler.js +1 -2
  173. package/node_modules/undici/lib/handler/redirect-handler.js +5 -51
  174. package/node_modules/undici/lib/handler/retry-handler.js +15 -2
  175. package/node_modules/undici/lib/interceptor/cache.js +30 -17
  176. package/node_modules/undici/lib/interceptor/decompress.js +28 -2
  177. package/node_modules/undici/lib/interceptor/dns.js +1 -1
  178. package/node_modules/undici/lib/interceptor/redirect.js +3 -3
  179. package/node_modules/undici/lib/llhttp/llhttp-wasm.js +1 -1
  180. package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +1 -1
  181. package/node_modules/undici/lib/mock/mock-agent.js +8 -8
  182. package/node_modules/undici/lib/mock/mock-call-history.js +15 -15
  183. package/node_modules/undici/lib/mock/mock-utils.js +37 -22
  184. package/node_modules/undici/lib/mock/snapshot-agent.js +16 -6
  185. package/node_modules/undici/lib/mock/snapshot-recorder.js +38 -3
  186. package/node_modules/undici/lib/util/cache.js +8 -7
  187. package/node_modules/undici/lib/util/runtime-features.js +3 -34
  188. package/node_modules/undici/lib/web/cache/cache.js +6 -8
  189. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
  190. package/node_modules/undici/lib/web/fetch/body.js +3 -9
  191. package/node_modules/undici/lib/web/fetch/formdata-parser.js +17 -6
  192. package/node_modules/undici/lib/web/fetch/formdata.js +21 -2
  193. package/node_modules/undici/lib/web/fetch/index.js +214 -221
  194. package/node_modules/undici/lib/web/webidl/index.js +7 -9
  195. package/node_modules/undici/lib/web/websocket/frame.js +1 -7
  196. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +13 -31
  197. package/node_modules/undici/lib/web/websocket/receiver.js +62 -22
  198. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +11 -17
  199. package/node_modules/undici/lib/web/websocket/websocket.js +6 -1
  200. package/node_modules/undici/package.json +9 -9
  201. package/node_modules/undici/types/agent.d.ts +0 -2
  202. package/node_modules/undici/types/client.d.ts +25 -19
  203. package/node_modules/undici/types/dispatcher.d.ts +7 -27
  204. package/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
  205. package/node_modules/undici/types/formdata.d.ts +0 -6
  206. package/node_modules/undici/types/h2c-client.d.ts +6 -6
  207. package/node_modules/undici/types/header.d.ts +5 -0
  208. package/node_modules/undici/types/index.d.ts +3 -1
  209. package/node_modules/undici/types/interceptors.d.ts +1 -1
  210. package/node_modules/undici/types/pool.d.ts +0 -2
  211. package/node_modules/undici/types/proxy-agent.d.ts +2 -2
  212. package/node_modules/undici/types/round-robin-pool.d.ts +0 -2
  213. package/node_modules/undici/types/snapshot-agent.d.ts +4 -0
  214. package/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -2
  215. package/node_modules/undici/types/webidl.d.ts +0 -1
  216. package/package.json +7 -8
  217. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  218. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +0 -92
  219. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +0 -31
  220. package/node_modules/undici/lib/handler/unwrap-handler.js +0 -100
  221. package/node_modules/undici/lib/handler/wrap-handler.js +0 -105
  222. package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  223. package/node_modules/undici/lib/util/promise.js +0 -28
  224. package/skills/refresh-kb-links/SKILL.md +0 -217
  225. package/skills/store-custodian/SKILL.md +0 -163
  226. package/skills/store-query-grammar/SKILL.md +0 -145
  227. package/skills/store-query-nlp/SKILL.md +0 -110
@@ -26,7 +26,7 @@ import { globSync } from "glob";
26
26
  import ignore from "ignore";
27
27
  import { minimatch } from "minimatch";
28
28
  import { CONFIG_DIR_NAME } from "../config.js";
29
- import { shouldUseWindowsShell } from "../utils/child-process.js";
29
+ import { resolveSpawnCommand } from "../utils/child-process.js";
30
30
  import { parseGitUrl } from "../utils/git.js";
31
31
  import { canonicalizePath, isLocalPath } from "../utils/paths.js";
32
32
  import { isStdoutTakenOver } from "./output-guard.js";
@@ -845,7 +845,7 @@ export class DefaultPackageManager {
845
845
  await Promise.all(tasks);
846
846
  }
847
847
  async shouldUpdateNpmSource(source, scope) {
848
- const installedPath = this.getNpmInstallPath(source, scope);
848
+ const installedPath = this.getManagedNpmInstallPath(source, scope);
849
849
  const installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;
850
850
  if (!installedVersion) {
851
851
  return true;
@@ -871,13 +871,9 @@ export class DefaultPackageManager {
871
871
  });
872
872
  }
873
873
  async installNpmBatch(specs, scope) {
874
- if (scope === "user") {
875
- await this.runNpmCommand(["install", "-g", ...specs]);
876
- return;
877
- }
878
874
  const installRoot = this.getNpmInstallRoot(scope, false);
879
875
  this.ensureNpmProject(installRoot);
880
- await this.runNpmCommand(["install", ...specs, "--prefix", installRoot]);
876
+ await this.runNpmCommand(this.getNpmInstallArgs(specs, installRoot));
881
877
  }
882
878
  async checkForAvailableUpdates() {
883
879
  if (isOfflineModeEnabled()) {
@@ -1364,6 +1360,13 @@ export class DefaultPackageManager {
1364
1360
  }
1365
1361
  return { command, args };
1366
1362
  }
1363
+ getPackageManagerName() {
1364
+ const npmCommand = this.getNpmCommand();
1365
+ const commandParts = [npmCommand.command, ...npmCommand.args];
1366
+ const separatorIndex = commandParts.lastIndexOf("--");
1367
+ const packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;
1368
+ return packageManagerCommand ? basename(packageManagerCommand).replace(/\.(cmd|exe)$/i, "") : "";
1369
+ }
1367
1370
  async runNpmCommand(args, options) {
1368
1371
  const npmCommand = this.getNpmCommand();
1369
1372
  await this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);
@@ -1379,24 +1382,30 @@ export class DefaultPackageManager {
1379
1382
  const npmCommand = this.getNpmCommand();
1380
1383
  return this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);
1381
1384
  }
1382
- async installNpm(source, scope, temporary) {
1383
- if (scope === "user" && !temporary) {
1384
- await this.runNpmCommand(["install", "-g", source.spec]);
1385
- return;
1385
+ getNpmInstallArgs(specs, installRoot) {
1386
+ const packageManagerName = this.getPackageManagerName();
1387
+ if (packageManagerName === "bun") {
1388
+ return ["install", ...specs, "--cwd", installRoot];
1386
1389
  }
1390
+ if (packageManagerName === "pnpm") {
1391
+ return ["install", ...specs, "--prefix", installRoot, "--config.strict-dep-builds=false"];
1392
+ }
1393
+ return ["install", ...specs, "--prefix", installRoot];
1394
+ }
1395
+ async installNpm(source, scope, temporary) {
1387
1396
  const installRoot = this.getNpmInstallRoot(scope, temporary);
1388
1397
  this.ensureNpmProject(installRoot);
1389
- await this.runNpmCommand(["install", source.spec, "--prefix", installRoot]);
1398
+ await this.runNpmCommand(this.getNpmInstallArgs([source.spec], installRoot));
1390
1399
  }
1391
1400
  async uninstallNpm(source, scope) {
1392
- if (scope === "user") {
1393
- await this.runNpmCommand(["uninstall", "-g", source.name]);
1394
- return;
1395
- }
1396
1401
  const installRoot = this.getNpmInstallRoot(scope, false);
1397
1402
  if (!existsSync(installRoot)) {
1398
1403
  return;
1399
1404
  }
1405
+ if (this.getPackageManagerName() === "bun") {
1406
+ await this.runNpmCommand(["uninstall", source.name, "--cwd", installRoot]);
1407
+ return;
1408
+ }
1400
1409
  await this.runNpmCommand(["uninstall", source.name, "--prefix", installRoot]);
1401
1410
  }
1402
1411
  async installGit(source, scope) {
@@ -1516,7 +1525,7 @@ export class DefaultPackageManager {
1516
1525
  if (scope === "project") {
1517
1526
  return join(this.cwd, CONFIG_DIR_NAME, "npm");
1518
1527
  }
1519
- return join(this.getGlobalNpmRoot(), "..");
1528
+ return join(this.agentDir, "npm");
1520
1529
  }
1521
1530
  getGlobalNpmRoot() {
1522
1531
  const npmCommand = this.getNpmCommand();
@@ -1524,8 +1533,7 @@ export class DefaultPackageManager {
1524
1533
  if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
1525
1534
  return this.globalNpmRoot;
1526
1535
  }
1527
- const isBunPackageManager = npmCommand.command === "bun";
1528
- if (isBunPackageManager) {
1536
+ if (this.getPackageManagerName() === "bun") {
1529
1537
  const binDir = this.runNpmCommandSync(["pm", "bin", "-g"]).trim();
1530
1538
  this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
1531
1539
  }
@@ -1536,14 +1544,7 @@ export class DefaultPackageManager {
1536
1544
  return this.globalNpmRoot;
1537
1545
  }
1538
1546
  getPnpmGlobalPackagePath(packageName) {
1539
- const npmCommand = this.getNpmCommand();
1540
- const commandParts = [npmCommand.command, ...npmCommand.args];
1541
- const separatorIndex = commandParts.lastIndexOf("--");
1542
- const packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;
1543
- const packageManagerName = packageManagerCommand
1544
- ? basename(packageManagerCommand).replace(/\.(cmd|exe)$/i, "")
1545
- : "";
1546
- if (packageManagerName !== "pnpm") {
1547
+ if (this.getPackageManagerName() !== "pnpm") {
1547
1548
  return undefined;
1548
1549
  }
1549
1550
  const output = this.runNpmCommandSync(["list", "-g", "--depth", "0", "--json"]);
@@ -1555,14 +1556,30 @@ export class DefaultPackageManager {
1555
1556
  }
1556
1557
  return undefined;
1557
1558
  }
1558
- getNpmInstallPath(source, scope) {
1559
+ getManagedNpmInstallPath(source, scope) {
1559
1560
  if (scope === "temporary") {
1560
1561
  return join(this.getTemporaryDir("npm"), "node_modules", source.name);
1561
1562
  }
1562
1563
  if (scope === "project") {
1563
1564
  return join(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
1564
1565
  }
1565
- return this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);
1566
+ return join(this.agentDir, "npm", "node_modules", source.name);
1567
+ }
1568
+ getLegacyGlobalNpmInstallPath(source) {
1569
+ try {
1570
+ return this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);
1571
+ }
1572
+ catch {
1573
+ return undefined;
1574
+ }
1575
+ }
1576
+ getNpmInstallPath(source, scope) {
1577
+ const managedPath = this.getManagedNpmInstallPath(source, scope);
1578
+ if (scope !== "user" || existsSync(managedPath)) {
1579
+ return managedPath;
1580
+ }
1581
+ const legacyPath = this.getLegacyGlobalNpmInstallPath(source);
1582
+ return legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;
1566
1583
  }
1567
1584
  getGitInstallPath(source, scope) {
1568
1585
  if (scope === "temporary") {
@@ -1911,20 +1928,22 @@ export class DefaultPackageManager {
1911
1928
  };
1912
1929
  }
1913
1930
  spawnCommand(command, args, options) {
1914
- return spawn(command, args, {
1931
+ const env = getEnv();
1932
+ const resolved = resolveSpawnCommand(command, args, { env });
1933
+ return spawn(resolved.command, resolved.args, {
1915
1934
  cwd: options?.cwd,
1916
1935
  stdio: isStdoutTakenOver() ? ["ignore", 2, 2] : "inherit",
1917
- shell: shouldUseWindowsShell(command),
1918
- env: getEnv(),
1936
+ env,
1919
1937
  });
1920
1938
  }
1921
1939
  spawnCaptureCommand(command, args, options) {
1922
1940
  const baseEnv = getEnv();
1923
- return spawn(command, args, {
1941
+ const env = options?.env ? { ...baseEnv, ...options.env } : baseEnv;
1942
+ const resolved = resolveSpawnCommand(command, args, { env });
1943
+ return spawn(resolved.command, resolved.args, {
1924
1944
  cwd: options?.cwd,
1925
1945
  stdio: ["ignore", "pipe", "pipe"],
1926
- shell: shouldUseWindowsShell(command),
1927
- env: options?.env ? { ...baseEnv, ...options.env } : baseEnv,
1946
+ env,
1928
1947
  });
1929
1948
  }
1930
1949
  runCommandCapture(command, args, options) {
@@ -1981,11 +2000,12 @@ export class DefaultPackageManager {
1981
2000
  });
1982
2001
  }
1983
2002
  runCommandSync(command, args) {
1984
- const result = spawnSync(command, args, {
2003
+ const env = getEnv();
2004
+ const resolved = resolveSpawnCommand(command, args, { env });
2005
+ const result = spawnSync(resolved.command, resolved.args, {
1985
2006
  stdio: ["ignore", "pipe", "pipe"],
1986
2007
  encoding: "utf-8",
1987
- shell: shouldUseWindowsShell(command),
1988
- env: getEnv(),
2008
+ env,
1989
2009
  });
1990
2010
  if (result.error || result.status !== 0) {
1991
2011
  throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.error?.message || result.stderr || result.stdout}`);