/**
 * Unified-diff helper. Pure synchronous function over node:fs + npm `diff`.
 * Does NOT spawn a subprocess to call git or system diff — the output is
 * generated in-process for cross-platform consistency.
 */
import { createTwoFilesPatch } from 'diff';
import * as fs from 'node:fs';
import { toOriginPath } from './origin-file.js';
export function unifiedDiff(currentPath) {
    const originPath = toOriginPath(currentPath);
    if (!fs.existsSync(originPath) || !fs.existsSync(currentPath))
        return '';
    const current = fs.readFileSync(currentPath, 'utf8');
    const origin = fs.readFileSync(originPath, 'utf8');
    // "old" = the user's modified file on disk; "new" = the codegen proposal
    // sitting in .origin. The diff therefore reads as "what would change if I
    // accept the proposal" — additions (+) come from the proposal, deletions
    // (-) come from the user's current state.
    return createTwoFilesPatch(currentPath, originPath, current, origin);
}
