codegraph-java 0.1.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 (866) hide show
  1. package/README.md +131 -0
  2. package/dist/base-graph/index.d.ts +57 -0
  3. package/dist/base-graph/index.d.ts.map +1 -0
  4. package/dist/base-graph/index.js +175 -0
  5. package/dist/base-graph/index.js.map +1 -0
  6. package/dist/bin/codegraph.d.ts +28 -0
  7. package/dist/bin/codegraph.d.ts.map +1 -0
  8. package/dist/bin/codegraph.js +2615 -0
  9. package/dist/bin/codegraph.js.map +1 -0
  10. package/dist/bin/command-supervision.d.ts +49 -0
  11. package/dist/bin/command-supervision.d.ts.map +1 -0
  12. package/dist/bin/command-supervision.js +95 -0
  13. package/dist/bin/command-supervision.js.map +1 -0
  14. package/dist/bin/fatal-handler.d.ts +20 -0
  15. package/dist/bin/fatal-handler.d.ts.map +1 -0
  16. package/dist/bin/fatal-handler.js +118 -0
  17. package/dist/bin/fatal-handler.js.map +1 -0
  18. package/dist/bin/node-version-check.d.ts +45 -0
  19. package/dist/bin/node-version-check.d.ts.map +1 -0
  20. package/dist/bin/node-version-check.js +98 -0
  21. package/dist/bin/node-version-check.js.map +1 -0
  22. package/dist/bin/uninstall.d.ts +14 -0
  23. package/dist/bin/uninstall.d.ts.map +1 -0
  24. package/dist/bin/uninstall.js +36 -0
  25. package/dist/bin/uninstall.js.map +1 -0
  26. package/dist/context/formatter.d.ts +36 -0
  27. package/dist/context/formatter.d.ts.map +1 -0
  28. package/dist/context/formatter.js +269 -0
  29. package/dist/context/formatter.js.map +1 -0
  30. package/dist/context/index.d.ts +131 -0
  31. package/dist/context/index.d.ts.map +1 -0
  32. package/dist/context/index.js +1378 -0
  33. package/dist/context/index.js.map +1 -0
  34. package/dist/context/markers.d.ts +19 -0
  35. package/dist/context/markers.d.ts.map +1 -0
  36. package/dist/context/markers.js +22 -0
  37. package/dist/context/markers.js.map +1 -0
  38. package/dist/db/index.d.ts +380 -0
  39. package/dist/db/index.d.ts.map +1 -0
  40. package/dist/db/index.js +854 -0
  41. package/dist/db/index.js.map +1 -0
  42. package/dist/db/migrations.d.ts +44 -0
  43. package/dist/db/migrations.d.ts.map +1 -0
  44. package/dist/db/migrations.js +255 -0
  45. package/dist/db/migrations.js.map +1 -0
  46. package/dist/db/queries.d.ts +1060 -0
  47. package/dist/db/queries.d.ts.map +1 -0
  48. package/dist/db/queries.js +3191 -0
  49. package/dist/db/queries.js.map +1 -0
  50. package/dist/db/schema.sql +209 -0
  51. package/dist/db/sqlite-adapter.d.ts +55 -0
  52. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  53. package/dist/db/sqlite-adapter.js +135 -0
  54. package/dist/db/sqlite-adapter.js.map +1 -0
  55. package/dist/db/wal-valve.d.ts +119 -0
  56. package/dist/db/wal-valve.d.ts.map +1 -0
  57. package/dist/db/wal-valve.js +290 -0
  58. package/dist/db/wal-valve.js.map +1 -0
  59. package/dist/directory.d.ts +213 -0
  60. package/dist/directory.d.ts.map +1 -0
  61. package/dist/directory.js +781 -0
  62. package/dist/directory.js.map +1 -0
  63. package/dist/errors.d.ts +150 -0
  64. package/dist/errors.d.ts.map +1 -0
  65. package/dist/errors.js +234 -0
  66. package/dist/errors.js.map +1 -0
  67. package/dist/extraction/extraction-version.d.ts +25 -0
  68. package/dist/extraction/extraction-version.d.ts.map +1 -0
  69. package/dist/extraction/extraction-version.js +28 -0
  70. package/dist/extraction/extraction-version.js.map +1 -0
  71. package/dist/extraction/function-ref.d.ts +118 -0
  72. package/dist/extraction/function-ref.d.ts.map +1 -0
  73. package/dist/extraction/function-ref.js +746 -0
  74. package/dist/extraction/function-ref.js.map +1 -0
  75. package/dist/extraction/generated-detection.d.ts +66 -0
  76. package/dist/extraction/generated-detection.d.ts.map +1 -0
  77. package/dist/extraction/generated-detection.js +248 -0
  78. package/dist/extraction/generated-detection.js.map +1 -0
  79. package/dist/extraction/grammars.d.ts +148 -0
  80. package/dist/extraction/grammars.d.ts.map +1 -0
  81. package/dist/extraction/grammars.js +558 -0
  82. package/dist/extraction/grammars.js.map +1 -0
  83. package/dist/extraction/index.d.ts +367 -0
  84. package/dist/extraction/index.d.ts.map +1 -0
  85. package/dist/extraction/index.js +2833 -0
  86. package/dist/extraction/index.js.map +1 -0
  87. package/dist/extraction/kernel/decode.d.ts +9 -0
  88. package/dist/extraction/kernel/decode.d.ts.map +1 -0
  89. package/dist/extraction/kernel/decode.js +162 -0
  90. package/dist/extraction/kernel/decode.js.map +1 -0
  91. package/dist/extraction/kernel/index.d.ts +64 -0
  92. package/dist/extraction/kernel/index.d.ts.map +1 -0
  93. package/dist/extraction/kernel/index.js +204 -0
  94. package/dist/extraction/kernel/index.js.map +1 -0
  95. package/dist/extraction/kernel/layout.d.ts +101 -0
  96. package/dist/extraction/kernel/layout.d.ts.map +1 -0
  97. package/dist/extraction/kernel/layout.js +104 -0
  98. package/dist/extraction/kernel/layout.js.map +1 -0
  99. package/dist/extraction/kernel/loader.d.ts +103 -0
  100. package/dist/extraction/kernel/loader.d.ts.map +1 -0
  101. package/dist/extraction/kernel/loader.js +146 -0
  102. package/dist/extraction/kernel/loader.js.map +1 -0
  103. package/dist/extraction/languages/c-cpp.d.ts +124 -0
  104. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  105. package/dist/extraction/languages/c-cpp.js +1689 -0
  106. package/dist/extraction/languages/c-cpp.js.map +1 -0
  107. package/dist/extraction/languages/index.d.ts +11 -0
  108. package/dist/extraction/languages/index.d.ts.map +1 -0
  109. package/dist/extraction/languages/index.js +15 -0
  110. package/dist/extraction/languages/index.js.map +1 -0
  111. package/dist/extraction/languages/java.d.ts +3 -0
  112. package/dist/extraction/languages/java.d.ts.map +1 -0
  113. package/dist/extraction/languages/java.js +315 -0
  114. package/dist/extraction/languages/java.js.map +1 -0
  115. package/dist/extraction/languages/rust.d.ts +23 -0
  116. package/dist/extraction/languages/rust.d.ts.map +1 -0
  117. package/dist/extraction/languages/rust.js +169 -0
  118. package/dist/extraction/languages/rust.js.map +1 -0
  119. package/dist/extraction/parse-pool.d.ts +167 -0
  120. package/dist/extraction/parse-pool.d.ts.map +1 -0
  121. package/dist/extraction/parse-pool.js +421 -0
  122. package/dist/extraction/parse-pool.js.map +1 -0
  123. package/dist/extraction/parse-worker.d.ts +8 -0
  124. package/dist/extraction/parse-worker.d.ts.map +1 -0
  125. package/dist/extraction/parse-worker.js +138 -0
  126. package/dist/extraction/parse-worker.js.map +1 -0
  127. package/dist/extraction/store-worker.d.ts +24 -0
  128. package/dist/extraction/store-worker.d.ts.map +1 -0
  129. package/dist/extraction/store-worker.js +139 -0
  130. package/dist/extraction/store-worker.js.map +1 -0
  131. package/dist/extraction/store-writer.d.ts +63 -0
  132. package/dist/extraction/store-writer.d.ts.map +1 -0
  133. package/dist/extraction/store-writer.js +174 -0
  134. package/dist/extraction/store-writer.js.map +1 -0
  135. package/dist/extraction/syntax-tokens.d.ts +103 -0
  136. package/dist/extraction/syntax-tokens.d.ts.map +1 -0
  137. package/dist/extraction/syntax-tokens.js +381 -0
  138. package/dist/extraction/syntax-tokens.js.map +1 -0
  139. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  140. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  141. package/dist/extraction/tree-sitter-helpers.js +153 -0
  142. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  143. package/dist/extraction/tree-sitter-types.d.ts +260 -0
  144. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  145. package/dist/extraction/tree-sitter-types.js +10 -0
  146. package/dist/extraction/tree-sitter-types.js.map +1 -0
  147. package/dist/extraction/tree-sitter.d.ts +745 -0
  148. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  149. package/dist/extraction/tree-sitter.js +6725 -0
  150. package/dist/extraction/tree-sitter.js.map +1 -0
  151. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  152. package/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  153. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  154. package/dist/extraction/wasm-runtime-flags.js +130 -0
  155. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  156. package/dist/graph/branch-guards.d.ts +248 -0
  157. package/dist/graph/branch-guards.d.ts.map +1 -0
  158. package/dist/graph/branch-guards.js +2231 -0
  159. package/dist/graph/branch-guards.js.map +1 -0
  160. package/dist/graph/dead-code.d.ts +251 -0
  161. package/dist/graph/dead-code.d.ts.map +1 -0
  162. package/dist/graph/dead-code.js +756 -0
  163. package/dist/graph/dead-code.js.map +1 -0
  164. package/dist/graph/dynamic-boundary-report.d.ts +121 -0
  165. package/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  166. package/dist/graph/dynamic-boundary-report.js +283 -0
  167. package/dist/graph/dynamic-boundary-report.js.map +1 -0
  168. package/dist/graph/index.d.ts +12 -0
  169. package/dist/graph/index.d.ts.map +1 -0
  170. package/dist/graph/index.js +28 -0
  171. package/dist/graph/index.js.map +1 -0
  172. package/dist/graph/named-symbol-flow.d.ts +153 -0
  173. package/dist/graph/named-symbol-flow.d.ts.map +1 -0
  174. package/dist/graph/named-symbol-flow.js +609 -0
  175. package/dist/graph/named-symbol-flow.js.map +1 -0
  176. package/dist/graph/queries.d.ts +106 -0
  177. package/dist/graph/queries.d.ts.map +1 -0
  178. package/dist/graph/queries.js +341 -0
  179. package/dist/graph/queries.js.map +1 -0
  180. package/dist/graph/traversal.d.ts +127 -0
  181. package/dist/graph/traversal.d.ts.map +1 -0
  182. package/dist/graph/traversal.js +599 -0
  183. package/dist/graph/traversal.js.map +1 -0
  184. package/dist/graph/type-hierarchy.d.ts +155 -0
  185. package/dist/graph/type-hierarchy.d.ts.map +1 -0
  186. package/dist/graph/type-hierarchy.js +382 -0
  187. package/dist/graph/type-hierarchy.js.map +1 -0
  188. package/dist/index.d.ts +886 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +2019 -0
  191. package/dist/index.js.map +1 -0
  192. package/dist/installer/beta-signup.d.ts +54 -0
  193. package/dist/installer/beta-signup.d.ts.map +1 -0
  194. package/dist/installer/beta-signup.js +178 -0
  195. package/dist/installer/beta-signup.js.map +1 -0
  196. package/dist/installer/config-writer.d.ts +28 -0
  197. package/dist/installer/config-writer.d.ts.map +1 -0
  198. package/dist/installer/config-writer.js +91 -0
  199. package/dist/installer/config-writer.js.map +1 -0
  200. package/dist/installer/index.d.ts +143 -0
  201. package/dist/installer/index.d.ts.map +1 -0
  202. package/dist/installer/index.js +632 -0
  203. package/dist/installer/index.js.map +1 -0
  204. package/dist/installer/instructions-template.d.ts +41 -0
  205. package/dist/installer/instructions-template.d.ts.map +1 -0
  206. package/dist/installer/instructions-template.js +53 -0
  207. package/dist/installer/instructions-template.js.map +1 -0
  208. package/dist/installer/targets/antigravity.d.ts +57 -0
  209. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  210. package/dist/installer/targets/antigravity.js +308 -0
  211. package/dist/installer/targets/antigravity.js.map +1 -0
  212. package/dist/installer/targets/claude.d.ts +62 -0
  213. package/dist/installer/targets/claude.d.ts.map +1 -0
  214. package/dist/installer/targets/claude.js +486 -0
  215. package/dist/installer/targets/claude.js.map +1 -0
  216. package/dist/installer/targets/codex.d.ts +32 -0
  217. package/dist/installer/targets/codex.d.ts.map +1 -0
  218. package/dist/installer/targets/codex.js +202 -0
  219. package/dist/installer/targets/codex.js.map +1 -0
  220. package/dist/installer/targets/copilot-cli.d.ts +32 -0
  221. package/dist/installer/targets/copilot-cli.d.ts.map +1 -0
  222. package/dist/installer/targets/copilot-cli.js +209 -0
  223. package/dist/installer/targets/copilot-cli.js.map +1 -0
  224. package/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
  225. package/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
  226. package/dist/installer/targets/copilot-jetbrains.js +238 -0
  227. package/dist/installer/targets/copilot-jetbrains.js.map +1 -0
  228. package/dist/installer/targets/copilot-vscode.d.ts +47 -0
  229. package/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
  230. package/dist/installer/targets/copilot-vscode.js +219 -0
  231. package/dist/installer/targets/copilot-vscode.js.map +1 -0
  232. package/dist/installer/targets/cursor.d.ts +35 -0
  233. package/dist/installer/targets/cursor.d.ts.map +1 -0
  234. package/dist/installer/targets/cursor.js +254 -0
  235. package/dist/installer/targets/cursor.js.map +1 -0
  236. package/dist/installer/targets/gemini.d.ts +26 -0
  237. package/dist/installer/targets/gemini.d.ts.map +1 -0
  238. package/dist/installer/targets/gemini.js +165 -0
  239. package/dist/installer/targets/gemini.js.map +1 -0
  240. package/dist/installer/targets/hermes.d.ts +18 -0
  241. package/dist/installer/targets/hermes.d.ts.map +1 -0
  242. package/dist/installer/targets/hermes.js +359 -0
  243. package/dist/installer/targets/hermes.js.map +1 -0
  244. package/dist/installer/targets/kiro.d.ts +27 -0
  245. package/dist/installer/targets/kiro.d.ts.map +1 -0
  246. package/dist/installer/targets/kiro.js +178 -0
  247. package/dist/installer/targets/kiro.js.map +1 -0
  248. package/dist/installer/targets/opencode.d.ts +38 -0
  249. package/dist/installer/targets/opencode.d.ts.map +1 -0
  250. package/dist/installer/targets/opencode.js +288 -0
  251. package/dist/installer/targets/opencode.js.map +1 -0
  252. package/dist/installer/targets/registry.d.ts +35 -0
  253. package/dist/installer/targets/registry.d.ts.map +1 -0
  254. package/dist/installer/targets/registry.js +101 -0
  255. package/dist/installer/targets/registry.js.map +1 -0
  256. package/dist/installer/targets/shared.d.ts +101 -0
  257. package/dist/installer/targets/shared.d.ts.map +1 -0
  258. package/dist/installer/targets/shared.js +264 -0
  259. package/dist/installer/targets/shared.js.map +1 -0
  260. package/dist/installer/targets/toml.d.ts +53 -0
  261. package/dist/installer/targets/toml.d.ts.map +1 -0
  262. package/dist/installer/targets/toml.js +226 -0
  263. package/dist/installer/targets/toml.js.map +1 -0
  264. package/dist/installer/targets/trae.d.ts +30 -0
  265. package/dist/installer/targets/trae.d.ts.map +1 -0
  266. package/dist/installer/targets/trae.js +164 -0
  267. package/dist/installer/targets/trae.js.map +1 -0
  268. package/dist/installer/targets/types.d.ts +108 -0
  269. package/dist/installer/targets/types.d.ts.map +1 -0
  270. package/dist/installer/targets/types.js +16 -0
  271. package/dist/installer/targets/types.js.map +1 -0
  272. package/dist/installer/targets/workbuddy.d.ts +29 -0
  273. package/dist/installer/targets/workbuddy.d.ts.map +1 -0
  274. package/dist/installer/targets/workbuddy.js +163 -0
  275. package/dist/installer/targets/workbuddy.js.map +1 -0
  276. package/dist/mcp/daemon-manager.d.ts +42 -0
  277. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  278. package/dist/mcp/daemon-manager.js +129 -0
  279. package/dist/mcp/daemon-manager.js.map +1 -0
  280. package/dist/mcp/daemon-paths.d.ts +79 -0
  281. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  282. package/dist/mcp/daemon-paths.js +219 -0
  283. package/dist/mcp/daemon-paths.js.map +1 -0
  284. package/dist/mcp/daemon-registry.d.ts +57 -0
  285. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  286. package/dist/mcp/daemon-registry.js +281 -0
  287. package/dist/mcp/daemon-registry.js.map +1 -0
  288. package/dist/mcp/daemon.d.ts +293 -0
  289. package/dist/mcp/daemon.d.ts.map +1 -0
  290. package/dist/mcp/daemon.js +864 -0
  291. package/dist/mcp/daemon.js.map +1 -0
  292. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  293. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  294. package/dist/mcp/dynamic-boundaries.js +360 -0
  295. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  296. package/dist/mcp/early-ppid.d.ts +26 -0
  297. package/dist/mcp/early-ppid.d.ts.map +1 -0
  298. package/dist/mcp/early-ppid.js +29 -0
  299. package/dist/mcp/early-ppid.js.map +1 -0
  300. package/dist/mcp/engine.d.ts +125 -0
  301. package/dist/mcp/engine.d.ts.map +1 -0
  302. package/dist/mcp/engine.js +392 -0
  303. package/dist/mcp/engine.js.map +1 -0
  304. package/dist/mcp/explore-dedup.d.ts +137 -0
  305. package/dist/mcp/explore-dedup.d.ts.map +1 -0
  306. package/dist/mcp/explore-dedup.js +236 -0
  307. package/dist/mcp/explore-dedup.js.map +1 -0
  308. package/dist/mcp/explore-diagnostics.d.ts +289 -0
  309. package/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  310. package/dist/mcp/explore-diagnostics.js +558 -0
  311. package/dist/mcp/explore-diagnostics.js.map +1 -0
  312. package/dist/mcp/explore-session-state.d.ts +217 -0
  313. package/dist/mcp/explore-session-state.d.ts.map +1 -0
  314. package/dist/mcp/explore-session-state.js +322 -0
  315. package/dist/mcp/explore-session-state.js.map +1 -0
  316. package/dist/mcp/index.d.ts +137 -0
  317. package/dist/mcp/index.d.ts.map +1 -0
  318. package/dist/mcp/index.js +567 -0
  319. package/dist/mcp/index.js.map +1 -0
  320. package/dist/mcp/liveness-watchdog.d.ts +35 -0
  321. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  322. package/dist/mcp/liveness-watchdog.js +269 -0
  323. package/dist/mcp/liveness-watchdog.js.map +1 -0
  324. package/dist/mcp/ppid-watchdog.d.ts +62 -0
  325. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  326. package/dist/mcp/ppid-watchdog.js +64 -0
  327. package/dist/mcp/ppid-watchdog.js.map +1 -0
  328. package/dist/mcp/proxy.d.ts +87 -0
  329. package/dist/mcp/proxy.d.ts.map +1 -0
  330. package/dist/mcp/proxy.js +672 -0
  331. package/dist/mcp/proxy.js.map +1 -0
  332. package/dist/mcp/query-pool.d.ts +108 -0
  333. package/dist/mcp/query-pool.d.ts.map +1 -0
  334. package/dist/mcp/query-pool.js +315 -0
  335. package/dist/mcp/query-pool.js.map +1 -0
  336. package/dist/mcp/query-worker.d.ts +24 -0
  337. package/dist/mcp/query-worker.d.ts.map +1 -0
  338. package/dist/mcp/query-worker.js +87 -0
  339. package/dist/mcp/query-worker.js.map +1 -0
  340. package/dist/mcp/server-instructions.d.ts +34 -0
  341. package/dist/mcp/server-instructions.d.ts.map +1 -0
  342. package/dist/mcp/server-instructions.js +111 -0
  343. package/dist/mcp/server-instructions.js.map +1 -0
  344. package/dist/mcp/session.d.ts +109 -0
  345. package/dist/mcp/session.d.ts.map +1 -0
  346. package/dist/mcp/session.js +380 -0
  347. package/dist/mcp/session.js.map +1 -0
  348. package/dist/mcp/startup-handshake.d.ts +44 -0
  349. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  350. package/dist/mcp/startup-handshake.js +73 -0
  351. package/dist/mcp/startup-handshake.js.map +1 -0
  352. package/dist/mcp/stdin-teardown.d.ts +27 -0
  353. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  354. package/dist/mcp/stdin-teardown.js +49 -0
  355. package/dist/mcp/stdin-teardown.js.map +1 -0
  356. package/dist/mcp/tools.d.ts +877 -0
  357. package/dist/mcp/tools.d.ts.map +1 -0
  358. package/dist/mcp/tools.js +6371 -0
  359. package/dist/mcp/tools.js.map +1 -0
  360. package/dist/mcp/transport.d.ts +188 -0
  361. package/dist/mcp/transport.d.ts.map +1 -0
  362. package/dist/mcp/transport.js +377 -0
  363. package/dist/mcp/transport.js.map +1 -0
  364. package/dist/mcp/version.d.ts +19 -0
  365. package/dist/mcp/version.d.ts.map +1 -0
  366. package/dist/mcp/version.js +71 -0
  367. package/dist/mcp/version.js.map +1 -0
  368. package/dist/project-config.d.ts +158 -0
  369. package/dist/project-config.d.ts.map +1 -0
  370. package/dist/project-config.js +489 -0
  371. package/dist/project-config.js.map +1 -0
  372. package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  373. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  374. package/dist/resolution/c-fnptr-synthesizer.js +1506 -0
  375. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  376. package/dist/resolution/callback-synthesizer.d.ts +59 -0
  377. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  378. package/dist/resolution/callback-synthesizer.js +4066 -0
  379. package/dist/resolution/callback-synthesizer.js.map +1 -0
  380. package/dist/resolution/cooperative-yield.d.ts +40 -0
  381. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  382. package/dist/resolution/cooperative-yield.js +44 -0
  383. package/dist/resolution/cooperative-yield.js.map +1 -0
  384. package/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  385. package/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  386. package/dist/resolution/expo-router-synthesizer.js +189 -0
  387. package/dist/resolution/expo-router-synthesizer.js.map +1 -0
  388. package/dist/resolution/frameworks/astro.d.ts +9 -0
  389. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  390. package/dist/resolution/frameworks/astro.js +169 -0
  391. package/dist/resolution/frameworks/astro.js.map +1 -0
  392. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  393. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  394. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  395. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  396. package/dist/resolution/frameworks/cics.d.ts +20 -0
  397. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  398. package/dist/resolution/frameworks/cics.js +90 -0
  399. package/dist/resolution/frameworks/cics.js.map +1 -0
  400. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  401. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  402. package/dist/resolution/frameworks/csharp.js +335 -0
  403. package/dist/resolution/frameworks/csharp.js.map +1 -0
  404. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  405. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  406. package/dist/resolution/frameworks/drupal.js +367 -0
  407. package/dist/resolution/frameworks/drupal.js.map +1 -0
  408. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  409. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  410. package/dist/resolution/frameworks/expo-modules.js +148 -0
  411. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  412. package/dist/resolution/frameworks/expo-router.d.ts +189 -0
  413. package/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  414. package/dist/resolution/frameworks/expo-router.js +785 -0
  415. package/dist/resolution/frameworks/expo-router.js.map +1 -0
  416. package/dist/resolution/frameworks/express.d.ts +8 -0
  417. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  418. package/dist/resolution/frameworks/express.js +540 -0
  419. package/dist/resolution/frameworks/express.js.map +1 -0
  420. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  421. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  422. package/dist/resolution/frameworks/fabric.js +354 -0
  423. package/dist/resolution/frameworks/fabric.js.map +1 -0
  424. package/dist/resolution/frameworks/go.d.ts +8 -0
  425. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  426. package/dist/resolution/frameworks/go.js +184 -0
  427. package/dist/resolution/frameworks/go.js.map +1 -0
  428. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  429. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  430. package/dist/resolution/frameworks/goframe.js +112 -0
  431. package/dist/resolution/frameworks/goframe.js.map +1 -0
  432. package/dist/resolution/frameworks/index.d.ts +30 -0
  433. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  434. package/dist/resolution/frameworks/index.js +72 -0
  435. package/dist/resolution/frameworks/index.js.map +1 -0
  436. package/dist/resolution/frameworks/java.d.ts +8 -0
  437. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  438. package/dist/resolution/frameworks/java.js +517 -0
  439. package/dist/resolution/frameworks/java.js.map +1 -0
  440. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  441. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  442. package/dist/resolution/frameworks/laravel.js +257 -0
  443. package/dist/resolution/frameworks/laravel.js.map +1 -0
  444. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  445. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  446. package/dist/resolution/frameworks/nestjs.js +690 -0
  447. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  448. package/dist/resolution/frameworks/nextjs.d.ts +76 -0
  449. package/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  450. package/dist/resolution/frameworks/nextjs.js +328 -0
  451. package/dist/resolution/frameworks/nextjs.js.map +1 -0
  452. package/dist/resolution/frameworks/object-literal.d.ts +32 -0
  453. package/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  454. package/dist/resolution/frameworks/object-literal.js +139 -0
  455. package/dist/resolution/frameworks/object-literal.js.map +1 -0
  456. package/dist/resolution/frameworks/package-deps.d.ts +14 -0
  457. package/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  458. package/dist/resolution/frameworks/package-deps.js +78 -0
  459. package/dist/resolution/frameworks/package-deps.js.map +1 -0
  460. package/dist/resolution/frameworks/play.d.ts +19 -0
  461. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  462. package/dist/resolution/frameworks/play.js +111 -0
  463. package/dist/resolution/frameworks/play.js.map +1 -0
  464. package/dist/resolution/frameworks/python.d.ts +10 -0
  465. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  466. package/dist/resolution/frameworks/python.js +566 -0
  467. package/dist/resolution/frameworks/python.js.map +1 -0
  468. package/dist/resolution/frameworks/react-native.d.ts +29 -0
  469. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  470. package/dist/resolution/frameworks/react-native.js +549 -0
  471. package/dist/resolution/frameworks/react-native.js.map +1 -0
  472. package/dist/resolution/frameworks/react-router.d.ts +46 -0
  473. package/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  474. package/dist/resolution/frameworks/react-router.js +187 -0
  475. package/dist/resolution/frameworks/react-router.js.map +1 -0
  476. package/dist/resolution/frameworks/react.d.ts +9 -0
  477. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  478. package/dist/resolution/frameworks/react.js +257 -0
  479. package/dist/resolution/frameworks/react.js.map +1 -0
  480. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  481. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  482. package/dist/resolution/frameworks/ruby.js +302 -0
  483. package/dist/resolution/frameworks/ruby.js.map +1 -0
  484. package/dist/resolution/frameworks/rust.d.ts +8 -0
  485. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  486. package/dist/resolution/frameworks/rust.js +304 -0
  487. package/dist/resolution/frameworks/rust.js.map +1 -0
  488. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  489. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  490. package/dist/resolution/frameworks/svelte.js +258 -0
  491. package/dist/resolution/frameworks/svelte.js.map +1 -0
  492. package/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  493. package/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  494. package/dist/resolution/frameworks/sveltekit-router.js +156 -0
  495. package/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  496. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  497. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  498. package/dist/resolution/frameworks/swift-objc.js +252 -0
  499. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  500. package/dist/resolution/frameworks/swift.d.ts +10 -0
  501. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  502. package/dist/resolution/frameworks/swift.js +410 -0
  503. package/dist/resolution/frameworks/swift.js.map +1 -0
  504. package/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  505. package/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  506. package/dist/resolution/frameworks/tanstack-router.js +437 -0
  507. package/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  508. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  509. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  510. package/dist/resolution/frameworks/terraform.js +277 -0
  511. package/dist/resolution/frameworks/terraform.js.map +1 -0
  512. package/dist/resolution/frameworks/vue-router.d.ts +82 -0
  513. package/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  514. package/dist/resolution/frameworks/vue-router.js +377 -0
  515. package/dist/resolution/frameworks/vue-router.js.map +1 -0
  516. package/dist/resolution/frameworks/vue.d.ts +9 -0
  517. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  518. package/dist/resolution/frameworks/vue.js +303 -0
  519. package/dist/resolution/frameworks/vue.js.map +1 -0
  520. package/dist/resolution/go-module.d.ts +26 -0
  521. package/dist/resolution/go-module.d.ts.map +1 -0
  522. package/dist/resolution/go-module.js +78 -0
  523. package/dist/resolution/go-module.js.map +1 -0
  524. package/dist/resolution/goframe-synthesizer.d.ts +29 -0
  525. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  526. package/dist/resolution/goframe-synthesizer.js +163 -0
  527. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  528. package/dist/resolution/import-resolver.d.ts +84 -0
  529. package/dist/resolution/import-resolver.d.ts.map +1 -0
  530. package/dist/resolution/import-resolver.js +2240 -0
  531. package/dist/resolution/import-resolver.js.map +1 -0
  532. package/dist/resolution/index.d.ts +343 -0
  533. package/dist/resolution/index.d.ts.map +1 -0
  534. package/dist/resolution/index.js +2352 -0
  535. package/dist/resolution/index.js.map +1 -0
  536. package/dist/resolution/lru-cache.d.ts +24 -0
  537. package/dist/resolution/lru-cache.d.ts.map +1 -0
  538. package/dist/resolution/lru-cache.js +62 -0
  539. package/dist/resolution/lru-cache.js.map +1 -0
  540. package/dist/resolution/memory-budget.d.ts +48 -0
  541. package/dist/resolution/memory-budget.d.ts.map +1 -0
  542. package/dist/resolution/memory-budget.js +162 -0
  543. package/dist/resolution/memory-budget.js.map +1 -0
  544. package/dist/resolution/name-matcher.d.ts +153 -0
  545. package/dist/resolution/name-matcher.d.ts.map +1 -0
  546. package/dist/resolution/name-matcher.js +2412 -0
  547. package/dist/resolution/name-matcher.js.map +1 -0
  548. package/dist/resolution/next-router-synthesizer.d.ts +27 -0
  549. package/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  550. package/dist/resolution/next-router-synthesizer.js +113 -0
  551. package/dist/resolution/next-router-synthesizer.js.map +1 -0
  552. package/dist/resolution/path-aliases.d.ts +70 -0
  553. package/dist/resolution/path-aliases.d.ts.map +1 -0
  554. package/dist/resolution/path-aliases.js +346 -0
  555. package/dist/resolution/path-aliases.js.map +1 -0
  556. package/dist/resolution/react-router-synthesizer.d.ts +33 -0
  557. package/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  558. package/dist/resolution/react-router-synthesizer.js +126 -0
  559. package/dist/resolution/react-router-synthesizer.js.map +1 -0
  560. package/dist/resolution/resolver-pool.d.ts +106 -0
  561. package/dist/resolution/resolver-pool.d.ts.map +1 -0
  562. package/dist/resolution/resolver-pool.js +344 -0
  563. package/dist/resolution/resolver-pool.js.map +1 -0
  564. package/dist/resolution/resolver-worker.d.ts +17 -0
  565. package/dist/resolution/resolver-worker.d.ts.map +1 -0
  566. package/dist/resolution/resolver-worker.js +141 -0
  567. package/dist/resolution/resolver-worker.js.map +1 -0
  568. package/dist/resolution/strip-comments.d.ts +27 -0
  569. package/dist/resolution/strip-comments.d.ts.map +1 -0
  570. package/dist/resolution/strip-comments.js +492 -0
  571. package/dist/resolution/strip-comments.js.map +1 -0
  572. package/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  573. package/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  574. package/dist/resolution/sveltekit-synthesizer.js +173 -0
  575. package/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  576. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  577. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  578. package/dist/resolution/swift-objc-bridge.js +256 -0
  579. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  580. package/dist/resolution/synth-utils.d.ts +26 -0
  581. package/dist/resolution/synth-utils.d.ts.map +1 -0
  582. package/dist/resolution/synth-utils.js +75 -0
  583. package/dist/resolution/synth-utils.js.map +1 -0
  584. package/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  585. package/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  586. package/dist/resolution/tanstack-router-synthesizer.js +114 -0
  587. package/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  588. package/dist/resolution/tier-synthesizer.d.ts +48 -0
  589. package/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  590. package/dist/resolution/tier-synthesizer.js +907 -0
  591. package/dist/resolution/tier-synthesizer.js.map +1 -0
  592. package/dist/resolution/types.d.ts +290 -0
  593. package/dist/resolution/types.d.ts.map +1 -0
  594. package/dist/resolution/types.js +8 -0
  595. package/dist/resolution/types.js.map +1 -0
  596. package/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  597. package/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  598. package/dist/resolution/vue-router-synthesizer.js +115 -0
  599. package/dist/resolution/vue-router-synthesizer.js.map +1 -0
  600. package/dist/resolution/workspace-packages.d.ts +58 -0
  601. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  602. package/dist/resolution/workspace-packages.js +346 -0
  603. package/dist/resolution/workspace-packages.js.map +1 -0
  604. package/dist/search/identifier-segments.d.ts +70 -0
  605. package/dist/search/identifier-segments.d.ts.map +1 -0
  606. package/dist/search/identifier-segments.js +205 -0
  607. package/dist/search/identifier-segments.js.map +1 -0
  608. package/dist/search/query-parser.d.ts +57 -0
  609. package/dist/search/query-parser.d.ts.map +1 -0
  610. package/dist/search/query-parser.js +177 -0
  611. package/dist/search/query-parser.js.map +1 -0
  612. package/dist/search/query-paths.d.ts +57 -0
  613. package/dist/search/query-paths.d.ts.map +1 -0
  614. package/dist/search/query-paths.js +298 -0
  615. package/dist/search/query-paths.js.map +1 -0
  616. package/dist/search/query-utils.d.ts +102 -0
  617. package/dist/search/query-utils.d.ts.map +1 -0
  618. package/dist/search/query-utils.js +487 -0
  619. package/dist/search/query-utils.js.map +1 -0
  620. package/dist/sync/git-hooks.d.ts +45 -0
  621. package/dist/sync/git-hooks.d.ts.map +1 -0
  622. package/dist/sync/git-hooks.js +227 -0
  623. package/dist/sync/git-hooks.js.map +1 -0
  624. package/dist/sync/index.d.ts +19 -0
  625. package/dist/sync/index.d.ts.map +1 -0
  626. package/dist/sync/index.js +35 -0
  627. package/dist/sync/index.js.map +1 -0
  628. package/dist/sync/watch-policy.d.ts +48 -0
  629. package/dist/sync/watch-policy.d.ts.map +1 -0
  630. package/dist/sync/watch-policy.js +124 -0
  631. package/dist/sync/watch-policy.js.map +1 -0
  632. package/dist/sync/watcher.d.ts +401 -0
  633. package/dist/sync/watcher.d.ts.map +1 -0
  634. package/dist/sync/watcher.js +967 -0
  635. package/dist/sync/watcher.js.map +1 -0
  636. package/dist/sync/worktree.d.ts +63 -0
  637. package/dist/sync/worktree.d.ts.map +1 -0
  638. package/dist/sync/worktree.js +182 -0
  639. package/dist/sync/worktree.js.map +1 -0
  640. package/dist/telemetry/index.d.ts +143 -0
  641. package/dist/telemetry/index.d.ts.map +1 -0
  642. package/dist/telemetry/index.js +541 -0
  643. package/dist/telemetry/index.js.map +1 -0
  644. package/dist/types.d.ts +486 -0
  645. package/dist/types.d.ts.map +1 -0
  646. package/dist/types.js +118 -0
  647. package/dist/types.js.map +1 -0
  648. package/dist/ui/color.d.ts +21 -0
  649. package/dist/ui/color.d.ts.map +1 -0
  650. package/dist/ui/color.js +42 -0
  651. package/dist/ui/color.js.map +1 -0
  652. package/dist/ui/glyphs.d.ts +67 -0
  653. package/dist/ui/glyphs.d.ts.map +1 -0
  654. package/dist/ui/glyphs.js +125 -0
  655. package/dist/ui/glyphs.js.map +1 -0
  656. package/dist/ui/shimmer-progress.d.ts +11 -0
  657. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  658. package/dist/ui/shimmer-progress.js +164 -0
  659. package/dist/ui/shimmer-progress.js.map +1 -0
  660. package/dist/ui/shimmer-worker.d.ts +2 -0
  661. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  662. package/dist/ui/shimmer-worker.js +126 -0
  663. package/dist/ui/shimmer-worker.js.map +1 -0
  664. package/dist/ui/types.d.ts +15 -0
  665. package/dist/ui/types.d.ts.map +1 -0
  666. package/dist/ui/types.js +3 -0
  667. package/dist/ui/types.js.map +1 -0
  668. package/dist/ui-server/api/deadcode.d.ts +84 -0
  669. package/dist/ui-server/api/deadcode.d.ts.map +1 -0
  670. package/dist/ui-server/api/deadcode.js +136 -0
  671. package/dist/ui-server/api/deadcode.js.map +1 -0
  672. package/dist/ui-server/api/effects.d.ts +87 -0
  673. package/dist/ui-server/api/effects.d.ts.map +1 -0
  674. package/dist/ui-server/api/effects.js +499 -0
  675. package/dist/ui-server/api/effects.js.map +1 -0
  676. package/dist/ui-server/api/entrypoints.d.ts +86 -0
  677. package/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  678. package/dist/ui-server/api/entrypoints.js +279 -0
  679. package/dist/ui-server/api/entrypoints.js.map +1 -0
  680. package/dist/ui-server/api/events.d.ts +183 -0
  681. package/dist/ui-server/api/events.d.ts.map +1 -0
  682. package/dist/ui-server/api/events.js +430 -0
  683. package/dist/ui-server/api/events.js.map +1 -0
  684. package/dist/ui-server/api/file.d.ts +66 -0
  685. package/dist/ui-server/api/file.d.ts.map +1 -0
  686. package/dist/ui-server/api/file.js +222 -0
  687. package/dist/ui-server/api/file.js.map +1 -0
  688. package/dist/ui-server/api/filecode.d.ts +126 -0
  689. package/dist/ui-server/api/filecode.d.ts.map +1 -0
  690. package/dist/ui-server/api/filecode.js +205 -0
  691. package/dist/ui-server/api/filecode.js.map +1 -0
  692. package/dist/ui-server/api/flow.d.ts +226 -0
  693. package/dist/ui-server/api/flow.d.ts.map +1 -0
  694. package/dist/ui-server/api/flow.js +611 -0
  695. package/dist/ui-server/api/flow.js.map +1 -0
  696. package/dist/ui-server/api/hierarchy.d.ts +81 -0
  697. package/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  698. package/dist/ui-server/api/hierarchy.js +92 -0
  699. package/dist/ui-server/api/hierarchy.js.map +1 -0
  700. package/dist/ui-server/api/index.d.ts +90 -0
  701. package/dist/ui-server/api/index.d.ts.map +1 -0
  702. package/dist/ui-server/api/index.js +332 -0
  703. package/dist/ui-server/api/index.js.map +1 -0
  704. package/dist/ui-server/api/map.d.ts +187 -0
  705. package/dist/ui-server/api/map.d.ts.map +1 -0
  706. package/dist/ui-server/api/map.js +498 -0
  707. package/dist/ui-server/api/map.js.map +1 -0
  708. package/dist/ui-server/api/node.d.ts +81 -0
  709. package/dist/ui-server/api/node.d.ts.map +1 -0
  710. package/dist/ui-server/api/node.js +388 -0
  711. package/dist/ui-server/api/node.js.map +1 -0
  712. package/dist/ui-server/api/nodes.d.ts +25 -0
  713. package/dist/ui-server/api/nodes.d.ts.map +1 -0
  714. package/dist/ui-server/api/nodes.js +45 -0
  715. package/dist/ui-server/api/nodes.js.map +1 -0
  716. package/dist/ui-server/api/program.d.ts +139 -0
  717. package/dist/ui-server/api/program.d.ts.map +1 -0
  718. package/dist/ui-server/api/program.js +315 -0
  719. package/dist/ui-server/api/program.js.map +1 -0
  720. package/dist/ui-server/api/respond.d.ts +76 -0
  721. package/dist/ui-server/api/respond.d.ts.map +1 -0
  722. package/dist/ui-server/api/respond.js +186 -0
  723. package/dist/ui-server/api/respond.js.map +1 -0
  724. package/dist/ui-server/api/route-roots.d.ts +39 -0
  725. package/dist/ui-server/api/route-roots.d.ts.map +1 -0
  726. package/dist/ui-server/api/route-roots.js +96 -0
  727. package/dist/ui-server/api/route-roots.js.map +1 -0
  728. package/dist/ui-server/api/routes.d.ts +59 -0
  729. package/dist/ui-server/api/routes.d.ts.map +1 -0
  730. package/dist/ui-server/api/routes.js +112 -0
  731. package/dist/ui-server/api/routes.js.map +1 -0
  732. package/dist/ui-server/api/screens.d.ts +117 -0
  733. package/dist/ui-server/api/screens.d.ts.map +1 -0
  734. package/dist/ui-server/api/screens.js +611 -0
  735. package/dist/ui-server/api/screens.js.map +1 -0
  736. package/dist/ui-server/api/search.d.ts +29 -0
  737. package/dist/ui-server/api/search.d.ts.map +1 -0
  738. package/dist/ui-server/api/search.js +232 -0
  739. package/dist/ui-server/api/search.js.map +1 -0
  740. package/dist/ui-server/api/session.d.ts +52 -0
  741. package/dist/ui-server/api/session.d.ts.map +1 -0
  742. package/dist/ui-server/api/session.js +196 -0
  743. package/dist/ui-server/api/session.js.map +1 -0
  744. package/dist/ui-server/api/source.d.ts +200 -0
  745. package/dist/ui-server/api/source.d.ts.map +1 -0
  746. package/dist/ui-server/api/source.js +419 -0
  747. package/dist/ui-server/api/source.js.map +1 -0
  748. package/dist/ui-server/api/stats.d.ts +27 -0
  749. package/dist/ui-server/api/stats.d.ts.map +1 -0
  750. package/dist/ui-server/api/stats.js +164 -0
  751. package/dist/ui-server/api/stats.js.map +1 -0
  752. package/dist/ui-server/api/steps.d.ts +274 -0
  753. package/dist/ui-server/api/steps.d.ts.map +1 -0
  754. package/dist/ui-server/api/steps.js +1446 -0
  755. package/dist/ui-server/api/steps.js.map +1 -0
  756. package/dist/ui-server/api/trail-store.d.ts +142 -0
  757. package/dist/ui-server/api/trail-store.d.ts.map +1 -0
  758. package/dist/ui-server/api/trail-store.js +323 -0
  759. package/dist/ui-server/api/trail-store.js.map +1 -0
  760. package/dist/ui-server/api/trails.d.ts +163 -0
  761. package/dist/ui-server/api/trails.d.ts.map +1 -0
  762. package/dist/ui-server/api/trails.js +369 -0
  763. package/dist/ui-server/api/trails.js.map +1 -0
  764. package/dist/ui-server/api/when.d.ts +125 -0
  765. package/dist/ui-server/api/when.d.ts.map +1 -0
  766. package/dist/ui-server/api/when.js +251 -0
  767. package/dist/ui-server/api/when.js.map +1 -0
  768. package/dist/ui-server/api/wire.d.ts +179 -0
  769. package/dist/ui-server/api/wire.d.ts.map +1 -0
  770. package/dist/ui-server/api/wire.js +231 -0
  771. package/dist/ui-server/api/wire.js.map +1 -0
  772. package/dist/ui-server/assets.d.ts +40 -0
  773. package/dist/ui-server/assets.d.ts.map +1 -0
  774. package/dist/ui-server/assets.js +110 -0
  775. package/dist/ui-server/assets.js.map +1 -0
  776. package/dist/ui-server/constants.d.ts +32 -0
  777. package/dist/ui-server/constants.d.ts.map +1 -0
  778. package/dist/ui-server/constants.js +35 -0
  779. package/dist/ui-server/constants.js.map +1 -0
  780. package/dist/ui-server/highlight/index.d.ts +113 -0
  781. package/dist/ui-server/highlight/index.d.ts.map +1 -0
  782. package/dist/ui-server/highlight/index.js +307 -0
  783. package/dist/ui-server/highlight/index.js.map +1 -0
  784. package/dist/ui-server/highlight/languages.d.ts +36 -0
  785. package/dist/ui-server/highlight/languages.d.ts.map +1 -0
  786. package/dist/ui-server/highlight/languages.js +50 -0
  787. package/dist/ui-server/highlight/languages.js.map +1 -0
  788. package/dist/ui-server/index.d.ts +92 -0
  789. package/dist/ui-server/index.d.ts.map +1 -0
  790. package/dist/ui-server/index.js +399 -0
  791. package/dist/ui-server/index.js.map +1 -0
  792. package/dist/ui-server/open-browser.d.ts +31 -0
  793. package/dist/ui-server/open-browser.d.ts.map +1 -0
  794. package/dist/ui-server/open-browser.js +79 -0
  795. package/dist/ui-server/open-browser.js.map +1 -0
  796. package/dist/ui-server/security.d.ts +127 -0
  797. package/dist/ui-server/security.d.ts.map +1 -0
  798. package/dist/ui-server/security.js +332 -0
  799. package/dist/ui-server/security.js.map +1 -0
  800. package/dist/ui-server/static.d.ts +45 -0
  801. package/dist/ui-server/static.d.ts.map +1 -0
  802. package/dist/ui-server/static.js +165 -0
  803. package/dist/ui-server/static.js.map +1 -0
  804. package/dist/upgrade/index.d.ts +177 -0
  805. package/dist/upgrade/index.d.ts.map +1 -0
  806. package/dist/upgrade/index.js +665 -0
  807. package/dist/upgrade/index.js.map +1 -0
  808. package/dist/upgrade/remove-binary.d.ts +87 -0
  809. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  810. package/dist/upgrade/remove-binary.js +289 -0
  811. package/dist/upgrade/remove-binary.js.map +1 -0
  812. package/dist/upgrade/update-check.d.ts +92 -0
  813. package/dist/upgrade/update-check.d.ts.map +1 -0
  814. package/dist/upgrade/update-check.js +258 -0
  815. package/dist/upgrade/update-check.js.map +1 -0
  816. package/dist/utils.d.ts +224 -0
  817. package/dist/utils.d.ts.map +1 -0
  818. package/dist/utils.js +583 -0
  819. package/dist/utils.js.map +1 -0
  820. package/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  821. package/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  822. package/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  823. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
  824. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
  825. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  826. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  827. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  828. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  829. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  830. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  831. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
  832. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
  833. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  834. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  835. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  836. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  837. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  838. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  839. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
  840. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  841. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  842. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  843. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  844. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  845. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  846. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  847. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
  848. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
  849. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  850. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  851. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  852. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  853. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  854. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  855. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
  856. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
  857. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  858. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  859. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  860. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  861. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  862. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  863. package/dist/viewer/assets/index-2IPslW5t.js +13 -0
  864. package/dist/viewer/assets/index-DSwi2Seu.css +1 -0
  865. package/dist/viewer/index.html +16 -0
  866. package/package.json +67 -0
