homegraph 1.1.3 → 1.2.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 (246) 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 +706 -168
  16. package/dist/bin/homegraph.js.map +1 -1
  17. package/dist/db/index.d.ts +20 -0
  18. package/dist/db/index.d.ts.map +1 -1
  19. package/dist/db/index.js +39 -0
  20. package/dist/db/index.js.map +1 -1
  21. package/dist/db/migrations.d.ts +1 -1
  22. package/dist/db/migrations.d.ts.map +1 -1
  23. package/dist/db/migrations.js +40 -1
  24. package/dist/db/migrations.js.map +1 -1
  25. package/dist/db/queries.d.ts +14 -0
  26. package/dist/db/queries.d.ts.map +1 -1
  27. package/dist/db/queries.js +174 -3
  28. package/dist/db/queries.js.map +1 -1
  29. package/dist/db/schema.sql +20 -0
  30. package/dist/directory.d.ts +32 -0
  31. package/dist/directory.d.ts.map +1 -1
  32. package/dist/directory.js +83 -0
  33. package/dist/directory.js.map +1 -1
  34. package/dist/extraction/arkts-batch-worker.d.ts +2 -0
  35. package/dist/extraction/arkts-batch-worker.d.ts.map +1 -0
  36. package/dist/extraction/arkts-batch-worker.js +28 -0
  37. package/dist/extraction/arkts-batch-worker.js.map +1 -0
  38. package/dist/extraction/context.d.ts +11 -0
  39. package/dist/extraction/context.d.ts.map +1 -1
  40. package/dist/extraction/context.js +20 -0
  41. package/dist/extraction/context.js.map +1 -1
  42. package/dist/extraction/index.d.ts +16 -2
  43. package/dist/extraction/index.d.ts.map +1 -1
  44. package/dist/extraction/index.js +619 -380
  45. package/dist/extraction/index.js.map +1 -1
  46. package/dist/extraction/languages/arkts-state-decorators.d.ts +13 -0
  47. package/dist/extraction/languages/arkts-state-decorators.d.ts.map +1 -0
  48. package/dist/extraction/languages/arkts-state-decorators.js +26 -0
  49. package/dist/extraction/languages/arkts-state-decorators.js.map +1 -0
  50. package/dist/extraction/languages/arkts-viewtree.d.ts +4 -2
  51. package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
  52. package/dist/extraction/languages/arkts-viewtree.js +21 -6
  53. package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
  54. package/dist/extraction/languages/arkts.d.ts +98 -2
  55. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  56. package/dist/extraction/languages/arkts.js +1290 -61
  57. package/dist/extraction/languages/arkts.js.map +1 -1
  58. package/dist/extraction/languages/c-cpp.d.ts +56 -0
  59. package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  60. package/dist/extraction/languages/c-cpp.js +198 -1
  61. package/dist/extraction/languages/c-cpp.js.map +1 -1
  62. package/dist/extraction/languages/ohos-api-consumer.d.ts +34 -0
  63. package/dist/extraction/languages/ohos-api-consumer.d.ts.map +1 -0
  64. package/dist/extraction/languages/ohos-api-consumer.js +283 -0
  65. package/dist/extraction/languages/ohos-api-consumer.js.map +1 -0
  66. package/dist/extraction/parse-pool.d.ts +126 -0
  67. package/dist/extraction/parse-pool.d.ts.map +1 -0
  68. package/dist/extraction/parse-pool.js +319 -0
  69. package/dist/extraction/parse-pool.js.map +1 -0
  70. package/dist/extraction/tree-sitter-types.d.ts +17 -0
  71. package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  72. package/dist/extraction/tree-sitter.d.ts +21 -0
  73. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  74. package/dist/extraction/tree-sitter.js +198 -27
  75. package/dist/extraction/tree-sitter.js.map +1 -1
  76. package/dist/graph/traversal.d.ts.map +1 -1
  77. package/dist/graph/traversal.js +76 -17
  78. package/dist/graph/traversal.js.map +1 -1
  79. package/dist/index.d.ts +25 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +78 -4
  82. package/dist/index.js.map +1 -1
  83. package/dist/mcp/daemon-paths.d.ts +30 -3
  84. package/dist/mcp/daemon-paths.d.ts.map +1 -1
  85. package/dist/mcp/daemon-paths.js +50 -10
  86. package/dist/mcp/daemon-paths.js.map +1 -1
  87. package/dist/mcp/daemon-registry.d.ts.map +1 -1
  88. package/dist/mcp/daemon-registry.js +7 -3
  89. package/dist/mcp/daemon-registry.js.map +1 -1
  90. package/dist/mcp/daemon.d.ts +48 -0
  91. package/dist/mcp/daemon.d.ts.map +1 -1
  92. package/dist/mcp/daemon.js +196 -32
  93. package/dist/mcp/daemon.js.map +1 -1
  94. package/dist/mcp/engine.d.ts +17 -0
  95. package/dist/mcp/engine.d.ts.map +1 -1
  96. package/dist/mcp/engine.js +73 -1
  97. package/dist/mcp/engine.js.map +1 -1
  98. package/dist/mcp/index.d.ts.map +1 -1
  99. package/dist/mcp/index.js +25 -43
  100. package/dist/mcp/index.js.map +1 -1
  101. package/dist/mcp/ppid-watchdog.d.ts +18 -0
  102. package/dist/mcp/ppid-watchdog.d.ts.map +1 -1
  103. package/dist/mcp/ppid-watchdog.js +37 -0
  104. package/dist/mcp/ppid-watchdog.js.map +1 -1
  105. package/dist/mcp/query-cache.d.ts +25 -0
  106. package/dist/mcp/query-cache.d.ts.map +1 -0
  107. package/dist/mcp/query-cache.js +191 -0
  108. package/dist/mcp/query-cache.js.map +1 -0
  109. package/dist/mcp/query-pool.d.ts +94 -0
  110. package/dist/mcp/query-pool.d.ts.map +1 -0
  111. package/dist/mcp/query-pool.js +297 -0
  112. package/dist/mcp/query-pool.js.map +1 -0
  113. package/dist/mcp/query-worker.d.ts +24 -0
  114. package/dist/mcp/query-worker.d.ts.map +1 -0
  115. package/dist/mcp/query-worker.js +87 -0
  116. package/dist/mcp/query-worker.js.map +1 -0
  117. package/dist/mcp/server-instructions.d.ts +5 -7
  118. package/dist/mcp/server-instructions.d.ts.map +1 -1
  119. package/dist/mcp/server-instructions.js +12 -14
  120. package/dist/mcp/server-instructions.js.map +1 -1
  121. package/dist/mcp/tools.d.ts +77 -0
  122. package/dist/mcp/tools.d.ts.map +1 -1
  123. package/dist/mcp/tools.js +696 -60
  124. package/dist/mcp/tools.js.map +1 -1
  125. package/dist/project-config.d.ts +20 -0
  126. package/dist/project-config.d.ts.map +1 -1
  127. package/dist/project-config.js +42 -2
  128. package/dist/project-config.js.map +1 -1
  129. package/dist/reasoning/login.js +1 -1
  130. package/dist/reasoning/login.js.map +1 -1
  131. package/dist/resolution/c-fnptr-synthesizer.d.ts +0 -28
  132. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  133. package/dist/resolution/c-fnptr-synthesizer.js +765 -79
  134. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  135. package/dist/resolution/callback-synthesizer.d.ts +1 -1
  136. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  137. package/dist/resolution/callback-synthesizer.js +72 -11
  138. package/dist/resolution/callback-synthesizer.js.map +1 -1
  139. package/dist/resolution/cooperative-yield.d.ts +32 -0
  140. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  141. package/dist/resolution/cooperative-yield.js +42 -0
  142. package/dist/resolution/cooperative-yield.js.map +1 -0
  143. package/dist/resolution/index.d.ts +11 -2
  144. package/dist/resolution/index.d.ts.map +1 -1
  145. package/dist/resolution/index.js +72 -4
  146. package/dist/resolution/index.js.map +1 -1
  147. package/dist/resolution/name-matcher.d.ts +22 -0
  148. package/dist/resolution/name-matcher.d.ts.map +1 -1
  149. package/dist/resolution/name-matcher.js +317 -20
  150. package/dist/resolution/name-matcher.js.map +1 -1
  151. package/dist/spec/config.d.ts +7 -11
  152. package/dist/spec/config.d.ts.map +1 -1
  153. package/dist/spec/config.js +77 -48
  154. package/dist/spec/config.js.map +1 -1
  155. package/dist/spec/db/fragment-node.d.ts +1 -0
  156. package/dist/spec/db/fragment-node.d.ts.map +1 -1
  157. package/dist/spec/db/fragment-node.js +8 -0
  158. package/dist/spec/db/fragment-node.js.map +1 -1
  159. package/dist/spec/db/fts.d.ts +14 -0
  160. package/dist/spec/db/fts.d.ts.map +1 -1
  161. package/dist/spec/db/fts.js +43 -4
  162. package/dist/spec/db/fts.js.map +1 -1
  163. package/dist/spec/db/schema.d.ts +6 -3
  164. package/dist/spec/db/schema.d.ts.map +1 -1
  165. package/dist/spec/db/schema.js +36 -4
  166. package/dist/spec/db/schema.js.map +1 -1
  167. package/dist/spec/db/schema.sql +11 -1
  168. package/dist/spec/evolve/logic-checker.d.ts +2 -2
  169. package/dist/spec/evolve/logic-checker.d.ts.map +1 -1
  170. package/dist/spec/evolve/logic-checker.js +3 -27
  171. package/dist/spec/evolve/logic-checker.js.map +1 -1
  172. package/dist/spec/evolve/pipeline.d.ts +21 -19
  173. package/dist/spec/evolve/pipeline.d.ts.map +1 -1
  174. package/dist/spec/evolve/pipeline.js +284 -31
  175. package/dist/spec/evolve/pipeline.js.map +1 -1
  176. package/dist/spec/evolve/spec-rewriter.d.ts +2 -2
  177. package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -1
  178. package/dist/spec/evolve/spec-rewriter.js +7 -31
  179. package/dist/spec/evolve/spec-rewriter.js.map +1 -1
  180. package/dist/spec/graph/queries.d.ts +97 -0
  181. package/dist/spec/graph/queries.d.ts.map +1 -1
  182. package/dist/spec/graph/queries.js +225 -0
  183. package/dist/spec/graph/queries.js.map +1 -1
  184. package/dist/spec/llm/client.d.ts +29 -0
  185. package/dist/spec/llm/client.d.ts.map +1 -0
  186. package/dist/spec/llm/client.js +123 -0
  187. package/dist/spec/llm/client.js.map +1 -0
  188. package/dist/spec/llm/index.d.ts +3 -0
  189. package/dist/spec/llm/index.d.ts.map +1 -0
  190. package/dist/spec/llm/index.js +11 -0
  191. package/dist/spec/llm/index.js.map +1 -0
  192. package/dist/spec/llm/prompts.d.ts +13 -0
  193. package/dist/spec/llm/prompts.d.ts.map +1 -0
  194. package/dist/spec/llm/prompts.js +75 -0
  195. package/dist/spec/llm/prompts.js.map +1 -0
  196. package/dist/spec/mining/git-scanner.d.ts +12 -0
  197. package/dist/spec/mining/git-scanner.d.ts.map +1 -1
  198. package/dist/spec/mining/git-scanner.js +41 -0
  199. package/dist/spec/mining/git-scanner.js.map +1 -1
  200. package/dist/spec/mining/pipeline.d.ts.map +1 -1
  201. package/dist/spec/mining/pipeline.js +14 -1
  202. package/dist/spec/mining/pipeline.js.map +1 -1
  203. package/dist/spec/utils.d.ts +2 -1
  204. package/dist/spec/utils.d.ts.map +1 -1
  205. package/dist/spec/utils.js +3 -1
  206. package/dist/spec/utils.js.map +1 -1
  207. package/dist/sync/worktree.d.ts +9 -0
  208. package/dist/sync/worktree.d.ts.map +1 -1
  209. package/dist/sync/worktree.js +40 -0
  210. package/dist/sync/worktree.js.map +1 -1
  211. package/dist/types.d.ts +6 -1
  212. package/dist/types.d.ts.map +1 -1
  213. package/dist/ui/shimmer-progress.d.ts +2 -0
  214. package/dist/ui/shimmer-progress.d.ts.map +1 -1
  215. package/dist/ui/shimmer-progress.js +19 -2
  216. package/dist/ui/shimmer-progress.js.map +1 -1
  217. package/dist/upgrade/index.js +1 -1
  218. package/dist/upgrade/index.js.map +1 -1
  219. package/package.json +3 -3
  220. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  221. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  222. package/scripts/exp_boundary_eval/README.md +247 -0
  223. package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
  224. package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
  225. package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
  226. package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
  227. package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
  228. package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
  229. package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -0
  230. package/scripts/exp_boundary_eval/_test_stdin.py +8 -0
  231. package/scripts/exp_boundary_eval/_utils.py +1116 -0
  232. package/scripts/exp_boundary_eval/analyze.py +1313 -0
  233. package/scripts/exp_boundary_eval/data/agents.json +109 -0
  234. package/scripts/exp_boundary_eval/data/experiments.json +140 -0
  235. package/scripts/exp_boundary_eval/deveco_arm.py +519 -0
  236. package/scripts/exp_boundary_eval/run_all.py +378 -0
  237. package/scripts/exp_boundary_eval/run_one.py +165 -0
  238. package/scripts/exp_boundary_eval/run_session.py +158 -0
  239. package/scripts/exp_boundary_eval/setup.py +120 -0
  240. package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -0
  241. package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -0
  242. package/scripts/exp_boundary_eval/win_node_launcher.py +24 -0
  243. package/scripts/npm-shim.js +25 -3
  244. package/scripts/ohos-sdk-publish.mjs +133 -0
  245. package/scripts/qa_eval/README.md +1 -1
  246. package/scripts/qa_eval/agent_runner.py +1 -1
