Skip to content

chat.tools.terminal.autoApprove does not work for npm exec -- ... commands #325635

Description

Description

chat.tools.terminal.autoApprove settings do not work for npm exec -- ... commands when the agent terminal uses PowerShell.

For this setting no combination of plain command prefix, regex, or object-style matchCommandLine syntax helps with following commands:

npm exec -- tsc --noEmit --pretty false
npm exec -- eslint src/some-file-name.ts

The prompt about pwsh is always shown. It worked for the simple "npx eslint": true though. I think it is a parsing issue with npm exec having double dashes. But strangely, matchCommandLine variant did not work either.

Steps to reproduce

  1. Add an auto-approval rule:
"chat.tools.terminal.autoApprove": {
  "npm exec -- tsc": {
    "approve": true,
    "matchCommandLine": true
  }
}
  1. Ask Copilot Agent to run:
npm exec -- tsc --noEmit --pretty false

Actual behavior

VS Code still displays the "Run pwsh command?" confirmation.

Terminal output:

RunInTerminalTool#CommandLineAutoApproveAnalyzer: Parsed sub-commands via powershell grammar [[]]
RunInTerminalTool#CommandLineAutoApproveAnalyzer: No sub-commands were parsed, auto approval is not allowed [null]
RunInTerminalTool#CommandLineFileWriteAnalyzer: File writes detected [[]]

Because no subcommands are parsed, the configured auto-approval rule is never evaluated.

Expected behavior

The PowerShell parser should recognize npm exec -- tsc ..., allowing it to match the configured prefix rule and run without confirmation.

The same configuration works with equivalent commands starting with npx, such as npx tsc.

Technical details

  • VS Code Version: 1.128.0 (user setup)
  • OS Version: Windows 11 Pro 25H2 x64 10.0.26200

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions