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

Method init

src/index.ts:419–444  ·  view source on GitHub ↗

* Initialize a new CodeGraph project * * Creates the .CodeGraph directory, database, and configuration. * * @param projectRoot - Path to the project root directory * @param options - Initialization options * @returns A new CodeGraph instance

(projectRoot: string, options: InitOptions = {})

Source from the content-addressed store, hash-verified

417 * @returns A new CodeGraph instance
418 */
419 static async init(projectRoot: string, options: InitOptions = {}): Promise<CodeGraph> {
420 await initGrammars();
421 const resolvedRoot = path.resolve(projectRoot);
422
423 // Check if already initialized
424 if (isInitialized(resolvedRoot)) {
425 throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
426 }
427
428 // Create directory structure
429 createDirectory(resolvedRoot);
430
431 // Initialize database
432 const dbPath = getDatabasePath(resolvedRoot);
433 const db = DatabaseConnection.initialize(dbPath);
434 const queries = new QueryBuilder(db.getDb());
435
436 const instance = new CodeGraph(db, queries, resolvedRoot);
437
438 // Run initial indexing if requested
439 if (options.index) {
440 await instance.indexAll({ onProgress: options.onProgress });
441 }
442
443 return instance;
444 }
445
446 /**
447 * Initialize synchronously (without indexing)

Callers 8

initGrammarsFunction · 0.45
runInitFunction · 0.45
dump-ast.mjsFile · 0.45
runGrammarFunction · 0.45
prepare.mjsFile · 0.45

Calls 8

indexAllMethod · 0.95
initGrammarsFunction · 0.90
isInitializedFunction · 0.90
createDirectoryFunction · 0.90
getDatabasePathFunction · 0.90
getDbMethod · 0.80
resolveMethod · 0.65
initializeMethod · 0.45

Tested by

no test coverage detected