Unify and streamline profile system architecture (#853)

* move claude rules and commands to assets/claude

* update claude profile to copy assets/claude to .claude

* fix formatting

* feat(profiles): Implement unified profile system

- Convert Claude and Codex profiles to use createProfile() factory
- Remove simple vs complex profile distinction in rule transformer
- Unify convertAllRulesToProfileRules() to handle all profiles consistently
- Fix mcpConfigPath construction in base-profile.js for null mcpConfigName
- Update terminology from 'simpleProfiles' to 'assetOnlyProfiles' throughout
- Ensure Claude .claude directory copying works in both CLI and MCP contexts
- All profiles now follow same execution flow with proper lifecycle functions

Changes:
- src/profiles/claude.js: Convert to createProfile() factory pattern
- src/profiles/codex.js: Convert to createProfile() factory pattern
- src/utils/rule-transformer.js: Unified profile handling logic
- src/utils/profiles.js: Remove simple profile categorization
- src/profiles/base-profile.js: Fix mcpConfigPath construction
- scripts/modules/commands.js: Update variable naming
- tests/: Update all tests for unified system and terminology

Fixes Claude profile asset copying issue in MCP context.
All tests passing (617 passed, 11 skipped).

* re-checkin claude files

* fix formatting

* chore: clean up test Claude rules files

* chore: add changeset for unified profile system

* add claude files back

* add changeset

* restore proper gitignore

* remove claude agents file from root

* remove incorrect doc

* simplify profiles and update tests

* update changeset

* update changeset

* remove profile specific code

* streamline profiles with defaults and update tests

* update changeset

* add newline at end of gitignore

* restore changes

* streamline profiles with defaults; update tests and add vscode test

* update rule profile tests

* update wording for clearer profile management

* refactor and clarify terminology

* use original projectRoot var name

* revert param desc

* use updated claude assets from neno

* add "YOUR_" before api key here

* streamline codex profile

* add gemini profile

* update gemini profile

* update tests

* relocate function

* update rules interactive setup Gemini desc

* remove duplicative code

* add comma
This commit is contained in:
Joe Danziger
2025-07-09 07:22:11 -04:00
committed by GitHub
parent 5f009a5e1f
commit 95c299df64
82 changed files with 4827 additions and 720 deletions

View File

@@ -0,0 +1,156 @@
import { jest } from '@jest/globals';
import fs from 'fs';
import path from 'path';
import os from 'os';
// Mock external modules
jest.mock('child_process', () => ({
execSync: jest.fn()
}));
// Mock console methods
jest.mock('console', () => ({
log: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
clear: jest.fn()
}));
describe('Gemini Profile Integration', () => {
let tempDir;
beforeEach(() => {
jest.clearAllMocks();
// Create a temporary directory for testing
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'task-master-test-'));
// Spy on fs methods
jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {});
jest.spyOn(fs, 'readFileSync').mockImplementation((filePath) => {
if (filePath.toString().includes('AGENTS.md')) {
return 'Sample AGENTS.md content for Gemini integration';
}
return '{}';
});
jest.spyOn(fs, 'existsSync').mockImplementation(() => false);
jest.spyOn(fs, 'mkdirSync').mockImplementation(() => {});
});
afterEach(() => {
// Clean up the temporary directory
try {
fs.rmSync(tempDir, { recursive: true, force: true });
} catch (err) {
console.error(`Error cleaning up: ${err.message}`);
}
});
// Test function that simulates the Gemini profile file copying behavior
function mockCreateGeminiStructure() {
// Gemini profile copies AGENTS.md to GEMINI.md in project root
const sourceContent = 'Sample AGENTS.md content for Gemini integration';
fs.writeFileSync(path.join(tempDir, 'GEMINI.md'), sourceContent);
// Gemini profile creates .gemini directory
fs.mkdirSync(path.join(tempDir, '.gemini'), { recursive: true });
// Gemini profile creates settings.json in .gemini directory
const settingsContent = JSON.stringify(
{
mcpServers: {
'task-master-ai': {
command: 'npx',
args: ['-y', 'task-master-ai'],
env: {
YOUR_ANTHROPIC_API_KEY: 'your-api-key-here',
YOUR_PERPLEXITY_API_KEY: 'your-api-key-here',
YOUR_OPENAI_API_KEY: 'your-api-key-here',
YOUR_GOOGLE_API_KEY: 'your-api-key-here',
YOUR_MISTRAL_API_KEY: 'your-api-key-here',
YOUR_AZURE_OPENAI_API_KEY: 'your-api-key-here',
YOUR_AZURE_OPENAI_ENDPOINT: 'your-endpoint-here',
YOUR_OPENROUTER_API_KEY: 'your-api-key-here',
YOUR_XAI_API_KEY: 'your-api-key-here',
YOUR_OLLAMA_API_KEY: 'your-api-key-here',
YOUR_OLLAMA_BASE_URL: 'http://localhost:11434/api',
YOUR_AWS_ACCESS_KEY_ID: 'your-access-key-id',
YOUR_AWS_SECRET_ACCESS_KEY: 'your-secret-access-key',
YOUR_AWS_REGION: 'us-east-1'
}
}
}
},
null,
2
);
fs.writeFileSync(
path.join(tempDir, '.gemini', 'settings.json'),
settingsContent
);
}
test('creates GEMINI.md file in project root', () => {
// Act
mockCreateGeminiStructure();
// Assert
expect(fs.writeFileSync).toHaveBeenCalledWith(
path.join(tempDir, 'GEMINI.md'),
'Sample AGENTS.md content for Gemini integration'
);
});
test('creates .gemini profile directory', () => {
// Act
mockCreateGeminiStructure();
// Assert
expect(fs.mkdirSync).toHaveBeenCalledWith(path.join(tempDir, '.gemini'), {
recursive: true
});
});
test('creates MCP configuration as settings.json', () => {
// Act
mockCreateGeminiStructure();
// Assert - Gemini profile should create settings.json instead of mcp.json
const writeFileCalls = fs.writeFileSync.mock.calls;
const settingsJsonCall = writeFileCalls.find((call) =>
call[0].toString().includes('.gemini/settings.json')
);
expect(settingsJsonCall).toBeDefined();
});
test('uses settings.json instead of mcp.json', () => {
// Act
mockCreateGeminiStructure();
// Assert - Should use settings.json, not mcp.json
const writeFileCalls = fs.writeFileSync.mock.calls;
const mcpJsonCalls = writeFileCalls.filter((call) =>
call[0].toString().includes('mcp.json')
);
expect(mcpJsonCalls).toHaveLength(0);
const settingsJsonCalls = writeFileCalls.filter((call) =>
call[0].toString().includes('settings.json')
);
expect(settingsJsonCalls).toHaveLength(1);
});
test('renames AGENTS.md to GEMINI.md', () => {
// Act
mockCreateGeminiStructure();
// Assert - Gemini should rename AGENTS.md to GEMINI.md
const writeFileCalls = fs.writeFileSync.mock.calls;
const geminiMdCall = writeFileCalls.find((call) =>
call[0].toString().includes('GEMINI.md')
);
expect(geminiMdCall).toBeDefined();
expect(geminiMdCall[0]).toBe(path.join(tempDir, 'GEMINI.md'));
});
});

