diff options
| author | Olcan <[email protected]> | 2025-05-02 08:15:46 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-02 08:15:46 -0700 |
| commit | a7679db6e99f971306bc4b27c603e93bc67ac254 (patch) | |
| tree | b123af46cbcc119434ddc0cc3d6f5b10d5637601 /packages/cli/src/config | |
| parent | 53ac7952c7ac11770037fecccda5f0f2fffa3e0b (diff) | |
sandbox setting and argument (#243)
Diffstat (limited to 'packages/cli/src/config')
| -rw-r--r-- | packages/cli/src/config/config.ts | 11 | ||||
| -rw-r--r-- | packages/cli/src/config/settings.ts | 18 |
2 files changed, 19 insertions, 10 deletions
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index b146048c..d680baaa 100644 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -12,12 +12,14 @@ import { loadEnvironment, createServerConfig, } from '@gemini-code/server'; +import { Settings } from './settings.js'; const DEFAULT_GEMINI_MODEL = 'gemini-2.5-flash-preview-04-17'; // Keep CLI-specific argument parsing interface CliArgs { model: string | undefined; + sandbox: boolean | string | undefined; debug_mode: boolean | undefined; question: string | undefined; full_context: boolean | undefined; @@ -31,6 +33,12 @@ async function parseArguments(): Promise<CliArgs> { description: `The Gemini model to use. Defaults to ${DEFAULT_GEMINI_MODEL}.`, default: process.env.GEMINI_CODE_MODEL || DEFAULT_GEMINI_MODEL, }) + .option('sandbox', { + alias: 's', + type: 'boolean', + description: 'Whether to run in sandbox mode. Defaults to false.', + default: false, + }) .option('debug_mode', { alias: 'z', type: 'boolean', @@ -57,7 +65,7 @@ async function parseArguments(): Promise<CliArgs> { } // Renamed function for clarity -export async function loadCliConfig(): Promise<Config> { +export async function loadCliConfig(settings: Settings): Promise<Config> { // Load .env file using logic from server package loadEnvironment(); @@ -77,6 +85,7 @@ export async function loadCliConfig(): Promise<Config> { return createServerConfig( process.env.GEMINI_API_KEY, argv.model || DEFAULT_GEMINI_MODEL, + argv.sandbox ?? settings.sandbox ?? false, process.cwd(), argv.debug_mode || false, argv.question || '', diff --git a/packages/cli/src/config/settings.ts b/packages/cli/src/config/settings.ts index 89bfce7a..d3fbd200 100644 --- a/packages/cli/src/config/settings.ts +++ b/packages/cli/src/config/settings.ts @@ -7,7 +7,6 @@ import * as fs from 'fs'; import * as path from 'path'; import { homedir } from 'os'; -import { Config } from '@gemini-code/server'; export const SETTINGS_DIRECTORY_NAME = '.gemini'; export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME); @@ -20,6 +19,7 @@ export enum SettingScope { export interface Settings { theme?: string; + sandbox?: boolean | string; // Add other settings here. } @@ -31,16 +31,16 @@ export class LoadedSettings { constructor(user: SettingsFile, workspace: SettingsFile) { this.user = user; this.workspace = workspace; - this.merged = this.computeMergedSettings(); + this._merged = this.computeMergedSettings(); } readonly user: SettingsFile; readonly workspace: SettingsFile; - private merged: Settings; + private _merged: Settings; - getMerged(): Settings { - return this.merged; + get merged(): Settings { + return this._merged; } private computeMergedSettings(): Settings { @@ -68,16 +68,16 @@ export class LoadedSettings { ): void { const settingsFile = this.forScope(scope); settingsFile.settings[key] = value; - this.merged = this.computeMergedSettings(); + this._merged = this.computeMergedSettings(); saveSettings(settingsFile); } } /** - * Loads settings from user and project configuration files. + * Loads settings from user and workspace directories. * Project settings override user settings. */ -export function loadSettings(config: Config): LoadedSettings { +export function loadSettings(workspaceDir: string): LoadedSettings { let userSettings: Settings = {}; let workspaceSettings = {}; @@ -92,7 +92,7 @@ export function loadSettings(config: Config): LoadedSettings { } const workspaceSettingsPath = path.join( - config.getTargetDir(), + workspaceDir, SETTINGS_DIRECTORY_NAME, 'settings.json', ); |
