(cwd, memory)
| 113 | } |
| 114 | |
| 115 | export async function writeMemoryFile(cwd, memory) { |
| 116 | if (!shouldStoreAsMemory(memory)) { |
| 117 | throw new Error("Invalid memory payload."); |
| 118 | } |
| 119 | |
| 120 | const { memoryDir } = await ensureMemoryDir(cwd); |
| 121 | const fileName = slugify(memory.name) + ".md"; |
| 122 | const filePath = path.join(memoryDir, fileName); |
| 123 | const content = buildMemoryFileContent(memory); |
| 124 | |
| 125 | await fs.writeFile(filePath, content, "utf8"); |
| 126 | return filePath; |
| 127 | } |
| 128 | |
| 129 | export async function readMemoryFile(filePath) { |
| 130 | const raw = await fs.readFile(filePath, "utf8"); |
no test coverage detected