mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 21:14:35 -07:00
feat(config): add setting to make directory tree context configurable (#19053)
This commit is contained in:
@@ -88,6 +88,7 @@ describe('getEnvironmentContext', () => {
|
||||
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
||||
}),
|
||||
getFileService: vi.fn(),
|
||||
getIncludeDirectoryTree: vi.fn().mockReturnValue(true),
|
||||
getEnvironmentMemory: vi.fn().mockReturnValue('Mock Environment Memory'),
|
||||
|
||||
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
||||
@@ -146,6 +147,24 @@ describe('getEnvironmentContext', () => {
|
||||
expect(getFolderStructure).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should omit directory structure when getIncludeDirectoryTree is false', async () => {
|
||||
(vi.mocked(mockConfig.getIncludeDirectoryTree!) as Mock).mockReturnValue(
|
||||
false,
|
||||
);
|
||||
|
||||
const parts = await getEnvironmentContext(mockConfig as Config);
|
||||
|
||||
expect(parts.length).toBe(1);
|
||||
const context = parts[0].text;
|
||||
|
||||
expect(context).toContain('<session_context>');
|
||||
expect(context).not.toContain('Directory Structure:');
|
||||
expect(context).not.toContain('Mock Folder Structure');
|
||||
expect(context).toContain('Mock Environment Memory');
|
||||
expect(context).toContain('</session_context>');
|
||||
expect(getFolderStructure).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should handle read_many_files returning no content', async () => {
|
||||
const mockReadManyFilesTool = {
|
||||
build: vi.fn().mockReturnValue({
|
||||
|
||||
@@ -53,7 +53,9 @@ export async function getEnvironmentContext(config: Config): Promise<Part[]> {
|
||||
day: 'numeric',
|
||||
});
|
||||
const platform = process.platform;
|
||||
const directoryContext = await getDirectoryContextString(config);
|
||||
const directoryContext = config.getIncludeDirectoryTree()
|
||||
? await getDirectoryContextString(config)
|
||||
: '';
|
||||
const tempDir = config.storage.getProjectTempDir();
|
||||
const environmentMemory = config.getEnvironmentMemory();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user