@opencodereview/core 1.9.1

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 (453) hide show
  1. package/dist/ai/anthropic-provider.d.ts +41 -0
  2. package/dist/ai/anthropic-provider.d.ts.map +1 -0
  3. package/dist/ai/anthropic-provider.js +139 -0
  4. package/dist/ai/anthropic-provider.js.map +1 -0
  5. package/dist/ai/index.d.ts +39 -0
  6. package/dist/ai/index.d.ts.map +1 -0
  7. package/dist/ai/index.js +41 -0
  8. package/dist/ai/index.js.map +1 -0
  9. package/dist/ai/ollama-provider.d.ts +46 -0
  10. package/dist/ai/ollama-provider.d.ts.map +1 -0
  11. package/dist/ai/ollama-provider.js +149 -0
  12. package/dist/ai/ollama-provider.js.map +1 -0
  13. package/dist/ai/openai-provider.d.ts +44 -0
  14. package/dist/ai/openai-provider.d.ts.map +1 -0
  15. package/dist/ai/openai-provider.js +137 -0
  16. package/dist/ai/openai-provider.js.map +1 -0
  17. package/dist/ai/orchestrator.d.ts +60 -0
  18. package/dist/ai/orchestrator.d.ts.map +1 -0
  19. package/dist/ai/orchestrator.js +188 -0
  20. package/dist/ai/orchestrator.js.map +1 -0
  21. package/dist/ai/prompts.d.ts +27 -0
  22. package/dist/ai/prompts.d.ts.map +1 -0
  23. package/dist/ai/prompts.js +112 -0
  24. package/dist/ai/prompts.js.map +1 -0
  25. package/dist/ai/types.d.ts +75 -0
  26. package/dist/ai/types.d.ts.map +1 -0
  27. package/dist/ai/types.js +10 -0
  28. package/dist/ai/types.js.map +1 -0
  29. package/dist/ai/v4/embedding/index.d.ts +10 -0
  30. package/dist/ai/v4/embedding/index.d.ts.map +1 -0
  31. package/dist/ai/v4/embedding/index.js +10 -0
  32. package/dist/ai/v4/embedding/index.js.map +1 -0
  33. package/dist/ai/v4/embedding/local.d.ts +68 -0
  34. package/dist/ai/v4/embedding/local.d.ts.map +1 -0
  35. package/dist/ai/v4/embedding/local.js +167 -0
  36. package/dist/ai/v4/embedding/local.js.map +1 -0
  37. package/dist/ai/v4/embedding/ollama.d.ts +58 -0
  38. package/dist/ai/v4/embedding/ollama.d.ts.map +1 -0
  39. package/dist/ai/v4/embedding/ollama.js +101 -0
  40. package/dist/ai/v4/embedding/ollama.js.map +1 -0
  41. package/dist/ai/v4/embedding/openai.d.ts +36 -0
  42. package/dist/ai/v4/embedding/openai.d.ts.map +1 -0
  43. package/dist/ai/v4/embedding/openai.js +76 -0
  44. package/dist/ai/v4/embedding/openai.js.map +1 -0
  45. package/dist/ai/v4/embedding/similarity.d.ts +36 -0
  46. package/dist/ai/v4/embedding/similarity.d.ts.map +1 -0
  47. package/dist/ai/v4/embedding/similarity.js +60 -0
  48. package/dist/ai/v4/embedding/similarity.js.map +1 -0
  49. package/dist/ai/v4/index.d.ts +51 -0
  50. package/dist/ai/v4/index.d.ts.map +1 -0
  51. package/dist/ai/v4/index.js +54 -0
  52. package/dist/ai/v4/index.js.map +1 -0
  53. package/dist/ai/v4/llm/anthropic.d.ts +38 -0
  54. package/dist/ai/v4/llm/anthropic.d.ts.map +1 -0
  55. package/dist/ai/v4/llm/anthropic.js +86 -0
  56. package/dist/ai/v4/llm/anthropic.js.map +1 -0
  57. package/dist/ai/v4/llm/index.d.ts +9 -0
  58. package/dist/ai/v4/llm/index.d.ts.map +1 -0
  59. package/dist/ai/v4/llm/index.js +9 -0
  60. package/dist/ai/v4/llm/index.js.map +1 -0
  61. package/dist/ai/v4/llm/ollama.d.ts +39 -0
  62. package/dist/ai/v4/llm/ollama.d.ts.map +1 -0
  63. package/dist/ai/v4/llm/ollama.js +95 -0
  64. package/dist/ai/v4/llm/ollama.js.map +1 -0
  65. package/dist/ai/v4/llm/openai.d.ts +38 -0
  66. package/dist/ai/v4/llm/openai.d.ts.map +1 -0
  67. package/dist/ai/v4/llm/openai.js +88 -0
  68. package/dist/ai/v4/llm/openai.js.map +1 -0
  69. package/dist/ai/v4/patterns/defect-patterns.d.ts +57 -0
  70. package/dist/ai/v4/patterns/defect-patterns.d.ts.map +1 -0
  71. package/dist/ai/v4/patterns/defect-patterns.js +331 -0
  72. package/dist/ai/v4/patterns/defect-patterns.js.map +1 -0
  73. package/dist/ai/v4/patterns/index.d.ts +8 -0
  74. package/dist/ai/v4/patterns/index.d.ts.map +1 -0
  75. package/dist/ai/v4/patterns/index.js +7 -0
  76. package/dist/ai/v4/patterns/index.js.map +1 -0
  77. package/dist/ai/v4/pipeline.d.ts +74 -0
  78. package/dist/ai/v4/pipeline.d.ts.map +1 -0
  79. package/dist/ai/v4/pipeline.js +381 -0
  80. package/dist/ai/v4/pipeline.js.map +1 -0
  81. package/dist/ai/v4/sla.d.ts +62 -0
  82. package/dist/ai/v4/sla.d.ts.map +1 -0
  83. package/dist/ai/v4/sla.js +136 -0
  84. package/dist/ai/v4/sla.js.map +1 -0
  85. package/dist/ai/v4/types.d.ts +117 -0
  86. package/dist/ai/v4/types.d.ts.map +1 -0
  87. package/dist/ai/v4/types.js +16 -0
  88. package/dist/ai/v4/types.js.map +1 -0
  89. package/dist/ai-healer/prompt-builder.d.ts +33 -0
  90. package/dist/ai-healer/prompt-builder.d.ts.map +1 -0
  91. package/dist/ai-healer/prompt-builder.js +89 -0
  92. package/dist/ai-healer/prompt-builder.js.map +1 -0
  93. package/dist/config/defaults.d.ts +14 -0
  94. package/dist/config/defaults.d.ts.map +1 -0
  95. package/dist/config/defaults.js +57 -0
  96. package/dist/config/defaults.js.map +1 -0
  97. package/dist/config/index.d.ts +8 -0
  98. package/dist/config/index.d.ts.map +1 -0
  99. package/dist/config/index.js +6 -0
  100. package/dist/config/index.js.map +1 -0
  101. package/dist/config/loader.d.ts +33 -0
  102. package/dist/config/loader.d.ts.map +1 -0
  103. package/dist/config/loader.js +245 -0
  104. package/dist/config/loader.js.map +1 -0
  105. package/dist/config/types.d.ts +58 -0
  106. package/dist/config/types.d.ts.map +1 -0
  107. package/dist/config/types.js +7 -0
  108. package/dist/config/types.js.map +1 -0
  109. package/dist/config/v4-config.d.ts +77 -0
  110. package/dist/config/v4-config.d.ts.map +1 -0
  111. package/dist/config/v4-config.js +336 -0
  112. package/dist/config/v4-config.js.map +1 -0
  113. package/dist/detectors/ai-detector.d.ts +38 -0
  114. package/dist/detectors/ai-detector.d.ts.map +1 -0
  115. package/dist/detectors/ai-detector.js +62 -0
  116. package/dist/detectors/ai-detector.js.map +1 -0
  117. package/dist/detectors/context-break.d.ts +57 -0
  118. package/dist/detectors/context-break.d.ts.map +1 -0
  119. package/dist/detectors/context-break.js +199 -0
  120. package/dist/detectors/context-break.js.map +1 -0
  121. package/dist/detectors/deep-hallucination.d.ts +42 -0
  122. package/dist/detectors/deep-hallucination.d.ts.map +1 -0
  123. package/dist/detectors/deep-hallucination.js +297 -0
  124. package/dist/detectors/deep-hallucination.js.map +1 -0
  125. package/dist/detectors/duplication.d.ts +61 -0
  126. package/dist/detectors/duplication.d.ts.map +1 -0
  127. package/dist/detectors/duplication.js +204 -0
  128. package/dist/detectors/duplication.js.map +1 -0
  129. package/dist/detectors/hallucination.d.ts +80 -0
  130. package/dist/detectors/hallucination.d.ts.map +1 -0
  131. package/dist/detectors/hallucination.js +350 -0
  132. package/dist/detectors/hallucination.js.map +1 -0
  133. package/dist/detectors/index.d.ts +35 -0
  134. package/dist/detectors/index.d.ts.map +1 -0
  135. package/dist/detectors/index.js +33 -0
  136. package/dist/detectors/index.js.map +1 -0
  137. package/dist/detectors/logic-gap.d.ts +58 -0
  138. package/dist/detectors/logic-gap.d.ts.map +1 -0
  139. package/dist/detectors/logic-gap.js +284 -0
  140. package/dist/detectors/logic-gap.js.map +1 -0
  141. package/dist/detectors/over-engineering.d.ts +44 -0
  142. package/dist/detectors/over-engineering.d.ts.map +1 -0
  143. package/dist/detectors/over-engineering.js +257 -0
  144. package/dist/detectors/over-engineering.js.map +1 -0
  145. package/dist/detectors/security-pattern.d.ts +43 -0
  146. package/dist/detectors/security-pattern.d.ts.map +1 -0
  147. package/dist/detectors/security-pattern.js +235 -0
  148. package/dist/detectors/security-pattern.js.map +1 -0
  149. package/dist/detectors/stale-api.d.ts +44 -0
  150. package/dist/detectors/stale-api.d.ts.map +1 -0
  151. package/dist/detectors/stale-api.js +160 -0
  152. package/dist/detectors/stale-api.js.map +1 -0
  153. package/dist/detectors/type-safety.d.ts +41 -0
  154. package/dist/detectors/type-safety.d.ts.map +1 -0
  155. package/dist/detectors/type-safety.js +306 -0
  156. package/dist/detectors/type-safety.js.map +1 -0
  157. package/dist/detectors/v4/context-coherence.d.ts +67 -0
  158. package/dist/detectors/v4/context-coherence.d.ts.map +1 -0
  159. package/dist/detectors/v4/context-coherence.js +319 -0
  160. package/dist/detectors/v4/context-coherence.js.map +1 -0
  161. package/dist/detectors/v4/hallucinated-import.d.ts +52 -0
  162. package/dist/detectors/v4/hallucinated-import.d.ts.map +1 -0
  163. package/dist/detectors/v4/hallucinated-import.js +206 -0
  164. package/dist/detectors/v4/hallucinated-import.js.map +1 -0
  165. package/dist/detectors/v4/index.d.ts +28 -0
  166. package/dist/detectors/v4/index.d.ts.map +1 -0
  167. package/dist/detectors/v4/index.js +40 -0
  168. package/dist/detectors/v4/index.js.map +1 -0
  169. package/dist/detectors/v4/over-engineering.d.ts +69 -0
  170. package/dist/detectors/v4/over-engineering.d.ts.map +1 -0
  171. package/dist/detectors/v4/over-engineering.js +234 -0
  172. package/dist/detectors/v4/over-engineering.js.map +1 -0
  173. package/dist/detectors/v4/security-pattern.d.ts +46 -0
  174. package/dist/detectors/v4/security-pattern.d.ts.map +1 -0
  175. package/dist/detectors/v4/security-pattern.js +233 -0
  176. package/dist/detectors/v4/security-pattern.js.map +1 -0
  177. package/dist/detectors/v4/stale-api.d.ts +59 -0
  178. package/dist/detectors/v4/stale-api.d.ts.map +1 -0
  179. package/dist/detectors/v4/stale-api.js +470 -0
  180. package/dist/detectors/v4/stale-api.js.map +1 -0
  181. package/dist/detectors/v4/types.d.ts +74 -0
  182. package/dist/detectors/v4/types.d.ts.map +1 -0
  183. package/dist/detectors/v4/types.js +10 -0
  184. package/dist/detectors/v4/types.js.map +1 -0
  185. package/dist/diff/filter.d.ts +35 -0
  186. package/dist/diff/filter.d.ts.map +1 -0
  187. package/dist/diff/filter.js +65 -0
  188. package/dist/diff/filter.js.map +1 -0
  189. package/dist/diff/index.d.ts +9 -0
  190. package/dist/diff/index.d.ts.map +1 -0
  191. package/dist/diff/index.js +8 -0
  192. package/dist/diff/index.js.map +1 -0
  193. package/dist/diff/parser.d.ts +61 -0
  194. package/dist/diff/parser.d.ts.map +1 -0
  195. package/dist/diff/parser.js +203 -0
  196. package/dist/diff/parser.js.map +1 -0
  197. package/dist/i18n/en.d.ts +18 -0
  198. package/dist/i18n/en.d.ts.map +1 -0
  199. package/dist/i18n/en.js +83 -0
  200. package/dist/i18n/en.js.map +1 -0
  201. package/dist/i18n/index.d.ts +13 -0
  202. package/dist/i18n/index.d.ts.map +1 -0
  203. package/dist/i18n/index.js +14 -0
  204. package/dist/i18n/index.js.map +1 -0
  205. package/dist/i18n/provider.d.ts +54 -0
  206. package/dist/i18n/provider.d.ts.map +1 -0
  207. package/dist/i18n/provider.js +88 -0
  208. package/dist/i18n/provider.js.map +1 -0
  209. package/dist/i18n/types.d.ts +37 -0
  210. package/dist/i18n/types.d.ts.map +1 -0
  211. package/dist/i18n/types.js +10 -0
  212. package/dist/i18n/types.js.map +1 -0
  213. package/dist/i18n/zh.d.ts +14 -0
  214. package/dist/i18n/zh.d.ts.map +1 -0
  215. package/dist/i18n/zh.js +83 -0
  216. package/dist/i18n/zh.js.map +1 -0
  217. package/dist/index.d.ts +113 -0
  218. package/dist/index.d.ts.map +1 -0
  219. package/dist/index.js +106 -0
  220. package/dist/index.js.map +1 -0
  221. package/dist/ir/index.d.ts +10 -0
  222. package/dist/ir/index.d.ts.map +1 -0
  223. package/dist/ir/index.js +9 -0
  224. package/dist/ir/index.js.map +1 -0
  225. package/dist/ir/types.d.ts +126 -0
  226. package/dist/ir/types.d.ts.map +1 -0
  227. package/dist/ir/types.js +33 -0
  228. package/dist/ir/types.js.map +1 -0
  229. package/dist/languages/go/index.d.ts +7 -0
  230. package/dist/languages/go/index.d.ts.map +1 -0
  231. package/dist/languages/go/index.js +7 -0
  232. package/dist/languages/go/index.js.map +1 -0
  233. package/dist/languages/go/parser.d.ts +89 -0
  234. package/dist/languages/go/parser.d.ts.map +1 -0
  235. package/dist/languages/go/parser.js +509 -0
  236. package/dist/languages/go/parser.js.map +1 -0
  237. package/dist/languages/index.d.ts +13 -0
  238. package/dist/languages/index.d.ts.map +1 -0
  239. package/dist/languages/index.js +14 -0
  240. package/dist/languages/index.js.map +1 -0
  241. package/dist/languages/java/index.d.ts +7 -0
  242. package/dist/languages/java/index.d.ts.map +1 -0
  243. package/dist/languages/java/index.js +7 -0
  244. package/dist/languages/java/index.js.map +1 -0
  245. package/dist/languages/java/parser.d.ts +82 -0
  246. package/dist/languages/java/parser.d.ts.map +1 -0
  247. package/dist/languages/java/parser.js +492 -0
  248. package/dist/languages/java/parser.js.map +1 -0
  249. package/dist/languages/kotlin/index.d.ts +7 -0
  250. package/dist/languages/kotlin/index.d.ts.map +1 -0
  251. package/dist/languages/kotlin/index.js +7 -0
  252. package/dist/languages/kotlin/index.js.map +1 -0
  253. package/dist/languages/kotlin/parser.d.ts +84 -0
  254. package/dist/languages/kotlin/parser.d.ts.map +1 -0
  255. package/dist/languages/kotlin/parser.js +507 -0
  256. package/dist/languages/kotlin/parser.js.map +1 -0
  257. package/dist/languages/python/index.d.ts +7 -0
  258. package/dist/languages/python/index.d.ts.map +1 -0
  259. package/dist/languages/python/index.js +7 -0
  260. package/dist/languages/python/index.js.map +1 -0
  261. package/dist/languages/python/parser.d.ts +91 -0
  262. package/dist/languages/python/parser.d.ts.map +1 -0
  263. package/dist/languages/python/parser.js +375 -0
  264. package/dist/languages/python/parser.js.map +1 -0
  265. package/dist/languages/registry.d.ts +81 -0
  266. package/dist/languages/registry.d.ts.map +1 -0
  267. package/dist/languages/registry.js +150 -0
  268. package/dist/languages/registry.js.map +1 -0
  269. package/dist/languages/types.d.ts +137 -0
  270. package/dist/languages/types.d.ts.map +1 -0
  271. package/dist/languages/types.js +10 -0
  272. package/dist/languages/types.js.map +1 -0
  273. package/dist/languages/typescript/index.d.ts +7 -0
  274. package/dist/languages/typescript/index.d.ts.map +1 -0
  275. package/dist/languages/typescript/index.js +7 -0
  276. package/dist/languages/typescript/index.js.map +1 -0
  277. package/dist/languages/typescript/parser.d.ts +51 -0
  278. package/dist/languages/typescript/parser.d.ts.map +1 -0
  279. package/dist/languages/typescript/parser.js +286 -0
  280. package/dist/languages/typescript/parser.js.map +1 -0
  281. package/dist/license/generator.d.ts +43 -0
  282. package/dist/license/generator.d.ts.map +1 -0
  283. package/dist/license/generator.js +72 -0
  284. package/dist/license/generator.js.map +1 -0
  285. package/dist/license/index.d.ts +11 -0
  286. package/dist/license/index.d.ts.map +1 -0
  287. package/dist/license/index.js +12 -0
  288. package/dist/license/index.js.map +1 -0
  289. package/dist/license/types.d.ts +85 -0
  290. package/dist/license/types.d.ts.map +1 -0
  291. package/dist/license/types.js +10 -0
  292. package/dist/license/types.js.map +1 -0
  293. package/dist/license/validator.d.ts +77 -0
  294. package/dist/license/validator.d.ts.map +1 -0
  295. package/dist/license/validator.js +275 -0
  296. package/dist/license/validator.js.map +1 -0
  297. package/dist/parser/extractor.d.ts +31 -0
  298. package/dist/parser/extractor.d.ts.map +1 -0
  299. package/dist/parser/extractor.js +10 -0
  300. package/dist/parser/extractor.js.map +1 -0
  301. package/dist/parser/extractors/go.d.ts +21 -0
  302. package/dist/parser/extractors/go.d.ts.map +1 -0
  303. package/dist/parser/extractors/go.js +569 -0
  304. package/dist/parser/extractors/go.js.map +1 -0
  305. package/dist/parser/extractors/index.d.ts +13 -0
  306. package/dist/parser/extractors/index.d.ts.map +1 -0
  307. package/dist/parser/extractors/index.js +13 -0
  308. package/dist/parser/extractors/index.js.map +1 -0
  309. package/dist/parser/extractors/java.d.ts +24 -0
  310. package/dist/parser/extractors/java.d.ts.map +1 -0
  311. package/dist/parser/extractors/java.js +611 -0
  312. package/dist/parser/extractors/java.js.map +1 -0
  313. package/dist/parser/extractors/kotlin.d.ts +25 -0
  314. package/dist/parser/extractors/kotlin.d.ts.map +1 -0
  315. package/dist/parser/extractors/kotlin.js +665 -0
  316. package/dist/parser/extractors/kotlin.js.map +1 -0
  317. package/dist/parser/extractors/python.d.ts +21 -0
  318. package/dist/parser/extractors/python.d.ts.map +1 -0
  319. package/dist/parser/extractors/python.js +514 -0
  320. package/dist/parser/extractors/python.js.map +1 -0
  321. package/dist/parser/extractors/typescript.d.ts +23 -0
  322. package/dist/parser/extractors/typescript.d.ts.map +1 -0
  323. package/dist/parser/extractors/typescript.js +664 -0
  324. package/dist/parser/extractors/typescript.js.map +1 -0
  325. package/dist/parser/index.d.ts +15 -0
  326. package/dist/parser/index.d.ts.map +1 -0
  327. package/dist/parser/index.js +14 -0
  328. package/dist/parser/index.js.map +1 -0
  329. package/dist/parser/manager.d.ts +50 -0
  330. package/dist/parser/manager.d.ts.map +1 -0
  331. package/dist/parser/manager.js +159 -0
  332. package/dist/parser/manager.js.map +1 -0
  333. package/dist/registry/builtins/go-builtins.d.ts +13 -0
  334. package/dist/registry/builtins/go-builtins.d.ts.map +1 -0
  335. package/dist/registry/builtins/go-builtins.js +63 -0
  336. package/dist/registry/builtins/go-builtins.js.map +1 -0
  337. package/dist/registry/builtins/java-builtins.d.ts +10 -0
  338. package/dist/registry/builtins/java-builtins.d.ts.map +1 -0
  339. package/dist/registry/builtins/java-builtins.js +59 -0
  340. package/dist/registry/builtins/java-builtins.js.map +1 -0
  341. package/dist/registry/builtins/kotlin-builtins.d.ts +10 -0
  342. package/dist/registry/builtins/kotlin-builtins.d.ts.map +1 -0
  343. package/dist/registry/builtins/kotlin-builtins.js +38 -0
  344. package/dist/registry/builtins/kotlin-builtins.js.map +1 -0
  345. package/dist/registry/builtins/node-builtins.d.ts +10 -0
  346. package/dist/registry/builtins/node-builtins.d.ts.map +1 -0
  347. package/dist/registry/builtins/node-builtins.js +36 -0
  348. package/dist/registry/builtins/node-builtins.js.map +1 -0
  349. package/dist/registry/builtins/python-builtins.d.ts +10 -0
  350. package/dist/registry/builtins/python-builtins.d.ts.map +1 -0
  351. package/dist/registry/builtins/python-builtins.js +43 -0
  352. package/dist/registry/builtins/python-builtins.js.map +1 -0
  353. package/dist/registry/cache.d.ts +53 -0
  354. package/dist/registry/cache.d.ts.map +1 -0
  355. package/dist/registry/cache.js +147 -0
  356. package/dist/registry/cache.js.map +1 -0
  357. package/dist/registry/go-registry.d.ts +52 -0
  358. package/dist/registry/go-registry.d.ts.map +1 -0
  359. package/dist/registry/go-registry.js +148 -0
  360. package/dist/registry/go-registry.js.map +1 -0
  361. package/dist/registry/index.d.ts +18 -0
  362. package/dist/registry/index.d.ts.map +1 -0
  363. package/dist/registry/index.js +21 -0
  364. package/dist/registry/index.js.map +1 -0
  365. package/dist/registry/maven-registry.d.ts +57 -0
  366. package/dist/registry/maven-registry.d.ts.map +1 -0
  367. package/dist/registry/maven-registry.js +155 -0
  368. package/dist/registry/maven-registry.js.map +1 -0
  369. package/dist/registry/npm-registry.d.ts +40 -0
  370. package/dist/registry/npm-registry.d.ts.map +1 -0
  371. package/dist/registry/npm-registry.js +155 -0
  372. package/dist/registry/npm-registry.js.map +1 -0
  373. package/dist/registry/pypi-registry.d.ts +49 -0
  374. package/dist/registry/pypi-registry.d.ts.map +1 -0
  375. package/dist/registry/pypi-registry.js +175 -0
  376. package/dist/registry/pypi-registry.js.map +1 -0
  377. package/dist/registry/registry-manager.d.ts +45 -0
  378. package/dist/registry/registry-manager.d.ts.map +1 -0
  379. package/dist/registry/registry-manager.js +107 -0
  380. package/dist/registry/registry-manager.js.map +1 -0
  381. package/dist/registry/types.d.ts +83 -0
  382. package/dist/registry/types.d.ts.map +1 -0
  383. package/dist/registry/types.js +12 -0
  384. package/dist/registry/types.js.map +1 -0
  385. package/dist/reporter/html-reporter.d.ts +20 -0
  386. package/dist/reporter/html-reporter.d.ts.map +1 -0
  387. package/dist/reporter/html-reporter.js +612 -0
  388. package/dist/reporter/html-reporter.js.map +1 -0
  389. package/dist/reporter/index.d.ts +28 -0
  390. package/dist/reporter/index.d.ts.map +1 -0
  391. package/dist/reporter/index.js +48 -0
  392. package/dist/reporter/index.js.map +1 -0
  393. package/dist/reporter/markdown-reporter.d.ts +16 -0
  394. package/dist/reporter/markdown-reporter.d.ts.map +1 -0
  395. package/dist/reporter/markdown-reporter.js +182 -0
  396. package/dist/reporter/markdown-reporter.js.map +1 -0
  397. package/dist/reporter/sarif-reporter.d.ts +67 -0
  398. package/dist/reporter/sarif-reporter.d.ts.map +1 -0
  399. package/dist/reporter/sarif-reporter.js +73 -0
  400. package/dist/reporter/sarif-reporter.js.map +1 -0
  401. package/dist/reporter/terminal-reporter.d.ts +14 -0
  402. package/dist/reporter/terminal-reporter.d.ts.map +1 -0
  403. package/dist/reporter/terminal-reporter.js +126 -0
  404. package/dist/reporter/terminal-reporter.js.map +1 -0
  405. package/dist/reporter/types.d.ts +43 -0
  406. package/dist/reporter/types.d.ts.map +1 -0
  407. package/dist/reporter/types.js +10 -0
  408. package/dist/reporter/types.js.map +1 -0
  409. package/dist/reporter/v4-html.d.ts +24 -0
  410. package/dist/reporter/v4-html.d.ts.map +1 -0
  411. package/dist/reporter/v4-html.js +359 -0
  412. package/dist/reporter/v4-html.js.map +1 -0
  413. package/dist/reporter/v4-terminal.d.ts +55 -0
  414. package/dist/reporter/v4-terminal.d.ts.map +1 -0
  415. package/dist/reporter/v4-terminal.js +199 -0
  416. package/dist/reporter/v4-terminal.js.map +1 -0
  417. package/dist/scanner/index.d.ts +9 -0
  418. package/dist/scanner/index.d.ts.map +1 -0
  419. package/dist/scanner/index.js +9 -0
  420. package/dist/scanner/index.js.map +1 -0
  421. package/dist/scanner/v4-scanner.d.ts +162 -0
  422. package/dist/scanner/v4-scanner.d.ts.map +1 -0
  423. package/dist/scanner/v4-scanner.js +327 -0
  424. package/dist/scanner/v4-scanner.js.map +1 -0
  425. package/dist/scorer/report.d.ts +52 -0
  426. package/dist/scorer/report.d.ts.map +1 -0
  427. package/dist/scorer/report.js +347 -0
  428. package/dist/scorer/report.js.map +1 -0
  429. package/dist/scorer/scoring-engine.d.ts +170 -0
  430. package/dist/scorer/scoring-engine.d.ts.map +1 -0
  431. package/dist/scorer/scoring-engine.js +308 -0
  432. package/dist/scorer/scoring-engine.js.map +1 -0
  433. package/dist/scorer/v4-adapter.d.ts +87 -0
  434. package/dist/scorer/v4-adapter.d.ts.map +1 -0
  435. package/dist/scorer/v4-adapter.js +145 -0
  436. package/dist/scorer/v4-adapter.js.map +1 -0
  437. package/dist/sla/index.d.ts +7 -0
  438. package/dist/sla/index.d.ts.map +1 -0
  439. package/dist/sla/index.js +6 -0
  440. package/dist/sla/index.js.map +1 -0
  441. package/dist/sla/tracker.d.ts +70 -0
  442. package/dist/sla/tracker.d.ts.map +1 -0
  443. package/dist/sla/tracker.js +151 -0
  444. package/dist/sla/tracker.js.map +1 -0
  445. package/dist/sla/types.d.ts +67 -0
  446. package/dist/sla/types.d.ts.map +1 -0
  447. package/dist/sla/types.js +42 -0
  448. package/dist/sla/types.js.map +1 -0
  449. package/dist/types.d.ts +172 -0
  450. package/dist/types.d.ts.map +1 -0
  451. package/dist/types.js +69 -0
  452. package/dist/types.js.map +1 -0
  453. package/package.json +97 -0
