gitnexus 1.5.3 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/README.md +10 -0
  2. package/dist/_shared/graph/types.d.ts +1 -1
  3. package/dist/_shared/graph/types.d.ts.map +1 -1
  4. package/dist/_shared/index.d.ts +1 -0
  5. package/dist/_shared/index.d.ts.map +1 -1
  6. package/dist/_shared/language-detection.d.ts.map +1 -1
  7. package/dist/_shared/language-detection.js +2 -0
  8. package/dist/_shared/language-detection.js.map +1 -1
  9. package/dist/_shared/languages.d.ts +1 -0
  10. package/dist/_shared/languages.d.ts.map +1 -1
  11. package/dist/_shared/languages.js +1 -0
  12. package/dist/_shared/languages.js.map +1 -1
  13. package/dist/_shared/lbug/schema-constants.d.ts +1 -1
  14. package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
  15. package/dist/_shared/lbug/schema-constants.js +3 -1
  16. package/dist/_shared/lbug/schema-constants.js.map +1 -1
  17. package/dist/_shared/mro-strategy.d.ts +19 -0
  18. package/dist/_shared/mro-strategy.d.ts.map +1 -0
  19. package/dist/_shared/mro-strategy.js +2 -0
  20. package/dist/_shared/mro-strategy.js.map +1 -0
  21. package/dist/cli/ai-context.d.ts +1 -0
  22. package/dist/cli/ai-context.js +28 -4
  23. package/dist/cli/analyze.d.ts +2 -0
  24. package/dist/cli/analyze.js +30 -4
  25. package/dist/cli/group.d.ts +2 -0
  26. package/dist/cli/group.js +233 -0
  27. package/dist/cli/index.js +3 -0
  28. package/dist/cli/serve.js +4 -1
  29. package/dist/cli/setup.js +34 -3
  30. package/dist/config/ignore-service.js +8 -3
  31. package/dist/core/augmentation/engine.js +1 -1
  32. package/dist/core/git-staleness.d.ts +13 -0
  33. package/dist/core/git-staleness.js +29 -0
  34. package/dist/core/group/bridge-db.d.ts +82 -0
  35. package/dist/core/group/bridge-db.js +460 -0
  36. package/dist/core/group/bridge-schema.d.ts +27 -0
  37. package/dist/core/group/bridge-schema.js +55 -0
  38. package/dist/core/group/config-parser.d.ts +3 -0
  39. package/dist/core/group/config-parser.js +83 -0
  40. package/dist/core/group/contract-extractor.d.ts +7 -0
  41. package/dist/core/group/contract-extractor.js +1 -0
  42. package/dist/core/group/extractors/fs-utils.d.ts +10 -0
  43. package/dist/core/group/extractors/fs-utils.js +24 -0
  44. package/dist/core/group/extractors/grpc-extractor.d.ts +25 -0
  45. package/dist/core/group/extractors/grpc-extractor.js +386 -0
  46. package/dist/core/group/extractors/grpc-patterns/go.d.ts +2 -0
  47. package/dist/core/group/extractors/grpc-patterns/go.js +97 -0
  48. package/dist/core/group/extractors/grpc-patterns/index.d.ts +19 -0
  49. package/dist/core/group/extractors/grpc-patterns/index.js +46 -0
  50. package/dist/core/group/extractors/grpc-patterns/java.d.ts +2 -0
  51. package/dist/core/group/extractors/grpc-patterns/java.js +173 -0
  52. package/dist/core/group/extractors/grpc-patterns/node.d.ts +4 -0
  53. package/dist/core/group/extractors/grpc-patterns/node.js +290 -0
  54. package/dist/core/group/extractors/grpc-patterns/proto.d.ts +9 -0
  55. package/dist/core/group/extractors/grpc-patterns/proto.js +134 -0
  56. package/dist/core/group/extractors/grpc-patterns/python.d.ts +2 -0
  57. package/dist/core/group/extractors/grpc-patterns/python.js +67 -0
  58. package/dist/core/group/extractors/grpc-patterns/types.d.ts +50 -0
  59. package/dist/core/group/extractors/grpc-patterns/types.js +1 -0
  60. package/dist/core/group/extractors/http-patterns/go.d.ts +2 -0
  61. package/dist/core/group/extractors/http-patterns/go.js +215 -0
  62. package/dist/core/group/extractors/http-patterns/index.d.ts +17 -0
  63. package/dist/core/group/extractors/http-patterns/index.js +44 -0
  64. package/dist/core/group/extractors/http-patterns/java.d.ts +2 -0
  65. package/dist/core/group/extractors/http-patterns/java.js +253 -0
  66. package/dist/core/group/extractors/http-patterns/node.d.ts +4 -0
  67. package/dist/core/group/extractors/http-patterns/node.js +354 -0
  68. package/dist/core/group/extractors/http-patterns/php.d.ts +2 -0
  69. package/dist/core/group/extractors/http-patterns/php.js +70 -0
  70. package/dist/core/group/extractors/http-patterns/python.d.ts +2 -0
  71. package/dist/core/group/extractors/http-patterns/python.js +133 -0
  72. package/dist/core/group/extractors/http-patterns/types.d.ts +61 -0
  73. package/dist/core/group/extractors/http-patterns/types.js +1 -0
  74. package/dist/core/group/extractors/http-route-extractor.d.ts +21 -0
  75. package/dist/core/group/extractors/http-route-extractor.js +391 -0
  76. package/dist/core/group/extractors/manifest-extractor.d.ts +54 -0
  77. package/dist/core/group/extractors/manifest-extractor.js +235 -0
  78. package/dist/core/group/extractors/topic-extractor.d.ts +8 -0
  79. package/dist/core/group/extractors/topic-extractor.js +97 -0
  80. package/dist/core/group/extractors/topic-patterns/go.d.ts +2 -0
  81. package/dist/core/group/extractors/topic-patterns/go.js +120 -0
  82. package/dist/core/group/extractors/topic-patterns/index.d.ts +14 -0
  83. package/dist/core/group/extractors/topic-patterns/index.js +38 -0
  84. package/dist/core/group/extractors/topic-patterns/java.d.ts +2 -0
  85. package/dist/core/group/extractors/topic-patterns/java.js +80 -0
  86. package/dist/core/group/extractors/topic-patterns/node.d.ts +4 -0
  87. package/dist/core/group/extractors/topic-patterns/node.js +155 -0
  88. package/dist/core/group/extractors/topic-patterns/python.d.ts +2 -0
  89. package/dist/core/group/extractors/topic-patterns/python.js +116 -0
  90. package/dist/core/group/extractors/topic-patterns/types.d.ts +25 -0
  91. package/dist/core/group/extractors/topic-patterns/types.js +10 -0
  92. package/dist/core/group/extractors/tree-sitter-scanner.d.ts +113 -0
  93. package/dist/core/group/extractors/tree-sitter-scanner.js +94 -0
  94. package/dist/core/group/matching.d.ts +13 -0
  95. package/dist/core/group/matching.js +198 -0
  96. package/dist/core/group/normalization.d.ts +3 -0
  97. package/dist/core/group/normalization.js +115 -0
  98. package/dist/core/group/service-boundary-detector.d.ts +8 -0
  99. package/dist/core/group/service-boundary-detector.js +155 -0
  100. package/dist/core/group/service.d.ts +46 -0
  101. package/dist/core/group/service.js +160 -0
  102. package/dist/core/group/storage.d.ts +9 -0
  103. package/dist/core/group/storage.js +91 -0
  104. package/dist/core/group/sync.d.ts +21 -0
  105. package/dist/core/group/sync.js +148 -0
  106. package/dist/core/group/types.d.ts +130 -0
  107. package/dist/core/group/types.js +1 -0
  108. package/dist/core/ingestion/binding-accumulator.d.ts +212 -0
  109. package/dist/core/ingestion/binding-accumulator.js +336 -0
  110. package/dist/core/ingestion/call-processor.d.ts +155 -24
  111. package/dist/core/ingestion/call-processor.js +1129 -247
  112. package/dist/core/ingestion/class-extractors/generic.d.ts +2 -0
  113. package/dist/core/ingestion/class-extractors/generic.js +135 -0
  114. package/dist/core/ingestion/class-types.d.ts +34 -0
  115. package/dist/core/ingestion/class-types.js +1 -0
  116. package/dist/core/ingestion/cobol-processor.d.ts +1 -1
  117. package/dist/core/ingestion/entry-point-scoring.d.ts +1 -0
  118. package/dist/core/ingestion/entry-point-scoring.js +1 -0
  119. package/dist/core/ingestion/field-types.d.ts +2 -2
  120. package/dist/core/ingestion/filesystem-walker.js +8 -0
  121. package/dist/core/ingestion/framework-detection.d.ts +1 -0
  122. package/dist/core/ingestion/framework-detection.js +1 -0
  123. package/dist/core/ingestion/heritage-processor.d.ts +8 -15
  124. package/dist/core/ingestion/heritage-processor.js +15 -28
  125. package/dist/core/ingestion/import-processor.d.ts +1 -11
  126. package/dist/core/ingestion/import-processor.js +1 -13
  127. package/dist/core/ingestion/import-resolvers/utils.js +1 -0
  128. package/dist/core/ingestion/import-resolvers/vue.d.ts +8 -0
  129. package/dist/core/ingestion/import-resolvers/vue.js +9 -0
  130. package/dist/core/ingestion/language-config.js +1 -1
  131. package/dist/core/ingestion/language-provider.d.ts +14 -3
  132. package/dist/core/ingestion/languages/c-cpp.js +168 -1
  133. package/dist/core/ingestion/languages/csharp.js +20 -0
  134. package/dist/core/ingestion/languages/dart.js +26 -4
  135. package/dist/core/ingestion/languages/go.js +22 -0
  136. package/dist/core/ingestion/languages/index.d.ts +1 -0
  137. package/dist/core/ingestion/languages/index.js +2 -0
  138. package/dist/core/ingestion/languages/java.js +17 -0
  139. package/dist/core/ingestion/languages/kotlin.js +24 -1
  140. package/dist/core/ingestion/languages/php.js +23 -11
  141. package/dist/core/ingestion/languages/python.js +9 -0
  142. package/dist/core/ingestion/languages/ruby.js +43 -0
  143. package/dist/core/ingestion/languages/rust.js +38 -0
  144. package/dist/core/ingestion/languages/swift.js +31 -0
  145. package/dist/core/ingestion/languages/typescript.d.ts +1 -0
  146. package/dist/core/ingestion/languages/typescript.js +52 -3
  147. package/dist/core/ingestion/languages/vue.d.ts +13 -0
  148. package/dist/core/ingestion/languages/vue.js +81 -0
  149. package/dist/core/ingestion/markdown-processor.d.ts +1 -1
  150. package/dist/core/ingestion/method-extractors/configs/c-cpp.d.ts +3 -0
  151. package/dist/core/ingestion/method-extractors/configs/c-cpp.js +387 -0
  152. package/dist/core/ingestion/method-extractors/configs/csharp.js +5 -1
  153. package/dist/core/ingestion/method-extractors/configs/dart.d.ts +2 -0
  154. package/dist/core/ingestion/method-extractors/configs/dart.js +376 -0
  155. package/dist/core/ingestion/method-extractors/configs/go.d.ts +2 -0
  156. package/dist/core/ingestion/method-extractors/configs/go.js +176 -0
  157. package/dist/core/ingestion/method-extractors/configs/jvm.js +14 -4
  158. package/dist/core/ingestion/method-extractors/configs/php.d.ts +2 -0
  159. package/dist/core/ingestion/method-extractors/configs/php.js +304 -0
  160. package/dist/core/ingestion/method-extractors/configs/python.d.ts +2 -0
  161. package/dist/core/ingestion/method-extractors/configs/python.js +309 -0
  162. package/dist/core/ingestion/method-extractors/configs/ruby.d.ts +2 -0
  163. package/dist/core/ingestion/method-extractors/configs/ruby.js +286 -0
  164. package/dist/core/ingestion/method-extractors/configs/rust.d.ts +2 -0
  165. package/dist/core/ingestion/method-extractors/configs/rust.js +195 -0
  166. package/dist/core/ingestion/method-extractors/configs/swift.d.ts +2 -0
  167. package/dist/core/ingestion/method-extractors/configs/swift.js +277 -0
  168. package/dist/core/ingestion/method-extractors/configs/typescript-javascript.js +85 -8
  169. package/dist/core/ingestion/method-extractors/generic.d.ts +6 -0
  170. package/dist/core/ingestion/method-extractors/generic.js +84 -17
  171. package/dist/core/ingestion/method-types.d.ts +29 -0
  172. package/dist/core/ingestion/model/field-registry.d.ts +18 -0
  173. package/dist/core/ingestion/model/field-registry.js +22 -0
  174. package/dist/core/ingestion/model/heritage-map.d.ts +70 -0
  175. package/dist/core/ingestion/model/heritage-map.js +159 -0
  176. package/dist/core/ingestion/model/index.d.ts +20 -0
  177. package/dist/core/ingestion/model/index.js +41 -0
  178. package/dist/core/ingestion/model/method-registry.d.ts +62 -0
  179. package/dist/core/ingestion/model/method-registry.js +130 -0
  180. package/dist/core/ingestion/model/registration-table.d.ts +139 -0
  181. package/dist/core/ingestion/model/registration-table.js +224 -0
  182. package/dist/core/ingestion/model/resolution-context.d.ts +93 -0
  183. package/dist/core/ingestion/model/resolution-context.js +337 -0
  184. package/dist/core/ingestion/model/resolve.d.ts +56 -0
  185. package/dist/core/ingestion/model/resolve.js +297 -0
  186. package/dist/core/ingestion/model/semantic-model.d.ts +86 -0
  187. package/dist/core/ingestion/model/semantic-model.js +120 -0
  188. package/dist/core/ingestion/model/symbol-table.d.ts +222 -0
  189. package/dist/core/ingestion/model/symbol-table.js +206 -0
  190. package/dist/core/ingestion/model/type-registry.d.ts +39 -0
  191. package/dist/core/ingestion/model/type-registry.js +62 -0
  192. package/dist/core/ingestion/mro-processor.d.ts +5 -4
  193. package/dist/core/ingestion/mro-processor.js +311 -107
  194. package/dist/core/ingestion/parsing-processor.d.ts +5 -4
  195. package/dist/core/ingestion/parsing-processor.js +224 -87
  196. package/dist/core/ingestion/pipeline-phases/cobol.d.ts +16 -0
  197. package/dist/core/ingestion/pipeline-phases/cobol.js +45 -0
  198. package/dist/core/ingestion/pipeline-phases/communities.d.ts +16 -0
  199. package/dist/core/ingestion/pipeline-phases/communities.js +62 -0
  200. package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +17 -0
  201. package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +156 -0
  202. package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +37 -0
  203. package/dist/core/ingestion/pipeline-phases/cross-file.js +63 -0
  204. package/dist/core/ingestion/pipeline-phases/index.d.ts +21 -0
  205. package/dist/core/ingestion/pipeline-phases/index.js +22 -0
  206. package/dist/core/ingestion/pipeline-phases/markdown.d.ts +17 -0
  207. package/dist/core/ingestion/pipeline-phases/markdown.js +33 -0
  208. package/dist/core/ingestion/pipeline-phases/mro.d.ts +18 -0
  209. package/dist/core/ingestion/pipeline-phases/mro.js +36 -0
  210. package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +22 -0
  211. package/dist/core/ingestion/pipeline-phases/orm-extraction.js +92 -0
  212. package/dist/core/ingestion/pipeline-phases/orm.d.ts +15 -0
  213. package/dist/core/ingestion/pipeline-phases/orm.js +74 -0
  214. package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +47 -0
  215. package/dist/core/ingestion/pipeline-phases/parse-impl.js +437 -0
  216. package/dist/core/ingestion/pipeline-phases/parse.d.ts +49 -0
  217. package/dist/core/ingestion/pipeline-phases/parse.js +33 -0
  218. package/dist/core/ingestion/pipeline-phases/processes.d.ts +16 -0
  219. package/dist/core/ingestion/pipeline-phases/processes.js +143 -0
  220. package/dist/core/ingestion/pipeline-phases/routes.d.ts +21 -0
  221. package/dist/core/ingestion/pipeline-phases/routes.js +243 -0
  222. package/dist/core/ingestion/pipeline-phases/runner.d.ts +22 -0
  223. package/dist/core/ingestion/pipeline-phases/runner.js +203 -0
  224. package/dist/core/ingestion/pipeline-phases/scan.d.ts +21 -0
  225. package/dist/core/ingestion/pipeline-phases/scan.js +46 -0
  226. package/dist/core/ingestion/pipeline-phases/structure.d.ts +27 -0
  227. package/dist/core/ingestion/pipeline-phases/structure.js +35 -0
  228. package/dist/core/ingestion/pipeline-phases/tools.d.ts +20 -0
  229. package/dist/core/ingestion/pipeline-phases/tools.js +79 -0
  230. package/dist/core/ingestion/pipeline-phases/types.d.ts +79 -0
  231. package/dist/core/ingestion/pipeline-phases/types.js +37 -0
  232. package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +35 -0
  233. package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +174 -0
  234. package/dist/core/ingestion/pipeline.d.ts +18 -10
  235. package/dist/core/ingestion/pipeline.js +66 -1410
  236. package/dist/core/ingestion/process-processor.js +1 -1
  237. package/dist/core/ingestion/tree-sitter-queries.d.ts +5 -5
  238. package/dist/core/ingestion/tree-sitter-queries.js +90 -0
  239. package/dist/core/ingestion/type-env.d.ts +15 -2
  240. package/dist/core/ingestion/type-env.js +163 -102
  241. package/dist/core/ingestion/type-extractors/csharp.js +17 -0
  242. package/dist/core/ingestion/type-extractors/jvm.js +11 -0
  243. package/dist/core/ingestion/type-extractors/php.js +0 -55
  244. package/dist/core/ingestion/type-extractors/ruby.js +0 -32
  245. package/dist/core/ingestion/type-extractors/swift.js +13 -0
  246. package/dist/core/ingestion/type-extractors/types.d.ts +8 -8
  247. package/dist/core/ingestion/type-extractors/typescript.js +66 -69
  248. package/dist/core/ingestion/utils/ast-helpers.d.ts +32 -44
  249. package/dist/core/ingestion/utils/ast-helpers.js +157 -573
  250. package/dist/core/ingestion/utils/env.d.ts +10 -0
  251. package/dist/core/ingestion/utils/env.js +10 -0
  252. package/dist/core/ingestion/utils/graph-sort.d.ts +58 -0
  253. package/dist/core/ingestion/utils/graph-sort.js +100 -0
  254. package/dist/core/ingestion/utils/method-props.d.ts +32 -0
  255. package/dist/core/ingestion/utils/method-props.js +147 -0
  256. package/dist/core/ingestion/vue-sfc-extractor.d.ts +44 -0
  257. package/dist/core/ingestion/vue-sfc-extractor.js +94 -0
  258. package/dist/core/ingestion/workers/parse-worker.d.ts +31 -19
  259. package/dist/core/ingestion/workers/parse-worker.js +469 -200
  260. package/dist/core/lbug/lbug-adapter.d.ts +6 -0
  261. package/dist/core/lbug/lbug-adapter.js +134 -27
  262. package/dist/core/lbug/pool-adapter.d.ts +76 -0
  263. package/dist/core/lbug/pool-adapter.js +522 -0
  264. package/dist/core/run-analyze.d.ts +2 -0
  265. package/dist/core/run-analyze.js +1 -1
  266. package/dist/core/search/bm25-index.js +1 -1
  267. package/dist/core/tree-sitter/parser-loader.js +1 -0
  268. package/dist/core/wiki/graph-queries.js +1 -1
  269. package/dist/mcp/core/embedder.js +6 -5
  270. package/dist/mcp/core/lbug-adapter.d.ts +3 -63
  271. package/dist/mcp/core/lbug-adapter.js +3 -484
  272. package/dist/mcp/local/local-backend.d.ts +31 -2
  273. package/dist/mcp/local/local-backend.js +255 -46
  274. package/dist/mcp/resources.js +5 -4
  275. package/dist/mcp/staleness.d.ts +3 -13
  276. package/dist/mcp/staleness.js +2 -31
  277. package/dist/mcp/tools.js +80 -4
  278. package/dist/server/analyze-job.d.ts +2 -0
  279. package/dist/server/analyze-job.js +4 -0
  280. package/dist/server/api.d.ts +20 -1
  281. package/dist/server/api.js +306 -71
  282. package/dist/server/git-clone.d.ts +2 -1
  283. package/dist/server/git-clone.js +98 -5
  284. package/dist/storage/git.d.ts +13 -0
  285. package/dist/storage/git.js +25 -0
  286. package/dist/storage/repo-manager.js +1 -1
  287. package/package.json +9 -3
  288. package/scripts/patch-tree-sitter-swift.cjs +78 -0
  289. package/vendor/tree-sitter-proto/binding.gyp +30 -0
  290. package/vendor/tree-sitter-proto/bindings/node/binding.cc +20 -0
  291. package/vendor/tree-sitter-proto/bindings/node/index.d.ts +28 -0
  292. package/vendor/tree-sitter-proto/bindings/node/index.js +7 -0
  293. package/vendor/tree-sitter-proto/package.json +18 -0
  294. package/vendor/tree-sitter-proto/src/node-types.json +1145 -0
  295. package/vendor/tree-sitter-proto/src/parser.c +10149 -0
  296. package/vendor/tree-sitter-proto/src/tree_sitter/alloc.h +54 -0
  297. package/vendor/tree-sitter-proto/src/tree_sitter/array.h +291 -0
  298. package/vendor/tree-sitter-proto/src/tree_sitter/parser.h +266 -0
  299. package/dist/core/ingestion/named-binding-processor.d.ts +0 -18
  300. package/dist/core/ingestion/named-binding-processor.js +0 -42
  301. package/dist/core/ingestion/resolution-context.d.ts +0 -58
  302. package/dist/core/ingestion/resolution-context.js +0 -135
  303. package/dist/core/ingestion/symbol-table.d.ts +0 -79
  304. package/dist/core/ingestion/symbol-table.js +0 -115
