@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,29 @@
|
|
|
1
|
+
// src/ast/project-scoped-identity.ts
|
|
2
|
+
function projectRelativePath(filePath, projectRoot) {
|
|
3
|
+
if (!projectRoot) return null;
|
|
4
|
+
const root = stripTrailingSlashes(projectRoot.split("\\").join("/"));
|
|
5
|
+
const file = stripTrailingSlashes(filePath.split("\\").join("/"));
|
|
6
|
+
if (root.length === 0 || file === root || !file.startsWith(root + "/")) return null;
|
|
7
|
+
return file.slice(root.length + 1);
|
|
8
|
+
}
|
|
9
|
+
function stripTrailingSlashes(p) {
|
|
10
|
+
let end = p.length;
|
|
11
|
+
while (end > 0 && p.charAt(end - 1) === "/") end--;
|
|
12
|
+
return p.slice(0, end);
|
|
13
|
+
}
|
|
14
|
+
function documentDirScope(filePath, projectRoot) {
|
|
15
|
+
const rel = projectRelativePath(filePath, projectRoot);
|
|
16
|
+
if (rel === null) return "";
|
|
17
|
+
const cut = rel.lastIndexOf("/");
|
|
18
|
+
if (cut < 0) return "";
|
|
19
|
+
return rel.slice(0, cut).split("/").filter((s) => s.length > 0).join(".");
|
|
20
|
+
}
|
|
21
|
+
function applyDocumentScope(basename, scope) {
|
|
22
|
+
return scope.length > 0 ? `${scope}.${basename}` : basename;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
projectRelativePath,
|
|
27
|
+
documentDirScope,
|
|
28
|
+
applyDocumentScope
|
|
29
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/intelligence/source-utils.ts
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
async function readSymbolSnippet(filePath, lineStart, lineEnd, maxLines = 12) {
|
|
4
|
+
if (!filePath || !lineStart) return void 0;
|
|
5
|
+
let text = "";
|
|
6
|
+
try {
|
|
7
|
+
text = await readFile(filePath, "utf8");
|
|
8
|
+
} catch {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
const end = Math.min(Math.max(lineEnd || lineStart, lineStart), lineStart + maxLines - 1);
|
|
12
|
+
return text.split("\n").slice(lineStart - 1, end).join("\n");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
readSymbolSnippet
|
|
17
|
+
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParallelIndexerConfig,
|
|
3
|
+
parallelIndexerCliSkipPatterns
|
|
4
|
+
} from "./chunk-PJTNGD3Z.js";
|
|
5
|
+
|
|
6
|
+
// src/ast/fingerprint.ts
|
|
7
|
+
import { createHash } from "crypto";
|
|
8
|
+
import { readFile, readdir, stat, open } from "fs/promises";
|
|
9
|
+
import path from "path";
|
|
10
|
+
function relativePathFingerprint(sortedRel) {
|
|
11
|
+
return createHash("sha1").update(Array.from(new Set(sortedRel)).sort().join("\n")).digest("hex").substring(0, 40);
|
|
12
|
+
}
|
|
13
|
+
async function gitIdentity(root) {
|
|
14
|
+
try {
|
|
15
|
+
const { execFile } = await import("child_process");
|
|
16
|
+
const run = (args) => new Promise((resolve) => {
|
|
17
|
+
execFile("git", ["-C", root, ...args], { timeout: 4e3 }, (err, stdout) => {
|
|
18
|
+
resolve(err ? "" : stdout.toString().trim());
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
const remote = await run(["remote", "get-url", "origin"]);
|
|
22
|
+
const head = await run(["rev-parse", "HEAD"]);
|
|
23
|
+
if (!remote && !head) return null;
|
|
24
|
+
return `${remote || "(no-remote)"}|${head || "(no-head)"}`;
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
var FULL_AST_LIMIT = 1 * 1024 * 1024;
|
|
30
|
+
var STRUCTURAL_LIMIT = 5 * 1024 * 1024;
|
|
31
|
+
var skipDirNames = /* @__PURE__ */ new Set([".git", ".svn", ".hg", ".cache", ".nyc_output", ".venv", ".next", ".nuxt", ".svelte-kit", ".turbo"]);
|
|
32
|
+
var compiledDirTokens = ["/perf/", "/Microbenchmarks/", "/wwwroot/", "/coverage/", "/node_modules/", "/dist/", "/build/", "/.git/", "/obj/", "/bin/", "/testData/"];
|
|
33
|
+
var cliSkipPatterns = Array.from(
|
|
34
|
+
/* @__PURE__ */ new Set([...ParallelIndexerConfig.skipPatterns, ...parallelIndexerCliSkipPatterns()])
|
|
35
|
+
);
|
|
36
|
+
async function loadIgnores(root, ownPath, parentIg) {
|
|
37
|
+
try {
|
|
38
|
+
const ignore = (await import("ignore")).default;
|
|
39
|
+
const ig = ignore({ ignorecase: false }).add(parentIg);
|
|
40
|
+
const entries = await readdir(ownPath, { withFileTypes: true });
|
|
41
|
+
for (const name of [".gitignore", ".bbignore"]) {
|
|
42
|
+
const f = entries.find((e) => e.isFile() && e.name === name);
|
|
43
|
+
if (!f) continue;
|
|
44
|
+
try {
|
|
45
|
+
const content = await readFile(path.join(ownPath, f.name), "utf8");
|
|
46
|
+
ig.add(content);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return ig;
|
|
51
|
+
} catch {
|
|
52
|
+
return parentIg;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
var DEFAULT_IGNORE_PATTERNS = [
|
|
56
|
+
"**/perf/**",
|
|
57
|
+
"**/Microbenchmarks/**",
|
|
58
|
+
"**/wwwroot/**",
|
|
59
|
+
"**/testassets/**",
|
|
60
|
+
"**/benchmarkapps/**",
|
|
61
|
+
"**/coverage/**",
|
|
62
|
+
"**/testData/**"
|
|
63
|
+
];
|
|
64
|
+
async function readShebang(p) {
|
|
65
|
+
try {
|
|
66
|
+
const fh = await open(p, "r");
|
|
67
|
+
try {
|
|
68
|
+
const buf = Buffer.alloc(256);
|
|
69
|
+
const { bytesRead } = await fh.read(buf, 0, 256, 0);
|
|
70
|
+
return buf.subarray(0, bytesRead).toString("utf8");
|
|
71
|
+
} finally {
|
|
72
|
+
await fh.close();
|
|
73
|
+
}
|
|
74
|
+
} catch {
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function walk(root, dir, ig, depth, rel) {
|
|
79
|
+
if (depth > 50) return;
|
|
80
|
+
let entries = [];
|
|
81
|
+
try {
|
|
82
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
83
|
+
} catch {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (dir !== root && entries.some((e) => e.isDirectory() && e.name === ".git")) return;
|
|
87
|
+
const localIg = await loadIgnores(root, dir, ig);
|
|
88
|
+
const { detectLanguageFromPath } = await import("./language-detection-DFCAU5DZ.js");
|
|
89
|
+
const jobs = [];
|
|
90
|
+
for (const entry of entries) {
|
|
91
|
+
if (entry.isDirectory() && skipDirNames.has(entry.name)) continue;
|
|
92
|
+
const fullPath = path.join(dir, entry.name);
|
|
93
|
+
const relativePath = path.relative(root, fullPath);
|
|
94
|
+
const withSlash = relativePath + (entry.isDirectory() ? "/" : "");
|
|
95
|
+
const normPath = "/" + relativePath + (entry.isDirectory() ? "/" : "");
|
|
96
|
+
if (compiledDirTokens.some((t) => normPath.includes(t))) continue;
|
|
97
|
+
if (localIg.ignores(withSlash)) continue;
|
|
98
|
+
if (entry.isDirectory()) {
|
|
99
|
+
jobs.push(walk(root, fullPath, localIg, depth + 1, rel));
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!entry.isFile()) continue;
|
|
103
|
+
const baseName = entry.name;
|
|
104
|
+
const hasExt = baseName.lastIndexOf(".") > 0;
|
|
105
|
+
let detected = null;
|
|
106
|
+
if (hasExt) {
|
|
107
|
+
detected = detectLanguageFromPath(fullPath);
|
|
108
|
+
} else {
|
|
109
|
+
detected = detectLanguageFromPath(fullPath);
|
|
110
|
+
if (!detected) detected = detectLanguageFromPath(fullPath, await readShebang(fullPath));
|
|
111
|
+
}
|
|
112
|
+
if (!detected) continue;
|
|
113
|
+
if (cliSkipPatterns.some((p) => p.test(normPath))) continue;
|
|
114
|
+
jobs.push(
|
|
115
|
+
(async () => {
|
|
116
|
+
try {
|
|
117
|
+
const s = await stat(fullPath);
|
|
118
|
+
if (s.size > STRUCTURAL_LIMIT) return;
|
|
119
|
+
rel.push(relativePath);
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
})()
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
await Promise.all(jobs);
|
|
126
|
+
}
|
|
127
|
+
async function computeCheckoutFingerprint(root) {
|
|
128
|
+
const { default: ignore } = await import("ignore");
|
|
129
|
+
const ig = ignore({ ignorecase: false }).add(DEFAULT_IGNORE_PATTERNS);
|
|
130
|
+
const rel = [];
|
|
131
|
+
await walk(root, root, ig, 0, rel);
|
|
132
|
+
const sorted = Array.from(new Set(rel)).sort();
|
|
133
|
+
const git = await gitIdentity(root);
|
|
134
|
+
const fingerprint = createHash("sha1").update(sorted.join("\n")).update(git ?? "").digest("hex").substring(0, 40);
|
|
135
|
+
return { fingerprint, fileCount: sorted.length, git };
|
|
136
|
+
}
|
|
137
|
+
function computeDbFingerprint(raw, git) {
|
|
138
|
+
const rows = raw.prepare("SELECT relative_path FROM brain_file").all();
|
|
139
|
+
const sorted = rows.map((r) => String(r.relative_path)).sort();
|
|
140
|
+
return createHash("sha1").update(sorted.join("\n")).update(git ?? "").digest("hex").substring(0, 40);
|
|
141
|
+
}
|
|
142
|
+
function readStoredFingerprint(raw, projectId) {
|
|
143
|
+
try {
|
|
144
|
+
const row = raw.prepare(
|
|
145
|
+
"SELECT codebase_fingerprint FROM brain_index_status WHERE project_id = ?"
|
|
146
|
+
).get(projectId);
|
|
147
|
+
return row?.codebase_fingerprint ?? void 0;
|
|
148
|
+
} catch {
|
|
149
|
+
return void 0;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function persistProjectFingerprint(projectId, projectPath) {
|
|
153
|
+
try {
|
|
154
|
+
const cf = await computeCheckoutFingerprint(projectPath);
|
|
155
|
+
const { BrainDatabase } = await import("./database-TCTZDLE5.js");
|
|
156
|
+
const raw = await BrainDatabase.getRawInstance(projectId);
|
|
157
|
+
raw.prepare(
|
|
158
|
+
`UPDATE brain_index_status SET codebase_fingerprint = ?, codebase_git = ?, time_updated = strftime('%s','now')*1000
|
|
159
|
+
WHERE project_id = ?`
|
|
160
|
+
).run(cf.fingerprint, cf.git ?? null, projectId);
|
|
161
|
+
return cf.fingerprint;
|
|
162
|
+
} catch {
|
|
163
|
+
return "";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
relativePathFingerprint,
|
|
169
|
+
gitIdentity,
|
|
170
|
+
computeCheckoutFingerprint,
|
|
171
|
+
computeDbFingerprint,
|
|
172
|
+
readStoredFingerprint,
|
|
173
|
+
persistProjectFingerprint
|
|
174
|
+
};
|