feat(context): add configurable memoryBoundaryMarkers setting (#24020)

This commit is contained in:
Sandy Tao
2026-03-27 14:51:32 -07:00
committed by GitHub
parent 765fb67011
commit 4034c030e7
13 changed files with 265 additions and 55 deletions
@@ -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,
);
});
});
});