fix formatting

This commit is contained in:
Joe Danziger
2025-05-26 19:07:27 -04:00
parent 9db5f78da3
commit d20d146ec0
5 changed files with 61 additions and 46 deletions

View File

@@ -19,8 +19,7 @@ import { RULES_PROFILES } from '../../../src/constants/profiles.js';
export function registerRulesTool(server) { export function registerRulesTool(server) {
server.addTool({ server.addTool({
name: 'rules', name: 'rules',
description: description: 'Add or remove rules profiles from the project.',
'Add or remove rules profiles from the project.',
parameters: z.object({ parameters: z.object({
action: z action: z
.enum(['add', 'remove']) .enum(['add', 'remove'])

View File

@@ -203,7 +203,9 @@ export function convertRuleToProfileRule(sourcePath, targetPath, profile) {
* Convert all Cursor rules to profile rules for a specific profile * Convert all Cursor rules to profile rules for a specific profile
*/ */
export function convertAllRulesToProfileRules(projectDir, profile) { export function convertAllRulesToProfileRules(projectDir, profile) {
const sourceDir = fileURLToPath(new URL('../../assets/rules', import.meta.url)); const sourceDir = fileURLToPath(
new URL('../../assets/rules', import.meta.url)
);
const targetDir = path.join(projectDir, profile.rulesDir); const targetDir = path.join(projectDir, profile.rulesDir);
// Ensure target directory exists // Ensure target directory exists
@@ -213,10 +215,7 @@ export function convertAllRulesToProfileRules(projectDir, profile) {
// Setup MCP configuration if enabled // Setup MCP configuration if enabled
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
setupMCPConfiguration( setupMCPConfiguration(projectDir, profile.mcpConfigPath);
projectDir,
profile.mcpConfigPath
);
} }
let success = 0; let success = 0;
@@ -231,7 +230,10 @@ export function convertAllRulesToProfileRules(projectDir, profile) {
// Check if source file exists // Check if source file exists
if (!fs.existsSync(sourcePath)) { if (!fs.existsSync(sourcePath)) {
log('warn', `[Rule Transformer] Source file not found: ${sourceFile}, skipping`); log(
'warn',
`[Rule Transformer] Source file not found: ${sourceFile}, skipping`
);
continue; continue;
} }

View File

@@ -31,7 +31,8 @@ describe('MCP Configuration Validation', () => {
} }
}; };
Object.entries(expectedMcpConfigurations).forEach(([profileName, expected]) => { Object.entries(expectedMcpConfigurations).forEach(
([profileName, expected]) => {
test(`should have correct MCP configuration for ${profileName} profile`, () => { test(`should have correct MCP configuration for ${profileName} profile`, () => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
expect(profile).toBeDefined(); expect(profile).toBeDefined();
@@ -40,15 +41,19 @@ describe('MCP Configuration Validation', () => {
expect(profile.mcpConfigName).toBe(expected.expectedConfigName); expect(profile.mcpConfigName).toBe(expected.expectedConfigName);
expect(profile.mcpConfigPath).toBe(expected.expectedPath); expect(profile.mcpConfigPath).toBe(expected.expectedPath);
}); });
}); }
);
}); });
describe('MCP Configuration Path Consistency', () => { describe('MCP Configuration Path Consistency', () => {
test('should ensure all profiles have consistent mcpConfigPath construction', () => { test('should ensure all profiles have consistent mcpConfigPath construction', () => {
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
const expectedPath = path.join(profile.profileDir, profile.mcpConfigName); const expectedPath = path.join(
profile.profileDir,
profile.mcpConfigName
);
expect(profile.mcpConfigPath).toBe(expectedPath); expect(profile.mcpConfigPath).toBe(expectedPath);
} }
}); });
@@ -56,7 +61,7 @@ describe('MCP Configuration Validation', () => {
test('should ensure no two profiles have the same MCP config path', () => { test('should ensure no two profiles have the same MCP config path', () => {
const mcpPaths = new Set(); const mcpPaths = new Set();
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
expect(mcpPaths.has(profile.mcpConfigPath)).toBe(false); expect(mcpPaths.has(profile.mcpConfigPath)).toBe(false);
@@ -66,7 +71,7 @@ describe('MCP Configuration Validation', () => {
}); });
test('should ensure all MCP-enabled profiles use proper directory structure', () => { test('should ensure all MCP-enabled profiles use proper directory structure', () => {
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
expect(profile.mcpConfigPath).toMatch(/^\.[\w-]+\/[\w_.]+$/); expect(profile.mcpConfigPath).toMatch(/^\.[\w-]+\/[\w_.]+$/);
@@ -75,7 +80,7 @@ describe('MCP Configuration Validation', () => {
}); });
test('should ensure all profiles have required MCP properties', () => { test('should ensure all profiles have required MCP properties', () => {
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
expect(profile).toHaveProperty('mcpConfig'); expect(profile).toHaveProperty('mcpConfig');
expect(profile).toHaveProperty('profileDir'); expect(profile).toHaveProperty('profileDir');
@@ -88,7 +93,7 @@ describe('MCP Configuration Validation', () => {
describe('MCP Configuration File Names', () => { describe('MCP Configuration File Names', () => {
test('should use standard mcp.json for MCP-enabled profiles', () => { test('should use standard mcp.json for MCP-enabled profiles', () => {
const standardMcpProfiles = ['cursor', 'windsurf', 'roo']; const standardMcpProfiles = ['cursor', 'windsurf', 'roo'];
standardMcpProfiles.forEach(profileName => { standardMcpProfiles.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
expect(profile.mcpConfigName).toBe('mcp.json'); expect(profile.mcpConfigName).toBe('mcp.json');
}); });
@@ -103,7 +108,7 @@ describe('MCP Configuration Validation', () => {
describe('Profile Directory Structure', () => { describe('Profile Directory Structure', () => {
test('should ensure each profile has a unique directory', () => { test('should ensure each profile has a unique directory', () => {
const profileDirs = new Set(); const profileDirs = new Set();
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
expect(profileDirs.has(profile.profileDir)).toBe(false); expect(profileDirs.has(profile.profileDir)).toBe(false);
profileDirs.add(profile.profileDir); profileDirs.add(profile.profileDir);
@@ -111,7 +116,7 @@ describe('MCP Configuration Validation', () => {
}); });
test('should ensure profile directories follow expected naming convention', () => { test('should ensure profile directories follow expected naming convention', () => {
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
expect(profile.profileDir).toMatch(/^\.[\w-]+$/); expect(profile.profileDir).toMatch(/^\.[\w-]+$/);
}); });
@@ -120,7 +125,7 @@ describe('MCP Configuration Validation', () => {
describe('MCP Configuration Creation Logic', () => { describe('MCP Configuration Creation Logic', () => {
test('should indicate which profiles require MCP configuration creation', () => { test('should indicate which profiles require MCP configuration creation', () => {
const mcpEnabledProfiles = RULES_PROFILES.filter(profileName => { const mcpEnabledProfiles = RULES_PROFILES.filter((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
return profile.mcpConfig !== false; return profile.mcpConfig !== false;
}); });
@@ -132,7 +137,7 @@ describe('MCP Configuration Validation', () => {
}); });
test('should provide all necessary information for MCP config creation', () => { test('should provide all necessary information for MCP config creation', () => {
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
expect(profile.mcpConfigPath).toBeDefined(); expect(profile.mcpConfigPath).toBeDefined();
@@ -147,7 +152,7 @@ describe('MCP Configuration Validation', () => {
test('should verify that rule transformer functions use mcpConfigPath correctly', () => { test('should verify that rule transformer functions use mcpConfigPath correctly', () => {
// This test verifies that the mcpConfigPath property exists and is properly formatted // This test verifies that the mcpConfigPath property exists and is properly formatted
// for use with the setupMCPConfiguration function // for use with the setupMCPConfiguration function
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
// Verify the path is properly formatted for path.join usage // Verify the path is properly formatted for path.join usage
@@ -162,7 +167,7 @@ describe('MCP Configuration Validation', () => {
}); });
test('should verify that mcpConfigPath is properly constructed for path.join usage', () => { test('should verify that mcpConfigPath is properly constructed for path.join usage', () => {
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
// Test that path.join works correctly with the mcpConfigPath // Test that path.join works correctly with the mcpConfigPath
@@ -181,7 +186,7 @@ describe('MCP Configuration Validation', () => {
describe('MCP Configuration Function Integration', () => { describe('MCP Configuration Function Integration', () => {
test('should verify that setupMCPConfiguration receives the correct mcpConfigPath parameter', () => { test('should verify that setupMCPConfiguration receives the correct mcpConfigPath parameter', () => {
// This test verifies the integration between rule transformer and mcp-utils // This test verifies the integration between rule transformer and mcp-utils
RULES_PROFILES.forEach(profileName => { RULES_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName); const profile = getRulesProfile(profileName);
if (profile.mcpConfig !== false) { if (profile.mcpConfig !== false) {
// Verify that the mcpConfigPath can be used directly with setupMCPConfiguration // Verify that the mcpConfigPath can be used directly with setupMCPConfiguration

View File

@@ -13,7 +13,7 @@ describe('Rule Transformer - General', () => {
// Verify expected profiles are present // Verify expected profiles are present
const expectedProfiles = ['cline', 'cursor', 'roo', 'windsurf']; const expectedProfiles = ['cline', 'cursor', 'roo', 'windsurf'];
expectedProfiles.forEach(profile => { expectedProfiles.forEach((profile) => {
expect(RULES_PROFILES).toContain(profile); expect(RULES_PROFILES).toContain(profile);
}); });
}); });
@@ -82,7 +82,12 @@ describe('Rule Transformer - General', () => {
}); });
it('should have valid fileMap with required files for each profile', () => { it('should have valid fileMap with required files for each profile', () => {
const expectedFiles = ['cursor_rules.mdc', 'dev_workflow.mdc', 'self_improve.mdc', 'taskmaster.mdc']; const expectedFiles = [
'cursor_rules.mdc',
'dev_workflow.mdc',
'self_improve.mdc',
'taskmaster.mdc'
];
RULES_PROFILES.forEach((profile) => { RULES_PROFILES.forEach((profile) => {
const profileConfig = getRulesProfile(profile); const profileConfig = getRulesProfile(profile);
@@ -97,7 +102,7 @@ describe('Rule Transformer - General', () => {
expect(fileMapKeys.length).toBeGreaterThan(0); expect(fileMapKeys.length).toBeGreaterThan(0);
// Check that all expected source files are defined in fileMap // Check that all expected source files are defined in fileMap
expectedFiles.forEach(expectedFile => { expectedFiles.forEach((expectedFile) => {
expect(fileMapKeys).toContain(expectedFile); expect(fileMapKeys).toContain(expectedFile);
expect(typeof profileConfig.fileMap[expectedFile]).toBe('string'); expect(typeof profileConfig.fileMap[expectedFile]).toBe('string');
expect(profileConfig.fileMap[expectedFile].length).toBeGreaterThan(0); expect(profileConfig.fileMap[expectedFile].length).toBeGreaterThan(0);
@@ -171,12 +176,16 @@ describe('Rule Transformer - General', () => {
// The mcpConfigPath should start with the profileDir // The mcpConfigPath should start with the profileDir
expect(profileConfig.mcpConfigPath).toMatch( expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(`^${profileConfig.profileDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`) new RegExp(
`^${profileConfig.profileDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`
)
); );
// The mcpConfigPath should end with the mcpConfigName // The mcpConfigPath should end with the mcpConfigName
expect(profileConfig.mcpConfigPath).toMatch( expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(`${profileConfig.mcpConfigName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`) new RegExp(
`${profileConfig.mcpConfigName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`
)
); );
}); });
}); });