"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mcpHandler = mcpHandler;
exports.showHelp = showHelp;
const child_process_1 = require("child_process");
const package_manager_1 = require("../../utils/package-manager");
const workspace_root_1 = require("../../utils/workspace-root");
async function mcpHandler(args) {
    const packageManagerCommands = (0, package_manager_1.getPackageManagerCommand)();
    (0, child_process_1.spawnSync)(packageManagerCommands.dlx, ['-y', 'nx-mcp@latest', ...args['_']], {
        stdio: 'inherit',
        cwd: workspace_root_1.workspaceRoot,
    });
}
async function showHelp() {
    const packageManagerCommands = (0, package_manager_1.getPackageManagerCommand)();
    const helpOutput = (0, child_process_1.spawnSync)(packageManagerCommands.dlx, ['-y', 'nx-mcp@latest', '--help'], {
        cwd: workspace_root_1.workspaceRoot,
        encoding: 'utf-8',
    });
    console.log(helpOutput.stdout?.toString().replaceAll('nx-mcp', 'nx mcp'));
}
