// engine/heal/markers.ts — SPEC-745
// Detects tier-3 markers: `// custom` header and .planu-do-not-heal allowlist.
import { existsSync, readFileSync } from 'node:fs';
import { join, basename } from 'node:path';
/**
 * Returns true if the file's first line contains '// custom' (case-insensitive).
 */
export function hasCustomMarker(filePath) {
    try {
        const content = readFileSync(filePath, 'utf-8');
        const firstLine = content.split('\n')[0] ?? '';
        return firstLine.toLowerCase().includes('// custom');
    }
    catch {
        return false;
    }
}
/**
 * Read the .planu-do-not-heal allowlist from projectRoot/planu/.
 * Returns a Set of relative file names (e.g. 'conventions.json').
 */
export function readDoNotHealList(projectRoot) {
    const allowlistPath = join(projectRoot, 'planu', '.planu-do-not-heal');
    if (!existsSync(allowlistPath)) {
        return new Set();
    }
    try {
        const content = readFileSync(allowlistPath, 'utf-8');
        const names = content
            .split('\n')
            .map((l) => l.trim())
            .filter((l) => l.length > 0 && !l.startsWith('#'));
        return new Set(names);
    }
    catch {
        return new Set();
    }
}
/**
 * Returns true if the file is in the .planu-do-not-heal allowlist.
 */
export function isInAllowlist(filePath, allowlist) {
    return allowlist.has(basename(filePath));
}
//# sourceMappingURL=markers.js.map