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

Function openEngine

__tests__/watcher-replaced-db.test.ts:219–231  ·  view source on GitHub ↗
(watch: boolean)

Source from the content-addressed store, hash-verified

217 });
218
219 async function openEngine(watch: boolean): Promise<MCPEngine> {
220 const seed = CodeGraph.initSync(root);
221 await seed.indexAll();
222 seed.close();
223 if (!fs.existsSync(ENGINE)) throw new Error(`${ENGINE} missing — run \`npm run build\` first`);
224 const { MCPEngine: Engine } = require(ENGINE) as { MCPEngine: typeof MCPEngine };
225 const engine = new Engine({ watch, writerLockRoot: watch ? root : undefined });
226 await engine.ensureInitialized(root);
227 // Drain the post-open catch-up gate (and prove the project is loaded).
228 const first = await engine.getToolHandler().execute('codegraph_search', { query: 'alpha' });
229 expect(first.content[0].text).toMatch(/alpha/);
230 return engine;
231 }
232
233 posixOnly('reopening a replaced database runs a catch-up sync into the new file', async () => {
234 const engine = await openEngine(true);

Callers 1

Calls 6

initSyncMethod · 0.80
ensureInitializedMethod · 0.80
executeMethod · 0.80
getToolHandlerMethod · 0.80
closeMethod · 0.65
indexAllMethod · 0.45

Tested by

no test coverage detected