pi-lens 4.5.0 → 4.5.2

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 (148) hide show
  1. package/CHANGELOG-USER.md +12 -12
  2. package/CHANGELOG.md +253 -0
  3. package/README.md +11 -2
  4. package/config/dependency-cruiser-eager-allowlist.json +1 -0
  5. package/dist/{chunk-ZULZS2I6.js → chunk-2ERVW2UF.js} +1115 -423
  6. package/dist/{chunk-BBSDJTOV.js → chunk-2K7BUOKS.js} +13 -13
  7. package/dist/{chunk-I2FYOZNW.js → chunk-3JJ4OAJI.js} +10 -10
  8. package/dist/{chunk-5JB4WENL.js → chunk-3UHGSUVL.js} +1 -1
  9. package/dist/{chunk-W26QZ3OM.js → chunk-463WN3VP.js} +10 -10
  10. package/dist/{chunk-4IZZEN63.js → chunk-4X3ML2UQ.js} +31 -34
  11. package/dist/{chunk-I3NZVAMN.js → chunk-5BI5YP57.js} +10 -10
  12. package/dist/{chunk-7U36VQL6.js → chunk-5Z4XLUFF.js} +3 -3
  13. package/dist/{chunk-DCA2MXVQ.js → chunk-62AJH3IN.js} +51 -29
  14. package/dist/{chunk-37IDWT6O.js → chunk-6F34GMP7.js} +16 -14
  15. package/dist/{chunk-VSQT6IHZ.js → chunk-6LIUVGOR.js} +28 -4
  16. package/dist/{chunk-27JQHK7Y.js → chunk-6REF4GCO.js} +1 -1
  17. package/dist/{chunk-INBK3HIT.js → chunk-7KRR24GO.js} +3 -3
  18. package/dist/{chunk-OZQQ3AIR.js → chunk-7OMOMBEQ.js} +9 -9
  19. package/dist/{chunk-ARTYCUGF.js → chunk-7ZFXICNN.js} +123 -20
  20. package/dist/{chunk-K4Z7MK6T.js → chunk-ABKRQVOY.js} +28 -52
  21. package/dist/{chunk-C5PLBTNR.js → chunk-ANSLRJBG.js} +1 -1
  22. package/dist/{chunk-HRLF35WL.js → chunk-AWMFBPGJ.js} +9 -9
  23. package/dist/{chunk-CXQYK4YT.js → chunk-BG7KHGNX.js} +2 -2
  24. package/dist/{chunk-ZI7YHV6I.js → chunk-BK2R2223.js} +10 -8
  25. package/dist/chunk-BXXC6KRR.js +107 -0
  26. package/dist/{chunk-QMWKSYWB.js → chunk-CKJS2AUI.js} +4 -4
  27. package/dist/{chunk-PPQHMSPH.js → chunk-COGU5KQJ.js} +15 -15
  28. package/dist/{chunk-NHA5K226.js → chunk-CQNXALZJ.js} +27 -6
  29. package/dist/{chunk-KZ732ZVW.js → chunk-CSZESDPP.js} +1 -1
  30. package/dist/chunk-CZ5TCJPB.js +98 -0
  31. package/dist/{chunk-LOEJFTF2.js → chunk-D2LFEA5U.js} +9 -2
  32. package/dist/chunk-D3KLF5CD.js +50 -0
  33. package/dist/{chunk-4DAHGU3V.js → chunk-ENJ2M76Y.js} +31 -29
  34. package/dist/{chunk-ZQSSO7LO.js → chunk-EQKF6BAK.js} +3 -3
  35. package/dist/{chunk-PFJLYRO3.js → chunk-F2SAP2FM.js} +40 -47
  36. package/dist/{chunk-ADYQRETD.js → chunk-F6QAJXQV.js} +2 -2
  37. package/dist/chunk-GR2QDWH5.js +25 -0
  38. package/dist/{chunk-LVLPA32Q.js → chunk-GVE5VZYQ.js} +48 -11
  39. package/dist/{chunk-AZG5UJYY.js → chunk-GWZZOJD2.js} +1 -1
  40. package/dist/chunk-GZS6VPIE.js +27 -0
  41. package/dist/chunk-H4B4SC7I.js +71 -0
  42. package/dist/{chunk-YCR6ZYTE.js → chunk-HA6TUJOE.js} +1 -1
  43. package/dist/{chunk-DI4AZZNY.js → chunk-HKPJTI47.js} +2 -2
  44. package/dist/{chunk-O6LCSHHI.js → chunk-HPKC55MA.js} +1 -1
  45. package/dist/{chunk-LQQNFCQJ.js → chunk-I65CQLCG.js} +1 -1
  46. package/dist/{chunk-P5MSLVUW.js → chunk-IDKLWVKY.js} +11 -11
  47. package/dist/chunk-IUM2Q7NF.js +25 -0
  48. package/dist/{chunk-L6BDRYUK.js → chunk-J24IS3KZ.js} +5 -5
  49. package/dist/{chunk-KNSOA43J.js → chunk-J2DAHH4T.js} +2 -2
  50. package/dist/{chunk-7ZVTFLCC.js → chunk-JBDZVOFL.js} +11 -11
  51. package/dist/{chunk-HIJ4CHFF.js → chunk-JC6NFC57.js} +3 -3
  52. package/dist/{chunk-K7O6AHSJ.js → chunk-JTHEUTW7.js} +11 -11
  53. package/dist/{chunk-KXGTLAUW.js → chunk-JWW3ODBN.js} +2 -2
  54. package/dist/{chunk-HIRBC72R.js → chunk-K3ZIYLHT.js} +4 -4
  55. package/dist/{chunk-6GLMMGCX.js → chunk-KDPZA2UE.js} +2 -3
  56. package/dist/{chunk-AXAR5ZW2.js → chunk-KMY2OU4T.js} +553 -434
  57. package/dist/{chunk-DFKOA74L.js → chunk-KQF7VT26.js} +10 -10
  58. package/dist/{chunk-S6MCMD27.js → chunk-KVGA7X76.js} +3 -3
  59. package/dist/{chunk-74AMPWNC.js → chunk-KW7O72AK.js} +2 -2
  60. package/dist/{chunk-UN72ZAJ5.js → chunk-LEQTVRSV.js} +9 -9
  61. package/dist/{chunk-B42AIWPJ.js → chunk-LKPSBM6S.js} +3 -3
  62. package/dist/{chunk-R4L7KZ7R.js → chunk-LKW2HFSZ.js} +9 -9
  63. package/dist/{chunk-3PO4YYOX.js → chunk-LURFD4HD.js} +4240 -3734
  64. package/dist/{chunk-PQXUZYTQ.js → chunk-M6ELTECW.js} +4 -4
  65. package/dist/{chunk-3QXFUP6T.js → chunk-MGVVYYKW.js} +12 -12
  66. package/dist/{chunk-CZJGAOKL.js → chunk-MQBKGRSB.js} +7 -7
  67. package/dist/{chunk-NNEQOC3U.js → chunk-MVG2ZEAO.js} +9 -7
  68. package/dist/{chunk-VWEBZ2JV.js → chunk-MY4XNNTX.js} +39 -41
  69. package/dist/{chunk-RIH3UBK4.js → chunk-N4AJVFRF.js} +11 -11
  70. package/dist/{chunk-TKOFTLGB.js → chunk-OFKKMXWM.js} +31 -36
  71. package/dist/{chunk-3PAS2ERX.js → chunk-OFZE4ANN.js} +8 -8
  72. package/dist/chunk-OLXBUTJR.js +61 -0
  73. package/dist/{chunk-6CFSDLHE.js → chunk-OZGEHOSG.js} +38 -17
  74. package/dist/{chunk-3TSMQZG6.js → chunk-PKGOROPQ.js} +40 -2
  75. package/dist/{chunk-OLWGYBYT.js → chunk-Q6D5QKRG.js} +17 -17
  76. package/dist/{chunk-QE7BJQ6K.js → chunk-QECLJFHI.js} +12 -17
  77. package/dist/{chunk-RJ3APNIP.js → chunk-QJA33VD5.js} +4 -4
  78. package/dist/{chunk-MOAVEPC4.js → chunk-R5XVJ6AN.js} +11 -11
  79. package/dist/{chunk-ZRQMENT4.js → chunk-REZL4OM4.js} +1 -1
  80. package/dist/{chunk-PKWEBMCA.js → chunk-RK5RBREN.js} +251 -201
  81. package/dist/chunk-RP5ZQTHO.js +86 -0
  82. package/dist/{chunk-J2ZB5MDS.js → chunk-RURPX2YV.js} +23 -23
  83. package/dist/chunk-TB5MGZLS.js +53 -0
  84. package/dist/chunk-TC63XRYP.js +27 -0
  85. package/dist/chunk-TJOYHAXJ.js +69 -0
  86. package/dist/{chunk-Q7J3JYJ2.js → chunk-TRXKDCBP.js} +13 -13
  87. package/dist/{chunk-6E5QLMWI.js → chunk-TTK37D7R.js} +22 -23
  88. package/dist/{chunk-XDNWR7SG.js → chunk-UH3QHLR5.js} +2 -2
  89. package/dist/{chunk-SCU62JLX.js → chunk-UNTJJ7GN.js} +7 -7
  90. package/dist/{chunk-O2MHF7QM.js → chunk-UPAFSETJ.js} +58 -63
  91. package/dist/{chunk-PQF6YGYB.js → chunk-UX75PTQW.js} +50 -31
  92. package/dist/{chunk-TWEOJE3D.js → chunk-V353PYMK.js} +1233 -576
  93. package/dist/{chunk-CQY2HEH7.js → chunk-V4TFQY5G.js} +2 -2
  94. package/dist/{chunk-B2OXE4AH.js → chunk-VC3W54G3.js} +446 -293
  95. package/dist/{chunk-JGUDT5KD.js → chunk-VSBCJVPC.js} +5 -5
  96. package/dist/{chunk-5HBQL7DH.js → chunk-WAQQGXVV.js} +3 -3
  97. package/dist/{chunk-7DPXUPRF.js → chunk-WLEVWR7Y.js} +2 -2
  98. package/dist/{chunk-QE5DJ7MX.js → chunk-WPMPVP5I.js} +4 -4
  99. package/dist/{chunk-KNJH6WJQ.js → chunk-WXNLFOC2.js} +7 -7
  100. package/dist/{chunk-XSC3BCN3.js → chunk-Y3ZNOZZS.js} +6 -6
  101. package/dist/{chunk-VGRGW4UL.js → chunk-YL6JQTWC.js} +29 -32
  102. package/dist/{chunk-7CLWC2UH.js → chunk-YVE5Q2UU.js} +86 -217
  103. package/dist/{chunk-LGH2HHZG.js → chunk-YZNARDMM.js} +42 -28
  104. package/dist/{chunk-NGNBJIUO.js → chunk-ZDWNFZJ2.js} +8 -8
  105. package/dist/{chunk-X33QECRJ.js → chunk-ZEUF7BIN.js} +2 -2
  106. package/dist/{chunk-2H5GHZKC.js → chunk-ZIF4WLWR.js} +45 -25
  107. package/dist/{chunk-WLD6BGON.js → chunk-ZSPVF7KI.js} +231 -24
  108. package/dist/{chunk-SDYLT45T.js → chunk-ZX6OKBVO.js} +2 -2
  109. package/dist/index.js +10566 -6819
  110. package/dist/mcp/analyze-cli.js +8 -8
  111. package/dist/mcp/cli.js +39 -41
  112. package/dist/mcp/server.js +1083 -685
  113. package/dist/mcp/worker.js +68 -59
  114. package/dist/probes/installer.js +21 -22
  115. package/docs/ci-bot-pr-checks.md +18 -9
  116. package/docs/ci.md +7 -0
  117. package/docs/configuration.md +24 -10
  118. package/docs/defect-shapes.md +61 -30
  119. package/docs/environment-variables.md +18 -9
  120. package/docs/globalconfig.md +17 -0
  121. package/docs/invariants/dispatch-runners.md +22 -0
  122. package/docs/invariants/lsp-trust-exec.md +33 -3
  123. package/docs/lsp-capability-matrix.md +23 -10
  124. package/docs/lsp-idle-eviction.md +7 -1
  125. package/docs/module-report-read-symbol.md +6 -2
  126. package/docs/pi-lens-merge-policy.md +3 -2
  127. package/docs/pi-lens-orchestration.md +2 -1
  128. package/docs/pi-lens-subagent.md +2 -1
  129. package/docs/release-qa-baseline.md +22 -17
  130. package/docs/servercapabilities.md +1 -1
  131. package/docs/settings.md +10 -2
  132. package/docs/tools.md +1 -1
  133. package/docs/usage.md +1 -0
  134. package/package.json +3 -3
  135. package/dist/chunk-2H7NFZ4Q.js +0 -25
  136. package/dist/chunk-5YJXF2IS.js +0 -56
  137. package/dist/chunk-7WKVCZI4.js +0 -69
  138. package/dist/chunk-BKWFDWYM.js +0 -46
  139. package/dist/chunk-G53LBDNU.js +0 -255
  140. package/dist/chunk-GCSDF5IE.js +0 -27
  141. package/dist/chunk-H5API74E.js +0 -67
  142. package/dist/chunk-HBX55MWO.js +0 -27
  143. package/dist/chunk-JOIKBUQN.js +0 -88
  144. package/dist/chunk-M2YMBT5G.js +0 -73
  145. package/dist/chunk-MJRGPEQ5.js +0 -25
  146. package/dist/chunk-QV3JPCMK.js +0 -17
  147. package/dist/chunk-TFKN5EIR.js +0 -27
  148. package/dist/chunk-UNP6Y4JV.js +0 -38
@@ -1,26 +1,27 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
+ findCommandOnPath,
3
4
  resolveToolCwd
