mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-29 06:25:16 -07:00
Update contextFileName to support an optional list of strings (#1001)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
MemoryTool,
|
||||
setGeminiMdFilename,
|
||||
getCurrentGeminiMdFilename,
|
||||
getAllGeminiMdFilenames,
|
||||
DEFAULT_CONTEXT_FILENAME,
|
||||
} from './memoryTool.js';
|
||||
import * as fs from 'fs/promises';
|
||||
@@ -74,6 +75,13 @@ describe('MemoryTool', () => {
|
||||
setGeminiMdFilename('');
|
||||
expect(getCurrentGeminiMdFilename()).toBe(initialName);
|
||||
});
|
||||
|
||||
it('should handle an array of filenames', () => {
|
||||
const newNames = ['CUSTOM_CONTEXT.md', 'ANOTHER_CONTEXT.md'];
|
||||
setGeminiMdFilename(newNames);
|
||||
expect(getCurrentGeminiMdFilename()).toBe('CUSTOM_CONTEXT.md');
|
||||
expect(getAllGeminiMdFilenames()).toEqual(newNames);
|
||||
});
|
||||
});
|
||||
|
||||
describe('performAddMemoryEntry (static method)', () => {
|
||||
|
||||
@@ -51,18 +51,32 @@ export const MEMORY_SECTION_HEADER = '## Gemini Added Memories';
|
||||
|
||||
// This variable will hold the currently configured filename for GEMINI.md context files.
|
||||
// It defaults to DEFAULT_CONTEXT_FILENAME but can be overridden by setGeminiMdFilename.
|
||||
let currentGeminiMdFilename = DEFAULT_CONTEXT_FILENAME;
|
||||
let currentGeminiMdFilename: string | string[] = DEFAULT_CONTEXT_FILENAME;
|
||||
|
||||
export function setGeminiMdFilename(newFilename: string): void {
|
||||
if (newFilename && newFilename.trim() !== '') {
|
||||
export function setGeminiMdFilename(newFilename: string | string[]): void {
|
||||
if (Array.isArray(newFilename)) {
|
||||
if (newFilename.length > 0) {
|
||||
currentGeminiMdFilename = newFilename.map((name) => name.trim());
|
||||
}
|
||||
} else if (newFilename && newFilename.trim() !== '') {
|
||||
currentGeminiMdFilename = newFilename.trim();
|
||||
}
|
||||
}
|
||||
|
||||
export function getCurrentGeminiMdFilename(): string {
|
||||
if (Array.isArray(currentGeminiMdFilename)) {
|
||||
return currentGeminiMdFilename[0];
|
||||
}
|
||||
return currentGeminiMdFilename;
|
||||
}
|
||||
|
||||
export function getAllGeminiMdFilenames(): string[] {
|
||||
if (Array.isArray(currentGeminiMdFilename)) {
|
||||
return currentGeminiMdFilename;
|
||||
}
|
||||
return [currentGeminiMdFilename];
|
||||
}
|
||||
|
||||
interface SaveMemoryParams {
|
||||
fact: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user