pi-lens 4.4.3 → 4.4.5

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 (185) hide show
  1. package/CHANGELOG.md +721 -0
  2. package/README.md +25 -3
  3. package/config/dependency-cruiser-eager-allowlist.json +1 -0
  4. package/dist/chunk-22Y2BM7H.js +23 -0
  5. package/dist/{chunk-WU567RSC.js → chunk-27VWVB23.js} +16 -14
  6. package/dist/{chunk-FLKWCIZH.js → chunk-2FYKETQJ.js} +10 -6
  7. package/dist/{chunk-MQLUAEOC.js → chunk-2LDMXL2M.js} +2 -2
  8. package/dist/{chunk-YSZNHOBY.js → chunk-2SDHYHHO.js} +17 -17
  9. package/dist/chunk-2Y6OJRSI.js +38 -0
  10. package/dist/chunk-3SNDVPOR.js +507 -0
  11. package/dist/{chunk-EJIUXPBX.js → chunk-3WCEHYOI.js} +1 -1
  12. package/dist/chunk-44X7VIKR.js +73 -0
  13. package/dist/{chunk-Q7DUK4LX.js → chunk-4FHUGDKU.js} +16 -14
  14. package/dist/{chunk-H6MF6EVN.js → chunk-4ODSZ35Z.js} +1498 -534
  15. package/dist/{chunk-ZGDGW2V3.js → chunk-4U7GDSZQ.js} +2 -2
  16. package/dist/chunk-54NIOJJZ.js +25 -0
  17. package/dist/{chunk-ZWFS3OEF.js → chunk-5DKE4HGX.js} +38 -37
  18. package/dist/{chunk-VRZP76YM.js → chunk-5LRUKYFA.js} +34 -4
  19. package/dist/{chunk-QOBUHWHX.js → chunk-63NMUNYP.js} +12 -16
  20. package/dist/{chunk-VWCXW2E7.js → chunk-6XSESGWD.js} +13 -6
  21. package/dist/{chunk-QGQ5CCCG.js → chunk-72J27ICO.js} +2 -3
  22. package/dist/{chunk-CSHFH5IN.js → chunk-7FLRUH6B.js} +1 -1
  23. package/dist/chunk-7IYC4ENJ.js +297 -0
  24. package/dist/chunk-7WWQAW5P.js +30 -0
  25. package/dist/{chunk-EU63SDCG.js → chunk-7ZS7MC24.js} +885 -451
  26. package/dist/{chunk-KBG47GHP.js → chunk-AHWA4AKM.js} +18 -12
  27. package/dist/{chunk-FMSO6RDZ.js → chunk-AI3GP74G.js} +17 -19
  28. package/dist/chunk-APFJKOP6.js +67 -0
  29. package/dist/{chunk-RXCOMYPY.js → chunk-ASRAO7KG.js} +31 -33
  30. package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
  31. package/dist/{chunk-QILIYSJF.js → chunk-CG5V25HX.js} +1 -1
  32. package/dist/chunk-CKEQFGLT.js +32 -0
  33. package/dist/{chunk-RPLINGVB.js → chunk-COOUUC5W.js} +6 -6
  34. package/dist/{chunk-GBPP5P7X.js → chunk-CPZ5JJW6.js} +4 -4
  35. package/dist/{chunk-OCAGUNBC.js → chunk-DS2USX5G.js} +13 -15
  36. package/dist/chunk-EA2ZRG44.js +27 -0
  37. package/dist/{chunk-ZHFZWTZV.js → chunk-EDMLIW6W.js} +13 -14
  38. package/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
  39. package/dist/chunk-EKNWOL2I.js +27 -0
  40. package/dist/{chunk-CMMHNUZ2.js → chunk-ELZRSR5N.js} +65 -43
  41. package/dist/{chunk-BKE7E7TC.js → chunk-EN5AM7PX.js} +11 -12
  42. package/dist/{chunk-N2H3ZPZY.js → chunk-EWXXLS26.js} +227 -24
  43. package/dist/chunk-EX4EXBW7.js +37 -0
  44. package/dist/{chunk-YYOIQFRS.js → chunk-EXVXBSGN.js} +130 -52
  45. package/dist/{chunk-6GFRNVYR.js → chunk-F7BO6FWH.js} +12 -13
  46. package/dist/chunk-FEDWAYDS.js +2485 -0
  47. package/dist/{chunk-JAU72XNY.js → chunk-FWZRGGGY.js} +73 -9
  48. package/dist/{chunk-GXW6K4YJ.js → chunk-G224FADB.js} +1 -1
  49. package/dist/chunk-G5UCJFT7.js +26 -0
  50. package/dist/{chunk-67WMNWEE.js → chunk-GLW3YDZZ.js} +22 -13
  51. package/dist/{chunk-724UL2TJ.js → chunk-GTDSYEA2.js} +72 -39
  52. package/dist/{chunk-PHDMFAKM.js → chunk-GYRZ72R4.js} +10 -4
  53. package/dist/chunk-HYVXA3BB.js +49 -0
  54. package/dist/{chunk-SAEFPSB6.js → chunk-IEBJF3PN.js} +23 -15
  55. package/dist/chunk-IJYGIDF4.js +186 -0
  56. package/dist/{chunk-ACXEQZOU.js → chunk-IL7K66ZQ.js} +101 -109
  57. package/dist/{chunk-ZXYDQ3TZ.js → chunk-JWOVP5BL.js} +50 -19
  58. package/dist/{chunk-OXXKQCSV.js → chunk-K2GUZ4DN.js} +4 -4
  59. package/dist/{chunk-AW7R2GWG.js → chunk-K4SZB56V.js} +39 -39
  60. package/dist/{chunk-WOA4LN2R.js → chunk-KCBRHV5E.js} +3 -3
  61. package/dist/{chunk-3W7IEVVL.js → chunk-KFXCL4OV.js} +47 -45
  62. package/dist/{chunk-2BBLFX75.js → chunk-KJJAVH3X.js} +81 -15
  63. package/dist/{chunk-VCHXCQFG.js → chunk-KPVLQHCZ.js} +4 -6
  64. package/dist/{chunk-P7266HLM.js → chunk-KX56K73G.js} +10 -13
  65. package/dist/{chunk-VSSBEUFT.js → chunk-LMCTHJ2H.js} +19 -19
  66. package/dist/{chunk-IBGIOBEE.js → chunk-MEFLGBCS.js} +69 -8
  67. package/dist/{chunk-TYM6OUIT.js → chunk-MKPCELNI.js} +17 -17
  68. package/dist/{chunk-XTMJ7XDT.js → chunk-N3PLNNCW.js} +1 -1
  69. package/dist/chunk-N5FBM25N.js +22 -0
  70. package/dist/{chunk-CHOW74WE.js → chunk-NFNVDDGB.js} +7 -12
  71. package/dist/{chunk-52FUZI6K.js → chunk-NLIVE7L6.js} +2 -30
  72. package/dist/{chunk-SS36ZX4J.js → chunk-OMJ3OFBJ.js} +6 -6
  73. package/dist/{chunk-4W4VLAPJ.js → chunk-OZNCKLOX.js} +13 -14
  74. package/dist/chunk-P5XUGPIX.js +31 -0
  75. package/dist/{chunk-5UCAH366.js → chunk-PJXNTPB2.js} +253 -33
  76. package/dist/chunk-PKOXJIVT.js +88 -0
  77. package/dist/{chunk-6C7JWPCP.js → chunk-PP2A5V2T.js} +27 -26
  78. package/dist/{chunk-L3BLXZG7.js → chunk-Q42LJANT.js} +31 -70
  79. package/dist/{chunk-AB3YYG6N.js → chunk-Q4BKKOVC.js} +8 -8
  80. package/dist/{chunk-3EFKIGZN.js → chunk-QT66NEYN.js} +4 -4
  81. package/dist/{chunk-3VPVG5SU.js → chunk-RCHO5W7M.js} +19 -18
  82. package/dist/{chunk-77M37OKR.js → chunk-RG3MXTRI.js} +7 -7
  83. package/dist/chunk-RG7OODGM.js +57 -0
  84. package/dist/{chunk-T6CPIZNT.js → chunk-RU34BA4D.js} +44 -39
  85. package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
  86. package/dist/{chunk-5NGR67U5.js → chunk-S55TEC7I.js} +33 -5
  87. package/dist/{chunk-M6HSLBWY.js → chunk-SJHC3BCZ.js} +7956 -8047
  88. package/dist/{chunk-XCJN5IJU.js → chunk-SNEUMLM7.js} +4 -4
  89. package/dist/{chunk-UZ3TUTRV.js → chunk-T4NGVFYI.js} +2 -2
  90. package/dist/{chunk-2VUQMUMT.js → chunk-THEXI2QO.js} +49 -43
  91. package/dist/{chunk-R3PCY3YS.js → chunk-TL2TCJYL.js} +15 -16
  92. package/dist/{chunk-C34ZXZ7O.js → chunk-TPYYEDP5.js} +838 -352
  93. package/dist/{chunk-AOHZU2BM.js → chunk-TVZRLTG6.js} +8 -1
  94. package/dist/{chunk-XMSXXAHW.js → chunk-UCVMSOXF.js} +2 -2
  95. package/dist/chunk-UL5SXQVX.js +32 -0
  96. package/dist/{chunk-GAEGEPOC.js → chunk-UO66IMVP.js} +2 -2
  97. package/dist/{chunk-N3X6Q4YT.js → chunk-UVY4TOJH.js} +3 -3
  98. package/dist/{chunk-2CD5RS6M.js → chunk-VIDEKABZ.js} +23 -2
  99. package/dist/{chunk-JSQFTSC6.js → chunk-VITFDI3O.js} +13 -14
  100. package/dist/{chunk-YIUAVF7E.js → chunk-VUAVE3QC.js} +42 -42
  101. package/dist/{chunk-QOZXJ4NA.js → chunk-WUY4BZEP.js} +21 -20
  102. package/dist/{chunk-VCO24T4L.js → chunk-X3UTCXAA.js} +43 -53
  103. package/dist/chunk-XHDBJODR.js +45 -0
  104. package/dist/{chunk-MXGY6KPT.js → chunk-XHLK33VM.js} +28 -21
  105. package/dist/{chunk-RWWYJ623.js → chunk-XI34NWDI.js} +2 -2
  106. package/dist/{chunk-QQNQ7SJW.js → chunk-XWFIHYCH.js} +12 -4
  107. package/dist/{chunk-6SDEP3AJ.js → chunk-Y2TPADJR.js} +10 -11
  108. package/dist/{chunk-MRXKYPCS.js → chunk-Y5KTA2OB.js} +17 -17
  109. package/dist/{chunk-7DYBLXYA.js → chunk-YKVDBNPO.js} +11 -5
  110. package/dist/{chunk-2B73ZPOK.js → chunk-YSDPVDFC.js} +3 -3
  111. package/dist/chunk-YWNO5Q4R.js +44 -0
  112. package/dist/{chunk-QHJ6DQ2R.js → chunk-YWWG4AQA.js} +165 -32
  113. package/dist/{chunk-3JNKMP3B.js → chunk-YXDCRUKQ.js} +4 -4
  114. package/dist/{chunk-UXGETRP4.js → chunk-YXGRRORB.js} +16 -17
  115. package/dist/{chunk-SQ4TVJBR.js → chunk-ZAPSUBLU.js} +13 -7
  116. package/dist/{chunk-76MWC2K6.js → chunk-ZPJM7DID.js} +90 -97
  117. package/dist/{chunk-XVF2VVXP.js → chunk-ZSUX7KEM.js} +16 -15
  118. package/dist/index.js +31038 -20893
  119. package/dist/mcp/analyze-cli.js +11 -11
  120. package/dist/mcp/cli.js +47 -43
  121. package/dist/mcp/server.js +2188 -906
  122. package/dist/mcp/worker.js +66 -63
  123. package/dist/probes/installer.js +21 -23
  124. package/dist/workers/project-snapshot-persist-worker.js +28 -9
  125. package/dist/workers/review-graph-persist-worker.js +1 -1
  126. package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
  127. package/docs/adr/README.md +1 -0
  128. package/docs/ast-grep_rules_catalog.md +5 -3
  129. package/docs/configuration.md +20 -0
  130. package/docs/engineering-principles.md +44 -0
  131. package/docs/environment-variables.md +20 -0
  132. package/docs/features.md +16 -1
  133. package/docs/globalconfig.md +37 -8
  134. package/docs/lsp-capability-matrix.md +105 -12
  135. package/docs/lsp-idle-eviction.md +44 -36
  136. package/docs/pi-lens-fixer.md +139 -14
  137. package/docs/pi-lens-investigator.md +14 -0
  138. package/docs/pi-lens-merge-policy.md +120 -17
  139. package/docs/pi-lens-monitor.md +71 -9
  140. package/docs/pi-lens-retro.md +6 -3
  141. package/docs/pi-lens-reviewer.md +160 -5
  142. package/docs/pi-lens-subagent.md +29 -14
  143. package/docs/release-qa-baseline.md +21 -7
  144. package/docs/servercapabilities.md +53 -63
  145. package/docs/settings.md +9 -5
  146. package/docs/subagent-compat.md +1 -1
  147. package/docs/usage.md +1 -0
  148. package/package.json +9 -5
  149. package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
  150. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
  151. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
  152. package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
  153. package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
  154. package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
  155. package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
  156. package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
  157. package/rules/rule-catalog.json +25 -1
  158. package/scripts/analyze-pi-lens-logs.mjs +15 -5
  159. package/scripts/download-grammars.js +40 -7
  160. package/scripts/lib/is-main-module.mjs +27 -0
  161. package/scripts/lib/latency-log-phases.mjs +95 -0
  162. package/scripts/lib/scratch-home-env.mjs +21 -0
  163. package/scripts/rpc-load-check.mjs +568 -81
  164. package/scripts/warm-loader-cache.mjs +2 -5
  165. package/dist/chunk-23WOO7TX.js +0 -23
  166. package/dist/chunk-3YN6V5TV.js +0 -85
  167. package/dist/chunk-466Z26MG.js +0 -30
  168. package/dist/chunk-4UNXBNE2.js +0 -24
  169. package/dist/chunk-6STA6Z7I.js +0 -47
  170. package/dist/chunk-ABBOA7UD.js +0 -157
  171. package/dist/chunk-BRGDSBJE.js +0 -28
  172. package/dist/chunk-EC47DWFA.js +0 -56
  173. package/dist/chunk-FCSOVF55.js +0 -273
  174. package/dist/chunk-IZSHAIJ7.js +0 -26
  175. package/dist/chunk-KDERNTCQ.js +0 -28
  176. package/dist/chunk-KSX3TXSZ.js +0 -69
  177. package/dist/chunk-LOP6GRPH.js +0 -31
  178. package/dist/chunk-PNQDPDRC.js +0 -184
  179. package/dist/chunk-UOPVJQ4N.js +0 -103
  180. package/dist/chunk-XAGLWMJ4.js +0 -51
  181. package/dist/chunk-XIJZVPD5.js +0 -39
  182. package/dist/chunk-Z3CCVDUB.js +0 -76
  183. package/dist/chunk-Z527N6YQ.js +0 -28
  184. package/dist/chunk-ZANLILYD.js +0 -79
  185. /package/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
