@optave/codegraph 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +7 -7
  2. package/dist/ast-analysis/engine.d.ts.map +1 -1
  3. package/dist/ast-analysis/engine.js +3 -9
  4. package/dist/ast-analysis/engine.js.map +1 -1
  5. package/dist/ast-analysis/shared.d.ts.map +1 -1
  6. package/dist/ast-analysis/shared.js +0 -1
  7. package/dist/ast-analysis/shared.js.map +1 -1
  8. package/dist/ast-analysis/visitors/cfg-conditionals.d.ts +5 -0
  9. package/dist/ast-analysis/visitors/cfg-conditionals.d.ts.map +1 -0
  10. package/dist/ast-analysis/visitors/cfg-conditionals.js +166 -0
  11. package/dist/ast-analysis/visitors/cfg-conditionals.js.map +1 -0
  12. package/dist/ast-analysis/visitors/cfg-loops.d.ts +7 -0
  13. package/dist/ast-analysis/visitors/cfg-loops.d.ts.map +1 -0
  14. package/dist/ast-analysis/visitors/cfg-loops.js +73 -0
  15. package/dist/ast-analysis/visitors/cfg-loops.js.map +1 -0
  16. package/dist/ast-analysis/visitors/cfg-shared.d.ts +56 -0
  17. package/dist/ast-analysis/visitors/cfg-shared.d.ts.map +1 -0
  18. package/dist/ast-analysis/visitors/cfg-shared.js +107 -0
  19. package/dist/ast-analysis/visitors/cfg-shared.js.map +1 -0
  20. package/dist/ast-analysis/visitors/cfg-try-catch.d.ts +4 -0
  21. package/dist/ast-analysis/visitors/cfg-try-catch.d.ts.map +1 -0
  22. package/dist/ast-analysis/visitors/cfg-try-catch.js +100 -0
  23. package/dist/ast-analysis/visitors/cfg-try-catch.js.map +1 -0
  24. package/dist/ast-analysis/visitors/cfg-visitor.d.ts +2 -2
  25. package/dist/ast-analysis/visitors/cfg-visitor.d.ts.map +1 -1
  26. package/dist/ast-analysis/visitors/cfg-visitor.js +11 -445
  27. package/dist/ast-analysis/visitors/cfg-visitor.js.map +1 -1
  28. package/dist/ast-analysis/visitors/complexity-visitor.d.ts.map +1 -1
  29. package/dist/ast-analysis/visitors/complexity-visitor.js.map +1 -1
  30. package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -1
  31. package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -1
  32. package/dist/cli/commands/batch.d.ts.map +1 -1
  33. package/dist/cli/commands/batch.js +4 -3
  34. package/dist/cli/commands/batch.js.map +1 -1
  35. package/dist/cli/commands/branch-compare.js +1 -1
  36. package/dist/cli/commands/branch-compare.js.map +1 -1
  37. package/dist/cli/commands/build.js +1 -1
  38. package/dist/cli/commands/build.js.map +1 -1
  39. package/dist/cli/commands/info.d.ts.map +1 -1
  40. package/dist/cli/commands/info.js +1 -2
  41. package/dist/cli/commands/info.js.map +1 -1
  42. package/dist/cli/commands/path.d.ts.map +1 -1
  43. package/dist/cli/commands/path.js +7 -2
  44. package/dist/cli/commands/path.js.map +1 -1
  45. package/dist/cli/commands/plot.d.ts.map +1 -1
  46. package/dist/cli/commands/plot.js +2 -2
  47. package/dist/cli/commands/plot.js.map +1 -1
  48. package/dist/cli/commands/watch.js +1 -1
  49. package/dist/cli/commands/watch.js.map +1 -1
  50. package/dist/cli/index.js +2 -2
  51. package/dist/cli/index.js.map +1 -1
  52. package/dist/cli/shared/open-graph.d.ts +2 -2
  53. package/dist/cli/shared/open-graph.d.ts.map +1 -1
  54. package/dist/cli/shared/open-graph.js.map +1 -1
  55. package/dist/cli/types.d.ts +1 -1
  56. package/dist/cli/types.d.ts.map +1 -1
  57. package/dist/cli.js +2 -3
  58. package/dist/cli.js.map +1 -1
  59. package/dist/db/connection.d.ts +17 -0
  60. package/dist/db/connection.d.ts.map +1 -1
  61. package/dist/db/connection.js +91 -2
  62. package/dist/db/connection.js.map +1 -1
  63. package/dist/db/index.d.ts +1 -1
  64. package/dist/db/index.d.ts.map +1 -1
  65. package/dist/db/index.js +1 -1
  66. package/dist/db/index.js.map +1 -1
  67. package/dist/db/migrations.d.ts.map +1 -1
  68. package/dist/db/migrations.js +7 -0
  69. package/dist/db/migrations.js.map +1 -1
  70. package/dist/domain/analysis/brief.d.ts.map +1 -1
  71. package/dist/domain/analysis/brief.js +1 -3
  72. package/dist/domain/analysis/brief.js.map +1 -1
  73. package/dist/domain/analysis/context.d.ts.map +1 -1
  74. package/dist/domain/analysis/context.js +2 -4
  75. package/dist/domain/analysis/context.js.map +1 -1
  76. package/dist/domain/analysis/dependencies.d.ts +49 -0
  77. package/dist/domain/analysis/dependencies.d.ts.map +1 -1
  78. package/dist/domain/analysis/dependencies.js +145 -0
  79. package/dist/domain/analysis/dependencies.js.map +1 -1
  80. package/dist/domain/analysis/diff-impact.d.ts +76 -0
  81. package/dist/domain/analysis/diff-impact.d.ts.map +1 -0
  82. package/dist/domain/analysis/diff-impact.js +282 -0
  83. package/dist/domain/analysis/diff-impact.js.map +1 -0
  84. package/dist/domain/analysis/exports.d.ts.map +1 -1
  85. package/dist/domain/analysis/exports.js +0 -1
  86. package/dist/domain/analysis/exports.js.map +1 -1
  87. package/dist/domain/analysis/fn-impact.d.ts +66 -0
  88. package/dist/domain/analysis/fn-impact.d.ts.map +1 -0
  89. package/dist/domain/analysis/fn-impact.js +189 -0
  90. package/dist/domain/analysis/fn-impact.js.map +1 -0
  91. package/dist/domain/analysis/impact.d.ts +8 -148
  92. package/dist/domain/analysis/impact.d.ts.map +1 -1
  93. package/dist/domain/analysis/impact.js +8 -568
  94. package/dist/domain/analysis/impact.js.map +1 -1
  95. package/dist/domain/analysis/module-map.d.ts.map +1 -1
  96. package/dist/domain/analysis/module-map.js +1 -3
  97. package/dist/domain/analysis/module-map.js.map +1 -1
  98. package/dist/domain/graph/builder/context.d.ts +2 -3
  99. package/dist/domain/graph/builder/context.d.ts.map +1 -1
  100. package/dist/domain/graph/builder/context.js.map +1 -1
  101. package/dist/domain/graph/builder/helpers.d.ts +4 -5
  102. package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
  103. package/dist/domain/graph/builder/helpers.js +1 -2
  104. package/dist/domain/graph/builder/helpers.js.map +1 -1
  105. package/dist/domain/graph/builder/incremental.d.ts +2 -3
  106. package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
  107. package/dist/domain/graph/builder/incremental.js.map +1 -1
  108. package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
  109. package/dist/domain/graph/builder/pipeline.js +6 -0
  110. package/dist/domain/graph/builder/pipeline.js.map +1 -1
  111. package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
  112. package/dist/domain/graph/builder/stages/build-edges.js +12 -2
  113. package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
  114. package/dist/domain/graph/builder/stages/build-structure.d.ts.map +1 -1
  115. package/dist/domain/graph/builder/stages/build-structure.js +155 -59
  116. package/dist/domain/graph/builder/stages/build-structure.js.map +1 -1
  117. package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
  118. package/dist/domain/graph/builder/stages/detect-changes.js +6 -6
  119. package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
  120. package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
  121. package/dist/domain/graph/builder/stages/finalize.js +85 -61
  122. package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
  123. package/dist/domain/graph/builder/stages/insert-nodes.d.ts.map +1 -1
  124. package/dist/domain/graph/builder/stages/insert-nodes.js.map +1 -1
  125. package/dist/domain/graph/builder/stages/resolve-imports.d.ts.map +1 -1
  126. package/dist/domain/graph/builder/stages/resolve-imports.js +58 -11
  127. package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
  128. package/dist/domain/graph/cycles.js +2 -2
  129. package/dist/domain/graph/cycles.js.map +1 -1
  130. package/dist/domain/graph/resolve.d.ts.map +1 -1
  131. package/dist/domain/graph/resolve.js +10 -8
  132. package/dist/domain/graph/resolve.js.map +1 -1
  133. package/dist/domain/graph/watcher.d.ts.map +1 -1
  134. package/dist/domain/graph/watcher.js +1 -3
  135. package/dist/domain/graph/watcher.js.map +1 -1
  136. package/dist/domain/parser.d.ts.map +1 -1
  137. package/dist/domain/parser.js +11 -12
  138. package/dist/domain/parser.js.map +1 -1
  139. package/dist/domain/queries.d.ts +3 -2
  140. package/dist/domain/queries.d.ts.map +1 -1
  141. package/dist/domain/queries.js +3 -2
  142. package/dist/domain/queries.js.map +1 -1
  143. package/dist/domain/search/generator.d.ts.map +1 -1
  144. package/dist/domain/search/generator.js.map +1 -1
  145. package/dist/extractors/csharp.js +2 -2
  146. package/dist/extractors/csharp.js.map +1 -1
  147. package/dist/extractors/go.js +2 -2
  148. package/dist/extractors/go.js.map +1 -1
  149. package/dist/extractors/helpers.d.ts +5 -0
  150. package/dist/extractors/helpers.d.ts.map +1 -1
  151. package/dist/extractors/helpers.js +5 -0
  152. package/dist/extractors/helpers.js.map +1 -1
  153. package/dist/extractors/javascript.js +58 -60
  154. package/dist/extractors/javascript.js.map +1 -1
  155. package/dist/extractors/php.js +2 -2
  156. package/dist/extractors/php.js.map +1 -1
  157. package/dist/extractors/python.js +2 -2
  158. package/dist/extractors/python.js.map +1 -1
  159. package/dist/extractors/rust.js +2 -2
  160. package/dist/extractors/rust.js.map +1 -1
  161. package/dist/features/audit.d.ts.map +1 -1
  162. package/dist/features/audit.js +1 -2
  163. package/dist/features/audit.js.map +1 -1
  164. package/dist/features/branch-compare.d.ts.map +1 -1
  165. package/dist/features/branch-compare.js +2 -3
  166. package/dist/features/branch-compare.js.map +1 -1
  167. package/dist/features/cfg.d.ts.map +1 -1
  168. package/dist/features/cfg.js +2 -4
  169. package/dist/features/cfg.js.map +1 -1
  170. package/dist/features/cochange.js +4 -4
  171. package/dist/features/cochange.js.map +1 -1
  172. package/dist/features/communities.js +4 -4
  173. package/dist/features/communities.js.map +1 -1
  174. package/dist/features/complexity-query.d.ts +37 -0
  175. package/dist/features/complexity-query.d.ts.map +1 -0
  176. package/dist/features/complexity-query.js +263 -0
  177. package/dist/features/complexity-query.js.map +1 -0
  178. package/dist/features/complexity.d.ts +2 -30
  179. package/dist/features/complexity.d.ts.map +1 -1
  180. package/dist/features/complexity.js +7 -261
  181. package/dist/features/complexity.js.map +1 -1
  182. package/dist/features/dataflow.d.ts.map +1 -1
  183. package/dist/features/dataflow.js +8 -24
  184. package/dist/features/dataflow.js.map +1 -1
  185. package/dist/features/export.d.ts +7 -8
  186. package/dist/features/export.d.ts.map +1 -1
  187. package/dist/features/export.js.map +1 -1
  188. package/dist/features/flow.d.ts.map +1 -1
  189. package/dist/features/flow.js.map +1 -1
  190. package/dist/features/graph-enrichment.d.ts.map +1 -1
  191. package/dist/features/graph-enrichment.js +1 -3
  192. package/dist/features/graph-enrichment.js.map +1 -1
  193. package/dist/features/manifesto.js +8 -8
  194. package/dist/features/manifesto.js.map +1 -1
  195. package/dist/features/snapshot.d.ts.map +1 -1
  196. package/dist/features/snapshot.js +0 -1
  197. package/dist/features/snapshot.js.map +1 -1
  198. package/dist/features/structure-query.d.ts +76 -0
  199. package/dist/features/structure-query.d.ts.map +1 -0
  200. package/dist/features/structure-query.js +245 -0
  201. package/dist/features/structure-query.js.map +1 -0
  202. package/dist/features/structure.d.ts +12 -67
  203. package/dist/features/structure.d.ts.map +1 -1
  204. package/dist/features/structure.js +188 -244
  205. package/dist/features/structure.js.map +1 -1
  206. package/dist/features/triage.js +2 -2
  207. package/dist/features/triage.js.map +1 -1
  208. package/dist/graph/algorithms/leiden/adapter.d.ts.map +1 -1
  209. package/dist/graph/algorithms/leiden/adapter.js +2 -9
  210. package/dist/graph/algorithms/leiden/adapter.js.map +1 -1
  211. package/dist/graph/classifiers/roles.d.ts +5 -1
  212. package/dist/graph/classifiers/roles.d.ts.map +1 -1
  213. package/dist/graph/classifiers/roles.js +20 -12
  214. package/dist/graph/classifiers/roles.js.map +1 -1
  215. package/dist/index.d.ts +1 -0
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js.map +1 -1
  218. package/dist/infrastructure/config.d.ts.map +1 -1
  219. package/dist/infrastructure/config.js +12 -11
  220. package/dist/infrastructure/config.js.map +1 -1
  221. package/dist/infrastructure/native.d.ts.map +1 -1
  222. package/dist/infrastructure/native.js +7 -3
  223. package/dist/infrastructure/native.js.map +1 -1
  224. package/dist/infrastructure/registry.d.ts.map +1 -1
  225. package/dist/infrastructure/registry.js +1 -1
  226. package/dist/infrastructure/registry.js.map +1 -1
  227. package/dist/infrastructure/update-check.js +3 -3
  228. package/dist/infrastructure/update-check.js.map +1 -1
  229. package/dist/mcp/server.d.ts.map +1 -1
  230. package/dist/mcp/server.js +2 -8
  231. package/dist/mcp/server.js.map +1 -1
  232. package/dist/mcp/tool-registry.d.ts.map +1 -1
  233. package/dist/mcp/tool-registry.js +9 -4
  234. package/dist/mcp/tool-registry.js.map +1 -1
  235. package/dist/mcp/tools/audit.js +1 -1
  236. package/dist/mcp/tools/audit.js.map +1 -1
  237. package/dist/mcp/tools/cfg.js +1 -1
  238. package/dist/mcp/tools/cfg.js.map +1 -1
  239. package/dist/mcp/tools/check.js +2 -2
  240. package/dist/mcp/tools/check.js.map +1 -1
  241. package/dist/mcp/tools/dataflow.js +2 -2
  242. package/dist/mcp/tools/dataflow.js.map +1 -1
  243. package/dist/mcp/tools/export-graph.js +1 -1
  244. package/dist/mcp/tools/export-graph.js.map +1 -1
  245. package/dist/mcp/tools/index.d.ts.map +1 -1
  246. package/dist/mcp/tools/index.js.map +1 -1
  247. package/dist/mcp/tools/path.d.ts +1 -0
  248. package/dist/mcp/tools/path.d.ts.map +1 -1
  249. package/dist/mcp/tools/path.js +9 -0
  250. package/dist/mcp/tools/path.js.map +1 -1
  251. package/dist/mcp/tools/query.js +1 -1
  252. package/dist/mcp/tools/query.js.map +1 -1
  253. package/dist/mcp/tools/semantic-search.js +1 -1
  254. package/dist/mcp/tools/semantic-search.js.map +1 -1
  255. package/dist/mcp/tools/sequence.js +1 -1
  256. package/dist/mcp/tools/sequence.js.map +1 -1
  257. package/dist/mcp/tools/symbol-children.js +1 -1
  258. package/dist/mcp/tools/symbol-children.js.map +1 -1
  259. package/dist/mcp/tools/triage.js +1 -1
  260. package/dist/mcp/tools/triage.js.map +1 -1
  261. package/dist/presentation/audit.d.ts.map +1 -1
  262. package/dist/presentation/audit.js +0 -1
  263. package/dist/presentation/audit.js.map +1 -1
  264. package/dist/presentation/diff-impact-mermaid.d.ts +11 -0
  265. package/dist/presentation/diff-impact-mermaid.d.ts.map +1 -0
  266. package/dist/presentation/diff-impact-mermaid.js +105 -0
  267. package/dist/presentation/diff-impact-mermaid.js.map +1 -0
  268. package/dist/presentation/flow.d.ts.map +1 -1
  269. package/dist/presentation/flow.js +0 -2
  270. package/dist/presentation/flow.js.map +1 -1
  271. package/dist/presentation/manifesto.d.ts.map +1 -1
  272. package/dist/presentation/manifesto.js +0 -1
  273. package/dist/presentation/manifesto.js.map +1 -1
  274. package/dist/presentation/queries-cli/inspect.d.ts.map +1 -1
  275. package/dist/presentation/queries-cli/inspect.js.map +1 -1
  276. package/dist/presentation/queries-cli/path.d.ts.map +1 -1
  277. package/dist/presentation/queries-cli/path.js +45 -1
  278. package/dist/presentation/queries-cli/path.js.map +1 -1
  279. package/dist/presentation/result-formatter.d.ts.map +1 -1
  280. package/dist/presentation/result-formatter.js +1 -3
  281. package/dist/presentation/result-formatter.js.map +1 -1
  282. package/dist/presentation/sequence.d.ts.map +1 -1
  283. package/dist/presentation/sequence.js +0 -1
  284. package/dist/presentation/sequence.js.map +1 -1
  285. package/dist/presentation/structure.d.ts.map +1 -1
  286. package/dist/presentation/structure.js.map +1 -1
  287. package/dist/presentation/triage.d.ts.map +1 -1
  288. package/dist/presentation/triage.js +0 -1
  289. package/dist/presentation/triage.js.map +1 -1
  290. package/dist/shared/constants.d.ts +9 -3
  291. package/dist/shared/constants.d.ts.map +1 -1
  292. package/dist/shared/constants.js +6 -3
  293. package/dist/shared/constants.js.map +1 -1
  294. package/dist/shared/errors.d.ts +2 -0
  295. package/dist/shared/errors.d.ts.map +1 -1
  296. package/dist/shared/errors.js +4 -0
  297. package/dist/shared/errors.js.map +1 -1
  298. package/dist/shared/version.d.ts +2 -0
  299. package/dist/shared/version.d.ts.map +1 -0
  300. package/dist/shared/version.js +5 -0
  301. package/dist/shared/version.js.map +1 -0
  302. package/dist/types.d.ts +2 -2
  303. package/dist/types.d.ts.map +1 -1
  304. package/package.json +8 -7
  305. package/src/ast-analysis/engine.ts +3 -9
  306. package/src/ast-analysis/shared.ts +0 -1
  307. package/src/ast-analysis/visitors/cfg-conditionals.ts +227 -0
  308. package/src/ast-analysis/visitors/cfg-loops.ts +136 -0
  309. package/src/ast-analysis/visitors/cfg-shared.ts +196 -0
  310. package/src/ast-analysis/visitors/cfg-try-catch.ts +142 -0
  311. package/src/ast-analysis/visitors/cfg-visitor.ts +34 -655
  312. package/src/ast-analysis/visitors/complexity-visitor.ts +0 -1
  313. package/src/ast-analysis/visitors/dataflow-visitor.ts +0 -1
  314. package/src/cli/commands/batch.ts +4 -3
  315. package/src/cli/commands/branch-compare.ts +1 -1
  316. package/src/cli/commands/build.ts +1 -1
  317. package/src/cli/commands/info.ts +1 -2
  318. package/src/cli/commands/path.ts +7 -2
  319. package/src/cli/commands/plot.ts +2 -2
  320. package/src/cli/commands/watch.ts +1 -1
  321. package/src/cli/index.ts +2 -2
  322. package/src/cli/shared/open-graph.ts +2 -2
  323. package/src/cli/types.ts +1 -1
  324. package/src/cli.ts +2 -3
  325. package/src/db/connection.ts +97 -13
  326. package/src/db/index.ts +2 -0
  327. package/src/db/migrations.ts +7 -0
  328. package/src/domain/analysis/brief.ts +0 -1
  329. package/src/domain/analysis/context.ts +2 -6
  330. package/src/domain/analysis/dependencies.ts +165 -0
  331. package/src/domain/analysis/diff-impact.ts +354 -0
  332. package/src/domain/analysis/exports.ts +0 -2
  333. package/src/domain/analysis/fn-impact.ts +241 -0
  334. package/src/domain/analysis/impact.ts +8 -718
  335. package/src/domain/analysis/module-map.ts +1 -5
  336. package/src/domain/graph/builder/context.ts +2 -2
  337. package/src/domain/graph/builder/helpers.ts +14 -11
  338. package/src/domain/graph/builder/incremental.ts +33 -28
  339. package/src/domain/graph/builder/pipeline.ts +8 -0
  340. package/src/domain/graph/builder/stages/build-edges.ts +17 -4
  341. package/src/domain/graph/builder/stages/build-structure.ts +205 -76
  342. package/src/domain/graph/builder/stages/detect-changes.ts +11 -12
  343. package/src/domain/graph/builder/stages/finalize.ts +100 -81
  344. package/src/domain/graph/builder/stages/insert-nodes.ts +12 -8
  345. package/src/domain/graph/builder/stages/resolve-imports.ts +75 -10
  346. package/src/domain/graph/cycles.ts +2 -2
  347. package/src/domain/graph/resolve.ts +14 -8
  348. package/src/domain/graph/watcher.ts +2 -4
  349. package/src/domain/parser.ts +11 -13
  350. package/src/domain/queries.ts +2 -2
  351. package/src/domain/search/generator.ts +3 -4
  352. package/src/extractors/csharp.ts +2 -2
  353. package/src/extractors/go.ts +2 -2
  354. package/src/extractors/helpers.ts +6 -0
  355. package/src/extractors/javascript.ts +58 -61
  356. package/src/extractors/php.ts +2 -2
  357. package/src/extractors/python.ts +2 -2
  358. package/src/extractors/rust.ts +2 -2
  359. package/src/features/audit.ts +1 -2
  360. package/src/features/branch-compare.ts +3 -9
  361. package/src/features/cfg.ts +2 -4
  362. package/src/features/cochange.ts +4 -4
  363. package/src/features/communities.ts +4 -4
  364. package/src/features/complexity-query.ts +370 -0
  365. package/src/features/complexity.ts +6 -365
  366. package/src/features/dataflow.ts +48 -70
  367. package/src/features/export.ts +12 -16
  368. package/src/features/flow.ts +0 -1
  369. package/src/features/graph-enrichment.ts +1 -3
  370. package/src/features/manifesto.ts +8 -8
  371. package/src/features/snapshot.ts +1 -2
  372. package/src/features/structure-query.ts +387 -0
  373. package/src/features/structure.ts +231 -376
  374. package/src/features/triage.ts +2 -2
  375. package/src/graph/algorithms/leiden/adapter.ts +2 -9
  376. package/src/graph/classifiers/roles.ts +22 -13
  377. package/src/index.ts +1 -0
  378. package/src/infrastructure/config.ts +12 -13
  379. package/src/infrastructure/native.ts +7 -3
  380. package/src/infrastructure/registry.ts +1 -1
  381. package/src/infrastructure/update-check.ts +3 -3
  382. package/src/mcp/server.ts +2 -10
  383. package/src/mcp/tool-registry.ts +11 -4
  384. package/src/mcp/tools/audit.ts +1 -1
  385. package/src/mcp/tools/cfg.ts +1 -1
  386. package/src/mcp/tools/check.ts +2 -2
  387. package/src/mcp/tools/dataflow.ts +2 -2
  388. package/src/mcp/tools/export-graph.ts +1 -1
  389. package/src/mcp/tools/index.ts +0 -1
  390. package/src/mcp/tools/path.ts +10 -0
  391. package/src/mcp/tools/query.ts +1 -1
  392. package/src/mcp/tools/semantic-search.ts +1 -1
  393. package/src/mcp/tools/sequence.ts +1 -1
  394. package/src/mcp/tools/symbol-children.ts +1 -1
  395. package/src/mcp/tools/triage.ts +1 -1
  396. package/src/presentation/audit.ts +0 -1
  397. package/src/presentation/diff-impact-mermaid.ts +127 -0
  398. package/src/presentation/flow.ts +0 -2
  399. package/src/presentation/manifesto.ts +0 -1
  400. package/src/presentation/queries-cli/inspect.ts +0 -1
  401. package/src/presentation/queries-cli/path.ts +71 -1
  402. package/src/presentation/result-formatter.ts +0 -1
  403. package/src/presentation/sequence.ts +0 -1
  404. package/src/presentation/structure.ts +0 -12
  405. package/src/presentation/triage.ts +0 -1
  406. package/src/shared/constants.ts +33 -19
  407. package/src/shared/errors.ts +5 -0
  408. package/src/shared/version.ts +10 -0
  409. package/src/types.ts +4 -10
  410. package/src/vendor.d.ts +0 -39
