mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-03 06:00:49 +00:00
fix core tool config
This commit is contained in:
parent
a525423672
commit
c01a309cda
19 changed files with 145 additions and 138 deletions
|
|
@ -983,7 +983,7 @@ describe('mergeExcludeTools', () => {
|
|||
process.argv = ['node', 'script.js'];
|
||||
const argv = await parseArguments();
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
expect(config.getExcludeTools()).toEqual([]);
|
||||
expect(config.getPermissionsDeny()).toEqual([]);
|
||||
});
|
||||
|
||||
it('should return default excludes when no excludeTools are specified and it is not interactive', async () => {
|
||||
|
|
@ -992,7 +992,7 @@ describe('mergeExcludeTools', () => {
|
|||
process.argv = ['node', 'script.js', '-p', 'test'];
|
||||
const argv = await parseArguments();
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
expect(config.getExcludeTools()).toEqual(defaultExcludes);
|
||||
expect(config.getPermissionsDeny()).toEqual(defaultExcludes);
|
||||
});
|
||||
|
||||
it('should handle settings with excludeTools but no extensions', async () => {
|
||||
|
|
@ -1000,10 +1000,10 @@ describe('mergeExcludeTools', () => {
|
|||
const argv = await parseArguments();
|
||||
const settings: Settings = { tools: { exclude: ['tool1', 'tool2'] } };
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
expect(config.getPermissionsDeny()).toEqual(
|
||||
expect.arrayContaining(['tool1', 'tool2']),
|
||||
);
|
||||
expect(config.getExcludeTools()).toHaveLength(2);
|
||||
expect(config.getPermissionsDeny()).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1028,7 +1028,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
const settings: Settings = {};
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).toContain(ShellTool.Name);
|
||||
expect(excludedTools).toContain(EditTool.Name);
|
||||
expect(excludedTools).toContain(WriteFileTool.Name);
|
||||
|
|
@ -1047,7 +1047,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
const settings: Settings = {};
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).toContain(ShellTool.Name);
|
||||
expect(excludedTools).toContain(EditTool.Name);
|
||||
expect(excludedTools).toContain(WriteFileTool.Name);
|
||||
|
|
@ -1067,7 +1067,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).toContain(ShellTool.Name);
|
||||
expect(excludedTools).toContain(EditTool.Name);
|
||||
expect(excludedTools).toContain(WriteFileTool.Name);
|
||||
|
|
@ -1084,7 +1084,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).not.toContain(ShellTool.Name);
|
||||
expect(excludedTools).toContain(EditTool.Name);
|
||||
expect(excludedTools).toContain(WriteFileTool.Name);
|
||||
|
|
@ -1101,7 +1101,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).not.toContain(ShellTool.Name);
|
||||
expect(excludedTools).toContain(EditTool.Name);
|
||||
expect(excludedTools).toContain(WriteFileTool.Name);
|
||||
|
|
@ -1121,7 +1121,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).toContain(ShellTool.Name);
|
||||
expect(excludedTools).not.toContain(EditTool.Name);
|
||||
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
||||
|
|
@ -1141,7 +1141,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).not.toContain(ShellTool.Name);
|
||||
expect(excludedTools).not.toContain(EditTool.Name);
|
||||
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
||||
|
|
@ -1154,7 +1154,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).not.toContain(ShellTool.Name);
|
||||
expect(excludedTools).not.toContain(EditTool.Name);
|
||||
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
||||
|
|
@ -1179,7 +1179,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).not.toContain(ShellTool.Name);
|
||||
expect(excludedTools).not.toContain(EditTool.Name);
|
||||
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
||||
|
|
@ -1199,7 +1199,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|||
const settings: Settings = { tools: { exclude: ['custom_tool'] } };
|
||||
const config = await loadCliConfig(settings, argv, undefined, []);
|
||||
|
||||
const excludedTools = config.getExcludeTools();
|
||||
const excludedTools = config.getPermissionsDeny();
|
||||
expect(excludedTools).toContain('custom_tool'); // From settings
|
||||
expect(excludedTools).toContain(ShellTool.Name); // From approval mode
|
||||
expect(excludedTools).not.toContain(EditTool.Name); // Should be allowed in auto-edit
|
||||
|
|
@ -1795,9 +1795,9 @@ describe('loadCliConfig tool exclusions', () => {
|
|||
process.argv = ['node', 'script.js'];
|
||||
const argv = await parseArguments();
|
||||
const config = await loadCliConfig({}, argv, undefined, []);
|
||||
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
||||
expect(config.getExcludeTools()).not.toContain('replace');
|
||||
expect(config.getExcludeTools()).not.toContain('write_file');
|
||||
expect(config.getPermissionsDeny()).not.toContain('run_shell_command');
|
||||
expect(config.getPermissionsDeny()).not.toContain('replace');
|
||||
expect(config.getPermissionsDeny()).not.toContain('write_file');
|
||||
});
|
||||
|
||||
it('should not exclude interactive tools in interactive mode with YOLO', async () => {
|
||||
|
|
@ -1805,9 +1805,9 @@ describe('loadCliConfig tool exclusions', () => {
|
|||
process.argv = ['node', 'script.js', '--yolo'];
|
||||
const argv = await parseArguments();
|
||||
const config = await loadCliConfig({}, argv, undefined, []);
|
||||
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
||||
expect(config.getExcludeTools()).not.toContain('replace');
|
||||
expect(config.getExcludeTools()).not.toContain('write_file');
|
||||
expect(config.getPermissionsDeny()).not.toContain('run_shell_command');
|
||||
expect(config.getPermissionsDeny()).not.toContain('replace');
|
||||
expect(config.getPermissionsDeny()).not.toContain('write_file');
|
||||
});
|
||||
|
||||
it('should exclude interactive tools in non-interactive mode without YOLO', async () => {
|
||||
|
|
@ -1815,9 +1815,9 @@ describe('loadCliConfig tool exclusions', () => {
|
|||
process.argv = ['node', 'script.js', '-p', 'test'];
|
||||
const argv = await parseArguments();
|
||||
const config = await loadCliConfig({}, argv, undefined, []);
|
||||
expect(config.getExcludeTools()).toContain('run_shell_command');
|
||||
expect(config.getExcludeTools()).toContain('edit');
|
||||
expect(config.getExcludeTools()).toContain('write_file');
|
||||
expect(config.getPermissionsDeny()).toContain('run_shell_command');
|
||||
expect(config.getPermissionsDeny()).toContain('edit');
|
||||
expect(config.getPermissionsDeny()).toContain('write_file');
|
||||
});
|
||||
|
||||
it('should not exclude interactive tools in non-interactive mode with YOLO', async () => {
|
||||
|
|
@ -1825,9 +1825,9 @@ describe('loadCliConfig tool exclusions', () => {
|
|||
process.argv = ['node', 'script.js', '-p', 'test', '--yolo'];
|
||||
const argv = await parseArguments();
|
||||
const config = await loadCliConfig({}, argv, undefined, []);
|
||||
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
||||
expect(config.getExcludeTools()).not.toContain('replace');
|
||||
expect(config.getExcludeTools()).not.toContain('write_file');
|
||||
expect(config.getPermissionsDeny()).not.toContain('run_shell_command');
|
||||
expect(config.getPermissionsDeny()).not.toContain('replace');
|
||||
expect(config.getPermissionsDeny()).not.toContain('write_file');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue