Repository navigation
feat(core): make portable shell scanner authoritative - #42581
Merged
Merged
Conversation
kitlangton
force-pushed
the
shell-scanner-parity
branch
from
August 14, 2026 14:14
65922c8 to
3b82a3e
Compare
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.
What
Reintroduce the portable Bash and PowerShell permission scanner behind the disabled-by-default
experimental.portable_shell_scannerflag.When enabled, the portable scanner is authoritative: tree-sitter is neither loaded nor run. Supported syntax preserves the default scanner's ordered command resources, reusable save patterns, and inferred directories. Unsupported syntax requests normal shell authorization for the untouched command and infers no external directories.
Before / After
Before
The previous scanner replacement treated a static heredoc as opaque, converted that uncertainty into an unknown directory, and requested
external_directory: "*". A scoped external-directory deny then blocked the command even when shell access was allowed. The first guarded version of this PR avoided that regression by always running tree-sitter and using it as a runtime fallback.After
With the experiment enabled, OpenCode uses only the portable scanner. Opaque input is authorized as the original shell command and never invents an external-directory wildcard. With the experiment disabled, the existing tree-sitter path is unchanged.
How
packages/schemaand Core config normalization add the opt-in experimental flag.packages/core/src/shell/parse.tsbranches before tree-sitter initialization and adapts portable structural output into legacy-compatible ordered resources, source-shaped save patterns, and directories.packages/core/src/tool/plugin/shell.tsselects the portable path from effective config while preserving the default.packages/shell-scanscans static Bash and PowerShell command positions, marks unsupported syntax opaque, and preserves nested-command discovery order.packages/core/test/shell-parse-parity.test.tscompares 21,863 deterministic supported cases directly against tree-sitter.Scope
Testing
packages/core:bun run test(1,761 passed, 16 skipped),bun typecheck.packages/shell-scan:bun run test(274 passed),bun typecheck.git diff --checkpass.bun run lintandbun run lint:effect-patternsremain red on pre-existing unrelated diagnostics; targeted Oxlint reports 0 errors.Flow
flowchart TD A[Shell invocation] --> B{portable_shell_scanner?} B -- false --> C[Load and run tree-sitter] B -- true --> D[Run portable scanner] D --> E{Supported syntax?} E -- yes --> F[Authorize compatible command resources and directories] E -- no --> G[Authorize untouched shell command] G --> H[Infer no directories] C --> I[Apply ordered permission rules] F --> I H --> I