Walk from cwd up to root, collecting directories (root last).
(cwd: string)
| 106 | |
| 107 | /** Walk from cwd up to root, collecting directories (root last). */ |
| 108 | function ancestorDirs(cwd: string): string[] { |
| 109 | const dirs: string[] = [] |
| 110 | let current = path.resolve(cwd) |
| 111 | const root = path.parse(current).root |
| 112 | while (current !== root) { |
| 113 | dirs.push(current) |
| 114 | const parent = path.dirname(current) |
| 115 | if (parent === current) break |
| 116 | current = parent |
| 117 | } |
| 118 | return dirs |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Load all AGENTS.md memory files, in precedence order (lowest first). The |