@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.
- package/CHANGELOG.md +298 -0
- package/EMBEDDINGS.md +355 -0
- package/LICENSE +21 -0
- package/README.md +415 -2
- package/bin/bb +13 -0
- package/dist/analysis-exclusions-7ZJDXOVZ.js +35 -0
- package/dist/brain-index-health-KY7K552E.js +17 -0
- package/dist/brain-relationship-enrichment-QH7OOHUF.js +558 -0
- package/dist/brain.sql-EIM4WS4D.js +29 -0
- package/dist/chunk-2BSKD7O3.js +40 -0
- package/dist/chunk-2DE27DVC.js +1314 -0
- package/dist/chunk-2RRBMNBQ.js +322 -0
- package/dist/chunk-2RTN2DFU.js +711 -0
- package/dist/chunk-2WXYNLBA.js +29 -0
- package/dist/chunk-3CTFIJJB.js +17 -0
- package/dist/chunk-3LFTSMIV.js +174 -0
- package/dist/chunk-47HKX4AJ.js +930 -0
- package/dist/chunk-4H22TLOT.js +543 -0
- package/dist/chunk-5SD45FLC.js +818 -0
- package/dist/chunk-66A5ZFYA.js +1758 -0
- package/dist/chunk-6AIRWAO2.js +247 -0
- package/dist/chunk-6WNGD3NN.js +196 -0
- package/dist/chunk-7AN7U5IZ.js +371 -0
- package/dist/chunk-BHB7BYYI.js +626 -0
- package/dist/chunk-BQ3OVQ3P.js +125 -0
- package/dist/chunk-CW4XXSNN.js +1479 -0
- package/dist/chunk-D2Q4Y47A.js +53 -0
- package/dist/chunk-DIYAGQJL.js +34 -0
- package/dist/chunk-DYM4FQEE.js +90 -0
- package/dist/chunk-EWMWK7WN.js +75 -0
- package/dist/chunk-FVVQTSIM.js +3427 -0
- package/dist/chunk-FWSL4VG6.js +1290 -0
- package/dist/chunk-GBI7V7KY.js +69 -0
- package/dist/chunk-GEFFO6O2.js +152 -0
- package/dist/chunk-HOWAQXJO.js +236 -0
- package/dist/chunk-HQSPJDHI.js +613 -0
- package/dist/chunk-IFZNR5UJ.js +2863 -0
- package/dist/chunk-J4PMBXQQ.js +336 -0
- package/dist/chunk-KAET47ZL.js +125 -0
- package/dist/chunk-KCDECRJY.js +440 -0
- package/dist/chunk-KLK3PBTO.js +1119 -0
- package/dist/chunk-L5TDYKYK.js +76 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-OWISBAOF.js +61 -0
- package/dist/chunk-PJTNGD3Z.js +6924 -0
- package/dist/chunk-QLK6ED4Q.js +235 -0
- package/dist/chunk-R2GW4F6R.js +19 -0
- package/dist/chunk-RCMTFSEF.js +87 -0
- package/dist/chunk-RH7KC5HU.js +12050 -0
- package/dist/chunk-RM3PY6TG.js +376 -0
- package/dist/chunk-ROMM6KMC.js +433 -0
- package/dist/chunk-SK6YVHFZ.js +211 -0
- package/dist/chunk-SM7RFQRO.js +214 -0
- package/dist/chunk-UFE77L67.js +782 -0
- package/dist/chunk-UGR4QIGS.js +67 -0
- package/dist/chunk-UUNHHX4M.js +13 -0
- package/dist/chunk-V44PGPA6.js +2104 -0
- package/dist/chunk-VL52PL2T.js +71 -0
- package/dist/chunk-VURYFIHW.js +201 -0
- package/dist/chunk-XJKJYIPP.js +7436 -0
- package/dist/chunk-YI6FF2ZR.js +340 -0
- package/dist/cli/index.js +37 -0
- package/dist/config-HZAAYDP3.js +10 -0
- package/dist/content-search-642F7E5V.js +593 -0
- package/dist/database-TCTZDLE5.js +9 -0
- package/dist/doctor-GXCKSJOX.js +395 -0
- package/dist/edit-engine-KM7MPFEC.js +51 -0
- package/dist/engine-42TZFNIZ.js +11 -0
- package/dist/engine-LO6L4JLQ.js +18 -0
- package/dist/fingerprint-XDXFRWO6.js +33 -0
- package/dist/framework-intelligence-DWFCKV44.js +860 -0
- package/dist/freshness-3K6VU5OT.js +174 -0
- package/dist/graph-engine-PL5YA7BA.js +21 -0
- package/dist/graph_request-MM4REP6H.js +350 -0
- package/dist/impact_request-WDE47IZ5.js +68 -0
- package/dist/index-space-IUUN5WYV.js +15 -0
- package/dist/index-status-6BD7UBHR.js +34 -0
- package/dist/index.js +159 -0
- package/dist/instance-FO6QZRLH.js +19 -0
- package/dist/language-detection-DFCAU5DZ.js +11 -0
- package/dist/lsp/server.js +4301 -0
- package/dist/mcp/server.js +132 -0
- package/dist/onboard-DIQZV2NW.js +161 -0
- package/dist/override-companion-pass-XR7MHTP7.js +117 -0
- package/dist/parallel-indexer-4PW3AFXP.js +88 -0
- package/dist/pool-worker.js +1153 -0
- package/dist/project-health-ZS5TS2Z6.js +94 -0
- package/dist/project-index-5SDPHITE.js +57 -0
- package/dist/project-registry-DGZBIZS7.js +355 -0
- package/dist/real-bash-analyzer-SXSV67E2.js +2201 -0
- package/dist/real-c-analyzer-SY7FTZ6W.js +5942 -0
- package/dist/real-clean-analyzer-IGDHHLZK.js +3470 -0
- package/dist/real-clojure-analyzer-4OH7IWLB.js +2818 -0
- package/dist/real-cpp-analyzer-7LTDRJRJ.js +4101 -0
- package/dist/real-csharp-analyzer-KICU3TLH.js +3298 -0
- package/dist/real-css-analyzer-HPU277Q6.js +15 -0
- package/dist/real-dart-analyzer-7LZ5LCMW.js +3944 -0
- package/dist/real-elixir-analyzer-BE3MEVZO.js +2192 -0
- package/dist/real-erlang-analyzer-BZMAKYBK.js +1731 -0
- package/dist/real-fsharp-analyzer-5QLTOV3E.js +2390 -0
- package/dist/real-go-analyzer-POD7MZQR.js +4126 -0
- package/dist/real-graphql-analyzer-MAQRZ6QW.js +1442 -0
- package/dist/real-groovy-analyzer-MEWSUPMJ.js +2285 -0
- package/dist/real-haskell-analyzer-I5L2GR3Y.js +2533 -0
- package/dist/real-hcl-analyzer-DBOPXSWJ.js +725 -0
- package/dist/real-html-analyzer-O63XZLZD.js +1759 -0
- package/dist/real-java-analyzer-CHCW3EKA.js +4677 -0
- package/dist/real-javascript-analyzer-QAAJQYZE.js +14 -0
- package/dist/real-json-analyzer-UGBR7YQN.js +1640 -0
- package/dist/real-julia-analyzer-35Q4GHOZ.js +2085 -0
- package/dist/real-kotlin-analyzer-GRAYCWW2.js +3956 -0
- package/dist/real-lua-analyzer-5BAPDZDF.js +1957 -0
- package/dist/real-makefile-analyzer-YJKAHNAS.js +920 -0
- package/dist/real-markdown-analyzer-UKUQZO4F.js +1215 -0
- package/dist/real-matlab-analyzer-FVIKQZKG.js +480 -0
- package/dist/real-nim-analyzer-M7FAIABG.js +3603 -0
- package/dist/real-objective-c-analyzer-XMYQIGQI.js +1518 -0
- package/dist/real-perl-analyzer-ZLY6M2DZ.js +1865 -0
- package/dist/real-php-analyzer-KI2ZAM7X.js +9368 -0
- package/dist/real-powershell-analyzer-B3T5ZP6U.js +2915 -0
- package/dist/real-protobuf-analyzer-23OZ75XV.js +867 -0
- package/dist/real-python-analyzer-I4TIUB6D.js +4880 -0
- package/dist/real-r-analyzer-FJZJXXS6.js +2596 -0
- package/dist/real-ruby-analyzer-M3UFIVTQ.js +2429 -0
- package/dist/real-rust-analyzer-LVSONPAN.js +3359 -0
- package/dist/real-scala-analyzer-CWPI33Q2.js +3293 -0
- package/dist/real-scss-analyzer-TGRJQ7TH.js +1515 -0
- package/dist/real-solidity-analyzer-4P2VBVWA.js +2608 -0
- package/dist/real-sql-analyzer-J7DYZOZR.js +3840 -0
- package/dist/real-svelte-analyzer-NHEN2SX5.js +2532 -0
- package/dist/real-swift-analyzer-2NSYULWI.js +2311 -0
- package/dist/real-toml-analyzer-L3C66L7Q.js +929 -0
- package/dist/real-typescript-analyzer-FTC6ETRQ.js +14 -0
- package/dist/real-vb-analyzer-ORY7LAQS.js +3145 -0
- package/dist/real-vba-analyzer-JH2TTUFI.js +466 -0
- package/dist/real-vue-analyzer-OO4FUGBV.js +2680 -0
- package/dist/real-xml-analyzer-6CQVR477.js +2405 -0
- package/dist/real-yaml-analyzer-J6MQG3YX.js +3528 -0
- package/dist/real-zig-analyzer-EFKCPJNU.js +2430 -0
- package/dist/regex-search-OPTLKUN5.js +239 -0
- package/dist/rules-I453JTRC.js +152 -0
- package/dist/scoped-path-MJYWJZQX.js +11 -0
- package/dist/setup-show-Y5GB5KXA.js +15 -0
- package/dist/setup-wizard-G5YYR5T6.js +24 -0
- package/dist/symbol-search-KB4MU4SI.js +16 -0
- package/dist/taint-YOTN5X55.js +202 -0
- package/dist/taint-analyzer-N7YLZU3N.js +163 -0
- package/dist/tool-handlers-G4NAGJIH.js +72 -0
- package/dist/tool-registry-BPEJNSZG.js +17 -0
- package/dist/tool-validation-RF675A3C.js +32 -0
- package/dist/type-inference-4Y7WTMFE.js +13 -0
- package/dist/vector-binary-LMY4QGAN.js +19 -0
- package/dist/version-LXGNFO37.js +9 -0
- package/dist/wasm-NMWO3WXY.js +16 -0
- package/docs/EMBEDDINGS.md +132 -0
- package/docs/README.md +178 -0
- package/docs/data/m10-baseline.json +602 -0
- package/docs/data/m10-benchmark-baseline.json +57 -0
- package/docs/data/m10-benchmark-last-run.json +127 -0
- package/docs/data/m10-final-audit.json +215 -0
- package/docs/data/m12-final-audit.json +138 -0
- package/docs/data/m12-surface-matrix.json +50 -0
- package/docs/data/public-tools.json +1902 -0
- package/docs/indexing/DEAD-ASSETS.md +88 -0
- package/docs/indexing/INDEXER-REVIEW.md +634 -0
- package/docs/indexing/PERFORMANCE-FINDINGS.md +106 -0
- package/docs/indexing/README.md +427 -0
- package/docs/indexing/discovery-matrix.md +41 -0
- package/docs/indexing/embeddings.md +325 -0
- package/docs/indexing/environment-variables.md +77 -0
- package/docs/indexing/performance.md +323 -0
- package/docs/indexing/resume.md +345 -0
- package/docs/indexing/troubleshooting.md +391 -0
- package/docs/man/bb.1 +190 -0
- package/docs/tools/bb_analyze.md +147 -0
- package/docs/tools/bb_annotate.md +110 -0
- package/docs/tools/bb_annotations.md +106 -0
- package/docs/tools/bb_ask.md +101 -0
- package/docs/tools/bb_cross_language.md +103 -0
- package/docs/tools/bb_doc.md +169 -0
- package/docs/tools/bb_edit.md +185 -0
- package/docs/tools/bb_graph.md +169 -0
- package/docs/tools/bb_health.md +156 -0
- package/docs/tools/bb_impact.md +117 -0
- package/docs/tools/bb_index.md +108 -0
- package/docs/tools/bb_migrate.md +135 -0
- package/docs/tools/bb_patterns.md +140 -0
- package/docs/tools/bb_search.md +150 -0
- package/docs/tools/bb_security.md +100 -0
- package/docs/tools/bb_visualize.md +184 -0
- package/grammars/README.md +57 -0
- package/grammars/THIRD-PARTY-NOTICES.md +50 -0
- package/grammars/tree-sitter-c/LICENSE +21 -0
- package/grammars/tree-sitter-clojure/LICENSE.md +21 -0
- package/grammars/tree-sitter-cpp/LICENSE +21 -0
- package/grammars/tree-sitter-csharp/LICENSE +21 -0
- package/grammars/tree-sitter-css/LICENSE +21 -0
- package/grammars/tree-sitter-css/README.md +21 -0
- package/grammars/tree-sitter-dart/LICENSE +20 -0
- package/grammars/tree-sitter-dart-upstream/LICENSE +20 -0
- package/grammars/tree-sitter-dart-upstream/README.md +18 -0
- package/grammars/tree-sitter-elixir/LICENSE +176 -0
- package/grammars/tree-sitter-elixir/README.md +11 -0
- package/grammars/tree-sitter-fsharp/LICENSE +21 -0
- package/grammars/tree-sitter-fsharp/README.md +45 -0
- package/grammars/tree-sitter-graphql/LICENSE +21 -0
- package/grammars/tree-sitter-graphql/README.md +106 -0
- package/grammars/tree-sitter-groovy/LICENSE +21 -0
- package/grammars/tree-sitter-groovy/README.md +4 -0
- package/grammars/tree-sitter-haskell/LICENSE +21 -0
- package/grammars/tree-sitter-haskell/README.md +394 -0
- package/grammars/tree-sitter-hcl/CHANGELOG.md +102 -0
- package/grammars/tree-sitter-hcl/LICENSE +201 -0
- package/grammars/tree-sitter-hcl/README.md +39 -0
- package/grammars/tree-sitter-html/LICENSE +21 -0
- package/grammars/tree-sitter-html/README.md +21 -0
- package/grammars/tree-sitter-julia/LICENSE +21 -0
- package/grammars/tree-sitter-julia/README.md +24 -0
- package/grammars/tree-sitter-kotlin/LICENSE +9 -0
- package/grammars/tree-sitter-lua/LICENSE.md +21 -0
- package/grammars/tree-sitter-lua/README.md +29 -0
- package/grammars/tree-sitter-make/LICENSE +21 -0
- package/grammars/tree-sitter-matlab/LICENSE +19 -0
- package/grammars/tree-sitter-matlab/README.md +99 -0
- package/grammars/tree-sitter-nim/LICENSE +373 -0
- package/grammars/tree-sitter-nim/README.md +46 -0
- package/grammars/tree-sitter-objc/LICENSE +21 -0
- package/grammars/tree-sitter-objc/README.md +20 -0
- package/grammars/tree-sitter-perl/LICENSE +7 -0
- package/grammars/tree-sitter-perl/README.md +100 -0
- package/grammars/tree-sitter-powershell/LICENSE +21 -0
- package/grammars/tree-sitter-powershell/README.md +7 -0
- package/grammars/tree-sitter-proto/LICENSE +21 -0
- package/grammars/tree-sitter-proto/README.md +105 -0
- package/grammars/tree-sitter-r/LICENSE +9 -0
- package/grammars/tree-sitter-r/README.md +66 -0
- package/grammars/tree-sitter-ruby/LICENSE +22 -0
- package/grammars/tree-sitter-scss/LICENSE +21 -0
- package/grammars/tree-sitter-scss/README.md +17 -0
- package/grammars/tree-sitter-solidity/LICENSE +7 -0
- package/grammars/tree-sitter-sql/LICENSE +21 -0
- package/grammars/tree-sitter-typescript/LICENSE +21 -0
- package/grammars/tree-sitter-vba/LICENSE +21 -0
- package/grammars/tree-sitter-vba/README.md +738 -0
- package/grammars/tree-sitter-vbnet/LICENSE +21 -0
- package/grammars/tree-sitter-vbnet/README.md +322 -0
- package/grammars/tree-sitter-xml/LICENSE +19 -0
- package/grammars/tree-sitter-yaml/LICENSE +20 -0
- package/grammars/tree-sitter-yaml/README.md +21 -0
- package/package.json +184 -4
- package/wasm/dart.wasm +0 -0
- package/wasm/tree-sitter-bash.wasm +0 -0
- package/wasm/tree-sitter-c.wasm +0 -0
- package/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/wasm/tree-sitter-clean.wasm +0 -0
- package/wasm/tree-sitter-clojure.wasm +0 -0
- package/wasm/tree-sitter-core_schema.wasm +0 -0
- package/wasm/tree-sitter-cpp.wasm +0 -0
- package/wasm/tree-sitter-css.wasm +0 -0
- package/wasm/tree-sitter-dart.wasm +0 -0
- package/wasm/tree-sitter-elisp.wasm +0 -0
- package/wasm/tree-sitter-elixir.wasm +0 -0
- package/wasm/tree-sitter-elm.wasm +0 -0
- package/wasm/tree-sitter-embedded_template.wasm +0 -0
- package/wasm/tree-sitter-erlang.wasm +0 -0
- package/wasm/tree-sitter-fsharp.wasm +0 -0
- package/wasm/tree-sitter-fsharp_signature.wasm +0 -0
- package/wasm/tree-sitter-go.wasm +0 -0
- package/wasm/tree-sitter-graphql.wasm +0 -0
- package/wasm/tree-sitter-groovy.wasm +0 -0
- package/wasm/tree-sitter-haskell.wasm +0 -0
- package/wasm/tree-sitter-hcl.wasm +0 -0
- package/wasm/tree-sitter-html.wasm +0 -0
- package/wasm/tree-sitter-java.wasm +0 -0
- package/wasm/tree-sitter-javascript.wasm +0 -0
- package/wasm/tree-sitter-json.wasm +0 -0
- package/wasm/tree-sitter-json_schema.wasm +0 -0
- package/wasm/tree-sitter-julia.wasm +0 -0
- package/wasm/tree-sitter-kotlin.wasm +0 -0
- package/wasm/tree-sitter-lua.wasm +0 -0
- package/wasm/tree-sitter-make.wasm +0 -0
- package/wasm/tree-sitter-markdown.wasm +0 -0
- package/wasm/tree-sitter-markdown_inline.wasm +0 -0
- package/wasm/tree-sitter-matlab.wasm +0 -0
- package/wasm/tree-sitter-nim.wasm +0 -0
- package/wasm/tree-sitter-objc.wasm +0 -0
- package/wasm/tree-sitter-ocaml.wasm +0 -0
- package/wasm/tree-sitter-perl.wasm +0 -0
- package/wasm/tree-sitter-php.wasm +0 -0
- package/wasm/tree-sitter-php_only.wasm +0 -0
- package/wasm/tree-sitter-powershell.wasm +0 -0
- package/wasm/tree-sitter-protobuf.wasm +0 -0
- package/wasm/tree-sitter-python.wasm +0 -0
- package/wasm/tree-sitter-ql.wasm +0 -0
- package/wasm/tree-sitter-r.wasm +0 -0
- package/wasm/tree-sitter-rescript.wasm +0 -0
- package/wasm/tree-sitter-ruby.wasm +0 -0
- package/wasm/tree-sitter-rust.wasm +0 -0
- package/wasm/tree-sitter-scala.wasm +0 -0
- package/wasm/tree-sitter-scss.wasm +0 -0
- package/wasm/tree-sitter-solidity.wasm +0 -0
- package/wasm/tree-sitter-sql.wasm +0 -0
- package/wasm/tree-sitter-svelte.wasm +0 -0
- package/wasm/tree-sitter-swift.wasm +0 -0
- package/wasm/tree-sitter-systemrdl.wasm +0 -0
- package/wasm/tree-sitter-terraform.wasm +0 -0
- package/wasm/tree-sitter-tlaplus.wasm +0 -0
- package/wasm/tree-sitter-toml.wasm +0 -0
- package/wasm/tree-sitter-tsx.wasm +0 -0
- package/wasm/tree-sitter-typescript.wasm +0 -0
- package/wasm/tree-sitter-vba.wasm +0 -0
- package/wasm/tree-sitter-vbnet.wasm +0 -0
- package/wasm/tree-sitter-vue.wasm +0 -0
- package/wasm/tree-sitter-xml.wasm +0 -0
- package/wasm/tree-sitter-yaml.wasm +0 -0
- package/wasm/tree-sitter-zig.wasm +0 -0
- package/wasm/tree-sitter.wasm +0 -0
- package/wasm/tsx.wasm +0 -0
- package/wasm/typescript.wasm +0 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import {
|
|
2
|
+
create
|
|
3
|
+
} from "./chunk-BQ3OVQ3P.js";
|
|
4
|
+
|
|
5
|
+
// src/brain/semantic/local-embed.ts
|
|
6
|
+
var log = create({ service: "local-embed" });
|
|
7
|
+
var WORD_DIM = 50;
|
|
8
|
+
var LOCAL_VECTOR_DIMENSION = WORD_DIM;
|
|
9
|
+
var BASE_WORDS = [
|
|
10
|
+
"function",
|
|
11
|
+
"class",
|
|
12
|
+
"return",
|
|
13
|
+
"import",
|
|
14
|
+
"export",
|
|
15
|
+
"const",
|
|
16
|
+
"let",
|
|
17
|
+
"var",
|
|
18
|
+
"async",
|
|
19
|
+
"await",
|
|
20
|
+
"if",
|
|
21
|
+
"else",
|
|
22
|
+
"for",
|
|
23
|
+
"while",
|
|
24
|
+
"switch",
|
|
25
|
+
"case",
|
|
26
|
+
"break",
|
|
27
|
+
"continue",
|
|
28
|
+
"try",
|
|
29
|
+
"catch",
|
|
30
|
+
"throw",
|
|
31
|
+
"new",
|
|
32
|
+
"this",
|
|
33
|
+
"super",
|
|
34
|
+
"extends",
|
|
35
|
+
"implements",
|
|
36
|
+
"interface",
|
|
37
|
+
"type",
|
|
38
|
+
"enum",
|
|
39
|
+
"public",
|
|
40
|
+
"private",
|
|
41
|
+
"protected",
|
|
42
|
+
"static",
|
|
43
|
+
"abstract",
|
|
44
|
+
"final",
|
|
45
|
+
"override",
|
|
46
|
+
"string",
|
|
47
|
+
"number",
|
|
48
|
+
"boolean",
|
|
49
|
+
"array",
|
|
50
|
+
"object",
|
|
51
|
+
"null",
|
|
52
|
+
"undefined",
|
|
53
|
+
"void",
|
|
54
|
+
"true",
|
|
55
|
+
"false",
|
|
56
|
+
"map",
|
|
57
|
+
"filter",
|
|
58
|
+
"reduce",
|
|
59
|
+
"find",
|
|
60
|
+
"sort",
|
|
61
|
+
"push",
|
|
62
|
+
"pop",
|
|
63
|
+
"slice",
|
|
64
|
+
"promise",
|
|
65
|
+
"callback",
|
|
66
|
+
"event",
|
|
67
|
+
"handler",
|
|
68
|
+
"listener",
|
|
69
|
+
"dispatch",
|
|
70
|
+
"subscribe",
|
|
71
|
+
"module",
|
|
72
|
+
"package",
|
|
73
|
+
"dependency",
|
|
74
|
+
"require",
|
|
75
|
+
"default",
|
|
76
|
+
"data",
|
|
77
|
+
"user",
|
|
78
|
+
"get",
|
|
79
|
+
"set",
|
|
80
|
+
"create",
|
|
81
|
+
"update",
|
|
82
|
+
"delete",
|
|
83
|
+
"fetch",
|
|
84
|
+
"load",
|
|
85
|
+
"save",
|
|
86
|
+
"list",
|
|
87
|
+
"item",
|
|
88
|
+
"result",
|
|
89
|
+
"error",
|
|
90
|
+
"success",
|
|
91
|
+
"fail",
|
|
92
|
+
"check",
|
|
93
|
+
"validate",
|
|
94
|
+
"parse",
|
|
95
|
+
"convert",
|
|
96
|
+
"format",
|
|
97
|
+
"render",
|
|
98
|
+
"display",
|
|
99
|
+
"show",
|
|
100
|
+
"hide",
|
|
101
|
+
"open",
|
|
102
|
+
"close",
|
|
103
|
+
"start",
|
|
104
|
+
"stop",
|
|
105
|
+
"init",
|
|
106
|
+
"setup",
|
|
107
|
+
"config",
|
|
108
|
+
"option",
|
|
109
|
+
"param",
|
|
110
|
+
"value",
|
|
111
|
+
"key",
|
|
112
|
+
"id",
|
|
113
|
+
"name",
|
|
114
|
+
"path",
|
|
115
|
+
"file",
|
|
116
|
+
"dir",
|
|
117
|
+
"read",
|
|
118
|
+
"write",
|
|
119
|
+
"send",
|
|
120
|
+
"receive",
|
|
121
|
+
"request",
|
|
122
|
+
"response",
|
|
123
|
+
"query",
|
|
124
|
+
"select",
|
|
125
|
+
"insert",
|
|
126
|
+
"table",
|
|
127
|
+
"column",
|
|
128
|
+
"row",
|
|
129
|
+
"index",
|
|
130
|
+
"join",
|
|
131
|
+
"api",
|
|
132
|
+
"http",
|
|
133
|
+
"url",
|
|
134
|
+
"server",
|
|
135
|
+
"client",
|
|
136
|
+
"host",
|
|
137
|
+
"port",
|
|
138
|
+
"connect",
|
|
139
|
+
"socket",
|
|
140
|
+
"auth",
|
|
141
|
+
"token",
|
|
142
|
+
"login",
|
|
143
|
+
"logout",
|
|
144
|
+
"session",
|
|
145
|
+
"cookie",
|
|
146
|
+
"password",
|
|
147
|
+
"hash",
|
|
148
|
+
"test",
|
|
149
|
+
"mock",
|
|
150
|
+
"stub",
|
|
151
|
+
"assert",
|
|
152
|
+
"expect",
|
|
153
|
+
"should",
|
|
154
|
+
"describe",
|
|
155
|
+
"before",
|
|
156
|
+
"after",
|
|
157
|
+
"build",
|
|
158
|
+
"deploy",
|
|
159
|
+
"release",
|
|
160
|
+
"version",
|
|
161
|
+
"tag",
|
|
162
|
+
"branch",
|
|
163
|
+
"commit",
|
|
164
|
+
"merge",
|
|
165
|
+
"payment",
|
|
166
|
+
"checkout",
|
|
167
|
+
"order",
|
|
168
|
+
"cart",
|
|
169
|
+
"product",
|
|
170
|
+
"price",
|
|
171
|
+
"customer",
|
|
172
|
+
"invoice",
|
|
173
|
+
"subscription",
|
|
174
|
+
"refund",
|
|
175
|
+
"transaction",
|
|
176
|
+
"balance",
|
|
177
|
+
"charge",
|
|
178
|
+
"billing",
|
|
179
|
+
"notification",
|
|
180
|
+
"message",
|
|
181
|
+
"email",
|
|
182
|
+
"template",
|
|
183
|
+
"report",
|
|
184
|
+
"dashboard",
|
|
185
|
+
"widget",
|
|
186
|
+
"component",
|
|
187
|
+
"screen",
|
|
188
|
+
"page",
|
|
189
|
+
"view",
|
|
190
|
+
"layout",
|
|
191
|
+
"style",
|
|
192
|
+
"theme",
|
|
193
|
+
"color",
|
|
194
|
+
"cache",
|
|
195
|
+
"store",
|
|
196
|
+
"database",
|
|
197
|
+
"repository",
|
|
198
|
+
"service",
|
|
199
|
+
"controller",
|
|
200
|
+
"model",
|
|
201
|
+
"middleware",
|
|
202
|
+
"route",
|
|
203
|
+
"router",
|
|
204
|
+
"endpoint",
|
|
205
|
+
"schema",
|
|
206
|
+
"migration",
|
|
207
|
+
"seed",
|
|
208
|
+
"state",
|
|
209
|
+
"context",
|
|
210
|
+
"provider",
|
|
211
|
+
"hook",
|
|
212
|
+
"effect",
|
|
213
|
+
"reducer",
|
|
214
|
+
"action"
|
|
215
|
+
];
|
|
216
|
+
var _wordMap = null;
|
|
217
|
+
var _wordVecs = null;
|
|
218
|
+
var tableCache = /* @__PURE__ */ new WeakMap();
|
|
219
|
+
var baseTable = null;
|
|
220
|
+
function hashWord(w) {
|
|
221
|
+
let h = 24301;
|
|
222
|
+
for (let i = 0; i < w.length; i++) {
|
|
223
|
+
h = Math.imul(h ^ w.charCodeAt(i), 1540483477);
|
|
224
|
+
h = Math.imul(h ^ h >>> 15, 1540483477);
|
|
225
|
+
}
|
|
226
|
+
return h >>> 0;
|
|
227
|
+
}
|
|
228
|
+
function seedPRNG(seed) {
|
|
229
|
+
let s = seed | 0;
|
|
230
|
+
return () => {
|
|
231
|
+
s = s + 1831565813 | 0;
|
|
232
|
+
let t = Math.imul(s ^ s >>> 15, 1 | s);
|
|
233
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
234
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function buildVectors(words) {
|
|
238
|
+
const unique = [...new Set(words.map((w) => w.toLowerCase().slice(0, 30)).filter((w) => w.length >= 2))];
|
|
239
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
240
|
+
const vecs = new Float32Array(unique.length * WORD_DIM);
|
|
241
|
+
for (let i = 0; i < unique.length; i++) {
|
|
242
|
+
map[unique[i]] = i;
|
|
243
|
+
vecs.set(wordVector(unique[i]), i * WORD_DIM);
|
|
244
|
+
}
|
|
245
|
+
_wordMap = map;
|
|
246
|
+
_wordVecs = vecs;
|
|
247
|
+
}
|
|
248
|
+
function publish(table) {
|
|
249
|
+
if (!table) return null;
|
|
250
|
+
_wordMap = table.map;
|
|
251
|
+
_wordVecs = table.vecs;
|
|
252
|
+
return table;
|
|
253
|
+
}
|
|
254
|
+
function wordVector(word) {
|
|
255
|
+
const v = new Float32Array(WORD_DIM);
|
|
256
|
+
const rng = seedPRNG(hashWord(word) | 0);
|
|
257
|
+
for (let d = 0; d < WORD_DIM; d++) v[d] = rng() * 2 - 1;
|
|
258
|
+
let norm = 0;
|
|
259
|
+
for (let d = 0; d < WORD_DIM; d++) norm += v[d] * v[d];
|
|
260
|
+
norm = Math.sqrt(norm);
|
|
261
|
+
if (norm > 0) for (let d = 0; d < WORD_DIM; d++) v[d] /= norm;
|
|
262
|
+
return v;
|
|
263
|
+
}
|
|
264
|
+
function tokenizeForEmbedding(text) {
|
|
265
|
+
const out = [];
|
|
266
|
+
for (const raw of String(text).split(/[^A-Za-z0-9]+/)) {
|
|
267
|
+
if (!raw) continue;
|
|
268
|
+
for (const part of raw.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(" ")) {
|
|
269
|
+
const word = part.toLowerCase();
|
|
270
|
+
if (word.length >= 2 && word.length <= 30 && !/^\d+$/.test(word)) out.push(word);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return out;
|
|
274
|
+
}
|
|
275
|
+
var PROJECT_VOCAB_MAX = 16;
|
|
276
|
+
var projectVocabCache = /* @__PURE__ */ new Map();
|
|
277
|
+
function projectVocabulary(rawDb, projectId) {
|
|
278
|
+
const cached = projectVocabCache.get(projectId);
|
|
279
|
+
if (cached) {
|
|
280
|
+
projectVocabCache.delete(projectId);
|
|
281
|
+
projectVocabCache.set(projectId, cached);
|
|
282
|
+
return cached;
|
|
283
|
+
}
|
|
284
|
+
const words = new Set(BASE_WORDS);
|
|
285
|
+
try {
|
|
286
|
+
const symbols = rawDb.prepare("SELECT DISTINCT name FROM brain_symbol WHERE project_id = ? LIMIT 80000").all(projectId);
|
|
287
|
+
const freq = {};
|
|
288
|
+
for (const s of symbols) {
|
|
289
|
+
if (!s.name) continue;
|
|
290
|
+
for (const w of tokenizeForEmbedding(String(s.name))) freq[w] = (freq[w] || 0) + 1;
|
|
291
|
+
}
|
|
292
|
+
const top = Object.entries(freq).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 5e3);
|
|
293
|
+
for (const [w] of top) words.add(w);
|
|
294
|
+
} catch (e) {
|
|
295
|
+
log.debug("project vocabulary failed, using base", { e: e?.message });
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
299
|
+
for (const w of words) map[w.toLowerCase().slice(0, 30)] = 0;
|
|
300
|
+
if (projectVocabCache.size >= PROJECT_VOCAB_MAX) {
|
|
301
|
+
const oldest = projectVocabCache.keys().next().value;
|
|
302
|
+
if (oldest !== void 0) projectVocabCache.delete(oldest);
|
|
303
|
+
}
|
|
304
|
+
projectVocabCache.set(projectId, map);
|
|
305
|
+
return map;
|
|
306
|
+
}
|
|
307
|
+
function getVectors(vocabulary) {
|
|
308
|
+
if (vocabulary) {
|
|
309
|
+
const cached = tableCache.get(vocabulary);
|
|
310
|
+
if (cached) return publish(cached);
|
|
311
|
+
buildVectors(Object.keys(vocabulary));
|
|
312
|
+
const table2 = _wordMap && _wordVecs ? { map: _wordMap, vecs: _wordVecs } : null;
|
|
313
|
+
if (table2) tableCache.set(vocabulary, table2);
|
|
314
|
+
return table2;
|
|
315
|
+
}
|
|
316
|
+
if (baseTable) return publish(baseTable);
|
|
317
|
+
if (_wordMap && _wordVecs) return { map: _wordMap, vecs: _wordVecs };
|
|
318
|
+
buildVectors(BASE_WORDS);
|
|
319
|
+
const table = _wordMap && _wordVecs ? { map: _wordMap, vecs: _wordVecs } : null;
|
|
320
|
+
baseTable = table;
|
|
321
|
+
return table;
|
|
322
|
+
}
|
|
323
|
+
function embedLocal(texts, vocabulary) {
|
|
324
|
+
const wv = getVectors(vocabulary);
|
|
325
|
+
if (!wv) return [];
|
|
326
|
+
const results = [];
|
|
327
|
+
for (const text of texts) {
|
|
328
|
+
const vec = new Array(WORD_DIM).fill(0);
|
|
329
|
+
const words = tokenizeForEmbedding(text);
|
|
330
|
+
let count = 0;
|
|
331
|
+
for (const w of words) {
|
|
332
|
+
const idx = wv.map[w];
|
|
333
|
+
if (idx !== void 0) {
|
|
334
|
+
const base = idx * WORD_DIM;
|
|
335
|
+
for (let d = 0; d < WORD_DIM; d++) vec[d] += wv.vecs[base + d];
|
|
336
|
+
count++;
|
|
337
|
+
} else {
|
|
338
|
+
for (let i = 0; i < w.length - 3; i++) {
|
|
339
|
+
const sub = w.slice(i, i + 4);
|
|
340
|
+
const si = wv.map[sub];
|
|
341
|
+
if (si !== void 0) {
|
|
342
|
+
const b = si * WORD_DIM;
|
|
343
|
+
for (let d = 0; d < WORD_DIM; d++) vec[d] += wv.vecs[b + d] * 0.25;
|
|
344
|
+
count++;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (count === 0) {
|
|
350
|
+
results.push(new Array(WORD_DIM).fill(0));
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
let norm = 0;
|
|
354
|
+
for (let d = 0; d < WORD_DIM; d++) norm += vec[d] * vec[d];
|
|
355
|
+
norm = Math.sqrt(norm);
|
|
356
|
+
if (norm > 0) for (let d = 0; d < WORD_DIM; d++) vec[d] /= norm;
|
|
357
|
+
results.push(vec);
|
|
358
|
+
}
|
|
359
|
+
return results;
|
|
360
|
+
}
|
|
361
|
+
async function initLocalModel() {
|
|
362
|
+
return getVectors() !== null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export {
|
|
366
|
+
LOCAL_VECTOR_DIMENSION,
|
|
367
|
+
tokenizeForEmbedding,
|
|
368
|
+
projectVocabulary,
|
|
369
|
+
embedLocal,
|
|
370
|
+
initLocalModel
|
|
371
|
+
};
|