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

Method init

src/index.ts:236–261  ·  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

234 * @returns A new CodeGraph instance
235 */
236 static async init(projectRoot: string, options: InitOptions = {}): Promise<CodeGraph> {
237 await initGrammars();
238 const resolvedRoot = path.resolve(projectRoot);
239
240 // Check if already initialized
241 if (isInitialized(resolvedRoot)) {
242 throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
243 }
244
245 // Create directory structure
246 createDirectory(resolvedRoot);
247
248 // Initialize database
249 const dbPath = getDatabasePath(resolvedRoot);
250 const db = DatabaseConnection.initialize(dbPath);
251 const queries = new QueryBuilder(db.getDb());
252
253 const instance = new CodeGraph(db, queries, resolvedRoot);
254
255 // Run initial indexing if requested
256 if (options.index) {
257 await instance.indexAll({ onProgress: options.onProgress });
258 }
259
260 return instance;
261 }
262
263 /**
264 * Initialize synchronously (without indexing)

Callers 15

initGrammarsFunction · 0.80
mainFunction · 0.80
dump-ast.mjsFile · 0.80
check-grammar.mjsFile · 0.80
mcp-daemon.test.tsFile · 0.80
loadFunction · 0.80

Calls 8

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

Tested by 5

loadFunction · 0.64
indexAndQueryFunction · 0.64
loadFunction · 0.64
indexCppFunction · 0.64
indexFunction · 0.64