/**
 * Shared types + helpers for `olam mcp install` and `olam mcp uninstall`.
 *
 * Both subcommands shell out to `claude mcp add`/`claude mcp remove`, take
 * a `--scope` flag with the same enum, and need a `which`-style PATH probe.
 * Living in a sibling file keeps the seam injectable without spreading
 * duplicate helpers across two files.
 */
import { spawnSync } from 'node:child_process';
export const DEFAULT_CLAUDE_SHELL_DEPS = {
    spawn: spawnSync,
    log: (msg) => console.log(msg),
};
export function isOnPath(deps, bin) {
    // Mirror `auth.ts` / `login.ts` win32 handling: `where` is the Windows equivalent of `which`.
    const probe = process.platform === 'win32' ? 'where' : 'which';
    const result = deps.spawn(probe, [bin], {
        encoding: 'utf8',
        stdio: ['ignore', 'pipe', 'ignore'],
    });
    return result.status === 0;
}
export function normaliseScope(raw) {
    const value = (raw ?? 'user').toLowerCase();
    return value === 'user' || value === 'project' || value === 'local' ? value : null;
}
export const REMEDY_CLAUDE_MISSING = '`claude` not found on PATH. Install Claude Code (https://docs.claude.com/claude-code) ' +
    'or paste the JSON snippet from docs/architecture/mcp-as-npx-served.md.';
// Real `claude mcp remove` output verified 2026-05-12 (captured from the
// installed @anthropic-ai/claude-code CLI):
//   --scope user    → "No user-scoped MCP server found with name: <n>"
//   --scope local   → "No project-local MCP server found with name: <n>"
//   --scope project → "No MCP server found with name: <n> in .mcp.json"
//
// Name-agnostic — same pattern matches `olam`, `agentmemory`, or any other
// MCP server name. Shared so `olam mcp uninstall` and `olam memory
// uninstall` stay in lockstep when claude evolves its stderr shape.
export const NOT_INSTALLED_PATTERN = /no\s+(?:\S+\s+)*mcp\s+server\s+found/i;
export function looksLikeNotInstalled(text) {
    return NOT_INSTALLED_PATTERN.test(text);
}
//# sourceMappingURL=install-shared.js.map