(watch: boolean)
| 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); |
no test coverage detected