routie dev init since i didn't adhere to any proper guidance up until now
This commit is contained in:
+142
@@ -0,0 +1,142 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RooCodeAgent = void 0;
|
||||
const path = __importStar(require("path"));
|
||||
const fs_1 = require("fs");
|
||||
const AgentsMdAgent_1 = require("./AgentsMdAgent");
|
||||
const FileSystemUtils_1 = require("../core/FileSystemUtils");
|
||||
/**
|
||||
* Agent for RooCode that writes to AGENTS.md and generates .roo/mcp.json
|
||||
* with project-level MCP server configuration.
|
||||
*/
|
||||
class RooCodeAgent {
|
||||
constructor() {
|
||||
this.agentsMdAgent = new AgentsMdAgent_1.AgentsMdAgent();
|
||||
}
|
||||
getIdentifier() {
|
||||
return 'roo';
|
||||
}
|
||||
getName() {
|
||||
return 'RooCode';
|
||||
}
|
||||
getDefaultOutputPath(projectRoot) {
|
||||
return {
|
||||
instructions: path.join(projectRoot, 'AGENTS.md'),
|
||||
mcp: path.join(projectRoot, '.roo', 'mcp.json'),
|
||||
};
|
||||
}
|
||||
async applyRulerConfig(concatenatedRules, projectRoot, rulerMcpJson, agentConfig, backup = true) {
|
||||
// First perform idempotent AGENTS.md write via composed AgentsMdAgent
|
||||
await this.agentsMdAgent.applyRulerConfig(concatenatedRules, projectRoot, null, {
|
||||
// Preserve explicit outputPath precedence semantics if provided.
|
||||
outputPath: agentConfig?.outputPath ||
|
||||
agentConfig?.outputPathInstructions ||
|
||||
undefined,
|
||||
}, backup);
|
||||
// Now handle .roo/mcp.json configuration
|
||||
const outputPaths = this.getDefaultOutputPath(projectRoot);
|
||||
const mcpPath = path.resolve(projectRoot, agentConfig?.outputPathConfig ?? outputPaths['mcp']);
|
||||
await (0, FileSystemUtils_1.ensureDirExists)(path.dirname(mcpPath));
|
||||
// Create base structure with mcpServers
|
||||
let finalMcpConfig = {
|
||||
mcpServers: {},
|
||||
};
|
||||
// Try to read existing .roo/mcp.json
|
||||
let existingConfig = {};
|
||||
try {
|
||||
const existingContent = await fs_1.promises.readFile(mcpPath, 'utf-8');
|
||||
const parsed = JSON.parse(existingContent);
|
||||
if (parsed && typeof parsed === 'object') {
|
||||
existingConfig = parsed;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// File doesn't exist or invalid JSON - start fresh
|
||||
existingConfig = {};
|
||||
}
|
||||
// Merge MCP servers if we have ruler config
|
||||
if (rulerMcpJson?.mcpServers) {
|
||||
const existingServers = existingConfig.mcpServers || {};
|
||||
const newServers = rulerMcpJson.mcpServers;
|
||||
// Shallow merge: new servers override existing with same name
|
||||
finalMcpConfig = {
|
||||
mcpServers: {
|
||||
...existingServers,
|
||||
...newServers,
|
||||
},
|
||||
};
|
||||
}
|
||||
else if (existingConfig.mcpServers) {
|
||||
// Keep existing servers if no new ones to add
|
||||
finalMcpConfig = {
|
||||
mcpServers: existingConfig.mcpServers,
|
||||
};
|
||||
}
|
||||
// If neither condition is met, finalMcpConfig remains { mcpServers: {} }
|
||||
// Write the config file with pretty JSON (2 spaces)
|
||||
const newContent = JSON.stringify(finalMcpConfig, null, 2);
|
||||
// Check if content has changed for idempotency
|
||||
let existingContent = null;
|
||||
try {
|
||||
existingContent = await fs_1.promises.readFile(mcpPath, 'utf8');
|
||||
}
|
||||
catch {
|
||||
existingContent = null;
|
||||
}
|
||||
if (existingContent !== null && existingContent === newContent) {
|
||||
// No change; skip backup/write for idempotency
|
||||
return;
|
||||
}
|
||||
// Backup (only if file existed and backup is enabled) then write new content
|
||||
if (backup) {
|
||||
await (0, FileSystemUtils_1.backupFile)(mcpPath);
|
||||
}
|
||||
await (0, FileSystemUtils_1.writeGeneratedFile)(mcpPath, newContent);
|
||||
}
|
||||
supportsMcpStdio() {
|
||||
return true;
|
||||
}
|
||||
supportsMcpRemote() {
|
||||
return true;
|
||||
}
|
||||
getMcpServerKey() {
|
||||
return 'mcpServers';
|
||||
}
|
||||
supportsNativeSkills() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.RooCodeAgent = RooCodeAgent;
|
||||
Reference in New Issue
Block a user