/** * Dependency graph query tool implementation * * Implements the scampi_query_graph MCP tool which queries the cached * dependency graph to find: * - Dependencies: Files that the queried file imports * - Dependents: Files that import the queried file * - Exports: Symbols exported by the queried file */ /** * Options for the queryGraph function */ export interface QueryGraphOptions { /** Type of query to perform */ queryType: "dependents" | "dependencies" | "exports" | "all"; } /** * Result of the queryGraph operation */ export interface QueryGraphResult { /** The queried file path */ file: string; /** Files that import this file (only if queryType is "dependents" or "all") */ dependents?: string[]; /** Files this file imports (only if queryType is "dependencies" or "all") */ dependencies?: string[]; /** What this file exports (only if queryType is "exports" or "all") */ exports?: string[]; /** Error message if the query failed */ error?: string; } /** * Error thrown when graph query fails */ export declare class QueryGraphError extends Error { readonly code: string; constructor(message: string, code: string); } /** * Query the cached dependency graph for a specific file * * This is the main implementation for the scampi_query_graph MCP tool. * It performs the following steps: * * 1. Validate the directory path * 2. Load the cached codebase map * 3. Find the file in the cache * 4. Based on query type, return: * - dependencies: Files this file imports * - dependents: Files that import this file * - exports: Symbols exported by this file * - all: All of the above * * @param directory - Absolute path to the codebase directory * @param file - Relative path to the file to query * @param options - Query options (query type) * @returns Promise resolving to QueryGraphResult * * @example * ```typescript * const result = await queryGraph('/path/to/project', 'src/index.ts', { * queryType: 'all' * }); * console.log('Dependencies:', result.dependencies); * console.log('Dependents:', result.dependents); * console.log('Exports:', result.exports); * ``` * * @example * ```typescript * // Query only dependencies * const result = await queryGraph('/path/to/project', 'src/auth/login.ts', { * queryType: 'dependencies' * }); * ``` */ export declare function queryGraph(directory: string, file: string, options: QueryGraphOptions): Promise; //# sourceMappingURL=query-graph.d.ts.map