mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-20 15:00:54 -07:00
Fix/pending tools and trust overrides (#27854)
This commit is contained in:
committed by
GitHub
parent
bca5667fc6
commit
0f8a157e5e
@@ -23,6 +23,7 @@ import {
|
||||
PRIORITY_YOLO_ALLOW_ALL,
|
||||
createPolicyEngineConfig,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { AgentSettings } from '../types.js';
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
@@ -612,3 +613,34 @@ describe('loadConfig', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('setIsTrusted', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it('should return true when GEMINI_FOLDER_TRUST env var is true', async () => {
|
||||
vi.stubEnv('GEMINI_FOLDER_TRUST', 'true');
|
||||
const { setIsTrusted } = await import('./config.js');
|
||||
expect(setIsTrusted(undefined)).toBe(true);
|
||||
expect(setIsTrusted({ isTrusted: false } as AgentSettings)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when GEMINI_FOLDER_TRUST env var is false', async () => {
|
||||
vi.stubEnv('GEMINI_FOLDER_TRUST', 'false');
|
||||
const { setIsTrusted } = await import('./config.js');
|
||||
expect(setIsTrusted(undefined)).toBe(false);
|
||||
expect(setIsTrusted({ isTrusted: true } as AgentSettings)).toBe(false);
|
||||
});
|
||||
|
||||
it('should fallback to agentSettings.isTrusted if env var is undefined', async () => {
|
||||
const { setIsTrusted } = await import('./config.js');
|
||||
expect(setIsTrusted({ isTrusted: true } as AgentSettings)).toBe(true);
|
||||
expect(setIsTrusted({ isTrusted: false } as AgentSettings)).toBe(false);
|
||||
expect(setIsTrusted(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,6 +34,8 @@ import { logger } from '../utils/logger.js';
|
||||
import type { Settings } from './settings.js';
|
||||
import { type AgentSettings, CoderAgentEvent } from '../types.js';
|
||||
|
||||
const INITIAL_FOLDER_TRUST = process.env['GEMINI_FOLDER_TRUST'];
|
||||
|
||||
export async function loadConfig(
|
||||
settings: Settings,
|
||||
extensionLoader: ExtensionLoader,
|
||||
@@ -182,6 +184,15 @@ export async function loadConfig(
|
||||
return config;
|
||||
}
|
||||
|
||||
export function setIsTrusted(
|
||||
agentSettings: AgentSettings | undefined,
|
||||
): boolean {
|
||||
if (INITIAL_FOLDER_TRUST !== undefined) {
|
||||
return INITIAL_FOLDER_TRUST === 'true';
|
||||
}
|
||||
return !!agentSettings?.isTrusted;
|
||||
}
|
||||
|
||||
export function setTargetDir(agentSettings: AgentSettings | undefined): string {
|
||||
const originalCWD = process.cwd();
|
||||
const targetDir =
|
||||
|
||||
Reference in New Issue
Block a user