"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = register;
const zod_1 = require("zod");
const defaults_1 = require("../../../lib/defaults");
function register(server, mgr) {
    server.registerTool('files_search', {
        description: 'Semantic search over all indexed project files by file path. ' +
            'Finds the most relevant files by matching query against file path embeddings using vector similarity. ' +
            'Searches file nodes only (not directories). ' +
            'Returns an array sorted by relevance score (0–1), each with: ' +
            'filePath, fileName, extension, language, size, score. ' +
            'Use this to discover which project files are relevant to a topic.',
        inputSchema: {
            query: zod_1.z.string().max(defaults_1.MAX_SEARCH_QUERY_LEN).describe('Natural language or path search query, e.g. "database config" or "test helpers"'),
            limit: zod_1.z.number().min(1).max(500).optional()
                .describe('Maximum number of results to return (default 10)'),
            minScore: zod_1.z.number().min(0).max(1).optional()
                .describe('Minimum relevance score 0–1 (default 0.3)'),
        },
    }, async ({ query, limit = defaults_1.FILE_SEARCH_TOP_K, minScore = defaults_1.SEARCH_MIN_SCORE_FILES }) => {
        const results = await mgr.search(query, { topK: limit, minScore });
        const clean = (_k, v) => (v === null ? undefined : v);
        return { content: [{ type: 'text', text: JSON.stringify(results, clean, 2) }] };
    });
}
