import { isTestFileStrict as isTestFile } from "../utils/test-file.js";
import type { CodeSymbol, Direction, CallNode } from "../types.js";
/**
 * Pre-computed adjacency lists for O(1) lookup during BFS.
 * Built once per traceCallChain / impactAnalysis call.
 */
export interface AdjacencyIndex {
    /** symbol id → symbols that this symbol references (callees) */
    callees: Map<string, CodeSymbol[]>;
    /** symbol id → symbols that reference this symbol (callers) */
    callers: Map<string, CodeSymbol[]>;
}
export interface CallSite {
    name: string;
    is_method_call: boolean;
}
/**
 * Extract identifiers that look like function/method calls from source code.
 * Matches patterns like: `functionName(`, `obj.methodName(`, `this.method(`.
 * Also matches JSX component usage: `<ComponentName`.
 *
 * Returns an array of CallSite entries with an `is_method_call` flag so
 * downstream graph consumers can exclude method calls from bare-function
 * caller edges (root cause fix for builtin hub contamination, spec D4).
 *
 * Method-call detection: the match position is preceded by `.` or `?.`
 * (including surrounding whitespace). Bracket notation `obj["map"]()` is
 * NOT detected (documented residual noise per spec).
 */
declare function extractCallSites(source: string): CallSite[];
/**
 * Build caller/callee adjacency lists by extracting actual call sites from source code.
 *
 * For each symbol with source, extracts identifiers used as function calls (pattern: `name(`)
 * and looks them up in the symbol name index. This produces much more accurate edges than
 * simple word-boundary matching, which matches any mention of a symbol name.
 *
 * @param allSymbols - All symbols in the index
 * @param skipTests - If true, exclude symbols from test files (default: true)
 * @param filterReactHooks - If true, skip edges to React stdlib hooks (useState, useEffect, etc.)
 *                           to reduce call graph noise in React codebases.
 */
declare function buildAdjacencyIndex(allSymbols: CodeSymbol[], skipTests?: boolean, filterReactHooks?: boolean): AdjacencyIndex;
/**
 * BFS traversal to build a call chain tree up to the given depth.
 * Uses pre-built adjacency index for O(1) neighbor lookups.
 * Enforces MAX_TREE_NODES and MAX_CHILDREN_PER_NODE limits.
 */
declare function buildCallTree(root: CodeSymbol, adjacency: AdjacencyIndex, direction: Direction, maxDepth: number): CallNode;
/**
 * Strip the `source` field from a CodeSymbol, keeping compact metadata.
 */
declare function stripSource(sym: CodeSymbol): CodeSymbol;
export type OutputFormat = "json" | "mermaid";
export interface TraceOptions {
    depth?: number | undefined;
    include_source?: boolean | undefined;
    include_tests?: boolean | undefined;
    output_format?: OutputFormat | undefined;
    /** Skip edges to React stdlib hooks (useState, useEffect, etc.) to reduce graph noise. */
    filter_react_hooks?: boolean | undefined;
}
/**
 * Trace the call chain for a symbol in a repository.
 * Returns a tree of callers or callees up to the specified depth.
 * By default, source code is stripped from symbols to keep output compact.
 * Test files are excluded by default (use include_tests: true to include them).
 */
export declare function traceCallChain(repo: string, symbolName: string, direction: Direction, depthOrOptions?: number | TraceOptions): Promise<CallNode>;
export type SymbolRole = "entry" | "core" | "utility" | "dead" | "leaf";
export interface SymbolRoleInfo {
    id: string;
    name: string;
    kind: string;
    file: string;
    role: SymbolRole;
    callers: number;
    callees: number;
}
/**
 * Classify every symbol's architectural role based on call graph connectivity.
 *
 * - entry: many callees, few callers (handlers, main, CLI commands)
 * - core: high connectivity both ways (key business logic)
 * - utility: many callers, few callees (helpers, formatters, validators)
 * - dead: zero callers (potentially unused)
 * - leaf: zero callees (terminal functions)
 */
export declare function classifySymbolRoles(repo: string, options?: {
    file_pattern?: string | undefined;
    include_tests?: boolean | undefined;
    top_n?: number | undefined;
}): Promise<SymbolRoleInfo[]>;
declare function classifyRole(callers: number, callees: number): SymbolRole;
export interface CircularDep {
    cycle: string[];
    length: number;
}
export interface CircularDepsResult {
    cycles: CircularDep[];
    total_files: number;
    total_edges: number;
    /** Package-level cycles in JS/TS monorepos. Present when index.workspaces
     *  is non-null (Task 12 of monorepo workspace intelligence plan). */
    package_cycles?: Array<{
        cycle: string[];
        length: number;
    }>;
    /** Workspace dependency targets that don't match any known workspace name.
     *  Surfaced as a diagnostic; never crashes SCC. */
    unresolved_workspace_refs?: Array<{
        from_workspace: string;
        missing_dep: string;
    }>;
}
export declare function findCircularDeps(repo: string, options?: {
    max_cycles?: number;
    file_pattern?: string;
}): Promise<CircularDepsResult>;
export { buildAdjacencyIndex, extractCallSites, buildCallTree, stripSource, isTestFile, classifyRole };
//# sourceMappingURL=graph-tools.d.ts.map