@@ -0,0 +1,665 @@
1
+ /**
2
+ * Open Code Review V4 — Kotlin Extractor
3
+ *
4
+ * Extracts CodeUnits from Kotlin tree-sitter CSTs.
5
+ * Handles: imports (basic, aliased), classes (regular, data, sealed),
6
+ * object declarations (singletons), functions (regular, extension),
7
+ * companion objects, properties, calls, complexity, symbols.
8
+ *
9
+ * @since 0.4.0
10
+ */
11
+ import { createCodeUnit } from '../../ir/types.js';
12
+ // ─── Tree-sitter node type constants ───────────────────────────────
13
+ /** Node types that represent branching (for cyclomatic complexity) */
14
+ const BRANCHING_NODES = new Set([
15
+ 'if_expression',
16
+ 'for_statement',
17
+ 'while_statement',
18
+ 'do_while_statement',
19
+ 'when_expression',
20
+ 'when_entry',
21
+ 'catch_block',
22
+ 'conjunction_expression', // &&
23
+ 'disjunction_expression', // ||
24
+ 'elvis_expression', // ?:
25
+ ]);
26
+ /** Node types that increase nesting depth */
27
+ const NESTING_NODES = new Set([
28
+ 'if_expression',
29
+ 'for_statement',
30
+ 'while_statement',
31
+ 'do_while_statement',
32
+ 'when_expression',
33
+ 'try_expression',
34
+ 'catch_block',
35
+ ]);
36
+ /** Node types for cognitive complexity */
37
+ const COGNITIVE_NODES = new Set([
38
+ 'if_expression',
39
+ 'for_statement',
40
+ 'while_statement',
41
+ 'do_while_statement',
42
+ 'when_expression',
43
+ 'catch_block',
44
+ ]);
45
+ // ─── Helper: Get node location ─────────────────────────────────────
46
+ function getLocation(node) {
47
+ return {
48
+ startLine: node.startPosition.row,
49
+ startColumn: node.startPosition.column,
50
+ endLine: node.endPosition.row,
51
+ endColumn: node.endPosition.column,
52
+ };
53
+ }
54
+ // ─── Helper: Count lines of code ───────────────────────────────────
55
+ function countLinesOfCode(source) {
56
+ const lines = source.split('\n');
57
+ let count = 0;
58
+ for (const line of lines) {
59
+ const trimmed = line.trim();
60
+ if (trimmed.length > 0 && !trimmed.startsWith('//') && !trimmed.startsWith('/*') && !trimmed.startsWith('*')) {
61
+ count++;
62
+ }
63
+ }
64
+ return count;
65
+ }
66
+ // ─── Helper: Check if Kotlin declaration is exported (public) ──────
67
+ /**
68
+ * In Kotlin, default visibility is public. So exported = NOT private/protected/internal.
69
+ */
70
+ function isExported(node) {
71
+ const modifiers = node.children.find(c => c.type === 'modifiers');
72
+ if (!modifiers)
73
+ return true; // default = public = exported
74
+ for (const mod of modifiers.children) {
75
+ if (mod.type === 'visibility_modifier') {
76
+ const text = mod.text;
77
+ if (text === 'private' || text === 'protected' || text === 'internal') {
78
+ return false;
79
+ }
80
+ }
81
+ }
82
+ return true;
83
+ }
84
+ // ─── Helper: Extract import from import_header ─────────────────────
85
+ function extractImport(node) {
86
+ if (node.type !== 'import_header')
87
+ return null;
88
+ // import_header children: import, identifier, ['.', wildcard_import], [import_alias]
89
+ const identNode = node.children.find(c => c.type === 'identifier');
90
+ if (!identNode)
91
+ return null;
92
+ const fullPath = identNode.text;
93
+ const aliasNode = node.children.find(c => c.type === 'import_alias');
94
+ const hasWildcard = node.children.some(c => c.type === 'wildcard_import');
95
+ const symbols = [];
96
+ let moduleName;
97
+ if (hasWildcard) {
98
+ // import kotlin.collections.* → identifier = "kotlin.collections", wildcard_import = "*"
99
+ // The identifier already contains the full module path
100
+ moduleName = fullPath;
101
+ symbols.push('*');
102
+ }
103
+ else {
104
+ // Split into module and symbol
105
+ const lastDot = fullPath.lastIndexOf('.');
106
+ if (lastDot >= 0) {
107
+ moduleName = fullPath.substring(0, lastDot);
108
+ symbols.push(fullPath.substring(lastDot + 1));
109
+ }
110
+ else {
111
+ moduleName = fullPath;
112
+ }
113
+ }
114
+ return {
115
+ module: moduleName,
116
+ symbols,
117
+ line: node.startPosition.row,
118
+ isRelative: false,
119
+ raw: node.text,
120
+ };
121
+ }
122
+ // ─── Helper: Extract calls from a subtree ──────────────────────────
123
+ function extractCalls(node) {
124
+ const calls = [];
125
+ function walk(n) {
126
+ if (n.type === 'call_expression') {
127
+ // call_expression children: [callee_expr, call_suffix]
128
+ // callee_expr can be: simple_identifier, navigation_expression, etc.
129
+ const calleeNode = n.children[0];
130
+ const callSuffix = n.children.find(c => c.type === 'call_suffix');
131
+ if (calleeNode) {
132
+ const callee = calleeNode.text;
133
+ let object;
134
+ let method;
135
+ if (calleeNode.type === 'navigation_expression') {
136
+ // navigation_expression children: [object_expr, navigation_suffix]
137
+ // navigation_suffix children: ["." or "?.", simple_identifier]
138
+ const objectExpr = calleeNode.children[0];
139
+ const navSuffix = calleeNode.children.find(c => c.type === 'navigation_suffix');
140
+ if (navSuffix) {
141
+ const nameInSuffix = navSuffix.children.find(c => c.type === 'simple_identifier');
142
+ object = objectExpr?.text;
143
+ method = nameInSuffix?.text ?? callee;
144
+ }
145
+ else {
146
+ // Fallback: parse as flat children
147
+ const parts = calleeNode.children.filter(c => c.type !== '.' && c.type !== '?.');
148
+ if (parts.length >= 2) {
149
+ object = parts.slice(0, -1).map(p => p.text).join('.');
150
+ method = parts[parts.length - 1].text;
151
+ }
152
+ else {
153
+ method = callee;
154
+ }
155
+ }
156
+ }
157
+ else if (calleeNode.type === 'simple_identifier') {
158
+ method = calleeNode.text;
159
+ }
160
+ else {
161
+ method = callee;
162
+ }
163
+ // Count arguments from call_suffix
164
+ let argCount = 0;
165
+ if (callSuffix) {
166
+ const valueArgs = callSuffix.children.find(c => c.type === 'value_arguments');
167
+ if (valueArgs) {
168
+ for (const arg of valueArgs.children) {
169
+ if (arg.type === 'value_argument') {
170
+ argCount++;
171
+ }
172
+ }
173
+ }
174
+ // Check for trailing lambda
175
+ const annotatedLambda = callSuffix.children.find(c => c.type === 'annotated_lambda');
176
+ const lambdaLiteral = callSuffix.children.find(c => c.type === 'lambda_literal');
177
+ if (annotatedLambda || lambdaLiteral) {
178
+ argCount++;
179
+ }
180
+ }
181
+ calls.push({
182
+ callee,
183
+ object,
184
+ method,
185
+ line: n.startPosition.row,
186
+ argCount,
187
+ });
188
+ }
189
+ }
190
+ for (let i = 0; i < n.childCount; i++) {
191
+ walk(n.child(i));
192
+ }
193
+ }
194
+ walk(node);
195
+ return calls;
196
+ }
197
+ // ─── Helper: Compute complexity ────────────────────────────────────
198
+ function computeComplexity(node, source) {
199
+ let cyclomatic = 1; // base complexity
200
+ let cognitive = 0;
201
+ let maxDepth = 0;
202
+ function walk(n, nestingDepth) {
203
+ // Cyclomatic complexity
204
+ if (BRANCHING_NODES.has(n.type)) {
205
+ if (n.type === 'conjunction_expression' ||
206
+ n.type === 'disjunction_expression') {
207
+ cyclomatic++;
208
+ }
209
+ else if (n.type === 'elvis_expression') {
210
+ cyclomatic++;
211
+ }
212
+ else if (n.type === 'when_entry') {
213
+ // Each when entry adds a branch
214
+ cyclomatic++;
215
+ }
216
+ else {
217
+ cyclomatic++;
218
+ }
219
+ }
220
+ // Cognitive complexity
221
+ if (COGNITIVE_NODES.has(n.type)) {
222
+ cognitive += 1 + nestingDepth;
223
+ }
224
+ // && / || / ?: add cognitive complexity
225
+ if (n.type === 'conjunction_expression' ||
226
+ n.type === 'disjunction_expression' ||
227
+ n.type === 'elvis_expression') {
228
+ cognitive += 1;
229
+ }
230
+ // Nesting
231
+ let newDepth = nestingDepth;
232
+ if (NESTING_NODES.has(n.type)) {
233
+ newDepth = nestingDepth + 1;
234
+ if (newDepth > maxDepth)
235
+ maxDepth = newDepth;
236
+ }
237
+ for (let i = 0; i < n.childCount; i++) {
238
+ walk(n.child(i), newDepth);
239
+ }
240
+ }
241
+ walk(node, 0);
242
+ return {
243
+ cyclomaticComplexity: cyclomatic,
244
+ cognitiveComplexity: cognitive,
245
+ maxNestingDepth: maxDepth,
246
+ linesOfCode: countLinesOfCode(source),
247
+ };
248
+ }
249
+ // ─── Helper: Count parameters (Kotlin) ─────────────────────────────
250
+ function countParameters(paramsNode) {
251
+ let count = 0;
252
+ for (const child of paramsNode.children) {
253
+ if (child.type === 'parameter') {
254
+ count++;
255
+ }
256
+ }
257
+ return count;
258
+ }
259
+ // ─── KotlinExtractor ───────────────────────────────────────────────
260
+ export class KotlinExtractor {
261
+ language = 'kotlin';
262
+ extract(tree, filePath, source) {
263
+ const units = [];
264
+ const root = tree.rootNode;
265
+ // 1. File-level CodeUnit
266
+ const fileImports = this.extractFileImports(root);
267
+ const fileCalls = extractCalls(root);
268
+ const fileDefs = this.extractFileDefinitions(root);
269
+ const fileComplexity = computeComplexity(root, source);
270
+ const fileUnit = createCodeUnit({
271
+ id: `file:${filePath}`,
272
+ file: filePath,
273
+ language: 'kotlin',
274
+ kind: 'file',
275
+ location: getLocation(root),
276
+ source,
277
+ imports: fileImports,
278
+ calls: fileCalls,
279
+ complexity: fileComplexity,
280
+ definitions: fileDefs,
281
+ references: [],
282
+ childIds: [],
283
+ });
284
+ units.push(fileUnit);
285
+ // 2. Extract top-level declarations
286
+ this.extractTopLevelDeclarations(root, filePath, fileUnit, units);
287
+ return units;
288
+ }
289
+ // ─── File-level imports ──────────────────────────────────────────
290
+ extractFileImports(root) {
291
+ const imports = [];
292
+ // In Kotlin, imports are under import_list
293
+ for (let i = 0; i < root.childCount; i++) {
294
+ const child = root.child(i);
295
+ if (child.type === 'import_list') {
296
+ for (const importHeader of child.children) {
297
+ if (importHeader.type === 'import_header') {
298
+ const info = extractImport(importHeader);
299
+ if (info)
300
+ imports.push(info);
301
+ }
302
+ }
303
+ }
304
+ else if (child.type === 'import_header') {
305
+ const info = extractImport(child);
306
+ if (info)
307
+ imports.push(info);
308
+ }
309
+ }
310
+ return imports;
311
+ }
312
+ // ─── File-level definitions ──────────────────────────────────────
313
+ extractFileDefinitions(root) {
314
+ const defs = [];
315
+ for (let i = 0; i < root.childCount; i++) {
316
+ const child = root.child(i);
317
+ if (child.type === 'class_declaration') {
318
+ const nameNode = child.children.find(c => c.type === 'type_identifier');
319
+ if (nameNode) {
320
+ defs.push({
321
+ name: nameNode.text,
322
+ kind: 'class',
323
+ line: child.startPosition.row,
324
+ exported: isExported(child),
325
+ });
326
+ }
327
+ }
328
+ else if (child.type === 'object_declaration') {
329
+ const nameNode = child.children.find(c => c.type === 'type_identifier');
330
+ if (nameNode) {
331
+ defs.push({
332
+ name: nameNode.text,
333
+ kind: 'class',
334
+ line: child.startPosition.row,
335
+ exported: isExported(child),
336
+ });
337
+ }
338
+ }
339
+ else if (child.type === 'function_declaration') {
340
+ const nameNode = child.children.find(c => c.type === 'simple_identifier');
341
+ if (nameNode) {
342
+ defs.push({
343
+ name: nameNode.text,
344
+ kind: 'function',
345
+ line: child.startPosition.row,
346
+ exported: isExported(child),
347
+ });
348
+ }
349
+ }
350
+ else if (child.type === 'property_declaration') {
351
+ const varDecl = child.children.find(c => c.type === 'variable_declaration');
352
+ if (varDecl) {
353
+ const nameNode = varDecl.children.find(c => c.type === 'simple_identifier');
354
+ if (nameNode) {
355
+ defs.push({
356
+ name: nameNode.text,
357
+ kind: 'variable',
358
+ line: child.startPosition.row,
359
+ exported: isExported(child),
360
+ });
361
+ }
362
+ }
363
+ }
364
+ }
365
+ return defs;
366
+ }
367
+ // ─── Extract top-level declarations ──────────────────────────────
368
+ extractTopLevelDeclarations(root, filePath, fileUnit, units) {
369
+ for (let i = 0; i < root.childCount; i++) {
370
+ const child = root.child(i);
371
+ if (child.type === 'class_declaration') {
372
+ this.extractClass(child, filePath, fileUnit, units);
373
+ }
374
+ else if (child.type === 'object_declaration') {
375
+ this.extractObjectDeclaration(child, filePath, fileUnit, units);
376
+ }
377
+ else if (child.type === 'function_declaration') {
378
+ this.extractFunction(child, filePath, fileUnit, units);
379
+ }
380
+ }
381
+ }
382
+ // ─── Extract a class declaration ─────────────────────────────────
383
+ extractClass(classNode, filePath, parentUnit, units) {
384
+ const nameNode = classNode.children.find(c => c.type === 'type_identifier');
385
+ if (!nameNode)
386
+ return;
387
+ const className = nameNode.text;
388
+ const classId = `class:${filePath}:${className}`;
389
+ const classSource = classNode.text;
390
+ const classCalls = extractCalls(classNode);
391
+ const classComplexity = computeComplexity(classNode, classSource);
392
+ const exported = isExported(classNode);
393
+ // Determine class kind (data, sealed, enum, interface, regular)
394
+ const modifiers = classNode.children.find(c => c.type === 'modifiers');
395
+ let symbolKind = 'class';
396
+ // Check if it's an interface
397
+ if (classNode.children.some(c => c.type === 'interface')) {
398
+ symbolKind = 'interface';
399
+ }
400
+ // Check for enum_class_body
401
+ const classBody = classNode.children.find(c => c.type === 'class_body');
402
+ const enumBody = classNode.children.find(c => c.type === 'enum_class_body');
403
+ if (enumBody) {
404
+ symbolKind = 'enum';
405
+ }
406
+ const classDefs = [
407
+ {
408
+ name: className,
409
+ kind: symbolKind,
410
+ line: classNode.startPosition.row,
411
+ exported,
412
+ },
413
+ ];
414
+ // Extract primary constructor parameters as definitions
415
+ const primaryCtor = classNode.children.find(c => c.type === 'primary_constructor');
416
+ if (primaryCtor) {
417
+ for (const param of primaryCtor.children) {
418
+ if (param.type === 'class_parameter') {
419
+ const paramName = param.children.find(c => c.type === 'simple_identifier');
420
+ if (paramName) {
421
+ const hasValOrVar = param.children.some(c => c.type === 'binding_pattern_kind');
422
+ classDefs.push({
423
+ name: paramName.text,
424
+ kind: hasValOrVar ? 'variable' : 'parameter',
425
+ line: param.startPosition.row,
426
+ exported: hasValOrVar, // val/var params are effectively public properties
427
+ });
428
+ }
429
+ }
430
+ }
431
+ }
432
+ const classUnit = createCodeUnit({
433
+ id: classId,
434
+ file: filePath,
435
+ language: 'kotlin',
436
+ kind: 'class',
437
+ location: getLocation(classNode),
438
+ source: classSource,
439
+ calls: classCalls,
440
+ complexity: classComplexity,
441
+ definitions: classDefs,
442
+ parentId: parentUnit.id,
443
+ });
444
+ units.push(classUnit);
445
+ parentUnit.childIds.push(classId);
446
+ // Extract members from class body
447
+ const body = classBody ?? enumBody;
448
+ if (body) {
449
+ this.extractClassMembers(body, className, filePath, classUnit, units);
450
+ }
451
+ }
452
+ // ─── Extract an object declaration (singleton) ───────────────────
453
+ extractObjectDeclaration(objNode, filePath, parentUnit, units) {
454
+ const nameNode = objNode.children.find(c => c.type === 'type_identifier');
455
+ if (!nameNode)
456
+ return;
457
+ const objName = nameNode.text;
458
+ const objId = `class:${filePath}:${objName}`;
459
+ const objSource = objNode.text;
460
+ const objCalls = extractCalls(objNode);
461
+ const objComplexity = computeComplexity(objNode, objSource);
462
+ const exported = isExported(objNode);
463
+ const objDefs = [
464
+ {
465
+ name: objName,
466
+ kind: 'class',
467
+ line: objNode.startPosition.row,
468
+ exported,
469
+ },
470
+ ];
471
+ const objUnit = createCodeUnit({
472
+ id: objId,
473
+ file: filePath,
474
+ language: 'kotlin',
475
+ kind: 'class',
476
+ location: getLocation(objNode),
477
+ source: objSource,
478
+ calls: objCalls,
479
+ complexity: objComplexity,
480
+ definitions: objDefs,
481
+ parentId: parentUnit.id,
482
+ });
483
+ units.push(objUnit);
484
+ parentUnit.childIds.push(objId);
485
+ // Extract members from object body
486
+ const body = objNode.children.find(c => c.type === 'class_body');
487
+ if (body) {
488
+ this.extractClassMembers(body, objName, filePath, objUnit, units);
489
+ }
490
+ }
491
+ // ─── Extract members from a class/object body ───────────────────
492
+ extractClassMembers(body, className, filePath, classUnit, units) {
493
+ for (let i = 0; i < body.childCount; i++) {
494
+ const member = body.child(i);
495
+ if (member.type === 'function_declaration') {
496
+ const nameNode = member.children.find(c => c.type === 'simple_identifier');
497
+ if (!nameNode)
498
+ continue;
499
+ const methodName = nameNode.text;
500
+ const methodId = `method:${filePath}:${className}.${methodName}`;
501
+ const methodSource = member.text;
502
+ const paramsNode = member.children.find(c => c.type === 'function_value_parameters');
503
+ const paramCount = paramsNode ? countParameters(paramsNode) : 0;
504
+ const complexity = computeComplexity(member, methodSource);
505
+ complexity.parameterCount = paramCount;
506
+ const calls = extractCalls(member);
507
+ const exported = isExported(member);
508
+ const methodDefs = [
509
+ {
510
+ name: methodName,
511
+ kind: 'method',
512
+ line: member.startPosition.row,
513
+ exported,
514
+ },
515
+ ];
516
+ // Extract parameter definitions
517
+ if (paramsNode) {
518
+ for (const param of paramsNode.children) {
519
+ if (param.type === 'parameter') {
520
+ const paramName = param.children.find(c => c.type === 'simple_identifier');
521
+ if (paramName) {
522
+ methodDefs.push({
523
+ name: paramName.text,
524
+ kind: 'parameter',
525
+ line: param.startPosition.row,
526
+ exported: false,
527
+ });
528
+ }
529
+ }
530
+ }
531
+ }
532
+ const methodUnit = createCodeUnit({
533
+ id: methodId,
534
+ file: filePath,
535
+ language: 'kotlin',
536
+ kind: 'method',
537
+ location: getLocation(member),
538
+ source: methodSource,
539
+ calls,
540
+ complexity,
541
+ definitions: methodDefs,
542
+ parentId: classUnit.id,
543
+ });
544
+ units.push(methodUnit);
545
+ classUnit.childIds.push(methodId);
546
+ }
547
+ else if (member.type === 'companion_object') {
548
+ // Extract companion object as a nested class-like unit
549
+ const companionName = `${className}.Companion`;
550
+ const companionId = `class:${filePath}:${companionName}`;
551
+ const companionSource = member.text;
552
+ const companionCalls = extractCalls(member);
553
+ const companionComplexity = computeComplexity(member, companionSource);
554
+ const companionDefs = [
555
+ {
556
+ name: 'Companion',
557
+ kind: 'class',
558
+ line: member.startPosition.row,
559
+ exported: true,
560
+ },
561
+ ];
562
+ const companionUnit = createCodeUnit({
563
+ id: companionId,
564
+ file: filePath,
565
+ language: 'kotlin',
566
+ kind: 'class',
567
+ location: getLocation(member),
568
+ source: companionSource,
569
+ calls: companionCalls,
570
+ complexity: companionComplexity,
571
+ definitions: companionDefs,
572
+ parentId: classUnit.id,
573
+ });
574
+ units.push(companionUnit);
575
+ classUnit.childIds.push(companionId);
576
+ // Extract functions inside companion object body
577
+ const companionBody = member.children.find(c => c.type === 'class_body');
578
+ if (companionBody) {
579
+ this.extractClassMembers(companionBody, companionName, filePath, companionUnit, units);
580
+ }
581
+ }
582
+ else if (member.type === 'property_declaration') {
583
+ // Properties add to the parent class definitions
584
+ const varDecl = member.children.find(c => c.type === 'variable_declaration');
585
+ if (varDecl) {
586
+ const nameNode = varDecl.children.find(c => c.type === 'simple_identifier');
587
+ if (nameNode) {
588
+ classUnit.definitions.push({
589
+ name: nameNode.text,
590
+ kind: 'variable',
591
+ line: member.startPosition.row,
592
+ exported: isExported(member),
593
+ });
594
+ }
595
+ }
596
+ }
597
+ }
598
+ }
599
+ // ─── Extract top-level functions ─────────────────────────────────
600
+ extractFunction(funcNode, filePath, parentUnit, units) {
601
+ const nameNode = funcNode.children.find(c => c.type === 'simple_identifier');
602
+ if (!nameNode)
603
+ return;
604
+ const funcName = nameNode.text;
605
+ // Check if it's an extension function
606
+ // Extension functions have a user_type (receiver) before the dot before the name
607
+ const dotIndex = funcNode.children.findIndex(c => c.text === '.');
608
+ let receiverType;
609
+ if (dotIndex > 0) {
610
+ const possibleReceiver = funcNode.children[dotIndex - 1];
611
+ if (possibleReceiver && possibleReceiver.type === 'user_type') {
612
+ receiverType = possibleReceiver.text;
613
+ }
614
+ }
615
+ const funcId = receiverType
616
+ ? `func:${filePath}:${receiverType}.${funcName}`
617
+ : `func:${filePath}:${funcName}`;
618
+ const funcSource = funcNode.text;
619
+ const paramsNode = funcNode.children.find(c => c.type === 'function_value_parameters');
620
+ const paramCount = paramsNode ? countParameters(paramsNode) : 0;
621
+ const complexity = computeComplexity(funcNode, funcSource);
622
+ complexity.parameterCount = paramCount;
623
+ const calls = extractCalls(funcNode);
624
+ const exported = isExported(funcNode);
625
+ const funcDefs = [
626
+ {
627
+ name: funcName,
628
+ kind: 'function',
629
+ line: funcNode.startPosition.row,
630
+ exported,
631
+ },
632
+ ];
633
+ // Extract parameter definitions
634
+ if (paramsNode) {
635
+ for (const param of paramsNode.children) {
636
+ if (param.type === 'parameter') {
637
+ const paramName = param.children.find(c => c.type === 'simple_identifier');
638
+ if (paramName) {
639
+ funcDefs.push({
640
+ name: paramName.text,
641
+ kind: 'parameter',
642
+ line: param.startPosition.row,
643
+ exported: false,
644
+ });
645
+ }
646
+ }
647
+ }
648
+ }
649
+ const funcUnit = createCodeUnit({
650
+ id: funcId,
651
+ file: filePath,
652
+ language: 'kotlin',
653
+ kind: 'function',
654
+ location: getLocation(funcNode),
655
+ source: funcSource,
656
+ calls,
657
+ complexity,
658
+ definitions: funcDefs,
659
+ parentId: parentUnit.id,
660
+ });
661
+ units.push(funcUnit);
662
+ parentUnit.childIds.push(funcId);
663
+ }
664
+ }
665
+ //# sourceMappingURL=kotlin.js.map