-
Notifications
You must be signed in to change notification settings - Fork 37.3k
Auto approve npm scripts from workspace package.json by default #285521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces automatic approval for npm, yarn, and pnpm script commands when the script is defined in the workspace's package.json file. The feature aims to streamline the developer experience by auto-approving safe script executions that are already trusted as part of the workspace.
Key changes:
- Adds a new
CommandLineNpmScriptAutoApproveAnalyzerthat checks if npm/yarn/pnpm run commands reference scripts defined in package.json - Introduces a new setting
chat.tools.terminal.autoApproveWorkspaceNpmScripts(enabled by default for trusted workspaces) - Comprehensive test coverage for various package manager commands and edge cases
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| commandLineNpmScriptAutoApproveAnalyzer.ts | New analyzer implementation that parses npm/yarn/pnpm commands, reads package.json, and auto-approves commands when scripts exist |
| terminalChatAgentToolsConfiguration.ts | Adds new configuration setting for controlling npm script auto-approval with workspace trust restrictions |
| runInTerminalTool.ts | Registers the new npm script analyzer alongside existing command line analyzers |
| commandLineNpmScriptAutoApproveAnalyzer.test.ts | Comprehensive test suite covering npm, yarn, pnpm commands, shorthands, built-in commands, and edge cases |
.../chatAgentTools/browser/tools/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.ts
Outdated
Show resolved
Hide resolved
.../chatAgentTools/browser/tools/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.ts
Outdated
Show resolved
Hide resolved
...ls/test/electron-browser/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.test.ts
Outdated
Show resolved
Hide resolved
.../chatAgentTools/browser/tools/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.ts
Outdated
Show resolved
Hide resolved
.../chatAgentTools/browser/tools/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.ts
Outdated
Show resolved
Hide resolved
...rkbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts
Outdated
Show resolved
Hide resolved
...ls/test/electron-browser/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.test.ts
Outdated
Show resolved
Hide resolved
.../chatAgentTools/browser/tools/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.ts
Outdated
Show resolved
Hide resolved
...ls/test/electron-browser/commandLineAnalyzer/commandLineNpmScriptAutoApproveAnalyzer.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Fixes #285509