fix(FN-000): compact selected memory file

This commit is contained in:
gsxdsm
2026-04-17 08:55:50 -07:00
parent f0415937d3
commit 20b01981b8
9 changed files with 131 additions and 81 deletions

View File

@@ -449,6 +449,7 @@ export {
ensureOpenClawMemoryFiles,
listProjectMemoryFiles,
readProjectMemoryFile,
readProjectMemoryFileContent,
writeProjectMemoryFile,
} from "./memory-backend.js";

View File

@@ -591,6 +591,19 @@ export async function readProjectMemoryFile(rootDir: string, options: MemoryGetO
return getMemoryFile(rootDir, options, "file");
}
export async function readProjectMemoryFileContent(rootDir: string, path: string): Promise<{ path: string; content: string }> {
const { absPath, displayPath } = resolveMemoryFilePath(rootDir, path);
try {
const content = await readFile(absPath, "utf-8");
return { path: displayPath, content };
} catch (err) {
if ((err as NodeJS.ErrnoException).code === "ENOENT") {
throw new MemoryBackendError("NOT_FOUND", `Memory path '${path}' not found`, "file");
}
throw new MemoryBackendError("READ_FAILED", `Failed to read memory path '${path}': ${(err as Error).message}`, "file");
}
}
export async function writeProjectMemoryFile(rootDir: string, path: string, content: string): Promise<MemoryWriteResult> {
const { absPath, displayPath } = resolveMemoryFilePath(rootDir, path);
await mkdir(dirname(absPath), { recursive: true });