pi-lens 4.4.11 → 4.5.0

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 (162) hide show
  1. package/CHANGELOG-USER.md +12 -12
  2. package/CHANGELOG.md +202 -0
  3. package/README.md +104 -217
  4. package/dist/{chunk-34RXPR7M.js → chunk-27JQHK7Y.js} +1 -1
  5. package/dist/{chunk-W6VLB6LL.js → chunk-2APSZHHI.js} +61 -3
  6. package/dist/{chunk-NLRKB32C.js → chunk-2H5GHZKC.js} +8 -8
  7. package/dist/{chunk-BJDB7PXU.js → chunk-2H7NFZ4Q.js} +11 -11
  8. package/dist/{chunk-OC4ZGVMH.js → chunk-37IDWT6O.js} +65 -19
  9. package/dist/{chunk-A4HKPAEN.js → chunk-3PAS2ERX.js} +8 -8
  10. package/dist/{chunk-DNB4ZQGN.js → chunk-3PO4YYOX.js} +9 -17
  11. package/dist/{chunk-SQBDX6IO.js → chunk-3QXFUP6T.js} +11 -11
  12. package/dist/{chunk-YVPB5YGO.js → chunk-3TSMQZG6.js} +32 -11
  13. package/dist/{chunk-3C6ZZAB2.js → chunk-4DAHGU3V.js} +16 -17
  14. package/dist/{chunk-BN36MQW5.js → chunk-4IZZEN63.js} +33 -36
  15. package/dist/{chunk-OYXD2MOM.js → chunk-5HBQL7DH.js} +2 -2
  16. package/dist/{chunk-B4FAFEBP.js → chunk-5JB4WENL.js} +1 -1
  17. package/dist/chunk-5YJXF2IS.js +56 -0
  18. package/dist/{chunk-AVOUHMCS.js → chunk-6CFSDLHE.js} +22 -18
  19. package/dist/{chunk-C4ICGFEO.js → chunk-6E5QLMWI.js} +24 -22
  20. package/dist/{chunk-WBXCIRVI.js → chunk-6GLMMGCX.js} +2 -2
  21. package/dist/{chunk-C2REOMPO.js → chunk-74AMPWNC.js} +2 -2
  22. package/dist/{chunk-K2GV34T2.js → chunk-7CLWC2UH.js} +26 -37
  23. package/dist/{chunk-NQFXN5U7.js → chunk-7DPXUPRF.js} +2 -2
  24. package/dist/{chunk-QAM2Q3VO.js → chunk-7U36VQL6.js} +2 -2
  25. package/dist/{chunk-2SD2CGVH.js → chunk-7WKVCZI4.js} +1 -1
  26. package/dist/{chunk-R2VUZZPJ.js → chunk-7ZVTFLCC.js} +10 -10
  27. package/dist/{chunk-IT7MFVGP.js → chunk-ADYQRETD.js} +2 -2
  28. package/dist/{chunk-532X3OCZ.js → chunk-ARTYCUGF.js} +28 -15
  29. package/dist/{chunk-DBAHJFBU.js → chunk-AXAR5ZW2.js} +228 -112
  30. package/dist/{chunk-KNP4ENFT.js → chunk-AZG5UJYY.js} +1 -1
  31. package/dist/{chunk-ITAPXBIB.js → chunk-B2OXE4AH.js} +60 -21
  32. package/dist/{chunk-PSUXESQ5.js → chunk-B42AIWPJ.js} +2 -2
  33. package/dist/{chunk-AJ62EQIQ.js → chunk-BBSDJTOV.js} +18 -16
  34. package/dist/{chunk-R2UF54ON.js → chunk-BKWFDWYM.js} +16 -16
  35. package/dist/{chunk-ZD4KVFXI.js → chunk-C5PLBTNR.js} +172 -3
  36. package/dist/{chunk-SRXYSLMW.js → chunk-CQY2HEH7.js} +1 -1
  37. package/dist/{chunk-7424ANRU.js → chunk-CXQYK4YT.js} +1 -1
  38. package/dist/{chunk-WXMUGUZV.js → chunk-CZJGAOKL.js} +8 -7
  39. package/dist/{chunk-QUZYRDT6.js → chunk-DCA2MXVQ.js} +11 -11
  40. package/dist/{chunk-HASJPQBC.js → chunk-DFKOA74L.js} +9 -9
  41. package/dist/{chunk-AYDE7RFV.js → chunk-DI4AZZNY.js} +2 -2
  42. package/dist/{chunk-GL6J5R34.js → chunk-G53LBDNU.js} +99 -5
  43. package/dist/chunk-GCSDF5IE.js +27 -0
  44. package/dist/{chunk-KBSC5Z3G.js → chunk-H5API74E.js} +6 -6
  45. package/dist/chunk-HBX55MWO.js +27 -0
  46. package/dist/{chunk-6RXMQYNU.js → chunk-HIJ4CHFF.js} +2 -2
  47. package/dist/{chunk-NWK7KKNO.js → chunk-HIRBC72R.js} +4 -4
  48. package/dist/{chunk-4WWPDMRA.js → chunk-HRLF35WL.js} +8 -8
  49. package/dist/{chunk-NR4KQOXZ.js → chunk-I2FYOZNW.js} +9 -9
  50. package/dist/{chunk-VDMF7Q2P.js → chunk-I3NZVAMN.js} +9 -9
  51. package/dist/{chunk-DPDA3ILA.js → chunk-INBK3HIT.js} +3 -3
  52. package/dist/{chunk-VI3BJMZO.js → chunk-J2ZB5MDS.js} +22 -24
  53. package/dist/{chunk-6XNVY3FW.js → chunk-JGUDT5KD.js} +4 -4
  54. package/dist/chunk-JOIKBUQN.js +88 -0
  55. package/dist/{chunk-VTXJAO5R.js → chunk-K4Z7MK6T.js} +169 -165
  56. package/dist/{chunk-GTNO6F6K.js → chunk-K7O6AHSJ.js} +10 -10
  57. package/dist/{chunk-WMCAEP2K.js → chunk-KNJH6WJQ.js} +6 -6
  58. package/dist/{chunk-SUIZOCSY.js → chunk-KNSOA43J.js} +1 -1
  59. package/dist/{chunk-OP5BMZKK.js → chunk-KXGTLAUW.js} +2 -2
  60. package/dist/{chunk-BLL4VYGZ.js → chunk-KZ732ZVW.js} +1 -1
  61. package/dist/{chunk-TRYOYWWU.js → chunk-L6BDRYUK.js} +19 -17
  62. package/dist/{chunk-FVEEEEIM.js → chunk-LGH2HHZG.js} +24 -6
  63. package/dist/{chunk-3R3Z54J7.js → chunk-LOEJFTF2.js} +1 -1
  64. package/dist/{chunk-HGEE5LDW.js → chunk-LQQNFCQJ.js} +1 -1
  65. package/dist/chunk-LVLPA32Q.js +810 -0
  66. package/dist/chunk-M2YMBT5G.js +73 -0
  67. package/dist/{chunk-KX4DF6XX.js → chunk-MJRGPEQ5.js} +11 -11
  68. package/dist/{chunk-3QCI3V6C.js → chunk-MOAVEPC4.js} +10 -10
  69. package/dist/{chunk-AFNPNHJV.js → chunk-NGNBJIUO.js} +7 -7
  70. package/dist/{chunk-AGEQRJ5A.js → chunk-NHA5K226.js} +1 -1
  71. package/dist/{chunk-HTUG7ZFK.js → chunk-NNEQOC3U.js} +31 -59
  72. package/dist/{chunk-6K4X7IIF.js → chunk-O2MHF7QM.js} +35 -38
  73. package/dist/{chunk-4HNBY7S7.js → chunk-OLWGYBYT.js} +15 -18
  74. package/dist/{chunk-IBEYUBCM.js → chunk-OZQQ3AIR.js} +17 -20
  75. package/dist/{chunk-LXE7JAMV.js → chunk-P5MSLVUW.js} +10 -10
  76. package/dist/{chunk-TBE4OLPA.js → chunk-PFJLYRO3.js} +37 -40
  77. package/dist/chunk-PKWEBMCA.js +2957 -0
  78. package/dist/{chunk-LHU6NG5Z.js → chunk-PPQHMSPH.js} +16 -15
  79. package/dist/{chunk-6EIV3H7O.js → chunk-PQF6YGYB.js} +12 -5
  80. package/dist/{chunk-BBJXIZ3X.js → chunk-PQXUZYTQ.js} +6 -35
  81. package/dist/{chunk-IJ55MYO6.js → chunk-Q7J3JYJ2.js} +13 -12
  82. package/dist/{chunk-BMMRLJA4.js → chunk-QE5DJ7MX.js} +27 -10
  83. package/dist/{chunk-E6Z3CJT2.js → chunk-QE7BJQ6K.js} +7 -7
  84. package/dist/{chunk-UY3WWW5R.js → chunk-QMWKSYWB.js} +4 -4
  85. package/dist/{chunk-QJ4T73J5.js → chunk-QV3JPCMK.js} +1 -1
  86. package/dist/{chunk-3NVGBFJS.js → chunk-R4L7KZ7R.js} +5 -5
  87. package/dist/{chunk-KDMJ2DJD.js → chunk-RIH3UBK4.js} +10 -10
  88. package/dist/{chunk-T5EGSBM2.js → chunk-RJ3APNIP.js} +3 -3
  89. package/dist/{chunk-D5L7Q57Z.js → chunk-S6MCMD27.js} +35 -12
  90. package/dist/{chunk-LPM6NKVI.js → chunk-SCU62JLX.js} +6 -6
  91. package/dist/{chunk-LHCDWFDB.js → chunk-SDYLT45T.js} +3 -3
  92. package/dist/chunk-TFKN5EIR.js +27 -0
  93. package/dist/{chunk-TPMBNWHO.js → chunk-TKOFTLGB.js} +34 -26
  94. package/dist/chunk-TQWRH25U.js +35 -0
  95. package/dist/{chunk-QBUSONNE.js → chunk-TWEOJE3D.js} +307 -74
  96. package/dist/{chunk-5RLEDUUE.js → chunk-UN72ZAJ5.js} +8 -8
  97. package/dist/{chunk-LIDFFCZZ.js → chunk-UNP6Y4JV.js} +16 -16
  98. package/dist/{chunk-HIUVHRLM.js → chunk-VGRGW4UL.js} +63 -57
  99. package/dist/{chunk-AOQKQWZU.js → chunk-VSQT6IHZ.js} +2 -2
  100. package/dist/{chunk-B4K6OSLL.js → chunk-VWEBZ2JV.js} +39 -40
  101. package/dist/chunk-W26QZ3OM.js +355 -0
  102. package/dist/{chunk-KDGKKK7A.js → chunk-XDNWR7SG.js} +2 -2
  103. package/dist/{chunk-TTGDTNSN.js → chunk-XSC3BCN3.js} +5 -5
  104. package/dist/{chunk-ME6MF2N2.js → chunk-YCR6ZYTE.js} +1 -1
  105. package/dist/{chunk-QDZ3ZZMY.js → chunk-ZI7YHV6I.js} +5 -5
  106. package/dist/{chunk-E3PNZDPH.js → chunk-ZQSSO7LO.js} +33 -1
  107. package/dist/{chunk-ECYUBKYX.js → chunk-ZULZS2I6.js} +391 -410
  108. package/dist/index.js +7314 -5703
  109. package/dist/mcp/analyze-cli.js +11 -13
  110. package/dist/mcp/cli.js +39 -40
  111. package/dist/mcp/server.js +618 -360
  112. package/dist/mcp/worker.js +57 -60
  113. package/dist/probes/installer.js +19 -17
  114. package/docs/agent-tools.md +54 -12
  115. package/docs/architecture.md +113 -0
  116. package/docs/ast-grep_rules_catalog.md +2 -2
  117. package/docs/ci.md +18 -4
  118. package/docs/configuration.md +3 -3
  119. package/docs/defect-shapes.md +41 -3
  120. package/docs/dependencies.md +10 -10
  121. package/docs/features.md +3 -3
  122. package/docs/globalconfig.md +8 -1
  123. package/docs/invariants/dispatch-runners.md +13 -1
  124. package/docs/invariants/lsp-trust-exec.md +26 -0
  125. package/docs/language-coverage.md +39 -0
  126. package/docs/lsp-capability-matrix.md +10 -4
  127. package/docs/lsp-idle-eviction.md +1 -1
  128. package/docs/mcp.md +2 -1
  129. package/docs/pi-lens-fixer.md +4 -0
  130. package/docs/pi-lens-merge-policy.md +1 -1
  131. package/docs/pi-lens-reviewer.md +4 -5
  132. package/docs/pi-lens-subagent.md +5 -2
  133. package/docs/prose-standard.md +112 -0
  134. package/docs/servercapabilities.md +1 -1
  135. package/docs/usage.md +51 -1
  136. package/package.json +1 -1
  137. package/rules/ast-grep-rules/rule-tests/array-callback-return-js-test.yml +23 -0
  138. package/rules/ast-grep-rules/rule-tests/array-callback-return-test.yml +23 -0
  139. package/rules/ast-grep-rules/rule-tests/no-negation-in-equality-check-js-test.yml +8 -0
  140. package/rules/ast-grep-rules/rule-tests/no-negation-in-equality-check-test.yml +8 -0
  141. package/rules/ast-grep-rules/rule-tests/unchecked-throwing-call-js-test.yml +16 -0
  142. package/rules/ast-grep-rules/rule-tests/unchecked-throwing-call-test.yml +16 -0
  143. package/rules/ast-grep-rules/rules/array-callback-return-js.yml +8 -0
  144. package/rules/ast-grep-rules/rules/array-callback-return.yml +8 -0
  145. package/rules/ast-grep-rules/rules/no-negation-in-equality-check-js.yml +17 -5
  146. package/rules/ast-grep-rules/rules/no-negation-in-equality-check.yml +17 -5
  147. package/rules/ast-grep-rules/rules/unchecked-throwing-call-js.yml +8 -1
  148. package/rules/ast-grep-rules/rules/unchecked-throwing-call.yml +8 -1
  149. package/rules/tree-sitter-queries/typescript/ts-react-antipatterns.yml +8 -0
  150. package/dist/chunk-3HZ6MNB2.js +0 -140
  151. package/dist/chunk-43KD3PPM.js +0 -162
  152. package/dist/chunk-5YTDZ5WP.js +0 -38
  153. package/dist/chunk-CKEQFGLT.js +0 -32
  154. package/dist/chunk-F37CCZUA.js +0 -27
  155. package/dist/chunk-JSQK5DH3.js +0 -256
  156. package/dist/chunk-R5BNSOIV.js +0 -29
  157. package/dist/chunk-RV5VX2XW.js +0 -29
  158. package/dist/chunk-UELHWF5I.js +0 -1037
  159. package/dist/chunk-UG4YLCJ5.js +0 -58
  160. package/dist/chunk-UQ6OZYTO.js +0 -91
  161. package/dist/chunk-V7IPIAE5.js +0 -74
  162. package/dist/chunk-YUF4DRYB.js +0 -2417
