MCPcopy Index your code
hub / github.com/Fission-AI/OpenSpec / findQualifyingRootSync

Function findQualifyingRootSync

src/core/root-selection.ts:275–289  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

273 * home tree.
274 */
275function 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
291async function resolveNearestOrDeclaredRoot(
292 nearestRoot: string,

Callers 1

resolveOpenSpecRootFunction · 0.85

Calls 2

findRepoPlanningRootSyncFunction · 0.85
classifyOpenSpecDirFunction · 0.85

Tested by

no test coverage detected