import { execSync } from "node:child_process";
function commandExists(cmd) {
    try {
        execSync(`which ${cmd}`, { stdio: "ignore" });
        return true;
    }
    catch {
        return false;
    }
}
let cachedOpenCodeResult = null;
/**
 * Set the cached OpenCode check result.
 * Called once at startup after running checkOpenCodeInstalled().
 */
export function setOpenCodeCheckResult(result) {
    cachedOpenCodeResult = result;
}
/**
 * Reset the cached OpenCode check result (for testing).
 */
export function resetOpenCodeCheckResult() {
    cachedOpenCodeResult = null;
}
export function detectCapabilities() {
    const warnings = [];
    const hasGit = commandExists("git");
    if (!hasGit) {
        warnings.push("missing_git");
    }
    const hasOpenCode = cachedOpenCodeResult?.available ?? false;
    const openCodeVersion = cachedOpenCodeResult?.version;
    if (!hasOpenCode) {
        warnings.push("missing_opencode");
    }
    return { hasGit, hasOpenCode, openCodeVersion, warnings };
}
//# sourceMappingURL=capabilities.js.map