specify whether to create mcp config and filename

This commit is contained in:
Joe Danziger
2025-05-21 12:43:05 -04:00
parent 9eacd6e061
commit c12cff1890
6 changed files with 35 additions and 15 deletions

View File

@@ -111,12 +111,14 @@ export async function rulesDirect(args, log, context = {}) {
const rulesDir = profile.rulesDir;
const brandRulesDir = path.join(projectRoot, rulesDir);
const brandDir = profile.brandDir;
const mcpPath = path.join(projectRoot, brandDir, 'mcp.json');
const mcpConfig = profile.mcpConfig !== false;
const mcpConfigName = profile.mcpConfigName || 'mcp.json';
const mcpPath = path.join(projectRoot, brandDir, mcpConfigName);
// Check what was created
const mcpConfigCreated = fs.existsSync(mcpPath);
const mcpConfigCreated = mcpConfig ? fs.existsSync(mcpPath) : undefined;
const rulesDirCreated = fs.existsSync(brandRulesDir);
const brandFolderCreated = fs.existsSync(brandDir);
const brandFolderCreated = fs.existsSync(path.join(projectRoot, brandDir));
const error =
failed > 0 ? `${failed} rule files failed to convert.` : null;
@@ -127,7 +129,7 @@ export async function rulesDirect(args, log, context = {}) {
brandFolderCreated,
skipped: false,
error,
success: mcpConfigCreated && rulesDirCreated && success > 0 && !error
success: (mcpConfig ? mcpConfigCreated : true) && rulesDirCreated && success > 0 && !error
};
addResults.push(resultObj);
}

View File

@@ -193,7 +193,7 @@ function convertRuleToBrandRule(sourcePath, targetPath, profile) {
* Process all Cursor rules and convert to brand rules
*/
function convertAllRulesToBrandRules(projectDir, profile) {
const { fileMap, brandName, rulesDir } = profile;
const { fileMap, brandName, rulesDir, mcpConfig, mcpConfigName } = profile;
// Use assets/rules as the source of rules instead of .cursor/rules
const cursorRulesDir = path.join(projectDir, 'assets', 'rules');
const brandRulesDir = path.join(projectDir, rulesDir);
@@ -207,9 +207,11 @@ function convertAllRulesToBrandRules(projectDir, profile) {
if (!fs.existsSync(brandRulesDir)) {
fs.mkdirSync(brandRulesDir, { recursive: true });
log('debug', `Created ${brandName} rules directory: ${brandRulesDir}`);
// Also create MCP configuration in the brand directory
const brandDir = profile.brandDir;
setupMCPConfiguration(path.join(projectDir, brandDir));
// Also create MCP configuration in the brand directory if enabled
if (mcpConfig !== false) {
const brandDir = profile.brandDir;
setupMCPConfiguration(path.join(projectDir, brandDir), mcpConfigName);
}
}
// Count successful and failed conversions
@@ -258,10 +260,10 @@ function convertAllRulesToBrandRules(projectDir, profile) {
* @returns {boolean} - True if removal succeeded, false otherwise
*/
function removeBrandRules(projectDir, profile) {
const { brandName, rulesDir } = profile;
const { brandName, rulesDir, mcpConfig, mcpConfigName } = profile;
const brandDir = profile.brandDir;
const brandRulesDir = path.join(projectDir, rulesDir);
const mcpPath = path.join(projectDir, brandDir, 'mcp.json');
const mcpPath = path.join(projectDir, brandDir, mcpConfigName);
const result = {
brandName,
@@ -273,7 +275,7 @@ function removeBrandRules(projectDir, profile) {
success: false // Overall success for this brand
};
if (fs.existsSync(mcpPath)) {
if (mcpConfig !== false && fs.existsSync(mcpPath)) {
try {
fs.unlinkSync(mcpPath);
result.mcpConfigRemoved = true;

View File

@@ -4,6 +4,8 @@ import path from 'path';
const brandName = 'Cline';
const brandDir = '.clinerules';
const rulesDir = '.clinerules';
const mcpConfig = false;
const mcpConfigName = undefined;
// File name mapping (specific files with naming changes)
const fileMap = {
@@ -137,5 +139,7 @@ export {
brandName,
brandDir,
rulesDir,
getTargetRuleFilename
};
getTargetRuleFilename,
mcpConfig,
mcpConfigName
};

View File

@@ -4,6 +4,8 @@ import path from 'path';
const brandName = 'Cursor';
const brandDir = '.cursor';
const rulesDir = '.cursor/rules';
const mcpConfig = true;
const mcpConfigName = 'mcp.json';
// File name mapping (specific files with naming changes)
const fileMap = {
@@ -83,5 +85,7 @@ export {
brandName,
brandDir,
rulesDir,
getTargetRuleFilename
getTargetRuleFilename,
mcpConfig,
mcpConfigName
};

View File

@@ -10,6 +10,8 @@ const __dirname = path.dirname(__filename);
const brandName = 'Roo';
const brandDir = '.roo';
const rulesDir = '.roo/rules';
const mcpConfig = true;
const mcpConfigName = 'mcp.json';
// File name mapping (specific files with naming changes)
const fileMap = {
@@ -240,5 +242,7 @@ export {
brandDir,
rulesDir,
getTargetRuleFilename,
mcpConfig,
mcpConfigName,
onPostConvertBrandRules
};

View File

@@ -4,6 +4,8 @@ import path from 'path';
const brandName = 'Windsurf';
const brandDir = '.windsurf';
const rulesDir = '.windsurf/rules';
const mcpConfig = true;
const mcpConfigName = 'mcp.json';
// File name mapping (specific files with naming changes)
const fileMap = {
@@ -133,5 +135,7 @@ export {
brandName,
brandDir,
rulesDir,
getTargetRuleFilename
getTargetRuleFilename,
mcpConfig,
mcpConfigName
};