@herbertgao/pi-extensions 2026.11.20 → 2026.11.21

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 (159) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +8 -8
  3. package/THIRD_PARTY_NOTICES.md +2 -2
  4. package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +8 -0
  5. package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +9 -5
  6. package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +11 -1
  7. package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +1 -1
  8. package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +71 -13
  9. package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +148 -47
  10. package/node_modules/@narumitw/pi-btw/CHANGELOG.md +7 -0
  11. package/node_modules/@narumitw/pi-btw/dist/chunks/{main-tree-picker-3PXJARQW.ts → main-tree-picker-WMTVRTR2.ts} +1 -1
  12. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-WMTVRTR2.ts.map +7 -0
  13. package/node_modules/@narumitw/pi-btw/dist/index.ts +1 -1
  14. package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +6 -0
  15. package/node_modules/@narumitw/pi-btw/package.json +5 -5
  16. package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +1 -1
  17. package/node_modules/@narumitw/pi-caffeinate/CHANGELOG.md +7 -0
  18. package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
  19. package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
  20. package/node_modules/pi-lens/CHANGELOG.md +121 -0
  21. package/node_modules/pi-lens/README.md +9 -2
  22. package/node_modules/pi-lens/dist/{chunk-ZVQUYCBU.js → chunk-2ERVW2UF.js} +161 -100
  23. package/node_modules/pi-lens/dist/{chunk-AFSG6YUB.js → chunk-2K7BUOKS.js} +13 -13
  24. package/node_modules/pi-lens/dist/{chunk-BJGWP4UX.js → chunk-3JJ4OAJI.js} +10 -10
  25. package/node_modules/pi-lens/dist/{chunk-GIK6VUCY.js → chunk-3UHGSUVL.js} +1 -1
  26. package/node_modules/pi-lens/dist/{chunk-EKQDQPX6.js → chunk-463WN3VP.js} +1 -1
  27. package/node_modules/pi-lens/dist/{chunk-F7BFIENK.js → chunk-4X3ML2UQ.js} +29 -32
  28. package/node_modules/pi-lens/dist/{chunk-7JMEPY6P.js → chunk-5BI5YP57.js} +10 -10
  29. package/node_modules/pi-lens/dist/{chunk-MKW7ZUTT.js → chunk-5Z4XLUFF.js} +3 -3
  30. package/node_modules/pi-lens/dist/{chunk-NIZKGBOU.js → chunk-62AJH3IN.js} +12 -14
  31. package/node_modules/pi-lens/dist/{chunk-4GLSO2EM.js → chunk-6F34GMP7.js} +12 -12
  32. package/node_modules/pi-lens/dist/{chunk-35UJUF27.js → chunk-6LIUVGOR.js} +13 -3
  33. package/node_modules/pi-lens/dist/{chunk-WJ7GY5WJ.js → chunk-6REF4GCO.js} +1 -1
  34. package/node_modules/pi-lens/dist/{chunk-HFIFEH46.js → chunk-7KRR24GO.js} +3 -3
  35. package/node_modules/pi-lens/dist/{chunk-WAK2AXQQ.js → chunk-7OMOMBEQ.js} +9 -9
  36. package/node_modules/pi-lens/dist/{chunk-S7KUDW73.js → chunk-7ZFXICNN.js} +15 -15
  37. package/node_modules/pi-lens/dist/{chunk-VEF3GFOL.js → chunk-ABKRQVOY.js} +28 -52
  38. package/node_modules/pi-lens/dist/{chunk-Y2LIOCA7.js → chunk-ANSLRJBG.js} +1 -1
  39. package/node_modules/pi-lens/dist/{chunk-ARTCVE6I.js → chunk-AWMFBPGJ.js} +9 -9
  40. package/node_modules/pi-lens/dist/{chunk-H6DNTQ4V.js → chunk-BG7KHGNX.js} +2 -2
  41. package/node_modules/pi-lens/dist/{chunk-FD4LJQ6Y.js → chunk-BK2R2223.js} +10 -8
  42. package/node_modules/pi-lens/dist/{chunk-TWAQFMLW.js → chunk-BXXC6KRR.js} +31 -34
  43. package/node_modules/pi-lens/dist/{chunk-S247BOH2.js → chunk-CKJS2AUI.js} +4 -4
  44. package/node_modules/pi-lens/dist/{chunk-GNK2IHVG.js → chunk-COGU5KQJ.js} +15 -15
  45. package/node_modules/pi-lens/dist/{chunk-P7EV5ISR.js → chunk-CQNXALZJ.js} +12 -6
  46. package/node_modules/pi-lens/dist/{chunk-IO6P3NBP.js → chunk-CSZESDPP.js} +1 -1
  47. package/node_modules/pi-lens/dist/chunk-CZ5TCJPB.js +98 -0
  48. package/node_modules/pi-lens/dist/{chunk-DLGJYQML.js → chunk-D2LFEA5U.js} +9 -2
  49. package/node_modules/pi-lens/dist/chunk-D3KLF5CD.js +50 -0
  50. package/node_modules/pi-lens/dist/{chunk-W2JPGW7Q.js → chunk-ENJ2M76Y.js} +20 -20
  51. package/node_modules/pi-lens/dist/{chunk-2DWNYVUN.js → chunk-EQKF6BAK.js} +3 -3
  52. package/node_modules/pi-lens/dist/{chunk-KIQSNH3F.js → chunk-F2SAP2FM.js} +38 -45
  53. package/node_modules/pi-lens/dist/{chunk-BYIEU4E4.js → chunk-F6QAJXQV.js} +2 -2
  54. package/node_modules/pi-lens/dist/chunk-GR2QDWH5.js +25 -0
  55. package/node_modules/pi-lens/dist/{chunk-T2D2WWP6.js → chunk-GVE5VZYQ.js} +5 -5
  56. package/node_modules/pi-lens/dist/{chunk-HMXWZUQW.js → chunk-GWZZOJD2.js} +1 -1
  57. package/node_modules/pi-lens/dist/chunk-GZS6VPIE.js +27 -0
  58. package/node_modules/pi-lens/dist/chunk-H4B4SC7I.js +71 -0
  59. package/node_modules/pi-lens/dist/{chunk-2RQREVGO.js → chunk-HA6TUJOE.js} +1 -1
  60. package/node_modules/pi-lens/dist/{chunk-NAACKIKT.js → chunk-HKPJTI47.js} +2 -2
  61. package/node_modules/pi-lens/dist/{chunk-NHHS5T52.js → chunk-HPKC55MA.js} +1 -1
  62. package/node_modules/pi-lens/dist/{chunk-B2QO7GHY.js → chunk-I65CQLCG.js} +1 -1
  63. package/node_modules/pi-lens/dist/{chunk-BQ72NQQM.js → chunk-IDKLWVKY.js} +11 -11
  64. package/node_modules/pi-lens/dist/chunk-IUM2Q7NF.js +25 -0
  65. package/node_modules/pi-lens/dist/{chunk-PVV27TOX.js → chunk-J24IS3KZ.js} +5 -5
  66. package/node_modules/pi-lens/dist/{chunk-DKXIUGNA.js → chunk-J2DAHH4T.js} +2 -2
  67. package/node_modules/pi-lens/dist/{chunk-CDAJQBKJ.js → chunk-JBDZVOFL.js} +11 -11
  68. package/node_modules/pi-lens/dist/{chunk-T7KHGEJ5.js → chunk-JC6NFC57.js} +3 -3
  69. package/node_modules/pi-lens/dist/{chunk-BWGNVM33.js → chunk-JTHEUTW7.js} +11 -11
  70. package/node_modules/pi-lens/dist/{chunk-WWZLT6AM.js → chunk-JWW3ODBN.js} +2 -2
  71. package/node_modules/pi-lens/dist/{chunk-Q32RJDYC.js → chunk-K3ZIYLHT.js} +4 -4
  72. package/node_modules/pi-lens/dist/{chunk-LDPY22FS.js → chunk-KDPZA2UE.js} +2 -3
  73. package/node_modules/pi-lens/dist/{chunk-YIEHUKX2.js → chunk-KMY2OU4T.js} +489 -285
  74. package/node_modules/pi-lens/dist/{chunk-WH6O4IFD.js → chunk-KQF7VT26.js} +10 -10
  75. package/node_modules/pi-lens/dist/{chunk-OG3UCAHV.js → chunk-KVGA7X76.js} +3 -3
  76. package/node_modules/pi-lens/dist/{chunk-TABDCX35.js → chunk-KW7O72AK.js} +2 -2
  77. package/node_modules/pi-lens/dist/{chunk-AOEVZXR6.js → chunk-LEQTVRSV.js} +9 -9
  78. package/node_modules/pi-lens/dist/{chunk-7BWPQZHE.js → chunk-LKPSBM6S.js} +3 -3
  79. package/node_modules/pi-lens/dist/{chunk-WA6U2URH.js → chunk-LKW2HFSZ.js} +6 -6
  80. package/node_modules/pi-lens/dist/{chunk-M3QGXGY4.js → chunk-LURFD4HD.js} +624 -97
  81. package/node_modules/pi-lens/dist/{chunk-2YQ5LI7R.js → chunk-M6ELTECW.js} +4 -4
  82. package/node_modules/pi-lens/dist/{chunk-OHTHVILU.js → chunk-MGVVYYKW.js} +12 -12
  83. package/node_modules/pi-lens/dist/{chunk-W2YHHNY3.js → chunk-MQBKGRSB.js} +7 -7
  84. package/node_modules/pi-lens/dist/{chunk-MET776XM.js → chunk-MVG2ZEAO.js} +6 -6
  85. package/node_modules/pi-lens/dist/{chunk-2XALJI2K.js → chunk-MY4XNNTX.js} +39 -41
  86. package/node_modules/pi-lens/dist/{chunk-GFCPPCNR.js → chunk-N4AJVFRF.js} +11 -11
  87. package/node_modules/pi-lens/dist/{chunk-UARVPNAU.js → chunk-OFKKMXWM.js} +31 -36
  88. package/node_modules/pi-lens/dist/{chunk-DHFJS2I4.js → chunk-OFZE4ANN.js} +8 -8
  89. package/node_modules/pi-lens/dist/chunk-OLXBUTJR.js +61 -0
  90. package/node_modules/pi-lens/dist/{chunk-SJ2SR432.js → chunk-OZGEHOSG.js} +38 -17
  91. package/node_modules/pi-lens/dist/{chunk-6MDWNZ7E.js → chunk-PKGOROPQ.js} +40 -2
  92. package/node_modules/pi-lens/dist/{chunk-3IWMNN2S.js → chunk-Q6D5QKRG.js} +17 -17
  93. package/node_modules/pi-lens/dist/{chunk-JGCBMCCS.js → chunk-QECLJFHI.js} +12 -17
  94. package/node_modules/pi-lens/dist/{chunk-KXKM2DFP.js → chunk-QJA33VD5.js} +4 -4
  95. package/node_modules/pi-lens/dist/{chunk-YV7XVYSJ.js → chunk-R5XVJ6AN.js} +11 -11
  96. package/node_modules/pi-lens/dist/{chunk-62PIU4TO.js → chunk-REZL4OM4.js} +1 -1
  97. package/node_modules/pi-lens/dist/{chunk-NNDZ7DOP.js → chunk-RK5RBREN.js} +74 -107
  98. package/node_modules/pi-lens/dist/chunk-RP5ZQTHO.js +86 -0
  99. package/node_modules/pi-lens/dist/{chunk-HKRESBMC.js → chunk-RURPX2YV.js} +23 -23
  100. package/node_modules/pi-lens/dist/chunk-TB5MGZLS.js +53 -0
  101. package/node_modules/pi-lens/dist/chunk-TC63XRYP.js +27 -0
  102. package/node_modules/pi-lens/dist/chunk-TJOYHAXJ.js +69 -0
  103. package/node_modules/pi-lens/dist/{chunk-NZ7NSKIW.js → chunk-TRXKDCBP.js} +13 -13
  104. package/node_modules/pi-lens/dist/{chunk-7WAQ3K26.js → chunk-TTK37D7R.js} +22 -23
  105. package/node_modules/pi-lens/dist/{chunk-ALTHJUZO.js → chunk-UH3QHLR5.js} +2 -2
  106. package/node_modules/pi-lens/dist/{chunk-6MZLS6CK.js → chunk-UNTJJ7GN.js} +7 -7
  107. package/node_modules/pi-lens/dist/{chunk-XRLZ75YY.js → chunk-UPAFSETJ.js} +54 -59
  108. package/node_modules/pi-lens/dist/{chunk-N2U644ZW.js → chunk-UX75PTQW.js} +50 -17
  109. package/node_modules/pi-lens/dist/{chunk-EXHSWN3P.js → chunk-V353PYMK.js} +423 -233
  110. package/node_modules/pi-lens/dist/{chunk-SL4G67AP.js → chunk-V4TFQY5G.js} +2 -2
  111. package/node_modules/pi-lens/dist/{chunk-YOMLAKU6.js → chunk-VC3W54G3.js} +289 -138
  112. package/node_modules/pi-lens/dist/{chunk-KSQJBGRO.js → chunk-VSBCJVPC.js} +5 -5
  113. package/node_modules/pi-lens/dist/{chunk-EBXCYEII.js → chunk-WAQQGXVV.js} +3 -3
  114. package/node_modules/pi-lens/dist/{chunk-7ORBRDFY.js → chunk-WLEVWR7Y.js} +2 -2
  115. package/node_modules/pi-lens/dist/{chunk-Q4UQNTLB.js → chunk-WPMPVP5I.js} +4 -4
  116. package/node_modules/pi-lens/dist/{chunk-TQKWR5AZ.js → chunk-WXNLFOC2.js} +7 -7
  117. package/node_modules/pi-lens/dist/{chunk-HOWHAKXO.js → chunk-Y3ZNOZZS.js} +6 -6
  118. package/node_modules/pi-lens/dist/{chunk-DNJJVKJZ.js → chunk-YL6JQTWC.js} +29 -32
  119. package/node_modules/pi-lens/dist/{chunk-HUWW77QY.js → chunk-YVE5Q2UU.js} +86 -217
  120. package/node_modules/pi-lens/dist/{chunk-25CAONWT.js → chunk-YZNARDMM.js} +12 -9
  121. package/node_modules/pi-lens/dist/{chunk-HERQPNY6.js → chunk-ZDWNFZJ2.js} +8 -8
  122. package/node_modules/pi-lens/dist/{chunk-MKQFSW2Q.js → chunk-ZEUF7BIN.js} +2 -2
  123. package/node_modules/pi-lens/dist/{chunk-AB26NAHA.js → chunk-ZIF4WLWR.js} +45 -25
  124. package/node_modules/pi-lens/dist/{chunk-6MWX2J5H.js → chunk-ZSPVF7KI.js} +227 -24
  125. package/node_modules/pi-lens/dist/{chunk-QQGZY2BR.js → chunk-ZX6OKBVO.js} +2 -2
  126. package/node_modules/pi-lens/dist/index.js +6455 -5243
  127. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
  128. package/node_modules/pi-lens/dist/mcp/cli.js +39 -41
  129. package/node_modules/pi-lens/dist/mcp/server.js +870 -559
  130. package/node_modules/pi-lens/dist/mcp/worker.js +68 -59
  131. package/node_modules/pi-lens/dist/probes/installer.js +19 -20
  132. package/node_modules/pi-lens/docs/configuration.md +24 -10
  133. package/node_modules/pi-lens/docs/defect-shapes.md +18 -2
  134. package/node_modules/pi-lens/docs/environment-variables.md +18 -9
  135. package/node_modules/pi-lens/docs/globalconfig.md +16 -0
  136. package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +7 -0
  137. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +33 -3
  138. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +23 -10
  139. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +8 -3
  140. package/node_modules/pi-lens/docs/release-qa-baseline.md +22 -17
  141. package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
  142. package/node_modules/pi-lens/docs/settings.md +9 -2
  143. package/node_modules/pi-lens/docs/tools.md +1 -1
  144. package/node_modules/pi-lens/package.json +3 -3
  145. package/package.json +7 -7
  146. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-3PXJARQW.ts.map +0 -7
  147. package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +0 -88
  148. package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +0 -27
  149. package/node_modules/pi-lens/dist/chunk-4E4OCW3L.js +0 -38
  150. package/node_modules/pi-lens/dist/chunk-5HVDD7IA.js +0 -17
  151. package/node_modules/pi-lens/dist/chunk-BKJ6WZKP.js +0 -255
  152. package/node_modules/pi-lens/dist/chunk-D3UQWOCB.js +0 -46
  153. package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +0 -73
  154. package/node_modules/pi-lens/dist/chunk-J7VNGHLN.js +0 -69
  155. package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +0 -25
  156. package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +0 -25
  157. package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +0 -56
  158. package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +0 -27
  159. package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +0 -27