@@ -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,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AAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,4EAA4E;YAC5E,yEAAyE;YACzE,MAAM,MAAM,GAAe,MAAM,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;YACjF,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,WAAW,CAAC;gBACf,IAAI,EAAE,QAAQ;gBACd,EAAE,EAAE,GAAG,CAAC,EAAE;gBACV,MAAM,EAAE,WAAW,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aACtE,CAAC,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"}
@@ -11,13 +11,11 @@
11
11
  * - Reinforce "explore instead of Read/Grep" for indexed code
12
12
  * - Anti-patterns (don't re-verify with grep; don't hand-reconstruct flows)
13
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.
14
+ * HomeGraph exposes the full tool surface by default (search, node, explore,
15
+ * spec tools, …). Lead with homegraph_explore for structural questions; the
16
+ * other tools are available when a narrower step helps.
19
17
  */
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";
18
+ export declare const SERVER_INSTRUCTIONS = "# HomeGraph \u2014 code intelligence over an indexed knowledge graph\n\nHomeGraph 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## Primary tool: homegraph_explore \u2014 use it instead of reading files\n\nFor structural and flow questions, `homegraph_explore` 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. HomeGraph 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. HomeGraph supplements those with structural context they don't have.\n";
21
19
  /**
22
20
  * Instructions variant sent when the server's own root has NO homegraph index.
23
21
  *
@@ -30,5 +28,5 @@ export declare const SERVER_INSTRUCTIONS = "# Codegraph \u2014 code intelligence
30
28
  * project playbook ({@link SERVER_INSTRUCTIONS}) is sent instead when the root
31
29
  * IS indexed, so the common case stays tight.
32
30
  */
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";
31
+ export declare const SERVER_INSTRUCTIONS_NO_ROOT_INDEX = "# HomeGraph \u2014 available (per-project; pass projectPath)\n\nHomeGraph 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). HomeGraph 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";
34
32
  //# 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;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,4sJAkD/B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iCAAiC,4pCAmB7C,CAAC"}
