@backbencher/brain 0.0.0-stage → 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 (319) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/EMBEDDINGS.md +355 -0
  3. package/LICENSE +21 -0
  4. package/README.md +415 -2
  5. package/bin/bb +13 -0
  6. package/dist/analysis-exclusions-7ZJDXOVZ.js +35 -0
  7. package/dist/brain-index-health-KY7K552E.js +17 -0
  8. package/dist/brain-relationship-enrichment-QH7OOHUF.js +558 -0
  9. package/dist/brain.sql-EIM4WS4D.js +29 -0
  10. package/dist/chunk-2BSKD7O3.js +40 -0
  11. package/dist/chunk-2DE27DVC.js +1314 -0
  12. package/dist/chunk-2RRBMNBQ.js +322 -0
  13. package/dist/chunk-2RTN2DFU.js +711 -0
  14. package/dist/chunk-2WXYNLBA.js +29 -0
  15. package/dist/chunk-3CTFIJJB.js +17 -0
  16. package/dist/chunk-3LFTSMIV.js +174 -0
  17. package/dist/chunk-47HKX4AJ.js +930 -0
  18. package/dist/chunk-4H22TLOT.js +543 -0
  19. package/dist/chunk-5SD45FLC.js +818 -0
  20. package/dist/chunk-66A5ZFYA.js +1758 -0
  21. package/dist/chunk-6AIRWAO2.js +247 -0
  22. package/dist/chunk-6WNGD3NN.js +196 -0
  23. package/dist/chunk-7AN7U5IZ.js +371 -0
  24. package/dist/chunk-BHB7BYYI.js +626 -0
  25. package/dist/chunk-BQ3OVQ3P.js +125 -0
  26. package/dist/chunk-CW4XXSNN.js +1479 -0
  27. package/dist/chunk-D2Q4Y47A.js +53 -0
  28. package/dist/chunk-DIYAGQJL.js +34 -0
  29. package/dist/chunk-DYM4FQEE.js +90 -0
  30. package/dist/chunk-EWMWK7WN.js +75 -0
  31. package/dist/chunk-FVVQTSIM.js +3427 -0
  32. package/dist/chunk-FWSL4VG6.js +1290 -0
  33. package/dist/chunk-GBI7V7KY.js +69 -0
  34. package/dist/chunk-GEFFO6O2.js +152 -0
  35. package/dist/chunk-HOWAQXJO.js +236 -0
  36. package/dist/chunk-HQSPJDHI.js +613 -0
  37. package/dist/chunk-IFZNR5UJ.js +2863 -0
  38. package/dist/chunk-J4PMBXQQ.js +336 -0
  39. package/dist/chunk-KAET47ZL.js +125 -0
  40. package/dist/chunk-KCDECRJY.js +440 -0
  41. package/dist/chunk-KLK3PBTO.js +1119 -0
  42. package/dist/chunk-L5TDYKYK.js +76 -0
  43. package/dist/chunk-MLKGABMK.js +9 -0
  44. package/dist/chunk-OWISBAOF.js +61 -0
  45. package/dist/chunk-PJTNGD3Z.js +6924 -0
  46. package/dist/chunk-QLK6ED4Q.js +235 -0
  47. package/dist/chunk-R2GW4F6R.js +19 -0
  48. package/dist/chunk-RCMTFSEF.js +87 -0
  49. package/dist/chunk-RH7KC5HU.js +12050 -0
  50. package/dist/chunk-RM3PY6TG.js +376 -0
  51. package/dist/chunk-ROMM6KMC.js +433 -0
  52. package/dist/chunk-SK6YVHFZ.js +211 -0
  53. package/dist/chunk-SM7RFQRO.js +214 -0
  54. package/dist/chunk-UFE77L67.js +782 -0
  55. package/dist/chunk-UGR4QIGS.js +67 -0
  56. package/dist/chunk-UUNHHX4M.js +13 -0
  57. package/dist/chunk-V44PGPA6.js +2104 -0
  58. package/dist/chunk-VL52PL2T.js +71 -0
  59. package/dist/chunk-VURYFIHW.js +201 -0
  60. package/dist/chunk-XJKJYIPP.js +7436 -0
  61. package/dist/chunk-YI6FF2ZR.js +340 -0
  62. package/dist/cli/index.js +37 -0
  63. package/dist/config-HZAAYDP3.js +10 -0
  64. package/dist/content-search-642F7E5V.js +593 -0
  65. package/dist/database-TCTZDLE5.js +9 -0
  66. package/dist/doctor-GXCKSJOX.js +395 -0
  67. package/dist/edit-engine-KM7MPFEC.js +51 -0
  68. package/dist/engine-42TZFNIZ.js +11 -0
  69. package/dist/engine-LO6L4JLQ.js +18 -0
  70. package/dist/fingerprint-XDXFRWO6.js +33 -0
  71. package/dist/framework-intelligence-DWFCKV44.js +860 -0
  72. package/dist/freshness-3K6VU5OT.js +174 -0
  73. package/dist/graph-engine-PL5YA7BA.js +21 -0
  74. package/dist/graph_request-MM4REP6H.js +350 -0
  75. package/dist/impact_request-WDE47IZ5.js +68 -0
  76. package/dist/index-space-IUUN5WYV.js +15 -0
  77. package/dist/index-status-6BD7UBHR.js +34 -0
  78. package/dist/index.js +159 -0
  79. package/dist/instance-FO6QZRLH.js +19 -0
  80. package/dist/language-detection-DFCAU5DZ.js +11 -0
  81. package/dist/lsp/server.js +4301 -0
  82. package/dist/mcp/server.js +132 -0
  83. package/dist/onboard-DIQZV2NW.js +161 -0
  84. package/dist/override-companion-pass-XR7MHTP7.js +117 -0
  85. package/dist/parallel-indexer-4PW3AFXP.js +88 -0
  86. package/dist/pool-worker.js +1153 -0
  87. package/dist/project-health-ZS5TS2Z6.js +94 -0
  88. package/dist/project-index-5SDPHITE.js +57 -0
  89. package/dist/project-registry-DGZBIZS7.js +355 -0
  90. package/dist/real-bash-analyzer-SXSV67E2.js +2201 -0
  91. package/dist/real-c-analyzer-SY7FTZ6W.js +5942 -0
  92. package/dist/real-clean-analyzer-IGDHHLZK.js +3470 -0
  93. package/dist/real-clojure-analyzer-4OH7IWLB.js +2818 -0
  94. package/dist/real-cpp-analyzer-7LTDRJRJ.js +4101 -0
  95. package/dist/real-csharp-analyzer-KICU3TLH.js +3298 -0
  96. package/dist/real-css-analyzer-HPU277Q6.js +15 -0
  97. package/dist/real-dart-analyzer-7LZ5LCMW.js +3944 -0
  98. package/dist/real-elixir-analyzer-BE3MEVZO.js +2192 -0
  99. package/dist/real-erlang-analyzer-BZMAKYBK.js +1731 -0
  100. package/dist/real-fsharp-analyzer-5QLTOV3E.js +2390 -0
  101. package/dist/real-go-analyzer-POD7MZQR.js +4126 -0
  102. package/dist/real-graphql-analyzer-MAQRZ6QW.js +1442 -0
  103. package/dist/real-groovy-analyzer-MEWSUPMJ.js +2285 -0
  104. package/dist/real-haskell-analyzer-I5L2GR3Y.js +2533 -0
  105. package/dist/real-hcl-analyzer-DBOPXSWJ.js +725 -0
  106. package/dist/real-html-analyzer-O63XZLZD.js +1759 -0
  107. package/dist/real-java-analyzer-CHCW3EKA.js +4677 -0
  108. package/dist/real-javascript-analyzer-QAAJQYZE.js +14 -0
  109. package/dist/real-json-analyzer-UGBR7YQN.js +1640 -0
  110. package/dist/real-julia-analyzer-35Q4GHOZ.js +2085 -0
  111. package/dist/real-kotlin-analyzer-GRAYCWW2.js +3956 -0
  112. package/dist/real-lua-analyzer-5BAPDZDF.js +1957 -0
  113. package/dist/real-makefile-analyzer-YJKAHNAS.js +920 -0
  114. package/dist/real-markdown-analyzer-UKUQZO4F.js +1215 -0
  115. package/dist/real-matlab-analyzer-FVIKQZKG.js +480 -0
  116. package/dist/real-nim-analyzer-M7FAIABG.js +3603 -0
  117. package/dist/real-objective-c-analyzer-XMYQIGQI.js +1518 -0
  118. package/dist/real-perl-analyzer-ZLY6M2DZ.js +1865 -0
  119. package/dist/real-php-analyzer-KI2ZAM7X.js +9368 -0
  120. package/dist/real-powershell-analyzer-B3T5ZP6U.js +2915 -0
  121. package/dist/real-protobuf-analyzer-23OZ75XV.js +867 -0
  122. package/dist/real-python-analyzer-I4TIUB6D.js +4880 -0
  123. package/dist/real-r-analyzer-FJZJXXS6.js +2596 -0
  124. package/dist/real-ruby-analyzer-M3UFIVTQ.js +2429 -0
  125. package/dist/real-rust-analyzer-LVSONPAN.js +3359 -0
  126. package/dist/real-scala-analyzer-CWPI33Q2.js +3293 -0
  127. package/dist/real-scss-analyzer-TGRJQ7TH.js +1515 -0
  128. package/dist/real-solidity-analyzer-4P2VBVWA.js +2608 -0
  129. package/dist/real-sql-analyzer-J7DYZOZR.js +3840 -0
  130. package/dist/real-svelte-analyzer-NHEN2SX5.js +2532 -0
  131. package/dist/real-swift-analyzer-2NSYULWI.js +2311 -0
  132. package/dist/real-toml-analyzer-L3C66L7Q.js +929 -0
  133. package/dist/real-typescript-analyzer-FTC6ETRQ.js +14 -0
  134. package/dist/real-vb-analyzer-ORY7LAQS.js +3145 -0
  135. package/dist/real-vba-analyzer-JH2TTUFI.js +466 -0
  136. package/dist/real-vue-analyzer-OO4FUGBV.js +2680 -0
  137. package/dist/real-xml-analyzer-6CQVR477.js +2405 -0
  138. package/dist/real-yaml-analyzer-J6MQG3YX.js +3528 -0
  139. package/dist/real-zig-analyzer-EFKCPJNU.js +2430 -0
  140. package/dist/regex-search-OPTLKUN5.js +239 -0
  141. package/dist/rules-I453JTRC.js +152 -0
  142. package/dist/scoped-path-MJYWJZQX.js +11 -0
  143. package/dist/setup-show-Y5GB5KXA.js +15 -0
  144. package/dist/setup-wizard-G5YYR5T6.js +24 -0
  145. package/dist/symbol-search-KB4MU4SI.js +16 -0
  146. package/dist/taint-YOTN5X55.js +202 -0
  147. package/dist/taint-analyzer-N7YLZU3N.js +163 -0
  148. package/dist/tool-handlers-G4NAGJIH.js +72 -0
  149. package/dist/tool-registry-BPEJNSZG.js +17 -0
  150. package/dist/tool-validation-RF675A3C.js +32 -0
  151. package/dist/type-inference-4Y7WTMFE.js +13 -0
  152. package/dist/vector-binary-LMY4QGAN.js +19 -0
  153. package/dist/version-LXGNFO37.js +9 -0
  154. package/dist/wasm-NMWO3WXY.js +16 -0
  155. package/docs/EMBEDDINGS.md +132 -0
  156. package/docs/README.md +178 -0
  157. package/docs/data/m10-baseline.json +602 -0
  158. package/docs/data/m10-benchmark-baseline.json +57 -0
  159. package/docs/data/m10-benchmark-last-run.json +127 -0
  160. package/docs/data/m10-final-audit.json +215 -0
  161. package/docs/data/m12-final-audit.json +138 -0
  162. package/docs/data/m12-surface-matrix.json +50 -0
  163. package/docs/data/public-tools.json +1902 -0
  164. package/docs/indexing/DEAD-ASSETS.md +88 -0
  165. package/docs/indexing/INDEXER-REVIEW.md +634 -0
  166. package/docs/indexing/PERFORMANCE-FINDINGS.md +106 -0
  167. package/docs/indexing/README.md +427 -0
  168. package/docs/indexing/discovery-matrix.md +41 -0
  169. package/docs/indexing/embeddings.md +325 -0
  170. package/docs/indexing/environment-variables.md +77 -0
  171. package/docs/indexing/performance.md +323 -0
  172. package/docs/indexing/resume.md +345 -0
  173. package/docs/indexing/troubleshooting.md +391 -0
  174. package/docs/man/bb.1 +190 -0
  175. package/docs/tools/bb_analyze.md +147 -0
  176. package/docs/tools/bb_annotate.md +110 -0
  177. package/docs/tools/bb_annotations.md +106 -0
  178. package/docs/tools/bb_ask.md +101 -0
  179. package/docs/tools/bb_cross_language.md +103 -0
  180. package/docs/tools/bb_doc.md +169 -0
  181. package/docs/tools/bb_edit.md +185 -0
  182. package/docs/tools/bb_graph.md +169 -0
  183. package/docs/tools/bb_health.md +156 -0
  184. package/docs/tools/bb_impact.md +117 -0
  185. package/docs/tools/bb_index.md +108 -0
  186. package/docs/tools/bb_migrate.md +135 -0
  187. package/docs/tools/bb_patterns.md +140 -0
  188. package/docs/tools/bb_search.md +150 -0
  189. package/docs/tools/bb_security.md +100 -0
  190. package/docs/tools/bb_visualize.md +184 -0
  191. package/grammars/README.md +57 -0
  192. package/grammars/THIRD-PARTY-NOTICES.md +50 -0
  193. package/grammars/tree-sitter-c/LICENSE +21 -0
  194. package/grammars/tree-sitter-clojure/LICENSE.md +21 -0
  195. package/grammars/tree-sitter-cpp/LICENSE +21 -0
  196. package/grammars/tree-sitter-csharp/LICENSE +21 -0
  197. package/grammars/tree-sitter-css/LICENSE +21 -0
  198. package/grammars/tree-sitter-css/README.md +21 -0
  199. package/grammars/tree-sitter-dart/LICENSE +20 -0
  200. package/grammars/tree-sitter-dart-upstream/LICENSE +20 -0
  201. package/grammars/tree-sitter-dart-upstream/README.md +18 -0
  202. package/grammars/tree-sitter-elixir/LICENSE +176 -0
  203. package/grammars/tree-sitter-elixir/README.md +11 -0
  204. package/grammars/tree-sitter-fsharp/LICENSE +21 -0
  205. package/grammars/tree-sitter-fsharp/README.md +45 -0
  206. package/grammars/tree-sitter-graphql/LICENSE +21 -0
  207. package/grammars/tree-sitter-graphql/README.md +106 -0
  208. package/grammars/tree-sitter-groovy/LICENSE +21 -0
  209. package/grammars/tree-sitter-groovy/README.md +4 -0
  210. package/grammars/tree-sitter-haskell/LICENSE +21 -0
  211. package/grammars/tree-sitter-haskell/README.md +394 -0
  212. package/grammars/tree-sitter-hcl/CHANGELOG.md +102 -0
  213. package/grammars/tree-sitter-hcl/LICENSE +201 -0
  214. package/grammars/tree-sitter-hcl/README.md +39 -0
  215. package/grammars/tree-sitter-html/LICENSE +21 -0
  216. package/grammars/tree-sitter-html/README.md +21 -0
  217. package/grammars/tree-sitter-julia/LICENSE +21 -0
  218. package/grammars/tree-sitter-julia/README.md +24 -0
  219. package/grammars/tree-sitter-kotlin/LICENSE +9 -0
  220. package/grammars/tree-sitter-lua/LICENSE.md +21 -0
  221. package/grammars/tree-sitter-lua/README.md +29 -0
  222. package/grammars/tree-sitter-make/LICENSE +21 -0
  223. package/grammars/tree-sitter-matlab/LICENSE +19 -0
  224. package/grammars/tree-sitter-matlab/README.md +99 -0
  225. package/grammars/tree-sitter-nim/LICENSE +373 -0
  226. package/grammars/tree-sitter-nim/README.md +46 -0
  227. package/grammars/tree-sitter-objc/LICENSE +21 -0
  228. package/grammars/tree-sitter-objc/README.md +20 -0
  229. package/grammars/tree-sitter-perl/LICENSE +7 -0
  230. package/grammars/tree-sitter-perl/README.md +100 -0
  231. package/grammars/tree-sitter-powershell/LICENSE +21 -0
  232. package/grammars/tree-sitter-powershell/README.md +7 -0
  233. package/grammars/tree-sitter-proto/LICENSE +21 -0
  234. package/grammars/tree-sitter-proto/README.md +105 -0
  235. package/grammars/tree-sitter-r/LICENSE +9 -0
  236. package/grammars/tree-sitter-r/README.md +66 -0
  237. package/grammars/tree-sitter-ruby/LICENSE +22 -0
  238. package/grammars/tree-sitter-scss/LICENSE +21 -0
  239. package/grammars/tree-sitter-scss/README.md +17 -0
  240. package/grammars/tree-sitter-solidity/LICENSE +7 -0
  241. package/grammars/tree-sitter-sql/LICENSE +21 -0
  242. package/grammars/tree-sitter-typescript/LICENSE +21 -0
  243. package/grammars/tree-sitter-vba/LICENSE +21 -0
  244. package/grammars/tree-sitter-vba/README.md +738 -0
  245. package/grammars/tree-sitter-vbnet/LICENSE +21 -0
  246. package/grammars/tree-sitter-vbnet/README.md +322 -0
  247. package/grammars/tree-sitter-xml/LICENSE +19 -0
  248. package/grammars/tree-sitter-yaml/LICENSE +20 -0
  249. package/grammars/tree-sitter-yaml/README.md +21 -0
  250. package/package.json +184 -4
  251. package/wasm/dart.wasm +0 -0
  252. package/wasm/tree-sitter-bash.wasm +0 -0
  253. package/wasm/tree-sitter-c.wasm +0 -0
  254. package/wasm/tree-sitter-c_sharp.wasm +0 -0
  255. package/wasm/tree-sitter-clean.wasm +0 -0
  256. package/wasm/tree-sitter-clojure.wasm +0 -0
  257. package/wasm/tree-sitter-core_schema.wasm +0 -0
  258. package/wasm/tree-sitter-cpp.wasm +0 -0
  259. package/wasm/tree-sitter-css.wasm +0 -0
  260. package/wasm/tree-sitter-dart.wasm +0 -0
  261. package/wasm/tree-sitter-elisp.wasm +0 -0
  262. package/wasm/tree-sitter-elixir.wasm +0 -0
  263. package/wasm/tree-sitter-elm.wasm +0 -0
  264. package/wasm/tree-sitter-embedded_template.wasm +0 -0
  265. package/wasm/tree-sitter-erlang.wasm +0 -0
  266. package/wasm/tree-sitter-fsharp.wasm +0 -0
  267. package/wasm/tree-sitter-fsharp_signature.wasm +0 -0
  268. package/wasm/tree-sitter-go.wasm +0 -0
  269. package/wasm/tree-sitter-graphql.wasm +0 -0
  270. package/wasm/tree-sitter-groovy.wasm +0 -0
  271. package/wasm/tree-sitter-haskell.wasm +0 -0
  272. package/wasm/tree-sitter-hcl.wasm +0 -0
  273. package/wasm/tree-sitter-html.wasm +0 -0
  274. package/wasm/tree-sitter-java.wasm +0 -0
  275. package/wasm/tree-sitter-javascript.wasm +0 -0
  276. package/wasm/tree-sitter-json.wasm +0 -0
  277. package/wasm/tree-sitter-json_schema.wasm +0 -0
  278. package/wasm/tree-sitter-julia.wasm +0 -0
  279. package/wasm/tree-sitter-kotlin.wasm +0 -0
  280. package/wasm/tree-sitter-lua.wasm +0 -0
  281. package/wasm/tree-sitter-make.wasm +0 -0
  282. package/wasm/tree-sitter-markdown.wasm +0 -0
  283. package/wasm/tree-sitter-markdown_inline.wasm +0 -0
  284. package/wasm/tree-sitter-matlab.wasm +0 -0
  285. package/wasm/tree-sitter-nim.wasm +0 -0
  286. package/wasm/tree-sitter-objc.wasm +0 -0
  287. package/wasm/tree-sitter-ocaml.wasm +0 -0
  288. package/wasm/tree-sitter-perl.wasm +0 -0
  289. package/wasm/tree-sitter-php.wasm +0 -0
  290. package/wasm/tree-sitter-php_only.wasm +0 -0
  291. package/wasm/tree-sitter-powershell.wasm +0 -0
  292. package/wasm/tree-sitter-protobuf.wasm +0 -0
  293. package/wasm/tree-sitter-python.wasm +0 -0
  294. package/wasm/tree-sitter-ql.wasm +0 -0
  295. package/wasm/tree-sitter-r.wasm +0 -0
  296. package/wasm/tree-sitter-rescript.wasm +0 -0
  297. package/wasm/tree-sitter-ruby.wasm +0 -0
  298. package/wasm/tree-sitter-rust.wasm +0 -0
  299. package/wasm/tree-sitter-scala.wasm +0 -0
  300. package/wasm/tree-sitter-scss.wasm +0 -0
  301. package/wasm/tree-sitter-solidity.wasm +0 -0
  302. package/wasm/tree-sitter-sql.wasm +0 -0
  303. package/wasm/tree-sitter-svelte.wasm +0 -0
  304. package/wasm/tree-sitter-swift.wasm +0 -0
  305. package/wasm/tree-sitter-systemrdl.wasm +0 -0
  306. package/wasm/tree-sitter-terraform.wasm +0 -0
  307. package/wasm/tree-sitter-tlaplus.wasm +0 -0
  308. package/wasm/tree-sitter-toml.wasm +0 -0
  309. package/wasm/tree-sitter-tsx.wasm +0 -0
  310. package/wasm/tree-sitter-typescript.wasm +0 -0
  311. package/wasm/tree-sitter-vba.wasm +0 -0
  312. package/wasm/tree-sitter-vbnet.wasm +0 -0
  313. package/wasm/tree-sitter-vue.wasm +0 -0
  314. package/wasm/tree-sitter-xml.wasm +0 -0
  315. package/wasm/tree-sitter-yaml.wasm +0 -0
  316. package/wasm/tree-sitter-zig.wasm +0 -0
  317. package/wasm/tree-sitter.wasm +0 -0
  318. package/wasm/tsx.wasm +0 -0
  319. package/wasm/typescript.wasm +0 -0
