// tools/ide-config-handler.ts — Tool handler for generate_ide_config (SPEC-080 AC-10)
import { handleGenerateIdeConfig } from '../engine/ide-config/index.js';
/**
 * Format the result of IDE config generation for MCP tool output.
 */
function formatResult(result) {
    const lines = [];
    if (result.dryRun) {
        lines.push('=== DRY RUN — No files written ===\n');
    }
    if (result.results.length === 0) {
        lines.push('No IDEs targeted for configuration.');
        if (result.detectedIdes.length === 0) {
            lines.push('No IDEs were detected on this system.');
            lines.push('Specify an IDE explicitly: ide = "vscode" | "cursor" | "windsurf" | etc.');
        }
    }
    for (const r of result.results) {
        lines.push(`## ${r.ide.toUpperCase()}`);
        lines.push(`File: ${r.filePath}`);
        if (r.merged) {
            lines.push('(Merged with existing configuration)');
        }
        lines.push('');
        lines.push('```');
        lines.push(r.content);
        lines.push('```');
        lines.push('');
        lines.push(r.instructions);
        if (r.validationErrors.length > 0) {
            lines.push('\nValidation warnings:');
            for (const err of r.validationErrors) {
                lines.push(`  - ${err.message}: ${err.suggestion}`);
            }
        }
        lines.push('');
    }
    if (result.detectedIdes.length > 0) {
        lines.push('### Detected IDEs:');
        for (const d of result.detectedIdes) {
            const icon = d.detected ? '+' : '-';
            lines.push(`  ${icon} ${d.ide} (${d.confidence}): ${d.details}`);
        }
    }
    return {
        content: [{ type: 'text', text: lines.join('\n') }],
    };
}
/**
 * Handle the generate_ide_config MCP tool invocation.
 */
export function handleIdeConfig(args) {
    const result = handleGenerateIdeConfig(args);
    return formatResult(result);
}
//# sourceMappingURL=ide-config-handler.js.map