MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / getSymbolGraph

Function getSymbolGraph

src/context/symbol-graph.ts:38–61  ·  view source on GitHub ↗
(
  projectRoot: string,
  opts: { ttlMs?: number; maxFiles?: number; signal?: AbortSignal } = {},
)

Source from the content-addressed store, hash-verified

36 * every turn. Returns null if the graph can't be built.
37 */
38export async function getSymbolGraph(
39 projectRoot: string,
40 opts: { ttlMs?: number; maxFiles?: number; signal?: AbortSignal } = {},
41): Promise<ImportGraph | null> {
42 const ttl = opts.ttlMs ?? DEFAULT_TTL_MS;
43 const cached = _cache.get(projectRoot);
44 if (cached && Date.now() - cached.builtAt < ttl) {
45 return cached.graph;
46 }
47 try {
48 const { walkSource } = await import('./retrieval.js');
49 const files = await walkSource(projectRoot, opts.maxFiles ?? 2000);
50 const graph = await buildImportGraph(
51 projectRoot,
52 files.map(f => ({ rel: f.rel, content: f.content })),
53 );
54 _cache.set(projectRoot, { graph, builtAt: Date.now() });
55 logger.debug('Symbol graph built', { files: graph.files.size });
56 return graph;
57 } catch (e: any) {
58 logger.debug('Symbol graph build failed', { err: e?.message });
59 return null;
60 }
61}
62
63/** Invalidate the cached graph for a project (e.g. after a big refactor). */
64export function invalidateSymbolGraph(projectRoot: string): void {

Callers 2

executeMethod · 0.85
buildInitialMessagesMethod · 0.85

Calls 5

buildImportGraphFunction · 0.85
debugMethod · 0.80
walkSourceFunction · 0.70
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected