// engine/ide-config/path-resolver.ts — Resolves config file paths per OS (SPEC-080 AC-12)
import { homedir } from 'node:os';
import { join } from 'node:path';
/**
 * Detects the current platform.
 * Extracted to allow test mocking.
 */
export function detectPlatform() {
    const p = process.platform;
    if (p === 'darwin' || p === 'win32' || p === 'linux') {
        return p;
    }
    /* v8 ignore next 1 */
    return 'linux'; // fallback for unknown Unix-like
}
/**
 * Returns the npx command appropriate for the current platform.
 */
export function getNpxCommand(platform) {
    return platform === 'win32' ? 'npx.cmd' : 'npx';
}
/**
 * Resolves `~` in a path to the actual home directory.
 */
export function expandHome(filePath) {
    if (filePath.startsWith('~/') || filePath === '~') {
        return join(homedir(), filePath.slice(2));
    }
    return filePath;
}
/**
 * Resolves the full config file path for an IDE given scope, platform, and project path.
 */
export function resolveConfigPath(ide, scope, platform, projectPath) {
    if (scope === 'global') {
        return expandHome(ide.globalConfigPath[platform]);
    }
    const configRelative = ide.configPath[platform];
    // Some IDEs always use global paths (e.g. windsurf, claude-desktop)
    if (configRelative.startsWith('~/')) {
        return expandHome(configRelative);
    }
    return join(projectPath, configRelative);
}
/**
 * Builds the base MCP server entry for planu.
 */
export function buildServerEntry(platform) {
    return {
        type: 'stdio',
        command: getNpxCommand(platform),
        args: ['-y', '@anthropic/planu-mcp-server'],
    };
}
//# sourceMappingURL=path-resolver.js.map