import {
  executeCodebaseSearch
} from "./chunk-S4IHNTCC.js";
import {
  CODEBASE_SEARCH_DESCRIPTION
} from "./chunk-YQMPVJ2L.js";

// tools/codebase_search/vercel.ts
import { tool } from "ai";
import { z } from "zod";
function createCodebaseSearchTool(config) {
  const schema = z.object({
    query: z.string().describe('A complete question about what you want to understand. Ask as if talking to a colleague: "How does X work?", "What happens when Y?", "Where is Z handled?"'),
    target_directories: z.array(z.string()).describe("Prefix directory paths to limit search scope (single directory only, no glob patterns). Use [] to search entire repo."),
    explanation: z.string().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal."),
    limit: z.number().optional().describe("Max results to return (default: 10)")
  });
  return tool({
    description: CODEBASE_SEARCH_DESCRIPTION,
    inputSchema: schema,
    execute: async (params) => {
      const { query, target_directories, explanation, limit } = params;
      const result = await executeCodebaseSearch(
        { query, target_directories, explanation, limit },
        config
      );
      if (!result.success) {
        return {
          error: result.error,
          results: []
        };
      }
      return {
        found: result.results.length,
        searchTime: `${result.stats.searchTimeMs}ms`,
        results: result.results.map((r) => ({
          file: r.filepath,
          symbol: r.symbolPath,
          lines: `${r.startLine}-${r.endLine}`,
          language: r.language,
          relevance: `${(r.rerankScore * 100).toFixed(1)}%`,
          code: r.content
        }))
      };
    }
  });
}
function getSystemPrompt() {
  return CODEBASE_SEARCH_DESCRIPTION;
}
var vercel_default = { createCodebaseSearchTool, getSystemPrompt };

export {
  createCodebaseSearchTool,
  getSystemPrompt,
  vercel_default
};
//# sourceMappingURL=chunk-PPXY4ZCE.js.map