mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 13:34:15 -07:00
refactor: Remove deprecated --all-files flag (#11228)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -159,7 +159,6 @@ describe('Server Config (config.ts)', () => {
|
||||
const TARGET_DIR = '/path/to/target';
|
||||
const DEBUG_MODE = false;
|
||||
const QUESTION = 'test question';
|
||||
const FULL_CONTEXT = false;
|
||||
const USER_MEMORY = 'Test User Memory';
|
||||
const TELEMETRY_SETTINGS = { enabled: false };
|
||||
const EMBEDDING_MODEL = 'gemini-embedding';
|
||||
@@ -171,7 +170,6 @@ describe('Server Config (config.ts)', () => {
|
||||
targetDir: TARGET_DIR,
|
||||
debugMode: DEBUG_MODE,
|
||||
question: QUESTION,
|
||||
fullContext: FULL_CONTEXT,
|
||||
userMemory: USER_MEMORY,
|
||||
telemetry: TELEMETRY_SETTINGS,
|
||||
sessionId: SESSION_ID,
|
||||
@@ -1006,7 +1004,6 @@ describe('BaseLlmClient Lifecycle', () => {
|
||||
const TARGET_DIR = '/path/to/target';
|
||||
const DEBUG_MODE = false;
|
||||
const QUESTION = 'test question';
|
||||
const FULL_CONTEXT = false;
|
||||
const USER_MEMORY = 'Test User Memory';
|
||||
const TELEMETRY_SETTINGS = { enabled: false };
|
||||
const EMBEDDING_MODEL = 'gemini-embedding';
|
||||
@@ -1018,7 +1015,6 @@ describe('BaseLlmClient Lifecycle', () => {
|
||||
targetDir: TARGET_DIR,
|
||||
debugMode: DEBUG_MODE,
|
||||
question: QUESTION,
|
||||
fullContext: FULL_CONTEXT,
|
||||
userMemory: USER_MEMORY,
|
||||
telemetry: TELEMETRY_SETTINGS,
|
||||
sessionId: SESSION_ID,
|
||||
|
||||
@@ -218,7 +218,7 @@ export interface ConfigParameters {
|
||||
targetDir: string;
|
||||
debugMode: boolean;
|
||||
question?: string;
|
||||
fullContext?: boolean;
|
||||
|
||||
coreTools?: string[];
|
||||
allowedTools?: string[];
|
||||
excludeTools?: string[];
|
||||
@@ -298,7 +298,7 @@ export class Config {
|
||||
private workspaceContext: WorkspaceContext;
|
||||
private readonly debugMode: boolean;
|
||||
private readonly question: string | undefined;
|
||||
private readonly fullContext: boolean;
|
||||
|
||||
private readonly coreTools: string[] | undefined;
|
||||
private readonly allowedTools: string[] | undefined;
|
||||
private readonly excludeTools: string[] | undefined;
|
||||
@@ -391,7 +391,7 @@ export class Config {
|
||||
);
|
||||
this.debugMode = params.debugMode;
|
||||
this.question = params.question;
|
||||
this.fullContext = params.fullContext ?? false;
|
||||
|
||||
this.coreTools = params.coreTools;
|
||||
this.allowedTools = params.allowedTools;
|
||||
this.excludeTools = params.excludeTools;
|
||||
@@ -692,10 +692,6 @@ export class Config {
|
||||
return this.question;
|
||||
}
|
||||
|
||||
getFullContext(): boolean {
|
||||
return this.fullContext;
|
||||
}
|
||||
|
||||
getCoreTools(): string[] | undefined {
|
||||
return this.coreTools;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ describe('Gemini Client (client.ts)', () => {
|
||||
getVertexAI: vi.fn().mockReturnValue(false),
|
||||
getUserAgent: vi.fn().mockReturnValue('test-agent'),
|
||||
getUserMemory: vi.fn().mockReturnValue(''),
|
||||
getFullContext: vi.fn().mockReturnValue(false),
|
||||
|
||||
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
||||
getProxy: vi.fn().mockReturnValue(undefined),
|
||||
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
||||
|
||||
@@ -592,7 +592,7 @@ describe('loggers', () => {
|
||||
}),
|
||||
getQuestion: () => 'test-question',
|
||||
getToolRegistry: () => new ToolRegistry(cfg1),
|
||||
getFullContext: () => false,
|
||||
|
||||
getUserMemory: () => 'user-memory',
|
||||
} as unknown as Config;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ describe('EditTool', () => {
|
||||
getSandbox: () => false,
|
||||
getDebugMode: () => false,
|
||||
getQuestion: () => undefined,
|
||||
getFullContext: () => false,
|
||||
|
||||
getToolDiscoveryCommand: () => undefined,
|
||||
getToolCallCommand: () => undefined,
|
||||
getMcpServerCommand: () => undefined,
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('SmartEditTool', () => {
|
||||
getSandbox: () => false,
|
||||
getDebugMode: () => false,
|
||||
getQuestion: () => undefined,
|
||||
getFullContext: () => false,
|
||||
|
||||
getToolDiscoveryCommand: () => undefined,
|
||||
getToolCallCommand: () => undefined,
|
||||
getMcpServerCommand: () => undefined,
|
||||
|
||||
@@ -81,7 +81,7 @@ const mockConfigInternal = {
|
||||
getSandbox: () => false,
|
||||
getDebugMode: () => false,
|
||||
getQuestion: () => undefined,
|
||||
getFullContext: () => false,
|
||||
|
||||
getToolDiscoveryCommand: () => undefined,
|
||||
getToolCallCommand: () => undefined,
|
||||
getMcpServerCommand: () => undefined,
|
||||
|
||||
@@ -168,7 +168,7 @@ describe('editCorrector', () => {
|
||||
targetDir: '/test',
|
||||
debugMode: false,
|
||||
question: undefined as string | undefined,
|
||||
fullContext: false,
|
||||
|
||||
coreTools: undefined as string[] | undefined,
|
||||
toolDiscoveryCommand: undefined as string | undefined,
|
||||
toolCallCommand: undefined as string | undefined,
|
||||
@@ -188,7 +188,7 @@ describe('editCorrector', () => {
|
||||
getToolRegistry: vi.fn(() => mockToolRegistry),
|
||||
getDebugMode: vi.fn(() => configParams.debugMode),
|
||||
getQuestion: vi.fn(() => configParams.question),
|
||||
getFullContext: vi.fn(() => configParams.fullContext),
|
||||
|
||||
getCoreTools: vi.fn(() => configParams.coreTools),
|
||||
getToolDiscoveryCommand: vi.fn(() => configParams.toolDiscoveryCommand),
|
||||
getToolCallCommand: vi.fn(() => configParams.toolCallCommand),
|
||||
|
||||
@@ -88,7 +88,7 @@ describe('getEnvironmentContext', () => {
|
||||
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
||||
}),
|
||||
getFileService: vi.fn(),
|
||||
getFullContext: vi.fn().mockReturnValue(false),
|
||||
|
||||
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
||||
};
|
||||
|
||||
@@ -142,32 +142,7 @@ describe('getEnvironmentContext', () => {
|
||||
expect(getFolderStructure).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should include full file context when getFullContext is true', async () => {
|
||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
||||
const mockReadManyFilesTool = {
|
||||
build: vi.fn().mockReturnValue({
|
||||
execute: vi
|
||||
.fn()
|
||||
.mockResolvedValue({ llmContent: 'Full file content here' }),
|
||||
}),
|
||||
};
|
||||
mockToolRegistry.getTool.mockReturnValue(mockReadManyFilesTool);
|
||||
|
||||
const parts = await getEnvironmentContext(mockConfig as Config);
|
||||
|
||||
expect(parts.length).toBe(2);
|
||||
expect(parts[1].text).toBe(
|
||||
'\n--- Full File Context ---\nFull file content here',
|
||||
);
|
||||
expect(mockToolRegistry.getTool).toHaveBeenCalledWith('read_many_files');
|
||||
expect(mockReadManyFilesTool.build).toHaveBeenCalledWith({
|
||||
paths: ['**/*'],
|
||||
useDefaultExcludes: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle read_many_files returning no content', async () => {
|
||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
||||
const mockReadManyFilesTool = {
|
||||
build: vi.fn().mockReturnValue({
|
||||
execute: vi.fn().mockResolvedValue({ llmContent: '' }),
|
||||
@@ -181,26 +156,10 @@ describe('getEnvironmentContext', () => {
|
||||
});
|
||||
|
||||
it('should handle read_many_files tool not being found', async () => {
|
||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
||||
mockToolRegistry.getTool.mockReturnValue(null);
|
||||
|
||||
const parts = await getEnvironmentContext(mockConfig as Config);
|
||||
|
||||
expect(parts.length).toBe(1); // No extra part added
|
||||
});
|
||||
|
||||
it('should handle errors when reading full file context', async () => {
|
||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
||||
const mockReadManyFilesTool = {
|
||||
build: vi.fn().mockReturnValue({
|
||||
execute: vi.fn().mockRejectedValue(new Error('Read error')),
|
||||
}),
|
||||
};
|
||||
mockToolRegistry.getTool.mockReturnValue(mockReadManyFilesTool);
|
||||
|
||||
const parts = await getEnvironmentContext(mockConfig as Config);
|
||||
|
||||
expect(parts.length).toBe(2);
|
||||
expect(parts[1].text).toBe('\n--- Error reading full file context ---');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -68,42 +68,6 @@ ${directoryContext}
|
||||
`.trim();
|
||||
|
||||
const initialParts: Part[] = [{ text: context }];
|
||||
const toolRegistry = config.getToolRegistry();
|
||||
|
||||
// Add full file context if the flag is set
|
||||
if (config.getFullContext()) {
|
||||
try {
|
||||
const readManyFilesTool = toolRegistry.getTool('read_many_files');
|
||||
if (readManyFilesTool) {
|
||||
const invocation = readManyFilesTool.build({
|
||||
paths: ['**/*'], // Read everything recursively
|
||||
useDefaultExcludes: true, // Use default excludes
|
||||
});
|
||||
|
||||
// Read all files in the target directory
|
||||
const result = await invocation.execute(AbortSignal.timeout(30000));
|
||||
if (result.llmContent) {
|
||||
initialParts.push({
|
||||
text: `\n--- Full File Context ---\n${result.llmContent}`,
|
||||
});
|
||||
} else {
|
||||
console.warn(
|
||||
'Full context requested, but read_many_files returned no content.',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
'Full context requested, but read_many_files tool not found.',
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
// Not using reportError here as it's a startup/config phase, not a chat/generation phase error.
|
||||
console.error('Error reading full file context:', error);
|
||||
initialParts.push({
|
||||
text: '\n--- Error reading full file context ---',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return initialParts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user