mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 08:24:10 -07:00
feat(core): Render memory hierarchically in context. (#18350)
This commit is contained in:
@@ -121,7 +121,7 @@ describe('memory commands', () => {
|
||||
describe('refreshMemory', () => {
|
||||
it('should refresh memory and show success message', async () => {
|
||||
mockRefresh.mockResolvedValue({
|
||||
memoryContent: 'refreshed content',
|
||||
memoryContent: { project: 'refreshed content' },
|
||||
fileCount: 2,
|
||||
filePaths: [],
|
||||
});
|
||||
@@ -136,14 +136,14 @@ describe('memory commands', () => {
|
||||
if (result.type === 'message') {
|
||||
expect(result.messageType).toBe('info');
|
||||
expect(result.content).toBe(
|
||||
'Memory refreshed successfully. Loaded 17 characters from 2 file(s).',
|
||||
'Memory refreshed successfully. Loaded 33 characters from 2 file(s).',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('should show a message if no memory content is found after refresh', async () => {
|
||||
mockRefresh.mockResolvedValue({
|
||||
memoryContent: '',
|
||||
memoryContent: { project: '' },
|
||||
fileCount: 0,
|
||||
filePaths: [],
|
||||
});
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
*/
|
||||
|
||||
import type { Config } from '../config/config.js';
|
||||
import { flattenMemory } from '../config/memory.js';
|
||||
import { refreshServerHierarchicalMemory } from '../utils/memoryDiscovery.js';
|
||||
import type { MessageActionReturn, ToolActionReturn } from './types.js';
|
||||
|
||||
export function showMemory(config: Config): MessageActionReturn {
|
||||
const memoryContent = config.getUserMemory() || '';
|
||||
const memoryContent = flattenMemory(config.getUserMemory());
|
||||
const fileCount = config.getGeminiMdFileCount() || 0;
|
||||
let content: string;
|
||||
|
||||
@@ -51,11 +52,11 @@ export async function refreshMemory(
|
||||
|
||||
if (config.isJitContextEnabled()) {
|
||||
await config.getContextManager()?.refresh();
|
||||
memoryContent = config.getUserMemory();
|
||||
memoryContent = flattenMemory(config.getUserMemory());
|
||||
fileCount = config.getGeminiMdFileCount();
|
||||
} else {
|
||||
const result = await refreshServerHierarchicalMemory(config);
|
||||
memoryContent = result.memoryContent;
|
||||
memoryContent = flattenMemory(result.memoryContent);
|
||||
fileCount = result.fileCount;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user