pi-lens 4.4.8 → 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 (163) hide show
  1. package/CHANGELOG-USER.md +31 -0
  2. package/CHANGELOG.md +178 -0
  3. package/README.md +2 -1
  4. package/config/dependency-cruiser-eager-allowlist.json +1 -1
  5. package/dist/{chunk-3O5EII3W.js → chunk-2VZ3VN3N.js} +2 -2
  6. package/dist/{chunk-SDFKOLSF.js → chunk-3HTZDY3C.js} +8 -6
  7. package/dist/{chunk-A5GRLYPZ.js → chunk-3NPWO5UO.js} +7 -13
  8. package/dist/{chunk-AGGUWKRK.js → chunk-47UCC4MM.js} +1 -1
  9. package/dist/chunk-4ENEJHF4.js +198 -0
  10. package/dist/{chunk-WXUDRAG6.js → chunk-5GEYJJHG.js} +10 -12
  11. package/dist/{chunk-HHR7WGCI.js → chunk-5YSEQHJN.js} +3 -3
  12. package/dist/{chunk-L3CLUGDY.js → chunk-6GPB3JLL.js} +3 -3
  13. package/dist/{chunk-5F3XF3SX.js → chunk-7R5GZIA6.js} +6 -6
  14. package/dist/{chunk-CUDD35TW.js → chunk-7UTSNTWM.js} +4 -4
  15. package/dist/{chunk-DYRZGUMA.js → chunk-7YTRG6YW.js} +2 -2
  16. package/dist/{chunk-JZRP4DGP.js → chunk-AACN5GNE.js} +2 -2
  17. package/dist/{chunk-7ANZ7XDD.js → chunk-ACRJ2GZ5.js} +2 -2
  18. package/dist/{chunk-6FIRFP6A.js → chunk-C3YRO3EU.js} +10 -12
  19. package/dist/{chunk-GMROJJRN.js → chunk-CB7PEVOJ.js} +9 -1
  20. package/dist/{chunk-BBET6HD6.js → chunk-CDFJF5YD.js} +1 -1
  21. package/dist/{chunk-NSPVR3FN.js → chunk-CJS6WE66.js} +17 -19
  22. package/dist/{chunk-6YUNI7B5.js → chunk-CM6BDY4E.js} +14 -60
  23. package/dist/{chunk-G5GV2Q7K.js → chunk-CZCAZVTD.js} +16 -2
  24. package/dist/chunk-DGKFWQK4.js +23 -0
  25. package/dist/{chunk-VOP4PJKA.js → chunk-E65WJVI5.js} +7 -9
  26. package/dist/{chunk-TV6RXRYH.js → chunk-EKNYSXFB.js} +8 -10
  27. package/dist/{chunk-4LL2VRNY.js → chunk-EY6LY2HO.js} +16 -18
  28. package/dist/{chunk-MC6VB2E5.js → chunk-F6BEQWAK.js} +17 -5
  29. package/dist/{chunk-R2QQC33W.js → chunk-FGNSESAC.js} +12 -14
  30. package/dist/{chunk-OC7VWJBZ.js → chunk-FRUBVFXV.js} +35 -37
  31. package/dist/{chunk-7CGIDRIK.js → chunk-G22UNQID.js} +14 -16
  32. package/dist/{chunk-L4NEVZ4T.js → chunk-GQTQUNCG.js} +25 -27
  33. package/dist/{chunk-ZKLTNLAW.js → chunk-H3BVMK47.js} +6 -6
  34. package/dist/chunk-H6FLQ5NW.js +28 -0
  35. package/dist/{chunk-2ZE3AUJQ.js → chunk-HEA3EM23.js} +13 -15
  36. package/dist/{chunk-CZL44WFN.js → chunk-HSOBIN22.js} +2 -2
  37. package/dist/{chunk-PKSUMEPT.js → chunk-HYSKJMZK.js} +3 -3
  38. package/dist/{chunk-VN3L2JWZ.js → chunk-IICERRFF.js} +5 -5
  39. package/dist/{chunk-O4N5BQ3T.js → chunk-IILEH3ZC.js} +8 -10
  40. package/dist/{chunk-WC6WRNQT.js → chunk-J3Q2NYJR.js} +2 -2
  41. package/dist/{chunk-SFLHSL5R.js → chunk-JUZ67QZQ.js} +18 -7
  42. package/dist/chunk-KR5VGMVT.js +25 -0
  43. package/dist/{chunk-UHHLR2VY.js → chunk-KV6GQOGN.js} +38 -41
  44. package/dist/{chunk-HUAM7QG3.js → chunk-KXMJLOZF.js} +25 -23
  45. package/dist/{chunk-BUZIQDFS.js → chunk-L4Y3ROKQ.js} +3 -3
  46. package/dist/{chunk-JBP7KESM.js → chunk-L6WBJGQS.js} +1 -1
  47. package/dist/{chunk-35WKJWO5.js → chunk-L7O774U7.js} +14 -14
  48. package/dist/{chunk-BOPDQ7AZ.js → chunk-LAHHGNAY.js} +19 -21
  49. package/dist/{chunk-RGGH6M34.js → chunk-LT62P654.js} +1 -1
  50. package/dist/{chunk-5T5A6YAJ.js → chunk-LWOM6LVS.js} +33 -34
  51. package/dist/{chunk-JYLOYTZD.js → chunk-MKPDIAZH.js} +5 -1
  52. package/dist/{chunk-CM73PPGD.js → chunk-MN635QYA.js} +3 -4
  53. package/dist/{chunk-BQG2QFVO.js → chunk-MQ4PPCJB.js} +21 -29
  54. package/dist/{chunk-HXFUTMX2.js → chunk-MRLH4MYU.js} +2 -2
  55. package/dist/{chunk-XOMGO63G.js → chunk-N56BNAA6.js} +19 -21
  56. package/dist/{chunk-7MAD5ZAY.js → chunk-N5CEGQPG.js} +14 -16
  57. package/dist/{chunk-ZFORSIED.js → chunk-NCLO6E6N.js} +13 -33
  58. package/dist/{chunk-SQC7K3SP.js → chunk-NL5LSKVD.js} +2 -2
  59. package/dist/{chunk-I22THIHI.js → chunk-NMUSOZ2D.js} +10 -12
  60. package/dist/{chunk-4NBWFYWW.js → chunk-NOWH2VA2.js} +8 -33
  61. package/dist/{chunk-NM2NWH55.js → chunk-NUSXS6YB.js} +6 -5
  62. package/dist/{chunk-OZWXLJMX.js → chunk-OSEKJEUU.js} +2 -2
  63. package/dist/{chunk-2BKUFQKR.js → chunk-OUYAUXAT.js} +405 -181
  64. package/dist/{chunk-JPRDTY5S.js → chunk-PBZNYHMM.js} +8 -10
  65. package/dist/{chunk-JE6HKLC7.js → chunk-PIIUNJIT.js} +2 -4
  66. package/dist/{chunk-ZZDIOAAJ.js → chunk-PRHYIA6X.js} +6 -6
  67. package/dist/{chunk-4W52ZKZX.js → chunk-PXQ45SGD.js} +2 -2
  68. package/dist/chunk-Q6JQKWPK.js +25 -0
  69. package/dist/{chunk-PIQQM32Y.js → chunk-QB7T2PHK.js} +2 -2
  70. package/dist/{chunk-HKIL6DCL.js → chunk-QGITU23N.js} +1 -1
  71. package/dist/chunk-QJJKOHLH.js +57 -0
  72. package/dist/{chunk-6LJOJ6EO.js → chunk-QP33NKYC.js} +14 -16
  73. package/dist/{chunk-DIWK3LBC.js → chunk-QVBOXT3L.js} +8 -10
  74. package/dist/{chunk-IYVYZQRL.js → chunk-RNJFRXEN.js} +5 -7
  75. package/dist/{chunk-G6JKM4O7.js → chunk-RNXOWDM6.js} +10 -10
  76. package/dist/{chunk-5RNB4HVK.js → chunk-RTFMDIKV.js} +1 -1
  77. package/dist/{chunk-XWIME22V.js → chunk-SIQHOB6P.js} +11 -13
  78. package/dist/{chunk-T2S3FNNJ.js → chunk-SLSMJPEF.js} +41 -42
  79. package/dist/chunk-T5QSLSMM.js +50 -0
  80. package/dist/chunk-TGQDAG4B.js +88 -0
  81. package/dist/{chunk-6GMGEKQN.js → chunk-THYHUIDR.js} +39 -12
  82. package/dist/{chunk-WMDUT4KH.js → chunk-TMNUTMT5.js} +72 -89
  83. package/dist/{chunk-7TNILKGY.js → chunk-TOE2RRCS.js} +1 -1
  84. package/dist/chunk-TYHPVE5H.js +25 -0
  85. package/dist/chunk-UAKO2M6B.js +73 -0
  86. package/dist/chunk-UC5AXW5Z.js +20 -0
  87. package/dist/chunk-UTJP6WOS.js +28 -0
  88. package/dist/{chunk-FRLAUP2B.js → chunk-UXTQ3QPD.js} +4 -4
  89. package/dist/{chunk-4QG55RRC.js → chunk-V2WDBOLZ.js} +10 -12
  90. package/dist/{chunk-FHEV6T4L.js → chunk-V67D6TMU.js} +8 -10
  91. package/dist/{chunk-VLQ7UKZH.js → chunk-VCRVNLE7.js} +135 -2
  92. package/dist/{chunk-KZ4ALBCH.js → chunk-VO4JFPTV.js} +2 -2
  93. package/dist/{chunk-GIRBSBGL.js → chunk-VWLSU3XV.js} +3 -3
  94. package/dist/{chunk-2453RRJ2.js → chunk-W5E72HJA.js} +59 -22
  95. package/dist/{chunk-VPLBLWFO.js → chunk-W7TY6HYX.js} +1 -1
  96. package/dist/{chunk-SP4TFY5F.js → chunk-WSSLVMDA.js} +11 -13
  97. package/dist/{chunk-PPKECBPP.js → chunk-WTB4GKMH.js} +10 -1
  98. package/dist/{chunk-X35S7HSB.js → chunk-X5BJ3G2P.js} +41 -30
  99. package/dist/{chunk-X66YJ2SS.js → chunk-XKFO2SZV.js} +33 -34
  100. package/dist/{chunk-OWTG6UMO.js → chunk-XLAI7UYY.js} +75 -22
  101. package/dist/{chunk-4B2YFN4U.js → chunk-XO756WE5.js} +45 -33
  102. package/dist/{chunk-VOXTCULR.js → chunk-XVB3Q2PG.js} +2 -4
  103. package/dist/{chunk-XYLC35E4.js → chunk-YOXCCJDF.js} +517 -308
  104. package/dist/{chunk-O2ARHQKF.js → chunk-ZCQBNPRH.js} +2 -2
  105. package/dist/chunk-ZD4KVFXI.js +234 -0
  106. package/dist/{chunk-LSFXZLPW.js → chunk-ZDMFGACN.js} +184 -235
  107. package/dist/{chunk-4BKU7PV3.js → chunk-ZMMHHXSW.js} +1 -1
  108. package/dist/{chunk-OY7WZI7Q.js → chunk-ZPM7ZIFL.js} +6 -6
  109. package/dist/{chunk-R4QWJQ2H.js → chunk-ZVCDHYWZ.js} +9 -11
  110. package/dist/{chunk-RZG472YW.js → chunk-ZZN74OGD.js} +83 -46
  111. package/dist/{chunk-BHWW6FAX.js → chunk-ZZSJAR76.js} +37 -19
  112. package/dist/index.js +4910 -4218
  113. package/dist/mcp/analyze-cli.js +12 -17
  114. package/dist/mcp/cli.js +41 -42
  115. package/dist/mcp/server.js +1451 -648
  116. package/dist/mcp/worker.js +59 -60
  117. package/dist/probes/installer.js +17 -19
  118. package/docs/agent-tools.md +40 -8
  119. package/docs/analysisall.md +1 -1
  120. package/docs/ci-bot-pr-checks.md +7 -5
  121. package/docs/configuration.md +51 -9
  122. package/docs/defect-shapes.md +52 -3
  123. package/docs/environment-variables.md +18 -1
  124. package/docs/features.md +12 -5
  125. package/docs/globalconfig.md +11 -3
  126. package/docs/invariants/lsp-trust-exec.md +9 -2
  127. package/docs/invariants/session-telemetry.md +2 -2
  128. package/docs/language-coverage.md +1 -0
  129. package/docs/lsp-capability-matrix.md +57 -35
  130. package/docs/lsp-idle-eviction.md +4 -1
  131. package/docs/merge-queue-rollout.md +10 -8
  132. package/docs/module-report-read-symbol.md +34 -23
  133. package/docs/pi-lens-fixer.md +11 -1
  134. package/docs/pi-lens-investigator.md +3 -0
  135. package/docs/pi-lens-merge-policy.md +15 -7
  136. package/docs/pi-lens-reviewer.md +1 -1
  137. package/docs/pi-lens-subagent.md +13 -0
  138. package/docs/public-api-stability.md +39 -5
  139. package/docs/release-qa-baseline.md +7 -4
  140. package/docs/schema/pi-lens-config-v1.json +11 -2
  141. package/docs/servercapabilities.md +3 -1
  142. package/docs/settings.md +2 -2
  143. package/docs/word-index.md +3 -2
  144. package/package.json +8 -3
  145. package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +1 -2
  146. package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +1 -2
  147. package/scripts/download-grammars.js +3 -2
  148. package/skills/pi-lens-lsp-navigation/SKILL.md +5 -1
  149. package/dist/chunk-2TS4GLOJ.js +0 -31
  150. package/dist/chunk-3JAHQBSY.js +0 -27
  151. package/dist/chunk-447YZL4S.js +0 -25
  152. package/dist/chunk-565VRUP4.js +0 -136
  153. package/dist/chunk-57X2CDRX.js +0 -49
  154. package/dist/chunk-GGYOZWHW.js +0 -27
  155. package/dist/chunk-IE5D3RA5.js +0 -58
  156. package/dist/chunk-LPYTPNOJ.js +0 -22
  157. package/dist/chunk-OFNMHPBT.js +0 -89
  158. package/dist/chunk-U3AS2FR6.js +0 -106
  159. package/dist/chunk-W3BGKBBK.js +0 -27
  160. package/dist/chunk-WQV6BI4Q.js +0 -48
  161. package/dist/chunk-YHGYAEFH.js +0 -443
  162. package/dist/chunk-ZONZ6YY3.js +0 -74
  163. package/dist/chunk-ZSM35JF4.js +0 -30