@@ -3,30 +3,32 @@ import {
3
3
  deserializeWordIndex,
4
4
  recordPersistedWordIndexWireBytes,
5
5
  serializeWordIndex
6
- } from "./chunk-SAEFPSB6.js";
6
+ } from "./chunk-IEBJF3PN.js";
7
7
  import {
8
8
  fingerprintProjectSnapshotJson
9
9
  } from "./chunk-2BEMIWEW.js";
10
+ import {
11
+ readGzipStageWorkerResult,
12
+ reapStageFile
13
+ } from "./chunk-IJYGIDF4.js";
10
14
  import {
11
15
  getProjectDataDir,
12
16
  isStaleStageFile,
13
17
  withGenerationLockSync
14
- } from "./chunk-C34ZXZ7O.js";
18
+ } from "./chunk-TPYYEDP5.js";
15
19
  import {
16
20
  writeFileAtomic
17
- } from "./chunk-2EECBNC5.js";
21
+ } from "./chunk-EIKRZ32J.js";
18
22
  import {
19
23
  incrementDegradationCount
20
- } from "./chunk-JAU72XNY.js";
24
+ } from "./chunk-FWZRGGGY.js";
21
25
  import {
22
26
  logLatency
23
- } from "./chunk-QQNQ7SJW.js";
24
- import {
25
- BoundedFifoMap
26
- } from "./chunk-ABBOA7UD.js";
27
+ } from "./chunk-XWFIHYCH.js";
27
28
  import {
29
+ BoundedFifoMap,
28
30
  normalizeMapKey
29
- } from "./chunk-N2H3ZPZY.js";
31
+ } from "./chunk-EWXXLS26.js";
30
32
 
