pi-lens 4.4.7 → 4.4.9

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 (186) hide show
  1. package/CHANGELOG-USER.md +31 -0
  2. package/CHANGELOG.md +327 -0
  3. package/README.md +13 -2
  4. package/config/dependency-cruiser-eager-allowlist.json +1 -1
  5. package/config/markdownlint/run-no-fix.mjs +36 -0
  6. package/dist/{chunk-4LM3VAZH.js → chunk-2VZ3VN3N.js} +2 -2
  7. package/dist/{chunk-PUZ3E2J4.js → chunk-3HTZDY3C.js} +8 -6
  8. package/dist/{chunk-RORGS5II.js → chunk-3NPWO5UO.js} +7 -13
  9. package/dist/{chunk-MNJIXFX4.js → chunk-47UCC4MM.js} +1 -1
  10. package/dist/chunk-4ENEJHF4.js +198 -0
  11. package/dist/chunk-5GEYJJHG.js +22 -0
  12. package/dist/{chunk-U6VN4NVL.js → chunk-5YSEQHJN.js} +3 -3
  13. package/dist/{chunk-6IR3ZYIB.js → chunk-6GPB3JLL.js} +3 -3
  14. package/dist/{chunk-MB6PXBUA.js → chunk-7R5GZIA6.js} +7 -15
  15. package/dist/{chunk-DH5JPM3K.js → chunk-7UTSNTWM.js} +10 -9
  16. package/dist/{chunk-24BILSZW.js → chunk-7YTRG6YW.js} +2 -2
  17. package/dist/{chunk-KW5JQPO5.js → chunk-AACN5GNE.js} +2 -2
  18. package/dist/{chunk-PKES3ISE.js → chunk-ACRJ2GZ5.js} +2 -2
  19. package/dist/{chunk-4ZYJHQMB.js → chunk-C3YRO3EU.js} +10 -12
  20. package/dist/{chunk-PQJFG24Z.js → chunk-CB7PEVOJ.js} +1300 -946
  21. package/dist/{chunk-ABPKUVA4.js → chunk-CDFJF5YD.js} +1 -1
  22. package/dist/{chunk-T7A2HK2B.js → chunk-CJS6WE66.js} +17 -18
  23. package/dist/{chunk-3YY7IXIL.js → chunk-CM6BDY4E.js} +14 -60
  24. package/dist/{chunk-RZOXUSPC.js → chunk-CZCAZVTD.js} +16 -2
  25. package/dist/chunk-DGKFWQK4.js +23 -0
  26. package/dist/{chunk-NA7SEXHE.js → chunk-E65WJVI5.js} +7 -9
  27. package/dist/{chunk-2TF6RXWB.js → chunk-EKNYSXFB.js} +8 -10
  28. package/dist/{chunk-RRV3FNNM.js → chunk-EY6LY2HO.js} +27 -30
  29. package/dist/{chunk-LBLBAFG3.js → chunk-F6BEQWAK.js} +17 -5
  30. package/dist/{chunk-4L36HG27.js → chunk-FGNSESAC.js} +12 -14
  31. package/dist/{chunk-3FRLWYBG.js → chunk-FRUBVFXV.js} +39 -42
  32. package/dist/{chunk-FB5SCCPT.js → chunk-G22UNQID.js} +14 -15
  33. package/dist/{chunk-LV4UMYVH.js → chunk-GQTQUNCG.js} +26 -27
  34. package/dist/{chunk-E7HJ56Y7.js → chunk-H3BVMK47.js} +64 -73
  35. package/dist/chunk-H6FLQ5NW.js +28 -0
  36. package/dist/{chunk-QHSNL7B2.js → chunk-HEA3EM23.js} +15 -19
  37. package/dist/{chunk-AWDSEDER.js → chunk-HSOBIN22.js} +2 -2
  38. package/dist/{chunk-EAOK7MIZ.js → chunk-HYSKJMZK.js} +17 -4
  39. package/dist/{chunk-VUZWQ7UG.js → chunk-IICERRFF.js} +46 -72
  40. package/dist/{chunk-OXOI55RU.js → chunk-IILEH3ZC.js} +8 -10
  41. package/dist/{chunk-ZKXQKGWZ.js → chunk-J3Q2NYJR.js} +4 -3
  42. package/dist/{chunk-YHC2O2WO.js → chunk-JUZ67QZQ.js} +20 -9
  43. package/dist/chunk-KR5VGMVT.js +25 -0
  44. package/dist/{chunk-F7K5IBZG.js → chunk-KV6GQOGN.js} +41 -44
  45. package/dist/{chunk-SNDXCFRS.js → chunk-KXMJLOZF.js} +25 -23
  46. package/dist/{chunk-CB4WHS4H.js → chunk-L4Y3ROKQ.js} +3 -3
  47. package/dist/{chunk-3F6BMY53.js → chunk-L6WBJGQS.js} +1 -1
  48. package/dist/{chunk-MPKRJBPK.js → chunk-L7O774U7.js} +30 -32
  49. package/dist/{chunk-URCQWAQ4.js → chunk-LAHHGNAY.js} +21 -21
  50. package/dist/{chunk-V63BC55Q.js → chunk-LT62P654.js} +1 -1
  51. package/dist/{chunk-ZMAUPOMG.js → chunk-LWOM6LVS.js} +34 -34
  52. package/dist/{chunk-HO6LWE2E.js → chunk-MKPDIAZH.js} +21 -1
  53. package/dist/{chunk-2PHMIAKO.js → chunk-MN635QYA.js} +3 -4
  54. package/dist/{chunk-KDX35VXP.js → chunk-MQ4PPCJB.js} +166 -149
  55. package/dist/{chunk-QOE342SU.js → chunk-MRLH4MYU.js} +2 -2
  56. package/dist/{chunk-CE6VMBCB.js → chunk-N56BNAA6.js} +20 -21
  57. package/dist/{chunk-L3CMBQMH.js → chunk-N5CEGQPG.js} +14 -17
  58. package/dist/{chunk-7E2563GA.js → chunk-NCLO6E6N.js} +13 -33
  59. package/dist/{chunk-J6JP25XU.js → chunk-NL5LSKVD.js} +4 -3
  60. package/dist/{chunk-U7BD2QL7.js → chunk-NMUSOZ2D.js} +10 -12
  61. package/dist/{chunk-BZARLRJW.js → chunk-NOWH2VA2.js} +8 -33
  62. package/dist/{chunk-U2SDMG7C.js → chunk-NUSXS6YB.js} +6 -5
  63. package/dist/{chunk-ZJTT47IG.js → chunk-OSEKJEUU.js} +2 -2
  64. package/dist/{chunk-FZKFVUEC.js → chunk-OUYAUXAT.js} +647 -355
  65. package/dist/{chunk-ZE3KXHS7.js → chunk-PBZNYHMM.js} +84 -4
  66. package/dist/{chunk-U5HPROLA.js → chunk-PIIUNJIT.js} +2 -4
  67. package/dist/chunk-PKLB2XJL.js +8 -0
  68. package/dist/{chunk-RC2Z6K47.js → chunk-PRHYIA6X.js} +15 -6
  69. package/dist/{chunk-RQS4QQSD.js → chunk-PXQ45SGD.js} +2 -2
  70. package/dist/chunk-Q6JQKWPK.js +25 -0
  71. package/dist/{chunk-F6X3YJWD.js → chunk-QB7T2PHK.js} +2 -2
  72. package/dist/{chunk-TIQJPRDD.js → chunk-QGITU23N.js} +3 -2
  73. package/dist/chunk-QJJKOHLH.js +57 -0
  74. package/dist/{chunk-4LOE5R5P.js → chunk-QP33NKYC.js} +18 -15
  75. package/dist/{chunk-N5WSK2K7.js → chunk-QVBOXT3L.js} +12 -17
  76. package/dist/{chunk-DPGEAHZT.js → chunk-RNJFRXEN.js} +10 -18
  77. package/dist/{chunk-EKWX4WD3.js → chunk-RNXOWDM6.js} +10 -10
  78. package/dist/{chunk-O4BJFESU.js → chunk-RTFMDIKV.js} +1 -1
  79. package/dist/{chunk-LS3QJRUB.js → chunk-SIQHOB6P.js} +11 -13
  80. package/dist/{chunk-3K2F6UDZ.js → chunk-SLSMJPEF.js} +43 -42
  81. package/dist/chunk-T5QSLSMM.js +50 -0
  82. package/dist/chunk-TGQDAG4B.js +88 -0
  83. package/dist/{chunk-4YHYPW2G.js → chunk-THYHUIDR.js} +44 -13
  84. package/dist/{chunk-YVHBNSME.js → chunk-TMNUTMT5.js} +1099 -1100
  85. package/dist/{chunk-WDBICWH3.js → chunk-TOE2RRCS.js} +1 -1
  86. package/dist/chunk-TYHPVE5H.js +25 -0
  87. package/dist/chunk-UAKO2M6B.js +73 -0
  88. package/dist/chunk-UC5AXW5Z.js +20 -0
  89. package/dist/chunk-UTJP6WOS.js +28 -0
  90. package/dist/{chunk-DQZFQSR5.js → chunk-UXTQ3QPD.js} +4 -4
  91. package/dist/chunk-UYXV5NIS.js +20 -0
  92. package/dist/{chunk-KKCK636N.js → chunk-V2WDBOLZ.js} +10 -12
  93. package/dist/{chunk-PR6PO3ES.js → chunk-V67D6TMU.js} +22 -20
  94. package/dist/{chunk-VSFLRN5Y.js → chunk-VCRVNLE7.js} +135 -2
  95. package/dist/{chunk-CPSR3AVL.js → chunk-VO4JFPTV.js} +2 -2
  96. package/dist/{chunk-XT2HTCJ5.js → chunk-VWLSU3XV.js} +6 -5
  97. package/dist/{chunk-WME2OQST.js → chunk-W5E72HJA.js} +66 -24
  98. package/dist/{chunk-LLS45EWB.js → chunk-W7TY6HYX.js} +6 -8
  99. package/dist/{chunk-CCV2EU7T.js → chunk-WSSLVMDA.js} +12 -13
  100. package/dist/{chunk-YISME6ON.js → chunk-WTB4GKMH.js} +10 -1
  101. package/dist/{chunk-KPPJTH44.js → chunk-X5BJ3G2P.js} +64 -35
  102. package/dist/{chunk-JMEKXFOL.js → chunk-XKFO2SZV.js} +39 -34
  103. package/dist/{chunk-HR3OJ3TH.js → chunk-XLAI7UYY.js} +84 -31
  104. package/dist/{chunk-H7OR7DFZ.js → chunk-XO756WE5.js} +53 -37
  105. package/dist/{chunk-F5Z6URKM.js → chunk-XVB3Q2PG.js} +2 -4
  106. package/dist/{chunk-R5MOQM2H.js → chunk-YOXCCJDF.js} +607 -366
  107. package/dist/{chunk-ZGSJDWQU.js → chunk-ZCQBNPRH.js} +2 -2
  108. package/dist/chunk-ZD4KVFXI.js +234 -0
  109. package/dist/{chunk-WGRJOXED.js → chunk-ZDMFGACN.js} +1295 -966
  110. package/dist/{chunk-OSTKYB55.js → chunk-ZMMHHXSW.js} +1 -1
  111. package/dist/{chunk-75GAYVNO.js → chunk-ZPM7ZIFL.js} +6 -6
  112. package/dist/{chunk-LUBPZN36.js → chunk-ZVCDHYWZ.js} +9 -11
  113. package/dist/{chunk-Y7F7IEE3.js → chunk-ZZN74OGD.js} +102 -7
  114. package/dist/{chunk-L5JYIU47.js → chunk-ZZSJAR76.js} +39 -20
  115. package/dist/index.js +10933 -8644
  116. package/dist/mcp/analyze-cli.js +12 -17
  117. package/dist/mcp/cli.js +43 -42
  118. package/dist/mcp/server.js +3073 -1147
  119. package/dist/mcp/worker.js +61 -61
  120. package/dist/probes/installer.js +18 -19
  121. package/docs/adr/0003-git-guard-latch-writer.md +11 -6
  122. package/docs/agent-tools.md +58 -16
  123. package/docs/alignment-families.md +29 -0
  124. package/docs/analysisall.md +1 -1
  125. package/docs/ast-grep_rules_catalog.md +6 -4
  126. package/docs/ci-bot-pr-checks.md +128 -0
  127. package/docs/configuration.md +150 -12
  128. package/docs/defect-shapes.md +107 -15
  129. package/docs/engineering-principles.md +27 -2
  130. package/docs/environment-variables.md +18 -1
  131. package/docs/features.md +14 -7
  132. package/docs/globalconfig.md +11 -3
  133. package/docs/invariants/git-guard-host.md +7 -3
  134. package/docs/invariants/language-config.md +15 -4
  135. package/docs/invariants/lsp-trust-exec.md +25 -4
  136. package/docs/invariants/paths-os.md +4 -2
  137. package/docs/invariants/session-telemetry.md +2 -2
  138. package/docs/language-coverage.md +1 -0
  139. package/docs/lsp-capability-matrix.md +167 -65
  140. package/docs/lsp-idle-eviction.md +4 -1
  141. package/docs/merge-queue-rollout.md +10 -8
  142. package/docs/module-report-read-symbol.md +34 -23
  143. package/docs/pi-lens-fixer.md +34 -17
  144. package/docs/pi-lens-investigator.md +3 -0
  145. package/docs/pi-lens-merge-policy.md +34 -17
  146. package/docs/pi-lens-monitor.md +9 -0
  147. package/docs/pi-lens-orchestration.md +4 -1
  148. package/docs/pi-lens-reviewer.md +6 -6
  149. package/docs/pi-lens-subagent.md +19 -3
  150. package/docs/public-api-stability.md +57 -7
  151. package/docs/release-qa-baseline.md +7 -4
  152. package/docs/schema/pi-lens-config-v1.json +21 -2
  153. package/docs/servercapabilities.md +3 -1
  154. package/docs/settings.md +11 -7
  155. package/docs/word-index.md +20 -7
  156. package/package.json +11 -4
  157. package/rules/ast-grep-rules/rule-tests/no-accumulating-spread-js-test.yml +37 -0
  158. package/rules/ast-grep-rules/rule-tests/ts-redundant-filter-map-test.yml +12 -1
  159. package/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-js-test.yml +12 -0
  160. package/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-test.yml +25 -0
  161. package/rules/ast-grep-rules/rules/no-accumulating-spread-js.yml +49 -1
  162. package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +1 -2
  163. package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +1 -2
  164. package/rules/ast-grep-rules/rules/ts-redundant-filter-map.yml +9 -1
  165. package/rules/ast-grep-rules/rules-disabled/filter-then-map-js.yml +17 -0
  166. package/rules/ast-grep-rules/rules-disabled/filter-then-map.yml +36 -0
  167. package/rules/ast-grep-rules/self-scan-baseline.json +1 -1
  168. package/scripts/download-grammars.js +3 -2
  169. package/skills/pi-lens-lsp-navigation/SKILL.md +5 -1
  170. package/dist/chunk-46TNM7XZ.js +0 -88
  171. package/dist/chunk-72OKUXSD.js +0 -31
  172. package/dist/chunk-7GLOLOSH.js +0 -57
  173. package/dist/chunk-AKUUMGD5.js +0 -26
  174. package/dist/chunk-ASUXV767.js +0 -22
  175. package/dist/chunk-CTADOKYM.js +0 -25
  176. package/dist/chunk-GNSIWBAT.js +0 -106
  177. package/dist/chunk-HWDAVBFU.js +0 -49
  178. package/dist/chunk-JJ2RRESP.js +0 -58
  179. package/dist/chunk-KXF5R4UN.js +0 -48
  180. package/dist/chunk-LSC3VADM.js +0 -23
  181. package/dist/chunk-OE5ZBP7F.js +0 -443
  182. package/dist/chunk-SHLDT3OI.js +0 -27
  183. package/dist/chunk-UF7RTZSO.js +0 -27
  184. package/dist/chunk-W4WP2ERB.js +0 -30
  185. package/dist/chunk-YES5CACN.js +0 -73
  186. package/dist/chunk-Z2XAOKHK.js +0 -136
