@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,69 @@
|
|
|
1
|
+
// src/lsp/relations.ts
|
|
2
|
+
var DECLARATION_RELATIONSHIPS = /* @__PURE__ */ new Set(["contains", "exports"]);
|
|
3
|
+
function isDeclarationRelationship(relationshipType) {
|
|
4
|
+
return DECLARATION_RELATIONSHIPS.has(relationshipType.trim().toLowerCase());
|
|
5
|
+
}
|
|
6
|
+
function relationDirection(row, symbolId) {
|
|
7
|
+
const isSource = row.source_symbol_id === symbolId;
|
|
8
|
+
const isTarget = row.target_symbol_id === symbolId;
|
|
9
|
+
if (isSource && isTarget) return "self";
|
|
10
|
+
if (isTarget) return "incoming";
|
|
11
|
+
if (isSource) return "outgoing";
|
|
12
|
+
return "unrelated";
|
|
13
|
+
}
|
|
14
|
+
function isUsageSiteRow(row, symbolId) {
|
|
15
|
+
return relationDirection(row, symbolId) === "incoming" && !isDeclarationRelationship(row.relationship_type);
|
|
16
|
+
}
|
|
17
|
+
function isUsageSite(site) {
|
|
18
|
+
return site.reversed === true && !isDeclarationRelationship(site.relationshipType);
|
|
19
|
+
}
|
|
20
|
+
function isUsageSiteAnyKind(site) {
|
|
21
|
+
const kinds = site.relationshipTypes;
|
|
22
|
+
if (site.reversed !== true) return false;
|
|
23
|
+
if (kinds === void 0 || kinds.length === 0) return isUsageSite(site);
|
|
24
|
+
return kinds.some((k) => !isDeclarationRelationship(k));
|
|
25
|
+
}
|
|
26
|
+
function usageSites(sites) {
|
|
27
|
+
return sites.filter(isUsageSiteAnyKind);
|
|
28
|
+
}
|
|
29
|
+
var USAGE_SITE_FILTER_LABEL = "usage sites only; declaration and callees excluded";
|
|
30
|
+
var USAGE_COUNT_UNIT_LABEL = "counted once per place: usage sites that resolve to the same file and line count as one, and the shared rows are reported separately";
|
|
31
|
+
function countUnresolvedNameMatchesByProjectAndName(db, projectId, name) {
|
|
32
|
+
const out = { name, external: 0, unresolved: 0, total: 0 };
|
|
33
|
+
if (!name) return out;
|
|
34
|
+
try {
|
|
35
|
+
const stmt = db.prepare(
|
|
36
|
+
`SELECT target_basis AS b, COUNT(*) AS c
|
|
37
|
+
FROM brain_relationship
|
|
38
|
+
WHERE project_id = ? AND target_external = ? AND target_symbol_id IS NULL
|
|
39
|
+
GROUP BY target_basis`
|
|
40
|
+
);
|
|
41
|
+
const rows = stmt.all?.(projectId, name) ?? [];
|
|
42
|
+
for (const r of rows) {
|
|
43
|
+
const c = Number(r.c ?? 0);
|
|
44
|
+
if (r.b === "external") out.external += c;
|
|
45
|
+
else out.unresolved += c;
|
|
46
|
+
out.total += c;
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
function countUnresolvedNameMatches(db, symbolId) {
|
|
53
|
+
try {
|
|
54
|
+
const sym = db.prepare("SELECT project_id AS p, name AS n FROM brain_symbol WHERE id = ?").get(symbolId);
|
|
55
|
+
if (!sym || !sym.n) return null;
|
|
56
|
+
return countUnresolvedNameMatchesByProjectAndName(db, sym.p, sym.n);
|
|
57
|
+
} catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
isDeclarationRelationship,
|
|
64
|
+
isUsageSiteRow,
|
|
65
|
+
usageSites,
|
|
66
|
+
USAGE_SITE_FILTER_LABEL,
|
|
67
|
+
USAGE_COUNT_UNIT_LABEL,
|
|
68
|
+
countUnresolvedNameMatches
|
|
69
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// src/brain/semantic/vector-binary.ts
|
|
2
|
+
var HOST_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
3
|
+
function vectorBlobBytes(dimension) {
|
|
4
|
+
return dimension * 4;
|
|
5
|
+
}
|
|
6
|
+
function encodeVectorBlob(vector) {
|
|
7
|
+
const n = vector.length;
|
|
8
|
+
const bytes = Buffer.allocUnsafe(n * 4);
|
|
9
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
10
|
+
for (let i = 0; i < n; i++) view.setFloat32(i * 4, vector[i], true);
|
|
11
|
+
return bytes;
|
|
12
|
+
}
|
|
13
|
+
function decodeVectorBlob(value, dimension) {
|
|
14
|
+
if (!value || dimension <= 0) return null;
|
|
15
|
+
let bytes;
|
|
16
|
+
if (value instanceof Uint8Array) bytes = value;
|
|
17
|
+
else if (value instanceof ArrayBuffer) bytes = new Uint8Array(value);
|
|
18
|
+
else return null;
|
|
19
|
+
const need = vectorBlobBytes(dimension);
|
|
20
|
+
if (bytes.byteLength !== need) return null;
|
|
21
|
+
if (HOST_LITTLE_ENDIAN && bytes.byteOffset % 4 === 0) {
|
|
22
|
+
return new Float32Array(bytes.buffer, bytes.byteOffset, dimension);
|
|
23
|
+
}
|
|
24
|
+
const out = new Float32Array(dimension);
|
|
25
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
26
|
+
for (let i = 0; i < dimension; i++) out[i] = view.getFloat32(i * 4, true);
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
function scanJsonVectorInto(text, out) {
|
|
30
|
+
const len = text.length;
|
|
31
|
+
let n = 0;
|
|
32
|
+
let i = 1;
|
|
33
|
+
let sign = 1;
|
|
34
|
+
let value = 0;
|
|
35
|
+
let fracDiv = 1;
|
|
36
|
+
let inFrac = false;
|
|
37
|
+
let seenDigit = false;
|
|
38
|
+
const cap = out.length;
|
|
39
|
+
while (i < len) {
|
|
40
|
+
const c = text.charCodeAt(i);
|
|
41
|
+
if (c === 45) {
|
|
42
|
+
sign = -1;
|
|
43
|
+
i++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (c === 43) {
|
|
47
|
+
i++;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (c >= 48 && c <= 57) {
|
|
51
|
+
const d = c - 48;
|
|
52
|
+
if (inFrac) {
|
|
53
|
+
fracDiv *= 10;
|
|
54
|
+
value += d / fracDiv;
|
|
55
|
+
} else {
|
|
56
|
+
value = value * 10 + d;
|
|
57
|
+
}
|
|
58
|
+
seenDigit = true;
|
|
59
|
+
i++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (c === 46) {
|
|
63
|
+
inFrac = true;
|
|
64
|
+
i++;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (c === 101 || c === 69) {
|
|
68
|
+
let j = i + 1;
|
|
69
|
+
let esign = 1;
|
|
70
|
+
if (text.charCodeAt(j) === 45) {
|
|
71
|
+
esign = -1;
|
|
72
|
+
j++;
|
|
73
|
+
} else if (text.charCodeAt(j) === 43) {
|
|
74
|
+
j++;
|
|
75
|
+
}
|
|
76
|
+
let ev = 0;
|
|
77
|
+
let anyDigit = false;
|
|
78
|
+
while (j < len) {
|
|
79
|
+
const d = text.charCodeAt(j);
|
|
80
|
+
if (d < 48 || d > 57) break;
|
|
81
|
+
ev = ev * 10 + (d - 48);
|
|
82
|
+
anyDigit = true;
|
|
83
|
+
j++;
|
|
84
|
+
}
|
|
85
|
+
if (!anyDigit) return 0;
|
|
86
|
+
value *= Math.pow(10, esign * ev);
|
|
87
|
+
i = j;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (c === 44 || c === 93) {
|
|
91
|
+
if (!seenDigit) return 0;
|
|
92
|
+
if (n >= cap) return 0;
|
|
93
|
+
out[n++] = sign * value;
|
|
94
|
+
sign = 1;
|
|
95
|
+
value = 0;
|
|
96
|
+
inFrac = false;
|
|
97
|
+
fracDiv = 1;
|
|
98
|
+
seenDigit = false;
|
|
99
|
+
if (c === 93) {
|
|
100
|
+
for (let k = i + 1; k < len; k++) {
|
|
101
|
+
const w = text.charCodeAt(k);
|
|
102
|
+
if (w !== 32 && w !== 9 && w !== 10 && w !== 13) return 0;
|
|
103
|
+
}
|
|
104
|
+
return n;
|
|
105
|
+
}
|
|
106
|
+
i++;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (c === 32 || c === 9 || c === 10 || c === 13 || c === 91) {
|
|
110
|
+
i++;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
function cosineFloat32(a, b, dimension) {
|
|
118
|
+
let dot = 0;
|
|
119
|
+
let na = 0;
|
|
120
|
+
let nb = 0;
|
|
121
|
+
for (let i = 0; i < dimension; i++) {
|
|
122
|
+
const x = a[i];
|
|
123
|
+
const y = b[i];
|
|
124
|
+
dot += x * y;
|
|
125
|
+
na += x * x;
|
|
126
|
+
nb += y * y;
|
|
127
|
+
}
|
|
128
|
+
if (na === 0 || nb === 0) return 0;
|
|
129
|
+
return dot / (Math.sqrt(na) * Math.sqrt(nb));
|
|
130
|
+
}
|
|
131
|
+
function l2Norm(a, dimension) {
|
|
132
|
+
let n = 0;
|
|
133
|
+
for (let i = 0; i < dimension; i++) n += a[i] * a[i];
|
|
134
|
+
return Math.sqrt(n);
|
|
135
|
+
}
|
|
136
|
+
function readRowVector(blob, jsonText, dimension, scratch) {
|
|
137
|
+
const fromBlob = decodeVectorBlob(blob, dimension);
|
|
138
|
+
if (fromBlob) return fromBlob;
|
|
139
|
+
if (typeof jsonText !== "string" || jsonText.length === 0) return null;
|
|
140
|
+
const n = scanJsonVectorInto(jsonText, scratch);
|
|
141
|
+
return n === dimension ? scratch : null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
vectorBlobBytes,
|
|
146
|
+
encodeVectorBlob,
|
|
147
|
+
decodeVectorBlob,
|
|
148
|
+
scanJsonVectorInto,
|
|
149
|
+
cosineFloat32,
|
|
150
|
+
l2Norm,
|
|
151
|
+
readRowVector
|
|
152
|
+
};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readSymbolSnippet
|
|
3
|
+
} from "./chunk-3CTFIJJB.js";
|
|
4
|
+
import {
|
|
5
|
+
checkResultsFreshness
|
|
6
|
+
} from "./chunk-QLK6ED4Q.js";
|
|
7
|
+
import {
|
|
8
|
+
BrainDatabase
|
|
9
|
+
} from "./chunk-KLK3PBTO.js";
|
|
10
|
+
import {
|
|
11
|
+
analysis_exclusions_exports
|
|
12
|
+
} from "./chunk-SM7RFQRO.js";
|
|
13
|
+
|
|
14
|
+
// src/intelligence/search/symbol-search.ts
|
|
15
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
16
|
+
function normalizePageSize(value) {
|
|
17
|
+
if (value === void 0 || value === null) return DEFAULT_PAGE_SIZE;
|
|
18
|
+
const n = Math.trunc(Number(value));
|
|
19
|
+
if (!Number.isFinite(n) || n < 0) return DEFAULT_PAGE_SIZE;
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function normalizeOffset(value) {
|
|
23
|
+
if (value === void 0 || value === null) return 0;
|
|
24
|
+
const n = Math.trunc(Number(value));
|
|
25
|
+
if (!Number.isFinite(n) || n < 0) return 0;
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
var LIKE_ESCAPE_CHAR = "\\";
|
|
29
|
+
function escapeLike(fragment) {
|
|
30
|
+
return fragment.split(LIKE_ESCAPE_CHAR).join(LIKE_ESCAPE_CHAR + LIKE_ESCAPE_CHAR).split("%").join(LIKE_ESCAPE_CHAR + "%").split("_").join(LIKE_ESCAPE_CHAR + "_");
|
|
31
|
+
}
|
|
32
|
+
var LIKE_ESCAPE_CLAUSE = ` ESCAPE '${LIKE_ESCAPE_CHAR}'`;
|
|
33
|
+
var NON_ASCII = /[^\x00-\x7F]/;
|
|
34
|
+
function longestAsciiPrefix(value) {
|
|
35
|
+
let i = 0;
|
|
36
|
+
while (i < value.length && value.charCodeAt(i) < 128) i++;
|
|
37
|
+
return value.slice(0, i);
|
|
38
|
+
}
|
|
39
|
+
function isNoiseCandidate(row) {
|
|
40
|
+
return analysis_exclusions_exports.isHardNoisePath(row.relativePath) || analysis_exclusions_exports.isNoiseSymbolName(row.name);
|
|
41
|
+
}
|
|
42
|
+
async function searchSymbols(projectId, rawQuery, options = {}) {
|
|
43
|
+
const raw = await BrainDatabase.getRawInstance(projectId, { readonly: true });
|
|
44
|
+
if (options.mode === "content") {
|
|
45
|
+
const { searchContent } = await import("./content-search-642F7E5V.js");
|
|
46
|
+
return searchContent(projectId, rawQuery, options);
|
|
47
|
+
}
|
|
48
|
+
if (options.mode === "regex" || options.regex) {
|
|
49
|
+
const { searchRegex } = await import("./regex-search-OPTLKUN5.js");
|
|
50
|
+
return searchRegex(projectId, rawQuery, options);
|
|
51
|
+
}
|
|
52
|
+
const query = String(rawQuery ?? "").trim();
|
|
53
|
+
const maxResults = normalizePageSize(options.maxResults);
|
|
54
|
+
const offset = normalizeOffset(options.offset);
|
|
55
|
+
if (!query) return emptyResult("symbol");
|
|
56
|
+
const caseSensitive = options.caseSensitive === true;
|
|
57
|
+
const unicodeQuery = NON_ASCII.test(query);
|
|
58
|
+
const phases = buildPhases(query, options.exact === true, caseSensitive, unicodeQuery);
|
|
59
|
+
const budget = offset + maxResults;
|
|
60
|
+
const fetchCap = Math.min(FETCH_CAP_MAX, Math.max(MIN_FETCH_CAP, budget * 4));
|
|
61
|
+
const idCap = Math.min(ID_CAP_MAX, Math.max(MIN_ID_CAP, budget * 4));
|
|
62
|
+
const candidates = [];
|
|
63
|
+
const seen = /* @__PURE__ */ new Set();
|
|
64
|
+
const truncationReasons = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const phase of phases) {
|
|
66
|
+
const rows = await runPhase(raw, projectId, phase, { fetchCap, idCap, options, query, caseSensitive });
|
|
67
|
+
if (rows.truncated) truncationReasons.add(`candidate-cap:${phase.relevance}`);
|
|
68
|
+
for (const row of rows.rows) {
|
|
69
|
+
if (seen.has(row.id)) continue;
|
|
70
|
+
seen.add(row.id);
|
|
71
|
+
candidates.push({ ...row, phaseRelevance: phase.relevance });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const beforeNoise = candidates.length;
|
|
75
|
+
const kept = candidates.filter((row) => !isNoiseCandidate(row));
|
|
76
|
+
if (beforeNoise !== kept.length) truncationReasons.add("noise-filter");
|
|
77
|
+
const folded = unicodeQuery ? query.toLowerCase() : query;
|
|
78
|
+
const score = (name) => name.toLowerCase() === folded ? 3 : name.toLowerCase().startsWith(folded) ? 2 : 1;
|
|
79
|
+
kept.sort((a, b) => {
|
|
80
|
+
return score(b.name) - score(a.name) || (analysis_exclusions_exports.isTestPath(a.relativePath) ? 1 : 0) - (analysis_exclusions_exports.isTestPath(b.relativePath) ? 1 : 0) || b.complexity - a.complexity || compareCodeUnits(a.relativePath, b.relativePath) || compareCodeUnits(a.name, b.name);
|
|
81
|
+
});
|
|
82
|
+
const page = kept.slice(offset, offset + maxResults);
|
|
83
|
+
const results = emptyResult("symbol");
|
|
84
|
+
for (const row of page) {
|
|
85
|
+
results.push({
|
|
86
|
+
file: row.relativePath,
|
|
87
|
+
fileId: row.fileId,
|
|
88
|
+
line: row.line,
|
|
89
|
+
column: 0,
|
|
90
|
+
context: `${row.symbolType}: ${row.name}`,
|
|
91
|
+
symbolName: row.name,
|
|
92
|
+
symbolType: row.symbolType,
|
|
93
|
+
language: row.language,
|
|
94
|
+
matchType: "symbol",
|
|
95
|
+
snippet: options.includeContent ? await readSymbolSnippet(row.filePath, row.line, row.lineEnd) || row.name : row.name,
|
|
96
|
+
complexity: row.complexity,
|
|
97
|
+
_relevance: score(row.name)
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
results.totalMatches = kept.length;
|
|
101
|
+
results.truncated = truncationReasons.size > 0;
|
|
102
|
+
if (truncationReasons.size > 0) results.truncationReason = [...truncationReasons].sort().join(",");
|
|
103
|
+
applyFreshness(raw, results);
|
|
104
|
+
return results;
|
|
105
|
+
}
|
|
106
|
+
function emptyResult(mode) {
|
|
107
|
+
const results = [];
|
|
108
|
+
results.searchMode = mode;
|
|
109
|
+
results.staleCount = 0;
|
|
110
|
+
results.freshCount = 0;
|
|
111
|
+
results.totalMatches = 0;
|
|
112
|
+
return results;
|
|
113
|
+
}
|
|
114
|
+
function compareCodeUnits(a, b) {
|
|
115
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
116
|
+
}
|
|
117
|
+
function buildPhases(query, exact, caseSensitive, unicodeQuery) {
|
|
118
|
+
if (unicodeQuery) {
|
|
119
|
+
const asciiPrefix = longestAsciiPrefix(query);
|
|
120
|
+
const narrow = asciiPrefix.length >= 2;
|
|
121
|
+
if (exact) {
|
|
122
|
+
return narrow ? [{ clause: "s.name LIKE ? ESCAPE '\\'", relevance: 3, value: escapeLike(asciiPrefix) + "%", substring: false, fold: "equal" }] : [{ clause: "LENGTH(s.name) = LENGTH(?)", relevance: 3, value: query, substring: false, fold: "equal" }];
|
|
123
|
+
}
|
|
124
|
+
if (narrow) {
|
|
125
|
+
return [
|
|
126
|
+
{ clause: "s.name LIKE ? ESCAPE '\\'", relevance: 3, value: escapeLike(asciiPrefix) + "%", substring: false, fold: "equal" },
|
|
127
|
+
{ clause: "s.name LIKE ? ESCAPE '\\'", relevance: 2, value: escapeLike(asciiPrefix) + "%", substring: false, fold: "prefix" },
|
|
128
|
+
{ clause: "1 = 1", relevance: 1, value: "", substring: true, fold: "substring" }
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
return [
|
|
132
|
+
{ clause: "LENGTH(s.name) = LENGTH(?)", relevance: 3, value: query, substring: true, fold: "equal" },
|
|
133
|
+
{ clause: "LENGTH(s.name) >= LENGTH(?)", relevance: 2, value: query, substring: true, fold: "prefix" },
|
|
134
|
+
{ clause: "LENGTH(s.name) >= LENGTH(?)", relevance: 1, value: query, substring: true, fold: "substring" }
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
if (exact) {
|
|
138
|
+
return [{ clause: caseSensitive ? "s.name = ?" : "s.name = ? COLLATE NOCASE", relevance: 3, value: query, substring: false }];
|
|
139
|
+
}
|
|
140
|
+
if (caseSensitive) {
|
|
141
|
+
return [
|
|
142
|
+
{ clause: "s.name = ?", relevance: 3, value: query, substring: false },
|
|
143
|
+
// Indexed range scan, not instr(): `instr(name, ?)` is a full table scan
|
|
144
|
+
// for every query (EXPLAIN QUERY PLAN: `SCAN brain_symbol`).
|
|
145
|
+
{ clause: "s.name LIKE ? ESCAPE '\\'", relevance: 2, value: escapeLike(query) + "%", substring: false },
|
|
146
|
+
{ clause: "s.name LIKE ? ESCAPE '\\'", relevance: 1, value: "%" + escapeLike(query) + "%", substring: true }
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
return [
|
|
150
|
+
{ clause: "s.name = ? COLLATE NOCASE", relevance: 3, value: query, substring: false },
|
|
151
|
+
{ clause: "s.name LIKE ? COLLATE NOCASE ESCAPE '\\'", relevance: 2, value: escapeLike(query) + "%", substring: false },
|
|
152
|
+
{ clause: "s.name LIKE ? COLLATE NOCASE ESCAPE '\\'", relevance: 1, value: "%" + escapeLike(query) + "%", substring: true }
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
function symbolSearchPhases(query, exact, caseSensitive) {
|
|
156
|
+
return buildPhases(query, exact, caseSensitive, NON_ASCII.test(query));
|
|
157
|
+
}
|
|
158
|
+
var MIN_FETCH_CAP = 2e4;
|
|
159
|
+
var FETCH_CAP_MAX = 2e5;
|
|
160
|
+
var MIN_ID_CAP = 2e4;
|
|
161
|
+
var ID_CAP_MAX = 2e5;
|
|
162
|
+
var ID_JOIN_CHUNK = 500;
|
|
163
|
+
async function runPhase(raw, projectId, phase, ctx) {
|
|
164
|
+
const { filters, params } = filterSql(ctx.options);
|
|
165
|
+
const base = `${SELECT_COLUMNS} FROM brain_symbol s JOIN brain_file f ON f.id = s.file_id
|
|
166
|
+
WHERE s.project_id = ? AND COALESCE(s.line_start, 0) > 0 AND s.name NOT LIKE '/%/%'${filters}`;
|
|
167
|
+
if (phase.fold) {
|
|
168
|
+
const rows2 = raw.prepare(`${base} AND ${phase.clause} LIMIT ?`).all(projectId, ...params, phase.value, ctx.fetchCap);
|
|
169
|
+
return { rows: filterFolded(rows2, phase, ctx.query), truncated: rows2.length >= ctx.fetchCap };
|
|
170
|
+
}
|
|
171
|
+
if (!phase.substring) {
|
|
172
|
+
const rows2 = raw.prepare(`${base} AND ${phase.clause} LIMIT ?`).all(projectId, ...params, phase.value, ctx.fetchCap);
|
|
173
|
+
return { rows: rows2, truncated: rows2.length >= ctx.fetchCap };
|
|
174
|
+
}
|
|
175
|
+
const { filters: idFilters, params: idFilterParams } = filterSql(ctx.options, "s", "f");
|
|
176
|
+
const idRows = raw.prepare(
|
|
177
|
+
`SELECT s.id FROM brain_symbol s JOIN brain_file f ON f.id = s.file_id
|
|
178
|
+
WHERE s.project_id = ? AND COALESCE(s.line_start, 0) > 0 AND s.name NOT LIKE '/%/%'${idFilters} AND ${phase.clause} LIMIT ?`
|
|
179
|
+
).all(projectId, ...idFilterParams, phase.value, ctx.idCap);
|
|
180
|
+
if (idRows.length === 0) return { rows: [], truncated: false };
|
|
181
|
+
const distinct = [...new Set(idRows.map((row) => row.id))];
|
|
182
|
+
const rows = [];
|
|
183
|
+
for (let start = 0; start < distinct.length; start += ID_JOIN_CHUNK) {
|
|
184
|
+
const chunk = distinct.slice(start, start + ID_JOIN_CHUNK);
|
|
185
|
+
const placeholders = chunk.map(() => "?").join(",");
|
|
186
|
+
const page = raw.prepare(`${SELECT_COLUMNS} FROM brain_symbol s JOIN brain_file f ON f.id = s.file_id WHERE s.id IN (${placeholders})${filters}`).all(...chunk, ...params);
|
|
187
|
+
rows.push(...page);
|
|
188
|
+
}
|
|
189
|
+
return { rows, truncated: idRows.length >= ctx.idCap };
|
|
190
|
+
}
|
|
191
|
+
var SELECT_COLUMNS = `SELECT s.id, s.file_id AS fileId, s.name, s.symbol_type AS symbolType,
|
|
192
|
+
COALESCE(s.line_start, 0) AS line, COALESCE(s.line_end, 0) AS lineEnd, COALESCE(s.complexity, 0) AS complexity,
|
|
193
|
+
f.relative_path AS relativePath, f.path AS filePath, COALESCE(f.language, 'unknown') AS language`;
|
|
194
|
+
function filterSql(options, symbolAlias = "s", fileAlias = "f") {
|
|
195
|
+
let filters = "";
|
|
196
|
+
const params = [];
|
|
197
|
+
if (options.languages?.length) {
|
|
198
|
+
filters += ` AND ${fileAlias}.language COLLATE NOCASE IN (${options.languages.map(() => "?").join(",")})`;
|
|
199
|
+
params.push(...options.languages);
|
|
200
|
+
}
|
|
201
|
+
if (options.symbolKind) {
|
|
202
|
+
filters += ` AND ${symbolAlias}.symbol_type COLLATE NOCASE = ?`;
|
|
203
|
+
params.push(options.symbolKind);
|
|
204
|
+
}
|
|
205
|
+
return { filters, params };
|
|
206
|
+
}
|
|
207
|
+
function filterFolded(rows, phase, query) {
|
|
208
|
+
const needle = query.toLowerCase();
|
|
209
|
+
return rows.filter((row) => {
|
|
210
|
+
const name = row.name.toLowerCase();
|
|
211
|
+
if (phase.fold === "equal") return name === needle;
|
|
212
|
+
if (phase.fold === "prefix") return name.startsWith(needle);
|
|
213
|
+
return name.includes(needle);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function applyFreshness(raw, results) {
|
|
217
|
+
try {
|
|
218
|
+
const freshness = checkResultsFreshness(raw, results.map((result) => ({ fileId: result.fileId })));
|
|
219
|
+
let staleCount = 0;
|
|
220
|
+
for (const result of results) {
|
|
221
|
+
if (["stale", "missing"].includes(freshness.get(result.fileId) ?? "")) {
|
|
222
|
+
result.stale = true;
|
|
223
|
+
staleCount++;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
results.staleCount = staleCount;
|
|
227
|
+
results.freshCount = results.length - staleCount;
|
|
228
|
+
} catch {
|
|
229
|
+
results.freshnessError = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
searchSymbols,
|
|
235
|
+
symbolSearchPhases
|
|
236
|
+
};
|