// engine/self-healing/strategies/lint-fix.ts — SPEC-474: ESLint auto-fix strategy
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
/**
 * Runs eslint --fix on the project and reports what was fixed.
 */
export async function applyLintFix(projectPath, _details) {
    try {
        await execFileAsync('pnpm', ['eslint', '--fix', 'src/', 'tests/', '--ext', '.ts'], {
            cwd: projectPath,
        });
        return {
            fixed: true,
            reason: 'ESLint --fix applied successfully',
            fixedIssues: ['Auto-fixable lint errors resolved'],
        };
    }
    catch (err) {
        // eslint exits with code 1 when there are unfixable errors — that's not a crash
        const message = err instanceof Error ? err.message : String(err);
        const hasResidualErrors = message.includes('error') || message.includes('warning');
        if (hasResidualErrors) {
            return {
                fixed: false,
                reason: `ESLint --fix ran but residual errors remain: ${message.slice(0, 200)}`,
            };
        }
        return {
            fixed: false,
            reason: `ESLint --fix failed to run: ${message.slice(0, 200)}`,
        };
    }
}
//# sourceMappingURL=lint-fix.js.map