31
33
  // dist/clients/project-snapshot.js
32
34
  import * as fs3 from "node:fs";
@@ -228,6 +230,13 @@ async function readWorkerHeapStatistics(worker) {
228
230
  heapSizeLimitBytes: stats.heap_size_limit
229
231
  };
230
232
  }
233
+ function notePersistWorkerMessageFault(host, fault, detail) {
234
+ incrementDegradationCount({
235
+ kind: "persist-worker-message-contained",
236
+ subject: `${host} persist worker: ${fault}`,
237
+ reason: typeof detail === "string" ? detail : detail instanceof Error ? detail.message : `non-Error ${typeof detail}`
238
+ });
239
+ }
231
240
 
232
241
  // dist/clients/project-snapshot.js
233
242
  var PROJECT_SNAPSHOT_VERSION = 2;
@@ -1093,22 +1102,34 @@ function dispatchMainThreadWriteThroughSeam(pending, reason) {
1093
1102
  }
1094
1103
  writeSnapshotBodyOnMainThread(pending, reason);
1095
1104
  }
1105
+ function reapSnapshotStage(stagePath, subject) {
1106
+ const failure = reapStageFile(stagePath);
1107
+ if (failure === void 0)
1108
+ return;
1109
+ incrementDegradationCount({
1110
+ kind: "project-snapshot-stage-reap-failed",
1111
+ subject,
1112
+ reason: `snapshot stage reap failed: ${failure.message}`
1113
+ });
1114
+ }
1096
1115
  function handleSnapshotWorkerResult(result) {
1097
1116
  const pending = _snapshotWorkerRequests.get(result.id);
1098
1117
  if (!pending) {
1099
- fs3.rmSync(result.stagePath, { force: true });
1118
+ if (typeof result.stagePath === "string") {
1119
+ reapSnapshotStage(result.stagePath, result.stagePath);
1120
+ }
1100
1121
  return;
1101
1122
  }
1102
1123
  _snapshotWorkerRequests.delete(result.id);
1103
1124
  if (result.error || result.rawBytes === void 0 || result.gzBytes === void 0 || result.serializeMs === void 0 || result.writeMs === void 0 || result.semanticFingerprint === void 0) {
1104
- fs3.rmSync(result.stagePath, { force: true });
1125
+ reapSnapshotStage(pending.stagePath, pending.gzPath);
1105
1126
  dispatchMainThreadWriteThroughSeam(pending, result.error ?? "invalid worker result");
1106
1127
  return;
1107
1128
  }
1108
1129
  if (!result.skippedUnchanged)
1109
1130
  _snapshotWorkerBodyWritesForTests++;
1110
1131
  if (_snapshotGenerationGateEnabledForTests && _snapshotGenerationStates.get(pending.key)?.generation !== result.generation) {
1111
- fs3.rmSync(result.stagePath, { force: true });
1132
+ reapSnapshotStage(pending.stagePath, pending.gzPath);
1112
1133
  completeSnapshotPersist(pending);
1113
1134
  return;
1114
1135
  }
@@ -1141,7 +1162,7 @@ function handleSnapshotWorkerResult(result) {
1141
1162
  return;
1142
1163
  }
1143
1164
  try {
1144
- const promoted = promoteSnapshotBody(pending, { stagePath: result.stagePath }, {
1165
+ const promoted = promoteSnapshotBody(pending, { stagePath: pending.stagePath }, {
1145
1166
  fingerprint: result.semanticFingerprint,
1146
1167
  generatedAt: pending.snapshot.generatedAt,
1147
1168
  gzBytes: result.gzBytes
@@ -1161,7 +1182,7 @@ function handleSnapshotWorkerResult(result) {
1161
1182
  });
1162
1183
  completeSnapshotPersist(pending);
1163
1184
  } catch (err) {
1164
- fs3.rm(result.stagePath, { force: true }, () => {
1185
+ fs3.rm(pending.stagePath, { force: true }, () => {
1165
1186
  });
1166
1187
  dispatchMainThreadWriteThroughSeam(pending, err instanceof Error ? err.message : String(err));
1167
1188
  }
@@ -1252,12 +1273,21 @@ function getSnapshotPersistWorker() {
1252
1273
  return void 0;
1253
1274
  }
1254
1275
  const worker = new Worker(workerPath);
1255
- worker.on("message", (result) => {
1256
- if (_snapshotPromotionSeamForTests) {
1257
- void _snapshotPromotionSeamForTests().then(() => handleSnapshotWorkerResult(result));
1258
- return;
1276
+ worker.on("message", (message) => {
1277
+ try {
1278
+ const result = readGzipStageWorkerResult(message);
1279
+ if (typeof result === "string") {
1280
+ notePersistWorkerMessageFault("project-snapshot", "rejected", result);
1281
+ return;
1282
+ }
1283
+ if (_snapshotPromotionSeamForTests) {
1284
+ void _snapshotPromotionSeamForTests().then(() => handleSnapshotWorkerResult(result)).catch((err) => notePersistWorkerMessageFault("project-snapshot", "threw", err));
1285
+ return;
1286
+ }
1287
+ handleSnapshotWorkerResult(result);
1288
+ } catch (err) {
1289
+ notePersistWorkerMessageFault("project-snapshot", "threw", err);
1259
1290
  }
1260
- handleSnapshotWorkerResult(result);
1261
1291
  });
1262
1292
  worker.on("error", (err) => handleSnapshotWorkerDeath(err.message));
1263
1293
  worker.on("exit", (code) => {
@@ -1563,6 +1593,7 @@ export {
1563
1593
  readJsonCache,
1564
1594
  readJsonCacheAsync,
1565
1595
  readWorkerHeapStatistics,
1596
+ notePersistWorkerMessageFault,
1566
1597
  PROJECT_SNAPSHOT_VERSION,
1567
1598
  getProjectSnapshotPath,
1568
1599
  getProjectSnapshotLegacyPath,
@@ -2,16 +2,16 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
2
2
  import {
3
3
  classifyProbeFailure,
4
4
  installRetryDelayMs
5
- } from "./chunk-VRZP76YM.js";
5
+ } from "./chunk-5LRUKYFA.js";
6
6
  import {
7
7
  safeSpawnAsync
8
- } from "./chunk-C34ZXZ7O.js";
8
+ } from "./chunk-TPYYEDP5.js";
9
9
  import {
10
10
  assertInstallAllowed
11
- } from "./chunk-ZANLILYD.js";
11
+ } from "./chunk-EIKRZ32J.js";
12
12
  import {
13
13
  logExtension
14
- } from "./chunk-XTMJ7XDT.js";
14
+ } from "./chunk-N3PLNNCW.js";
15
15
 
16
16
  // dist/clients/dispatch/runners/utils/lazy-installer.js
17
17
  var LAZY_INSTALL_SPECS = {
@@ -2,32 +2,36 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
2
2
  import {
3
3
  createAvailabilityProbeFlight,
4
4
  probeToolAsync
5
- } from "./chunk-RWWYJ623.js";
5
+ } from "./chunk-XI34NWDI.js";
6
6
  import {
7
7
  classifyProbeFailure,
8
8
  createAvailabilityLatch,
9
9
  isTransientDecision,
10
10
  logAvailabilityDecision,
11
11
  startHostStallSampler
12
- } from "./chunk-VRZP76YM.js";
12
+ } from "./chunk-5LRUKYFA.js";
13
13
  import {
14
+ NODE_MODULES_BIN_DIRS,
14
15
  createGenerationSource,
16
+ isUntrustedProjectPath,
17
+ projectLocalBinDirs,
18
+ recordProjectCommandRefusal,
15
19
  safeSpawnAsync
16
- } from "./chunk-C34ZXZ7O.js";
20
+ } from "./chunk-TPYYEDP5.js";
17
21
  import {
18
22
  getProjectTrustState
19
- } from "./chunk-ZANLILYD.js";
23
+ } from "./chunk-EIKRZ32J.js";
20
24
  import {
21
25
  recordDegradationOnce
22
- } from "./chunk-JAU72XNY.js";
26
+ } from "./chunk-FWZRGGGY.js";
23
27
  import {
24
28
  logExtension
25
- } from "./chunk-XTMJ7XDT.js";
29
+ } from "./chunk-N3PLNNCW.js";
26
30
  import {
27
31
  isAtOrAboveHomeDir,
28
32
  isUnderDir,
29
33
  walkUpDirs
30
- } from "./chunk-N2H3ZPZY.js";
34
+ } from "./chunk-EWXXLS26.js";
31
35
 
32
36
  // dist/clients/package-manager.js
33
37
  import * as fs from "node:fs";
@@ -196,32 +200,37 @@ var globalBinDirCache = /* @__PURE__ */ new Map();
196
200
  var packageManagerCacheGeneration = createGenerationSource("package-manager-global-bin");
197
201
  var globalBinDirProbeFlights = createAvailabilityProbeFlight();
198
202
  async function globalBinDirsFor(pm) {
199
- const cached = globalBinDirCache.get(pm);
203
+ const scoped = getProjectTrustState() !== "trusted";
204
+ const key = `${scoped ? "scoped" : "trusted"}:${pm}`;
205
+ const cached = globalBinDirCache.get(key);
200
206
  if (cached)
201
207
  return cached;
202
208
  const generation = packageManagerCacheGeneration.capture();
203
- const shared = globalBinDirProbeFlights.run(pm, () => probeGlobalBinDirs(pm, generation));
209
+ const shared = globalBinDirProbeFlights.run(key, () => probeGlobalBinDirs(pm, key, scoped, generation));
204
210
  return shared.promise;
205
211
  }
206
- async function probeGlobalBinDirs(pm, generation) {
212
+ async function probeGlobalBinDirs(pm, key, scoped, generation) {
207
213
  if (pm === "bun") {
208
214
  const base = process.env.BUN_INSTALL || path.join(os.homedir(), ".bun");
209
215
  const dirs2 = [path.join(base, "bin")];
210
- generation.guardedWrite(pm, () => {
211
- globalBinDirCache.set(pm, dirs2);
216
+ generation.guardedWrite(key, () => {
217
+ globalBinDirCache.set(key, dirs2);
212
218
  });
213
219
  return dirs2;
214
220
  }
215
221
  const query = pm === "npm" ? ["config", "get", "prefix"] : pm === "pnpm" ? ["bin", "-g"] : ["global", "bin"];
216
- const res = await safeSpawnAsync(pmBinary(pm), query, { timeout: 5e3 });
222
+ const res = await safeSpawnAsync(pmBinary(pm), query, {
223
+ timeout: 5e3,
224
+ ...scoped && { cwd: os.homedir() }
225
+ });
217
226
  if (res.status !== 0 || res.error)
218
227
  return [];
219
228
  const out = res.stdout.trim();
220
229
  if (!out)
221
230
  return [];
222
231
  const dirs = pm === "npm" ? [onWindows() ? out : path.join(out, "bin")] : [out];
223
- generation.guardedWrite(pm, () => {
224
- globalBinDirCache.set(pm, dirs);
232
+ generation.guardedWrite(key, () => {
233
+ globalBinDirCache.set(key, dirs);
225
234
  });
226
235
  return dirs;
227
236
  }
@@ -247,29 +256,19 @@ async function findGlobalBinary(command, windowsExt = ".cmd") {
247
256
  for (const binDir of await allAvailableGlobalBinDirs()) {
248
257
  for (const name of candidates) {
249
258
  const full = path.join(binDir, name);
250
- if (fs.existsSync(full))
251
- return full;
259
+ if (!fs.existsSync(full))
260
+ continue;
261
+ if (isUntrustedProjectPath(full)) {
262
+ recordProjectCommandRefusal(full);
263
+ continue;
264
+ }
265
+ return full;
252
266
  }
253
267
  }
254
268
  } catch {
255
269
  }
256
270
  return void 0;
257
271
  }
258
- var NODE_MODULES_BIN_DIRS = [
259
- path.join("node_modules", ".bin")
260
- ];
261
- var VENDOR_BIN_DIRS = [path.join("vendor", "bin")];
262
- var VENV_BIN_DIRS = [
263
- path.join(".venv", "bin"),
264
- path.join("venv", "bin"),
265
- path.join(".venv", "Scripts"),
266
- path.join("venv", "Scripts")
267
- ];
268
- var PROJECT_LOCAL_BIN_DIRS = [
269
- ...NODE_MODULES_BIN_DIRS,
270
- ...VENDOR_BIN_DIRS,
271
- ...VENV_BIN_DIRS
272
- ];
273
272
  function localBinPath(value) {
274
273
  return typeof value === "string" ? value : void 0;
275
274
  }
@@ -292,14 +291,16 @@ function refuseLocalBin(tool, root) {
292
291
  return { kind: "refused-by-trust", tool, root: resolvedRoot, trust };
293
292
  }
294
293
  function isProjectLocalBinPath(resolvedCommand, cwd) {
295
- for (const ancestor of walkUpDirs(cwd)) {
296
- if (isAtOrAboveHomeDir(ancestor, os.homedir()))
297
- break;
298
- if (PROJECT_LOCAL_BIN_DIRS.some((binDir) => isUnderDir(resolvedCommand, path.join(ancestor, binDir))))
294
+ for (const binDir of projectLocalBinDirs(cwd)) {
295
+ if (isUnderDir(resolvedCommand, binDir))
299
296
  return true;
300
297
  }
301
298
  return false;
302
299
  }
300
+ function commandSearchReachesProject(cwd) {
301
+ const posix = process.platform !== "win32";
302
+ return (process.env.PATH ?? "").split(path.delimiter).some((entry) => entry === "" ? posix : !path.isAbsolute(entry) || isUnderDir(entry, cwd) || isProjectLocalBinPath(entry, cwd));
303
+ }
303
304
  function expandCandidateNames(tools, windowsExt, isWindows) {
304
305
  return isWindows && windowsExt !== "" ? tools.flatMap((tool) => [`${tool}${windowsExt}`, tool]) : [...tools];
305
306
  }
@@ -315,7 +316,7 @@ function* matchesInDir(dir, names, binDirs) {
315
316
  function* localBinMatches(tools, startDir, options) {
316
317
  const { windowsExt = ".cmd", homeDir = os.homedir(), binDirs = NODE_MODULES_BIN_DIRS, isWindows = onWindows(), ceiling = true } = options;
317
318
  const names = expandCandidateNames(tools, windowsExt, isWindows);
318
- for (const dir of walkUpDirs(startDir)) {
319
+ for (const dir of walkUpDirs(startDir, { spelling: true })) {
319
320
  if (ceiling && isAtOrAboveHomeDir(dir, homeDir))
320
321
  return;
321
322
  yield* matchesInDir(dir, names, binDirs);
@@ -354,10 +355,9 @@ export {
354
355
  updateArgs,
355
356
  allAvailableGlobalBinDirs,
356
357
  findGlobalBinary,
357
- VENDOR_BIN_DIRS,
358
- VENV_BIN_DIRS,
359
358
  localBinPath,
360
359
  isProjectLocalBinPath,
360
+ commandSearchReachesProject,
361
361
  findLocalBinUpwards,
362
362
  findLocalBinsAt,
363
363
  findLocalBinAt,
@@ -4,14 +4,14 @@ import {
4
4
  } from "./chunk-3MED75HT.js";
5
5
  import {
6
6
  getProjectDataDir
7
- } from "./chunk-C34ZXZ7O.js";
7
+ } from "./chunk-TPYYEDP5.js";
8
8
  import {
9
9
  writeFileAtomic
10
- } from "./chunk-2EECBNC5.js";
10
+ } from "./chunk-EIKRZ32J.js";
11
11
  import {
12
12
  normalizeMapKey,
13
13
  toProjectRelativePath
14
- } from "./chunk-N2H3ZPZY.js";
14
+ } from "./chunk-EWXXLS26.js";
15
15
 
16
16
  // dist/clients/call-graph.js
17
17
  import * as fs from "node:fs";
@@ -1,10 +1,7 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  tryLazyInstallForFormatter
4
- } from "./chunk-OXXKQCSV.js";
5
- import {
6
- stripAnsi
7
- } from "./chunk-FC4RP4I2.js";
4
+ } from "./chunk-K2GUZ4DN.js";
8
5
  import {
9
6
  OXFMT_SUPPORTED_EXTENSIONS,
10
7
  findPSScriptAnalyzerConfigPath,
@@ -46,69 +43,73 @@ import {
46
43
  hasTerraformConfig,
47
44
  hasVitePlusConfig,
48
45
  stripGradleCommentsAndStrings
49
- } from "./chunk-RPLINGVB.js";
50
- import {
51
- load
52
- } from "./chunk-QOZXJ4NA.js";
46
+ } from "./chunk-COOUUC5W.js";
53
47
  import {
54
48
  readTextFileOrUndefined,
55
49
  resolveCargoPackageEdition
56
- } from "./chunk-P7266HLM.js";
50
+ } from "./chunk-KX56K73G.js";
51
+ import {
52
+ load
53
+ } from "./chunk-WUY4BZEP.js";
54
+ import {
55
+ stripAnsi
56
+ } from "./chunk-6HWVI6MI.js";
57
57
  import {
58
58
  getToolPath
59
- } from "./chunk-ACXEQZOU.js";
59
+ } from "./chunk-IL7K66ZQ.js";
60
60
  import {
61
61
  resolveToolCwd
62
- } from "./chunk-Q7DUK4LX.js";
62
+ } from "./chunk-4FHUGDKU.js";
63
63
  import {
64
- VENDOR_BIN_DIRS,
65
- VENV_BIN_DIRS,
66
64
  findGlobalBinary,
67
65
  findLocalBinUpwards,
68
66
  localBinPath
69
- } from "./chunk-AW7R2GWG.js";
67
+ } from "./chunk-K4SZB56V.js";
70
68
  import {
71
69
  getIsolatedNpxSpawnOptions,
72
70
  probeToolAsync
73
- } from "./chunk-RWWYJ623.js";
71
+ } from "./chunk-XI34NWDI.js";
74
72
  import {
75
73
  classifyProbeFailure,
76
74
  createAvailabilityLatch,
77
75
  logAvailabilityDecision,
78
76
  startHostStallSampler
79
- } from "./chunk-VRZP76YM.js";
77
+ } from "./chunk-5LRUKYFA.js";
80
78
  import {
79
+ VENDOR_BIN_DIRS,
80
+ VENV_BIN_DIRS,
81
+ admittedLookupAnswer,
81
82
  createGenerationSource,
82
83
  safeSpawnAsync
83
- } from "./chunk-C34ZXZ7O.js";
84
+ } from "./chunk-TPYYEDP5.js";
84
85
  import {
85
86
  TERRAGRUNT_FILENAMES
86
- } from "./chunk-PHDMFAKM.js";
87
+ } from "./chunk-GYRZ72R4.js";
87
88
  import {
88
- assertInstallAllowed
89
- } from "./chunk-ZANLILYD.js";
89
+ assertInstallAllowed,
90
+ getProjectTrustGeneration
91
+ } from "./chunk-EIKRZ32J.js";
90
92
  import {
91
93
  compareOrdinal,
92
94
  getDegradationLedgerGeneration,
93
95
  incrementDegradationCount,
94
96
  recordDegradationOnce
95
- } from "./chunk-JAU72XNY.js";
97
+ } from "./chunk-FWZRGGGY.js";
96
98
  import {
97
99
  logExtension
98
- } from "./chunk-XTMJ7XDT.js";
100
+ } from "./chunk-N3PLNNCW.js";
99
101
  import {
100
102
  logLatency
101
- } from "./chunk-QQNQ7SJW.js";
103
+ } from "./chunk-XWFIHYCH.js";
102
104
  import {
103
105
  BoundedFifoMap,
104
- BoundedLruCache
105
- } from "./chunk-ABBOA7UD.js";
106
- import {
106
+ BoundedLruCache,
107
107
  findNearestContaining,
108
108
  findNearestMarkerRoot,
109
109
  normalizeMapKey,
110
+ realpathOrResolve,
110
111
  toPosix
111
- } from "./chunk-N2H3ZPZY.js";
112
+ } from "./chunk-EWXXLS26.js";
112
113
 
