添加注释

This commit is contained in:
2026-05-11 17:04:23 +08:00
parent cbaa1099de
commit 61e9fa94ac
3 changed files with 8 additions and 0 deletions
+3
View File
@@ -35,6 +35,7 @@ const SUSPICIOUS_MEMORY_PATTERNS = [
];
export class MemoryStore {
// Memory 文件可能被多次连续追加,串行化可避免并发覆盖掉刚写入的条目。
private writeQueue: Promise<void> = Promise.resolve();
constructor(
@@ -46,6 +47,7 @@ export class MemoryStore {
await ensureDirectory(this.baseDir);
await ensureDirectory(join(this.baseDir, "users"));
await ensureDirectory(join(this.baseDir, "workspaces"));
// 历史备份与正式数据分目录存放,便于排查和手工恢复。
await ensureDirectory(this.historyDir);
}
@@ -64,6 +66,7 @@ export class MemoryStore {
const entry: MemoryEntry = { content };
entries.unshift(entry);
// 每次覆盖 memory 文件前先保留上一版,写入失败时由底层工具恢复。
await atomicWriteFileWithHistory(
this.filePath(scope, key),
renderMemoryMarkdown(scope, entries),