refactor(memory): replace MemoryManagerAgent with prompt-driven memory editing across four tiers (#25716)

This commit is contained in:
Sandy Tao
2026-04-21 18:21:55 -07:00
committed by GitHub
parent ffb28c772b
commit 6edfba481f
24 changed files with 772 additions and 477 deletions
+27 -7
View File
@@ -8,7 +8,10 @@ import * as fs from 'node:fs/promises';
import * as fsSync from 'node:fs';
import * as path from 'node:path';
import { bfsFileSearch } from './bfsFileSearch.js';
import { getAllGeminiMdFilenames } from '../tools/memoryTool.js';
import {
getAllGeminiMdFilenames,
PROJECT_MEMORY_INDEX_FILENAME,
} from '../tools/memoryTool.js';
import type { FileDiscoveryService } from '../services/fileDiscoveryService.js';
import { processImports } from './memoryImportProcessor.js';
import {
@@ -488,17 +491,34 @@ export async function getGlobalMemoryPaths(): Promise<string[]> {
export async function getUserProjectMemoryPaths(
projectMemoryDir: string,
): Promise<string[]> {
const geminiMdFilenames = getAllGeminiMdFilenames();
const preferredMemoryPath = normalizePath(
path.join(projectMemoryDir, PROJECT_MEMORY_INDEX_FILENAME),
);
try {
await fs.access(preferredMemoryPath, fsSync.constants.R_OK);
debugLogger.debug(
'[DEBUG] [MemoryDiscovery] Found user project memory index:',
preferredMemoryPath,
);
return [preferredMemoryPath];
} catch {
// Fall back to the legacy private GEMINI.md file if the project has not
// been migrated to MEMORY.md yet.
}
const geminiMdFilenames = getAllGeminiMdFilenames();
const accessChecks = geminiMdFilenames.map(async (filename) => {
const memoryPath = normalizePath(path.join(projectMemoryDir, filename));
const legacyMemoryPath = normalizePath(
path.join(projectMemoryDir, filename),
);
try {
await fs.access(memoryPath, fsSync.constants.R_OK);
await fs.access(legacyMemoryPath, fsSync.constants.R_OK);
debugLogger.debug(
'[DEBUG] [MemoryDiscovery] Found user project memory file:',
memoryPath,
'[DEBUG] [MemoryDiscovery] Found legacy user project memory file:',
legacyMemoryPath,
);
return memoryPath;
return legacyMemoryPath;
} catch {
return null;
}