@optave/codegraph 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1303) hide show
  1. package/README.md +31 -28
  2. package/dist/ast-analysis/engine.d.ts +15 -13
  3. package/dist/ast-analysis/engine.d.ts.map +1 -1
  4. package/dist/ast-analysis/engine.js +40 -26
  5. package/dist/ast-analysis/engine.js.map +1 -1
  6. package/dist/ast-analysis/metrics.d.ts +4 -18
  7. package/dist/ast-analysis/metrics.d.ts.map +1 -1
  8. package/dist/ast-analysis/metrics.js.map +1 -1
  9. package/dist/ast-analysis/rules/csharp.d.ts +6 -23
  10. package/dist/ast-analysis/rules/csharp.d.ts.map +1 -1
  11. package/dist/ast-analysis/rules/csharp.js +0 -3
  12. package/dist/ast-analysis/rules/csharp.js.map +1 -1
  13. package/dist/ast-analysis/rules/go.d.ts +6 -23
  14. package/dist/ast-analysis/rules/go.d.ts.map +1 -1
  15. package/dist/ast-analysis/rules/go.js +0 -3
  16. package/dist/ast-analysis/rules/go.js.map +1 -1
  17. package/dist/ast-analysis/rules/index.d.ts +6 -30
  18. package/dist/ast-analysis/rules/index.d.ts.map +1 -1
  19. package/dist/ast-analysis/rules/index.js +0 -5
  20. package/dist/ast-analysis/rules/index.js.map +1 -1
  21. package/dist/ast-analysis/rules/java.d.ts +6 -23
  22. package/dist/ast-analysis/rules/java.d.ts.map +1 -1
  23. package/dist/ast-analysis/rules/java.js +0 -3
  24. package/dist/ast-analysis/rules/java.js.map +1 -1
  25. package/dist/ast-analysis/rules/javascript.d.ts +6 -30
  26. package/dist/ast-analysis/rules/javascript.d.ts.map +1 -1
  27. package/dist/ast-analysis/rules/javascript.js +0 -5
  28. package/dist/ast-analysis/rules/javascript.js.map +1 -1
  29. package/dist/ast-analysis/rules/php.d.ts +6 -23
  30. package/dist/ast-analysis/rules/php.d.ts.map +1 -1
  31. package/dist/ast-analysis/rules/php.js +0 -3
  32. package/dist/ast-analysis/rules/php.js.map +1 -1
  33. package/dist/ast-analysis/rules/python.d.ts +6 -23
  34. package/dist/ast-analysis/rules/python.d.ts.map +1 -1
  35. package/dist/ast-analysis/rules/python.js +0 -3
  36. package/dist/ast-analysis/rules/python.js.map +1 -1
  37. package/dist/ast-analysis/rules/ruby.d.ts +6 -23
  38. package/dist/ast-analysis/rules/ruby.d.ts.map +1 -1
  39. package/dist/ast-analysis/rules/ruby.js +0 -3
  40. package/dist/ast-analysis/rules/ruby.js.map +1 -1
  41. package/dist/ast-analysis/rules/rust.d.ts +6 -23
  42. package/dist/ast-analysis/rules/rust.d.ts.map +1 -1
  43. package/dist/ast-analysis/rules/rust.js +0 -3
  44. package/dist/ast-analysis/rules/rust.js.map +1 -1
  45. package/dist/ast-analysis/shared.d.ts +11 -105
  46. package/dist/ast-analysis/shared.d.ts.map +1 -1
  47. package/dist/ast-analysis/shared.js +1 -27
  48. package/dist/ast-analysis/shared.js.map +1 -1
  49. package/dist/ast-analysis/visitor-utils.d.ts +36 -11
  50. package/dist/ast-analysis/visitor-utils.d.ts.map +1 -1
  51. package/dist/ast-analysis/visitor-utils.js.map +1 -1
  52. package/dist/ast-analysis/visitor.d.ts +2 -94
  53. package/dist/ast-analysis/visitor.d.ts.map +1 -1
  54. package/dist/ast-analysis/visitor.js +0 -16
  55. package/dist/ast-analysis/visitor.js.map +1 -1
  56. package/dist/ast-analysis/visitors/ast-store-visitor.d.ts +2 -10
  57. package/dist/ast-analysis/visitors/ast-store-visitor.d.ts.map +1 -1
  58. package/dist/ast-analysis/visitors/ast-store-visitor.js +10 -20
  59. package/dist/ast-analysis/visitors/ast-store-visitor.js.map +1 -1
  60. package/dist/ast-analysis/visitors/cfg-visitor.d.ts +4 -7
  61. package/dist/ast-analysis/visitors/cfg-visitor.d.ts.map +1 -1
  62. package/dist/ast-analysis/visitors/cfg-visitor.js +20 -65
  63. package/dist/ast-analysis/visitors/cfg-visitor.js.map +1 -1
  64. package/dist/ast-analysis/visitors/complexity-visitor.d.ts +6 -15
  65. package/dist/ast-analysis/visitors/complexity-visitor.d.ts.map +1 -1
  66. package/dist/ast-analysis/visitors/complexity-visitor.js +6 -41
  67. package/dist/ast-analysis/visitors/complexity-visitor.js.map +1 -1
  68. package/dist/ast-analysis/visitors/dataflow-visitor.d.ts +4 -7
  69. package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -1
  70. package/dist/ast-analysis/visitors/dataflow-visitor.js +19 -33
  71. package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -1
  72. package/dist/cli/commands/ast.d.ts +2 -8
  73. package/dist/cli/commands/ast.d.ts.map +1 -1
  74. package/dist/cli/commands/ast.js.map +1 -1
  75. package/dist/cli/commands/audit.d.ts +2 -8
  76. package/dist/cli/commands/audit.d.ts.map +1 -1
  77. package/dist/cli/commands/audit.js.map +1 -1
  78. package/dist/cli/commands/batch.d.ts +2 -8
  79. package/dist/cli/commands/batch.d.ts.map +1 -1
  80. package/dist/cli/commands/batch.js +9 -3
  81. package/dist/cli/commands/batch.js.map +1 -1
  82. package/dist/cli/commands/branch-compare.d.ts +2 -6
  83. package/dist/cli/commands/branch-compare.d.ts.map +1 -1
  84. package/dist/cli/commands/branch-compare.js +1 -1
  85. package/dist/cli/commands/branch-compare.js.map +1 -1
  86. package/dist/cli/commands/brief.d.ts +2 -6
  87. package/dist/cli/commands/brief.d.ts.map +1 -1
  88. package/dist/cli/commands/brief.js.map +1 -1
  89. package/dist/cli/commands/build.d.ts +2 -6
  90. package/dist/cli/commands/build.d.ts.map +1 -1
  91. package/dist/cli/commands/build.js +2 -2
  92. package/dist/cli/commands/build.js.map +1 -1
  93. package/dist/cli/commands/cfg.d.ts +2 -9
  94. package/dist/cli/commands/cfg.d.ts.map +1 -1
  95. package/dist/cli/commands/cfg.js.map +1 -1
  96. package/dist/cli/commands/check.d.ts +2 -7
  97. package/dist/cli/commands/check.d.ts.map +1 -1
  98. package/dist/cli/commands/check.js.map +1 -1
  99. package/dist/cli/commands/children.d.ts +2 -8
  100. package/dist/cli/commands/children.d.ts.map +1 -1
  101. package/dist/cli/commands/children.js.map +1 -1
  102. package/dist/cli/commands/co-change.d.ts +2 -6
  103. package/dist/cli/commands/co-change.d.ts.map +1 -1
  104. package/dist/cli/commands/co-change.js +9 -5
  105. package/dist/cli/commands/co-change.js.map +1 -1
  106. package/dist/cli/commands/communities.d.ts +2 -7
  107. package/dist/cli/commands/communities.d.ts.map +1 -1
  108. package/dist/cli/commands/communities.js.map +1 -1
  109. package/dist/cli/commands/complexity.d.ts +2 -8
  110. package/dist/cli/commands/complexity.d.ts.map +1 -1
  111. package/dist/cli/commands/complexity.js.map +1 -1
  112. package/dist/cli/commands/context.d.ts +2 -9
  113. package/dist/cli/commands/context.d.ts.map +1 -1
  114. package/dist/cli/commands/context.js.map +1 -1
  115. package/dist/cli/commands/cycles.d.ts +2 -6
  116. package/dist/cli/commands/cycles.d.ts.map +1 -1
  117. package/dist/cli/commands/cycles.js.map +1 -1
  118. package/dist/cli/commands/dataflow.d.ts +2 -9
  119. package/dist/cli/commands/dataflow.d.ts.map +1 -1
  120. package/dist/cli/commands/dataflow.js.map +1 -1
  121. package/dist/cli/commands/deps.d.ts +2 -7
  122. package/dist/cli/commands/deps.d.ts.map +1 -1
  123. package/dist/cli/commands/deps.js.map +1 -1
  124. package/dist/cli/commands/diff-impact.d.ts +2 -6
  125. package/dist/cli/commands/diff-impact.d.ts.map +1 -1
  126. package/dist/cli/commands/diff-impact.js.map +1 -1
  127. package/dist/cli/commands/embed.d.ts +2 -7
  128. package/dist/cli/commands/embed.d.ts.map +1 -1
  129. package/dist/cli/commands/embed.js +2 -1
  130. package/dist/cli/commands/embed.js.map +1 -1
  131. package/dist/cli/commands/export.d.ts +2 -6
  132. package/dist/cli/commands/export.d.ts.map +1 -1
  133. package/dist/cli/commands/export.js.map +1 -1
  134. package/dist/cli/commands/exports.d.ts +2 -7
  135. package/dist/cli/commands/exports.d.ts.map +1 -1
  136. package/dist/cli/commands/exports.js.map +1 -1
  137. package/dist/cli/commands/flow.d.ts +2 -9
  138. package/dist/cli/commands/flow.d.ts.map +1 -1
  139. package/dist/cli/commands/flow.js.map +1 -1
  140. package/dist/cli/commands/fn-impact.d.ts +2 -9
  141. package/dist/cli/commands/fn-impact.d.ts.map +1 -1
  142. package/dist/cli/commands/fn-impact.js.map +1 -1
  143. package/dist/cli/commands/impact.d.ts +2 -6
  144. package/dist/cli/commands/impact.d.ts.map +1 -1
  145. package/dist/cli/commands/impact.js.map +1 -1
  146. package/dist/cli/commands/implementations.d.ts +2 -9
  147. package/dist/cli/commands/implementations.d.ts.map +1 -1
  148. package/dist/cli/commands/implementations.js.map +1 -1
  149. package/dist/cli/commands/info.d.ts +2 -5
  150. package/dist/cli/commands/info.d.ts.map +1 -1
  151. package/dist/cli/commands/info.js +2 -1
  152. package/dist/cli/commands/info.js.map +1 -1
  153. package/dist/cli/commands/interfaces.d.ts +2 -9
  154. package/dist/cli/commands/interfaces.d.ts.map +1 -1
  155. package/dist/cli/commands/interfaces.js.map +1 -1
  156. package/dist/cli/commands/map.d.ts +2 -6
  157. package/dist/cli/commands/map.d.ts.map +1 -1
  158. package/dist/cli/commands/map.js.map +1 -1
  159. package/dist/cli/commands/mcp.d.ts +2 -6
  160. package/dist/cli/commands/mcp.d.ts.map +1 -1
  161. package/dist/cli/commands/mcp.js +4 -5
  162. package/dist/cli/commands/mcp.js.map +1 -1
  163. package/dist/cli/commands/models.d.ts +2 -5
  164. package/dist/cli/commands/models.d.ts.map +1 -1
  165. package/dist/cli/commands/models.js +5 -3
  166. package/dist/cli/commands/models.js.map +1 -1
  167. package/dist/cli/commands/owners.d.ts +2 -7
  168. package/dist/cli/commands/owners.d.ts.map +1 -1
  169. package/dist/cli/commands/owners.js.map +1 -1
  170. package/dist/cli/commands/path.d.ts +2 -7
  171. package/dist/cli/commands/path.d.ts.map +1 -1
  172. package/dist/cli/commands/path.js.map +1 -1
  173. package/dist/cli/commands/plot.d.ts +2 -6
  174. package/dist/cli/commands/plot.d.ts.map +1 -1
  175. package/dist/cli/commands/plot.js +3 -1
  176. package/dist/cli/commands/plot.js.map +1 -1
  177. package/dist/cli/commands/query.d.ts +2 -9
  178. package/dist/cli/commands/query.d.ts.map +1 -1
  179. package/dist/cli/commands/query.js.map +1 -1
  180. package/dist/cli/commands/registry.d.ts +2 -15
  181. package/dist/cli/commands/registry.d.ts.map +1 -1
  182. package/dist/cli/commands/registry.js.map +1 -1
  183. package/dist/cli/commands/roles.d.ts +2 -8
  184. package/dist/cli/commands/roles.d.ts.map +1 -1
  185. package/dist/cli/commands/roles.js.map +1 -1
  186. package/dist/cli/commands/search.d.ts +2 -8
  187. package/dist/cli/commands/search.d.ts.map +1 -1
  188. package/dist/cli/commands/search.js +1 -5
  189. package/dist/cli/commands/search.js.map +1 -1
  190. package/dist/cli/commands/sequence.d.ts +2 -9
  191. package/dist/cli/commands/sequence.d.ts.map +1 -1
  192. package/dist/cli/commands/sequence.js.map +1 -1
  193. package/dist/cli/commands/snapshot.d.ts +2 -10
  194. package/dist/cli/commands/snapshot.d.ts.map +1 -1
  195. package/dist/cli/commands/snapshot.js.map +1 -1
  196. package/dist/cli/commands/stats.d.ts +2 -6
  197. package/dist/cli/commands/stats.d.ts.map +1 -1
  198. package/dist/cli/commands/stats.js.map +1 -1
  199. package/dist/cli/commands/structure.d.ts +2 -6
  200. package/dist/cli/commands/structure.d.ts.map +1 -1
  201. package/dist/cli/commands/structure.js.map +1 -1
  202. package/dist/cli/commands/triage.d.ts +2 -7
  203. package/dist/cli/commands/triage.d.ts.map +1 -1
  204. package/dist/cli/commands/triage.js.map +1 -1
  205. package/dist/cli/commands/watch.d.ts +2 -5
  206. package/dist/cli/commands/watch.d.ts.map +1 -1
  207. package/dist/cli/commands/watch.js +1 -1
  208. package/dist/cli/commands/watch.js.map +1 -1
  209. package/dist/cli/commands/where.d.ts +2 -8
  210. package/dist/cli/commands/where.d.ts.map +1 -1
  211. package/dist/cli/commands/where.js +1 -1
  212. package/dist/cli/commands/where.js.map +1 -1
  213. package/dist/cli/index.d.ts +8 -17
  214. package/dist/cli/index.d.ts.map +1 -1
  215. package/dist/cli/index.js +27 -7
  216. package/dist/cli/index.js.map +1 -1
  217. package/dist/cli/shared/open-graph.d.ts +4 -7
  218. package/dist/cli/shared/open-graph.d.ts.map +1 -1
  219. package/dist/cli/shared/open-graph.js +0 -4
  220. package/dist/cli/shared/open-graph.js.map +1 -1
  221. package/dist/cli/shared/options.d.ts +8 -15
  222. package/dist/cli/shared/options.d.ts.map +1 -1
  223. package/dist/cli/shared/options.js +0 -2
  224. package/dist/cli/shared/options.js.map +1 -1
  225. package/dist/cli/shared/output.d.ts +1 -1
  226. package/dist/cli/shared/output.d.ts.map +1 -1
  227. package/dist/cli/shared/output.js.map +1 -1
  228. package/dist/cli/types.d.ts +30 -0
  229. package/dist/cli/types.d.ts.map +1 -0
  230. package/dist/cli/types.js +2 -0
  231. package/dist/cli/types.js.map +1 -0
  232. package/dist/cli.d.ts.map +1 -1
  233. package/dist/cli.js +2 -1
  234. package/dist/cli.js.map +1 -1
  235. package/dist/db/connection.d.ts +15 -19
  236. package/dist/db/connection.d.ts.map +1 -1
  237. package/dist/db/connection.js +2 -10
  238. package/dist/db/connection.js.map +1 -1
  239. package/dist/db/index.d.ts +5 -4
  240. package/dist/db/index.d.ts.map +1 -1
  241. package/dist/db/index.js +1 -1
  242. package/dist/db/index.js.map +1 -1
  243. package/dist/db/migrations.d.ts +8 -5
  244. package/dist/db/migrations.d.ts.map +1 -1
  245. package/dist/db/migrations.js +6 -3
  246. package/dist/db/migrations.js.map +1 -1
  247. package/dist/db/query-builder.d.ts +28 -46
  248. package/dist/db/query-builder.d.ts.map +1 -1
  249. package/dist/db/query-builder.js +2 -21
  250. package/dist/db/query-builder.js.map +1 -1
  251. package/dist/db/repository/base.d.ts +38 -101
  252. package/dist/db/repository/base.d.ts.map +1 -1
  253. package/dist/db/repository/base.js +6 -38
  254. package/dist/db/repository/base.js.map +1 -1
  255. package/dist/db/repository/build-stmts.d.ts +7 -16
  256. package/dist/db/repository/build-stmts.d.ts.map +1 -1
  257. package/dist/db/repository/build-stmts.js +0 -17
  258. package/dist/db/repository/build-stmts.js.map +1 -1
  259. package/dist/db/repository/cached-stmt.d.ts +2 -6
  260. package/dist/db/repository/cached-stmt.d.ts.map +1 -1
  261. package/dist/db/repository/cached-stmt.js +0 -5
  262. package/dist/db/repository/cached-stmt.js.map +1 -1
  263. package/dist/db/repository/cfg.d.ts +21 -14
  264. package/dist/db/repository/cfg.d.ts.map +1 -1
  265. package/dist/db/repository/cfg.js +0 -11
  266. package/dist/db/repository/cfg.js.map +1 -1
  267. package/dist/db/repository/cochange.d.ts +4 -10
  268. package/dist/db/repository/cochange.d.ts.map +1 -1
  269. package/dist/db/repository/cochange.js +0 -7
  270. package/dist/db/repository/cochange.js.map +1 -1
  271. package/dist/db/repository/complexity.d.ts +2 -10
  272. package/dist/db/repository/complexity.d.ts.map +1 -1
  273. package/dist/db/repository/complexity.js +0 -3
  274. package/dist/db/repository/complexity.js.map +1 -1
  275. package/dist/db/repository/dataflow.d.ts +2 -3
  276. package/dist/db/repository/dataflow.d.ts.map +1 -1
  277. package/dist/db/repository/dataflow.js +2 -3
  278. package/dist/db/repository/dataflow.js.map +1 -1
  279. package/dist/db/repository/edges.d.ts +25 -132
  280. package/dist/db/repository/edges.d.ts.map +1 -1
  281. package/dist/db/repository/edges.js +2 -58
  282. package/dist/db/repository/edges.js.map +1 -1
  283. package/dist/db/repository/embeddings.d.ts +4 -10
  284. package/dist/db/repository/embeddings.d.ts.map +1 -1
  285. package/dist/db/repository/embeddings.js +1 -8
  286. package/dist/db/repository/embeddings.js.map +1 -1
  287. package/dist/db/repository/graph-read.d.ts +5 -28
  288. package/dist/db/repository/graph-read.d.ts.map +1 -1
  289. package/dist/db/repository/graph-read.js +0 -8
  290. package/dist/db/repository/graph-read.js.map +1 -1
  291. package/dist/db/repository/in-memory-repository.d.ts +73 -141
  292. package/dist/db/repository/in-memory-repository.d.ts.map +1 -1
  293. package/dist/db/repository/in-memory-repository.js +28 -20
  294. package/dist/db/repository/in-memory-repository.js.map +1 -1
  295. package/dist/db/repository/index.d.ts +13 -13
  296. package/dist/db/repository/index.d.ts.map +1 -1
  297. package/dist/db/repository/index.js +1 -1
  298. package/dist/db/repository/index.js.map +1 -1
  299. package/dist/db/repository/nodes.d.ts +40 -105
  300. package/dist/db/repository/nodes.d.ts.map +1 -1
  301. package/dist/db/repository/nodes.js +29 -74
  302. package/dist/db/repository/nodes.js.map +1 -1
  303. package/dist/db/repository/sqlite-repository.d.ts +48 -93
  304. package/dist/db/repository/sqlite-repository.d.ts.map +1 -1
  305. package/dist/db/repository/sqlite-repository.js +7 -2
  306. package/dist/db/repository/sqlite-repository.js.map +1 -1
  307. package/dist/domain/analysis/brief.d.ts +16 -7
  308. package/dist/domain/analysis/brief.d.ts.map +1 -1
  309. package/dist/domain/analysis/brief.js +3 -8
  310. package/dist/domain/analysis/brief.js.map +1 -1
  311. package/dist/domain/analysis/context.d.ts +240 -2
  312. package/dist/domain/analysis/context.d.ts.map +1 -1
  313. package/dist/domain/analysis/context.js +39 -32
  314. package/dist/domain/analysis/context.js.map +1 -1
  315. package/dist/domain/analysis/dependencies.d.ts +113 -37
  316. package/dist/domain/analysis/dependencies.d.ts.map +1 -1
  317. package/dist/domain/analysis/dependencies.js +20 -27
  318. package/dist/domain/analysis/dependencies.js.map +1 -1
  319. package/dist/domain/analysis/exports.d.ts +7 -1
  320. package/dist/domain/analysis/exports.d.ts.map +1 -1
  321. package/dist/domain/analysis/exports.js +48 -33
  322. package/dist/domain/analysis/exports.js.map +1 -1
  323. package/dist/domain/analysis/impact.d.ts +128 -16
  324. package/dist/domain/analysis/impact.d.ts.map +1 -1
  325. package/dist/domain/analysis/impact.js +14 -54
  326. package/dist/domain/analysis/impact.js.map +1 -1
  327. package/dist/domain/analysis/implementations.d.ts +28 -28
  328. package/dist/domain/analysis/implementations.d.ts.map +1 -1
  329. package/dist/domain/analysis/implementations.js +0 -10
  330. package/dist/domain/analysis/implementations.js.map +1 -1
  331. package/dist/domain/analysis/module-map.d.ts +44 -24
  332. package/dist/domain/analysis/module-map.d.ts.map +1 -1
  333. package/dist/domain/analysis/module-map.js +19 -7
  334. package/dist/domain/analysis/module-map.js.map +1 -1
  335. package/dist/domain/analysis/roles.d.ts +13 -1
  336. package/dist/domain/analysis/roles.d.ts.map +1 -1
  337. package/dist/domain/analysis/roles.js +10 -2
  338. package/dist/domain/analysis/roles.js.map +1 -1
  339. package/dist/domain/analysis/symbol-lookup.d.ts +120 -7
  340. package/dist/domain/analysis/symbol-lookup.d.ts.map +1 -1
  341. package/dist/domain/analysis/symbol-lookup.js +11 -7
  342. package/dist/domain/analysis/symbol-lookup.js.map +1 -1
  343. package/dist/domain/graph/builder/context.d.ts +32 -67
  344. package/dist/domain/graph/builder/context.d.ts.map +1 -1
  345. package/dist/domain/graph/builder/context.js +0 -36
  346. package/dist/domain/graph/builder/context.js.map +1 -1
  347. package/dist/domain/graph/builder/helpers.d.ts +14 -14
  348. package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
  349. package/dist/domain/graph/builder/helpers.js +62 -23
  350. package/dist/domain/graph/builder/helpers.js.map +1 -1
  351. package/dist/domain/graph/builder/incremental.d.ts +50 -13
  352. package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
  353. package/dist/domain/graph/builder/incremental.js +10 -19
  354. package/dist/domain/graph/builder/incremental.js.map +1 -1
  355. package/dist/domain/graph/builder/pipeline.d.ts +2 -7
  356. package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
  357. package/dist/domain/graph/builder/pipeline.js +21 -19
  358. package/dist/domain/graph/builder/pipeline.js.map +1 -1
  359. package/dist/domain/graph/builder/stages/build-edges.d.ts +2 -4
  360. package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
  361. package/dist/domain/graph/builder/stages/build-edges.js +6 -12
  362. package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
  363. package/dist/domain/graph/builder/stages/build-structure.d.ts +2 -4
  364. package/dist/domain/graph/builder/stages/build-structure.d.ts.map +1 -1
  365. package/dist/domain/graph/builder/stages/build-structure.js +8 -8
  366. package/dist/domain/graph/builder/stages/build-structure.js.map +1 -1
  367. package/dist/domain/graph/builder/stages/collect-files.d.ts +2 -4
  368. package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -1
  369. package/dist/domain/graph/builder/stages/collect-files.js +0 -3
  370. package/dist/domain/graph/builder/stages/collect-files.js.map +1 -1
  371. package/dist/domain/graph/builder/stages/detect-changes.d.ts +2 -4
  372. package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
  373. package/dist/domain/graph/builder/stages/detect-changes.js +38 -45
  374. package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
  375. package/dist/domain/graph/builder/stages/finalize.d.ts +2 -4
  376. package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
  377. package/dist/domain/graph/builder/stages/finalize.js +45 -26
  378. package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
  379. package/dist/domain/graph/builder/stages/insert-nodes.d.ts +2 -4
  380. package/dist/domain/graph/builder/stages/insert-nodes.d.ts.map +1 -1
  381. package/dist/domain/graph/builder/stages/insert-nodes.js +57 -33
  382. package/dist/domain/graph/builder/stages/insert-nodes.js.map +1 -1
  383. package/dist/domain/graph/builder/stages/parse-files.d.ts +2 -4
  384. package/dist/domain/graph/builder/stages/parse-files.d.ts.map +1 -1
  385. package/dist/domain/graph/builder/stages/parse-files.js +0 -3
  386. package/dist/domain/graph/builder/stages/parse-files.js.map +1 -1
  387. package/dist/domain/graph/builder/stages/resolve-imports.d.ts +5 -17
  388. package/dist/domain/graph/builder/stages/resolve-imports.d.ts.map +1 -1
  389. package/dist/domain/graph/builder/stages/resolve-imports.js +0 -22
  390. package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
  391. package/dist/domain/graph/builder/stages/run-analyses.d.ts +2 -4
  392. package/dist/domain/graph/builder/stages/run-analyses.d.ts.map +1 -1
  393. package/dist/domain/graph/builder/stages/run-analyses.js +3 -4
  394. package/dist/domain/graph/builder/stages/run-analyses.js.map +1 -1
  395. package/dist/domain/graph/builder.d.ts +3 -3
  396. package/dist/domain/graph/builder.d.ts.map +1 -1
  397. package/dist/domain/graph/builder.js.map +1 -1
  398. package/dist/domain/graph/change-journal.d.ts +39 -46
  399. package/dist/domain/graph/change-journal.d.ts.map +1 -1
  400. package/dist/domain/graph/change-journal.js +1 -24
  401. package/dist/domain/graph/change-journal.js.map +1 -1
  402. package/dist/domain/graph/cycles.d.ts +10 -17
  403. package/dist/domain/graph/cycles.d.ts.map +1 -1
  404. package/dist/domain/graph/cycles.js +4 -24
  405. package/dist/domain/graph/cycles.js.map +1 -1
  406. package/dist/domain/graph/journal.d.ts +13 -25
  407. package/dist/domain/graph/journal.d.ts.map +1 -1
  408. package/dist/domain/graph/journal.js +0 -14
  409. package/dist/domain/graph/journal.js.map +1 -1
  410. package/dist/domain/graph/resolve.d.ts +20 -25
  411. package/dist/domain/graph/resolve.d.ts.map +1 -1
  412. package/dist/domain/graph/resolve.js +62 -9
  413. package/dist/domain/graph/resolve.js.map +1 -1
  414. package/dist/domain/graph/watcher.d.ts +3 -1
  415. package/dist/domain/graph/watcher.d.ts.map +1 -1
  416. package/dist/domain/graph/watcher.js +14 -6
  417. package/dist/domain/graph/watcher.js.map +1 -1
  418. package/dist/domain/parser.d.ts +26 -72
  419. package/dist/domain/parser.d.ts.map +1 -1
  420. package/dist/domain/parser.js +38 -46
  421. package/dist/domain/parser.js.map +1 -1
  422. package/dist/domain/queries.d.ts +20 -13
  423. package/dist/domain/queries.d.ts.map +1 -1
  424. package/dist/domain/queries.js +1 -1
  425. package/dist/domain/queries.js.map +1 -1
  426. package/dist/domain/search/generator.d.ts +5 -9
  427. package/dist/domain/search/generator.d.ts.map +1 -1
  428. package/dist/domain/search/generator.js +4 -8
  429. package/dist/domain/search/generator.js.map +1 -1
  430. package/dist/domain/search/index.d.ts +14 -7
  431. package/dist/domain/search/index.d.ts.map +1 -1
  432. package/dist/domain/search/index.js.map +1 -1
  433. package/dist/domain/search/models.d.ts +17 -60
  434. package/dist/domain/search/models.d.ts.map +1 -1
  435. package/dist/domain/search/models.js +13 -9
  436. package/dist/domain/search/models.js.map +1 -1
  437. package/dist/domain/search/search/cli-formatter.d.ts +9 -5
  438. package/dist/domain/search/search/cli-formatter.d.ts.map +1 -1
  439. package/dist/domain/search/search/cli-formatter.js +4 -10
  440. package/dist/domain/search/search/cli-formatter.js.map +1 -1
  441. package/dist/domain/search/search/filters.d.ts +8 -18
  442. package/dist/domain/search/search/filters.d.ts.map +1 -1
  443. package/dist/domain/search/search/filters.js +0 -17
  444. package/dist/domain/search/search/filters.js.map +1 -1
  445. package/dist/domain/search/search/hybrid.d.ts +20 -21
  446. package/dist/domain/search/search/hybrid.d.ts.map +1 -1
  447. package/dist/domain/search/search/hybrid.js +2 -13
  448. package/dist/domain/search/search/hybrid.js.map +1 -1
  449. package/dist/domain/search/search/keyword.d.ts +13 -12
  450. package/dist/domain/search/search/keyword.d.ts.map +1 -1
  451. package/dist/domain/search/search/keyword.js +2 -10
  452. package/dist/domain/search/search/keyword.js.map +1 -1
  453. package/dist/domain/search/search/prepare.d.ts +23 -11
  454. package/dist/domain/search/search/prepare.d.ts.map +1 -1
  455. package/dist/domain/search/search/prepare.js +0 -7
  456. package/dist/domain/search/search/prepare.js.map +1 -1
  457. package/dist/domain/search/search/semantic.d.ts +36 -29
  458. package/dist/domain/search/search/semantic.d.ts.map +1 -1
  459. package/dist/domain/search/search/semantic.js +3 -17
  460. package/dist/domain/search/search/semantic.js.map +1 -1
  461. package/dist/domain/search/stores/fts5.d.ts +3 -4
  462. package/dist/domain/search/stores/fts5.d.ts.map +1 -1
  463. package/dist/domain/search/stores/fts5.js +1 -5
  464. package/dist/domain/search/stores/fts5.js.map +1 -1
  465. package/dist/domain/search/stores/sqlite-blob.d.ts +1 -23
  466. package/dist/domain/search/stores/sqlite-blob.d.ts.map +1 -1
  467. package/dist/domain/search/stores/sqlite-blob.js +3 -9
  468. package/dist/domain/search/stores/sqlite-blob.js.map +1 -1
  469. package/dist/domain/search/strategies/source.d.ts +2 -1
  470. package/dist/domain/search/strategies/source.d.ts.map +1 -1
  471. package/dist/domain/search/strategies/source.js.map +1 -1
  472. package/dist/domain/search/strategies/structured.d.ts +6 -2
  473. package/dist/domain/search/strategies/structured.d.ts.map +1 -1
  474. package/dist/domain/search/strategies/structured.js +0 -5
  475. package/dist/domain/search/strategies/structured.js.map +1 -1
  476. package/dist/domain/search/strategies/text-utils.d.ts +3 -5
  477. package/dist/domain/search/strategies/text-utils.d.ts.map +1 -1
  478. package/dist/domain/search/strategies/text-utils.js +5 -7
  479. package/dist/domain/search/strategies/text-utils.js.map +1 -1
  480. package/dist/extractors/csharp.d.ts +2 -8
  481. package/dist/extractors/csharp.d.ts.map +1 -1
  482. package/dist/extractors/csharp.js +30 -19
  483. package/dist/extractors/csharp.js.map +1 -1
  484. package/dist/extractors/go.d.ts +2 -8
  485. package/dist/extractors/go.d.ts.map +1 -1
  486. package/dist/extractors/go.js +72 -10
  487. package/dist/extractors/go.js.map +1 -1
  488. package/dist/extractors/hcl.d.ts +2 -7
  489. package/dist/extractors/hcl.d.ts.map +1 -1
  490. package/dist/extractors/hcl.js +25 -16
  491. package/dist/extractors/hcl.js.map +1 -1
  492. package/dist/extractors/helpers.d.ts +7 -6
  493. package/dist/extractors/helpers.d.ts.map +1 -1
  494. package/dist/extractors/helpers.js +6 -5
  495. package/dist/extractors/helpers.js.map +1 -1
  496. package/dist/extractors/index.d.ts +9 -9
  497. package/dist/extractors/index.d.ts.map +1 -1
  498. package/dist/extractors/index.js.map +1 -1
  499. package/dist/extractors/java.d.ts +2 -8
  500. package/dist/extractors/java.d.ts.map +1 -1
  501. package/dist/extractors/java.js +7 -4
  502. package/dist/extractors/java.js.map +1 -1
  503. package/dist/extractors/javascript.d.ts +2 -75
  504. package/dist/extractors/javascript.d.ts.map +1 -1
  505. package/dist/extractors/javascript.js +62 -59
  506. package/dist/extractors/javascript.js.map +1 -1
  507. package/dist/extractors/php.d.ts +2 -8
  508. package/dist/extractors/php.d.ts.map +1 -1
  509. package/dist/extractors/php.js +13 -7
  510. package/dist/extractors/php.js.map +1 -1
  511. package/dist/extractors/python.d.ts +2 -8
  512. package/dist/extractors/python.d.ts.map +1 -1
  513. package/dist/extractors/python.js +23 -11
  514. package/dist/extractors/python.js.map +1 -1
  515. package/dist/extractors/ruby.d.ts +2 -7
  516. package/dist/extractors/ruby.d.ts.map +1 -1
  517. package/dist/extractors/ruby.js +8 -4
  518. package/dist/extractors/ruby.js.map +1 -1
  519. package/dist/extractors/rust.d.ts +2 -8
  520. package/dist/extractors/rust.d.ts.map +1 -1
  521. package/dist/extractors/rust.js +8 -5
  522. package/dist/extractors/rust.js.map +1 -1
  523. package/dist/features/ast.d.ts +59 -28
  524. package/dist/features/ast.d.ts.map +1 -1
  525. package/dist/features/ast.js +14 -53
  526. package/dist/features/ast.js.map +1 -1
  527. package/dist/features/audit.d.ts +13 -4
  528. package/dist/features/audit.d.ts.map +1 -1
  529. package/dist/features/audit.js +12 -21
  530. package/dist/features/audit.js.map +1 -1
  531. package/dist/features/batch.d.ts +44 -100
  532. package/dist/features/batch.d.ts.map +1 -1
  533. package/dist/features/batch.js +0 -41
  534. package/dist/features/batch.js.map +1 -1
  535. package/dist/features/boundaries.d.ts +42 -60
  536. package/dist/features/boundaries.d.ts.map +1 -1
  537. package/dist/features/boundaries.js +9 -87
  538. package/dist/features/boundaries.js.map +1 -1
  539. package/dist/features/branch-compare.d.ts +69 -50
  540. package/dist/features/branch-compare.d.ts.map +1 -1
  541. package/dist/features/branch-compare.js +27 -51
  542. package/dist/features/branch-compare.js.map +1 -1
  543. package/dist/features/cfg.d.ts +70 -48
  544. package/dist/features/cfg.d.ts.map +1 -1
  545. package/dist/features/cfg.js +81 -59
  546. package/dist/features/cfg.js.map +1 -1
  547. package/dist/features/check.d.ts +75 -90
  548. package/dist/features/check.d.ts.map +1 -1
  549. package/dist/features/check.js +2 -47
  550. package/dist/features/check.js.map +1 -1
  551. package/dist/features/cochange.d.ts +47 -98
  552. package/dist/features/cochange.d.ts.map +1 -1
  553. package/dist/features/cochange.js +10 -63
  554. package/dist/features/cochange.js.map +1 -1
  555. package/dist/features/communities.d.ts +18 -34
  556. package/dist/features/communities.d.ts.map +1 -1
  557. package/dist/features/communities.js +13 -41
  558. package/dist/features/communities.js.map +1 -1
  559. package/dist/features/complexity.d.ts +64 -117
  560. package/dist/features/complexity.d.ts.map +1 -1
  561. package/dist/features/complexity.js +58 -110
  562. package/dist/features/complexity.js.map +1 -1
  563. package/dist/features/dataflow.d.ts +56 -65
  564. package/dist/features/dataflow.d.ts.map +1 -1
  565. package/dist/features/dataflow.js +24 -55
  566. package/dist/features/dataflow.js.map +1 -1
  567. package/dist/features/export.d.ts +16 -9
  568. package/dist/features/export.d.ts.map +1 -1
  569. package/dist/features/export.js +20 -16
  570. package/dist/features/export.js.map +1 -1
  571. package/dist/features/flow.d.ts +17 -45
  572. package/dist/features/flow.d.ts.map +1 -1
  573. package/dist/features/flow.js +4 -27
  574. package/dist/features/flow.js.map +1 -1
  575. package/dist/features/graph-enrichment.d.ts +43 -53
  576. package/dist/features/graph-enrichment.d.ts.map +1 -1
  577. package/dist/features/graph-enrichment.js +15 -18
  578. package/dist/features/graph-enrichment.js.map +1 -1
  579. package/dist/features/manifesto.d.ts +18 -41
  580. package/dist/features/manifesto.d.ts.map +1 -1
  581. package/dist/features/manifesto.js +22 -39
  582. package/dist/features/manifesto.js.map +1 -1
  583. package/dist/features/owners.d.ts +44 -98
  584. package/dist/features/owners.d.ts.map +1 -1
  585. package/dist/features/owners.js +2 -54
  586. package/dist/features/owners.js.map +1 -1
  587. package/dist/features/sequence.d.ts +41 -32
  588. package/dist/features/sequence.d.ts.map +1 -1
  589. package/dist/features/sequence.js +7 -36
  590. package/dist/features/sequence.js.map +1 -1
  591. package/dist/features/shared/find-nodes.d.ts +6 -10
  592. package/dist/features/shared/find-nodes.d.ts.map +1 -1
  593. package/dist/features/shared/find-nodes.js +1 -10
  594. package/dist/features/shared/find-nodes.js.map +1 -1
  595. package/dist/features/snapshot.d.ts +16 -55
  596. package/dist/features/snapshot.d.ts.map +1 -1
  597. package/dist/features/snapshot.js +2 -40
  598. package/dist/features/snapshot.js.map +1 -1
  599. package/dist/features/structure.d.ts +80 -28
  600. package/dist/features/structure.d.ts.map +1 -1
  601. package/dist/features/structure.js +64 -76
  602. package/dist/features/structure.js.map +1 -1
  603. package/dist/features/triage.d.ts +45 -11
  604. package/dist/features/triage.d.ts.map +1 -1
  605. package/dist/features/triage.js +10 -27
  606. package/dist/features/triage.js.map +1 -1
  607. package/dist/graph/algorithms/bfs.d.ts +7 -8
  608. package/dist/graph/algorithms/bfs.d.ts.map +1 -1
  609. package/dist/graph/algorithms/bfs.js +1 -4
  610. package/dist/graph/algorithms/bfs.js.map +1 -1
  611. package/dist/graph/algorithms/centrality.d.ts +6 -7
  612. package/dist/graph/algorithms/centrality.d.ts.map +1 -1
  613. package/dist/graph/algorithms/centrality.js +0 -3
  614. package/dist/graph/algorithms/centrality.js.map +1 -1
  615. package/dist/graph/algorithms/index.d.ts +6 -5
  616. package/dist/graph/algorithms/index.d.ts.map +1 -1
  617. package/dist/graph/algorithms/index.js +1 -0
  618. package/dist/graph/algorithms/index.js.map +1 -1
  619. package/dist/graph/algorithms/leiden/adapter.d.ts +37 -0
  620. package/dist/graph/algorithms/leiden/adapter.d.ts.map +1 -0
  621. package/dist/graph/algorithms/leiden/adapter.js +165 -0
  622. package/dist/graph/algorithms/leiden/adapter.js.map +1 -0
  623. package/dist/graph/algorithms/leiden/cpm.d.ts +28 -0
  624. package/dist/graph/algorithms/leiden/cpm.d.ts.map +1 -0
  625. package/dist/graph/algorithms/leiden/cpm.js +48 -0
  626. package/dist/graph/algorithms/leiden/cpm.js.map +1 -0
  627. package/dist/graph/algorithms/leiden/index.d.ts +37 -0
  628. package/dist/graph/algorithms/leiden/index.d.ts.map +1 -0
  629. package/dist/graph/algorithms/leiden/index.js +142 -0
  630. package/dist/graph/algorithms/leiden/index.js.map +1 -0
  631. package/dist/graph/algorithms/leiden/modularity.d.ts +33 -0
  632. package/dist/graph/algorithms/leiden/modularity.d.ts.map +1 -0
  633. package/dist/graph/algorithms/leiden/modularity.js +80 -0
  634. package/dist/graph/algorithms/leiden/modularity.js.map +1 -0
  635. package/dist/graph/algorithms/leiden/optimiser.d.ts +62 -0
  636. package/dist/graph/algorithms/leiden/optimiser.d.ts.map +1 -0
  637. package/dist/graph/algorithms/leiden/optimiser.js +498 -0
  638. package/dist/graph/algorithms/leiden/optimiser.js.map +1 -0
  639. package/dist/graph/algorithms/leiden/partition.d.ts +44 -0
  640. package/dist/graph/algorithms/leiden/partition.d.ts.map +1 -0
  641. package/dist/graph/algorithms/leiden/partition.js +433 -0
  642. package/dist/graph/algorithms/leiden/partition.js.map +1 -0
  643. package/dist/graph/algorithms/leiden/rng.d.ts +9 -0
  644. package/dist/graph/algorithms/leiden/rng.d.ts.map +1 -0
  645. package/dist/graph/algorithms/leiden/rng.js +17 -0
  646. package/dist/graph/algorithms/leiden/rng.js.map +1 -0
  647. package/dist/graph/algorithms/louvain.d.ts +20 -4
  648. package/dist/graph/algorithms/louvain.d.ts.map +1 -1
  649. package/dist/graph/algorithms/louvain.js +15 -14
  650. package/dist/graph/algorithms/louvain.js.map +1 -1
  651. package/dist/graph/algorithms/shortest-path.d.ts +3 -5
  652. package/dist/graph/algorithms/shortest-path.d.ts.map +1 -1
  653. package/dist/graph/algorithms/shortest-path.js +2 -5
  654. package/dist/graph/algorithms/shortest-path.js.map +1 -1
  655. package/dist/graph/algorithms/tarjan.d.ts +3 -3
  656. package/dist/graph/algorithms/tarjan.d.ts.map +1 -1
  657. package/dist/graph/algorithms/tarjan.js +1 -2
  658. package/dist/graph/algorithms/tarjan.js.map +1 -1
  659. package/dist/graph/builders/dependency.d.ts +14 -11
  660. package/dist/graph/builders/dependency.d.ts.map +1 -1
  661. package/dist/graph/builders/dependency.js +2 -6
  662. package/dist/graph/builders/dependency.js.map +1 -1
  663. package/dist/graph/builders/index.d.ts +3 -3
  664. package/dist/graph/builders/index.d.ts.map +1 -1
  665. package/dist/graph/builders/index.js.map +1 -1
  666. package/dist/graph/builders/structure.d.ts +6 -3
  667. package/dist/graph/builders/structure.d.ts.map +1 -1
  668. package/dist/graph/builders/structure.js +5 -4
  669. package/dist/graph/builders/structure.js.map +1 -1
  670. package/dist/graph/builders/temporal.d.ts +9 -6
  671. package/dist/graph/builders/temporal.d.ts.map +1 -1
  672. package/dist/graph/builders/temporal.js +1 -3
  673. package/dist/graph/builders/temporal.js.map +1 -1
  674. package/dist/graph/classifiers/index.d.ts +2 -2
  675. package/dist/graph/classifiers/index.d.ts.map +1 -1
  676. package/dist/graph/classifiers/index.js.map +1 -1
  677. package/dist/graph/classifiers/risk.d.ts +25 -35
  678. package/dist/graph/classifiers/risk.d.ts.map +1 -1
  679. package/dist/graph/classifiers/risk.js +10 -16
  680. package/dist/graph/classifiers/risk.js.map +1 -1
  681. package/dist/graph/classifiers/roles.d.ts +19 -15
  682. package/dist/graph/classifiers/roles.d.ts.map +1 -1
  683. package/dist/graph/classifiers/roles.js +4 -7
  684. package/dist/graph/classifiers/roles.js.map +1 -1
  685. package/dist/graph/index.d.ts +4 -4
  686. package/dist/graph/index.d.ts.map +1 -1
  687. package/dist/graph/index.js.map +1 -1
  688. package/dist/graph/model.d.ts +39 -37
  689. package/dist/graph/model.d.ts.map +1 -1
  690. package/dist/graph/model.js +4 -25
  691. package/dist/graph/model.js.map +1 -1
  692. package/dist/index.cjs +0 -2
  693. package/dist/index.d.ts +35 -25
  694. package/dist/index.d.ts.map +1 -1
  695. package/dist/index.js.map +1 -1
  696. package/dist/infrastructure/config.d.ts +177 -210
  697. package/dist/infrastructure/config.d.ts.map +1 -1
  698. package/dist/infrastructure/config.js +22 -10
  699. package/dist/infrastructure/config.js.map +1 -1
  700. package/dist/infrastructure/logger.d.ts +6 -6
  701. package/dist/infrastructure/logger.d.ts.map +1 -1
  702. package/dist/infrastructure/logger.js.map +1 -1
  703. package/dist/infrastructure/native.d.ts +12 -4
  704. package/dist/infrastructure/native.d.ts.map +1 -1
  705. package/dist/infrastructure/native.js +2 -2
  706. package/dist/infrastructure/native.js.map +1 -1
  707. package/dist/infrastructure/registry.d.ts +34 -22
  708. package/dist/infrastructure/registry.d.ts.map +1 -1
  709. package/dist/infrastructure/registry.js +1 -1
  710. package/dist/infrastructure/registry.js.map +1 -1
  711. package/dist/infrastructure/result-formatter.d.ts +1 -1
  712. package/dist/infrastructure/result-formatter.d.ts.map +1 -1
  713. package/dist/infrastructure/result-formatter.js.map +1 -1
  714. package/dist/infrastructure/test-filter.d.ts +3 -3
  715. package/dist/infrastructure/test-filter.d.ts.map +1 -1
  716. package/dist/infrastructure/test-filter.js.map +1 -1
  717. package/dist/infrastructure/update-check.d.ts +12 -10
  718. package/dist/infrastructure/update-check.d.ts.map +1 -1
  719. package/dist/infrastructure/update-check.js +3 -7
  720. package/dist/infrastructure/update-check.js.map +1 -1
  721. package/dist/mcp/index.d.ts +2 -2
  722. package/dist/mcp/index.d.ts.map +1 -1
  723. package/dist/mcp/index.js.map +1 -1
  724. package/dist/mcp/middleware.d.ts +13 -13
  725. package/dist/mcp/middleware.d.ts.map +1 -1
  726. package/dist/mcp/middleware.js +0 -6
  727. package/dist/mcp/middleware.js.map +1 -1
  728. package/dist/mcp/server.d.ts +21 -1
  729. package/dist/mcp/server.d.ts.map +1 -1
  730. package/dist/mcp/server.js +79 -13
  731. package/dist/mcp/server.js.map +1 -1
  732. package/dist/mcp/tool-registry.d.ts +17 -4
  733. package/dist/mcp/tool-registry.d.ts.map +1 -1
  734. package/dist/mcp/tool-registry.js +0 -3
  735. package/dist/mcp/tool-registry.js.map +1 -1
  736. package/dist/mcp/tools/ast-query.d.ts +13 -8
  737. package/dist/mcp/tools/ast-query.d.ts.map +1 -1
  738. package/dist/mcp/tools/ast-query.js.map +1 -1
  739. package/dist/mcp/tools/audit.d.ts +14 -2
  740. package/dist/mcp/tools/audit.d.ts.map +1 -1
  741. package/dist/mcp/tools/audit.js +1 -1
  742. package/dist/mcp/tools/audit.js.map +1 -1
  743. package/dist/mcp/tools/batch-query.d.ts +11 -7
  744. package/dist/mcp/tools/batch-query.d.ts.map +1 -1
  745. package/dist/mcp/tools/batch-query.js.map +1 -1
  746. package/dist/mcp/tools/branch-compare.d.ts +11 -2
  747. package/dist/mcp/tools/branch-compare.d.ts.map +1 -1
  748. package/dist/mcp/tools/branch-compare.js.map +1 -1
  749. package/dist/mcp/tools/brief.d.ts +8 -2
  750. package/dist/mcp/tools/brief.d.ts.map +1 -1
  751. package/dist/mcp/tools/brief.js.map +1 -1
  752. package/dist/mcp/tools/cfg.d.ts +13 -9
  753. package/dist/mcp/tools/cfg.d.ts.map +1 -1
  754. package/dist/mcp/tools/cfg.js +1 -1
  755. package/dist/mcp/tools/cfg.js.map +1 -1
  756. package/dist/mcp/tools/check.d.ts +19 -23
  757. package/dist/mcp/tools/check.d.ts.map +1 -1
  758. package/dist/mcp/tools/check.js +2 -2
  759. package/dist/mcp/tools/check.js.map +1 -1
  760. package/dist/mcp/tools/co-changes.d.ts +11 -9
  761. package/dist/mcp/tools/co-changes.d.ts.map +1 -1
  762. package/dist/mcp/tools/co-changes.js.map +1 -1
  763. package/dist/mcp/tools/code-owners.d.ts +11 -47
  764. package/dist/mcp/tools/code-owners.d.ts.map +1 -1
  765. package/dist/mcp/tools/code-owners.js.map +1 -1
  766. package/dist/mcp/tools/communities.d.ts +12 -7
  767. package/dist/mcp/tools/communities.d.ts.map +1 -1
  768. package/dist/mcp/tools/communities.js.map +1 -1
  769. package/dist/mcp/tools/complexity.d.ts +15 -6
  770. package/dist/mcp/tools/complexity.d.ts.map +1 -1
  771. package/dist/mcp/tools/complexity.js +0 -1
  772. package/dist/mcp/tools/complexity.js.map +1 -1
  773. package/dist/mcp/tools/context.d.ts +15 -2
  774. package/dist/mcp/tools/context.d.ts.map +1 -1
  775. package/dist/mcp/tools/context.js.map +1 -1
  776. package/dist/mcp/tools/dataflow.d.ts +14 -5
  777. package/dist/mcp/tools/dataflow.d.ts.map +1 -1
  778. package/dist/mcp/tools/dataflow.js +2 -2
  779. package/dist/mcp/tools/dataflow.js.map +1 -1
  780. package/dist/mcp/tools/diff-impact.d.ts +13 -2
  781. package/dist/mcp/tools/diff-impact.d.ts.map +1 -1
  782. package/dist/mcp/tools/diff-impact.js.map +1 -1
  783. package/dist/mcp/tools/execution-flow.d.ts +14 -16
  784. package/dist/mcp/tools/execution-flow.d.ts.map +1 -1
  785. package/dist/mcp/tools/execution-flow.js.map +1 -1
  786. package/dist/mcp/tools/export-graph.d.ts +10 -2
  787. package/dist/mcp/tools/export-graph.d.ts.map +1 -1
  788. package/dist/mcp/tools/export-graph.js +3 -1
  789. package/dist/mcp/tools/export-graph.js.map +1 -1
  790. package/dist/mcp/tools/file-deps.d.ts +10 -2
  791. package/dist/mcp/tools/file-deps.d.ts.map +1 -1
  792. package/dist/mcp/tools/file-deps.js.map +1 -1
  793. package/dist/mcp/tools/file-exports.d.ts +11 -2
  794. package/dist/mcp/tools/file-exports.d.ts.map +1 -1
  795. package/dist/mcp/tools/file-exports.js.map +1 -1
  796. package/dist/mcp/tools/find-cycles.d.ts +3 -2
  797. package/dist/mcp/tools/find-cycles.d.ts.map +1 -1
  798. package/dist/mcp/tools/find-cycles.js.map +1 -1
  799. package/dist/mcp/tools/fn-impact.d.ts +13 -2
  800. package/dist/mcp/tools/fn-impact.d.ts.map +1 -1
  801. package/dist/mcp/tools/fn-impact.js.map +1 -1
  802. package/dist/mcp/tools/impact-analysis.d.ts +8 -2
  803. package/dist/mcp/tools/impact-analysis.d.ts.map +1 -1
  804. package/dist/mcp/tools/impact-analysis.js +0 -3
  805. package/dist/mcp/tools/impact-analysis.js.map +1 -1
  806. package/dist/mcp/tools/implementations.d.ts +12 -2
  807. package/dist/mcp/tools/implementations.d.ts.map +1 -1
  808. package/dist/mcp/tools/implementations.js.map +1 -1
  809. package/dist/mcp/tools/index.d.ts +9 -2
  810. package/dist/mcp/tools/index.d.ts.map +1 -1
  811. package/dist/mcp/tools/index.js +2 -2
  812. package/dist/mcp/tools/index.js.map +1 -1
  813. package/dist/mcp/tools/interfaces.d.ts +12 -2
  814. package/dist/mcp/tools/interfaces.d.ts.map +1 -1
  815. package/dist/mcp/tools/interfaces.js.map +1 -1
  816. package/dist/mcp/tools/list-functions.d.ts +11 -2
  817. package/dist/mcp/tools/list-functions.d.ts.map +1 -1
  818. package/dist/mcp/tools/list-functions.js.map +1 -1
  819. package/dist/mcp/tools/list-repos.d.ts +7 -10
  820. package/dist/mcp/tools/list-repos.d.ts.map +1 -1
  821. package/dist/mcp/tools/list-repos.js.map +1 -1
  822. package/dist/mcp/tools/module-map.d.ts +8 -2
  823. package/dist/mcp/tools/module-map.d.ts.map +1 -1
  824. package/dist/mcp/tools/module-map.js.map +1 -1
  825. package/dist/mcp/tools/node-roles.d.ts +11 -2
  826. package/dist/mcp/tools/node-roles.d.ts.map +1 -1
  827. package/dist/mcp/tools/node-roles.js.map +1 -1
  828. package/dist/mcp/tools/path.d.ts +13 -2
  829. package/dist/mcp/tools/path.d.ts.map +1 -1
  830. package/dist/mcp/tools/path.js.map +1 -1
  831. package/dist/mcp/tools/query.d.ts +19 -2
  832. package/dist/mcp/tools/query.d.ts.map +1 -1
  833. package/dist/mcp/tools/query.js +1 -1
  834. package/dist/mcp/tools/query.js.map +1 -1
  835. package/dist/mcp/tools/semantic-search.d.ts +11 -45
  836. package/dist/mcp/tools/semantic-search.d.ts.map +1 -1
  837. package/dist/mcp/tools/semantic-search.js +2 -2
  838. package/dist/mcp/tools/semantic-search.js.map +1 -1
  839. package/dist/mcp/tools/sequence.d.ts +15 -17
  840. package/dist/mcp/tools/sequence.d.ts.map +1 -1
  841. package/dist/mcp/tools/sequence.js +1 -1
  842. package/dist/mcp/tools/sequence.js.map +1 -1
  843. package/dist/mcp/tools/structure.d.ts +12 -2
  844. package/dist/mcp/tools/structure.d.ts.map +1 -1
  845. package/dist/mcp/tools/structure.js.map +1 -1
  846. package/dist/mcp/tools/symbol-children.d.ts +12 -2
  847. package/dist/mcp/tools/symbol-children.d.ts.map +1 -1
  848. package/dist/mcp/tools/symbol-children.js +1 -1
  849. package/dist/mcp/tools/symbol-children.js.map +1 -1
  850. package/dist/mcp/tools/triage.d.ts +16 -2
  851. package/dist/mcp/tools/triage.d.ts.map +1 -1
  852. package/dist/mcp/tools/triage.js +1 -1
  853. package/dist/mcp/tools/triage.js.map +1 -1
  854. package/dist/mcp/tools/where.d.ts +11 -2
  855. package/dist/mcp/tools/where.d.ts.map +1 -1
  856. package/dist/mcp/tools/where.js.map +1 -1
  857. package/dist/presentation/audit.d.ts +14 -4
  858. package/dist/presentation/audit.d.ts.map +1 -1
  859. package/dist/presentation/audit.js +1 -3
  860. package/dist/presentation/audit.js.map +1 -1
  861. package/dist/presentation/batch.d.ts +19 -9
  862. package/dist/presentation/batch.d.ts.map +1 -1
  863. package/dist/presentation/batch.js +3 -8
  864. package/dist/presentation/batch.js.map +1 -1
  865. package/dist/presentation/branch-compare.d.ts +12 -1
  866. package/dist/presentation/branch-compare.d.ts.map +1 -1
  867. package/dist/presentation/branch-compare.js +7 -9
  868. package/dist/presentation/branch-compare.js.map +1 -1
  869. package/dist/presentation/brief.d.ts +8 -11
  870. package/dist/presentation/brief.d.ts.map +1 -1
  871. package/dist/presentation/brief.js +0 -10
  872. package/dist/presentation/brief.js.map +1 -1
  873. package/dist/presentation/cfg.d.ts +12 -4
  874. package/dist/presentation/cfg.d.ts.map +1 -1
  875. package/dist/presentation/cfg.js +0 -3
  876. package/dist/presentation/cfg.js.map +1 -1
  877. package/dist/presentation/check.d.ts +18 -4
  878. package/dist/presentation/check.d.ts.map +1 -1
  879. package/dist/presentation/check.js +10 -4
  880. package/dist/presentation/check.js.map +1 -1
  881. package/dist/presentation/cochange.d.ts +31 -8
  882. package/dist/presentation/cochange.d.ts.map +1 -1
  883. package/dist/presentation/cochange.js +0 -6
  884. package/dist/presentation/cochange.js.map +1 -1
  885. package/dist/presentation/colors.d.ts +11 -25
  886. package/dist/presentation/colors.d.ts.map +1 -1
  887. package/dist/presentation/colors.js +3 -0
  888. package/dist/presentation/colors.js.map +1 -1
  889. package/dist/presentation/communities.d.ts +10 -4
  890. package/dist/presentation/communities.d.ts.map +1 -1
  891. package/dist/presentation/communities.js +0 -3
  892. package/dist/presentation/communities.js.map +1 -1
  893. package/dist/presentation/complexity.d.ts +16 -4
  894. package/dist/presentation/complexity.d.ts.map +1 -1
  895. package/dist/presentation/complexity.js +0 -3
  896. package/dist/presentation/complexity.js.map +1 -1
  897. package/dist/presentation/dataflow.d.ts +13 -4
  898. package/dist/presentation/dataflow.d.ts.map +1 -1
  899. package/dist/presentation/dataflow.js +12 -17
  900. package/dist/presentation/dataflow.js.map +1 -1
  901. package/dist/presentation/export.d.ts +82 -89
  902. package/dist/presentation/export.d.ts.map +1 -1
  903. package/dist/presentation/export.js +0 -63
  904. package/dist/presentation/export.js.map +1 -1
  905. package/dist/presentation/flow.d.ts +15 -4
  906. package/dist/presentation/flow.d.ts.map +1 -1
  907. package/dist/presentation/flow.js +6 -3
  908. package/dist/presentation/flow.js.map +1 -1
  909. package/dist/presentation/manifesto.d.ts +12 -4
  910. package/dist/presentation/manifesto.d.ts.map +1 -1
  911. package/dist/presentation/manifesto.js +1 -3
  912. package/dist/presentation/manifesto.js.map +1 -1
  913. package/dist/presentation/owners.d.ts +15 -4
  914. package/dist/presentation/owners.d.ts.map +1 -1
  915. package/dist/presentation/owners.js +0 -3
  916. package/dist/presentation/owners.js.map +1 -1
  917. package/dist/presentation/queries-cli/exports.d.ts +11 -1
  918. package/dist/presentation/queries-cli/exports.d.ts.map +1 -1
  919. package/dist/presentation/queries-cli/exports.js.map +1 -1
  920. package/dist/presentation/queries-cli/impact.d.ts +22 -5
  921. package/dist/presentation/queries-cli/impact.d.ts.map +1 -1
  922. package/dist/presentation/queries-cli/impact.js +2 -2
  923. package/dist/presentation/queries-cli/impact.js.map +1 -1
  924. package/dist/presentation/queries-cli/index.d.ts +5 -5
  925. package/dist/presentation/queries-cli/index.d.ts.map +1 -1
  926. package/dist/presentation/queries-cli/index.js.map +1 -1
  927. package/dist/presentation/queries-cli/inspect.d.ts +22 -7
  928. package/dist/presentation/queries-cli/inspect.d.ts.map +1 -1
  929. package/dist/presentation/queries-cli/inspect.js.map +1 -1
  930. package/dist/presentation/queries-cli/overview.d.ts +17 -3
  931. package/dist/presentation/queries-cli/overview.d.ts.map +1 -1
  932. package/dist/presentation/queries-cli/overview.js +1 -1
  933. package/dist/presentation/queries-cli/overview.js.map +1 -1
  934. package/dist/presentation/queries-cli/path.d.ts +14 -1
  935. package/dist/presentation/queries-cli/path.d.ts.map +1 -1
  936. package/dist/presentation/queries-cli/path.js.map +1 -1
  937. package/dist/presentation/queries-cli.d.ts +11 -1
  938. package/dist/presentation/queries-cli.d.ts.map +1 -1
  939. package/dist/presentation/queries-cli.js.map +1 -1
  940. package/dist/presentation/query.d.ts +1 -1
  941. package/dist/presentation/query.d.ts.map +1 -1
  942. package/dist/presentation/query.js +0 -4
  943. package/dist/presentation/query.js.map +1 -1
  944. package/dist/presentation/result-formatter.d.ts +12 -9
  945. package/dist/presentation/result-formatter.d.ts.map +1 -1
  946. package/dist/presentation/result-formatter.js +10 -35
  947. package/dist/presentation/result-formatter.js.map +1 -1
  948. package/dist/presentation/sequence-renderer.d.ts +18 -11
  949. package/dist/presentation/sequence-renderer.d.ts.map +1 -1
  950. package/dist/presentation/sequence-renderer.js +2 -15
  951. package/dist/presentation/sequence-renderer.js.map +1 -1
  952. package/dist/presentation/sequence.d.ts +14 -4
  953. package/dist/presentation/sequence.d.ts.map +1 -1
  954. package/dist/presentation/sequence.js +1 -3
  955. package/dist/presentation/sequence.js.map +1 -1
  956. package/dist/presentation/structure.d.ts +44 -6
  957. package/dist/presentation/structure.d.ts.map +1 -1
  958. package/dist/presentation/structure.js +1 -1
  959. package/dist/presentation/structure.js.map +1 -1
  960. package/dist/presentation/table.d.ts +12 -16
  961. package/dist/presentation/table.d.ts.map +1 -1
  962. package/dist/presentation/table.js +0 -6
  963. package/dist/presentation/table.js.map +1 -1
  964. package/dist/presentation/triage.d.ts +18 -4
  965. package/dist/presentation/triage.d.ts.map +1 -1
  966. package/dist/presentation/triage.js +3 -5
  967. package/dist/presentation/triage.js.map +1 -1
  968. package/dist/presentation/viewer.d.ts +79 -62
  969. package/dist/presentation/viewer.d.ts.map +1 -1
  970. package/dist/presentation/viewer.js +25 -47
  971. package/dist/presentation/viewer.js.map +1 -1
  972. package/dist/shared/constants.d.ts +6 -6
  973. package/dist/shared/constants.d.ts.map +1 -1
  974. package/dist/shared/constants.js.map +1 -1
  975. package/dist/shared/errors.d.ts +21 -29
  976. package/dist/shared/errors.d.ts.map +1 -1
  977. package/dist/shared/errors.js +0 -9
  978. package/dist/shared/errors.js.map +1 -1
  979. package/dist/shared/file-utils.d.ts +22 -9
  980. package/dist/shared/file-utils.d.ts.map +1 -1
  981. package/dist/shared/file-utils.js +2 -3
  982. package/dist/shared/file-utils.js.map +1 -1
  983. package/dist/shared/generators.d.ts +47 -52
  984. package/dist/shared/generators.d.ts.map +1 -1
  985. package/dist/shared/generators.js +5 -19
  986. package/dist/shared/generators.js.map +1 -1
  987. package/dist/shared/hierarchy.d.ts +2 -1
  988. package/dist/shared/hierarchy.d.ts.map +1 -1
  989. package/dist/shared/hierarchy.js.map +1 -1
  990. package/dist/shared/kinds.d.ts +11 -10
  991. package/dist/shared/kinds.d.ts.map +1 -1
  992. package/dist/shared/kinds.js +14 -3
  993. package/dist/shared/kinds.js.map +1 -1
  994. package/dist/shared/normalize.d.ts +24 -11
  995. package/dist/shared/normalize.d.ts.map +1 -1
  996. package/dist/shared/normalize.js +1 -5
  997. package/dist/shared/normalize.js.map +1 -1
  998. package/dist/shared/paginate.d.ts +33 -59
  999. package/dist/shared/paginate.d.ts.map +1 -1
  1000. package/dist/shared/paginate.js +0 -14
  1001. package/dist/shared/paginate.js.map +1 -1
  1002. package/dist/types.d.ts +234 -15
  1003. package/dist/types.d.ts.map +1 -1
  1004. package/package.json +14 -15
  1005. package/src/ast-analysis/{engine.js → engine.ts} +151 -64
  1006. package/src/ast-analysis/{metrics.js → metrics.ts} +14 -4
  1007. package/src/ast-analysis/rules/{csharp.js → csharp.ts} +11 -9
  1008. package/src/ast-analysis/rules/{go.js → go.ts} +12 -10
  1009. package/src/ast-analysis/rules/{index.js → index.ts} +14 -14
  1010. package/src/ast-analysis/rules/{java.js → java.ts} +11 -9
  1011. package/src/ast-analysis/rules/{javascript.js → javascript.ts} +11 -11
  1012. package/src/ast-analysis/rules/{php.js → php.ts} +11 -9
  1013. package/src/ast-analysis/rules/{python.js → python.ts} +11 -9
  1014. package/src/ast-analysis/rules/{ruby.js → ruby.ts} +11 -9
  1015. package/src/ast-analysis/rules/{rust.js → rust.ts} +11 -9
  1016. package/src/ast-analysis/{shared.js → shared.ts} +44 -43
  1017. package/src/ast-analysis/{visitor-utils.js → visitor-utils.ts} +49 -12
  1018. package/src/ast-analysis/{visitor.js → visitor.ts} +29 -31
  1019. package/src/ast-analysis/visitors/{ast-store-visitor.js → ast-store-visitor.ts} +44 -36
  1020. package/src/ast-analysis/visitors/{cfg-visitor.js → cfg-visitor.ts} +251 -155
  1021. package/src/ast-analysis/visitors/{complexity-visitor.js → complexity-visitor.ts} +74 -61
  1022. package/src/ast-analysis/visitors/{dataflow-visitor.js → dataflow-visitor.ts} +149 -63
  1023. package/src/cli/commands/{ast.js → ast.ts} +3 -2
  1024. package/src/cli/commands/{audit.js → audit.ts} +7 -6
  1025. package/src/cli/commands/{batch.js → batch.ts} +30 -14
  1026. package/src/cli/commands/{branch-compare.js → branch-compare.ts} +6 -4
  1027. package/src/cli/commands/{brief.js → brief.ts} +3 -2
  1028. package/src/cli/commands/{build.js → build.ts} +10 -8
  1029. package/src/cli/commands/{cfg.js → cfg.ts} +4 -3
  1030. package/src/cli/commands/{check.js → check.ts} +7 -6
  1031. package/src/cli/commands/{children.js → children.ts} +4 -3
  1032. package/src/cli/commands/{co-change.js → co-change.ts} +17 -12
  1033. package/src/cli/commands/{communities.js → communities.ts} +4 -2
  1034. package/src/cli/commands/{complexity.js → complexity.ts} +5 -4
  1035. package/src/cli/commands/{context.js → context.ts} +5 -4
  1036. package/src/cli/commands/{cycles.js → cycles.ts} +4 -3
  1037. package/src/cli/commands/{dataflow.js → dataflow.ts} +5 -4
  1038. package/src/cli/commands/{deps.js → deps.ts} +4 -3
  1039. package/src/cli/commands/{diff-impact.js → diff-impact.ts} +3 -2
  1040. package/src/cli/commands/{embed.js → embed.ts} +6 -4
  1041. package/src/cli/commands/{export.js → export.ts} +8 -7
  1042. package/src/cli/commands/{exports.js → exports.ts} +3 -2
  1043. package/src/cli/commands/{flow.js → flow.ts} +4 -3
  1044. package/src/cli/commands/{fn-impact.js → fn-impact.ts} +5 -4
  1045. package/src/cli/commands/{impact.js → impact.ts} +3 -2
  1046. package/src/cli/commands/{implementations.js → implementations.ts} +4 -3
  1047. package/src/cli/commands/{info.js → info.ts} +6 -3
  1048. package/src/cli/commands/{interfaces.js → interfaces.ts} +4 -3
  1049. package/src/cli/commands/{map.js → map.ts} +3 -2
  1050. package/src/cli/commands/{mcp.js → mcp.ts} +8 -7
  1051. package/src/cli/commands/models.ts +29 -0
  1052. package/src/cli/commands/{owners.js → owners.ts} +3 -2
  1053. package/src/cli/commands/{path.js → path.ts} +6 -5
  1054. package/src/cli/commands/{plot.js → plot.ts} +35 -14
  1055. package/src/cli/commands/{query.js → query.ts} +8 -7
  1056. package/src/cli/commands/{registry.js → registry.ts} +12 -6
  1057. package/src/cli/commands/{roles.js → roles.ts} +3 -2
  1058. package/src/cli/commands/{search.js → search.ts} +12 -15
  1059. package/src/cli/commands/{sequence.js → sequence.ts} +5 -4
  1060. package/src/cli/commands/{snapshot.js → snapshot.ts} +5 -4
  1061. package/src/cli/commands/{stats.js → stats.ts} +2 -1
  1062. package/src/cli/commands/{structure.js → structure.ts} +4 -2
  1063. package/src/cli/commands/{triage.js → triage.ts} +14 -13
  1064. package/src/cli/commands/{watch.js → watch.ts} +3 -2
  1065. package/src/cli/commands/{where.js → where.ts} +3 -2
  1066. package/src/cli/{index.js → index.ts} +40 -15
  1067. package/src/cli/shared/{open-graph.js → open-graph.ts} +5 -5
  1068. package/src/cli/shared/{options.js → options.ts} +6 -6
  1069. package/src/cli/types.ts +33 -0
  1070. package/src/{cli.js → cli.ts} +3 -2
  1071. package/src/db/{connection.js → connection.ts} +46 -37
  1072. package/src/db/{index.js → index.ts} +4 -0
  1073. package/src/db/{migrations.js → migrations.ts} +33 -11
  1074. package/src/db/{query-builder.js → query-builder.ts} +50 -65
  1075. package/src/db/repository/base.ts +192 -0
  1076. package/src/db/repository/{build-stmts.js → build-stmts.ts} +28 -22
  1077. package/src/db/repository/{cached-stmt.js → cached-stmt.ts} +8 -7
  1078. package/src/db/repository/{cfg.js → cfg.ts} +27 -18
  1079. package/src/db/repository/{cochange.js → cochange.ts} +8 -14
  1080. package/src/db/repository/{complexity.js → complexity.ts} +6 -5
  1081. package/src/db/repository/dataflow.ts +19 -0
  1082. package/src/db/repository/{edges.js → edges.ts} +57 -95
  1083. package/src/db/repository/{embeddings.js → embeddings.ts} +10 -14
  1084. package/src/db/repository/{graph-read.js → graph-read.ts} +17 -17
  1085. package/src/db/repository/{in-memory-repository.js → in-memory-repository.ts} +155 -93
  1086. package/src/db/repository/{index.js → index.ts} +2 -0
  1087. package/src/db/repository/{nodes.js → nodes.ts} +120 -106
  1088. package/src/db/repository/{sqlite-repository.js → sqlite-repository.ts} +71 -42
  1089. package/src/domain/analysis/{brief.js → brief.ts} +34 -19
  1090. package/src/domain/analysis/{context.js → context.ts} +179 -79
  1091. package/src/domain/analysis/{dependencies.js → dependencies.ts} +149 -61
  1092. package/src/domain/analysis/{exports.js → exports.ts} +101 -54
  1093. package/src/domain/analysis/{impact.js → impact.ts} +178 -132
  1094. package/src/domain/analysis/{implementations.js → implementations.ts} +13 -14
  1095. package/src/domain/analysis/{module-map.js → module-map.ts} +128 -61
  1096. package/src/domain/analysis/{roles.js → roles.ts} +24 -6
  1097. package/src/domain/analysis/{symbol-lookup.js → symbol-lookup.ts} +78 -34
  1098. package/src/domain/graph/builder/context.ts +81 -0
  1099. package/src/domain/graph/builder/helpers.ts +289 -0
  1100. package/src/domain/graph/builder/{incremental.js → incremental.ts} +179 -76
  1101. package/src/domain/graph/builder/{pipeline.js → pipeline.ts} +33 -27
  1102. package/src/domain/graph/builder/stages/{build-edges.js → build-edges.ts} +174 -56
  1103. package/src/domain/graph/builder/stages/{build-structure.js → build-structure.ts} +34 -17
  1104. package/src/domain/graph/builder/stages/{collect-files.js → collect-files.ts} +6 -8
  1105. package/src/domain/graph/builder/stages/{detect-changes.js → detect-changes.ts} +156 -123
  1106. package/src/domain/graph/builder/stages/{finalize.js → finalize.ts} +79 -41
  1107. package/src/domain/graph/builder/stages/{insert-nodes.js → insert-nodes.ts} +102 -47
  1108. package/src/domain/graph/builder/stages/{parse-files.js → parse-files.ts} +2 -4
  1109. package/src/domain/graph/builder/stages/{resolve-imports.js → resolve-imports.ts} +26 -39
  1110. package/src/domain/graph/builder/stages/{run-analyses.js → run-analyses.ts} +10 -7
  1111. package/src/domain/graph/{change-journal.js → change-journal.ts} +48 -37
  1112. package/src/domain/graph/cycles.ts +66 -0
  1113. package/src/domain/graph/{journal.js → journal.ts} +22 -26
  1114. package/src/domain/graph/{resolve.js → resolve.ts} +125 -35
  1115. package/src/domain/graph/{watcher.js → watcher.ts} +45 -19
  1116. package/src/domain/{parser.js → parser.ts} +151 -105
  1117. package/src/domain/{queries.js → queries.ts} +1 -1
  1118. package/src/domain/search/{generator.js → generator.ts} +28 -21
  1119. package/src/domain/search/{index.js → index.ts} +2 -0
  1120. package/src/domain/search/{models.js → models.ts} +62 -38
  1121. package/src/domain/search/search/{cli-formatter.js → cli-formatter.ts} +22 -21
  1122. package/src/domain/search/search/{filters.js → filters.ts} +7 -19
  1123. package/src/domain/search/search/{hybrid.js → hybrid.ts} +69 -25
  1124. package/src/domain/search/search/{keyword.js → keyword.ts} +42 -16
  1125. package/src/domain/search/search/{prepare.js → prepare.ts} +34 -13
  1126. package/src/domain/search/search/{semantic.js → semantic.ts} +73 -37
  1127. package/src/domain/search/stores/{fts5.js → fts5.ts} +8 -8
  1128. package/src/domain/search/stores/sqlite-blob.ts +15 -0
  1129. package/src/domain/search/strategies/{source.js → source.ts} +6 -1
  1130. package/src/domain/search/strategies/{structured.js → structured.ts} +12 -7
  1131. package/src/domain/search/strategies/{text-utils.js → text-utils.ts} +9 -11
  1132. package/src/extractors/{csharp.js → csharp.ts} +71 -42
  1133. package/src/extractors/{go.js → go.ts} +105 -30
  1134. package/src/extractors/{hcl.js → hcl.ts} +52 -27
  1135. package/src/extractors/{helpers.js → helpers.ts} +20 -15
  1136. package/src/extractors/{java.js → java.ts} +43 -24
  1137. package/src/extractors/{javascript.js → javascript.ts} +165 -133
  1138. package/src/extractors/{php.js → php.ts} +45 -32
  1139. package/src/extractors/{python.js → python.ts} +63 -36
  1140. package/src/extractors/{ruby.js → ruby.ts} +40 -25
  1141. package/src/extractors/{rust.js → rust.ts} +41 -31
  1142. package/src/features/{ast.js → ast.ts} +117 -72
  1143. package/src/features/{audit.js → audit.ts} +173 -54
  1144. package/src/features/batch.ts +182 -0
  1145. package/src/features/{boundaries.js → boundaries.ts} +101 -116
  1146. package/src/features/{branch-compare.js → branch-compare.ts} +153 -81
  1147. package/src/features/{cfg.js → cfg.ts} +230 -88
  1148. package/src/features/{check.js → check.ts} +143 -70
  1149. package/src/features/{cochange.js → cochange.ts} +117 -97
  1150. package/src/features/{communities.js → communities.ts} +85 -57
  1151. package/src/features/{complexity.js → complexity.ts} +256 -156
  1152. package/src/features/{dataflow.js → dataflow.ts} +242 -143
  1153. package/src/features/{export.js → export.ts} +164 -52
  1154. package/src/features/{flow.js → flow.ts} +63 -45
  1155. package/src/features/{graph-enrichment.js → graph-enrichment.ts} +138 -49
  1156. package/src/features/{manifesto.js → manifesto.ts} +138 -77
  1157. package/src/features/{owners.js → owners.ts} +88 -73
  1158. package/src/features/{sequence.js → sequence.ts} +114 -65
  1159. package/src/features/shared/{find-nodes.js → find-nodes.ts} +10 -13
  1160. package/src/features/{snapshot.js → snapshot.ts} +28 -47
  1161. package/src/features/{structure.js → structure.ts} +309 -130
  1162. package/src/features/{triage.js → triage.ts} +80 -42
  1163. package/src/graph/algorithms/{bfs.js → bfs.ts} +18 -10
  1164. package/src/graph/algorithms/{centrality.js → centrality.ts} +9 -5
  1165. package/src/graph/algorithms/{index.js → index.ts} +1 -0
  1166. package/src/graph/algorithms/leiden/LICENSE +24 -0
  1167. package/src/graph/algorithms/leiden/adapter.ts +204 -0
  1168. package/src/graph/algorithms/leiden/cpm.ts +77 -0
  1169. package/src/graph/algorithms/leiden/index.ts +185 -0
  1170. package/src/graph/algorithms/leiden/modularity.ts +122 -0
  1171. package/src/graph/algorithms/leiden/optimiser.ts +598 -0
  1172. package/src/graph/algorithms/leiden/partition.ts +479 -0
  1173. package/src/graph/algorithms/leiden/rng.ts +20 -0
  1174. package/src/graph/algorithms/louvain.ts +47 -0
  1175. package/src/graph/algorithms/{shortest-path.js → shortest-path.ts} +9 -10
  1176. package/src/graph/algorithms/{tarjan.js → tarjan.ts} +15 -14
  1177. package/src/graph/builders/{dependency.js → dependency.ts} +43 -17
  1178. package/src/graph/builders/structure.ts +58 -0
  1179. package/src/graph/builders/temporal.ts +51 -0
  1180. package/src/graph/classifiers/{risk.js → risk.ts} +52 -22
  1181. package/src/graph/classifiers/{roles.js → roles.ts} +32 -16
  1182. package/src/graph/{model.js → model.ts} +49 -58
  1183. package/src/index.cjs +1 -1
  1184. package/src/infrastructure/{config.js → config.ts} +82 -54
  1185. package/src/infrastructure/{logger.js → logger.ts} +6 -6
  1186. package/src/infrastructure/{native.js → native.ts} +16 -15
  1187. package/src/infrastructure/{registry.js → registry.ts} +48 -16
  1188. package/src/infrastructure/{test-filter.js → test-filter.ts} +1 -1
  1189. package/src/infrastructure/{update-check.js → update-check.ts} +30 -16
  1190. package/src/mcp/{middleware.js → middleware.ts} +6 -12
  1191. package/src/mcp/server.ts +249 -0
  1192. package/src/mcp/{tool-registry.js → tool-registry.ts} +16 -9
  1193. package/src/mcp/tools/{ast-query.js → ast-query.ts} +12 -1
  1194. package/src/mcp/tools/{audit.js → audit.ts} +14 -2
  1195. package/src/mcp/tools/batch-query.ts +22 -0
  1196. package/src/mcp/tools/{branch-compare.js → branch-compare.ts} +11 -1
  1197. package/src/mcp/tools/brief.ts +15 -0
  1198. package/src/mcp/tools/{cfg.js → cfg.ts} +13 -2
  1199. package/src/mcp/tools/{check.js → check.ts} +20 -3
  1200. package/src/mcp/tools/{co-changes.js → co-changes.ts} +10 -1
  1201. package/src/mcp/tools/code-owners.ts +22 -0
  1202. package/src/mcp/tools/{communities.js → communities.ts} +11 -1
  1203. package/src/mcp/tools/{complexity.js → complexity.ts} +14 -2
  1204. package/src/mcp/tools/{context.js → context.ts} +14 -1
  1205. package/src/mcp/tools/{dataflow.js → dataflow.ts} +15 -3
  1206. package/src/mcp/tools/{diff-impact.js → diff-impact.ts} +12 -1
  1207. package/src/mcp/tools/{execution-flow.js → execution-flow.ts} +13 -1
  1208. package/src/mcp/tools/{export-graph.js → export-graph.ts} +13 -3
  1209. package/src/mcp/tools/{file-deps.js → file-deps.ts} +9 -1
  1210. package/src/mcp/tools/{file-exports.js → file-exports.ts} +10 -1
  1211. package/src/mcp/tools/{find-cycles.js → find-cycles.ts} +5 -1
  1212. package/src/mcp/tools/{fn-impact.js → fn-impact.ts} +12 -1
  1213. package/src/mcp/tools/impact-analysis.ts +15 -0
  1214. package/src/mcp/tools/{implementations.js → implementations.ts} +11 -1
  1215. package/src/mcp/tools/{index.js → index.ts} +11 -3
  1216. package/src/mcp/tools/{interfaces.js → interfaces.ts} +11 -1
  1217. package/src/mcp/tools/{list-functions.js → list-functions.ts} +10 -1
  1218. package/src/mcp/tools/list-repos.ts +17 -0
  1219. package/src/mcp/tools/module-map.ts +13 -0
  1220. package/src/mcp/tools/{node-roles.js → node-roles.ts} +10 -1
  1221. package/src/mcp/tools/path.ts +24 -0
  1222. package/src/mcp/tools/{query.js → query.ts} +19 -2
  1223. package/src/mcp/tools/{semantic-search.js → semantic-search.ts} +13 -4
  1224. package/src/mcp/tools/{sequence.js → sequence.ts} +15 -2
  1225. package/src/mcp/tools/{structure.js → structure.ts} +11 -1
  1226. package/src/mcp/tools/symbol-children.ts +24 -0
  1227. package/src/mcp/tools/{triage.js → triage.ts} +20 -5
  1228. package/src/mcp/tools/{where.js → where.ts} +10 -1
  1229. package/src/presentation/{audit.js → audit.ts} +23 -6
  1230. package/src/presentation/batch.ts +49 -0
  1231. package/src/presentation/{branch-compare.js → branch-compare.ts} +59 -12
  1232. package/src/presentation/{brief.js → brief.ts} +26 -14
  1233. package/src/presentation/{cfg.js → cfg.ts} +37 -5
  1234. package/src/presentation/{check.js → check.ts} +61 -5
  1235. package/src/presentation/{cochange.js → cochange.ts} +30 -10
  1236. package/src/presentation/{colors.js → colors.ts} +8 -3
  1237. package/src/presentation/{communities.js → communities.ts} +45 -5
  1238. package/src/presentation/{complexity.js → complexity.ts} +49 -5
  1239. package/src/presentation/dataflow.ts +173 -0
  1240. package/src/presentation/{export.js → export.ts} +160 -95
  1241. package/src/presentation/{flow.js → flow.ts} +39 -8
  1242. package/src/presentation/{manifesto.js → manifesto.ts} +26 -7
  1243. package/src/presentation/{owners.js → owners.ts} +43 -6
  1244. package/src/presentation/queries-cli/{exports.js → exports.ts} +49 -8
  1245. package/src/presentation/queries-cli/{impact.js → impact.ts} +139 -23
  1246. package/src/presentation/queries-cli/{inspect.js → inspect.ts} +209 -28
  1247. package/src/presentation/queries-cli/{overview.js → overview.ts} +151 -30
  1248. package/src/presentation/queries-cli/{path.js → path.ts} +53 -9
  1249. package/src/presentation/{query.js → query.ts} +0 -4
  1250. package/src/presentation/{result-formatter.js → result-formatter.ts} +44 -48
  1251. package/src/presentation/sequence-renderer.ts +46 -0
  1252. package/src/presentation/{sequence.js → sequence.ts} +16 -5
  1253. package/src/presentation/{structure.js → structure.ts} +62 -5
  1254. package/src/presentation/{table.js → table.ts} +14 -8
  1255. package/src/presentation/{triage.js → triage.ts} +44 -8
  1256. package/src/presentation/{viewer.js → viewer.ts} +96 -54
  1257. package/src/shared/{constants.js → constants.ts} +4 -4
  1258. package/src/shared/{errors.js → errors.ts} +16 -20
  1259. package/src/shared/{file-utils.js → file-utils.ts} +55 -23
  1260. package/src/shared/{generators.js → generators.ts} +78 -31
  1261. package/src/shared/{hierarchy.js → hierarchy.ts} +12 -6
  1262. package/src/shared/{kinds.js → kinds.ts} +34 -12
  1263. package/src/shared/{normalize.js → normalize.ts} +37 -10
  1264. package/src/shared/{paginate.js → paginate.ts} +30 -19
  1265. package/src/types.ts +258 -17
  1266. package/src/vendor.d.ts +39 -0
  1267. package/dist/index.cjs.map +0 -1
  1268. package/dist/index.d.cts +0 -3
  1269. package/dist/index.d.cts.map +0 -1
  1270. package/src/cli/commands/models.js +0 -19
  1271. package/src/db/repository/base.js +0 -201
  1272. package/src/db/repository/dataflow.js +0 -17
  1273. package/src/domain/graph/builder/context.js +0 -85
  1274. package/src/domain/graph/builder/helpers.js +0 -218
  1275. package/src/domain/graph/cycles.js +0 -82
  1276. package/src/domain/search/stores/sqlite-blob.js +0 -24
  1277. package/src/features/batch.js +0 -156
  1278. package/src/graph/algorithms/louvain.js +0 -26
  1279. package/src/graph/builders/structure.js +0 -40
  1280. package/src/graph/builders/temporal.js +0 -33
  1281. package/src/mcp/server.js +0 -143
  1282. package/src/mcp/tools/batch-query.js +0 -11
  1283. package/src/mcp/tools/brief.js +0 -8
  1284. package/src/mcp/tools/code-owners.js +0 -12
  1285. package/src/mcp/tools/impact-analysis.js +0 -12
  1286. package/src/mcp/tools/list-repos.js +0 -11
  1287. package/src/mcp/tools/module-map.js +0 -6
  1288. package/src/mcp/tools/path.js +0 -12
  1289. package/src/mcp/tools/symbol-children.js +0 -14
  1290. package/src/presentation/batch.js +0 -26
  1291. package/src/presentation/dataflow.js +0 -110
  1292. package/src/presentation/sequence-renderer.js +0 -43
  1293. /package/src/cli/shared/{output.js → output.ts} +0 -0
  1294. /package/src/domain/graph/{builder.js → builder.ts} +0 -0
  1295. /package/src/extractors/{index.js → index.ts} +0 -0
  1296. /package/src/graph/builders/{index.js → index.ts} +0 -0
  1297. /package/src/graph/classifiers/{index.js → index.ts} +0 -0
  1298. /package/src/graph/{index.js → index.ts} +0 -0
  1299. /package/src/{index.js → index.ts} +0 -0
  1300. /package/src/infrastructure/{result-formatter.js → result-formatter.ts} +0 -0
  1301. /package/src/mcp/{index.js → index.ts} +0 -0
  1302. /package/src/presentation/queries-cli/{index.js → index.ts} +0 -0
  1303. /package/src/presentation/{queries-cli.js → queries-cli.ts} +0 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Modularity quality functions.
