fix(bash): handle real-world scripts safely#1
Draft
Adam0120 wants to merge 2 commits into
Draft
Conversation
1745053 to
c8a48a2
Compare
Omar-Elwazeery
pushed a commit
that referenced
this pull request
Jul 11, 2026
…tier when they collide with real callables (colbymchenry#1252) handleExplore's named-symbol seeding treats every identifier-shaped query token as "a symbol the agent named" and grants its definition the named-FIRST sort tier. Natural-language questions broke this assumption: ordinary words exact-matched unrelated callables ("check" -> WalCheckpointValve.check, "serve" -> query-worker serve, "initialize" -> DatabaseConnection.initialize), and those collisions outranked — and within the per-repo file budget fully displaced — the corroborated answer files, forcing the agent back to Read/Grep. The >3-def single-pick fallback had the same hole: on grpc, the colbymchenry#1064 flagship query "add a parameter to NewClient" itself tiered balancerStateAggregator.add's file to slot #1. Guard: a shape-precise token (camelCase, PascalCase, snake_case, qualified) seeds unconditionally — it is an unambiguous symbol reference. A bare lowercase word seeds only defs whose file another query token co-names (that token is itself an exact symbol name defined in the same file — the "check drain fire" sibling-bag shape), which an incidental English-word collision never is. Applied by filtering cands ahead of both branches so the overloaded-name fallback is covered too. Validated per the retrieval playbook: deterministic probes on this repo (collision queries fixed; sibling-bag and single-camelCase retained), and baseline-vs-fixed probes on the colbymchenry#1064 repos — Alamofire and excalidraw byte-identical, grpc improved (the add-collision file drops out and clientconn.go + dialoptions.go lead). Full suite green. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a focused follow-up for colbymchenry#1217. It keeps that PR's Bash extractor and adds the fixes needed for real deployment-script repositories:
tree-sitter-bash0.25.1 WASM and ship its MIT notice;S6_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)without guessing arbitrary dynamic paths;.sh,.bash, or.batssuffixes;Reproduction and root cause
On a 101-script deployment repository, the grammar currently obtained from
tree-sitter-wasmsindexed only 1 script successfully and reported 100 parse errors. A minimalcase "$1" in ... esacreproducesresolved is not a functionunderweb-tree-sitter0.25. The bundled grammar is fromtree-sitter-bash0.20.5 (ABI 13); the official 0.25.1 npm artifact is ABI 15 and parses the same corpus cleanly.The original resolver also tried Bash filename suffixes before the requested path. Shells do not perform that extension search, so
source ./helperscould be connected tohelpers.batseven when the exact extensionless file existed—or when no runtime-resolvable file existed at all.Real scripts commonly source files through a canonical variable holding the current script directory. This patch folds only an exact, root-level deterministic idiom, processes assignments in AST order, and invalidates the value on every later write. Function-body, here-doc, branch, arbitrary-variable, and reassignment cases stay unresolved by design.
Validation
npm run build.shfiles recognized as Bash; 3,840 nodes; 6,836 edges; 234 cross-file import edgess6_wire_local.sh -> atomic-write.shand_ensure_connect_wrapper -> dirextalk_atomic_write8292919c88a0f7d3fb31d0cd0253ca5a9531bc1ede82b0537f2c63dd8abe6a7a(byte-identical to the official npm artifact)Behavior boundary
This does not attempt general shell evaluation, environment expansion, command substitution, or fuzzy path inference. Dynamic cases remain unresolved so the graph prefers missing edges over incorrect ones.