@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,340 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkFileFreshness
|
|
3
|
+
} from "./chunk-QLK6ED4Q.js";
|
|
4
|
+
import {
|
|
5
|
+
ASTEngine
|
|
6
|
+
} from "./chunk-V44PGPA6.js";
|
|
7
|
+
|
|
8
|
+
// src/ast/safety-primitives.ts
|
|
9
|
+
var NON_LEAF_IDENTIFIER_TYPES = /* @__PURE__ */ new Set([
|
|
10
|
+
"scoped_identifier",
|
|
11
|
+
"scoped_type_identifier",
|
|
12
|
+
"qualified_identifier",
|
|
13
|
+
"aliased_identifier",
|
|
14
|
+
"qualified_name"
|
|
15
|
+
]);
|
|
16
|
+
var EXTRA_REFERENCE_TYPES = /* @__PURE__ */ new Set([
|
|
17
|
+
"variable_name",
|
|
18
|
+
// PHP $var, Bash $var
|
|
19
|
+
"simple_variable",
|
|
20
|
+
// PowerShell $var
|
|
21
|
+
"variable",
|
|
22
|
+
// Haskell function/pattern var, PowerShell $var (named node)
|
|
23
|
+
"constructor",
|
|
24
|
+
// Haskell data constructor
|
|
25
|
+
"type",
|
|
26
|
+
// Haskell type name (named node; anonymous `type` keywords are excluded by isNamed)
|
|
27
|
+
"module",
|
|
28
|
+
// Haskell module name (named node)
|
|
29
|
+
"constant"
|
|
30
|
+
// Ruby CONST
|
|
31
|
+
]);
|
|
32
|
+
function isIdentifierNodeType(type) {
|
|
33
|
+
if (!type || NON_LEAF_IDENTIFIER_TYPES.has(type)) return false;
|
|
34
|
+
return type === "identifier" || type.endsWith("identifier") || EXTRA_REFERENCE_TYPES.has(type);
|
|
35
|
+
}
|
|
36
|
+
function isCommentNodeType(type) {
|
|
37
|
+
const t = type.toLowerCase();
|
|
38
|
+
return t === "comment" || t.endsWith("comment") || // line_comment, block_comment, doc_comment, container_doc_comment, documentation_comment
|
|
39
|
+
t === "shebang" || t === "haddock" || // Haskell doc comments
|
|
40
|
+
t === "marginalia";
|
|
41
|
+
}
|
|
42
|
+
function isStringNodeType(type) {
|
|
43
|
+
const t = type.toLowerCase();
|
|
44
|
+
return t.includes("string") || // string, string_content, string_fragment, string_literal, raw_string, template_string, string_value, string_scalar, interpolated_string, here_string, triple_quoted_string, verbatim_string_literal, multiline_string_literal, string_start/end, line_string_literal, …
|
|
45
|
+
t.includes("heredoc") || // heredoc, heredoc_body, heredoc_beginning, heredoc_end, heredoc_template
|
|
46
|
+
t === "charlist" || // Elixir '...'
|
|
47
|
+
t === "str_lit" || // Clojure "..."
|
|
48
|
+
t === "char_lit" || // Clojure \a character literal
|
|
49
|
+
t === "literal" || // SQL string/numeric literal; Haskell literal container (string/integer/char — all non-reference bytes)
|
|
50
|
+
t === "double_quote_scalar" || // YAML "..."
|
|
51
|
+
t === "single_quote_scalar" || // YAML '...'
|
|
52
|
+
t.startsWith("block_scalar");
|
|
53
|
+
}
|
|
54
|
+
var MEMBER_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
55
|
+
"property_identifier",
|
|
56
|
+
"field_identifier",
|
|
57
|
+
"shorthand_property_identifier",
|
|
58
|
+
"statement_identifier",
|
|
59
|
+
"label_name"
|
|
60
|
+
]);
|
|
61
|
+
var MEMBER_ACCESS_OBJECT_FIELDS = ["object", "receiver"];
|
|
62
|
+
var MEMBER_ACCESS_NAME_FIELDS = ["name", "property", "field", "attribute", "member"];
|
|
63
|
+
var PARENT_FIELD_CANDIDATES = [
|
|
64
|
+
"name",
|
|
65
|
+
"value",
|
|
66
|
+
"left",
|
|
67
|
+
"right",
|
|
68
|
+
"key",
|
|
69
|
+
"target",
|
|
70
|
+
"pattern",
|
|
71
|
+
"object",
|
|
72
|
+
"receiver",
|
|
73
|
+
"property",
|
|
74
|
+
"field",
|
|
75
|
+
"attribute",
|
|
76
|
+
"member",
|
|
77
|
+
"alias",
|
|
78
|
+
"operator",
|
|
79
|
+
"type",
|
|
80
|
+
"body",
|
|
81
|
+
"expression",
|
|
82
|
+
"arguments",
|
|
83
|
+
"initializer",
|
|
84
|
+
"declarator"
|
|
85
|
+
];
|
|
86
|
+
function parentFieldOf(node) {
|
|
87
|
+
const parent = node?.parent;
|
|
88
|
+
if (!parent || typeof parent.childForFieldName !== "function") return null;
|
|
89
|
+
for (const f of PARENT_FIELD_CANDIDATES) {
|
|
90
|
+
const child = parent.childForFieldName(f);
|
|
91
|
+
if (child && child.startIndex === node.startIndex && child.endIndex === node.endIndex) return f;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function isMemberNameNode(node) {
|
|
96
|
+
if (MEMBER_NODE_TYPES.has(node.type)) return true;
|
|
97
|
+
const parent = node.parent;
|
|
98
|
+
if (!parent) return false;
|
|
99
|
+
const objNode = MEMBER_ACCESS_OBJECT_FIELDS.map((f) => typeof parent.childForFieldName === "function" ? parent.childForFieldName(f) : null).find((n) => n != null);
|
|
100
|
+
if (!objNode) return false;
|
|
101
|
+
if (objNode.startIndex === node.startIndex && objNode.endIndex === node.endIndex) return false;
|
|
102
|
+
const isName = MEMBER_ACCESS_NAME_FIELDS.map((f) => typeof parent.childForFieldName === "function" ? parent.childForFieldName(f) : null).some((n) => n != null && n.startIndex === node.startIndex && n.endIndex === node.endIndex);
|
|
103
|
+
return isName;
|
|
104
|
+
}
|
|
105
|
+
function isBodyNodeType(type) {
|
|
106
|
+
const t = type.toLowerCase();
|
|
107
|
+
return t.endsWith("body") || // function_body, class_body, interface_body, enum_body, method_body, constructor_body, accessor_body, object_body, impl_body, script_block_body, enum_class_body
|
|
108
|
+
t === "block" || // Rust, Go, Java, C#, Python, Lua, Dart
|
|
109
|
+
t === "compound_statement" || // C/C++, Bash
|
|
110
|
+
t === "statement_block" || // TypeScript/JavaScript
|
|
111
|
+
t === "body_statement" || // Ruby
|
|
112
|
+
t === "do_block" || // Elixir
|
|
113
|
+
t === "script_block" || // PowerShell
|
|
114
|
+
t === "declaration_list" || // C# class/interface/enum body
|
|
115
|
+
t === "field_declaration_list" || // Rust struct / Go struct body
|
|
116
|
+
t === "enum_variant_list";
|
|
117
|
+
}
|
|
118
|
+
var INTERPOLATION_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
119
|
+
"template_substitution",
|
|
120
|
+
// JS/TS `${...}`
|
|
121
|
+
"interpolation",
|
|
122
|
+
// Ruby #{...}, Python f-string {...}
|
|
123
|
+
"interpolation_expression",
|
|
124
|
+
// Swift \(...)
|
|
125
|
+
"string_interpolation",
|
|
126
|
+
// Scala s"...${...}", Dart $expr / ${expr}
|
|
127
|
+
"expansion",
|
|
128
|
+
// Bash $var / $(...) / ${...}
|
|
129
|
+
"simple_expansion",
|
|
130
|
+
// Bash $var
|
|
131
|
+
"command_substitution",
|
|
132
|
+
// Bash $(...)
|
|
133
|
+
"arithmetic_expansion",
|
|
134
|
+
// Bash $((...))
|
|
135
|
+
"process_substitution",
|
|
136
|
+
// Bash <(...)
|
|
137
|
+
"subshell",
|
|
138
|
+
// Bash (...)
|
|
139
|
+
"variable_name",
|
|
140
|
+
// PHP $var / Bash $var (live code reference)
|
|
141
|
+
"interpolated_expression"
|
|
142
|
+
// PHP {$var}
|
|
143
|
+
]);
|
|
144
|
+
function walkNodes(rootNode) {
|
|
145
|
+
const stack = [rootNode];
|
|
146
|
+
return (function* () {
|
|
147
|
+
while (stack.length > 0) {
|
|
148
|
+
const node = stack.pop();
|
|
149
|
+
yield node;
|
|
150
|
+
const children = node.children;
|
|
151
|
+
for (let i = children.length - 1; i >= 0; i--) stack.push(children[i]);
|
|
152
|
+
}
|
|
153
|
+
})();
|
|
154
|
+
}
|
|
155
|
+
function collectMaskedRanges(tree) {
|
|
156
|
+
const masked = [];
|
|
157
|
+
const code = [];
|
|
158
|
+
for (const node of walkNodes(tree.rootNode)) {
|
|
159
|
+
const type = node.type;
|
|
160
|
+
if (isCommentNodeType(type)) {
|
|
161
|
+
masked.push({ startIndex: node.startIndex, endIndex: node.endIndex, kind: "comment", nodeType: type });
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (isStringNodeType(type)) {
|
|
165
|
+
masked.push({ startIndex: node.startIndex, endIndex: node.endIndex, kind: "string", nodeType: type });
|
|
166
|
+
}
|
|
167
|
+
if (INTERPOLATION_NODE_TYPES.has(type)) {
|
|
168
|
+
code.push({ startIndex: node.startIndex, endIndex: node.endIndex, kind: "string", nodeType: type });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return { masked, code };
|
|
172
|
+
}
|
|
173
|
+
function buildMaskFromRanges(masked, code, contentLength) {
|
|
174
|
+
const len = Math.max(0, contentLength);
|
|
175
|
+
const mask = new Uint8Array(len);
|
|
176
|
+
mask.fill(1);
|
|
177
|
+
for (const r of masked) {
|
|
178
|
+
const end = Math.min(r.endIndex, len);
|
|
179
|
+
for (let i = r.startIndex; i < end; i++) mask[i] = 0;
|
|
180
|
+
}
|
|
181
|
+
for (const r of code) {
|
|
182
|
+
const end = Math.min(r.endIndex, len);
|
|
183
|
+
for (let i = r.startIndex; i < end; i++) mask[i] = 1;
|
|
184
|
+
}
|
|
185
|
+
return mask;
|
|
186
|
+
}
|
|
187
|
+
function isDeclarationContainerType(type) {
|
|
188
|
+
const t = type.toLowerCase();
|
|
189
|
+
return t.includes("declarator") || // C/C++ function_declarator; JS/TS variable_declarator
|
|
190
|
+
t.includes("declaration") || // function_declaration, method_declaration, function_declaration_left (F#)
|
|
191
|
+
t.includes("definition") || // function_definition (Python/PHP/Scala), method_definition (TS/JS)
|
|
192
|
+
t.includes("signature") || // Dart function_signature
|
|
193
|
+
t.endsWith("_item") || // Rust function_item
|
|
194
|
+
t.endsWith("_spec") || // Go type_spec
|
|
195
|
+
t === "function" || // Haskell top-level binding
|
|
196
|
+
t === "function_clause" || // Erlang
|
|
197
|
+
// C#: a bare `int Target() { … }` fragment is not inside a class, so the
|
|
198
|
+
// grammar parses it as a LOCAL FUNCTION. Measured shape; without this entry
|
|
199
|
+
// a full C# method declaration is invisible to the structural detector.
|
|
200
|
+
t === "local_function_statement" || t === "method" || // Ruby `def`
|
|
201
|
+
t === "class" || // Ruby class (bare `class` node)
|
|
202
|
+
t === "module" || // Ruby module
|
|
203
|
+
t === "constructor";
|
|
204
|
+
}
|
|
205
|
+
function collectDeclaredNames(tree) {
|
|
206
|
+
const out = [];
|
|
207
|
+
for (const node of walkNodes(tree.rootNode)) {
|
|
208
|
+
if (!node.isNamed) continue;
|
|
209
|
+
if (!isDeclarationContainerType(node.type)) continue;
|
|
210
|
+
const named = typeof node.childForFieldName === "function" ? node.childForFieldName("name") : null;
|
|
211
|
+
let nameNode = named && named.namedChildCount === 0 ? named : null;
|
|
212
|
+
if (nameNode === null && named === null) {
|
|
213
|
+
nameNode = (node.children ?? []).find(
|
|
214
|
+
(child) => child && child.isNamed && child.namedChildCount === 0 && isIdentifierNodeType(String(child.type))
|
|
215
|
+
) ?? null;
|
|
216
|
+
}
|
|
217
|
+
if (!nameNode) continue;
|
|
218
|
+
const text = String(nameNode.text ?? "");
|
|
219
|
+
if (text.length === 0) continue;
|
|
220
|
+
out.push({
|
|
221
|
+
text,
|
|
222
|
+
startIndex: nameNode.startIndex,
|
|
223
|
+
endIndex: nameNode.endIndex,
|
|
224
|
+
declarationType: node.type,
|
|
225
|
+
declarationStart: node.startIndex,
|
|
226
|
+
declarationEnd: node.endIndex
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return out;
|
|
230
|
+
}
|
|
231
|
+
function collectBodyRanges(tree) {
|
|
232
|
+
const out = [];
|
|
233
|
+
for (const node of walkNodes(tree.rootNode)) {
|
|
234
|
+
if (!node.isNamed) continue;
|
|
235
|
+
if (!isBodyNodeType(node.type)) continue;
|
|
236
|
+
out.push({ startIndex: node.startIndex, endIndex: node.endIndex, nodeType: node.type });
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
function extractIdentifierOccurrences(tree, content) {
|
|
241
|
+
const out = [];
|
|
242
|
+
for (const node of walkNodes(tree.rootNode)) {
|
|
243
|
+
const type = node.type;
|
|
244
|
+
if (isCommentNodeType(type)) continue;
|
|
245
|
+
if (!node.isNamed) continue;
|
|
246
|
+
if (!isIdentifierNodeType(type)) continue;
|
|
247
|
+
if (node.namedChildCount !== 0) continue;
|
|
248
|
+
const text = content.substring(node.startIndex, node.endIndex);
|
|
249
|
+
if (text.length === 0) continue;
|
|
250
|
+
out.push({
|
|
251
|
+
text,
|
|
252
|
+
startIndex: node.startIndex,
|
|
253
|
+
endIndex: node.endIndex,
|
|
254
|
+
nodeType: type,
|
|
255
|
+
parentType: node.parent ? node.parent.type : "",
|
|
256
|
+
isMemberName: isMemberNameNode(node),
|
|
257
|
+
parentField: parentFieldOf(node),
|
|
258
|
+
startLine: node.startPosition.row + 1,
|
|
259
|
+
startColumn: node.startPosition.column + 1,
|
|
260
|
+
endLine: node.endPosition.row + 1,
|
|
261
|
+
endColumn: node.endPosition.column + 1
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
function extractCommentSites(tree) {
|
|
267
|
+
const out = [];
|
|
268
|
+
const stack = tree?.rootNode ? [tree.rootNode] : [];
|
|
269
|
+
while (stack.length > 0) {
|
|
270
|
+
const node = stack.pop();
|
|
271
|
+
if (node === null || node === void 0) continue;
|
|
272
|
+
if (isCommentNodeType(String(node.type))) {
|
|
273
|
+
out.push({ endLine: Number(node?.endPosition?.row ?? 0) + 1, text: String(node?.text ?? "") });
|
|
274
|
+
}
|
|
275
|
+
const children = node?.children ?? [];
|
|
276
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
277
|
+
if (children[i] !== null && children[i] !== void 0) stack.push(children[i]);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return out;
|
|
281
|
+
}
|
|
282
|
+
async function parseForSafety(filePath, content) {
|
|
283
|
+
const { language, tree, parser, transientLuaGrammar } = await ASTEngine.parseTree(filePath, content);
|
|
284
|
+
try {
|
|
285
|
+
const { masked, code } = collectMaskedRanges(tree);
|
|
286
|
+
return {
|
|
287
|
+
language,
|
|
288
|
+
content,
|
|
289
|
+
mask: buildMaskFromRanges(masked, code, content.length),
|
|
290
|
+
occurrences: extractIdentifierOccurrences(tree, content),
|
|
291
|
+
maskedRanges: masked,
|
|
292
|
+
codeRanges: code,
|
|
293
|
+
bodyRanges: collectBodyRanges(tree),
|
|
294
|
+
commentSites: extractCommentSites(tree),
|
|
295
|
+
declaredNames: collectDeclaredNames(tree),
|
|
296
|
+
hasSyntaxError: Boolean(tree?.rootNode?.hasError)
|
|
297
|
+
};
|
|
298
|
+
} finally {
|
|
299
|
+
try {
|
|
300
|
+
if (tree && typeof tree.delete === "function") tree.delete();
|
|
301
|
+
} catch {
|
|
302
|
+
}
|
|
303
|
+
if (language === "lua") {
|
|
304
|
+
try {
|
|
305
|
+
if (parser && typeof parser.delete === "function") parser.delete();
|
|
306
|
+
} catch {
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
if (transientLuaGrammar && typeof transientLuaGrammar.delete === "function") transientLuaGrammar.delete();
|
|
310
|
+
} catch {
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function collectStaleFiles(raw, fileIds) {
|
|
316
|
+
const out = [];
|
|
317
|
+
const seen = /* @__PURE__ */ new Set();
|
|
318
|
+
for (const fileId of fileIds) {
|
|
319
|
+
if (!fileId || seen.has(fileId)) continue;
|
|
320
|
+
seen.add(fileId);
|
|
321
|
+
const f = checkFileFreshness(raw, fileId);
|
|
322
|
+
if (f && f.status !== "fresh") out.push({ fileId, path: f.path, status: f.status });
|
|
323
|
+
}
|
|
324
|
+
return out;
|
|
325
|
+
}
|
|
326
|
+
function assertFreshFiles(raw, fileIds, context) {
|
|
327
|
+
const stale = collectStaleFiles(raw, fileIds);
|
|
328
|
+
if (stale.length > 0) {
|
|
329
|
+
const detail = stale.map((s) => `${s.path} (${s.status})`).join(", ");
|
|
330
|
+
throw new Error(`${context}: ${stale.length} file(s) are not fresh \u2014 ${detail}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export {
|
|
335
|
+
isIdentifierNodeType,
|
|
336
|
+
isCommentNodeType,
|
|
337
|
+
extractIdentifierOccurrences,
|
|
338
|
+
parseForSafety,
|
|
339
|
+
assertFreshFiles
|
|
340
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runCli
|
|
3
|
+
} from "../chunk-FWSL4VG6.js";
|
|
4
|
+
import "../chunk-66A5ZFYA.js";
|
|
5
|
+
import "../chunk-J4PMBXQQ.js";
|
|
6
|
+
import "../chunk-2RRBMNBQ.js";
|
|
7
|
+
import "../chunk-2RTN2DFU.js";
|
|
8
|
+
import "../chunk-PJTNGD3Z.js";
|
|
9
|
+
import "../chunk-4H22TLOT.js";
|
|
10
|
+
import "../chunk-5SD45FLC.js";
|
|
11
|
+
import "../chunk-7AN7U5IZ.js";
|
|
12
|
+
import "../chunk-UGR4QIGS.js";
|
|
13
|
+
import "../chunk-GEFFO6O2.js";
|
|
14
|
+
import "../chunk-VURYFIHW.js";
|
|
15
|
+
import "../chunk-DYM4FQEE.js";
|
|
16
|
+
import {
|
|
17
|
+
getProjectId
|
|
18
|
+
} from "../chunk-DIYAGQJL.js";
|
|
19
|
+
import "../chunk-UUNHHX4M.js";
|
|
20
|
+
import "../chunk-6WNGD3NN.js";
|
|
21
|
+
import "../chunk-QLK6ED4Q.js";
|
|
22
|
+
import "../chunk-KLK3PBTO.js";
|
|
23
|
+
import "../chunk-V44PGPA6.js";
|
|
24
|
+
import "../chunk-BQ3OVQ3P.js";
|
|
25
|
+
import "../chunk-SK6YVHFZ.js";
|
|
26
|
+
import "../chunk-2BSKD7O3.js";
|
|
27
|
+
import "../chunk-KAET47ZL.js";
|
|
28
|
+
import "../chunk-KCDECRJY.js";
|
|
29
|
+
import "../chunk-D2Q4Y47A.js";
|
|
30
|
+
import "../chunk-SM7RFQRO.js";
|
|
31
|
+
import "../chunk-L5TDYKYK.js";
|
|
32
|
+
import "../chunk-ROMM6KMC.js";
|
|
33
|
+
import "../chunk-MLKGABMK.js";
|
|
34
|
+
export {
|
|
35
|
+
getProjectId,
|
|
36
|
+
runCli
|
|
37
|
+
};
|