@@ -10,7 +10,6 @@ import {
10
10
  getAmbientAbortSignal,
11
11
  hasSpawnFailureKind,
12
12
  holdOwnChildPid,
13
- isCommandAvailable,
14
13
  isCommandAvailableAsync,
15
14
  isOwnLiveChild,
16
15
  mergeWindowsEnvironment,
@@ -22,23 +21,20 @@ import {
22
21
  resolveWindowsCommandForEnvironment,
23
22
  safeSpawn,
24
23
  safeSpawnAsync,
25
- safeSpawnBatch,
26
24
  setAmbientAbortSignal,
27
25
  spawnAbortScope,
28
26
  statIsFile,
29
27
  trustScopedEnvironment,
30
28
  trustScopedSearchPath
31
- } from "./chunk-YVHBNSME.js";
32
- import "./chunk-KPPJTH44.js";
33
- import "./chunk-J6JP25XU.js";
34
- import "./chunk-U5HPROLA.js";
35
- import "./chunk-WME2OQST.js";
36
- import "./chunk-KXF5R4UN.js";
29
+ } from "./chunk-TMNUTMT5.js";
30
+ import "./chunk-X5BJ3G2P.js";
31
+ import "./chunk-NL5LSKVD.js";
32
+ import "./chunk-PIIUNJIT.js";
33
+ import "./chunk-W5E72HJA.js";
37
34
  import "./chunk-S26LC76R.js";
