summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/hooks')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.test.ts24
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.ts6
-rw-r--r--packages/cli/src/ui/hooks/useShowMemoryCommand.ts20
3 files changed, 37 insertions, 13 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
index 03f8cc9c..31105509 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
@@ -62,14 +62,15 @@ import {
} from './slashCommandProcessor.js';
import { MessageType } from '../types.js';
import {
- type Config,
- MCPServerStatus,
- getMCPServerStatus,
+ Config,
MCPDiscoveryState,
+ MCPServerStatus,
getMCPDiscoveryState,
+ getMCPServerStatus,
GeminiClient,
} from '@gemini-cli/core';
import { useSessionStats } from '../contexts/SessionContext.js';
+import { LoadedSettings } from '../../config/settings.js';
vi.mock('@gemini-code/core', async (importOriginal) => {
const actual = await importOriginal<typeof import('@gemini-code/core')>();
@@ -161,10 +162,16 @@ describe('useSlashCommandProcessor', () => {
process.env = { ...globalThis.process.env };
});
- const getProcessorHook = (showToolDescriptions: boolean = false) =>
- renderHook(() =>
+ const getProcessorHook = (showToolDescriptions: boolean = false) => {
+ const settings = {
+ merged: {
+ contextFileName: 'GEMINI.md',
+ },
+ } as LoadedSettings;
+ return renderHook(() =>
useSlashCommandProcessor(
mockConfig,
+ settings,
[],
mockAddItem,
mockClearItems,
@@ -181,6 +188,7 @@ describe('useSlashCommandProcessor', () => {
mockSetQuittingMessages,
),
);
+ };
const getProcessor = (showToolDescriptions: boolean = false) =>
getProcessorHook(showToolDescriptions).result.current;
@@ -253,7 +261,11 @@ describe('useSlashCommandProcessor', () => {
});
expect(
ShowMemoryCommandModule.createShowMemoryAction,
- ).toHaveBeenCalledWith(mockConfig, expect.any(Function));
+ ).toHaveBeenCalledWith(
+ mockConfig,
+ expect.any(Object),
+ expect.any(Function),
+ );
expect(mockReturnedShowAction).toHaveBeenCalled();
expect(commandResult).toBe(true);
});
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index 679c294c..66dfe213 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -32,6 +32,7 @@ import { createShowMemoryAction } from './useShowMemoryCommand.js';
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
import { formatDuration, formatMemoryUsage } from '../utils/formatters.js';
import { getCliVersion } from '../../utils/version.js';
+import { LoadedSettings } from '../../config/settings.js';
export interface SlashCommandActionReturn {
shouldScheduleTool?: boolean;
@@ -60,6 +61,7 @@ export interface SlashCommand {
*/
export const useSlashCommandProcessor = (
config: Config | null,
+ settings: LoadedSettings,
history: HistoryItem[],
addItem: UseHistoryManagerReturn['addItem'],
clearItems: UseHistoryManagerReturn['clearItems'],
@@ -135,9 +137,9 @@ export const useSlashCommandProcessor = (
);
const showMemoryAction = useCallback(async () => {
- const actionFn = createShowMemoryAction(config, addMessage);
+ const actionFn = createShowMemoryAction(config, settings, addMessage);
await actionFn();
- }, [config, addMessage]);
+ }, [config, settings, addMessage]);
const addMemoryAction = useCallback(
(
diff --git a/packages/cli/src/ui/hooks/useShowMemoryCommand.ts b/packages/cli/src/ui/hooks/useShowMemoryCommand.ts
index aea55849..341298ba 100644
--- a/packages/cli/src/ui/hooks/useShowMemoryCommand.ts
+++ b/packages/cli/src/ui/hooks/useShowMemoryCommand.ts
@@ -6,9 +6,11 @@
import { Message, MessageType } from '../types.js';
import { Config } from '@gemini-cli/core';
+import { LoadedSettings } from '../../config/settings.js';
export function createShowMemoryAction(
config: Config | null,
+ settings: LoadedSettings,
addMessage: (message: Message) => void,
) {
return async () => {
@@ -29,18 +31,26 @@ export function createShowMemoryAction(
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 GEMINI.md files loaded: ${fileCount}`);
+ 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} GEMINI.md file(s).`,
+ content: `Loaded memory from ${fileCount} ${name} file${
+ fileCount > 1 ? 's' : ''
+ }.`,
timestamp: new Date(),
});
}
@@ -48,7 +58,7 @@ export function createShowMemoryAction(
if (currentMemory && currentMemory.trim().length > 0) {
addMessage({
type: MessageType.INFO,
- content: `Current combined GEMINI.md memory content:\n\`\`\`markdown\n${currentMemory}\n\`\`\``,
+ content: `Current combined memory content:\n\`\`\`markdown\n${currentMemory}\n\`\`\``,
timestamp: new Date(),
});
} else {
@@ -56,8 +66,8 @@ export function createShowMemoryAction(
type: MessageType.INFO,
content:
fileCount > 0
- ? 'Hierarchical memory (GEMINI.md) is loaded but content is empty.'
- : 'No hierarchical memory (GEMINI.md) is currently loaded.',
+ ? '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(),
});
}