homegraph 1.1.3 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) hide show
  1. package/README.md +43 -18
  2. package/dist/arkts/ohos-api-index.d.ts +15 -0
  3. package/dist/arkts/ohos-api-index.d.ts.map +1 -0
  4. package/dist/arkts/ohos-api-index.js +190 -0
  5. package/dist/arkts/ohos-api-index.js.map +1 -0
  6. package/dist/arkts/ohos-sdk-input.d.ts +36 -0
  7. package/dist/arkts/ohos-sdk-input.d.ts.map +1 -0
  8. package/dist/arkts/ohos-sdk-input.js +214 -0
  9. package/dist/arkts/ohos-sdk-input.js.map +1 -0
  10. package/dist/bin/command-supervision.d.ts +12 -0
  11. package/dist/bin/command-supervision.d.ts.map +1 -0
  12. package/dist/bin/command-supervision.js +86 -0
  13. package/dist/bin/command-supervision.js.map +1 -0
  14. package/dist/bin/homegraph.d.ts +1 -1
  15. package/dist/bin/homegraph.js +709 -168
  16. package/dist/bin/homegraph.js.map +1 -1
  17. package/dist/context/index.d.ts.map +1 -1
  18. package/dist/context/index.js +85 -0
  19. package/dist/context/index.js.map +1 -1
  20. package/dist/db/index.d.ts +84 -5
  21. package/dist/db/index.d.ts.map +1 -1
  22. package/dist/db/index.js +217 -14
  23. package/dist/db/index.js.map +1 -1
  24. package/dist/db/migrations.d.ts +1 -1
  25. package/dist/db/migrations.d.ts.map +1 -1
  26. package/dist/db/migrations.js +58 -1
  27. package/dist/db/migrations.js.map +1 -1
  28. package/dist/db/queries.d.ts +131 -2
  29. package/dist/db/queries.d.ts.map +1 -1
  30. package/dist/db/queries.js +473 -9
  31. package/dist/db/queries.js.map +1 -1
  32. package/dist/db/schema.sql +52 -1
  33. package/dist/db/wal-valve.d.ts +106 -0
  34. package/dist/db/wal-valve.d.ts.map +1 -0
  35. package/dist/db/wal-valve.js +208 -0
  36. package/dist/db/wal-valve.js.map +1 -0
  37. package/dist/directory.d.ts +36 -0
  38. package/dist/directory.d.ts.map +1 -1
  39. package/dist/directory.js +274 -0
  40. package/dist/directory.js.map +1 -1
  41. package/dist/extraction/arkts-batch-worker.d.ts +2 -0
  42. package/dist/extraction/arkts-batch-worker.d.ts.map +1 -0
  43. package/dist/extraction/arkts-batch-worker.js +28 -0
  44. package/dist/extraction/arkts-batch-worker.js.map +1 -0
  45. package/dist/extraction/cfml-extractor.d.ts +107 -0
  46. package/dist/extraction/cfml-extractor.d.ts.map +1 -0
  47. package/dist/extraction/cfml-extractor.js +494 -0
  48. package/dist/extraction/cfml-extractor.js.map +1 -0
  49. package/dist/extraction/context.d.ts +11 -0
  50. package/dist/extraction/context.d.ts.map +1 -1
  51. package/dist/extraction/context.js +20 -0
  52. package/dist/extraction/context.js.map +1 -1
  53. package/dist/extraction/grammars.d.ts +25 -1
  54. package/dist/extraction/grammars.d.ts.map +1 -1
  55. package/dist/extraction/grammars.js +177 -24
  56. package/dist/extraction/grammars.js.map +1 -1
  57. package/dist/extraction/index.d.ts +55 -2
  58. package/dist/extraction/index.d.ts.map +1 -1
  59. package/dist/extraction/index.js +923 -381
  60. package/dist/extraction/index.js.map +1 -1
  61. package/dist/extraction/languages/arkts-state-decorators.d.ts +13 -0
  62. package/dist/extraction/languages/arkts-state-decorators.d.ts.map +1 -0
  63. package/dist/extraction/languages/arkts-state-decorators.js +26 -0
  64. package/dist/extraction/languages/arkts-state-decorators.js.map +1 -0
  65. package/dist/extraction/languages/arkts-viewtree.d.ts +4 -2
  66. package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
  67. package/dist/extraction/languages/arkts-viewtree.js +21 -6
  68. package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
  69. package/dist/extraction/languages/arkts.d.ts +98 -2
  70. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  71. package/dist/extraction/languages/arkts.js +1290 -61
  72. package/dist/extraction/languages/arkts.js.map +1 -1
  73. package/dist/extraction/languages/c-cpp.d.ts +98 -0
  74. package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  75. package/dist/extraction/languages/c-cpp.js +563 -1
  76. package/dist/extraction/languages/c-cpp.js.map +1 -1
  77. package/dist/extraction/languages/cfquery.d.ts +12 -0
  78. package/dist/extraction/languages/cfquery.d.ts.map +1 -0
  79. package/dist/extraction/languages/cfquery.js +28 -0
  80. package/dist/extraction/languages/cfquery.js.map +1 -0
  81. package/dist/extraction/languages/cfscript.d.ts +3 -0
  82. package/dist/extraction/languages/cfscript.d.ts.map +1 -0
  83. package/dist/extraction/languages/cfscript.js +73 -0
  84. package/dist/extraction/languages/cfscript.js.map +1 -0
  85. package/dist/extraction/languages/cobol.d.ts +33 -0
  86. package/dist/extraction/languages/cobol.d.ts.map +1 -0
  87. package/dist/extraction/languages/cobol.js +499 -0
  88. package/dist/extraction/languages/cobol.js.map +1 -0
  89. package/dist/extraction/languages/erlang.d.ts +3 -0
  90. package/dist/extraction/languages/erlang.d.ts.map +1 -0
  91. package/dist/extraction/languages/erlang.js +350 -0
  92. package/dist/extraction/languages/erlang.js.map +1 -0
  93. package/dist/extraction/languages/index.d.ts.map +1 -1
  94. package/dist/extraction/languages/index.js +16 -0
  95. package/dist/extraction/languages/index.js.map +1 -1
  96. package/dist/extraction/languages/nix.d.ts +3 -0
  97. package/dist/extraction/languages/nix.d.ts.map +1 -0
  98. package/dist/extraction/languages/nix.js +294 -0
  99. package/dist/extraction/languages/nix.js.map +1 -0
  100. package/dist/extraction/languages/ohos-api-consumer.d.ts +34 -0
  101. package/dist/extraction/languages/ohos-api-consumer.d.ts.map +1 -0
  102. package/dist/extraction/languages/ohos-api-consumer.js +283 -0
  103. package/dist/extraction/languages/ohos-api-consumer.js.map +1 -0
  104. package/dist/extraction/languages/solidity.d.ts +3 -0
  105. package/dist/extraction/languages/solidity.d.ts.map +1 -0
  106. package/dist/extraction/languages/solidity.js +293 -0
  107. package/dist/extraction/languages/solidity.js.map +1 -0
  108. package/dist/extraction/languages/terraform.d.ts +3 -0
  109. package/dist/extraction/languages/terraform.d.ts.map +1 -0
  110. package/dist/extraction/languages/terraform.js +641 -0
  111. package/dist/extraction/languages/terraform.js.map +1 -0
  112. package/dist/extraction/languages/vbnet.d.ts +11 -0
  113. package/dist/extraction/languages/vbnet.d.ts.map +1 -0
  114. package/dist/extraction/languages/vbnet.js +141 -0
  115. package/dist/extraction/languages/vbnet.js.map +1 -0
  116. package/dist/extraction/mybatis-extractor.d.ts +30 -10
  117. package/dist/extraction/mybatis-extractor.d.ts.map +1 -1
  118. package/dist/extraction/mybatis-extractor.js +140 -38
  119. package/dist/extraction/mybatis-extractor.js.map +1 -1
  120. package/dist/extraction/parse-pool.d.ts +152 -0
  121. package/dist/extraction/parse-pool.d.ts.map +1 -0
  122. package/dist/extraction/parse-pool.js +387 -0
  123. package/dist/extraction/parse-pool.js.map +1 -0
  124. package/dist/extraction/parse-worker.js +9 -2
  125. package/dist/extraction/parse-worker.js.map +1 -1
  126. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  127. package/dist/extraction/tree-sitter-helpers.js +1 -0
  128. package/dist/extraction/tree-sitter-helpers.js.map +1 -1
  129. package/dist/extraction/tree-sitter-types.d.ts +20 -1
  130. package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  131. package/dist/extraction/tree-sitter.d.ts +59 -0
  132. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  133. package/dist/extraction/tree-sitter.js +952 -37
  134. package/dist/extraction/tree-sitter.js.map +1 -1
  135. package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  136. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  137. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  138. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  139. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  140. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  141. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  142. package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  143. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  144. package/dist/graph/traversal.d.ts.map +1 -1
  145. package/dist/graph/traversal.js +77 -18
  146. package/dist/graph/traversal.js.map +1 -1
  147. package/dist/index.d.ts +85 -2
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +426 -9
  150. package/dist/index.js.map +1 -1
  151. package/dist/installer/index.d.ts +42 -0
  152. package/dist/installer/index.d.ts.map +1 -1
  153. package/dist/installer/index.js +97 -2
  154. package/dist/installer/index.js.map +1 -1
  155. package/dist/mcp/daemon-paths.d.ts +30 -3
  156. package/dist/mcp/daemon-paths.d.ts.map +1 -1
  157. package/dist/mcp/daemon-paths.js +50 -10
  158. package/dist/mcp/daemon-paths.js.map +1 -1
  159. package/dist/mcp/daemon-registry.d.ts.map +1 -1
  160. package/dist/mcp/daemon-registry.js +7 -3
  161. package/dist/mcp/daemon-registry.js.map +1 -1
  162. package/dist/mcp/daemon.d.ts +73 -3
  163. package/dist/mcp/daemon.d.ts.map +1 -1
  164. package/dist/mcp/daemon.js +258 -40
  165. package/dist/mcp/daemon.js.map +1 -1
  166. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
  167. package/dist/mcp/dynamic-boundaries.js +2 -1
  168. package/dist/mcp/dynamic-boundaries.js.map +1 -1
  169. package/dist/mcp/early-ppid.d.ts +26 -0
  170. package/dist/mcp/early-ppid.d.ts.map +1 -0
  171. package/dist/mcp/early-ppid.js +29 -0
  172. package/dist/mcp/early-ppid.js.map +1 -0
  173. package/dist/mcp/engine.d.ts +16 -0
  174. package/dist/mcp/engine.d.ts.map +1 -1
  175. package/dist/mcp/engine.js +100 -2
  176. package/dist/mcp/engine.js.map +1 -1
  177. package/dist/mcp/index.d.ts.map +1 -1
  178. package/dist/mcp/index.js +66 -49
  179. package/dist/mcp/index.js.map +1 -1
  180. package/dist/mcp/liveness-watchdog.d.ts +18 -1
  181. package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  182. package/dist/mcp/liveness-watchdog.js +73 -13
  183. package/dist/mcp/liveness-watchdog.js.map +1 -1
  184. package/dist/mcp/memory-budget.d.ts +30 -0
  185. package/dist/mcp/memory-budget.d.ts.map +1 -0
  186. package/dist/mcp/memory-budget.js +123 -0
  187. package/dist/mcp/memory-budget.js.map +1 -0
  188. package/dist/mcp/ppid-watchdog.d.ts +18 -0
  189. package/dist/mcp/ppid-watchdog.d.ts.map +1 -1
  190. package/dist/mcp/ppid-watchdog.js +37 -0
  191. package/dist/mcp/ppid-watchdog.js.map +1 -1
  192. package/dist/mcp/proxy.d.ts.map +1 -1
  193. package/dist/mcp/proxy.js +88 -4
  194. package/dist/mcp/proxy.js.map +1 -1
  195. package/dist/mcp/query-cache.d.ts +56 -0
  196. package/dist/mcp/query-cache.d.ts.map +1 -0
  197. package/dist/mcp/query-cache.js +261 -0
  198. package/dist/mcp/query-cache.js.map +1 -0
  199. package/dist/mcp/query-pool.d.ts +128 -0
  200. package/dist/mcp/query-pool.d.ts.map +1 -0
  201. package/dist/mcp/query-pool.js +374 -0
  202. package/dist/mcp/query-pool.js.map +1 -0
  203. package/dist/mcp/query-worker.d.ts +24 -0
  204. package/dist/mcp/query-worker.d.ts.map +1 -0
  205. package/dist/mcp/query-worker.js +87 -0
  206. package/dist/mcp/query-worker.js.map +1 -0
  207. package/dist/mcp/server-instructions.d.ts +4 -29
  208. package/dist/mcp/server-instructions.d.ts.map +1 -1
  209. package/dist/mcp/server-instructions.js +39 -86
  210. package/dist/mcp/server-instructions.js.map +1 -1
  211. package/dist/mcp/session.d.ts +14 -0
  212. package/dist/mcp/session.d.ts.map +1 -1
  213. package/dist/mcp/session.js +28 -1
  214. package/dist/mcp/session.js.map +1 -1
  215. package/dist/mcp/startup-handshake.d.ts +44 -0
  216. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  217. package/dist/mcp/startup-handshake.js +73 -0
  218. package/dist/mcp/startup-handshake.js.map +1 -0
  219. package/dist/mcp/tools.d.ts +179 -2
  220. package/dist/mcp/tools.d.ts.map +1 -1
  221. package/dist/mcp/tools.js +3027 -192
  222. package/dist/mcp/tools.js.map +1 -1
  223. package/dist/mcp/transport.d.ts.map +1 -1
  224. package/dist/mcp/transport.js +18 -0
  225. package/dist/mcp/transport.js.map +1 -1
  226. package/dist/project-config.d.ts +58 -0
  227. package/dist/project-config.d.ts.map +1 -1
  228. package/dist/project-config.js +141 -2
  229. package/dist/project-config.js.map +1 -1
  230. package/dist/reasoning/login.js +1 -1
  231. package/dist/reasoning/login.js.map +1 -1
  232. package/dist/resolution/c-fnptr-synthesizer.d.ts +2 -29
  233. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  234. package/dist/resolution/c-fnptr-synthesizer.js +866 -148
  235. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  236. package/dist/resolution/callback-synthesizer.d.ts +9 -1
  237. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  238. package/dist/resolution/callback-synthesizer.js +1232 -183
  239. package/dist/resolution/callback-synthesizer.js.map +1 -1
  240. package/dist/resolution/cooperative-yield.d.ts +32 -0
  241. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  242. package/dist/resolution/cooperative-yield.js +42 -0
  243. package/dist/resolution/cooperative-yield.js.map +1 -0
  244. package/dist/resolution/frameworks/cics.d.ts +20 -0
  245. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  246. package/dist/resolution/frameworks/cics.js +90 -0
  247. package/dist/resolution/frameworks/cics.js.map +1 -0
  248. package/dist/resolution/frameworks/index.d.ts.map +1 -1
  249. package/dist/resolution/frameworks/index.js +3 -0
  250. package/dist/resolution/frameworks/index.js.map +1 -1
  251. package/dist/resolution/frameworks/java.d.ts.map +1 -1
  252. package/dist/resolution/frameworks/java.js +14 -6
  253. package/dist/resolution/frameworks/java.js.map +1 -1
  254. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  255. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  256. package/dist/resolution/frameworks/terraform.js +277 -0
  257. package/dist/resolution/frameworks/terraform.js.map +1 -0
  258. package/dist/resolution/goframe-synthesizer.d.ts +2 -1
  259. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -1
  260. package/dist/resolution/goframe-synthesizer.js +8 -3
  261. package/dist/resolution/goframe-synthesizer.js.map +1 -1
  262. package/dist/resolution/import-resolver.d.ts +7 -0
  263. package/dist/resolution/import-resolver.d.ts.map +1 -1
  264. package/dist/resolution/import-resolver.js +129 -4
  265. package/dist/resolution/import-resolver.js.map +1 -1
  266. package/dist/resolution/index.d.ts +65 -3
  267. package/dist/resolution/index.d.ts.map +1 -1
  268. package/dist/resolution/index.js +477 -59
  269. package/dist/resolution/index.js.map +1 -1
  270. package/dist/resolution/name-matcher.d.ts +22 -3
  271. package/dist/resolution/name-matcher.d.ts.map +1 -1
  272. package/dist/resolution/name-matcher.js +657 -39
  273. package/dist/resolution/name-matcher.js.map +1 -1
  274. package/dist/resolution/strip-comments.d.ts +1 -1
  275. package/dist/resolution/strip-comments.d.ts.map +1 -1
  276. package/dist/resolution/strip-comments.js +49 -0
  277. package/dist/resolution/strip-comments.js.map +1 -1
  278. package/dist/resolution/types.d.ts +29 -0
  279. package/dist/resolution/types.d.ts.map +1 -1
  280. package/dist/resolution/workspace-packages.d.ts +10 -0
  281. package/dist/resolution/workspace-packages.d.ts.map +1 -1
  282. package/dist/resolution/workspace-packages.js +142 -4
  283. package/dist/resolution/workspace-packages.js.map +1 -1
  284. package/dist/search/identifier-segments.d.ts +60 -0
  285. package/dist/search/identifier-segments.d.ts.map +1 -0
  286. package/dist/search/identifier-segments.js +176 -0
  287. package/dist/search/identifier-segments.js.map +1 -0
  288. package/dist/search/query-utils.d.ts +201 -0
  289. package/dist/search/query-utils.d.ts.map +1 -1
  290. package/dist/search/query-utils.js +919 -2
  291. package/dist/search/query-utils.js.map +1 -1
  292. package/dist/spec/config.d.ts +7 -11
  293. package/dist/spec/config.d.ts.map +1 -1
  294. package/dist/spec/config.js +77 -48
  295. package/dist/spec/config.js.map +1 -1
  296. package/dist/spec/db/fragment-node.d.ts +1 -0
  297. package/dist/spec/db/fragment-node.d.ts.map +1 -1
  298. package/dist/spec/db/fragment-node.js +8 -0
  299. package/dist/spec/db/fragment-node.js.map +1 -1
  300. package/dist/spec/db/fts.d.ts +14 -0
  301. package/dist/spec/db/fts.d.ts.map +1 -1
  302. package/dist/spec/db/fts.js +43 -4
  303. package/dist/spec/db/fts.js.map +1 -1
  304. package/dist/spec/db/schema.d.ts +6 -3
  305. package/dist/spec/db/schema.d.ts.map +1 -1
  306. package/dist/spec/db/schema.js +36 -4
  307. package/dist/spec/db/schema.js.map +1 -1
  308. package/dist/spec/db/schema.sql +11 -1
  309. package/dist/spec/evolve/logic-checker.d.ts +2 -2
  310. package/dist/spec/evolve/logic-checker.d.ts.map +1 -1
  311. package/dist/spec/evolve/logic-checker.js +3 -27
  312. package/dist/spec/evolve/logic-checker.js.map +1 -1
  313. package/dist/spec/evolve/pipeline.d.ts +21 -19
  314. package/dist/spec/evolve/pipeline.d.ts.map +1 -1
  315. package/dist/spec/evolve/pipeline.js +284 -31
  316. package/dist/spec/evolve/pipeline.js.map +1 -1
  317. package/dist/spec/evolve/spec-rewriter.d.ts +2 -2
  318. package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -1
  319. package/dist/spec/evolve/spec-rewriter.js +7 -31
  320. package/dist/spec/evolve/spec-rewriter.js.map +1 -1
  321. package/dist/spec/graph/queries.d.ts +97 -0
  322. package/dist/spec/graph/queries.d.ts.map +1 -1
  323. package/dist/spec/graph/queries.js +225 -0
  324. package/dist/spec/graph/queries.js.map +1 -1
  325. package/dist/spec/llm/client.d.ts +29 -0
  326. package/dist/spec/llm/client.d.ts.map +1 -0
  327. package/dist/spec/llm/client.js +123 -0
  328. package/dist/spec/llm/client.js.map +1 -0
  329. package/dist/spec/llm/index.d.ts +3 -0
  330. package/dist/spec/llm/index.d.ts.map +1 -0
  331. package/dist/spec/llm/index.js +11 -0
  332. package/dist/spec/llm/index.js.map +1 -0
  333. package/dist/spec/llm/prompts.d.ts +13 -0
  334. package/dist/spec/llm/prompts.d.ts.map +1 -0
  335. package/dist/spec/llm/prompts.js +75 -0
  336. package/dist/spec/llm/prompts.js.map +1 -0
  337. package/dist/spec/mining/git-scanner.d.ts +12 -0
  338. package/dist/spec/mining/git-scanner.d.ts.map +1 -1
  339. package/dist/spec/mining/git-scanner.js +41 -0
  340. package/dist/spec/mining/git-scanner.js.map +1 -1
  341. package/dist/spec/mining/pipeline.d.ts.map +1 -1
  342. package/dist/spec/mining/pipeline.js +14 -1
  343. package/dist/spec/mining/pipeline.js.map +1 -1
  344. package/dist/spec/utils.d.ts +2 -1
  345. package/dist/spec/utils.d.ts.map +1 -1
  346. package/dist/spec/utils.js +3 -1
  347. package/dist/spec/utils.js.map +1 -1
  348. package/dist/sync/git-hooks.d.ts.map +1 -1
  349. package/dist/sync/git-hooks.js +2 -0
  350. package/dist/sync/git-hooks.js.map +1 -1
  351. package/dist/sync/watcher.d.ts +10 -5
  352. package/dist/sync/watcher.d.ts.map +1 -1
  353. package/dist/sync/watcher.js +51 -14
  354. package/dist/sync/watcher.js.map +1 -1
  355. package/dist/sync/worktree.d.ts +9 -0
  356. package/dist/sync/worktree.d.ts.map +1 -1
  357. package/dist/sync/worktree.js +45 -0
  358. package/dist/sync/worktree.js.map +1 -1
  359. package/dist/types.d.ts +25 -2
  360. package/dist/types.d.ts.map +1 -1
  361. package/dist/types.js +10 -0
  362. package/dist/types.js.map +1 -1
  363. package/dist/ui/shimmer-progress.d.ts +2 -0
  364. package/dist/ui/shimmer-progress.d.ts.map +1 -1
  365. package/dist/ui/shimmer-progress.js +19 -2
  366. package/dist/ui/shimmer-progress.js.map +1 -1
  367. package/dist/upgrade/index.d.ts +32 -0
  368. package/dist/upgrade/index.d.ts.map +1 -1
  369. package/dist/upgrade/index.js +163 -15
  370. package/dist/upgrade/index.js.map +1 -1
  371. package/dist/upgrade/remove-binary.d.ts +87 -0
  372. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  373. package/dist/upgrade/remove-binary.js +289 -0
  374. package/dist/upgrade/remove-binary.js.map +1 -0
  375. package/dist/upgrade/update-check.d.ts +92 -0
  376. package/dist/upgrade/update-check.d.ts.map +1 -0
  377. package/dist/upgrade/update-check.js +258 -0
  378. package/dist/upgrade/update-check.js.map +1 -0
  379. package/package.json +4 -4
  380. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  381. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  382. package/scripts/agent-eval/run-all.sh +6 -0
  383. package/scripts/build-bundle.sh +5 -0
  384. package/scripts/exp_boundary_eval/README.md +247 -0
  385. package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -0
  386. package/scripts/exp_boundary_eval/_test_stdin.py +8 -0
  387. package/scripts/exp_boundary_eval/_utils.py +1116 -0
  388. package/scripts/exp_boundary_eval/analyze.py +1313 -0
  389. package/scripts/exp_boundary_eval/deveco_arm.py +519 -0
  390. package/scripts/exp_boundary_eval/run_all.py +378 -0
  391. package/scripts/exp_boundary_eval/run_one.py +165 -0
  392. package/scripts/exp_boundary_eval/run_session.py +158 -0
  393. package/scripts/exp_boundary_eval/setup.py +120 -0
  394. package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -0
  395. package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -0
  396. package/scripts/exp_boundary_eval/win_node_launcher.py +24 -0
  397. package/scripts/npm-shim.js +32 -3
  398. package/scripts/ohos-sdk-publish.mjs +133 -0
  399. package/scripts/qa_eval/README.md +0 -407
  400. package/scripts/qa_eval/_test_deveco_probe.py +0 -41
  401. package/scripts/qa_eval/agent_runner.py +0 -526
  402. package/scripts/qa_eval/data/.gitignore +0 -4
  403. package/scripts/qa_eval/data/test-set.jsonl +0 -2
  404. package/scripts/qa_eval/eval_metrics.py +0 -274
  405. package/scripts/qa_eval/external_agent.py +0 -976
  406. package/scripts/qa_eval/llm_config.py +0 -92
  407. package/scripts/qa_eval/memory_monitor.py +0 -132
  408. package/scripts/qa_eval/my_answer_accuracy.py +0 -187
  409. package/scripts/qa_eval/requirements.txt +0 -2
  410. package/scripts/qa_eval/run_pipeline.py +0 -804
  411. package/scripts/qa_eval/stats_efficiency.py +0 -279
  412. package/scripts/qa_eval/stats_scores.py +0 -207
