@colbymchenry/codegraph-darwin-arm64 0.9.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 (569) hide show
  1. package/bin/codegraph +3 -0
  2. package/lib/dist/bin/codegraph.d.ts +21 -0
  3. package/lib/dist/bin/codegraph.d.ts.map +1 -0
  4. package/lib/dist/bin/codegraph.js +1273 -0
  5. package/lib/dist/bin/codegraph.js.map +1 -0
  6. package/lib/dist/bin/node-version-check.d.ts +37 -0
  7. package/lib/dist/bin/node-version-check.d.ts.map +1 -0
  8. package/lib/dist/bin/node-version-check.js +79 -0
  9. package/lib/dist/bin/node-version-check.js.map +1 -0
  10. package/lib/dist/bin/uninstall.d.ts +14 -0
  11. package/lib/dist/bin/uninstall.d.ts.map +1 -0
  12. package/lib/dist/bin/uninstall.js +36 -0
  13. package/lib/dist/bin/uninstall.js.map +1 -0
  14. package/lib/dist/config.d.ts +51 -0
  15. package/lib/dist/config.d.ts.map +1 -0
  16. package/lib/dist/config.js +321 -0
  17. package/lib/dist/config.js.map +1 -0
  18. package/lib/dist/context/formatter.d.ts +30 -0
  19. package/lib/dist/context/formatter.d.ts.map +1 -0
  20. package/lib/dist/context/formatter.js +244 -0
  21. package/lib/dist/context/formatter.js.map +1 -0
  22. package/lib/dist/context/index.d.ts +97 -0
  23. package/lib/dist/context/index.d.ts.map +1 -0
  24. package/lib/dist/context/index.js +1050 -0
  25. package/lib/dist/context/index.js.map +1 -0
  26. package/lib/dist/db/index.d.ts +83 -0
  27. package/lib/dist/db/index.d.ts.map +1 -0
  28. package/lib/dist/db/index.js +219 -0
  29. package/lib/dist/db/index.js.map +1 -0
  30. package/lib/dist/db/migrations.d.ts +44 -0
  31. package/lib/dist/db/migrations.d.ts.map +1 -0
  32. package/lib/dist/db/migrations.js +131 -0
  33. package/lib/dist/db/migrations.js.map +1 -0
  34. package/lib/dist/db/queries.d.ts +253 -0
  35. package/lib/dist/db/queries.d.ts.map +1 -0
  36. package/lib/dist/db/queries.js +1207 -0
  37. package/lib/dist/db/queries.js.map +1 -0
  38. package/lib/dist/db/schema.sql +151 -0
  39. package/lib/dist/db/sqlite-adapter.d.ts +46 -0
  40. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -0
  41. package/lib/dist/db/sqlite-adapter.js +114 -0
  42. package/lib/dist/db/sqlite-adapter.js.map +1 -0
  43. package/lib/dist/directory.d.ts +57 -0
  44. package/lib/dist/directory.d.ts.map +1 -0
  45. package/lib/dist/directory.js +264 -0
  46. package/lib/dist/directory.js.map +1 -0
  47. package/lib/dist/errors.d.ts +136 -0
  48. package/lib/dist/errors.d.ts.map +1 -0
  49. package/lib/dist/errors.js +219 -0
  50. package/lib/dist/errors.js.map +1 -0
  51. package/lib/dist/extraction/dfm-extractor.d.ts +31 -0
  52. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -0
  53. package/lib/dist/extraction/dfm-extractor.js +151 -0
  54. package/lib/dist/extraction/dfm-extractor.js.map +1 -0
  55. package/lib/dist/extraction/grammars.d.ts +78 -0
  56. package/lib/dist/extraction/grammars.d.ts.map +1 -0
  57. package/lib/dist/extraction/grammars.js +332 -0
  58. package/lib/dist/extraction/grammars.js.map +1 -0
  59. package/lib/dist/extraction/index.d.ts +130 -0
  60. package/lib/dist/extraction/index.d.ts.map +1 -0
  61. package/lib/dist/extraction/index.js +1305 -0
  62. package/lib/dist/extraction/index.js.map +1 -0
  63. package/lib/dist/extraction/languages/c-cpp.d.ts +4 -0
  64. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  65. package/lib/dist/extraction/languages/c-cpp.js +126 -0
  66. package/lib/dist/extraction/languages/c-cpp.js.map +1 -0
  67. package/lib/dist/extraction/languages/csharp.d.ts +3 -0
  68. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -0
  69. package/lib/dist/extraction/languages/csharp.js +72 -0
  70. package/lib/dist/extraction/languages/csharp.js.map +1 -0
  71. package/lib/dist/extraction/languages/dart.d.ts +3 -0
  72. package/lib/dist/extraction/languages/dart.d.ts.map +1 -0
  73. package/lib/dist/extraction/languages/dart.js +192 -0
  74. package/lib/dist/extraction/languages/dart.js.map +1 -0
  75. package/lib/dist/extraction/languages/go.d.ts +3 -0
  76. package/lib/dist/extraction/languages/go.d.ts.map +1 -0
  77. package/lib/dist/extraction/languages/go.js +58 -0
  78. package/lib/dist/extraction/languages/go.js.map +1 -0
  79. package/lib/dist/extraction/languages/index.d.ts +10 -0
  80. package/lib/dist/extraction/languages/index.d.ts.map +1 -0
  81. package/lib/dist/extraction/languages/index.js +49 -0
  82. package/lib/dist/extraction/languages/index.js.map +1 -0
  83. package/lib/dist/extraction/languages/java.d.ts +3 -0
  84. package/lib/dist/extraction/languages/java.d.ts.map +1 -0
  85. package/lib/dist/extraction/languages/java.js +64 -0
  86. package/lib/dist/extraction/languages/java.js.map +1 -0
  87. package/lib/dist/extraction/languages/javascript.d.ts +3 -0
  88. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -0
  89. package/lib/dist/extraction/languages/javascript.js +90 -0
  90. package/lib/dist/extraction/languages/javascript.js.map +1 -0
  91. package/lib/dist/extraction/languages/kotlin.d.ts +3 -0
  92. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -0
  93. package/lib/dist/extraction/languages/kotlin.js +253 -0
  94. package/lib/dist/extraction/languages/kotlin.js.map +1 -0
  95. package/lib/dist/extraction/languages/lua.d.ts +3 -0
  96. package/lib/dist/extraction/languages/lua.d.ts.map +1 -0
  97. package/lib/dist/extraction/languages/lua.js +150 -0
  98. package/lib/dist/extraction/languages/lua.js.map +1 -0
  99. package/lib/dist/extraction/languages/luau.d.ts +3 -0
  100. package/lib/dist/extraction/languages/luau.d.ts.map +1 -0
  101. package/lib/dist/extraction/languages/luau.js +37 -0
  102. package/lib/dist/extraction/languages/luau.js.map +1 -0
  103. package/lib/dist/extraction/languages/pascal.d.ts +3 -0
  104. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -0
  105. package/lib/dist/extraction/languages/pascal.js +66 -0
  106. package/lib/dist/extraction/languages/pascal.js.map +1 -0
  107. package/lib/dist/extraction/languages/php.d.ts +3 -0
  108. package/lib/dist/extraction/languages/php.d.ts.map +1 -0
  109. package/lib/dist/extraction/languages/php.js +107 -0
  110. package/lib/dist/extraction/languages/php.js.map +1 -0
  111. package/lib/dist/extraction/languages/python.d.ts +3 -0
  112. package/lib/dist/extraction/languages/python.d.ts.map +1 -0
  113. package/lib/dist/extraction/languages/python.js +56 -0
  114. package/lib/dist/extraction/languages/python.js.map +1 -0
  115. package/lib/dist/extraction/languages/ruby.d.ts +3 -0
  116. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -0
  117. package/lib/dist/extraction/languages/ruby.js +114 -0
  118. package/lib/dist/extraction/languages/ruby.js.map +1 -0
  119. package/lib/dist/extraction/languages/rust.d.ts +3 -0
  120. package/lib/dist/extraction/languages/rust.d.ts.map +1 -0
  121. package/lib/dist/extraction/languages/rust.js +109 -0
  122. package/lib/dist/extraction/languages/rust.js.map +1 -0
  123. package/lib/dist/extraction/languages/scala.d.ts +3 -0
  124. package/lib/dist/extraction/languages/scala.d.ts.map +1 -0
  125. package/lib/dist/extraction/languages/scala.js +139 -0
  126. package/lib/dist/extraction/languages/scala.js.map +1 -0
  127. package/lib/dist/extraction/languages/swift.d.ts +3 -0
  128. package/lib/dist/extraction/languages/swift.d.ts.map +1 -0
  129. package/lib/dist/extraction/languages/swift.js +91 -0
  130. package/lib/dist/extraction/languages/swift.js.map +1 -0
  131. package/lib/dist/extraction/languages/typescript.d.ts +3 -0
  132. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -0
  133. package/lib/dist/extraction/languages/typescript.js +129 -0
  134. package/lib/dist/extraction/languages/typescript.js.map +1 -0
  135. package/lib/dist/extraction/liquid-extractor.d.ts +52 -0
  136. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -0
  137. package/lib/dist/extraction/liquid-extractor.js +313 -0
  138. package/lib/dist/extraction/liquid-extractor.js.map +1 -0
  139. package/lib/dist/extraction/parse-worker.d.ts +8 -0
  140. package/lib/dist/extraction/parse-worker.d.ts.map +1 -0
  141. package/lib/dist/extraction/parse-worker.js +94 -0
  142. package/lib/dist/extraction/parse-worker.js.map +1 -0
  143. package/lib/dist/extraction/svelte-extractor.d.ts +56 -0
  144. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -0
  145. package/lib/dist/extraction/svelte-extractor.js +272 -0
  146. package/lib/dist/extraction/svelte-extractor.js.map +1 -0
  147. package/lib/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  148. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  149. package/lib/dist/extraction/tree-sitter-helpers.js +103 -0
  150. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -0
  151. package/lib/dist/extraction/tree-sitter-types.d.ts +179 -0
  152. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  153. package/lib/dist/extraction/tree-sitter-types.js +10 -0
  154. package/lib/dist/extraction/tree-sitter-types.js.map +1 -0
  155. package/lib/dist/extraction/tree-sitter.d.ts +233 -0
  156. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -0
  157. package/lib/dist/extraction/tree-sitter.js +2425 -0
  158. package/lib/dist/extraction/tree-sitter.js.map +1 -0
  159. package/lib/dist/extraction/vue-extractor.d.ts +36 -0
  160. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -0
  161. package/lib/dist/extraction/vue-extractor.js +163 -0
  162. package/lib/dist/extraction/vue-extractor.js.map +1 -0
  163. package/lib/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  164. package/lib/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  165. package/lib/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  166. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  167. package/lib/dist/graph/index.d.ts +8 -0
  168. package/lib/dist/graph/index.d.ts.map +1 -0
  169. package/lib/dist/graph/index.js +13 -0
  170. package/lib/dist/graph/index.js.map +1 -0
  171. package/lib/dist/graph/queries.d.ts +106 -0
  172. package/lib/dist/graph/queries.d.ts.map +1 -0
  173. package/lib/dist/graph/queries.js +366 -0
  174. package/lib/dist/graph/queries.js.map +1 -0
  175. package/lib/dist/graph/traversal.d.ts +127 -0
  176. package/lib/dist/graph/traversal.d.ts.map +1 -0
  177. package/lib/dist/graph/traversal.js +493 -0
  178. package/lib/dist/graph/traversal.js.map +1 -0
  179. package/lib/dist/index.d.ts +453 -0
  180. package/lib/dist/index.d.ts.map +1 -0
  181. package/lib/dist/index.js +833 -0
  182. package/lib/dist/index.js.map +1 -0
  183. package/lib/dist/installer/claude-md-template.d.ts +14 -0
  184. package/lib/dist/installer/claude-md-template.d.ts.map +1 -0
  185. package/lib/dist/installer/claude-md-template.js +21 -0
  186. package/lib/dist/installer/claude-md-template.js.map +1 -0
  187. package/lib/dist/installer/config-writer.d.ts +29 -0
  188. package/lib/dist/installer/config-writer.d.ts.map +1 -0
  189. package/lib/dist/installer/config-writer.js +111 -0
  190. package/lib/dist/installer/config-writer.js.map +1 -0
  191. package/lib/dist/installer/index.d.ts +65 -0
  192. package/lib/dist/installer/index.d.ts.map +1 -0
  193. package/lib/dist/installer/index.js +406 -0
  194. package/lib/dist/installer/index.js.map +1 -0
  195. package/lib/dist/installer/instructions-template.d.ts +28 -0
  196. package/lib/dist/installer/instructions-template.d.ts.map +1 -0
  197. package/lib/dist/installer/instructions-template.js +64 -0
  198. package/lib/dist/installer/instructions-template.js.map +1 -0
  199. package/lib/dist/installer/targets/claude.d.ts +47 -0
  200. package/lib/dist/installer/targets/claude.d.ts.map +1 -0
  201. package/lib/dist/installer/targets/claude.js +401 -0
  202. package/lib/dist/installer/targets/claude.js.map +1 -0
  203. package/lib/dist/installer/targets/codex.d.ts +18 -0
  204. package/lib/dist/installer/targets/codex.d.ts.map +1 -0
  205. package/lib/dist/installer/targets/codex.js +185 -0
  206. package/lib/dist/installer/targets/codex.js.map +1 -0
  207. package/lib/dist/installer/targets/cursor.d.ts +35 -0
  208. package/lib/dist/installer/targets/cursor.d.ts.map +1 -0
  209. package/lib/dist/installer/targets/cursor.js +229 -0
  210. package/lib/dist/installer/targets/cursor.js.map +1 -0
  211. package/lib/dist/installer/targets/opencode.d.ts +30 -0
  212. package/lib/dist/installer/targets/opencode.d.ts.map +1 -0
  213. package/lib/dist/installer/targets/opencode.js +235 -0
  214. package/lib/dist/installer/targets/opencode.js.map +1 -0
  215. package/lib/dist/installer/targets/registry.d.ts +35 -0
  216. package/lib/dist/installer/targets/registry.d.ts.map +1 -0
  217. package/lib/dist/installer/targets/registry.js +83 -0
  218. package/lib/dist/installer/targets/registry.js.map +1 -0
  219. package/lib/dist/installer/targets/shared.d.ts +77 -0
  220. package/lib/dist/installer/targets/shared.d.ts.map +1 -0
  221. package/lib/dist/installer/targets/shared.js +246 -0
  222. package/lib/dist/installer/targets/shared.js.map +1 -0
  223. package/lib/dist/installer/targets/toml.d.ts +52 -0
  224. package/lib/dist/installer/targets/toml.d.ts.map +1 -0
  225. package/lib/dist/installer/targets/toml.js +147 -0
  226. package/lib/dist/installer/targets/toml.js.map +1 -0
  227. package/lib/dist/installer/targets/types.d.ts +116 -0
  228. package/lib/dist/installer/targets/types.d.ts.map +1 -0
  229. package/lib/dist/installer/targets/types.js +16 -0
  230. package/lib/dist/installer/targets/types.js.map +1 -0
  231. package/lib/dist/mcp/index.d.ts +94 -0
  232. package/lib/dist/mcp/index.d.ts.map +1 -0
  233. package/lib/dist/mcp/index.js +453 -0
  234. package/lib/dist/mcp/index.js.map +1 -0
  235. package/lib/dist/mcp/server-instructions.d.ts +19 -0
  236. package/lib/dist/mcp/server-instructions.d.ts.map +1 -0
  237. package/lib/dist/mcp/server-instructions.js +71 -0
  238. package/lib/dist/mcp/server-instructions.js.map +1 -0
  239. package/lib/dist/mcp/tools.d.ts +257 -0
  240. package/lib/dist/mcp/tools.d.ts.map +1 -0
  241. package/lib/dist/mcp/tools.js +1646 -0
  242. package/lib/dist/mcp/tools.js.map +1 -0
  243. package/lib/dist/mcp/transport.d.ts +106 -0
  244. package/lib/dist/mcp/transport.d.ts.map +1 -0
  245. package/lib/dist/mcp/transport.js +233 -0
  246. package/lib/dist/mcp/transport.js.map +1 -0
  247. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  248. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  249. package/lib/dist/resolution/frameworks/cargo-workspace.js +225 -0
  250. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  251. package/lib/dist/resolution/frameworks/csharp.d.ts +8 -0
  252. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  253. package/lib/dist/resolution/frameworks/csharp.js +213 -0
  254. package/lib/dist/resolution/frameworks/csharp.js.map +1 -0
  255. package/lib/dist/resolution/frameworks/express.d.ts +8 -0
  256. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -0
  257. package/lib/dist/resolution/frameworks/express.js +225 -0
  258. package/lib/dist/resolution/frameworks/express.js.map +1 -0
  259. package/lib/dist/resolution/frameworks/go.d.ts +8 -0
  260. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -0
  261. package/lib/dist/resolution/frameworks/go.js +158 -0
  262. package/lib/dist/resolution/frameworks/go.js.map +1 -0
  263. package/lib/dist/resolution/frameworks/index.d.ts +42 -0
  264. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -0
  265. package/lib/dist/resolution/frameworks/index.js +133 -0
  266. package/lib/dist/resolution/frameworks/index.js.map +1 -0
  267. package/lib/dist/resolution/frameworks/java.d.ts +8 -0
  268. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -0
  269. package/lib/dist/resolution/frameworks/java.js +177 -0
  270. package/lib/dist/resolution/frameworks/java.js.map +1 -0
  271. package/lib/dist/resolution/frameworks/laravel.d.ts +13 -0
  272. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  273. package/lib/dist/resolution/frameworks/laravel.js +248 -0
  274. package/lib/dist/resolution/frameworks/laravel.js.map +1 -0
  275. package/lib/dist/resolution/frameworks/nestjs.d.ts +26 -0
  276. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  277. package/lib/dist/resolution/frameworks/nestjs.js +374 -0
  278. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -0
  279. package/lib/dist/resolution/frameworks/python.d.ts +10 -0
  280. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -0
  281. package/lib/dist/resolution/frameworks/python.js +278 -0
  282. package/lib/dist/resolution/frameworks/python.js.map +1 -0
  283. package/lib/dist/resolution/frameworks/react.d.ts +8 -0
  284. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -0
  285. package/lib/dist/resolution/frameworks/react.js +272 -0
  286. package/lib/dist/resolution/frameworks/react.js.map +1 -0
  287. package/lib/dist/resolution/frameworks/ruby.d.ts +8 -0
  288. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  289. package/lib/dist/resolution/frameworks/ruby.js +198 -0
  290. package/lib/dist/resolution/frameworks/ruby.js.map +1 -0
  291. package/lib/dist/resolution/frameworks/rust.d.ts +8 -0
  292. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -0
  293. package/lib/dist/resolution/frameworks/rust.js +207 -0
  294. package/lib/dist/resolution/frameworks/rust.js.map +1 -0
  295. package/lib/dist/resolution/frameworks/svelte.d.ts +9 -0
  296. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  297. package/lib/dist/resolution/frameworks/svelte.js +249 -0
  298. package/lib/dist/resolution/frameworks/svelte.js.map +1 -0
  299. package/lib/dist/resolution/frameworks/swift.d.ts +10 -0
  300. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -0
  301. package/lib/dist/resolution/frameworks/swift.js +376 -0
  302. package/lib/dist/resolution/frameworks/swift.js.map +1 -0
  303. package/lib/dist/resolution/frameworks/vue.d.ts +9 -0
  304. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -0
  305. package/lib/dist/resolution/frameworks/vue.js +306 -0
  306. package/lib/dist/resolution/frameworks/vue.js.map +1 -0
  307. package/lib/dist/resolution/import-resolver.d.ts +40 -0
  308. package/lib/dist/resolution/import-resolver.d.ts.map +1 -0
  309. package/lib/dist/resolution/import-resolver.js +663 -0
  310. package/lib/dist/resolution/import-resolver.js.map +1 -0
  311. package/lib/dist/resolution/index.d.ts +106 -0
  312. package/lib/dist/resolution/index.d.ts.map +1 -0
  313. package/lib/dist/resolution/index.js +709 -0
  314. package/lib/dist/resolution/index.js.map +1 -0
  315. package/lib/dist/resolution/name-matcher.d.ts +32 -0
  316. package/lib/dist/resolution/name-matcher.d.ts.map +1 -0
  317. package/lib/dist/resolution/name-matcher.js +384 -0
  318. package/lib/dist/resolution/name-matcher.js.map +1 -0
  319. package/lib/dist/resolution/path-aliases.d.ts +68 -0
  320. package/lib/dist/resolution/path-aliases.d.ts.map +1 -0
  321. package/lib/dist/resolution/path-aliases.js +238 -0
  322. package/lib/dist/resolution/path-aliases.js.map +1 -0
  323. package/lib/dist/resolution/strip-comments.d.ts +27 -0
  324. package/lib/dist/resolution/strip-comments.d.ts.map +1 -0
  325. package/lib/dist/resolution/strip-comments.js +441 -0
  326. package/lib/dist/resolution/strip-comments.js.map +1 -0
  327. package/lib/dist/resolution/types.d.ts +172 -0
  328. package/lib/dist/resolution/types.d.ts.map +1 -0
  329. package/lib/dist/resolution/types.js +8 -0
  330. package/lib/dist/resolution/types.js.map +1 -0
  331. package/lib/dist/search/query-parser.d.ts +57 -0
  332. package/lib/dist/search/query-parser.d.ts.map +1 -0
  333. package/lib/dist/search/query-parser.js +177 -0
  334. package/lib/dist/search/query-parser.js.map +1 -0
  335. package/lib/dist/search/query-utils.d.ts +53 -0
  336. package/lib/dist/search/query-utils.d.ts.map +1 -0
  337. package/lib/dist/search/query-utils.js +350 -0
  338. package/lib/dist/search/query-utils.js.map +1 -0
  339. package/lib/dist/sync/git-hooks.d.ts +45 -0
  340. package/lib/dist/sync/git-hooks.d.ts.map +1 -0
  341. package/lib/dist/sync/git-hooks.js +223 -0
  342. package/lib/dist/sync/git-hooks.js.map +1 -0
  343. package/lib/dist/sync/index.d.ts +17 -0
  344. package/lib/dist/sync/index.d.ts.map +1 -0
  345. package/lib/dist/sync/index.js +28 -0
  346. package/lib/dist/sync/index.js.map +1 -0
  347. package/lib/dist/sync/watch-policy.d.ts +48 -0
  348. package/lib/dist/sync/watch-policy.d.ts.map +1 -0
  349. package/lib/dist/sync/watch-policy.js +124 -0
  350. package/lib/dist/sync/watch-policy.js.map +1 -0
  351. package/lib/dist/sync/watcher.d.ts +81 -0
  352. package/lib/dist/sync/watcher.d.ts.map +1 -0
  353. package/lib/dist/sync/watcher.js +194 -0
  354. package/lib/dist/sync/watcher.js.map +1 -0
  355. package/lib/dist/types.d.ts +423 -0
  356. package/lib/dist/types.d.ts.map +1 -0
  357. package/lib/dist/types.js +262 -0
  358. package/lib/dist/types.js.map +1 -0
  359. package/lib/dist/ui/glyphs.d.ts +42 -0
  360. package/lib/dist/ui/glyphs.d.ts.map +1 -0
  361. package/lib/dist/ui/glyphs.js +78 -0
  362. package/lib/dist/ui/glyphs.js.map +1 -0
  363. package/lib/dist/ui/shimmer-progress.d.ts +11 -0
  364. package/lib/dist/ui/shimmer-progress.d.ts.map +1 -0
  365. package/lib/dist/ui/shimmer-progress.js +90 -0
  366. package/lib/dist/ui/shimmer-progress.js.map +1 -0
  367. package/lib/dist/ui/shimmer-worker.d.ts +2 -0
  368. package/lib/dist/ui/shimmer-worker.d.ts.map +1 -0
  369. package/lib/dist/ui/shimmer-worker.js +118 -0
  370. package/lib/dist/ui/shimmer-worker.js.map +1 -0
  371. package/lib/dist/ui/types.d.ts +17 -0
  372. package/lib/dist/ui/types.d.ts.map +1 -0
  373. package/lib/dist/ui/types.js +3 -0
  374. package/lib/dist/ui/types.js.map +1 -0
  375. package/lib/dist/utils.d.ts +205 -0
  376. package/lib/dist/utils.d.ts.map +1 -0
  377. package/lib/dist/utils.js +549 -0
  378. package/lib/dist/utils.js.map +1 -0
  379. package/lib/node_modules/.package-lock.json +116 -0
  380. package/lib/node_modules/@clack/core/CHANGELOG.md +348 -0
  381. package/lib/node_modules/@clack/core/LICENSE +9 -0
  382. package/lib/node_modules/@clack/core/README.md +22 -0
  383. package/lib/node_modules/@clack/core/dist/index.d.mts +363 -0
  384. package/lib/node_modules/@clack/core/dist/index.mjs +17 -0
  385. package/lib/node_modules/@clack/core/dist/index.mjs.map +1 -0
  386. package/lib/node_modules/@clack/core/package.json +63 -0
  387. package/lib/node_modules/@clack/prompts/CHANGELOG.md +591 -0
  388. package/lib/node_modules/@clack/prompts/LICENSE +9 -0
  389. package/lib/node_modules/@clack/prompts/README.md +375 -0
  390. package/lib/node_modules/@clack/prompts/dist/index.d.mts +396 -0
  391. package/lib/node_modules/@clack/prompts/dist/index.mjs +144 -0
  392. package/lib/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
  393. package/lib/node_modules/@clack/prompts/package.json +68 -0
  394. package/lib/node_modules/commander/LICENSE +22 -0
  395. package/lib/node_modules/commander/Readme.md +1176 -0
  396. package/lib/node_modules/commander/esm.mjs +16 -0
  397. package/lib/node_modules/commander/index.js +24 -0
  398. package/lib/node_modules/commander/lib/argument.js +150 -0
  399. package/lib/node_modules/commander/lib/command.js +2777 -0
  400. package/lib/node_modules/commander/lib/error.js +39 -0
  401. package/lib/node_modules/commander/lib/help.js +747 -0
  402. package/lib/node_modules/commander/lib/option.js +380 -0
  403. package/lib/node_modules/commander/lib/suggestSimilar.js +101 -0
  404. package/lib/node_modules/commander/package-support.json +19 -0
  405. package/lib/node_modules/commander/package.json +82 -0
  406. package/lib/node_modules/commander/typings/esm.d.mts +3 -0
  407. package/lib/node_modules/commander/typings/index.d.ts +1113 -0
  408. package/lib/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  409. package/lib/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  410. package/lib/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  411. package/lib/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  412. package/lib/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  413. package/lib/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  414. package/lib/node_modules/fast-string-truncated-width/license +21 -0
  415. package/lib/node_modules/fast-string-truncated-width/package.json +35 -0
  416. package/lib/node_modules/fast-string-truncated-width/readme.md +59 -0
  417. package/lib/node_modules/fast-string-width/dist/index.d.ts +4 -0
  418. package/lib/node_modules/fast-string-width/dist/index.js +14 -0
  419. package/lib/node_modules/fast-string-width/license +21 -0
  420. package/lib/node_modules/fast-string-width/package.json +34 -0
  421. package/lib/node_modules/fast-string-width/readme.md +42 -0
  422. package/lib/node_modules/fast-wrap-ansi/LICENSE +23 -0
  423. package/lib/node_modules/fast-wrap-ansi/README.md +26 -0
  424. package/lib/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  425. package/lib/node_modules/fast-wrap-ansi/lib/main.js +219 -0
  426. package/lib/node_modules/fast-wrap-ansi/lib/main.js.map +1 -0
  427. package/lib/node_modules/fast-wrap-ansi/package.json +51 -0
  428. package/lib/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  429. package/lib/node_modules/jsonc-parser/LICENSE.md +21 -0
  430. package/lib/node_modules/jsonc-parser/README.md +364 -0
  431. package/lib/node_modules/jsonc-parser/SECURITY.md +41 -0
  432. package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  433. package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  434. package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  435. package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  436. package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  437. package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  438. package/lib/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  439. package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  440. package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  441. package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  442. package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  443. package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  444. package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  445. package/lib/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  446. package/lib/node_modules/jsonc-parser/package.json +37 -0
  447. package/lib/node_modules/picomatch/LICENSE +21 -0
  448. package/lib/node_modules/picomatch/README.md +738 -0
  449. package/lib/node_modules/picomatch/index.js +17 -0
  450. package/lib/node_modules/picomatch/lib/constants.js +180 -0
  451. package/lib/node_modules/picomatch/lib/parse.js +1085 -0
  452. package/lib/node_modules/picomatch/lib/picomatch.js +341 -0
  453. package/lib/node_modules/picomatch/lib/scan.js +391 -0
  454. package/lib/node_modules/picomatch/lib/utils.js +72 -0
  455. package/lib/node_modules/picomatch/package.json +83 -0
  456. package/lib/node_modules/picomatch/posix.js +3 -0
  457. package/lib/node_modules/sisteransi/license +21 -0
  458. package/lib/node_modules/sisteransi/package.json +34 -0
  459. package/lib/node_modules/sisteransi/readme.md +113 -0
  460. package/lib/node_modules/sisteransi/src/index.js +58 -0
  461. package/lib/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  462. package/lib/node_modules/tree-sitter-wasms/LICENSE +24 -0
  463. package/lib/node_modules/tree-sitter-wasms/README.md +23 -0
  464. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  465. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  466. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  467. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  468. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  469. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  470. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  471. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  472. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  473. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  474. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  475. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  476. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  477. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  478. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  479. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  480. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  481. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  482. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  483. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  484. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  485. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  486. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  487. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  488. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  489. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  490. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  491. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  492. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  493. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  494. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  495. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  496. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  497. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  498. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  499. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  500. package/lib/node_modules/tree-sitter-wasms/package.json +64 -0
  501. package/lib/node_modules/web-tree-sitter/LICENSE +21 -0
  502. package/lib/node_modules/web-tree-sitter/README.md +269 -0
  503. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs +4558 -0
  504. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +7 -0
  505. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js +4516 -0
  506. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js.map +7 -0
  507. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
  508. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +31 -0
  509. package/lib/node_modules/web-tree-sitter/lib/alloc.c +48 -0
  510. package/lib/node_modules/web-tree-sitter/lib/alloc.h +41 -0
  511. package/lib/node_modules/web-tree-sitter/lib/array.h +291 -0
  512. package/lib/node_modules/web-tree-sitter/lib/atomic.h +68 -0
  513. package/lib/node_modules/web-tree-sitter/lib/clock.h +146 -0
  514. package/lib/node_modules/web-tree-sitter/lib/error_costs.h +11 -0
  515. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.c +523 -0
  516. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.h +36 -0
  517. package/lib/node_modules/web-tree-sitter/lib/host.h +21 -0
  518. package/lib/node_modules/web-tree-sitter/lib/language.c +293 -0
  519. package/lib/node_modules/web-tree-sitter/lib/language.h +293 -0
  520. package/lib/node_modules/web-tree-sitter/lib/length.h +52 -0
  521. package/lib/node_modules/web-tree-sitter/lib/lexer.c +483 -0
  522. package/lib/node_modules/web-tree-sitter/lib/lexer.h +54 -0
  523. package/lib/node_modules/web-tree-sitter/lib/lib.c +12 -0
  524. package/lib/node_modules/web-tree-sitter/lib/node.c +875 -0
  525. package/lib/node_modules/web-tree-sitter/lib/parser.c +2297 -0
  526. package/lib/node_modules/web-tree-sitter/lib/parser.h +286 -0
  527. package/lib/node_modules/web-tree-sitter/lib/point.h +48 -0
  528. package/lib/node_modules/web-tree-sitter/lib/query.c +4347 -0
  529. package/lib/node_modules/web-tree-sitter/lib/reduce_action.h +34 -0
  530. package/lib/node_modules/web-tree-sitter/lib/reusable_node.h +95 -0
  531. package/lib/node_modules/web-tree-sitter/lib/stack.c +912 -0
  532. package/lib/node_modules/web-tree-sitter/lib/stack.h +133 -0
  533. package/lib/node_modules/web-tree-sitter/lib/subtree.c +1034 -0
  534. package/lib/node_modules/web-tree-sitter/lib/subtree.h +399 -0
  535. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.c +987 -0
  536. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
  537. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm +0 -0
  538. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
  539. package/lib/node_modules/web-tree-sitter/lib/tree.c +170 -0
  540. package/lib/node_modules/web-tree-sitter/lib/tree.h +31 -0
  541. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.c +716 -0
  542. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.h +48 -0
  543. package/lib/node_modules/web-tree-sitter/lib/ts_assert.h +11 -0
  544. package/lib/node_modules/web-tree-sitter/lib/unicode.h +75 -0
  545. package/lib/node_modules/web-tree-sitter/lib/wasm_store.c +1937 -0
  546. package/lib/node_modules/web-tree-sitter/lib/wasm_store.h +31 -0
  547. package/lib/node_modules/web-tree-sitter/package.json +98 -0
  548. package/lib/node_modules/web-tree-sitter/src/bindings.ts +26 -0
  549. package/lib/node_modules/web-tree-sitter/src/constants.ts +133 -0
  550. package/lib/node_modules/web-tree-sitter/src/index.ts +31 -0
  551. package/lib/node_modules/web-tree-sitter/src/language.ts +291 -0
  552. package/lib/node_modules/web-tree-sitter/src/lookahead_iterator.ts +75 -0
  553. package/lib/node_modules/web-tree-sitter/src/marshal.ts +176 -0
  554. package/lib/node_modules/web-tree-sitter/src/node.ts +646 -0
  555. package/lib/node_modules/web-tree-sitter/src/parser.ts +325 -0
  556. package/lib/node_modules/web-tree-sitter/src/query.ts +973 -0
  557. package/lib/node_modules/web-tree-sitter/src/tree.ts +145 -0
  558. package/lib/node_modules/web-tree-sitter/src/tree_cursor.ts +318 -0
  559. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs +4031 -0
  560. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs.map +7 -0
  561. package/lib/node_modules/web-tree-sitter/tree-sitter.js +3980 -0
  562. package/lib/node_modules/web-tree-sitter/tree-sitter.js.map +7 -0
  563. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  564. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm.map +30 -0
  565. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1030 -0
  566. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +56 -0
  567. package/lib/package.json +55 -0
  568. package/node +0 -0
  569. package/package.json +17 -0
