import { applyCliInstructions, scanAgentInstructions, } from "./agent_instructions_scan.js";
import { offerInstall, scanForMcpConfigs } from "./mcp_config_scan.js";
function envPort(name) {
    const value = process.env[name];
    return value && /^\d+$/.test(value) ? parseInt(value, 10) : undefined;
}
export async function configureMcpServers(options) {
    const devPort = envPort("NEOTOMA_SESSION_DEV_PORT");
    const prodPort = envPort("NEOTOMA_SESSION_PROD_PORT");
    const { configs, repoRoot } = await scanForMcpConfigs(options.cwd, {
        includeUserLevel: options.includeUserLevel ?? true,
        userLevelFirst: false,
        devPort,
        prodPort,
        neotomaRepoRoot: options.repoRoot,
    });
    const result = await offerInstall(configs, repoRoot, {
        cwd: options.cwd,
        devPort,
        prodPort,
        autoInstallScope: options.autoInstallScope,
        autoInstallEnv: options.autoInstallEnv,
        mcpTransport: options.mcpTransport,
        assumeYes: options.assumeYes,
        rewriteExistingNeotoma: options.rewriteExistingNeotoma,
        silent: options.silent,
        boxAlreadyShown: options.boxAlreadyShown,
        skipProjectSync: options.skipProjectSync,
    });
    return { ...result, repoRoot };
}
export async function configureCliInstructions(options) {
    const scan = await scanAgentInstructions(options.cwd, {
        includeUserLevel: options.includeUserLevel ?? true,
    });
    const result = await applyCliInstructions(scan, {
        scope: options.scope,
        env: options.env,
    });
    return { ...result, projectRoot: scan.projectRoot };
}
//# sourceMappingURL=harness_configure.js.map