View File

@@ -8,8 +8,8 @@ describe('MCP Configuration Validation', () => {
cline: {
shouldHaveMcp: false,
expectedDir: '.clinerules',
expectedConfigName: 'cline_mcp_settings.json',
expectedPath: '.clinerules/cline_mcp_settings.json'
expectedConfigName: null,
expectedPath: null
},
cursor: {
shouldHaveMcp: true,
@@ -17,6 +17,12 @@ describe('MCP Configuration Validation', () => {
expectedConfigName: 'mcp.json',
expectedPath: '.cursor/mcp.json'
},
gemini: {
shouldHaveMcp: true,
expectedDir: '.gemini',
expectedConfigName: 'settings.json',
expectedPath: '.gemini/settings.json'
},
roo: {
shouldHaveMcp: true,
expectedDir: '.roo',
@@ -26,8 +32,8 @@ describe('MCP Configuration Validation', () => {
trae: {
shouldHaveMcp: false,
expectedDir: '.trae',
expectedConfigName: 'trae_mcp_settings.json',
expectedPath: '.trae/trae_mcp_settings.json'
expectedConfigName: null,
expectedPath: null
},
vscode: {
shouldHaveMcp: true,
@@ -111,51 +117,68 @@ describe('MCP Configuration Validation', () => {
});
});
test('should use profile-specific config name for non-MCP profiles', () => {
test('should use custom settings.json for Gemini profile', () => {
const profile = getRulesProfile('gemini');
expect(profile.mcpConfigName).toBe('settings.json');
});
test('should have null config name for non-MCP profiles', () => {
const clineProfile = getRulesProfile('cline');
expect(clineProfile.mcpConfigName).toBe('cline_mcp_settings.json');
expect(clineProfile.mcpConfigName).toBe(null);
const traeProfile = getRulesProfile('trae');
expect(traeProfile.mcpConfigName).toBe('trae_mcp_settings.json');
expect(traeProfile.mcpConfigName).toBe(null);
const claudeProfile = getRulesProfile('claude');
expect(claudeProfile.mcpConfigName).toBe(null);
const codexProfile = getRulesProfile('codex');
expect(codexProfile.mcpConfigName).toBe(null);
});
});
describe('Profile Directory Structure', () => {
test('should ensure each profile has a unique directory', () => {
const profileDirs = new Set();
// Simple profiles that use root directory (can share the same directory)
const simpleProfiles = ['claude', 'codex'];
// Profiles that use root directory (can share the same directory)
const rootProfiles = ['claude', 'codex', 'gemini'];
RULE_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName);
// Simple profiles can share the root directory
if (simpleProfiles.includes(profileName)) {
expect(profile.profileDir).toBe('.');
return;
// Root profiles can share the root directory for rules
if (rootProfiles.includes(profileName) && profile.rulesDir === '.') {
expect(profile.rulesDir).toBe('.');
}
// Full profiles should have unique directories
expect(profileDirs.has(profile.profileDir)).toBe(false);
profileDirs.add(profile.profileDir);
// Profile directories should be unique (except for root profiles)
if (!rootProfiles.includes(profileName) || profile.profileDir !== '.') {
expect(profileDirs.has(profile.profileDir)).toBe(false);
profileDirs.add(profile.profileDir);
}
});
});
test('should ensure profile directories follow expected naming convention', () => {
// Simple profiles that use root directory
const simpleProfiles = ['claude', 'codex'];
// Profiles that use root directory for rules
const rootRulesProfiles = ['claude', 'codex', 'gemini'];
RULE_PROFILES.forEach((profileName) => {
const profile = getRulesProfile(profileName);
// Simple profiles use root directory
if (simpleProfiles.includes(profileName)) {
expect(profile.profileDir).toBe('.');
return;
// Some profiles use root directory for rules
if (
rootRulesProfiles.includes(profileName) &&
profile.rulesDir === '.'
) {
expect(profile.rulesDir).toBe('.');
}
// Full profiles should follow the .name pattern
expect(profile.profileDir).toMatch(/^\.[\w-]+$/);
// Profile directories (not rules directories) should follow the .name pattern
// unless they are root profiles with profileDir = '.'
if (profile.profileDir !== '.') {
expect(profile.profileDir).toMatch(/^\.[\w-]+$/);
}
});
});
});
@@ -168,6 +191,7 @@ describe('MCP Configuration Validation', () => {
});
expect(mcpEnabledProfiles).toContain('cursor');
expect(mcpEnabledProfiles).toContain('gemini');
expect(mcpEnabledProfiles).toContain('roo');
expect(mcpEnabledProfiles).toContain('vscode');
expect(mcpEnabledProfiles).toContain('windsurf');
@@ -244,4 +268,84 @@ describe('MCP Configuration Validation', () => {
});
});
});
describe('MCP configuration validation', () => {
const mcpProfiles = ['cursor', 'gemini', 'roo', 'windsurf', 'vscode'];
const nonMcpProfiles = ['claude', 'codex', 'cline', 'trae'];
test.each(mcpProfiles)(
'should have valid MCP config for %s profile',
(profileName) => {
const profile = getRulesProfile(profileName);
expect(profile).toBeDefined();
expect(profile.mcpConfig).toBe(true);
expect(profile.mcpConfigPath).toBeDefined();
expect(typeof profile.mcpConfigPath).toBe('string');
}
);
test.each(nonMcpProfiles)(
'should not require MCP config for %s profile',
(profileName) => {
const profile = getRulesProfile(profileName);
expect(profile).toBeDefined();
expect(profile.mcpConfig).toBe(false);
}
);
});
describe('Profile structure validation', () => {
const mcpProfiles = [
'cursor',
'gemini',
'roo',
'windsurf',
'cline',
'trae',
'vscode'
];
const profilesWithLifecycle = ['claude'];
const profilesWithoutLifecycle = ['codex'];
test.each(mcpProfiles)(
'should have file mappings for %s profile',
(profileName) => {
const profile = getRulesProfile(profileName);
expect(profile).toBeDefined();
expect(profile.fileMap).toBeDefined();
expect(typeof profile.fileMap).toBe('object');
expect(Object.keys(profile.fileMap).length).toBeGreaterThan(0);
}
);
test.each(profilesWithLifecycle)(
'should have file mappings and lifecycle functions for %s profile',
(profileName) => {
const profile = getRulesProfile(profileName);
expect(profile).toBeDefined();
// Claude profile has both fileMap and lifecycle functions
expect(profile.fileMap).toBeDefined();
expect(typeof profile.fileMap).toBe('object');
expect(Object.keys(profile.fileMap).length).toBeGreaterThan(0);
expect(typeof profile.onAddRulesProfile).toBe('function');
expect(typeof profile.onRemoveRulesProfile).toBe('function');
expect(typeof profile.onPostConvertRulesProfile).toBe('function');
}
);
test.each(profilesWithoutLifecycle)(
'should have file mappings without lifecycle functions for %s profile',
(profileName) => {
const profile = getRulesProfile(profileName);
expect(profile).toBeDefined();
// Codex profile has fileMap but no lifecycle functions (simplified)
expect(profile.fileMap).toBeDefined();
expect(typeof profile.fileMap).toBe('object');
expect(Object.keys(profile.fileMap).length).toBeGreaterThan(0);
expect(profile.onAddRulesProfile).toBeUndefined();
expect(profile.onRemoveRulesProfile).toBeUndefined();
expect(profile.onPostConvertRulesProfile).toBeUndefined();
}
);
});
});

