@colbymchenry/codegraph-darwin-x64 0.9.8 → 1.0.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 (301) hide show
  1. package/lib/dist/bin/codegraph.d.ts +1 -0
  2. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  3. package/lib/dist/bin/codegraph.js +247 -39
  4. package/lib/dist/bin/codegraph.js.map +1 -1
  5. package/lib/dist/context/index.d.ts +9 -0
  6. package/lib/dist/context/index.d.ts.map +1 -1
  7. package/lib/dist/context/index.js +102 -6
  8. package/lib/dist/context/index.js.map +1 -1
  9. package/lib/dist/context/markers.d.ts +19 -0
  10. package/lib/dist/context/markers.d.ts.map +1 -0
  11. package/lib/dist/context/markers.js +22 -0
  12. package/lib/dist/context/markers.js.map +1 -0
  13. package/lib/dist/db/index.d.ts.map +1 -1
  14. package/lib/dist/db/index.js +2 -1
  15. package/lib/dist/db/index.js.map +1 -1
  16. package/lib/dist/db/migrations.d.ts +1 -1
  17. package/lib/dist/db/migrations.d.ts.map +1 -1
  18. package/lib/dist/db/migrations.js +10 -1
  19. package/lib/dist/db/migrations.js.map +1 -1
  20. package/lib/dist/db/queries.d.ts +43 -0
  21. package/lib/dist/db/queries.d.ts.map +1 -1
  22. package/lib/dist/db/queries.js +103 -7
  23. package/lib/dist/db/queries.js.map +1 -1
  24. package/lib/dist/db/schema.sql +1 -0
  25. package/lib/dist/db/sqlite-adapter.d.ts +7 -0
  26. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  27. package/lib/dist/db/sqlite-adapter.js +3 -0
  28. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  29. package/lib/dist/directory.d.ts +34 -2
  30. package/lib/dist/directory.d.ts.map +1 -1
  31. package/lib/dist/directory.js +129 -35
  32. package/lib/dist/directory.js.map +1 -1
  33. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  34. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  35. package/lib/dist/extraction/astro-extractor.js +320 -0
  36. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  37. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  38. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  39. package/lib/dist/extraction/extraction-version.js +28 -0
  40. package/lib/dist/extraction/extraction-version.js.map +1 -0
  41. package/lib/dist/extraction/function-ref.d.ts +118 -0
  42. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  43. package/lib/dist/extraction/function-ref.js +727 -0
  44. package/lib/dist/extraction/function-ref.js.map +1 -0
  45. package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
  46. package/lib/dist/extraction/generated-detection.js +3 -0
  47. package/lib/dist/extraction/generated-detection.js.map +1 -1
  48. package/lib/dist/extraction/grammars.d.ts +7 -1
  49. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  50. package/lib/dist/extraction/grammars.js +52 -4
  51. package/lib/dist/extraction/grammars.js.map +1 -1
  52. package/lib/dist/extraction/index.d.ts +34 -0
  53. package/lib/dist/extraction/index.d.ts.map +1 -1
  54. package/lib/dist/extraction/index.js +346 -62
  55. package/lib/dist/extraction/index.js.map +1 -1
  56. package/lib/dist/extraction/languages/c-cpp.d.ts +8 -0
  57. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  58. package/lib/dist/extraction/languages/c-cpp.js +87 -28
  59. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  60. package/lib/dist/extraction/languages/csharp.d.ts +22 -0
  61. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
  62. package/lib/dist/extraction/languages/csharp.js +84 -2
  63. package/lib/dist/extraction/languages/csharp.js.map +1 -1
  64. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  65. package/lib/dist/extraction/languages/dart.js +161 -1
  66. package/lib/dist/extraction/languages/dart.js.map +1 -1
  67. package/lib/dist/extraction/languages/go.d.ts.map +1 -1
  68. package/lib/dist/extraction/languages/go.js +43 -2
  69. package/lib/dist/extraction/languages/go.js.map +1 -1
  70. package/lib/dist/extraction/languages/index.d.ts.map +1 -1
  71. package/lib/dist/extraction/languages/index.js +2 -0
  72. package/lib/dist/extraction/languages/index.js.map +1 -1
  73. package/lib/dist/extraction/languages/java.d.ts.map +1 -1
  74. package/lib/dist/extraction/languages/java.js +42 -1
  75. package/lib/dist/extraction/languages/java.js.map +1 -1
  76. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
  77. package/lib/dist/extraction/languages/javascript.js +16 -0
  78. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  79. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  80. package/lib/dist/extraction/languages/kotlin.js +69 -0
  81. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  82. package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
  83. package/lib/dist/extraction/languages/objc.js +42 -0
  84. package/lib/dist/extraction/languages/objc.js.map +1 -1
  85. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
  86. package/lib/dist/extraction/languages/pascal.js +11 -0
  87. package/lib/dist/extraction/languages/pascal.js.map +1 -1
  88. package/lib/dist/extraction/languages/php.d.ts.map +1 -1
  89. package/lib/dist/extraction/languages/php.js +90 -1
  90. package/lib/dist/extraction/languages/php.js.map +1 -1
  91. package/lib/dist/extraction/languages/r.d.ts +3 -0
  92. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  93. package/lib/dist/extraction/languages/r.js +314 -0
  94. package/lib/dist/extraction/languages/r.js.map +1 -0
  95. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
  96. package/lib/dist/extraction/languages/ruby.js +35 -0
  97. package/lib/dist/extraction/languages/ruby.js.map +1 -1
  98. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  99. package/lib/dist/extraction/languages/rust.js +35 -2
  100. package/lib/dist/extraction/languages/rust.js.map +1 -1
  101. package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
  102. package/lib/dist/extraction/languages/scala.js +61 -1
  103. package/lib/dist/extraction/languages/scala.js.map +1 -1
  104. package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
  105. package/lib/dist/extraction/languages/swift.js +61 -0
  106. package/lib/dist/extraction/languages/swift.js.map +1 -1
  107. package/lib/dist/extraction/languages/typescript.d.ts +13 -0
  108. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  109. package/lib/dist/extraction/languages/typescript.js +38 -0
  110. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  111. package/lib/dist/extraction/liquid-extractor.d.ts +7 -0
  112. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  113. package/lib/dist/extraction/liquid-extractor.js +53 -9
  114. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  115. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  116. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  117. package/lib/dist/extraction/razor-extractor.js +285 -0
  118. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  119. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
  120. package/lib/dist/extraction/svelte-extractor.js +6 -3
  121. package/lib/dist/extraction/svelte-extractor.js.map +1 -1
  122. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  123. package/lib/dist/extraction/tree-sitter-helpers.js +59 -10
  124. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  125. package/lib/dist/extraction/tree-sitter-types.d.ts +33 -0
  126. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  127. package/lib/dist/extraction/tree-sitter.d.ts +237 -0
  128. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  129. package/lib/dist/extraction/tree-sitter.js +1820 -68
  130. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  131. package/lib/dist/extraction/vue-extractor.d.ts +15 -0
  132. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
  133. package/lib/dist/extraction/vue-extractor.js +94 -3
  134. package/lib/dist/extraction/vue-extractor.js.map +1 -1
  135. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  136. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  137. package/lib/dist/graph/queries.d.ts.map +1 -1
  138. package/lib/dist/graph/queries.js +13 -40
  139. package/lib/dist/graph/queries.js.map +1 -1
  140. package/lib/dist/graph/traversal.d.ts.map +1 -1
  141. package/lib/dist/graph/traversal.js +16 -4
  142. package/lib/dist/graph/traversal.js.map +1 -1
  143. package/lib/dist/index.d.ts +41 -3
  144. package/lib/dist/index.d.ts.map +1 -1
  145. package/lib/dist/index.js +99 -9
  146. package/lib/dist/index.js.map +1 -1
  147. package/lib/dist/installer/index.d.ts.map +1 -1
  148. package/lib/dist/installer/index.js +52 -2
  149. package/lib/dist/installer/index.js.map +1 -1
  150. package/lib/dist/installer/instructions-template.d.ts +34 -11
  151. package/lib/dist/installer/instructions-template.d.ts.map +1 -1
  152. package/lib/dist/installer/instructions-template.js +44 -12
  153. package/lib/dist/installer/instructions-template.js.map +1 -1
  154. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  155. package/lib/dist/installer/targets/claude.js +6 -10
  156. package/lib/dist/installer/targets/claude.js.map +1 -1
  157. package/lib/dist/installer/targets/codex.js +4 -6
  158. package/lib/dist/installer/targets/codex.js.map +1 -1
  159. package/lib/dist/installer/targets/gemini.js +4 -6
  160. package/lib/dist/installer/targets/gemini.js.map +1 -1
  161. package/lib/dist/installer/targets/opencode.d.ts +9 -1
  162. package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
  163. package/lib/dist/installer/targets/opencode.js +91 -40
  164. package/lib/dist/installer/targets/opencode.js.map +1 -1
  165. package/lib/dist/installer/targets/shared.d.ts +14 -0
  166. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  167. package/lib/dist/installer/targets/shared.js +19 -2
  168. package/lib/dist/installer/targets/shared.js.map +1 -1
  169. package/lib/dist/mcp/daemon.d.ts +60 -1
  170. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  171. package/lib/dist/mcp/daemon.js +221 -8
  172. package/lib/dist/mcp/daemon.js.map +1 -1
  173. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  174. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  175. package/lib/dist/mcp/dynamic-boundaries.js +359 -0
  176. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  177. package/lib/dist/mcp/index.d.ts.map +1 -1
  178. package/lib/dist/mcp/index.js +18 -9
  179. package/lib/dist/mcp/index.js.map +1 -1
  180. package/lib/dist/mcp/ppid-watchdog.d.ts +44 -0
  181. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  182. package/lib/dist/mcp/ppid-watchdog.js +27 -0
  183. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  184. package/lib/dist/mcp/proxy.d.ts +6 -0
  185. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  186. package/lib/dist/mcp/proxy.js +153 -24
  187. package/lib/dist/mcp/proxy.js.map +1 -1
  188. package/lib/dist/mcp/server-instructions.d.ts +12 -1
  189. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  190. package/lib/dist/mcp/server-instructions.js +58 -32
  191. package/lib/dist/mcp/server-instructions.js.map +1 -1
  192. package/lib/dist/mcp/session.d.ts +2 -0
  193. package/lib/dist/mcp/session.d.ts.map +1 -1
  194. package/lib/dist/mcp/session.js +49 -2
  195. package/lib/dist/mcp/session.js.map +1 -1
  196. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  197. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  198. package/lib/dist/mcp/stdin-teardown.js +49 -0
  199. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  200. package/lib/dist/mcp/tools.d.ts +110 -49
  201. package/lib/dist/mcp/tools.d.ts.map +1 -1
  202. package/lib/dist/mcp/tools.js +1222 -972
  203. package/lib/dist/mcp/tools.js.map +1 -1
  204. package/lib/dist/mcp/transport.d.ts.map +1 -1
  205. package/lib/dist/mcp/transport.js +18 -2
  206. package/lib/dist/mcp/transport.js.map +1 -1
  207. package/lib/dist/resolution/callback-synthesizer.d.ts +3 -3
  208. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  209. package/lib/dist/resolution/callback-synthesizer.js +549 -21
  210. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  211. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  212. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  213. package/lib/dist/resolution/frameworks/astro.js +169 -0
  214. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  215. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
  216. package/lib/dist/resolution/frameworks/expo-modules.js +6 -1
  217. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
  218. package/lib/dist/resolution/frameworks/index.d.ts +1 -0
  219. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  220. package/lib/dist/resolution/frameworks/index.js +5 -1
  221. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  222. package/lib/dist/resolution/frameworks/java.js +6 -1
  223. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  224. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  225. package/lib/dist/resolution/frameworks/python.js +7 -3
  226. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  227. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  228. package/lib/dist/resolution/frameworks/react-native.js +53 -3
  229. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  230. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  231. package/lib/dist/resolution/frameworks/react.js +15 -3
  232. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  233. package/lib/dist/resolution/frameworks/svelte.js +5 -1
  234. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  235. package/lib/dist/resolution/frameworks/vue.js +24 -27
  236. package/lib/dist/resolution/frameworks/vue.js.map +1 -1
  237. package/lib/dist/resolution/import-resolver.d.ts +10 -0
  238. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  239. package/lib/dist/resolution/import-resolver.js +564 -2
  240. package/lib/dist/resolution/import-resolver.js.map +1 -1
  241. package/lib/dist/resolution/index.d.ts +80 -0
  242. package/lib/dist/resolution/index.d.ts.map +1 -1
  243. package/lib/dist/resolution/index.js +457 -7
  244. package/lib/dist/resolution/index.js.map +1 -1
  245. package/lib/dist/resolution/name-matcher.d.ts +61 -0
  246. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  247. package/lib/dist/resolution/name-matcher.js +590 -14
  248. package/lib/dist/resolution/name-matcher.js.map +1 -1
  249. package/lib/dist/resolution/types.d.ts +27 -3
  250. package/lib/dist/resolution/types.d.ts.map +1 -1
  251. package/lib/dist/resolution/workspace-packages.d.ts +48 -0
  252. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  253. package/lib/dist/resolution/workspace-packages.js +208 -0
  254. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  255. package/lib/dist/search/query-utils.d.ts +35 -1
  256. package/lib/dist/search/query-utils.d.ts.map +1 -1
  257. package/lib/dist/search/query-utils.js +109 -10
  258. package/lib/dist/search/query-utils.js.map +1 -1
  259. package/lib/dist/sync/watcher.d.ts +124 -32
  260. package/lib/dist/sync/watcher.d.ts.map +1 -1
  261. package/lib/dist/sync/watcher.js +326 -111
  262. package/lib/dist/sync/watcher.js.map +1 -1
  263. package/lib/dist/telemetry/index.d.ts +146 -0
  264. package/lib/dist/telemetry/index.d.ts.map +1 -0
  265. package/lib/dist/telemetry/index.js +544 -0
  266. package/lib/dist/telemetry/index.js.map +1 -0
  267. package/lib/dist/types.d.ts +25 -2
  268. package/lib/dist/types.d.ts.map +1 -1
  269. package/lib/dist/types.js +3 -0
  270. package/lib/dist/types.js.map +1 -1
  271. package/lib/dist/upgrade/index.d.ts +132 -0
  272. package/lib/dist/upgrade/index.d.ts.map +1 -0
  273. package/lib/dist/upgrade/index.js +462 -0
  274. package/lib/dist/upgrade/index.js.map +1 -0
  275. package/lib/dist/utils.d.ts +30 -24
  276. package/lib/dist/utils.d.ts.map +1 -1
  277. package/lib/dist/utils.js +64 -48
  278. package/lib/dist/utils.js.map +1 -1
  279. package/lib/node_modules/.package-lock.json +1 -29
  280. package/lib/package.json +1 -2
  281. package/package.json +1 -1
  282. package/lib/node_modules/chokidar/LICENSE +0 -21
  283. package/lib/node_modules/chokidar/README.md +0 -305
  284. package/lib/node_modules/chokidar/esm/handler.d.ts +0 -90
  285. package/lib/node_modules/chokidar/esm/handler.js +0 -629
  286. package/lib/node_modules/chokidar/esm/index.d.ts +0 -215
  287. package/lib/node_modules/chokidar/esm/index.js +0 -798
  288. package/lib/node_modules/chokidar/esm/package.json +0 -1
  289. package/lib/node_modules/chokidar/handler.d.ts +0 -90
  290. package/lib/node_modules/chokidar/handler.js +0 -635
  291. package/lib/node_modules/chokidar/index.d.ts +0 -215
  292. package/lib/node_modules/chokidar/index.js +0 -804
  293. package/lib/node_modules/chokidar/package.json +0 -69
  294. package/lib/node_modules/readdirp/LICENSE +0 -21
  295. package/lib/node_modules/readdirp/README.md +0 -120
  296. package/lib/node_modules/readdirp/esm/index.d.ts +0 -108
  297. package/lib/node_modules/readdirp/esm/index.js +0 -257
  298. package/lib/node_modules/readdirp/esm/package.json +0 -1
  299. package/lib/node_modules/readdirp/index.d.ts +0 -108
  300. package/lib/node_modules/readdirp/index.js +0 -263
  301. package/lib/node_modules/readdirp/package.json +0 -70
