(cwd = process.cwd())
| 124 | * (and thus get more weight from the model). |
| 125 | */ |
| 126 | export function loadMemoryFiles(cwd = process.cwd()): MemoryFile[] { |
| 127 | const processed = new Set<string>() |
| 128 | const files: MemoryFile[] = [] |
| 129 | |
| 130 | // 1. User memory (~/.orbcode/AGENTS.md) |
| 131 | files.push(...loadWithIncludes(path.join(getConfigDir(), "AGENTS.md"), "user", processed, 0)) |
| 132 | |
| 133 | // 2. Project memory (AGENTS.md + .orb/AGENTS.md), root -> cwd. The legacy |
| 134 | // .orbcode/AGENTS.md location is still read for backward compatibility. |
| 135 | for (const dir of ancestorDirs(cwd).reverse()) { |
| 136 | files.push(...loadWithIncludes(path.join(dir, "AGENTS.md"), "project", processed, 0)) |
| 137 | files.push(...loadWithIncludes(path.join(dir, ".orb", "AGENTS.md"), "project", processed, 0)) |
| 138 | files.push(...loadWithIncludes(path.join(dir, ".orbcode", "AGENTS.md"), "project", processed, 0)) |
| 139 | } |
| 140 | |
| 141 | // 3. Local memory (AGENTS.local.md), root -> cwd — highest precedence |
| 142 | for (const dir of ancestorDirs(cwd).reverse()) { |
| 143 | files.push(...loadWithIncludes(path.join(dir, "AGENTS.local.md"), "local", processed, 0)) |
| 144 | } |
| 145 | |
| 146 | return files |
| 147 | } |
| 148 | |
| 149 | /** Render the memory files into a single system-prompt section. */ |
| 150 | export function renderMemorySection(files: MemoryFile[]): string { |
no test coverage detected