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

Method freshen

src/mcp/tools.ts:2437–2451  ·  view source on GitHub ↗

* Heal a long-lived connection whose `.codegraph/` was removed and recreated * at the same path (a worktree recreated, or `rm -rf .codegraph` + re-init) * before handing it to a tool. Otherwise the daemon keeps serving the * pre-removal snapshot from its now-unlinked file handle until resta

(cg: CodeGraph)

Source from the content-addressed store, hash-verified

2435 * tool call.
2436 */
2437 private freshen(cg: CodeGraph): CodeGraph {
2438 try {
2439 if (cg.reopenIfReplaced()) {
2440 process.stderr.write(
2441 '[CodeGraph MCP] The index was replaced on disk (e.g. a git worktree ' +
2442 'recreated at the same path); reopened the live database in place.\n'
2443 );
2444 this.onDatabaseReopened?.(cg);
2445 }
2446 } catch {
2447 // Best-effort self-heal — a failed reopen must never break the tool call;
2448 // the (still stale) handle keeps serving and the next call retries.
2449 }
2450 return cg;
2451 }
2452
2453 /**
2454 * Close all cached project connections

Callers 2

getCodeGraphMethod · 0.95
openProjectRootMethod · 0.95

Calls 2

reopenIfReplacedMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected