summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useShowMemoryCommand.ts
diff options
context:
space:
mode:
authorAllen Hutchison <[email protected]>2025-05-23 08:53:22 -0700
committerGitHub <[email protected]>2025-05-23 08:53:22 -0700
commita008d8178015a182656ea8f5a39b9dde554da5ae (patch)
tree059bd07837939034426f3473cda7b4a055dc661e /packages/cli/src/ui/hooks/useShowMemoryCommand.ts
parentf8c4276e69cb8262433a4059540c873c2c996420 (diff)
Refactor(server): Centralize GEMINI.md discovery logic in server (#498)
Diffstat (limited to 'packages/cli/src/ui/hooks/useShowMemoryCommand.ts')
-rw-r--r--packages/cli/src/ui/hooks/useShowMemoryCommand.ts45
1 files changed, 15 insertions, 30 deletions
diff --git a/packages/cli/src/ui/hooks/useShowMemoryCommand.ts b/packages/cli/src/ui/hooks/useShowMemoryCommand.ts
index c15b27cd..c8719bbd 100644
--- a/packages/cli/src/ui/hooks/useShowMemoryCommand.ts
+++ b/packages/cli/src/ui/hooks/useShowMemoryCommand.ts
@@ -6,11 +6,6 @@
import { Message, MessageType } from '../types.js';
import { Config } from '@gemini-code/server';
-import { getGeminiMdFilePaths } from '../../config/config.js';
-import { homedir } from 'os';
-import process from 'node:process';
-
-export const SHOW_MEMORY_COMMAND_NAME = '/showmemory';
export function createShowMemoryAction(
config: Config | null,
@@ -27,52 +22,42 @@ export function createShowMemoryAction(
}
const debugMode = config.getDebugMode();
- const cwd = process.cwd();
- const homeDir = homedir();
if (debugMode) {
- console.log(`[DEBUG] Show Memory: CWD=${cwd}, Home=${homeDir}`);
- }
-
- const filePaths = await getGeminiMdFilePaths(cwd, homeDir, debugMode);
-
- if (filePaths.length > 0) {
- addMessage({
- type: MessageType.INFO,
- content: `The following GEMINI.md files are being used (in order of precedence):\n- ${filePaths.join('\n- ')}`,
- timestamp: new Date(),
- });
- } else {
- addMessage({
- type: MessageType.INFO,
- content: 'No GEMINI.md files found in the hierarchy.',
- timestamp: new Date(),
- });
+ console.log('[DEBUG] Show Memory command invoked.');
}
const currentMemory = config.getUserMemory();
+ const fileCount = config.getGeminiMdFileCount();
- if (config.getDebugMode()) {
+ if (debugMode) {
console.log(
`[DEBUG] Showing memory. Content from config.getUserMemory() (first 200 chars): ${currentMemory.substring(0, 200)}...`,
);
+ console.log(`[DEBUG] Number of GEMINI.md files loaded: ${fileCount}`);
+ }
+
+ if (fileCount > 0) {
+ addMessage({
+ type: MessageType.INFO,
+ content: `Loaded memory from ${fileCount} GEMINI.md file(s).`,
+ timestamp: new Date(),
+ });
}
if (currentMemory && currentMemory.trim().length > 0) {
addMessage({
type: MessageType.INFO,
- // Display with a clear heading, and potentially format for readability if very long.
- // For now, direct display. Consider using Markdown formatting for code blocks if memory contains them.
content: `Current combined GEMINI.md memory content:\n\`\`\`markdown\n${currentMemory}\n\`\`\``,
timestamp: new Date(),
});
} else {
- // This message might be redundant if filePaths.length === 0, but kept for explicitness
- // if somehow memory is empty even if files were found (e.g., all files are empty).
addMessage({
type: MessageType.INFO,
content:
- 'No hierarchical memory (GEMINI.md) is currently loaded or memory is empty.',
+ fileCount > 0
+ ? 'Hierarchical memory (GEMINI.md) is loaded but content is empty.'
+ : 'No hierarchical memory (GEMINI.md) is currently loaded.',
timestamp: new Date(),
});
}