/**
 * Map an on-PATH `indusk` binary path to the package manager that installed
 * it. Returns null for unknown locations or empty input.
 *
 * pnpm: `~/Library/pnpm/indusk` (macOS), `~/.local/share/pnpm/indusk`
 *   (Linux), `%LOCALAPPDATA%\pnpm\indusk` (Windows). Detection key: the
 *   path contains `/pnpm/` (or `\pnpm\`) as a segment.
 * bun: `~/.bun/bin/indusk`. Detection key: contains `/.bun/`.
 * npm: anything under a `node_modules/.bin` ancestor, or homebrew's
 *   `/opt/homebrew/bin`, or nvm's per-version `bin/` dirs. Default for
 *   everything that didn't match pnpm or bun.
 */
export function detectGlobalManagerFromPath(binaryPath) {
    if (!binaryPath)
        return null;
    const normalized = binaryPath.replace(/\\/g, "/");
    if (/\/pnpm\//.test(normalized))
        return "pnpm";
    if (/\/\.bun\//.test(normalized))
        return "bun";
    return "npm";
}
/**
 * Build the global-install command for a given manager + version. Returned
 * as a single shell-safe string suitable for `execSync` (version is pinned
 * with `@${version}`; the package name is a fixed literal).
 */
export function installCommandFor(manager, version) {
    const pkg = `@infinitedusky/indusk-mcp@${version}`;
    switch (manager) {
        case "pnpm":
            return `pnpm add -g ${pkg}`;
        case "bun":
            return `bun install -g ${pkg}`;
        case "npm":
            return `npm i -g ${pkg}`;
    }
}
/**
 * Human-readable name for error/help messages. Same string the user would
 * type to recover manually.
 */
export function managerLabel(manager) {
    return manager;
}
