@opencodehub/ingestion 0.1.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 (563) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +69 -0
  3. package/dist/extract/index.d.ts +8 -0
  4. package/dist/extract/index.d.ts.map +1 -0
  5. package/dist/extract/index.js +6 -0
  6. package/dist/extract/index.js.map +1 -0
  7. package/dist/extract/orm-detector.d.ts +19 -0
  8. package/dist/extract/orm-detector.d.ts.map +1 -0
  9. package/dist/extract/orm-detector.js +209 -0
  10. package/dist/extract/orm-detector.js.map +1 -0
  11. package/dist/extract/property-access.d.ts +76 -0
  12. package/dist/extract/property-access.d.ts.map +1 -0
  13. package/dist/extract/property-access.js +260 -0
  14. package/dist/extract/property-access.js.map +1 -0
  15. package/dist/extract/receiver-resolver.d.ts +86 -0
  16. package/dist/extract/receiver-resolver.d.ts.map +1 -0
  17. package/dist/extract/receiver-resolver.js +77 -0
  18. package/dist/extract/receiver-resolver.js.map +1 -0
  19. package/dist/extract/route-detector-java.d.ts +29 -0
  20. package/dist/extract/route-detector-java.d.ts.map +1 -0
  21. package/dist/extract/route-detector-java.js +190 -0
  22. package/dist/extract/route-detector-java.js.map +1 -0
  23. package/dist/extract/route-detector-nestjs.d.ts +30 -0
  24. package/dist/extract/route-detector-nestjs.d.ts.map +1 -0
  25. package/dist/extract/route-detector-nestjs.js +134 -0
  26. package/dist/extract/route-detector-nestjs.js.map +1 -0
  27. package/dist/extract/route-detector-python.d.ts +28 -0
  28. package/dist/extract/route-detector-python.d.ts.map +1 -0
  29. package/dist/extract/route-detector-python.js +100 -0
  30. package/dist/extract/route-detector-python.js.map +1 -0
  31. package/dist/extract/route-detector-rails.d.ts +28 -0
  32. package/dist/extract/route-detector-rails.d.ts.map +1 -0
  33. package/dist/extract/route-detector-rails.js +162 -0
  34. package/dist/extract/route-detector-rails.js.map +1 -0
  35. package/dist/extract/route-detector.d.ts +45 -0
  36. package/dist/extract/route-detector.d.ts.map +1 -0
  37. package/dist/extract/route-detector.js +467 -0
  38. package/dist/extract/route-detector.js.map +1 -0
  39. package/dist/extract/tool-detector.d.ts +26 -0
  40. package/dist/extract/tool-detector.d.ts.map +1 -0
  41. package/dist/extract/tool-detector.js +364 -0
  42. package/dist/extract/tool-detector.js.map +1 -0
  43. package/dist/extract/types.d.ts +89 -0
  44. package/dist/extract/types.d.ts.map +1 -0
  45. package/dist/extract/types.js +11 -0
  46. package/dist/extract/types.js.map +1 -0
  47. package/dist/index.d.ts +10 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +10 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/parse/cobol-regex.d.ts +85 -0
  52. package/dist/parse/cobol-regex.d.ts.map +1 -0
  53. package/dist/parse/cobol-regex.js +355 -0
  54. package/dist/parse/cobol-regex.js.map +1 -0
  55. package/dist/parse/grammar-registry.d.ts +115 -0
  56. package/dist/parse/grammar-registry.d.ts.map +1 -0
  57. package/dist/parse/grammar-registry.js +278 -0
  58. package/dist/parse/grammar-registry.js.map +1 -0
  59. package/dist/parse/index.d.ts +14 -0
  60. package/dist/parse/index.d.ts.map +1 -0
  61. package/dist/parse/index.js +10 -0
  62. package/dist/parse/index.js.map +1 -0
  63. package/dist/parse/language-detector.d.ts +17 -0
  64. package/dist/parse/language-detector.d.ts.map +1 -0
  65. package/dist/parse/language-detector.js +104 -0
  66. package/dist/parse/language-detector.js.map +1 -0
  67. package/dist/parse/parse-worker.d.ts +24 -0
  68. package/dist/parse/parse-worker.d.ts.map +1 -0
  69. package/dist/parse/parse-worker.js +230 -0
  70. package/dist/parse/parse-worker.js.map +1 -0
  71. package/dist/parse/types.d.ts +49 -0
  72. package/dist/parse/types.d.ts.map +1 -0
  73. package/dist/parse/types.js +11 -0
  74. package/dist/parse/types.js.map +1 -0
  75. package/dist/parse/unified-queries.d.ts +37 -0
  76. package/dist/parse/unified-queries.d.ts.map +1 -0
  77. package/dist/parse/unified-queries.js +623 -0
  78. package/dist/parse/unified-queries.js.map +1 -0
  79. package/dist/parse/wasm-fallback.d.ts +88 -0
  80. package/dist/parse/wasm-fallback.d.ts.map +1 -0
  81. package/dist/parse/wasm-fallback.js +258 -0
  82. package/dist/parse/wasm-fallback.js.map +1 -0
  83. package/dist/parse/worker-pool.d.ts +48 -0
  84. package/dist/parse/worker-pool.d.ts.map +1 -0
  85. package/dist/parse/worker-pool.js +97 -0
  86. package/dist/parse/worker-pool.js.map +1 -0
  87. package/dist/pipeline/dep-parsers/go.d.ts +25 -0
  88. package/dist/pipeline/dep-parsers/go.d.ts.map +1 -0
  89. package/dist/pipeline/dep-parsers/go.js +146 -0
  90. package/dist/pipeline/dep-parsers/go.js.map +1 -0
  91. package/dist/pipeline/dep-parsers/index.d.ts +17 -0
  92. package/dist/pipeline/dep-parsers/index.d.ts.map +1 -0
  93. package/dist/pipeline/dep-parsers/index.js +16 -0
  94. package/dist/pipeline/dep-parsers/index.js.map +1 -0
  95. package/dist/pipeline/dep-parsers/maven.d.ts +24 -0
  96. package/dist/pipeline/dep-parsers/maven.d.ts.map +1 -0
  97. package/dist/pipeline/dep-parsers/maven.js +131 -0
  98. package/dist/pipeline/dep-parsers/maven.js.map +1 -0
  99. package/dist/pipeline/dep-parsers/npm.d.ts +30 -0
  100. package/dist/pipeline/dep-parsers/npm.d.ts.map +1 -0
  101. package/dist/pipeline/dep-parsers/npm.js +309 -0
  102. package/dist/pipeline/dep-parsers/npm.js.map +1 -0
  103. package/dist/pipeline/dep-parsers/nuget.d.ts +24 -0
  104. package/dist/pipeline/dep-parsers/nuget.d.ts.map +1 -0
  105. package/dist/pipeline/dep-parsers/nuget.js +178 -0
  106. package/dist/pipeline/dep-parsers/nuget.js.map +1 -0
  107. package/dist/pipeline/dep-parsers/python.d.ts +21 -0
  108. package/dist/pipeline/dep-parsers/python.d.ts.map +1 -0
  109. package/dist/pipeline/dep-parsers/python.js +369 -0
  110. package/dist/pipeline/dep-parsers/python.js.map +1 -0
  111. package/dist/pipeline/dep-parsers/rust.d.ts +18 -0
  112. package/dist/pipeline/dep-parsers/rust.d.ts.map +1 -0
  113. package/dist/pipeline/dep-parsers/rust.js +134 -0
  114. package/dist/pipeline/dep-parsers/rust.js.map +1 -0
  115. package/dist/pipeline/dep-parsers/spdx-normalize.d.ts +15 -0
  116. package/dist/pipeline/dep-parsers/spdx-normalize.d.ts.map +1 -0
  117. package/dist/pipeline/dep-parsers/spdx-normalize.js +31 -0
  118. package/dist/pipeline/dep-parsers/spdx-normalize.js.map +1 -0
  119. package/dist/pipeline/dep-parsers/types.d.ts +63 -0
  120. package/dist/pipeline/dep-parsers/types.d.ts.map +1 -0
  121. package/dist/pipeline/dep-parsers/types.js +56 -0
  122. package/dist/pipeline/dep-parsers/types.js.map +1 -0
  123. package/dist/pipeline/gitignore-stack.d.ts +44 -0
  124. package/dist/pipeline/gitignore-stack.d.ts.map +1 -0
  125. package/dist/pipeline/gitignore-stack.js +69 -0
  126. package/dist/pipeline/gitignore-stack.js.map +1 -0
  127. package/dist/pipeline/gitignore.d.ts +67 -0
  128. package/dist/pipeline/gitignore.d.ts.map +1 -0
  129. package/dist/pipeline/gitignore.js +210 -0
  130. package/dist/pipeline/gitignore.js.map +1 -0
  131. package/dist/pipeline/index.d.ts +53 -0
  132. package/dist/pipeline/index.d.ts.map +1 -0
  133. package/dist/pipeline/index.js +29 -0
  134. package/dist/pipeline/index.js.map +1 -0
  135. package/dist/pipeline/orchestrator.d.ts +105 -0
  136. package/dist/pipeline/orchestrator.d.ts.map +1 -0
  137. package/dist/pipeline/orchestrator.js +175 -0
  138. package/dist/pipeline/orchestrator.js.map +1 -0
  139. package/dist/pipeline/ownership-helpers/drift.d.ts +41 -0
  140. package/dist/pipeline/ownership-helpers/drift.d.ts.map +1 -0
  141. package/dist/pipeline/ownership-helpers/drift.js +122 -0
  142. package/dist/pipeline/ownership-helpers/drift.js.map +1 -0
  143. package/dist/pipeline/ownership-helpers/gini-community.d.ts +24 -0
  144. package/dist/pipeline/ownership-helpers/gini-community.d.ts.map +1 -0
  145. package/dist/pipeline/ownership-helpers/gini-community.js +32 -0
  146. package/dist/pipeline/ownership-helpers/gini-community.js.map +1 -0
  147. package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts +71 -0
  148. package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts.map +1 -0
  149. package/dist/pipeline/ownership-helpers/git-blame-batcher.js +178 -0
  150. package/dist/pipeline/ownership-helpers/git-blame-batcher.js.map +1 -0
  151. package/dist/pipeline/ownership-helpers/line-overlap.d.ts +35 -0
  152. package/dist/pipeline/ownership-helpers/line-overlap.d.ts.map +1 -0
  153. package/dist/pipeline/ownership-helpers/line-overlap.js +62 -0
  154. package/dist/pipeline/ownership-helpers/line-overlap.js.map +1 -0
  155. package/dist/pipeline/ownership-helpers/orphan.d.ts +73 -0
  156. package/dist/pipeline/ownership-helpers/orphan.d.ts.map +1 -0
  157. package/dist/pipeline/ownership-helpers/orphan.js +117 -0
  158. package/dist/pipeline/ownership-helpers/orphan.js.map +1 -0
  159. package/dist/pipeline/phases/accesses.d.ts +44 -0
  160. package/dist/pipeline/phases/accesses.d.ts.map +1 -0
  161. package/dist/pipeline/phases/accesses.js +194 -0
  162. package/dist/pipeline/phases/accesses.js.map +1 -0
  163. package/dist/pipeline/phases/annotate.d.ts +28 -0
  164. package/dist/pipeline/phases/annotate.d.ts.map +1 -0
  165. package/dist/pipeline/phases/annotate.js +60 -0
  166. package/dist/pipeline/phases/annotate.js.map +1 -0
  167. package/dist/pipeline/phases/cochange.d.ts +42 -0
  168. package/dist/pipeline/phases/cochange.d.ts.map +1 -0
  169. package/dist/pipeline/phases/cochange.js +0 -0
  170. package/dist/pipeline/phases/cochange.js.map +1 -0
  171. package/dist/pipeline/phases/communities.d.ts +34 -0
  172. package/dist/pipeline/phases/communities.d.ts.map +1 -0
  173. package/dist/pipeline/phases/communities.js +412 -0
  174. package/dist/pipeline/phases/communities.js.map +1 -0
  175. package/dist/pipeline/phases/complexity.d.ts +50 -0
  176. package/dist/pipeline/phases/complexity.d.ts.map +1 -0
  177. package/dist/pipeline/phases/complexity.js +794 -0
  178. package/dist/pipeline/phases/complexity.js.map +1 -0
  179. package/dist/pipeline/phases/confidence-demote.d.ts +23 -0
  180. package/dist/pipeline/phases/confidence-demote.d.ts.map +1 -0
  181. package/dist/pipeline/phases/confidence-demote.js +113 -0
  182. package/dist/pipeline/phases/confidence-demote.js.map +1 -0
  183. package/dist/pipeline/phases/content-cache.d.ts +166 -0
  184. package/dist/pipeline/phases/content-cache.d.ts.map +1 -0
  185. package/dist/pipeline/phases/content-cache.js +323 -0
  186. package/dist/pipeline/phases/content-cache.js.map +1 -0
  187. package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts +25 -0
  188. package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts.map +1 -0
  189. package/dist/pipeline/phases/coverage-parsers/cobertura.js +139 -0
  190. package/dist/pipeline/phases/coverage-parsers/cobertura.js.map +1 -0
  191. package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts +25 -0
  192. package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts.map +1 -0
  193. package/dist/pipeline/phases/coverage-parsers/coverage-py.js +51 -0
  194. package/dist/pipeline/phases/coverage-parsers/coverage-py.js.map +1 -0
  195. package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts +32 -0
  196. package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts.map +1 -0
  197. package/dist/pipeline/phases/coverage-parsers/jacoco.js +98 -0
  198. package/dist/pipeline/phases/coverage-parsers/jacoco.js.map +1 -0
  199. package/dist/pipeline/phases/coverage-parsers/lcov.d.ts +21 -0
  200. package/dist/pipeline/phases/coverage-parsers/lcov.d.ts.map +1 -0
  201. package/dist/pipeline/phases/coverage-parsers/lcov.js +104 -0
  202. package/dist/pipeline/phases/coverage-parsers/lcov.js.map +1 -0
  203. package/dist/pipeline/phases/coverage-parsers/types.d.ts +27 -0
  204. package/dist/pipeline/phases/coverage-parsers/types.d.ts.map +1 -0
  205. package/dist/pipeline/phases/coverage-parsers/types.js +39 -0
  206. package/dist/pipeline/phases/coverage-parsers/types.js.map +1 -0
  207. package/dist/pipeline/phases/coverage.d.ts +39 -0
  208. package/dist/pipeline/phases/coverage.d.ts.map +1 -0
  209. package/dist/pipeline/phases/coverage.js +154 -0
  210. package/dist/pipeline/phases/coverage.js.map +1 -0
  211. package/dist/pipeline/phases/cross-file.d.ts +40 -0
  212. package/dist/pipeline/phases/cross-file.d.ts.map +1 -0
  213. package/dist/pipeline/phases/cross-file.js +411 -0
  214. package/dist/pipeline/phases/cross-file.js.map +1 -0
  215. package/dist/pipeline/phases/dead-code.d.ts +28 -0
  216. package/dist/pipeline/phases/dead-code.d.ts.map +1 -0
  217. package/dist/pipeline/phases/dead-code.js +157 -0
  218. package/dist/pipeline/phases/dead-code.js.map +1 -0
  219. package/dist/pipeline/phases/default-set.d.ts +24 -0
  220. package/dist/pipeline/phases/default-set.d.ts.map +1 -0
  221. package/dist/pipeline/phases/default-set.js +133 -0
  222. package/dist/pipeline/phases/default-set.js.map +1 -0
  223. package/dist/pipeline/phases/dependencies.d.ts +59 -0
  224. package/dist/pipeline/phases/dependencies.d.ts.map +1 -0
  225. package/dist/pipeline/phases/dependencies.js +281 -0
  226. package/dist/pipeline/phases/dependencies.js.map +1 -0
  227. package/dist/pipeline/phases/embedder-pool.d.ts +31 -0
  228. package/dist/pipeline/phases/embedder-pool.d.ts.map +1 -0
  229. package/dist/pipeline/phases/embedder-pool.js +79 -0
  230. package/dist/pipeline/phases/embedder-pool.js.map +1 -0
  231. package/dist/pipeline/phases/embedder-worker.d.ts +28 -0
  232. package/dist/pipeline/phases/embedder-worker.d.ts.map +1 -0
  233. package/dist/pipeline/phases/embedder-worker.js +43 -0
  234. package/dist/pipeline/phases/embedder-worker.js.map +1 -0
  235. package/dist/pipeline/phases/embeddings.d.ts +117 -0
  236. package/dist/pipeline/phases/embeddings.d.ts.map +1 -0
  237. package/dist/pipeline/phases/embeddings.js +697 -0
  238. package/dist/pipeline/phases/embeddings.js.map +1 -0
  239. package/dist/pipeline/phases/fetches.d.ts +47 -0
  240. package/dist/pipeline/phases/fetches.d.ts.map +1 -0
  241. package/dist/pipeline/phases/fetches.js +207 -0
  242. package/dist/pipeline/phases/fetches.js.map +1 -0
  243. package/dist/pipeline/phases/incremental-helper.d.ts +96 -0
  244. package/dist/pipeline/phases/incremental-helper.d.ts.map +1 -0
  245. package/dist/pipeline/phases/incremental-helper.js +125 -0
  246. package/dist/pipeline/phases/incremental-helper.js.map +1 -0
  247. package/dist/pipeline/phases/incremental-scope.d.ts +67 -0
  248. package/dist/pipeline/phases/incremental-scope.d.ts.map +1 -0
  249. package/dist/pipeline/phases/incremental-scope.js +225 -0
  250. package/dist/pipeline/phases/incremental-scope.js.map +1 -0
  251. package/dist/pipeline/phases/markdown.d.ts +29 -0
  252. package/dist/pipeline/phases/markdown.d.ts.map +1 -0
  253. package/dist/pipeline/phases/markdown.js +298 -0
  254. package/dist/pipeline/phases/markdown.js.map +1 -0
  255. package/dist/pipeline/phases/mro.d.ts +24 -0
  256. package/dist/pipeline/phases/mro.d.ts.map +1 -0
  257. package/dist/pipeline/phases/mro.js +303 -0
  258. package/dist/pipeline/phases/mro.js.map +1 -0
  259. package/dist/pipeline/phases/openapi.d.ts +52 -0
  260. package/dist/pipeline/phases/openapi.d.ts.map +1 -0
  261. package/dist/pipeline/phases/openapi.js +285 -0
  262. package/dist/pipeline/phases/openapi.js.map +1 -0
  263. package/dist/pipeline/phases/orm.d.ts +26 -0
  264. package/dist/pipeline/phases/orm.d.ts.map +1 -0
  265. package/dist/pipeline/phases/orm.js +183 -0
  266. package/dist/pipeline/phases/orm.js.map +1 -0
  267. package/dist/pipeline/phases/ownership.d.ts +88 -0
  268. package/dist/pipeline/phases/ownership.d.ts.map +1 -0
  269. package/dist/pipeline/phases/ownership.js +479 -0
  270. package/dist/pipeline/phases/ownership.js.map +1 -0
  271. package/dist/pipeline/phases/parse.d.ts +63 -0
  272. package/dist/pipeline/phases/parse.d.ts.map +1 -0
  273. package/dist/pipeline/phases/parse.js +994 -0
  274. package/dist/pipeline/phases/parse.js.map +1 -0
  275. package/dist/pipeline/phases/processes.d.ts +47 -0
  276. package/dist/pipeline/phases/processes.d.ts.map +1 -0
  277. package/dist/pipeline/phases/processes.js +620 -0
  278. package/dist/pipeline/phases/processes.js.map +1 -0
  279. package/dist/pipeline/phases/profile.d.ts +33 -0
  280. package/dist/pipeline/phases/profile.d.ts.map +1 -0
  281. package/dist/pipeline/phases/profile.js +91 -0
  282. package/dist/pipeline/phases/profile.js.map +1 -0
  283. package/dist/pipeline/phases/repo-node.d.ts +112 -0
  284. package/dist/pipeline/phases/repo-node.d.ts.map +1 -0
  285. package/dist/pipeline/phases/repo-node.js +272 -0
  286. package/dist/pipeline/phases/repo-node.js.map +1 -0
  287. package/dist/pipeline/phases/risk-snapshot.d.ts +34 -0
  288. package/dist/pipeline/phases/risk-snapshot.d.ts.map +1 -0
  289. package/dist/pipeline/phases/risk-snapshot.js +63 -0
  290. package/dist/pipeline/phases/risk-snapshot.js.map +1 -0
  291. package/dist/pipeline/phases/routes.d.ts +31 -0
  292. package/dist/pipeline/phases/routes.d.ts.map +1 -0
  293. package/dist/pipeline/phases/routes.js +262 -0
  294. package/dist/pipeline/phases/routes.js.map +1 -0
  295. package/dist/pipeline/phases/sbom.d.ts +45 -0
  296. package/dist/pipeline/phases/sbom.d.ts.map +1 -0
  297. package/dist/pipeline/phases/sbom.js +289 -0
  298. package/dist/pipeline/phases/sbom.js.map +1 -0
  299. package/dist/pipeline/phases/scan.d.ts +54 -0
  300. package/dist/pipeline/phases/scan.d.ts.map +1 -0
  301. package/dist/pipeline/phases/scan.js +340 -0
  302. package/dist/pipeline/phases/scan.js.map +1 -0
  303. package/dist/pipeline/phases/scip-index.d.ts +54 -0
  304. package/dist/pipeline/phases/scip-index.d.ts.map +1 -0
  305. package/dist/pipeline/phases/scip-index.js +469 -0
  306. package/dist/pipeline/phases/scip-index.js.map +1 -0
  307. package/dist/pipeline/phases/structure.d.ts +21 -0
  308. package/dist/pipeline/phases/structure.d.ts.map +1 -0
  309. package/dist/pipeline/phases/structure.js +115 -0
  310. package/dist/pipeline/phases/structure.js.map +1 -0
  311. package/dist/pipeline/phases/summarize.d.ts +126 -0
  312. package/dist/pipeline/phases/summarize.d.ts.map +1 -0
  313. package/dist/pipeline/phases/summarize.js +401 -0
  314. package/dist/pipeline/phases/summarize.js.map +1 -0
  315. package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts +42 -0
  316. package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts.map +1 -0
  317. package/dist/pipeline/phases/temporal-helpers/branch-divergence.js +96 -0
  318. package/dist/pipeline/phases/temporal-helpers/branch-divergence.js.map +1 -0
  319. package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts +22 -0
  320. package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts.map +1 -0
  321. package/dist/pipeline/phases/temporal-helpers/churn-decay.js +32 -0
  322. package/dist/pipeline/phases/temporal-helpers/churn-decay.js.map +1 -0
  323. package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts +21 -0
  324. package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts.map +1 -0
  325. package/dist/pipeline/phases/temporal-helpers/conventional-commits.js +37 -0
  326. package/dist/pipeline/phases/temporal-helpers/conventional-commits.js.map +1 -0
  327. package/dist/pipeline/phases/temporal-helpers/gini.d.ts +32 -0
  328. package/dist/pipeline/phases/temporal-helpers/gini.d.ts.map +1 -0
  329. package/dist/pipeline/phases/temporal-helpers/gini.js +78 -0
  330. package/dist/pipeline/phases/temporal-helpers/gini.js.map +1 -0
  331. package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts +14 -0
  332. package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts.map +1 -0
  333. package/dist/pipeline/phases/temporal-helpers/revert-detect.js +25 -0
  334. package/dist/pipeline/phases/temporal-helpers/revert-detect.js.map +1 -0
  335. package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts +18 -0
  336. package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts.map +1 -0
  337. package/dist/pipeline/phases/temporal-helpers/test-pair.js +119 -0
  338. package/dist/pipeline/phases/temporal-helpers/test-pair.js.map +1 -0
  339. package/dist/pipeline/phases/temporal.d.ts +65 -0
  340. package/dist/pipeline/phases/temporal.d.ts.map +1 -0
  341. package/dist/pipeline/phases/temporal.js +621 -0
  342. package/dist/pipeline/phases/temporal.js.map +1 -0
  343. package/dist/pipeline/phases/tools.d.ts +21 -0
  344. package/dist/pipeline/phases/tools.d.ts.map +1 -0
  345. package/dist/pipeline/phases/tools.js +118 -0
  346. package/dist/pipeline/phases/tools.js.map +1 -0
  347. package/dist/pipeline/profile-detectors/api-contracts.d.ts +18 -0
  348. package/dist/pipeline/profile-detectors/api-contracts.d.ts.map +1 -0
  349. package/dist/pipeline/profile-detectors/api-contracts.js +78 -0
  350. package/dist/pipeline/profile-detectors/api-contracts.js.map +1 -0
  351. package/dist/pipeline/profile-detectors/framework-detector.d.ts +11 -0
  352. package/dist/pipeline/profile-detectors/framework-detector.d.ts.map +1 -0
  353. package/dist/pipeline/profile-detectors/framework-detector.js +11 -0
  354. package/dist/pipeline/profile-detectors/framework-detector.js.map +1 -0
  355. package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts +7 -0
  356. package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts.map +1 -0
  357. package/dist/pipeline/profile-detectors/frameworks-catalog.js +7 -0
  358. package/dist/pipeline/profile-detectors/frameworks-catalog.js.map +1 -0
  359. package/dist/pipeline/profile-detectors/frameworks.d.ts +7 -0
  360. package/dist/pipeline/profile-detectors/frameworks.d.ts.map +1 -0
  361. package/dist/pipeline/profile-detectors/frameworks.js +7 -0
  362. package/dist/pipeline/profile-detectors/frameworks.js.map +1 -0
  363. package/dist/pipeline/profile-detectors/iac.d.ts +22 -0
  364. package/dist/pipeline/profile-detectors/iac.d.ts.map +1 -0
  365. package/dist/pipeline/profile-detectors/iac.js +97 -0
  366. package/dist/pipeline/profile-detectors/iac.js.map +1 -0
  367. package/dist/pipeline/profile-detectors/languages.d.ts +18 -0
  368. package/dist/pipeline/profile-detectors/languages.d.ts.map +1 -0
  369. package/dist/pipeline/profile-detectors/languages.js +60 -0
  370. package/dist/pipeline/profile-detectors/languages.js.map +1 -0
  371. package/dist/pipeline/profile-detectors/manifests.d.ts +7 -0
  372. package/dist/pipeline/profile-detectors/manifests.d.ts.map +1 -0
  373. package/dist/pipeline/profile-detectors/manifests.js +7 -0
  374. package/dist/pipeline/profile-detectors/manifests.js.map +1 -0
  375. package/dist/pipeline/profile-detectors/src-dirs.d.ts +17 -0
  376. package/dist/pipeline/profile-detectors/src-dirs.d.ts.map +1 -0
  377. package/dist/pipeline/profile-detectors/src-dirs.js +89 -0
  378. package/dist/pipeline/profile-detectors/src-dirs.js.map +1 -0
  379. package/dist/pipeline/profile-detectors/variant-detectors.d.ts +7 -0
  380. package/dist/pipeline/profile-detectors/variant-detectors.d.ts.map +1 -0
  381. package/dist/pipeline/profile-detectors/variant-detectors.js +7 -0
  382. package/dist/pipeline/profile-detectors/variant-detectors.js.map +1 -0
  383. package/dist/pipeline/runner.d.ts +54 -0
  384. package/dist/pipeline/runner.d.ts.map +1 -0
  385. package/dist/pipeline/runner.js +247 -0
  386. package/dist/pipeline/runner.js.map +1 -0
  387. package/dist/pipeline/types.d.ts +235 -0
  388. package/dist/pipeline/types.d.ts.map +1 -0
  389. package/dist/pipeline/types.js +15 -0
  390. package/dist/pipeline/types.js.map +1 -0
  391. package/dist/providers/c.d.ts +3 -0
  392. package/dist/providers/c.d.ts.map +1 -0
  393. package/dist/providers/c.js +162 -0
  394. package/dist/providers/c.js.map +1 -0
  395. package/dist/providers/cobol.d.ts +19 -0
  396. package/dist/providers/cobol.d.ts.map +1 -0
  397. package/dist/providers/cobol.js +44 -0
  398. package/dist/providers/cobol.js.map +1 -0
  399. package/dist/providers/cpp.d.ts +3 -0
  400. package/dist/providers/cpp.d.ts.map +1 -0
  401. package/dist/providers/cpp.js +200 -0
  402. package/dist/providers/cpp.js.map +1 -0
  403. package/dist/providers/csharp.d.ts +3 -0
  404. package/dist/providers/csharp.d.ts.map +1 -0
  405. package/dist/providers/csharp.js +292 -0
  406. package/dist/providers/csharp.js.map +1 -0
  407. package/dist/providers/dart.d.ts +3 -0
  408. package/dist/providers/dart.d.ts.map +1 -0
  409. package/dist/providers/dart.js +214 -0
  410. package/dist/providers/dart.js.map +1 -0
  411. package/dist/providers/definition-ids.d.ts +18 -0
  412. package/dist/providers/definition-ids.d.ts.map +1 -0
  413. package/dist/providers/definition-ids.js +23 -0
  414. package/dist/providers/definition-ids.js.map +1 -0
  415. package/dist/providers/extract-helpers.d.ts +60 -0
  416. package/dist/providers/extract-helpers.d.ts.map +1 -0
  417. package/dist/providers/extract-helpers.js +296 -0
  418. package/dist/providers/extract-helpers.js.map +1 -0
  419. package/dist/providers/extraction-types.d.ts +85 -0
  420. package/dist/providers/extraction-types.d.ts.map +1 -0
  421. package/dist/providers/extraction-types.js +13 -0
  422. package/dist/providers/extraction-types.js.map +1 -0
  423. package/dist/providers/go.d.ts +3 -0
  424. package/dist/providers/go.d.ts.map +1 -0
  425. package/dist/providers/go.js +359 -0
  426. package/dist/providers/go.js.map +1 -0
  427. package/dist/providers/http-detect.d.ts +44 -0
  428. package/dist/providers/http-detect.d.ts.map +1 -0
  429. package/dist/providers/http-detect.js +307 -0
  430. package/dist/providers/http-detect.js.map +1 -0
  431. package/dist/providers/index.d.ts +38 -0
  432. package/dist/providers/index.d.ts.map +1 -0
  433. package/dist/providers/index.js +33 -0
  434. package/dist/providers/index.js.map +1 -0
  435. package/dist/providers/java.d.ts +3 -0
  436. package/dist/providers/java.d.ts.map +1 -0
  437. package/dist/providers/java.js +259 -0
  438. package/dist/providers/java.js.map +1 -0
  439. package/dist/providers/javascript.d.ts +3 -0
  440. package/dist/providers/javascript.d.ts.map +1 -0
  441. package/dist/providers/javascript.js +139 -0
  442. package/dist/providers/javascript.js.map +1 -0
  443. package/dist/providers/kotlin.d.ts +3 -0
  444. package/dist/providers/kotlin.d.ts.map +1 -0
  445. package/dist/providers/kotlin.js +175 -0
  446. package/dist/providers/kotlin.js.map +1 -0
  447. package/dist/providers/php.d.ts +3 -0
  448. package/dist/providers/php.d.ts.map +1 -0
  449. package/dist/providers/php.js +218 -0
  450. package/dist/providers/php.js.map +1 -0
  451. package/dist/providers/python-accesses.d.ts +9 -0
  452. package/dist/providers/python-accesses.d.ts.map +1 -0
  453. package/dist/providers/python-accesses.js +22 -0
  454. package/dist/providers/python-accesses.js.map +1 -0
  455. package/dist/providers/python.d.ts +3 -0
  456. package/dist/providers/python.d.ts.map +1 -0
  457. package/dist/providers/python.js +323 -0
  458. package/dist/providers/python.js.map +1 -0
  459. package/dist/providers/registry.d.ts +4 -0
  460. package/dist/providers/registry.d.ts.map +1 -0
  461. package/dist/providers/registry.js +46 -0
  462. package/dist/providers/registry.js.map +1 -0
  463. package/dist/providers/resolution/c3.d.ts +6 -0
  464. package/dist/providers/resolution/c3.d.ts.map +1 -0
  465. package/dist/providers/resolution/c3.js +76 -0
  466. package/dist/providers/resolution/c3.js.map +1 -0
  467. package/dist/providers/resolution/context.d.ts +38 -0
  468. package/dist/providers/resolution/context.d.ts.map +1 -0
  469. package/dist/providers/resolution/context.js +45 -0
  470. package/dist/providers/resolution/context.js.map +1 -0
  471. package/dist/providers/resolution/first-wins.d.ts +3 -0
  472. package/dist/providers/resolution/first-wins.d.ts.map +1 -0
  473. package/dist/providers/resolution/first-wins.js +27 -0
  474. package/dist/providers/resolution/first-wins.js.map +1 -0
  475. package/dist/providers/resolution/mro.d.ts +16 -0
  476. package/dist/providers/resolution/mro.d.ts.map +1 -0
  477. package/dist/providers/resolution/mro.js +14 -0
  478. package/dist/providers/resolution/mro.js.map +1 -0
  479. package/dist/providers/resolution/none.d.ts +3 -0
  480. package/dist/providers/resolution/none.d.ts.map +1 -0
  481. package/dist/providers/resolution/none.js +11 -0
  482. package/dist/providers/resolution/none.js.map +1 -0
  483. package/dist/providers/resolution/python-all-filter.d.ts +25 -0
  484. package/dist/providers/resolution/python-all-filter.d.ts.map +1 -0
  485. package/dist/providers/resolution/python-all-filter.js +64 -0
  486. package/dist/providers/resolution/python-all-filter.js.map +1 -0
  487. package/dist/providers/resolution/resolver-strategy.d.ts +42 -0
  488. package/dist/providers/resolution/resolver-strategy.d.ts.map +1 -0
  489. package/dist/providers/resolution/resolver-strategy.js +50 -0
  490. package/dist/providers/resolution/resolver-strategy.js.map +1 -0
  491. package/dist/providers/resolution/single-inheritance.d.ts +3 -0
  492. package/dist/providers/resolution/single-inheritance.d.ts.map +1 -0
  493. package/dist/providers/resolution/single-inheritance.js +21 -0
  494. package/dist/providers/resolution/single-inheritance.js.map +1 -0
  495. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts +16 -0
  496. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts.map +1 -0
  497. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js +50 -0
  498. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js.map +1 -0
  499. package/dist/providers/resolution/stack-graphs/glue.d.ts +15 -0
  500. package/dist/providers/resolution/stack-graphs/glue.d.ts.map +1 -0
  501. package/dist/providers/resolution/stack-graphs/glue.js +44 -0
  502. package/dist/providers/resolution/stack-graphs/glue.js.map +1 -0
  503. package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts +30 -0
  504. package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts.map +1 -0
  505. package/dist/providers/resolution/stack-graphs/node-edge-builder.js +366 -0
  506. package/dist/providers/resolution/stack-graphs/node-edge-builder.js.map +1 -0
  507. package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts +9 -0
  508. package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts.map +1 -0
  509. package/dist/providers/resolution/stack-graphs/partial-path-engine.js +152 -0
  510. package/dist/providers/resolution/stack-graphs/partial-path-engine.js.map +1 -0
  511. package/dist/providers/resolution/stack-graphs/rule-parser.d.ts +11 -0
  512. package/dist/providers/resolution/stack-graphs/rule-parser.d.ts.map +1 -0
  513. package/dist/providers/resolution/stack-graphs/rule-parser.js +247 -0
  514. package/dist/providers/resolution/stack-graphs/rule-parser.js.map +1 -0
  515. package/dist/providers/resolution/stack-graphs/types.d.ts +93 -0
  516. package/dist/providers/resolution/stack-graphs/types.d.ts.map +1 -0
  517. package/dist/providers/resolution/stack-graphs/types.js +11 -0
  518. package/dist/providers/resolution/stack-graphs/types.js.map +1 -0
  519. package/dist/providers/resolution/stack-graphs-python.d.ts +27 -0
  520. package/dist/providers/resolution/stack-graphs-python.d.ts.map +1 -0
  521. package/dist/providers/resolution/stack-graphs-python.js +104 -0
  522. package/dist/providers/resolution/stack-graphs-python.js.map +1 -0
  523. package/dist/providers/resolution/stack-graphs-ts.d.ts +134 -0
  524. package/dist/providers/resolution/stack-graphs-ts.d.ts.map +1 -0
  525. package/dist/providers/resolution/stack-graphs-ts.js +372 -0
  526. package/dist/providers/resolution/stack-graphs-ts.js.map +1 -0
  527. package/dist/providers/ruby.d.ts +3 -0
  528. package/dist/providers/ruby.d.ts.map +1 -0
  529. package/dist/providers/ruby.js +259 -0
  530. package/dist/providers/ruby.js.map +1 -0
  531. package/dist/providers/rust.d.ts +3 -0
  532. package/dist/providers/rust.d.ts.map +1 -0
  533. package/dist/providers/rust.js +318 -0
  534. package/dist/providers/rust.js.map +1 -0
  535. package/dist/providers/swift.d.ts +3 -0
  536. package/dist/providers/swift.d.ts.map +1 -0
  537. package/dist/providers/swift.js +177 -0
  538. package/dist/providers/swift.js.map +1 -0
  539. package/dist/providers/test-helpers.d.ts +24 -0
  540. package/dist/providers/test-helpers.d.ts.map +1 -0
  541. package/dist/providers/test-helpers.js +33 -0
  542. package/dist/providers/test-helpers.js.map +1 -0
  543. package/dist/providers/ts-shared.d.ts +30 -0
  544. package/dist/providers/ts-shared.d.ts.map +1 -0
  545. package/dist/providers/ts-shared.js +328 -0
  546. package/dist/providers/ts-shared.js.map +1 -0
  547. package/dist/providers/tsx.d.ts +7 -0
  548. package/dist/providers/tsx.d.ts.map +1 -0
  549. package/dist/providers/tsx.js +79 -0
  550. package/dist/providers/tsx.js.map +1 -0
  551. package/dist/providers/types.d.ts +166 -0
  552. package/dist/providers/types.d.ts.map +1 -0
  553. package/dist/providers/types.js +7 -0
  554. package/dist/providers/types.js.map +1 -0
  555. package/dist/providers/typescript-family-accesses.d.ts +14 -0
  556. package/dist/providers/typescript-family-accesses.d.ts.map +1 -0
  557. package/dist/providers/typescript-family-accesses.js +27 -0
  558. package/dist/providers/typescript-family-accesses.js.map +1 -0
  559. package/dist/providers/typescript.d.ts +9 -0
  560. package/dist/providers/typescript.d.ts.map +1 -0
  561. package/dist/providers/typescript.js +84 -0
  562. package/dist/providers/typescript.js.map +1 -0
  563. package/package.json +108 -0