4
- } from "./chunk-LVLPA32Q.js";
5
+ } from "./chunk-GVE5VZYQ.js";
5
6
  import {
6
7
  allAvailableGlobalBinDirs,
7
8
  installArgs,
8
9
  pmBinary,
9
10
  resolveNodePackageManager
10
- } from "./chunk-LGH2HHZG.js";
11
+ } from "./chunk-YZNARDMM.js";
11
12
  import {
12
13
  probeToolAsync
13
- } from "./chunk-KXGTLAUW.js";
14
- import {
15
- registerBackgroundWriteDrain
16
- } from "./chunk-UYXV5NIS.js";
14
+ } from "./chunk-JWW3ODBN.js";
17
15
  import {
18
16
  TRANSIENT_MAX_COOLDOWN_MS,
19
17
  classifyProbeFailure,
20
18
  createAvailabilityLatch,
21
19
  logAvailabilityDecision,
22
20
  startHostStallSampler
23
- } from "./chunk-6GLMMGCX.js";
21
+ } from "./chunk-KDPZA2UE.js";
22
+ import {
23
+ registerBackgroundWriteDrain
24
+ } from "./chunk-UYXV5NIS.js";
24
25
  import {
25
26
  acquireBoundedPidFileLock,
26
27
  acquireQuarantinePidFileLock,
@@ -40,30 +41,27 @@ import {
40
41
  startGenerationHeartbeat,
41
42
  tryAcquireGeneration,
42
43
  windowsExe
43
- } from "./chunk-3PO4YYOX.js";
44
- import {
45
- hashContentBytes
46
- } from "./chunk-CIA7X2PZ.js";
44
+ } from "./chunk-LURFD4HD.js";
47
45
  import {
48
46
  assertInstallAllowed,
49
47
  getProjectTrustGeneration,
50
48
  projectTrustDenialReason,
51
49
  writeFileAtomic,
52
50
  writeFileAtomicAsync
53
- } from "./chunk-W26QZ3OM.js";
51
+ } from "./chunk-463WN3VP.js";
54
52
  import {
55
53
  getDegradationLedgerGeneration,
56
54
  incrementDegradationCount,
57
55
  logExtension,
58
56
  recordDegradationOnce
59
- } from "./chunk-NHA5K226.js";
57
+ } from "./chunk-CQNXALZJ.js";
60
58
  import {
61
59
  createNdjsonLogger,
62
60
  getGlobalPiLensLogDir,
63
61
  getMaxLogSizeMB,
64
62
  isTestMode,
65
63
  isToolInstallDisabled
66
- } from "./chunk-7CLWC2UH.js";
64
+ } from "./chunk-YVE5Q2UU.js";
67
65
  import {
68
66
  BoundedLruCache,
69
67
  findLocalToolConfig,
@@ -71,57 +69,119 @@ import {
71
69
  isUnderDir,
72
70
  realpathOrResolve,
73
71
  toPosix
74
- } from "./chunk-WLD6BGON.js";
72
+ } from "./chunk-ZSPVF7KI.js";
75
73
  import {
76
74
  __require
77
75
  } from "./chunk-NXL4FFQQ.js";
78
76
 
79
77
  // dist/clients/installer/index.js
80
- import { existsSync, readFileSync as readFileSync2, statSync as statSync2, unlinkSync, writeFileSync } from "node:fs";
81
- import fs2 from "node:fs/promises";
78
+ import { existsSync, readFileSync as readFileSync2, statSync, unlinkSync, writeFileSync } from "node:fs";
79
+ import { createReadStream, createWriteStream as createWriteStream2 } from "node:fs";
80
+ import fs3 from "node:fs/promises";
82
81
  import { randomUUID } from "node:crypto";
83
- import https from "node:https";
82
+ import https2 from "node:https";
84
83
  import { createRequire } from "node:module";
85
84
  import os from "node:os";
86
- import path4 from "node:path";
85
+ import path3 from "node:path";
86
+ import { createGunzip } from "node:zlib";
87
+ import { pipeline as pipeline2 } from "node:stream/promises";
87
88
 
