* Reconcile the index with the current filesystem once, right after open — * catches edits, adds, deletes, and `git pull`/`checkout` changes made while * no watcher was running. Runs in the background, but the returned promise * is pushed into the ToolHandler as a one-shot gate so the *firs
()
| 294 | * is populated by the watcher, not by catch-up). |
| 295 | */ |
| 296 | private catchUpSync(): void { |
| 297 | const cg = this.cg; |
| 298 | if (!cg) return; |
| 299 | const p = cg |
| 300 | .sync() |
| 301 | .then((result) => { |
| 302 | const changed = result.filesAdded + result.filesModified + result.filesRemoved; |
| 303 | if (changed > 0) { |
| 304 | process.stderr.write(`[CodeGraph MCP] Caught up ${changed} file(s) changed since last run\n`); |
| 305 | } |
| 306 | }) |
| 307 | .catch((err) => { |
| 308 | const msg = err instanceof Error ? err.message : String(err); |
| 309 | process.stderr.write(`[CodeGraph MCP] Catch-up sync failed: ${msg}\n`); |
| 310 | }); |
| 311 | this.toolHandler.setCatchUpGate(p); |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | /** |
no test coverage detected