@@ -1,16 +1,16 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  resolveToolCwd
4
- } from "./chunk-JSQK5DH3.js";
4
+ } from "./chunk-LVLPA32Q.js";
5
5
  import {
6
6
  allAvailableGlobalBinDirs,
7
7
  installArgs,
8
8
  pmBinary,
9
9
  resolveNodePackageManager
10
- } from "./chunk-FVEEEEIM.js";
10
+ } from "./chunk-LGH2HHZG.js";
11
11
  import {
12
12
  probeToolAsync
13
- } from "./chunk-OP5BMZKK.js";
13
+ } from "./chunk-KXGTLAUW.js";
14
14
  import {
15
15
  registerBackgroundWriteDrain
16
16
  } from "./chunk-UYXV5NIS.js";
@@ -20,7 +20,7 @@ import {
20
20
  createAvailabilityLatch,
21
21
  logAvailabilityDecision,
22
22
  startHostStallSampler
23
- } from "./chunk-WBXCIRVI.js";
23
+ } from "./chunk-6GLMMGCX.js";
24
24
  import {
25
25
  acquireBoundedPidFileLock,
26
26
  acquireQuarantinePidFileLock,
@@ -40,7 +40,7 @@ import {
40
40
  startGenerationHeartbeat,
41
41
  tryAcquireGeneration,
42
42
  windowsExe
43
- } from "./chunk-DNB4ZQGN.js";
43
+ } from "./chunk-3PO4YYOX.js";
44
44
  import {
45
45
  hashContentBytes
46
46
  } from "./chunk-CIA7X2PZ.js";
