microsoft / microsoft/vscode

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

Open
#325,635 0 comments 1 reaction 1 assignee Claimed by @anthonykim1 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

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:

```jsonc
"chat.tools.terminal.autoApprove": {
"npm exec -- tsc": {
"approve": true,
"matchCommandLine": true
}
}
```

2. Ask Copilot Agent to run:

```powershell
npm exec -- tsc --noEmit --pretty false
```

### Actual behavior

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

Terminal output:

```text
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.