@@ -0,0 +1,134 @@
1
+ import { createRequire } from 'node:module';
2
+ import { compilePatterns, runCompiledPatterns, } from '../tree-sitter-scanner.js';
3
+ /**
4
+ * Protobuf (.proto) tree-sitter plugin for gRPC contract extraction.
5
+ *
6
+ * Uses `tree-sitter-proto` (coder3101/tree-sitter-proto) as an
7
+ * optionalDependency — if the grammar is not installed (e.g. native
8
+ * compilation failed on an unusual platform), the plugin exports
9
+ * `null` and the orchestrator falls back to the existing manual
10
+ * string-sanitizing parser.
11
+ *
12
+ * The grammar is vendored in `vendor/tree-sitter-proto/` with
13
+ * parser.c regenerated against tree-sitter-cli 0.24 (ABI version 14)
14
+ * so it is compatible with the project's tree-sitter 0.25 runtime.
15
+ */
16
+ const _require = createRequire(import.meta.url);
17
+ let ProtoGrammar = null;
18
+ try {
19
+ ProtoGrammar = _require('tree-sitter-proto');
20
+ }
21
+ catch {
22
+ // Grammar not installed — PROTO_GRPC_PLUGIN will be null.
23
+ }
24
+ let PACKAGE_PATTERNS = null;
25
+ let SERVICE_PATTERNS = null;
26
+ if (ProtoGrammar) {
27
+ try {
28
+ // Validate that the grammar actually loads end-to-end: compile queries
29
+ // AND parse + walk a trivial proto file. tree-sitter's internal
30
+ // `initializeLanguageNodeClasses` can fail with a TDZ error in some
31
+ // test runners (vitest forks) when SyntaxNode isn't fully initialized
32
+ // yet. Catching that here ensures `PROTO_GRPC_PLUGIN` stays null and
33
+ // the orchestrator falls back to the manual parser.
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
+ const _Parser = _require('tree-sitter');
36
+ // Smoke-test: parse + setLanguage to verify the grammar is
37
+ // end-to-end compatible with this tree-sitter runtime.
38
+ const _testParser = new _Parser();
39
+ _testParser.setLanguage(ProtoGrammar);
40
+ _testParser.parse('service X { rpc Y (R) returns (R); }');
41
+ PACKAGE_PATTERNS = compilePatterns({
42
+ name: 'proto-package',
43
+ language: ProtoGrammar,
44
+ patterns: [
45
+ {
46
+ meta: {},
47
+ query: `(package (full_ident) @pkg)`,
48
+ },
49
+ ],
50
+ });
51
+ SERVICE_PATTERNS = compilePatterns({
52
+ name: 'proto-service',
53
+ language: ProtoGrammar,
54
+ patterns: [
55
+ {
56
+ meta: {},
57
+ query: `
58
+ (service
59
+ (service_name) @service_name
60
+ (rpc
61
+ (rpc_name) @rpc_name))
62
+ `,
63
+ },
64
+ ],
65
+ });
66
+ }
67
+ catch {
68
+ // Compilation failed (grammar ABI mismatch?) — fall back to null.
69
+ PACKAGE_PATTERNS = null;
70
+ SERVICE_PATTERNS = null;
71
+ ProtoGrammar = null;
72
+ }
73
+ }
74
+ function buildPlugin() {
75
+ if (!ProtoGrammar || !PACKAGE_PATTERNS || !SERVICE_PATTERNS)
76
+ return null;
77
+ const pkgPatterns = PACKAGE_PATTERNS;
78
+ const svcPatterns = SERVICE_PATTERNS;
79
+ return {
80
+ name: 'proto-grpc',
81
+ language: ProtoGrammar,
82
+ scan(tree) {
83
+ const out = [];
84
+ // Extract `package` declaration (first match wins).
85
+ let pkg = '';
86
+ for (const match of runCompiledPatterns(pkgPatterns, tree)) {
87
+ const pkgNode = match.captures.pkg;
88
+ if (pkgNode) {
89
+ pkg = pkgNode.text;
90
+ break;
91
+ }
92
+ }
93
+ // Extract `service → rpc` pairs. The query returns one match per
94
+ // (service, rpc) combination thanks to the nested structure.
95
+ for (const match of runCompiledPatterns(svcPatterns, tree)) {
96
+ const serviceNode = match.captures.service_name;
97
+ const rpcNode = match.captures.rpc_name;
98
+ if (!serviceNode || !rpcNode)
99
+ continue;
100
+ const serviceName = serviceNode.text;
101
+ const methodName = rpcNode.text;
102
+ out.push({
103
+ role: 'provider',
104
+ serviceName,
105
+ symbolName: `${serviceName}.${methodName}`,
106
+ source: 'proto',
107
+ methodName,
108
+ // Proto definitions are the canonical source of truth — always
109
+ // high confidence regardless of cross-referencing.
110
+ confidenceWithProto: 0.85,
111
+ confidenceWithoutProto: 0.85,
112
+ });
113
+ }
114
+ return out;
115
+ },
116
+ };
117
+ }
118
+ /**
119
+ * The proto plugin, or `null` if tree-sitter-proto is not available.
120
+ * The orchestrator checks this at import time and decides whether to
121
+ * use the tree-sitter path or the fallback manual parser.
122
+ */
123
+ export const PROTO_GRPC_PLUGIN = buildPlugin();
124
+ /** The package declaration text from a proto file's tree. */
125
+ export function extractPackageFromTree(tree) {
126
+ if (!PACKAGE_PATTERNS)
127
+ return '';
128
+ for (const match of runCompiledPatterns(PACKAGE_PATTERNS, tree)) {
129
+ const pkgNode = match.captures.pkg;
130
+ if (pkgNode)
131
+ return pkgNode.text;
132
+ }
133
+ return '';
134
+ }
@@ -0,0 +1,2 @@
1
+ import type { GrpcLanguagePlugin } from './types.js';
2
+ export declare const PYTHON_GRPC_PLUGIN: GrpcLanguagePlugin;
@@ -0,0 +1,67 @@
1
+ import Python from 'tree-sitter-python';
2
+ import { compilePatterns, runCompiledPatterns, } from '../tree-sitter-scanner.js';
3
+ /**
4
+ * Python gRPC plugin. Detects:
5
+ * - Provider: `add_XxxServicer_to_server(...)` calls (bare identifier
6
+ * or qualified attribute form `auth_pb2_grpc.add_XxxServicer_to_server`)
7
+ * - Consumer: `XxxStub(channel)` calls (bare or `auth_pb2_grpc.XxxStub`)
8
+ */
9
+ const ADD_SERVICER_RE = /^add_(\w+)Servicer_to_server$/;
10
+ const STUB_RE = /^(\w+)Stub$/;
11
+ /** Reserved names that would produce garbage service names. */
12
+ const STUB_IGNORE = new Set(['Mock', 'Test', 'Fake', 'Stub']);
13
+ // Any call whose target is either a bare identifier or an attribute
14
+ // access (`obj.method`). The plugin filters the function name in JS.
15
+ const CALL_PATTERNS = compilePatterns({
16
+ name: 'python-grpc-call',
17
+ language: Python,
18
+ patterns: [
19
+ {
20
+ meta: {},
21
+ query: `
22
+ (call
23
+ function: [
24
+ (identifier) @fn
25
+ (attribute attribute: (identifier) @fn)
26
+ ])
27
+ `,
28
+ },
29
+ ],
30
+ });
31
+ export const PYTHON_GRPC_PLUGIN = {
32
+ name: 'python-grpc',
33
+ language: Python,
34
+ scan(tree) {
35
+ const out = [];
36
+ for (const match of runCompiledPatterns(CALL_PATTERNS, tree)) {
37
+ const fnNode = match.captures.fn;
38
+ if (!fnNode)
39
+ continue;
40
+ const fnText = fnNode.text;
41
+ const addServicer = ADD_SERVICER_RE.exec(fnText);
42
+ if (addServicer) {
43
+ out.push({
44
+ role: 'provider',
45
+ serviceName: addServicer[1],
46
+ symbolName: fnText,
47
+ source: 'python_servicer',
48
+ confidenceWithProto: 0.8,
49
+ confidenceWithoutProto: 0.65,
50
+ });
51
+ continue;
52
+ }
53
+ const stubMatch = STUB_RE.exec(fnText);
54
+ if (stubMatch && !STUB_IGNORE.has(stubMatch[1])) {
55
+ out.push({
56
+ role: 'consumer',
57
+ serviceName: stubMatch[1],
58
+ symbolName: fnText,
59
+ source: 'python_stub',
60
+ confidenceWithProto: 0.75,
61
+ confidenceWithoutProto: 0.55,
62
+ });
63
+ }
64
+ }
65
+ return out;
66
+ },
67
+ };
@@ -0,0 +1,50 @@
1
+ import type Parser from 'tree-sitter';
2
+ /**
3
+ * Shared types for the grpc-extractor language plugins.
4
+ *
5
+ * Each plugin lives in its own file (java.ts, go.ts, ...) and owns the
6
+ * tree-sitter grammar import + query sources. The top-level
7
+ * `grpc-extractor.ts` orchestrator only knows about this type module
8
+ * and the plugin registry (`./index.ts`). It MUST NOT import any
9
+ * grammar or query text directly.
10
+ */
11
+ export type GrpcRole = 'provider' | 'consumer';
12
+ /**
13
+ * One raw gRPC detection produced by a plugin's `scan()` function. The
14
+ * orchestrator uses the proto map to resolve the full package-qualified
15
+ * contract id and choose a confidence based on whether the proto was
16
+ * found.
17
+ *
18
+ * Most patterns produce service-level detections; `TS @GrpcMethod` is
19
+ * the only pattern that captures an explicit `methodName`, producing
20
+ * a method-level contract (`grpc::pkg.Service/Method`).
21
+ */
22
+ export interface GrpcDetection {
23
+ role: GrpcRole;
24
+ /** Short service name, e.g. `"AuthService"`. */
25
+ serviceName: string;
26
+ /** Symbol name emitted into the contract's symbolRef. */
27
+ symbolName: string;
28
+ /** Metadata source label (goes into `meta.source`). */
29
+ source: string;
30
+ /** Explicit method name; set only by TS `@GrpcMethod`. */
31
+ methodName?: string;
32
+ /** Confidence when the proto map resolves the service. */
33
+ confidenceWithProto: number;
34
+ /** Confidence when the proto map has no entry. */
35
+ confidenceWithoutProto: number;
36
+ }
37
+ /**
38
+ * One language-scoped gRPC plugin. Plugins own the tree-sitter grammar
39
+ * and a `scan(tree)` function that returns zero or more
40
+ * `GrpcDetection`s. The plugin is free to run multiple compiled query
41
+ * bundles and walk the AST to cross-reference captures.
42
+ *
43
+ * `language` is typed `unknown` for the same reason as in
44
+ * `tree-sitter-scanner.ts`.
45
+ */
46
+ export interface GrpcLanguagePlugin {
47
+ name: string;
48
+ language: unknown;
49
+ scan(tree: Parser.Tree): GrpcDetection[];
50
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { HttpLanguagePlugin } from './types.js';
2
+ export declare const GO_HTTP_PLUGIN: HttpLanguagePlugin;
@@ -0,0 +1,215 @@
1
+ import Go from 'tree-sitter-go';
2
+ import { compilePatterns, runCompiledPatterns, unquoteLiteral, } from '../tree-sitter-scanner.js';
3
+ /**
4
+ * Go HTTP plugin. Handles:
5
+ * - gin / echo / chi framework routing — `r.GET("/path", handler)`
6
+ * - net/http stdlib — `http.HandleFunc("/path", handler)`
7
+ * - net/http consumer — `http.Get(...)`, `http.NewRequest("METHOD", ...)`
8
+ * - resty consumer — `client.R().Delete("/path")`
9
+ */
10
+ // ─── Provider: framework routing ──────────────────────────────────────
11
+ // Matches `\w+\.GET(...)` etc. (gin, echo, chi all share this shape).
12
+ // Captures the HTTP method (field name), path literal, and handler
13
+ // identifier passed as the second argument.
14
+ const FRAMEWORK_ROUTE_PATTERNS = compilePatterns({
15
+ name: 'go-framework-route',
16
+ language: Go,
17
+ patterns: [
18
+ {
19
+ meta: {},
20
+ query: `
21
+ (call_expression
22
+ function: (selector_expression
23
+ field: (field_identifier) @http_method (#match? @http_method "^(GET|POST|PUT|DELETE|PATCH)$"))
24
+ arguments: (argument_list
25
+ (interpreted_string_literal) @path
26
+ (identifier) @handler))
27
+ `,
28
+ },
29
+ ],
30
+ });
31
+ // ─── Provider: net/http `http.HandleFunc("/p", handler)` ─────────────
32
+ const HANDLE_FUNC_PATTERNS = compilePatterns({
33
+ name: 'go-handle-func',
34
+ language: Go,
35
+ patterns: [
36
+ {
37
+ meta: {},
38
+ query: `
39
+ (call_expression
40
+ function: (selector_expression
41
+ operand: (identifier) @pkg (#eq? @pkg "http")
42
+ field: (field_identifier) @fn (#eq? @fn "HandleFunc"))
43
+ arguments: (argument_list
44
+ (interpreted_string_literal) @path
45
+ (identifier) @handler))
46
+ `,
47
+ },
48
+ ],
49
+ });
50
+ // ─── Consumer: net/http stdlib Get / Post / Head ─────────────────────
51
+ const HTTP_CLIENT_METHOD_TO_HTTP = {
52
+ Get: 'GET',
53
+ Post: 'POST',
54
+ Head: 'GET', // HEAD has no body semantics we care about — treat as GET for contract matching
55
+ };
56
+ const HTTP_CLIENT_PATTERNS = compilePatterns({
57
+ name: 'go-http-client',
58
+ language: Go,
59
+ patterns: [
60
+ {
61
+ meta: {},
62
+ query: `
63
+ (call_expression
64
+ function: (selector_expression
65
+ operand: (identifier) @pkg (#eq? @pkg "http")
66
+ field: (field_identifier) @fn (#match? @fn "^(Get|Post|Head)$"))
67
+ arguments: (argument_list . (interpreted_string_literal) @path))
68
+ `,
69
+ },
70
+ ],
71
+ });
72
+ // ─── Consumer: net/http `http.NewRequest("METHOD", "/path", ...)` ────
73
+ const NEW_REQUEST_PATTERNS = compilePatterns({
74
+ name: 'go-new-request',
75
+ language: Go,
76
+ patterns: [
77
+ {
78
+ meta: {},
79
+ query: `
80
+ (call_expression
81
+ function: (selector_expression
82
+ operand: (identifier) @pkg (#eq? @pkg "http")
83
+ field: (field_identifier) @fn (#eq? @fn "NewRequest"))
84
+ arguments: (argument_list
85
+ .
86
+ (interpreted_string_literal) @http_method
87
+ (interpreted_string_literal) @path))
88
+ `,
89
+ },
90
+ ],
91
+ });
92
+ // ─── Consumer: resty `client.R().Delete("/path")` ─────────────────────
93
+ // Matches any chained call whose receiver is `something.R()` and whose
94
+ // method name is an HTTP verb. This is how go-resty's fluent API looks.
95
+ const RESTY_PATTERNS = compilePatterns({
96
+ name: 'go-resty',
97
+ language: Go,
98
+ patterns: [
99
+ {
100
+ meta: {},
101
+ query: `
102
+ (call_expression
103
+ function: (selector_expression
104
+ operand: (call_expression
105
+ function: (selector_expression
106
+ field: (field_identifier) @r (#eq? @r "R")))
107
+ field: (field_identifier) @http_method (#match? @http_method "^(Get|Post|Put|Delete|Patch)$"))
108
+ arguments: (argument_list . (interpreted_string_literal) @path))
109
+ `,
110
+ },
111
+ ],
112
+ });
113
+ export const GO_HTTP_PLUGIN = {
114
+ name: 'go-http',
115
+ language: Go,
116
+ scan(tree) {
117
+ const out = [];
118
+ // Framework providers: r.GET/POST/... with handler identifier
119
+ for (const match of runCompiledPatterns(FRAMEWORK_ROUTE_PATTERNS, tree)) {
120
+ const methodNode = match.captures.http_method;
121
+ const pathNode = match.captures.path;
122
+ const handlerNode = match.captures.handler;
123
+ if (!methodNode || !pathNode)
124
+ continue;
125
+ const path = unquoteLiteral(pathNode.text);
126
+ if (path === null)
127
+ continue;
128
+ out.push({
129
+ role: 'provider',
130
+ framework: 'go-framework',
131
+ method: methodNode.text.toUpperCase(),
132
+ path,
133
+ name: handlerNode?.text ?? null,
134
+ confidence: 0.8,
135
+ });
136
+ }
137
+ // net/http HandleFunc: default method GET
138
+ for (const match of runCompiledPatterns(HANDLE_FUNC_PATTERNS, tree)) {
139
+ const pathNode = match.captures.path;
140
+ const handlerNode = match.captures.handler;
141
+ if (!pathNode)
142
+ continue;
143
+ const path = unquoteLiteral(pathNode.text);
144
+ if (path === null)
145
+ continue;
146
+ out.push({
147
+ role: 'provider',
148
+ framework: 'go-stdlib',
149
+ method: 'GET',
150
+ path,
151
+ name: handlerNode?.text ?? null,
152
+ confidence: 0.8,
153
+ });
154
+ }
155
+ // net/http client: http.Get/Post/Head
156
+ for (const match of runCompiledPatterns(HTTP_CLIENT_PATTERNS, tree)) {
157
+ const fnNode = match.captures.fn;
158
+ const pathNode = match.captures.path;
159
+ if (!fnNode || !pathNode)
160
+ continue;
161
+ const httpMethod = HTTP_CLIENT_METHOD_TO_HTTP[fnNode.text];
162
+ if (!httpMethod)
163
+ continue;
164
+ const path = unquoteLiteral(pathNode.text);
165
+ if (path === null)
166
+ continue;
167
+ out.push({
168
+ role: 'consumer',
169
+ framework: 'go-stdlib',
170
+ method: httpMethod,
171
+ path,
172
+ name: null,
173
+ confidence: 0.7,
174
+ });
175
+ }
176
+ // net/http NewRequest
177
+ for (const match of runCompiledPatterns(NEW_REQUEST_PATTERNS, tree)) {
178
+ const methodNode = match.captures.http_method;
179
+ const pathNode = match.captures.path;
180
+ if (!methodNode || !pathNode)
181
+ continue;
182
+ const method = unquoteLiteral(methodNode.text);
183
+ const path = unquoteLiteral(pathNode.text);
184
+ if (method === null || path === null)
185
+ continue;
186
+ out.push({
187
+ role: 'consumer',
188
+ framework: 'go-stdlib',
189
+ method: method.toUpperCase(),
190
+ path,
191
+ name: null,
192
+ confidence: 0.7,
193
+ });
194
+ }
195
+ // resty
196
+ for (const match of runCompiledPatterns(RESTY_PATTERNS, tree)) {
197
+ const methodNode = match.captures.http_method;
198
+ const pathNode = match.captures.path;
199
+ if (!methodNode || !pathNode)
200
+ continue;
201
+ const path = unquoteLiteral(pathNode.text);
202
+ if (path === null)
203
+ continue;
204
+ out.push({
205
+ role: 'consumer',
206
+ framework: 'go-resty',
207
+ method: methodNode.text.toUpperCase(),
208
+ path,
209
+ name: null,
210
+ confidence: 0.7,
211
+ });
212
+ }
213
+ return out;
214
+ },
215
+ };
@@ -0,0 +1,17 @@
1
+ import type { HttpLanguagePlugin } from './types.js';
2
+ export type { HttpDetection, HttpLanguagePlugin, HttpRole } from './types.js';
3
+ /**
4
+ * Glob for files worth scanning for HTTP routes. Kept alongside the
5
+ * registry so adding a new language widens the glob in one edit.
6
+ *
7
+ * `.vue` / `.svelte` files are intentionally omitted for the source-scan
8
+ * path — they need their own grammar-aware extraction and the existing
9
+ * regex fallback for them was never very accurate. The graph-assisted
10
+ * Strategy A still handles them via the ingestion pipeline.
11
+ */
12
+ export declare const HTTP_SCAN_GLOB = "**/*.{ts,tsx,js,jsx,java,go,py,php}";
13
+ /**
14
+ * Return the HTTP plugin registered for the given file's extension,
15
+ * or `undefined` if the extension is not registered.
16
+ */
17
+ export declare function getPluginForFile(rel: string): HttpLanguagePlugin | undefined;
@@ -0,0 +1,44 @@
1
+ import * as path from 'node:path';
2
+ import { JAVA_HTTP_PLUGIN } from './java.js';
3
+ import { GO_HTTP_PLUGIN } from './go.js';
4
+ import { PYTHON_HTTP_PLUGIN } from './python.js';
5
+ import { PHP_HTTP_PLUGIN } from './php.js';
6
+ import { JAVASCRIPT_HTTP_PLUGIN, TYPESCRIPT_HTTP_PLUGIN, TSX_HTTP_PLUGIN } from './node.js';
7
+ /**
8
+ * File-extension → HTTP language plugin registry. The top-level
9
+ * orchestrator (`http-route-extractor.ts`) looks up the plugin for each
10
+ * file it visits and delegates the tree-sitter scanning to the plugin.
11
+ *
12
+ * Keys are lowercase extensions including the leading dot. To add a
13
+ * new language, drop a `http-patterns/<lang>.ts` that exports a
14
+ * `HttpLanguagePlugin`, import it here and register the extension(s).
15
+ * No edits to `http-route-extractor.ts` are required.
16
+ */
17
+ const REGISTRY = {
18
+ '.java': JAVA_HTTP_PLUGIN,
19
+ '.go': GO_HTTP_PLUGIN,
20
+ '.py': PYTHON_HTTP_PLUGIN,
21
+ '.php': PHP_HTTP_PLUGIN,
22
+ '.js': JAVASCRIPT_HTTP_PLUGIN,
23
+ '.jsx': JAVASCRIPT_HTTP_PLUGIN,
24
+ '.ts': TYPESCRIPT_HTTP_PLUGIN,
25
+ '.tsx': TSX_HTTP_PLUGIN,
26
+ };
27
+ /**
28
+ * Glob for files worth scanning for HTTP routes. Kept alongside the
29
+ * registry so adding a new language widens the glob in one edit.
30
+ *
31
+ * `.vue` / `.svelte` files are intentionally omitted for the source-scan
32
+ * path — they need their own grammar-aware extraction and the existing
33
+ * regex fallback for them was never very accurate. The graph-assisted
34
+ * Strategy A still handles them via the ingestion pipeline.
35
+ */
36
+ export const HTTP_SCAN_GLOB = '**/*.{ts,tsx,js,jsx,java,go,py,php}';
37
+ /**
38
+ * Return the HTTP plugin registered for the given file's extension,
39
+ * or `undefined` if the extension is not registered.
40
+ */
41
+ export function getPluginForFile(rel) {
42
+ const ext = path.extname(rel).toLowerCase();
43
+ return REGISTRY[ext];
44
+ }
@@ -0,0 +1,2 @@
1
+ import type { HttpLanguagePlugin } from './types.js';
2
+ export declare const JAVA_HTTP_PLUGIN: HttpLanguagePlugin;