@@ -50,20 +50,20 @@ import {
50
50
  projectTrustDenialReason,
51
51
  writeFileAtomic,
52
52
  writeFileAtomicAsync
53
- } from "./chunk-43KD3PPM.js";
53
+ } from "./chunk-W26QZ3OM.js";
54
54
  import {
55
55
  getDegradationLedgerGeneration,
56
56
  incrementDegradationCount,
57
57
  logExtension,
58
58
  recordDegradationOnce
59
- } from "./chunk-AGEQRJ5A.js";
59
+ } from "./chunk-NHA5K226.js";
60
60
  import {
61
61
  createNdjsonLogger,
62
62
  getGlobalPiLensLogDir,
63
63
  getMaxLogSizeMB,
64
64
  isTestMode,
65
65
  isToolInstallDisabled
66
- } from "./chunk-K2GV34T2.js";
66
+ } from "./chunk-7CLWC2UH.js";
67
67
  import {
68
68
  BoundedLruCache,
69
69
  findLocalToolConfig,
@@ -864,7 +864,7 @@ var TOOLS = [
864
864
  checkCommand: "cmake-language-server",
865
865
  checkArgs: ["--version"],
866
866
  installStrategy: "pip",
867
- packageName: "cmake-language-server",
867
+ packageName: "cmake-language-server>=0.1.11",
868
868
  binaryName: "cmake-language-server",
869
869
  // Upstream 0.1.11 (the latest release) imports `LanguageServer` from
870
870
  // `pygls.server`, a symbol pygls 2 removed, while declaring only
@@ -3747,14 +3747,21 @@ exec "${resolvedInner}" "$@"
3747
3747
  return void 0;
3748
3748
  }
3749
3749
  }