@@ -0,0 +1,354 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { findDbPath, openReadonlyOrFail } from '../../db/index.js';
5
+ import { cachedStmt } from '../../db/repository/cached-stmt.js';
6
+ import { evaluateBoundaries } from '../../features/boundaries.js';
7
+ import { coChangeForFiles } from '../../features/cochange.js';
8
+ import { ownersForFiles } from '../../features/owners.js';
9
+ import { loadConfig } from '../../infrastructure/config.js';
10
+ import { debug } from '../../infrastructure/logger.js';
11
+ import { isTestFile } from '../../infrastructure/test-filter.js';
12
+ import { paginateResult } from '../../shared/paginate.js';
13
+ import type { BetterSqlite3Database, NodeRow, StmtCache } from '../../types.js';
14
+ import { bfsTransitiveCallers } from './fn-impact.js';
15
+
16
+ const _defsStmtCache: StmtCache<NodeRow> = new WeakMap();
17
+
18
+ // --- diffImpactData helpers ---
19
+
20
+ /**
21
+ * Walk up from repoRoot until a .git directory is found.
22
+ * Returns true if a git root exists, false otherwise.
23
+ */
24
+ function findGitRoot(repoRoot: string): boolean {
25
+ let checkDir = repoRoot;
26
+ while (checkDir) {
27
+ if (fs.existsSync(path.join(checkDir, '.git'))) {
28
+ return true;
29
+ }
30
+ const parent = path.dirname(checkDir);
31
+ if (parent === checkDir) break;
32
+ checkDir = parent;
33
+ }
34
+ return false;
35
+ }
36
+
37
+ /**
38
+ * Execute git diff and return the raw output string.
39
+ * Returns `{ output: string }` on success or `{ error: string }` on failure.
40
+ */
41
+ function runGitDiff(
42
+ repoRoot: string,
43
+ opts: { staged?: boolean; ref?: string },
44
+ ): { output: string; error?: never } | { error: string; output?: never } {
45
+ try {
46
+ const args = opts.staged
47
+ ? ['diff', '--cached', '--unified=0', '--no-color']
48
+ : ['diff', opts.ref || 'HEAD', '--unified=0', '--no-color'];
49
+ const output = execFileSync('git', args, {
50
+ cwd: repoRoot,
51
+ encoding: 'utf-8',
52
+ maxBuffer: 10 * 1024 * 1024,
53
+ stdio: ['pipe', 'pipe', 'pipe'],
54
+ });
55
+ return { output };
56
+ } catch (e: unknown) {
57
+ return { error: `Failed to run git diff: ${(e as Error).message}` };
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Parse raw git diff output into a changedRanges map and newFiles set.
63
+ */
64
+ function parseGitDiff(diffOutput: string) {
65
+ const changedRanges = new Map<string, Array<{ start: number; end: number }>>();
66
+ const newFiles = new Set<string>();
67
+ let currentFile: string | null = null;
68
+ let prevIsDevNull = false;
69
+
70
+ for (const line of diffOutput.split('\n')) {
71
+ if (line.startsWith('--- /dev/null')) {
72
+ prevIsDevNull = true;
73
+ continue;
74
+ }
75
+ if (line.startsWith('--- ')) {
76
+ prevIsDevNull = false;
77
+ continue;
78
+ }
79
+ const fileMatch = line.match(/^\+\+\+ b\/(.+)/);
80
+ if (fileMatch) {
81
+ currentFile = fileMatch[1]!;
82
+ if (!changedRanges.has(currentFile)) changedRanges.set(currentFile, []);
83
+ if (prevIsDevNull) newFiles.add(currentFile!);
84
+ prevIsDevNull = false;
85
+ continue;
86
+ }
87
+ const hunkMatch = line.match(/^@@ .+ \+(\d+)(?:,(\d+))? @@/);
88
+ if (hunkMatch && currentFile) {
89
+ const start = parseInt(hunkMatch[1]!, 10);
90
+ const count = parseInt(hunkMatch[2] || '1', 10);
91
+ changedRanges.get(currentFile)!.push({ start, end: start + count - 1 });
92
+ }
93
+ }
94
+
95
+ return { changedRanges, newFiles };
96
+ }
97
+
98
+ /**
99
+ * Find all function/method/class nodes whose line ranges overlap any changed range.
100
+ */
101
+ function findAffectedFunctions(
102
+ db: BetterSqlite3Database,
103
+ changedRanges: Map<string, Array<{ start: number; end: number }>>,
104
+ noTests: boolean,
105
+ ): NodeRow[] {
106
+ const affectedFunctions: NodeRow[] = [];
107
+ const defsStmt = cachedStmt(
108
+ _defsStmtCache,
109
+ db,
110
+ `SELECT * FROM nodes WHERE file = ? AND kind IN ('function', 'method', 'class') ORDER BY line`,
111
+ );
112
+ for (const [file, ranges] of changedRanges) {
113
+ if (noTests && isTestFile(file)) continue;
114
+ const defs = defsStmt.all(file) as NodeRow[];
115
+ for (let i = 0; i < defs.length; i++) {
116
+ const def = defs[i]!;
117
+ const endLine = def.end_line || (defs[i + 1] ? defs[i + 1]!.line - 1 : 999999);
118
+ for (const range of ranges) {
119
+ if (range.start <= endLine && range.end >= def.line) {
120
+ affectedFunctions.push(def);
121
+ break;
122
+ }
123
+ }
124
+ }
125
+ }
126
+ return affectedFunctions;
127
+ }
128
+
129
+ /**
130
+ * Run BFS per affected function, collecting per-function results and the full affected set.
131
+ */
132
+ function buildFunctionImpactResults(
133
+ db: BetterSqlite3Database,
134
+ affectedFunctions: NodeRow[],
135
+ noTests: boolean,
136
+ maxDepth: number,
137
+ includeImplementors = true,
138
+ ) {
139
+ const allAffected = new Set<string>();
140
+ const functionResults = affectedFunctions.map((fn) => {
141
+ const edges: Array<{ from: string; to: string }> = [];
142
+ const idToKey = new Map<number, string>();
143
+ idToKey.set(fn.id, `${fn.file}::${fn.name}:${fn.line}`);
144
+
145
+ const { levels, totalDependents } = bfsTransitiveCallers(db, fn.id, {
146
+ noTests,
147
+ maxDepth,
148
+ includeImplementors,
149
+ onVisit(c, parentId) {
150
+ allAffected.add(`${c.file}:${c.name}`);
151
+ const callerKey = `${c.file}::${c.name}:${c.line}`;
152
+ idToKey.set(c.id, callerKey);
153
+ edges.push({ from: idToKey.get(parentId)!, to: callerKey });
154
+ },
155
+ });
156
+
157
+ return {
158
+ name: fn.name,
159
+ kind: fn.kind,
160
+ file: fn.file,
161
+ line: fn.line,
162
+ transitiveCallers: totalDependents,
163
+ levels,
164
+ edges,
165
+ };
166
+ });
167
+
168
+ return { functionResults, allAffected };
169
+ }
170
+
171
+ /**
172
+ * Look up historically co-changed files for the set of changed files.
173
+ * Returns an empty array if the co_changes table is unavailable.
174
+ */
175
+ function lookupCoChanges(
176
+ db: BetterSqlite3Database,
177
+ changedRanges: Map<string, unknown>,
178
+ affectedFiles: Set<string>,
179
+ noTests: boolean,
180
+ ) {
181
+ try {
182
+ db.prepare('SELECT 1 FROM co_changes LIMIT 1').get();
183
+ const changedFilesList = [...changedRanges.keys()];
184
+ const coResults = coChangeForFiles(changedFilesList, db, {
185
+ minJaccard: 0.3,
186
+ limit: 20,
187
+ noTests,
188
+ });
189
+ return coResults.filter((r: { file: string }) => !affectedFiles.has(r.file));
190
+ } catch (e: unknown) {
191
+ debug(`co_changes lookup skipped: ${(e as Error).message}`);
192
+ return [];
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Look up CODEOWNERS for changed and affected files.
198
+ * Returns null if no owners are found or lookup fails.
199
+ */
200
+ function lookupOwnership(
201
+ changedRanges: Map<string, unknown>,
202
+ affectedFiles: Set<string>,
203
+ repoRoot: string,
204
+ ) {
205
+ try {
206
+ const allFilePaths = [...new Set([...changedRanges.keys(), ...affectedFiles])];
207
+ const ownerResult = ownersForFiles(allFilePaths, repoRoot);
208
+ if (ownerResult.affectedOwners.length > 0) {
209
+ return {
210
+ owners: Object.fromEntries(ownerResult.owners),
211
+ affectedOwners: ownerResult.affectedOwners,
212
+ suggestedReviewers: ownerResult.suggestedReviewers,
213
+ };
214
+ }
215
+ return null;
216
+ } catch (e: unknown) {
217
+ debug(`CODEOWNERS lookup skipped: ${(e as Error).message}`);
218
+ return null;
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Check manifesto boundary violations scoped to the changed files.
224
+ * Returns `{ boundaryViolations, boundaryViolationCount }`.
225
+ */
226
+ function checkBoundaryViolations(
227
+ db: BetterSqlite3Database,
228
+ changedRanges: Map<string, unknown>,
229
+ noTests: boolean,
230
+ opts: any,
231
+ repoRoot: string,
232
+ ) {
233
+ try {
234
+ const cfg = opts.config || loadConfig(repoRoot);
235
+ const boundaryConfig = cfg.manifesto?.boundaries;
236
+ if (boundaryConfig) {
237
+ const result = evaluateBoundaries(db, boundaryConfig, {
238
+ scopeFiles: [...changedRanges.keys()],
239
+ noTests,
240
+ });
241
+ return {
242
+ boundaryViolations: result.violations,
243
+ boundaryViolationCount: result.violationCount,
244
+ };
245
+ }
246
+ } catch (e: unknown) {
247
+ debug(`boundary check skipped: ${(e as Error).message}`);
248
+ }
249
+ return { boundaryViolations: [], boundaryViolationCount: 0 };
250
+ }
251
+
252
+ // --- diffImpactData ---
253
+
254
+ /**
255
+ * Compute diff-impact analysis between two git refs (or staged changes).
256
+ * Uses execFileSync (via runGitDiff) to avoid shell injection.
257
+ */
258
+ export function diffImpactData(
259
+ customDbPath: string,
260
+ opts: {
261
+ noTests?: boolean;
262
+ depth?: number;
263
+ staged?: boolean;
264
+ ref?: string;
265
+ includeImplementors?: boolean;
266
+ limit?: number;
267
+ offset?: number;
268
+ config?: any;
269
+ } = {},
270
+ ) {
271
+ const db = openReadonlyOrFail(customDbPath);
272
+ try {
273
+ const noTests = opts.noTests || false;
274
+ const config = opts.config || loadConfig();
275
+ const maxDepth = opts.depth || config.analysis?.impactDepth || 3;
276
+
277
+ const dbPath = findDbPath(customDbPath);
278
+ const repoRoot = path.resolve(path.dirname(dbPath), '..');
279
+
280
+ if (!findGitRoot(repoRoot)) {
281
+ return { error: `Not a git repository: ${repoRoot}` };
282
+ }
283
+
284
+ const gitResult = runGitDiff(repoRoot, opts);
285
+ if ('error' in gitResult) return { error: gitResult.error };
286
+
287
+ if (!gitResult.output.trim()) {
288
+ return {
289
+ changedFiles: 0,
290
+ newFiles: [],
291
+ affectedFunctions: [],
292
+ affectedFiles: [],
293
+ summary: null,
294
+ };
295
+ }
296
+
297
+ const { changedRanges, newFiles } = parseGitDiff(gitResult.output);
298
+
299
+ if (changedRanges.size === 0) {
300
+ return {
301
+ changedFiles: 0,
302
+ newFiles: [],
303
+ affectedFunctions: [],
304
+ affectedFiles: [],
305
+ summary: null,
306
+ };
307
+ }
308
+
309
+ const affectedFunctions = findAffectedFunctions(db, changedRanges, noTests);
310
+ const includeImplementors = opts.includeImplementors !== false;
311
+ const { functionResults, allAffected } = buildFunctionImpactResults(
312
+ db,
313
+ affectedFunctions,
314
+ noTests,
315
+ maxDepth,
316
+ includeImplementors,
317
+ );
318
+
319
+ const affectedFiles = new Set<string>();
320
+ for (const key of allAffected) affectedFiles.add(key.split(':')[0]!);
321
+
322
+ const historicallyCoupled = lookupCoChanges(db, changedRanges, affectedFiles, noTests);
323
+ const ownership = lookupOwnership(changedRanges, affectedFiles, repoRoot);
324
+ const { boundaryViolations, boundaryViolationCount } = checkBoundaryViolations(
325
+ db,
326
+ changedRanges,
327
+ noTests,
328
+ opts,
329
+ repoRoot,
330
+ );
331
+
332
+ const base = {
333
+ changedFiles: changedRanges.size,
334
+ newFiles: [...newFiles],
335
+ affectedFunctions: functionResults,
336
+ affectedFiles: [...affectedFiles],
337
+ historicallyCoupled,
338
+ ownership,
339
+ boundaryViolations,
340
+ boundaryViolationCount,
341
+ summary: {
342
+ functionsChanged: affectedFunctions.length,
343
+ callersAffected: allAffected.size,
344
+ filesAffected: affectedFiles.size,
345
+ historicallyCoupledCount: historicallyCoupled.length,
346
+ ownersAffected: ownership ? ownership.affectedOwners.length : 0,
347
+ boundaryViolationCount,
348
+ },
349
+ };
350
+ return paginateResult(base, 'affectedFunctions', { limit: opts.limit, offset: opts.offset });
351
+ } finally {
352
+ db.close();
353
+ }
354
+ }
@@ -34,7 +34,6 @@ export function exportsData(
34
34
  unused?: boolean;
35
35
  limit?: number;
36
36
  offset?: number;
37
- // biome-ignore lint/suspicious/noExplicitAny: config shape is dynamic
38
37
  config?: any;
39
38
  } = {},
40
39
  ) {
@@ -84,7 +83,6 @@ export function exportsData(
84
83
  totalReexported: first.totalReexported,
85
84
  totalReexportedUnused: first.totalReexportedUnused,
86
85
  };
87
- // biome-ignore lint/suspicious/noExplicitAny: paginateResult returns dynamic shape
88
86
  const paginated: any = paginateResult(base, 'results', {
89
87
  limit: opts.limit,
90
88
  offset: opts.offset,
@@ -0,0 +1,241 @@
1
+ import {
2
+ findDistinctCallers,
3
+ findFileNodes,
4
+ findImplementors,
5
+ findImportDependents,
6
+ findNodeById,
7
+ openReadonlyOrFail,
8
+ } from '../../db/index.js';
9
+ import { loadConfig } from '../../infrastructure/config.js';
10
+ import { isTestFile } from '../../infrastructure/test-filter.js';
11
+ import { normalizeSymbol } from '../../shared/normalize.js';
12
+ import { paginateResult } from '../../shared/paginate.js';
13
+ import type { BetterSqlite3Database, NodeRow, RelatedNodeRow } from '../../types.js';
14
+ import { findMatchingNodes } from './symbol-lookup.js';
15
+
16
+ // --- Shared BFS: transitive callers ---
17
+
18
+ const INTERFACE_LIKE_KINDS = new Set(['interface', 'trait']);
19
+
20
+ /**
21
+ * Check whether the graph contains any 'implements' edges.
22
+ * Cached per db handle so the query runs at most once per connection.
23
+ */
24
+ const _hasImplementsCache: WeakMap<BetterSqlite3Database, boolean> = new WeakMap();
25
+ function hasImplementsEdges(db: BetterSqlite3Database): boolean {
26
+ if (_hasImplementsCache.has(db)) return _hasImplementsCache.get(db)!;
27
+ const row = db.prepare("SELECT 1 FROM edges WHERE kind = 'implements' LIMIT 1").get();
28
+ const result = !!row;
29
+ _hasImplementsCache.set(db, result);
30
+ return result;
31
+ }
32
+
33
+ /**
34
+ * BFS traversal to find transitive callers of a node.
35
+ * When an interface/trait node is encountered (either as the start node or
36
+ * during traversal), its concrete implementors are also added to the frontier
37
+ * so that changes to an interface signature propagate to all implementors.
38
+ */
39
+ export function bfsTransitiveCallers(
40
+ db: BetterSqlite3Database,
41
+ startId: number,
42
+ {
43
+ noTests = false,
44
+ maxDepth = 3,
45
+ includeImplementors = true,
46
+ onVisit,
47
+ }: {
48
+ noTests?: boolean;
49
+ maxDepth?: number;
50
+ includeImplementors?: boolean;
51
+ onVisit?: (
52
+ caller: RelatedNodeRow & { viaImplements?: boolean },
53
+ parentId: number,
54
+ depth: number,
55
+ ) => void;
56
+ } = {},
57
+ ) {
58
+ // Skip all implementor lookups when the graph has no implements edges
59
+ const resolveImplementors = includeImplementors && hasImplementsEdges(db);
60
+
61
+ const visited = new Set([startId]);
62
+ const levels: Record<
63
+ number,
64
+ Array<{ name: string; kind: string; file: string; line: number; viaImplements?: boolean }>
65
+ > = {};
66
+ let frontier = [startId];
67
+
68
+ // Seed: if start node is an interface/trait, include its implementors at depth 1.
69
+ // Implementors go into a separate list so their callers appear at depth 2, not depth 1.
70
+ const implNextFrontier: number[] = [];
71
+ if (resolveImplementors) {
72
+ const startNode = findNodeById(db, startId) as NodeRow | undefined;
73
+ if (startNode && INTERFACE_LIKE_KINDS.has(startNode.kind)) {
74
+ const impls = findImplementors(db, startId) as RelatedNodeRow[];
75
+ for (const impl of impls) {
76
+ if (!visited.has(impl.id) && (!noTests || !isTestFile(impl.file))) {
77
+ visited.add(impl.id);
78
+ implNextFrontier.push(impl.id);
79
+ if (!levels[1]) levels[1] = [];
80
+ levels[1].push({
81
+ name: impl.name,
82
+ kind: impl.kind,
83
+ file: impl.file,
84
+ line: impl.line,
85
+ viaImplements: true,
86
+ });
87
+ if (onVisit) onVisit({ ...impl, viaImplements: true }, startId, 1);
88
+ }
89
+ }
90
+ }
91
+ }
92
+
93
+ for (let d = 1; d <= maxDepth; d++) {
94
+ // On the first wave, merge seeded implementors so their callers appear at d=2
95
+ if (d === 1 && implNextFrontier.length > 0) {
96
+ frontier = [...frontier, ...implNextFrontier];
97
+ }
98
+ const nextFrontier: number[] = [];
99
+ for (const fid of frontier) {
100
+ const callers = findDistinctCallers(db, fid) as RelatedNodeRow[];
101
+ for (const c of callers) {
102
+ if (!visited.has(c.id) && (!noTests || !isTestFile(c.file))) {
103
+ visited.add(c.id);
104
+ nextFrontier.push(c.id);
105
+ if (!levels[d]) levels[d] = [];
106
+ levels[d]!.push({ name: c.name, kind: c.kind, file: c.file, line: c.line });
107
+ if (onVisit) onVisit(c, fid, d);
108
+ }
109
+
110
+ // If a caller is an interface/trait, also pull in its implementors
111
+ // Implementors are one extra hop away, so record at d+1
112
+ if (resolveImplementors && INTERFACE_LIKE_KINDS.has(c.kind)) {
113
+ const impls = findImplementors(db, c.id) as RelatedNodeRow[];
114
+ for (const impl of impls) {
115
+ if (!visited.has(impl.id) && (!noTests || !isTestFile(impl.file))) {
116
+ visited.add(impl.id);
117
+ nextFrontier.push(impl.id);
118
+ const implDepth = d + 1;
119
+ if (!levels[implDepth]) levels[implDepth] = [];
120
+ levels[implDepth].push({
121
+ name: impl.name,
122
+ kind: impl.kind,
123
+ file: impl.file,
124
+ line: impl.line,
125
+ viaImplements: true,
126
+ });
127
+ if (onVisit) onVisit({ ...impl, viaImplements: true }, c.id, implDepth);
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ frontier = nextFrontier;
134
+ if (frontier.length === 0) break;
135
+ }
136
+
137
+ return { totalDependents: visited.size - 1, levels };
138
+ }
139
+
140
+ export function impactAnalysisData(
141
+ file: string,
142
+ customDbPath: string,
143
+ opts: { noTests?: boolean } = {},
144
+ ) {
145
+ const db = openReadonlyOrFail(customDbPath);
146
+ try {
147
+ const noTests = opts.noTests || false;
148
+ const fileNodes = findFileNodes(db, `%${file}%`) as NodeRow[];
149
+ if (fileNodes.length === 0) {
150
+ return { file, sources: [], levels: {}, totalDependents: 0 };
151
+ }
152
+
153
+ const visited = new Set<number>();
154
+ const queue: number[] = [];
155
+ const levels = new Map<number, number>();
156
+
157
+ for (const fn of fileNodes) {
158
+ visited.add(fn.id);
159
+ queue.push(fn.id);
160
+ levels.set(fn.id, 0);
161
+ }
162
+
163
+ while (queue.length > 0) {
164
+ const current = queue.shift()!;
165
+ const level = levels.get(current)!;
166
+ const dependents = findImportDependents(db, current) as RelatedNodeRow[];
167
+ for (const dep of dependents) {
168
+ if (!visited.has(dep.id) && (!noTests || !isTestFile(dep.file))) {
169
+ visited.add(dep.id);
170
+ queue.push(dep.id);
171
+ levels.set(dep.id, level + 1);
172
+ }
173
+ }
174
+ }
175
+
176
+ const byLevel: Record<number, Array<{ file: string }>> = {};
177
+ for (const [id, level] of levels) {
178
+ if (level === 0) continue;
179
+ if (!byLevel[level]) byLevel[level] = [];
180
+ const node = findNodeById(db, id) as NodeRow | undefined;
181
+ if (node) byLevel[level].push({ file: node.file });
182
+ }
183
+
184
+ return {
185
+ file,
186
+ sources: fileNodes.map((f) => f.file),
187
+ levels: byLevel,
188
+ totalDependents: visited.size - fileNodes.length,
189
+ };
190
+ } finally {
191
+ db.close();
192
+ }
193
+ }
194
+
195
+ export function fnImpactData(
196
+ name: string,
197
+ customDbPath: string,
198
+ opts: {
199
+ depth?: number;
200
+ noTests?: boolean;
201
+ file?: string;
202
+ kind?: string;
203
+ includeImplementors?: boolean;
204
+ limit?: number;
205
+ offset?: number;
206
+ config?: any;
207
+ } = {},
208
+ ) {
209
+ const db = openReadonlyOrFail(customDbPath);
210
+ try {
211
+ const config = opts.config || loadConfig();
212
+ const maxDepth = opts.depth || config.analysis?.fnImpactDepth || 5;
213
+ const noTests = opts.noTests || false;
214
+ const hc = new Map();
215
+
216
+ const nodes = findMatchingNodes(db, name, { noTests, file: opts.file, kind: opts.kind });
217
+ if (nodes.length === 0) {
218
+ return { name, results: [] };
219
+ }
220
+
221
+ const includeImplementors = opts.includeImplementors !== false;
222
+
223
+ const results = nodes.map((node) => {
224
+ const { levels, totalDependents } = bfsTransitiveCallers(db, node.id, {
225
+ noTests,
226
+ maxDepth,
227
+ includeImplementors,
228
+ });
229
+ return {
230
+ ...normalizeSymbol(node, db, hc),
231
+ levels,
232
+ totalDependents,
233
+ };
234
+ });
235
+
236
+ const base = { name, results };
237
+ return paginateResult(base, 'results', { limit: opts.limit, offset: opts.offset });
238
+ } finally {
239
+ db.close();
240
+ }
241
+ }