View File

@@ -0,0 +1,70 @@
import { jest } from '@jest/globals';
import { getRulesProfile } from '../../../src/utils/rule-transformer.js';
import { geminiProfile } from '../../../src/profiles/gemini.js';
describe('Rule Transformer - Gemini Profile', () => {
test('should have correct profile configuration', () => {
const geminiProfile = getRulesProfile('gemini');
expect(geminiProfile).toBeDefined();
expect(geminiProfile.profileName).toBe('gemini');
expect(geminiProfile.displayName).toBe('Gemini');
expect(geminiProfile.profileDir).toBe('.gemini');
expect(geminiProfile.rulesDir).toBe('.');
expect(geminiProfile.mcpConfig).toBe(true);
expect(geminiProfile.mcpConfigName).toBe('settings.json');
expect(geminiProfile.mcpConfigPath).toBe('.gemini/settings.json');
expect(geminiProfile.includeDefaultRules).toBe(false);
expect(geminiProfile.fileMap).toEqual({
'AGENTS.md': 'GEMINI.md'
});
});
test('should have minimal profile implementation', () => {
// Verify that gemini.js is minimal (no lifecycle functions)
expect(geminiProfile.onAddRulesProfile).toBeUndefined();
expect(geminiProfile.onRemoveRulesProfile).toBeUndefined();
expect(geminiProfile.onPostConvertRulesProfile).toBeUndefined();
});
test('should use settings.json instead of mcp.json', () => {
const geminiProfile = getRulesProfile('gemini');
expect(geminiProfile.mcpConfigName).toBe('settings.json');
expect(geminiProfile.mcpConfigPath).toBe('.gemini/settings.json');
});
test('should not include default rules', () => {
const geminiProfile = getRulesProfile('gemini');
expect(geminiProfile.includeDefaultRules).toBe(false);
});
test('should have correct file mapping', () => {
const geminiProfile = getRulesProfile('gemini');
expect(geminiProfile.fileMap).toEqual({
'AGENTS.md': 'GEMINI.md'
});
});
test('should place GEMINI.md in root directory', () => {
const geminiProfile = getRulesProfile('gemini');
// rulesDir determines where fileMap files go
expect(geminiProfile.rulesDir).toBe('.');
// This means AGENTS.md -> GEMINI.md will be placed in the root
});
test('should place settings.json in .gemini directory', () => {
const geminiProfile = getRulesProfile('gemini');
// profileDir + mcpConfigName determines MCP config location
expect(geminiProfile.profileDir).toBe('.gemini');
expect(geminiProfile.mcpConfigName).toBe('settings.json');
expect(geminiProfile.mcpConfigPath).toBe('.gemini/settings.json');
});
test('should have proper conversion config', () => {
const geminiProfile = getRulesProfile('gemini');
// Gemini should have the standard conversion config
expect(geminiProfile.conversionConfig).toBeDefined();
expect(geminiProfile.globalReplacements).toBeDefined();
expect(Array.isArray(geminiProfile.globalReplacements)).toBe(true);
});
});

