Correctly support comma-separated values for --allowed-tools (#8386)

Co-authored-by: anthony bushong <agmsb@users.noreply.github.com>
This commit is contained in:
Roy Binux
2025-09-19 14:50:59 -07:00
committed by GitHub
parent ab982b8e32
commit 532497b3d1
2 changed files with 14 additions and 0 deletions

View File

@@ -296,6 +296,17 @@ describe('parseArguments', () => {
mockExit.mockRestore();
mockConsoleError.mockRestore();
});
it('should support comma-separated values for --allowed-tools', async () => {
process.argv = [
'node',
'script.js',
'--allowed-tools',
'read_file,ShellTool(git status)',
];
const argv = await parseArguments({} as Settings);
expect(argv.allowedTools).toEqual(['read_file', 'ShellTool(git status)']);
});
});
describe('loadCliConfig', () => {

View File

@@ -233,6 +233,9 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
type: 'array',
string: true,
description: 'Tools that are allowed to run without confirmation',
coerce: (tools: string[]) =>
// Handle comma-separated values
tools.flatMap((tool) => tool.split(',').map((t) => t.trim())),
})
.option('extensions', {
alias: 'e',