38
- import "./chunk-Z2XAOKHK.js";
39
- import "./chunk-VSFLRN5Y.js";
35
+ import "./chunk-VCRVNLE7.js";
40
36
  import "./chunk-LJDODBBZ.js";
41
- import "./chunk-PQJFG24Z.js";
37
+ import "./chunk-CB7PEVOJ.js";
42
38
  import "./chunk-NXL4FFQQ.js";
43
39
  export {
44
40
  SpawnFailureError,
@@ -51,7 +47,6 @@ export {
51
47
  getAmbientAbortSignal,
52
48
  hasSpawnFailureKind,
53
49
  holdOwnChildPid,
54
- isCommandAvailable,
55
50
  isCommandAvailableAsync,
56
51
  isOwnLiveChild,
57
52
  mergeWindowsEnvironment,
@@ -63,7 +58,6 @@ export {
63
58
  resolveWindowsCommandForEnvironment,
64
59
  safeSpawn,
65
60
  safeSpawnAsync,
66
- safeSpawnBatch,
67
61
  setAmbientAbortSignal,
68
62
  spawnAbortScope,
69
63
  statIsFile,
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  detectFileRole
4
- } from "./chunk-KPPJTH44.js";
4
+ } from "./chunk-X5BJ3G2P.js";
5
5
 
6
6
  // dist/clients/collateral-test-role.js
7
7
  function isTestRoleCollateral(filePath) {
@@ -0,0 +1,198 @@
1
+ import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+ import {
3
+ measureFile
4
+ } from "./chunk-ZD4KVFXI.js";
5
+ import {
6
+ isComplexityLanguageId,
7
+ isComplexitySupportedFile,
8
+ resolveTreeSitterLanguage,
9
+ walk,
10
+ withTreeSitterRoot
11
+ } from "./chunk-ZZSJAR76.js";
12
+ import "./chunk-Z54ZSOBZ.js";
13
+ import "./chunk-5YSEQHJN.js";
14
+ import "./chunk-QGITU23N.js";
15
+ import "./chunk-WTB4GKMH.js";
16
+ import "./chunk-MKPDIAZH.js";
17
+ import "./chunk-AACN5GNE.js";
18
+ import "./chunk-TMNUTMT5.js";
19
+ import "./chunk-CZCAZVTD.js";
20
+ import "./chunk-X5BJ3G2P.js";
21
+ import "./chunk-NL5LSKVD.js";
22
+ import "./chunk-PIIUNJIT.js";
23
+ import {
24
+ createSubsystemLogger
25
+ } from "./chunk-W5E72HJA.js";
26
+ import "./chunk-S26LC76R.js";
27
+ import "./chunk-VCRVNLE7.js";
28
+ import "./chunk-LJDODBBZ.js";
29
+ import "./chunk-CB7PEVOJ.js";
30
+ import "./chunk-NXL4FFQQ.js";
31
+
32
+ // dist/clients/complexity-client.js
33
+ import * as fs from "node:fs";
34
+ import * as path from "node:path";
35
+ var COMMENT_TYPES = /* @__PURE__ */ new Set(["comment", "line_comment", "block_comment"]);
36
+ function countTryCatch(root) {
37
+ let count = 0;
38
+ walk(root, (n) => {
39
+ if (n.type === "try_statement")
40
+ count++;
41
+ });
42
+ return count;
43
+ }
44
+ function countLines(content, root) {
45
+ const lines = content.split(/\r?\n/);
46
+ const commentLineSet = /* @__PURE__ */ new Set();
47
+ walk(root, (n) => {
48
+ if (COMMENT_TYPES.has(n.type)) {
49
+ for (let l = n.startPosition.row; l <= n.endPosition.row; l++) {
50
+ commentLineSet.add(l);
51
+ }
52
+ }
53
+ });
54
+ const codeLines = lines.filter((line, i) => {
55
+ if (line.trim().length === 0)
56
+ return false;
57
+ if (!commentLineSet.has(i))
58
+ return true;
59
+ const stripped = line.replace(/\/\/.*$/, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/#.*$/, "").trim();
60
+ return stripped.length > 0;
61
+ }).length;
62
+ return { codeLines, commentLines: commentLineSet.size };
63
+ }
64
+ var AI_COMMENT_PATTERNS = [
65
+ /(?:🔍|✅|📝|🔧|🐛|⚠️|🚀|💡|🎯|📌|🏷️|🔑|🏗️|🧪|🗑️|🔄|♻️|📋|🔖|📊|💬|🔥|💎|⭐|🌟|🎨|🛠️)/u,
66
+ /(?:\/\/|#)\s*(Initialize|Setup|Clean up|Create|Define|Check if|Handle|Process|Validate|Return|Get|Set|Add|Remove|Update|Fetch)\b/i,
67
+ /(?:\/\/|#)\s*(This function|This method|This code|Here we|Now we)\b/i,
68
+ /\/\*\*?\s*(Overview|Summary|Description|Example|Usage)\s*\*?\//i
69
+ ];
70
+ function countAICommentPatterns(sourceText) {
71
+ let count = 0;
72
+ for (const line of sourceText.split(/\r?\n/)) {
73
+ const trimmed = line.trim();
74
+ if (trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*") || trimmed.startsWith("#")) {
75
+ for (const pattern of AI_COMMENT_PATTERNS) {
76
+ if (pattern.test(line)) {
77
+ count++;
78
+ break;
79
+ }
80
+ }
81
+ }
82
+ }
83
+ return count;
84
+ }
85
+ function calculateCodeEntropy(sourceText) {
86
+ const tokens = sourceText.replace(/\/\/.*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/["'`][^"'`]*["'`]/g, "STR").replace(/\b\d+(\.\d+)?\b/g, "NUM").split(/[\s\n\r\t,;:()[\]{}=<>!&|+\-*/%^~?]+/).filter((t) => t.length > 0);
87
+ if (tokens.length === 0)
88
+ return 0;
89
+ const freq = /* @__PURE__ */ new Map();
90
+ for (const token of tokens)
91
+ freq.set(token, (freq.get(token) || 0) + 1);
92
+ let entropy = 0;
93
+ for (const count of freq.values()) {
94
+ const p = count / tokens.length;
95
+ if (p > 0)
96
+ entropy -= p * Math.log2(p);
97
+ }
98
+ return entropy;
99
+ }
100
+ function calculateMaintainabilityIndex(cyclomatic, loc, comments) {
101
+ if (loc === 0)
102
+ return 100;
103
+ const lnLOC = Math.log(loc);
104
+ let mi = (171 - 0.23 * cyclomatic - 16.2 * lnLOC) * 100 / 171;
105
+ const commentBonus = Math.min(10, comments / loc * 50);
106
+ mi += commentBonus;
107
+ return Math.max(0, Math.min(100, mi));
108
+ }
109
+ function countSingleUseFunctions(functions) {
110
+ return functions.filter((f) => f.length < 10 && f.cyclomatic <= 2 && /^(get|set|check|is|has|validate|format|parse|convert|create|make)/i.test(f.name)).length;
111
+ }
112
+ var ComplexityClient = class {
113
+ log;
114
+ constructor(verbose = false) {
115
+ this.log = verbose ? createSubsystemLogger("complexity") : () => {
116
+ };
117
+ }
118
+ /** True if the file's grammar has a complexity node mapping.
119
+ *
120
+ * Delegates to the module-free predicate in `tree-sitter-shared.ts`: the
121
+ * same question is asked by `handleToolCallImpl` BEFORE the analyzer
122
+ * bootstrap is loaded (#2467), and two copies of it would be two answers. */
123
+ isSupportedFile(filePath) {
124
+ return isComplexitySupportedFile(filePath);
125
+ }
126
+ /** Analyze complexity metrics for a file (null if unsupported / unparseable). */
127
+ async analyzeFile(filePath) {
128
+ const absolutePath = path.resolve(filePath);
129
+ const languageId = resolveTreeSitterLanguage(absolutePath);
130
+ if (!languageId || !isComplexityLanguageId(languageId))
131
+ return null;
132
+ let content;
133
+ try {
134
+ if (!fs.existsSync(absolutePath))
135
+ return null;
136
+ content = fs.readFileSync(absolutePath, "utf-8");
137
+ } catch (err) {
138
+ this.log(`Read error for ${filePath}: ${err.message}`);
139
+ return null;
140
+ }
141
+ try {
142
+ const parsed = await withTreeSitterRoot(absolutePath, content, (root) => this.computeMetrics(absolutePath, content, root, languageId), "complexity");
143
+ return parsed.parsed ? parsed.value : null;
144
+ } catch (err) {
145
+ this.log(`Analysis error for ${filePath}: ${err.message}`);
146
+ return null;
147
+ }
148
+ }
149
+ computeMetrics(absolutePath, content, root, languageId) {
150
+ const { codeLines, commentLines } = countLines(content, root);
151
+ const file = measureFile(root, languageId);
152
+ const functions = file.functions.map((f) => ({
153
+ name: f.name,
154
+ line: f.line,
155
+ length: f.length,
156
+ cyclomatic: f.cyclomatic - 1,
157
+ cognitive: f.cognitive,
158
+ nestingDepth: f.nesting
159
+ }));
160
+ const funcStats = this.aggregateFunctionStats(functions);
161
+ return {
162
+ filePath: path.relative(process.cwd(), absolutePath),
163
+ maxNestingDepth: file.nesting,
164
+ avgFunctionLength: funcStats.avgLength,
165
+ maxFunctionLength: funcStats.maxLength,
166
+ functionCount: functions.length,
167
+ cyclomaticComplexity: funcStats.avgCyclomatic,
168
+ maxCyclomaticComplexity: funcStats.maxCyclomatic,
169
+ cognitiveComplexity: file.cognitive,
170
+ maintainabilityIndex: Math.round(calculateMaintainabilityIndex(funcStats.avgCyclomatic, codeLines, commentLines) * 10) / 10,
171
+ linesOfCode: codeLines,
172
+ commentLines,
173
+ codeEntropy: Math.round(calculateCodeEntropy(content) * 100) / 100,
174
+ maxParamsInFunction: Math.max(0, ...file.functions.map((f) => f.parameters)),
175
+ aiCommentPatterns: countAICommentPatterns(content),
176
+ singleUseFunctions: countSingleUseFunctions(functions),
177
+ tryCatchCount: countTryCatch(root),
178
+ functions
179
+ };
180
+ }
181
+ aggregateFunctionStats(functions) {
182
+ if (functions.length === 0) {
183
+ return { avgLength: 0, maxLength: 0, avgCyclomatic: 1, maxCyclomatic: 1 };
184
+ }
185
+ const lengths = functions.map((f) => f.length);
186
+ const cyclomatics = functions.map((f) => f.cyclomatic);
187
+ const sum = (arr) => arr.reduce((a, b) => a + b, 0);
188
+ return {
189
+ avgLength: Math.round(sum(lengths) / lengths.length),
190
+ maxLength: Math.max(...lengths),
191
+ avgCyclomatic: Math.max(1, Math.round(sum(cyclomatics) / cyclomatics.length)),
192
+ maxCyclomatic: Math.max(1, Math.max(...cyclomatics))
193
+ };
194
+ }
195
+ };
196
+ export {
197
+ ComplexityClient
198
+ };
@@ -0,0 +1,22 @@
1
+ import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+ import {
3
+ computeImpactCascade,
4
+ computeTransitiveImpact
5
+ } from "./chunk-HYSKJMZK.js";
6
+ import "./chunk-PKLB2XJL.js";
7
+ import "./chunk-7UTSNTWM.js";
8
+ import "./chunk-J3Q2NYJR.js";
9
+ import "./chunk-TMNUTMT5.js";
10
+ import "./chunk-X5BJ3G2P.js";
11
+ import "./chunk-NL5LSKVD.js";
12
+ import "./chunk-PIIUNJIT.js";
13
+ import "./chunk-W5E72HJA.js";
14
+ import "./chunk-S26LC76R.js";
15
+ import "./chunk-VCRVNLE7.js";
16
+ import "./chunk-LJDODBBZ.js";
17
+ import "./chunk-CB7PEVOJ.js";
18
+ import "./chunk-NXL4FFQQ.js";
19
+ export {
20
+ computeImpactCascade,
21
+ computeTransitiveImpact
22
+ };
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  getGlobalPiLensDir
4
- } from "./chunk-YVHBNSME.js";
4
+ } from "./chunk-TMNUTMT5.js";
5
5
  import {
6
6
  getTurnId
7
- } from "./chunk-VSFLRN5Y.js";
7
+ } from "./chunk-VCRVNLE7.js";
8
8
  import {
9
9
  BoundedFifoMap
10
- } from "./chunk-PQJFG24Z.js";
10
+ } from "./chunk-CB7PEVOJ.js";
11
11
 
12
12
  // dist/clients/custom-rule-locations.js
13
13
  import * as path from "node:path";
@@ -4,14 +4,14 @@ import {
4
4
  } from "./chunk-3MED75HT.js";
5
5
  import {
6
6
  getProjectDataDir
7
- } from "./chunk-YVHBNSME.js";
7
+ } from "./chunk-TMNUTMT5.js";
8
8
  import {
9
9
  writeFileAtomic
10
- } from "./chunk-U5HPROLA.js";
10
+ } from "./chunk-PIIUNJIT.js";
11
11
  import {
12
12
  normalizeMapKey,
13
13
  toProjectRelativePath
14
- } from "./chunk-PQJFG24Z.js";
14
+ } from "./chunk-CB7PEVOJ.js";
15
15
 
16
16
  // dist/clients/call-graph.js
17
17
  import * as fs from "node:fs";
@@ -1,24 +1,24 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  loadProjectSnapshotWithoutWordIndex
4
- } from "./chunk-RC2Z6K47.js";
4
+ } from "./chunk-PRHYIA6X.js";
5
5
  import {
6
6
  resolvePackagePath
7
- } from "./chunk-TIQJPRDD.js";
7
+ } from "./chunk-QGITU23N.js";
8
8
  import {
9
9
  TERRAGRUNT_FILENAMES
10
- } from "./chunk-RZOXUSPC.js";
10
+ } from "./chunk-CZCAZVTD.js";
11
11
  import {
12
12
  recordDegradationOnce
13
- } from "./chunk-WME2OQST.js";
13
+ } from "./chunk-W5E72HJA.js";
14
14
  import {
15
15
  logLatency
16
- } from "./chunk-Z2XAOKHK.js";
16
+ } from "./chunk-VCRVNLE7.js";
17
17
  import {
18
18
  findNearestContaining,
19
19
  normalizeMapKey,
20
20
  walkUpDirs
21
- } from "./chunk-PQJFG24Z.js";
21
+ } from "./chunk-CB7PEVOJ.js";
22
22
 
23
23
  // dist/clients/tool-policy.js
24
24
  import * as fs from "node:fs";
@@ -1430,18 +1430,10 @@ function* walkUpDirsUntilPackageJson(cwd) {
1430
1430
  }
1431
1431
  }
1432
1432
  function findNearestPackageJsonPath(cwd) {
1433
- let dir = cwd;
1434
- const root = path.parse(dir).root;
1435
- while (true) {
1433
+ for (const dir of walkUpDirs(cwd)) {
1436
1434
  const pkgPath = path.join(dir, "package.json");
1437
1435
  if (fs.existsSync(pkgPath))
1438
1436
  return pkgPath;
1439
- if (dir === root)
1440
- break;
1441
- const parent = path.dirname(dir);
1442
- if (parent === dir)
1443
- break;
1444
- dir = parent;
1445
1437
  }
1446
1438
  return void 0;
1447
1439
  }
@@ -4,17 +4,18 @@ import {
4
4
  readCargoDependencyNames,
5
5
  readCargoPackageName,
6
6
  readCargoWorkspaceMembers
7
- } from "./chunk-ZKXQKGWZ.js";
7
+ } from "./chunk-J3Q2NYJR.js";
8
8
  import {
9
9
  getProjectIgnoreMatcher,
10
10
  isExcludedDirName
11
- } from "./chunk-YVHBNSME.js";
11
+ } from "./chunk-TMNUTMT5.js";
12
12
  import {
13
13
  getWorkspaceManifestMarkers
14
- } from "./chunk-J6JP25XU.js";
14
+ } from "./chunk-NL5LSKVD.js";
15
15
  import {
16
- normalizeMapKey
17
- } from "./chunk-PQJFG24Z.js";
16
+ normalizeMapKey,
17
+ toPosix
18
+ } from "./chunk-CB7PEVOJ.js";
18
19
 
19
20
  // dist/clients/review-graph/workspace-modules.js
20
21
  import * as fs from "node:fs";
@@ -77,7 +78,7 @@ function normalizeWorkspacePatterns(value) {
77
78
  return [];
78
79
  }
79
80
  function expandWorkspacePattern(cwd, pattern) {
80
- const normalized = stripQuotes(pattern.trim()).replace(/\\/g, "/");
81
+ const normalized = toPosix(stripQuotes(pattern.trim()));
81
82
  if (!normalized || normalized.startsWith("!"))
82
83
  return [];
83
84
  const starIndex = normalized.indexOf("*");
@@ -136,7 +137,7 @@ function moduleFromPackageJson(cwd, pkgRoot) {
136
137
  return {
137
138
  name: pkgJson.name,
138
139
  root: normalizeMapKey(pkgRoot),
139
- relativePath: path.relative(cwd, pkgRoot).replace(/\\/g, "/"),
140
+ relativePath: toPosix(path.relative(cwd, pkgRoot)),
140
141
  entrypoints: pkgJson.main ? [pkgJson.main] : ["index.js"],
141
142
  internalDeps: [],
142
143
  externalDeps: depsFromPackageJson(pkgJson)
@@ -183,7 +184,7 @@ function scanCargoModules(cwd) {
183
184
  modules.push({
184
185
  name,
185
186
  root: normalizeMapKey(pkgRoot),
186
- relativePath: path.relative(cwd, pkgRoot).replace(/\\/g, "/"),
187
+ relativePath: toPosix(path.relative(cwd, pkgRoot)),
187
188
  entrypoints: ["src/lib.rs", "src/main.rs"],
188
189
  internalDeps: [],
189
190
  externalDeps: deps
@@ -216,7 +217,7 @@ function scanGoModules(cwd) {
216
217
  modules.push({
217
218
  name,
218
219
  root: normalizeMapKey(pkgRoot),
219
- relativePath: path.relative(cwd, pkgRoot).replace(/\\/g, "/"),
220
+ relativePath: toPosix(path.relative(cwd, pkgRoot)),
220
221
  entrypoints: ["."],
221
222
  internalDeps: [],
222
223
  externalDeps: []
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  resolveOpengrepRulePack
4
- } from "./chunk-O4BJFESU.js";
4
+ } from "./chunk-RTFMDIKV.js";
5
5
  import {
6
6
  findLocalToolConfig
7
- } from "./chunk-PQJFG24Z.js";
7
+ } from "./chunk-CB7PEVOJ.js";
8
8
 
9
9
  // dist/clients/opengrep-config.js
10
10
  import * as path from "node:path";
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  getProjectTrustGeneration
4
- } from "./chunk-U5HPROLA.js";
4
+ } from "./chunk-PIIUNJIT.js";
5
5
  import {
6
6
  logLatency
7
- } from "./chunk-Z2XAOKHK.js";
7
+ } from "./chunk-VCRVNLE7.js";
8
8
 
9
9
  // dist/clients/dispatch/runners/utils/availability-policy.js
10
10
  function describeProbeEvidence(result, command) {
@@ -3,10 +3,10 @@ import {
3
3
  findGoverningTsconfigDir,
4
4
  getDirectoryMarkers,
5
5
  registerWorkspaceTopologyReset
6
- } from "./chunk-J6JP25XU.js";
6
+ } from "./chunk-NL5LSKVD.js";
7
7
  import {
8
8
  BoundedLruCache
9
- } from "./chunk-PQJFG24Z.js";
9
+ } from "./chunk-CB7PEVOJ.js";
10
10
 
11
11
  // dist/clients/review-graph/tsconfig-paths.js
12
12
  import * as fs from "node:fs";
@@ -1,21 +1,19 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  collectSourceFiles
4
- } from "./chunk-EKWX4WD3.js";
5
- import "./chunk-ZGSJDWQU.js";
6
- import "./chunk-YVHBNSME.js";
4
+ } from "./chunk-RNXOWDM6.js";
5
+ import "./chunk-ZCQBNPRH.js";
6
+ import "./chunk-TMNUTMT5.js";
7
7
  import "./chunk-QYF5S6P6.js";
8
- import "./chunk-RZOXUSPC.js";
9
- import "./chunk-KPPJTH44.js";
10
- import "./chunk-J6JP25XU.js";
11
- import "./chunk-U5HPROLA.js";
12
- import "./chunk-WME2OQST.js";
13
- import "./chunk-KXF5R4UN.js";
8
+ import "./chunk-CZCAZVTD.js";
9
+ import "./chunk-X5BJ3G2P.js";
10
+ import "./chunk-NL5LSKVD.js";
11
+ import "./chunk-PIIUNJIT.js";
12
+ import "./chunk-W5E72HJA.js";
14
13
  import "./chunk-S26LC76R.js";
15
- import "./chunk-Z2XAOKHK.js";
16
- import "./chunk-VSFLRN5Y.js";
14
+ import "./chunk-VCRVNLE7.js";
17
15
  import "./chunk-LJDODBBZ.js";
18
- import "./chunk-PQJFG24Z.js";
16
+ import "./chunk-CB7PEVOJ.js";
19
17
  import "./chunk-NXL4FFQQ.js";
20
18
 
21
19
  // dist/clients/todo-scanner.js