View File

@@ -17,6 +17,7 @@ describe('Rule Transformer - General', () => {
'cline',
'codex',
'cursor',
'gemini',
'roo',
'trae',
'vscode',
@@ -55,9 +56,6 @@ describe('Rule Transformer - General', () => {
describe('Profile Structure', () => {
it('should have all required properties for each profile', () => {
// Simple profiles that only copy files (no rule transformation)
const simpleProfiles = ['claude', 'codex'];
RULE_PROFILES.forEach((profile) => {
const profileConfig = getRulesProfile(profile);
@@ -68,50 +66,50 @@ describe('Rule Transformer - General', () => {
expect(profileConfig).toHaveProperty('rulesDir');
expect(profileConfig).toHaveProperty('profileDir');
// Simple profiles have minimal structure
if (simpleProfiles.includes(profile)) {
// For simple profiles, conversionConfig and fileMap can be empty
expect(typeof profileConfig.conversionConfig).toBe('object');
expect(typeof profileConfig.fileMap).toBe('object');
return;
// All profiles should have conversionConfig and fileMap objects
expect(typeof profileConfig.conversionConfig).toBe('object');
expect(typeof profileConfig.fileMap).toBe('object');
// Check that conversionConfig has required structure for profiles with rules
const hasRules = Object.keys(profileConfig.fileMap).length > 0;
if (hasRules) {
expect(profileConfig.conversionConfig).toHaveProperty('profileTerms');
expect(profileConfig.conversionConfig).toHaveProperty('toolNames');
expect(profileConfig.conversionConfig).toHaveProperty('toolContexts');
expect(profileConfig.conversionConfig).toHaveProperty('toolGroups');
expect(profileConfig.conversionConfig).toHaveProperty('docUrls');
expect(profileConfig.conversionConfig).toHaveProperty(
'fileReferences'
);
// Verify arrays are actually arrays
expect(
Array.isArray(profileConfig.conversionConfig.profileTerms)
).toBe(true);
expect(typeof profileConfig.conversionConfig.toolNames).toBe(
'object'
);
expect(
Array.isArray(profileConfig.conversionConfig.toolContexts)
).toBe(true);
expect(Array.isArray(profileConfig.conversionConfig.toolGroups)).toBe(
true
);
expect(Array.isArray(profileConfig.conversionConfig.docUrls)).toBe(
true
);
}
// Check that conversionConfig has required structure for full profiles
expect(profileConfig.conversionConfig).toHaveProperty('profileTerms');
expect(profileConfig.conversionConfig).toHaveProperty('toolNames');
expect(profileConfig.conversionConfig).toHaveProperty('toolContexts');
expect(profileConfig.conversionConfig).toHaveProperty('toolGroups');
expect(profileConfig.conversionConfig).toHaveProperty('docUrls');
expect(profileConfig.conversionConfig).toHaveProperty('fileReferences');
// Verify arrays are actually arrays
expect(Array.isArray(profileConfig.conversionConfig.profileTerms)).toBe(
true
);
expect(typeof profileConfig.conversionConfig.toolNames).toBe('object');
expect(Array.isArray(profileConfig.conversionConfig.toolContexts)).toBe(
true
);
expect(Array.isArray(profileConfig.conversionConfig.toolGroups)).toBe(
true
);
expect(Array.isArray(profileConfig.conversionConfig.docUrls)).toBe(
true
);
});
});
it('should have valid fileMap with required files for each profile', () => {
const expectedFiles = [
const expectedRuleFiles = [
'cursor_rules.mdc',
'dev_workflow.mdc',
'self_improve.mdc',
'taskmaster.mdc'
];
// Simple profiles that only copy files (no rule transformation)
const simpleProfiles = ['claude', 'codex'];
RULE_PROFILES.forEach((profile) => {
const profileConfig = getRulesProfile(profile);
@@ -120,33 +118,43 @@ describe('Rule Transformer - General', () => {
expect(typeof profileConfig.fileMap).toBe('object');
expect(profileConfig.fileMap).not.toBeNull();
// Simple profiles can have empty fileMap since they don't transform rules
if (simpleProfiles.includes(profile)) {
return;
}
// Check that fileMap is not empty for full profiles
const fileMapKeys = Object.keys(profileConfig.fileMap);
// All profiles should have some fileMap entries now
expect(fileMapKeys.length).toBeGreaterThan(0);
// Check that all expected source files are defined in fileMap
expectedFiles.forEach((expectedFile) => {
expect(fileMapKeys).toContain(expectedFile);
expect(typeof profileConfig.fileMap[expectedFile]).toBe('string');
expect(profileConfig.fileMap[expectedFile].length).toBeGreaterThan(0);
});
// Check if this profile has rule files or asset files
const hasRuleFiles = expectedRuleFiles.some((file) =>
fileMapKeys.includes(file)
);
const hasAssetFiles = fileMapKeys.some(
(file) => !expectedRuleFiles.includes(file)
);
// Verify fileMap has exactly the expected files
expect(fileMapKeys.sort()).toEqual(expectedFiles.sort());
if (hasRuleFiles) {
// Profiles with rule files should have all expected rule files
expectedRuleFiles.forEach((expectedFile) => {
expect(fileMapKeys).toContain(expectedFile);
expect(typeof profileConfig.fileMap[expectedFile]).toBe('string');
expect(profileConfig.fileMap[expectedFile].length).toBeGreaterThan(
0
);
});
}
if (hasAssetFiles) {
// Profiles with asset files (like Claude/Codex) should have valid asset mappings
fileMapKeys.forEach((key) => {
expect(typeof profileConfig.fileMap[key]).toBe('string');
expect(profileConfig.fileMap[key].length).toBeGreaterThan(0);
});
}
});
});
});
describe('MCP Configuration Properties', () => {
it('should have all required MCP properties for each profile', () => {
// Simple profiles that only copy files (no MCP configuration)
const simpleProfiles = ['claude', 'codex'];
RULE_PROFILES.forEach((profile) => {
const profileConfig = getRulesProfile(profile);
@@ -155,23 +163,23 @@ describe('Rule Transformer - General', () => {
expect(profileConfig).toHaveProperty('mcpConfigName');
expect(profileConfig).toHaveProperty('mcpConfigPath');
// Simple profiles have no MCP configuration
if (simpleProfiles.includes(profile)) {
expect(profileConfig.mcpConfig).toBe(false);
// Check types based on MCP configuration
expect(typeof profileConfig.mcpConfig).toBe('boolean');
if (profileConfig.mcpConfig === false) {
// Profiles without MCP configuration
expect(profileConfig.mcpConfigName).toBe(null);
expect(profileConfig.mcpConfigPath).toBe(null);
return;
} else {
// Profiles with MCP configuration
expect(typeof profileConfig.mcpConfigName).toBe('string');
expect(typeof profileConfig.mcpConfigPath).toBe('string');
// Check that mcpConfigPath is properly constructed
expect(profileConfig.mcpConfigPath).toBe(
`${profileConfig.profileDir}/${profileConfig.mcpConfigName}`
);
}
// Check types for full profiles
expect(typeof profileConfig.mcpConfig).toBe('boolean');
expect(typeof profileConfig.mcpConfigName).toBe('string');
expect(typeof profileConfig.mcpConfigPath).toBe('string');
// Check that mcpConfigPath is properly constructed
expect(profileConfig.mcpConfigPath).toBe(
`${profileConfig.profileDir}/${profileConfig.mcpConfigName}`
);
});
});
@@ -184,8 +192,8 @@ describe('Rule Transformer - General', () => {
},
cline: {
mcpConfig: false,
mcpConfigName: 'cline_mcp_settings.json',
expectedPath: '.clinerules/cline_mcp_settings.json'
mcpConfigName: null,
expectedPath: null
},
codex: {
mcpConfig: false,
@@ -197,6 +205,11 @@ describe('Rule Transformer - General', () => {
mcpConfigName: 'mcp.json',
expectedPath: '.cursor/mcp.json'
},
gemini: {
mcpConfig: true,
mcpConfigName: 'settings.json',
expectedPath: '.gemini/settings.json'
},
roo: {
mcpConfig: true,
mcpConfigName: 'mcp.json',
@@ -204,8 +217,8 @@ describe('Rule Transformer - General', () => {
},
trae: {
mcpConfig: false,
mcpConfigName: 'trae_mcp_settings.json',
expectedPath: '.trae/trae_mcp_settings.json'
mcpConfigName: null,
expectedPath: null
},
vscode: {
mcpConfig: true,
@@ -230,31 +243,28 @@ describe('Rule Transformer - General', () => {
});
it('should have consistent profileDir and mcpConfigPath relationship', () => {
// Simple profiles that only copy files (no MCP configuration)
const simpleProfiles = ['claude', 'codex'];
RULE_PROFILES.forEach((profile) => {
const profileConfig = getRulesProfile(profile);
// Simple profiles have null mcpConfigPath
if (simpleProfiles.includes(profile)) {
if (profileConfig.mcpConfig === false) {
// Profiles without MCP configuration have null mcpConfigPath
expect(profileConfig.mcpConfigPath).toBe(null);
return;
} else {
// Profiles with MCP configuration should have valid paths
// The mcpConfigPath should start with the profileDir
expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(
`^${profileConfig.profileDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`
)
);
// The mcpConfigPath should end with the mcpConfigName
expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(
`${profileConfig.mcpConfigName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`
)
);
}
// The mcpConfigPath should start with the profileDir
expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(
`^${profileConfig.profileDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`
)
);
// The mcpConfigPath should end with the mcpConfigName
expect(profileConfig.mcpConfigPath).toMatch(
new RegExp(
`${profileConfig.mcpConfigName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`
)
);
});
});

View File

@@ -136,8 +136,8 @@ describe('Selective Rules Removal', () => {
expect(result.filesRemoved).toEqual([
'cursor_rules.mdc',
'taskmaster/dev_workflow.mdc',
'taskmaster/taskmaster.mdc',
'self_improve.mdc'
'self_improve.mdc',
'taskmaster/taskmaster.mdc'
]);
expect(result.notice).toContain('Preserved 2 existing rule files');
@@ -226,8 +226,8 @@ describe('Selective Rules Removal', () => {
expect(result.filesRemoved).toEqual([
'cursor_rules.mdc',
'taskmaster/dev_workflow.mdc',
'taskmaster/taskmaster.mdc',
'self_improve.mdc'
'self_improve.mdc',
'taskmaster/taskmaster.mdc'
]);
// The function may fail due to directory reading issues in the test environment,
@@ -354,8 +354,8 @@ describe('Selective Rules Removal', () => {
// Mock sequence: only Task Master rules, rules dir removed, but profile dir not empty due to MCP
mockReaddirSync
.mockReturnValueOnce(['cursor_rules.mdc']) // Only Task Master files
.mockReturnValueOnce([]) // rules dir empty after removal
.mockReturnValueOnce(['mcp.json']); // Profile dir has MCP config remaining
.mockReturnValueOnce(['my_custom_rule.mdc']) // rules dir has other files remaining
.mockReturnValueOnce(['rules', 'mcp.json']); // Profile dir has rules and MCP config remaining
// Mock MCP config with multiple servers (Task Master will be removed, others preserved)
const mockMcpConfig = {
@@ -400,8 +400,9 @@ describe('Selective Rules Removal', () => {
// Mock sequence: only Task Master rules, rules dir removed, but profile dir has other files/folders
mockReaddirSync
.mockReturnValueOnce(['cursor_rules.mdc']) // Only Task Master files
.mockReturnValueOnce([]) // rules dir empty after removal
.mockReturnValueOnce(['cursor_rules.mdc']) // Only Task Master files (initial check)
.mockReturnValueOnce(['cursor_rules.mdc']) // Task Master files list for filtering
.mockReturnValueOnce([]) // Rules dir empty after removal (not used since no remaining files)
.mockReturnValueOnce(['workflows', 'custom-config.json']); // Profile dir has other files/folders
// Mock MCP config with only Task Master (will be completely deleted)
@@ -420,7 +421,7 @@ describe('Selective Rules Removal', () => {
expect(result.success).toBe(true);
expect(result.profileDirRemoved).toBe(false);
expect(result.mcpResult.deleted).toBe(true);
expect(result.notice).toContain('Preserved 2 existing files/folders');
expect(result.notice).toContain('existing files/folders in .cursor');
// Verify profile directory was NOT removed (other files/folders exist)
expect(mockRmSync).not.toHaveBeenCalledWith(
@@ -587,8 +588,30 @@ describe('Selective Rules Removal', () => {
// Mock mixed scenario: some Task Master files, some existing files, other MCP servers
mockExistsSync.mockImplementation((filePath) => {
if (filePath.includes('.cursor')) return true;
if (filePath.includes('mcp.json')) return true;
// Only .cursor directories exist
if (filePath === path.join(projectRoot, '.cursor')) return true;
if (filePath === path.join(projectRoot, '.cursor/rules')) return true;
if (filePath === path.join(projectRoot, '.cursor/mcp.json'))
return true;
// Only cursor_rules.mdc exists, not the other taskmaster files
if (
filePath === path.join(projectRoot, '.cursor/rules/cursor_rules.mdc')
)
return true;
if (
filePath ===
path.join(projectRoot, '.cursor/rules/taskmaster/dev_workflow.mdc')
)
return false;
if (
filePath === path.join(projectRoot, '.cursor/rules/self_improve.mdc')
)
return false;
if (
filePath ===
path.join(projectRoot, '.cursor/rules/taskmaster/taskmaster.mdc')
)
return false;
return false;
});

View File

@@ -8,10 +8,10 @@ describe('Rules Subdirectory Support Feature', () => {
expect(cursorProfile.supportsRulesSubdirectories).toBe(true);
// Verify that Cursor uses taskmaster subdirectories in its file mapping
expect(cursorProfile.fileMap['dev_workflow.mdc']).toBe(
expect(cursorProfile.fileMap['rules/dev_workflow.mdc']).toBe(
'taskmaster/dev_workflow.mdc'
);
expect(cursorProfile.fileMap['taskmaster.mdc']).toBe(
expect(cursorProfile.fileMap['rules/taskmaster.mdc']).toBe(
'taskmaster/taskmaster.mdc'
);
});
@@ -26,10 +26,10 @@ describe('Rules Subdirectory Support Feature', () => {
// Verify that these profiles do NOT use taskmaster subdirectories in their file mapping
const expectedExt = profile.targetExtension || '.md';
expect(profile.fileMap['dev_workflow.mdc']).toBe(
expect(profile.fileMap['rules/dev_workflow.mdc']).toBe(
`dev_workflow${expectedExt}`
);
expect(profile.fileMap['taskmaster.mdc']).toBe(
expect(profile.fileMap['rules/taskmaster.mdc']).toBe(
`taskmaster${expectedExt}`
);
});