@stupidloud/codegraph 0.8.1 → 0.9.9

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 (341) hide show
  1. package/README.md +319 -152
  2. package/dist/bin/codegraph.d.ts +4 -0
  3. package/dist/bin/codegraph.d.ts.map +1 -1
  4. package/dist/bin/codegraph.js +354 -90
  5. package/dist/bin/codegraph.js.map +1 -1
  6. package/dist/bin/node-version-check.d.ts +17 -0
  7. package/dist/bin/node-version-check.d.ts.map +1 -1
  8. package/dist/bin/node-version-check.js +37 -0
  9. package/dist/bin/node-version-check.js.map +1 -1
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +1 -11
  12. package/dist/config.js.map +1 -1
  13. package/dist/context/formatter.d.ts.map +1 -1
  14. package/dist/context/formatter.js +25 -6
  15. package/dist/context/formatter.js.map +1 -1
  16. package/dist/context/index.d.ts +22 -0
  17. package/dist/context/index.d.ts.map +1 -1
  18. package/dist/context/index.js +257 -6
  19. package/dist/context/index.js.map +1 -1
  20. package/dist/context/markers.d.ts +19 -0
  21. package/dist/context/markers.d.ts.map +1 -0
  22. package/dist/context/markers.js +22 -0
  23. package/dist/context/markers.js.map +1 -0
  24. package/dist/db/index.d.ts +30 -1
  25. package/dist/db/index.d.ts.map +1 -1
  26. package/dist/db/index.js +75 -25
  27. package/dist/db/index.js.map +1 -1
  28. package/dist/db/queries.d.ts +104 -0
  29. package/dist/db/queries.d.ts.map +1 -1
  30. package/dist/db/queries.js +328 -31
  31. package/dist/db/queries.js.map +1 -1
  32. package/dist/db/sqlite-adapter.d.ts +24 -23
  33. package/dist/db/sqlite-adapter.d.ts.map +1 -1
  34. package/dist/db/sqlite-adapter.js +54 -174
  35. package/dist/db/sqlite-adapter.js.map +1 -1
  36. package/dist/directory.d.ts.map +1 -1
  37. package/dist/directory.js +6 -20
  38. package/dist/directory.js.map +1 -1
  39. package/dist/extraction/generated-detection.d.ts +30 -0
  40. package/dist/extraction/generated-detection.d.ts.map +1 -0
  41. package/dist/extraction/generated-detection.js +80 -0
  42. package/dist/extraction/generated-detection.js.map +1 -0
  43. package/dist/extraction/grammars.d.ts +23 -1
  44. package/dist/extraction/grammars.d.ts.map +1 -1
  45. package/dist/extraction/grammars.js +107 -3
  46. package/dist/extraction/grammars.js.map +1 -1
  47. package/dist/extraction/index.d.ts +22 -14
  48. package/dist/extraction/index.d.ts.map +1 -1
  49. package/dist/extraction/index.js +272 -183
  50. package/dist/extraction/index.js.map +1 -1
  51. package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  52. package/dist/extraction/languages/c-cpp.js +45 -0
  53. package/dist/extraction/languages/c-cpp.js.map +1 -1
  54. package/dist/extraction/languages/csharp.d.ts.map +1 -1
  55. package/dist/extraction/languages/csharp.js +2 -1
  56. package/dist/extraction/languages/csharp.js.map +1 -1
  57. package/dist/extraction/languages/go.d.ts.map +1 -1
  58. package/dist/extraction/languages/go.js +18 -2
  59. package/dist/extraction/languages/go.js.map +1 -1
  60. package/dist/extraction/languages/index.d.ts.map +1 -1
  61. package/dist/extraction/languages/index.js +6 -0
  62. package/dist/extraction/languages/index.js.map +1 -1
  63. package/dist/extraction/languages/java.d.ts.map +1 -1
  64. package/dist/extraction/languages/java.js +6 -0
  65. package/dist/extraction/languages/java.js.map +1 -1
  66. package/dist/extraction/languages/kotlin.d.ts.map +1 -1
  67. package/dist/extraction/languages/kotlin.js +6 -0
  68. package/dist/extraction/languages/kotlin.js.map +1 -1
  69. package/dist/extraction/languages/lua.d.ts +3 -0
  70. package/dist/extraction/languages/lua.d.ts.map +1 -0
  71. package/dist/extraction/languages/lua.js +150 -0
  72. package/dist/extraction/languages/lua.js.map +1 -0
  73. package/dist/extraction/languages/luau.d.ts +3 -0
  74. package/dist/extraction/languages/luau.d.ts.map +1 -0
  75. package/dist/extraction/languages/luau.js +37 -0
  76. package/dist/extraction/languages/luau.js.map +1 -0
  77. package/dist/extraction/languages/objc.d.ts +3 -0
  78. package/dist/extraction/languages/objc.d.ts.map +1 -0
  79. package/dist/extraction/languages/objc.js +133 -0
  80. package/dist/extraction/languages/objc.js.map +1 -0
  81. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  82. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  83. package/dist/extraction/mybatis-extractor.js +198 -0
  84. package/dist/extraction/mybatis-extractor.js.map +1 -0
  85. package/dist/extraction/tree-sitter-types.d.ts +14 -0
  86. package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  87. package/dist/extraction/tree-sitter.d.ts +84 -0
  88. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  89. package/dist/extraction/tree-sitter.js +715 -16
  90. package/dist/extraction/tree-sitter.js.map +1 -1
  91. package/dist/extraction/vue-extractor.d.ts +15 -0
  92. package/dist/extraction/vue-extractor.d.ts.map +1 -1
  93. package/dist/extraction/vue-extractor.js +88 -0
  94. package/dist/extraction/vue-extractor.js.map +1 -1
  95. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  96. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  97. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  98. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  99. package/dist/extraction/wasm-runtime-flags.js +106 -0
  100. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  101. package/dist/graph/traversal.d.ts.map +1 -1
  102. package/dist/graph/traversal.js +76 -38
  103. package/dist/graph/traversal.js.map +1 -1
  104. package/dist/index.d.ts +77 -8
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +133 -19
  107. package/dist/index.js.map +1 -1
  108. package/dist/installer/config-writer.d.ts +7 -8
  109. package/dist/installer/config-writer.d.ts.map +1 -1
  110. package/dist/installer/config-writer.js +7 -27
  111. package/dist/installer/config-writer.js.map +1 -1
  112. package/dist/installer/index.d.ts +51 -16
  113. package/dist/installer/index.d.ts.map +1 -1
  114. package/dist/installer/index.js +120 -29
  115. package/dist/installer/index.js.map +1 -1
  116. package/dist/installer/instructions-template.d.ts +11 -21
  117. package/dist/installer/instructions-template.d.ts.map +1 -1
  118. package/dist/installer/instructions-template.js +12 -56
  119. package/dist/installer/instructions-template.js.map +1 -1
  120. package/dist/installer/targets/antigravity.d.ts +57 -0
  121. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  122. package/dist/installer/targets/antigravity.js +308 -0
  123. package/dist/installer/targets/antigravity.js.map +1 -0
  124. package/dist/installer/targets/claude.d.ts +26 -1
  125. package/dist/installer/targets/claude.d.ts.map +1 -1
  126. package/dist/installer/targets/claude.js +118 -40
  127. package/dist/installer/targets/claude.js.map +1 -1
  128. package/dist/installer/targets/codex.d.ts.map +1 -1
  129. package/dist/installer/targets/codex.js +15 -13
  130. package/dist/installer/targets/codex.js.map +1 -1
  131. package/dist/installer/targets/cursor.d.ts.map +1 -1
  132. package/dist/installer/targets/cursor.js +61 -36
  133. package/dist/installer/targets/cursor.js.map +1 -1
  134. package/dist/installer/targets/gemini.d.ts +26 -0
  135. package/dist/installer/targets/gemini.d.ts.map +1 -0
  136. package/dist/installer/targets/gemini.js +167 -0
  137. package/dist/installer/targets/gemini.js.map +1 -0
  138. package/dist/installer/targets/hermes.d.ts +18 -0
  139. package/dist/installer/targets/hermes.d.ts.map +1 -0
  140. package/dist/installer/targets/hermes.js +359 -0
  141. package/dist/installer/targets/hermes.js.map +1 -0
  142. package/dist/installer/targets/kiro.d.ts +27 -0
  143. package/dist/installer/targets/kiro.d.ts.map +1 -0
  144. package/dist/installer/targets/kiro.js +178 -0
  145. package/dist/installer/targets/kiro.js.map +1 -0
  146. package/dist/installer/targets/opencode.d.ts.map +1 -1
  147. package/dist/installer/targets/opencode.js +15 -13
  148. package/dist/installer/targets/opencode.js.map +1 -1
  149. package/dist/installer/targets/registry.d.ts.map +1 -1
  150. package/dist/installer/targets/registry.js +8 -0
  151. package/dist/installer/targets/registry.js.map +1 -1
  152. package/dist/installer/targets/shared.d.ts.map +1 -1
  153. package/dist/installer/targets/shared.js +3 -2
  154. package/dist/installer/targets/shared.js.map +1 -1
  155. package/dist/installer/targets/types.d.ts +1 -16
  156. package/dist/installer/targets/types.d.ts.map +1 -1
  157. package/dist/mcp/daemon-paths.d.ts +46 -0
  158. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  159. package/dist/mcp/daemon-paths.js +125 -0
  160. package/dist/mcp/daemon-paths.js.map +1 -0
  161. package/dist/mcp/daemon.d.ts +161 -0
  162. package/dist/mcp/daemon.d.ts.map +1 -0
  163. package/dist/mcp/daemon.js +403 -0
  164. package/dist/mcp/daemon.js.map +1 -0
  165. package/dist/mcp/engine.d.ts +105 -0
  166. package/dist/mcp/engine.d.ts.map +1 -0
  167. package/dist/mcp/engine.js +270 -0
  168. package/dist/mcp/engine.js.map +1 -0
  169. package/dist/mcp/index.d.ts +70 -52
  170. package/dist/mcp/index.d.ts.map +1 -1
  171. package/dist/mcp/index.js +355 -331
  172. package/dist/mcp/index.js.map +1 -1
  173. package/dist/mcp/proxy.d.ts +81 -0
  174. package/dist/mcp/proxy.d.ts.map +1 -0
  175. package/dist/mcp/proxy.js +510 -0
  176. package/dist/mcp/proxy.js.map +1 -0
  177. package/dist/mcp/server-instructions.d.ts +1 -1
  178. package/dist/mcp/server-instructions.d.ts.map +1 -1
  179. package/dist/mcp/server-instructions.js +21 -21
  180. package/dist/mcp/session.d.ts +77 -0
  181. package/dist/mcp/session.d.ts.map +1 -0
  182. package/dist/mcp/session.js +294 -0
  183. package/dist/mcp/session.js.map +1 -0
  184. package/dist/mcp/tools.d.ts +171 -15
  185. package/dist/mcp/tools.d.ts.map +1 -1
  186. package/dist/mcp/tools.js +1714 -298
  187. package/dist/mcp/tools.js.map +1 -1
  188. package/dist/mcp/transport.d.ts +111 -29
  189. package/dist/mcp/transport.d.ts.map +1 -1
  190. package/dist/mcp/transport.js +181 -71
  191. package/dist/mcp/transport.js.map +1 -1
  192. package/dist/mcp/version.d.ts +19 -0
  193. package/dist/mcp/version.d.ts.map +1 -0
  194. package/dist/mcp/version.js +71 -0
  195. package/dist/mcp/version.js.map +1 -0
  196. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  197. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  198. package/dist/resolution/callback-synthesizer.js +1300 -0
  199. package/dist/resolution/callback-synthesizer.js.map +1 -0
  200. package/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  201. package/dist/resolution/frameworks/csharp.js +36 -8
  202. package/dist/resolution/frameworks/csharp.js.map +1 -1
  203. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  204. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  205. package/dist/resolution/frameworks/drupal.js +367 -0
  206. package/dist/resolution/frameworks/drupal.js.map +1 -0
  207. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  208. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  209. package/dist/resolution/frameworks/expo-modules.js +143 -0
  210. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  211. package/dist/resolution/frameworks/express.d.ts.map +1 -1
  212. package/dist/resolution/frameworks/express.js +102 -19
  213. package/dist/resolution/frameworks/express.js.map +1 -1
  214. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  215. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  216. package/dist/resolution/frameworks/fabric.js +354 -0
  217. package/dist/resolution/frameworks/fabric.js.map +1 -0
  218. package/dist/resolution/frameworks/go.d.ts.map +1 -1
  219. package/dist/resolution/frameworks/go.js +6 -3
  220. package/dist/resolution/frameworks/go.js.map +1 -1
  221. package/dist/resolution/frameworks/index.d.ts +6 -0
  222. package/dist/resolution/frameworks/index.d.ts.map +1 -1
  223. package/dist/resolution/frameworks/index.js +29 -1
  224. package/dist/resolution/frameworks/index.js.map +1 -1
  225. package/dist/resolution/frameworks/java.d.ts.map +1 -1
  226. package/dist/resolution/frameworks/java.js +339 -12
  227. package/dist/resolution/frameworks/java.js.map +1 -1
  228. package/dist/resolution/frameworks/laravel.d.ts.map +1 -1
  229. package/dist/resolution/frameworks/laravel.js +17 -8
  230. package/dist/resolution/frameworks/laravel.js.map +1 -1
  231. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  232. package/dist/resolution/frameworks/nestjs.js +324 -0
  233. package/dist/resolution/frameworks/nestjs.js.map +1 -1
  234. package/dist/resolution/frameworks/play.d.ts +19 -0
  235. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  236. package/dist/resolution/frameworks/play.js +111 -0
  237. package/dist/resolution/frameworks/play.js.map +1 -0
  238. package/dist/resolution/frameworks/python.d.ts.map +1 -1
  239. package/dist/resolution/frameworks/python.js +134 -16
  240. package/dist/resolution/frameworks/python.js.map +1 -1
  241. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  242. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  243. package/dist/resolution/frameworks/react-native.js +360 -0
  244. package/dist/resolution/frameworks/react-native.js.map +1 -0
  245. package/dist/resolution/frameworks/react.d.ts.map +1 -1
  246. package/dist/resolution/frameworks/react.js +96 -3
  247. package/dist/resolution/frameworks/react.js.map +1 -1
  248. package/dist/resolution/frameworks/ruby.d.ts.map +1 -1
  249. package/dist/resolution/frameworks/ruby.js +106 -2
  250. package/dist/resolution/frameworks/ruby.js.map +1 -1
  251. package/dist/resolution/frameworks/rust.d.ts.map +1 -1
  252. package/dist/resolution/frameworks/rust.js +102 -5
  253. package/dist/resolution/frameworks/rust.js.map +1 -1
  254. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  255. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  256. package/dist/resolution/frameworks/swift-objc.js +252 -0
  257. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  258. package/dist/resolution/frameworks/swift.d.ts.map +1 -1
  259. package/dist/resolution/frameworks/swift.js +30 -6
  260. package/dist/resolution/frameworks/swift.js.map +1 -1
  261. package/dist/resolution/go-module.d.ts +26 -0
  262. package/dist/resolution/go-module.d.ts.map +1 -0
  263. package/dist/resolution/go-module.js +78 -0
  264. package/dist/resolution/go-module.js.map +1 -0
  265. package/dist/resolution/import-resolver.d.ts +28 -0
  266. package/dist/resolution/import-resolver.d.ts.map +1 -1
  267. package/dist/resolution/import-resolver.js +617 -5
  268. package/dist/resolution/import-resolver.js.map +1 -1
  269. package/dist/resolution/index.d.ts +11 -0
  270. package/dist/resolution/index.d.ts.map +1 -1
  271. package/dist/resolution/index.js +196 -10
  272. package/dist/resolution/index.js.map +1 -1
  273. package/dist/resolution/lru-cache.d.ts +24 -0
  274. package/dist/resolution/lru-cache.d.ts.map +1 -0
  275. package/dist/resolution/lru-cache.js +62 -0
  276. package/dist/resolution/lru-cache.js.map +1 -0
  277. package/dist/resolution/name-matcher.d.ts.map +1 -1
  278. package/dist/resolution/name-matcher.js +212 -0
  279. package/dist/resolution/name-matcher.js.map +1 -1
  280. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  281. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  282. package/dist/resolution/swift-objc-bridge.js +256 -0
  283. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  284. package/dist/resolution/types.d.ts +44 -0
  285. package/dist/resolution/types.d.ts.map +1 -1
  286. package/dist/resolution/workspace-packages.d.ts +48 -0
  287. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  288. package/dist/resolution/workspace-packages.js +208 -0
  289. package/dist/resolution/workspace-packages.js.map +1 -0
  290. package/dist/search/query-utils.d.ts +18 -0
  291. package/dist/search/query-utils.d.ts.map +1 -1
  292. package/dist/search/query-utils.js +30 -0
  293. package/dist/search/query-utils.js.map +1 -1
  294. package/dist/sync/git-hooks.d.ts.map +1 -1
  295. package/dist/sync/git-hooks.js +2 -0
  296. package/dist/sync/git-hooks.js.map +1 -1
  297. package/dist/sync/index.d.ts +3 -1
  298. package/dist/sync/index.d.ts.map +1 -1
  299. package/dist/sync/index.js +8 -1
  300. package/dist/sync/index.js.map +1 -1
  301. package/dist/sync/watcher.d.ts +214 -12
  302. package/dist/sync/watcher.d.ts.map +1 -1
  303. package/dist/sync/watcher.js +467 -55
  304. package/dist/sync/watcher.js.map +1 -1
  305. package/dist/sync/worktree.d.ts +54 -0
  306. package/dist/sync/worktree.d.ts.map +1 -0
  307. package/dist/sync/worktree.js +137 -0
  308. package/dist/sync/worktree.js.map +1 -0
  309. package/dist/types.d.ts +9 -1
  310. package/dist/types.d.ts.map +1 -1
  311. package/dist/types.js +14 -0
  312. package/dist/types.js.map +1 -1
  313. package/dist/utils.js +1 -1
  314. package/package.json +2 -2
  315. package/scripts/add-lang/bench.sh +60 -0
  316. package/scripts/add-lang/check-grammar.mjs +75 -0
  317. package/scripts/add-lang/dump-ast.mjs +103 -0
  318. package/scripts/add-lang/verify-extraction.mjs +70 -0
  319. package/scripts/agent-eval/arms-F.sh +21 -0
  320. package/scripts/agent-eval/arms-matrix.sh +37 -0
  321. package/scripts/agent-eval/bench-readme.sh +28 -0
  322. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  323. package/scripts/agent-eval/block-read-hook.sh +19 -0
  324. package/scripts/agent-eval/hook-settings.json +15 -0
  325. package/scripts/agent-eval/itrun.sh +24 -11
  326. package/scripts/agent-eval/parse-arms.mjs +116 -0
  327. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  328. package/scripts/agent-eval/probe-context.mjs +21 -0
  329. package/scripts/agent-eval/probe-explore.mjs +40 -0
  330. package/scripts/agent-eval/probe-node.mjs +20 -0
  331. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  332. package/scripts/agent-eval/probe-trace.mjs +20 -0
  333. package/scripts/agent-eval/run-arms.sh +56 -0
  334. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  335. package/scripts/build-bundle.sh +118 -0
  336. package/scripts/npm-sdk.js +75 -0
  337. package/scripts/npm-shim.js +246 -0
  338. package/scripts/pack-npm.sh +119 -0
  339. package/scripts/prepare-release.mjs +270 -0
  340. package/scripts/patch-tree-sitter-dart.js +0 -112
  341. package/scripts/release.sh +0 -68
