MCPcopy
hub / github.com/colbymchenry/codegraph / resolveProjectPath

Function resolveProjectPath

src/bin/codegraph.ts:200–225  ·  view source on GitHub ↗

* Resolve project path from argument or current directory * Walks up parent directories to find nearest initialized CodeGraph project * (must have .codegraph/codegraph.db, not just .codegraph/lessons.db)

(pathArg?: string)

Source from the content-addressed store, hash-verified

198 * (must have .codegraph/codegraph.db, not just .codegraph/lessons.db)
199 */
200function resolveProjectPath(pathArg?: string): string {
201 const absolutePath = path.resolve(pathArg || process.cwd());
202
203 // If exact path is initialized (has codegraph.db), use it
204 if (isInitialized(absolutePath)) {
205 return absolutePath;
206 }
207
208 // Walk up to find nearest parent with CodeGraph initialized
209 // Note: findNearestCodeGraphRoot finds any .codegraph folder, but we need one with codegraph.db
210 let current = absolutePath;
211 const root = path.parse(current).root;
212
213 while (current !== root) {
214 const parent = path.dirname(current);
215 if (parent === current) break;
216 current = parent;
217
218 if (isInitialized(current)) {
219 return current;
220 }
221 }
222
223 // Not found - return original path (will fail later with helpful error)
224 return absolutePath;
225}
226
227/**
228 * Format a number with commas

Callers 1

mainFunction · 0.85

Calls 2

isInitializedFunction · 0.90
resolveMethod · 0.80

Tested by

no test coverage detected