// Planu — Paradigm registry loader (SPEC-035a)
// Reads and caches the paradigm-registry.json config file.
import { readFile } from 'node:fs/promises';
let registryCache = null;
/**
 * Load the paradigm registry from config.
 * Returns an empty registry on any read/parse failure.
 */
export async function loadParadigmRegistry() {
    if (registryCache) {
        return registryCache;
    }
    try {
        const configUrl = new URL('../config/paradigm-registry.json', import.meta.url);
        const raw = await readFile(configUrl, 'utf-8');
        registryCache = JSON.parse(raw);
        return registryCache;
    }
    catch {
        return { paradigms: [] };
    }
}
/**
 * Find a paradigm entry by its id.
 * Returns null if not found.
 */
export async function findParadigmById(id) {
    const registry = await loadParadigmRegistry();
    return registry.paradigms.find((p) => p.id === id) ?? null;
}
/**
 * Get all paradigm entries in the registry.
 */
export async function getAllParadigms() {
    const registry = await loadParadigmRegistry();
    return registry.paradigms;
}
/**
 * Clear the in-memory cache (primarily for testing).
 */
export function clearRegistryCache() {
    registryCache = null;
}
//# sourceMappingURL=paradigm-registry.js.map