Repository navigation
Conversation
extractBashCommands and isReadShapedBashCommand split only on &&, ; and |, so every line after the first was read as arguments of the first command. Multi-line commands are now scanned once: quotes, comments and heredoc bodies are blanked and an unquoted newline separates commands. Single-line commands are parsed exactly as before. Closes getagentseal#1929
This branch has not been deployed
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
extractBashCommandsandisReadShapedBashCommandsplit only on&&,;and|. A newline also ends a shell command, sogit status\nnpm testgave["git"],cd /tmp\nnpm test\nlsgave[], andls\nrm -rf distwas judged read-only, which the read-edit-ratio and retry detectors then trusted (Bash-heavy workflows are misread: shell reads uncounted, retries overcounted #941). Closes Bash parsing ignores newlines, so later lines of a multi-line command are dropped #1929.maskForSplittingscans a multi-line command once: quoted text,#comments and heredoc bodies (<<,<<-, quoted or escaped delimiters, several heredocs on one line) are blanked, and an unquoted newline becomes;. A newline after an odd run of backslashes (also before\r\n) is a line continuation.<<<is not a heredoc. The mask keeps the input's length, as the separator slicing needs.stripQuotedStrings) unchanged, so its output is identical to main.FACTS_VERSIONgoes 3 to 4 and the digest intests/scan-facts-version.test.tsis recorded, withmaskForSplittingandHEREDOC_STARTadded to the pinned rules, becauseisReadShapedBashCommandfeeds stored scan facts. Stored Optimize facts are rebuilt once after the update.Behavior changes besides the bug case (multi-line commands only):
do,done,then,fi) and a line that is only)are counted as names, the same wayfor/doalready were on one line.#comments are skipped in multi-line commands, so a comment line no longer counts as a#command or makes a read-only call non-read. Single-line commands keep the old handling (for examplels # x; rm ystill gives["ls", "rm"]).Known limits, unchanged from main:
$((1<<2))on a line is still read as a heredoc start, and a backslash before a quote (\') is not treated as an escape, as instripQuotedStrings.Testing / Verification
npm testpassesnpm run buildsucceedsRun on Windows 11, Node 24, branch = main 40d5880 + this diff, 2026-11-11:
tests/bash-commands.test.tsfail withsrc/bash-utils.tsfrom main and pass with the fix.npx vitest run tests/bash-commands.test.ts tests/scan-facts-version.test.ts tests/classifier.test.ts tests/optimize.test.ts tests/guard: 258 passed (7 files).npx tsc --noEmit: exit 0.npm test -- --maxWorkers=2on this branch: 5681 passed, 14 failed, 34 skipped (5729). On main: 5675 passed, 15 failed, 34 skipped (5724). All 14 failures on the branch also fail on main (Windows path and process tests: launcher-homes, plugin-signing, plugin-tar-security, quota-providers, serve-stdio and others). The branch adds no new failure. I left thenpm test passesbox unticked because the suite is not green on Windows.npm run build: the tsup CLI step succeeds. The chainedbuild:dashstep (npm ci --silentin dash/) exits 1 on this Windows machine on main too; run on its own,npm ciandnpm run buildin dash/ succeed. Left unticked for CI to confirm.;and as parsing each line alone; 20000 generated multi-line scripts with comments, heredocs (with apostrophes in the body) and CRLF match the expected command list. 20000-character inputs finish in under 10 ms.AI disclosure: Validated with Claude Opus 5.5. The owner directs and reviews the work.