1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { Message, MessageType } from '../types.js';
import { Config } from '@google/gemini-cli-core';
import { LoadedSettings } from '../../config/settings.js';
export function createShowMemoryAction(
config: Config | null,
settings: LoadedSettings,
addMessage: (message: Message) => void,
) {
return async () => {
if (!config) {
addMessage({
type: MessageType.ERROR,
content: 'Configuration not available. Cannot show memory.',
timestamp: new Date(),
});
return;
}
const debugMode = config.getDebugMode();
if (debugMode) {
console.log('[DEBUG] Show Memory command invoked.');
}
const currentMemory = config.getUserMemory();
const fileCount = config.getGeminiMdFileCount();
const contextFileName = settings.merged.contextFileName;
const contextFileNames = Array.isArray(contextFileName)
? contextFileName
: [contextFileName];
if (debugMode) {
console.log(
`[DEBUG] Showing memory. Content from config.getUserMemory() (first 200 chars): ${currentMemory.substring(0, 200)}...`,
);
console.log(`[DEBUG] Number of context files loaded: ${fileCount}`);
}
if (fileCount > 0) {
const allNamesTheSame = new Set(contextFileNames).size < 2;
const name = allNamesTheSame ? contextFileNames[0] : 'context';
addMessage({
type: MessageType.INFO,
content: `Loaded memory from ${fileCount} ${name} file${
fileCount > 1 ? 's' : ''
}.`,
timestamp: new Date(),
});
}
if (currentMemory && currentMemory.trim().length > 0) {
addMessage({
type: MessageType.INFO,
content: `Current combined memory content:\n\`\`\`markdown\n${currentMemory}\n\`\`\``,
timestamp: new Date(),
});
} else {
addMessage({
type: MessageType.INFO,
content:
fileCount > 0
? 'Hierarchical memory (GEMINI.md or other context files) is loaded but content is empty.'
: 'No hierarchical memory (GEMINI.md or other context files) is currently loaded.',
timestamp: new Date(),
});
}
};
}
|