// tools/check-spec-accuracy.ts — Handler for the check_spec_accuracy MCP tool
// Validates spec content against the framework registry to detect hallucinated APIs.
import { validateSpecContent, formatReport } from '../engine/registry/core.js';
/**
 * Handle check_spec_accuracy tool invocations.
 * Accepts spec text and optional framework list, returns a Markdown accuracy report.
 */
export async function handleCheckSpecAccuracy(args) {
    const { specContent, frameworks } = args;
    const report = await validateSpecContent(specContent, frameworks);
    const markdown = formatReport(report);
    const summaryLines = [
        `**Score:** ${report.score}/100`,
        `**Problemas encontrados:** ${report.issues.length}`,
        `**Frameworks detectados:** ${report.frameworksDetected.join(', ') || 'ninguno'}`,
    ];
    if (report.frameworksNotInRegistry.length > 0) {
        summaryLines.push(`**Frameworks sin datos en registry:** ${report.frameworksNotInRegistry.join(', ')}`);
    }
    if (report.staleRegistryEntries.length > 0) {
        summaryLines.push(`**Entradas desactualizadas (>180 dias):** ${report.staleRegistryEntries.join(', ')}`);
    }
    const output = ['# check_spec_accuracy', '', ...summaryLines, '', markdown].join('\n');
    return {
        content: [{ type: 'text', text: output }],
    };
}
//# sourceMappingURL=check-spec-accuracy.js.map