3750
- function recordPackageManagerInstallException(toolId, strategyLabel, packageName, err) {
3750
+ function recordPackageManagerInstallException(toolId, strategyLabel, packageName, err, recordManagedToolInstall = true) {
3751
3751
  const message = boundInstallError(err.message);
3752
+ if (recordManagedToolInstall && !(err instanceof InstallLockLostError))
3753
+ recordDegradationOnce({
3754
+ kind: "managed-tool-install",
3755
+ subject: toolId,
3756
+ reason: message
3757
+ });
3752
3758
  logSessionStart(`auto-install ${strategyLabel} ${packageName}: exception: ${message}`);
3753
3759
  installFailureReasons.set(toolId, message);
3754
3760
  return void 0;
3755
3761
  }
3756
- var INSTALL_ERROR_LINE_LIMIT = 1e3;
3762
+ var INSTALL_ERROR_LINE_LIMIT = 5e3;
3757
3763
  var INSTALL_CANDIDATE_ERROR_LIMIT = 200;
3764
+ var PEP668_LOG_ERROR_LIMIT = 1e3;
3758
3765
  function boundInstallError(value, limit = INSTALL_ERROR_LINE_LIMIT) {
3759
3766
  const line = value.replace(/[\r\n]+/g, " ").trim();
3760
3767
  return line.length > limit ? `${line.slice(0, limit - 3)}...` : line;
@@ -3877,7 +3884,15 @@ async function installNpmTool(toolId, packageName, binaryName, verificationArgs
3877
3884
  }
3878
3885
  return binPath;
3879
3886
  } catch (err) {
3880
- return recordPackageManagerInstallException(toolId, "npm", packageName, err);
3887
+ return recordPackageManagerInstallException(
3888
+ toolId,
3889
+ "npm",
3890
+ packageName,
3891
+ err,
3892
+ // Pass lock loss through the shared helper so its dedicated exclusion
3893
+ // remains the single guard against a duplicate managed-install row.
3894
+ err instanceof InstallLockLostError
3895
+ );
3881
3896
  }
3882
3897
  }
3883
3898
  function pipCommandCandidates() {
@@ -3944,7 +3959,7 @@ async function installPipTool(toolId, packageName, binaryName, options = {}) {
3944
3959
  const logKey = `${getDegradationLedgerGeneration()}:${subject}`;
3945
3960
  if (pipPep668LoggedRefusals.current(logKey) === 0) {
3946
3961
  pipPep668LoggedRefusals.bump(logKey);
3947
- logSessionStart(`auto-install pip ${packageName}: ${strategy} refused by PEP 668 (${boundInstallError(reason)})`);
3962
+ logSessionStart(`auto-install pip ${packageName}: ${strategy} refused by PEP 668 (${boundInstallError(reason, PEP668_LOG_ERROR_LIMIT)})`);
3948
3963
  }
3949
3964
  };
3950
3965
  const succeeded = (strategy, binaryPath) => {
@@ -3968,6 +3983,32 @@ async function installPipTool(toolId, packageName, binaryName, options = {}) {
3968
3983
  ...spawnEnv ? { env: spawnEnv } : {}
3969
3984
  });
3970
3985
  };
