MCPcopy
hub / github.com/giancarloerra/SocratiCode / rebuildGraph

Function rebuildGraph

src/services/code-graph.ts:154–179  ·  view source on GitHub ↗
(
  projectPath: string,
  optsOrExtras?: Set<string> | RebuildGraphOptions,
)

Source from the content-addressed store, hash-verified

152 * Set) or a `RebuildGraphOptions` object.
153 */
154export async function rebuildGraph(
155 projectPath: string,
156 optsOrExtras?: Set<string> | RebuildGraphOptions,
157): Promise<CodeGraph> {
158 const resolved = path.resolve(projectPath);
159 const opts: RebuildGraphOptions =
160 optsOrExtras instanceof Set ? { extraExtensions: optsOrExtras } : (optsOrExtras ?? {});
161
162 // Concurrency guard: if already building, return the existing promise
163 const existing = graphBuildPromises.get(resolved);
164 if (existing) {
165 logger.info("Graph build already in progress, joining existing build", { projectPath: resolved });
166 return existing;
167 }
168
169 // Start tracked build
170 const promise = doRebuildGraph(resolved, opts);
171 graphBuildPromises.set(resolved, promise);
172
173 try {
174 const graph = await promise;
175 return graph;
176 } finally {
177 graphBuildPromises.delete(resolved);
178 }
179}
180
181/** Internal: performs the actual graph rebuild with progress tracking */
182async function doRebuildGraph(

Callers 8

handleGraphToolFunction · 0.85
indexProjectFunction · 0.85
updateProjectIndexFunction · 0.85
mainFunction · 0.85
tools.test.tsFile · 0.85
code-graph.test.tsFile · 0.85

Calls 4

doRebuildGraphFunction · 0.85
getMethod · 0.80
setMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected