mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
feat(memory): make directory search limit on memory discovery configurable with settings.json (#4460)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,7 +30,6 @@ import { WebSearchTool } from '../tools/web-search.js';
|
||||
import { GeminiClient } from '../core/client.js';
|
||||
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||
import { GitService } from '../services/gitService.js';
|
||||
import { loadServerHierarchicalMemory } from '../utils/memoryDiscovery.js';
|
||||
import { getProjectTempDir } from '../utils/paths.js';
|
||||
import {
|
||||
initializeTelemetry,
|
||||
@@ -577,21 +576,6 @@ export class Config {
|
||||
return this.gitService;
|
||||
}
|
||||
|
||||
async refreshMemory(): Promise<{ memoryContent: string; fileCount: number }> {
|
||||
const { memoryContent, fileCount } = await loadServerHierarchicalMemory(
|
||||
this.getWorkingDir(),
|
||||
this.getDebugMode(),
|
||||
this.getFileService(),
|
||||
this.getExtensionContextFilePaths(),
|
||||
this.getFileFilteringOptions(),
|
||||
);
|
||||
|
||||
this.setUserMemory(memoryContent);
|
||||
this.setGeminiMdFileCount(fileCount);
|
||||
|
||||
return { memoryContent, fileCount };
|
||||
}
|
||||
|
||||
async createToolRegistry(): Promise<ToolRegistry> {
|
||||
const registry = new ToolRegistry(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user