@@ -14,15 +14,13 @@ exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = exports.SERVER_INSTRUCTIONS = void 0
14
14
  * - Reinforce "explore instead of Read/Grep" for indexed code
15
15
  * - Anti-patterns (don't re-verify with grep; don't hand-reconstruct flows)
16
16
  *
17
- * Keep it tight. The agent reads this every session long instructions
18
- * burn tokens. The DEFAULT MCP surface is `homegraph_explore` ALONE (see
19
- * DEFAULT_MCP_TOOLS in tools.ts) reference only that tool here. The other
20
- * tools (node/search/callers/…) stay defined and are re-enablable via
21
- * HOMEGRAPH_MCP_TOOLS, but they are NOT listed to agents, so don't name them.
17
+ * HomeGraph exposes the full tool surface by default (search, node, explore,
18
+ * spec tools, …). Lead with homegraph_explore for structural questions; the
19
+ * other tools are available when a narrower step helps.
22
20
  */
23
- exports.SERVER_INSTRUCTIONS = `# Codegraph — code intelligence over an indexed knowledge graph
21
+ exports.SERVER_INSTRUCTIONS = `# HomeGraph — code intelligence over an indexed knowledge graph
24
22
 
25
- Codegraph is a SQLite knowledge graph of every symbol, edge, and file in
23
+ HomeGraph is a SQLite knowledge graph of every symbol, edge, and file in
26
24
  the workspace — pre-computed structure you would otherwise re-derive by