3986
+ const pythonReleaseFor = async (command) => {
3987
+ const interpreter = command === "pip3" ? "python3" : command === "pip" ? "python" : command;
3988
+ const pipProbe = await run(command, ["--version"]);
3989
+ const pipRelease = `${pipProbe.stdout}
3990
+ ${pipProbe.stderr}`.match(/(?:python|Python)\s+([0-9]+(?:\.[0-9]+){1,2})/)?.[1];
3991
+ if (pipRelease)
3992
+ return pipRelease;
3993
+ if (interpreter === command)
3994
+ return void 0;
3995
+ const interpreterProbe = await run(interpreter, ["--version"]);
3996
+ return `${interpreterProbe.stdout}
3997
+ ${interpreterProbe.stderr}`.match(/^Python\s+([0-9]+(?:\.[0-9]+){1,2})/m)?.[1];
3998
+ };
3999
+ const candidateFailure = async (command, args, failureText) => {
4000
+ const pythonRelease = await pythonReleaseFor(command);
4001
+ const error = failureText;
4002
+ const requiresPython = error.match(/ERROR:\s+Ignored[^\r\n]*Requires-Python[^\r\n]*/i)?.[0];
4003
+ const tail = requiresPython ? error.replace(requiresPython, "").trim() : error;
4004
+ const evidence = [];
4005
+ if (pythonRelease)
4006
+ evidence.push(`Python ${pythonRelease}`);
4007
+ if (requiresPython)
4008
+ evidence.push(boundInstallError(requiresPython, INSTALL_CANDIDATE_ERROR_LIMIT));
4009
+ evidence.push(boundInstallError(tail, INSTALL_CANDIDATE_ERROR_LIMIT));
4010
+ return `${command} ${args.join(" ")}: ${evidence.join(" | ")}`;
4011
+ };
3971
4012
  const addBinToPath = async (binDir) => {
3972
4013
  try {
3973
4014
  await fs2.access(binDir);
@@ -4058,8 +4099,7 @@ async function installPipTool(toolId, packageName, binaryName, options = {}) {
4058
4099
  const binaryPath = base ? await addBinToPath(pipScriptsDir(base, installerPlatform())) : void 0;
4059
4100
  return succeeded("user", binaryPath ?? packageName);
4060
4101
  }
4061
- const candidateError = `${candidate.command} ${args.join(" ")}: ${boundInstallError(error, INSTALL_CANDIDATE_ERROR_LIMIT)}`;
4062
- candidateErrors.push(candidateError);
4102
+ candidateErrors.push(await candidateFailure(candidate.command, args, error));
4063
4103
  if (pep668.test(error)) {
4064
4104
  userRefused = true;
4065
4105
  refuse("user", error);
@@ -4081,8 +4121,7 @@ async function installPipTool(toolId, packageName, binaryName, options = {}) {
4081
4121
  const result = await run(candidate.command, args, privateEnv);
4082
4122
  const error = (result.error?.message ?? result.stderr).trim();
4083
4123
  if (result.status !== 0) {
4084
- const candidateError = `${candidate.command} ${args.join(" ")}: ${boundInstallError(error, INSTALL_CANDIDATE_ERROR_LIMIT)}`;
4085
- candidateErrors.push(candidateError);
4124
+ candidateErrors.push(await candidateFailure(candidate.command, args, error));
4086
4125
  continue;
4087
4126
  }
4088
4127
  const binaryPath = await addBinToPath(pipScriptsDir(privateBase, installerPlatform()));
@@ -4111,7 +4150,7 @@ async function installGemTool(toolId, packageName) {
4111
4150
  }
4112
4151
  return packageName;
4113
4152
  } catch (err) {
4114
- return recordPackageManagerInstallException(toolId, "gem", packageName, err);
4153
+ return recordPackageManagerInstallException(toolId, "gem", packageName, err, err instanceof InstallLockLostError);
4115
4154
  }
4116
4155
  }
4117
4156
  async function stampInstallResolution(toolId) {
@@ -4120,7 +4159,7 @@ async function stampInstallResolution(toolId) {
4120
4159
  return;
4121
4160
  try {
4122
4161
  const resolutionId = lastInstallResolutionId.get(toolId);
4123
- const refresh = await import("./chunk-VI3BJMZO.js");
4162
+ const refresh = await import("./chunk-J2ZB5MDS.js");
4124
4163
  await refresh.stampManagedToolInstall(toolId, resolutionId);
4125
4164
  } catch {
4126
4165
  }
@@ -4133,7 +4172,7 @@ async function finishInstallAttempt(toolId, ok, startedAt) {
4133
4172
  if (ok) {
4134
4173
  resetSafeSpawnWindowsCommandCache();
4135
4174
  try {
4136
- const { resetMadgeManagedPathMemo } = await import("./chunk-UG4YLCJ5.js");
4175
+ const { resetMadgeManagedPathMemo } = await import("./chunk-5YJXF2IS.js");
4137
4176
  resetMadgeManagedPathMemo();
4138
4177
  } catch (err) {
4139
4178
  logSessionStart(`auto-install ${toolId}: madge memo reset failed: ${err.message}`);
@@ -4163,7 +4202,7 @@ async function installTool(toolId, ownsLock) {
4163
4202
  return false;
4164
4203
  const npmPath = await installNpmTool(tool.id, tool.packageName, tool.binaryName, tool.checkArgs, getToolVerificationTimeout(tool), packageEntryVerification(tool), ownsLock);
4165
4204
  if (npmPath !== void 0) {
4166
- await import("./chunk-VI3BJMZO.js").then((m) => m.stampManagedToolInstalled(tool.id, tool.packageName)).catch(() => {
4205
+ await import("./chunk-J2ZB5MDS.js").then((m) => m.stampManagedToolInstalled(tool.id, tool.packageName)).catch(() => {
4167
4206
  });
4168
4207
  }
4169
4208
  return finishInstallAttempt(tool.id, npmPath !== void 0, startedAt);
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  isMutatingToolName
4
- } from "./chunk-AOQKQWZU.js";
4
+ } from "./chunk-VSQT6IHZ.js";
5
5
  import {
6
6
  logLatency
7
- } from "./chunk-K2GV34T2.js";
7
+ } from "./chunk-7CLWC2UH.js";
8
8
  import {
9
9
  normalizeMapKey
10
10
  } from "./chunk-WLD6BGON.js";
@@ -1,31 +1,31 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
+ MAX_MEASURED_BYTES,
3
4
  measureFile
4
- } from "./chunk-ZD4KVFXI.js";
5
+ } from "./chunk-C5PLBTNR.js";
6
+ import "./chunk-5W3R6LFT.js";
5
7
  import {
6
8
  isComplexityLanguageId,
7
9
  isComplexitySupportedFile,
8
10
  resolveTreeSitterLanguage,
9
11
  walk,
10
12
  withTreeSitterRoot
11
- } from "./chunk-OC4ZGVMH.js";
13
+ } from "./chunk-37IDWT6O.js";
12
14
  import "./chunk-Z54ZSOBZ.js";
13
- import "./chunk-5YTDZ5WP.js";
14
- import "./chunk-E3PNZDPH.js";
15
- import "./chunk-AYDE7RFV.js";
16
- import "./chunk-3HZ6MNB2.js";
17
- import "./chunk-WBXCIRVI.js";
18
- import "./chunk-DNB4ZQGN.js";
19
- import "./chunk-SRXYSLMW.js";
20
- import "./chunk-6EIV3H7O.js";
21
- import "./chunk-3R3Z54J7.js";
15
+ import "./chunk-ZQSSO7LO.js";
16
+ import "./chunk-DI4AZZNY.js";
17
+ import "./chunk-6GLMMGCX.js";
18
+ import "./chunk-3PO4YYOX.js";
19
+ import "./chunk-CQY2HEH7.js";
20
+ import "./chunk-PQF6YGYB.js";
21
+ import "./chunk-LOEJFTF2.js";
22
22
  import "./chunk-CIA7X2PZ.js";
23
- import "./chunk-43KD3PPM.js";
23
+ import "./chunk-W26QZ3OM.js";
24
24
  import {
25
25
  createSubsystemLogger
26
- } from "./chunk-AGEQRJ5A.js";
26
+ } from "./chunk-NHA5K226.js";
27
27
  import "./chunk-S26LC76R.js";
28
- import "./chunk-K2GV34T2.js";
28
+ import "./chunk-7CLWC2UH.js";
29
29
  import "./chunk-LJDODBBZ.js";
30
30
  import "./chunk-WLD6BGON.js";
31
31
  import "./chunk-NXL4FFQQ.js";
@@ -149,7 +149,8 @@ var ComplexityClient = class {
149
149
  }
150
150
  computeMetrics(absolutePath, content, root, languageId) {
151
151
  const { codeLines, commentLines } = countLines(content, root);
152
- const file = measureFile(root, languageId);
152
+ const keyFunctions = Buffer.byteLength(content, "utf-8") <= MAX_MEASURED_BYTES;
153
+ const file = measureFile(root, languageId, keyFunctions);
153
154
  const functions = file.functions.map((f) => ({
154
155
  name: f.name,
155
156
  line: f.line,
@@ -176,7 +177,8 @@ var ComplexityClient = class {
176
177
  aiCommentPatterns: countAICommentPatterns(content),
177
178
  singleUseFunctions: countSingleUseFunctions(functions),
178
179
  tryCatchCount: countTryCatch(root),
179
- functions
180
+ functions,
181
+ measuredFunctions: keyFunctions ? file.functions : void 0
180
182
  };
181
183
  }
182
184
  aggregateFunctionStats(functions) {
@@ -11,23 +11,23 @@ import {
11
11
  shouldScanTrivy,
12
12
  trivyEvidenceFiles,
13
13
  worktreeSkipDirs
14
- } from "./chunk-WXMUGUZV.js";
15
- import "./chunk-D5L7Q57Z.js";
16
- import "./chunk-QDZ3ZZMY.js";
17
- import "./chunk-DPDA3ILA.js";
18
- import "./chunk-LHCDWFDB.js";
19
- import "./chunk-QJ4T73J5.js";
20
- import "./chunk-W6VLB6LL.js";
21
- import "./chunk-OP5BMZKK.js";
22
- import "./chunk-WBXCIRVI.js";
23
- import "./chunk-DNB4ZQGN.js";
24
- import "./chunk-B4FAFEBP.js";
25
- import "./chunk-6EIV3H7O.js";
26
- import "./chunk-3R3Z54J7.js";
27
- import "./chunk-43KD3PPM.js";
28
- import "./chunk-AGEQRJ5A.js";
14
+ } from "./chunk-CZJGAOKL.js";
15
+ import "./chunk-S6MCMD27.js";
16
+ import "./chunk-ZI7YHV6I.js";
17
+ import "./chunk-INBK3HIT.js";
18
+ import "./chunk-SDYLT45T.js";
19
+ import "./chunk-QV3JPCMK.js";
20
+ import "./chunk-2APSZHHI.js";
21
+ import "./chunk-KXGTLAUW.js";
22
+ import "./chunk-6GLMMGCX.js";
23
+ import "./chunk-3PO4YYOX.js";
24
+ import "./chunk-5JB4WENL.js";
25
+ import "./chunk-PQF6YGYB.js";
26
+ import "./chunk-LOEJFTF2.js";
27
+ import "./chunk-W26QZ3OM.js";
28
+ import "./chunk-NHA5K226.js";
29
29
  import "./chunk-S26LC76R.js";
30
- import "./chunk-K2GV34T2.js";
30
+ import "./chunk-7CLWC2UH.js";
31
31
  import "./chunk-LJDODBBZ.js";
32
32
  import "./chunk-WLD6BGON.js";
33
33
  import "./chunk-NXL4FFQQ.js";
@@ -1,4 +1,10 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+ import {
3
+ buildQualifiedName
4
+ } from "./chunk-5W3R6LFT.js";
5
+ import {
6
+ firstChildOfType
7
+ } from "./chunk-37IDWT6O.js";
2
8
 
3
9
  // dist/clients/metrics/function-metrics.js
4
10
  var JSTS = {
@@ -10,6 +16,12 @@ var JSTS = {
10
16
  "generator_function",
11
17
  "generator_function_declaration"
12
18
  ]),
19
+ containers: /* @__PURE__ */ new Set([
20
+ "class_declaration",
21
+ "abstract_class_declaration",
22
+ "class",
23
+ "interface_declaration"
24
+ ]),
13
25
  // `switch_default` is not a decision.
14
26
  decisions: /* @__PURE__ */ new Set([
15
27
  "if_statement",
@@ -44,6 +56,7 @@ var JSTS = {
44
56
  };
45
57
  var PYTHON = {
46
58
  functions: /* @__PURE__ */ new Set(["function_definition", "lambda"]),
59
+ containers: /* @__PURE__ */ new Set(["class_definition"]),
47
60
  decisions: /* @__PURE__ */ new Set([
48
61
  "if_statement",
49
62
  "elif_clause",
@@ -77,6 +90,8 @@ var GO = {
77
90
  "method_declaration",
78
91
  "func_literal"
79
92
  ]),
93
+ // A Go method's owner is its receiver type (`ownerOf`), not a container.
94
+ containers: /* @__PURE__ */ new Set(),
80
95
  // `default_case` is not a decision.
81
96
  decisions: /* @__PURE__ */ new Set([
82
97
  "if_statement",
@@ -103,6 +118,7 @@ var GO = {
103
118
  };
104
119
  var RUST = {
105
120
  functions: /* @__PURE__ */ new Set(["function_item", "closure_expression"]),
121
+ containers: /* @__PURE__ */ new Set(["impl_item", "trait_item", "mod_item"]),
106
122
  decisions: /* @__PURE__ */ new Set([
107
123
  "if_expression",
108
124
  "while_expression",
@@ -212,23 +228,176 @@ function measureFunction(fn, languageId, visit) {
212
228
  parameters: countParameters(fn)
213
229
  };
214
230
  }
215
- function measureFile(root, languageId) {
231
+ function functionName(node) {
232
+ const type = node.type;
233
+ if (type === "function_declaration") {
234
+ return firstChildOfType(node, "identifier")?.text;
235
+ }
236
+ if (type === "method_definition") {
237
+ const kids = node.children ?? [];
238
+ const paramsIdx = kids.findIndex((c) => c?.type === "formal_parameters");
239
+ for (let i = paramsIdx - 1; i >= 0; i -= 1) {
240
+ const t = kids[i]?.type;
241
+ if (t === "property_identifier" || t === "private_property_identifier" || t === "computed_property_name" || t === "string" || t === "number") {
242
+ return kids[i].text;
243
+ }
244
+ }
245
+ return void 0;
246
+ }
247
+ if (type === "arrow_function" || type === "function_expression") {
248
+ const parent = node.parent;
249
+ if (parent?.type === "variable_declarator") {
250
+ return firstChildOfType(parent, "identifier")?.text;
251
+ }
252
+ if (parent?.type === "pair")
253
+ return (parent.children ?? [])[0]?.text;
254
+ return void 0;
255
+ }
256
+ if (type === "lambda") {
257
+ const parent = node.parent;
258
+ return parent?.type === "assignment" ? parent.childForFieldName("left")?.text : void 0;
259
+ }
260
+ return node.childForFieldName("name")?.text;
261
+ }
262
+ function receiverType(fn) {
263
+ const receiver = fn.childForFieldName("receiver");
264
+ if (!receiver)
265
+ return void 0;
266
+ let found;
267
+ const visit = (node) => {
268
+ if (found !== void 0)
269
+ return;
270
+ if (node.type === "type_identifier") {
271
+ found = node.text;
272
+ return;
273
+ }
274
+ for (const child of node.children ?? [])
275
+ if (child)
276
+ visit(child);
277
+ };
278
+ visit(receiver);
279
+ return found;
280
+ }
281
+ function containerName(node) {
282
+ return node.childForFieldName("name")?.text ?? node.childForFieldName("type")?.text;
283
+ }
284
+ var ANONYMOUS_KEY = "<anonymous>";
285
+ var MAX_MEASURED_BYTES = 256 * 1024;
286
+ function assignKeys(functions, declared, receivers, containers, languageId) {
287
+ const owners = [...containers];
288
+ functions.forEach((fn, i) => {
289
+ const name = declared[i];
290
+ if (name !== void 0)
291
+ owners.push({ name, startLine: fn.line, endLine: fn.endLine });
292
+ });
293
+ owners.forEach((owner, priority) => {
294
+ owner.priority = priority;
295
+ });
296
+ const entries = [
297
+ ...owners.map((owner) => ({ ...owner, index: -1 })),
298
+ ...functions.map((fn, index) => ({
299
+ name: void 0,
300
+ startLine: fn.line,
301
+ endLine: fn.endLine,
302
+ index
303
+ }))
304
+ ];
305
+ const byEnd = [];
306
+ let lastLine = 0;
307
+ for (const entry of entries) {
308
+ (byEnd[entry.endLine] ??= []).push(entry);
309
+ lastLine = Math.max(lastLine, entry.endLine);
310
+ }
311
+ const byStart = [];
312
+ for (let line = lastLine; line >= 0; line--) {
313
+ for (const entry of byEnd[line] ?? []) {
314
+ (byStart[entry.startLine] ??= []).push(entry);
315
+ }
316
+ }
317
+ const ending = [];
318
+ for (const owner of owners) {
319
+ const prior = ending[owner.endLine];
320
+ const span = owner.endLine - owner.startLine;
321
+ if (span > 0 && (!prior || span < prior.endLine - prior.startLine))
322
+ ending[owner.endLine] = owner;
323
+ }
324
+ const open = [];
325
+ const ownerNames = [];
326
+ for (let line = 0; line <= lastLine; line++) {
327
+ for (const entry of byStart[line] ?? []) {
328
+ while (open.length && open[open.length - 1].endLine < entry.endLine)
329
+ open.pop();
330
+ const top = open[open.length - 1];
331
+ const equal = top?.startLine === entry.startLine && top.endLine === entry.endLine;
332
+ if (entry.index >= 0) {
333
+ let owner = equal ? open[open.length - 2] : top;
334
+ const boundary = ending[entry.endLine];
335
+ if (entry.startLine === entry.endLine && boundary && (!owner || boundary.endLine - boundary.startLine < owner.endLine - owner.startLine || boundary.endLine - boundary.startLine === owner.endLine - owner.startLine && boundary.priority < owner.priority))
336
+ owner = boundary;
337
+ ownerNames[entry.index] = owner?.name;
338
+ }
339
+ if (entry.name !== void 0 && !equal)
340
+ open.push({ ...entry, name: entry.name });
341
+ }
342
+ }
343
+ const seen = /* @__PURE__ */ new Map();
344
+ return functions.map((fn, i) => {
345
+ const base = declared[i] ?? ANONYMOUS_KEY;
346
+ const owner = languageId === "go" && receivers[i] !== null ? receivers[i] : ownerNames[i];
347
+ const qualified = buildQualifiedName(owner, base) ?? base;
348
+ const count = (seen.get(qualified) ?? 0) + 1;
349
+ seen.set(qualified, count);
350
+ return { ...fn, key: count === 1 ? qualified : `${qualified}#${count}` };
351
+ });
352
+ }
353
+ function measureFile(root, languageId, keyFunctions = true) {
216
354
  const table = TABLES[languageId];
217
355
  const functions = [];
356
+ const declared = [];
357
+ const receivers = [];
358
+ const containers = [];
218
359
  const { cognitive, nesting } = tally(root, table, false, (node, type) => {
360
+ if (keyFunctions && table.containers.has(type)) {
361
+ const name = containerName(node);
362
+ if (name !== void 0)
363
+ containers.push({
364
+ name,
365
+ startLine: node.startPosition.row + 1,
366
+ endLine: node.endPosition.row + 1
367
+ });
368
+ return;
369
+ }
219
370
  if (!table.functions.has(type) || !node.isNamed)
220
371
  return;
221
372
  const line = node.startPosition.row + 1;
373
+ if (keyFunctions) {
374
+ declared.push(functionName(node));
375
+ receivers.push(languageId === "go" && type === "method_declaration" ? receiverType(node) : null);
376
+ }
222
377
  functions.push({
223
- name: node.childForFieldName("name")?.text ?? `<anonymous@L${line}>`,
378
+ name: functionName(node) ?? `<anonymous@L${line}>`,
224
379
  line,
380
+ endLine: node.endPosition.row + 1,
225
381
  ...measureFunction(node, languageId)
226
382
  });
227
383
  });
228
- return { cognitive, nesting, functions };
384
+ let keyed;
385
+ return {
386
+ cognitive,
387
+ nesting,
388
+ functions: !keyFunctions ? functions.map((fn) => ({ ...fn, key: ANONYMOUS_KEY })) : functions.map((fn, index) => ({
389
+ ...fn,
390
+ get key() {
391
+ keyed ??= assignKeys(functions, declared, receivers, containers, languageId);
392
+ return keyed[index].key;
393
+ }
394
+ }))
395
+ };
229
396
  }
230
397
 
231
398
  export {
232
399
  measureFunction,
400
+ functionName,
401
+ MAX_MEASURED_BYTES,
233
402
  measureFile
234
403
  };
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  findNearestDirWithMarker
4
- } from "./chunk-3R3Z54J7.js";
4
+ } from "./chunk-LOEJFTF2.js";
5
5
  import {
6
6
  isWindowsPath
7
7
  } from "./chunk-WLD6BGON.js";
@@ -3,7 +3,7 @@ import {
3
3
  findGoverningTsconfigDir,
4
4
  getDirectoryMarkers,
5
5
  registerWorkspaceTopologyReset
6
- } from "./chunk-3R3Z54J7.js";
6
+ } from "./chunk-LOEJFTF2.js";
7
7
  import {
8
8
  BoundedLruCache
9
9
  } from "./chunk-WLD6BGON.js";
@@ -2,25 +2,26 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
2
2
  import {
3
3
  getScratchTreeGlobPatterns,
4
4
  nestedWorktreeOffsets
5
- } from "./chunk-D5L7Q57Z.js";
5
+ } from "./chunk-S6MCMD27.js";
6
6
  import {
7
7
  SecurityScanClient
8
- } from "./chunk-QDZ3ZZMY.js";
8
+ } from "./chunk-ZI7YHV6I.js";
9
9
  import {
10
10
  parseReportJson
11
- } from "./chunk-DPDA3ILA.js";
11
+ } from "./chunk-INBK3HIT.js";
12
12
  import {
13
13
  safeSpawnAsync
14
- } from "./chunk-DNB4ZQGN.js";
14
+ } from "./chunk-3PO4YYOX.js";
15
15
  import {
16
16
  loadPiLensProjectConfig
17
- } from "./chunk-6EIV3H7O.js";
17
+ } from "./chunk-PQF6YGYB.js";
18
18
  import {
19
19
  incrementDegradationCount
20
- } from "./chunk-AGEQRJ5A.js";
20
+ } from "./chunk-NHA5K226.js";
21
21
  import {
22
22
  isUnderDir,
23
23
  normalizeMapKey,
24
+ realpathOrResolve,
24
25
  toPosix
25
26
  } from "./chunk-WLD6BGON.js";
26
27
 
@@ -179,7 +180,7 @@ var TrivyClient = class extends SecurityScanClient {
179
180
  * same root share a single process.
180
181
  */
181
182
  async scan(cwd) {
182
- const targetDir = path.resolve(cwd);
183
+ const targetDir = realpathOrResolve(cwd);
183
184
  const scannedAt = (/* @__PURE__ */ new Date()).toISOString();
184
185
  if (!shouldScanTrivy(targetDir)) {
185
186
  return {
@@ -3,48 +3,48 @@ import {
3
3
  augmentPythonEnvironment,
4
4
  detectPythonEnvironment,
5
5
  emitBounded
6
- } from "./chunk-NLRKB32C.js";
6
+ } from "./chunk-2H5GHZKC.js";
7
7
  import {
8
8
  scannerReportParentDir
9
- } from "./chunk-QJ4T73J5.js";
9
+ } from "./chunk-QV3JPCMK.js";
10
10
  import {
11
11
  stripAnsi
12
12
  } from "./chunk-6HWVI6MI.js";
13
13
  import {
14
14
  resolveToolCwd
15
- } from "./chunk-JSQK5DH3.js";
15
+ } from "./chunk-LVLPA32Q.js";
16
16
  import {
17
17
  findGlobalBinary,
18
18
  findLocalBinAt,
19
19
  localBinPath
20
- } from "./chunk-FVEEEEIM.js";
20
+ } from "./chunk-LGH2HHZG.js";
21
21
  import {
22
22
  getIsolatedNpxSpawnOptions
23
- } from "./chunk-OP5BMZKK.js";
23
+ } from "./chunk-KXGTLAUW.js";
24
24
  import {
25
25
  resolveLanguageRootForFile
26
- } from "./chunk-TTGDTNSN.js";
26
+ } from "./chunk-XSC3BCN3.js";
27
27
  import {
28
28
  resolveGitCheckout,
29
29
  safeSpawn,
30
30
  safeSpawnAsync
31
- } from "./chunk-DNB4ZQGN.js";
31
+ } from "./chunk-3PO4YYOX.js";
32
32
  import {
33
33
  DOTNET_CSHARP_ROOT_MARKERS,
34
34
  detectFileKind
35
- } from "./chunk-SRXYSLMW.js";
35
+ } from "./chunk-CQY2HEH7.js";
36
36
  import {
37
37
  PathKeyedMap,
38
38
  detectFileRole
39
- } from "./chunk-6EIV3H7O.js";
39
+ } from "./chunk-PQF6YGYB.js";
40
40
  import {
41
41
  findNearestDirWithAnyBasename
42
- } from "./chunk-3R3Z54J7.js";
42
+ } from "./chunk-LOEJFTF2.js";
43
43
  import {
44
44
  LEDGER_FIELD_MAX,
45
45
  createSubsystemLogger,
46
46
  recordDegradationOnce
47
- } from "./chunk-AGEQRJ5A.js";
47
+ } from "./chunk-NHA5K226.js";
48
48
  import {
49
49
  BoundedFifoMap,
50
50
  direntsHaveMarkerGlobMatch,