/**
 * Load and query the upgrade-guidance map used by the feedback ingest cron
 * and the `process_feedback` triage skill.
 *
 * Each entry maps a set of fix keywords / surface names to a pre-populated
 * `UpgradeGuidance` template. The classifier matches a feedback's title/body
 * against these entries to determine whether the fix has already shipped and,
 * if so, what install/verification instructions to hand back to the agent.
 */
import { readFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
let cached = null;
function resolveMapPath() {
    const envPath = process.env.NEOTOMA_UPGRADE_GUIDANCE_MAP_PATH;
    if (envPath)
        return envPath;
    const here = path.dirname(fileURLToPath(import.meta.url));
    return path.resolve(here, "../../../docs/subsystems/feedback_upgrade_guidance_map.json");
}
export function loadUpgradeGuidanceMap() {
    if (cached)
        return cached;
    const raw = readFileSync(resolveMapPath(), "utf8");
    cached = JSON.parse(raw);
    return cached;
}
export function findUpgradeGuidance(text) {
    const map = loadUpgradeGuidanceMap();
    const needle = text.toLowerCase();
    for (const entry of map.entries) {
        const hit = entry.keywords.some((k) => needle.includes(k.toLowerCase())) ||
            entry.surface_names.some((s) => needle.includes(s.toLowerCase()));
        if (hit)
            return entry;
    }
    return null;
}
//# sourceMappingURL=upgrade_guidance_map.js.map