@@ -0,0 +1,374 @@
1
+ "use strict";
2
+ /**
3
+ * Query pool — runs CPU-heavy read-tool calls on a pool of worker threads so
4
+ * the shared daemon's main event loop stays free for the MCP transport.
5
+ *
6
+ * Why this exists: see {@link ./query-worker}. One daemon, one event loop, one
7
+ * synchronous SQLite connection serializes every concurrent `codegraph_explore`
8
+ * AND starves the transport (a 10-way wave delivered 0 transport heartbeats in
9
+ * 25s — responses can't flush until the whole batch drains, so clients time
10
+ * out). Spreading the dispatch across worker threads (each its own WAL read
11
+ * connection) restores true multi-core parallelism and an idle main loop.
12
+ *
13
+ * Properties:
14
+ * - lazy growth: **no worker until the first heavy call**, then grows to
15
+ * `size` on demand. Eager warm-start used to open a second full DB on every
16
+ * MCP session and balloon RSS (~5GB on ~800MB indexes).
17
+ * - **default concurrency is 1** — each worker is another V8 + WAL open; on
18
+ * large indexes two workers routinely doubled working-set into multi-GB.
19
+ * Override with `CODEGRAPH_QUERY_POOL_SIZE` when you truly need more.
20
+ * - **admission**: when outstanding work already fills `size` in-flight plus
21
+ * another `size` waiting, further calls resolve immediately with
22
+ * success-shaped busy/partial guidance instead of queuing up to die at the
23
+ * client hard timeout.
24
+ * - crash recovery: a dead worker is respawned and its in-flight call retried
25
+ * once; a poison call that keeps crashing fails gracefully (never wedges the
26
+ * pool). A crash budget trips a circuit breaker (`healthy` → false) so the
27
+ * caller falls back to in-process dispatch instead of thrashing respawns.
28
+ * - graceful backstop: a call that can't be served within `softTimeoutMs`
29
+ * (default 20s, clamped ≤30s — well under typical ~60s MCP client timeouts)
30
+ * resolves with SUCCESS-shaped static "Partial / busy, retry" guidance —
31
+ * never `isError`, and never DB/FTS work on the timeout callback (that
32
+ * can freeze the transport so the client still sees empty `-32001`).
33
+ */
34
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ var desc = Object.getOwnPropertyDescriptor(m, k);
37
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
38
+ desc = { enumerable: true, get: function() { return m[k]; } };
39
+ }
40
+ Object.defineProperty(o, k2, desc);
41
+ }) : (function(o, m, k, k2) {
42
+ if (k2 === undefined) k2 = k;
43
+ o[k2] = m[k];
44
+ }));
45
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
46
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
47
+ }) : function(o, v) {
48
+ o["default"] = v;
49
+ });
50
+ var __importStar = (this && this.__importStar) || (function () {
51
+ var ownKeys = function(o) {
52
+ ownKeys = Object.getOwnPropertyNames || function (o) {
53
+ var ar = [];
54
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
55
+ return ar;
56
+ };
57
+ return ownKeys(o);
58
+ };
59
+ return function (mod) {
60
+ if (mod && mod.__esModule) return mod;
61
+ var result = {};
62
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
63
+ __setModuleDefault(result, mod);
64
+ return result;
65
+ };
66
+ })();
67
+ Object.defineProperty(exports, "__esModule", { value: true });
68
+ exports.QueryPool = void 0;
69
+ exports.resolvePoolSize = resolvePoolSize;
70
+ exports.resolveBusyTimeoutMs = resolveBusyTimeoutMs;
71
+ exports.resolveToolDeadlineMs = resolveToolDeadlineMs;
72
+ const worker_threads_1 = require("worker_threads");
73
+ const path = __importStar(require("path"));
74
+ const os = __importStar(require("os"));
75
+ /** Compiled sibling — `query-worker.js` lives next to this file in `dist/mcp/`. */
76
+ const WORKER_FILE = path.join(__dirname, 'query-worker.js');
77
+ /**
78
+ * Default soft backstop — must stay **well below** typical MCP client hard
79
+ * timeouts (~60s). Eval / agent configs sometimes set the env to 60000, which
80
+ * races the client and yields empty `-32001`; we clamp to
81
+ * {@link MAX_BUSY_TIMEOUT_MS} regardless. Prefer returning busy/partial early
82
+ * so the agent can retry once instead of waiting out the client hard cut.
83
+ */
84
+ const DEFAULT_BUSY_TIMEOUT_MS = 15_000;
85
+ /** Hard ceiling — leave headroom under ~30–60s client timeouts (flush / scheduling). */
86
+ const MAX_BUSY_TIMEOUT_MS = 20_000;
87
+ /**
88
+ * Default concurrent workers when env is unset. Keep at 1: a second connection
89
+ * on a large index is a multi-GB RSS hit. Explicit env overrides still go up to
90
+ * {@link MAX_POOL_SIZE}.
91
+ */
92
+ const DEFAULT_POOL_CAP = 1;
93
+ /** Hard ceiling on pool size regardless of core count / env. */
94
+ const MAX_POOL_SIZE = 16;
95
+ /**
96
+ * Total worker deaths before the pool declares itself unhealthy and the caller
97
+ * reverts to in-process dispatch. High enough to ride out a few transient
98
+ * crashes, low enough that a systematically-broken worker (e.g. a platform that
99
+ * can't spawn threads) degrades quickly instead of respawning forever.
100
+ */
101
+ const CRASH_BUDGET = 12;
102
+ /**
103
+ * Max workers cold-starting at once. A worker's cold start is heavy — full
104
+ * module load (tree-sitter etc.) + opening a large WAL DB — and starting the
105
+ * whole pool simultaneously thrashes CPU/I-O so badly it can stall the daemon's
106
+ * main loop for tens of seconds. Warming a couple at a time keeps each start
107
+ * fast; as one reports ready the next begins, so the pool still reaches full
108
+ * size within a few calls of a burst, just without the thundering herd.
109
+ */
110
+ const MAX_CONCURRENT_SPAWN = 2;
111
+ /**
112
+ * Resolve the pool size from the `CODEGRAPH_QUERY_POOL_SIZE` override and the
113
+ * machine's core count. `0` (or a negative) explicitly disables the pool (the
114
+ * caller serves in-process — today's behavior). Unset → `clamp(cores-1, 1, 1)`:
115
+ * one parallel explore without a second full-DB RSS hit. Explicit overrides still
116
+ * honor up to {@link MAX_POOL_SIZE}.
117
+ */
118
+ function resolvePoolSize(envVal, cpuCount) {
119
+ if (envVal !== undefined && envVal !== '') {
120
+ const n = Number(envVal);
121
+ if (Number.isFinite(n) && n >= 0)
122
+ return Math.min(Math.floor(n), MAX_POOL_SIZE);
123
+ // non-numeric / negative → fall through to the default
124
+ }
125
+ return Math.max(1, Math.min(cpuCount - 1, DEFAULT_POOL_CAP));
126
+ }
127
+ /**
128
+ * Soft / tool deadline. Env `CODEGRAPH_QUERY_BUSY_TIMEOUT_MS` may raise or
129
+ * lower it, but is always clamped into `[1000, MAX_BUSY_TIMEOUT_MS]` so a
130
+ * mistaken `60000` cannot race DevEco/Cursor's ~60s MCP hard timeout.
131
+ */
132
+ function resolveBusyTimeoutMs() {
133
+ const raw = process.env.CODEGRAPH_QUERY_BUSY_TIMEOUT_MS;
134
+ if (raw === undefined || raw === '')
135
+ return DEFAULT_BUSY_TIMEOUT_MS;
136
+ const n = Number(raw);
137
+ if (!Number.isFinite(n) || n < 1000)
138
+ return DEFAULT_BUSY_TIMEOUT_MS;
139
+ return Math.min(Math.floor(n), MAX_BUSY_TIMEOUT_MS);
140
+ }
141
+ /** Same as {@link resolveBusyTimeoutMs} — used by ToolHandler for all tools. */
142
+ function resolveToolDeadlineMs() {
143
+ return resolveBusyTimeoutMs();
144
+ }
145
+ /** Success-shaped overload guidance (NEVER isError — see the abandonment rule). */
146
+ function busyGuidance(waitedMs, reason = 'timeout') {
147
+ const secs = Math.max(1, Math.round(waitedMs / 1000));
148
+ const why = reason === 'admission'
149
+ ? 'too many concurrent HomeGraph queries are already in flight'
150
+ : `this call waited ${secs}s in the queue / on a worker`;
151
+ return {
152
+ content: [{
153
+ type: 'text',
154
+ text: `⚠️ **Partial result** — HomeGraph is busy (${why}). This is NOT an error. ` +
155
+ `Retry ONE \`homegraph_explore\` with the concrete symbol/file names from the question — ` +
156
+ `do not fire search+explore or node+callers+callees in parallel, and do not fall back to grep/read ` +
157
+ `for symbols you already named (that duplicates tokens). A single retry usually returns full source.`,
158
+ }],
159
+ };
160
+ }
161
+ class QueryPool {
162
+ idle = [];
163
+ queue = [];
164
+ inflight = new Map();
165
+ workers = new Set();
166
+ // Workers spawned but not yet 'ready'. Growth must count these so a single
167
+ // first call (with the eager worker still starting) doesn't spawn the WHOLE
168
+ // pool at once — N simultaneous cold worker starts (each a full module load +
169
+ // a large DB open) saturate the box and starve the main loop. Grow only when
170
+ // the queue outstrips idle + pending.
171
+ pendingWorkers = new Set();
172
+ nextId = 1;
173
+ totalCrashes = 0;
174
+ destroyed = false;
175
+ root;
176
+ maxSize;
177
+ softTimeoutMs;
178
+ maxRetries;
179
+ createWorker;
180
+ everReady = false;
181
+ constructor(opts) {
182
+ this.root = opts.root;
183
+ this.maxSize = Math.max(1, Math.min(opts.size ?? Math.min(DEFAULT_POOL_CAP, Math.max(1, os.cpus().length - 1)), MAX_POOL_SIZE));
184
+ this.softTimeoutMs = opts.softTimeoutMs ?? resolveBusyTimeoutMs();
185
+ this.maxRetries = opts.maxRetries ?? 1;
186
+ this.createWorker = opts.createWorker ?? (() => new worker_threads_1.Worker(WORKER_FILE, { workerData: { root: this.root } }));
187
+ // One eager warm worker so the first tool call isn't queued behind a cold start (#662).
188
+ this.spawnOne();
189
+ }
190
+ /**
191
+ * True once at least one worker has completed a successful cold-start handshake.
192
+ * False during the cold-start window (and after destroy) so ToolHandler can
193
+ * fall back to in-process dispatch instead of queuing behind a busy backstop.
194
+ */
195
+ get ready() {
196
+ return this.everReady && !this.destroyed;
197
+ }
198
+ /** Pool size cap (for logging/status). */
199
+ get size() { return this.maxSize; }
200
+ /** Live worker count (for tests/status). */
201
+ get liveWorkers() { return this.workers.size; }
202
+ /**
203
+ * False once the crash budget is exhausted (or after destroy). The ToolHandler
204
+ * checks this and falls back to in-process dispatch — a broken worker platform
205
+ * degrades to today's behavior instead of failing tool calls.
206
+ */
207
+ get healthy() {
208
+ return !this.destroyed && this.totalCrashes < CRASH_BUDGET;
209
+ }
210
+ /** In-flight + unsettled queued jobs (for admission / tests). */
211
+ outstandingCount() {
212
+ return this.inflight.size + this.queue.filter((j) => !j.settled).length;
213
+ }
214
+ /**
215
+ * How many unsettled jobs we tolerate before refusing new ones immediately.
216
+ * One full wave running + one full wave waiting — further fan-out gets
217
+ * busy/partial guidance instead of stacking up to the soft timeout.
218
+ */
219
+ admissionLimit() {
220
+ return this.maxSize * 2;
221
+ }
222
+ spawnOne() {
223
+ if (this.destroyed || this.workers.size >= this.maxSize)
224
+ return;
225
+ let w;
226
+ try {
227
+ w = this.createWorker();
228
+ }
229
+ catch {
230
+ this.totalCrashes++; // counts toward the circuit breaker
231
+ return;
232
+ }
233
+ this.workers.add(w);
234
+ this.pendingWorkers.add(w);
235
+ w.on('message', (m) => this.onMessage(w, (m ?? {})));
236
+ w.on('error', () => this.onWorkerGone(w));
237
+ w.on('exit', (code) => { if (code !== 0)
238
+ this.onWorkerGone(w); });
239
+ }
240
+ onMessage(w, m) {
241
+ if (!m)
242
+ return;
243
+ if (m.type === 'ready') {
244
+ this.pendingWorkers.delete(w);
245
+ if (m.ok === false)
246
+ this.totalCrashes++; // hard open failure
247
+ else
248
+ this.everReady = true;
249
+ this.idle.push(w);
250
+ this.drain();
251
+ return;
252
+ }
253
+ if (m.type === 'result') {
254
+ const job = this.inflight.get(w);
255
+ this.inflight.delete(w);
256
+ this.idle.push(w);
257
+ if (job)
258
+ this.settle(job, m.result ?? busyGuidance(0));
259
+ this.drain();
260
+ }
261
+ }
262
+ // A worker died (crash hook, OOM, segfault, exit≠0). Respawn a replacement and
263
+ // retry its in-flight job once; a job that keeps crashing workers fails
264
+ // gracefully so it can't loop the pool forever.
265
+ onWorkerGone(w) {
266
+ if (!this.workers.has(w))
267
+ return; // already handled (error+exit both fire)
268
+ this.workers.delete(w);
269
+ this.pendingWorkers.delete(w);
270
+ this.idle = this.idle.filter((x) => x !== w);
271
+ this.totalCrashes++;
272
+ const job = this.inflight.get(w);
273
+ this.inflight.delete(w);
274
+ try {
275
+ void w.terminate();
276
+ }
277
+ catch { /* already gone */ }
278
+ if (this.healthy)
279
+ this.spawnOne(); // keep capacity
280
+ if (job) {
281
+ if (job.retries < this.maxRetries && this.healthy) {
282
+ job.retries++;
283
+ this.queue.unshift(job); // head of line — retry promptly
284
+ }
285
+ else {
286
+ this.settle(job, { isError: true, content: [{ type: 'text', text: 'codegraph worker crashed; please retry the call.' }] });
287
+ }
288
+ }
289
+ this.drain();
290
+ }
291
+ drain() {
292
+ // Grow toward maxSize while queued work outstrips workers that are idle OR
293
+ // already on their way up (pending) — so we never spawn the whole pool for a
294
+ // single call whose eager worker just hasn't reported ready yet.
295
+ while (this.queue.length > this.idle.length + this.pendingWorkers.size &&
296
+ this.workers.size < this.maxSize &&
297
+ this.pendingWorkers.size < MAX_CONCURRENT_SPAWN &&
298
+ this.healthy) {
299
+ this.spawnOne();
300
+ }
301
+ while (this.idle.length && this.queue.length) {
302
+ // Skip jobs the backstop already answered.
303
+ let job;
304
+ while (this.queue.length && (job = this.queue.shift()) && job.settled)
305
+ job = undefined;
306
+ if (!job || job.settled)
307
+ break;
308
+ const w = this.idle.pop();
309
+ this.inflight.set(w, job);
310
+ w.postMessage({ type: 'call', id: job.id, toolName: job.toolName, args: job.args });
311
+ }
312
+ }
313
+ settle(job, result) {
314
+ if (job.settled)
315
+ return; // already answered (by backstop or worker)
316
+ job.settled = true;
317
+ if (job.softTimer)
318
+ clearTimeout(job.softTimer);
319
+ job.resolve(result);
320
+ }
321
+ settleBusyOrPartial(job, reason) {
322
+ if (job.settled)
323
+ return;
324
+ const partial = job.onSoftTimeout?.();
325
+ if (partial) {
326
+ this.settle(job, partial);
327
+ return;
328
+ }
329
+ this.settle(job, busyGuidance(Date.now() - job.enqueuedAt, reason));
330
+ }
331
+ /** Run a read tool on the pool. Always resolves (never rejects). */
332
+ run(toolName, args, opts) {
333
+ return new Promise((resolve) => {
334
+ const job = {
335
+ id: this.nextId++, toolName, args, resolve,
336
+ retries: 0, settled: false, enqueuedAt: Date.now(),
337
+ onSoftTimeout: opts?.onSoftTimeout,
338
+ };
339
+ // Hard admission: refuse to stack another wave that would sit until soft
340
+ // timeout / client hard timeout. Caller gets partial/busy NOW.
341
+ if (this.outstandingCount() >= this.admissionLimit()) {
342
+ this.settleBusyOrPartial(job, 'admission');
343
+ return;
344
+ }
345
+ // Don't let the caller wait past softTimeoutMs. The worker may still be
346
+ // busy (we can't cancel synchronous CPU), but the CLIENT gets a prompt,
347
+ // success-shaped "retry"/partial instead of a hard timeout.
348
+ job.softTimer = setTimeout(() => {
349
+ this.settleBusyOrPartial(job, 'timeout');
350
+ }, this.softTimeoutMs);
351
+ job.softTimer.unref?.();
352
+ this.queue.push(job);
353
+ this.drain();
354
+ });
355
+ }
356
+ /** Terminate all workers and answer any outstanding calls gracefully. */
357
+ async destroy() {
358
+ if (this.destroyed)
359
+ return;
360
+ this.destroyed = true;
361
+ const ws = [...this.workers];
362
+ this.workers.clear();
363
+ this.pendingWorkers.clear();
364
+ this.idle = [];
365
+ for (const job of [...this.inflight.values(), ...this.queue]) {
366
+ this.settle(job, { isError: true, content: [{ type: 'text', text: 'codegraph is shutting down; retry shortly.' }] });
367
+ }
368
+ this.inflight.clear();
369
+ this.queue = [];
370
+ await Promise.all(ws.map((w) => Promise.resolve(w.terminate()).catch(() => { })));
371
+ }
372
+ }
373
+ exports.QueryPool = QueryPool;
374
+ //# sourceMappingURL=query-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-pool.js","sourceRoot":"","sources":["../../src/mcp/query-pool.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGH,0CAOC;AAOD,oDAMC;AAGD,sDAEC;AA/HD,mDAAwC;AACxC,2CAA6B;AAC7B,uCAAyB;AAGzB,mFAAmF;AACnF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAgB5D;;;;;;GAMG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EAAE,CAAC;QACf,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4CAA4C,EAAE,CAAC,EAAE,CAAC,CAAC;QACvH,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;IACvG,CAAC;CACF;AAvND,8BAuNC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Query worker thread — issue: concurrent MCP tool calls starve the daemon.
3
+ *
4
+ * The shared daemon serves every session on ONE event loop with synchronous
5
+ * `node:sqlite`. `codegraph_explore` is CPU-heavy (FTS + RWR/personalized-
6
+ * PageRank + impact + output building) stitched together by microtask `await`s,
7
+ * so N concurrent explores keep the microtask queue continuously full and
8
+ * starve the macrotask phases — timers AND socket I/O. The transport freezes:
9
+ * no response flushes, no request is read, until the whole batch drains. With
10
+ * ~10 subagents that routinely exceeds the MCP client's request timeout.
11
+ *
12
+ * This worker moves the heavy read-tool dispatch OFF the daemon's main loop.
13
+ * Each worker owns its OWN read connection (node:sqlite WAL allows N concurrent
14
+ * readers across connections — verified: a worker reader sees the main writer's
15
+ * committed catch-up/watcher writes), so {@link QueryPool} runs N tool calls in
16
+ * true parallel up to core count while the main loop stays free for the MCP
17
+ * transport. The worker runs {@link ToolHandler.executeReadTool} — validation +
18
+ * dispatch + error classification — and returns the raw {@link ToolResult}; the
19
+ * MAIN thread keeps the catch-up gate, the watcher-state notices (staleness /
20
+ * worktree), `codegraph_status`, and telemetry, none of which a watcher-less
21
+ * read connection can answer.
22
+ */
23
+ export {};
24
+ //# sourceMappingURL=query-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-worker.d.ts","sourceRoot":"","sources":["../../src/mcp/query-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /**
3
+ * Query worker thread — issue: concurrent MCP tool calls starve the daemon.
4
+ *
5
+ * The shared daemon serves every session on ONE event loop with synchronous
6
+ * `node:sqlite`. `codegraph_explore` is CPU-heavy (FTS + RWR/personalized-
7
+ * PageRank + impact + output building) stitched together by microtask `await`s,
8
+ * so N concurrent explores keep the microtask queue continuously full and
9
+ * starve the macrotask phases — timers AND socket I/O. The transport freezes:
10
+ * no response flushes, no request is read, until the whole batch drains. With
11
+ * ~10 subagents that routinely exceeds the MCP client's request timeout.
12
+ *
13
+ * This worker moves the heavy read-tool dispatch OFF the daemon's main loop.
14
+ * Each worker owns its OWN read connection (node:sqlite WAL allows N concurrent
15
+ * readers across connections — verified: a worker reader sees the main writer's
16
+ * committed catch-up/watcher writes), so {@link QueryPool} runs N tool calls in
17
+ * true parallel up to core count while the main loop stays free for the MCP
18
+ * transport. The worker runs {@link ToolHandler.executeReadTool} — validation +
19
+ * dispatch + error classification — and returns the raw {@link ToolResult}; the
20
+ * MAIN thread keeps the catch-up gate, the watcher-state notices (staleness /
21
+ * worktree), `codegraph_status`, and telemetry, none of which a watcher-less
22
+ * read connection can answer.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const worker_threads_1 = require("worker_threads");
26
+ // Mirror the engine's lazy-require of the heavy CodeGraph + tools chain. This
27
+ // module is only ever loaded as a Worker, so the require runs once on spawn.
28
+ const loadCodeGraph = () => require('../index').default;
29
+ const loadToolHandler = () => require('./tools').ToolHandler;
30
+ if (worker_threads_1.parentPort) {
31
+ const port = worker_threads_1.parentPort;
32
+ const { root } = worker_threads_1.workerData;
33
+ // Open the default project's READ connection once, at spawn. Other repos are
34
+ // opened lazily on first cross-project (projectPath) call by the ToolHandler's
35
+ // own per-handler cache. openSync does not start a watcher — workers are pure
36
+ // readers; the single watcher/writer stays on the daemon's main thread.
37
+ let handler = null;
38
+ let initError = null;
39
+ try {
40
+ const cg = loadCodeGraph().openSync(root);
41
+ handler = new (loadToolHandler())(cg);
42
+ }
43
+ catch (err) {
44
+ initError = err instanceof Error ? err.message : String(err);
45
+ }
46
+ // Tell the pool we're up. `ok:false` lets the pool count a hard open failure
47
+ // against its crash budget (→ fall back to in-process) without hanging.
48
+ port.postMessage({ type: 'ready', ok: initError === null, error: initError });
49
+ port.on('message', (msg) => {
50
+ if (!msg || msg.type !== 'call')
51
+ return;
52
+ void serve(msg);
53
+ });
54
+ const serve = async (msg) => {
55
+ // Test-only crash hook so the pool's worker-recovery path is exercisable
56
+ // deterministically. Gated behind an env flag only the suite sets — inert in
57
+ // normal operation (and `__test_crash__` isn't a real tool name anyway).
58
+ if (msg.toolName === '__test_crash__' && process.env.CODEGRAPH_QUERY_WORKER_ALLOW_TEST_CRASH === '1') {
59
+ process.exit(13);
60
+ }
61
+ if (!handler) {
62
+ port.postMessage({
63
+ type: 'result',
64
+ id: msg.id,
65
+ result: errorResult(`codegraph worker could not open the project: ${initError}`),
66
+ });
67
+ return;
68
+ }
69
+ try {
70
+ // executeReadTool already classifies NotIndexed/PathRefusal/internal errors
71
+ // into a ToolResult and never throws — the catch is belt-and-suspenders.
72
+ const result = await handler.executeReadTool(msg.toolName, msg.args);
73
+ port.postMessage({ type: 'result', id: msg.id, result });
74
+ }
75
+ catch (err) {
76
+ port.postMessage({
77
+ type: 'result',
78
+ id: msg.id,
79
+ result: errorResult(err instanceof Error ? err.message : String(err)),
80
+ });
81
+ }
82
+ };
83
+ }
84
+ function errorResult(text) {
85
+ return { isError: true, content: [{ type: 'text', text }] };
86
+ }
87
+ //# sourceMappingURL=query-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-worker.js","sourceRoot":"","sources":["../../src/mcp/query-worker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;AAEH,mDAAwD;AAcxD,8EAA8E;AAC9E,6EAA6E;AAC7E,MAAM,aAAa,GAAG,GAAsC,EAAE,CAC3D,OAAO,CAAC,UAAU,CAA+B,CAAC,OAAO,CAAC;AAC7D,MAAM,eAAe,GAAG,GAAyC,EAAE,CAChE,OAAO,CAAC,SAAS,CAA8B,CAAC,WAAW,CAAC;AAE/D,IAAI,2BAAU,EAAE,CAAC;IACf,MAAM,IAAI,GAAG,2BAAU,CAAC;IACxB,MAAM,EAAE,IAAI,EAAE,GAAG,2BAAwB,CAAC;IAE1C,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,wEAAwE;IACxE,IAAI,OAAO,GAA8D,IAAI,CAAC;IAC9E,IAAI,SAAS,GAAkB,IAAI,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,aAAa,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,SAAS,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC;IAED,6EAA6E;IAC7E,wEAAwE;IACxE,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,KAAK,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAE9E,IAAI,CAAC,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,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC9D,CAAC"}
@@ -1,34 +1,9 @@
1
1
  /**
2
2
  * Server-level instructions emitted in the MCP `initialize` response.
3
3
  *
4
- * MCP clients (Claude Code, Cursor, opencode, LangChain, OpenAI Agent
5
- * SDK, …) surface this text in the agent's system prompt automatically,
6
- * giving the agent a high-level playbook for the homegraph toolset
7
- * before it sees individual tool descriptions.
8
- *
9
- * Goals when editing this:
10
- * - Lead the agent to homegraph_explore for any structural/flow question
11
- * - Reinforce "explore instead of Read/Grep" for indexed code
12
- * - Anti-patterns (don't re-verify with grep; don't hand-reconstruct flows)
13
- *
14
- * Keep it tight. The agent reads this every session — long instructions
15
- * burn tokens. The DEFAULT MCP surface is `homegraph_explore` ALONE (see
16
- * DEFAULT_MCP_TOOLS in tools.ts) — reference only that tool here. The other
17
- * tools (node/search/callers/…) stay defined and are re-enablable via
18
- * HOMEGRAPH_MCP_TOOLS, but they are NOT listed to agents, so don't name them.
19
- */
20
- export declare const SERVER_INSTRUCTIONS = "# Codegraph \u2014 code intelligence over an indexed knowledge graph\n\nCodegraph is a SQLite knowledge graph of every symbol, edge, and file in\nthe workspace \u2014 pre-computed structure you would otherwise re-derive by\nreading files (cached intelligence: thousands of parse/trace decisions you\ndon't pay to re-reason each run). Reads are sub-millisecond; the index lags\nwrites by ~1s through the file watcher. Reach for it BEFORE *and* while\nwriting or editing code \u2014 not just for questions: one call returns the\nverbatim source PLUS who calls it and what it affects, so you edit with the\nblast radius in view. More accurate context, in far fewer tokens and\nround-trips than reading files yourself.\n\n## One tool: homegraph_explore \u2014 use it instead of reading files\n\nThere is a single tool, `homegraph_explore`, and it is Read-equivalent. It\ntakes either a natural-language question or a bag of symbol/file names and\nreturns the **verbatim, line-numbered source** of the relevant symbols\ngrouped by file \u2014 the same `<n>\\t<line>` shape `Read` gives you, safe to\n`Edit` from \u2014 PLUS the call path among them (including dynamic-dispatch hops\nlike callbacks, React re-render, and JSX children that grep can't follow) and\na blast-radius summary of what depends on them.\n\nWhether you're answering \"how does X work\" or implementing a change (fixing a\nbug, adding a feature), call `homegraph_explore` before you Read. ONE call\nusually answers the whole question. Codegraph IS the pre-built search index \u2014\nso running your own grep + read loop, or delegating the lookup to a separate\nfile-reading sub-task/agent, repeats work homegraph already did and costs more\nfor the same answer. A direct homegraph answer is typically one to a few\ncalls; a grep/read exploration is dozens.\n\n## How to query\n\n- **Almost any question \u2014 \"how does X work\", architecture, a bug, \"what/where is X\", or surveying an area** \u2192 `homegraph_explore` with a natural-language question or the relevant names. ONE capped call returns the verbatim source grouped by file; most often the ONLY call you need.\n- **\"How does X reach/become Y? / the flow / the path from X to Y\"** \u2192 `homegraph_explore`, naming the symbols that span the flow (e.g. `mutateElement renderScene`) \u2014 it surfaces the call path among them, riding dynamic-dispatch hops, and returns their source.\n- **Reading or editing a file/symbol you can name** \u2192 put its name or file path in the `homegraph_explore` query \u2014 it returns that current line-numbered source (safe to `Edit` from) with the call path and blast radius attached, so you don't Read it separately. For an overloaded name it returns every matching definition's body in one call.\n- **Need more?** Call `homegraph_explore` again with more specific names \u2014 treat the source it returns as already Read.\n\n## Anti-patterns\n\n- **Trust homegraph's results \u2014 don't re-verify them with grep.** They come from a full AST parse; re-checking with grep is slower, less accurate, and wastes context.\n- **Don't grep or Read first** to find or understand indexed code \u2014 ONE `homegraph_explore` returns the relevant symbols' source together in a single round-trip. Reach for raw `Read`/`Grep` only to confirm a specific detail homegraph didn't cover, or for what homegraph doesn't index (configs, docs).\n- **Don't reconstruct a flow by hand** \u2014 name the endpoints in one `homegraph_explore` and it surfaces the path between them, dynamic-dispatch hops included.\n- **After editing, check the staleness banner.** When a tool response starts with \"\u26A0\uFE0F Some files referenced below were edited since the last index sync\u2026\", the listed files are pending re-index \u2014 Read those specific files for accurate content. Every file NOT in that banner is fresh, so still trust homegraph. A different, rarer banner \u2014 \"\u26A0\uFE0F HomeGraph auto-sync is DISABLED\u2026\" \u2014 means live watching stopped entirely (the whole index is frozen, not just a few files); until it's resolved, Read files directly to confirm anything that may have changed.\n\n## Limitations\n\n- If a tool reports a project isn't indexed (no `.homegraph/`), stop calling homegraph tools for that project for the rest of the session and use your built-in tools there instead. Indexing is the user's decision \u2014 mention they can run `homegraph init` if it comes up, but don't run it yourself.\n- Index lags file writes by ~1 second.\n- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.\n- No live correctness validation \u2014 that's still the TypeScript compiler / test suite / linter's job. Codegraph supplements those with structural context they don't have.\n";
21
- /**
22
- * Instructions variant sent when the server's own root has NO homegraph index.
23
- *
24
- * The tools are still exposed (gating tool availability on whether `./` has an
25
- * index is the bug behind #964: it breaks monorepos where only sub-projects are
26
- * indexed, and a server that started before `homegraph init` never surfaces the
27
- * tools afterward). Instead of an "inactive" note, this variant tells the agent
28
- * homegraph works **per project**: there's no default project to query, so pass
29
- * a `projectPath` to any project that HAS a `.homegraph/`. The full single-
30
- * project playbook ({@link SERVER_INSTRUCTIONS}) is sent instead when the root
31
- * IS indexed, so the common case stays tight.
4
+ * Single source of truth for agent-facing tool guidance (issue #529).
5
+ * Edit here — not installer prompts or eval harness prompts.
32
6
  */