@@ -0,0 +1,88 @@
1
+ /**
2
+ * WASM parser opener (default runtime) + native-availability probe.
3
+ *
4
+ * WASM is the default parse runtime as of Node 24 / M5. The native
5
+ * `tree-sitter` N-API addon is still fully supported and is opt-in via
6
+ * `OCH_NATIVE_PARSER=1` (or `--native-parser` on the CLI) — useful on
7
+ * Node 22 developer boxes where native parsing is measurably faster.
8
+ * Exotic environments (musl-libc Alpine, Cloudflare Workers, sandboxed
9
+ * Electron renderers, AWS Lambda ARM64 custom runtimes, restricted CI)
10
+ * can't load `.node` addons at all; on those hosts the default WASM
11
+ * path Just Works and `isNativeAvailable()` returns false.
12
+ *
13
+ * `openWasmParser(lang)` lazily initializes the web-tree-sitter runtime
14
+ * once per process and resolves the grammar WASM from the installed
15
+ * `tree-sitter-<lang>` package. Per-grammar cache means repeated calls
16
+ * are O(1).
17
+ *
18
+ * Query execution uses the same unified S-expression bodies from
19
+ * `unified-queries.ts`; the parse-phase consumer receives byte-
20
+ * identical ParseCapture output whether the runtime was native or WASM
21
+ * (asserted by the parity test in `wasm-parity.test.ts`).
22
+ */
23
+ import type { LanguageId } from "./types.js";
24
+ /**
25
+ * Returns true when `require('tree-sitter')` succeeds in the current process.
26
+ * Result is cached — subsequent calls are O(1).
27
+ *
28
+ * Call this at worker startup rather than on every parse.
29
+ */
30
+ export declare function isNativeAvailable(): boolean;
31
+ /**
32
+ * For tests and diagnostics: reset the cached detection result.
33
+ */
34
+ export declare function resetNativeAvailabilityCache(): void;
35
+ /**
36
+ * Minimal shape of what `openWasmParser` returns — enough to run the
37
+ * same capture loop the native worker implements. Intentionally
38
+ * decoupled from the `web-tree-sitter` types so test code can stub it.
39
+ */
40
+ export interface WasmParserHandle {
41
+ readonly language: LanguageId;
42
+ /** Parse a source string and return the underlying tree. */
43
+ parse(source: string): WasmTree;
44
+ /**
45
+ * Execute the unified query and return the flat capture list. Callers
46
+ * translate into `ParseCapture` via the normal coordinate remapping
47
+ * (1-indexed lines, 0-indexed columns).
48
+ */
49
+ runQuery(queryText: string, source: string): readonly WasmCapture[];
50
+ }
51
+ export interface WasmTree {
52
+ readonly rootNode: WasmNode;
53
+ }
54
+ export interface WasmNode {
55
+ readonly type: string;
56
+ readonly text: string;
57
+ readonly startPosition: {
58
+ readonly row: number;
59
+ readonly column: number;
60
+ };
61
+ readonly endPosition: {
62
+ readonly row: number;
63
+ readonly column: number;
64
+ };
65
+ }
66
+ export interface WasmCapture {
67
+ readonly name: string;
68
+ readonly node: WasmNode;
69
+ }
70
+ /**
71
+ * Attempt to open a WASM-backed parser for `lang`. Returns `null` when
72
+ * either the `web-tree-sitter` runtime or the grammar's bundled `.wasm`
73
+ * could not be resolved — callers log a debug note and skip that file.
74
+ */
75
+ export declare function openWasmParser(lang: LanguageId): Promise<WasmParserHandle | null>;
76
+ /**
77
+ * Test hook: clear the per-process WASM parser cache. Never call in
78
+ * production paths — it would force a re-init of every grammar.
79
+ */
80
+ export declare function _resetWasmCacheForTests(): void;
81
+ /**
82
+ * Test hook: expose the grammar-path resolver so unit tests can assert
83
+ * the two-stage cascade (per-grammar package → tree-sitter-wasms
84
+ * catalog) resolves kotlin/swift/dart correctly. Not part of the public
85
+ * API — callers in production paths must go through `openWasmParser`.
86
+ */
87
+ export declare function _resolveGrammarWasmPathForTests(lang: LanguageId): string | undefined;
88
+ //# sourceMappingURL=wasm-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-fallback.d.ts","sourceRoot":"","sources":["../../src/parse/wasm-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAgB7C;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAW3C;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAMD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,4DAA4D;IAC5D,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAAC;CACrE;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1E,QAAQ,CAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAsCD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAwCvF;AA+HD;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAEpF"}
@@ -0,0 +1,258 @@
1
+ /**
2
+ * WASM parser opener (default runtime) + native-availability probe.
3
+ *
4
+ * WASM is the default parse runtime as of Node 24 / M5. The native
5
+ * `tree-sitter` N-API addon is still fully supported and is opt-in via
6
+ * `OCH_NATIVE_PARSER=1` (or `--native-parser` on the CLI) — useful on
7
+ * Node 22 developer boxes where native parsing is measurably faster.
8
+ * Exotic environments (musl-libc Alpine, Cloudflare Workers, sandboxed
9
+ * Electron renderers, AWS Lambda ARM64 custom runtimes, restricted CI)
10
+ * can't load `.node` addons at all; on those hosts the default WASM
11
+ * path Just Works and `isNativeAvailable()` returns false.
12
+ *
13
+ * `openWasmParser(lang)` lazily initializes the web-tree-sitter runtime
14
+ * once per process and resolves the grammar WASM from the installed
15
+ * `tree-sitter-<lang>` package. Per-grammar cache means repeated calls
16
+ * are O(1).
17
+ *
18
+ * Query execution uses the same unified S-expression bodies from
19
+ * `unified-queries.ts`; the parse-phase consumer receives byte-
20
+ * identical ParseCapture output whether the runtime was native or WASM
21
+ * (asserted by the parity test in `wasm-parity.test.ts`).
22
+ */
23
+ import { createRequire } from "node:module";
24
+ import path from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+ const requireFn = createRequire(import.meta.url);
27
+ // Resolve packages/ingestion/vendor/wasms/ relative to this module regardless
28
+ // of whether we're running from src/ (ts-node-style) or dist/ (compiled).
29
+ // `vendor/` lives at the package root, so we walk up from the file's dirname
30
+ // until we find it. Computed once at module load.
31
+ const VENDOR_WASMS_DIR = (() => {
32
+ const here = path.dirname(fileURLToPath(import.meta.url));
33
+ // src → <pkg>/src/parse; dist → <pkg>/dist/parse — both 2 levels up
34
+ return path.resolve(here, "..", "..", "vendor", "wasms");
35
+ })();
36
+ let cached;
37
+ /**
38
+ * Returns true when `require('tree-sitter')` succeeds in the current process.
39
+ * Result is cached — subsequent calls are O(1).
40
+ *
41
+ * Call this at worker startup rather than on every parse.
42
+ */
43
+ export function isNativeAvailable() {
44
+ if (cached !== undefined) {
45
+ return cached;
46
+ }
47
+ try {
48
+ requireFn("tree-sitter");
49
+ cached = true;
50
+ }
51
+ catch {
52
+ cached = false;
53
+ }
54
+ return cached;
55
+ }
56
+ /**
57
+ * For tests and diagnostics: reset the cached detection result.
58
+ */
59
+ export function resetNativeAvailabilityCache() {
60
+ cached = undefined;
61
+ }
62
+ /**
63
+ * Per-LanguageId cache of WASM grammar handles. Populated lazily.
64
+ * `null` entries mean "tried and failed" — we don't retry forever.
65
+ */
66
+ const wasmCache = new Map();
67
+ let wasmRuntime;
68
+ /**
69
+ * Attempt to open a WASM-backed parser for `lang`. Returns `null` when
70
+ * either the `web-tree-sitter` runtime or the grammar's bundled `.wasm`
71
+ * could not be resolved — callers log a debug note and skip that file.
72
+ */
73
+ export async function openWasmParser(lang) {
74
+ const cached = wasmCache.get(lang);
75
+ if (cached !== undefined)
76
+ return cached;
77
+ try {
78
+ const runtime = await ensureWasmRuntime();
79
+ if (runtime === undefined) {
80
+ wasmCache.set(lang, null);
81
+ return null;
82
+ }
83
+ const wasmPath = resolveGrammarWasmPath(lang);
84
+ if (wasmPath === undefined) {
85
+ wasmCache.set(lang, null);
86
+ return null;
87
+ }
88
+ const tsLanguage = await runtime.Language.load(wasmPath);
89
+ const Parser = runtime.Parser;
90
+ const parser = new Parser();
91
+ parser.setLanguage(tsLanguage);
92
+ const handle = {
93
+ language: lang,
94
+ parse: (source) => parser.parse(source),
95
+ runQuery: (queryText, source) => {
96
+ // Fresh Query per call so state stays clean between bodies.
97
+ // Query construction is cheap relative to the parse itself.
98
+ const q = new runtime.Query(tsLanguage, queryText);
99
+ const tree = parser.parse(source);
100
+ const out = [];
101
+ for (const m of q.matches(tree.rootNode)) {
102
+ for (const cap of m.captures)
103
+ out.push(cap);
104
+ }
105
+ return out;
106
+ },
107
+ };
108
+ wasmCache.set(lang, handle);
109
+ return handle;
110
+ }
111
+ catch {
112
+ wasmCache.set(lang, null);
113
+ return null;
114
+ }
115
+ }
116
+ /**
117
+ * Load the web-tree-sitter runtime on demand and initialize it. Returns
118
+ * `undefined` when the package isn't installed or the runtime refuses to
119
+ * init (sandboxed, missing WebAssembly, etc.).
120
+ */
121
+ async function ensureWasmRuntime() {
122
+ if (wasmRuntime?.initialized === true)
123
+ return wasmRuntime;
124
+ let mod;
125
+ try {
126
+ mod = requireFn("web-tree-sitter");
127
+ }
128
+ catch {
129
+ return undefined;
130
+ }
131
+ try {
132
+ if (typeof mod.Parser.init === "function") {
133
+ await mod.Parser.init();
134
+ }
135
+ }
136
+ catch {
137
+ return undefined;
138
+ }
139
+ wasmRuntime = {
140
+ Parser: mod.Parser,
141
+ Query: mod.Query,
142
+ Language: mod.Language,
143
+ initialized: true,
144
+ };
145
+ return wasmRuntime;
146
+ }
147
+ /**
148
+ * Resolve the `.wasm` grammar asset for `lang`. Two-stage cascade:
149
+ *
150
+ * 1. Per-grammar-package lookup — for the 11 languages whose
151
+ * `tree-sitter-<lang>` npm package ships its own `.wasm` alongside
152
+ * the `.node` addon (typescript, tsx, javascript, python, go, rust,
153
+ * java, csharp, c, cpp, ruby, php).
154
+ * 2. Vendored-WASM fallback — for kotlin, swift, and dart, whose
155
+ * per-grammar packages do NOT ship a `.wasm`. We build these once
156
+ * from the same grammar sources npm pins (zero drift) and commit
157
+ * them to `packages/ingestion/vendor/wasms/`. See
158
+ * `scripts/build-vendor-wasms.sh` and `vendor/wasms/README.md`.
159
+ *
160
+ * Returns `undefined` when neither stage resolves (package not
161
+ * installed, or language not in either table).
162
+ */
163
+ function resolveGrammarWasmPath(lang) {
164
+ const direct = tryPerGrammarPackage(lang);
165
+ if (direct !== undefined)
166
+ return direct;
167
+ return tryVendoredWasm(lang);
168
+ }
169
+ /**
170
+ * Stage 1: resolve a `.wasm` that ships inside the per-grammar
171
+ * `tree-sitter-<lang>` npm package. Returns `undefined` when the
172
+ * language has no entry in this table or the package is not installed.
173
+ */
174
+ function tryPerGrammarPackage(lang) {
175
+ // `tree-sitter-typescript` ships two wasms in one package — select by
176
+ // language variant.
177
+ if (lang === "typescript" || lang === "tsx") {
178
+ const pkgDir = resolvePackageDir("tree-sitter-typescript");
179
+ if (pkgDir === undefined)
180
+ return undefined;
181
+ const fname = lang === "typescript" ? "tree-sitter-typescript.wasm" : "tree-sitter-tsx.wasm";
182
+ return path.join(pkgDir, fname);
183
+ }
184
+ const mapping = {
185
+ javascript: { pkg: "tree-sitter-javascript", file: "tree-sitter-javascript.wasm" },
186
+ python: { pkg: "tree-sitter-python", file: "tree-sitter-python.wasm" },
187
+ go: { pkg: "tree-sitter-go", file: "tree-sitter-go.wasm" },
188
+ rust: { pkg: "tree-sitter-rust", file: "tree-sitter-rust.wasm" },
189
+ java: { pkg: "tree-sitter-java", file: "tree-sitter-java.wasm" },
190
+ // c-sharp publishes `tree-sitter-c_sharp.wasm` (underscore, not hyphen).
191
+ csharp: { pkg: "tree-sitter-c-sharp", file: "tree-sitter-c_sharp.wasm" },
192
+ c: { pkg: "tree-sitter-c", file: "tree-sitter-c.wasm" },
193
+ cpp: { pkg: "tree-sitter-cpp", file: "tree-sitter-cpp.wasm" },
194
+ ruby: { pkg: "tree-sitter-ruby", file: "tree-sitter-ruby.wasm" },
195
+ // Use php_only (pure PHP, no HTML template injection) to match native loader (grammar-registry.ts:244-254).
196
+ php: { pkg: "tree-sitter-php", file: "tree-sitter-php_only.wasm" },
197
+ };
198
+ const entry = mapping[lang];
199
+ if (entry === undefined)
200
+ return undefined;
201
+ const pkgDir = resolvePackageDir(entry.pkg);
202
+ if (pkgDir === undefined)
203
+ return undefined;
204
+ return path.join(pkgDir, entry.file);
205
+ }
206
+ /**
207
+ * Stage 2: resolve from the vendored WASM directory at
208
+ * `packages/ingestion/vendor/wasms/`. Only opted-in for languages whose
209
+ * per-grammar npm package does NOT ship a `.wasm` — kotlin, swift, dart.
210
+ *
211
+ * These are built once from the same grammar sources our package.json
212
+ * pins (zero version drift vs native) and committed to the repo. The
213
+ * upstream `tree-sitter-wasms` catalog can't be used because its 0.1.13
214
+ * artifacts were built with tree-sitter-cli 0.20.x and ship the legacy
215
+ * `dylink` section, which web-tree-sitter 0.26+ refuses to load (it
216
+ * requires the standardized `dylink.0` section).
217
+ *
218
+ * Keep this table minimal — adding a language here is a deliberate
219
+ * architectural choice. See `scripts/build-vendor-wasms.sh`.
220
+ */
221
+ function tryVendoredWasm(lang) {
222
+ const catalog = {
223
+ kotlin: "tree-sitter-kotlin.wasm",
224
+ swift: "tree-sitter-swift.wasm",
225
+ dart: "tree-sitter-dart.wasm",
226
+ };
227
+ const fname = catalog[lang];
228
+ if (fname === undefined)
229
+ return undefined;
230
+ return path.join(VENDOR_WASMS_DIR, fname);
231
+ }
232
+ function resolvePackageDir(pkgName) {
233
+ try {
234
+ const manifestPath = requireFn.resolve(`${pkgName}/package.json`);
235
+ return path.dirname(manifestPath);
236
+ }
237
+ catch {
238
+ return undefined;
239
+ }
240
+ }
241
+ /**
242
+ * Test hook: clear the per-process WASM parser cache. Never call in
243
+ * production paths — it would force a re-init of every grammar.
244
+ */
245
+ export function _resetWasmCacheForTests() {
246
+ wasmCache.clear();
247
+ wasmRuntime = undefined;
248
+ }
249
+ /**
250
+ * Test hook: expose the grammar-path resolver so unit tests can assert
251
+ * the two-stage cascade (per-grammar package → tree-sitter-wasms
252
+ * catalog) resolves kotlin/swift/dart correctly. Not part of the public
253
+ * API — callers in production paths must go through `openWasmParser`.
254
+ */
255
+ export function _resolveGrammarWasmPathForTests(lang) {
256
+ return resolveGrammarWasmPath(lang);
257
+ }
258
+ //# sourceMappingURL=wasm-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-fallback.js","sourceRoot":"","sources":["../../src/parse/wasm-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEjD,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE;IAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,oEAAoE;IACpE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC,CAAC,EAAE,CAAC;AAEL,IAAI,MAA2B,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,CAAC;QACH,SAAS,CAAC,aAAa,CAAC,CAAC;QACzB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B;IAC1C,MAAM,GAAG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QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,SAAS,CAAC,KAAK,EAAE,CAAC;IAClB,WAAW,GAAG,SAAS,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,IAAgB;IAC9D,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Piscina-backed worker pool wrapper with byte-budget chunking.
3
+ *
4
+ * Callers pass a list of tasks; the pool chunks them into batches respecting
5
+ * a byte budget (default 20 MB) and file cap (default 200 files), dispatches
6
+ * each batch to one worker, and collects the results. Output is sorted by
7
+ * `filePath` so two runs with identical inputs produce byte-identical output
8
+ * regardless of worker completion order.
9
+ *
10
+ * Sizing: by default `maxThreads = clamp(os.availableParallelism(), 2, 8)`.
11
+ * Beyond 8 the bottleneck shifts to main-thread GC pressure and file I/O, so
12
+ * we cap there. Callers can override.
13
+ */
14
+ import type { ParseResult, ParseTask } from "./types.js";
15
+ /** Options for a single dispatch() call. */
16
+ export interface DispatchOptions {
17
+ /** Max cumulative bytes per worker batch. Default 20 MB. */
18
+ readonly byteBudget?: number;
19
+ /** Max files per worker batch (guards against many-tiny-files). Default 200. */
20
+ readonly fileCap?: number;
21
+ }
22
+ /** Options passed at pool construction. */
23
+ export interface ParsePoolOptions {
24
+ readonly minThreads?: number;
25
+ readonly maxThreads?: number;
26
+ }
27
+ /**
28
+ * Main-thread wrapper around the piscina pool.
29
+ */
30
+ export declare class ParsePool {
31
+ #private;
32
+ constructor(opts?: ParsePoolOptions);
33
+ /**
34
+ * Dispatch a set of parse tasks across the pool.
35
+ *
36
+ * Results are always sorted by `filePath` so output is deterministic
37
+ * regardless of worker completion order.
38
+ */
39
+ dispatch(tasks: readonly ParseTask[], opts?: DispatchOptions): Promise<readonly ParseResult[]>;
40
+ /** Shut down the pool; pending tasks are aborted. */
41
+ destroy(): Promise<void>;
42
+ }
43
+ /**
44
+ * Walk tasks in input order, accumulating into batches until either the
45
+ * byte budget or file cap is reached. Exported for testing.
46
+ */
47
+ export declare function chunkTasks(tasks: readonly ParseTask[], byteBudget: number, fileCap: number): ParseTask[][];
48
+ //# sourceMappingURL=worker-pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-pool.d.ts","sourceRoot":"","sources":["../../src/parse/worker-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAc,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMrE,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAUD;;GAEG;AACH,qBAAa,SAAS;;gBAGR,IAAI,GAAE,gBAAqB;IAUvC;;;;;OAKG;IACG,QAAQ,CACZ,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC;IAsBlC,qDAAqD;IAC/C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,SAAS,EAAE,EAAE,CAwBf"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Piscina-backed worker pool wrapper with byte-budget chunking.
3
+ *
4
+ * Callers pass a list of tasks; the pool chunks them into batches respecting
5
+ * a byte budget (default 20 MB) and file cap (default 200 files), dispatches
6
+ * each batch to one worker, and collects the results. Output is sorted by
7
+ * `filePath` so two runs with identical inputs produce byte-identical output
8
+ * regardless of worker completion order.
9
+ *
10
+ * Sizing: by default `maxThreads = clamp(os.availableParallelism(), 2, 8)`.
11
+ * Beyond 8 the bottleneck shifts to main-thread GC pressure and file I/O, so
12
+ * we cap there. Callers can override.
13
+ */
14
+ import { availableParallelism } from "node:os";
15
+ import { fileURLToPath } from "node:url";
16
+ import { Piscina } from "piscina";
17
+ // When we compile with tsc, __filename resolution is via import.meta.url.
18
+ // The worker file sits next to this one as `parse-worker.js` in dist/.
19
+ const WORKER_FILENAME = fileURLToPath(new URL("./parse-worker.js", import.meta.url));
20
+ const DEFAULT_BYTE_BUDGET = 20 * 1024 * 1024;
21
+ const DEFAULT_FILE_CAP = 200;
22
+ function defaultMaxThreads() {
23
+ const cpus = availableParallelism();
24
+ return Math.max(2, Math.min(cpus, 8));
25
+ }
26
+ /**
27
+ * Main-thread wrapper around the piscina pool.
28
+ */
29
+ export class ParsePool {
30
+ #pool;
31
+ constructor(opts = {}) {
32
+ const minThreads = opts.minThreads ?? 2;
33
+ const maxThreads = opts.maxThreads ?? defaultMaxThreads();
34
+ this.#pool = new Piscina({
35
+ filename: WORKER_FILENAME,
36
+ minThreads,
37
+ maxThreads,
38
+ });
39
+ }
40
+ /**
41
+ * Dispatch a set of parse tasks across the pool.
42
+ *
43
+ * Results are always sorted by `filePath` so output is deterministic
44
+ * regardless of worker completion order.
45
+ */
46
+ async dispatch(tasks, opts = {}) {
47
+ if (tasks.length === 0) {
48
+ return [];
49
+ }
50
+ const byteBudget = opts.byteBudget ?? DEFAULT_BYTE_BUDGET;
51
+ const fileCap = opts.fileCap ?? DEFAULT_FILE_CAP;
52
+ const batches = chunkTasks(tasks, byteBudget, fileCap);
53
+ const batchResults = await Promise.all(batches.map((batch) => this.#pool.run({ tasks: batch })));
54
+ const flat = [];
55
+ for (const br of batchResults) {
56
+ for (const r of br) {
57
+ flat.push(r);
58
+ }
59
+ }
60
+ flat.sort((a, b) => (a.filePath < b.filePath ? -1 : a.filePath > b.filePath ? 1 : 0));
61
+ return flat;
62
+ }
63
+ /** Shut down the pool; pending tasks are aborted. */
64
+ async destroy() {
65
+ await this.#pool.destroy();
66
+ }
67
+ }
68
+ /**
69
+ * Walk tasks in input order, accumulating into batches until either the
70
+ * byte budget or file cap is reached. Exported for testing.
71
+ */
72
+ export function chunkTasks(tasks, byteBudget, fileCap) {
73
+ const batches = [];
74
+ let current = [];
75
+ let currentBytes = 0;
76
+ for (const t of tasks) {
77
+ const size = t.content.byteLength;
78
+ // Flush the current batch BEFORE appending if either:
79
+ // (a) adding this task would meet or exceed the byte budget, or
80
+ // (b) the batch is already full by file count.
81
+ // The `>=` on bytes ensures that when a task's size hits the budget exactly
82
+ // it starts a new batch — matching the documented behavior on borderline
83
+ // inputs such as three 5MB files with a 10MB budget → three batches.
84
+ if (current.length > 0 && (currentBytes + size >= byteBudget || current.length >= fileCap)) {
85
+ batches.push(current);
86
+ current = [];
87
+ currentBytes = 0;
88
+ }
89
+ current.push(t);
90
+ currentBytes += size;
91
+ }
92
+ if (current.length > 0) {
93
+ batches.push(current);
94
+ }
95
+ return batches;
96
+ }
97
+ //# sourceMappingURL=worker-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-pool.js","sourceRoot":"","sources":["../../src/parse/worker-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,0EAA0E;AAC1E,uEAAuE;AACvE,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,C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,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,YAAY,IAAI,IAAI,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Go ecosystem manifest parser.
3
+ *
4
+ * Supported inputs:
5
+ * - `go.sum` — one module per line, format
6
+ * `<module> <version>[/go.mod] <h1:hash>`
7
+ * We consume only the 2-column (module, version) projection and skip
8
+ * the `/go.mod` discriminator so each module is emitted once.
9
+ * - `go.mod` — uses the text format specified at https://go.dev/ref/mod.
10
+ * We parse the `require` block (single- or multi-line form), capture
11
+ * `<module> <version>` pairs, and skip `replace` / `exclude` directives.
12
+ *
13
+ * The version is the raw Go module pseudo-version string (e.g.
14
+ * `v1.2.3`, or `v0.0.0-20231201123456-abcdef012345`) exactly as it appears
15
+ * in the source file.
16
+ *
17
+ * License detection: neither go.mod nor go.sum carries license metadata.
18
+ * The canonical source is `pkg.go.dev` + the module's `LICENSE` file,
19
+ * both of which live behind a network boundary this phase forbids.
20
+ * Per-dep `license` therefore stays undefined and the dependencies
21
+ * phase maps that to the `"UNKNOWN"` sentinel.
22
+ */
23
+ import type { ParseDepsFn } from "./types.js";
24
+ export declare const parseGoDeps: ParseDepsFn;
25
+ //# sourceMappingURL=go.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../../src/pipeline/dep-parsers/go.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAIhE,eAAO,MAAM,WAAW,EAAE,WAgBzB,CAAC"}