@@ -0,0 +1,453 @@
1
+ "use strict";
2
+ /**
3
+ * CodeGraph MCP Server
4
+ *
5
+ * Model Context Protocol server that exposes CodeGraph functionality
6
+ * as tools for AI assistants like Claude.
7
+ *
8
+ * @module mcp
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { MCPServer } from 'codegraph';
13
+ *
14
+ * const server = new MCPServer('/path/to/project');
15
+ * await server.start();
16
+ * ```
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || (function () {
35
+ var ownKeys = function(o) {
36
+ ownKeys = Object.getOwnPropertyNames || function (o) {
37
+ var ar = [];
38
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
39
+ return ar;
40
+ };
41
+ return ownKeys(o);
42
+ };
43
+ return function (mod) {
44
+ if (mod && mod.__esModule) return mod;
45
+ var result = {};
46
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
47
+ __setModuleDefault(result, mod);
48
+ return result;
49
+ };
50
+ })();
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.ToolHandler = exports.tools = exports.StdioTransport = exports.MCPServer = void 0;
53
+ const path = __importStar(require("path"));
54
+ const index_1 = __importStar(require("../index"));
55
+ const sync_1 = require("../sync");
56
+ const transport_1 = require("./transport");
57
+ const tools_1 = require("./tools");
58
+ const server_instructions_1 = require("./server-instructions");
59
+ /**
60
+ * Convert a file:// URI to a filesystem path.
61
+ * Handles URL encoding and Windows drive letter paths.
62
+ */
63
+ function fileUriToPath(uri) {
64
+ try {
65
+ const url = new URL(uri);
66
+ let filePath = decodeURIComponent(url.pathname);
67
+ // On Windows, file:///C:/path produces pathname /C:/path — strip leading /
68
+ if (process.platform === 'win32' && /^\/[a-zA-Z]:/.test(filePath)) {
69
+ filePath = filePath.slice(1);
70
+ }
71
+ return path.resolve(filePath);
72
+ }
73
+ catch {
74
+ // Fallback for non-standard URIs
75
+ return uri.replace(/^file:\/\/\/?/, '');
76
+ }
77
+ }
78
+ /**
79
+ * MCP Server Info
80
+ */
81
+ const SERVER_INFO = {
82
+ name: 'codegraph',
83
+ version: '0.1.0',
84
+ };
85
+ /**
86
+ * MCP Protocol Version
87
+ */
88
+ const PROTOCOL_VERSION = '2024-11-05';
89
+ /**
90
+ * How long to wait for the client's `roots/list` response before giving up
91
+ * and falling back to the process cwd.
92
+ */
93
+ const ROOTS_LIST_TIMEOUT_MS = 5000;
94
+ /**
95
+ * Extract the first usable filesystem path from a `roots/list` result.
96
+ * Shape per MCP spec: `{ roots: [{ uri: "file:///path", name?: string }] }`.
97
+ * Returns null if the result is empty or malformed.
98
+ */
99
+ function firstRootPath(result) {
100
+ if (!result || typeof result !== 'object')
101
+ return null;
102
+ const roots = result.roots;
103
+ if (!Array.isArray(roots) || roots.length === 0)
104
+ return null;
105
+ const first = roots[0];
106
+ if (typeof first?.uri !== 'string')
107
+ return null;
108
+ return fileUriToPath(first.uri);
109
+ }
110
+ /**
111
+ * MCP Server for CodeGraph
112
+ *
113
+ * Implements the Model Context Protocol to expose CodeGraph
114
+ * functionality as tools that can be called by AI assistants.
115
+ */
116
+ class MCPServer {
117
+ transport;
118
+ cg = null;
119
+ toolHandler;
120
+ projectPath;
121
+ // In-flight background init kicked off from handleInitialize. Tracked so the
122
+ // sync retry path doesn't race against it (double-opening the SQLite file).
123
+ initPromise = null;
124
+ // Whether the client advertised the MCP `roots` capability during initialize.
125
+ // If so, and no explicit project path was given, we ask it for the workspace
126
+ // root via roots/list rather than guessing from the (often wrong) cwd.
127
+ clientSupportsRoots = false;
128
+ // Guards the one-shot deferred resolution (roots/list or cwd) so we don't
129
+ // re-issue roots/list on every tool call.
130
+ rootsAttempted = false;
131
+ constructor(projectPath) {
132
+ this.projectPath = projectPath || null;
133
+ this.transport = new transport_1.StdioTransport();
134
+ // Create ToolHandler eagerly — cross-project queries work even without a default project
135
+ this.toolHandler = new tools_1.ToolHandler(null);
136
+ }
137
+ /**
138
+ * Start the MCP server
139
+ *
140
+ * Note: CodeGraph initialization is deferred until the initialize request
141
+ * is received, which includes the rootUri from the client.
142
+ */
143
+ async start() {
144
+ // Start listening for messages immediately - don't check initialization yet
145
+ // We'll get the project path from the initialize request's rootUri
146
+ this.transport.start(this.handleMessage.bind(this));
147
+ // Keep the process running
148
+ process.on('SIGINT', () => this.stop());
149
+ process.on('SIGTERM', () => this.stop());
150
+ // When the parent process (Claude Code) exits, stdin closes.
151
+ // Detect this and shut down gracefully to prevent orphaned processes.
152
+ process.stdin.on('end', () => this.stop());
153
+ process.stdin.on('close', () => this.stop());
154
+ }
155
+ /**
156
+ * Try to initialize CodeGraph for the default project.
157
+ *
158
+ * Walks up parent directories to find the nearest .codegraph/ folder,
159
+ * similar to how git finds .git/ directories.
160
+ *
161
+ * If initialization fails, the error is recorded but the server continues
162
+ * to work — cross-project queries and retries on subsequent tool calls
163
+ * are still possible.
164
+ */
165
+ async tryInitializeDefault(projectPath) {
166
+ // Record where we searched so a later "not initialized" error can name it.
167
+ this.toolHandler.setDefaultProjectHint(projectPath);
168
+ // Walk up parent directories to find nearest .codegraph/
169
+ const resolvedRoot = (0, index_1.findNearestCodeGraphRoot)(projectPath);
170
+ if (!resolvedRoot) {
171
+ this.projectPath = projectPath;
172
+ return;
173
+ }
174
+ this.projectPath = resolvedRoot;
175
+ try {
176
+ this.cg = await index_1.default.open(resolvedRoot);
177
+ this.toolHandler.setDefaultCodeGraph(this.cg);
178
+ this.startWatching();
179
+ }
180
+ catch (err) {
181
+ // Log the error so transient failures are diagnosable (see issue #47)
182
+ const msg = err instanceof Error ? err.message : String(err);
183
+ process.stderr.write(`[CodeGraph MCP] Failed to open project at ${resolvedRoot}: ${msg}\n`);
184
+ }
185
+ }
186
+ /**
187
+ * Retry initialization of the default project if it previously failed.
188
+ * Called lazily on tool calls that need the default project.
189
+ * Re-walks parent directories each time so it picks up projects
190
+ * initialized after the MCP server started.
191
+ *
192
+ * Awaits any in-flight background init (kicked off by handleInitialize) so
193
+ * we never open the SQLite file twice concurrently.
194
+ */
195
+ async retryInitIfNeeded() {
196
+ // Wait for the background init started during handleInitialize, if any.
197
+ if (this.initPromise) {
198
+ try {
199
+ await this.initPromise;
200
+ }
201
+ catch { /* errored init falls through to retry */ }
202
+ }
203
+ // Already initialized successfully
204
+ if (this.toolHandler.hasDefaultCodeGraph())
205
+ return;
206
+ // No explicit path was given at initialize. Resolve it now, exactly once:
207
+ // ask the client via roots/list (if it advertised roots), else use cwd.
208
+ // Deferring to here lets a roots answer override the wrong cwd, and the
209
+ // one-shot guard means we never re-issue roots/list per tool call.
210
+ if (!this.projectPath && !this.rootsAttempted) {
211
+ this.rootsAttempted = true;
212
+ this.initPromise = (this.clientSupportsRoots
213
+ ? this.initFromRoots()
214
+ : this.tryInitializeDefault(process.cwd())).finally(() => { this.initPromise = null; });
215
+ try {
216
+ await this.initPromise;
217
+ }
218
+ catch { /* fall through to last-resort below */ }
219
+ if (this.toolHandler.hasDefaultCodeGraph())
220
+ return;
221
+ }
222
+ // Last resort: re-walk from the best candidate we have. Picks up projects
223
+ // initialized after the server started, and covers clients that sent no
224
+ // usable initialize signal at all.
225
+ const candidate = this.projectPath ?? process.cwd();
226
+ this.toolHandler.setDefaultProjectHint(candidate);
227
+ const resolvedRoot = (0, index_1.findNearestCodeGraphRoot)(candidate);
228
+ if (!resolvedRoot)
229
+ return;
230
+ try {
231
+ // Close any previously failed instance to avoid leaking resources
232
+ if (this.cg) {
233
+ try {
234
+ this.cg.close();
235
+ }
236
+ catch { /* ignore */ }
237
+ this.cg = null;
238
+ }
239
+ this.cg = index_1.default.openSync(resolvedRoot);
240
+ this.projectPath = resolvedRoot;
241
+ this.toolHandler.setDefaultCodeGraph(this.cg);
242
+ this.startWatching();
243
+ }
244
+ catch {
245
+ // Still failing — will retry on next tool call
246
+ }
247
+ }
248
+ /**
249
+ * Resolve the project root via the MCP `roots/list` request and initialize
250
+ * from the first root the client reports. Falls back to the process cwd if
251
+ * the client returns no usable root or doesn't answer in time. See issue #196.
252
+ */
253
+ async initFromRoots() {
254
+ let target = process.cwd();
255
+ try {
256
+ const result = await this.transport.request('roots/list', undefined, ROOTS_LIST_TIMEOUT_MS);
257
+ const rootPath = firstRootPath(result);
258
+ if (rootPath) {
259
+ target = rootPath;
260
+ }
261
+ else {
262
+ process.stderr.write('[CodeGraph MCP] Client returned no workspace roots; falling back to process cwd.\n');
263
+ }
264
+ }
265
+ catch (err) {
266
+ const msg = err instanceof Error ? err.message : String(err);
267
+ process.stderr.write(`[CodeGraph MCP] roots/list request failed (${msg}); falling back to process cwd.\n`);
268
+ }
269
+ await this.tryInitializeDefault(target);
270
+ }
271
+ /**
272
+ * Start file watching on the active CodeGraph instance.
273
+ * Logs sync activity to stderr for diagnostics.
274
+ */
275
+ startWatching() {
276
+ if (!this.cg)
277
+ return;
278
+ // When the watcher is intentionally disabled (e.g. WSL2 /mnt drives, or
279
+ // CODEGRAPH_NO_WATCH=1), say so explicitly and tell the user how to keep
280
+ // the graph fresh — otherwise the silent staleness is hard to diagnose.
281
+ const disabledReason = (0, sync_1.watchDisabledReason)(this.projectPath ?? process.cwd());
282
+ if (disabledReason) {
283
+ process.stderr.write(`[CodeGraph MCP] File watcher disabled — ${disabledReason}. ` +
284
+ `The graph will not auto-update; run \`codegraph sync\` (or install the git sync hooks via \`codegraph init\`) to refresh.\n`);
285
+ return;
286
+ }
287
+ const started = this.cg.watch({
288
+ onSyncComplete: (result) => {
289
+ if (result.filesChanged > 0) {
290
+ process.stderr.write(`[CodeGraph MCP] Auto-synced ${result.filesChanged} file(s) in ${result.durationMs}ms\n`);
291
+ }
292
+ },
293
+ onSyncError: (err) => {
294
+ process.stderr.write(`[CodeGraph MCP] Auto-sync error: ${err.message}\n`);
295
+ },
296
+ });
297
+ if (started) {
298
+ process.stderr.write('[CodeGraph MCP] File watcher active — graph will auto-sync on changes\n');
299
+ }
300
+ else {
301
+ // start() can also return false when recursive fs.watch isn't supported.
302
+ process.stderr.write('[CodeGraph MCP] File watcher unavailable on this platform — run `codegraph sync` to refresh the graph after changes.\n');
303
+ }
304
+ }
305
+ /**
306
+ * Stop the server
307
+ */
308
+ stop() {
309
+ // Close all cached cross-project connections first
310
+ this.toolHandler.closeAll();
311
+ // Close the main CodeGraph instance
312
+ if (this.cg) {
313
+ this.cg.close();
314
+ this.cg = null;
315
+ }
316
+ this.transport.stop();
317
+ process.exit(0);
318
+ }
319
+ /**
320
+ * Handle incoming JSON-RPC messages
321
+ */
322
+ async handleMessage(message) {
323
+ // Check if it's a request (has id) or notification (no id)
324
+ const isRequest = 'id' in message;
325
+ switch (message.method) {
326
+ case 'initialize':
327
+ if (isRequest) {
328
+ await this.handleInitialize(message);
329
+ }
330
+ break;
331
+ case 'initialized':
332
+ // Notification that client has finished initialization
333
+ // No action needed - the client is ready
334
+ break;
335
+ case 'tools/list':
336
+ if (isRequest) {
337
+ await this.handleToolsList(message);
338
+ }
339
+ break;
340
+ case 'tools/call':
341
+ if (isRequest) {
342
+ await this.handleToolsCall(message);
343
+ }
344
+ break;
345
+ case 'ping':
346
+ if (isRequest) {
347
+ this.transport.sendResult(message.id, {});
348
+ }
349
+ break;
350
+ default:
351
+ if (isRequest) {
352
+ this.transport.sendError(message.id, transport_1.ErrorCodes.MethodNotFound, `Method not found: ${message.method}`);
353
+ }
354
+ }
355
+ }
356
+ /**
357
+ * Handle initialize request
358
+ */
359
+ async handleInitialize(request) {
360
+ const params = request.params;
361
+ // Does the client support the MCP `roots` protocol? If so, and we have no
362
+ // explicit path, we ask it for the workspace root after the handshake
363
+ // instead of falling back to the (frequently wrong) cwd. See issue #196.
364
+ this.clientSupportsRoots = !!params?.capabilities?.roots;
365
+ // Explicit project signal, strongest first: a client-provided rootUri /
366
+ // workspaceFolders (LSP-style, non-standard but some clients send it), else
367
+ // the --path the server was launched with. cwd is NOT used here — we defer
368
+ // it so a roots/list answer can win over it.
369
+ let explicitPath = null;
370
+ if (params?.rootUri) {
371
+ explicitPath = fileUriToPath(params.rootUri);
372
+ }
373
+ else if (params?.workspaceFolders?.[0]?.uri) {
374
+ explicitPath = fileUriToPath(params.workspaceFolders[0].uri);
375
+ }
376
+ else if (this.projectPath) {
377
+ explicitPath = this.projectPath;
378
+ }
379
+ // Respond to the handshake BEFORE doing any heavy initialization. Loading
380
+ // the SQLite DB and the tree-sitter WASM runtime can take many seconds on
381
+ // slow filesystems (Docker Desktop VirtioFS on macOS, WSL2). Clients like
382
+ // Claude Code time out the handshake at ~30s, which manifested as
383
+ // "MCP tools never appear" — the child was alive and had received the
384
+ // initialize but was still awaiting initGrammars(). See issue #172.
385
+ //
386
+ // We accept the client's protocol version but respond with our supported
387
+ // version. The `instructions` field is surfaced by MCP clients in the
388
+ // agent's system prompt automatically — it's the right place for the
389
+ // universal tool-selection playbook, ahead of individual tool descriptions.
390
+ this.transport.sendResult(request.id, {
391
+ protocolVersion: PROTOCOL_VERSION,
392
+ capabilities: {
393
+ tools: {},
394
+ },
395
+ serverInfo: SERVER_INFO,
396
+ instructions: server_instructions_1.SERVER_INSTRUCTIONS,
397
+ });
398
+ // If we know the project dir, kick off init in the background now. Tool
399
+ // calls that arrive before it finishes fall through to `retryInitIfNeeded`,
400
+ // which waits for this promise rather than racing it with a second open.
401
+ //
402
+ // If we DON'T know it (no rootUri, no --path), defer: the first tool call
403
+ // resolves it via roots/list (when the client supports roots) or cwd. This
404
+ // is the fix for issue #196 — clients that launch the server outside the
405
+ // project and don't pass a rootUri previously got a misleading "not
406
+ // initialized" error on every call.
407
+ if (explicitPath) {
408
+ this.initPromise = this.tryInitializeDefault(explicitPath).finally(() => {
409
+ this.initPromise = null;
410
+ });
411
+ }
412
+ }
413
+ /**
414
+ * Handle tools/list request
415
+ */
416
+ async handleToolsList(request) {
417
+ await this.retryInitIfNeeded();
418
+ this.transport.sendResult(request.id, {
419
+ tools: this.toolHandler.getTools(),
420
+ });
421
+ }
422
+ /**
423
+ * Handle tools/call request
424
+ */
425
+ async handleToolsCall(request) {
426
+ const params = request.params;
427
+ if (!params || !params.name) {
428
+ this.transport.sendError(request.id, transport_1.ErrorCodes.InvalidParams, 'Missing tool name');
429
+ return;
430
+ }
431
+ const toolName = params.name;
432
+ const toolArgs = params.arguments || {};
433
+ // Validate tool exists
434
+ const tool = tools_1.tools.find(t => t.name === toolName);
435
+ if (!tool) {
436
+ this.transport.sendError(request.id, transport_1.ErrorCodes.InvalidParams, `Unknown tool: ${toolName}`);
437
+ return;
438
+ }
439
+ // If the default project isn't initialized yet, retry in case it was
440
+ // initialized after the MCP server started (e.g. user ran codegraph init)
441
+ await this.retryInitIfNeeded();
442
+ const result = await this.toolHandler.execute(toolName, toolArgs);
443
+ this.transport.sendResult(request.id, result);
444
+ }
445
+ }
446
+ exports.MCPServer = MCPServer;
447
+ // Export for use in CLI
448
+ var transport_2 = require("./transport");
449
+ Object.defineProperty(exports, "StdioTransport", { enumerable: true, get: function () { return transport_2.StdioTransport; } });
450
+ var tools_2 = require("./tools");
451
+ Object.defineProperty(exports, "tools", { enumerable: true, get: function () { return tools_2.tools; } });
452
+ Object.defineProperty(exports, "ToolHandler", { enumerable: true, get: function () { return tools_2.ToolHandler; } });
453
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,kDAA+D;AAC/D,kCAA8C;AAC9C,2CAA8F;AAC9F,mCAA6C;AAC7C,+DAA4D;AAE5D;;;GAGG;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* MCP clients (Claude Code, Cursor, opencode, LangChain, OpenAI Agent
5
+ * SDK, …) surface this text in the agent's system prompt automatically,
6
+ * giving the agent a high-level playbook for the codegraph toolset
7
+ * before it sees individual tool descriptions.
8
+ *
9
+ * Goals when editing this:
10
+ * - Tool selection by intent (which tool for which question)
11
+ * - Common chains (refactor planning = X then Y)
12
+ * - Anti-patterns (don't grep when codegraph_search is faster)
13
+ *
14
+ * Keep it tight. The agent reads this every session — long instructions
15
+ * burn tokens. Reference only tools that exist on `main`; gate any
16
+ * conditional tools behind feature checks if/when they ship.
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- **\"What is the symbol named X?\"** \u2192 `codegraph_search`\n- **\"What's the deal with this task / feature / area?\"** \u2192 `codegraph_context` (PRIMARY \u2014 composes search + node + callers + callees in one call)\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- **Onboarding**: `codegraph_context` first. If still unclear, `codegraph_explore` for breadth, then `codegraph_node` on specific symbols.\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 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`** 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";
19
+ //# sourceMappingURL=server-instructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,wtGAiD/B,CAAC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SERVER_INSTRUCTIONS = void 0;
4
+ /**
5
+ * Server-level instructions emitted in the MCP `initialize` response.
6
+ *
7
+ * MCP clients (Claude Code, Cursor, opencode, LangChain, OpenAI Agent
8
+ * SDK, …) surface this text in the agent's system prompt automatically,
9
+ * giving the agent a high-level playbook for the codegraph toolset
10
+ * before it sees individual tool descriptions.
11
+ *
12
+ * Goals when editing this:
13
+ * - Tool selection by intent (which tool for which question)
14
+ * - Common chains (refactor planning = X then Y)
15
+ * - Anti-patterns (don't grep when codegraph_search is faster)
16
+ *
17
+ * Keep it tight. The agent reads this every session — long instructions
18
+ * burn tokens. Reference only tools that exist on `main`; gate any
19
+ * conditional tools behind feature checks if/when they ship.
20
+ */
21
+ exports.SERVER_INSTRUCTIONS = `# Codegraph — code intelligence over an indexed knowledge graph
22
+
23
+ Codegraph is a SQLite knowledge graph of every symbol, edge, and file
24
+ in the workspace. Reads are sub-millisecond; the index lags writes by
25
+ about a second through the file watcher. Consult it BEFORE writing or
26
+ editing code, not during.
27
+
28
+ ## Answer directly — don't delegate exploration
29
+
30
+ For "how does X work", architecture, trace, or where-is-X questions,
31
+ answer DIRECTLY using 2-3 codegraph calls: \`codegraph_context\` first,
32
+ then ONE \`codegraph_explore\` for the source of the symbols it surfaces.
33
+ Codegraph IS the pre-built search index — so delegating the lookup to a
34
+ separate file-reading sub-task/agent, or running your own grep + read
35
+ loop, repeats work codegraph already did and costs more for the same
36
+ answer. Reach for raw Read/Grep only to confirm a specific detail
37
+ codegraph didn't cover. A direct codegraph answer is typically a handful
38
+ of calls; a grep/read exploration is dozens.
39
+
40
+ ## Tool selection by intent
41
+
42
+ - **"What is the symbol named X?"** → \`codegraph_search\`
43
+ - **"What's the deal with this task / feature / area?"** → \`codegraph_context\` (PRIMARY — composes search + node + callers + callees in one call)
44
+ - **"What calls this?"** → \`codegraph_callers\`
45
+ - **"What does this call?"** → \`codegraph_callees\`
46
+ - **"What would changing this break?"** → \`codegraph_impact\`
47
+ - **"Show me this symbol's source / signature / docstring."** → \`codegraph_node\`
48
+ - **"Show me several related symbols' source / survey an area."** → \`codegraph_explore\` (ONE capped call; prefer over many codegraph_node/Read)
49
+ - **"What's in directory X?"** → \`codegraph_files\`
50
+ - **"Is the index ready / what's its size?"** → \`codegraph_status\`
51
+
52
+ ## Common chains
53
+
54
+ - **Onboarding**: \`codegraph_context\` first. If still unclear, \`codegraph_explore\` for breadth, then \`codegraph_node\` on specific symbols.
55
+ - **Refactor planning**: \`codegraph_search\` → \`codegraph_callers\` → \`codegraph_impact\`. The blast-radius answer comes from impact, not from walking callers manually.
56
+ - **Debugging a regression**: \`codegraph_callers\` of the suspected symbol; widen with \`codegraph_impact\` if an unexpected call appears.
57
+
58
+ ## Anti-patterns
59
+
60
+ - **Don't grep first** when looking up a symbol by name — \`codegraph_search\` is faster and returns kind + location + signature.
61
+ - **Don't chain \`codegraph_search\` + \`codegraph_node\`** when you just want context — \`codegraph_context\` is one round-trip.
62
+ - **Don't loop \`codegraph_node\` over many symbols** — 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.
63
+ - **Don't query the index immediately after editing a file** — the watcher needs ~500ms to debounce + sync. Wait for the next turn.
64
+
65
+ ## Limitations
66
+
67
+ - Index lags file writes by ~1 second.
68
+ - Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.
69
+ - 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
+ `;
71
+ //# sourceMappingURL=server-instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDlC,CAAC"}