113
114
  // dist/clients/formatters.js
114
115
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -316,7 +317,7 @@ function detectIndentation(content) {
316
317
  return hasDetectableIndentation(content) ? void 0 : DEFAULT_INDENTATION;
317
318
  }
318
319
  if (tabs > spaceCounts.length)
319
- return { style: "tab", width: 1 };
320
+ return { style: "tab" };
320
321
  if (spaceCounts.length > tabs) {
321
322
  const minimum = Math.min(...spaceCounts);
322
323
  const gcd = spaceCounts.reduce((unit, count) => greatestCommonDivisor(unit, count), 0);
@@ -1312,7 +1313,7 @@ async function which(command) {
1312
1313
  const result = await safeSpawnAsync(process.platform === "win32" ? "where" : "which", [command], { timeout: WHICH_BUDGET_MS });
1313
1314
  const hostStallMs = stallSampler.stop();
1314
1315
  const elapsedMs = Date.now() - startedAt;
1315
- const resolved = !result.error && result.status === 0 ? result.stdout?.trim().split(/\r?\n/)[0] ?? null : null;
1316
+ const resolved = !result.error && result.status === 0 ? admittedLookupAnswer(result.stdout ?? "") : null;
1316
1317
  if (resolved) {
1317
1318
  entry.resolved = resolved;
1318
1319
  entry.latch.noteAvailable();
@@ -1503,29 +1504,21 @@ async function indentationArgs(filePath, tool, cwd) {
1503
1504
  });
1504
1505
  return null;
1505
1506
  }
1507
+ const tab = indentation.style === "tab";
1506
1508
  if (tool === "shfmt")
1507
- return indentation.style === "tab" ? ["-i", "0"] : ["-i", String(indentation.width)];
1509
+ return tab ? ["-i", "0"] : ["-i", String(indentation.width)];
1508
1510
  if (tool === "prettier") {
1509
- return [
1510
- indentation.style === "tab" ? "--use-tabs" : "--no-use-tabs",
1511
- "--tab-width",
1512
- String(indentation.width)
1513
- ];
1511
+ return tab ? ["--use-tabs"] : ["--no-use-tabs", "--tab-width", String(indentation.width)];
1514
1512
  }
1515
1513
  if (tool === "ruff") {
1516
- return [
1514
+ return tab ? ["--config", "format.indent-style='tab'"] : [
1517
1515
  "--config",
1518
1516
  `indent-width=${indentation.width}`,
1519
1517
  "--config",
1520
- `format.indent-style='${indentation.style}'`
1518
+ "format.indent-style='space'"
1521
1519
  ];
1522
1520
  }
1523
- return [
1524
- "--indent-style",
1525
- indentation.style,
1526
- "--indent-width",
1527
- String(indentation.width)
1528
- ];
1521
+ return tab ? ["--indent-style", "tab"] : ["--indent-style", "space", "--indent-width", String(indentation.width)];
1529
1522
  }
1530
1523
  function resolveFormatterCwd(absolutePath, formatterName, homeDir = os2.homedir()) {
1531
1524
  return resolveToolCwd("formatter", formatterName ?? "unknown", absolutePath, {
@@ -2302,7 +2295,12 @@ async function getFormattersForFile(filePath, cwd) {
2302
2295
  const base = path4.basename(filePath).toLowerCase();
2303
2296
  const normalizedCwd = normalizeMapKey(cwd);
2304
2297
  const cacheKey = FILENAME_FORMATTER_BASENAMES.has(base) ? `${normalizedCwd}:${ext}:${base}` : `${normalizedCwd}:${ext}`;
2298
+ const trustGeneration = getProjectTrustGeneration();
2305
2299
  let cached = detectionCache.get(normalizedCwd);
2300
+ if (cached && cached.trustGeneration !== trustGeneration) {
2301
+ detectionCache.delete(normalizedCwd);
2302
+ cached = void 0;
2303
+ }
2306
2304
  if (cached?.entries.has(cacheKey)) {
2307
2305
  const enabledNames2 = cached.entries.get(cacheKey);
2308
2306
  const selectedFormatterName = enabledNames2 && enabledNames2.length > 0 ? enabledNames2[0] : null;
@@ -2331,7 +2329,11 @@ async function getFormattersForFile(filePath, cwd) {
2331
2329
  }
2332
2330
  cached = detectionCache.get(normalizedCwd);
2333
2331
  if (!cached) {
2334
- cached = { signature: configSignature, entries: /* @__PURE__ */ new Map() };
2332
+ cached = {
2333
+ signature: configSignature,
2334
+ trustGeneration,
2335
+ entries: /* @__PURE__ */ new Map()
2336
+ };
2335
2337
  detectionCache.set(normalizedCwd, cached);
2336
2338
  }
2337
2339
  }
@@ -2516,7 +2518,7 @@ async function resolveFormatterCommand(formatter, absolutePath, cwd) {
2516
2518
  }
2517
2519
  async function formatFile(filePath, formatter, enter) {
2518
2520
  try {
2519
- const absolutePath = path4.resolve(filePath);
2521
+ const absolutePath = realpathOrResolve(filePath);
2520
2522
  const cwd = path4.dirname(absolutePath);
2521
2523
  const formatterCwd = resolveToolCwd("formatter", formatter.name, absolutePath, { cwd: path4.parse(absolutePath).root }).cwd;
2522
2524
  const cmd = await resolveFormatterCommand(formatter, absolutePath, cwd);