feat(memory): make directory search limit on memory discovery configurable with settings.json (#4460)

This commit is contained in:
Brandon Keiji
2025-07-23 14:48:35 -07:00
committed by GitHub
parent 9d3164621a
commit d7a304bcff
11 changed files with 104 additions and 83 deletions

View File

@@ -18,7 +18,6 @@ import {
} from '../core/contentGenerator.js';
import { GeminiClient } from '../core/client.js';
import { GitService } from '../services/gitService.js';
import { loadServerHierarchicalMemory } from '../utils/memoryDiscovery.js';
// Mock dependencies that might be called during Config construction or createServerConfig
vi.mock('../tools/tool-registry', () => {
@@ -313,39 +312,4 @@ describe('Server Config (config.ts)', () => {
expect(config.getTelemetryOtlpEndpoint()).toBe(DEFAULT_OTLP_ENDPOINT);
});
});
describe('refreshMemory', () => {
it('should update memory and file count on successful refresh', async () => {
const config = new Config(baseParams);
const mockMemoryData = {
memoryContent: 'new memory content',
fileCount: 5,
};
(loadServerHierarchicalMemory as Mock).mockResolvedValue(mockMemoryData);
const result = await config.refreshMemory();
expect(loadServerHierarchicalMemory).toHaveBeenCalledWith(
config.getWorkingDir(),
config.getDebugMode(),
config.getFileService(),
config.getExtensionContextFilePaths(),
config.getFileFilteringOptions(),
);
expect(config.getUserMemory()).toBe(mockMemoryData.memoryContent);
expect(config.getGeminiMdFileCount()).toBe(mockMemoryData.fileCount);
expect(result).toEqual(mockMemoryData);
});
it('should propagate errors from loadServerHierarchicalMemory', async () => {
const config = new Config(baseParams);
const testError = new Error('Failed to load memory');
(loadServerHierarchicalMemory as Mock).mockRejectedValue(testError);
await expect(config.refreshMemory()).rejects.toThrow(testError);
});
});
});