/** * search_code Tool * * Primary semantic search MCP tool for code. Takes a natural language query, * converts it to an embedding vector, and searches the LanceDB index for * similar code chunks. Returns ranked results with file paths, content, * and line numbers. * * Features: * - Natural language code search * - Configurable result count (top_k) * - Normalized similarity scores (0.0 - 1.0) * - Search timing information */ import { z } from 'zod'; import { type CompactSearchOutput } from '../utils/searchResultProcessing.js'; import type { StrategyOrchestrator } from '../engines/strategyOrchestrator.js'; import { type SearchMode } from '../engines/hybridSearch.js'; /** * Input schema for search_code tool * * Validates the query string and optional top_k parameter. * SMCP-061: Added mode and alpha parameters for hybrid search. */ export declare const SearchCodeInputSchema: z.ZodObject<{ query: z.ZodString; top_k: z.ZodDefault; compact: z.ZodDefault; mode: z.ZodOptional>; alpha: z.ZodOptional; }, z.core.$strip>; /** * Inferred input type from schema */ export type SearchCodeInput = z.infer; /** * Single search result in the output */ export interface SearchCodeResult { /** Relative file path (forward-slash separated) */ path: string; /** Chunk content text */ text: string; /** Similarity score (0.0 - 1.0, higher is more similar) */ score: number; /** Start line in source file (1-indexed) */ startLine: number; /** End line in source file (1-indexed) */ endLine: number; } /** * Output structure for search_code tool */ export interface SearchCodeOutput { /** Array of search results sorted by relevance */ results: SearchCodeResult[]; /** Total number of results returned */ totalResults: number; /** Time taken for search in milliseconds */ searchTimeMs: number; /** Warning message if index is in an incomplete state (MCP-15) */ warning?: string; /** Search mode used (SMCP-061) */ searchMode?: SearchMode; } /** * Tool context containing the project path */ export interface ToolContext { /** Absolute path to the project root */ projectPath: string; /** Optional strategy orchestrator for flushing pending changes before search */ orchestrator?: StrategyOrchestrator; } /** * Execute semantic search on the code index * * Searches the LanceDB index for code chunks that are semantically similar * to the provided query. The query is converted to an embedding vector * using the same model used for indexing. * * @param input - The search input containing query and optional top_k * @param context - Tool context containing the project path * @returns Search results with timing information * @throws MCPError with INDEX_NOT_FOUND if no index exists for the project * * @example * ```typescript * const results = await searchCode( * { query: 'function that calculates hash', top_k: 10 }, * { projectPath: '/path/to/project' } * ); * * console.log(results.results[0].path); // 'src/utils/hash.ts' * console.log(results.searchTimeMs); // 45 * ``` */ export declare function searchCode(input: SearchCodeInput, context: ToolContext): Promise; /** * MCP tool definition for search_code * * This tool provides semantic search over the code index. * It does NOT require confirmation as it's a read-only operation. * SMCP-061: Added mode and alpha parameters for hybrid search. * * @param enhanced - Whether to include enhanced AI guidance hints in the description */ export declare function createSearchCodeTool(enhanced?: boolean): { name: string; description: string; inputSchema: { type: "object"; properties: { query: { type: string; description: string; }; top_k: { type: string; description: string; default: number; minimum: number; maximum: number; }; compact: { type: string; description: string; default: boolean; }; mode: { type: string; enum: string[]; description: string; }; alpha: { type: string; description: string; minimum: number; maximum: number; }; }; required: string[]; }; requiresConfirmation: boolean; }; /** * Default search_code tool definition (without enhanced hints) * * For backward compatibility. Use createSearchCodeTool(enhanced) for * dynamic description generation. */ export declare const searchCodeTool: { name: string; description: string; inputSchema: { type: "object"; properties: { query: { type: string; description: string; }; top_k: { type: string; description: string; default: number; minimum: number; maximum: number; }; compact: { type: string; description: string; default: boolean; }; mode: { type: string; enum: string[]; description: string; }; alpha: { type: string; description: string; minimum: number; maximum: number; }; }; required: string[]; }; requiresConfirmation: boolean; }; export { SearchCodeInputSchema as SearchNowInputSchema, searchCode as searchNow, searchCodeTool as searchNowTool, }; //# sourceMappingURL=searchCode.d.ts.map