27
25
  reading files (cached intelligence: thousands of parse/trace decisions you
28
26
  don't pay to re-reason each run). Reads are sub-millisecond; the index lags
@@ -32,9 +30,9 @@ verbatim source PLUS who calls it and what it affects, so you edit with the
32
30
  blast radius in view. More accurate context, in far fewer tokens and
33
31
  round-trips than reading files yourself.
34
32
 
35
- ## One tool: homegraph_explore — use it instead of reading files
33
+ ## Primary tool: homegraph_explore — use it instead of reading files
36
34
 
37
- There is a single tool, \`homegraph_explore\`, and it is Read-equivalent. It
35
+ For structural and flow questions, \`homegraph_explore\` is Read-equivalent. It
38
36
  takes either a natural-language question or a bag of symbol/file names and
39
37
  returns the **verbatim, line-numbered source** of the relevant symbols
40
38
  grouped by file — the same \`<n>\\t<line>\` shape \`Read\` gives you, safe to
@@ -44,7 +42,7 @@ a blast-radius summary of what depends on them.
44
42
 
45
43
  Whether you're answering "how does X work" or implementing a change (fixing a
46
44
  bug, adding a feature), call \`homegraph_explore\` before you Read. ONE call
47
- usually answers the whole question. Codegraph IS the pre-built search index —
45
+ usually answers the whole question. HomeGraph IS the pre-built search index —
48
46
  so running your own grep + read loop, or delegating the lookup to a separate
49
47
  file-reading sub-task/agent, repeats work homegraph already did and costs more
50
48
  for the same answer. A direct homegraph answer is typically one to a few
@@ -69,7 +67,7 @@ calls; a grep/read exploration is dozens.
69
67
  - 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 — mention they can run \`homegraph init\` if it comes up, but don't run it yourself.
70
68
  - Index lags file writes by ~1 second.
71
69
  - Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.
72
- - No live correctness validation — that's still the TypeScript compiler / test suite / linter's job. Codegraph supplements those with structural context they don't have.
70
+ - No live correctness validation — that's still the TypeScript compiler / test suite / linter's job. HomeGraph supplements those with structural context they don't have.
73
71
  `;
74
72
  /**
75
73
  * Instructions variant sent when the server's own root has NO homegraph index.
@@ -83,9 +81,9 @@ calls; a grep/read exploration is dozens.
83
81
  * project playbook ({@link SERVER_INSTRUCTIONS}) is sent instead when the root
84
82
  * IS indexed, so the common case stays tight.
85
83
  */
86
- exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# Codegraph — available (per-project; pass projectPath)
84
+ exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# HomeGraph — available (per-project; pass projectPath)
87
85
 
88
- Codegraph is a SQLite knowledge graph of a codebase's symbols, edges, and
86
+ HomeGraph is a SQLite knowledge graph of a codebase's symbols, edges, and
89
87
  files: one \`homegraph_explore\` call returns the verbatim, line-numbered source
90
88
  of the relevant symbols PLUS the call paths between them and a blast-radius
91
89
  summary — replacing a grep + Read loop with one round-trip.
@@ -95,7 +93,7 @@ default project — but the tools are available and work **per project**:
95
93
 
96
94
  - To query a project that HAS a \`.homegraph/\` index (e.g. a service inside a
97
95
  monorepo, or a second repo), pass its path as \`projectPath\` to
98
- \`homegraph_explore\` (and any other homegraph tool). Codegraph resolves the
96
+ \`homegraph_explore\` (and any other homegraph tool). HomeGraph resolves the
99
97
  nearest \`.homegraph/\` at or above that path and answers from it — for as many
100
98
  projects as you like in one session.
101
99
  - For a project with no \`.homegraph/\`, use your built-in tools (Read/Grep/Glob)
@@ -1 +1 @@
1
- {"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDlC,CAAC;AAEF;;;;;;;;;;;GAWG;AACU,QAAA,iCAAiC,GAAG;;;;;;;;;;;;;;;;;;;CAmBhD,CAAC"}
1
+ {"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDlC,CAAC;AAEF;;;;;;;;;;;GAWG;AACU,QAAA,iCAAiC,GAAG;;;;;;;;;;;;;;;;;;;CAmBhD,CAAC"}
@@ -4,6 +4,7 @@
4
4
  * Defines the tools exposed by the HomeGraph MCP server.
5
5
  */
6
6
  import type HomeGraph from '../index';
7
+ import type { QueryPool } from './query-pool';
7
8
  import type { PendingFile } from '../sync';
8
9
  /**
9
10
  * An expected, recoverable "homegraph can't serve this" condition — most
@@ -113,6 +114,33 @@ export interface ToolDefinition {
113
114
  properties: Record<string, PropertySchema>;
114
115
  required?: string[];
115
116
  };
117
+ /** Behavioral hints for clients (see {@link ToolAnnotations}). */
118
+ annotations?: ToolAnnotations;
119
+ }
120
+ /**
121
+ * MCP ToolAnnotations — behavioral hints a client MAY use to decide how, or
122
+ * whether, to run a tool (introduced in the 2025-03-26 spec, carried in
123
+ * 2025-06-18). They are advisory and never to be trusted for security, but
124
+ * clients gate on them: Cursor's Ask mode, for one, refuses any MCP tool that
125
+ * doesn't advertise `readOnlyHint: true` (issue #1018).
126
+ *
127
+ * The field is purely additive — a client that predates annotations ignores it
128
+ * — so codegraph advertises these even though `initialize` still negotiates the
129
+ * 2024-11-05 protocol version.
130
+ *
131
+ * https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations
132
+ */
133
+ export interface ToolAnnotations {
134
+ /** Human-readable title for the tool. */
135
+ title?: string;
136
+ /** If true, the tool does not modify its environment. Default (unset): false. */
137
+ readOnlyHint?: boolean;
138
+ /** Meaningful only when NOT read-only: may the tool perform destructive updates? */
139
+ destructiveHint?: boolean;
140
+ /** If true, repeat calls with the same arguments have no additional effect. */
141
+ idempotentHint?: boolean;
142
+ /** If true, the tool interacts with an open world of external entities. */
143
+ openWorldHint?: boolean;
116
144
  }
117
145
  interface PropertySchema {
118
146
  type: string;
@@ -159,7 +187,15 @@ export declare class ToolHandler {
159
187
  private defaultProjectHint;
160
188
  private worktreeMismatchCache;
161
189
  private catchUpGate;
190
+ private queryPool;
162
191
  constructor(cg: HomeGraph | null);
192
+ /**
193
+ * Engine-only: attach (or detach with null) the worker-thread query pool. The
194
+ * shared daemon sets this once its default project is open; the workers each
195
+ * hold their own WAL read connection and run {@link executeReadTool}. A
196
+ * worker's own ToolHandler never has a pool, so there is no nested off-loading.
197
+ */
198
+ setQueryPool(pool: QueryPool | null): void;
163
199
  /**
164
200
  * Update the default HomeGraph instance (e.g. after lazy initialization)
165
201
  */
@@ -287,6 +323,27 @@ export declare class ToolHandler {
287
323
  * Execute a tool by name
288
324
  */
289
325
  execute(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
326
+ /**
327
+ * Run a single read tool to completion and return its raw {@link ToolResult},
328
+ * classifying expected failures the same way {@link execute}'s catch does so
329
+ * the SHAPE is identical whether dispatch runs in-process or on a worker:
330
+ * NotIndexed → success-shaped guidance, PathRefusal → clean error, anything
331
+ * else → internal-error-with-retry. Never throws.
332
+ *
333
+ * This is the worker thread's entry point (see {@link ./query-worker}) and the
334
+ * in-process fallback for {@link execute}. It deliberately does NOT run the
335
+ * catch-up gate or the staleness/worktree notices — those need the daemon's
336
+ * watched main instance and stay on the main thread. Cross-cutting allowlist +
337
+ * path validation already ran in {@link execute} before routing here.
338
+ */
339
+ executeReadTool(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
340
+ /**
341
+ * Pure dispatch over the read tools — the switch, with no gate, no notices, no
342
+ * allowlist/validation (the caller owns those). `homegraph_status` is handled
343
+ * on the main thread in {@link execute} and never reaches here. May throw
344
+ * NotIndexed/PathRefusal, which {@link executeReadTool} classifies.
345
+ */
346
+ private dispatchTool;
290
347
  /**
291
348
  * Handle homegraph_search
292
349
  */
@@ -480,6 +537,26 @@ export declare class ToolHandler {
480
537
  * or not the code index is present.
481
538
  */
482
539
  private handleSpecMatch;
540
+ /**
541
+ * Find which specs are related to the given file path by matching against
542
+ * code-fragment file paths in the Commit4Spec knowledge graph.
543
+ *
544
+ * Traverses: filePath → code_fragment_nodes → commit_fragment_relations
545
+ * → spec_commit_relations → spec_nodes.
546
+ */
547
+ private handleSpecFind;
548
+ /**
549
+ * Trace a code symbol back to its associated Specs.
550
+ *
551
+ * Uses the HomeGraph code index to resolve the symbol to AST-level node(s),
552
+ * then queries the Commit4Spec knowledge graph for associated Specs via
553
+ * five-dimensional scoring (file-path, content FTS5, name FTS5, recency,
554
+ * line overlap).
555
+ *
556
+ * This bridges the two databases: homegraph.db (code entities) →
557
+ * commit4spec.db (Spec knowledge graph).
558
+ */
559
+ private handleSpecTrace;
483
560
  /**
484
561
  * Find a symbol by name, handling disambiguation when multiple matches exist.
485
562
  * Returns the best match and a note about alternatives if any.
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"A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