fix: address memory review findings

Remove shell-based memory tree inspection and pre-sync before memory pushes.
Switch sync update detection to git HEAD comparisons instead of localized output parsing.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Harivansh Rathi 2026-03-08 12:56:39 -07:00
parent 2886855706
commit e0801dedb0
3 changed files with 129 additions and 60 deletions

View file

@ -8,6 +8,7 @@ import type { MemoryFrontmatter, MemoryMdSettings } from "./memory-md.js";
import {
createDefaultFiles,
ensureDirectoryStructure,
formatMemoryDirectoryTree,
getCurrentDate,
getMemoryDir,
getProjectRepoPath,
@ -184,6 +185,14 @@ export function registerMemorySync(
};
}
const syncResult = await syncRepository(pi, settings, isRepoInitialized);
if (!syncResult.success) {
return {
content: [{ type: "text", text: syncResult.message }],
details: { success: false, configured: true },
};
}
const statusResult = await gitExec(
pi,
localPath,
@ -793,26 +802,7 @@ export function registerMemoryCheck(
};
}
const { execSync } = await import("node:child_process");
let treeOutput = "";
try {
treeOutput = execSync(`tree -L 3 -I "node_modules" "${memoryDir}"`, {
encoding: "utf-8",
});
} catch {
try {
treeOutput = execSync(
`find "${memoryDir}" -type d -not -path "*/node_modules/*" | head -20`,
{
encoding: "utf-8",
},
);
} catch {
treeOutput =
"Unable to generate directory tree. Please check permissions.";
}
}
const treeOutput = formatMemoryDirectoryTree(memoryDir);
const files = listMemoryFiles(memoryDir);
const relPaths = files.map((f) => path.relative(memoryDir, f));