mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat: Add --yolo mode that automatically accepts all tools executions (#695)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import { FileDiff } from './tools.js';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import { Config } from '../config/config.js';
|
||||
import { ApprovalMode, Config } from '../config/config.js';
|
||||
import { Content, Part, SchemaUnion } from '@google/genai';
|
||||
|
||||
describe('EditTool', () => {
|
||||
@@ -41,8 +41,8 @@ describe('EditTool', () => {
|
||||
|
||||
mockConfig = {
|
||||
getTargetDir: () => rootDir,
|
||||
getAlwaysSkipModificationConfirmation: vi.fn(() => false),
|
||||
setAlwaysSkipModificationConfirmation: vi.fn(),
|
||||
getApprovalMode: vi.fn(() => false),
|
||||
setApprovalMode: vi.fn(),
|
||||
// getGeminiConfig: () => ({ apiKey: 'test-api-key' }), // This was not a real Config method
|
||||
// Add other properties/methods of Config if EditTool uses them
|
||||
// Minimal other methods to satisfy Config type if needed by EditTool constructor or other direct uses:
|
||||
@@ -65,12 +65,10 @@ describe('EditTool', () => {
|
||||
} as unknown as Config;
|
||||
|
||||
// Reset mocks before each test
|
||||
(mockConfig.getAlwaysSkipModificationConfirmation as Mock).mockClear();
|
||||
(mockConfig.setAlwaysSkipModificationConfirmation as Mock).mockClear();
|
||||
(mockConfig.getApprovalMode as Mock).mockClear();
|
||||
(mockConfig.getApprovalMode as Mock).mockClear();
|
||||
// Default to not skipping confirmation
|
||||
(mockConfig.getAlwaysSkipModificationConfirmation as Mock).mockReturnValue(
|
||||
false,
|
||||
);
|
||||
(mockConfig.getApprovalMode as Mock).mockReturnValue(ApprovalMode.DEFAULT);
|
||||
|
||||
// Reset mocks and set default implementation for ensureCorrectEdit
|
||||
mockEnsureCorrectEdit.mockReset();
|
||||
@@ -439,9 +437,9 @@ describe('EditTool', () => {
|
||||
new_string: fileContent,
|
||||
};
|
||||
|
||||
(
|
||||
mockConfig.getAlwaysSkipModificationConfirmation as Mock
|
||||
).mockReturnValueOnce(true);
|
||||
(mockConfig.getApprovalMode as Mock).mockReturnValueOnce(
|
||||
ApprovalMode.AUTO_EDIT,
|
||||
);
|
||||
const result = await tool.execute(params, new AbortController().signal);
|
||||
|
||||
expect(result.llmContent).toMatch(/Created new file/);
|
||||
|
||||
Reference in New Issue
Block a user