import fs from 'fs-extra';
import { getPackagePath } from '../lib/paths.js';
const CONFIG_PATH = getPackagePath('config/sources.json');
export async function loadSourcesConfig() {
    const exists = await fs.pathExists(CONFIG_PATH);
    if (!exists) {
        throw new Error(`Missing config at ${CONFIG_PATH}`);
    }
    const raw = await fs.readJson(CONFIG_PATH);
    return {
        skills: normalize(raw.skills ?? []),
        mcps: normalize(raw.mcps ?? [])
    };
}
function normalize(list) {
    return list.map((item) => ({
        ...item,
        file: getPackagePath(item.file),
        priority: Number.isFinite(item.priority) ? item.priority : 0
    }));
}