@@ -0,0 +1,433 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
5
+ // src/brain/brain.sql.ts
6
+ var brain_sql_exports = {};
7
+ __export(brain_sql_exports, {
8
+ BrainAnalysisFindingTable: () => BrainAnalysisFindingTable,
9
+ BrainAnalysisOccurrenceTable: () => BrainAnalysisOccurrenceTable,
10
+ BrainAnalysisRunTable: () => BrainAnalysisRunTable,
11
+ BrainFileTable: () => BrainFileTable,
12
+ BrainImportTable: () => BrainImportTable,
13
+ BrainIndexStatusTable: () => BrainIndexStatusTable,
14
+ BrainProjectHealthTable: () => BrainProjectHealthTable,
15
+ BrainQueryCacheTable: () => BrainQueryCacheTable,
16
+ BrainRelationshipTable: () => BrainRelationshipTable,
17
+ BrainSemanticEmbeddingTable: () => BrainSemanticEmbeddingTable,
18
+ BrainSymbolTable: () => BrainSymbolTable,
19
+ BrainTaintFlowTable: () => BrainTaintFlowTable
20
+ });
21
+ import { sqliteTable as sqliteTable2, text as text2, integer as integer2, real, blob, index } from "drizzle-orm/sqlite-core";
22
+
23
+ // src/project/project.sql.ts
24
+ var project_sql_exports = {};
25
+ __export(project_sql_exports, {
26
+ ProjectTable: () => ProjectTable
27
+ });
28
+ import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
29
+ var ProjectTable = sqliteTable("project", {
30
+ id: text("id").primaryKey(),
31
+ workspace_id: text("workspace_id").notNull(),
32
+ name: text("name"),
33
+ time_created: integer("time_created").notNull(),
34
+ time_updated: integer("time_updated").notNull()
35
+ });
36
+
37
+ // src/brain/brain.sql.ts
38
+ var Timestamps = {
39
+ time_created: integer2("time_created").notNull(),
40
+ time_updated: integer2("time_updated").notNull()
41
+ };
42
+ var BrainFileTable = sqliteTable2(
43
+ "brain_file",
44
+ {
45
+ id: text2().primaryKey(),
46
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
47
+ path: text2().notNull(),
48
+ relative_path: text2().notNull(),
49
+ file_hash: text2().notNull(),
50
+ size_bytes: integer2(),
51
+ line_count: integer2(),
52
+ language: text2(),
53
+ last_modified: real(),
54
+ indexed_at: text2(),
55
+ layer: text2(),
56
+ // e.g., "ui", "business", "data", "infrastructure"
57
+ is_test_file: integer2({ mode: "boolean" }),
58
+ is_config_file: integer2({ mode: "boolean" }),
59
+ is_documentation: integer2({ mode: "boolean" }),
60
+ framework_type: text2(),
61
+ // e.g., "react", "flutter", "express", "django"
62
+ has_syntax_errors: integer2({ mode: "boolean" }).notNull().default(false),
63
+ error_report: text2({ mode: "json" }),
64
+ ...Timestamps
65
+ },
66
+ (table) => [
67
+ index("brain_file_project_idx").on(table.project_id),
68
+ index("brain_file_path_idx").on(table.path),
69
+ index("brain_file_language_idx").on(table.language),
70
+ index("brain_file_hash_idx").on(table.file_hash),
71
+ index("brain_file_syntax_errors_idx").on(table.has_syntax_errors),
72
+ // COMPOUND INDEXES for ultra-fast lookups
73
+ index("brain_file_proj_path_idx").on(table.project_id, table.path),
74
+ index("brain_file_proj_hash_idx").on(table.project_id, table.file_hash)
75
+ ]
76
+ );
77
+ var BrainSymbolTable = sqliteTable2(
78
+ "brain_symbol",
79
+ {
80
+ id: text2().primaryKey(),
81
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
82
+ file_id: text2().notNull().references(() => BrainFileTable.id, { onDelete: "cascade" }),
83
+ name: text2().notNull(),
84
+ qualified_name: text2(),
85
+ // Full namespace/module path
86
+ symbol_type: text2().notNull(),
87
+ // "function", "class", "variable", "interface", "enum", "type", etc.
88
+ line_start: integer2(),
89
+ line_end: integer2(),
90
+ byte_start: integer2(),
91
+ byte_end: integer2(),
92
+ return_type: text2(),
93
+ parameters: text2({ mode: "json" }),
94
+ docstring: text2(),
95
+ visibility: text2(),
96
+ // "public", "private", "protected", "internal"
97
+ is_async: integer2({ mode: "boolean" }),
98
+ is_static: integer2({ mode: "boolean" }),
99
+ is_abstract: integer2({ mode: "boolean" }),
100
+ is_override: integer2({ mode: "boolean" }),
101
+ is_getter: integer2({ mode: "boolean" }),
102
+ is_setter: integer2({ mode: "boolean" }),
103
+ complexity: integer2(),
104
+ owner_symbol_id: text2(),
105
+ // Parent class/namespace
106
+ scope_kind: text2(),
107
+ // "global", "class", "function", "module"
108
+ is_declaration: integer2({ mode: "boolean" }),
109
+ // #612: analyzer-published declaration (c prototype, cpp/rust/zig signature form); NULL/0 = definition
110
+ annotations: text2({ mode: "json" }),
111
+ // Language-specific annotations/decorators
112
+ generic_parameters: text2({ mode: "json" }),
113
+ qualified_calls: text2({ mode: "json" }),
114
+ // ProxiCall-style: JSON array of qualified call strings extracted as-is
115
+ gravity_score: real().default(0),
116
+ layer: text2().default("core"),
117
+ api_contract_path: text2(),
118
+ // Deterministic mapping: Exact Route URL or Fetch URL for 100% accurate cross-language links
119
+ ...Timestamps
120
+ },
121
+ (table) => [
122
+ index("brain_symbol_project_idx").on(table.project_id),
123
+ index("brain_symbol_file_idx").on(table.file_id),
124
+ index("brain_symbol_name_idx").on(table.name),
125
+ index("brain_symbol_type_idx").on(table.symbol_type),
126
+ index("brain_symbol_qualified_idx").on(table.qualified_name),
127
+ index("brain_symbol_owner_idx").on(table.owner_symbol_id),
128
+ // COMPOUND INDEXES for ultra-fast lookups
129
+ index("brain_sym_proj_file_idx").on(table.project_id, table.file_id),
130
+ index("brain_sym_proj_name_idx").on(table.project_id, table.name),
131
+ index("brain_sym_proj_type_idx").on(table.project_id, table.symbol_type),
132
+ // Tool query: find symbol by project + name + type (callers/callees trace)
133
+ index("brain_sym_proj_name_type_idx").on(table.project_id, table.name, table.symbol_type)
134
+ ]
135
+ );
136
+ var BrainRelationshipTable = sqliteTable2(
137
+ "brain_relationship",
138
+ {
139
+ id: text2().primaryKey(),
140
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
141
+ source_symbol_id: text2().references(() => BrainSymbolTable.id, { onDelete: "cascade" }),
142
+ target_symbol_id: text2().references(() => BrainSymbolTable.id, { onDelete: "set null" }),
143
+ source_external: text2(),
144
+ // For unresolved / external sources (when source is a string but symbol not declared)
145
+ target_external: text2(),
146
+ // For external dependencies
147
+ relationship_type: text2().notNull(),
148
+ // "calls", "extends", "implements", "uses", "imports", "exports", etc.
149
+ confidence: real().notNull(),
150
+ // 0.0 to 1.0 - AI confidence in relationship
151
+ context: text2(),
152
+ // Additional context about the relationship
153
+ line_number: integer2(),
154
+ // Where relationship occurs
155
+ is_cross_language: integer2({ mode: "boolean" }),
156
+ // True for relationships across languages
157
+ bridge_mechanism: text2(),
158
+ // How cross-language bridge works (API, FFI, etc.)
159
+ is_cross_file: integer2({ mode: "boolean" }).notNull().default(false),
160
+ // Fast UI stat index
161
+ metadata: text2({ mode: "json" }),
162
+ // Flexible metadata storage
163
+ ...Timestamps
164
+ },
165
+ (table) => [
166
+ index("brain_rel_project_idx").on(table.project_id),
167
+ index("brain_rel_source_idx").on(table.source_symbol_id),
168
+ index("brain_rel_target_idx").on(table.target_symbol_id),
169
+ // Enrichment in-degree: GROUP BY target_symbol_id WHERE project_id
170
+ index("brain_rel_proj_target_idx").on(table.project_id, table.target_symbol_id),
171
+ index("brain_rel_type_idx").on(table.relationship_type),
172
+ index("brain_rel_confidence_idx").on(table.confidence),
173
+ index("brain_rel_cross_lang_idx").on(table.is_cross_language),
174
+ index("brain_rel_cross_file_idx").on(table.is_cross_file),
175
+ // COMPOUND INDEXES for ultra-fast lookups
176
+ index("brain_rel_proj_source_idx").on(table.project_id, table.source_symbol_id),
177
+ index("brain_rel_proj_target_idx").on(table.project_id, table.target_symbol_id),
178
+ index("brain_rel_proj_type_idx").on(table.project_id, table.relationship_type),
179
+ // Tool query: find callers/callees by target symbol + relationship type
180
+ index("brain_rel_target_type_idx").on(table.target_symbol_id, table.relationship_type),
181
+ // M29.R3: hover's cross-language probes (is_cross_language = 1 AND
182
+ // target/source_symbol_id = ?) need the composite form — see schema-ddl.ts.
183
+ index("brain_rel_target_cross_idx").on(table.target_symbol_id, table.is_cross_language),
184
+ index("brain_rel_source_cross_idx").on(table.source_symbol_id, table.is_cross_language)
185
+ ]
186
+ );
187
+ var BrainImportTable = sqliteTable2(
188
+ "brain_import",
189
+ {
190
+ id: text2().primaryKey(),
191
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
192
+ file_id: text2().notNull().references(() => BrainFileTable.id, { onDelete: "cascade" }),
193
+ imported_name: text2().notNull(),
194
+ imported_as: text2(),
195
+ // Alias name
196
+ import_path: text2().notNull(),
197
+ import_type: text2().notNull(),
198
+ // "default", "named", "namespace", "side_effect"
199
+ is_external: integer2({ mode: "boolean" }),
200
+ // External package vs internal
201
+ package_name: text2(),
202
+ // For external imports
203
+ line_number: integer2(),
204
+ is_dynamic: integer2({ mode: "boolean" }),
205
+ // Dynamic imports
206
+ resolved_symbol_id: text2(),
207
+ // Link to actual symbol if internal
208
+ ...Timestamps
209
+ },
210
+ (table) => [
211
+ index("brain_import_project_idx").on(table.project_id),
212
+ index("brain_import_file_idx").on(table.file_id),
213
+ index("brain_import_path_idx").on(table.import_path),
214
+ index("brain_import_name_idx").on(table.imported_name),
215
+ index("brain_import_external_idx").on(table.is_external)
216
+ ]
217
+ );
218
+ var BrainTaintFlowTable = sqliteTable2(
219
+ "brain_taint_flow",
220
+ {
221
+ id: text2().primaryKey(),
222
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
223
+ source_symbol_id: text2().references(() => BrainSymbolTable.id, { onDelete: "cascade" }),
224
+ sink_symbol_id: text2().references(() => BrainSymbolTable.id, { onDelete: "cascade" }),
225
+ source_type: text2().notNull(),
226
+ // "user_input", "database_read", "network_receive"
227
+ sink_type: text2().notNull(),
228
+ // "database_write", "log_output", "shell_execution", "http_response"
229
+ vulnerability_type: text2().notNull(),
230
+ // "sql_injection", "xss", "pii_leak", "command_injection"
231
+ severity: text2().notNull(),
232
+ // "critical", "high", "medium", "low"
233
+ is_mitigated: integer2({ mode: "boolean" }).notNull().default(false),
234
+ flow_path: text2({ mode: "json" }),
235
+ // Array of intermediate symbol IDs
236
+ cross_language_boundaries: integer2().notNull().default(0),
237
+ mitigation_steps: text2({ mode: "json" }),
238
+ ...Timestamps
239
+ },
240
+ (table) => [
241
+ index("brain_taint_project_idx").on(table.project_id),
242
+ index("brain_taint_source_idx").on(table.source_symbol_id),
243
+ index("brain_taint_sink_idx").on(table.sink_symbol_id),
244
+ index("brain_taint_vuln_idx").on(table.vulnerability_type),
245
+ index("brain_taint_severity_idx").on(table.severity)
246
+ ]
247
+ );
248
+ var BrainAnalysisRunTable = sqliteTable2(
249
+ "brain_analysis_run",
250
+ {
251
+ id: text2().primaryKey(),
252
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
253
+ kind: text2().notNull(),
254
+ status: text2().notNull(),
255
+ engine_version: text2().notNull(),
256
+ input_hash: text2().notNull(),
257
+ started_at: integer2().notNull(),
258
+ completed_at: integer2(),
259
+ finding_count: integer2().notNull().default(0),
260
+ error: text2(),
261
+ ...Timestamps
262
+ },
263
+ (table) => [
264
+ index("brain_analysis_run_project_idx").on(table.project_id),
265
+ index("brain_analysis_run_kind_idx").on(table.kind),
266
+ index("brain_analysis_run_started_idx").on(table.started_at)
267
+ ]
268
+ );
269
+ var BrainAnalysisFindingTable = sqliteTable2(
270
+ "brain_analysis_finding",
271
+ {
272
+ id: text2().primaryKey(),
273
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
274
+ kind: text2().notNull(),
275
+ fingerprint: text2().notNull(),
276
+ rule: text2().notNull(),
277
+ title: text2().notNull(),
278
+ severity: text2().notNull(),
279
+ state: text2().notNull(),
280
+ confidence: real(),
281
+ evidence: text2({ mode: "json" }),
282
+ first_seen_at: integer2().notNull(),
283
+ last_seen_at: integer2().notNull(),
284
+ resolved_at: integer2(),
285
+ suppressed_at: integer2(),
286
+ mitigated_at: integer2(),
287
+ occurrence_count: integer2().notNull().default(0),
288
+ ...Timestamps
289
+ },
290
+ (table) => [
291
+ index("brain_analysis_finding_project_idx").on(table.project_id),
292
+ index("brain_analysis_finding_fingerprint_idx").on(table.project_id, table.kind, table.fingerprint),
293
+ index("brain_analysis_finding_state_idx").on(table.project_id, table.state)
294
+ ]
295
+ );
296
+ var BrainAnalysisOccurrenceTable = sqliteTable2(
297
+ "brain_analysis_occurrence",
298
+ {
299
+ id: text2().primaryKey(),
300
+ finding_id: text2().notNull().references(() => BrainAnalysisFindingTable.id, { onDelete: "cascade" }),
301
+ run_id: text2().notNull().references(() => BrainAnalysisRunTable.id, { onDelete: "cascade" }),
302
+ state: text2().notNull(),
303
+ location: text2(),
304
+ evidence: text2({ mode: "json" }),
305
+ observed_at: integer2().notNull(),
306
+ ...Timestamps
307
+ },
308
+ (table) => [
309
+ index("brain_analysis_occurrence_finding_idx").on(table.finding_id),
310
+ index("brain_analysis_occurrence_run_idx").on(table.run_id)
311
+ ]
312
+ );
313
+ var BrainQueryCacheTable = sqliteTable2(
314
+ "brain_query_cache",
315
+ {
316
+ id: text2().primaryKey(),
317
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
318
+ query_type: text2().notNull(),
319
+ // "call_graph", "impact_analysis", "feature_map", etc.
320
+ query_hash: text2().notNull(),
321
+ query_params: text2({ mode: "json" }),
322
+ result_data: text2({ mode: "json" }),
323
+ confidence: real().notNull(),
324
+ computation_time_ms: integer2(),
325
+ cache_expires_at: integer2(),
326
+ hit_count: integer2().notNull().default(0),
327
+ ...Timestamps
328
+ },
329
+ (table) => [
330
+ index("brain_cache_project_idx").on(table.project_id),
331
+ index("brain_cache_query_type_idx").on(table.query_type),
332
+ index("brain_cache_hash_idx").on(table.query_hash),
333
+ index("brain_cache_expires_idx").on(table.cache_expires_at)
334
+ ]
335
+ );
336
+ var BrainProjectHealthTable = sqliteTable2("brain_project_health", {
337
+ project_id: text2().$type().primaryKey().references(() => ProjectTable.id, { onDelete: "cascade" }),
338
+ complexity_score: integer2().notNull().default(0),
339
+ // 0-100
340
+ maintainability_score: integer2().notNull().default(0),
341
+ // 0-100
342
+ technical_debt_score: integer2().notNull().default(0),
343
+ // 0-100
344
+ code_quality_score: integer2().notNull().default(0),
345
+ // 0-100
346
+ language_distribution: text2({ mode: "json" }),
347
+ // LanguageMetric[]
348
+ service_metrics: text2({ mode: "json" }),
349
+ // ServiceMetric[]
350
+ dependency_metrics: text2({ mode: "json" }),
351
+ // DependencyMetric
352
+ circular_dependencies: text2({ mode: "json" }),
353
+ // string[][]
354
+ contract_drift: text2({ mode: "json" }),
355
+ // string[]
356
+ performance_bottlenecks: text2({ mode: "json" }),
357
+ // string[]
358
+ ...Timestamps
359
+ });
360
+ var BrainIndexStatusTable = sqliteTable2("brain_index_status", {
361
+ project_id: text2().$type().primaryKey().references(() => ProjectTable.id, { onDelete: "cascade" }),
362
+ status: text2(),
363
+ // M21.I2: persisted complete/partial status (previously dropped)
364
+ last_full_index: integer2(),
365
+ // Timestamp
366
+ last_incremental_index: integer2(),
367
+ total_files: integer2().notNull().default(0),
368
+ indexed_files: integer2().notNull().default(0),
369
+ total_symbols: integer2().notNull().default(0),
370
+ total_relationships: integer2().notNull().default(0),
371
+ indexing_version: text2().notNull(),
372
+ // Schema version for migrations
373
+ languages_detected: text2({ mode: "json" }),
374
+ // Array of languages found
375
+ frameworks_detected: text2({ mode: "json" }),
376
+ // Array of frameworks detected
377
+ indexing_errors: text2({ mode: "json" }),
378
+ // Array of error messages
379
+ performance_stats: text2({ mode: "json" }),
380
+ // Indexing performance metrics
381
+ ...Timestamps
382
+ });
383
+ var BrainSemanticEmbeddingTable = sqliteTable2(
384
+ "brain_semantic_embedding",
385
+ {
386
+ id: text2().primaryKey(),
387
+ project_id: text2().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
388
+ entity_id: text2().notNull(),
389
+ // Can be symbol_id, file_id, or pattern_id
390
+ entity_type: text2().notNull(),
391
+ // "symbol", "file", "pattern", "comment", "documentation"
392
+ embedding_model: text2().notNull(),
393
+ // "openai-ada-002", "sentence-transformers", etc.
394
+ embedding_vector: text2().notNull(),
395
+ // "" for dense rows (blob is authoritative); JSON for sparse/legacy rows
396
+ // Dense vectors are stored ONCE here as little-endian float32 (2026-11-01 contract);
397
+ // NULL on legacy rows (readers then scan embedding_vector). See vector-binary.ts.
398
+ embedding_blob: blob("embedding_blob", { mode: "buffer" }),
399
+ vector_dimension: integer2().notNull(),
400
+ content_hash: text2().notNull(),
401
+ // Hash of content that generated embedding
402
+ semantic_context: text2({ mode: "json" }),
403
+ // Additional context for better search
404
+ similarity_threshold: real().default(0.7),
405
+ // Minimum similarity for matches
406
+ last_updated: integer2().notNull(),
407
+ ...Timestamps
408
+ },
409
+ (table) => [
410
+ index("brain_embed_project_idx").on(table.project_id),
411
+ index("brain_embed_entity_idx").on(table.entity_id),
412
+ index("brain_embed_type_idx").on(table.entity_type),
413
+ index("brain_embed_model_idx").on(table.embedding_model),
414
+ index("brain_embed_hash_idx").on(table.content_hash)
415
+ ]
416
+ );
417
+
418
+ export {
419
+ project_sql_exports,
420
+ BrainFileTable,
421
+ BrainSymbolTable,
422
+ BrainRelationshipTable,
423
+ BrainImportTable,
424
+ BrainTaintFlowTable,
425
+ BrainAnalysisRunTable,
426
+ BrainAnalysisFindingTable,
427
+ BrainAnalysisOccurrenceTable,
428
+ BrainQueryCacheTable,
429
+ BrainProjectHealthTable,
430
+ BrainIndexStatusTable,
431
+ BrainSemanticEmbeddingTable,
432
+ brain_sql_exports
433
+ };
@@ -0,0 +1,211 @@
1
+ import {
2
+ bbWasmCandidates,
3
+ bbWasmDirs
4
+ } from "./chunk-2BSKD7O3.js";
5
+
6
+ // src/util/wasm.ts
7
+ import { createRequire } from "module";
8
+ import { existsSync, readFileSync, readdirSync } from "fs";
9
+ import { join, dirname } from "path";
10
+ import { fileURLToPath } from "url";
11
+ var require2 = createRequire(import.meta.url);
12
+ var __filename = fileURLToPath(import.meta.url);
13
+ var __dirname = dirname(__filename);
14
+ var _wtsModule = null;
15
+ var _wasmRegistry = {};
16
+ var _wasiShimInstalled = false;
17
+ function installWasiShim() {
18
+ if (_wasiShimInstalled) return;
19
+ _wasiShimInstalled = true;
20
+ let currentImports = null;
21
+ const memOf = () => currentImports?.env?.memory;
22
+ const view = () => {
23
+ const mem = memOf();
24
+ return mem ? new DataView(mem.buffer) : null;
25
+ };
26
+ const writeInt32 = (ptr, value) => {
27
+ const v = view();
28
+ if (v && Number.isFinite(ptr)) v.setInt32(ptr, value, true);
29
+ };
30
+ const writeBigInt = (ptr, value) => {
31
+ const v = view();
32
+ if (v && Number.isFinite(ptr)) v.setBigUint64(ptr, value, true);
33
+ };
34
+ const wasi = {
35
+ clock_time_get: (_clockId, _precisionPtr, timePtr) => {
36
+ writeBigInt(timePtr, BigInt(Date.now()) * 1000000n);
37
+ return 0;
38
+ },
39
+ proc_exit: () => {
40
+ },
41
+ fd_write: (_fd, _iov, _iovcnt, pnum) => {
42
+ writeInt32(pnum, 0);
43
+ return 0;
44
+ },
45
+ fd_read: () => -1,
46
+ fd_close: () => 0,
47
+ fd_seek: () => -1,
48
+ fd_fdstat_get: () => -1,
49
+ fd_fdstat_set_flags: () => -1,
50
+ fd_prestat_get: () => -1,
51
+ fd_prestat_dir_name: () => -1,
52
+ fd_sync: () => -1,
53
+ random_get: (buf, len) => {
54
+ const v = view();
55
+ if (v) for (let i = 0; i < len; i++) v.setUint8(buf + i, Math.floor(Math.random() * 256));
56
+ return 0;
57
+ },
58
+ environ_get: () => 0,
59
+ environ_sizes_get: (countPtr, sizePtr) => {
60
+ writeInt32(countPtr, 0);
61
+ writeInt32(sizePtr, 0);
62
+ return 0;
63
+ },
64
+ args_get: () => 0,
65
+ args_sizes_get: (countPtr, sizePtr) => {
66
+ writeInt32(countPtr, 0);
67
+ writeInt32(sizePtr, 0);
68
+ return 0;
69
+ },
70
+ sched_yield: () => 0,
71
+ poll_oneoff: () => 0,
72
+ path_open: () => -1,
73
+ path_filestat_get: () => -1,
74
+ path_filestat_set_times: () => -1,
75
+ path_create_directory: () => -1,
76
+ path_remove_directory: () => -1,
77
+ path_unlink_file: () => -1,
78
+ path_rename: () => -1,
79
+ path_link: () => -1,
80
+ path_symlink: () => -1,
81
+ path_readlink: () => -1,
82
+ path_filestat_set_size: () => -1,
83
+ clock_res_get: (_clockId, resPtr) => {
84
+ writeBigInt(resPtr, 1000000n);
85
+ return 0;
86
+ }
87
+ };
88
+ const patchImports = (imports) => {
89
+ if (!imports || typeof imports !== "object") return imports;
90
+ currentImports = imports;
91
+ if (imports.wasi_snapshot_preview1) {
92
+ imports.wasi_snapshot_preview1 = { ...imports.wasi_snapshot_preview1, ...wasi };
93
+ }
94
+ return imports;
95
+ };
96
+ const origInstantiate = WebAssembly.instantiate;
97
+ const origInstantiateStreaming = WebAssembly.instantiateStreaming;
98
+ WebAssembly.instantiate = async (bytes, imports) => {
99
+ if (imports) imports = patchImports(imports);
100
+ return origInstantiate.call(WebAssembly, bytes, imports);
101
+ };
102
+ WebAssembly.instantiateStreaming = async (resp, imports) => {
103
+ if (imports) imports = patchImports(imports);
104
+ return origInstantiateStreaming.call(WebAssembly, resp, imports);
105
+ };
106
+ }
107
+ function tryLoadWasm(name) {
108
+ if (_wasmRegistry[name]) return;
109
+ const paths = bbWasmCandidates(dirname(fileURLToPath(import.meta.url)), name);
110
+ for (const p of paths) {
111
+ if (existsSync(p)) {
112
+ try {
113
+ _wasmRegistry[name] = new Uint8Array(readFileSync(p));
114
+ return;
115
+ } catch {
116
+ }
117
+ }
118
+ }
119
+ }
120
+ async function ensureWasmRegistry() {
121
+ const dirs = bbWasmDirs(__dirname);
122
+ for (const wasmDir of dirs) {
123
+ if (existsSync(wasmDir)) {
124
+ try {
125
+ const files = (await import("fs")).readdirSync(wasmDir);
126
+ for (const f of files) {
127
+ if (f.endsWith(".wasm") && !_wasmRegistry[f]) {
128
+ try {
129
+ _wasmRegistry[f] = new Uint8Array(readFileSync(join(wasmDir, f)));
130
+ } catch {
131
+ }
132
+ }
133
+ }
134
+ } catch {
135
+ }
136
+ }
137
+ }
138
+ }
139
+ async function loadWebTreeSitter() {
140
+ if (!_wtsModule) {
141
+ installWasiShim();
142
+ _wtsModule = await import("web-tree-sitter");
143
+ const initFn = _wtsModule.default?.init || _wtsModule.init;
144
+ if (initFn) {
145
+ const coreName = "tree-sitter.wasm";
146
+ const coreBytes = hasWasmInRegistry(coreName);
147
+ const coreAbs = resolveWasmAsset(coreName);
148
+ const initOptions = {};
149
+ if (coreBytes) initOptions.wasmBinary = coreBytes;
150
+ if (coreAbs !== coreName) initOptions.locateFile = () => coreAbs;
151
+ await initFn(initOptions);
152
+ }
153
+ }
154
+ return _wtsModule;
155
+ }
156
+ function resolveWasmAsset(name) {
157
+ const wasmName = name.split("/").pop() || name;
158
+ const paths = bbWasmCandidates(dirname(fileURLToPath(import.meta.url)), wasmName);
159
+ for (const p of paths) {
160
+ if (existsSync(p)) return p;
161
+ }
162
+ return name;
163
+ }
164
+ function hasWasmInRegistry(name) {
165
+ const wasmName = name.split("/").pop() || name;
166
+ tryLoadWasm(wasmName);
167
+ if (_wasmRegistry[wasmName]) return _wasmRegistry[wasmName];
168
+ if (_wasmRegistry[name]) return _wasmRegistry[name];
169
+ const paths = bbWasmCandidates(dirname(fileURLToPath(import.meta.url)), wasmName);
170
+ for (const p of paths) {
171
+ if (existsSync(p)) {
172
+ try {
173
+ const data = new Uint8Array(readFileSync(p));
174
+ _wasmRegistry[wasmName] = data;
175
+ return data;
176
+ } catch {
177
+ }
178
+ }
179
+ }
180
+ return void 0;
181
+ }
182
+ function isWasmRegistryLoaded() {
183
+ return false;
184
+ }
185
+ (function _autoLoadWasm() {
186
+ const dirs = bbWasmDirs(__dirname);
187
+ for (const wasmDir of dirs) {
188
+ if (existsSync(wasmDir)) {
189
+ try {
190
+ const files = readdirSync(wasmDir);
191
+ for (const f of files) {
192
+ if (f.endsWith(".wasm") && !_wasmRegistry[f]) {
193
+ try {
194
+ _wasmRegistry[f] = new Uint8Array(readFileSync(join(wasmDir, f)));
195
+ } catch {
196
+ }
197
+ }
198
+ }
199
+ } catch {
200
+ }
201
+ }
202
+ }
203
+ })();
204
+
205
+ export {
206
+ ensureWasmRegistry,
207
+ loadWebTreeSitter,
208
+ resolveWasmAsset,
209
+ hasWasmInRegistry,
210
+ isWasmRegistryLoaded
211
+ };