specify whether to create mcp config and filename
This commit is contained in:
@@ -111,12 +111,14 @@ export async function rulesDirect(args, log, context = {}) {
|
|||||||
const rulesDir = profile.rulesDir;
|
const rulesDir = profile.rulesDir;
|
||||||
const brandRulesDir = path.join(projectRoot, rulesDir);
|
const brandRulesDir = path.join(projectRoot, rulesDir);
|
||||||
const brandDir = profile.brandDir;
|
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
|
// Check what was created
|
||||||
const mcpConfigCreated = fs.existsSync(mcpPath);
|
const mcpConfigCreated = mcpConfig ? fs.existsSync(mcpPath) : undefined;
|
||||||
const rulesDirCreated = fs.existsSync(brandRulesDir);
|
const rulesDirCreated = fs.existsSync(brandRulesDir);
|
||||||
const brandFolderCreated = fs.existsSync(brandDir);
|
const brandFolderCreated = fs.existsSync(path.join(projectRoot, brandDir));
|
||||||
|
|
||||||
const error =
|
const error =
|
||||||
failed > 0 ? `${failed} rule files failed to convert.` : null;
|
failed > 0 ? `${failed} rule files failed to convert.` : null;
|
||||||
@@ -127,7 +129,7 @@ export async function rulesDirect(args, log, context = {}) {
|
|||||||
brandFolderCreated,
|
brandFolderCreated,
|
||||||
skipped: false,
|
skipped: false,
|
||||||
error,
|
error,
|
||||||
success: mcpConfigCreated && rulesDirCreated && success > 0 && !error
|
success: (mcpConfig ? mcpConfigCreated : true) && rulesDirCreated && success > 0 && !error
|
||||||
};
|
};
|
||||||
addResults.push(resultObj);
|
addResults.push(resultObj);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ function convertRuleToBrandRule(sourcePath, targetPath, profile) {
|
|||||||
* Process all Cursor rules and convert to brand rules
|
* Process all Cursor rules and convert to brand rules
|
||||||
*/
|
*/
|
||||||
function convertAllRulesToBrandRules(projectDir, profile) {
|
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
|
// Use assets/rules as the source of rules instead of .cursor/rules
|
||||||
const cursorRulesDir = path.join(projectDir, 'assets', 'rules');
|
const cursorRulesDir = path.join(projectDir, 'assets', 'rules');
|
||||||
const brandRulesDir = path.join(projectDir, rulesDir);
|
const brandRulesDir = path.join(projectDir, rulesDir);
|
||||||
@@ -207,9 +207,11 @@ function convertAllRulesToBrandRules(projectDir, profile) {
|
|||||||
if (!fs.existsSync(brandRulesDir)) {
|
if (!fs.existsSync(brandRulesDir)) {
|
||||||
fs.mkdirSync(brandRulesDir, { recursive: true });
|
fs.mkdirSync(brandRulesDir, { recursive: true });
|
||||||
log('debug', `Created ${brandName} rules directory: ${brandRulesDir}`);
|
log('debug', `Created ${brandName} rules directory: ${brandRulesDir}`);
|
||||||
// Also create MCP configuration in the brand directory
|
// Also create MCP configuration in the brand directory if enabled
|
||||||
|
if (mcpConfig !== false) {
|
||||||
const brandDir = profile.brandDir;
|
const brandDir = profile.brandDir;
|
||||||
setupMCPConfiguration(path.join(projectDir, brandDir));
|
setupMCPConfiguration(path.join(projectDir, brandDir), mcpConfigName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count successful and failed conversions
|
// Count successful and failed conversions
|
||||||
@@ -258,10 +260,10 @@ function convertAllRulesToBrandRules(projectDir, profile) {
|
|||||||
* @returns {boolean} - True if removal succeeded, false otherwise
|
* @returns {boolean} - True if removal succeeded, false otherwise
|
||||||
*/
|
*/
|
||||||
function removeBrandRules(projectDir, profile) {
|
function removeBrandRules(projectDir, profile) {
|
||||||
const { brandName, rulesDir } = profile;
|
const { brandName, rulesDir, mcpConfig, mcpConfigName } = profile;
|
||||||
const brandDir = profile.brandDir;
|
const brandDir = profile.brandDir;
|
||||||
const brandRulesDir = path.join(projectDir, rulesDir);
|
const brandRulesDir = path.join(projectDir, rulesDir);
|
||||||
const mcpPath = path.join(projectDir, brandDir, 'mcp.json');
|
const mcpPath = path.join(projectDir, brandDir, mcpConfigName);
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
brandName,
|
brandName,
|
||||||
@@ -273,7 +275,7 @@ function removeBrandRules(projectDir, profile) {
|
|||||||
success: false // Overall success for this brand
|
success: false // Overall success for this brand
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fs.existsSync(mcpPath)) {
|
if (mcpConfig !== false && fs.existsSync(mcpPath)) {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(mcpPath);
|
fs.unlinkSync(mcpPath);
|
||||||
result.mcpConfigRemoved = true;
|
result.mcpConfigRemoved = true;
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import path from 'path';
|
|||||||
const brandName = 'Cline';
|
const brandName = 'Cline';
|
||||||
const brandDir = '.clinerules';
|
const brandDir = '.clinerules';
|
||||||
const rulesDir = '.clinerules';
|
const rulesDir = '.clinerules';
|
||||||
|
const mcpConfig = false;
|
||||||
|
const mcpConfigName = undefined;
|
||||||
|
|
||||||
// File name mapping (specific files with naming changes)
|
// File name mapping (specific files with naming changes)
|
||||||
const fileMap = {
|
const fileMap = {
|
||||||
@@ -137,5 +139,7 @@ export {
|
|||||||
brandName,
|
brandName,
|
||||||
brandDir,
|
brandDir,
|
||||||
rulesDir,
|
rulesDir,
|
||||||
getTargetRuleFilename
|
getTargetRuleFilename,
|
||||||
|
mcpConfig,
|
||||||
|
mcpConfigName
|
||||||
};
|
};
|
||||||
@@ -4,6 +4,8 @@ import path from 'path';
|
|||||||
const brandName = 'Cursor';
|
const brandName = 'Cursor';
|
||||||
const brandDir = '.cursor';
|
const brandDir = '.cursor';
|
||||||
const rulesDir = '.cursor/rules';
|
const rulesDir = '.cursor/rules';
|
||||||
|
const mcpConfig = true;
|
||||||
|
const mcpConfigName = 'mcp.json';
|
||||||
|
|
||||||
// File name mapping (specific files with naming changes)
|
// File name mapping (specific files with naming changes)
|
||||||
const fileMap = {
|
const fileMap = {
|
||||||
@@ -83,5 +85,7 @@ export {
|
|||||||
brandName,
|
brandName,
|
||||||
brandDir,
|
brandDir,
|
||||||
rulesDir,
|
rulesDir,
|
||||||
getTargetRuleFilename
|
getTargetRuleFilename,
|
||||||
|
mcpConfig,
|
||||||
|
mcpConfigName
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const __dirname = path.dirname(__filename);
|
|||||||
const brandName = 'Roo';
|
const brandName = 'Roo';
|
||||||
const brandDir = '.roo';
|
const brandDir = '.roo';
|
||||||
const rulesDir = '.roo/rules';
|
const rulesDir = '.roo/rules';
|
||||||
|
const mcpConfig = true;
|
||||||
|
const mcpConfigName = 'mcp.json';
|
||||||
|
|
||||||
// File name mapping (specific files with naming changes)
|
// File name mapping (specific files with naming changes)
|
||||||
const fileMap = {
|
const fileMap = {
|
||||||
@@ -240,5 +242,7 @@ export {
|
|||||||
brandDir,
|
brandDir,
|
||||||
rulesDir,
|
rulesDir,
|
||||||
getTargetRuleFilename,
|
getTargetRuleFilename,
|
||||||
|
mcpConfig,
|
||||||
|
mcpConfigName,
|
||||||
onPostConvertBrandRules
|
onPostConvertBrandRules
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import path from 'path';
|
|||||||
const brandName = 'Windsurf';
|
const brandName = 'Windsurf';
|
||||||
const brandDir = '.windsurf';
|
const brandDir = '.windsurf';
|
||||||
const rulesDir = '.windsurf/rules';
|
const rulesDir = '.windsurf/rules';
|
||||||
|
const mcpConfig = true;
|
||||||
|
const mcpConfigName = 'mcp.json';
|
||||||
|
|
||||||
// File name mapping (specific files with naming changes)
|
// File name mapping (specific files with naming changes)
|
||||||
const fileMap = {
|
const fileMap = {
|
||||||
@@ -133,5 +135,7 @@ export {
|
|||||||
brandName,
|
brandName,
|
||||||
brandDir,
|
brandDir,
|
||||||
rulesDir,
|
rulesDir,
|
||||||
getTargetRuleFilename
|
getTargetRuleFilename,
|
||||||
|
mcpConfig,
|
||||||
|
mcpConfigName
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user