* The nearest-root walk, qualified: an `openspec/` DIRECTORY alone is * not a root — it must carry a planning shape or a config file. * Without this, the recommended `~/openspec/ ` store layout would * make $HOME a phantom root that captures every command under the * home tree.
(startPath: string)
| 273 | * home tree. |
| 274 | */ |
| 275 | function findQualifyingRootSync(startPath: string): string | null { |
| 276 | let candidate = findRepoPlanningRootSync(startPath); |
| 277 | while (candidate) { |
| 278 | const { hasPlanningShape, pointer } = classifyOpenSpecDir(candidate); |
| 279 | if (hasPlanningShape || pointer.filePath) { |
| 280 | return candidate; |
| 281 | } |
| 282 | const parent = path.dirname(candidate); |
| 283 | if (parent === candidate) { |
| 284 | return null; |
| 285 | } |
| 286 | candidate = findRepoPlanningRootSync(parent); |
| 287 | } |
| 288 | return null; |
| 289 | } |
| 290 | |
| 291 | async function resolveNearestOrDeclaredRoot( |
| 292 | nearestRoot: string, |
no test coverage detected