88
- // dist/clients/command-path.js
89
- import { statSync } from "node:fs";
90
- import * as path from "node:path";
91
- function findCommandOnPath(command, isWindows) {
92
- const pathEnv = process.env.PATH || process.env.Path || process.env.path || "";
93
- const dirs = pathEnv.split(path.delimiter);
94
- const names = isWindows ? [command, `${command}.exe`, `${command}.cmd`, `${command}.bat`] : [command];
95
- for (const dir of dirs) {
96
- if (!dir)
97
- continue;
98
- for (const name of names) {
99
- const candidate = isWindows ? path.join(dir, name) : `${dir}${path.sep}${name}`;
100
- try {
101
- const stat = statSync(candidate);
102
- if (!stat.isFile() || stat.size === 0)
103
- continue;
104
- if (isUntrustedProjectPath(candidate)) {
105
- recordProjectCommandRefusal(candidate);
106
- continue;
89
+ // dist/clients/installer/download.js
90
+ import { createHash } from "node:crypto";
91
+ import { createWriteStream } from "node:fs";
92
+ import fs from "node:fs/promises";
93
+ import http from "node:http";
94
+ import https from "node:https";
95
+ import { Transform } from "node:stream";
96
+ import { pipeline } from "node:stream/promises";
97
+ var MAX_BYTES = 512 * 1024 * 1024;
98
+ var TIMEOUT_MS = 12e4;
99
+ var InstallerDownloadError = class extends globalThis.Error {
100
+ code;
101
+ constructor(code, message) {
102
+ super(message);
103
+ this.name = "InstallerDownloadError";
104
+ this.code = code;
105
+ }
106
+ };
107
+ function downloadInstallerFile(url, destination, maxRedirects = 5, headers = {}, maxBytes = MAX_BYTES) {
108
+ return new Promise((resolve, reject) => {
109
+ let settled = false;
110
+ const fail = (error) => {
111
+ if (settled)
112
+ return;
113
+ settled = true;
114
+ void fs.rm(destination, { force: true }).finally(() => reject(error));
115
+ };
116
+ const request = (url.startsWith("http:") ? http : https).get(url, { headers: { "User-Agent": "pi-lens/1.0", ...headers } }, (res) => {
117
+ if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
118
+ res.resume();
119
+ if (maxRedirects === 0)
120
+ return fail(new InstallerDownloadError("stream", "Too many redirects"));
121
+ if (!URL.canParse(res.headers.location, url))
122
+ return fail(new InstallerDownloadError("stream", `invalid redirect Location from ${url}`));
123
+ const next = new URL(res.headers.location, url).href;
124
+ const nextHeaders = next.startsWith(url) ? headers : (() => {
125
+ const { Authorization: _drop, ...rest } = headers;
126
+ return rest;
127
+ })();
128
+ downloadInstallerFile(next, destination, maxRedirects - 1, nextHeaders, maxBytes).then(resolve, fail);
129
+ return;
130
+ }
131
+ if (res.statusCode !== 200) {
132
+ res.resume();
133
+ return fail(new InstallerDownloadError("stream", `HTTP ${res.statusCode ?? 0} for ${url}`));
134
+ }
135
+ let bytes = 0;
136
+ const digest = createHash("sha256");
137
+ const limiter = new Transform({
138
+ transform(chunk, _encoding, callback) {
139
+ bytes += chunk.length;
140
+ if (bytes > maxBytes)
141
+ return callback(new InstallerDownloadError("cap", `download exceeds ${maxBytes} bytes`));
142
+ digest.update(chunk);
143
+ callback(null, chunk);
107
144
  }
108
- return candidate;
109
- } catch {
145
+ });
146
+ const responseWithPipe = res;
147
+ if (typeof responseWithPipe.pipe !== "function") {
148
+ const output = createWriteStream(destination);
149
+ res.on("data", (chunk) => limiter.write(chunk));
150
+ res.on("error", fail);
151
+ res.on("end", () => limiter.end());
152
+ limiter.on("data", (chunk) => output.write(chunk));
153
+ limiter.on("end", () => output.end());
154
+ limiter.on("error", (error) => {
155
+ output.destroy();
156
+ fail(error);
157
+ });
158
+ output.on("error", fail);
159
+ output.on("finish", () => {
160
+ if (!settled) {
161
+ settled = true;
162
+ resolve({ bytes, sha256: digest.digest("hex") });
163
+ }
164
+ });
165
+ return;
110
166
  }
111
- }
112
- }
113
- return null;
167
+ pipeline(res, limiter, createWriteStream(destination)).then(() => {
168
+ if (!settled) {
169
+ settled = true;
170
+ resolve({ bytes, sha256: digest.digest("hex") });
171
+ }
172
+ }, (error) => fail(error instanceof InstallerDownloadError ? error : new InstallerDownloadError("stream", `download stream failed: ${error.message}`)));
173
+ });
174
+ request.setTimeout?.(TIMEOUT_MS, () => request.destroy(new InstallerDownloadError("timeout", `download timed out after ${TIMEOUT_MS}ms`)));
175
+ request.on("error", (error) => fail(error instanceof InstallerDownloadError ? error : new InstallerDownloadError("network", `download failed: ${error.message}`)));
176
+ });
114
177
  }
115
178
 
116
- // dist/clients/installer/index.js
117
- import { createGunzip } from "node:zlib";
118
-
119
179
  // dist/clients/durable-store.js
120
- import * as fs from "node:fs";
180
+ import * as fs2 from "node:fs";
121
181
  import fsp from "node:fs/promises";
122
- function readLocked(path5) {
182
+ function readLocked(path4) {
123
183
  try {
124
- return fs.readFileSync(path5, "utf8");
184
+ return fs2.readFileSync(path4, "utf8");
125
185
  } catch {
126
186
  return void 0;
127
187
  }
@@ -154,9 +214,9 @@ function commitDurableStore(options) {
154
214
  }
155
215
  return committed;
156
216
  }
157
- async function readLockedAsync(path5) {
217
+ async function readLockedAsync(path4) {
158
218
  try {
159
- return await fsp.readFile(path5, "utf8");
219
+ return await fsp.readFile(path4, "utf8");
160
220
  } catch (error) {
161
221
  if (error.code === "ENOENT")
162
222
  return void 0;
@@ -194,8 +254,8 @@ async function commitDurableStoreAsync(options) {
194
254
  }
195
255
 
196
256
  // dist/clients/sessionstart-logger.js
197
- import * as path2 from "node:path";
198
- var SESSIONSTART_LOG_FILE = path2.join(getGlobalPiLensLogDir(), "sessionstart.log");
257
+ import * as path from "node:path";
258
+ var SESSIONSTART_LOG_FILE = path.join(getGlobalPiLensLogDir(), "sessionstart.log");
199
259
  var writer = createNdjsonLogger({
200
260
  filePath: SESSIONSTART_LOG_FILE,
201
261
  maxBytes: getMaxLogSizeMB() * 1024 * 1024,
@@ -208,10 +268,10 @@ function logSessionStart(message) {
208
268
  }
209
269
 
210
270
  // dist/clients/zizmor-config.js
211
- import * as path3 from "node:path";
271
+ import * as path2 from "node:path";
212
272
  var LOCAL_ZIZMOR_CONFIG_NAMES = [
213
- path3.join(".github", "zizmor.yml"),
214
- path3.join(".github", "zizmor.yaml"),
273
+ path2.join(".github", "zizmor.yml"),
274
+ path2.join(".github", "zizmor.yaml"),
215
275
  "zizmor.yml",
216
276
  "zizmor.yaml"
217
277
  ];
@@ -220,7 +280,7 @@ function findLocalZizmorConfig(startDir) {
220
280
  }
221
281
  function isZizmorAuditTarget(filePath) {
222
282
  const normalized = toPosix(filePath);
223
- const base = path3.basename(normalized).toLowerCase();
283
+ const base = path2.basename(normalized).toLowerCase();
224
284
  if (/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/i.test(normalized))
225
285
  return true;
226
286
  if (base === "action.yml" || base === "action.yaml")
@@ -366,10 +426,10 @@ async function resolveGitHubToken(envKeys = ["GITHUB_TOKEN", "GH_TOKEN"], option
366
426
 
367
427
  // dist/clients/installer/index.js
368
428
  var _installerRequire = createRequire(import.meta.url);
369
- var TOOLS_DIR = path4.join(getGlobalPiLensDir(), "tools");
429
+ var TOOLS_DIR = path3.join(getGlobalPiLensDir(), "tools");
370
430
  var USER_BASE_PROBE_TIMEOUT_MS = 5e3;
371
431
  var ARCHIVE_COMMAND_TIMEOUT_MS = 12e4;
372
- var INSTALL_LOCK_PATH = path4.join(TOOLS_DIR, ".install.lock");
432
+ var INSTALL_LOCK_PATH = path3.join(TOOLS_DIR, ".install.lock");
373
433
  var INSTALL_LOCK_GENERATIONS = `${INSTALL_LOCK_PATH}s`;
374
434
  var activeInstallLocks = /* @__PURE__ */ new Set();
375
435
  var installLockExitCleanupRegistered = false;
@@ -386,7 +446,7 @@ function legacyInstallLockIsStale(maxAgeMs) {
386
446
  return expired || Number.isInteger(owner.pid) && owner.pid > 0 && !realIsPidAlive(owner.pid);
387
447
  } catch {
388
448
  try {
389
- return Date.now() - statSync2(INSTALL_LOCK_PATH).mtimeMs > maxAgeMs;
449
+ return Date.now() - statSync(INSTALL_LOCK_PATH).mtimeMs > maxAgeMs;
390
450
  } catch {
391
451
  return false;
392
452
  }
@@ -496,7 +556,7 @@ async function acquireInstallLock() {
496
556
  };
497
557
  }
498
558
  var GLOBAL_HOME_DIR = getGlobalPiLensDir();
499
- var GITHUB_BIN_DIR = path4.join(GLOBAL_HOME_DIR, "bin");
559
+ var GITHUB_BIN_DIR = path3.join(GLOBAL_HOME_DIR, "bin");
500
560
  var GITHUB_BIN_DIR_PINNED = Boolean(process.env.PI_LENS_HOME?.trim());
501
561
  function assertManagedBinDirInsidePinnedHome(toolId) {
502
562
  if (!GITHUB_BIN_DIR_PINNED)
@@ -578,6 +638,7 @@ function managedGitHubFormatterTool(spec) {
578
638
  checkCommand: spec.id,
579
639
  checkArgs: ["--version"],
580
640
  installStrategy: "github",
641
+ ...spec.autoInstall && { autoInstall: true },
581
642
  binaryName: spec.id,
582
643
  github: {
583
644
  repo: `${spec.owner}/${spec.repo}`,
@@ -592,6 +653,7 @@ var MANAGED_GITHUB_FORMATTERS = [
592
653
  {
593
654
  id: "typstyle",
594
655
  name: "typstyle",
656
+ autoInstall: true,
595
657
  owner: "typstyle-rs",
596
658
  repo: "typstyle",
597
659
  assetPattern: archAssetMatch({
@@ -679,6 +741,8 @@ var TOOLS = [
679
741
  // Core LSP servers
680
742
  {
681
743
  id: "typescript-language-server",
744
+ // Preinstalled at session start for a TypeScript project, as before (#5410 D9).
745
+ autoInstall: true,
682
746
  name: "TypeScript Language Server",
683
747
  checkCommand: "typescript-language-server",
684
748
  checkArgs: ["--version"],
@@ -706,6 +770,7 @@ var TOOLS = [
706
770
  },
707
771
  {
708
772
  id: "pyright",
773
+ autoInstall: true,
709
774
  name: "Pyright",
710
775
  checkCommand: "pyright",
711
776
  checkArgs: ["--version"],
@@ -716,6 +781,7 @@ var TOOLS = [
716
781
  // Linting/formatting tools
717
782
  {
718
783
  id: "prettier",
784
+ autoInstall: true,
719
785
  name: "Prettier",
720
786
  checkCommand: "prettier",
721
787
  checkArgs: ["--version"],
@@ -726,6 +792,7 @@ var TOOLS = [
726
792
  ...MANAGED_PACKAGE_FORMATTERS.map(managedPackageFormatterTool),
727
793
  {
728
794
  id: "ruff",
795
+ autoInstall: true,
729
796
  name: "Ruff",
730
797
  checkCommand: "ruff",
731
798
  checkArgs: ["--version"],
@@ -746,6 +813,7 @@ var TOOLS = [
746
813
  },
747
814
  {
748
815
  id: "biome",
816
+ autoInstall: true,
749
817
  name: "Biome",
750
818
  checkCommand: "biome",
751
819
  checkArgs: ["--version"],
@@ -768,6 +836,7 @@ var TOOLS = [
768
836
  // Analysis tools (run at session start / turn end)
769
837
  {
770
838
  id: "madge",
839
+ autoInstall: true,
771
840
  name: "Madge",
772
841
  checkCommand: "madge",
773
842
  checkArgs: ["--version"],
@@ -777,17 +846,19 @@ var TOOLS = [
777
846
  },
778
847
  {
779
848
  id: "jscpd",
849
+ autoInstall: true,
780
850
  name: "jscpd",
781
851
  checkCommand: "jscpd",
782
852
  checkArgs: ["--version"],
783
853
  installStrategy: "npm",
784
- packageName: "jscpd@5.4.2",
785
- // v5.4.2 is the repository's exact devDependency; the v4 packaging defect that required the older v5.0.12 pin is gone, and parseReport() reads the unchanged clone-report fields.
854
+ packageName: "jscpd@5.4.3",
855
+ // v5.4.3 is the repository's exact devDependency; the v4 packaging defect that required the older v5.0.12 pin is gone, and parseReport() reads the unchanged clone-report fields.
786
856
  binaryName: "jscpd"
787
857
  },
788
858
  // Structural search and dead code detection
789
859
  {
790
860
  id: "ast-grep",
861
+ autoInstall: true,
791
862
  name: "ast-grep CLI",
792
863
  checkCommand: "ast-grep",
793
864
  checkArgs: ["--version"],
@@ -809,6 +880,7 @@ var TOOLS = [
809
880
  },
810
881
  {
811
882
  id: "knip",
883
+ autoInstall: true,
812
884
  name: "Knip",
813
885
  checkCommand: "knip",
814
886
  checkArgs: ["--version"],
@@ -818,6 +890,7 @@ var TOOLS = [
818
890
  },
819
891
  {
820
892
  id: "yamllint",
893
+ autoInstall: true,
821
894
  name: "yamllint",
822
895
  checkCommand: "yamllint",
823
896
  checkArgs: ["--version"],
@@ -827,6 +900,7 @@ var TOOLS = [
827
900
  },
828
901
  {
829
902
  id: "sqlfluff",
903
+ autoInstall: true,
830
904
  name: "sqlfluff",
831
905
  checkCommand: "sqlfluff",
832
906
  checkArgs: ["--version"],
@@ -910,6 +984,7 @@ var TOOLS = [
910
984
  },
911
985
  {
912
986
  id: "htmlhint",
987
+ autoInstall: true,
913
988
  name: "HTMLHint",
914
989
  checkCommand: "htmlhint",
915
990
  checkArgs: ["--version"],
@@ -919,6 +994,7 @@ var TOOLS = [
919
994
  },
920
995
  {
921
996
  id: "hadolint",
997
+ autoInstall: true,
922
998
  name: "Hadolint",
923
999
  checkCommand: "hadolint",
924
1000
  checkArgs: ["--version"],
@@ -928,7 +1004,7 @@ var TOOLS = [
928
1004
  repo: "hadolint/hadolint",
929
1005
  assetMatch: (platform, arch) => {
930
1006
  if (platform === "linux")
931
- return arch === "arm64" ? "linux.aarch64" : "linux.x86_64";
1007
+ return arch === "arm64" ? "linux-arm64" : "linux-x86_64";
932
1008
  if (platform === "darwin")
933
1009
  return arch === "arm64" ? "macos-arm64" : "macos-x86_64";
934
1010
  if (platform === "win32")
@@ -939,6 +1015,7 @@ var TOOLS = [
939
1015
  },
940
1016
  {
941
1017
  id: "helm",
1018
+ autoInstall: true,
942
1019
  name: "Helm",
943
1020
  checkCommand: "helm",
944
1021
  // Probed against helm 4.3.0: `--version` exits 1 ("unknown flag"), `version --short` exits 0.
@@ -947,6 +1024,15 @@ var TOOLS = [
947
1024
  binaryName: "helm",
948
1025
  github: {
949
1026
  repo: "helm/helm",
1027
+ // The GitHub release holds only `.asc` signatures (#5643); the
1028
+ // archives are served from get.helm.sh under the same names.
1029
+ derivedAsset: (tagName, assetSubstring) => {
1030
+ const name = `helm-${tagName}-${assetSubstring}`;
1031
+ return {
1032
+ name,
1033
+ browser_download_url: `https://get.helm.sh/${name}`
1034
+ };
1035
+ },
950
1036
  assetMatch: (platform, arch) => {
951
1037
  const cpu = arch === "arm64" ? "arm64" : "amd64";
952
1038
  if (platform === "linux")
@@ -966,6 +1052,7 @@ var TOOLS = [
966
1052
  // Opengrep: a single standalone binary per platform on GitHub releases —
967
1053
  // no login, no telemetry (the reason for switching off Semgrep, #111).
968
1054
  id: "opengrep",
1055
+ autoInstall: true,
969
1056
  name: "Opengrep",
970
1057
  checkCommand: "opengrep",
971
1058
  checkArgs: ["--version"],
@@ -975,13 +1062,14 @@ var TOOLS = [
975
1062
  repo: "opengrep/opengrep",
976
1063
  assetMatch: (platform, arch) => {
977
1064
  if (platform === "linux")
978
- return arch === "arm64" ? "opengrep_manylinux_aarch64" : "opengrep_manylinux_x86";
1065
+ return arch === "arm64" ? "opengrep_linux_aarch64" : "opengrep_linux_x86";
979
1066
  if (platform === "darwin")
980
1067
  return arch === "arm64" ? "opengrep_osx_arm64" : "opengrep_osx_x86";
981
1068
  if (platform === "win32")
982
- return "opengrep_windows_x86.exe";
1069
+ return "opengrep_windows_x86.zip";
983
1070
  return void 0;
984
- }
1071
+ },
1072
+ bundleArchiveDlls: true
985
1073
  }
986
1074
  },
987
1075
  {
@@ -1070,6 +1158,7 @@ var TOOLS = [
1070
1158
  },
1071
1159
  {
1072
1160
  id: "markdownlint",
1161
+ autoInstall: true,
1073
1162
  name: "markdownlint-cli2",
1074
1163
  checkCommand: "markdownlint-cli2",
1075
1164
  // `--version` is interpreted as a file glob by markdownlint-cli2. Use
@@ -1081,6 +1170,7 @@ var TOOLS = [
1081
1170
  },
1082
1171
  {
1083
1172
  id: "mypy",
1173
+ autoInstall: true,
1084
1174
  name: "mypy",
1085
1175
  checkCommand: "mypy",
1086
1176
  checkArgs: ["--version"],
@@ -1099,6 +1189,7 @@ var TOOLS = [
1099
1189
  },
1100
1190
  {
1101
1191
  id: "stylelint",
1192
+ autoInstall: true,
1102
1193
  name: "Stylelint",
1103
1194
  checkCommand: "stylelint",
1104
1195
  checkArgs: ["--version"],
@@ -1108,6 +1199,7 @@ var TOOLS = [
1108
1199
  },
1109
1200
  {
1110
1201
  id: "oxlint",
1202
+ autoInstall: true,
1111
1203
  name: "Oxlint",
1112
1204
  checkCommand: "oxlint",
1113
1205
  checkArgs: ["--version"],
@@ -1118,6 +1210,7 @@ var TOOLS = [
1118
1210
  // GitHub release binaries
1119
1211
  {
1120
1212
  id: "shellcheck",
1213
+ autoInstall: true,
1121
1214
  name: "ShellCheck",
1122
1215
  checkCommand: "shellcheck",
1123
1216
  checkArgs: ["--version"],
@@ -1139,6 +1232,7 @@ var TOOLS = [
1139
1232
  },
1140
1233
  {
1141
1234
  id: "shfmt",
1235
+ autoInstall: true,
1142
1236
  name: "shfmt",
1143
1237
  checkCommand: "shfmt",
1144
1238
  checkArgs: ["--version"],
@@ -1152,7 +1246,7 @@ var TOOLS = [
1152
1246
  if (platform === "darwin")
1153
1247
  return arch === "arm64" ? "darwin_arm64" : "darwin_amd64";
1154
1248
  if (platform === "win32")
1155
- return arch === "arm64" ? "windows_arm64.exe" : "windows_amd64.exe";
1249
+ return "windows_amd64.exe";
1156
1250
  return void 0;
1157
1251
  }
1158
1252
  // bare binary, no archive
@@ -1207,6 +1301,7 @@ var TOOLS = [
1207
1301
  },
1208
1302
  {
1209
1303
  id: "golangci-lint",
1304
+ autoInstall: true,
1210
1305
  name: "golangci-lint",
1211
1306
  checkCommand: "golangci-lint",
1212
1307
  checkArgs: ["--version"],
@@ -1228,6 +1323,7 @@ var TOOLS = [
1228
1323
  },
1229
1324
  {
1230
1325
  id: "ktlint",
1326
+ autoInstall: true,
1231
1327
  name: "ktlint",
1232
1328
  checkCommand: "ktlint",
1233
1329
  checkArgs: ["--version"],
@@ -1256,6 +1352,7 @@ var TOOLS = [
1256
1352
  // fat JAR — no native binary, no npm package — so it uses the maven strategy
1257
1353
  // (#129). Run via a `java -jar` launcher; requires a JRE.
1258
1354
  id: "ktfmt",
1355
+ autoInstall: true,
1259
1356
  name: "ktfmt",
1260
1357
  checkCommand: "ktfmt",
1261
1358
  checkArgs: ["--version"],
@@ -1274,6 +1371,7 @@ var TOOLS = [
1274
1371
  // NOT a runnable fat JAR — so it uses the archive strategy, not maven
1275
1372
  // (refs #133). Requires a JRE (gated by the runner, not the install).
1276
1373
  id: "spotbugs",
1374
+ autoInstall: true,
1277
1375
  name: "SpotBugs",
1278
1376
  checkCommand: "spotbugs",
1279
1377
  // Probed against spotbugs 4.10.2 (JRE 21): `--version` exits 1 ("Unknown option"), `-version` prints 4.10.2.
@@ -1430,6 +1528,7 @@ var TOOLS = [
1430
1528
  },
1431
1529
  {
1432
1530
  id: "actionlint",
1531
+ autoInstall: true,
1433
1532
  name: "actionlint",
1434
1533
  checkCommand: "actionlint",
1435
1534
  checkArgs: ["--version"],
@@ -1552,6 +1651,7 @@ var TOOLS = [
1552
1651
  },
1553
1652
  {
1554
1653
  id: "tflint",
1654
+ autoInstall: true,
1555
1655
  name: "tflint",
1556
1656
  checkCommand: "tflint",
1557
1657
  checkArgs: ["--version"],
@@ -1559,7 +1659,11 @@ var TOOLS = [
1559
1659
  binaryName: "tflint",
1560
1660
  github: {
1561
1661
  repo: "terraform-linters/tflint",
1562
- assetMatch: archAssetMatch(OS_ARCH_ZIP_ASSETS),
1662
+ // No windows_arm64 build upstream (#5624): x64 via emulation.
1663
+ assetMatch: archAssetMatch({
1664
+ ...OS_ARCH_ZIP_ASSETS,
1665
+ win32: { x64: "windows_amd64.zip", arm64: "windows_amd64.zip" }
1666
+ }),
1563
1667
  binaryInArchive: "tflint"
1564
1668
  }
1565
1669
  },
@@ -1568,6 +1672,7 @@ var TOOLS = [
1568
1672
  // Windows arm64 uses the x64 binary through Windows' built-in emulation —
1569
1673
  // there is no terragrunt_windows_arm64.exe upstream.
1570
1674
  id: "terragrunt",
1675
+ autoInstall: true,
1571
1676
  name: "terragrunt",
1572
1677
  checkCommand: "terragrunt",
1573
1678
  checkArgs: ["--version"],
@@ -1615,6 +1720,7 @@ var TOOLS = [
1615
1720
  },
1616
1721
  {
1617
1722
  id: "trivy",
1723
+ autoInstall: true,
1618
1724
  name: "Trivy",
1619
1725
  checkCommand: "trivy",
1620
1726
  checkArgs: ["--version"],
@@ -1638,6 +1744,7 @@ var TOOLS = [
1638
1744
  },
1639
1745
  {
1640
1746
  id: "swiftlint",
1747
+ autoInstall: true,
1641
1748
  name: "SwiftLint",
1642
1749
  checkCommand: "swiftlint",
1643
1750
  checkArgs: ["--version"],
@@ -1657,6 +1764,7 @@ var TOOLS = [
1657
1764
  },
1658
1765
  {
1659
1766
  id: "taplo",
1767
+ autoInstall: true,
1660
1768
  name: "taplo",
1661
1769
  checkCommand: "taplo",
1662
1770
  checkArgs: ["--version"],
@@ -1685,13 +1793,12 @@ var TOOLS = [
1685
1793
  github: {
1686
1794
  repo: "vale-cli/vale",
1687
1795
  assetMatch: (platform, arch) => {
1688
- const version = "3.14.2";
1689
1796
  if (platform === "linux")
1690
- return arch === "arm64" ? `vale_${version}_Linux_arm64.tar.gz` : `vale_${version}_Linux_64-bit.tar.gz`;
1797
+ return arch === "arm64" ? "_Linux_arm64.tar.gz" : "_Linux_64-bit.tar.gz";
1691
1798
  if (platform === "darwin")
1692
- return arch === "arm64" ? `vale_${version}_macOS_arm64.tar.gz` : `vale_${version}_macOS_64-bit.tar.gz`;
1799
+ return arch === "arm64" ? "_macOS_arm64.tar.gz" : "_macOS_64-bit.tar.gz";
1693
1800
  if (platform === "win32")
1694
- return `vale_${version}_Windows_64-bit.zip`;
1801
+ return "_Windows_64-bit.zip";
1695
1802
  return void 0;
1696
1803
  },
1697
1804
  binaryInArchive: "vale"
@@ -1707,7 +1814,16 @@ var TOOLS = [
1707
1814
  binaryName: "terraform-ls",
1708
1815
  github: {
1709
1816
  repo: "hashicorp/terraform-ls",
1710
- hashiCorpReleaseProduct: "terraform-ls",
1817
+ derivedAsset: (tagName, assetSubstring) => {
1818
+ const version = tagName.replace(/^v/, "").trim();
1819
+ if (!version)
1820
+ return void 0;
1821
+ const name = `terraform-ls_${version}_${assetSubstring}`;
1822
+ return {
1823
+ name,
1824
+ browser_download_url: `https://releases.hashicorp.com/terraform-ls/${version}/${name}`
1825
+ };
1826
+ },
1711
1827
  assetMatch: archAssetMatch(OS_ARCH_ZIP_ASSETS),
1712
1828
  binaryInArchive: "terraform-ls"
1713
1829
  }
@@ -1916,7 +2032,7 @@ var resolvedPathCache = new BoundedLruCache(256);
1916
2032
  function resetResolvedPathCache() {
1917
2033
  resolvedPathCache.clear();
1918
2034
  }
1919
- var PROBE_CACHE_PATH = path4.join(getGlobalPiLensDir(), "probe-cache.json");
2035
+ var PROBE_CACHE_PATH = path3.join(getGlobalPiLensDir(), "probe-cache.json");
1920
2036
  var PROBE_CACHE_LOCK_STALE_MS = 18e4;
1921
2037
  var PROBE_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
1922
2038
  var PROBE_CACHE_TRANSIENT_COOLDOWN_MS = TRANSIENT_MAX_COOLDOWN_MS;
@@ -1931,11 +2047,12 @@ var _probeCacheRetryAttempt = 0;
1931
2047
  var _probeCacheChangeGeneration = 0;
1932
2048
  var _probeCacheChanges = /* @__PURE__ */ new Map();
1933
2049
  var _probeCacheChangeVersions = /* @__PURE__ */ new Map();
2050
+ var _probeCacheUpdatesPending = /* @__PURE__ */ new Set();
1934
2051
  async function readProbeCache() {
1935
2052
  if (_probeCache !== null)
1936
2053
  return _probeCache;
1937
2054
  try {
1938
- const raw = await fs2.readFile(PROBE_CACHE_PATH, "utf-8");
2055
+ const raw = await fs3.readFile(PROBE_CACHE_PATH, "utf-8");
1939
2056
  const parsed = JSON.parse(raw);
1940
2057
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1941
2058
  throw new Error("probe-cache root is not an object");
@@ -2083,6 +2200,7 @@ async function flushProbeCache() {
2083
2200
  }
2084
2201
  }
2085
2202
  async function settleProbeCacheForTests() {
2203
+ await Promise.allSettled(_probeCacheUpdatesPending);
2086
2204
  const result = await flushProbeCache();
2087
2205
  if (result === "idle" || result === "written")
2088
2206
  return void 0;
@@ -2115,8 +2233,8 @@ async function checkProbeCache(toolId) {
2115
2233
  return void 0;
2116
2234
  }
2117
2235
  try {
2118
- await fs2.access(entry.path);
2119
- const stat = await fs2.stat(entry.path);
2236
+ await fs3.access(entry.path);
2237
+ const stat = await fs3.stat(entry.path);
2120
2238
  if (stat.mtimeMs !== entry.mtimeMs || entry.sizeBytes !== void 0 && stat.size !== entry.sizeBytes) {
2121
2239
  logSessionStart(`auto-install probe-cache ${toolId}: miss (mtime/size changed)`);
2122
2240
  delete cache[toolId];
@@ -2137,27 +2255,34 @@ async function checkProbeCache(toolId) {
2137
2255
  return void 0;
2138
2256
  }
2139
2257
  }
2140
- async function updateProbeCache(toolId, resolvedPath, transient = false) {
2141
- try {
2142
- const stat = await fs2.stat(resolvedPath);
2143
- const cache = await readProbeCache();
2144
- const entry = {
2145
- path: resolvedPath,
2146
- mtimeMs: stat.mtimeMs,
2147
- sizeBytes: stat.size,
2148
- cachedAt: Date.now(),
2149
- ...transient && { transient: true }
2150
- };
2151
- cache[toolId] = entry;
2152
- markProbeCacheChange(toolId, entry);
2153
- } catch {
2154
- }
2258
+ function updateProbeCache(toolId, resolvedPath, transient = false) {
2259
+ const pending = (async () => {
2260
+ try {
2261
+ const stat = await fs3.stat(resolvedPath);
2262
+ const cache = await readProbeCache();
2263
+ const entry = {
2264
+ path: resolvedPath,
2265
+ mtimeMs: stat.mtimeMs,
2266
+ sizeBytes: stat.size,
2267
+ cachedAt: Date.now(),
2268
+ ...transient && { transient: true }
2269
+ };
2270
+ cache[toolId] = entry;
2271
+ markProbeCacheChange(toolId, entry);
2272
+ } catch {
2273
+ }
2274
+ })();
2275
+ _probeCacheUpdatesPending.add(pending);
2276
+ void pending.finally(() => _probeCacheUpdatesPending.delete(pending));
2277
+ return pending;
2155
2278
  }
2156
2279
  function resetProbeCacheStateForTesting() {
2280
+ const unsettled = _probeCacheUpdatesPending.size;
2157
2281
  _probeCache = null;
2158
2282
  _probeCacheDirty = false;
2159
2283
  _probeCacheChanges.clear();
2160
2284
  _probeCacheChangeVersions.clear();
2285
+ _probeCacheUpdatesPending.clear();
2161
2286
  _probeCacheChangeGeneration = 0;
2162
2287
  _probeCacheRetryAttempt = 0;
2163
2288
  resetResolvedPathCache();
@@ -2172,6 +2297,7 @@ function resetProbeCacheStateForTesting() {
2172
2297
  clearTimeout(_probeCacheFlushTimer);
2173
2298
  _probeCacheFlushTimer = null;
2174
2299
  }
2300
+ return unsettled;
2175
2301
  }
2176
2302
  function _peekEnsureInFlightForTesting() {
2177
2303
  return ensureInFlight;
@@ -2195,7 +2321,7 @@ async function isSpawnableCommand(command) {
2195
2321
  const namesPath = installerPlatform() === "win32" ? /[\\/]/.test(command) : command.includes("/");
2196
2322
  if (namesPath) {
2197
2323
  try {
2198
- const stat = statSync2(command);
2324
+ const stat = statSync(command);
2199
2325
  return stat.isFile() && stat.size > 0;
2200
2326
  } catch {
2201
2327
  return false;
@@ -2226,17 +2352,17 @@ function packageEntryVerification(tool) {
2226
2352
  return tool.verification === "package-entry" ? tool.packageName : void 0;
2227
2353
  }
2228
2354
  async function verifyNpmPackageEntry(binPath, packageName) {
2229
- const nodeModulesDir = path4.dirname(path4.dirname(binPath));
2355
+ const nodeModulesDir = path3.dirname(path3.dirname(binPath));
2230
2356
  const pinned = parsePinnedVersion(packageName);
2231
2357
  const bareName = pinned ? packageName.slice(0, -(pinned.length + 1)) : packageName;
2232
- const packageDir = path4.join(nodeModulesDir, ...bareName.split("/"));
2233
- const shimName = path4.basename(binPath).replace(/\.(cmd|exe|ps1|bat)$/i, "").toLowerCase();
2358
+ const packageDir = path3.join(nodeModulesDir, ...bareName.split("/"));
2359
+ const shimName = path3.basename(binPath).replace(/\.(cmd|exe|ps1|bat)$/i, "").toLowerCase();
2234
2360
  const fail = (reason) => {
2235
2361
  logSessionStart(`auto-install verify: failed for ${binPath} (check=package-entry, kind=${reason})`);
2236
2362
  return false;
2237
2363
  };
2238
2364
  try {
2239
- const shim = statSync2(binPath);
2365
+ const shim = statSync(binPath);
2240
2366
  if (!shim.isFile() || shim.size === 0)
2241
2367
  return fail("shim-not-a-file");
2242
2368
  } catch {
@@ -2244,7 +2370,7 @@ async function verifyNpmPackageEntry(binPath, packageName) {
2244
2370
  }
2245
2371
  let manifest;
2246
2372
  try {
2247
- manifest = JSON.parse(await fs2.readFile(path4.join(packageDir, "package.json"), "utf8"));
2373
+ manifest = JSON.parse(await fs3.readFile(path3.join(packageDir, "package.json"), "utf8"));
2248
2374
  } catch {
2249
2375
  return fail("package-json-unreadable");
2250
2376
  }
@@ -2262,7 +2388,7 @@ async function verifyNpmPackageEntry(binPath, packageName) {
2262
2388
  return fail("package-json-no-entry");
2263
2389
  }
2264
2390
  try {
2265
- const stat = statSync2(path4.join(packageDir, entry));
2391
+ const stat = statSync(path3.join(packageDir, entry));
2266
2392
  if (!stat.isFile() || stat.size === 0)
2267
2393
  return fail("entry-not-a-file");
2268
2394
  } catch {
@@ -2399,10 +2525,10 @@ async function getAllToolStatuses(toolIds) {
2399
2525
  continue;
2400
2526
  }
2401
2527
  }
2402
- const localBase = path4.join(TOOLS_DIR, "node_modules", ".bin", tool.binaryName || tool.id);
2528
+ const localBase = path3.join(TOOLS_DIR, "node_modules", ".bin", tool.binaryName || tool.id);
2403
2529
  const localPath = installerPlatform() === "win32" ? `${localBase}.cmd` : localBase;
2404
2530
  try {
2405
- await fs2.access(localPath);
2531
+ await fs3.access(localPath);
2406
2532
  if (await verifyToolBinary(localPath, void 0, void 0, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2407
2533
  status.installed = true;
2408
2534
  status.source = "pi-lens-auto";
@@ -2426,11 +2552,11 @@ async function getArchiveTreeBundlePath(tool) {
2426
2552
  if (tool.installStrategy !== "archive" || tool.archive?.launcher) {
2427
2553
  return void 0;
2428
2554
  }
2429
- const extractDir = path4.join(TOOLS_DIR, tool.id);
2555
+ const extractDir = path3.join(TOOLS_DIR, tool.id);
2430
2556
  const treeMarker = tool.archive && resolveTreeMarker(tool.archive);
2431
- const marker = treeMarker ? path4.join(extractDir, ...treeMarker.split("/")) : extractDir;
2557
+ const marker = treeMarker ? path3.join(extractDir, ...treeMarker.split("/")) : extractDir;
2432
2558
  try {
2433
- await fs2.access(marker);
2559
+ await fs3.access(marker);
2434
2560
  return extractDir;
2435
2561
  } catch {
2436
2562
  return void 0;
@@ -2449,14 +2575,14 @@ function resolvePlatformPackageBinary(tool) {
2449
2575
  const fromMain = createRequire(mainPkgJson);
2450
2576
  let pkgDir;
2451
2577
  try {
2452
- pkgDir = path4.dirname(fromMain.resolve(`${platformPkg}/package.json`));
2578
+ pkgDir = path3.dirname(fromMain.resolve(`${platformPkg}/package.json`));
2453
2579
  } catch {
2454
- pkgDir = path4.dirname(_installerRequire.resolve(`${platformPkg}/package.json`));
2580
+ pkgDir = path3.dirname(_installerRequire.resolve(`${platformPkg}/package.json`));
2455
2581
  }
2456
2582
  const isWin = installerPlatform() === "win32";
2457
2583
  for (const bin of spec.binaries) {
2458
2584
  for (const name of isWin ? [`${bin}.exe`, bin] : [bin]) {
2459
- const candidate = path4.join(pkgDir, name);
2585
+ const candidate = path3.join(pkgDir, name);
2460
2586
  if (existsSync(candidate))
2461
2587
  return candidate;
2462
2588
  }
@@ -2494,11 +2620,11 @@ async function getToolPathResolved(toolId, onTransient, storeOnly) {
2494
2620
  if (seen)
2495
2621
  lastManagedInstallVersion.set(toolId, seen);
2496
2622
  } : void 0;
2497
- const localBase = path4.join(TOOLS_DIR, "node_modules", ".bin", tool.binaryName || tool.id);
2623
+ const localBase = path3.join(TOOLS_DIR, "node_modules", ".bin", tool.binaryName || tool.id);
2498
2624
  if (installerPlatform() === "win32") {
2499
2625
  const cmdPath = `${localBase}.cmd`;
2500
2626
  try {
2501
- await fs2.access(cmdPath);
2627
+ await fs3.access(cmdPath);
2502
2628
  if (await verifyToolBinary(cmdPath, recordVersion, onTransient, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2503
2629
  return cmdPath;
2504
2630
  }
@@ -2507,7 +2633,7 @@ async function getToolPathResolved(toolId, onTransient, storeOnly) {
2507
2633
  }
2508
2634
  const exePath = `${localBase}.exe`;
2509
2635
  try {
2510
- await fs2.access(exePath);
2636
+ await fs3.access(exePath);
2511
2637
  if (await verifyToolBinary(exePath, recordVersion, onTransient, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2512
2638
  return exePath;
2513
2639
  }
@@ -2517,7 +2643,7 @@ async function getToolPathResolved(toolId, onTransient, storeOnly) {
2517
2643
  }
2518
2644
  if (installerPlatform() !== "win32") {
2519
2645
  try {
2520
- await fs2.access(localBase);
2646
+ await fs3.access(localBase);
2521
2647
  if (await verifyToolBinary(localBase, recordVersion, onTransient, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2522
2648
  return localBase;
2523
2649
  }
@@ -2579,14 +2705,14 @@ async function getToolPathResolved(toolId, onTransient, storeOnly) {
2579
2705
  async function findGitHubToolPath(binaryName) {
2580
2706
  const isWindows = process.platform === "win32";
2581
2707
  const candidates = isWindows ? [
2582
- path4.join(GITHUB_BIN_DIR, `${binaryName}.exe`),
2583
- path4.join(GITHUB_BIN_DIR, `${binaryName}.bat`),
2584
- path4.join(GITHUB_BIN_DIR, `${binaryName}.cmd`),
2585
- path4.join(GITHUB_BIN_DIR, binaryName)
2586
- ] : [path4.join(GITHUB_BIN_DIR, binaryName)];
2708
+ path3.join(GITHUB_BIN_DIR, `${binaryName}.exe`),
2709
+ path3.join(GITHUB_BIN_DIR, `${binaryName}.bat`),
2710
+ path3.join(GITHUB_BIN_DIR, `${binaryName}.cmd`),
2711
+ path3.join(GITHUB_BIN_DIR, binaryName)
2712
+ ] : [path3.join(GITHUB_BIN_DIR, binaryName)];
2587
2713
  for (const candidate of candidates) {
2588
2714
  try {
2589
- await fs2.access(candidate);
2715
+ await fs3.access(candidate);
2590
2716
  return candidate;
2591
2717
  } catch {
2592
2718
  }
@@ -2642,7 +2768,7 @@ function getArchiveBinaryCandidates(binaryName, platform, assetName) {
2642
2768
  async function firstVerifiedBinary(candidates, onTransient, verificationArgs, verificationTimeoutMs) {
2643
2769
  for (const candidate of candidates) {
2644
2770
  try {
2645
- await fs2.access(candidate);
2771
+ await fs3.access(candidate);
2646
2772
  if (isUntrustedProjectPath(candidate)) {
2647
2773
  recordProjectCommandRefusal(candidate);
2648
2774
  continue;
@@ -2660,9 +2786,9 @@ async function findNpmGlobalToolPath(binaryName, onTransient, verificationArgs =
2660
2786
  const binDirs = await getNpmGlobalBinCandidates(onTransient);
2661
2787
  for (const dir of binDirs) {
2662
2788
  const candidates = isWindows ? [
2663
- path4.join(dir, `${binaryName}.cmd`),
2664
- path4.join(dir, `${binaryName}.exe`)
2665
- ] : [path4.join(dir, binaryName)];
2789
+ path3.join(dir, `${binaryName}.cmd`),
2790
+ path3.join(dir, `${binaryName}.exe`)
2791
+ ] : [path3.join(dir, binaryName)];
2666
2792
  const verified = await firstVerifiedBinary(candidates, onTransient, verificationArgs, verificationTimeoutMs);
2667
2793
  if (verified)
2668
2794
  return verified;
@@ -2675,7 +2801,7 @@ async function getNpmGlobalBinCandidates(onTransient) {
2675
2801
  const add = (value) => {
2676
2802
  if (!value)
2677
2803
  return;
2678
- const normalized = path4.resolve(value.trim());
2804
+ const normalized = path3.resolve(value.trim());
2679
2805
  if (!normalized)
2680
2806
  return;
2681
2807
  if (seen.has(normalized))
@@ -2684,9 +2810,9 @@ async function getNpmGlobalBinCandidates(onTransient) {
2684
2810
  dirs.push(normalized);
2685
2811
  };
2686
2812
  if (process.platform === "win32") {
2687
- add(path4.join(process.env.APPDATA || "", "npm"));
2813
+ add(path3.join(process.env.APPDATA || "", "npm"));
2688
2814
  } else {
2689
- add(path4.join(os.homedir(), ".npm-global", "bin"));
2815
+ add(path3.join(os.homedir(), ".npm-global", "bin"));
2690
2816
  }
2691
2817
  for (const dir of await allAvailableGlobalBinDirs(onTransient)) {
2692
2818
  add(dir);
@@ -2696,31 +2822,31 @@ async function getNpmGlobalBinCandidates(onTransient) {
2696
2822
  async function findPipUserToolPath(binaryName, onTransient, verificationArgs = ["--version"], verificationTimeoutMs = 1e4, piLensPrefixesOnly = false) {
2697
2823
  const isWindows = installerPlatform() === "win32";
2698
2824
  const userBaseCandidates = [
2699
- path4.join(getGlobalPiLensDir(), "pip-tools"),
2700
- path4.join(getGlobalPiLensDir(), "pip-user"),
2825
+ path3.join(getGlobalPiLensDir(), "pip-tools"),
2826
+ path3.join(getGlobalPiLensDir(), "pip-user"),
2701
2827
  ...piLensPrefixesOnly ? [] : await getPythonUserBaseCandidates()
2702
2828
  ];
2703
2829
  for (const userBase of userBaseCandidates) {
2704
2830
  const scriptDirs = [pipScriptsDir(userBase, installerPlatform())];
2705
2831
  if (isWindows) {
2706
2832
  try {
2707
- const children = await fs2.readdir(userBase, { withFileTypes: true });
2833
+ const children = await fs3.readdir(userBase, { withFileTypes: true });
2708
2834
  for (const entry of children) {
2709
2835
  if (!entry.isDirectory())
2710
2836
  continue;
2711
2837
  if (!/^python\d+$/i.test(entry.name))
2712
2838
  continue;
2713
- scriptDirs.push(path4.join(userBase, entry.name, "Scripts"));
2839
+ scriptDirs.push(path3.join(userBase, entry.name, "Scripts"));
2714
2840
  }
2715
2841
  } catch {
2716
2842
  }
2717
2843
  }
2718
2844
  for (const dir of scriptDirs) {
2719
2845
  const candidates = isWindows ? [
2720
- path4.join(dir, `${binaryName}.exe`),
2721
- path4.join(dir, `${binaryName}.cmd`),
2722
- path4.join(dir, binaryName)
2723
- ] : [path4.join(dir, binaryName)];
2846
+ path3.join(dir, `${binaryName}.exe`),
2847
+ path3.join(dir, `${binaryName}.cmd`),
2848
+ path3.join(dir, binaryName)
2849
+ ] : [path3.join(dir, binaryName)];
2724
2850
  const verified = await firstVerifiedBinary(candidates, onTransient, verificationArgs, verificationTimeoutMs);
2725
2851
  if (verified)
2726
2852
  return verified;
@@ -2756,7 +2882,7 @@ async function getPythonUserBaseCandidates() {
2756
2882
  candidates.push(normalized);
2757
2883
  };
2758
2884
  if (process.platform === "win32") {
2759
- add(path4.join(process.env.APPDATA || "", "Python"));
2885
+ add(path3.join(process.env.APPDATA || "", "Python"));
2760
2886
  }
2761
2887
  const probes = process.platform === "win32" ? [
2762
2888
  { command: "py", args: ["-m", "site", "--user-base"] },
@@ -2812,7 +2938,7 @@ function sameHost(a, b) {
2812
2938
  }
2813
2939
  function httpsGetWithMeta(url, maxRedirects = 5, headers = {}) {
2814
2940
  return new Promise((resolve, reject) => {
2815
- https.get(url, { headers: { "User-Agent": "pi-lens/1.0", ...headers } }, (res) => {
2941
+ https2.get(url, { headers: { "User-Agent": "pi-lens/1.0", ...headers } }, (res) => {
2816
2942
  if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
2817
2943
  if (maxRedirects === 0)
2818
2944
  return reject(new Error("Too many redirects"));
@@ -2895,27 +3021,34 @@ async function installGitHubTool(tool, prefetchedRelease) {
2895
3021
  logSessionStart(`github-install ${tool.id}: release metadata has no assets array`);
2896
3022
  return void 0;
2897
3023
  }
2898
- const asset = pickReleaseAsset(releaseJson.assets, assetSubstring) ?? deriveHashiCorpReleaseAsset(tool, releaseJson.tag_name, assetSubstring);
3024
+ const asset = pickReleaseAsset(releaseJson.assets, assetSubstring) ?? deriveReleaseAsset(tool, releaseJson.tag_name, assetSubstring);
2899
3025
  if (!asset) {
2900
3026
  logSessionStart(`github-install ${tool.id}: no asset matched "${assetSubstring}"`);
2901
3027
  return void 0;
2902
3028
  }
2903
3029
  logSessionStart(`github-install ${tool.id}: downloading ${asset.name}`);
2904
3030
  debugLog(`[github] downloading ${asset.name} from ${asset.browser_download_url}`);
3031
+ await fs3.mkdir(GITHUB_BIN_DIR, { recursive: true });
3032
+ const binaryName = tool.binaryName ?? tool.id;
3033
+ const isWindows = platform === "win32";
3034
+ const finalBinaryName = getGitHubInstalledBinaryName(binaryName, platform, asset.name);
3035
+ let destPath = path3.join(GITHUB_BIN_DIR, finalBinaryName);
3036
+ const downloadPath = path3.join(GITHUB_BIN_DIR, `.${tool.id}.download-${randomUUID()}`);
2905
3037
  const downloadStart = Date.now();
2906
- let assetBuffer;
3038
+ let downloadedBytes = 0;
2907
3039
  try {
2908
- assetBuffer = await httpsGet(asset.browser_download_url);
2909
- logSessionStart(`github-install ${tool.id}: downloaded ${asset.name} (${assetBuffer.length} bytes, ${Date.now() - downloadStart}ms)`);
3040
+ ({ bytes: downloadedBytes } = await downloadInstallerFile(asset.browser_download_url, downloadPath));
3041
+ logSessionStart(`github-install ${tool.id}: downloaded ${asset.name} (${downloadedBytes} bytes, ${Date.now() - downloadStart}ms)`);
2910
3042
  } catch (err) {
2911
- logSessionStart(`github-install ${tool.id}: download failed: ${err.message}`);
3043
+ await fs3.rm(downloadPath, { force: true });
3044
+ recordDegradationOnce({
3045
+ kind: "managed-tool-download",
3046
+ subject: tool.id,
3047
+ reason: err.message
3048
+ });
3049
+ logSessionStart(`github-install ${tool.id}: streamed download failed: ${err.message}`);
2912
3050
  return void 0;
2913
3051
  }
2914
- await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
2915
- const binaryName = tool.binaryName ?? tool.id;
2916
- const isWindows = platform === "win32";
2917
- const finalBinaryName = getGitHubInstalledBinaryName(binaryName, platform, asset.name);
2918
- let destPath = path4.join(GITHUB_BIN_DIR, finalBinaryName);
2919
3052
  const assetName = asset.name;
2920
3053
  const launcherRuntime = launcherForGitHubAsset(spec, assetName);
2921
3054
  if (launcherRuntime && !await isCommandAvailable(launcherRuntime, ["--version"])) {
@@ -2925,13 +3058,12 @@ async function installGitHubTool(tool, prefetchedRelease) {
2925
3058
  try {
2926
3059
  assertManagedBinDirInsidePinnedHome(tool.id);
2927
3060
  if (launcherRuntime) {
2928
- const assetPath = path4.join(GITHUB_BIN_DIR, `${tool.id}${assetName.endsWith(".phar") ? ".phar" : ".jar"}`);
2929
- await writeFileAtomicAsync(assetPath, assetBuffer, {
2930
- bestEffort: false,
2931
- mode: 488
2932
- });
3061
+ const assetPath = path3.join(GITHUB_BIN_DIR, `${tool.id}${assetName.endsWith(".phar") ? ".phar" : ".jar"}`);
3062
+ await fs3.rename(downloadPath, assetPath);
3063
+ if (!isWindows)
3064
+ await fs3.chmod(assetPath, 488);
2933
3065
  const launcherName = isWindows ? `${binaryName}.bat` : binaryName;
2934
- destPath = path4.join(GITHUB_BIN_DIR, launcherName);
3066
+ destPath = path3.join(GITHUB_BIN_DIR, launcherName);
2935
3067
  const runtimeTarget = assetName.endsWith(".phar") ? `${tool.id}.phar` : `${tool.id}.jar`;
2936
3068
  const command = isWindows ? `@echo off\r
2937
3069
  ${launcherRuntime} "%~dp0${runtimeTarget}" %*\r
@@ -2943,77 +3075,81 @@ exec ${launcherRuntime} "$(dirname "$0")/${runtimeTarget}" "$@"
2943
3075
  mode: isWindows ? void 0 : 488
2944
3076
  });
2945
3077
  } else if (assetName.endsWith(".gz") && !assetName.endsWith(".tar.gz")) {
2946
- const decompressed = await new Promise((resolve, reject) => {
2947
- const gunzip = createGunzip();
2948
- const chunks = [];
2949
- gunzip.on("data", (chunk) => chunks.push(chunk));
2950
- gunzip.on("end", () => resolve(Buffer.concat(chunks)));
2951
- gunzip.on("error", reject);
2952
- gunzip.end(assetBuffer);
2953
- });
2954
- await writeFileAtomicAsync(destPath, decompressed, {
2955
- bestEffort: false,
2956
- mode: 488
2957
- });
3078
+ const decompressedPath = `${downloadPath}.decompressed`;
3079
+ await pipeline2(createReadStream(downloadPath), createGunzip(), createWriteStream2(decompressedPath));
3080
+ await fs3.rename(decompressedPath, destPath);
3081
+ if (!isWindows)
3082
+ await fs3.chmod(destPath, 488);
2958
3083
  } else if (assetName.endsWith(".tar.gz") || assetName.endsWith(".tar.xz")) {
2959
- const tmpArchive = path4.join(GITHUB_BIN_DIR, `_tmp_${assetName}`);
2960
- await fs2.writeFile(tmpArchive, assetBuffer);
2961
- const tmpDir = path4.join(GITHUB_BIN_DIR, `_tmp_extract_${tool.id}`);
2962
- await fs2.mkdir(tmpDir, { recursive: true });
3084
+ const tmpArchive = path3.join(GITHUB_BIN_DIR, `_tmp_${assetName}`);
3085
+ await fs3.rename(downloadPath, tmpArchive);
3086
+ const tmpDir = path3.join(GITHUB_BIN_DIR, `_tmp_extract_${tool.id}`);
3087
+ await fs3.mkdir(tmpDir, { recursive: true });
2963
3088
  const extracted = await runCommand("tar", ["xf", tmpArchive, "-C", tmpDir], GITHUB_BIN_DIR);
2964
- await fs2.rm(tmpArchive, { force: true });
3089
+ await fs3.rm(tmpArchive, { force: true });
2965
3090
  if (!extracted) {
2966
- await fs2.rm(tmpDir, { recursive: true, force: true });
3091
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2967
3092
  logSessionStart(`github-install ${tool.id}: tar extraction failed for ${assetName}`);
2968
3093
  return void 0;
2969
3094
  }
2970
3095
  const tarBinaryName = spec.binaryInArchive ?? binaryName;
2971
3096
  const tarSrcBinary = await findFirstFileRecursive(tmpDir, getArchiveBinaryCandidates(tarBinaryName, platform, assetName));
2972
3097
  if (!tarSrcBinary) {
2973
- await fs2.rm(tmpDir, { recursive: true, force: true });
3098
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2974
3099
  logSessionStart(`github-install ${tool.id}: binary candidates ${JSON.stringify(getArchiveBinaryCandidates(tarBinaryName, platform, assetName))} not found in tar ${assetName}`);
2975
3100
  return void 0;
2976
3101
  }
2977
- await fs2.rename(tarSrcBinary, destPath);
2978
- await fs2.rm(tmpDir, { recursive: true, force: true });
3102
+ await fs3.rename(tarSrcBinary, destPath);
3103
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2979
3104
  if (!isWindows)
2980
- await fs2.chmod(destPath, 488);
3105
+ await fs3.chmod(destPath, 488);
2981
3106
  } else if (assetName.endsWith(".zip")) {
2982
- const tmpArchive = path4.join(GITHUB_BIN_DIR, `_tmp_${assetName}`);
2983
- await fs2.writeFile(tmpArchive, assetBuffer);
2984
- const tmpDir = path4.join(GITHUB_BIN_DIR, `_tmp_extract_${tool.id}`);
2985
- await fs2.mkdir(tmpDir, { recursive: true });
3107
+ const tmpArchive = path3.join(GITHUB_BIN_DIR, `_tmp_${assetName}`);
3108
+ await fs3.rename(downloadPath, tmpArchive);
3109
+ const tmpDir = path3.join(GITHUB_BIN_DIR, `_tmp_extract_${tool.id}`);
3110
+ await fs3.mkdir(tmpDir, { recursive: true });
2986
3111
  const extracted = isWindows ? await runCommand("powershell", [
2987
3112
  "-NoProfile",
2988
3113
  "-Command",
2989
3114
  `Expand-Archive -LiteralPath '${tmpArchive}' -DestinationPath '${tmpDir}' -Force`
2990
3115
  ], GITHUB_BIN_DIR) : await runCommand("unzip", ["-q", "-o", tmpArchive, "-d", tmpDir], GITHUB_BIN_DIR);
2991
- await fs2.rm(tmpArchive, { force: true });
3116
+ await fs3.rm(tmpArchive, { force: true });
2992
3117
  if (!extracted) {
2993
- await fs2.rm(tmpDir, { recursive: true, force: true });
3118
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2994
3119
  logSessionStart(`github-install ${tool.id}: zip extraction failed for ${assetName}`);
2995
3120
  return void 0;
2996
3121
  }
2997
3122
  const archiveBinaryName = spec.binaryInArchive ?? binaryName;
2998
3123
  const srcBinary = await findFirstFileRecursive(tmpDir, getArchiveBinaryCandidates(archiveBinaryName, platform, assetName));
2999
3124
  if (!srcBinary) {
3000
- await fs2.rm(tmpDir, { recursive: true, force: true });
3125
+ await fs3.rm(tmpDir, { recursive: true, force: true });
3001
3126
  logSessionStart(`github-install ${tool.id}: binary candidates ${JSON.stringify(getArchiveBinaryCandidates(archiveBinaryName, platform, assetName))} not found in zip ${assetName}`);
3002
3127
  return void 0;
3003
3128
  }
3004
- await fs2.rename(srcBinary, destPath);
3005
- await fs2.rm(tmpDir, { recursive: true, force: true });
3129
+ if (spec.bundleArchiveDlls) {
3130
+ const siblingDir = path3.dirname(srcBinary);
3131
+ for (const entry of await fs3.readdir(siblingDir)) {
3132
+ if (entry.toLowerCase().endsWith(".dll")) {
3133
+ await fs3.rename(path3.join(siblingDir, entry), path3.join(GITHUB_BIN_DIR, entry));
3134
+ }
3135
+ }
3136
+ }
3137
+ await fs3.rename(srcBinary, destPath);
3138
+ await fs3.rm(tmpDir, { recursive: true, force: true });
3006
3139
  if (!isWindows)
3007
- await fs2.chmod(destPath, 488);
3140
+ await fs3.chmod(destPath, 488);
3008
3141
  } else {
3009
- await writeFileAtomicAsync(destPath, assetBuffer, {
3010
- bestEffort: false,
3011
- mode: 488
3012
- });
3142
+ await fs3.rename(downloadPath, destPath);
3143
+ if (!isWindows)
3144
+ await fs3.chmod(destPath, 488);
3013
3145
  }
3014
3146
  } catch (err) {
3147
+ await fs3.rm(downloadPath, { force: true });
3015
3148
  logSessionStart(`github-install ${tool.id}: install failed: ${err.message}`);
3016
3149
  return void 0;
3150
+ } finally {
3151
+ await fs3.rm(downloadPath, { force: true });
3152
+ await fs3.rm(`${downloadPath}.decompressed`, { force: true });
3017
3153
  }
3018
3154
  for (const extraName of spec.extraAssets?.(platform, arch) ?? []) {
3019
3155
  const extraAsset = releaseJson.assets.find((a) => a.name === extraName);
@@ -3021,11 +3157,18 @@ exec ${launcherRuntime} "$(dirname "$0")/${runtimeTarget}" "$@"
3021
3157
  logSessionStart(`github-install ${tool.id}: required extra asset "${extraName}" not found`);
3022
3158
  return void 0;
3023
3159
  }
3160
+ const extraPath = path3.join(GITHUB_BIN_DIR, `.${tool.id}.${extraName}.download-${randomUUID()}`);
3024
3161
  try {
3025
- const extraBuffer = await httpsGet(extraAsset.browser_download_url);
3026
- await writeFileAtomicAsync(path4.join(GITHUB_BIN_DIR, extraName), extraBuffer, { bestEffort: false, mode: 488 });
3027
- logSessionStart(`github-install ${tool.id}: installed extra asset ${extraName} (${extraBuffer.length} bytes)`);
3162
+ const { bytes } = await downloadInstallerFile(extraAsset.browser_download_url, extraPath);
3163
+ await fs3.rename(extraPath, path3.join(GITHUB_BIN_DIR, extraName));
3164
+ logSessionStart(`github-install ${tool.id}: installed extra asset ${extraName} (${bytes} bytes)`);
3028
3165
  } catch (err) {
3166
+ await fs3.rm(extraPath, { force: true });
3167
+ recordDegradationOnce({
3168
+ kind: "managed-tool-download",
3169
+ subject: `${tool.id}:${extraName}`,
3170
+ reason: err.message
3171
+ });
3029
3172
  logSessionStart(`github-install ${tool.id}: extra asset ${extraName} download failed: ${err.message}`);
3030
3173
  return void 0;
3031
3174
  }
@@ -3036,9 +3179,9 @@ exec ${launcherRuntime} "$(dirname "$0")/${runtimeTarget}" "$@"
3036
3179
  }
3037
3180
  async function findFirstFileRecursive(dir, names) {
3038
3181
  const wanted = new Set(names.map((name) => name.toLowerCase()));
3039
- const entries = await fs2.readdir(dir, { withFileTypes: true });
3182
+ const entries = await fs3.readdir(dir, { withFileTypes: true });
3040
3183
  for (const entry of entries) {
3041
- const full = path4.join(dir, entry.name);
3184
+ const full = path3.join(dir, entry.name);
3042
3185
  if (entry.isDirectory()) {
3043
3186
  const found = await findFirstFileRecursive(full, names);
3044
3187
  if (found)
@@ -3167,7 +3310,7 @@ async function isManagedToolPresent(toolId) {
3167
3310
  if (!tool.packageName)
3168
3311
  return false;
3169
3312
  try {
3170
- await fs2.access(path4.join(TOOLS_DIR, "node_modules", tool.packageName, "package.json"));
3313
+ await fs3.access(path3.join(TOOLS_DIR, "node_modules", tool.packageName, "package.json"));
3171
3314
  return true;
3172
3315
  } catch {
3173
3316
  return false;
@@ -3454,7 +3597,7 @@ async function refreshPinnedManagedTool(tool, known) {
3454
3597
  };
3455
3598
  }
3456
3599
  function resolveManagedNpmBinPath(binaryName) {
3457
- const binBase = path4.join(TOOLS_DIR, "node_modules", ".bin", binaryName);
3600
+ const binBase = path3.join(TOOLS_DIR, "node_modules", ".bin", binaryName);
3458
3601
  return installerPlatform() === "win32" ? `${binBase}.cmd` : binBase;
3459
3602
  }
3460
3603
  function invalidateManagedToolResolution(toolId) {
@@ -3482,20 +3625,26 @@ async function installMavenTool(tool) {
3482
3625
  const url = `${base}/${groupPath}/${spec.artifactId}/${spec.version}/${jarFile}`;
3483
3626
  lastInstallResolutionId.set(tool.id, mavenCoordinate(spec));
3484
3627
  logSessionStart(`maven-install ${tool.id}: downloading ${url}`);
3485
- let jarBuffer;
3628
+ await fs3.mkdir(GITHUB_BIN_DIR, { recursive: true });
3629
+ const jarDownloadPath = path3.join(GITHUB_BIN_DIR, `.${tool.id}.jar-${randomUUID()}`);
3486
3630
  try {
3487
- jarBuffer = await httpsGet(url);
3631
+ await downloadInstallerFile(url, jarDownloadPath);
3488
3632
  } catch (err) {
3633
+ await fs3.rm(jarDownloadPath, { force: true });
3634
+ recordDegradationOnce({
3635
+ kind: "managed-tool-download",
3636
+ subject: tool.id,
3637
+ reason: err.message
3638
+ });
3489
3639
  logSessionStart(`maven-install ${tool.id}: download failed: ${err.message}`);
3490
3640
  return void 0;
3491
3641
  }
3492
3642
  try {
3493
- await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
3494
3643
  assertManagedBinDirInsidePinnedHome(tool.id);
3495
- const jarPath = path4.join(GITHUB_BIN_DIR, `${tool.id}.jar`);
3496
- await writeFileAtomicAsync(jarPath, jarBuffer, { bestEffort: false });
3644
+ const jarPath = path3.join(GITHUB_BIN_DIR, `${tool.id}.jar`);
3645
+ await fs3.rename(jarDownloadPath, jarPath);
3497
3646
  const launcherName = isWindows ? `${binaryName}.bat` : binaryName;
3498
- const launcherPath = path4.join(GITHUB_BIN_DIR, launcherName);
3647
+ const launcherPath = path3.join(GITHUB_BIN_DIR, launcherName);
3499
3648
  if (isWindows) {
3500
3649
  await writeFileAtomicAsync(launcherPath, `@echo off\r
3501
3650
  java -jar "%~dp0${tool.id}.jar" %*\r
@@ -3505,10 +3654,11 @@ java -jar "%~dp0${tool.id}.jar" %*\r
3505
3654
  exec java -jar "$(dirname "$0")/${tool.id}.jar" "$@"
3506
3655
  `, { bestEffort: false, mode: 488 });
3507
3656
  }
3508
- logSessionStart(`maven-install ${tool.id}: installed \u2192 ${launcherPath} (${jarBuffer.length} bytes)`);
3657
+ logSessionStart(`maven-install ${tool.id}: installed \u2192 ${launcherPath}`);
3509
3658
  debugLog(`[maven] installed ${tool.name} \u2192 ${launcherPath}`);
3510
3659
  return launcherPath;
3511
3660
  } catch (err) {
3661
+ await fs3.rm(jarDownloadPath, { force: true });
3512
3662
  logSessionStart(`maven-install ${tool.id}: install failed: ${err.message}`);
3513
3663
  return void 0;
3514
3664
  }
@@ -3531,34 +3681,34 @@ function recordArchiveExtractionDegradation(toolId, format, reason) {
3531
3681
  }
3532
3682
  async function stripExtractedArchiveRoot(dir, components) {
3533
3683
  for (let i = 0; i < components; i++) {
3534
- const entries = await fs2.readdir(dir, { withFileTypes: true });
3684
+ const entries = await fs3.readdir(dir, { withFileTypes: true });
3535
3685
  const [entry] = entries;
3536
3686
  if (entries.length !== 1 || !entry?.isDirectory())
3537
3687
  return false;
3538
- const root = path4.join(dir, entry.name);
3539
- for (const child of await fs2.readdir(root))
3540
- await fs2.rename(path4.join(root, child), path4.join(dir, child));
3541
- await fs2.rm(root, { recursive: true, force: true });
3688
+ const root = path3.join(dir, entry.name);
3689
+ for (const child of await fs3.readdir(root))
3690
+ await fs3.rename(path3.join(root, child), path3.join(dir, child));
3691
+ await fs3.rm(root, { recursive: true, force: true });
3542
3692
  }
3543
3693
  return true;
3544
3694
  }
3545
3695
  async function swapExtractedDir(toolId, tmpDir, finalDir) {
3546
3696
  const backupDir = `${finalDir}.rollback`;
3547
- await fs2.rm(backupDir, { recursive: true, force: true });
3697
+ await fs3.rm(backupDir, { recursive: true, force: true });
3548
3698
  let hadPrevious = false;
3549
3699
  try {
3550
- await fs2.rename(finalDir, backupDir);
3700
+ await fs3.rename(finalDir, backupDir);
3551
3701
  hadPrevious = true;
3552
3702
  } catch (err) {
3553
3703
  if (err.code !== "ENOENT")
3554
3704
  throw err;
3555
3705
  }
3556
3706
  try {
3557
- await fs2.rename(tmpDir, finalDir);
3707
+ await fs3.rename(tmpDir, finalDir);
3558
3708
  } catch (err) {
3559
3709
  if (hadPrevious) {
3560
3710
  try {
3561
- await fs2.rename(backupDir, finalDir);
3711
+ await fs3.rename(backupDir, finalDir);
3562
3712
  } catch (rollbackErr) {
3563
3713
  recordDegradationOnce({
3564
3714
  kind: "managed-tool-refresh",
@@ -3571,7 +3721,7 @@ async function swapExtractedDir(toolId, tmpDir, finalDir) {
3571
3721
  throw err;
3572
3722
  }
3573
3723
  if (hadPrevious) {
3574
- await fs2.rm(backupDir, { recursive: true, force: true }).catch(() => {
3724
+ await fs3.rm(backupDir, { recursive: true, force: true }).catch(() => {
3575
3725
  });
3576
3726
  }
3577
3727
  }
@@ -3587,7 +3737,7 @@ function runtimeHomeVerdict(runtime) {
3587
3737
  const names = windows ? [`${runtime}.exe`, runtime] : [runtime];
3588
3738
  return names.some((name) => {
3589
3739
  try {
3590
- const stat = statSync2(path4.join(root, home.dir, name));
3740
+ const stat = statSync(path3.join(root, home.dir, name));
3591
3741
  return stat.isFile() && stat.size > 0 && (windows || (stat.mode & 73) !== 0);
3592
3742
  } catch {
3593
3743
  return false;
@@ -3609,15 +3759,24 @@ async function installArchiveTool(tool) {
3609
3759
  }
3610
3760
  lastInstallResolutionId.set(tool.id, url);
3611
3761
  logSessionStart(`archive-install ${tool.id}: downloading ${url}`);
3612
- let archiveBuffer;
3762
+ await fs3.mkdir(TOOLS_DIR, { recursive: true });
3763
+ const archiveDownloadPath = path3.join(TOOLS_DIR, `.${tool.id}.archive-${randomUUID()}`);
3764
+ let archiveBytes = 0;
3765
+ let archiveDigest = "";
3613
3766
  try {
3614
- archiveBuffer = await httpsGet(url);
3767
+ ({ bytes: archiveBytes, sha256: archiveDigest } = await downloadInstallerFile(url, archiveDownloadPath));
3615
3768
  } catch (err) {
3769
+ await fs3.rm(archiveDownloadPath, { force: true });
3770
+ recordDegradationOnce({
3771
+ kind: "managed-tool-download",
3772
+ subject: tool.id,
3773
+ reason: err.message
3774
+ });
3616
3775
  logSessionStart(`archive-install ${tool.id}: download failed: ${err.message}`);
3617
3776
  return void 0;
3618
3777
  }
3619
3778
  const pinned = spec.sha256?.[url];
3620
- const digest = hashContentBytes(archiveBuffer);
3779
+ const digest = archiveDigest;
3621
3780
  if (digest !== pinned) {
3622
3781
  const reason = pinned === void 0 ? "sha256-unpinned" : "sha256-mismatch";
3623
3782
  recordDegradationOnce({
@@ -3625,21 +3784,22 @@ async function installArchiveTool(tool) {
3625
3784
  subject: `${tool.id}:${archiveKind}:integrity`,
3626
3785
  reason: `archive integrity ${reason}`
3627
3786
  });
3628
- installFailureReasons.set(tool.id, `archive integrity ${reason} (${archiveBuffer.length} bytes from ${url})`);
3787
+ installFailureReasons.set(tool.id, `archive integrity ${reason} (${archiveBytes} bytes from ${url})`);
3629
3788
  logSessionStart(`archive-install ${tool.id}: refused ${reason} (got ${digest}, pinned ${pinned ?? "none"}) \u2014 keeping installed version`);
3789
+ await fs3.rm(archiveDownloadPath, { force: true });
3630
3790
  return void 0;
3631
3791
  }
3632
3792
  const extractName = tool.id;
3633
3793
  const tmpExtractName = `${extractName}.refresh-tmp`;
3634
3794
  const archiveName = `${tool.id}.download.${archiveKind === "zip" ? "zip" : "tgz"}`;
3635
- const extractDir = path4.join(TOOLS_DIR, extractName);
3636
- const tmpExtractDir = path4.join(TOOLS_DIR, tmpExtractName);
3637
- const tmpArchive = path4.join(TOOLS_DIR, archiveName);
3795
+ const extractDir = path3.join(TOOLS_DIR, extractName);
3796
+ const tmpExtractDir = path3.join(TOOLS_DIR, tmpExtractName);
3797
+ const tmpArchive = path3.join(TOOLS_DIR, archiveName);
3638
3798
  try {
3639
- await fs2.mkdir(TOOLS_DIR, { recursive: true });
3640
- await fs2.rm(tmpExtractDir, { recursive: true, force: true });
3641
- await fs2.mkdir(tmpExtractDir, { recursive: true });
3642
- await fs2.writeFile(tmpArchive, archiveBuffer);
3799
+ await fs3.mkdir(TOOLS_DIR, { recursive: true });
3800
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true });
3801
+ await fs3.mkdir(tmpExtractDir, { recursive: true });
3802
+ await fs3.rename(archiveDownloadPath, tmpArchive);
3643
3803
  const stripComponents = spec.stripComponents ?? 1;
3644
3804
  const extractionArgs = archiveKind === "zip" && isWindows ? [
3645
3805
  "-NoProfile",
@@ -3663,69 +3823,69 @@ async function installArchiveTool(tool) {
3663
3823
  ok: extractionResult.status === 0,
3664
3824
  reason: extractionResult.spawnFailure?.kind === "tool-not-found" ? "extractor-unavailable" : extractionResult.spawnFailure ? "extractor-error" : "extractor-exit"
3665
3825
  };
3666
- await fs2.rm(tmpArchive, { force: true });
3826
+ await fs3.rm(tmpArchive, { force: true });
3667
3827
  if (!extracted.ok) {
3668
3828
  recordArchiveExtractionDegradation(tool.id, archiveKind, extracted.reason);
3669
3829
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} extraction failed (${extracted.reason}) \u2014 keeping installed version`);
3670
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3830
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3671
3831
  });
3672
3832
  return void 0;
3673
3833
  }
3674
3834
  if (archiveKind === "zip" && !await stripExtractedArchiveRoot(tmpExtractDir, stripComponents)) {
3675
3835
  recordArchiveExtractionDegradation(tool.id, archiveKind, "layout-invalid");
3676
3836
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} layout invalid \u2014 keeping installed version`);
3677
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3837
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3678
3838
  });
3679
3839
  return void 0;
3680
3840
  }
3681
3841
  if (!spec.launcher) {
3682
3842
  const treeMarker = resolveTreeMarker(spec, platform);
3683
- const tmpMarker = treeMarker ? path4.join(tmpExtractDir, ...treeMarker.split("/")) : tmpExtractDir;
3843
+ const tmpMarker = treeMarker ? path3.join(tmpExtractDir, ...treeMarker.split("/")) : tmpExtractDir;
3684
3844
  try {
3685
- await fs2.access(tmpMarker);
3845
+ await fs3.access(tmpMarker);
3686
3846
  } catch {
3687
3847
  recordArchiveExtractionDegradation(tool.id, archiveKind, "marker-missing");
3688
3848
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} marker missing after extraction \u2014 keeping installed version`);
3689
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3849
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3690
3850
  });
3691
3851
  return void 0;
3692
3852
  }
3693
3853
  await swapExtractedDir(tool.id, tmpExtractDir, extractDir);
3694
- logSessionStart(`archive-install ${tool.id}: installed tree bundle \u2192 ${extractDir} (extracted ${archiveBuffer.length} bytes, sha256 verified ${digest})`);
3854
+ logSessionStart(`archive-install ${tool.id}: installed tree bundle \u2192 ${extractDir} (extracted ${archiveBytes} bytes, sha256 verified ${digest})`);
3695
3855
  debugLog(`[archive] installed ${tool.name} bundle \u2192 ${extractDir}`);
3696
3856
  return extractDir;
3697
3857
  }
3698
3858
  const launcherParts = spec.launcher.split("/").map((p) => p);
3699
- const tmpInnerLauncher = path4.join(tmpExtractDir, ...launcherParts);
3859
+ const tmpInnerLauncher = path3.join(tmpExtractDir, ...launcherParts);
3700
3860
  const tmpResolvedInner = isWindows ? `${tmpInnerLauncher}.bat` : tmpInnerLauncher;
3701
3861
  try {
3702
- await fs2.access(tmpResolvedInner);
3862
+ await fs3.access(tmpResolvedInner);
3703
3863
  } catch {
3704
3864
  recordArchiveExtractionDegradation(tool.id, archiveKind, "launcher-missing");
3705
3865
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} launcher missing after extraction \u2014 keeping installed version`);
3706
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3866
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3707
3867
  });
3708
3868
  return void 0;
3709
3869
  }
3710
3870
  if (!isWindows)
3711
- await fs2.chmod(tmpResolvedInner, 488).catch(() => {
3871
+ await fs3.chmod(tmpResolvedInner, 488).catch(() => {
3712
3872
  });
3713
- const launcherStat = await fs2.stat(tmpResolvedInner).catch(() => void 0);
3873
+ const launcherStat = await fs3.stat(tmpResolvedInner).catch(() => void 0);
3714
3874
  const launcherRunnable = launcherStat?.isFile() === true && launcherStat.size > 0 && (isWindows || (launcherStat.mode & 73) !== 0);
3715
3875
  if (!launcherRunnable) {
3716
3876
  recordArchiveExtractionDegradation(tool.id, archiveKind, "launcher-invalid");
3717
3877
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} launcher is empty or not executable \u2014 keeping installed version`);
3718
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3878
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3719
3879
  });
3720
3880
  return void 0;
3721
3881
  }
3722
- await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
3882
+ await fs3.mkdir(GITHUB_BIN_DIR, { recursive: true });
3723
3883
  assertManagedBinDirInsidePinnedHome(tool.id);
3724
3884
  await swapExtractedDir(tool.id, tmpExtractDir, extractDir);
3725
- const innerLauncher = path4.join(extractDir, ...launcherParts);
3885
+ const innerLauncher = path3.join(extractDir, ...launcherParts);
3726
3886
  const resolvedInner = isWindows ? `${innerLauncher}.bat` : innerLauncher;
3727
3887
  const launcherName = isWindows ? `${binaryName}.bat` : binaryName;
3728
- const shimPath = path4.join(GITHUB_BIN_DIR, launcherName);
3888
+ const shimPath = path3.join(GITHUB_BIN_DIR, launcherName);
3729
3889
  if (isWindows) {
3730
3890
  await writeFileAtomicAsync(shimPath, `@echo off\r
3731
3891
  call "${resolvedInner}" %*\r
@@ -3735,13 +3895,15 @@ call "${resolvedInner}" %*\r
3735
3895
  exec "${resolvedInner}" "$@"
3736
3896
  `, { bestEffort: false, mode: 488 });
3737
3897
  }
3738
- logSessionStart(`archive-install ${tool.id}: installed \u2192 ${shimPath} (extracted ${archiveBuffer.length} bytes, sha256 verified ${digest})`);
3898
+ logSessionStart(`archive-install ${tool.id}: installed \u2192 ${shimPath} (extracted ${archiveBytes} bytes, sha256 verified ${digest})`);
3739
3899
  debugLog(`[archive] installed ${tool.name} \u2192 ${shimPath}`);
3740
3900
  return shimPath;
3741
3901
  } catch (err) {
3742
- await fs2.rm(tmpArchive, { force: true }).catch(() => {
3902
+ await fs3.rm(archiveDownloadPath, { force: true }).catch(() => {
3903
+ });
3904
+ await fs3.rm(tmpArchive, { force: true }).catch(() => {
3743
3905
  });
3744
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3906
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3745
3907
  });
3746
3908
  logSessionStart(`archive-install ${tool.id}: install failed: ${err.message} \u2014 keeping installed version`);
3747
3909
  return void 0;
@@ -3780,10 +3942,10 @@ async function installNpmTool(toolId, packageName, binaryName, verificationArgs
3780
3942
  }
3781
3943
  };
3782
3944
  try {
3783
- await fs2.mkdir(TOOLS_DIR, { recursive: true });
3784
- const packageJsonPath = path4.join(TOOLS_DIR, "package.json");
3945
+ await fs3.mkdir(TOOLS_DIR, { recursive: true });
3946
+ const packageJsonPath = path3.join(TOOLS_DIR, "package.json");
3785
3947
  try {
3786
- await fs2.access(packageJsonPath);
3948
+ await fs3.access(packageJsonPath);
3787
3949
  } catch {
3788
3950
  await writeFileAtomicAsync(packageJsonPath, JSON.stringify({ name: "pi-lens-tools", version: "1.0.0" }, null, 2), { bestEffort: false });
3789
3951
  }
@@ -3829,11 +3991,11 @@ async function installNpmTool(toolId, packageName, binaryName, verificationArgs
3829
3991
  if (!outcome.ok) {
3830
3992
  throw new Error(`Failed to install ${packageName}: ${outcome.stderr}`);
3831
3993
  }
3832
- const binBase = path4.join(TOOLS_DIR, "node_modules", ".bin", binaryName);
3994
+ const binBase = path3.join(TOOLS_DIR, "node_modules", ".bin", binaryName);
3833
3995
  const binPath = installerPlatform() === "win32" ? `${binBase}.cmd` : binBase;
3834
3996
  if (installerPlatform() !== "win32") {
3835
3997
  try {
3836
- await fs2.chmod(binPath, 488);
3998
+ await fs3.chmod(binPath, 488);
3837
3999
  } catch {
3838
4000
  }
3839
4001
  }
@@ -3871,12 +4033,12 @@ async function installNpmTool(toolId, packageName, binaryName, verificationArgs
3871
4033
  if (!isValid) {
3872
4034
  logSessionStart(`auto-install ${packageName}: installed but verification failed, cleaning up`);
3873
4035
  try {
3874
- const packagePath = path4.join(TOOLS_DIR, "node_modules", packageName);
3875
- await fs2.rm(packagePath, { recursive: true, force: true });
3876
- await fs2.rm(binBase, { force: true });
4036
+ const packagePath = path3.join(TOOLS_DIR, "node_modules", packageName);
4037
+ await fs3.rm(packagePath, { recursive: true, force: true });
4038
+ await fs3.rm(binBase, { force: true });
3877
4039
  if (isWindows) {
3878
- await fs2.rm(`${binBase}.cmd`, { force: true });
3879
- await fs2.rm(`${binBase}.ps1`, { force: true });
4040
+ await fs3.rm(`${binBase}.cmd`, { force: true });
4041
+ await fs3.rm(`${binBase}.ps1`, { force: true });
3880
4042
  }
3881
4043
  } catch {
3882
4044
  }
@@ -3899,7 +4061,7 @@ function pipCommandCandidates() {
3899
4061
  return process.platform === "win32" ? ["pip", "py", "python"] : ["pip3", "pip", "python3", "python"];
3900
4062
  }
3901
4063
  function pipScriptsDir(base, platform = installerPlatform()) {
3902
- return path4.join(base, platform === "win32" ? "Scripts" : "bin");
4064
+ return path3.join(base, platform === "win32" ? "Scripts" : "bin");
3903
4065
  }
3904
4066
  var pipPep668LoggedRefusals = createGenerationMap("installer-pep668-log");
3905
4067
  async function pipConstraintEnvFor(toolId) {
@@ -3907,8 +4069,8 @@ async function pipConstraintEnvFor(toolId) {
3907
4069
  if (!constraints || constraints.length === 0)
3908
4070
  return {};
3909
4071
  const directories = [
3910
- path4.join(getGlobalPiLensDir(), "pip-constraints"),
3911
- path4.join(os.tmpdir(), "pi-lens-pip-constraints")
4072
+ path3.join(getGlobalPiLensDir(), "pip-constraints"),
4073
+ path3.join(os.tmpdir(), "pi-lens-pip-constraints")
3912
4074
  ];
3913
4075
  const directory = directories.find((candidate) => !/\s/.test(candidate));
3914
4076
  if (!directory) {
@@ -3919,9 +4081,9 @@ async function pipConstraintEnvFor(toolId) {
3919
4081
  });
3920
4082
  return {};
3921
4083
  }
3922
- const file = path4.join(directory, `${toolId}.txt`);
4084
+ const file = path3.join(directory, `${toolId}.txt`);
3923
4085
  try {
3924
- await fs2.mkdir(path4.dirname(file), { recursive: true });
4086
+ await fs3.mkdir(path3.dirname(file), { recursive: true });
3925
4087
  await writeFileAtomicAsync(file, `${constraints.join("\n")}
3926
4088
  `, {
3927
4089
  bestEffort: false
@@ -4011,12 +4173,12 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4011
4173
  };
4012
4174
  const addBinToPath = async (binDir) => {
4013
4175
  try {
4014
- await fs2.access(binDir);
4176
+ await fs3.access(binDir);
4015
4177
  } catch {
4016
4178
  return void 0;
4017
4179
  }
4018
4180
  const currentPath = process.env.PATH || process.env.Path || "";
4019
- const separator = isWindows ? ";" : path4.delimiter;
4181
+ const separator = isWindows ? ";" : path3.delimiter;
4020
4182
  if (!currentPath.toLowerCase().split(separator).includes(binDir.toLowerCase())) {
4021
4183
  const updatedPath = `${binDir}${separator}${currentPath}`;
4022
4184
  process.env.PATH = updatedPath;
@@ -4025,9 +4187,9 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4025
4187
  }
4026
4188
  const names = isWindows ? [`${binaryName}.exe`, `${binaryName}.cmd`, binaryName] : [binaryName];
4027
4189
  for (const name of names) {
4028
- const candidate = path4.join(binDir, name);
4190
+ const candidate = path3.join(binDir, name);
4029
4191
  try {
4030
- await fs2.access(candidate);
4192
+ await fs3.access(candidate);
4031
4193
  return candidate;
4032
4194
  } catch {
4033
4195
  }
@@ -4043,7 +4205,7 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4043
4205
  "--value",
4044
4206
  "PIPX_BIN_DIR"
4045
4207
  ]);
4046
- const binDir = location.status === 0 && location.stdout.trim() ? location.stdout.trim() : path4.join(os.homedir(), ".local", "bin");
4208
+ const binDir = location.status === 0 && location.stdout.trim() ? location.stdout.trim() : path3.join(os.homedir(), ".local", "bin");
4047
4209
  const binaryPath = await addBinToPath(binDir);
4048
4210
  if (binaryPath)
4049
4211
  return succeeded("pipx", binaryPath);
@@ -4054,12 +4216,12 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4054
4216
  const pythonCandidates = pipCandidates.filter(({ command }) => command === "python3" || command === "python" || command === "py");
4055
4217
  const pythonAvailability = await Promise.all(pythonCandidates.map(({ command }) => isCommandAvailable(command)));
4056
4218
  const availablePythonCandidates = pythonCandidates.filter((_, index) => pythonAvailability[index]);
4057
- const venvRoot = path4.join(getGlobalPiLensDir(), "pip-tools");
4219
+ const venvRoot = path3.join(getGlobalPiLensDir(), "pip-tools");
4058
4220
  for (const candidate of availablePythonCandidates) {
4059
4221
  const venvBin = pipScriptsDir(venvRoot, installerPlatform());
4060
- let venvPip = path4.join(venvBin, isWindows ? "pip.exe" : "pip");
4222
+ let venvPip = path3.join(venvBin, isWindows ? "pip.exe" : "pip");
4061
4223
  try {
4062
- await fs2.access(venvPip);
4224
+ await fs3.access(venvPip);
4063
4225
  } catch {
4064
4226
  const created = await run(candidate.command, ["-m", "venv", venvRoot]);
4065
4227
  const error2 = (created.error?.message ?? created.stderr).trim();
@@ -4069,11 +4231,11 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4069
4231
  }
4070
4232
  }
4071
4233
  try {
4072
- await fs2.access(venvPip);
4234
+ await fs3.access(venvPip);
4073
4235
  } catch {
4074
- venvPip = path4.join(venvBin, isWindows ? "pip.cmd" : "pip3");
4236
+ venvPip = path3.join(venvBin, isWindows ? "pip.cmd" : "pip3");
4075
4237
  try {
4076
- await fs2.access(venvPip);
4238
+ await fs3.access(venvPip);
4077
4239
  } catch {
4078
4240
  continue;
4079
4241
  }
@@ -4107,7 +4269,7 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4107
4269
  }
4108
4270
  if (!userRefused)
4109
4271
  throw new Error(`pip install failed: ${candidateErrors.join(" | ") || "unknown error"}`);
4110
- const privateBase = path4.join(getGlobalPiLensDir(), "pip-user");
4272
+ const privateBase = path3.join(getGlobalPiLensDir(), "pip-user");
4111
4273
  const privateEnv = { ...process.env, PYTHONUSERBASE: privateBase };
4112
4274
  for (const candidate of pipCandidates) {
4113
4275
  const args = candidate.command === "pip" || candidate.command === "pip3" ? [...verb, "--user", "--break-system-packages", packageName] : [
@@ -4159,7 +4321,7 @@ async function stampInstallResolution(toolId) {
4159
4321
  return;
4160
4322
  try {
4161
4323
  const resolutionId = lastInstallResolutionId.get(toolId);
4162
- const refresh = await import("./chunk-J2ZB5MDS.js");
4324
+ const refresh = await import("./chunk-RURPX2YV.js");
4163
4325
  await refresh.stampManagedToolInstall(toolId, resolutionId);
4164
4326
  } catch {
4165
4327
  }
@@ -4172,7 +4334,7 @@ async function finishInstallAttempt(toolId, ok, startedAt) {
4172
4334
  if (ok) {
4173
4335
  resetSafeSpawnWindowsCommandCache();
4174
4336
  try {
4175
- const { resetMadgeManagedPathMemo } = await import("./chunk-5YJXF2IS.js");
4337
+ const { resetMadgeManagedPathMemo } = await import("./chunk-TB5MGZLS.js");
4176
4338
  resetMadgeManagedPathMemo();
4177
4339
  } catch (err) {
4178
4340
  logSessionStart(`auto-install ${toolId}: madge memo reset failed: ${err.message}`);
@@ -4202,7 +4364,7 @@ async function installTool(toolId, ownsLock) {
4202
4364
  return false;
4203
4365
  const npmPath = await installNpmTool(tool.id, tool.packageName, tool.binaryName, tool.checkArgs, getToolVerificationTimeout(tool), packageEntryVerification(tool), ownsLock);
4204
4366
  if (npmPath !== void 0) {
4205
- await import("./chunk-J2ZB5MDS.js").then((m) => m.stampManagedToolInstalled(tool.id, tool.packageName)).catch(() => {
4367
+ await import("./chunk-RURPX2YV.js").then((m) => m.stampManagedToolInstalled(tool.id, tool.packageName)).catch(() => {
4206
4368
  });
4207
4369
  }
4208
4370
  return finishInstallAttempt(tool.id, npmPath !== void 0, startedAt);
@@ -4341,7 +4503,7 @@ async function ensureToolResolved(toolId, opts) {
4341
4503
  return cached;
4342
4504
  }
4343
4505
  try {
4344
- await fs2.access(cached);
4506
+ await fs3.access(cached);
4345
4507
  lastEnsureResolutionSource.set(toolId, "session-cache");
4346
4508
  return cached;
4347
4509
  } catch {
@@ -4445,10 +4607,10 @@ async function ensureToolResolved(toolId, opts) {
4445
4607
  }
4446
4608
  }
4447
4609
  async function getToolEnvironment() {
4448
- const localBin = path4.join(TOOLS_DIR, "node_modules", ".bin");
4610
+ const localBin = path3.join(TOOLS_DIR, "node_modules", ".bin");
4449
4611
  const currentPath = process.env.PATH || process.env.Path || process.env.path || "";
4450
4612
  const separator = process.platform === "win32" ? ";" : ":";
4451
- const nodeDir = path4.dirname(process.execPath);
4613
+ const nodeDir = path3.dirname(process.execPath);
4452
4614
  const withNode = nodeDir ? `${nodeDir}${separator}${currentPath}` : currentPath;
4453
4615
  const augmentedPath = `${GITHUB_BIN_DIR}${separator}${localBin}${separator}${withNode}`;
4454
4616
  const env = {
@@ -4463,12 +4625,12 @@ async function getToolEnvironment() {
4463
4625
  async function checkAllTools() {
4464
4626
  const results = [];
4465
4627
  for (const tool of TOOLS) {
4466
- const path5 = await getToolPath(tool.id);
4628
+ const path4 = await getToolPath(tool.id);
4467
4629
  results.push({
4468
4630
  id: tool.id,
4469
4631
  name: tool.name,
4470
- installed: path5 !== void 0,
4471
- path: path5
4632
+ installed: path4 !== void 0,
4633
+ path: path4
4472
4634
  });
4473
4635
  }
4474
4636
  return results;
@@ -4548,27 +4710,19 @@ function isAssetSidecar(name) {
4548
4710
  function pickReleaseAsset(assets, assetSubstring) {
4549
4711
  return assets.find((a) => a.name === assetSubstring) ?? assets.find((a) => a.name.includes(assetSubstring) && !isAssetSidecar(a.name));
4550
4712
  }
4551
- function deriveHashiCorpReleaseAsset(tool, tagName, assetSubstring) {
4552
- const product = tool.github?.hashiCorpReleaseProduct;
4553
- if (!product || !tagName)
4554
- return void 0;
4555
- const version = tagName.replace(/^v/, "").trim();
4556
- if (!version)
4713
+ function deriveReleaseAsset(tool, tagName, assetSubstring) {
4714
+ if (!tagName)
4557
4715
  return void 0;
4558
- const assetName = `${product}_${version}_${assetSubstring}`;
4559
- return {
4560
- name: assetName,
4561
- browser_download_url: `https://releases.hashicorp.com/${product}/${version}/${assetName}`
4562
- };
4716
+ return tool.github?.derivedAsset?.(tagName, assetSubstring);
4563
4717
  }
4564
- function resolveDerivedHashiCorpReleaseAsset(toolId, tagName, platform, arch) {
4718
+ function resolveDerivedReleaseAsset(toolId, tagName, platform, arch) {
4565
4719
  const tool = TOOLS.find((t) => t.id === toolId);
4566
4720
  if (!tool)
4567
4721
  return void 0;
4568
4722
  const assetSubstring = tool.github?.assetMatch(platform, arch);
4569
4723
  if (!assetSubstring)
4570
4724
  return void 0;
4571
- return deriveHashiCorpReleaseAsset(tool, tagName, assetSubstring);
4725
+ return deriveReleaseAsset(tool, tagName, assetSubstring);
4572
4726
  }
4573
4727
 
4574
4728
  export {
@@ -4579,7 +4733,6 @@ export {
4579
4733
  commitDurableStore,
4580
4734
  commitDurableStoreAsync,
4581
4735
  logSessionStart,
4582
- findCommandOnPath,
4583
4736
  getManagedToolsDir,
4584
4737
  TOOLS,
4585
4738
  getToolVerificationTimeout,
@@ -4632,5 +4785,5 @@ export {
4632
4785
  resolveGitHubInstalledBinaryName,
4633
4786
  resolveGitHubArchiveBinaryCandidates,
4634
4787
  pickReleaseAsset,
4635
- resolveDerivedHashiCorpReleaseAsset
4788
+ resolveDerivedReleaseAsset
4636
4789
  };