33
- export declare const SERVER_INSTRUCTIONS_NO_ROOT_INDEX = "# Codegraph \u2014 available (per-project; pass projectPath)\n\nCodegraph is a SQLite knowledge graph of a codebase's symbols, edges, and\nfiles: one `homegraph_explore` call returns the verbatim, line-numbered source\nof the relevant symbols PLUS the call paths between them and a blast-radius\nsummary \u2014 replacing a grep + Read loop with one round-trip.\n\nThis server started somewhere with no `.homegraph/` of its own, so there is no\ndefault project \u2014 but the tools are available and work **per project**:\n\n- To query a project that HAS a `.homegraph/` index (e.g. a service inside a\n monorepo, or a second repo), pass its path as `projectPath` to\n `homegraph_explore` (and any other homegraph tool). Codegraph resolves the\n nearest `.homegraph/` at or above that path and answers from it \u2014 for as many\n projects as you like in one session.\n- For a project with no `.homegraph/`, use your built-in tools (Read/Grep/Glob)\n for that project. Indexing is the user's decision \u2014 don't run it yourself, but\n if it comes up they can run `homegraph init` in a project to enable homegraph\n there (a new index is picked up live, no restart).\n";
7
+ export declare const SERVER_INSTRUCTIONS = "# HomeGraph \u2014 when to call\n\nHomeGraph is a **local structural index of THIS repo**: symbols + call/import/extends edges + files. Use it only when the answer needs that graph.\n\n## Call HomeGraph (closed set)\n\nUse `homegraph_explore` (primary) when **all** of these hold:\n\n1. The evidence lives **in this repository's source** (not an external SDK manual).\n2. You need **structure**: definition location, who calls whom, how A reaches B, multi-file wiring, or in-repo import/usage of a named API/`@kit` module.\n3. You can put **concrete names** in `query` \u2014 symbol, `Type.member`, file basename, or `@kit\u2026` (skip `homegraph_search` when names are already known).\n\nTypical fits:\n\n- How a **feature in this repo** is wired (mechanism / cross-file / click\u2192handler flow)\n- Callers / callees / blast radius of a **named** symbol\n- What a **named component/method** does (include the name; one explore is enough)\n- In-repo usages of an imported API (not the official feature catalog)\n\n**One explore with names** beats search\u2192explore\u2192node\u2192grep\u2192read. Treat returned line-numbered source as already Read. After a full explore \u2014 **answer**; do not re-verify with grep/read/node for the same symbols. Busy/partial \u2192 retry that **same** explore once.\n\n## Do not call HomeGraph otherwise\n\nIf the question is **outside the set above**, do **not** open any `homegraph_*` tool \u2014 use Read / Grep / Glob / SDK docs. HomeGraph is not a general Q&A layer; forcing it on the wrong shape costs time and tokens and often lowers quality.\n\n## Tool roles\n\n| Tool | Role |\n|------|------|\n| **homegraph_explore** | Primary for the closed set above |\n| homegraph_node | One known symbol body (or indexed file) after explore named it |\n| homegraph_callers / callees | Compact edge lists for a named symbol |\n| homegraph_search | Rare \u2014 unknown spelling only |\n| homegraph_files | Folder tree only |\n\n## Tips\n\n- **Deadline / partial** \u2014 success-shaped; retry ONE explore with the same names. Do not abandon to grep for those symbols.\n- **Staleness banner** \u2014 Read only the listed edited files.\n- **Not indexed** \u2014 built-in tools; user runs `homegraph init` \u2014 you do not.\n";
8
+ export declare const SERVER_INSTRUCTIONS_NO_ROOT_INDEX = "# HomeGraph \u2014 per-project (pass projectPath)\n\nHomeGraph indexes a codebase into a symbol graph. Call it **only** for in-repo structural / flow / usage questions on a project that has `.homegraph/`. Pass that project as `projectPath`.\n\n- Fits the closed set (structure, callers, wiring, named symbol/file) \u2192 `homegraph_explore`\n- Anything else \u2192 Read/Grep/Glob \u2014 **do not call homegraph_***\n- No index \u2192 Read/Grep/Glob; user runs `homegraph init` if they want indexing\n";
34
9
  //# sourceMappingURL=server-instructions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,qsJAkD/B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iCAAiC,4pCAmB7C,CAAC"}
1
+ {"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,mBAAmB,wtEAwC/B,CAAC;AAEF,eAAO,MAAM,iCAAiC,yfAO7C,CAAC"}