blob: 63a7734f44c7900c492770485636216bf72b92f4 (
plain)
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
|
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as fs from 'fs/promises';
import * as path from 'path';
import { homedir } from 'os';
import { SETTINGS_DIRECTORY_NAME } from './settings.js';
import {
// getErrorMessage, // Removed as it's not used
MemoryTool,
GEMINI_MD_FILENAME,
// MEMORY_SECTION_HEADER, // Removed as it's not used
} from '@gemini-code/server';
/**
* Gets the absolute path to the global GEMINI.md file.
*/
export function getGlobalMemoryFilePath(): string {
return path.join(homedir(), SETTINGS_DIRECTORY_NAME, GEMINI_MD_FILENAME);
}
/**
* Adds a new memory entry to the global GEMINI.md file under the specified header.
*/
export async function addMemoryEntry(text: string): Promise<void> {
const filePath = getGlobalMemoryFilePath();
// The performAddMemoryEntry method from MemoryTool will handle its own errors
// and throw an appropriately formatted error if needed.
await MemoryTool.performAddMemoryEntry(text, filePath, {
readFile: fs.readFile,
writeFile: fs.writeFile,
mkdir: fs.mkdir,
});
}
|