@@ -0,0 +1,510 @@
1
+ "use strict";
2
+ /**
3
+ * MCP proxy mode — issue #411.
4
+ *
5
+ * The proxy is a near-transparent stdio↔socket pipe. Once it has verified
6
+ * the daemon's hello line (same major.minor.patch as ours), it does no
7
+ * protocol parsing of its own: every byte the MCP host writes to the proxy's
8
+ * stdin goes straight to the daemon socket, and every byte the daemon emits
9
+ * goes straight to the host's stdout. Server-initiated JSON-RPC requests
10
+ * (e.g. `roots/list`) flow through the same pipe transparently.
11
+ *
12
+ * Lifecycle expectations:
13
+ * - The proxy exits when *either* stream closes (host stdin closed →
14
+ * daemon socket end, or daemon-side socket close → host stdout end).
15
+ * - Closing the socket on the proxy side is what tells the daemon to
16
+ * decrement its connected-clients refcount.
17
+ * - On a parent-process death we can't detect via stdin close (e.g. SIGKILL
18
+ * of the MCP host), the proxy's PPID watchdog catches it — same logic
19
+ * the direct-mode server uses; see issue #277.
20
+ */
21
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ var desc = Object.getOwnPropertyDescriptor(m, k);
24
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
+ desc = { enumerable: true, get: function() { return m[k]; } };
26
+ }
27
+ Object.defineProperty(o, k2, desc);
28
+ }) : (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ o[k2] = m[k];
31
+ }));
32
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
34
+ }) : function(o, v) {
35
+ o["default"] = v;
36
+ });
37
+ var __importStar = (this && this.__importStar) || (function () {
38
+ var ownKeys = function(o) {
39
+ ownKeys = Object.getOwnPropertyNames || function (o) {
40
+ var ar = [];
41
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
42
+ return ar;
43
+ };
44
+ return ownKeys(o);
45
+ };
46
+ return function (mod) {
47
+ if (mod && mod.__esModule) return mod;
48
+ var result = {};
49
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
50
+ __setModuleDefault(result, mod);
51
+ return result;
52
+ };
53
+ })();
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.runProxy = runProxy;
56
+ exports.connectWithHello = connectWithHello;
57
+ exports.runLocalHandshakeProxy = runLocalHandshakeProxy;
58
+ const fs = __importStar(require("fs"));
59
+ const net = __importStar(require("net"));
60
+ const wasm_runtime_flags_1 = require("../extraction/wasm-runtime-flags");
61
+ const daemon_1 = require("./daemon");
62
+ const version_1 = require("./version");
63
+ const session_1 = require("./session");
64
+ const server_instructions_1 = require("./server-instructions");
65
+ const tools_1 = require("./tools");
66
+ /** Default poll cadence for the PPID watchdog (same as the direct server). */
67
+ const DEFAULT_PPID_POLL_MS = 5000;
68
+ /**
69
+ * Attempt to connect to the daemon at `socketPath` and pipe stdio through it.
70
+ *
71
+ * Returns a promise that resolves when either:
72
+ * - the connection succeeded and one of stdin/socket has now closed
73
+ * (after which the process should exit), or
74
+ * - the connection failed early enough that the caller can still fall
75
+ * back to direct mode.
76
+ *
77
+ * The `expectedVersion` param defaults to the package's own version — daemon
78
+ * and proxy MUST match exactly. Mismatch resolves with
79
+ * `outcome: 'fallback-needed'` so the caller can transparently start its own
80
+ * server. (We accept the cost of two concurrent servers in this case as the
81
+ * price of never silently running a stale daemon against newer client code.)
82
+ */
83
+ async function runProxy(socketPath, expectedVersion = version_1.CodeGraphPackageVersion) {
84
+ // POSIX: refuse to connect to a stale socket file that points at no
85
+ // listening process. `fs.existsSync` is a cheap pre-check; a real
86
+ // ECONNREFUSED below catches the rare "exists but unbound" race.
87
+ if (process.platform !== 'win32' && !fs.existsSync(socketPath)) {
88
+ return { outcome: 'fallback-needed', reason: 'socket file missing' };
89
+ }
90
+ const socket = net.createConnection(socketPath);
91
+ socket.setEncoding('utf8');
92
+ const hello = await readHelloLine(socket).catch((err) => {
93
+ socket.destroy();
94
+ return new Error(String(err));
95
+ });
96
+ if (hello instanceof Error) {
97
+ return { outcome: 'fallback-needed', reason: hello.message };
98
+ }
99
+ if (hello.codegraph !== expectedVersion) {
100
+ process.stderr.write(`[CodeGraph MCP] Found a daemon on ${socketPath} but version (${hello.codegraph}) ` +
101
+ `differs from ours (${expectedVersion}); falling back to direct mode.\n`);
102
+ socket.destroy();
103
+ return { outcome: 'fallback-needed', reason: 'version mismatch' };
104
+ }
105
+ process.stderr.write(`[CodeGraph MCP] Attached to shared daemon on ${socketPath} (pid ${hello.pid}, v${hello.codegraph}).\n`);
106
+ startPpidWatchdog(socket);
107
+ await pipeUntilClose(socket);
108
+ // Host disconnected (or the daemon went away). The proxy's only job is the
109
+ // pipe; exit now so we don't linger — process.stdin's 'data' listener would
110
+ // otherwise keep the event loop alive and leave a zombie launcher behind.
111
+ process.exit(0);
112
+ }
113
+ /**
114
+ * Connect to a daemon at `socketPath` and verify its hello (exact version match).
115
+ * Returns the live socket (hello already consumed) or null if unreachable / stale
116
+ * / version-mismatched. Unlike {@link runProxy} it does NOT pipe — the caller
117
+ * owns the socket. Used by the local-handshake proxy's background connect.
118
+ */
119
+ async function connectWithHello(socketPath, expectedVersion = version_1.CodeGraphPackageVersion) {
120
+ if (process.platform !== 'win32' && !fs.existsSync(socketPath))
121
+ return null;
122
+ const socket = net.createConnection(socketPath);
123
+ socket.setEncoding('utf8');
124
+ const hello = await readHelloLine(socket).catch(() => null);
125
+ if (!hello) {
126
+ socket.destroy();
127
+ return null; // no daemon yet — caller should keep polling
128
+ }
129
+ if (hello.codegraph !== expectedVersion) {
130
+ // A daemon IS up but it's the wrong version — definitive, not a "not yet".
131
+ // Don't poll; the caller serves in-process so we never run stale-vs-new.
132
+ process.stderr.write(`[CodeGraph MCP] Found a daemon on ${socketPath} but version (${hello.codegraph}) ` +
133
+ `differs from ours (${expectedVersion}); serving this session in-process.\n`);
134
+ socket.destroy();
135
+ return 'version-mismatch';
136
+ }
137
+ process.stderr.write(`[CodeGraph MCP] Attached to shared daemon on ${socketPath} (pid ${hello.pid}, v${hello.codegraph}).\n`);
138
+ return socket;
139
+ }
140
+ /**
141
+ * Local-handshake proxy (the cold-start fix).
142
+ *
143
+ * Answers `initialize` + `tools/list` from STATIC constants the instant the
144
+ * client asks — tools register in ~process-startup time instead of waiting
145
+ * ~600ms for the daemon to spawn+bind, which is what produced the "No such tool
146
+ * available" race that made headless agents flail into grep/Read. Tool CALLS are
147
+ * forwarded to the shared daemon (connected in the background); the daemon's
148
+ * response to the forwarded `initialize` is suppressed (the client already got
149
+ * the local one). If the daemon never comes up (version mismatch / spawn fail),
150
+ * a lazily-created in-process engine serves the calls — so the handshake speedup
151
+ * never costs the old fall-back-to-direct robustness.
152
+ */
153
+ async function runLocalHandshakeProxy(deps) {
154
+ let daemonStatus = 'connecting';
155
+ let daemonSocket = null;
156
+ let clientInitId = undefined; // suppress the daemon's reply to the forwarded initialize
157
+ const pending = []; // client lines buffered until the daemon resolves
158
+ let engine = null;
159
+ let engineReady = null;
160
+ let shuttingDown = false;
161
+ const writeClient = (obj) => {
162
+ try {
163
+ process.stdout.write((typeof obj === 'string' ? obj : JSON.stringify(obj)) + '\n');
164
+ }
165
+ catch { /* host gone */ }
166
+ };
167
+ const shutdown = () => {
168
+ if (shuttingDown)
169
+ return;
170
+ shuttingDown = true;
171
+ try {
172
+ daemonSocket?.destroy();
173
+ }
174
+ catch { /* ignore */ }
175
+ try {
176
+ engine?.stop();
177
+ }
178
+ catch { /* ignore */ }
179
+ process.exit(0);
180
+ };
181
+ const ensureEngine = () => {
182
+ if (!engine)
183
+ engine = deps.makeEngine();
184
+ if (!engineReady)
185
+ engineReady = engine.ensureInitialized(deps.root).catch(() => { });
186
+ return engineReady;
187
+ };
188
+ // Daemon-unavailable fallback: serve a client message in-process.
189
+ const handleLocally = async (line) => {
190
+ let msg;
191
+ try {
192
+ msg = JSON.parse(line);
193
+ }
194
+ catch {
195
+ return;
196
+ }
197
+ const id = msg.id;
198
+ if (msg.method === 'tools/call' && id !== undefined) {
199
+ try {
200
+ await ensureEngine();
201
+ const params = (msg.params || {});
202
+ const result = await engine.getToolHandler().execute(params.name, params.arguments || {});
203
+ writeClient({ jsonrpc: '2.0', id, result });
204
+ }
205
+ catch (err) {
206
+ writeClient({ jsonrpc: '2.0', id, error: { code: -32603, message: err instanceof Error ? err.message : String(err) } });
207
+ }
208
+ }
209
+ else if (msg.method === 'ping' && id !== undefined) {
210
+ writeClient({ jsonrpc: '2.0', id, result: {} });
211
+ }
212
+ // initialize already answered locally; notifications (initialized) need no reply.
213
+ };
214
+ const routeToDaemon = (line) => {
215
+ if (daemonStatus === 'ready' && daemonSocket) {
216
+ try {
217
+ daemonSocket.write(line.endsWith('\n') ? line : line + '\n');
218
+ }
219
+ catch { /* close path */ }
220
+ }
221
+ else if (daemonStatus === 'failed') {
222
+ void handleLocally(line);
223
+ }
224
+ else {
225
+ pending.push(line);
226
+ }
227
+ };
228
+ // ---- client (stdin) ----
229
+ let stdinBuf = '';
230
+ process.stdin.setEncoding('utf8');
231
+ process.stdin.on('data', (chunk) => {
232
+ stdinBuf += chunk;
233
+ let idx;
234
+ while ((idx = stdinBuf.indexOf('\n')) !== -1) {
235
+ const line = stdinBuf.slice(0, idx).trim();
236
+ stdinBuf = stdinBuf.slice(idx + 1);
237
+ if (!line)
238
+ continue;
239
+ let msg;
240
+ try {
241
+ msg = JSON.parse(line);
242
+ }
243
+ catch {
244
+ routeToDaemon(line);
245
+ continue;
246
+ }
247
+ if (msg.method === 'initialize') {
248
+ clientInitId = msg.id;
249
+ writeClient({ jsonrpc: '2.0', id: msg.id, result: { protocolVersion: session_1.PROTOCOL_VERSION, capabilities: { tools: {} }, serverInfo: session_1.SERVER_INFO, instructions: server_instructions_1.SERVER_INSTRUCTIONS } });
250
+ routeToDaemon(line); // prime the daemon so it resolves the project (its reply is suppressed below)
251
+ }
252
+ else if (msg.method === 'tools/list') {
253
+ writeClient({ jsonrpc: '2.0', id: msg.id, result: { tools: (0, tools_1.getStaticTools)() } });
254
+ }
255
+ else if (msg.method === 'resources/list') {
256
+ // No resources exposed — answer the probe locally so it never reaches
257
+ // the daemon as an unhandled method and logs `-32601`. (#621)
258
+ writeClient({ jsonrpc: '2.0', id: msg.id, result: { resources: [] } });
259
+ }
260
+ else if (msg.method === 'resources/templates/list') {
261
+ writeClient({ jsonrpc: '2.0', id: msg.id, result: { resourceTemplates: [] } });
262
+ }
263
+ else if (msg.method === 'prompts/list') {
264
+ writeClient({ jsonrpc: '2.0', id: msg.id, result: { prompts: [] } });
265
+ }
266
+ else {
267
+ routeToDaemon(line);
268
+ }
269
+ }
270
+ });
271
+ process.stdin.on('end', shutdown);
272
+ process.stdin.on('close', shutdown);
273
+ startPpidWatchdogNoSocket(shutdown);
274
+ // ---- daemon connection (background) ----
275
+ let socket = null;
276
+ try {
277
+ socket = await deps.getDaemonSocket();
278
+ }
279
+ catch {
280
+ socket = null;
281
+ }
282
+ if (socket && !shuttingDown) {
283
+ daemonSocket = socket;
284
+ daemonStatus = 'ready';
285
+ let sockBuf = '';
286
+ socket.setEncoding('utf8');
287
+ socket.on('data', (chunk) => {
288
+ sockBuf += chunk;
289
+ let idx;
290
+ while ((idx = sockBuf.indexOf('\n')) !== -1) {
291
+ const line = sockBuf.slice(0, idx);
292
+ sockBuf = sockBuf.slice(idx + 1);
293
+ if (!line.trim())
294
+ continue;
295
+ if (clientInitId !== undefined) {
296
+ try {
297
+ const m = JSON.parse(line);
298
+ if (m.id === clientInitId && ('result' in m || 'error' in m))
299
+ continue;
300
+ }
301
+ catch { /* relay */ }
302
+ }
303
+ writeClient(line);
304
+ }
305
+ });
306
+ socket.on('close', shutdown);
307
+ socket.on('error', shutdown);
308
+ for (const line of pending) {
309
+ try {
310
+ socket.write(line + '\n');
311
+ }
312
+ catch { /* ignore */ }
313
+ }
314
+ pending.length = 0;
315
+ }
316
+ else if (!shuttingDown) {
317
+ daemonStatus = 'failed';
318
+ process.stderr.write('[CodeGraph MCP] Shared daemon unavailable; serving this session in-process (degraded).\n');
319
+ const buffered = pending.splice(0);
320
+ for (const line of buffered)
321
+ await handleLocally(line);
322
+ }
323
+ await new Promise(() => { });
324
+ }
325
+ /** PPID watchdog for the local-handshake proxy — same #277 logic as
326
+ * {@link startPpidWatchdog} but with no socket to close (the caller's shutdown
327
+ * handles teardown). */
328
+ function startPpidWatchdogNoSocket(onDeath) {
329
+ const pollMs = parsePollMs(process.env.CODEGRAPH_PPID_POLL_MS);
330
+ if (pollMs <= 0)
331
+ return;
332
+ const originalPpid = process.ppid;
333
+ const hostPpid = parseHostPpid(process.env[wasm_runtime_flags_1.HOST_PPID_ENV]);
334
+ const timer = setInterval(() => {
335
+ if (process.ppid !== originalPpid || (hostPpid !== null && !isProcessAliveLocal(hostPpid))) {
336
+ process.stderr.write('[CodeGraph MCP] Parent process exited; shutting down.\n');
337
+ onDeath();
338
+ }
339
+ }, pollMs);
340
+ timer.unref?.();
341
+ }
342
+ /**
343
+ * Read one CRLF/LF-terminated JSON line from the socket, parse it as the
344
+ * daemon hello, and return it. Bounded to {@link MAX_HELLO_LINE_BYTES} so a
345
+ * malicious or broken peer can't OOM us. Times out at 3s — a healthy daemon
346
+ * sends hello immediately on accept.
347
+ */
348
+ function readHelloLine(socket) {
349
+ return new Promise((resolve, reject) => {
350
+ let buffer = '';
351
+ const cleanup = () => {
352
+ socket.removeListener('data', onData);
353
+ socket.removeListener('error', onError);
354
+ socket.removeListener('close', onClose);
355
+ clearTimeout(timer);
356
+ };
357
+ const onData = (chunk) => {
358
+ buffer += typeof chunk === 'string' ? chunk : chunk.toString('utf8');
359
+ const idx = buffer.indexOf('\n');
360
+ if (idx === -1) {
361
+ if (buffer.length > daemon_1.MAX_HELLO_LINE_BYTES) {
362
+ cleanup();
363
+ reject(new Error('daemon hello line exceeded size limit'));
364
+ }
365
+ return;
366
+ }
367
+ const line = buffer.slice(0, idx);
368
+ // Re-emit anything past the newline so the pipe-stage sees it.
369
+ const tail = buffer.slice(idx + 1);
370
+ cleanup();
371
+ if (tail.length > 0) {
372
+ // Push back via unshift — Node's net.Socket supports it on readable streams.
373
+ socket.unshift(tail);
374
+ }
375
+ try {
376
+ const parsed = JSON.parse(line);
377
+ if (typeof parsed.codegraph !== 'string' || typeof parsed.pid !== 'number') {
378
+ reject(new Error('daemon hello missing required fields'));
379
+ return;
380
+ }
381
+ resolve(parsed);
382
+ }
383
+ catch (err) {
384
+ reject(new Error(`daemon hello not JSON: ${err instanceof Error ? err.message : String(err)}`));
385
+ }
386
+ };
387
+ const onError = (err) => { cleanup(); reject(err); };
388
+ const onClose = () => { cleanup(); reject(new Error('daemon closed connection before hello')); };
389
+ const timer = setTimeout(() => {
390
+ cleanup();
391
+ reject(new Error('timed out waiting for daemon hello'));
392
+ }, 3000);
393
+ timer.unref?.();
394
+ socket.on('data', onData);
395
+ socket.on('error', onError);
396
+ socket.on('close', onClose);
397
+ });
398
+ }
399
+ /**
400
+ * Pipe stdin → socket and socket → stdout. Resolves once either end closes
401
+ * so the process can exit. Note: we deliberately do NOT use
402
+ * `process.stdin.pipe(socket)` because pipe propagates 'end' onto the
403
+ * downstream, which would close the socket prematurely if stdin happens to
404
+ * end early — the MCP spec allows it to stay open across reconnects.
405
+ */
406
+ function pipeUntilClose(socket) {
407
+ return new Promise((resolve) => {
408
+ let resolved = false;
409
+ const done = () => { if (!resolved) {
410
+ resolved = true;
411
+ resolve();
412
+ } };
413
+ process.stdin.on('data', (chunk) => {
414
+ try {
415
+ socket.write(chunk);
416
+ }
417
+ catch { /* socket may have errored — close path catches it */ }
418
+ });
419
+ process.stdin.on('end', () => {
420
+ try {
421
+ socket.end();
422
+ }
423
+ catch { /* ignore */ }
424
+ done();
425
+ });
426
+ process.stdin.on('close', () => {
427
+ try {
428
+ socket.destroy();
429
+ }
430
+ catch { /* ignore */ }
431
+ done();
432
+ });
433
+ socket.on('data', (chunk) => {
434
+ try {
435
+ process.stdout.write(chunk);
436
+ }
437
+ catch { /* ignore */ }
438
+ });
439
+ socket.on('end', () => done());
440
+ socket.on('close', () => done());
441
+ socket.on('error', (err) => {
442
+ process.stderr.write(`[CodeGraph MCP] daemon socket error: ${err.message}\n`);
443
+ done();
444
+ });
445
+ });
446
+ }
447
+ /**
448
+ * PPID watchdog mirroring the one in `MCPServer.start` — kills the proxy if
449
+ * the MCP host (or its proxy of a host, see HOST_PPID_ENV) goes away without
450
+ * closing stdin. Issue #277 documents why we can't rely on stdin EOF on
451
+ * Linux: the parent may be SIGKILL'd and reparenting doesn't close pipes.
452
+ *
453
+ * The proxy's "kill" is just a socket close + process.exit — no SQLite or
454
+ * watchers to clean up, so this is cheap.
455
+ */
456
+ function startPpidWatchdog(socket) {
457
+ const pollMs = parsePollMs(process.env.CODEGRAPH_PPID_POLL_MS);
458
+ if (pollMs <= 0)
459
+ return;
460
+ const originalPpid = process.ppid;
461
+ const hostPpid = parseHostPpid(process.env[wasm_runtime_flags_1.HOST_PPID_ENV]);
462
+ const timer = setInterval(() => {
463
+ const current = process.ppid;
464
+ const ppidChanged = current !== originalPpid;
465
+ const hostGone = hostPpid !== null && !isProcessAliveLocal(hostPpid);
466
+ if (ppidChanged || hostGone) {
467
+ const reason = ppidChanged
468
+ ? `ppid ${originalPpid} -> ${current}`
469
+ : `host pid ${hostPpid} exited`;
470
+ process.stderr.write(`[CodeGraph MCP] Parent process exited (${reason}); shutting down.\n`);
471
+ try {
472
+ socket.destroy();
473
+ }
474
+ catch { /* ignore */ }
475
+ process.exit(0);
476
+ }
477
+ }, pollMs);
478
+ timer.unref?.();
479
+ }
480
+ function parsePollMs(raw) {
481
+ if (raw === undefined || raw === '')
482
+ return DEFAULT_PPID_POLL_MS;
483
+ const parsed = Number(raw);
484
+ if (!Number.isFinite(parsed))
485
+ return DEFAULT_PPID_POLL_MS;
486
+ if (parsed < 0)
487
+ return DEFAULT_PPID_POLL_MS;
488
+ return Math.floor(parsed);
489
+ }
490
+ function parseHostPpid(raw) {
491
+ if (raw === undefined || raw === '')
492
+ return null;
493
+ const parsed = Number(raw);
494
+ if (!Number.isInteger(parsed) || parsed <= 1)
495
+ return null;
496
+ return parsed;
497
+ }
498
+ function isProcessAliveLocal(pid) {
499
+ try {
500
+ process.kill(pid, 0);
501
+ return true;
502
+ }
503
+ catch (err) {
504
+ const e = err;
505
+ if (e.code === 'EPERM')
506
+ return true;
507
+ return false;
508
+ }
509
+ }
510
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/mcp/proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCH,4BAyCC;AAQD,4CA0BC;AA8BD,wDAuHC;AAvQD,uCAAyB;AACzB,yCAA2B;AAC3B,yEAAiE;AACjE,qCAA6D;AAC7D,uCAAoD;AACpD,uCAA0D;AAC1D,+DAA4D;AAC5D,mCAAyC;AAGzC,8EAA8E;AAC9E,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAalC;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,QAAQ,CAC5B,UAAkB,EAClB,kBAA0B,iCAAuB;IAEjD,oEAAoE;IACpE,kEAAkE;IAClE,iEAAiE;IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IACvE,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAE3B,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACtD,MAAM,CAA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AAO;YAAE,OAAO,IAAI,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -15,5 +15,5 @@
15
15
  * burn tokens. Reference only tools that exist on `main`; gate any
