// tools/auto-fix-validation.ts — SPEC-474: Auto-fix validation handler
import { runHealingLoop } from '../engine/self-healing/healer.js';
import { trackCost } from '../engine/cost-tracking/operation-tracker.js';
function formatHealingResult(result) {
    const statusIcon = result.finalStatus === 'healed'
        ? 'HEALED'
        : result.finalStatus === 'partial'
            ? 'PARTIAL'
            : 'STILL_FAILING';
    const lines = [
        `Self-healing result for ${result.specId}: ${statusIcon}`,
        ``,
        `Initial failure: ${result.initialFailure}`,
        ``,
        `Attempts (${result.attempts.length}):`,
        ...result.attempts.map((a) => `  [${a.attempt}] ${a.strategy} → ${a.status.toUpperCase()}: ${a.details}`),
    ];
    if (result.fixedIssues.length > 0) {
        lines.push(``, `Fixed issues:`);
        result.fixedIssues.forEach((issue) => lines.push(`  - ${issue}`));
    }
    if (result.remainingIssues.length > 0) {
        lines.push(``, `Remaining issues:`);
        result.remainingIssues.forEach((issue) => lines.push(`  - ${issue}`));
    }
    return lines.join('\n');
}
export async function handleAutoFixValidation(input) {
    return trackCost(input.projectPath, 'auto_fix_validation', async () => {
        const result = await runHealingLoop(input.specId, input.projectPath, {
            type: input.failureType,
            details: input.failureDetails,
        });
        return {
            content: [{ type: 'text', text: formatHealingResult(result) }],
        };
    }); // end trackCost
}
export async function handleRunHealingLoop(input) {
    const result = await runHealingLoop(input.specId, input.projectPath, {
        type: input.failureType,
        details: input.failureDetails,
    });
    return {
        content: [{ type: 'text', text: formatHealingResult(result) }],
    };
}
//# sourceMappingURL=auto-fix-validation.js.map