You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminal auto-approve: a partially-failed tree-sitter parse can still auto-approve #328108
Follow up to #328052 and #328107. Workbench runInTerminal path, live on main.
Problem
When tree-sitter cannot fully parse a command line it still produces a partial tree, and extractSubCommands happily returns the captures it found. Those partial captures can omit executable parts of the line, so the sub-commands that were captured can all match allow rules and the line auto-approves — while the parts the parser dropped still run.
ls matches the default allow rule, so the line auto-approves and ./x.sh executes without confirmation.
Both triggers are common in agent-emitted commands:
a bare -- separator (npm run test -- --grep x)
./path at command position (./scripts/test.sh)
Existing precedent
The Agent Host auto-approver already guards this — commandAutoApprover.ts returns undefined (→ requires confirmation) when tree.rootNode.hasError is set for a PowerShell parse, with the rationale that an erroring parse can produce truncated captures that hide part of the command line from rule matching.
The workbench has no equivalent gate: commandLineAutoApproveAnalyzer.ts only bails when !subCommands?.length, i.e. when the parse produced nothing. A partial parse proceeds normally.
Suggested fix
Treat an errored parse as unanalyzable and require confirmation, matching the Agent Host.
Activity