@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,376 @@
|
|
|
1
|
+
import {
|
|
2
|
+
classifyTier
|
|
3
|
+
} from "./chunk-RCMTFSEF.js";
|
|
4
|
+
|
|
5
|
+
// src/lsp/signature.ts
|
|
6
|
+
var UNRESOLVED_TYPE = "unknown";
|
|
7
|
+
var UNKNOWN_PARAMETER_LIST = "\u2026";
|
|
8
|
+
var RAW_JSON_SHAPE = /[{\[]\s*"?[A-Za-z_][A-Za-z0-9_]*"?\s*:/;
|
|
9
|
+
var CALLABLE_TYPES = /* @__PURE__ */ new Set([
|
|
10
|
+
"function",
|
|
11
|
+
"method",
|
|
12
|
+
"constructor",
|
|
13
|
+
"procedure",
|
|
14
|
+
"subroutine",
|
|
15
|
+
"getter",
|
|
16
|
+
"setter"
|
|
17
|
+
]);
|
|
18
|
+
function parseParameters(raw) {
|
|
19
|
+
if (raw === null || raw === void 0 || raw.trim() === "") return { shape: "absent", entries: [], text: "" };
|
|
20
|
+
const text = raw.trim();
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
parsed = JSON.parse(text);
|
|
24
|
+
} catch {
|
|
25
|
+
return { shape: RAW_JSON_SHAPE.test(text) ? "serialized" : "opaque", entries: [], text };
|
|
26
|
+
}
|
|
27
|
+
if (!Array.isArray(parsed)) return { shape: "serialized", entries: [], text };
|
|
28
|
+
if (parsed.length === 0) return { shape: "empty", entries: [], text };
|
|
29
|
+
const entries = [];
|
|
30
|
+
for (const item of parsed) {
|
|
31
|
+
if (typeof item === "string") {
|
|
32
|
+
if (item.trim() !== "") entries.push({ name: item.trim() });
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (item === null || typeof item !== "object") {
|
|
36
|
+
return { shape: "serialized", entries: [], text };
|
|
37
|
+
}
|
|
38
|
+
const e = item;
|
|
39
|
+
const name = typeof e.name === "string" ? e.name : "";
|
|
40
|
+
if (name.trim() === "") {
|
|
41
|
+
return { shape: "serialized", entries: [], text };
|
|
42
|
+
}
|
|
43
|
+
entries.push({
|
|
44
|
+
name: name.trim(),
|
|
45
|
+
type: typeof e.type === "string" ? e.type : null,
|
|
46
|
+
isOptional: e.isOptional === true || e.optional === true,
|
|
47
|
+
defaultValue: typeof e.defaultValue === "string" ? e.defaultValue : null,
|
|
48
|
+
isRest: e.isRest === true || e.rest === true || e.variadic === true,
|
|
49
|
+
isImplicit: e.isImplicit === true
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return { shape: "list", entries, text };
|
|
53
|
+
}
|
|
54
|
+
function splitRestMarker(name) {
|
|
55
|
+
if (name.startsWith("...")) return { name: name.slice(3), rest: true };
|
|
56
|
+
if (name.startsWith("*") && name.length > 1) return { name: name.slice(1), rest: true };
|
|
57
|
+
return { name, rest: false };
|
|
58
|
+
}
|
|
59
|
+
function resolvedType(type) {
|
|
60
|
+
const t = (type ?? "").trim();
|
|
61
|
+
return t === "" ? UNRESOLVED_TYPE : t;
|
|
62
|
+
}
|
|
63
|
+
function renderParameter(entry, language) {
|
|
64
|
+
const marked = splitRestMarker(entry.name);
|
|
65
|
+
const rest = entry.isRest === true || marked.rest;
|
|
66
|
+
const name = marked.name;
|
|
67
|
+
const type = resolvedType(entry.type);
|
|
68
|
+
const lang = (language ?? "").toLowerCase();
|
|
69
|
+
const trailingDefault = entry.defaultValue !== null && entry.defaultValue !== void 0 && entry.defaultValue !== "" ? ` = ${entry.defaultValue}` : "";
|
|
70
|
+
if (rest) {
|
|
71
|
+
if (lang === "python") return `*${name}: ${type}`;
|
|
72
|
+
if (lang === "java") return `${type}... ${name}`;
|
|
73
|
+
if (lang === "kotlin") return `vararg ${name}: ${type}`;
|
|
74
|
+
if (lang === "scala") return `${name}: ${type}*`;
|
|
75
|
+
return `...${name}: ${type}`;
|
|
76
|
+
}
|
|
77
|
+
if (entry.isImplicit === true) return name;
|
|
78
|
+
if (lang === "java") return trailingDefault !== "" ? `${type} ${name}${trailingDefault}` : `${type} ${name}`;
|
|
79
|
+
if (entry.isOptional === true && trailingDefault === "") {
|
|
80
|
+
if (lang === "javascript" || lang === "typescript" || lang === "" || lang === "unknown") return `${name}?: ${type}`;
|
|
81
|
+
return `${name}: ${type}`;
|
|
82
|
+
}
|
|
83
|
+
return `${name}: ${type}${trailingDefault}`;
|
|
84
|
+
}
|
|
85
|
+
function renderParameterList(raw, language) {
|
|
86
|
+
const parsed = parseParameters(raw);
|
|
87
|
+
switch (parsed.shape) {
|
|
88
|
+
case "absent":
|
|
89
|
+
return UNKNOWN_PARAMETER_LIST;
|
|
90
|
+
case "empty":
|
|
91
|
+
return "";
|
|
92
|
+
case "list":
|
|
93
|
+
return parsed.entries.map((e) => renderParameter(e, language)).join(", ");
|
|
94
|
+
case "opaque":
|
|
95
|
+
return parsed.text;
|
|
96
|
+
case "serialized":
|
|
97
|
+
return UNKNOWN_PARAMETER_LIST;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function renderSignature(symbol, language) {
|
|
101
|
+
const parts = [];
|
|
102
|
+
const visibility = (symbol.visibility ?? "").trim();
|
|
103
|
+
if (visibility !== "") parts.push(visibility);
|
|
104
|
+
parts.push(symbol.symbol_type);
|
|
105
|
+
let sig = symbol.symbol_type.toLowerCase() === symbol.name.toLowerCase() ? parts.join(" ") : `${parts.join(" ")} ${symbol.name}`;
|
|
106
|
+
const type = (symbol.symbol_type ?? "").toLowerCase();
|
|
107
|
+
if (CALLABLE_TYPES.has(type)) {
|
|
108
|
+
sig += `(${renderParameterList(symbol.parameters, language)})`;
|
|
109
|
+
}
|
|
110
|
+
const ret = (symbol.return_type ?? "").trim();
|
|
111
|
+
if (ret !== "") sig += ` \u2192 ${ret}`;
|
|
112
|
+
return sig;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/lsp/cross_language_hover.ts
|
|
116
|
+
function tierForCrossLanguageEdge(edge) {
|
|
117
|
+
return classifyTier({
|
|
118
|
+
relationshipType: edge.relationship_type,
|
|
119
|
+
confidence: edge.confidence,
|
|
120
|
+
evidenceClass: edge.evidence_class
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
var UNNAMED_BRIDGE = "unnamed bridge (stored row carries no mechanism)";
|
|
124
|
+
function factsFromRows(rows, hoverLanguage) {
|
|
125
|
+
if (hoverLanguage === null) return [];
|
|
126
|
+
const facts = [];
|
|
127
|
+
for (const row of rows) {
|
|
128
|
+
if (!row.other_language) continue;
|
|
129
|
+
facts.push({
|
|
130
|
+
pair: `${hoverLanguage} \u2192 ${row.other_language}`,
|
|
131
|
+
direction: row.direction,
|
|
132
|
+
bridge: row.bridge_mechanism ?? UNNAMED_BRIDGE,
|
|
133
|
+
tier: tierForCrossLanguageEdge(row),
|
|
134
|
+
confidence: row.confidence ?? 0,
|
|
135
|
+
relationshipType: row.relationship_type
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return facts;
|
|
139
|
+
}
|
|
140
|
+
function crossLanguageSection(facts) {
|
|
141
|
+
if (facts.length === 0) return "";
|
|
142
|
+
const lines = ["**cross-language** (from stored index rows only):"];
|
|
143
|
+
for (const f of facts) {
|
|
144
|
+
const dir = f.direction === "caller" ? "called from" : "calls into";
|
|
145
|
+
lines.push(`- ${dir} ${f.pair.split(" \u2192 ")[1]} via ${f.bridge} \u2014 ${f.tier} (confidence ${f.confidence})`);
|
|
146
|
+
}
|
|
147
|
+
return lines.join("\n");
|
|
148
|
+
}
|
|
149
|
+
function storedCrossLanguageRows(db, symbolId) {
|
|
150
|
+
const rows = [];
|
|
151
|
+
const callers = db.prepare(
|
|
152
|
+
`SELECT r.relationship_type, r.confidence, r.bridge_mechanism, sf.language AS other_language, r.metadata
|
|
153
|
+
FROM brain_relationship r
|
|
154
|
+
JOIN brain_symbol ss ON ss.id = r.source_symbol_id AND ss.project_id = r.project_id
|
|
155
|
+
JOIN brain_file sf ON sf.id = ss.file_id
|
|
156
|
+
WHERE r.is_cross_language = 1 AND r.target_symbol_id = ?
|
|
157
|
+
AND r.project_id = (SELECT s2.project_id FROM brain_symbol s2 WHERE s2.id = ?)`
|
|
158
|
+
).all(symbolId, symbolId);
|
|
159
|
+
for (const r of callers) rows.push({ ...r, direction: "caller", evidence_class: parseEvidenceClass(r.metadata) });
|
|
160
|
+
const callees = db.prepare(
|
|
161
|
+
`SELECT r.relationship_type, r.confidence, r.bridge_mechanism, tf.language AS other_language, r.metadata
|
|
162
|
+
FROM brain_relationship r
|
|
163
|
+
JOIN brain_symbol ts ON ts.id = r.target_symbol_id AND ts.project_id = r.project_id
|
|
164
|
+
JOIN brain_file tf ON tf.id = ts.file_id
|
|
165
|
+
WHERE r.is_cross_language = 1 AND r.source_symbol_id = ?
|
|
166
|
+
AND r.project_id = (SELECT s2.project_id FROM brain_symbol s2 WHERE s2.id = ?)`
|
|
167
|
+
).all(symbolId, symbolId);
|
|
168
|
+
for (const r of callees) rows.push({ ...r, direction: "callee", evidence_class: parseEvidenceClass(r.metadata) });
|
|
169
|
+
return rows;
|
|
170
|
+
}
|
|
171
|
+
function parseEvidenceClass(metadata) {
|
|
172
|
+
if (!metadata) return null;
|
|
173
|
+
try {
|
|
174
|
+
const parsed = JSON.parse(metadata);
|
|
175
|
+
return typeof parsed["evidenceClass"] === "string" ? parsed["evidenceClass"] : null;
|
|
176
|
+
} catch {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
var CROSS_LANGUAGE_DEFAULT_LIMIT = 200;
|
|
181
|
+
var CROSS_LANGUAGE_MAX_LIMIT = 1e3;
|
|
182
|
+
var CROSS_LANGUAGE_COPY_CAP = 200;
|
|
183
|
+
var SELF_COLUMNS = `r.id AS row_id, r.relationship_type AS relationship_type, r.confidence AS confidence,
|
|
184
|
+
r.bridge_mechanism AS bridge_mechanism, r.metadata AS metadata`;
|
|
185
|
+
var COPY_COLUMNS = `ts.id AS self_id, ts.name AS self_name, tf.relative_path AS self_file,
|
|
186
|
+
tf.language AS self_language, ts.line_start AS self_line,
|
|
187
|
+
NULL AS owner_id, NULL AS owner_name, NULL AS owner_file, NULL AS owner_language, NULL AS owner_line`;
|
|
188
|
+
var OTHER_COLUMNS_AS_TARGET = `ss.id AS other_id, ss.name AS other_name, sf.relative_path AS other_file,
|
|
189
|
+
sf.language AS other_language, ss.line_start AS other_line`;
|
|
190
|
+
var AGENT_FACTS_SQL = `
|
|
191
|
+
SELECT ${SELF_COLUMNS}, 'caller' AS direction, ${COPY_COLUMNS}, ${OTHER_COLUMNS_AS_TARGET}
|
|
192
|
+
FROM brain_symbol ts
|
|
193
|
+
CROSS JOIN brain_relationship r ON r.target_symbol_id = ts.id AND r.is_cross_language = 1
|
|
194
|
+
CROSS JOIN brain_symbol ss ON ss.id = r.source_symbol_id
|
|
195
|
+
JOIN brain_file tf ON tf.id = ts.file_id
|
|
196
|
+
JOIN brain_file sf ON sf.id = ss.file_id
|
|
197
|
+
WHERE ts.name = ? AND r.project_id = ?
|
|
198
|
+
UNION ALL
|
|
199
|
+
SELECT ${SELF_COLUMNS}, 'callee' AS direction, ${COPY_COLUMNS}, ${OTHER_COLUMNS_AS_TARGET}
|
|
200
|
+
FROM brain_symbol ts
|
|
201
|
+
CROSS JOIN brain_relationship r ON r.source_symbol_id = ts.id AND r.is_cross_language = 1
|
|
202
|
+
CROSS JOIN brain_symbol ss ON ss.id = r.target_symbol_id
|
|
203
|
+
JOIN brain_file tf ON tf.id = ts.file_id
|
|
204
|
+
JOIN brain_file sf ON sf.id = ss.file_id
|
|
205
|
+
WHERE ts.name = ? AND r.project_id = ?
|
|
206
|
+
ORDER BY self_file, self_line, direction, other_file, other_line, row_id`;
|
|
207
|
+
var ALL_COPIES_SQL = `
|
|
208
|
+
SELECT s.id AS id, s.name AS name, f.relative_path AS file, f.language AS language, s.line_start AS line
|
|
209
|
+
FROM brain_symbol s
|
|
210
|
+
JOIN brain_file f ON f.id = s.file_id
|
|
211
|
+
WHERE s.project_id = ? AND s.name = ?
|
|
212
|
+
ORDER BY f.relative_path, s.line_start, s.id
|
|
213
|
+
LIMIT ?`;
|
|
214
|
+
var COPY_COUNT_SQL = `
|
|
215
|
+
SELECT COUNT(*) AS total
|
|
216
|
+
FROM brain_symbol
|
|
217
|
+
WHERE project_id = ? AND name = ?`;
|
|
218
|
+
var COPY_LANGUAGES_SQL = `
|
|
219
|
+
SELECT DISTINCT f.language AS language
|
|
220
|
+
FROM brain_symbol s
|
|
221
|
+
JOIN brain_file f ON f.id = s.file_id
|
|
222
|
+
WHERE s.project_id = ? AND s.name = ? AND f.language IS NOT NULL AND TRIM(f.language) <> ''
|
|
223
|
+
ORDER BY f.language`;
|
|
224
|
+
var MEMBER_FACTS_SQL = `
|
|
225
|
+
SELECT ${SELF_COLUMNS}, 'caller' AS direction,
|
|
226
|
+
m.id AS self_id, m.name AS self_name, mfile.relative_path AS self_file,
|
|
227
|
+
mfile.language AS self_language, m.line_start AS self_line,
|
|
228
|
+
owner.id AS owner_id, owner.name AS owner_name, ofile.relative_path AS owner_file,
|
|
229
|
+
ofile.language AS owner_language, owner.line_start AS owner_line,
|
|
230
|
+
${OTHER_COLUMNS_AS_TARGET}
|
|
231
|
+
FROM brain_symbol owner
|
|
232
|
+
CROSS JOIN brain_symbol m ON m.owner_symbol_id = owner.id
|
|
233
|
+
CROSS JOIN brain_relationship r ON r.target_symbol_id = m.id AND r.is_cross_language = 1
|
|
234
|
+
JOIN brain_file mfile ON mfile.id = m.file_id
|
|
235
|
+
JOIN brain_file ofile ON ofile.id = owner.file_id
|
|
236
|
+
JOIN brain_symbol ss ON ss.id = r.source_symbol_id
|
|
237
|
+
JOIN brain_file sf ON sf.id = ss.file_id
|
|
238
|
+
WHERE owner.name = ? AND r.project_id = ? AND m.name <> owner.name
|
|
239
|
+
UNION ALL
|
|
240
|
+
SELECT ${SELF_COLUMNS}, 'callee' AS direction,
|
|
241
|
+
m.id AS self_id, m.name AS self_name, mfile.relative_path AS self_file,
|
|
242
|
+
mfile.language AS self_language, m.line_start AS self_line,
|
|
243
|
+
owner.id AS owner_id, owner.name AS owner_name, ofile.relative_path AS owner_file,
|
|
244
|
+
ofile.language AS owner_language, owner.line_start AS owner_line,
|
|
245
|
+
ss.id AS other_id, ss.name AS other_name, sf.relative_path AS other_file,
|
|
246
|
+
sf.language AS other_language, ss.line_start AS other_line
|
|
247
|
+
FROM brain_symbol owner
|
|
248
|
+
CROSS JOIN brain_symbol m ON m.owner_symbol_id = owner.id
|
|
249
|
+
CROSS JOIN brain_relationship r ON r.source_symbol_id = m.id AND r.is_cross_language = 1
|
|
250
|
+
JOIN brain_file mfile ON mfile.id = m.file_id
|
|
251
|
+
JOIN brain_file ofile ON ofile.id = owner.file_id
|
|
252
|
+
JOIN brain_symbol ss ON ss.id = r.target_symbol_id
|
|
253
|
+
JOIN brain_file sf ON sf.id = ss.file_id
|
|
254
|
+
WHERE owner.name = ? AND r.project_id = ? AND m.name <> owner.name
|
|
255
|
+
ORDER BY self_file, self_line, owner_file, owner_line, direction, other_file, other_line, row_id`;
|
|
256
|
+
var DEEPER_DESCENDANT_ROWS_SQL = `
|
|
257
|
+
WITH RECURSIVE down(id, depth) AS (
|
|
258
|
+
SELECT m.id, 1
|
|
259
|
+
FROM brain_symbol o
|
|
260
|
+
CROSS JOIN brain_symbol m ON m.owner_symbol_id = o.id
|
|
261
|
+
WHERE o.project_id = ? AND o.name = ?
|
|
262
|
+
UNION ALL
|
|
263
|
+
SELECT m.id, down.depth + 1
|
|
264
|
+
FROM brain_symbol m JOIN down ON m.owner_symbol_id = down.id
|
|
265
|
+
)
|
|
266
|
+
SELECT COUNT(*) AS n FROM (
|
|
267
|
+
SELECT r.id FROM down CROSS JOIN brain_relationship r ON r.target_symbol_id = down.id
|
|
268
|
+
WHERE r.project_id = ? AND r.is_cross_language = 1 AND down.depth >= 2
|
|
269
|
+
UNION
|
|
270
|
+
SELECT r.id FROM down CROSS JOIN brain_relationship r ON r.source_symbol_id = down.id
|
|
271
|
+
WHERE r.project_id = ? AND r.is_cross_language = 1 AND down.depth >= 2
|
|
272
|
+
)`;
|
|
273
|
+
function factFromRow(row, match, counters) {
|
|
274
|
+
const pair = row.self_language && row.other_language && row.self_language.toLowerCase() !== row.other_language.toLowerCase() ? `${row.self_language} \u2192 ${row.other_language}` : null;
|
|
275
|
+
if (pair === null) {
|
|
276
|
+
counters.unpairable++;
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
const self = { symbol: row.self_name, file: row.self_file, language: row.self_language, line: row.self_line };
|
|
280
|
+
const fact = {
|
|
281
|
+
self,
|
|
282
|
+
direction: row.direction,
|
|
283
|
+
other: { symbol: row.other_name, file: row.other_file, language: row.other_language, line: row.other_line },
|
|
284
|
+
pair,
|
|
285
|
+
bridge: row.bridge_mechanism ?? UNNAMED_BRIDGE,
|
|
286
|
+
tier: tierForCrossLanguageEdge({
|
|
287
|
+
relationship_type: row.relationship_type,
|
|
288
|
+
confidence: row.confidence,
|
|
289
|
+
evidence_class: parseEvidenceClass(row.metadata)
|
|
290
|
+
}),
|
|
291
|
+
confidence: row.confidence ?? 0,
|
|
292
|
+
relationshipType: row.relationship_type,
|
|
293
|
+
rowId: row.row_id,
|
|
294
|
+
match
|
|
295
|
+
};
|
|
296
|
+
if (match === "owner-cascade") {
|
|
297
|
+
fact.owner = { symbol: row.owner_name, file: row.owner_file, language: row.owner_language, line: row.owner_line };
|
|
298
|
+
fact.matchedMember = self;
|
|
299
|
+
fact.matchedMemberId = row.self_id;
|
|
300
|
+
}
|
|
301
|
+
return fact;
|
|
302
|
+
}
|
|
303
|
+
function storedCrossLanguageFactsByName(db, projectId, name) {
|
|
304
|
+
const rows = db.prepare(AGENT_FACTS_SQL).all(name, projectId, name, projectId);
|
|
305
|
+
const memberRows = db.prepare(MEMBER_FACTS_SQL).all(name, projectId, name, projectId);
|
|
306
|
+
const allCopies = db.prepare(ALL_COPIES_SQL).all(projectId, name, CROSS_LANGUAGE_COPY_CAP);
|
|
307
|
+
const deeperDescendantRows = db.prepare(DEEPER_DESCENDANT_ROWS_SQL).get(projectId, name, projectId, projectId).n;
|
|
308
|
+
const copyTotal = db.prepare(COPY_COUNT_SQL).get(projectId, name).total;
|
|
309
|
+
const copyLanguages = db.prepare(COPY_LANGUAGES_SQL).all(projectId, name).map((r) => r.language);
|
|
310
|
+
const copies = /* @__PURE__ */ new Map();
|
|
311
|
+
for (const copy of allCopies) {
|
|
312
|
+
copies.set(copy.id, { id: copy.id, symbol: copy.name, file: copy.file, language: copy.language, line: copy.line, crossRowCount: 0 });
|
|
313
|
+
}
|
|
314
|
+
const seenRows = /* @__PURE__ */ new Set();
|
|
315
|
+
const facts = [];
|
|
316
|
+
const memberFacts = [];
|
|
317
|
+
const members = /* @__PURE__ */ new Set();
|
|
318
|
+
const counters = { unpairable: 0 };
|
|
319
|
+
let collapsed = 0;
|
|
320
|
+
for (const row of rows) {
|
|
321
|
+
const copy = copies.get(row.self_id);
|
|
322
|
+
if (copy) copy.crossRowCount++;
|
|
323
|
+
else {
|
|
324
|
+
copies.set(row.self_id, { id: row.self_id, symbol: row.self_name, file: row.self_file, language: row.self_language, line: row.self_line, crossRowCount: 1 });
|
|
325
|
+
}
|
|
326
|
+
if (seenRows.has(row.row_id)) {
|
|
327
|
+
collapsed++;
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
seenRows.add(row.row_id);
|
|
331
|
+
const fact = factFromRow(row, "exact", counters);
|
|
332
|
+
if (fact) facts.push(fact);
|
|
333
|
+
}
|
|
334
|
+
for (const row of memberRows) {
|
|
335
|
+
if (seenRows.has(row.row_id)) {
|
|
336
|
+
collapsed++;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
seenRows.add(row.row_id);
|
|
340
|
+
members.add(row.self_id);
|
|
341
|
+
const fact = factFromRow(row, "owner-cascade", counters);
|
|
342
|
+
if (fact) memberFacts.push(fact);
|
|
343
|
+
}
|
|
344
|
+
const sorted = [...copies.values()].sort((a, b) => (a.file ?? "").localeCompare(b.file ?? "") || (a.line ?? 0) - (b.line ?? 0) || a.id.localeCompare(b.id));
|
|
345
|
+
const copyList = sorted.slice(0, CROSS_LANGUAGE_COPY_CAP);
|
|
346
|
+
const languages = copyLanguages.slice().sort();
|
|
347
|
+
return {
|
|
348
|
+
copies: copyList,
|
|
349
|
+
copyCount: copyTotal,
|
|
350
|
+
languages,
|
|
351
|
+
ambiguous: copyTotal > 1,
|
|
352
|
+
copiesTruncated: copyTotal > copyList.length,
|
|
353
|
+
copiesCap: CROSS_LANGUAGE_COPY_CAP,
|
|
354
|
+
deeperDescendantRowCount: deeperDescendantRows,
|
|
355
|
+
facts,
|
|
356
|
+
memberFacts,
|
|
357
|
+
storedRowCount: rows.length + memberRows.length,
|
|
358
|
+
unpairableRowCount: counters.unpairable,
|
|
359
|
+
collapsedRowCount: collapsed,
|
|
360
|
+
memberCount: members.size
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export {
|
|
365
|
+
UNRESOLVED_TYPE,
|
|
366
|
+
UNKNOWN_PARAMETER_LIST,
|
|
367
|
+
parseParameters,
|
|
368
|
+
renderParameterList,
|
|
369
|
+
renderSignature,
|
|
370
|
+
factsFromRows,
|
|
371
|
+
crossLanguageSection,
|
|
372
|
+
storedCrossLanguageRows,
|
|
373
|
+
CROSS_LANGUAGE_DEFAULT_LIMIT,
|
|
374
|
+
CROSS_LANGUAGE_MAX_LIMIT,
|
|
375
|
+
storedCrossLanguageFactsByName
|
|
376
|
+
};
|