import fs from 'node:fs/promises';
import path from 'node:path';
import { writeJsonAtomic } from '../fsx.js';
const CACHE_RELATIVE_PATH = '.sneakoscope/reports/codex-native-feature-matrix.json';
export function codexNativeCapabilityCachePath(root) {
    return path.join(root, CACHE_RELATIVE_PATH);
}
export async function readCodexNativeCapabilityCache(root) {
    const file = codexNativeCapabilityCachePath(root);
    const text = await fs.readFile(file, 'utf8').catch(() => null);
    if (!text)
        return null;
    const parsed = JSON.parse(text);
    return parsed?.schema === 'sks.codex-native-feature-matrix.v1' ? parsed : null;
}
export async function writeCodexNativeCapabilityCache(root, matrix) {
    const file = codexNativeCapabilityCachePath(root);
    await writeJsonAtomic(file, matrix);
    return file;
}
//# sourceMappingURL=codex-native-capability-cache.js.map