3
+ * Vendored from ngraph.leiden (MIT) — no external dependencies.
4
+ */
5
+ // Typed array safe-access helper (see adapter.ts for rationale)
6
+ function fget(a, i) {
7
+ return a[i];
8
+ }
9
+ function iget(a, i) {
10
+ return a[i];
11
+ }
12
+ export function diffModularity(part, g, v, c, gamma = 1.0) {
13
+ if (g.directed)
14
+ return diffModularityDirected(part, g, v, c, gamma);
15
+ const oldC = iget(part.nodeCommunity, v);
16
+ if (c === oldC)
17
+ return 0;
18
+ const k_v = fget(g.strengthOut, v);
19
+ const m2 = g.totalWeight;
20
+ const k_v_in_new = part.getNeighborEdgeWeightToCommunity(c) || 0;
21
+ const k_v_in_old = part.getNeighborEdgeWeightToCommunity(oldC) || 0;
22
+ const wTot_new = c < part.communityTotalStrength.length ? fget(part.communityTotalStrength, c) : 0;
23
+ const wTot_old = fget(part.communityTotalStrength, oldC);
24
+ const gain_remove = -(k_v_in_old / m2 - (gamma * (k_v * wTot_old)) / (m2 * m2));
25
+ const gain_add = k_v_in_new / m2 - (gamma * (k_v * wTot_new)) / (m2 * m2);
26
+ return gain_remove + gain_add;
27
+ }
28
+ export function diffModularityDirected(part, g, v, c, gamma = 1.0) {
29
+ const oldC = iget(part.nodeCommunity, v);
30
+ if (c === oldC)
31
+ return 0;
32
+ const m = g.totalWeight;
33
+ const k_out = fget(g.strengthOut, v);
34
+ const k_in = fget(g.strengthIn, v);
35
+ const w_new_in = c < g.n ? part.getInEdgeWeightFromCommunity(c) || 0 : 0;
36
+ const w_new_out = c < g.n ? part.getOutEdgeWeightToCommunity(c) || 0 : 0;
37
+ const w_old_in = part.getInEdgeWeightFromCommunity(oldC) || 0;
38
+ const w_old_out = part.getOutEdgeWeightToCommunity(oldC) || 0;
39
+ const T_new = c < part.communityTotalInStrength.length ? fget(part.communityTotalInStrength, c) : 0;
40
+ const F_new = c < part.communityTotalOutStrength.length ? fget(part.communityTotalOutStrength, c) : 0;
41
+ const T_old = fget(part.communityTotalInStrength, oldC);
42
+ const F_old = fget(part.communityTotalOutStrength, oldC);
43
+ // Self-loop correction: the self-loop edge (v->v) appears in both
44
+ // outEdgeWeightToCommunity[oldC] and inEdgeWeightFromCommunity[oldC],
45
+ // making w_old include 2x selfLoop. Since the self-loop moves with the
46
+ // node, add it back to match moveNodeToCommunity's directed accounting.
47
+ const selfW = fget(g.selfLoop, v) || 0;
48
+ const deltaInternal = (w_new_in + w_new_out - w_old_in - w_old_out + 2 * selfW) / m;
49
+ // The full delta(F*T) expansion includes a constant 2*k_out*k_in term that
50
+ // doesn't depend on the target community but does affect the move-vs-stay
51
+ // decision. Without it, coarse-level merges can appear profitable when
52
+ // they actually decrease quality.
53
+ const deltaExpected = (gamma * (k_out * (T_new - T_old) + k_in * (F_new - F_old) + 2 * k_out * k_in)) / (m * m);
54
+ return deltaInternal - deltaExpected;
55
+ }
56
+ export function qualityModularity(part, g, gamma = 1.0) {
57
+ const m2 = g.totalWeight;
58
+ let sum = 0;
59
+ if (g.directed) {
60
+ for (let c = 0; c < part.communityCount; c++)
61
+ sum +=
62
+ fget(part.communityInternalEdgeWeight, c) / m2 -
63
+ (gamma *
64
+ (fget(part.communityTotalOutStrength, c) * fget(part.communityTotalInStrength, c))) /
65
+ (m2 * m2);
66
+ }
67
+ else {
68
+ // communityInternalEdgeWeight counts each undirected edge once (j > i),
69
+ // but m2 = totalWeight = 2m (sum of symmetrized degrees). The standard
70
+ // Newman-Girvan formula is Q = sum_c [2*L_c/(2m) - gamma*(d_c/(2m))^2], so
71
+ // we multiply lc by 2 to match.
72
+ for (let c = 0; c < part.communityCount; c++) {
73
+ const lc = fget(part.communityInternalEdgeWeight, c);
74
+ const dc = fget(part.communityTotalStrength, c);
75
+ sum += (2 * lc) / m2 - (gamma * (dc * dc)) / (m2 * m2);
76
+ }
77
+ }
78
+ return sum;
79
+ }
80
+ //# sourceMappingURL=modularity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modularity.js","sourceRoot":"","sources":["../../../../src/graph/algorithms/leiden/modularity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6BH,gEAAgE;AAChE,SAAS,IAAI,CAAC,CAAe,EAAE,CAAS;IACtC,OAAO,CAAC,CAAC,CAAC,CAAW,CAAC;AACxB,CAAC;AACD,SAAS,IAAI,CAAC,CAAa,EAAE,CAAS;IACpC,OAAO,CAAC,CAAC,CAAC,CAAW,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,IAAmB,EACnB,CAAY,EACZ,CAAS,EACT,CAAS,EACT,QAAgB,GAAG;IAEnB,IAAI,CAAC,CAAC,QAAQ;QAAE,OAAO,sBAAsB,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACpE,MAAM,IAAI,GAAW,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,MAAM,GAAG,GAAW,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAW,CAAC,CAAC,WAAW,CAAC;IACjC,MAAM,UAAU,GAAW,IAAI,CAAC,gCAAgC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzE,MAAM,UAAU,GAAW,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5E,MAAM,QAAQ,GACZ,CAAC,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;IACjE,MAAM,WAAW,GAAW,CAAC,CAAC,UAAU,GAAG,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACxF,MAAM,QAAQ,GAAW,UAAU,GAAG,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClF,OAAO,WAAW,GAAG,QAAQ,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,IAAmB,EACnB,CAAY,EACZ,CAAS,EACT,CAAS,EACT,QAAgB,GAAG;IAEnB,MAAM,IAAI,GAAW,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,MAAM,CAAC,GAAW,CAAC,CAAC,WAAW,CAAC;IAChC,MAAM,KAAK,GAAW,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAW,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,SAAS,GAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAW,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,SAAS,GAAW,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,KAAK,GACT,CAAC,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,MAAM,KAAK,GACT,CAAC,GAAG,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1F,MAAM,KAAK,GAAW,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;IAChE,MAAM,KAAK,GAAW,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACjE,kEAAkE;IAClE,sEAAsE;IACtE,uEAAuE;IACvE,wEAAwE;IACxE,MAAM,KAAK,GAAW,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAW,CAAC,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5F,2EAA2E;IAC3E,0EAA0E;IAC1E,uEAAuE;IACvE,kCAAkC;IAClC,MAAM,aAAa,GACjB,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5F,OAAO,aAAa,GAAG,aAAa,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAmB,EAAE,CAAY,EAAE,QAAgB,GAAG;IACtF,MAAM,EAAE,GAAW,CAAC,CAAC,WAAW,CAAC;IACjC,IAAI,GAAG,GAAW,CAAC,CAAC;IACpB,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,EAAE;YAC1C,GAAG;gBACD,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC,GAAG,EAAE;oBAC9C,CAAC,KAAK;wBACJ,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC,CAAC;wBACnF,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,wEAAwE;QACxE,uEAAuE;QACvE,2EAA2E;QAC3E,gCAAgC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,EAAE,GAAW,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC,CAAC;YAC7D,MAAM,EAAE,GAAW,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;YACxD,GAAG,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Core Leiden/Louvain community detection optimiser.
3
+ * Vendored from ngraph.leiden (MIT) — adapted to use CodeGraph + local RNG.
4
+ */
5
+ import { CodeGraph } from '../../model.js';
6
+ import type { GraphAdapter, GraphAdapterOptions } from './adapter.js';
7
+ import type { Partition } from './partition.js';
8
+ declare const CandidateStrategy: {
9
+ readonly Neighbors: 0;
10
+ readonly All: 1;
11
+ readonly RandomAny: 2;
12
+ readonly RandomNeighbor: 3;
13
+ };
14
+ type CandidateStrategyCode = (typeof CandidateStrategy)[keyof typeof CandidateStrategy];
15
+ export interface LeidenOptions {
16
+ directed?: boolean;
17
+ randomSeed?: number;
18
+ maxLevels?: number;
19
+ maxLocalPasses?: number;
20
+ allowNewCommunity?: boolean;
21
+ candidateStrategy?: 'neighbors' | 'all' | 'random' | 'random-neighbor';
22
+ quality?: string;
23
+ resolution?: number;
24
+ refine?: boolean;
25
+ preserveLabels?: boolean | Map<number, number>;
26
+ maxCommunitySize?: number;
27
+ refinementTheta?: number;
28
+ fixedNodes?: Set<string> | string[];
29
+ linkWeight?: GraphAdapterOptions['linkWeight'];
30
+ nodeSize?: GraphAdapterOptions['nodeSize'];
31
+ baseNodeIds?: string[];
32
+ }
33
+ export interface NormalizedOptions {
34
+ directed: boolean;
35
+ randomSeed: number;
36
+ maxLevels: number;
37
+ maxLocalPasses: number;
38
+ allowNewCommunity: boolean;
39
+ candidateStrategyCode: CandidateStrategyCode;
40
+ quality: string;
41
+ resolution: number;
42
+ refine: boolean;
43
+ preserveLabels: boolean | Map<number, number> | undefined;
44
+ maxCommunitySize: number;
45
+ refinementTheta: number;
46
+ fixedNodes: Set<string> | string[] | undefined;
47
+ }
48
+ export interface LevelEntry {
49
+ graph: GraphAdapter;
50
+ partition: Partition;
51
+ }
52
+ export interface LouvainResult {
53
+ graph: GraphAdapter;
54
+ partition: Partition;
55
+ levels: LevelEntry[];
56
+ originalToCurrent: Int32Array;
57
+ originalNodeIds: string[];
58
+ baseGraph: GraphAdapter;
59
+ }
60
+ export declare function runLouvainUndirectedModularity(graph: CodeGraph, optionsInput?: LeidenOptions): LouvainResult;
61
+ export {};
62
+ //# sourceMappingURL=optimiser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimiser.d.ts","sourceRoot":"","sources":["../../../../src/graph/algorithms/leiden/optimiser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAa,YAAY,EAAE,mBAAmB,EAAe,MAAM,cAAc,CAAC;AAI9F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAUhD,QAAA,MAAM,iBAAiB;;;;;CAKb,CAAC;AAEX,KAAK,qBAAqB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAExF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,iBAAiB,CAAC;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC1D,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,iBAAiB,EAAE,UAAU,CAAC;IAC9B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,YAAY,CAAC;CACzB;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,SAAS,EAChB,YAAY,GAAE,aAAkB,GAC/B,aAAa,CA0Lf"}
@@ -0,0 +1,498 @@
1
+ /**
2
+ * Core Leiden/Louvain community detection optimiser.
3
+ * Vendored from ngraph.leiden (MIT) — adapted to use CodeGraph + local RNG.
4
+ */
5
+ import { CodeGraph } from '../../model.js';
6
+ import { makeGraphAdapter } from './adapter.js';
7
+ import { diffCPM } from './cpm.js';
8
+ import { diffModularity } from './modularity.js';
9
+ import { makePartition } from './partition.js';
10
+ import { createRng } from './rng.js';
11
+ // Mirrored in DEFAULTS.community (src/infrastructure/config.js) for user override
12
+ // via .codegraphrc.json. Callers (e.g. louvain.ts) can pass overrides through options.
13
+ const DEFAULT_MAX_LEVELS = 50;
14
+ const DEFAULT_MAX_LOCAL_PASSES = 20;
15
+ const GAIN_EPSILON = 1e-12;
16
+ const CandidateStrategy = {
17
+ Neighbors: 0,
18
+ All: 1,
19
+ RandomAny: 2,
20
+ RandomNeighbor: 3,
21
+ };
22
+ export function runLouvainUndirectedModularity(graph, optionsInput = {}) {
23
+ const options = normalizeOptions(optionsInput);
24
+ let currentGraph = graph;
25
+ const levels = [];
26
+ const rngSource = createRng(options.randomSeed);
27
+ const random = () => rngSource.nextDouble();
28
+ const baseGraphAdapter = makeGraphAdapter(currentGraph, {
29
+ directed: options.directed,
30
+ ...optionsInput,
31
+ });
32
+ const origN = baseGraphAdapter.n;
33
+ const originalToCurrent = new Int32Array(origN);
34
+ for (let i = 0; i < origN; i++)
35
+ originalToCurrent[i] = i;
36
+ let fixedNodeMask = null;
37
+ if (options.fixedNodes) {
38
+ const fixed = new Uint8Array(origN);
39
+ const asSet = options.fixedNodes instanceof Set ? options.fixedNodes : new Set(options.fixedNodes);
40
+ for (const id of asSet) {
41
+ const idx = baseGraphAdapter.idToIndex.get(String(id));
42
+ if (idx != null)
43
+ fixed[idx] = 1;
44
+ }
45
+ fixedNodeMask = fixed;
46
+ }
47
+ for (let level = 0; level < options.maxLevels; level++) {
48
+ const graphAdapter = level === 0
49
+ ? baseGraphAdapter
50
+ : makeGraphAdapter(currentGraph, { directed: options.directed, ...optionsInput });
51
+ const partition = makePartition(graphAdapter);
52
+ partition.graph = graphAdapter;
53
+ partition.initializeAggregates();
54
+ const order = new Int32Array(graphAdapter.n);
55
+ for (let i = 0; i < graphAdapter.n; i++)
56
+ order[i] = i;
57
+ let improved = true;
58
+ let localPasses = 0;
59
+ const strategyCode = options.candidateStrategyCode;
60
+ while (improved) {
61
+ improved = false;
62
+ localPasses++;
63
+ shuffleArrayInPlace(order, random);
64
+ for (let idx = 0; idx < order.length; idx++) {
65
+ const nodeIndex = order[idx];
66
+ if (level === 0 && fixedNodeMask && fixedNodeMask[nodeIndex])
67
+ continue;
68
+ const candidateCount = partition.accumulateNeighborCommunityEdgeWeights(nodeIndex);
69
+ let bestCommunityId = partition.nodeCommunity[nodeIndex];
70
+ let bestGain = 0;
71
+ const maxCommunitySize = options.maxCommunitySize;
72
+ if (strategyCode === CandidateStrategy.All) {
73
+ for (let communityId = 0; communityId < partition.communityCount; communityId++) {
74
+ if (communityId === partition.nodeCommunity[nodeIndex])
75
+ continue;
76
+ if (maxCommunitySize < Infinity &&
77
+ partition.getCommunityTotalSize(communityId) + graphAdapter.size[nodeIndex] >
78
+ maxCommunitySize)
79
+ continue;
80
+ const gain = computeQualityGain(partition, nodeIndex, communityId, options);
81
+ if (gain > bestGain) {
82
+ bestGain = gain;
83
+ bestCommunityId = communityId;
84
+ }
85
+ }
86
+ }
87
+ else if (strategyCode === CandidateStrategy.RandomAny) {
88
+ const tries = Math.min(10, Math.max(1, partition.communityCount));
89
+ for (let trialIndex = 0; trialIndex < tries; trialIndex++) {
90
+ const communityId = (random() * partition.communityCount) | 0;
91
+ if (communityId === partition.nodeCommunity[nodeIndex])
92
+ continue;
93
+ if (maxCommunitySize < Infinity &&
94
+ partition.getCommunityTotalSize(communityId) + graphAdapter.size[nodeIndex] >
95
+ maxCommunitySize)
96
+ continue;
97
+ const gain = computeQualityGain(partition, nodeIndex, communityId, options);
98
+ if (gain > bestGain) {
99
+ bestGain = gain;
100
+ bestCommunityId = communityId;
101
+ }
102
+ }
103
+ }
104
+ else if (strategyCode === CandidateStrategy.RandomNeighbor) {
105
+ const tries = Math.min(10, Math.max(1, candidateCount));
106
+ for (let trialIndex = 0; trialIndex < tries; trialIndex++) {
107
+ const communityId = partition.getCandidateCommunityAt((random() * candidateCount) | 0);
108
+ if (communityId === partition.nodeCommunity[nodeIndex])
109
+ continue;
110
+ if (maxCommunitySize < Infinity &&
111
+ partition.getCommunityTotalSize(communityId) + graphAdapter.size[nodeIndex] >
112
+ maxCommunitySize)
113
+ continue;
114
+ const gain = computeQualityGain(partition, nodeIndex, communityId, options);
115
+ if (gain > bestGain) {
116
+ bestGain = gain;
117
+ bestCommunityId = communityId;
118
+ }
119
+ }
120
+ }
121
+ else {
122
+ for (let trialIndex = 0; trialIndex < candidateCount; trialIndex++) {
123
+ const communityId = partition.getCandidateCommunityAt(trialIndex);
124
+ if (maxCommunitySize < Infinity) {
125
+ const nextSize = partition.getCommunityTotalSize(communityId) + graphAdapter.size[nodeIndex];
126
+ if (nextSize > maxCommunitySize)
127
+ continue;
128
+ }
129
+ const gain = computeQualityGain(partition, nodeIndex, communityId, options);
130
+ if (gain > bestGain) {
131
+ bestGain = gain;
132
+ bestCommunityId = communityId;
133
+ }
134
+ }
135
+ }
136
+ if (options.allowNewCommunity) {
137
+ const newCommunityId = partition.communityCount;
138
+ const gain = computeQualityGain(partition, nodeIndex, newCommunityId, options);
139
+ if (gain > bestGain) {
140
+ bestGain = gain;
141
+ bestCommunityId = newCommunityId;
142
+ }
143
+ }
144
+ if (bestCommunityId !== partition.nodeCommunity[nodeIndex] && bestGain > GAIN_EPSILON) {
145
+ partition.moveNodeToCommunity(nodeIndex, bestCommunityId);
146
+ improved = true;
147
+ }
148
+ }
149
+ if (localPasses >= options.maxLocalPasses)
150
+ break;
151
+ }
152
+ renumberCommunities(partition, options.preserveLabels);
153
+ let effectivePartition = partition;
154
+ if (options.refine) {
155
+ const refined = refineWithinCoarseCommunities(graphAdapter, partition, random, options, level === 0 ? fixedNodeMask : null);
156
+ // Post-refinement: split any disconnected communities into their
157
+ // connected components. This is the cheap O(V+E) alternative to
158
+ // checking gamma-connectedness on every candidate during refinement.
159
+ // A disconnected community violates even basic connectivity, so
160
+ // splitting is always correct.
161
+ splitDisconnectedCommunities(graphAdapter, refined);
162
+ renumberCommunities(refined, options.preserveLabels);
163
+ effectivePartition = refined;
164
+ }
165
+ levels.push({ graph: graphAdapter, partition: effectivePartition });
166
+ const fineToCoarse = effectivePartition.nodeCommunity;
167
+ for (let i = 0; i < originalToCurrent.length; i++) {
168
+ originalToCurrent[i] = fineToCoarse[originalToCurrent[i]];
169
+ }
170
+ // Terminate when no further coarsening is possible. Check both the
171
+ // move-phase partition (did the greedy phase find merges?) and the
172
+ // effective partition that feeds buildCoarseGraph (would coarsening
173
+ // actually reduce the graph?). When refine is enabled the refined
174
+ // partition starts from singletons and may have more communities than
175
+ // the move phase found, so checking only effectivePartition would
176
+ // cause premature termination.
177
+ if (partition.communityCount === graphAdapter.n &&
178
+ effectivePartition.communityCount === graphAdapter.n)
179
+ break;
180
+ currentGraph = buildCoarseGraph(graphAdapter, effectivePartition);
181
+ }
182
+ const last = levels[levels.length - 1];
183
+ return {
184
+ graph: last.graph,
185
+ partition: last.partition,
186
+ levels,
187
+ originalToCurrent,
188
+ originalNodeIds: baseGraphAdapter.nodeIds,
189
+ baseGraph: baseGraphAdapter,
190
+ };
191
+ }
192
+ // Build a coarse graph where each community becomes a single node.
193
+ // Self-loops (g.selfLoop[]) don't need separate handling here because they
194
+ // are already present in g.outEdges (directed path keeps them in both arrays).
195
+ // When the coarse graph is fed back to makeGraphAdapter at the next level,
196
+ // the adapter re-detects cu===cu edges as self-loops and populates selfLoop[].
197
+ function buildCoarseGraph(g, p) {
198
+ const coarse = new CodeGraph({ directed: g.directed });
199
+ for (let c = 0; c < p.communityCount; c++) {
200
+ coarse.addNode(String(c), { size: p.communityTotalSize[c] });
201
+ }
202
+ const acc = new Map();
203
+ for (let i = 0; i < g.n; i++) {
204
+ const cu = p.nodeCommunity[i];
205
+ const list = g.outEdges[i];
206
+ for (let k = 0; k < list.length; k++) {
207
+ const j = list[k].to;
208
+ const w = list[k].w;
209
+ const cv = p.nodeCommunity[j];
210
+ // Undirected: each non-self edge (i,j) appears in both outEdges[i] and
211
+ // outEdges[j]. For intra-community edges (cu===cv), skip the reverse to
212
+ // avoid inflating the coarse self-loop weight by 2x.
213
+ if (!g.directed && cu === cv && j < i)
214
+ continue;
215
+ const key = `${cu}:${cv}`;
216
+ acc.set(key, (acc.get(key) || 0) + w);
217
+ }
218
+ }
219
+ for (const [key, w] of acc.entries()) {
220
+ const parts = key.split(':');
221
+ coarse.addEdge(parts[0], parts[1], { weight: w });
222
+ }
223
+ return coarse;
224
+ }
225
+ /**
226
+ * True Leiden refinement phase (Algorithm 3, Traag et al. 2019).
227
+ *
228
+ * Key properties that distinguish this from Louvain-style refinement:
229
+ *
230
+ * 1. Singleton start — each node begins in its own community.
231
+ * 2. Singleton guard — only nodes still in singleton communities are
232
+ * considered for merging. Once a node joins a non-singleton community
233
+ * it is locked for the remainder of the pass. This prevents oscillation
234
+ * and is essential for the gamma-connectedness guarantee.
235
+ * 3. Single pass — one randomized sweep through all nodes, not an
236
+ * iterative loop until convergence (that would be Louvain behavior).
237
+ * 4. Probabilistic selection — candidate communities are sampled from
238
+ * a Boltzmann distribution p(v, C) proportional to exp(deltaH / theta),
239
+ * with the "stay as singleton" option (deltaH = 0) included in the
240
+ * distribution. This means a node may probabilistically choose to remain
241
+ * alone even when positive-gain merges exist.
242
+ *
243
+ * theta (refinementTheta) controls temperature: lower = more deterministic
244
+ * (approaches greedy), higher = more exploratory. Determinism is preserved
245
+ * via the seeded PRNG — same seed produces the same assignments.
246
+ */
247
+ function refineWithinCoarseCommunities(g, basePart, rng, opts, fixedMask0) {
248
+ const p = makePartition(g);
249
+ p.initializeAggregates();
250
+ p.graph = g;
251
+ const macro = basePart.nodeCommunity;
252
+ const commMacro = new Int32Array(p.communityCount);
253
+ for (let i = 0; i < p.communityCount; i++)
254
+ commMacro[i] = macro[i];
255
+ const theta = typeof opts.refinementTheta === 'number' ? opts.refinementTheta : 1.0;
256
+ if (theta <= 0)
257
+ throw new RangeError(`refinementTheta must be > 0 (got ${theta})`);
258
+ // Single pass in random order (Algorithm 3, step 2).
259
+ const order = new Int32Array(g.n);
260
+ for (let i = 0; i < g.n; i++)
261
+ order[i] = i;
262
+ shuffleArrayInPlace(order, rng);
263
+ // Pre-allocate flat arrays for candidate collection to avoid per-node GC pressure.
264
+ // Maximum possible candidates per node is bounded by g.n (community count).
265
+ const candC = new Int32Array(g.n);
266
+ const candGain = new Float64Array(g.n);
267
+ const candWeight = new Float64Array(g.n);
268
+ for (let idx = 0; idx < order.length; idx++) {
269
+ const v = order[idx];
270
+ if (fixedMask0?.[v])
271
+ continue;
272
+ // Singleton guard: only move nodes still alone in their community.
273
+ if (p.getCommunityNodeCount(p.nodeCommunity[v]) > 1)
274
+ continue;
275
+ const macroV = macro[v];
276
+ const touchedCount = p.accumulateNeighborCommunityEdgeWeights(v);
277
+ const maxSize = Number.isFinite(opts.maxCommunitySize)
278
+ ? opts.maxCommunitySize
279
+ : Infinity;
280
+ // Collect eligible communities and their quality gains.
281
+ let candLen = 0;
282
+ for (let t = 0; t < touchedCount; t++) {
283
+ const c = p.getCandidateCommunityAt(t);
284
+ if (c === p.nodeCommunity[v])
285
+ continue;
286
+ if (commMacro[c] !== macroV)
287
+ continue;
288
+ if (maxSize < Infinity) {
289
+ const nextSize = p.getCommunityTotalSize(c) + g.size[v];
290
+ if (nextSize > maxSize)
291
+ continue;
292
+ }
293
+ const gain = computeQualityGain(p, v, c, opts);
294
+ if (gain > GAIN_EPSILON) {
295
+ candC[candLen] = c;
296
+ candGain[candLen] = gain;
297
+ candLen++;
298
+ }
299
+ }
300
+ if (candLen === 0)
301
+ continue;
302
+ // Probabilistic selection: p(v, C) proportional to exp(deltaH / theta),
303
+ // with the "stay" option (deltaH = 0) included per Algorithm 3.
304
+ // For numerical stability, subtract the max gain before exponentiation.
305
+ let maxGain = 0;
306
+ for (let i = 0; i < candLen; i++) {
307
+ if (candGain[i] > maxGain)
308
+ maxGain = candGain[i];
309
+ }
310
+ // "Stay as singleton" weight: exp((0 - maxGain) / theta)
311
+ const stayWeight = Math.exp((0 - maxGain) / theta);
312
+ let totalWeight = stayWeight;
313
+ for (let i = 0; i < candLen; i++) {
314
+ candWeight[i] = Math.exp((candGain[i] - maxGain) / theta);
315
+ totalWeight += candWeight[i];
316
+ }
317
+ const r = rng() * totalWeight;
318
+ if (r < stayWeight)
319
+ continue; // node stays as singleton
320
+ let cumulative = stayWeight;
321
+ let chosenC = candC[candLen - 1]; // fallback
322
+ for (let i = 0; i < candLen; i++) {
323
+ cumulative += candWeight[i];
324
+ if (r < cumulative) {
325
+ chosenC = candC[i];
326
+ break;
327
+ }
328
+ }
329
+ p.moveNodeToCommunity(v, chosenC);
330
+ }
331
+ return p;
332
+ }
333
+ /**
334
+ * Post-refinement connectivity check. For each community, run a BFS on
335
+ * the subgraph induced by its members (using the adapter's outEdges).
336
+ * If a community has multiple connected components, assign secondary
337
+ * components to new community IDs, then reinitialize aggregates once.
338
+ *
339
+ * O(V+E) total since communities partition V.
340
+ *
341
+ * This replaces the per-candidate gamma-connectedness check from the paper
342
+ * with a cheaper post-step that catches the most important violation
343
+ * (disconnected subcommunities).
344
+ */
345
+ function splitDisconnectedCommunities(g, partition) {
346
+ const n = g.n;
347
+ const nc = partition.nodeCommunity;
348
+ const members = partition.getCommunityMembers();
349
+ let nextC = partition.communityCount;
350
+ let didSplit = false;
351
+ const visited = new Uint8Array(n);
352
+ const inCommunity = new Uint8Array(n);
353
+ for (let c = 0; c < members.length; c++) {
354
+ const nodes = members[c];
355
+ if (nodes.length <= 1)
356
+ continue;
357
+ for (let i = 0; i < nodes.length; i++)
358
+ inCommunity[nodes[i]] = 1;
359
+ let componentCount = 0;
360
+ for (let i = 0; i < nodes.length; i++) {
361
+ const start = nodes[i];
362
+ if (visited[start])
363
+ continue;
364
+ componentCount++;
365
+ // BFS within the community subgraph.
366
+ // For directed graphs, traverse both outEdges and inEdges to check
367
+ // weak connectivity (reachability ignoring edge direction).
368
+ const queue = [start];
369
+ visited[start] = 1;
370
+ let head = 0;
371
+ while (head < queue.length) {
372
+ const v = queue[head++];
373
+ const out = g.outEdges[v];
374
+ for (let k = 0; k < out.length; k++) {
375
+ const w = out[k].to;
376
+ if (inCommunity[w] && !visited[w]) {
377
+ visited[w] = 1;
378
+ queue.push(w);
379
+ }
380
+ }
381
+ if (g.directed) {
382
+ const inc = g.inEdges[v];
383
+ for (let k = 0; k < inc.length; k++) {
384
+ const w = inc[k].from;
385
+ if (inCommunity[w] && !visited[w]) {
386
+ visited[w] = 1;
387
+ queue.push(w);
388
+ }
389
+ }
390
+ }
391
+ }
392
+ if (componentCount > 1) {
393
+ // Secondary component — assign new community ID directly.
394
+ const newC = nextC++;
395
+ for (let q = 0; q < queue.length; q++)
396
+ nc[queue[q]] = newC;
397
+ didSplit = true;
398
+ }
399
+ }
400
+ for (let i = 0; i < nodes.length; i++) {
401
+ inCommunity[nodes[i]] = 0;
402
+ visited[nodes[i]] = 0;
403
+ }
404
+ }
405
+ if (didSplit) {
406
+ // Grow the partition's typed arrays to accommodate new community IDs,
407
+ // then recompute all aggregates from the updated nodeCommunity array.
408
+ partition.resizeCommunities(nextC);
409
+ partition.initializeAggregates();
410
+ }
411
+ }
412
+ function computeQualityGain(partition, v, c, opts) {
413
+ if (!partition.graph) {
414
+ throw new Error('partition.graph must be set before computeQualityGain');
415
+ }
416
+ const quality = (opts.quality || 'modularity').toLowerCase();
417
+ const gamma = typeof opts.resolution === 'number' ? opts.resolution : 1.0;
418
+ if (quality === 'cpm') {
419
+ return diffCPM(partition, partition.graph, v, c, gamma);
420
+ }
421
+ // diffModularity dispatches to diffModularityDirected internally when g.directed is true
422
+ return diffModularity(partition, partition.graph, v, c, gamma);
423
+ }
424
+ function shuffleArrayInPlace(arr, rng = Math.random) {
425
+ for (let i = arr.length - 1; i > 0; i--) {
426
+ const j = Math.floor(rng() * (i + 1));
427
+ const t = arr[i];
428
+ arr[i] = arr[j];
429
+ arr[j] = t;
430
+ }
431
+ return arr;
432
+ }
433
+ function resolveCandidateStrategy(options) {
434
+ const val = options.candidateStrategy;
435
+ if (typeof val !== 'string')
436
+ return CandidateStrategy.Neighbors;
437
+ switch (val) {
438
+ case 'neighbors':
439
+ return CandidateStrategy.Neighbors;
440
+ case 'all':
441
+ return CandidateStrategy.All;
442
+ case 'random':
443
+ return CandidateStrategy.RandomAny;
444
+ case 'random-neighbor':
445
+ return CandidateStrategy.RandomNeighbor;
446
+ default:
447
+ return CandidateStrategy.Neighbors;
448
+ }
449
+ }
450
+ function normalizeOptions(options = {}) {
451
+ const directed = !!options.directed;
452
+ const randomSeed = Number.isFinite(options.randomSeed)
453
+ ? options.randomSeed
454
+ : 42;
455
+ const maxLevels = Number.isFinite(options.maxLevels)
456
+ ? options.maxLevels
457
+ : DEFAULT_MAX_LEVELS;
458
+ const maxLocalPasses = Number.isFinite(options.maxLocalPasses)
459
+ ? options.maxLocalPasses
460
+ : DEFAULT_MAX_LOCAL_PASSES;
461
+ const allowNewCommunity = !!options.allowNewCommunity;
462
+ const candidateStrategyCode = resolveCandidateStrategy(options);
463
+ const quality = (options.quality || 'modularity').toLowerCase();
464
+ const resolution = typeof options.resolution === 'number' ? options.resolution : 1.0;
465
+ const refine = options.refine !== false;
466
+ const preserveLabels = options.preserveLabels;
467
+ const maxCommunitySize = Number.isFinite(options.maxCommunitySize)
468
+ ? options.maxCommunitySize
469
+ : Infinity;
470
+ const refinementTheta = typeof options.refinementTheta === 'number' ? options.refinementTheta : 1.0;
471
+ return {
472
+ directed,
473
+ randomSeed,
474
+ maxLevels,
475
+ maxLocalPasses,
476
+ allowNewCommunity,
477
+ candidateStrategyCode,
478
+ quality,
479
+ resolution,
480
+ refine,
481
+ preserveLabels,
482
+ maxCommunitySize,
483
+ refinementTheta,
484
+ fixedNodes: options.fixedNodes,
485
+ };
486
+ }
487
+ function renumberCommunities(partition, preserveLabels) {
488
+ if (preserveLabels && preserveLabels instanceof Map) {
489
+ partition.compactCommunityIds({ preserveMap: preserveLabels });
490
+ }
491
+ else if (preserveLabels === true) {
492
+ partition.compactCommunityIds({ keepOldOrder: true });
493
+ }
494
+ else {
495
+ partition.compactCommunityIds();
496
+ }
497
+ }
498
+ //# sourceMappingURL=optimiser.js.map