UNPKG

rulesync

Version:

Unified AI rules management CLI tool that generates configuration files for various AI development tools

79 lines (76 loc) 2.29 kB
import { shouldIncludeServer } from "./chunk-VI6SBYFB.js"; // src/generators/mcp/roo.ts function generateRooMcp(config) { const rooConfig = { mcpServers: {} }; for (const [serverName, server] of Object.entries(config.mcpServers)) { if (!shouldIncludeServer(server, "roo")) continue; const rooServer = {}; if (server.command) { rooServer.command = server.command; if (server.args) rooServer.args = server.args; } else if (server.url || server.httpUrl) { const url = server.httpUrl || server.url; if (url) { rooServer.url = url; } if (server.httpUrl || server.transport === "http") { rooServer.type = "streamable-http"; } else if (server.transport === "sse" || server.type === "sse") { rooServer.type = "sse"; } } if (server.env) { rooServer.env = {}; for (const [key, value] of Object.entries(server.env)) { if (value.startsWith("${env:") && value.endsWith("}")) { rooServer.env[key] = value; } else { rooServer.env[key] = `\${env:${value}}`; } } } if (server.disabled !== void 0) { rooServer.disabled = server.disabled; } if (server.alwaysAllow) { rooServer.alwaysAllow = server.alwaysAllow; } if (server.networkTimeout !== void 0) { rooServer.networkTimeout = Math.max(3e4, Math.min(3e5, server.networkTimeout)); } rooConfig.mcpServers[serverName] = rooServer; } return JSON.stringify(rooConfig, null, 2); } function generateRooMcpConfiguration(mcpServers, baseDir = "") { const filepath = baseDir ? `${baseDir}/.roo/mcp.json` : ".roo/mcp.json"; const config = { mcpServers: {} }; for (const [serverName, server] of Object.entries(mcpServers)) { if (!shouldIncludeServer(server, "roo")) { continue; } const { targets: _targets, ...serverConfig } = server; const rooServer = { ...serverConfig }; if (serverConfig.httpUrl !== void 0 && serverConfig.url !== void 0) { rooServer.url = serverConfig.httpUrl; } config.mcpServers[serverName] = rooServer; } return [ { filepath, content: `${JSON.stringify(config, null, 2)} ` } ]; } export { generateRooMcp, generateRooMcpConfiguration };