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
@@ -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-3YY7IXIL.js";
5
- import "./chunk-WDBICWH3.js";
6
- import "./chunk-5W3R6LFT.js";
7
- import {
8
- firstChildOfType,
9
- isComplexityLanguageId,
10
- isComplexitySupportedFile,
11
- resolveTreeSitterLanguage,
12
- walk,
13
- withTreeSitterRoot
14
- } from "./chunk-L5JYIU47.js";
15
- import "./chunk-Z54ZSOBZ.js";
16
- import "./chunk-U6VN4NVL.js";
17
- import "./chunk-TIQJPRDD.js";
18
- import "./chunk-YISME6ON.js";
19
- import "./chunk-HO6LWE2E.js";
20
- import "./chunk-KW5JQPO5.js";
21
- import "./chunk-YVHBNSME.js";
22
- import "./chunk-RZOXUSPC.js";
23
- import "./chunk-KPPJTH44.js";
24
- import "./chunk-J6JP25XU.js";
25
- import "./chunk-U5HPROLA.js";
26
- import "./chunk-WME2OQST.js";
27
- import {
28
- createSubsystemLogger
29
- } from "./chunk-KXF5R4UN.js";
30
- import "./chunk-S26LC76R.js";
31
- import "./chunk-Z2XAOKHK.js";
32
- import "./chunk-VSFLRN5Y.js";
33
- import "./chunk-LJDODBBZ.js";
34
- import "./chunk-PQJFG24Z.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,27 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- GoClient,
4
- goClient,
5
- resetGoAvailability
6
- } from "./chunk-4LM3VAZH.js";
7
- import "./chunk-CB4WHS4H.js";
8
- import "./chunk-3F6BMY53.js";
9
- import "./chunk-KW5JQPO5.js";
10
- import "./chunk-YVHBNSME.js";
11
- import "./chunk-AWQWXSW4.js";
12
- import "./chunk-KPPJTH44.js";
13
- import "./chunk-J6JP25XU.js";
14
- import "./chunk-U5HPROLA.js";
15
- import "./chunk-WME2OQST.js";
16
- import "./chunk-KXF5R4UN.js";
17
- import "./chunk-S26LC76R.js";
18
- import "./chunk-Z2XAOKHK.js";
19
- import "./chunk-VSFLRN5Y.js";
20
- import "./chunk-LJDODBBZ.js";
21
- import "./chunk-PQJFG24Z.js";
22
- import "./chunk-NXL4FFQQ.js";
23
- export {
24
- GoClient,
25
- goClient,
26
- resetGoAvailability
27
- };
@@ -1,27 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- RustClient,
4
- resetRustAvailability,
5
- rustClient
6
- } from "./chunk-RQS4QQSD.js";
7
- import "./chunk-CB4WHS4H.js";
8
- import "./chunk-3F6BMY53.js";
9
- import "./chunk-KW5JQPO5.js";
10
- import "./chunk-YVHBNSME.js";
11
- import "./chunk-AWQWXSW4.js";
12
- import "./chunk-KPPJTH44.js";
13
- import "./chunk-J6JP25XU.js";
14
- import "./chunk-U5HPROLA.js";
15
- import "./chunk-WME2OQST.js";
16
- import "./chunk-KXF5R4UN.js";
17
- import "./chunk-S26LC76R.js";
18
- import "./chunk-Z2XAOKHK.js";
19
- import "./chunk-VSFLRN5Y.js";
20
- import "./chunk-LJDODBBZ.js";
21
- import "./chunk-PQJFG24Z.js";
22
- import "./chunk-NXL4FFQQ.js";
23
- export {
24
- RustClient,
25
- resetRustAvailability,
26
- rustClient
27
- };
@@ -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-DQZFQSR5.js";
6
- import "./chunk-WDBICWH3.js";
7
- import "./chunk-L5JYIU47.js";
8
- import "./chunk-Z54ZSOBZ.js";
9
- import "./chunk-U6VN4NVL.js";
10
- import "./chunk-TIQJPRDD.js";
11
- import "./chunk-YISME6ON.js";
12
- import "./chunk-HO6LWE2E.js";
13
- import "./chunk-KW5JQPO5.js";
14
- import "./chunk-YVHBNSME.js";
15
- import "./chunk-RZOXUSPC.js";
16
- import "./chunk-KPPJTH44.js";
17
- import "./chunk-J6JP25XU.js";
18
- import "./chunk-U5HPROLA.js";
19
- import "./chunk-WME2OQST.js";
20
- import "./chunk-KXF5R4UN.js";
21
- import "./chunk-S26LC76R.js";
22
- import "./chunk-Z2XAOKHK.js";
23
- import "./chunk-VSFLRN5Y.js";
24
- import "./chunk-LJDODBBZ.js";
25
- import "./chunk-PQJFG24Z.js";
26
- import "./chunk-NXL4FFQQ.js";
27
- export {
28
- importFactProvider,
29
- importFactsApplyTo
30
- };
@@ -1,73 +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-FZKFVUEC.js";
13
- import "./chunk-XT2HTCJ5.js";
14
- import "./chunk-XIMYZ3JA.js";
15
- import "./chunk-R5MOQM2H.js";
16
- import "./chunk-24BILSZW.js";
17
- import "./chunk-PR6PO3ES.js";
18
- import "./chunk-RC2Z6K47.js";
19
- import "./chunk-F5Z6URKM.js";
20
- import "./chunk-MPKRJBPK.js";
21
- import "./chunk-DH5JPM3K.js";
22
- import "./chunk-PKES3ISE.js";
23
- import "./chunk-ZKXQKGWZ.js";
24
- import "./chunk-L5JYIU47.js";
25
- import "./chunk-Z54ZSOBZ.js";
26
- import "./chunk-U6VN4NVL.js";
27
- import "./chunk-TIQJPRDD.js";
28
- import "./chunk-YISME6ON.js";
29
- import "./chunk-6HWVI6MI.js";
30
- import "./chunk-O4BJFESU.js";
31
- import "./chunk-CKEQFGLT.js";
32
- import "./chunk-HO6LWE2E.js";
33
- import "./chunk-SNDXCFRS.js";
34
- import "./chunk-QOE342SU.js";
35
- import "./chunk-AWDSEDER.js";
36
- import "./chunk-LLS45EWB.js";
37
- import "./chunk-2BEMIWEW.js";
38
- import "./chunk-IJYGIDF4.js";
39
- import "./chunk-KDX35VXP.js";
40
- import "./chunk-DPGEAHZT.js";
41
- import "./chunk-NA7SEXHE.js";
42
- import "./chunk-3F6BMY53.js";
43
- import "./chunk-KW5JQPO5.js";
44
- import "./chunk-PUZ3E2J4.js";
45
- import "./chunk-ABPKUVA4.js";
46
- import "./chunk-EKWX4WD3.js";
47
- import "./chunk-ZGSJDWQU.js";
48
- import "./chunk-YVHBNSME.js";
49
- import "./chunk-AWQWXSW4.js";
50
- import "./chunk-QYF5S6P6.js";
51
- import "./chunk-RZOXUSPC.js";
52
- import "./chunk-KPPJTH44.js";
53
- import "./chunk-J6JP25XU.js";
54
- import "./chunk-U5HPROLA.js";
55
- import "./chunk-WME2OQST.js";
56
- import "./chunk-KXF5R4UN.js";
57
- import "./chunk-S26LC76R.js";
58
- import "./chunk-Z2XAOKHK.js";
59
- import "./chunk-VSFLRN5Y.js";
60
- import "./chunk-LJDODBBZ.js";
61
- import "./chunk-PQJFG24Z.js";
62
- import "./chunk-NXL4FFQQ.js";
63
- export {
64
- adaptLspService,
65
- getLSPService,
66
- groupFilesByPrimaryServer,
67
- hasAuxiliaryLspPublishedForRoot,
68
- notifyExternalFileChange,
69
- peekLSPService,
70
- resetLSPService,
71
- resyncGitChangedFiles,
72
- runPerServerGroups
73
- };