@@ -1,443 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- calcCyclomaticComplexity
4
- } from "./chunk-6YUNI7B5.js";
5
- import "./chunk-7TNILKGY.js";
6
- import "./chunk-5W3R6LFT.js";
7
- import {
8
- firstChildOfType,
9
- isComplexityLanguageId,
10
- isComplexitySupportedFile,
11
- resolveTreeSitterLanguage,
12
- walk,
13
- withTreeSitterRoot
14
- } from "./chunk-BHWW6FAX.js";
15
- import "./chunk-Z54ZSOBZ.js";
16
- import "./chunk-HHR7WGCI.js";
17
- import "./chunk-HKIL6DCL.js";
18
- import "./chunk-PPKECBPP.js";
19
- import "./chunk-JYLOYTZD.js";
20
- import "./chunk-JZRP4DGP.js";
21
- import "./chunk-WMDUT4KH.js";
22
- import "./chunk-G5GV2Q7K.js";
23
- import "./chunk-X35S7HSB.js";
24
- import "./chunk-SQC7K3SP.js";
25
- import "./chunk-JE6HKLC7.js";
26
- import "./chunk-2453RRJ2.js";
27
- import {
28
- createSubsystemLogger
29
- } from "./chunk-WQV6BI4Q.js";
30
- import "./chunk-S26LC76R.js";
31
- import "./chunk-565VRUP4.js";
32
- import "./chunk-VLQ7UKZH.js";
33
- import "./chunk-LJDODBBZ.js";
34
- import "./chunk-GMROJJRN.js";
35
- import "./chunk-NXL4FFQQ.js";
36
-
37
- // dist/clients/complexity-client.js
38
- import * as fs from "node:fs";
39
- import * as path from "node:path";
40
- var JSTS = {
41
- functionLike: /* @__PURE__ */ new Set([
42
- "function_declaration",
43
- "method_definition",
44
- "function_expression",
45
- "arrow_function",
46
- "generator_function",
47
- "generator_function_declaration"
48
- ]),
49
- nesting: /* @__PURE__ */ new Set([
50
- "if_statement",
51
- "while_statement",
52
- "for_statement",
53
- "for_in_statement",
54
- "switch_statement",
55
- "function_declaration",
56
- "function_expression",
57
- "arrow_function",
58
- "method_definition",
59
- "class_declaration",
60
- "try_statement",
61
- "catch_clause"
62
- ]),
63
- decision: /* @__PURE__ */ new Set([
64
- "if_statement",
65
- "while_statement",
66
- "for_statement",
67
- "for_in_statement",
68
- "switch_case",
69
- "ternary_expression"
70
- ]),
71
- cognitive: /* @__PURE__ */ new Set([
72
- "if_statement",
73
- "while_statement",
74
- "for_statement",
75
- "for_in_statement",
76
- "switch_statement",
77
- "switch_case",
78
- "ternary_expression",
79
- "catch_clause"
80
- ]),
81
- logicalOpNodes: /* @__PURE__ */ new Set(),
82
- logicalBinaryOps: /* @__PURE__ */ new Set(["&&", "||", "??"]),
83
- tryNode: "try_statement",
84
- nameChildTypes: ["identifier", "property_identifier"]
85
- };
86
- var PYTHON = {
87
- functionLike: /* @__PURE__ */ new Set(["function_definition", "lambda"]),
88
- nesting: /* @__PURE__ */ new Set([
89
- "if_statement",
90
- "for_statement",
91
- "while_statement",
92
- "match_statement",
93
- "function_definition",
94
- "class_definition",
95
- "try_statement",
96
- "except_clause",
97
- "elif_clause"
98
- ]),
99
- decision: /* @__PURE__ */ new Set([
100
- "if_statement",
101
- "elif_clause",
102
- "for_statement",
103
- "while_statement",
104
- "case_clause",
105
- "conditional_expression"
106
- ]),
107
- cognitive: /* @__PURE__ */ new Set([
108
- "if_statement",
109
- "elif_clause",
110
- "for_statement",
111
- "while_statement",
112
- "match_statement",
113
- "case_clause",
114
- "conditional_expression",
115
- "except_clause"
116
- ]),
117
- logicalOpNodes: /* @__PURE__ */ new Set(["boolean_operator"]),
118
- logicalBinaryOps: /* @__PURE__ */ new Set(),
119
- tryNode: "try_statement",
120
- nameChildTypes: ["identifier"]
121
- };
122
- var GO = {
123
- functionLike: /* @__PURE__ */ new Set([
124
- "function_declaration",
125
- "method_declaration",
126
- "func_literal"
127
- ]),
128
- nesting: /* @__PURE__ */ new Set([
129
- "if_statement",
130
- "for_statement",
131
- "expression_switch_statement",
132
- "type_switch_statement",
133
- "select_statement",
134
- "function_declaration",
135
- "method_declaration"
136
- ]),
137
- decision: /* @__PURE__ */ new Set([
138
- "if_statement",
139
- "for_statement",
140
- "expression_case",
141
- "type_case",
142
- "communication_case"
143
- ]),
144
- cognitive: /* @__PURE__ */ new Set([
145
- "if_statement",
146
- "for_statement",
147
- "expression_switch_statement",
148
- "type_switch_statement",
149
- "select_statement",
150
- "expression_case",
151
- "type_case",
152
- "communication_case"
153
- ]),
154
- logicalOpNodes: /* @__PURE__ */ new Set(),
155
- logicalBinaryOps: /* @__PURE__ */ new Set(["&&", "||"]),
156
- tryNode: void 0,
157
- // Go has no try/catch (error returns)
158
- nameChildTypes: ["identifier", "field_identifier"]
159
- };
160
- var RUST = {
161
- functionLike: /* @__PURE__ */ new Set(["function_item", "closure_expression"]),
162
- nesting: /* @__PURE__ */ new Set([
163
- "if_expression",
164
- "while_expression",
165
- "for_expression",
166
- "loop_expression",
167
- "match_expression",
168
- "function_item"
169
- ]),
170
- decision: /* @__PURE__ */ new Set([
171
- "if_expression",
172
- "while_expression",
173
- "for_expression",
174
- "loop_expression",
175
- "match_arm"
176
- ]),
177
- cognitive: /* @__PURE__ */ new Set([
178
- "if_expression",
179
- "while_expression",
180
- "for_expression",
181
- "loop_expression",
182
- "match_expression",
183
- "match_arm"
184
- ]),
185
- logicalOpNodes: /* @__PURE__ */ new Set(),
186
- logicalBinaryOps: /* @__PURE__ */ new Set(["&&", "||"]),
187
- tryNode: void 0,
188
- // Rust uses Result/? — no try/catch
189
- nameChildTypes: ["identifier"]
190
- };
191
- var LANGUAGE_NODES = {
192
- typescript: JSTS,
193
- tsx: JSTS,
194
- javascript: JSTS,
195
- python: PYTHON,
196
- go: GO,
197
- rust: RUST
198
- };
199
- var COMMENT_TYPES = /* @__PURE__ */ new Set(["comment", "line_comment", "block_comment"]);
200
- function isLogicalOp(node, nodes) {
201
- if (nodes.logicalOpNodes.has(node.type))
202
- return true;
203
- if (nodes.logicalBinaryOps.size > 0 && node.type === "binary_expression") {
204
- return (node.children ?? []).some((c) => c && nodes.logicalBinaryOps.has(c.type));
205
- }
206
- return false;
207
- }
208
- function subtreeCyclomatic(root, nodes) {
209
- if (nodes === JSTS)
210
- return calcCyclomaticComplexity(root) - 1;
211
- let cc = 0;
212
- walk(root, (n) => {
213
- if (nodes.decision.has(n.type))
214
- cc++;
215
- if (isLogicalOp(n, nodes))
216
- cc++;
217
- });
218
- return cc;
219
- }
220
- function subtreeCognitive(node, nesting, nodes) {
221
- let complexity = 0;
222
- if (nodes.cognitive.has(node.type))
223
- complexity += 1 + nesting;
224
- if ((node.type === "break_statement" || node.type === "continue_statement") && (node.children ?? []).some((c) => c && (c.type === "statement_identifier" || c.type === "identifier" || c.type === "label_name" || c.type === "label"))) {
225
- complexity += 1 + nesting;
226
- }
227
- if (isLogicalOp(node, nodes))
228
- complexity += 1;
229
- const childNesting = nodes.nesting.has(node.type) ? nesting + 1 : nesting;
230
- for (const child of node.children ?? []) {
231
- if (child)
232
- complexity += subtreeCognitive(child, childNesting, nodes);
233
- }
234
- return complexity;
235
- }
236
- function subtreeMaxNesting(node, currentDepth, nodes) {
237
- let maxDepth = currentDepth;
238
- if (nodes.nesting.has(node.type)) {
239
- currentDepth++;
240
- maxDepth = Math.max(maxDepth, currentDepth);
241
- }
242
- for (const child of node.children ?? []) {
243
- if (child) {
244
- maxDepth = Math.max(maxDepth, subtreeMaxNesting(child, currentDepth, nodes));
245
- }
246
- }
247
- return maxDepth;
248
- }
249
- function functionName(fnNode, nodes) {
250
- for (const t of nodes.nameChildTypes) {
251
- const id = firstChildOfType(fnNode, t);
252
- if (id)
253
- return id.text;
254
- }
255
- return void 0;
256
- }
257
- function collectFunctionMetrics(root, nodes) {
258
- const functions = [];
259
- const visit = (node, nestingLevel) => {
260
- if (nodes.functionLike.has(node.type)) {
261
- const startLine = node.startPosition.row;
262
- const endLine = node.endPosition.row;
263
- functions.push({
264
- name: functionName(node, nodes) ?? `<anonymous@L${startLine + 1}>`,
265
- line: startLine + 1,
266
- length: endLine - startLine + 1,
267
- cyclomatic: subtreeCyclomatic(node, nodes),
268
- cognitive: subtreeCognitive(node, nestingLevel, nodes),
269
- nestingDepth: subtreeMaxNesting(node, 0, nodes)
270
- });
271
- }
272
- const newNesting = nodes.nesting.has(node.type) ? nestingLevel + 1 : nestingLevel;
273
- for (const child of node.children ?? []) {
274
- if (child)
275
- visit(child, newNesting);
276
- }
277
- };
278
- visit(root, 0);
279
- return functions;
280
- }
281
- function countTryCatch(root, nodes) {
282
- if (!nodes.tryNode)
283
- return 0;
284
- let count = 0;
285
- walk(root, (n) => {
286
- if (n.type === nodes.tryNode)
287
- count++;
288
- });
289
- return count;
290
- }
291
- function countLines(content, root) {
292
- const lines = content.split(/\r?\n/);
293
- const commentLineSet = /* @__PURE__ */ new Set();
294
- walk(root, (n) => {
295
- if (COMMENT_TYPES.has(n.type)) {
296
- for (let l = n.startPosition.row; l <= n.endPosition.row; l++) {
297
- commentLineSet.add(l);
298
- }
299
- }
300
- });
301
- const codeLines = lines.filter((line, i) => {
302
- if (line.trim().length === 0)
303
- return false;
304
- if (!commentLineSet.has(i))
305
- return true;
306
- const stripped = line.replace(/\/\/.*$/, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/#.*$/, "").trim();
307
- return stripped.length > 0;
308
- }).length;
309
- return { codeLines, commentLines: commentLineSet.size };
310
- }
311
- var AI_COMMENT_PATTERNS = [
312
- /(?:🔍|✅|📝|🔧|🐛|⚠️|🚀|💡|🎯|📌|🏷️|🔑|🏗️|🧪|🗑️|🔄|♻️|📋|🔖|📊|💬|🔥|💎|⭐|🌟|🎨|🛠️)/u,
313
- /(?:\/\/|#)\s*(Initialize|Setup|Clean up|Create|Define|Check if|Handle|Process|Validate|Return|Get|Set|Add|Remove|Update|Fetch)\b/i,
314
- /(?:\/\/|#)\s*(This function|This method|This code|Here we|Now we)\b/i,
315
- /\/\*\*?\s*(Overview|Summary|Description|Example|Usage)\s*\*?\//i
316
- ];
317
- function countAICommentPatterns(sourceText) {
318
- let count = 0;
319
- for (const line of sourceText.split(/\r?\n/)) {
320
- const trimmed = line.trim();
321
- if (trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*") || trimmed.startsWith("#")) {
322
- for (const pattern of AI_COMMENT_PATTERNS) {
323
- if (pattern.test(line)) {
324
- count++;
325
- break;
326
- }
327
- }
328
- }
329
- }
330
- return count;
331
- }
332
- function calculateCodeEntropy(sourceText) {
333
- 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);
334
- if (tokens.length === 0)
335
- return 0;
336
- const freq = /* @__PURE__ */ new Map();
337
- for (const token of tokens)
338
- freq.set(token, (freq.get(token) || 0) + 1);
339
- let entropy = 0;
340
- for (const count of freq.values()) {
341
- const p = count / tokens.length;
342
- if (p > 0)
343
- entropy -= p * Math.log2(p);
344
- }
345
- return entropy;
346
- }
347
- function calculateMaintainabilityIndex(cyclomatic, loc, comments) {
348
- if (loc === 0)
349
- return 100;
350
- const lnLOC = Math.log(loc);
351
- let mi = (171 - 0.23 * cyclomatic - 16.2 * lnLOC) * 100 / 171;
352
- const commentBonus = Math.min(10, comments / loc * 50);
353
- mi += commentBonus;
354
- return Math.max(0, Math.min(100, mi));
355
- }
356
- function calculateMaxParams(functions) {
357
- return Math.min(10, Math.max(2, Math.round(functions.reduce((a, f) => a + f.length, 0) / Math.max(1, functions.length) / 5)));
358
- }
359
- function countSingleUseFunctions(functions) {
360
- 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;
361
- }
362
- var ComplexityClient = class {
363
- log;
364
- constructor(verbose = false) {
365
- this.log = verbose ? createSubsystemLogger("complexity") : () => {
366
- };
367
- }
368
- /** True if the file's grammar has a complexity node mapping.
369
- *
370
- * Delegates to the module-free predicate in `tree-sitter-shared.ts`: the
371
- * same question is asked by `handleToolCallImpl` BEFORE the analyzer
372
- * bootstrap is loaded (#2467), and two copies of it would be two answers. */
373
- isSupportedFile(filePath) {
374
- return isComplexitySupportedFile(filePath);
375
- }
376
- /** Analyze complexity metrics for a file (null if unsupported / unparseable). */
377
- async analyzeFile(filePath) {
378
- const absolutePath = path.resolve(filePath);
379
- const languageId = resolveTreeSitterLanguage(absolutePath);
380
- const nodes = languageId && isComplexityLanguageId(languageId) ? LANGUAGE_NODES[languageId] : void 0;
381
- if (!nodes)
382
- return null;
383
- let content;
384
- try {
385
- if (!fs.existsSync(absolutePath))
386
- return null;
387
- content = fs.readFileSync(absolutePath, "utf-8");
388
- } catch (err) {
389
- this.log(`Read error for ${filePath}: ${err.message}`);
390
- return null;
391
- }
392
- try {
393
- const parsed = await withTreeSitterRoot(absolutePath, content, (root) => this.computeMetrics(absolutePath, content, root, nodes), "complexity");
394
- return parsed.parsed ? parsed.value : null;
395
- } catch (err) {
396
- this.log(`Analysis error for ${filePath}: ${err.message}`);
397
- return null;
398
- }
399
- }
400
- computeMetrics(absolutePath, content, root, nodes) {
401
- const { codeLines, commentLines } = countLines(content, root);
402
- const functions = collectFunctionMetrics(root, nodes);
403
- const maxNestingDepth = subtreeMaxNesting(root, 0, nodes);
404
- const cognitive = subtreeCognitive(root, 0, nodes);
405
- const funcStats = this.aggregateFunctionStats(functions);
406
- return {
407
- filePath: path.relative(process.cwd(), absolutePath),
408
- maxNestingDepth,
409
- avgFunctionLength: funcStats.avgLength,
410
- maxFunctionLength: funcStats.maxLength,
411
- functionCount: functions.length,
412
- cyclomaticComplexity: funcStats.avgCyclomatic,
413
- maxCyclomaticComplexity: funcStats.maxCyclomatic,
414
- cognitiveComplexity: cognitive,
415
- maintainabilityIndex: Math.round(calculateMaintainabilityIndex(funcStats.avgCyclomatic, codeLines, commentLines) * 10) / 10,
416
- linesOfCode: codeLines,
417
- commentLines,
418
- codeEntropy: Math.round(calculateCodeEntropy(content) * 100) / 100,
419
- maxParamsInFunction: calculateMaxParams(functions),
420
- aiCommentPatterns: countAICommentPatterns(content),
421
- singleUseFunctions: countSingleUseFunctions(functions),
422
- tryCatchCount: countTryCatch(root, nodes),
423
- functions
424
- };
425
- }
426
- aggregateFunctionStats(functions) {
427
- if (functions.length === 0) {
428
- return { avgLength: 0, maxLength: 0, avgCyclomatic: 1, maxCyclomatic: 1 };
429
- }
430
- const lengths = functions.map((f) => f.length);
431
- const cyclomatics = functions.map((f) => f.cyclomatic);
432
- const sum = (arr) => arr.reduce((a, b) => a + b, 0);
433
- return {
434
- avgLength: Math.round(sum(lengths) / lengths.length),
435
- maxLength: Math.max(...lengths),
436
- avgCyclomatic: Math.max(1, Math.round(sum(cyclomatics) / cyclomatics.length)),
437
- maxCyclomatic: Math.max(1, Math.max(...cyclomatics))
438
- };
439
- }
440
- };
441
- export {
442
- ComplexityClient
443
- };
@@ -1,74 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- adaptLspService,
4
- getLSPService,
5
- groupFilesByPrimaryServer,
6
- hasAuxiliaryLspPublishedForRoot,
7
- notifyExternalFileChange,
8
- peekLSPService,
9
- resetLSPService,
10
- resyncGitChangedFiles,
11
- runPerServerGroups
12
- } from "./chunk-2BKUFQKR.js";
13
- import "./chunk-GIRBSBGL.js";
14
- import "./chunk-XIMYZ3JA.js";
15
- import "./chunk-XYLC35E4.js";
16
- import "./chunk-DYRZGUMA.js";
17
- import "./chunk-FHEV6T4L.js";
18
- import "./chunk-ZZDIOAAJ.js";
19
- import "./chunk-VOXTCULR.js";
20
- import "./chunk-35WKJWO5.js";
21
- import "./chunk-CUDD35TW.js";
22
- import "./chunk-7ANZ7XDD.js";
23
- import "./chunk-WC6WRNQT.js";
24
- import "./chunk-BHWW6FAX.js";
25
- import "./chunk-Z54ZSOBZ.js";
26
- import "./chunk-HHR7WGCI.js";
27
- import "./chunk-HKIL6DCL.js";
28
- import "./chunk-PPKECBPP.js";
29
- import "./chunk-6HWVI6MI.js";
30
- import "./chunk-5RNB4HVK.js";
31
- import "./chunk-CKEQFGLT.js";
32
- import "./chunk-JYLOYTZD.js";
33
- import "./chunk-HUAM7QG3.js";
34
- import "./chunk-HXFUTMX2.js";
35
- import "./chunk-CZL44WFN.js";
36
- import "./chunk-VPLBLWFO.js";
37
- import "./chunk-2BEMIWEW.js";
38
- import "./chunk-IJYGIDF4.js";
39
- import "./chunk-BQG2QFVO.js";
40
- import "./chunk-IYVYZQRL.js";
41
- import "./chunk-VOP4PJKA.js";
42
- import "./chunk-JBP7KESM.js";
43
- import "./chunk-UYXV5NIS.js";
44
- import "./chunk-JZRP4DGP.js";
45
- import "./chunk-SDFKOLSF.js";
46
- import "./chunk-BBET6HD6.js";
47
- import "./chunk-G6JKM4O7.js";
48
- import "./chunk-O2ARHQKF.js";
49
- import "./chunk-WMDUT4KH.js";
50
- import "./chunk-AWQWXSW4.js";
51
- import "./chunk-QYF5S6P6.js";
52
- import "./chunk-G5GV2Q7K.js";
53
- import "./chunk-X35S7HSB.js";
54
- import "./chunk-SQC7K3SP.js";
55
- import "./chunk-JE6HKLC7.js";
56
- import "./chunk-2453RRJ2.js";
57
- import "./chunk-WQV6BI4Q.js";
58
- import "./chunk-S26LC76R.js";
59
- import "./chunk-565VRUP4.js";
60
- import "./chunk-VLQ7UKZH.js";
61
- import "./chunk-LJDODBBZ.js";
62
- import "./chunk-GMROJJRN.js";
63
- import "./chunk-NXL4FFQQ.js";
64
- export {
65
- adaptLspService,
66
- getLSPService,
67
- groupFilesByPrimaryServer,
68
- hasAuxiliaryLspPublishedForRoot,
69
- notifyExternalFileChange,
70
- peekLSPService,
71
- resetLSPService,
72
- resyncGitChangedFiles,
73
- runPerServerGroups
74
- };
@@ -1,30 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- importFactProvider,
4
- importFactsApplyTo
5
- } from "./chunk-FRLAUP2B.js";
6
- import "./chunk-7TNILKGY.js";
7
- import "./chunk-BHWW6FAX.js";
8
- import "./chunk-Z54ZSOBZ.js";
9
- import "./chunk-HHR7WGCI.js";
10
- import "./chunk-HKIL6DCL.js";
11
- import "./chunk-PPKECBPP.js";
12
- import "./chunk-JYLOYTZD.js";
13
- import "./chunk-JZRP4DGP.js";
14
- import "./chunk-WMDUT4KH.js";
15
- import "./chunk-G5GV2Q7K.js";
16
- import "./chunk-X35S7HSB.js";
17
- import "./chunk-SQC7K3SP.js";
18
- import "./chunk-JE6HKLC7.js";
19
- import "./chunk-2453RRJ2.js";
20
- import "./chunk-WQV6BI4Q.js";
21
- import "./chunk-S26LC76R.js";
22
- import "./chunk-565VRUP4.js";
23
- import "./chunk-VLQ7UKZH.js";
24
- import "./chunk-LJDODBBZ.js";
25
- import "./chunk-GMROJJRN.js";
26
- import "./chunk-NXL4FFQQ.js";
27
- export {
28
- importFactProvider,
29
- importFactsApplyTo
30
- };