@backbencher/brain 0.0.0-stage → 0.1.1
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-Q5APTJQL.js +17 -0
- package/dist/brain-relationship-enrichment-MYR2AM4F.js +558 -0
- package/dist/brain.sql-EIM4WS4D.js +29 -0
- package/dist/chunk-22V37YTK.js +1758 -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-2WXYNLBA.js +29 -0
- package/dist/chunk-3CTFIJJB.js +17 -0
- package/dist/chunk-3ZTOHHSW.js +2104 -0
- package/dist/chunk-4H22TLOT.js +543 -0
- package/dist/chunk-5BVAH26D.js +340 -0
- package/dist/chunk-62DHLYW6.js +3427 -0
- package/dist/chunk-7AN7U5IZ.js +371 -0
- package/dist/chunk-7DRPNVIN.js +782 -0
- package/dist/chunk-7MBYT777.js +174 -0
- package/dist/chunk-AHDWGM7Q.js +236 -0
- package/dist/chunk-B5GEAAYF.js +818 -0
- package/dist/chunk-BEIZZ73B.js +1479 -0
- package/dist/chunk-BQ3OVQ3P.js +125 -0
- package/dist/chunk-D2Q4Y47A.js +53 -0
- package/dist/chunk-DIYAGQJL.js +34 -0
- package/dist/chunk-DWKXZ6IF.js +336 -0
- package/dist/chunk-DYM4FQEE.js +90 -0
- package/dist/chunk-ENW4BTBA.js +930 -0
- package/dist/chunk-EWMWK7WN.js +75 -0
- package/dist/chunk-EY5ZZUUA.js +626 -0
- package/dist/chunk-GBI7V7KY.js +69 -0
- package/dist/chunk-GEFFO6O2.js +152 -0
- package/dist/chunk-HJEWO5EV.js +247 -0
- package/dist/chunk-HQSPJDHI.js +613 -0
- package/dist/chunk-KAET47ZL.js +125 -0
- package/dist/chunk-KCDECRJY.js +440 -0
- package/dist/chunk-L5TDYKYK.js +76 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-NO3U3FJQ.js +201 -0
- package/dist/chunk-OWISBAOF.js +61 -0
- package/dist/chunk-QKTRECYS.js +1119 -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-RM3PY6TG.js +376 -0
- package/dist/chunk-ROMM6KMC.js +433 -0
- package/dist/chunk-SGGCSHAX.js +12050 -0
- package/dist/chunk-SK6YVHFZ.js +211 -0
- package/dist/chunk-SM7RFQRO.js +214 -0
- package/dist/chunk-UGR4QIGS.js +67 -0
- package/dist/chunk-UQNQZXHY.js +711 -0
- package/dist/chunk-UUNHHX4M.js +13 -0
- package/dist/chunk-VL52PL2T.js +71 -0
- package/dist/chunk-WIG36E67.js +196 -0
- package/dist/chunk-XHK3WWGB.js +7436 -0
- package/dist/chunk-XTQM2IP3.js +2863 -0
- package/dist/chunk-ZE2LG76D.js +1296 -0
- package/dist/chunk-ZETTGPAW.js +6950 -0
- package/dist/cli/index.js +37 -0
- package/dist/config-HZAAYDP3.js +10 -0
- package/dist/content-search-7XIP555Q.js +593 -0
- package/dist/database-76RP44JG.js +9 -0
- package/dist/doctor-ANGETYMN.js +395 -0
- package/dist/edit-engine-CG72LDZD.js +51 -0
- package/dist/engine-BKEOGN7N.js +11 -0
- package/dist/engine-VIW6NSKO.js +18 -0
- package/dist/fingerprint-OBLIMZLP.js +33 -0
- package/dist/framework-intelligence-3LORTPOX.js +860 -0
- package/dist/freshness-3K6VU5OT.js +174 -0
- package/dist/graph-engine-HBSQNPTB.js +21 -0
- package/dist/graph_request-Q6NKB6N2.js +350 -0
- package/dist/impact_request-LYP672WE.js +68 -0
- package/dist/index-space-IUUN5WYV.js +15 -0
- package/dist/index-status-7OVGYSGW.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-FK2XKZXY.js +88 -0
- package/dist/pool-worker.js +1153 -0
- package/dist/project-health-6XPENVAA.js +94 -0
- package/dist/project-index-5SDPHITE.js +57 -0
- package/dist/project-registry-ZJ3DVUGO.js +355 -0
- package/dist/real-bash-analyzer-EJAU5LW5.js +2201 -0
- package/dist/real-c-analyzer-HBD3FNNH.js +5942 -0
- package/dist/real-clean-analyzer-4EEZLPV5.js +3470 -0
- package/dist/real-clojure-analyzer-Q55EBOO2.js +2818 -0
- package/dist/real-cpp-analyzer-IVVOD25R.js +4101 -0
- package/dist/real-csharp-analyzer-ZBNLNJZJ.js +3298 -0
- package/dist/real-css-analyzer-6XRQLUN7.js +15 -0
- package/dist/real-dart-analyzer-OLR72EFW.js +3944 -0
- package/dist/real-elixir-analyzer-MQWGAH2I.js +2192 -0
- package/dist/real-erlang-analyzer-7BVPQEHO.js +1731 -0
- package/dist/real-fsharp-analyzer-C2UPFNOA.js +2390 -0
- package/dist/real-go-analyzer-UKGI43YS.js +4126 -0
- package/dist/real-graphql-analyzer-VE2EEFII.js +1442 -0
- package/dist/real-groovy-analyzer-W26VACFW.js +2285 -0
- package/dist/real-haskell-analyzer-5CVVAJRX.js +2533 -0
- package/dist/real-hcl-analyzer-5ZT4U43N.js +725 -0
- package/dist/real-html-analyzer-JWNX3C6I.js +1759 -0
- package/dist/real-java-analyzer-GU42VBGQ.js +4677 -0
- package/dist/real-javascript-analyzer-QA4QOJ6W.js +14 -0
- package/dist/real-json-analyzer-MPA6PRXL.js +1640 -0
- package/dist/real-julia-analyzer-22CWYQMN.js +2085 -0
- package/dist/real-kotlin-analyzer-QDZJLXXU.js +3956 -0
- package/dist/real-lua-analyzer-G7NHLYKS.js +1957 -0
- package/dist/real-makefile-analyzer-OCY3GT5N.js +920 -0
- package/dist/real-markdown-analyzer-TEJK2JXJ.js +1215 -0
- package/dist/real-matlab-analyzer-Q5SWLN7Z.js +480 -0
- package/dist/real-nim-analyzer-YLXSK563.js +3603 -0
- package/dist/real-objective-c-analyzer-D23ACC2R.js +1518 -0
- package/dist/real-perl-analyzer-WWTRHYDT.js +1865 -0
- package/dist/real-php-analyzer-JNKJHTCL.js +9368 -0
- package/dist/real-powershell-analyzer-XRSNQERV.js +2915 -0
- package/dist/real-protobuf-analyzer-3OKUCZ7T.js +867 -0
- package/dist/real-python-analyzer-VXAFWI72.js +4880 -0
- package/dist/real-r-analyzer-ZGAIDVI4.js +2596 -0
- package/dist/real-ruby-analyzer-X2KTLVBH.js +2429 -0
- package/dist/real-rust-analyzer-OFFHPL2A.js +3359 -0
- package/dist/real-scala-analyzer-TSTW27J6.js +3293 -0
- package/dist/real-scss-analyzer-AVWYPSOQ.js +1515 -0
- package/dist/real-solidity-analyzer-UCI2KWUB.js +2608 -0
- package/dist/real-sql-analyzer-F77ZMQXR.js +3840 -0
- package/dist/real-svelte-analyzer-SF7NRUO5.js +2532 -0
- package/dist/real-swift-analyzer-MN5QT3QN.js +2311 -0
- package/dist/real-toml-analyzer-66L7BDCQ.js +929 -0
- package/dist/real-typescript-analyzer-6KEMVDWQ.js +14 -0
- package/dist/real-vb-analyzer-VICVPOP7.js +3145 -0
- package/dist/real-vba-analyzer-HXLTTHKM.js +466 -0
- package/dist/real-vue-analyzer-QXR56CFV.js +2680 -0
- package/dist/real-xml-analyzer-YL465ZJW.js +2405 -0
- package/dist/real-yaml-analyzer-SUBCBNSI.js +3528 -0
- package/dist/real-zig-analyzer-HIQLZMGY.js +2430 -0
- package/dist/regex-search-NJKHMZNO.js +239 -0
- package/dist/rules-ACHPB7QU.js +152 -0
- package/dist/scoped-path-MJYWJZQX.js +11 -0
- package/dist/setup-show-NT5ZHYNE.js +15 -0
- package/dist/setup-wizard-G5YYR5T6.js +24 -0
- package/dist/symbol-search-GZJIM2J2.js +16 -0
- package/dist/taint-KXUHHPIE.js +202 -0
- package/dist/taint-analyzer-N7YLZU3N.js +163 -0
- package/dist/tool-handlers-OJDC35DI.js +72 -0
- package/dist/tool-registry-BPEJNSZG.js +17 -0
- package/dist/tool-validation-Q57YMMBX.js +32 -0
- package/dist/type-inference-QMT2RMLV.js +13 -0
- package/dist/vector-binary-LMY4QGAN.js +19 -0
- package/dist/version-ABP2TUL2.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,391 @@
|
|
|
1
|
+
# Troubleshooting the worker pool
|
|
2
|
+
|
|
3
|
+
> Gated by `script/verify-docs-indexing.ts` (see [`README.md`](README.md)). Source
|
|
4
|
+
> of truth: `resolvePoolWorkerFork` (`src/ast/parallel-indexer.ts:1246-1269`),
|
|
5
|
+
> the diagnosing resolver `resolvePoolWorkerForkSafe`
|
|
6
|
+
> (`src/ast/pool-diagnostics.ts`), the fork pre-flight test
|
|
7
|
+
> (`src/ast/parallel-indexer.ts:4770-4825`), the startup watchdog
|
|
8
|
+
> (`:1593-1600`), and the fallback decision (`:4816-4825`). Every message
|
|
9
|
+
> quoted below is emitted verbatim by that code, and the gate checks it.
|
|
10
|
+
|
|
11
|
+
## The symptom, in your words
|
|
12
|
+
|
|
13
|
+
> "The index takes forever."
|
|
14
|
+
>
|
|
15
|
+
> "It says it indexed everything but it's crawling."
|
|
16
|
+
>
|
|
17
|
+
> "My 32-core machine is running one thread."
|
|
18
|
+
>
|
|
19
|
+
> "Is it even using the workers?"
|
|
20
|
+
|
|
21
|
+
Underneath all of those is one observable fact. Every index run prints a line
|
|
22
|
+
saying which parse path it used (`src/cli/index.ts:376-384`):
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
parsed with the worker pool
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
parsed in-process — the worker pool was unavailable, so this run was serial and is correspondingly slower
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
There is also a fourth possibility, and it means what it says:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
parsed: mode not recorded for this run (pre-dates the parseMode field)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
and a fifth, for a run that parsed nothing at all:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
parsed nothing — no files needed parsing, so no parse mode was used
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If you are seeing the middle line, the run lost its worker pool and fell back
|
|
45
|
+
to **single-threaded** parsing. Every other number on the summary still reads
|
|
46
|
+
perfectly — `errors: 0`, `timeouts: 0` — because in-process parsing is
|
|
47
|
+
*correct*, just slow. This line is the only thing that reveals it, which is why
|
|
48
|
+
it exists.
|
|
49
|
+
|
|
50
|
+
## Diagnose it
|
|
51
|
+
|
|
52
|
+
Run these three, in order. The first two are read-only.
|
|
53
|
+
|
|
54
|
+
### 1. Ask the last run
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
bb status
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
✓ last index of /proj: 8 files, 24 symbols, 22 relationships
|
|
62
|
+
total n/a | parse 1218ms | dbFlush 27ms | discovery 77ms | startup 990ms
|
|
63
|
+
mode worker-pool | workers 1 | noop no
|
|
64
|
+
db: <data-dir>/projects/<projectId>/brain.db
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Real output from a fixture. Two fields matter:
|
|
68
|
+
|
|
69
|
+
- **`mode`** — `worker-pool`, or `in-process`.
|
|
70
|
+
- **`workers`** — how many were actually spawned. It is `0` for every
|
|
71
|
+
in-process run. On a no-op run (nothing to parse) it is `0` too, because no
|
|
72
|
+
worker was ever needed; check `noop` before concluding the pool failed.
|
|
73
|
+
|
|
74
|
+
`bb status` also shows an in-flight run, so you can watch `workerCount` and
|
|
75
|
+
`filesPerSecond` while the run is still going.
|
|
76
|
+
|
|
77
|
+
### 2. Turn the logs up
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
bb index --verbose
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`--verbose` sets `BB_LOG_LEVEL=debug` (`src/cli/index.ts:713`, `:720-723`).
|
|
84
|
+
There is **no `-v` short form** — `-v` is `--version`. This matters here more
|
|
85
|
+
than anywhere else: without `--verbose`, workers default to `error` and
|
|
86
|
+
deliberately swallow everything below it (`src/ast/pool-worker.ts:20-22`), so
|
|
87
|
+
WASM-load failures, engine-load failures and pool diagnostics are **invisible**.
|
|
88
|
+
|
|
89
|
+
What to look for:
|
|
90
|
+
|
|
91
|
+
| Log line | Meaning |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| `worker pool fork test passed — using parallel workers` | The pool is healthy. |
|
|
94
|
+
| `worker pool fork unavailable, falling back to in-process` | The pre-flight test failed; see causes 1–3. |
|
|
95
|
+
| `worker pool unavailable — no tsx binary found (dev mode)` | Cause 1. |
|
|
96
|
+
| `starting worker pool` with `numWorkers` / `files` / `batchSize` | The pool sized itself; useful for the "only one worker" question. |
|
|
97
|
+
| `Worker did not become ready within startup timeout — killing` | Cause 3. |
|
|
98
|
+
| `worker N engine load FAILED: …` (stderr, prefixed `[brain]`) | Cause 4. |
|
|
99
|
+
| `[worker] …` / `[worker-out] …` on stderr | Raw worker stderr/stdout. **Only relayed when `BB_WORKER_ECHO=1`** — otherwise it is drained and discarded (`src/ast/parallel-indexer.ts:1621-1632`). |
|
|
100
|
+
| `[BB-PARSE-ERR] <lang> \| <path> \| <msg>` | Per-file parse failure. Full detail also lands in `~/.bb/logs/parse-errors.log` (`src/ast/pool-worker.ts:846`). |
|
|
101
|
+
|
|
102
|
+
One caveat on the relay: echoing every worker line produced a wall of
|
|
103
|
+
`[worker] [INFO] [ast-engine] …` that buried the progress line, so the echo is
|
|
104
|
+
opt-in. If you need it for one diagnosis, set `BB_WORKER_ECHO=1` alongside
|
|
105
|
+
`--verbose`.
|
|
106
|
+
|
|
107
|
+
### 3. Check for the environment mistake
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
echo "BB_POOL_WORKER=[$BB_POOL_WORKER]"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
If that prints anything other than empty, see [Cause 5](#cause-5--bb_pool_worker-is-set-in-your-environment).
|
|
114
|
+
|
|
115
|
+
## Causes and fixes
|
|
116
|
+
|
|
117
|
+
### Cause 1 — `tsx` cannot be found (development checkouts)
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
worker pool unavailable — no tsx binary found (dev mode)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Worker fork targets are resolved by `resolvePoolWorkerFork`
|
|
124
|
+
(`src/ast/parallel-indexer.ts:1246-1269`):
|
|
125
|
+
|
|
126
|
+
| Situation | Fork target |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| Compiled `dist/` | `dist/pool-worker.js` — the module itself, no loader needed |
|
|
129
|
+
| Node running from `src/` | the `tsx` binary **plus** `src/ast/pool-worker.ts` |
|
|
130
|
+
| Bun running from `src/` | `src/ast/pool-worker.ts` directly (Bun runs TypeScript natively) |
|
|
131
|
+
|
|
132
|
+
In the Node-from-`src` case the resolver looks for `node_modules/.bin/tsx`
|
|
133
|
+
first, then `tsx` on `PATH` (`src/ast/parallel-indexer.ts:1262-1263`). If
|
|
134
|
+
neither exists it returns no worker path at all, and every file in the queue is
|
|
135
|
+
failed with:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
worker pool unavailable (startup failure)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
(`src/ast/parallel-indexer.ts:1553`).
|
|
142
|
+
|
|
143
|
+
**This cannot happen in a normal published install** — a `dist/` build forks
|
|
144
|
+
`dist/pool-worker.js` directly and never looks for `tsx`. It does not need
|
|
145
|
+
`node_modules` at all beyond its own runtime deps.
|
|
146
|
+
|
|
147
|
+
**Fix:** install dependencies (`npm install`), or make `tsx` resolvable on
|
|
148
|
+
`PATH`. If you are running from `src/`, you are in a development checkout and
|
|
149
|
+
dependencies are expected to be installed.
|
|
150
|
+
|
|
151
|
+
### Cause 2 — the fork pre-flight test fails
|
|
152
|
+
|
|
153
|
+
Before any real parsing, `bb index` forks one worker and waits for it to answer
|
|
154
|
+
`ready` (`src/ast/parallel-indexer.ts:4784-4813`). The wait is **not** a separate
|
|
155
|
+
60-second constant: it is `poolStartupTimeoutMs()` — the *same* knob and the
|
|
156
|
+
same value as the pool's own startup watchdog, `BB_WORKER_STARTUP_TIMEOUT_MS`,
|
|
157
|
+
default **30 000 ms** (`src/ast/pool-diagnostics.ts:77-90`,
|
|
158
|
+
`src/ast/parallel-indexer.ts:4789`). It used to be hardcoded at 60s while the
|
|
159
|
+
watchdog was 30s, so a slow machine could fail the real pool at 30s and then sit
|
|
160
|
+
through another 60s waiting for a probe that was never going to pass.
|
|
161
|
+
|
|
162
|
+
The failure reasons are specific:
|
|
163
|
+
|
|
164
|
+
| Rejection message | Meaning |
|
|
165
|
+
| --- | --- |
|
|
166
|
+
| `worker fork test timed out after 30s` | The worker started but never became ready — usually a broken runtime, or a machine so loaded that booting the engine took over the timeout. The number is your configured timeout, rounded to seconds. |
|
|
167
|
+
| `worker exited with code N` | The worker crashed during boot. `N` is its exit code. Note the `exit` handler only rejects a **non-zero** code, so a worker that exits 0 without sending `ready` is caught by the timeout, not by this branch. |
|
|
168
|
+
| Any `error` event from `fork()` | The fork itself failed. |
|
|
169
|
+
|
|
170
|
+
Any of these makes the run fall back to in-process parsing
|
|
171
|
+
(`src/ast/parallel-indexer.ts:4816-4825`). Because the timeout is the same
|
|
172
|
+
knob, `BB_WORKER_STARTUP_TIMEOUT_MS` moves both — see
|
|
173
|
+
[Cause 3](#cause-3--the-startup-watchdog-fires).
|
|
174
|
+
|
|
175
|
+
**Fix:**
|
|
176
|
+
|
|
177
|
+
1. Re-run with `--verbose` and read the reason. That is the whole diagnosis.
|
|
178
|
+
2. If it is a timeout, the machine is overloaded or the disk is very slow.
|
|
179
|
+
Close other builds, wait for load to drop, retry.
|
|
180
|
+
3. If it is a crash, check for missing tree-sitter grammar `.wasm` assets —
|
|
181
|
+
see [Cause 4](#cause-4--the-workers-engine-failed-to-load).
|
|
182
|
+
4. Confirm the run still completes. An in-process run indexes every file
|
|
183
|
+
correctly; it is only slower. Let it finish before you escalate.
|
|
184
|
+
|
|
185
|
+
### Cause 3 — the startup watchdog fires
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
Worker did not become ready within startup timeout — killing
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Each forked worker gets a startup watchdog. If it has not signalled `ready`
|
|
192
|
+
within `BB_WORKER_STARTUP_TIMEOUT_MS` (default **30 000 ms**), it is `SIGKILL`ed
|
|
193
|
+
and counted as a startup failure (`src/ast/parallel-indexer.ts:1593-1600`).
|
|
194
|
+
The pool allows at most `max(numWorkers, 2)` startup attempts
|
|
195
|
+
(`MAX_STARTUP_FAILURES`, `src/ast/parallel-indexer.ts:1545`) before failing the
|
|
196
|
+
remaining queue visibly, so a broken runtime cannot produce an infinite
|
|
197
|
+
spawn-kill loop (`src/ast/parallel-indexer.ts:1728-1730`).
|
|
198
|
+
|
|
199
|
+
A garbage or non-positive `BB_WORKER_STARTUP_TIMEOUT_MS` does **not** become
|
|
200
|
+
`setTimeout(fn, NaN)`: the reader falls back to the 30 s default
|
|
201
|
+
(`src/ast/pool-diagnostics.ts:85-89`), because that would report every worker as
|
|
202
|
+
hung.
|
|
203
|
+
|
|
204
|
+
**Fix:** raise the watchdog for a loaded or slow machine:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
BB_WORKER_STARTUP_TIMEOUT_MS=120000 bb index --verbose
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
This is a legitimate production knob, not a test hook, and it governs **both**
|
|
211
|
+
the fork pre-flight and the per-worker watchdog. Raising it fixes a *timeout*;
|
|
212
|
+
it cannot fix a crash. If raising it does not help, the worker is failing to
|
|
213
|
+
boot for another reason.
|
|
214
|
+
|
|
215
|
+
### Cause 4 — the workers' engine failed to load
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
[brain] worker 3 engine load FAILED: <error>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The process forked and answered, but the AST engine inside it did not load —
|
|
222
|
+
usually a missing or unreadable tree-sitter grammar `.wasm`. The worker is not
|
|
223
|
+
pooled in this case; it is kept idle so its regex-based fallback extractor can
|
|
224
|
+
still handle files (`src/ast/parallel-indexer.ts:1640-1653`).
|
|
225
|
+
|
|
226
|
+
**Fix:**
|
|
227
|
+
|
|
228
|
+
1. `bb index --verbose` — a WASM-load failure is suppressed at default log
|
|
229
|
+
level and only appears here.
|
|
230
|
+
2. Check that the grammar assets are present. They are resolved from the
|
|
231
|
+
package's `wasm/` directory, from `~/.bb/wasm/`, or from the install
|
|
232
|
+
directory.
|
|
233
|
+
3. Reinstall the package that ships the grammars if they are missing.
|
|
234
|
+
4. If a single language's grammar is broken, exclude that language's files with
|
|
235
|
+
`.bbignore` so the rest of the project indexes cleanly.
|
|
236
|
+
|
|
237
|
+
Note that files can also fail individually with a 45-second per-file timeout
|
|
238
|
+
(`BB_FILE_TIMEOUT_MS`, default 45 000 ms — `src/ast/parallel-indexer.ts:130`).
|
|
239
|
+
Such a file is killed, retried up to 3 times (`MAX_FILE_RETRIES`,
|
|
240
|
+
`src/ast/parallel-indexer.ts:1411`), and then recorded as a poison pill with the
|
|
241
|
+
error `Max retries exceeded (poison pill)` (`:1517-1521`). It shows up in the
|
|
242
|
+
`breakdown:` line as `timeouts`, not as a startup problem.
|
|
243
|
+
|
|
244
|
+
Note also that the pool's own success message hardcodes the file timeout in its
|
|
245
|
+
prose — `worker pool available — using parallel indexing with 45s timeouts`
|
|
246
|
+
(`src/ast/parallel-indexer.ts:4814`) — so that "45s" is **not** evidence your
|
|
247
|
+
`BB_FILE_TIMEOUT_MS` took effect. It is a literal in a string, not the
|
|
248
|
+
configured value.
|
|
249
|
+
|
|
250
|
+
### Cause 5 — `BB_POOL_WORKER` is set in your environment
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
$ echo "[$BB_POOL_WORKER]"
|
|
254
|
+
[1]
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
`BB_POOL_WORKER=1` is how the parent tells a forked child "you are a pool
|
|
258
|
+
worker". The parent sets it on every fork
|
|
259
|
+
(`src/ast/parallel-indexer.ts:4781`, `:1515`). **You should never set it
|
|
260
|
+
yourself** — in particular do not try to "force in-process" with it.
|
|
261
|
+
|
|
262
|
+
Setting `BB_POOL_WORKER=0` looks like a supported opt-out and is not one; it is
|
|
263
|
+
what `resolvePoolWorkerForkSafe` treats as a disable request
|
|
264
|
+
(`src/ast/pool-diagnostics.ts:80`, `:190-201`), which makes the whole run fall
|
|
265
|
+
back to in-process parsing.
|
|
266
|
+
|
|
267
|
+
If you export `BB_POOL_WORKER=1` in your own shell, every forked child warns on
|
|
268
|
+
stderr (`src/ast/pool-worker.ts:1454-1458`) because a real child should not have
|
|
269
|
+
inherited it from you:
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
[BB-WORKER-STARTUP] forked with BB_POOL_WORKER=1 rather than "1"; serving anyway — unset BB_POOL_WORKER to use in-process indexing
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
(The `rather than "1"` in that message is the *correct* value — the line exists to
|
|
276
|
+
be read, not matched.) The older and worse failure was that such a child skipped
|
|
277
|
+
the keep-alive, exited 0 **without ever sending `ready`**, and the fork probe —
|
|
278
|
+
which only rejects a non-zero exit — then hung for its full timeout before
|
|
279
|
+
reporting a failure that named nothing. That is fixed; the keep-alive is now
|
|
280
|
+
gated on `process.connected` (the IPC channel), not on the env var
|
|
281
|
+
(`src/ast/pool-worker.ts:1453`, and the reasoning at `:1432-1452`).
|
|
282
|
+
|
|
283
|
+
**Fix:**
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
unset BB_POOL_WORKER
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
If you set it in a `.env`, `.zshrc`, `.bashrc`, or a CI config, remove it.
|
|
290
|
+
|
|
291
|
+
### Cause 6 — only one worker, and that is correct
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
$ bb index --verbose
|
|
295
|
+
... starting worker pool {"numWorkers":1, "files":7, "batchSize":10}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
This is **not** a bug. The pool sizes itself as
|
|
299
|
+
`min(concurrency, ceil(files / batchSize))` with `batchSize = 10`
|
|
300
|
+
(`src/ast/parallel-indexer.ts:1310-1311`, `:136`). Seven files means
|
|
301
|
+
`ceil(7/10) = 1`, so one worker — on any machine, with any core count.
|
|
302
|
+
|
|
303
|
+
`concurrency` itself is `max(2, min(cpus - 1, 12))`
|
|
304
|
+
(`src/ast/parallel-indexer.ts:125`), so the ceiling is **12 workers** no matter
|
|
305
|
+
how many cores you have. Verified live: this box reports 12 CPUs and the pool
|
|
306
|
+
logs `concurrency: 11`.
|
|
307
|
+
|
|
308
|
+
**Confirm** with `bb status` → `mode` and `workers`.
|
|
309
|
+
|
|
310
|
+
**Fix:** none for small projects. If you genuinely have thousands of files and
|
|
311
|
+
still see `workers: 1`, that is a real degradation — go back to Cause 1.
|
|
312
|
+
|
|
313
|
+
And do not assume more workers is faster. The one controlled comparison in this
|
|
314
|
+
repository (`validation/m19/results/S3-controls.json:1-60`, 100-file disjoint samples)
|
|
315
|
+
found 12 workers slightly faster on the throughput control but *slower* on the
|
|
316
|
+
memory control, and the evidence file states plainly that the samples were
|
|
317
|
+
disjoint and sequential, "not a same-input benchmark".
|
|
318
|
+
|
|
319
|
+
## Environment variables that control worker behaviour
|
|
320
|
+
|
|
321
|
+
| Variable | Default | Effect |
|
|
322
|
+
| --- | --- | --- |
|
|
323
|
+
| `BB_POOL_WORKER` | unset | Set to `1` **by the parent** on every forked worker (`src/ast/parallel-indexer.ts:4781`). `0`/`false`/`off`/`no`/`none` are read as a request to disable the pool entirely (`src/ast/pool-diagnostics.ts:80`). Any other value you export yourself is inherited by children and warned about. See [Cause 5](#cause-5--bb_pool_worker-is-set-in-your-environment). |
|
|
324
|
+
| `BB_POOL_WORKER_SELFTEST` | unset | Set to `1` to make a pool worker print a machine-readable startup line and exit — a one-shot check of the worker alone, without running a whole index (`src/ast/pool-worker.ts:1519`). Run it directly: `BB_POOL_WORKER_SELFTEST=1 node dist/pool-worker.js`. Start here when `bb doctor` reports the pool unavailable and you want the worker's own view rather than the parent's. |
|
|
325
|
+
| `BB_WORKER_STARTUP_TIMEOUT_MS` | `30000` | How long a forked worker has to signal `ready` before it is `SIGKILL`ed and counted as a startup failure (`src/ast/pool-diagnostics.ts:77-90`, `src/ast/parallel-indexer.ts:1593-1600`). Governs the fork pre-flight test too. A non-positive or unparseable value falls back to 30 s. Raise it on loaded machines. |
|
|
326
|
+
| `BB_FILE_TIMEOUT_MS` | `45000` | Per-file hard timeout. A file exceeding it is killed and retried up to 3 times (`src/ast/parallel-indexer.ts:130`, `:1411`). |
|
|
327
|
+
| `BB_LOG_LEVEL` | `error` inside workers | Workers default to `error` and suppress everything below (`src/ast/pool-worker.ts:20-22`). `--verbose` sets `debug`; `--quiet` sets `warn` (`src/cli/index.ts:720-727`). An explicit value you export is inherited by workers rather than overridden. |
|
|
328
|
+
| `BB_DATA_DIR` | `~/.bb` | Relocates the whole data directory (`src/util/bb-data-dir.ts:11-13`). Workers resolve their diagnostics log from it too (`src/ast/pool-worker.ts:27-28`). |
|
|
329
|
+
|
|
330
|
+
**Concurrency has no env var.** Worker count is derived from `os.cpus().length`
|
|
331
|
+
and the file count; there is no supported way to set it from the environment.
|
|
332
|
+
|
|
333
|
+
**Worker output echo has one**, and it is undocumented on purpose: `BB_WORKER_ECHO=1`
|
|
334
|
+
relays raw worker stdout/stderr as `[worker]` / `[worker-out]`. It defaults to
|
|
335
|
+
off because unconditional echoing buried the progress line. The gate records
|
|
336
|
+
this deliberate omission in `KNOWN_UNDOCUMENTED`.
|
|
337
|
+
|
|
338
|
+
### Test-only hooks — do not use in production
|
|
339
|
+
|
|
340
|
+
These require `BB_TEST_HOOKS=1` and exist to make failure modes
|
|
341
|
+
deterministically testable. They are quarantined behind that flag so a stray
|
|
342
|
+
environment variable cannot stall a real index (`src/ast/pool-worker.ts:1292`,
|
|
343
|
+
`:1385`).
|
|
344
|
+
|
|
345
|
+
| Variable | Requires | Effect |
|
|
346
|
+
| --- | --- | --- |
|
|
347
|
+
| `BB_TEST_HOOKS` | — | Gate for the three below. Unset in normal use. |
|
|
348
|
+
| `BB_WORKER_DELAY_READY_MS` | `BB_TEST_HOOKS=1` | Delays the `ready` signal, exercising the startup watchdog. |
|
|
349
|
+
| `BB_WORKER_CRASH_ON_BATCH` | `BB_TEST_HOOKS=1` | Makes a worker crash on a batch. |
|
|
350
|
+
| `BB_WORKER_DELAY_PARSE_MS` | `BB_TEST_HOOKS=1` | Delays parsing inside a worker. |
|
|
351
|
+
| `BB_TEST_INDEX_LOCK_OFF` | `BB_TEST_HOOKS=1` | Disables the single-flight index lock (`src/ast/index-lock.ts:322`). |
|
|
352
|
+
|
|
353
|
+
If you have `BB_TEST_HOOKS=1` exported, unset it. It also unlocks a freshness
|
|
354
|
+
short-circuit in the `bb_analyze` MCP tool handler
|
|
355
|
+
(`src/mcp/tools/bb_analyze/handler.ts:164`).
|
|
356
|
+
|
|
357
|
+
## Gate runtime: Node/tsx vs Bun-from-source
|
|
358
|
+
|
|
359
|
+
The product runs under both Node (the shipped `bin/bb`, `dist/`) and Bun (from source, `bun src/cli/index.ts`),
|
|
360
|
+
but the **pool diagnostics gates** (`script/verify-pool-workers.ts`, `script/verify-pool-doctor.ts`) exercise
|
|
361
|
+
Node's `fork`/`worker_threads` + tsx startup/ABI semantics, which are the shipped binary's worker path. Run
|
|
362
|
+
them with `npx tsx`. Under Bun they print a `RUNTIME: bun — … not applicable under Bun-from-source` note
|
|
363
|
+
before their checks, because the Bun-from-source CLI uses a different worker implementation and a failure
|
|
364
|
+
there is a runtime mismatch, not a product defect. The rest of the gate suite is designed for `npx tsx`;
|
|
365
|
+
`script/m21/verify-index-resume.ts` and the indexer gates are runtime-independent (they call the API).
|
|
366
|
+
|
|
367
|
+
## The related lock error
|
|
368
|
+
|
|
369
|
+
Shape of the message (`src/ast/index-lock.ts:115`; the pid, host and timestamp are
|
|
370
|
+
interpolated, so do not match on them):
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
✗ another index run is already active for this project (pid 4821, started 2026-10-02T17:41:03.000Z, kind=index); wait for it to finish, or if it crashed the stale lock at .index.lock is reclaimed automatically on the next run
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
This is not a worker problem — the pool never started because the run never
|
|
377
|
+
started. Indexing is single-flight per project
|
|
378
|
+
(`src/ast/index-lock.ts`, `IndexLockHeldError`). Either another `bb index` / MCP index is
|
|
379
|
+
live, or a previous one crashed; the message says which, and a stale lock from a
|
|
380
|
+
crashed process is reclaimed automatically on the next run. Do not delete the
|
|
381
|
+
lock file by hand.
|
|
382
|
+
|
|
383
|
+
`--force` acquires the same lock *before* it wipes
|
|
384
|
+
(`src/cli/index.ts:168-180`), so a `--force` run cannot slip between another
|
|
385
|
+
run's wipe and its parse.
|
|
386
|
+
|
|
387
|
+
## Related
|
|
388
|
+
|
|
389
|
+
- [`README.md`](README.md) — flag semantics
|
|
390
|
+
- [`performance.md`](performance.md) — why a serial run is so much slower
|
|
391
|
+
- [`docs/TROUBLESHOOTING.md`](../TROUBLESHOOTING.md) — general `bb` troubleshooting
|
package/docs/man/bb.1
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
.TH BB 1 "September 2026" "bb 0.3.0" "User Commands"
|
|
2
|
+
.SH NAME
|
|
3
|
+
bb \- Backbencher Brain, universal code intelligence for 40+ languages
|
|
4
|
+
.SH SYNOPSIS
|
|
5
|
+
.B bb
|
|
6
|
+
[\fIoptions\fR] [\fIcommand\fR]
|
|
7
|
+
.SH DESCRIPTION
|
|
8
|
+
.B bb
|
|
9
|
+
indexes a codebase into a local knowledge base (AST, symbols, embeddings)
|
|
10
|
+
and serves it to humans and AI agents: keyword and semantic search, question
|
|
11
|
+
answering over the index, health reporting, and an MCP server that editors
|
|
12
|
+
and agent hosts can connect to.
|
|
13
|
+
.PP
|
|
14
|
+
Embedding vectors make semantic search (\fIbb_search\fR, \fIbb_ask\fR) much
|
|
15
|
+
more precise. Without a configured embedding provider, semantic search falls
|
|
16
|
+
back to local word vectors, which are deliberately weaker; both kinds of
|
|
17
|
+
vectors are stored separately, labeled by producing model, and never compared
|
|
18
|
+
across vector spaces.
|
|
19
|
+
.SH COMMANDS
|
|
20
|
+
.TP
|
|
21
|
+
.B tool
|
|
22
|
+
Run one of the public tools with JSON arguments (the MCP surface, also usable
|
|
23
|
+
from scripts).
|
|
24
|
+
.TP
|
|
25
|
+
.BI index " dir"
|
|
26
|
+
Index a project. The first interactive run offers embedding setup when no
|
|
27
|
+
provider is configured yet; the wizard prompts only once (an explicit skip is
|
|
28
|
+
remembered). Re-run with
|
|
29
|
+
.B \-\-force
|
|
30
|
+
after changing the embedding model so stored vectors are rebuilt.
|
|
31
|
+
.TP
|
|
32
|
+
.B setup
|
|
33
|
+
Configure the embedding provider interactively: pick a prefilled free
|
|
34
|
+
provider or a custom OpenAI-compatible endpoint, paste the API key (input is
|
|
35
|
+
hidden), the key is validated with one live /embeddings call before it is
|
|
36
|
+
saved, and the config is written with permissions 0600.
|
|
37
|
+
.TP
|
|
38
|
+
.B setup show
|
|
39
|
+
Print the effective embedding configuration: every precedence tier (env,
|
|
40
|
+
global, project), the winning tier, and the key as a last-four fingerprint
|
|
41
|
+
only. The full key is never displayed. Exits 1 when nothing is configured.
|
|
42
|
+
.TP
|
|
43
|
+
.B doctor
|
|
44
|
+
Diagnose embedding setup, worker-pool startup and index consistency from real
|
|
45
|
+
local state: the embedding configuration tiers, file permissions, the models
|
|
46
|
+
actually stored in the project index, and a live probe that forks a pool worker
|
|
47
|
+
and asks what it loaded (the only way to tell "no tsx" from "tsx ran and the
|
|
48
|
+
engine would not load", which look identical from the outside and need opposite
|
|
49
|
+
fixes). Every finding names the exact command that resolves it. Read-only by
|
|
50
|
+
default; exits 1 when a hard finding exists.
|
|
51
|
+
This is the first command to run when pool workers do not start or when semantic
|
|
52
|
+
search returns poor results.
|
|
53
|
+
.TP
|
|
54
|
+
.B doctor \-\-fix
|
|
55
|
+
Repair config file permissions to 0600 only. This is the single mutating arm
|
|
56
|
+
of doctor: every change is printed, and everything else (keys, config
|
|
57
|
+
content, index) is never modified.
|
|
58
|
+
.TP
|
|
59
|
+
.BI search " query"
|
|
60
|
+
Search the index. Modes are
|
|
61
|
+
.BR symbols " (default), " content ", " symbol ", and " file .
|
|
62
|
+
There is no semantic mode: embeddings power
|
|
63
|
+
.BR bb_ask ,
|
|
64
|
+
not
|
|
65
|
+
.BR bb_search .
|
|
66
|
+
.TP
|
|
67
|
+
.BI health " [dir]"
|
|
68
|
+
Index health and freshness.
|
|
69
|
+
.TP
|
|
70
|
+
.BI stats " [dir]"
|
|
71
|
+
Query index counts at any time \(em files, symbols, relationships, embeddings
|
|
72
|
+
\(em and print the database path. Unlike
|
|
73
|
+
.B health
|
|
74
|
+
this is a count, not an assessment: use it to check what is stored.
|
|
75
|
+
.TP
|
|
76
|
+
.BI status " [dir]"
|
|
77
|
+
Show in-flight and last-run index state with per-phase timings (discovery,
|
|
78
|
+
worker startup, parse, database flush), which parse mode ran, and how many
|
|
79
|
+
workers were used. This is the command to reach for when indexing felt slow:
|
|
80
|
+
the phase timings say whether the time went to parsing or to the derived pass.
|
|
81
|
+
.TP
|
|
82
|
+
.BI projects " [options]"
|
|
83
|
+
List every indexed project with its database path, size, counts and last index
|
|
84
|
+
time \(em useful for finding or reclaiming disk.
|
|
85
|
+
.B \-\-remove
|
|
86
|
+
<id> deletes one project's index;
|
|
87
|
+
.B \-\-force
|
|
88
|
+
skips the confirmation.
|
|
89
|
+
.TP
|
|
90
|
+
.B upgrade
|
|
91
|
+
Report whether a newer
|
|
92
|
+
.I bb
|
|
93
|
+
is published, and print the exact command to install it. bb is installed with
|
|
94
|
+
.BR "npm install -g @backbencher/brain" ,
|
|
95
|
+
so npm owns the install and this command deliberately does not replace its own
|
|
96
|
+
files \(em a self-updater would fight the package manager and fail on a
|
|
97
|
+
read-only or root-owned global prefix.
|
|
98
|
+
.B \-\-check
|
|
99
|
+
reports only, changing nothing;
|
|
100
|
+
.B \-\-to
|
|
101
|
+
<dist-tag-or-range>
|
|
102
|
+
compares against something other than
|
|
103
|
+
.IR latest .
|
|
104
|
+
When the registry cannot be reached, or answers with an error, it says so and
|
|
105
|
+
exits 1 rather than reporting that you are up to date \(em a claim it cannot
|
|
106
|
+
support. After upgrading, re-index with
|
|
107
|
+
.BR "bb index \-\-changed" .
|
|
108
|
+
.TP
|
|
109
|
+
.BI onboard " [dir]"
|
|
110
|
+
Write the bb tools guidance section into
|
|
111
|
+
.I <dir>/AGENTS.md
|
|
112
|
+
so an agent host discovers the bb tools without being told. The section is
|
|
113
|
+
generated from the tool registry (it can never name a tool that does not
|
|
114
|
+
exist), and writing is idempotent: only the block between the
|
|
115
|
+
.B bb:onboard
|
|
116
|
+
markers is replaced, everything else in the file is preserved.
|
|
117
|
+
.B \-\-check
|
|
118
|
+
reports drift or ghost tool names and exits 1 without writing;
|
|
119
|
+
.B \-\-print
|
|
120
|
+
shows the generated section;
|
|
121
|
+
.B \-\-file
|
|
122
|
+
chooses another guide file.
|
|
123
|
+
.TP
|
|
124
|
+
.B mcp
|
|
125
|
+
Start the MCP server over stdio for Claude Code, Cursor, VS Code, and other
|
|
126
|
+
MCP hosts.
|
|
127
|
+
.TP
|
|
128
|
+
.B version
|
|
129
|
+
Print the bb version (same as
|
|
130
|
+
.B \-v
|
|
131
|
+
and
|
|
132
|
+
.B \-\-version
|
|
133
|
+
).
|
|
134
|
+
.TP
|
|
135
|
+
.B help
|
|
136
|
+
Show help for any command.
|
|
137
|
+
.SH OPTIONS
|
|
138
|
+
.TP
|
|
139
|
+
.B \-\-verbose
|
|
140
|
+
Show diagnostics: debug logs, per-file worker and WASM lines. This is how you
|
|
141
|
+
see why the worker pool did or did not start. Note there is no short form:
|
|
142
|
+
.B \-v
|
|
143
|
+
is
|
|
144
|
+
.BR \-\-version .
|
|
145
|
+
.TP
|
|
146
|
+
.B \-\-quiet
|
|
147
|
+
Suppress informational output; warnings and errors only. Note there is no short
|
|
148
|
+
form.
|
|
149
|
+
.TP
|
|
150
|
+
.BR \-v ", " \-\-version
|
|
151
|
+
Output the version number.
|
|
152
|
+
.TP
|
|
153
|
+
.BR \-h ", " \-\-help
|
|
154
|
+
Display help for the command.
|
|
155
|
+
.SH EMBEDDING SETUP
|
|
156
|
+
Configuration precedence is: environment variables
|
|
157
|
+
.RB ( BB_EMBEDDING_BASE_URL ,
|
|
158
|
+
.BR BB_EMBEDDING_API_KEY ,
|
|
159
|
+
.BR BB_EMBEDDING_MODEL ),
|
|
160
|
+
then the global config
|
|
161
|
+
.B ~/.bb/config.json
|
|
162
|
+
(written by
|
|
163
|
+
.BR bb\ setup ),
|
|
164
|
+
then the project file
|
|
165
|
+
.BR bb.json .
|
|
166
|
+
The config file holds an API key, so it is written with permissions 0600; if
|
|
167
|
+
it is ever more open, `bb doctor` warns and `bb doctor --fix` repairs the
|
|
168
|
+
permissions. Free-tier providers are offered in the wizard (OpenRouter,
|
|
169
|
+
NVIDIA NIM), and any OpenAI-compatible /embeddings endpoint can be used as a
|
|
170
|
+
custom provider. After adding or changing a model, refresh stored vectors
|
|
171
|
+
with `bb index --force`.
|
|
172
|
+
.SH EXIT STATUS
|
|
173
|
+
.TP
|
|
174
|
+
.B 0
|
|
175
|
+
Success, or doctor found only warnings (no hard finding).
|
|
176
|
+
.TP
|
|
177
|
+
.B 1
|
|
178
|
+
Error, or a hard finding exists (for example: nothing configured, or the
|
|
179
|
+
index was built with a different embedding model than the configuration).
|
|
180
|
+
.SH SEE ALSO
|
|
181
|
+
The repository README and EMBEDDINGS.md document setup, diagnostics, and the
|
|
182
|
+
honesty rules in full.
|
|
183
|
+
.PP
|
|
184
|
+
Full indexing reference, in the repository under
|
|
185
|
+
.BR docs/indexing/ :
|
|
186
|
+
.BR README.md " (flag semantics), " resume.md " (interrupting and resuming), "
|
|
187
|
+
.BR performance.md " (measured timings), " troubleshooting.md " (the worker
|
|
188
|
+
pool), and " embeddings.md " (embedding configuration).
|
|
189
|
+
.B bb\ index\ \-\-help
|
|
190
|
+
points at the same directory.
|