@@ -2,23 +2,23 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
2
2
  import {
3
3
  findCommandOnPath,
4
4
  resolveToolCwd
5
- } from "./chunk-T2D2WWP6.js";
5
+ } from "./chunk-GVE5VZYQ.js";
6
6
  import {
7
7
  allAvailableGlobalBinDirs,
8
8
  installArgs,
9
9
  pmBinary,
10
10
  resolveNodePackageManager
11
- } from "./chunk-25CAONWT.js";
11
+ } from "./chunk-YZNARDMM.js";
12
12
  import {
13
13
  probeToolAsync
14
- } from "./chunk-WWZLT6AM.js";
14
+ } from "./chunk-JWW3ODBN.js";
15
15
  import {
16
16
  TRANSIENT_MAX_COOLDOWN_MS,
17
17
  classifyProbeFailure,
18
18
  createAvailabilityLatch,
19
19
  logAvailabilityDecision,
20
20
  startHostStallSampler
21
- } from "./chunk-LDPY22FS.js";
21
+ } from "./chunk-KDPZA2UE.js";
22
22
  import {
23
23
  registerBackgroundWriteDrain
24
24
  } from "./chunk-UYXV5NIS.js";
@@ -41,30 +41,27 @@ import {
41
41
  startGenerationHeartbeat,
42
42
  tryAcquireGeneration,
43
43
  windowsExe
44
- } from "./chunk-M3QGXGY4.js";
45
- import {
46
- hashContentBytes
47
- } from "./chunk-CIA7X2PZ.js";
44
+ } from "./chunk-LURFD4HD.js";
48
45
  import {
49
46
  assertInstallAllowed,
50
47
  getProjectTrustGeneration,
51
48
  projectTrustDenialReason,
52
49
  writeFileAtomic,
53
50
  writeFileAtomicAsync
54
- } from "./chunk-EKQDQPX6.js";
51
+ } from "./chunk-463WN3VP.js";
55
52
  import {
56
53
  getDegradationLedgerGeneration,
57
54
  incrementDegradationCount,
58
55
  logExtension,
59
56
  recordDegradationOnce
60
- } from "./chunk-P7EV5ISR.js";
57
+ } from "./chunk-CQNXALZJ.js";
61
58
  import {
62
59
  createNdjsonLogger,
63
60
  getGlobalPiLensLogDir,
64
61
  getMaxLogSizeMB,
65
62
  isTestMode,
66
63
  isToolInstallDisabled
67
- } from "./chunk-HUWW77QY.js";
64
+ } from "./chunk-YVE5Q2UU.js";
68
65
  import {
69
66
  BoundedLruCache,
70
67
  findLocalToolConfig,
@@ -72,27 +69,119 @@ import {
72
69
  isUnderDir,
73
70
  realpathOrResolve,
74
71
  toPosix
75
- } from "./chunk-6MWX2J5H.js";
72
+ } from "./chunk-ZSPVF7KI.js";
76
73
  import {
77
74
  __require
78
75
  } from "./chunk-NXL4FFQQ.js";