16
16
  * conditional tools behind feature checks if/when they ship.
17
17
  */
18
- 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\nin the workspace. Reads are sub-millisecond; the index lags writes by\nabout a second through the file watcher. Consult it BEFORE writing or\nediting code, not during.\n\n## Answer directly \u2014 don't delegate exploration\n\nFor \"how does X work\", architecture, trace, or where-is-X questions,\nanswer DIRECTLY using 2-3 codegraph calls: `codegraph_context` first,\nthen ONE `codegraph_explore` for the source of the symbols it surfaces.\nCodegraph IS the pre-built search index \u2014 so delegating the lookup to a\nseparate file-reading sub-task/agent, or running your own grep + read\nloop, repeats work codegraph already did and costs more for the same\nanswer. Reach for raw Read/Grep only to confirm a specific detail\ncodegraph didn't cover. A direct codegraph answer is typically a handful\nof calls; a grep/read exploration is dozens.\n\n## Tool selection by intent\n\n- **\"How does X work? / trace X end to end / explain the Y system / architecture?\"** \u2192 `codegraph_explore` (PRIMARY for understanding \u2014 seed it with the key symbol names, read its output, don't grep+Read your way there)\n- **\"What is the symbol named X? / where is X defined?\"** \u2192 `codegraph_search` (pinpoint lookups)\n- **\"What's the deal with this task / feature / area?\"** \u2192 `codegraph_context` (lighter composed view of search + node + callers + callees)\n- **\"What calls this?\"** \u2192 `codegraph_callers`\n- **\"What does this call?\"** \u2192 `codegraph_callees`\n- **\"What would changing this break?\"** \u2192 `codegraph_impact`\n- **\"Show me this symbol's source / signature / docstring.\"** \u2192 `codegraph_node`\n- **\"Show me several related symbols' source / survey an area.\"** \u2192 `codegraph_explore` (ONE capped call; prefer over many codegraph_node/Read)\n- **\"What's in directory X?\"** \u2192 `codegraph_files`\n- **\"Is the index ready / what's its size?\"** \u2192 `codegraph_status`\n\n## Common chains\n\n- **Understanding / onboarding**: feed `codegraph_explore` the key symbol/file names and read its output (line-numbered source from many files in one call). If the question names nothing concrete, do ONE quick `codegraph_search` / `codegraph_context` to surface the names, then explore with them. Fill remaining gaps with `codegraph_node` / Read \u2014 don't drop back to grep+Read for the whole topic.\n- **Refactor planning**: `codegraph_search` \u2192 `codegraph_callers` \u2192 `codegraph_impact`. The blast-radius answer comes from impact, not from walking callers manually.\n- **Debugging a regression**: `codegraph_callers` of the suspected symbol; widen with `codegraph_impact` if an unexpected call appears.\n\n## Anti-patterns\n\n- **Don't search-then-Read your way through an understanding question** \u2014 feed the names you find into `codegraph_explore` instead of Reading the files one by one; it does that whole loop in one call and returns line numbers you can cite directly.\n- **Don't grep first** when looking up a symbol by name \u2014 `codegraph_search` is faster and returns kind + location + signature.\n- **Don't reach for `codegraph_explore` on a pinpoint \"where is X defined\" lookup** \u2014 `codegraph_search` is one cheap call.\n- **Don't chain `codegraph_search` + `codegraph_node`** when you just want context \u2014 `codegraph_context` is one round-trip.\n- **Don't loop `codegraph_node` over many symbols** \u2014 one `codegraph_explore` call returns them all grouped by file, while each separate call re-reads the whole context and costs far more. Use `codegraph_node` for a single symbol.\n- **Don't query the index immediately after editing a file** \u2014 the watcher needs ~500ms to debounce + sync. Wait for the next turn.\n\n## Limitations\n\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 = "# Codegraph \u2014 code intelligence over an indexed knowledge graph\n\nCodegraph is a SQLite knowledge graph of every symbol, edge, and file\nin the workspace. Reads are sub-millisecond; the index lags writes by\nabout a second through the file watcher. Consult it BEFORE writing or\nediting code, not during.\n\n## Answer directly \u2014 don't delegate exploration\n\nFor \"how does X work\", architecture, trace, or where-is-X questions,\nanswer DIRECTLY \u2014 usually with ONE `codegraph_explore` call.\n`codegraph_explore` takes either a natural-language question or a bag of\nsymbol/file names and returns the verbatim source of the relevant symbols\ngrouped by file, so it is Read-equivalent and most often the ONLY\ncodegraph call you need. Codegraph IS the pre-built search index \u2014 so\ndelegating the lookup to a separate file-reading sub-task/agent, or\nrunning your own grep + read loop, repeats work codegraph already did and\ncosts more for the same answer. Reach for raw Read/Grep only to confirm a\nspecific detail codegraph didn't cover. A direct codegraph answer is\ntypically one to a few calls; a grep/read exploration is dozens.\n\n## Tool selection by intent\n\n- **Almost any question \u2014 \"how does X work\", architecture, a bug, \"what/where is X\", or surveying an area** \u2192 `codegraph_explore` (PRIMARY \u2014 call FIRST; ONE capped call returns the verbatim source of the relevant symbols 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 `codegraph_explore`, naming the symbols that span the flow (e.g. `mutateElement renderScene`) \u2014 it surfaces the call path among them, including dynamic-dispatch hops (callbacks, React re-render, JSX children) grep can't follow\n- **\"What is the symbol named X?\" (just its location)** \u2192 `codegraph_search`\n- **\"What calls this?\" / \"What does this call?\" / \"What would changing this break?\"** \u2192 `codegraph_callers` / `codegraph_callees` / `codegraph_impact`\n- **One specific symbol's full source (esp. a body `codegraph_explore` trimmed), or an OVERLOADED name** \u2192 `codegraph_node` (with `includeCode`): for an ambiguous name it returns EVERY matching definition's body in one call, so you never Read a file to find the right overload\n- **\"What's in directory X?\"** \u2192 `codegraph_files`\n- **\"Is the index ready / what's its size?\"** \u2192 `codegraph_status`\n\n## Common chains\n\n- **Flow / \"how does X reach Y\"**: ONE `codegraph_explore` with the symbol names spanning the flow \u2014 it surfaces the call path among them (riding dynamic-dispatch hops) AND returns their source. No need to reconstruct the path with `codegraph_search` + `codegraph_callers`.\n- **Onboarding / understanding any area**: ONE `codegraph_explore` is usually the whole answer. Only follow up \u2014 `codegraph_node` for a specific symbol \u2014 if something is still unclear.\n- **Refactor planning**: `codegraph_search` \u2192 `codegraph_callers` \u2192 `codegraph_impact`. The blast-radius answer comes from impact, not from walking callers manually.\n- **Debugging a regression**: `codegraph_callers` of the suspected symbol; widen with `codegraph_impact` if an unexpected call appears.\n\n## Anti-patterns\n\n- **Trust codegraph'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 first** when looking up a symbol by name \u2014 `codegraph_search` is faster and returns kind + location + signature.\n- **Don't chain `codegraph_search` + `codegraph_node`** to understand an area \u2014 ONE `codegraph_explore` returns the relevant symbols' source together in a single round-trip.\n- **Don't loop `codegraph_node` over many symbols** \u2014 one `codegraph_explore` call returns them all grouped by file, while each separate call re-reads the whole context and costs far more. Use `codegraph_node` for a single symbol.\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 codegraph. `codegraph_status` also lists pending files under \"Pending sync\".\n\n## Limitations\n\n- If a tool reports the project isn't initialized, `.codegraph/` doesn't exist yet \u2014 offer to run `codegraph init -i` to build the index.\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";
19
19
  //# 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;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,ymIAoD/B,CAAC"}
1
+ {"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,0yJAoD/B,CAAC"}