Skip to content

tree-sitter PowerShell grammar cannot parse ~8% of realistic agent commands, blocking auto-approve suggestions #328110

Open

Description

Follow up to #328052, #328108, #328109.

Problem

The tree-sitter-powershell grammar shipped in @vscode/tree-sitter-wasm fails to parse a meaningful fraction of the command lines agents actually emit. Since both the workbench and the Agent Host derive auto-approval from the parse, an unparsable command line means no auto-approval and no way for the user to fix it from the confirmation UI.

Measurement

36 plausible agent-emitted commands parsed with the PowerShell grammar; 3 produced hasError:

ERROR  npm run test -- --grep "foo"
ERROR  ./scripts/test.sh
ERROR  git diff -- src/

That is ~8%. Two distinct triggers, both very common:

  1. a bare -- separator (npm run test -- …, git diff -- <path>)
  2. ./path at command position (./scripts/test.sh, ./gradlew build)

A third known limitation is already worked around in both codebases: POSIX-style --flag=value arguments parse as assignment expressions and truncate the surrounding command (#294010), which both TreeSitterCommandParser and the Agent Host's CommandAutoApprover mask before parsing.

Impact

With the errored-parse gate in place (#328108, and already shipping in the Agent Host), these command lines resolve to noMatch with autoApproveRuleResolvable: false. The renderer only offers persistent auto-approve actions when autoApproveRuleResolvable is set (chatTerminalToolConfirmationSubPart.ts), so the user sees a confirmation with no auto-approve options at all, every time, forever.

Honouring explicit matchCommandLine rules before parsing (#328109) gives users an escape hatch but does not remove the underlying gap — the suggested sub-command rules still cannot be generated.

Possible directions

  1. Fix upstream in the tree-sitter PowerShell grammar (the -- and ./path cases) and pick up the updated wasm.
  2. Extend the existing masking workaround to cover a bare -- separator, in the same spirit as the --flag=value mask.
  3. Fall back to a coarser tokenizer for suggestion generation only (never for enforcement) so the confirmation can still offer a sensible sub-command rule.

Option 2 is the cheapest and matches an existing precedent; option 1 is the real fix.

Activity

  1. added
    bug
    terminal
    agent-host
    on Jul 29, 2026
  2. neverendingqs commented on Aug 31, 2026

    @neverendingqs

    Anthony Kim (@anthonykim1) - curious as to the status of this issue and when it's planned for. I hit this many times per day across all my sessions.

  3. iket0731 commented on Sep 24, 2026

    @iket0731

    This seems to affect quite a few users. The same root cause (standalone -- failing to parse in PowerShell) has been reported separately in #325635, #324059 and #321748.

    There's also an open community PR, #335465, that implements option 2 (masking a bare -- before parsing, similar to the existing --flag=value workaround). It is waiting for a review.

    Anthony Kim (@anthonykim1) Would this approach be acceptable as a short-term fix while the upstream grammar is addressed? It would help a lot of us who hit this many times a day. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent-hostbugterminal

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions