mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-15 06:12:50 -07:00
feat(context): add configurable memoryBoundaryMarkers setting (#24020)
This commit is contained in:
@@ -46,6 +46,7 @@ describe('ContextManager', () => {
|
||||
getMcpInstructions: vi.fn().mockReturnValue('MCP Instructions'),
|
||||
}),
|
||||
isTrustedFolder: vi.fn().mockReturnValue(true),
|
||||
getMemoryBoundaryMarkers: vi.fn().mockReturnValue(['.git']),
|
||||
} as unknown as Config;
|
||||
|
||||
contextManager = new ContextManager(mockConfig);
|
||||
@@ -81,12 +82,14 @@ describe('ContextManager', () => {
|
||||
await contextManager.refresh();
|
||||
|
||||
expect(memoryDiscovery.getGlobalMemoryPaths).toHaveBeenCalled();
|
||||
expect(memoryDiscovery.getEnvironmentMemoryPaths).toHaveBeenCalledWith([
|
||||
'/app',
|
||||
]);
|
||||
expect(memoryDiscovery.getEnvironmentMemoryPaths).toHaveBeenCalledWith(
|
||||
['/app'],
|
||||
['.git'],
|
||||
);
|
||||
expect(memoryDiscovery.readGeminiMdFiles).toHaveBeenCalledWith(
|
||||
expect.arrayContaining([...globalPaths, ...envPaths]),
|
||||
'tree',
|
||||
['.git'],
|
||||
);
|
||||
|
||||
expect(contextManager.getGlobalMemory()).toContain('Global Content');
|
||||
@@ -172,6 +175,7 @@ describe('ContextManager', () => {
|
||||
expect(memoryDiscovery.readGeminiMdFiles).toHaveBeenCalledWith(
|
||||
['/home/user/.gemini/GEMINI.md', '/app/gemini.md'],
|
||||
'tree',
|
||||
['.git'],
|
||||
);
|
||||
expect(contextManager.getEnvironmentMemory()).toContain(
|
||||
'Project Content',
|
||||
@@ -197,6 +201,7 @@ describe('ContextManager', () => {
|
||||
['/app'],
|
||||
expect.any(Set),
|
||||
expect.any(Set),
|
||||
['.git'],
|
||||
);
|
||||
expect(result).toMatch(/--- Context from: \/app\/src\/GEMINI\.md ---/);
|
||||
expect(result).toContain('Src Content');
|
||||
@@ -226,5 +231,25 @@ describe('ContextManager', () => {
|
||||
expect(memoryDiscovery.loadJitSubdirectoryMemory).not.toHaveBeenCalled();
|
||||
expect(result).toBe('');
|
||||
});
|
||||
|
||||
it('should pass custom boundary markers from config', async () => {
|
||||
const customMarkers = ['.monorepo-root', 'package.json'];
|
||||
vi.mocked(mockConfig.getMemoryBoundaryMarkers).mockReturnValue(
|
||||
customMarkers,
|
||||
);
|
||||
vi.mocked(memoryDiscovery.loadJitSubdirectoryMemory).mockResolvedValue({
|
||||
files: [],
|
||||
});
|
||||
|
||||
await contextManager.discoverContext('/app/src/file.ts', ['/app']);
|
||||
|
||||
expect(memoryDiscovery.loadJitSubdirectoryMemory).toHaveBeenCalledWith(
|
||||
'/app/src/file.ts',
|
||||
['/app'],
|
||||
expect.any(Set),
|
||||
expect.any(Set),
|
||||
customMarkers,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,9 +51,10 @@ export class ContextManager {
|
||||
getExtensionMemoryPaths(this.config.getExtensionLoader()),
|
||||
),
|
||||
this.config.isTrustedFolder()
|
||||
? getEnvironmentMemoryPaths([
|
||||
...this.config.getWorkspaceContext().getDirectories(),
|
||||
])
|
||||
? getEnvironmentMemoryPaths(
|
||||
[...this.config.getWorkspaceContext().getDirectories()],
|
||||
this.config.getMemoryBoundaryMarkers(),
|
||||
)
|
||||
: Promise.resolve([]),
|
||||
]);
|
||||
|
||||
@@ -76,6 +77,7 @@ export class ContextManager {
|
||||
const allContents = await readGeminiMdFiles(
|
||||
allPaths,
|
||||
this.config.getImportFormat(),
|
||||
this.config.getMemoryBoundaryMarkers(),
|
||||
);
|
||||
|
||||
const loadedFilePaths = allContents
|
||||
@@ -133,6 +135,7 @@ export class ContextManager {
|
||||
trustedRoots,
|
||||
this.loadedPaths,
|
||||
this.loadedFileIdentities,
|
||||
this.config.getMemoryBoundaryMarkers(),
|
||||
);
|
||||
|
||||
if (result.files.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user