@@ -52,6 +52,8 @@ const transport_1 = require("./transport");
52
52
  const tools_1 = require("./tools");
53
53
  const server_instructions_1 = require("./server-instructions");
54
54
  const version_1 = require("./version");
55
+ const directory_1 = require("../directory");
56
+ const telemetry_1 = require("../telemetry");
55
57
  /**
56
58
  * MCP Server Info — kept on the session because some clients log it. The
57
59
  * version tracks the real package version (was a hard-coded '0.1.0').
@@ -106,6 +108,8 @@ class MCPSession {
106
108
  transport;
107
109
  engine;
108
110
  clientSupportsRoots = false;
111
+ /** From the initialize handshake — attributes usage rollups to the agent host. */
112
+ clientInfo;
109
113
  rootsAttempted = false;
110
114
  resolvePromise = null;
111
115
  explicitProjectPath;
@@ -154,6 +158,22 @@ class MCPSession {
154
158
  if (isRequest)
155
159
  this.transport.sendResult(message.id, {});
156
160
  break;
161
+ case 'resources/list':
162
+ // We expose no MCP resources, but some clients (opencode, Codex) probe
163
+ // for them on connect; reply with an empty list instead of a
164
+ // MethodNotFound error that surfaces as a scary `-32601` log line. (#621)
165
+ if (isRequest)
166
+ this.transport.sendResult(message.id, { resources: [] });
167
+ break;
168
+ case 'resources/templates/list':
169
+ if (isRequest)
170
+ this.transport.sendResult(message.id, { resourceTemplates: [] });
171
+ break;
172
+ case 'prompts/list':
173
+ // Likewise — no prompts exposed, but answer the probe cleanly. (#621)
174
+ if (isRequest)
175
+ this.transport.sendResult(message.id, { prompts: [] });
176
+ break;
157
177
  default:
158
178
  if (isRequest) {
159
179
  this.transport.sendError(message.id, transport_1.ErrorCodes.MethodNotFound, `Method not found: ${message.method}`);
@@ -163,6 +183,12 @@ class MCPSession {
163
183
  async handleInitialize(request) {
164
184
  const params = request.params;
165
185
  this.clientSupportsRoots = !!params?.capabilities?.roots;
186
+ if (params?.clientInfo) {
187
+ this.clientInfo = {
188
+ name: typeof params.clientInfo.name === 'string' ? params.clientInfo.name : undefined,
189
+ version: typeof params.clientInfo.version === 'string' ? params.clientInfo.version : undefined,
190
+ };
191
+ }
166
192
  // Explicit project signal, strongest first: client-provided rootUri /
167
193
  // workspaceFolders (LSP-style), else the --path the server was launched
168
194
  // with. cwd is NOT used here — we defer it so a roots/list answer can
@@ -177,12 +203,23 @@ class MCPSession {
177
203
  else if (this.explicitProjectPath) {
178
204
  explicitPath = this.explicitProjectPath;
179
205
  }
206
+ // Pick the instructions variant by the workspace's index state — a cheap
207
+ // synchronous walk-up (existsSync loop only, no DB open, so the #172
208
+ // respond-fast contract holds). An unindexed workspace gets the short
209
+ // "inactive this session" note instead of the full playbook: the playbook
210
+ // tells the agent to lean on tools that would all fail, and early failures
211
+ // teach the agent to abandon codegraph entirely. `tools/list` is gated the
212
+ // same way (empty list when unindexed). When no explicit path is known yet
213
+ // (roots/list dance pending), cwd is the best predictor of where the
214
+ // default project will resolve — and on a mismatch the worst case is the
215
+ // optimistic full playbook backstopped by the empty tool list.
216
+ const indexed = (0, directory_1.findNearestCodeGraphRoot)(explicitPath ?? process.cwd()) !== null;
180
217
  // Respond to the handshake BEFORE doing any heavy init — see issue #172.
181
218
  this.transport.sendResult(request.id, {
182
219
  protocolVersion: exports.PROTOCOL_VERSION,
183
220
  capabilities: { tools: {} },
184
221
  serverInfo: exports.SERVER_INFO,
185
- instructions: server_instructions_1.SERVER_INSTRUCTIONS,
222
+ instructions: indexed ? server_instructions_1.SERVER_INSTRUCTIONS : server_instructions_1.SERVER_INSTRUCTIONS_UNINDEXED,
186
223
  });
187
224
  if (explicitPath) {
188
225
  // Kick off engine init in the background. If another session in the
@@ -193,8 +230,15 @@ class MCPSession {
193
230
  }
194
231
  async handleToolsList(request) {
195
232
  await this.retryInitIfNeeded();
233
+ // An unindexed workspace serves an EMPTY tool list: absence is the one
234
+ // signal an agent can't misread. Listing 8 tools that all fail wastes the
235
+ // agent's calls and teaches it codegraph is broken (observed: one or two
236
+ // early isError responses and the agent stops calling codegraph for the
237
+ // whole session). A `codegraph init` run after the server started is
238
+ // picked up on the next tools/list — retryInitIfNeeded re-walks — though
239
+ // most hosts only request the list once per connection.
196
240
  this.transport.sendResult(request.id, {
197
- tools: this.engine.getToolHandler().getTools(),
241
+ tools: this.engine.hasDefaultCodeGraph() ? this.engine.getToolHandler().getTools() : [],
198
242
  });
199
243
  }
200
244
  async handleToolsCall(request) {
@@ -213,6 +257,9 @@ class MCPSession {
213
257
  await this.retryInitIfNeeded();
214
258
  const result = await this.engine.getToolHandler().execute(toolName, toolArgs);
215
259
  this.transport.sendResult(request.id, result);
260
+ // After the reply is on the wire — telemetry must never delay a tool
261
+ // response (in-memory increment only; see src/telemetry).
262
+ (0, telemetry_1.getTelemetry)().recordUsage('mcp_tool', toolName, !result.isError, this.clientInfo);
216
263
  }
217
264
  /**
218
265
  * Lazy default-project resolution. Three layers:
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,2CAAgG;AAEhG,mCAAgC;AAChC,+DAA4D;AAC5D,uCAAoD;AAEpD;;;GAGG;AACH,2EAA2E;AAC3E,4EAA4E;AAC/D,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,iCAAuB;CACjC,CAAC;AAEF,uDAAuD;AAC1C,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAE7C;;;GAGG;AACH,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC;;;GAGG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClE,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,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C7G,CAAC;QACD,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;CACF;AA5OD,gCA4OC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Treat a stdin failure as a shutdown signal — issue #799.
3
+ *
4
+ * An MCP stdio server's lifeline is its stdin: when the host/client goes away,
5
+ * stdin should end and the server should exit. The server paths listened for
6
+ * `'end'` and `'close'` — but NOT `'error'`.
7
+ *
8
+ * That gap bites with a socket-backed stdin, which is the shape VS Code /
9
+ * Claude Code use (a socketpair, not a pipe). When the client dies, the socket
10
+ * can surface as an `'error'` (ECONNRESET / hangup) rather than a clean
11
+ * `'close'`. With no `'error'` listener, Node escalates it to the process-wide
12
+ * `uncaughtException` handler, which logs and keeps running — so the server
13
+ * orphans instead of exiting. Worse, on Linux a `POLLHUP` socket fd left
14
+ * registered in epoll wakes the event loop continuously, pinning a core at
15
+ * 100% CPU (the spin reported in #799); once the main thread spins, the
16
+ * `setInterval` PPID watchdog can't even fire, so the orphan runs forever.
17
+ *
18
+ * Fix: listen for `'error'` as well, and DESTROY the stdin stream on any
19
+ * terminal event so the fd leaves epoll and can't keep churning, then run the
20
+ * caller's shutdown. Fires `onTerminal` at most once — callers' shutdowns are
21
+ * already re-entry-guarded, but the single-shot guard also keeps `destroy()`'s
22
+ * follow-on `'close'` from re-invoking it.
23
+ *
24
+ * `stream` is injectable for tests; it defaults to `process.stdin`.
25
+ */
26
+ export declare function treatStdinFailureAsShutdown(onTerminal: () => void, stream?: NodeJS.ReadableStream): void;
27
+ //# sourceMappingURL=stdin-teardown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-teardown.d.ts","sourceRoot":"","sources":["../../src/mcp/stdin-teardown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,IAAI,EACtB,MAAM,GAAE,MAAM,CAAC,cAA8B,GAC5C,IAAI,CAiBN"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.treatStdinFailureAsShutdown = treatStdinFailureAsShutdown;
4
+ /**
5
+ * Treat a stdin failure as a shutdown signal — issue #799.
6
+ *
7
+ * An MCP stdio server's lifeline is its stdin: when the host/client goes away,
8
+ * stdin should end and the server should exit. The server paths listened for
9
+ * `'end'` and `'close'` — but NOT `'error'`.
10
+ *
11
+ * That gap bites with a socket-backed stdin, which is the shape VS Code /
12
+ * Claude Code use (a socketpair, not a pipe). When the client dies, the socket
13
+ * can surface as an `'error'` (ECONNRESET / hangup) rather than a clean
14
+ * `'close'`. With no `'error'` listener, Node escalates it to the process-wide
15
+ * `uncaughtException` handler, which logs and keeps running — so the server
16
+ * orphans instead of exiting. Worse, on Linux a `POLLHUP` socket fd left
17
+ * registered in epoll wakes the event loop continuously, pinning a core at
18
+ * 100% CPU (the spin reported in #799); once the main thread spins, the
19
+ * `setInterval` PPID watchdog can't even fire, so the orphan runs forever.
20
+ *
21
+ * Fix: listen for `'error'` as well, and DESTROY the stdin stream on any
22
+ * terminal event so the fd leaves epoll and can't keep churning, then run the
23
+ * caller's shutdown. Fires `onTerminal` at most once — callers' shutdowns are
24
+ * already re-entry-guarded, but the single-shot guard also keeps `destroy()`'s
25
+ * follow-on `'close'` from re-invoking it.
26
+ *
27
+ * `stream` is injectable for tests; it defaults to `process.stdin`.
28
+ */
29
+ function treatStdinFailureAsShutdown(onTerminal, stream = process.stdin) {
30
+ let fired = false;
31
+ const fire = () => {
32
+ if (fired)
33
+ return;
34
+ fired = true;
35
+ // Drop the fd from epoll so a hung/half-closed socket can't keep waking
36
+ // the loop. Best-effort: the stream may already be torn down.
37
+ try {
38
+ stream.destroy?.();
39
+ }
40
+ catch {
41
+ /* already gone */
42
+ }
43
+ onTerminal();
44
+ };
45
+ stream.on('end', fire);
46
+ stream.on('close', fire);
47
+ stream.on('error', fire);
48
+ }
49
+ //# sourceMappingURL=stdin-teardown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-teardown.js","sourceRoot":"","sources":["../../src/mcp/stdin-teardown.ts"],"names":[],"mappings":";;AAyBA,kEAoBC;AA7CD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,2BAA2B,CACzC,UAAsB,EACtB,SAAgC,OAAO,CAAC,KAAK;IAE7C,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,KAAK;YAAE,OAAO;QAClB,KAAK,GAAG,IAAI,CAAC;QACb,wEAAwE;QACxE,8DAA8D;QAC9D,IAAI,CAAC;YACF,MAAuC,CAAC,OAAO,EAAE,EAAE,CAAC;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;QACD,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC"}
@@ -5,6 +5,25 @@
5
5
  */
6
6
  import type CodeGraph from '../index';
7
7
  import type { PendingFile } from '../sync';
8
+ /**
9
+ * An expected, recoverable "codegraph can't serve this" condition — most
10
+ * importantly a project with no index. The dispatch catch converts these to
11
+ * SUCCESS-shaped responses (guidance text, NO isError): an `isError: true`
12
+ * early in a session teaches the agent the toolset is broken and it stops
13
+ * calling codegraph entirely (observed repeatedly), which is exactly wrong
14
+ * for conditions the agent can simply work around (use built-in tools for
15
+ * that codebase / pass projectPath). isError is reserved for "stop trying"
16
+ * cases: security refusals ({@link PathRefusalError}) and genuine
17
+ * malfunctions.
18
+ */
19
+ export declare class NotIndexedError extends Error {
20
+ }
21
+ /**
22
+ * A security refusal (sensitive system path). Stays `isError: true` WITHOUT
23
+ * retry guidance — abandoning this path is the desired agent reaction.
24
+ */
25
+ export declare class PathRefusalError extends Error {
26
+ }
8
27
  /**
9
28
  * Calculate the recommended number of codegraph_explore calls based on project size.
10
29
  * Larger codebases need more exploration calls to cover their surface area,
@@ -105,8 +124,9 @@ export interface ToolResult {
105
124
  /**
106
125
  * All CodeGraph MCP tools
107
126
  *
108
- * Designed for minimal context usage - use codegraph_context as the primary tool,
109
- * and only use other tools for targeted follow-up queries.
127
+ * Designed for minimal context usage - use codegraph_explore as the primary tool
128
+ * (one call usually answers the whole question), and only use other tools for
129
+ * targeted follow-up queries.
110
130
  *
111
131
  * All tools support cross-project queries via the optional `projectPath` parameter.
112
132
  */
@@ -158,7 +178,7 @@ export declare class ToolHandler {
158
178
  * Unset/empty → every tool is exposed. Lets an operator (or an A/B harness)
159
179
  * trim the tool surface without rebuilding the client config; the ablated
160
180
  * tool is then truly absent from ListTools rather than merely denied on call.
161
- * Matching is on the short form, so "trace" and "codegraph_trace" both work.
181
+ * Matching is on the short form, so "node" and "codegraph_node" both work.
162
182
  */
163
183
  private toolAllowlist;
164
184
  /** Whether a tool name passes the CODEGRAPH_MCP_TOOLS allowlist (if any). */
@@ -241,26 +261,15 @@ export declare class ToolHandler {
241
261
  */
242
262
  private handleSearch;
243
263
  /**
244
- * Handle codegraph_context
264
+ * Group symbol matches into DISTINCT DEFINITIONS — one group per
265
+ * (filePath, qualifiedName), so same-file overloads stay together while
266
+ * unrelated same-named classes across a monorepo's apps (#764: one
267
+ * `UserService` per NestJS app) are kept apart. Optionally narrowed by a
268
+ * `file` path/suffix first.
245
269
  */
246
- private handleContext;
247
- /**
248
- * Detect a flow-style task ("how does X reach Y", "trace the path from A to B")
249
- * and pre-run trace between the most likely endpoints, returning the trace
250
- * body to splice into the context response. Returns '' for non-flow queries
251
- * or when no plausible endpoint pair can be extracted.
252
- *
253
- * Conservative by design: only fires when the task has both a clear flow
254
- * keyword AND at least two distinct PascalCase / camelCase identifiers.
255
- * False positives waste a graph query; false negatives just fall back to
256
- * the agent calling trace itself (existing path-proximity wiring handles
257
- * disambiguation either way).
258
- */
259
- private maybeInlineFlowTrace;
260
- /**
261
- * Heuristic to detect if a query looks like a feature request
262
- */
263
- private looksLikeFeatureRequest;
270
+ private groupDefinitions;
271
+ /** Section heading for one distinct definition in grouped output. */
272
+ private definitionHeading;
264
273
  /**
265
274
  * Handle codegraph_callers
266
275
  */
@@ -273,18 +282,6 @@ export declare class ToolHandler {
273
282
  * Handle codegraph_impact
274
283
  */
275
284
  private handleImpact;
276
- /**
277
- * Handle codegraph_trace — shortest CALL PATH between two symbols.
278
- *
279
- * Exposes GraphTraverser.findPath: the chain of functions from `from` to `to`,
280
- * each hop annotated with file:line and the call-site line. This is the
281
- * capability grep/Read structurally cannot provide. When no static path
282
- * exists, the chain has almost certainly broken at dynamic dispatch
283
- * (callbacks, descriptors, metaclasses) — we say so and surface the start
284
- * symbol's outgoing calls so the agent bridges the one missing hop with
285
- * codegraph_node rather than blindly reading.
286
- */
287
- private handleTrace;
288
285
  /**
289
286
  * Describe a synthesized (dynamic-dispatch) edge for human output: how the
290
287
  * callback was wired up — the bridge static parsing can't see. Returns null
@@ -292,19 +289,6 @@ export declare class ToolHandler {
292
289
  * hop reads as "registered via onUpdate at App.tsx:3148", not a bare arrow.
293
290
  */
294
291
  private synthEdgeNote;
295
- /**
296
- * Read one trimmed source line at "relpath:line" (relative to the project
297
- * root). `cache` holds split file contents so a multi-hop trace reads each
298
- * file at most once. Returns null if the file/line can't be resolved.
299
- */
300
- private sourceLineAt;
301
- /**
302
- * Read a hop's body — filePath lines [startLine..endLine] — for inlining into
303
- * a trace, capped (lines + chars) so the whole path stays path-scoped even on
304
- * a 7-hop chain. Dedents to the body's own indentation and marks truncation.
305
- * Shares `cache` with sourceLineAt so each file is read at most once per trace.
306
- */
307
- private sourceRangeAt;
308
292
  /**
309
293
  * Flow-from-named-symbols: an agent's codegraph_explore query is a bag of
310
294
  * symbol names that usually spans the flow it's investigating (e.g.
@@ -320,6 +304,53 @@ export declare class ToolHandler {
320
304
  * dropping unrelated `OmsOrderService::list`.
321
305
  */
322
306
  private buildFlowFromNamedSymbols;
307
+ /**
308
+ * Dynamic-boundary surfacing (#687): when the flow among the agent's named
309
+ * symbols does not fully connect, scan the disconnected symbols' bodies for
310
+ * dynamic-dispatch sites (computed member calls, getattr, reflection, typed
311
+ * message buses, runtime-keyed emits) and ANNOUNCE the boundary — the exact
312
+ * site, the form, and (when a key is statically visible) candidate targets —
313
+ * instead of guessing edges. The answer to "how does A reach B" when no
314
+ * static path exists IS the dispatch site: that's where the flow continues
315
+ * at runtime. Query-time, deterministic, zero graph mutation; a fully
316
+ * connected flow never reaches this method.
317
+ */
318
+ private buildDynamicBoundaries;
319
+ /**
320
+ * Shortlist candidate runtime targets for a dispatch key surfaced by
321
+ * {@link buildDynamicBoundaries}. Exact conventional names first (`save` →
322
+ * `onSave`/`handleSave`; `CreateCmd` → `CreateCmdHandler`), then FTS, with a
323
+ * normalized-containment post-filter (FTS camel-splitting is fuzzier than a
324
+ * candidate list should be). Symbols the agent already named sort first and
325
+ * are marked — that's the "you were right, here's the wiring" case.
326
+ */
327
+ private boundaryCandidates;
328
+ /**
329
+ * Compact "blast radius" for the entry symbols of an explore result: who
330
+ * depends on each (callers) and which test files cover it — LOCATIONS ONLY,
331
+ * no source, so the agent knows what to update / re-verify before editing
332
+ * without reaching for a separate impact call. Always-on, but skips symbols
333
+ * that have no dependents (nothing to warn about), and returns '' when none
334
+ * qualify so a leaf-only exploration stays clean.
335
+ */
336
+ private buildBlastRadiusSection;
337
+ /**
338
+ * Graph-connectivity relevance via Random-Walk-with-Restart (personalized
339
+ * PageRank) from the query's matched SEED nodes over the call/reference graph.
340
+ *
341
+ * This is the ranking signal text search (FTS/bm25) CANNOT provide, and it's
342
+ * codegraph's home turf: relevance by STRUCTURE, not words. A file whose
343
+ * symbols are call-connected to the matched cluster accrues walk mass and
344
+ * ranks high; a lone TEXT match — e.g. `LensSwitcher.swift` matched the word
345
+ * "switch" from `switchOrganization`, but calls none of `setUser`/`fetchUser`
346
+ * — gets only its own restart probability and ranks ~0. Immune to the
347
+ * tokenization trap that fools term matching, deterministic, no embeddings.
348
+ *
349
+ * Undirected adjacency (reachability both ways), restart α=0.25 to the seeds,
350
+ * power iteration to convergence. Bounded to the already-relevant subgraph, so
351
+ * it's a few hundred nodes × ~25 iterations — negligible cost.
352
+ */
353
+ private computeGraphRelevance;
323
354
  /**
324
355
  * Handle codegraph_explore — deep exploration in a single call
325
356
  *
@@ -336,6 +367,22 @@ export declare class ToolHandler {
336
367
  * Handle codegraph_node
337
368
  */
338
369
  private handleNode;
370
+ /**
371
+ * FILE READ MODE: resolve `fileArg` (path or basename) to an indexed file and
372
+ * read it like the Read tool — its current on-disk source with line numbers,
373
+ * narrowable with `offset`/`limit` exactly as Read's are — preceded by a
374
+ * one-line blast-radius header (which files depend on it). `symbolsOnly`
375
+ * returns just the structural map (symbols + dependents) instead of source.
376
+ *
377
+ * Parity goal: the numbered source block is byte-for-byte the shape Read
378
+ * returns (`<n>\t<line>`, no padding), so the agent treats it as a Read — only
379
+ * faster (served from the index) and with the blast radius attached. Security:
380
+ * yaml/properties files are summarized by key, never dumped (#383); reads go
381
+ * through validatePathWithinRoot (#527).
382
+ */
383
+ private handleFileView;
384
+ /** Render one symbol: details + (optional) body/outline + its caller/callee trail. */
385
+ private renderNodeSection;
339
386
  /**
340
387
  * Build the "trail" for a symbol: its direct callees (what it calls) and
341
388
  * callers (what calls it), each with file:line — so codegraph_node doubles as
@@ -393,7 +440,15 @@ export declare class ToolHandler {
393
440
  * Python — `stage_apply::run` matches a `run` in `stage_apply.rs`)
394
441
  */
395
442
  private matchesSymbol;
396
- private findSymbol;
443
+ /**
444
+ * Find ALL definitions matching a name, ranked, so codegraph_node can return
445
+ * every overload instead of guessing one (the wrong guess → a Read). Keepers
446
+ * rank before generated stubs (.pb.go etc.); stable within a group preserves
447
+ * FTS order. Returns [] when nothing matches; a qualified lookup that finds no
448
+ * exact match returns [] rather than a misleading fuzzy file hit (#173); a
449
+ * bare name with no exact match falls back to the single top fuzzy result.
450
+ */
451
+ private findSymbolMatches;
397
452
  /**
398
453
  * Find ALL symbols matching a name. Used by callers/callees/impact to aggregate
399
454
  * results across all matching symbols (e.g., multiple classes with an `execute` method).
@@ -405,6 +460,13 @@ export declare class ToolHandler {
405
460
  private truncateOutput;
406
461
  private formatSearchResults;
407
462
  private formatNodeList;
463
+ /**
464
+ * Relationship label for a non-`calls` edge in callers/callees lists. A
465
+ * function-as-value edge (#756) is the high-signal one: `callers(cb)`
466
+ * showing "via callback registration" tells the agent this is where the
467
+ * callback is WIRED, not where it's invoked.
468
+ */
469
+ private edgeLabel;
408
470
  private formatImpact;
409
471
  /**
410
472
  * Build a compact structural outline of a container symbol from its
@@ -415,7 +477,6 @@ export declare class ToolHandler {
415
477
  */
416
478
  private buildContainerOutline;
417
479
  private formatNodeDetails;
418
- private formatTaskContext;
419
480
  private textResult;
420
481
  private errorResult;
421
482
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;AAetC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA+D3C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,4EAA4E;IAC5E,eAAe,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,sBAAsB,EAAE,MAAM,CAAC;IAC/B,0EAA0E;IAC1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