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:
Tolik Malibroda
2025-06-02 22:05:45 +02:00
committed by GitHub
parent 42bedbc3d3
commit 0795e55f0e
15 changed files with 364 additions and 156 deletions

View File

@@ -15,6 +15,7 @@ import {
ConfigParameters,
setGeminiMdFilename as setServerGeminiMdFilename,
getCurrentGeminiMdFilename,
ApprovalMode,
} from '@gemini-code/core';
import { Settings } from './settings.js';
import { readPackageUp } from 'read-package-up';
@@ -38,6 +39,7 @@ interface CliArgs {
prompt: string | undefined;
all_files: boolean | undefined;
show_memory_usage: boolean | undefined;
yolo: boolean | undefined;
}
async function parseArguments(): Promise<CliArgs> {
@@ -75,6 +77,13 @@ async function parseArguments(): Promise<CliArgs> {
description: 'Show memory usage in status bar',
default: false,
})
.option('yolo', {
alias: 'y',
type: 'boolean',
description:
'Automatically accept all actions (aka YOLO mode, see https://www.youtube.com/watch?v=xvFZjo5PgG0 for more details)?',
default: false,
})
.version() // This will enable the --version flag based on package.json
.help()
.alias('h', 'help')
@@ -158,7 +167,7 @@ export async function loadCliConfig(settings: Settings): Promise<Config> {
const configParams: ConfigParameters = {
apiKey: apiKeyForServer,
model: argv.model || DEFAULT_GEMINI_MODEL,
sandbox: argv.sandbox ?? settings.sandbox ?? false,
sandbox: argv.sandbox ?? settings.sandbox ?? argv.yolo ?? false,
targetDir: process.cwd(),
debugMode,
question: argv.prompt || '',
@@ -171,6 +180,7 @@ export async function loadCliConfig(settings: Settings): Promise<Config> {
userAgent,
userMemory: memoryContent,
geminiMdFileCount: fileCount,
approvalMode: argv.yolo || false ? ApprovalMode.YOLO : ApprovalMode.DEFAULT,
vertexai: useVertexAI,
showMemoryUsage:
argv.show_memory_usage || settings.showMemoryUsage || false,