/** * Subgraph Extractor * * For files that are too large to send as raw source to the LLM, * extracts a compact call-graph neighborhood around "god functions" * (high fan-out) and formats it as a structured prompt section. * * This dramatically reduces token usage while preserving structural * information about complex orchestration code. */ import type { SerializedCallGraph, FunctionNode } from './call-graph.js'; import type { FileSignatureMap } from './signature-extractor.js'; export interface SubgraphOptions { maxDepth?: number; maxNodes?: number; /** If provided, derive maxDepth/maxNodes from the token budget */ tokenBudget?: number; } /** Derive a reasonable maxDepth from a token budget (rough heuristic). */ export declare function depthFromBudget(tokenBudget: number): number; export interface SubGraphNode { name: string; file: string; fanIn: number; fanOut: number; } export interface SubGraph { root: SubGraphNode; /** Callee nodes reachable within MAX_DEPTH */ nodes: SubGraphNode[]; /** [callerName, calleeName] pairs */ edges: Array<[string, string]>; } /** * Return all god functions (fanOut >= threshold) defined in a given file. * Normalises path separators for cross-platform matching. */ export declare function getFileGodFunctions(callGraph: SerializedCallGraph, filePath: string, fanOutThreshold?: number): FunctionNode[]; /** * Extract a depth-limited subgraph around a root node. * Only follows outgoing (callee) edges. */ export declare function extractSubgraph(callGraph: SerializedCallGraph, root: FunctionNode, options?: SubgraphOptions): SubGraph; /** * Build a graph-based prompt section for a large file. * * Returns null if no call-graph data is available for the file, * signalling the caller to fall back to raw source chunking. */ export declare function buildGraphPromptSection(callGraph: SerializedCallGraph | undefined, signatures: FileSignatureMap[] | undefined, filePath: string, tokenBudget?: number): string | null; //# sourceMappingURL=subgraph-extractor.d.ts.map