import { existsSync, readFileSync } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
const CONFIG_DIR = join(homedir(), ".config", "rpiv-ask-user-question");
const CONFIG_PATH = join(CONFIG_DIR, "config.json");
export function loadConfig() {
    if (!existsSync(CONFIG_PATH))
        return {};
    try {
        const parsed = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
        if (parsed === null || typeof parsed !== "object")
            return {};
        return parsed;
    }
    catch {
        return {};
    }
}
export function validateGuidanceFields(fields) {
    if (!fields || typeof fields !== "object")
        return {};
    const g = fields;
    const result = {};
    if (typeof g.promptSnippet === "string" && g.promptSnippet.length > 0) {
        result.promptSnippet = g.promptSnippet;
    }
    if (Array.isArray(g.promptGuidelines) &&
        g.promptGuidelines.length > 0 &&
        g.promptGuidelines.every((s) => typeof s === "string" && s.length > 0)) {
        result.promptGuidelines = g.promptGuidelines;
    }
    return result;
}
//# sourceMappingURL=config.js.map