@@ -0,0 +1,1378 @@
1
+ "use strict";
2
+ /**
3
+ * Context Builder
4
+ *
5
+ * Builds rich context for tasks by combining FTS search with graph traversal.
6
+ * Outputs structured context ready to inject into Claude.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.formatContextAsJson = exports.formatContextAsMarkdown = exports.ContextBuilder = exports.LOW_CONFIDENCE_MARKER = void 0;
43
+ exports.createContextBuilder = createContextBuilder;
44
+ const fs = __importStar(require("fs"));
45
+ const path = __importStar(require("path"));
46
+ const formatter_1 = require("./formatter");
47
+ const errors_1 = require("../errors");
48
+ const utils_1 = require("../utils");
49
+ const query_utils_1 = require("../search/query-utils");
50
+ const markers_1 = require("./markers");
51
+ /**
52
+ * Extract likely symbol names from a natural language query
53
+ *
54
+ * Identifies potential code symbols using patterns:
55
+ * - CamelCase: UserService, signInWithGoogle
56
+ * - snake_case: user_service, sign_in
57
+ * - SCREAMING_SNAKE: MAX_RETRIES
58
+ * - dot.notation: app.isPackaged (extracts both sides)
59
+ * - Single words that look like identifiers (no spaces, not common English words)
60
+ *
61
+ * @param query - Natural language query
62
+ * @returns Array of potential symbol names
63
+ */
64
+ function extractSymbolsFromQuery(query) {
65
+ const symbols = new Set();
66
+ // Extract CamelCase identifiers (2+ chars, starts with letter)
67
+ const camelCasePattern = /\b([A-Z][a-z]+(?:[A-Z][a-z]*)*|[a-z]+(?:[A-Z][a-z]*)+)\b/g;
68
+ let match;
69
+ while ((match = camelCasePattern.exec(query)) !== null) {
70
+ if (match[1] && match[1].length >= 2) {
71
+ symbols.add(match[1]);
72
+ }
73
+ }
74
+ // Extract snake_case identifiers
75
+ const snakeCasePattern = /\b([a-z][a-z0-9]*(?:_[a-z0-9]+)+)\b/gi;
76
+ while ((match = snakeCasePattern.exec(query)) !== null) {
77
+ if (match[1] && match[1].length >= 3) {
78
+ symbols.add(match[1]);
79
+ }
80
+ }
81
+ // Extract SCREAMING_SNAKE_CASE
82
+ const screamingPattern = /\b([A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+)\b/g;
83
+ while ((match = screamingPattern.exec(query)) !== null) {
84
+ if (match[1]) {
85
+ symbols.add(match[1]);
86
+ }
87
+ }
88
+ // Extract ALL_CAPS acronyms (2+ chars, e.g., REST, HTTP, LRU, API)
89
+ const acronymPattern = /\b([A-Z]{2,})\b/g;
90
+ while ((match = acronymPattern.exec(query)) !== null) {
91
+ if (match[1]) {
92
+ symbols.add(match[1]);
93
+ }
94
+ }
95
+ // Extract dot.notation and split into parts (e.g., "app.isPackaged" -> ["app", "isPackaged"])
96
+ const dotPattern = /\b([a-zA-Z][a-zA-Z0-9]*(?:\.[a-zA-Z][a-zA-Z0-9]*)+)\b/g;
97
+ while ((match = dotPattern.exec(query)) !== null) {
98
+ if (match[1]) {
99
+ // Add both the full path and individual parts
100
+ symbols.add(match[1]);
101
+ const parts = match[1].split('.');
102
+ for (const part of parts) {
103
+ if (part.length >= 2) {
104
+ symbols.add(part);
105
+ }
106
+ }
107
+ }
108
+ }
109
+ // Extract plain lowercase identifiers (3+ chars, not already matched)
110
+ // Catches symbol names like "undo", "redo", "history", "render", "parse"
111
+ const lowercasePattern = /\b([a-z][a-z0-9]{2,})\b/g;
112
+ while ((match = lowercasePattern.exec(query)) !== null) {
113
+ if (match[1]) {
114
+ symbols.add(match[1]);
115
+ }
116
+ }
117
+ // Filter out common English words that aren't likely symbol names
118
+ const commonWords = new Set([
119
+ 'the', 'and', 'for', 'with', 'from', 'this', 'that', 'have', 'been',
120
+ 'will', 'would', 'could', 'should', 'does', 'done', 'make', 'made',
121
+ 'use', 'used', 'using', 'work', 'works', 'find', 'found', 'show',
122
+ 'call', 'called', 'calling', 'get', 'set', 'add', 'all', 'any',
123
+ 'how', 'what', 'when', 'where', 'which', 'who', 'why',
124
+ 'not', 'but', 'are', 'was', 'were', 'has', 'had', 'its',
125
+ 'can', 'did', 'may', 'also', 'into', 'than', 'then', 'them',
126
+ 'each', 'other', 'some', 'such', 'only', 'same', 'about',
127
+ 'after', 'before', 'between', 'through', 'during', 'without',
128
+ 'again', 'further', 'once', 'here', 'there', 'both', 'just',
129
+ 'more', 'most', 'very', 'being', 'having', 'doing',
130
+ 'system', 'need', 'needs', 'want', 'wants', 'like', 'look',
131
+ 'change', 'changes', 'changed', 'changing',
132
+ // Common English nouns/verbs that match thousands of unrelated code symbols
133
+ 'layer', 'handle', 'handles', 'handling', 'incoming', 'outgoing',
134
+ 'data', 'flow', 'flows', 'level', 'levels', 'request', 'requests',
135
+ 'response', 'responses', 'implement', 'implements', 'implementation',
136
+ 'interface', 'interfaces', 'class', 'classes', 'method', 'methods',
137
+ 'trigger', 'triggers', 'affected', 'affect', 'affects',
138
+ 'else', 'code', 'failing', 'failed', 'silently', 'decide', 'decides',
139
+ 'return', 'returns', 'returned', 'take', 'takes', 'taken',
140
+ 'check', 'checks', 'checked', 'create', 'creates', 'created',
141
+ 'read', 'reads', 'write', 'writes', 'written',
142
+ 'start', 'starts', 'stop', 'stops', 'run', 'runs', 'running',
143
+ ]);
144
+ return Array.from(symbols).filter(s => !commonWords.has(s.toLowerCase()));
145
+ }
146
+ /**
147
+ * Default options for context building
148
+ *
149
+ * Tuned for minimal context usage while still providing useful results:
150
+ * - Fewer nodes and code blocks by default
151
+ * - Smaller code block size limit
152
+ * - Shallower traversal
153
+ */
154
+ const DEFAULT_BUILD_OPTIONS = {
155
+ maxNodes: 20, // Reduced from 50 - most tasks don't need 50 symbols
156
+ maxCodeBlocks: 5, // Reduced from 10 - only show most relevant code
157
+ maxCodeBlockSize: 1500, // Reduced from 2000
158
+ includeCode: true,
159
+ format: 'markdown',
160
+ searchLimit: 3, // Reduced from 5 - fewer entry points
161
+ traversalDepth: 1, // Reduced from 2 - shallower graph expansion
162
+ minScore: 0.3,
163
+ };
164
+ /**
165
+ * Node kinds that provide high information value in context results.
166
+ * Imports/exports are excluded because they have near-zero information density -
167
+ * they tell you something exists, not how it works.
168
+ */
169
+ const HIGH_VALUE_NODE_KINDS = [
170
+ 'function', 'method', 'class', 'interface', 'type_alias', 'struct', 'union', 'trait',
171
+ 'component', 'route', 'variable', 'constant', 'enum', 'module', 'namespace',
172
+ ];
173
+ /**
174
+ * Default options for finding relevant context
175
+ */
176
+ const DEFAULT_FIND_OPTIONS = {
177
+ searchLimit: 3, // Reduced from 5
178
+ traversalDepth: 1, // Reduced from 2
179
+ maxNodes: 20, // Reduced from 50
180
+ minScore: 0.3,
181
+ edgeKinds: [],
182
+ nodeKinds: HIGH_VALUE_NODE_KINDS, // Filter out imports/exports by default
183
+ seedNames: [], // Segment-vocab supplement — filled by the facade
184
+ };
185
+ // Re-export the low-confidence sentinel (defined in a dependency-free leaf so
186
+ // the MCP layer can import it without pulling this module's deps onto the
187
+ // cold-start path). Builder code below uses the imported binding directly.
188
+ var markers_2 = require("./markers");
189
+ Object.defineProperty(exports, "LOW_CONFIDENCE_MARKER", { enumerable: true, get: function () { return markers_2.LOW_CONFIDENCE_MARKER; } });
190
+ /**
191
+ * Context Builder
192
+ *
193
+ * Coordinates semantic search and graph traversal to build
194
+ * comprehensive context for tasks.
195
+ */
196
+ class ContextBuilder {
197
+ projectRoot;
198
+ queries;
199
+ traverser;
200
+ constructor(projectRoot, queries, traverser) {
201
+ this.projectRoot = projectRoot;
202
+ this.queries = queries;
203
+ this.traverser = traverser;
204
+ }
205
+ /**
206
+ * Whether the project's `codegraph.json` `deprioritize` patterns cover this
207
+ * path (#982). Explore ranks through its own path scorer as well as through
208
+ * `searchNodes`, so the lever has to be applied here too or the setting would
209
+ * only half-work — and explore is the surface #982 actually reports on.
210
+ *
211
+ * Only the -15 relevance penalty is shared. Explore's hard `continue` filters
212
+ * and its non-production budget cap are deliberately NOT joined: those REMOVE
213
+ * content, and `deprioritize` is a ranking lever by definition — `exclude` is
214
+ * the lever for taking things out of reach.
215
+ */
216
+ isDeprioritized(filePath) {
217
+ return this.queries.getDeprioritizedPathMatcher()?.(filePath) ?? false;
218
+ }
219
+ /**
220
+ * Build context for a task
221
+ *
222
+ * Pipeline:
223
+ * 1. Parse task input (string or {title, description})
224
+ * 2. Run semantic search to find entry points
225
+ * 3. Expand graph around entry points
226
+ * 4. Extract code blocks for key nodes
227
+ * 5. Format output for Claude
228
+ *
229
+ * @param input - Task description or object with title/description
230
+ * @param options - Build options
231
+ * @returns TaskContext (structured) or formatted string
232
+ */
233
+ async buildContext(input, options = {}) {
234
+ const opts = { ...DEFAULT_BUILD_OPTIONS, ...options };
235
+ // Parse input
236
+ const query = typeof input === 'string' ? input : `${input.title}${input.description ? `: ${input.description}` : ''}`;
237
+ // Find relevant context (semantic search + graph expansion)
238
+ const subgraph = await this.findRelevantContext(query, {
239
+ searchLimit: opts.searchLimit,
240
+ traversalDepth: opts.traversalDepth,
241
+ maxNodes: opts.maxNodes,
242
+ minScore: opts.minScore,
243
+ });
244
+ // Get entry points (nodes from semantic search)
245
+ const entryPoints = this.getEntryPoints(subgraph);
246
+ // Extract code blocks for key nodes
247
+ const codeBlocks = opts.includeCode
248
+ ? await this.extractCodeBlocks(subgraph, opts.maxCodeBlocks, opts.maxCodeBlockSize)
249
+ : [];
250
+ // Get related files
251
+ const relatedFiles = this.getRelatedFiles(subgraph);
252
+ // Generate summary
253
+ const summary = this.generateSummary(query, subgraph, entryPoints);
254
+ // Calculate stats
255
+ const stats = {
256
+ nodeCount: subgraph.nodes.size,
257
+ edgeCount: subgraph.edges.length,
258
+ fileCount: relatedFiles.length,
259
+ codeBlockCount: codeBlocks.length,
260
+ totalCodeSize: codeBlocks.reduce((sum, block) => sum + block.content.length, 0),
261
+ };
262
+ const context = {
263
+ query,
264
+ subgraph,
265
+ entryPoints,
266
+ codeBlocks,
267
+ relatedFiles,
268
+ summary,
269
+ stats,
270
+ };
271
+ // Return formatted output or raw context
272
+ if (opts.format === 'markdown') {
273
+ // Bounded candidate set (entry points + subgraph + code blocks), so the
274
+ // DB-backed generated check is one probe, not a per-comparison query.
275
+ const isGenerated = this.queries.generatedPredicateFor([
276
+ ...entryPoints.map((n) => n.filePath),
277
+ ...Array.from(subgraph.nodes.values(), (n) => n.filePath),
278
+ ...codeBlocks.map((b) => b.filePath),
279
+ ]);
280
+ return (0, formatter_1.formatContextAsMarkdown)(context, isGenerated)
281
+ + this.buildCallPathsSection(subgraph)
282
+ + (subgraph.confidence === 'low' ? this.buildLowConfidenceNote(entryPoints) : '');
283
+ }
284
+ else if (opts.format === 'json') {
285
+ return (0, formatter_1.formatContextAsJson)(context);
286
+ }
287
+ return context;
288
+ }
289
+ /**
290
+ * Honest handoff appended when retrieval confidence is low (the query matched
291
+ * mostly common words). Instead of the usual "this covers the surface" framing
292
+ * — which, when wrong, sends the agent off to Read/Grep — it admits the
293
+ * uncertainty and routes the agent to the precise tools (explore with real
294
+ * symbol names, search, or files to browse the closest areas we *did* surface).
295
+ */
296
+ buildLowConfidenceNote(entryPoints) {
297
+ const dirs = [];
298
+ const seen = new Set();
299
+ for (const n of entryPoints) {
300
+ const slash = n.filePath.lastIndexOf('/');
301
+ const dir = slash > 0 ? n.filePath.slice(0, slash) : n.filePath;
302
+ if (!seen.has(dir)) {
303
+ seen.add(dir);
304
+ dirs.push(dir);
305
+ }
306
+ if (dirs.length >= 4)
307
+ break;
308
+ }
309
+ const dirLine = dirs.length
310
+ ? `\n- \`codegraph_files\` a likely area: ${dirs.map(d => `\`${d}\``).join(', ')}`
311
+ : '';
312
+ return `\n\n${markers_1.LOW_CONFIDENCE_MARKER}\n\n`
313
+ + 'This query matched mostly on common words, so the entry points above may '
314
+ + 'be off-target — treat them as a starting point, not a complete answer. '
315
+ + 'For a reliable result:\n'
316
+ + '- `codegraph_explore` with the **exact symbol names** you are after '
317
+ + '(class / function / method names), or\n'
318
+ + '- `codegraph_search <name>` for one specific symbol'
319
+ + dirLine
320
+ + '\n\nDo not assume the list above is comprehensive.';
321
+ }
322
+ /**
323
+ * Surface short call-paths among the symbols this context already found,
324
+ * derived in-memory from the subgraph's `calls` edges (no extra queries).
325
+ *
326
+ * This bakes the value of path-finding INTO the always-loaded `context` tool.
327
+ * Agents reliably read context's output but do NOT discover/adopt a standalone
328
+ * trace tool (in deferred-MCP harnesses they only ToolSearch-select tools they
329
+ * already know). Delivering the flow here means "how does X reach Y" is
330
+ * answered without the agent needing to find, load, or choose a new tool.
331
+ * Chains stop where the static call graph ends (e.g. dynamic dispatch) — that
332
+ * truncation is honest, and the agent can codegraph_node the last hop to bridge.
333
+ */
334
+ buildCallPathsSection(subgraph) {
335
+ const adj = new Map();
336
+ for (const e of subgraph.edges) {
337
+ if (e.kind !== 'calls')
338
+ continue;
339
+ if (!subgraph.nodes.has(e.source) || !subgraph.nodes.has(e.target))
340
+ continue;
341
+ const list = adj.get(e.source);
342
+ if (list)
343
+ list.push(e.target);
344
+ else
345
+ adj.set(e.source, [e.target]);
346
+ }
347
+ if (adj.size === 0)
348
+ return '';
349
+ const MAX_HOPS = 6;
350
+ const chains = [];
351
+ let budget = 2000; // bound DFS work on dense subgraphs
352
+ const dfs = (id, path, seen) => {
353
+ if (budget-- <= 0)
354
+ return;
355
+ const next = (adj.get(id) ?? []).filter((t) => !seen.has(t));
356
+ if (next.length === 0 || path.length >= MAX_HOPS) {
357
+ if (path.length >= 3)
358
+ chains.push([...path]); // >=3 nodes = a real flow, not a single call
359
+ return;
360
+ }
361
+ for (const t of next) {
362
+ seen.add(t);
363
+ dfs(t, [...path, t], seen);
364
+ seen.delete(t);
365
+ }
366
+ };
367
+ const starts = (subgraph.roots.length > 0
368
+ ? subgraph.roots.filter((id) => adj.has(id))
369
+ : [...adj.keys()]).slice(0, 5);
370
+ for (const s of starts)
371
+ dfs(s, [s], new Set([s]));
372
+ if (chains.length === 0)
373
+ return '';
374
+ // Keep only chains that connect TWO OR MORE query-relevant symbols (roots).
375
+ // A chain from a root into an arbitrary callee (render → onMagicFrameGenerate)
376
+ // is structurally valid but tangential to the question; requiring ≥2 roots
377
+ // keeps the chain anchored to what the user actually asked about. Rank by
378
+ // #roots then length, and drop any that are a sub-path of a longer kept chain.
379
+ const rootSet = new Set(subgraph.roots);
380
+ const rootCount = (c) => c.reduce((n, id) => n + (rootSet.has(id) ? 1 : 0), 0);
381
+ const relevant = chains.filter((c) => rootCount(c) >= 2);
382
+ relevant.sort((a, b) => rootCount(b) - rootCount(a) || b.length - a.length);
383
+ const kept = [];
384
+ for (const c of relevant) {
385
+ const key = c.join('>');
386
+ if (kept.some((k) => k.join('>').includes(key)))
387
+ continue;
388
+ kept.push(c);
389
+ if (kept.length >= 3)
390
+ break;
391
+ }
392
+ if (kept.length === 0)
393
+ return '';
394
+ const name = (id) => subgraph.nodes.get(id)?.name ?? id;
395
+ // Synthesized (dynamic-dispatch) hops are real `calls` edges but invisible to
396
+ // static parsing — mark them inline so the agent sees WHERE the callback was
397
+ // wired up (`registered @file:line`) instead of grepping for it. Keyed by
398
+ // "source>target".
399
+ const synthByPair = new Map();
400
+ for (const e of subgraph.edges) {
401
+ if (e.kind !== 'calls' || e.provenance !== 'heuristic')
402
+ continue;
403
+ const m = e.metadata;
404
+ if (!m?.synthesizedBy)
405
+ continue;
406
+ const at = typeof m.registeredAt === 'string' ? ` @${m.registeredAt}` : '';
407
+ const label = m.synthesizedBy === 'callback'
408
+ ? `callback via ${m.via ? `\`${String(m.via)}\`` : 'registrar'}${at}`
409
+ : m.synthesizedBy === 'react-render'
410
+ ? `React re-render via setState${at}`
411
+ : m.synthesizedBy === 'jsx-render'
412
+ ? `renders <${String(m.via || 'child')}>`
413
+ : m.synthesizedBy === 'vue-handler'
414
+ ? `Vue @${String(m.event || 'event')} handler`
415
+ : m.synthesizedBy === 'http-client'
416
+ ? `HTTP ${String(m.method || 'GET')} ${String(m.href || '')} — the client's call onto its own route${at}`
417
+ : m.synthesizedBy === 'queue-job'
418
+ ? `queue job ${m.event ? `\`${String(m.event)}\`` : ''}${m.queue ? ` on \`${String(m.queue)}\`` : ''}${at}`
419
+ : m.synthesizedBy === 'event-bus' && m.channel === 'socket'
420
+ ? `socket message ${m.event ? `\`${String(m.event)}\`` : ''}${m.tier === 'client→server' ? ' → server' : m.tier === 'server→client' ? ' → client' : ''}${at}`
421
+ : `event ${m.event ? `\`${String(m.event)}\`` : ''}${at}`;
422
+ synthByPair.set(`${e.source}>${e.target}`, label);
423
+ }
424
+ const renderChain = (c) => {
425
+ let s = name(c[0]);
426
+ for (let i = 1; i < c.length; i++) {
427
+ const synth = synthByPair.get(`${c[i - 1]}>${c[i]}`);
428
+ s += synth ? ` →[${synth}] ${name(c[i])}` : ` → ${name(c[i])}`;
429
+ }
430
+ return s;
431
+ };
432
+ const hasSynth = kept.some((c) => c.some((_, i) => i > 0 && synthByPair.has(`${c[i - 1]}>${c[i]}`)));
433
+ const lines = [
434
+ '',
435
+ '## Call paths',
436
+ '',
437
+ 'Execution flow among the key symbols (traced through the call graph):',
438
+ '',
439
+ ...kept.map((c) => `- ${renderChain(c)}`),
440
+ '',
441
+ hasSynth
442
+ ? '_Hops marked `[callback/event …]` are dynamic dispatch bridged by codegraph (with the registration site); the rest are direct calls. codegraph_node any symbol for its body._'
443
+ : '_codegraph_node any symbol above for its source + its own callers/callees._',
444
+ ];
445
+ return '\n' + lines.join('\n') + '\n';
446
+ }
447
+ /**
448
+ * Find relevant subgraph for a query
449
+ *
450
+ * Uses hybrid search combining exact symbol lookup with semantic search:
451
+ * 1. Extract potential symbol names from query
452
+ * 2. Look up exact matches for those symbols (high confidence)
453
+ * 3. Use semantic search for concept matching
454
+ * 4. Merge results, prioritizing exact matches
455
+ * 5. Traverse graph from entry points
456
+ *
457
+ * @param query - Natural language query
458
+ * @param options - Search and traversal options
459
+ * @returns Subgraph of relevant nodes and edges
460
+ */
461
+ async findRelevantContext(query, options = {}) {
462
+ const opts = { ...DEFAULT_FIND_OPTIONS, ...options };
463
+ // Start with empty subgraph
464
+ const nodes = new Map();
465
+ const edges = [];
466
+ const roots = [];
467
+ // Handle empty query - return empty subgraph
468
+ if (!query || query.trim().length === 0) {
469
+ return { nodes, edges, roots };
470
+ }
471
+ // === HYBRID SEARCH ===
472
+ // Step 1: Extract potential symbol names from query
473
+ const symbolsFromQuery = extractSymbolsFromQuery(query);
474
+ (0, errors_1.logDebug)('Extracted symbols from query', { query, symbols: symbolsFromQuery });
475
+ // Step 2: Look up exact matches for extracted symbols
476
+ let exactMatches = [];
477
+ if (symbolsFromQuery.length > 0 || opts.seedNames.length > 0) {
478
+ try {
479
+ if (symbolsFromQuery.length > 0) {
480
+ // Get more results so we can apply co-location boosting before trimming
481
+ exactMatches = this.queries.findNodesByExactName(symbolsFromQuery, {
482
+ limit: Math.ceil(opts.searchLimit * 5),
483
+ kinds: opts.nodeKinds && opts.nodeKinds.length > 0 ? opts.nodeKinds : undefined,
484
+ });
485
+ }
486
+ // Step 2a: segment-vocabulary seeds. Word-level query terms cannot
487
+ // reach camelCase names through FTS (one token per name), so the
488
+ // caller resolves query words → names via the segment vocab and hands
489
+ // them in as seedNames. Merged at a dampened score — a symbol the
490
+ // query names outright must outrank a segment-derived one — but
491
+ // BEFORE the co-location boost below, because several seeds landing
492
+ // in one file (pinFeedIfNearBottom + feedAtBottom + handleFeedScroll)
493
+ // is exactly the evidence that file is the answer.
494
+ if (opts.seedNames.length > 0) {
495
+ const seedResults = this.queries.findNodesByExactName(opts.seedNames, {
496
+ limit: Math.ceil(opts.searchLimit * 3),
497
+ kinds: opts.nodeKinds && opts.nodeKinds.length > 0 ? opts.nodeKinds : undefined,
498
+ });
499
+ const known = new Set(exactMatches.map((r) => r.node.id));
500
+ for (const r of seedResults) {
501
+ if (known.has(r.node.id))
502
+ continue;
503
+ known.add(r.node.id);
504
+ exactMatches.push({ ...r, score: r.score * 0.6 });
505
+ }
506
+ (0, errors_1.logDebug)('Segment seed matches', { seedNames: opts.seedNames, added: known.size });
507
+ }
508
+ // Co-location boost: when multiple extracted symbols appear in the same file,
509
+ // those results are much more likely to be what the user is looking for.
510
+ // E.g., "scrapeLoop" + "run" both in scrape/scrape.go → boost both.
511
+ if (exactMatches.length > 1) {
512
+ // Build a map of files → how many distinct symbol names matched in that file
513
+ const fileSymbolCounts = new Map();
514
+ for (const r of exactMatches) {
515
+ const names = fileSymbolCounts.get(r.node.filePath) || new Set();
516
+ names.add(r.node.name.toLowerCase());
517
+ fileSymbolCounts.set(r.node.filePath, names);
518
+ }
519
+ // Boost results in files where multiple query symbols co-occur
520
+ exactMatches = exactMatches.map(r => {
521
+ const symbolCount = fileSymbolCounts.get(r.node.filePath)?.size || 1;
522
+ return {
523
+ ...r,
524
+ score: symbolCount > 1 ? r.score + (symbolCount - 1) * 20 : r.score,
525
+ };
526
+ });
527
+ exactMatches.sort((a, b) => b.score - a.score);
528
+ }
529
+ // Trim back to reasonable size
530
+ exactMatches = exactMatches.slice(0, Math.ceil(opts.searchLimit * 2));
531
+ (0, errors_1.logDebug)('Exact symbol matches', { count: exactMatches.length });
532
+ }
533
+ catch (error) {
534
+ (0, errors_1.logDebug)('Exact symbol lookup failed', { error: String(error) });
535
+ }
536
+ }
537
+ // Step 2b: Search for extracted symbols as definition (class/interface) prefixes.
538
+ // When the user writes "REST", "bulk", or "allocation", they usually mean classes
539
+ // like RestController, BulkRequest, AllocationService — not nodes named exactly that.
540
+ // Also tries stem variants: "caching" → "cache" finds Cache, CacheBuilder.
541
+ if (symbolsFromQuery.length > 0) {
542
+ const definitionKinds = ['class', 'interface', 'struct', 'union', 'trait',
543
+ 'protocol', 'enum', 'type_alias'];
544
+ // Expand symbols with stem variants for broader definition matching
545
+ const expandedSymbols = new Set(symbolsFromQuery);
546
+ for (const sym of symbolsFromQuery) {
547
+ for (const variant of (0, query_utils_1.getStemVariants)(sym)) {
548
+ expandedSymbols.add(variant);
549
+ }
550
+ }
551
+ for (const sym of expandedSymbols) {
552
+ // Title-case the symbol: "REST" → "Rest", "bulk" → "Bulk", "allocation" → "Allocation"
553
+ const titleCased = sym.charAt(0).toUpperCase() + sym.slice(1).toLowerCase();
554
+ if (titleCased === sym)
555
+ continue; // already title-case (e.g., "Engine") — handled by exact match
556
+ // Fetch more results since popular prefixes have many matches
557
+ const prefixResults = this.queries.searchNodes(titleCased, {
558
+ limit: 30,
559
+ kinds: definitionKinds,
560
+ });
561
+ const matched = [];
562
+ for (const r of prefixResults) {
563
+ if (r.node.name.toLowerCase().startsWith(titleCased.toLowerCase())) {
564
+ // Favor shorter names: "AllocationService" (18 chars) over
565
+ // "AllocationBalancingRoundMetrics" (31 chars). Core classes tend
566
+ // to have concise names; test/helper classes are verbose.
567
+ const brevityBonus = Math.max(0, 10 - (r.node.name.length - titleCased.length) / 3);
568
+ matched.push({ ...r, score: r.score + 15 + brevityBonus });
569
+ }
570
+ }
571
+ matched.sort((a, b) => b.score - a.score);
572
+ for (const r of matched.slice(0, Math.ceil(opts.searchLimit))) {
573
+ const existing = exactMatches.find(e => e.node.id === r.node.id);
574
+ if (!existing) {
575
+ exactMatches.push(r);
576
+ }
577
+ }
578
+ }
579
+ exactMatches.sort((a, b) => b.score - a.score);
580
+ exactMatches = exactMatches.slice(0, Math.ceil(opts.searchLimit * 3));
581
+ }
582
+ // Step 3: Run text search for natural language term matching
583
+ // This catches file-name and node-name matches that semantic search may miss,
584
+ // which is critical for template-heavy codebases (e.g., Liquid/Shopify themes)
585
+ // where file names are the primary identifiers.
586
+ let textResults = [];
587
+ try {
588
+ const searchTerms = (0, query_utils_1.extractSearchTerms)(query);
589
+ if (searchTerms.length > 0) {
590
+ // Search each term individually to get broader coverage,
591
+ // then boost results that match multiple terms
592
+ const termResultsMap = new Map();
593
+ // When no explicit kind filter is set, exclude imports — they flood FTS
594
+ // results with qualified name matches (e.g., "REST" matches 445K import paths)
595
+ // but are almost never what exploration queries want.
596
+ const searchKinds = opts.nodeKinds && opts.nodeKinds.length > 0
597
+ ? opts.nodeKinds
598
+ : ['file', 'module', 'class', 'struct', 'union', 'interface', 'trait', 'protocol',
599
+ 'function', 'method', 'property', 'field', 'variable', 'constant',
600
+ 'enum', 'enum_member', 'type_alias', 'namespace', 'export',
601
+ 'route', 'component'];
602
+ for (const term of searchTerms) {
603
+ const termResults = this.queries.searchNodes(term, {
604
+ limit: opts.searchLimit * 2,
605
+ kinds: searchKinds,
606
+ });
607
+ for (const r of termResults) {
608
+ const existing = termResultsMap.get(r.node.id);
609
+ if (existing) {
610
+ existing.termHits++;
611
+ existing.result.score = Math.max(existing.result.score, r.score);
612
+ }
613
+ else {
614
+ termResultsMap.set(r.node.id, { result: r, termHits: 1 });
615
+ }
616
+ }
617
+ }
618
+ // Boost results matching multiple terms and sort
619
+ textResults = Array.from(termResultsMap.values())
620
+ .map(({ result, termHits }) => ({
621
+ ...result,
622
+ score: result.score + (termHits - 1) * 5,
623
+ }))
624
+ .sort((a, b) => b.score - a.score)
625
+ .slice(0, opts.searchLimit * 2);
626
+ }
627
+ (0, errors_1.logDebug)('Text search results', { count: textResults.length });
628
+ }
629
+ catch (error) {
630
+ (0, errors_1.logDebug)('Text search failed', { query, error: String(error) });
631
+ }
632
+ // Step 4: Merge results, taking the max score when duplicates appear
633
+ // across search channels. Exact matches may have lower scores than FTS
634
+ // results for the same node — use the best score from any channel.
635
+ const resultById = new Map();
636
+ let searchResults = [];
637
+ // Add exact matches first
638
+ for (const result of exactMatches) {
639
+ const existing = resultById.get(result.node.id);
640
+ if (existing) {
641
+ existing.score = Math.max(existing.score, result.score);
642
+ }
643
+ else {
644
+ resultById.set(result.node.id, result);
645
+ searchResults.push(result);
646
+ }
647
+ }
648
+ // Add text search results, upgrading scores for duplicates
649
+ for (const result of textResults) {
650
+ const existing = resultById.get(result.node.id);
651
+ if (existing) {
652
+ existing.score = Math.max(existing.score, result.score);
653
+ }
654
+ else {
655
+ resultById.set(result.node.id, result);
656
+ searchResults.push(result);
657
+ }
658
+ }
659
+ const queryLower = query.toLowerCase();
660
+ const isTestQuery = queryLower.includes('test') || queryLower.includes('spec');
661
+ // Deprioritize test files early so they don't take multi-term boost slots
662
+ if (!isTestQuery) {
663
+ for (const result of searchResults) {
664
+ if ((0, query_utils_1.isTestFile)(result.node.filePath)) {
665
+ result.score *= 0.3;
666
+ }
667
+ }
668
+ }
669
+ // Iter7 — Core-directory boost. On projects with one file that holds
670
+ // the dense majority of internal call edges (e.g. sinatra's
671
+ // `lib/sinatra/base.rb` at 85% of all in-file edges), the agent's
672
+ // task usually asks about the framework's core. Without this boost,
673
+ // ranking favors small focused extension files (e.g. text search
674
+ // picks `sinatra-contrib/lib/sinatra/multi_route.rb`'s 10-line
675
+ // `route` method over `base.rb`'s `route!` because the extension
676
+ // file's `route` matches the query verbatim AND the file is small,
677
+ // dwarfing the longer name `route!` in a 1500-line file). Boost
678
+ // results that share a directory prefix with the dominant file's
679
+ // directory so the core file's siblings outrank sibling-package
680
+ // extensions.
681
+ try {
682
+ const dominant = this.queries.getDominantFile?.();
683
+ if (dominant && dominant.edgeCount >= 3 * dominant.nextEdgeCount) {
684
+ // Take the directory of the dominant file (everything up to the
685
+ // last slash). For `lib/sinatra/base.rb` → `lib/sinatra/`.
686
+ const slash = dominant.filePath.lastIndexOf('/');
687
+ if (slash > 0) {
688
+ const coreDir = dominant.filePath.slice(0, slash + 1);
689
+ for (const result of searchResults) {
690
+ if (result.node.filePath.startsWith(coreDir)) {
691
+ result.score += 25;
692
+ }
693
+ }
694
+ }
695
+ }
696
+ }
697
+ catch {
698
+ // SQL failure — fall through, scoring works without the boost
699
+ }
700
+ // Step 5a: Multi-term co-occurrence re-ranking (applied BEFORE truncation).
701
+ // For multi-word queries like "search execution from request to shard",
702
+ // nodes matching 2+ query terms in their name or path are far more relevant
703
+ // than nodes matching just one generic term. Without this, "ExecutionUtils"
704
+ // (matches only "execution") fills budget slots meant for "ShardSearchRequest"
705
+ // (matches "shard" + "search" + "request").
706
+ const queryTermsForBoost = (0, query_utils_1.extractSearchTerms)(query);
707
+ if (queryTermsForBoost.length >= 2) {
708
+ // Group terms that are substrings of each other (stem variants of the same
709
+ // root word). "indexed", "indexe", "index" should count as ONE concept match,
710
+ // not three. Without this, stem variants inflate matchCount and give false
711
+ // multi-term boosts to symbols matching one root word multiple times.
712
+ const termGroups = [];
713
+ const sorted = [...queryTermsForBoost].sort((a, b) => b.length - a.length);
714
+ const assigned = new Set();
715
+ for (const term of sorted) {
716
+ if (assigned.has(term))
717
+ continue;
718
+ const group = [term];
719
+ assigned.add(term);
720
+ for (const other of sorted) {
721
+ if (assigned.has(other))
722
+ continue;
723
+ if (term.includes(other) || other.includes(term)) {
724
+ group.push(other);
725
+ assigned.add(other);
726
+ }
727
+ }
728
+ termGroups.push(group);
729
+ }
730
+ // Build a set of exact-match node IDs so we can exempt them from dampening.
731
+ // When the query is "LiveEditMode DevServerPreview", these are specific
732
+ // symbols the user asked for — dampening them because they only match 1
733
+ // term group is counter-productive.
734
+ const exactMatchIds = new Set(exactMatches.map(r => r.node.id));
735
+ // ...but only exempt exact matches the user *named as an identifier*
736
+ // (camelCase/snake_case/acronym). A plain dictionary word that happens to
737
+ // exact-match an unrelated symbol — query "flat object" → a constant named
738
+ // FLAT — must NOT be exempt, or the +exact-name bonus floats it to the top
739
+ // of a prose query with zero corroboration from any other term. Classify by
740
+ // the QUERY token (what the user typed), not the matched symbol's name.
741
+ const distinctiveTokens = new Set(symbolsFromQuery.filter(query_utils_1.isDistinctiveIdentifier).map(s => s.toLowerCase()));
742
+ const distinctiveExactMatchIds = new Set(exactMatches
743
+ .filter(r => distinctiveTokens.has(r.node.name.toLowerCase()))
744
+ .map(r => r.node.id));
745
+ for (const result of searchResults) {
746
+ // Check term matches in name (substring) and path DIRECTORIES (exact).
747
+ // Directory segments must match exactly — "search" matches directory
748
+ // "search/" but NOT "elasticsearch/". The class name is checked
749
+ // separately via substring match on the node name.
750
+ const nameLower = result.node.name.toLowerCase();
751
+ const dirSegments = path.dirname(result.node.filePath).toLowerCase().split('/');
752
+ let matchCount = 0;
753
+ for (const group of termGroups) {
754
+ const groupMatches = group.some(term => {
755
+ const inName = nameLower.includes(term);
756
+ const inDir = dirSegments.some(seg => seg === term);
757
+ return inName || inDir;
758
+ });
759
+ if (groupMatches)
760
+ matchCount++;
761
+ }
762
+ if (matchCount >= 2) {
763
+ // Multiplicative boost — 2 terms → 2x, 3 terms → 2.5x
764
+ result.score *= 1 + matchCount * 0.5;
765
+ }
766
+ else if (distinctiveExactMatchIds.has(result.node.id)) {
767
+ // Exact match on a distinctive identifier the user explicitly named —
768
+ // keep full score (e.g. "LiveEditMode DevServerPreview").
769
+ }
770
+ else if (exactMatchIds.has(result.node.id)) {
771
+ // Exact match on a COMMON word (e.g. "flat" → FLAT): high-scoring noise
772
+ // inflated by the +exact-name bonus, corroborated by no other query
773
+ // term. Demote hard so corroborated matches win.
774
+ result.score *= 0.3;
775
+ }
776
+ else {
777
+ // Mild dampen for generic single-term matches — they might be generic
778
+ // but could also be the right result (e.g., "Protocol" class for an IPC query).
779
+ result.score *= 0.6;
780
+ }
781
+ }
782
+ searchResults.sort((a, b) => b.score - a.score);
783
+ }
784
+ // Step 5b: CamelCase-boundary matching via LIKE query.
785
+ // FTS can't find "Search" inside "TransportSearchAction" (one FTS token).
786
+ // LIKE reliably finds these substring matches. Results are appended with
787
+ // guaranteed slots so they don't compete with higher-scoring prefix matches.
788
+ if (symbolsFromQuery.length > 0) {
789
+ const camelDefinitionKinds = ['class', 'interface', 'struct', 'union', 'trait',
790
+ 'protocol', 'enum', 'type_alias'];
791
+ // Callable kinds participate too: in service-layer codebases the
792
+ // camel-infix definers of a queried FIELD are methods/functions
793
+ // (`profileInfo` → `getProfileInfoV2`), not classes — the type-only
794
+ // whitelist made this whole step dead code there (#1196). Fetched as a
795
+ // SEPARATE LIKE batch so one hot single-word term can't crowd classes
796
+ // out of the length-ordered 200-row batch.
797
+ const camelCallableKinds = ['function', 'method', 'component'];
798
+ const camelSearchedTerms = new Set();
799
+ const searchIdSet = new Set(searchResults.map(r => r.node.id));
800
+ // Track per-node term hits for multi-term boosting
801
+ const camelNodeTerms = new Map();
802
+ const maxCamelPerTerm = Math.ceil(opts.searchLimit / 2);
803
+ for (const sym of symbolsFromQuery) {
804
+ const titleCased = sym.charAt(0).toUpperCase() + sym.slice(1).toLowerCase();
805
+ if (titleCased.length < 3)
806
+ continue;
807
+ const termKey = titleCased.toLowerCase();
808
+ if (camelSearchedTerms.has(termKey))
809
+ continue;
810
+ camelSearchedTerms.add(termKey);
811
+ // Fetch a large batch — popular terms like "Search" in Elasticsearch
812
+ // have hundreds of substring matches. The LIKE scan cost is the same
813
+ // regardless of LIMIT (SQLite scans all matches to sort), so we fetch
814
+ // generously and let path-relevance scoring pick the best ones.
815
+ const likeResults = [
816
+ ...this.queries.findNodesByNameSubstring(titleCased, {
817
+ limit: 200,
818
+ kinds: camelDefinitionKinds,
819
+ excludePrefix: true,
820
+ }),
821
+ ...this.queries.findNodesByNameSubstring(titleCased, {
822
+ limit: 200,
823
+ kinds: camelCallableKinds,
824
+ excludePrefix: true,
825
+ }),
826
+ ];
827
+ // Filter to CamelCase boundaries, score by path relevance, and take top N
828
+ const termCandidates = [];
829
+ for (const r of likeResults) {
830
+ const name = r.node.name;
831
+ // Case-INSENSITIVE hump lookup: title-casing lowercases interior
832
+ // humps (`profileInfo` → `Profileinfo`), which SQLite's LIKE still
833
+ // matched but a case-sensitive indexOf here silently dropped —
834
+ // making every multi-hump query term unfindable by this step
835
+ // (#1196). The match must still LAND on an uppercase char, so a
836
+ // plain lowercase infix can't slip through.
837
+ const idx = name.toLowerCase().indexOf(termKey);
838
+ if (idx <= 0)
839
+ continue;
840
+ if (!/[A-Z]/.test(name.charAt(idx)))
841
+ continue;
842
+ // Accept CamelCase boundary (lowercase before match) OR
843
+ // acronym boundary (uppercase before match, e.g., RPCProtocol)
844
+ if (!/[a-zA-Z]/.test(name.charAt(idx - 1)))
845
+ continue;
846
+ if (searchIdSet.has(r.node.id))
847
+ continue;
848
+ if ((0, query_utils_1.isTestFile)(r.node.filePath) && !isTestQuery)
849
+ continue;
850
+ const pathScore = (0, query_utils_1.scorePathRelevance)(r.node.filePath, query, undefined, this.isDeprioritized(r.node.filePath));
851
+ const brevityBonus = Math.max(0, 6 - (name.length - titleCased.length) / 4);
852
+ termCandidates.push({ node: r.node, score: 8 + brevityBonus + pathScore });
853
+ }
854
+ termCandidates.sort((a, b) => b.score - a.score);
855
+ // Widen the per-term pool for accumulation so multi-term co-occurrences
856
+ // can be discovered. A class matching 3 query terms at CamelCase boundaries
857
+ // is far more relevant than one matching just 1, but it needs to survive
858
+ // the per-term cut for EACH term to accumulate its count.
859
+ const accumPerTerm = maxCamelPerTerm * 4;
860
+ for (const r of termCandidates.slice(0, accumPerTerm)) {
861
+ const existing = camelNodeTerms.get(r.node.id);
862
+ if (existing) {
863
+ existing.termCount++;
864
+ }
865
+ else {
866
+ camelNodeTerms.set(r.node.id, {
867
+ result: r,
868
+ termCount: 1,
869
+ });
870
+ }
871
+ }
872
+ }
873
+ // Append CamelCase matches with multi-term boost.
874
+ // These are structurally important (class names containing query terms at
875
+ // CamelCase boundaries) but score much lower than FTS results. Scale their
876
+ // scores up so multi-term CamelCase matches can compete with FTS results.
877
+ const camelResults = [];
878
+ for (const [, info] of camelNodeTerms) {
879
+ // Multi-term CamelCase matches are extremely relevant — a class matching
880
+ // 3+ query terms in its name (e.g., ExtensionHostProcess) is almost
881
+ // certainly what the user wants. Scale aggressively.
882
+ info.result.score = info.result.score * (1 + info.termCount) + (info.termCount - 1) * 30;
883
+ camelResults.push(info.result);
884
+ }
885
+ camelResults.sort((a, b) => b.score - a.score);
886
+ const maxCamelTotal = opts.searchLimit;
887
+ for (const r of camelResults.slice(0, maxCamelTotal)) {
888
+ searchResults.push(r);
889
+ searchIdSet.add(r.node.id);
890
+ }
891
+ // Step 5c: Compound term matching — find classes whose name contains 2+
892
+ // query terms at ANY position (not just CamelCase boundaries).
893
+ // The CamelCase step above requires idx > 0, which misses classes that
894
+ // START with a query term (e.g., "SearchShardsRequest" starts with "Search").
895
+ // For multi-word queries, a class matching multiple query terms in its name
896
+ // is almost certainly relevant regardless of position.
897
+ if (symbolsFromQuery.length >= 2) {
898
+ // Collect ALL LIKE results per term (reusing findNodesByNameSubstring)
899
+ // but without the CamelCase boundary or prefix exclusion filters.
900
+ const compoundTermMap = new Map();
901
+ for (const sym of symbolsFromQuery) {
902
+ const titleCased = sym.charAt(0).toUpperCase() + sym.slice(1).toLowerCase();
903
+ if (titleCased.length < 3)
904
+ continue;
905
+ const likeResults = [
906
+ ...this.queries.findNodesByNameSubstring(titleCased, {
907
+ limit: 200,
908
+ kinds: camelDefinitionKinds,
909
+ excludePrefix: false,
910
+ }),
911
+ // Same separate callable batch as Step 5b (#1196).
912
+ ...this.queries.findNodesByNameSubstring(titleCased, {
913
+ limit: 200,
914
+ kinds: camelCallableKinds,
915
+ excludePrefix: false,
916
+ }),
917
+ ];
918
+ for (const r of likeResults) {
919
+ if (searchIdSet.has(r.node.id))
920
+ continue;
921
+ if ((0, query_utils_1.isTestFile)(r.node.filePath) && !isTestQuery)
922
+ continue;
923
+ const entry = compoundTermMap.get(r.node.id);
924
+ if (entry) {
925
+ entry.terms.add(titleCased);
926
+ }
927
+ else {
928
+ compoundTermMap.set(r.node.id, { node: r.node, terms: new Set([titleCased]) });
929
+ }
930
+ }
931
+ }
932
+ // Keep only nodes matching 2+ distinct terms
933
+ const compoundResults = [];
934
+ for (const [, entry] of compoundTermMap) {
935
+ if (entry.terms.size >= 2) {
936
+ const pathScore = (0, query_utils_1.scorePathRelevance)(entry.node.filePath, query, undefined, this.isDeprioritized(entry.node.filePath));
937
+ const brevityBonus = Math.max(0, 6 - entry.node.name.length / 8);
938
+ compoundResults.push({
939
+ node: entry.node,
940
+ score: 10 + (entry.terms.size - 1) * 20 + pathScore + brevityBonus,
941
+ });
942
+ }
943
+ }
944
+ compoundResults.sort((a, b) => b.score - a.score);
945
+ const maxCompound = Math.ceil(opts.searchLimit / 2);
946
+ for (const r of compoundResults.slice(0, maxCompound)) {
947
+ searchResults.push(r);
948
+ searchIdSet.add(r.node.id);
949
+ }
950
+ }
951
+ }
952
+ // Final sort and truncation — all search channels (exact, text, CamelCase,
953
+ // compound) have now contributed. Sort by score so multi-term matches from
954
+ // later steps can outrank dampened single-term matches from earlier steps.
955
+ searchResults.sort((a, b) => b.score - a.score);
956
+ searchResults = searchResults.slice(0, opts.searchLimit * 3);
957
+ // Filter by minimum score
958
+ let filteredResults = searchResults.filter((r) => r.score >= opts.minScore);
959
+ // Resolve imports/exports to their actual definitions
960
+ // If someone searches "terminal" and finds `import { TerminalPanel }`,
961
+ // they want the TerminalPanel class, not the import statement
962
+ filteredResults = this.resolveImportsToDefinitions(filteredResults);
963
+ // Cap entry points so traversal budget isn't spread too thin.
964
+ // With 36 entry points and maxNodes=120, each gets only 3 nodes — useless.
965
+ // Cap to searchLimit so each entry point gets a meaningful traversal budget.
966
+ if (filteredResults.length > opts.searchLimit) {
967
+ filteredResults = filteredResults.slice(0, opts.searchLimit);
968
+ }
969
+ // Confidence signal for the honest-handoff footer (consumed in buildContext).
970
+ // A multi-term prose query that resolves only to isolated common-word matches
971
+ // — no entry point corroborated by 2+ distinct query terms, and none a
972
+ // distinctive identifier the user explicitly named — is LOW confidence: the
973
+ // results are best-effort, not a located answer, so the agent should be told
974
+ // to drill in with explore/trace rather than trust the list as comprehensive.
975
+ // Single-keyword and symbol-name queries are exempt (their single match IS the
976
+ // answer), so the handoff never fires on them.
977
+ let confidence = 'high';
978
+ const confTerms = (0, query_utils_1.extractSearchTerms)(query, { stems: false }).filter(t => t.length >= 3);
979
+ if (confTerms.length >= 2 && filteredResults.length > 0) {
980
+ const distinctive = new Set(symbolsFromQuery.filter(query_utils_1.isDistinctiveIdentifier).map(s => s.toLowerCase()));
981
+ const anyStrong = filteredResults.some(r => {
982
+ if (distinctive.has(r.node.name.toLowerCase()))
983
+ return true;
984
+ const nameLower = r.node.name.toLowerCase();
985
+ const dirSegs = path.dirname(r.node.filePath).toLowerCase().split('/');
986
+ let hits = 0;
987
+ for (const t of confTerms) {
988
+ if (nameLower.includes(t) || dirSegs.includes(t)) {
989
+ if (++hits >= 2)
990
+ return true;
991
+ }
992
+ }
993
+ return false;
994
+ });
995
+ if (!anyStrong)
996
+ confidence = 'low';
997
+ }
998
+ // Add entry points to subgraph
999
+ for (const result of filteredResults) {
1000
+ nodes.set(result.node.id, result.node);
1001
+ roots.push(result.node.id);
1002
+ }
1003
+ // Expand type hierarchy for class/interface entry points.
1004
+ // BFS often exhausts its per-entry-point budget on contained methods
1005
+ // before reaching extends/implements neighbors. This dedicated step
1006
+ // ensures subclasses and superclasses always appear in results.
1007
+ // Budget: up to maxNodes/4 hierarchy nodes to avoid flooding.
1008
+ const typeHierarchyKinds = new Set(['class', 'interface', 'struct', 'union', 'trait', 'protocol']);
1009
+ const maxHierarchyNodes = Math.ceil(opts.maxNodes / 4);
1010
+ let hierarchyNodesAdded = 0;
1011
+ for (const result of filteredResults) {
1012
+ if (hierarchyNodesAdded >= maxHierarchyNodes)
1013
+ break;
1014
+ if (typeHierarchyKinds.has(result.node.kind)) {
1015
+ const hierarchy = this.traverser.getTypeHierarchy(result.node.id);
1016
+ for (const [id, node] of hierarchy.nodes) {
1017
+ if (!nodes.has(id)) {
1018
+ nodes.set(id, node);
1019
+ hierarchyNodesAdded++;
1020
+ }
1021
+ }
1022
+ for (const edge of hierarchy.edges) {
1023
+ const exists = edges.some((e) => e.source === edge.source && e.target === edge.target && e.kind === edge.kind);
1024
+ if (!exists) {
1025
+ edges.push(edge);
1026
+ }
1027
+ }
1028
+ }
1029
+ }
1030
+ // Pass 2: expand hierarchy of newly-discovered parent types to find siblings.
1031
+ // E.g., InternalEngine → Engine (parent, from pass 1) → ReadOnlyEngine (sibling).
1032
+ if (hierarchyNodesAdded > 0) {
1033
+ const pass2Candidates = [...nodes.values()].filter(n => typeHierarchyKinds.has(n.kind) && !roots.includes(n.id));
1034
+ for (const candidate of pass2Candidates) {
1035
+ if (hierarchyNodesAdded >= maxHierarchyNodes)
1036
+ break;
1037
+ const siblingHierarchy = this.traverser.getTypeHierarchy(candidate.id);
1038
+ for (const [id, node] of siblingHierarchy.nodes) {
1039
+ if (!nodes.has(id) && hierarchyNodesAdded < maxHierarchyNodes) {
1040
+ nodes.set(id, node);
1041
+ hierarchyNodesAdded++;
1042
+ }
1043
+ }
1044
+ for (const edge of siblingHierarchy.edges) {
1045
+ if (nodes.has(edge.source) && nodes.has(edge.target)) {
1046
+ const exists = edges.some((e) => e.source === edge.source && e.target === edge.target && e.kind === edge.kind);
1047
+ if (!exists) {
1048
+ edges.push(edge);
1049
+ }
1050
+ }
1051
+ }
1052
+ }
1053
+ }
1054
+ // Traverse from each entry point
1055
+ for (const result of filteredResults) {
1056
+ const traversalResult = this.traverser.traverseBFS(result.node.id, {
1057
+ maxDepth: opts.traversalDepth,
1058
+ edgeKinds: opts.edgeKinds && opts.edgeKinds.length > 0 ? opts.edgeKinds : undefined,
1059
+ nodeKinds: opts.nodeKinds && opts.nodeKinds.length > 0 ? opts.nodeKinds : undefined,
1060
+ direction: 'both',
1061
+ limit: Math.ceil(opts.maxNodes / Math.max(1, filteredResults.length)),
1062
+ });
1063
+ // Merge nodes
1064
+ for (const [id, node] of traversalResult.nodes) {
1065
+ if (!nodes.has(id)) {
1066
+ nodes.set(id, node);
1067
+ }
1068
+ }
1069
+ // Merge edges (avoid duplicates)
1070
+ for (const edge of traversalResult.edges) {
1071
+ const exists = edges.some((e) => e.source === edge.source && e.target === edge.target && e.kind === edge.kind);
1072
+ if (!exists) {
1073
+ edges.push(edge);
1074
+ }
1075
+ }
1076
+ }
1077
+ // Trim to max nodes if needed
1078
+ let finalNodes = nodes;
1079
+ let finalEdges = edges;
1080
+ if (nodes.size > opts.maxNodes) {
1081
+ // Prioritize entry points and their direct neighbors
1082
+ const priorityIds = new Set(roots);
1083
+ for (const edge of edges) {
1084
+ if (priorityIds.has(edge.source)) {
1085
+ priorityIds.add(edge.target);
1086
+ }
1087
+ if (priorityIds.has(edge.target)) {
1088
+ priorityIds.add(edge.source);
1089
+ }
1090
+ }
1091
+ // Keep priority nodes, then fill remaining slots
1092
+ finalNodes = new Map();
1093
+ for (const id of priorityIds) {
1094
+ const node = nodes.get(id);
1095
+ if (node && finalNodes.size < opts.maxNodes) {
1096
+ finalNodes.set(id, node);
1097
+ }
1098
+ }
1099
+ // Fill remaining from other nodes
1100
+ for (const [id, node] of nodes) {
1101
+ if (finalNodes.size >= opts.maxNodes)
1102
+ break;
1103
+ if (!finalNodes.has(id)) {
1104
+ finalNodes.set(id, node);
1105
+ }
1106
+ }
1107
+ // Filter edges to only include kept nodes
1108
+ finalEdges = edges.filter((e) => finalNodes.has(e.source) && finalNodes.has(e.target));
1109
+ }
1110
+ // Per-file diversity cap: prevent any single file from monopolizing the
1111
+ // node budget. When BFS traverses from a method, it follows `contains`
1112
+ // to the parent class, then back down to all sibling methods. With
1113
+ // multiple entry points in the same class, one file can consume 30-40%
1114
+ // of maxNodes. Cap each file to ~20% to ensure cross-file diversity.
1115
+ const maxPerFile = Math.max(5, Math.ceil(opts.maxNodes * 0.2));
1116
+ const fileCounts = new Map();
1117
+ for (const [id, node] of finalNodes) {
1118
+ const ids = fileCounts.get(node.filePath) || [];
1119
+ ids.push(id);
1120
+ fileCounts.set(node.filePath, ids);
1121
+ }
1122
+ const rootSet = new Set(roots);
1123
+ for (const [, nodeIds] of fileCounts) {
1124
+ if (nodeIds.length <= maxPerFile)
1125
+ continue;
1126
+ // Sort: entry points first, then classes/interfaces, then others
1127
+ const kindPriority = {
1128
+ class: 3, interface: 3, struct: 3, trait: 3, protocol: 3, enum: 3,
1129
+ method: 1, function: 1, property: 0, field: 0, variable: 0,
1130
+ };
1131
+ nodeIds.sort((a, b) => {
1132
+ const aRoot = rootSet.has(a) ? 10 : 0;
1133
+ const bRoot = rootSet.has(b) ? 10 : 0;
1134
+ const aKind = kindPriority[finalNodes.get(a).kind] ?? 0;
1135
+ const bKind = kindPriority[finalNodes.get(b).kind] ?? 0;
1136
+ return (bRoot + bKind) - (aRoot + aKind);
1137
+ });
1138
+ // Remove excess nodes (keep the highest-priority ones)
1139
+ for (const id of nodeIds.slice(maxPerFile)) {
1140
+ finalNodes.delete(id);
1141
+ }
1142
+ }
1143
+ // Non-production node cap: limit test/sample/integration/example files to
1144
+ // at most 15% of the budget. Many codebases have dozens of near-identical
1145
+ // test implementations (e.g., 6 Guard classes in integration tests) that
1146
+ // individually survive score dampening but collectively flood the result.
1147
+ // Test entry points are NOT exempt — they should be evicted too.
1148
+ if (!isTestQuery) {
1149
+ const maxNonProd = Math.max(3, Math.ceil(opts.maxNodes * 0.15));
1150
+ const nonProdIds = [];
1151
+ for (const [id, node] of finalNodes) {
1152
+ if ((0, query_utils_1.isTestFile)(node.filePath)) {
1153
+ nonProdIds.push(id);
1154
+ }
1155
+ }
1156
+ if (nonProdIds.length > maxNonProd) {
1157
+ for (const id of nonProdIds.slice(maxNonProd)) {
1158
+ finalNodes.delete(id);
1159
+ // Also remove from roots — test file entry points shouldn't anchor results
1160
+ const rootIdx = roots.indexOf(id);
1161
+ if (rootIdx !== -1)
1162
+ roots.splice(rootIdx, 1);
1163
+ }
1164
+ }
1165
+ }
1166
+ // Re-filter edges after per-file and non-production caps
1167
+ finalEdges = finalEdges.filter((e) => finalNodes.has(e.source) && finalNodes.has(e.target));
1168
+ // Edge recovery: BFS with many entry points leaves most nodes disconnected.
1169
+ // Discover edges between already-selected nodes to recover connectivity.
1170
+ const recoveryKinds = ['calls', 'extends', 'implements', 'references', 'overrides', 'navigates'];
1171
+ const recoveredEdges = this.queries.findEdgesBetweenNodes([...finalNodes.keys()], recoveryKinds);
1172
+ const existingEdgeKeys = new Set(finalEdges.map((e) => `${e.source}:${e.target}:${e.kind}`));
1173
+ for (const edge of recoveredEdges) {
1174
+ const key = `${edge.source}:${edge.target}:${edge.kind}`;
1175
+ if (!existingEdgeKeys.has(key)) {
1176
+ finalEdges.push(edge);
1177
+ existingEdgeKeys.add(key);
1178
+ }
1179
+ }
1180
+ return { nodes: finalNodes, edges: finalEdges, roots, confidence };
1181
+ }
1182
+ /**
1183
+ * Get the source code for a node
1184
+ *
1185
+ * Reads the file and extracts the code between startLine and endLine.
1186
+ *
1187
+ * @param nodeId - ID of the node
1188
+ * @returns Code string or null if not found
1189
+ */
1190
+ async getCode(nodeId) {
1191
+ const node = this.queries.getNodeById(nodeId);
1192
+ if (!node) {
1193
+ return null;
1194
+ }
1195
+ return this.extractNodeCode(node);
1196
+ }
1197
+ /**
1198
+ * Extract code from a node's source file
1199
+ */
1200
+ async extractNodeCode(node) {
1201
+ // SECURITY (#383): a config-leaf node's on-disk line is `key = <secret>`.
1202
+ // Return the KEY only — never read the value off disk. This closes the
1203
+ // includeCode / buildContext code-block path, mirroring the explore source
1204
+ // renderer; an agent that genuinely needs a value can read the file itself.
1205
+ if ((0, utils_1.isConfigLeafNode)(node)) {
1206
+ return node.signature || node.qualifiedName || node.name;
1207
+ }
1208
+ const filePath = (0, utils_1.validatePathWithinRoot)(this.projectRoot, node.filePath);
1209
+ if (!filePath || !fs.existsSync(filePath)) {
1210
+ return null;
1211
+ }
1212
+ try {
1213
+ const content = fs.readFileSync(filePath, 'utf-8');
1214
+ const lines = content.split('\n');
1215
+ // Extract lines (1-indexed to 0-indexed)
1216
+ const startIdx = Math.max(0, node.startLine - 1);
1217
+ const endIdx = Math.min(lines.length, node.endLine);
1218
+ return lines.slice(startIdx, endIdx).join('\n');
1219
+ }
1220
+ catch (error) {
1221
+ (0, errors_1.logDebug)('Failed to extract code from node', { nodeId: node.id, filePath: node.filePath, error: String(error) });
1222
+ return null;
1223
+ }
1224
+ }
1225
+ /**
1226
+ * Get entry points from a subgraph (the root nodes)
1227
+ */
1228
+ getEntryPoints(subgraph) {
1229
+ return subgraph.roots
1230
+ .map((id) => subgraph.nodes.get(id))
1231
+ .filter((n) => n !== undefined);
1232
+ }
1233
+ /**
1234
+ * Extract code blocks for key nodes in the subgraph
1235
+ */
1236
+ async extractCodeBlocks(subgraph, maxBlocks, maxBlockSize) {
1237
+ const blocks = [];
1238
+ // Prioritize entry points, then functions/methods
1239
+ const priorityNodes = [];
1240
+ // First: entry points
1241
+ for (const id of subgraph.roots) {
1242
+ const node = subgraph.nodes.get(id);
1243
+ if (node) {
1244
+ priorityNodes.push(node);
1245
+ }
1246
+ }
1247
+ // Then: functions and methods
1248
+ for (const node of subgraph.nodes.values()) {
1249
+ if (!subgraph.roots.includes(node.id)) {
1250
+ if (node.kind === 'function' || node.kind === 'method') {
1251
+ priorityNodes.push(node);
1252
+ }
1253
+ }
1254
+ }
1255
+ // Then: classes
1256
+ for (const node of subgraph.nodes.values()) {
1257
+ if (!subgraph.roots.includes(node.id)) {
1258
+ if (node.kind === 'class') {
1259
+ priorityNodes.push(node);
1260
+ }
1261
+ }
1262
+ }
1263
+ // Extract code for priority nodes
1264
+ for (const node of priorityNodes) {
1265
+ if (blocks.length >= maxBlocks)
1266
+ break;
1267
+ const code = await this.extractNodeCode(node);
1268
+ if (code) {
1269
+ // Truncate if too long. Language-neutral marker (no `//` — not a
1270
+ // comment in Python, Ruby, etc.); this renders inside a fenced
1271
+ // source block whose language varies.
1272
+ const truncated = code.length > maxBlockSize
1273
+ ? code.slice(0, maxBlockSize) + '\n... (truncated) ...'
1274
+ : code;
1275
+ blocks.push({
1276
+ content: truncated,
1277
+ filePath: node.filePath,
1278
+ startLine: node.startLine,
1279
+ endLine: node.endLine,
1280
+ language: node.language,
1281
+ node,
1282
+ });
1283
+ }
1284
+ }
1285
+ return blocks;
1286
+ }
1287
+ /**
1288
+ * Get unique files from a subgraph
1289
+ */
1290
+ getRelatedFiles(subgraph) {
1291
+ const files = new Set();
1292
+ for (const node of subgraph.nodes.values()) {
1293
+ files.add(node.filePath);
1294
+ }
1295
+ return Array.from(files).sort();
1296
+ }
1297
+ /**
1298
+ * Generate a summary of the context
1299
+ */
1300
+ generateSummary(_query, subgraph, entryPoints) {
1301
+ const nodeCount = subgraph.nodes.size;
1302
+ const edgeCount = subgraph.edges.length;
1303
+ const files = this.getRelatedFiles(subgraph);
1304
+ const entryPointNames = entryPoints
1305
+ .slice(0, 3)
1306
+ .map((n) => n.name)
1307
+ .join(', ');
1308
+ const remaining = entryPoints.length > 3 ? ` and ${entryPoints.length - 3} more` : '';
1309
+ return `Found ${nodeCount} relevant code symbols across ${files.length} files. ` +
1310
+ `Key entry points: ${entryPointNames}${remaining}. ` +
1311
+ `${edgeCount} relationships identified.`;
1312
+ }
1313
+ /**
1314
+ * Resolve import/export nodes to their actual definitions
1315
+ *
1316
+ * When search returns `import { TerminalPanel }`, users want the TerminalPanel
1317
+ * class definition, not the import statement. This follows the `imports` edge
1318
+ * to find and return the actual definition instead.
1319
+ *
1320
+ * @param results - Search results that may include import/export nodes
1321
+ * @returns Results with imports resolved to definitions where possible
1322
+ */
1323
+ resolveImportsToDefinitions(results) {
1324
+ const resolved = [];
1325
+ const seenIds = new Set();
1326
+ for (const result of results) {
1327
+ const { node, score } = result;
1328
+ // If it's not an import/export, keep it as-is
1329
+ if (node.kind !== 'import' && node.kind !== 'export') {
1330
+ if (!seenIds.has(node.id)) {
1331
+ seenIds.add(node.id);
1332
+ resolved.push(result);
1333
+ }
1334
+ continue;
1335
+ }
1336
+ // For imports/exports, try to find what they reference
1337
+ // Imports have outgoing 'imports' edges to the definition
1338
+ // Exports have outgoing 'exports' edges to the definition
1339
+ const edgeKind = node.kind === 'import' ? 'imports' : 'exports';
1340
+ const outgoingEdges = this.queries.getOutgoingEdges(node.id, [edgeKind]);
1341
+ let foundDefinition = false;
1342
+ for (const edge of outgoingEdges) {
1343
+ const targetNode = this.queries.getNodeById(edge.target);
1344
+ if (targetNode && !seenIds.has(targetNode.id)) {
1345
+ // Found the definition - use it instead of the import
1346
+ seenIds.add(targetNode.id);
1347
+ resolved.push({
1348
+ node: targetNode,
1349
+ score: score, // Preserve the original score
1350
+ });
1351
+ foundDefinition = true;
1352
+ (0, errors_1.logDebug)('Resolved import to definition', {
1353
+ import: node.name,
1354
+ definition: targetNode.name,
1355
+ kind: targetNode.kind,
1356
+ });
1357
+ }
1358
+ }
1359
+ // If we couldn't resolve the import, skip it (it's low-value on its own)
1360
+ if (!foundDefinition) {
1361
+ (0, errors_1.logDebug)('Skipping unresolved import', { name: node.name, file: node.filePath });
1362
+ }
1363
+ }
1364
+ return resolved;
1365
+ }
1366
+ }
1367
+ exports.ContextBuilder = ContextBuilder;
1368
+ /**
1369
+ * Create a context builder
1370
+ */
1371
+ function createContextBuilder(projectRoot, queries, traverser) {
1372
+ return new ContextBuilder(projectRoot, queries, traverser);
1373
+ }
1374
+ // Re-export formatter
1375
+ var formatter_2 = require("./formatter");
1376
+ Object.defineProperty(exports, "formatContextAsMarkdown", { enumerable: true, get: function () { return formatter_2.formatContextAsMarkdown; } });
1377
+ Object.defineProperty(exports, "formatContextAsJson", { enumerable: true, get: function () { return formatter_2.formatContextAsJson; } });
1378
+ //# sourceMappingURL=index.js.map