MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / openSync

Method openSync

src/index.ts:381–401  ·  view source on GitHub ↗

* Open synchronously (without sync)

(projectRoot: string)

Source from the content-addressed store, hash-verified

379 * Open synchronously (without sync)
380 */
381 static openSync(projectRoot: string): CodeGraph {
382 const resolvedRoot = path.resolve(projectRoot);
383
384 // Check if initialized
385 if (!isInitialized(resolvedRoot)) {
386 throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
387 }
388
389 // Validate directory structure
390 const validation = validateDirectory(resolvedRoot);
391 if (!validation.valid) {
392 throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
393 }
394
395 // Open database
396 const dbPath = getDatabasePath(resolvedRoot);
397 const db = DatabaseConnection.open(dbPath);
398 const queries = new QueryBuilder(db.getDb());
399
400 return new CodeGraph(db, queries, resolvedRoot);
401 }
402
403 /**
404 * Check if a directory has been initialized as a CodeGraph project

Callers 15

readFileInChunksFunction · 0.80
spawnDetachedDaemonFunction · 0.80
getCodeGraphMethod · 0.80
retryInitializeSyncMethod · 0.80
query-worker.tsFile · 0.80
mainFunction · 0.80
probe-sweep.mjsFile · 0.80
probe-trace.mjsFile · 0.80
probe-explore.mjsFile · 0.80
probe-node.mjsFile · 0.80
probe-context.mjsFile · 0.80

Calls 7

isInitializedFunction · 0.90
validateDirectoryFunction · 0.90
getDatabasePathFunction · 0.90
resolveMethod · 0.80
getDbMethod · 0.80
joinMethod · 0.45
openMethod · 0.45

Tested by 2

graphCountsFunction · 0.64
runFunction · 0.64