mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-30 07:51:07 -07:00
feat(core): Implement JIT context memory loading and UI sync (#14469)
This commit is contained in:
@@ -92,6 +92,7 @@ describe('getEnvironmentContext', () => {
|
||||
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
||||
}),
|
||||
getFileService: vi.fn(),
|
||||
getEnvironmentMemory: vi.fn().mockReturnValue('Mock Environment Memory'),
|
||||
|
||||
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
||||
storage: {
|
||||
@@ -122,6 +123,7 @@ describe('getEnvironmentContext', () => {
|
||||
expect(context).toContain(
|
||||
'Here is the folder structure of the current working directories:\n\nMock Folder Structure',
|
||||
);
|
||||
expect(context).toContain('Mock Environment Memory');
|
||||
expect(getFolderStructure).toHaveBeenCalledWith('/test/dir', {
|
||||
fileService: undefined,
|
||||
});
|
||||
|
||||
@@ -62,6 +62,7 @@ export async function getEnvironmentContext(config: Config): Promise<Part[]> {
|
||||
const platform = process.platform;
|
||||
const directoryContext = await getDirectoryContextString(config);
|
||||
const tempDir = config.storage.getProjectTempDir();
|
||||
const environmentMemory = config.getEnvironmentMemory();
|
||||
|
||||
const context = `
|
||||
This is the Gemini CLI. We are setting up the context for our chat.
|
||||
@@ -69,6 +70,8 @@ Today's date is ${today} (formatted according to the user's locale).
|
||||
My operating system is: ${platform}
|
||||
The project's temporary directory is: ${tempDir}
|
||||
${directoryContext}
|
||||
|
||||
${environmentMemory}
|
||||
`.trim();
|
||||
|
||||
const initialParts: Part[] = [{ text: context }];
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'node:events';
|
||||
import type { LoadServerHierarchicalMemoryResponse } from './memoryDiscovery.js';
|
||||
|
||||
/**
|
||||
* Defines the severity level for user-facing feedback.
|
||||
@@ -64,7 +63,9 @@ export interface OutputPayload {
|
||||
/**
|
||||
* Payload for the 'memory-changed' event.
|
||||
*/
|
||||
export type MemoryChangedPayload = LoadServerHierarchicalMemoryResponse;
|
||||
export interface MemoryChangedPayload {
|
||||
fileCount: number;
|
||||
}
|
||||
|
||||
export enum CoreEvent {
|
||||
UserFeedback = 'user-feedback',
|
||||
|
||||
@@ -932,7 +932,9 @@ included directory memory
|
||||
path.join(extensionPath, 'CustomContext.md'),
|
||||
);
|
||||
expect(config.getGeminiMdFilePaths()).equals(refreshResult.filePaths);
|
||||
expect(mockEventListener).toHaveBeenCalledExactlyOnceWith(refreshResult);
|
||||
expect(mockEventListener).toHaveBeenCalledExactlyOnceWith({
|
||||
fileCount: refreshResult.fileCount,
|
||||
});
|
||||
});
|
||||
|
||||
it('should include MCP instructions in user memory', async () => {
|
||||
|
||||
@@ -577,7 +577,7 @@ export async function refreshServerHierarchicalMemory(config: Config) {
|
||||
config.setUserMemory(finalMemory);
|
||||
config.setGeminiMdFileCount(result.fileCount);
|
||||
config.setGeminiMdFilePaths(result.filePaths);
|
||||
coreEvents.emit(CoreEvent.MemoryChanged, result);
|
||||
coreEvents.emit(CoreEvent.MemoryChanged, { fileCount: result.fileCount });
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user