79
76
 
80
77
  // dist/clients/installer/index.js
81
78
  import { existsSync, readFileSync as readFileSync2, statSync, unlinkSync, writeFileSync } from "node:fs";
82
- import fs2 from "node:fs/promises";
79
+ import { createReadStream, createWriteStream as createWriteStream2 } from "node:fs";
80
+ import fs3 from "node:fs/promises";
83
81
  import { randomUUID } from "node:crypto";
84
- import https from "node:https";
82
+ import https2 from "node:https";
85
83
  import { createRequire } from "node:module";
86
84
  import os from "node:os";
87
85
  import path3 from "node:path";
88
86
  import { createGunzip } from "node:zlib";
87
+ import { pipeline as pipeline2 } from "node:stream/promises";
88
+
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);
144
+ }
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;
166
+ }
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
+ });
177
+ }
89
178
 
90
179
  // dist/clients/durable-store.js
91
- import * as fs from "node:fs";
180
+ import * as fs2 from "node:fs";
92
181
  import fsp from "node:fs/promises";
93
182
  function readLocked(path4) {
94
183
  try {
95
- return fs.readFileSync(path4, "utf8");
184
+ return fs2.readFileSync(path4, "utf8");
96
185
  } catch {
97
186
  return void 0;
98
187
  }
@@ -549,6 +638,7 @@ function managedGitHubFormatterTool(spec) {
549
638
  checkCommand: spec.id,
550
639
  checkArgs: ["--version"],
551
640
  installStrategy: "github",
641
+ ...spec.autoInstall && { autoInstall: true },
552
642
  binaryName: spec.id,
553
643
  github: {
554
644
  repo: `${spec.owner}/${spec.repo}`,
@@ -563,6 +653,7 @@ var MANAGED_GITHUB_FORMATTERS = [
563
653
  {
564
654
  id: "typstyle",
565
655
  name: "typstyle",
656
+ autoInstall: true,
566
657
  owner: "typstyle-rs",
567
658
  repo: "typstyle",
568
659
  assetPattern: archAssetMatch({
@@ -650,6 +741,8 @@ var TOOLS = [
650
741
  // Core LSP servers
651
742
  {
652
743
  id: "typescript-language-server",
744
+ // Preinstalled at session start for a TypeScript project, as before (#5410 D9).
745
+ autoInstall: true,
653
746
  name: "TypeScript Language Server",
654
747
  checkCommand: "typescript-language-server",
655
748
  checkArgs: ["--version"],
@@ -677,6 +770,7 @@ var TOOLS = [
677
770
  },
678
771
  {
679
772
  id: "pyright",
773
+ autoInstall: true,
680
774
  name: "Pyright",
681
775
  checkCommand: "pyright",
682
776
  checkArgs: ["--version"],
@@ -687,6 +781,7 @@ var TOOLS = [
687
781
  // Linting/formatting tools
688
782
  {
689
783
  id: "prettier",
784
+ autoInstall: true,
690
785
  name: "Prettier",
691
786
  checkCommand: "prettier",
692
787
  checkArgs: ["--version"],
@@ -697,6 +792,7 @@ var TOOLS = [
697
792
  ...MANAGED_PACKAGE_FORMATTERS.map(managedPackageFormatterTool),
698
793
  {
699
794
  id: "ruff",
795
+ autoInstall: true,
700
796
  name: "Ruff",
701
797
  checkCommand: "ruff",
702
798
  checkArgs: ["--version"],
@@ -717,6 +813,7 @@ var TOOLS = [
717
813
  },
718
814
  {
719
815
  id: "biome",
816
+ autoInstall: true,
720
817
  name: "Biome",
721
818
  checkCommand: "biome",
722
819
  checkArgs: ["--version"],
@@ -739,6 +836,7 @@ var TOOLS = [
739
836
  // Analysis tools (run at session start / turn end)
740
837
  {
741
838
  id: "madge",
839
+ autoInstall: true,
742
840
  name: "Madge",
743
841
  checkCommand: "madge",
744
842
  checkArgs: ["--version"],
@@ -748,17 +846,19 @@ var TOOLS = [
748
846
  },
749
847
  {
750
848
  id: "jscpd",
849
+ autoInstall: true,
751
850
  name: "jscpd",
752
851
  checkCommand: "jscpd",
753
852
  checkArgs: ["--version"],
754
853
  installStrategy: "npm",
755
- packageName: "jscpd@5.4.2",
756
- // 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.
757
856
  binaryName: "jscpd"
758
857
  },
759
858
  // Structural search and dead code detection
760
859
  {
761
860
  id: "ast-grep",
861
+ autoInstall: true,
762
862
  name: "ast-grep CLI",
763
863
  checkCommand: "ast-grep",
764
864
  checkArgs: ["--version"],
@@ -780,6 +880,7 @@ var TOOLS = [
780
880
  },
781
881
  {
782
882
  id: "knip",
883
+ autoInstall: true,
783
884
  name: "Knip",
784
885
  checkCommand: "knip",
785
886
  checkArgs: ["--version"],
@@ -789,6 +890,7 @@ var TOOLS = [
789
890
  },
790
891
  {
791
892
  id: "yamllint",
893
+ autoInstall: true,
792
894
  name: "yamllint",
793
895
  checkCommand: "yamllint",
794
896
  checkArgs: ["--version"],
@@ -798,6 +900,7 @@ var TOOLS = [
798
900
  },
799
901
  {
800
902
  id: "sqlfluff",
903
+ autoInstall: true,
801
904
  name: "sqlfluff",
802
905
  checkCommand: "sqlfluff",
803
906
  checkArgs: ["--version"],
@@ -881,6 +984,7 @@ var TOOLS = [
881
984
  },
882
985
  {
883
986
  id: "htmlhint",
987
+ autoInstall: true,
884
988
  name: "HTMLHint",
885
989
  checkCommand: "htmlhint",
886
990
  checkArgs: ["--version"],
@@ -890,6 +994,7 @@ var TOOLS = [
890
994
  },
891
995
  {
892
996
  id: "hadolint",
997
+ autoInstall: true,
893
998
  name: "Hadolint",
894
999
  checkCommand: "hadolint",
895
1000
  checkArgs: ["--version"],
@@ -910,6 +1015,7 @@ var TOOLS = [
910
1015
  },
911
1016
  {
912
1017
  id: "helm",
1018
+ autoInstall: true,
913
1019
  name: "Helm",
914
1020
  checkCommand: "helm",
915
1021
  // Probed against helm 4.3.0: `--version` exits 1 ("unknown flag"), `version --short` exits 0.
@@ -946,6 +1052,7 @@ var TOOLS = [
946
1052
  // Opengrep: a single standalone binary per platform on GitHub releases —
947
1053
  // no login, no telemetry (the reason for switching off Semgrep, #111).
948
1054
  id: "opengrep",
1055
+ autoInstall: true,
949
1056
  name: "Opengrep",
950
1057
  checkCommand: "opengrep",
951
1058
  checkArgs: ["--version"],
@@ -1051,6 +1158,7 @@ var TOOLS = [
1051
1158
  },
1052
1159
  {
1053
1160
  id: "markdownlint",
1161
+ autoInstall: true,
1054
1162
  name: "markdownlint-cli2",
1055
1163
  checkCommand: "markdownlint-cli2",
1056
1164
  // `--version` is interpreted as a file glob by markdownlint-cli2. Use
@@ -1062,6 +1170,7 @@ var TOOLS = [
1062
1170
  },
1063
1171
  {
1064
1172
  id: "mypy",
1173
+ autoInstall: true,
1065
1174
  name: "mypy",
1066
1175
  checkCommand: "mypy",
1067
1176
  checkArgs: ["--version"],
@@ -1080,6 +1189,7 @@ var TOOLS = [
1080
1189
  },
1081
1190
  {
1082
1191
  id: "stylelint",
1192
+ autoInstall: true,
1083
1193
  name: "Stylelint",
1084
1194
  checkCommand: "stylelint",
1085
1195
  checkArgs: ["--version"],
@@ -1089,6 +1199,7 @@ var TOOLS = [
1089
1199
  },
1090
1200
  {
1091
1201
  id: "oxlint",
1202
+ autoInstall: true,
1092
1203
  name: "Oxlint",
1093
1204
  checkCommand: "oxlint",
1094
1205
  checkArgs: ["--version"],
@@ -1099,6 +1210,7 @@ var TOOLS = [
1099
1210
  // GitHub release binaries
1100
1211
  {
1101
1212
  id: "shellcheck",
1213
+ autoInstall: true,
1102
1214
  name: "ShellCheck",
1103
1215
  checkCommand: "shellcheck",
1104
1216
  checkArgs: ["--version"],
@@ -1120,6 +1232,7 @@ var TOOLS = [
1120
1232
  },
1121
1233
  {
1122
1234
  id: "shfmt",
1235
+ autoInstall: true,
1123
1236
  name: "shfmt",
1124
1237
  checkCommand: "shfmt",
1125
1238
  checkArgs: ["--version"],
@@ -1188,6 +1301,7 @@ var TOOLS = [
1188
1301
  },
1189
1302
  {
1190
1303
  id: "golangci-lint",
1304
+ autoInstall: true,
1191
1305
  name: "golangci-lint",
1192
1306
  checkCommand: "golangci-lint",
1193
1307
  checkArgs: ["--version"],
@@ -1209,6 +1323,7 @@ var TOOLS = [
1209
1323
  },
1210
1324
  {
1211
1325
  id: "ktlint",
1326
+ autoInstall: true,
1212
1327
  name: "ktlint",
1213
1328
  checkCommand: "ktlint",
1214
1329
  checkArgs: ["--version"],
@@ -1237,6 +1352,7 @@ var TOOLS = [
1237
1352
  // fat JAR — no native binary, no npm package — so it uses the maven strategy
1238
1353
  // (#129). Run via a `java -jar` launcher; requires a JRE.
1239
1354
  id: "ktfmt",
1355
+ autoInstall: true,
1240
1356
  name: "ktfmt",
1241
1357
  checkCommand: "ktfmt",
1242
1358
  checkArgs: ["--version"],
@@ -1255,6 +1371,7 @@ var TOOLS = [
1255
1371
  // NOT a runnable fat JAR — so it uses the archive strategy, not maven
1256
1372
  // (refs #133). Requires a JRE (gated by the runner, not the install).
1257
1373
  id: "spotbugs",
1374
+ autoInstall: true,
1258
1375
  name: "SpotBugs",
1259
1376
  checkCommand: "spotbugs",
1260
1377
  // Probed against spotbugs 4.10.2 (JRE 21): `--version` exits 1 ("Unknown option"), `-version` prints 4.10.2.
@@ -1411,6 +1528,7 @@ var TOOLS = [
1411
1528
  },
1412
1529
  {
1413
1530
  id: "actionlint",
1531
+ autoInstall: true,
1414
1532
  name: "actionlint",
1415
1533
  checkCommand: "actionlint",
1416
1534
  checkArgs: ["--version"],
@@ -1533,6 +1651,7 @@ var TOOLS = [
1533
1651
  },
1534
1652
  {
1535
1653
  id: "tflint",
1654
+ autoInstall: true,
1536
1655
  name: "tflint",
1537
1656
  checkCommand: "tflint",
1538
1657
  checkArgs: ["--version"],
@@ -1553,6 +1672,7 @@ var TOOLS = [
1553
1672
  // Windows arm64 uses the x64 binary through Windows' built-in emulation —
1554
1673
  // there is no terragrunt_windows_arm64.exe upstream.
1555
1674
  id: "terragrunt",
1675
+ autoInstall: true,
1556
1676
  name: "terragrunt",
1557
1677
  checkCommand: "terragrunt",
1558
1678
  checkArgs: ["--version"],
@@ -1600,6 +1720,7 @@ var TOOLS = [
1600
1720
  },
1601
1721
  {
1602
1722
  id: "trivy",
1723
+ autoInstall: true,
1603
1724
  name: "Trivy",
1604
1725
  checkCommand: "trivy",
1605
1726
  checkArgs: ["--version"],
@@ -1623,6 +1744,7 @@ var TOOLS = [
1623
1744
  },
1624
1745
  {
1625
1746
  id: "swiftlint",
1747
+ autoInstall: true,
1626
1748
  name: "SwiftLint",
1627
1749
  checkCommand: "swiftlint",
1628
1750
  checkArgs: ["--version"],
@@ -1642,6 +1764,7 @@ var TOOLS = [
1642
1764
  },
1643
1765
  {
1644
1766
  id: "taplo",
1767
+ autoInstall: true,
1645
1768
  name: "taplo",
1646
1769
  checkCommand: "taplo",
1647
1770
  checkArgs: ["--version"],
@@ -1929,7 +2052,7 @@ async function readProbeCache() {
1929
2052
  if (_probeCache !== null)
1930
2053
  return _probeCache;
1931
2054
  try {
1932
- const raw = await fs2.readFile(PROBE_CACHE_PATH, "utf-8");
2055
+ const raw = await fs3.readFile(PROBE_CACHE_PATH, "utf-8");
1933
2056
  const parsed = JSON.parse(raw);
1934
2057
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1935
2058
  throw new Error("probe-cache root is not an object");
@@ -2110,8 +2233,8 @@ async function checkProbeCache(toolId) {
2110
2233
  return void 0;
2111
2234
  }
2112
2235
  try {
2113
- await fs2.access(entry.path);
2114
- const stat = await fs2.stat(entry.path);
2236
+ await fs3.access(entry.path);
2237
+ const stat = await fs3.stat(entry.path);
2115
2238
  if (stat.mtimeMs !== entry.mtimeMs || entry.sizeBytes !== void 0 && stat.size !== entry.sizeBytes) {
2116
2239
  logSessionStart(`auto-install probe-cache ${toolId}: miss (mtime/size changed)`);
2117
2240
  delete cache[toolId];
@@ -2135,7 +2258,7 @@ async function checkProbeCache(toolId) {
2135
2258
  function updateProbeCache(toolId, resolvedPath, transient = false) {
2136
2259
  const pending = (async () => {
2137
2260
  try {
2138
- const stat = await fs2.stat(resolvedPath);
2261
+ const stat = await fs3.stat(resolvedPath);
2139
2262
  const cache = await readProbeCache();
2140
2263
  const entry = {
2141
2264
  path: resolvedPath,
@@ -2247,7 +2370,7 @@ async function verifyNpmPackageEntry(binPath, packageName) {
2247
2370
  }
2248
2371
  let manifest;
2249
2372
  try {
2250
- manifest = JSON.parse(await fs2.readFile(path3.join(packageDir, "package.json"), "utf8"));
2373
+ manifest = JSON.parse(await fs3.readFile(path3.join(packageDir, "package.json"), "utf8"));
2251
2374
  } catch {
2252
2375
  return fail("package-json-unreadable");
2253
2376
  }
@@ -2405,7 +2528,7 @@ async function getAllToolStatuses(toolIds) {
2405
2528
  const localBase = path3.join(TOOLS_DIR, "node_modules", ".bin", tool.binaryName || tool.id);
2406
2529
  const localPath = installerPlatform() === "win32" ? `${localBase}.cmd` : localBase;
2407
2530
  try {
2408
- await fs2.access(localPath);
2531
+ await fs3.access(localPath);
2409
2532
  if (await verifyToolBinary(localPath, void 0, void 0, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2410
2533
  status.installed = true;
2411
2534
  status.source = "pi-lens-auto";
@@ -2433,7 +2556,7 @@ async function getArchiveTreeBundlePath(tool) {
2433
2556
  const treeMarker = tool.archive && resolveTreeMarker(tool.archive);
2434
2557
  const marker = treeMarker ? path3.join(extractDir, ...treeMarker.split("/")) : extractDir;
2435
2558
  try {
2436
- await fs2.access(marker);
2559
+ await fs3.access(marker);
2437
2560
  return extractDir;
2438
2561
  } catch {
2439
2562
  return void 0;
@@ -2501,7 +2624,7 @@ async function getToolPathResolved(toolId, onTransient, storeOnly) {
2501
2624
  if (installerPlatform() === "win32") {
2502
2625
  const cmdPath = `${localBase}.cmd`;
2503
2626
  try {
2504
- await fs2.access(cmdPath);
2627
+ await fs3.access(cmdPath);
2505
2628
  if (await verifyToolBinary(cmdPath, recordVersion, onTransient, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2506
2629
  return cmdPath;
2507
2630
  }
@@ -2510,7 +2633,7 @@ async function getToolPathResolved(toolId, onTransient, storeOnly) {
2510
2633
  }
2511
2634
  const exePath = `${localBase}.exe`;
2512
2635
  try {
2513
- await fs2.access(exePath);
2636
+ await fs3.access(exePath);
2514
2637
  if (await verifyToolBinary(exePath, recordVersion, onTransient, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2515
2638
  return exePath;
2516
2639
  }
@@ -2520,7 +2643,7 @@ async function getToolPathResolved(toolId, onTransient, storeOnly) {
2520
2643
  }
2521
2644
  if (installerPlatform() !== "win32") {
2522
2645
  try {
2523
- await fs2.access(localBase);
2646
+ await fs3.access(localBase);
2524
2647
  if (await verifyToolBinary(localBase, recordVersion, onTransient, getToolVerificationTimeout(tool), tool.checkArgs, packageEntryVerification(tool))) {
2525
2648
  return localBase;
2526
2649
  }
@@ -2589,7 +2712,7 @@ async function findGitHubToolPath(binaryName) {
2589
2712
  ] : [path3.join(GITHUB_BIN_DIR, binaryName)];
2590
2713
  for (const candidate of candidates) {
2591
2714
  try {
2592
- await fs2.access(candidate);
2715
+ await fs3.access(candidate);
2593
2716
  return candidate;
2594
2717
  } catch {
2595
2718
  }
@@ -2645,7 +2768,7 @@ function getArchiveBinaryCandidates(binaryName, platform, assetName) {
2645
2768
  async function firstVerifiedBinary(candidates, onTransient, verificationArgs, verificationTimeoutMs) {
2646
2769
  for (const candidate of candidates) {
2647
2770
  try {
2648
- await fs2.access(candidate);
2771
+ await fs3.access(candidate);
2649
2772
  if (isUntrustedProjectPath(candidate)) {
2650
2773
  recordProjectCommandRefusal(candidate);
2651
2774
  continue;
@@ -2707,7 +2830,7 @@ async function findPipUserToolPath(binaryName, onTransient, verificationArgs = [
2707
2830
  const scriptDirs = [pipScriptsDir(userBase, installerPlatform())];
2708
2831
  if (isWindows) {
2709
2832
  try {
2710
- const children = await fs2.readdir(userBase, { withFileTypes: true });
2833
+ const children = await fs3.readdir(userBase, { withFileTypes: true });
2711
2834
  for (const entry of children) {
2712
2835
  if (!entry.isDirectory())
2713
2836
  continue;
@@ -2815,7 +2938,7 @@ function sameHost(a, b) {
2815
2938
  }
2816
2939
  function httpsGetWithMeta(url, maxRedirects = 5, headers = {}) {
2817
2940
  return new Promise((resolve, reject) => {
2818
- 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) => {
2819
2942
  if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
2820
2943
  if (maxRedirects === 0)
2821
2944
  return reject(new Error("Too many redirects"));
@@ -2905,20 +3028,27 @@ async function installGitHubTool(tool, prefetchedRelease) {
2905
3028
  }
2906
3029
  logSessionStart(`github-install ${tool.id}: downloading ${asset.name}`);
2907
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()}`);
2908
3037
  const downloadStart = Date.now();
2909
- let assetBuffer;
3038
+ let downloadedBytes = 0;
2910
3039
  try {
2911
- assetBuffer = await httpsGet(asset.browser_download_url);
2912
- 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)`);
2913
3042
  } catch (err) {
2914
- 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}`);
2915
3050
  return void 0;
2916
3051
  }
2917
- await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
2918
- const binaryName = tool.binaryName ?? tool.id;
2919
- const isWindows = platform === "win32";
2920
- const finalBinaryName = getGitHubInstalledBinaryName(binaryName, platform, asset.name);
2921
- let destPath = path3.join(GITHUB_BIN_DIR, finalBinaryName);
2922
3052
  const assetName = asset.name;
2923
3053
  const launcherRuntime = launcherForGitHubAsset(spec, assetName);
2924
3054
  if (launcherRuntime && !await isCommandAvailable(launcherRuntime, ["--version"])) {
@@ -2929,10 +3059,9 @@ async function installGitHubTool(tool, prefetchedRelease) {
2929
3059
  assertManagedBinDirInsidePinnedHome(tool.id);
2930
3060
  if (launcherRuntime) {
2931
3061
  const assetPath = path3.join(GITHUB_BIN_DIR, `${tool.id}${assetName.endsWith(".phar") ? ".phar" : ".jar"}`);
2932
- await writeFileAtomicAsync(assetPath, assetBuffer, {
2933
- bestEffort: false,
2934
- mode: 488
2935
- });
3062
+ await fs3.rename(downloadPath, assetPath);
3063
+ if (!isWindows)
3064
+ await fs3.chmod(assetPath, 488);
2936
3065
  const launcherName = isWindows ? `${binaryName}.bat` : binaryName;
2937
3066
  destPath = path3.join(GITHUB_BIN_DIR, launcherName);
2938
3067
  const runtimeTarget = assetName.endsWith(".phar") ? `${tool.id}.phar` : `${tool.id}.jar`;
@@ -2946,85 +3075,81 @@ exec ${launcherRuntime} "$(dirname "$0")/${runtimeTarget}" "$@"
2946
3075
  mode: isWindows ? void 0 : 488
2947
3076
  });
2948
3077
  } else if (assetName.endsWith(".gz") && !assetName.endsWith(".tar.gz")) {
2949
- const decompressed = await new Promise((resolve, reject) => {
2950
- const gunzip = createGunzip();
2951
- const chunks = [];
2952
- gunzip.on("data", (chunk) => chunks.push(chunk));
2953
- gunzip.on("end", () => resolve(Buffer.concat(chunks)));
2954
- gunzip.on("error", reject);
2955
- gunzip.end(assetBuffer);
2956
- });
2957
- await writeFileAtomicAsync(destPath, decompressed, {
2958
- bestEffort: false,
2959
- mode: 488
2960
- });
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);
2961
3083
  } else if (assetName.endsWith(".tar.gz") || assetName.endsWith(".tar.xz")) {
2962
3084
  const tmpArchive = path3.join(GITHUB_BIN_DIR, `_tmp_${assetName}`);
2963
- await fs2.writeFile(tmpArchive, assetBuffer);
3085
+ await fs3.rename(downloadPath, tmpArchive);
2964
3086
  const tmpDir = path3.join(GITHUB_BIN_DIR, `_tmp_extract_${tool.id}`);
2965
- await fs2.mkdir(tmpDir, { recursive: true });
3087
+ await fs3.mkdir(tmpDir, { recursive: true });
2966
3088
  const extracted = await runCommand("tar", ["xf", tmpArchive, "-C", tmpDir], GITHUB_BIN_DIR);
2967
- await fs2.rm(tmpArchive, { force: true });
3089
+ await fs3.rm(tmpArchive, { force: true });
2968
3090
  if (!extracted) {
2969
- await fs2.rm(tmpDir, { recursive: true, force: true });
3091
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2970
3092
  logSessionStart(`github-install ${tool.id}: tar extraction failed for ${assetName}`);
2971
3093
  return void 0;
2972
3094
  }
2973
3095
  const tarBinaryName = spec.binaryInArchive ?? binaryName;
2974
3096
  const tarSrcBinary = await findFirstFileRecursive(tmpDir, getArchiveBinaryCandidates(tarBinaryName, platform, assetName));
2975
3097
  if (!tarSrcBinary) {
2976
- await fs2.rm(tmpDir, { recursive: true, force: true });
3098
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2977
3099
  logSessionStart(`github-install ${tool.id}: binary candidates ${JSON.stringify(getArchiveBinaryCandidates(tarBinaryName, platform, assetName))} not found in tar ${assetName}`);
2978
3100
  return void 0;
2979
3101
  }
2980
- await fs2.rename(tarSrcBinary, destPath);
2981
- await fs2.rm(tmpDir, { recursive: true, force: true });
3102
+ await fs3.rename(tarSrcBinary, destPath);
3103
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2982
3104
  if (!isWindows)
2983
- await fs2.chmod(destPath, 488);
3105
+ await fs3.chmod(destPath, 488);
2984
3106
  } else if (assetName.endsWith(".zip")) {
2985
3107
  const tmpArchive = path3.join(GITHUB_BIN_DIR, `_tmp_${assetName}`);
2986
- await fs2.writeFile(tmpArchive, assetBuffer);
3108
+ await fs3.rename(downloadPath, tmpArchive);
2987
3109
  const tmpDir = path3.join(GITHUB_BIN_DIR, `_tmp_extract_${tool.id}`);
2988
- await fs2.mkdir(tmpDir, { recursive: true });
3110
+ await fs3.mkdir(tmpDir, { recursive: true });
2989
3111
  const extracted = isWindows ? await runCommand("powershell", [
2990
3112
  "-NoProfile",
2991
3113
  "-Command",
2992
3114
  `Expand-Archive -LiteralPath '${tmpArchive}' -DestinationPath '${tmpDir}' -Force`
2993
3115
  ], GITHUB_BIN_DIR) : await runCommand("unzip", ["-q", "-o", tmpArchive, "-d", tmpDir], GITHUB_BIN_DIR);
2994
- await fs2.rm(tmpArchive, { force: true });
3116
+ await fs3.rm(tmpArchive, { force: true });
2995
3117
  if (!extracted) {
2996
- await fs2.rm(tmpDir, { recursive: true, force: true });
3118
+ await fs3.rm(tmpDir, { recursive: true, force: true });
2997
3119
  logSessionStart(`github-install ${tool.id}: zip extraction failed for ${assetName}`);
2998
3120
  return void 0;
2999
3121
  }
3000
3122
  const archiveBinaryName = spec.binaryInArchive ?? binaryName;
3001
3123
  const srcBinary = await findFirstFileRecursive(tmpDir, getArchiveBinaryCandidates(archiveBinaryName, platform, assetName));
3002
3124
  if (!srcBinary) {
3003
- await fs2.rm(tmpDir, { recursive: true, force: true });
3125
+ await fs3.rm(tmpDir, { recursive: true, force: true });
3004
3126
  logSessionStart(`github-install ${tool.id}: binary candidates ${JSON.stringify(getArchiveBinaryCandidates(archiveBinaryName, platform, assetName))} not found in zip ${assetName}`);
3005
3127
  return void 0;
3006
3128
  }
3007
3129
  if (spec.bundleArchiveDlls) {
3008
3130
  const siblingDir = path3.dirname(srcBinary);
3009
- for (const entry of await fs2.readdir(siblingDir)) {
3131
+ for (const entry of await fs3.readdir(siblingDir)) {
3010
3132
  if (entry.toLowerCase().endsWith(".dll")) {
3011
- await fs2.rename(path3.join(siblingDir, entry), path3.join(GITHUB_BIN_DIR, entry));
3133
+ await fs3.rename(path3.join(siblingDir, entry), path3.join(GITHUB_BIN_DIR, entry));
3012
3134
  }
3013
3135
  }
3014
3136
  }
3015
- await fs2.rename(srcBinary, destPath);
3016
- await fs2.rm(tmpDir, { recursive: true, force: true });
3137
+ await fs3.rename(srcBinary, destPath);
3138
+ await fs3.rm(tmpDir, { recursive: true, force: true });
3017
3139
  if (!isWindows)
3018
- await fs2.chmod(destPath, 488);
3140
+ await fs3.chmod(destPath, 488);
3019
3141
  } else {
3020
- await writeFileAtomicAsync(destPath, assetBuffer, {
3021
- bestEffort: false,
3022
- mode: 488
3023
- });
3142
+ await fs3.rename(downloadPath, destPath);
3143
+ if (!isWindows)
3144
+ await fs3.chmod(destPath, 488);
3024
3145
  }
3025
3146
  } catch (err) {
3147
+ await fs3.rm(downloadPath, { force: true });
3026
3148
  logSessionStart(`github-install ${tool.id}: install failed: ${err.message}`);
3027
3149
  return void 0;
3150
+ } finally {
3151
+ await fs3.rm(downloadPath, { force: true });
3152
+ await fs3.rm(`${downloadPath}.decompressed`, { force: true });
3028
3153
  }
3029
3154
  for (const extraName of spec.extraAssets?.(platform, arch) ?? []) {
3030
3155
  const extraAsset = releaseJson.assets.find((a) => a.name === extraName);
@@ -3032,11 +3157,18 @@ exec ${launcherRuntime} "$(dirname "$0")/${runtimeTarget}" "$@"
3032
3157
  logSessionStart(`github-install ${tool.id}: required extra asset "${extraName}" not found`);
3033
3158
  return void 0;
3034
3159
  }
3160
+ const extraPath = path3.join(GITHUB_BIN_DIR, `.${tool.id}.${extraName}.download-${randomUUID()}`);
3035
3161
  try {
3036
- const extraBuffer = await httpsGet(extraAsset.browser_download_url);
3037
- await writeFileAtomicAsync(path3.join(GITHUB_BIN_DIR, extraName), extraBuffer, { bestEffort: false, mode: 488 });
3038
- 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)`);
3039
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
+ });
3040
3172
  logSessionStart(`github-install ${tool.id}: extra asset ${extraName} download failed: ${err.message}`);
3041
3173
  return void 0;
3042
3174
  }
@@ -3047,7 +3179,7 @@ exec ${launcherRuntime} "$(dirname "$0")/${runtimeTarget}" "$@"
3047
3179
  }
3048
3180
  async function findFirstFileRecursive(dir, names) {
3049
3181
  const wanted = new Set(names.map((name) => name.toLowerCase()));
3050
- const entries = await fs2.readdir(dir, { withFileTypes: true });
3182
+ const entries = await fs3.readdir(dir, { withFileTypes: true });
3051
3183
  for (const entry of entries) {
3052
3184
  const full = path3.join(dir, entry.name);
3053
3185
  if (entry.isDirectory()) {
@@ -3178,7 +3310,7 @@ async function isManagedToolPresent(toolId) {
3178
3310
  if (!tool.packageName)
3179
3311
  return false;
3180
3312
  try {
3181
- await fs2.access(path3.join(TOOLS_DIR, "node_modules", tool.packageName, "package.json"));
3313
+ await fs3.access(path3.join(TOOLS_DIR, "node_modules", tool.packageName, "package.json"));
3182
3314
  return true;
3183
3315
  } catch {
3184
3316
  return false;
@@ -3493,18 +3625,24 @@ async function installMavenTool(tool) {
3493
3625
  const url = `${base}/${groupPath}/${spec.artifactId}/${spec.version}/${jarFile}`;
3494
3626
  lastInstallResolutionId.set(tool.id, mavenCoordinate(spec));
3495
3627
  logSessionStart(`maven-install ${tool.id}: downloading ${url}`);
3496
- let jarBuffer;
3628
+ await fs3.mkdir(GITHUB_BIN_DIR, { recursive: true });
3629
+ const jarDownloadPath = path3.join(GITHUB_BIN_DIR, `.${tool.id}.jar-${randomUUID()}`);
3497
3630
  try {
3498
- jarBuffer = await httpsGet(url);
3631
+ await downloadInstallerFile(url, jarDownloadPath);
3499
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
+ });
3500
3639
  logSessionStart(`maven-install ${tool.id}: download failed: ${err.message}`);
3501
3640
  return void 0;
3502
3641
  }
3503
3642
  try {
3504
- await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
3505
3643
  assertManagedBinDirInsidePinnedHome(tool.id);
3506
3644
  const jarPath = path3.join(GITHUB_BIN_DIR, `${tool.id}.jar`);
3507
- await writeFileAtomicAsync(jarPath, jarBuffer, { bestEffort: false });
3645
+ await fs3.rename(jarDownloadPath, jarPath);
3508
3646
  const launcherName = isWindows ? `${binaryName}.bat` : binaryName;
3509
3647
  const launcherPath = path3.join(GITHUB_BIN_DIR, launcherName);
3510
3648
  if (isWindows) {
@@ -3516,10 +3654,11 @@ java -jar "%~dp0${tool.id}.jar" %*\r
3516
3654
  exec java -jar "$(dirname "$0")/${tool.id}.jar" "$@"
3517
3655
  `, { bestEffort: false, mode: 488 });
3518
3656
  }
3519
- logSessionStart(`maven-install ${tool.id}: installed \u2192 ${launcherPath} (${jarBuffer.length} bytes)`);
3657
+ logSessionStart(`maven-install ${tool.id}: installed \u2192 ${launcherPath}`);
3520
3658
  debugLog(`[maven] installed ${tool.name} \u2192 ${launcherPath}`);
3521
3659
  return launcherPath;
3522
3660
  } catch (err) {
3661
+ await fs3.rm(jarDownloadPath, { force: true });
3523
3662
  logSessionStart(`maven-install ${tool.id}: install failed: ${err.message}`);
3524
3663
  return void 0;
3525
3664
  }
@@ -3542,34 +3681,34 @@ function recordArchiveExtractionDegradation(toolId, format, reason) {
3542
3681
  }
3543
3682
  async function stripExtractedArchiveRoot(dir, components) {
3544
3683
  for (let i = 0; i < components; i++) {
3545
- const entries = await fs2.readdir(dir, { withFileTypes: true });
3684
+ const entries = await fs3.readdir(dir, { withFileTypes: true });
3546
3685
  const [entry] = entries;
3547
3686
  if (entries.length !== 1 || !entry?.isDirectory())
3548
3687
  return false;
3549
3688
  const root = path3.join(dir, entry.name);
3550
- for (const child of await fs2.readdir(root))
3551
- await fs2.rename(path3.join(root, child), path3.join(dir, child));
3552
- await fs2.rm(root, { recursive: true, force: true });
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 });
3553
3692
  }
3554
3693
  return true;
3555
3694
  }
3556
3695
  async function swapExtractedDir(toolId, tmpDir, finalDir) {
3557
3696
  const backupDir = `${finalDir}.rollback`;
3558
- await fs2.rm(backupDir, { recursive: true, force: true });
3697
+ await fs3.rm(backupDir, { recursive: true, force: true });
3559
3698
  let hadPrevious = false;
3560
3699
  try {
3561
- await fs2.rename(finalDir, backupDir);
3700
+ await fs3.rename(finalDir, backupDir);
3562
3701
  hadPrevious = true;
3563
3702
  } catch (err) {
3564
3703
  if (err.code !== "ENOENT")
3565
3704
  throw err;
3566
3705
  }
3567
3706
  try {
3568
- await fs2.rename(tmpDir, finalDir);
3707
+ await fs3.rename(tmpDir, finalDir);
3569
3708
  } catch (err) {
3570
3709
  if (hadPrevious) {
3571
3710
  try {
3572
- await fs2.rename(backupDir, finalDir);
3711
+ await fs3.rename(backupDir, finalDir);
3573
3712
  } catch (rollbackErr) {
3574
3713
  recordDegradationOnce({
3575
3714
  kind: "managed-tool-refresh",
@@ -3582,7 +3721,7 @@ async function swapExtractedDir(toolId, tmpDir, finalDir) {
3582
3721
  throw err;
3583
3722
  }
3584
3723
  if (hadPrevious) {
3585
- await fs2.rm(backupDir, { recursive: true, force: true }).catch(() => {
3724
+ await fs3.rm(backupDir, { recursive: true, force: true }).catch(() => {
3586
3725
  });
3587
3726
  }
3588
3727
  }
@@ -3620,15 +3759,24 @@ async function installArchiveTool(tool) {
3620
3759
  }
3621
3760
  lastInstallResolutionId.set(tool.id, url);
3622
3761
  logSessionStart(`archive-install ${tool.id}: downloading ${url}`);
3623
- 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 = "";
3624
3766
  try {
3625
- archiveBuffer = await httpsGet(url);
3767
+ ({ bytes: archiveBytes, sha256: archiveDigest } = await downloadInstallerFile(url, archiveDownloadPath));
3626
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
+ });
3627
3775
  logSessionStart(`archive-install ${tool.id}: download failed: ${err.message}`);
3628
3776
  return void 0;
3629
3777
  }
3630
3778
  const pinned = spec.sha256?.[url];
3631
- const digest = hashContentBytes(archiveBuffer);
3779
+ const digest = archiveDigest;
3632
3780
  if (digest !== pinned) {
3633
3781
  const reason = pinned === void 0 ? "sha256-unpinned" : "sha256-mismatch";
3634
3782
  recordDegradationOnce({
@@ -3636,8 +3784,9 @@ async function installArchiveTool(tool) {
3636
3784
  subject: `${tool.id}:${archiveKind}:integrity`,
3637
3785
  reason: `archive integrity ${reason}`
3638
3786
  });
3639
- installFailureReasons.set(tool.id, `archive integrity ${reason} (${archiveBuffer.length} bytes from ${url})`);
3787
+ installFailureReasons.set(tool.id, `archive integrity ${reason} (${archiveBytes} bytes from ${url})`);
3640
3788
  logSessionStart(`archive-install ${tool.id}: refused ${reason} (got ${digest}, pinned ${pinned ?? "none"}) \u2014 keeping installed version`);
3789
+ await fs3.rm(archiveDownloadPath, { force: true });
3641
3790
  return void 0;
3642
3791
  }
3643
3792
  const extractName = tool.id;
@@ -3647,10 +3796,10 @@ async function installArchiveTool(tool) {
3647
3796
  const tmpExtractDir = path3.join(TOOLS_DIR, tmpExtractName);
3648
3797
  const tmpArchive = path3.join(TOOLS_DIR, archiveName);
3649
3798
  try {
3650
- await fs2.mkdir(TOOLS_DIR, { recursive: true });
3651
- await fs2.rm(tmpExtractDir, { recursive: true, force: true });
3652
- await fs2.mkdir(tmpExtractDir, { recursive: true });
3653
- 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);
3654
3803
  const stripComponents = spec.stripComponents ?? 1;
3655
3804
  const extractionArgs = archiveKind === "zip" && isWindows ? [
3656
3805
  "-NoProfile",
@@ -3674,18 +3823,18 @@ async function installArchiveTool(tool) {
3674
3823
  ok: extractionResult.status === 0,
3675
3824
  reason: extractionResult.spawnFailure?.kind === "tool-not-found" ? "extractor-unavailable" : extractionResult.spawnFailure ? "extractor-error" : "extractor-exit"
3676
3825
  };
3677
- await fs2.rm(tmpArchive, { force: true });
3826
+ await fs3.rm(tmpArchive, { force: true });
3678
3827
  if (!extracted.ok) {
3679
3828
  recordArchiveExtractionDegradation(tool.id, archiveKind, extracted.reason);
3680
3829
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} extraction failed (${extracted.reason}) \u2014 keeping installed version`);
3681
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3830
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3682
3831
  });
3683
3832
  return void 0;
3684
3833
  }
3685
3834
  if (archiveKind === "zip" && !await stripExtractedArchiveRoot(tmpExtractDir, stripComponents)) {
3686
3835
  recordArchiveExtractionDegradation(tool.id, archiveKind, "layout-invalid");
3687
3836
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} layout invalid \u2014 keeping installed version`);
3688
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3837
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3689
3838
  });
3690
3839
  return void 0;
3691
3840
  }
@@ -3693,16 +3842,16 @@ async function installArchiveTool(tool) {
3693
3842
  const treeMarker = resolveTreeMarker(spec, platform);
3694
3843
  const tmpMarker = treeMarker ? path3.join(tmpExtractDir, ...treeMarker.split("/")) : tmpExtractDir;
3695
3844
  try {
3696
- await fs2.access(tmpMarker);
3845
+ await fs3.access(tmpMarker);
3697
3846
  } catch {
3698
3847
  recordArchiveExtractionDegradation(tool.id, archiveKind, "marker-missing");
3699
3848
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} marker missing after extraction \u2014 keeping installed version`);
3700
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3849
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3701
3850
  });
3702
3851
  return void 0;
3703
3852
  }
3704
3853
  await swapExtractedDir(tool.id, tmpExtractDir, extractDir);
3705
- 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})`);
3706
3855
  debugLog(`[archive] installed ${tool.name} bundle \u2192 ${extractDir}`);
3707
3856
  return extractDir;
3708
3857
  }
@@ -3710,27 +3859,27 @@ async function installArchiveTool(tool) {
3710
3859
  const tmpInnerLauncher = path3.join(tmpExtractDir, ...launcherParts);
3711
3860
  const tmpResolvedInner = isWindows ? `${tmpInnerLauncher}.bat` : tmpInnerLauncher;
3712
3861
  try {
3713
- await fs2.access(tmpResolvedInner);
3862
+ await fs3.access(tmpResolvedInner);
3714
3863
  } catch {
3715
3864
  recordArchiveExtractionDegradation(tool.id, archiveKind, "launcher-missing");
3716
3865
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} launcher missing after extraction \u2014 keeping installed version`);
3717
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3866
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3718
3867
  });
3719
3868
  return void 0;
3720
3869
  }
3721
3870
  if (!isWindows)
3722
- await fs2.chmod(tmpResolvedInner, 488).catch(() => {
3871
+ await fs3.chmod(tmpResolvedInner, 488).catch(() => {
3723
3872
  });
3724
- const launcherStat = await fs2.stat(tmpResolvedInner).catch(() => void 0);
3873
+ const launcherStat = await fs3.stat(tmpResolvedInner).catch(() => void 0);
3725
3874
  const launcherRunnable = launcherStat?.isFile() === true && launcherStat.size > 0 && (isWindows || (launcherStat.mode & 73) !== 0);
3726
3875
  if (!launcherRunnable) {
3727
3876
  recordArchiveExtractionDegradation(tool.id, archiveKind, "launcher-invalid");
3728
3877
  logSessionStart(`archive-install ${tool.id}: ${archiveKind} launcher is empty or not executable \u2014 keeping installed version`);
3729
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3878
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3730
3879
  });
3731
3880
  return void 0;
3732
3881
  }
3733
- await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
3882
+ await fs3.mkdir(GITHUB_BIN_DIR, { recursive: true });
3734
3883
  assertManagedBinDirInsidePinnedHome(tool.id);
3735
3884
  await swapExtractedDir(tool.id, tmpExtractDir, extractDir);
3736
3885
  const innerLauncher = path3.join(extractDir, ...launcherParts);
@@ -3746,13 +3895,15 @@ call "${resolvedInner}" %*\r
3746
3895
  exec "${resolvedInner}" "$@"
3747
3896
  `, { bestEffort: false, mode: 488 });
3748
3897
  }
3749
- 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})`);
3750
3899
  debugLog(`[archive] installed ${tool.name} \u2192 ${shimPath}`);
3751
3900
  return shimPath;
3752
3901
  } catch (err) {
3753
- await fs2.rm(tmpArchive, { force: true }).catch(() => {
3902
+ await fs3.rm(archiveDownloadPath, { force: true }).catch(() => {
3903
+ });
3904
+ await fs3.rm(tmpArchive, { force: true }).catch(() => {
3754
3905
  });
3755
- await fs2.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3906
+ await fs3.rm(tmpExtractDir, { recursive: true, force: true }).catch(() => {
3756
3907
  });
3757
3908
  logSessionStart(`archive-install ${tool.id}: install failed: ${err.message} \u2014 keeping installed version`);
3758
3909
  return void 0;
@@ -3791,10 +3942,10 @@ async function installNpmTool(toolId, packageName, binaryName, verificationArgs
3791
3942
  }
3792
3943
  };
3793
3944
  try {
3794
- await fs2.mkdir(TOOLS_DIR, { recursive: true });
3945
+ await fs3.mkdir(TOOLS_DIR, { recursive: true });
3795
3946
  const packageJsonPath = path3.join(TOOLS_DIR, "package.json");
3796
3947
  try {
3797
- await fs2.access(packageJsonPath);
3948
+ await fs3.access(packageJsonPath);
3798
3949
  } catch {
3799
3950
  await writeFileAtomicAsync(packageJsonPath, JSON.stringify({ name: "pi-lens-tools", version: "1.0.0" }, null, 2), { bestEffort: false });
3800
3951
  }
@@ -3844,7 +3995,7 @@ async function installNpmTool(toolId, packageName, binaryName, verificationArgs
3844
3995
  const binPath = installerPlatform() === "win32" ? `${binBase}.cmd` : binBase;
3845
3996
  if (installerPlatform() !== "win32") {
3846
3997
  try {
3847
- await fs2.chmod(binPath, 488);
3998
+ await fs3.chmod(binPath, 488);
3848
3999
  } catch {
3849
4000
  }
3850
4001
  }
@@ -3883,11 +4034,11 @@ async function installNpmTool(toolId, packageName, binaryName, verificationArgs
3883
4034
  logSessionStart(`auto-install ${packageName}: installed but verification failed, cleaning up`);
3884
4035
  try {
3885
4036
  const packagePath = path3.join(TOOLS_DIR, "node_modules", packageName);
3886
- await fs2.rm(packagePath, { recursive: true, force: true });
3887
- await fs2.rm(binBase, { force: true });
4037
+ await fs3.rm(packagePath, { recursive: true, force: true });
4038
+ await fs3.rm(binBase, { force: true });
3888
4039
  if (isWindows) {
3889
- await fs2.rm(`${binBase}.cmd`, { force: true });
3890
- await fs2.rm(`${binBase}.ps1`, { force: true });
4040
+ await fs3.rm(`${binBase}.cmd`, { force: true });
4041
+ await fs3.rm(`${binBase}.ps1`, { force: true });
3891
4042
  }
3892
4043
  } catch {
3893
4044
  }
@@ -3932,7 +4083,7 @@ async function pipConstraintEnvFor(toolId) {
3932
4083
  }
3933
4084
  const file = path3.join(directory, `${toolId}.txt`);
3934
4085
  try {
3935
- await fs2.mkdir(path3.dirname(file), { recursive: true });
4086
+ await fs3.mkdir(path3.dirname(file), { recursive: true });
3936
4087
  await writeFileAtomicAsync(file, `${constraints.join("\n")}
3937
4088
  `, {
3938
4089
  bestEffort: false
@@ -4022,7 +4173,7 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4022
4173
  };
4023
4174
  const addBinToPath = async (binDir) => {
4024
4175
  try {
4025
- await fs2.access(binDir);
4176
+ await fs3.access(binDir);
4026
4177
  } catch {
4027
4178
  return void 0;
4028
4179
  }
@@ -4038,7 +4189,7 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4038
4189
  for (const name of names) {
4039
4190
  const candidate = path3.join(binDir, name);
4040
4191
  try {
4041
- await fs2.access(candidate);
4192
+ await fs3.access(candidate);
4042
4193
  return candidate;
4043
4194
  } catch {
4044
4195
  }
@@ -4070,7 +4221,7 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4070
4221
  const venvBin = pipScriptsDir(venvRoot, installerPlatform());
4071
4222
  let venvPip = path3.join(venvBin, isWindows ? "pip.exe" : "pip");
4072
4223
  try {
4073
- await fs2.access(venvPip);
4224
+ await fs3.access(venvPip);
4074
4225
  } catch {
4075
4226
  const created = await run(candidate.command, ["-m", "venv", venvRoot]);
4076
4227
  const error2 = (created.error?.message ?? created.stderr).trim();
@@ -4080,11 +4231,11 @@ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
4080
4231
  }
4081
4232
  }
4082
4233
  try {
4083
- await fs2.access(venvPip);
4234
+ await fs3.access(venvPip);
4084
4235
  } catch {
4085
4236
  venvPip = path3.join(venvBin, isWindows ? "pip.cmd" : "pip3");
4086
4237
  try {
4087
- await fs2.access(venvPip);
4238
+ await fs3.access(venvPip);
4088
4239
  } catch {
4089
4240
  continue;
4090
4241
  }
@@ -4170,7 +4321,7 @@ async function stampInstallResolution(toolId) {
4170
4321
  return;
4171
4322
  try {
4172
4323
  const resolutionId = lastInstallResolutionId.get(toolId);
4173
- const refresh = await import("./chunk-HKRESBMC.js");
4324
+ const refresh = await import("./chunk-RURPX2YV.js");
4174
4325
  await refresh.stampManagedToolInstall(toolId, resolutionId);
4175
4326
  } catch {
4176
4327
  }
@@ -4183,7 +4334,7 @@ async function finishInstallAttempt(toolId, ok, startedAt) {
4183
4334
  if (ok) {
4184
4335
  resetSafeSpawnWindowsCommandCache();
4185
4336
  try {
4186
- const { resetMadgeManagedPathMemo } = await import("./chunk-UWBD3JMH.js");
4337
+ const { resetMadgeManagedPathMemo } = await import("./chunk-TB5MGZLS.js");
4187
4338
  resetMadgeManagedPathMemo();
4188
4339
  } catch (err) {
4189
4340
  logSessionStart(`auto-install ${toolId}: madge memo reset failed: ${err.message}`);
@@ -4213,7 +4364,7 @@ async function installTool(toolId, ownsLock) {
4213
4364
  return false;
4214
4365
  const npmPath = await installNpmTool(tool.id, tool.packageName, tool.binaryName, tool.checkArgs, getToolVerificationTimeout(tool), packageEntryVerification(tool), ownsLock);
4215
4366
  if (npmPath !== void 0) {
4216
- await import("./chunk-HKRESBMC.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(() => {
4217
4368
  });
4218
4369
  }
4219
4370
  return finishInstallAttempt(tool.id, npmPath !== void 0, startedAt);
@@ -4352,7 +4503,7 @@ async function ensureToolResolved(toolId, opts) {
4352
4503
  return cached;
4353
4504
  }
4354
4505
  try {
4355
- await fs2.access(cached);
4506
+ await fs3.access(cached);
4356
4507
  lastEnsureResolutionSource.set(toolId, "session-cache");
4357
4508
  return cached;
4358
4509
  } catch {