| 32 | * Ensure memory directory structure exists. |
| 33 | */ |
| 34 | export async function initMemory(workspaceDir) { |
| 35 | if (!workspaceDir) return |
| 36 | const memDir = memoryDir(workspaceDir) |
| 37 | await mkdir(join(memDir, TOPICS_DIR), { recursive: true }) |
| 38 | await mkdir(join(memDir, LOGS_DIR), { recursive: true }) |
| 39 | |
| 40 | const indexPath = join(memDir, MEMORY_INDEX) |
| 41 | if (!existsSync(indexPath)) { |
| 42 | await writeFile(indexPath, '# Memory Index\n\n(暂无记忆)\n', 'utf8') |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Load the MEMORY.md index, capped at MAX_INDEX_LINES / MAX_INDEX_BYTES. |