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

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import { claudeProfile } from '../../../src/profiles/claude.js';
describe('Claude Profile Initialization Functionality', () => {
let claudeProfileContent;
@@ -14,23 +15,25 @@ describe('Claude Profile Initialization Functionality', () => {
claudeProfileContent = fs.readFileSync(claudeJsPath, 'utf8');
});
test('claude.js is a simple profile with correct configuration', () => {
expect(claudeProfileContent).toContain("profileName: 'claude'");
test('claude.js has correct asset-only profile configuration', () => {
// Check for explicit, non-default values in the source file
expect(claudeProfileContent).toContain("name: 'claude'");
expect(claudeProfileContent).toContain("displayName: 'Claude Code'");
expect(claudeProfileContent).toContain("profileDir: '.'");
expect(claudeProfileContent).toContain("rulesDir: '.'");
});
expect(claudeProfileContent).toContain("profileDir: '.'"); // non-default
expect(claudeProfileContent).toContain("rulesDir: '.'"); // non-default
expect(claudeProfileContent).toContain('mcpConfig: false'); // non-default
expect(claudeProfileContent).toContain('includeDefaultRules: false'); // non-default
expect(claudeProfileContent).toContain("'AGENTS.md': 'CLAUDE.md'");
test('claude.js has no MCP configuration', () => {
expect(claudeProfileContent).toContain('mcpConfig: false');
expect(claudeProfileContent).toContain('mcpConfigName: null');
expect(claudeProfileContent).toContain('mcpConfigPath: null');
});
test('claude.js has empty file map (simple profile)', () => {
expect(claudeProfileContent).toContain('fileMap: {}');
expect(claudeProfileContent).toContain('conversionConfig: {}');
expect(claudeProfileContent).toContain('globalReplacements: []');
// Check the final computed properties on the profile object
expect(claudeProfile.profileName).toBe('claude');
expect(claudeProfile.displayName).toBe('Claude Code');
expect(claudeProfile.profileDir).toBe('.');
expect(claudeProfile.rulesDir).toBe('.');
expect(claudeProfile.mcpConfig).toBe(false);
expect(claudeProfile.mcpConfigName).toBe(null); // computed
expect(claudeProfile.includeDefaultRules).toBe(false);
expect(claudeProfile.fileMap['AGENTS.md']).toBe('CLAUDE.md');
});
test('claude.js has lifecycle functions for file management', () => {
@@ -41,13 +44,12 @@ describe('Claude Profile Initialization Functionality', () => {
);
});
test('claude.js copies AGENTS.md to CLAUDE.md', () => {
expect(claudeProfileContent).toContain("'AGENTS.md'");
expect(claudeProfileContent).toContain("'CLAUDE.md'");
expect(claudeProfileContent).toContain('copyFileSync');
test('claude.js handles .claude directory in lifecycle functions', () => {
expect(claudeProfileContent).toContain('.claude');
expect(claudeProfileContent).toContain('copyRecursiveSync');
});
test('claude.js has proper error handling', () => {
test('claude.js has proper error handling in lifecycle functions', () => {
expect(claudeProfileContent).toContain('try {');
expect(claudeProfileContent).toContain('} catch (err) {');
expect(claudeProfileContent).toContain("log('error'");

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import { clineProfile } from '../../../src/profiles/cline.js';
describe('Cline Profile Initialization Functionality', () => {
let clineProfileContent;
@@ -10,39 +11,48 @@ describe('Cline Profile Initialization Functionality', () => {
});
test('cline.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(clineProfileContent).toContain("name: 'cline'");
expect(clineProfileContent).toContain("displayName: 'Cline'");
expect(clineProfileContent).toContain("rulesDir: '.clinerules'");
expect(clineProfileContent).toContain("profileDir: '.clinerules'");
expect(clineProfileContent).toContain("profileDir: '.clinerules'"); // non-default
expect(clineProfileContent).toContain("rulesDir: '.clinerules'"); // non-default
expect(clineProfileContent).toContain('mcpConfig: false'); // non-default
// Check the final computed properties on the profile object
expect(clineProfile.profileName).toBe('cline');
expect(clineProfile.displayName).toBe('Cline');
expect(clineProfile.profileDir).toBe('.clinerules');
expect(clineProfile.rulesDir).toBe('.clinerules');
expect(clineProfile.mcpConfig).toBe(false);
expect(clineProfile.mcpConfigName).toBe(null);
});
test('cline.js configures .mdc to .md extension mapping', () => {
expect(clineProfileContent).toContain("fileExtension: '.mdc'");
expect(clineProfileContent).toContain("targetExtension: '.md'");
});
test('cline.js uses standard tool mappings', () => {
expect(clineProfileContent).toContain('COMMON_TOOL_MAPPINGS.STANDARD');
// Should contain comment about standard tool names
expect(clineProfileContent).toContain('standard tool names');
});
test('cline.js contains correct URL configuration', () => {
expect(clineProfileContent).toContain("url: 'cline.bot'");
expect(clineProfileContent).toContain("docsUrl: 'docs.cline.bot'");
});
test('cline.js has MCP configuration disabled', () => {
expect(clineProfileContent).toContain('mcpConfig: false');
expect(clineProfileContent).toContain(
"mcpConfigName: 'cline_mcp_settings.json'"
// Check that the profile object has the correct file mapping behavior (cline converts to .md)
expect(clineProfile.fileMap['rules/cursor_rules.mdc']).toBe(
'cline_rules.md'
);
});
test('cline.js uses standard tool mappings', () => {
// Check that the profile uses default tool mappings (equivalent to COMMON_TOOL_MAPPINGS.STANDARD)
// This verifies the architectural pattern: no custom toolMappings = standard tool names
expect(clineProfileContent).not.toContain('toolMappings:');
expect(clineProfileContent).not.toContain('apply_diff');
expect(clineProfileContent).not.toContain('search_files');
// Verify the result: default mappings means tools keep their original names
expect(clineProfile.conversionConfig.toolNames.edit_file).toBe('edit_file');
expect(clineProfile.conversionConfig.toolNames.search).toBe('search');
});
test('cline.js has custom file mapping for cursor_rules.mdc', () => {
expect(clineProfileContent).toContain('customFileMap:');
expect(clineProfileContent).toContain(
"'cursor_rules.mdc': 'cline_rules.md'"
// Check actual behavior - cline gets default rule files
expect(Object.keys(clineProfile.fileMap)).toContain(
'rules/cursor_rules.mdc'
);
expect(clineProfile.fileMap['rules/cursor_rules.mdc']).toBe(
'cline_rules.md'
);
});

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import { codexProfile } from '../../../src/profiles/codex.js';
describe('Codex Profile Initialization Functionality', () => {
let codexProfileContent;
@@ -9,46 +10,41 @@ describe('Codex Profile Initialization Functionality', () => {
codexProfileContent = fs.readFileSync(codexJsPath, 'utf8');
});
test('codex.js is a simple profile with correct configuration', () => {
expect(codexProfileContent).toContain("profileName: 'codex'");
test('codex.js has correct asset-only profile configuration', () => {
// Check for explicit, non-default values in the source file
expect(codexProfileContent).toContain("name: 'codex'");
expect(codexProfileContent).toContain("displayName: 'Codex'");
expect(codexProfileContent).toContain("profileDir: '.'");
expect(codexProfileContent).toContain("rulesDir: '.'");
expect(codexProfileContent).toContain("profileDir: '.'"); // non-default
expect(codexProfileContent).toContain("rulesDir: '.'"); // non-default
expect(codexProfileContent).toContain('mcpConfig: false'); // non-default
expect(codexProfileContent).toContain('includeDefaultRules: false'); // non-default
expect(codexProfileContent).toContain("'AGENTS.md': 'AGENTS.md'");
// Check the final computed properties on the profile object
expect(codexProfile.profileName).toBe('codex');
expect(codexProfile.displayName).toBe('Codex');
expect(codexProfile.profileDir).toBe('.');
expect(codexProfile.rulesDir).toBe('.');
expect(codexProfile.mcpConfig).toBe(false);
expect(codexProfile.mcpConfigName).toBe(null); // computed
expect(codexProfile.includeDefaultRules).toBe(false);
expect(codexProfile.fileMap['AGENTS.md']).toBe('AGENTS.md');
});
test('codex.js has no MCP configuration', () => {
expect(codexProfileContent).toContain('mcpConfig: false');
expect(codexProfileContent).toContain('mcpConfigName: null');
expect(codexProfileContent).toContain('mcpConfigPath: null');
test('codex.js has no lifecycle functions', () => {
// Codex has been simplified - no lifecycle functions
expect(codexProfileContent).not.toContain('function onAddRulesProfile');
expect(codexProfileContent).not.toContain('function onRemoveRulesProfile');
expect(codexProfileContent).not.toContain(
'function onPostConvertRulesProfile'
);
expect(codexProfileContent).not.toContain('log(');
});
test('codex.js has empty file map (simple profile)', () => {
expect(codexProfileContent).toContain('fileMap: {}');
expect(codexProfileContent).toContain('conversionConfig: {}');
expect(codexProfileContent).toContain('globalReplacements: []');
});
test('codex.js has lifecycle functions for file management', () => {
expect(codexProfileContent).toContain('function onAddRulesProfile');
expect(codexProfileContent).toContain('function onRemoveRulesProfile');
expect(codexProfileContent).toContain('function onPostConvertRulesProfile');
});
test('codex.js copies AGENTS.md to AGENTS.md (same filename)', () => {
expect(codexProfileContent).toContain("'AGENTS.md'");
expect(codexProfileContent).toContain('copyFileSync');
// Should copy to the same filename (AGENTS.md)
expect(codexProfileContent).toMatch(/destFile.*AGENTS\.md/);
});
test('codex.js has proper error handling', () => {
expect(codexProfileContent).toContain('try {');
expect(codexProfileContent).toContain('} catch (err) {');
expect(codexProfileContent).toContain("log('error'");
});
test('codex.js removes AGENTS.md on profile removal', () => {
expect(codexProfileContent).toContain('rmSync');
expect(codexProfileContent).toContain('force: true');
test('codex.js has minimal implementation', () => {
// Should just use createProfile factory
expect(codexProfileContent).toContain('createProfile({');
expect(codexProfileContent).toContain("name: 'codex'");
expect(codexProfileContent).toContain("'AGENTS.md': 'AGENTS.md'");
});
});

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import { cursorProfile } from '../../../src/profiles/cursor.js';
describe('Cursor Profile Initialization Functionality', () => {
let cursorProfileContent;
@@ -15,30 +16,42 @@ describe('Cursor Profile Initialization Functionality', () => {
});
test('cursor.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(cursorProfileContent).toContain("name: 'cursor'");
expect(cursorProfileContent).toContain("displayName: 'Cursor'");
expect(cursorProfileContent).toContain("rulesDir: '.cursor/rules'");
expect(cursorProfileContent).toContain("profileDir: '.cursor'");
expect(cursorProfileContent).toContain("url: 'cursor.so'");
expect(cursorProfileContent).toContain("docsUrl: 'docs.cursor.com'");
expect(cursorProfileContent).toContain("targetExtension: '.mdc'"); // non-default
// Check the final computed properties on the profile object
expect(cursorProfile.profileName).toBe('cursor');
expect(cursorProfile.displayName).toBe('Cursor');
expect(cursorProfile.profileDir).toBe('.cursor'); // default
expect(cursorProfile.rulesDir).toBe('.cursor/rules'); // default
expect(cursorProfile.mcpConfig).toBe(true); // default
expect(cursorProfile.mcpConfigName).toBe('mcp.json'); // default
});
test('cursor.js preserves .mdc extension in both input and output', () => {
expect(cursorProfileContent).toContain("fileExtension: '.mdc'");
expect(cursorProfileContent).toContain("targetExtension: '.mdc'");
// Should preserve cursor_rules.mdc filename
expect(cursorProfileContent).toContain(
"'cursor_rules.mdc': 'cursor_rules.mdc'"
// Check that the profile object has the correct file mapping behavior (cursor keeps .mdc)
expect(cursorProfile.fileMap['rules/cursor_rules.mdc']).toBe(
'cursor_rules.mdc'
);
// Also check that targetExtension is explicitly set in the file
expect(cursorProfileContent).toContain("targetExtension: '.mdc'");
});
test('cursor.js uses standard tool mappings (no tool renaming)', () => {
expect(cursorProfileContent).toContain('COMMON_TOOL_MAPPINGS.STANDARD');
// Should not contain custom tool mappings since cursor keeps original names
expect(cursorProfileContent).not.toContain('edit_file');
// Check that the profile uses default tool mappings (equivalent to COMMON_TOOL_MAPPINGS.STANDARD)
// This verifies the architectural pattern: no custom toolMappings = standard tool names
expect(cursorProfileContent).not.toContain('toolMappings:');
expect(cursorProfileContent).not.toContain('apply_diff');
});
expect(cursorProfileContent).not.toContain('search_files');
test('cursor.js contains correct URL configuration', () => {
expect(cursorProfileContent).toContain("url: 'cursor.so'");
expect(cursorProfileContent).toContain("docsUrl: 'docs.cursor.com'");
// Verify the result: default mappings means tools keep their original names
expect(cursorProfile.conversionConfig.toolNames.edit_file).toBe(
'edit_file'
);
expect(cursorProfile.conversionConfig.toolNames.search).toBe('search');
});
});

View File

@@ -0,0 +1,72 @@
import fs from 'fs';
import path from 'path';
import { geminiProfile } from '../../../src/profiles/gemini.js';
describe('Gemini Profile Initialization Functionality', () => {
let geminiProfileContent;
beforeAll(() => {
const geminiJsPath = path.join(
process.cwd(),
'src',
'profiles',
'gemini.js'
);
geminiProfileContent = fs.readFileSync(geminiJsPath, 'utf8');
});
test('gemini.js has correct profile configuration', () => {
// Check for explicit, non-default values in the source file
expect(geminiProfileContent).toContain("name: 'gemini'");
expect(geminiProfileContent).toContain("displayName: 'Gemini'");
expect(geminiProfileContent).toContain("url: 'codeassist.google'");
expect(geminiProfileContent).toContain(
"docsUrl: 'github.com/google-gemini/gemini-cli'"
);
expect(geminiProfileContent).toContain("profileDir: '.gemini'");
expect(geminiProfileContent).toContain("rulesDir: '.'"); // non-default
expect(geminiProfileContent).toContain("mcpConfigName: 'settings.json'"); // non-default
expect(geminiProfileContent).toContain('includeDefaultRules: false'); // non-default
expect(geminiProfileContent).toContain("'AGENTS.md': 'GEMINI.md'");
// Check the final computed properties on the profile object
expect(geminiProfile.profileName).toBe('gemini');
expect(geminiProfile.displayName).toBe('Gemini');
expect(geminiProfile.profileDir).toBe('.gemini');
expect(geminiProfile.rulesDir).toBe('.');
expect(geminiProfile.mcpConfig).toBe(true); // computed from mcpConfigName
expect(geminiProfile.mcpConfigName).toBe('settings.json');
expect(geminiProfile.mcpConfigPath).toBe('.gemini/settings.json'); // computed
expect(geminiProfile.includeDefaultRules).toBe(false);
expect(geminiProfile.fileMap['AGENTS.md']).toBe('GEMINI.md');
});
test('gemini.js has no lifecycle functions', () => {
// Gemini profile should not have any lifecycle functions
expect(geminiProfileContent).not.toContain('function onAddRulesProfile');
expect(geminiProfileContent).not.toContain('function onRemoveRulesProfile');
expect(geminiProfileContent).not.toContain(
'function onPostConvertRulesProfile'
);
expect(geminiProfileContent).not.toContain('onAddRulesProfile:');
expect(geminiProfileContent).not.toContain('onRemoveRulesProfile:');
expect(geminiProfileContent).not.toContain('onPostConvertRulesProfile:');
});
test('gemini.js uses custom MCP config name', () => {
// Gemini uses settings.json instead of mcp.json
expect(geminiProfileContent).toContain("mcpConfigName: 'settings.json'");
// Should not contain mcp.json as a config value (comments are OK)
expect(geminiProfileContent).not.toMatch(
/mcpConfigName:\s*['"]mcp\.json['"]/
);
});
test('gemini.js has minimal implementation', () => {
// Verify the profile is minimal (no extra functions or logic)
const lines = geminiProfileContent.split('\n');
const nonEmptyLines = lines.filter((line) => line.trim().length > 0);
// Should be around 16 lines (import, export, and profile definition)
expect(nonEmptyLines.length).toBeLessThan(20);
});
});

View File

@@ -1,6 +1,8 @@
import { jest } from '@jest/globals';
import fs from 'fs';
import path from 'path';
import { rooProfile } from '../../../src/profiles/roo.js';
import { COMMON_TOOL_MAPPINGS } from '../../../src/profiles/base-profile.js';
describe('Roo Profile Initialization Functionality', () => {
let rooProfileContent;
@@ -11,6 +13,33 @@ describe('Roo Profile Initialization Functionality', () => {
rooProfileContent = fs.readFileSync(rooJsPath, 'utf8');
});
test('roo.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(rooProfileContent).toContain("name: 'roo'");
expect(rooProfileContent).toContain("displayName: 'Roo Code'");
expect(rooProfileContent).toContain(
'toolMappings: COMMON_TOOL_MAPPINGS.ROO_STYLE'
);
// Check the final computed properties on the profile object
expect(rooProfile.profileName).toBe('roo');
expect(rooProfile.displayName).toBe('Roo Code');
expect(rooProfile.profileDir).toBe('.roo'); // default
expect(rooProfile.rulesDir).toBe('.roo/rules'); // default
expect(rooProfile.mcpConfig).toBe(true); // default
});
test('roo.js uses custom ROO_STYLE tool mappings', () => {
// Check that the profile uses the correct, non-standard tool mappings
expect(rooProfileContent).toContain(
'toolMappings: COMMON_TOOL_MAPPINGS.ROO_STYLE'
);
// Verify the result: roo uses custom tool names
expect(rooProfile.conversionConfig.toolNames.edit_file).toBe('apply_diff');
expect(rooProfile.conversionConfig.toolNames.search).toBe('search_files');
});
test('roo.js profile ensures Roo directory structure via onAddRulesProfile', () => {
// Check if onAddRulesProfile function exists
expect(rooProfileContent).toContain(

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import { traeProfile } from '../../../src/profiles/trae.js';
describe('Trae Profile Initialization Functionality', () => {
let traeProfileContent;
@@ -10,32 +11,36 @@ describe('Trae Profile Initialization Functionality', () => {
});
test('trae.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(traeProfileContent).toContain("name: 'trae'");
expect(traeProfileContent).toContain("displayName: 'Trae'");
expect(traeProfileContent).toContain("rulesDir: '.trae/rules'");
expect(traeProfileContent).toContain("profileDir: '.trae'");
expect(traeProfileContent).toContain("url: 'trae.ai'");
expect(traeProfileContent).toContain("docsUrl: 'docs.trae.ai'");
expect(traeProfileContent).toContain('mcpConfig: false');
// Check the final computed properties on the profile object
expect(traeProfile.profileName).toBe('trae');
expect(traeProfile.displayName).toBe('Trae');
expect(traeProfile.profileDir).toBe('.trae'); // default
expect(traeProfile.rulesDir).toBe('.trae/rules'); // default
expect(traeProfile.mcpConfig).toBe(false); // non-default
expect(traeProfile.mcpConfigName).toBe(null); // computed from mcpConfig
});
test('trae.js configures .mdc to .md extension mapping', () => {
expect(traeProfileContent).toContain("fileExtension: '.mdc'");
expect(traeProfileContent).toContain("targetExtension: '.md'");
// Check that the profile object has the correct file mapping behavior (trae converts to .md)
expect(traeProfile.fileMap['rules/cursor_rules.mdc']).toBe('trae_rules.md');
});
test('trae.js uses standard tool mappings', () => {
expect(traeProfileContent).toContain('COMMON_TOOL_MAPPINGS.STANDARD');
// Should contain comment about standard tool names
expect(traeProfileContent).toContain('standard tool names');
});
// Check that the profile uses default tool mappings (equivalent to COMMON_TOOL_MAPPINGS.STANDARD)
// This verifies the architectural pattern: no custom toolMappings = standard tool names
expect(traeProfileContent).not.toContain('toolMappings:');
expect(traeProfileContent).not.toContain('apply_diff');
expect(traeProfileContent).not.toContain('search_files');
test('trae.js contains correct URL configuration', () => {
expect(traeProfileContent).toContain("url: 'trae.ai'");
expect(traeProfileContent).toContain("docsUrl: 'docs.trae.ai'");
});
test('trae.js has MCP configuration disabled', () => {
expect(traeProfileContent).toContain('mcpConfig: false');
expect(traeProfileContent).toContain(
"mcpConfigName: 'trae_mcp_settings.json'"
);
// Verify the result: default mappings means tools keep their original names
expect(traeProfile.conversionConfig.toolNames.edit_file).toBe('edit_file');
expect(traeProfile.conversionConfig.toolNames.search).toBe('search');
});
});

View File

@@ -0,0 +1,58 @@
import fs from 'fs';
import path from 'path';
import { vscodeProfile } from '../../../src/profiles/vscode.js';
describe('VSCode Profile Initialization Functionality', () => {
let vscodeProfileContent;
beforeAll(() => {
const vscodeJsPath = path.join(
process.cwd(),
'src',
'profiles',
'vscode.js'
);
vscodeProfileContent = fs.readFileSync(vscodeJsPath, 'utf8');
});
test('vscode.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(vscodeProfileContent).toContain("name: 'vscode'");
expect(vscodeProfileContent).toContain("displayName: 'VS Code'");
expect(vscodeProfileContent).toContain("url: 'code.visualstudio.com'");
expect(vscodeProfileContent).toContain(
"docsUrl: 'code.visualstudio.com/docs'"
);
expect(vscodeProfileContent).toContain("rulesDir: '.github/instructions'"); // non-default
expect(vscodeProfileContent).toContain('customReplacements'); // non-default
// Check the final computed properties on the profile object
expect(vscodeProfile.profileName).toBe('vscode');
expect(vscodeProfile.displayName).toBe('VS Code');
expect(vscodeProfile.profileDir).toBe('.vscode'); // default
expect(vscodeProfile.rulesDir).toBe('.github/instructions'); // non-default
expect(vscodeProfile.globalReplacements).toBeDefined(); // computed from customReplacements
expect(Array.isArray(vscodeProfile.globalReplacements)).toBe(true);
});
test('vscode.js configures .mdc to .md extension mapping', () => {
// Check that the profile object has the correct file mapping behavior (vscode converts to .md)
expect(vscodeProfile.fileMap['rules/cursor_rules.mdc']).toBe(
'vscode_rules.md'
);
});
test('vscode.js uses standard tool mappings', () => {
// Check that the profile uses default tool mappings (equivalent to COMMON_TOOL_MAPPINGS.STANDARD)
// This verifies the architectural pattern: no custom toolMappings = standard tool names
expect(vscodeProfileContent).not.toContain('toolMappings:');
expect(vscodeProfileContent).not.toContain('apply_diff');
expect(vscodeProfileContent).not.toContain('search_files');
// Verify the result: default mappings means tools keep their original names
expect(vscodeProfile.conversionConfig.toolNames.edit_file).toBe(
'edit_file'
);
expect(vscodeProfile.conversionConfig.toolNames.search).toBe('search');
});
});

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import { windsurfProfile } from '../../../src/profiles/windsurf.js';
describe('Windsurf Profile Initialization Functionality', () => {
let windsurfProfileContent;
@@ -15,25 +16,39 @@ describe('Windsurf Profile Initialization Functionality', () => {
});
test('windsurf.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(windsurfProfileContent).toContain("name: 'windsurf'");
expect(windsurfProfileContent).toContain("displayName: 'Windsurf'");
expect(windsurfProfileContent).toContain("rulesDir: '.windsurf/rules'");
expect(windsurfProfileContent).toContain("profileDir: '.windsurf'");
expect(windsurfProfileContent).toContain("url: 'windsurf.com'");
expect(windsurfProfileContent).toContain("docsUrl: 'docs.windsurf.com'");
// Check the final computed properties on the profile object
expect(windsurfProfile.profileName).toBe('windsurf');
expect(windsurfProfile.displayName).toBe('Windsurf');
expect(windsurfProfile.profileDir).toBe('.windsurf'); // default
expect(windsurfProfile.rulesDir).toBe('.windsurf/rules'); // default
expect(windsurfProfile.mcpConfig).toBe(true); // default
expect(windsurfProfile.mcpConfigName).toBe('mcp.json'); // default
});
test('windsurf.js configures .mdc to .md extension mapping', () => {
expect(windsurfProfileContent).toContain("fileExtension: '.mdc'");
expect(windsurfProfileContent).toContain("targetExtension: '.md'");
// Check that the profile object has the correct file mapping behavior (windsurf converts to .md)
expect(windsurfProfile.fileMap['rules/cursor_rules.mdc']).toBe(
'windsurf_rules.md'
);
});
test('windsurf.js uses standard tool mappings', () => {
expect(windsurfProfileContent).toContain('COMMON_TOOL_MAPPINGS.STANDARD');
// Should contain comment about standard tool names
expect(windsurfProfileContent).toContain('standard tool names');
});
// Check that the profile uses default tool mappings (equivalent to COMMON_TOOL_MAPPINGS.STANDARD)
// This verifies the architectural pattern: no custom toolMappings = standard tool names
expect(windsurfProfileContent).not.toContain('toolMappings:');
expect(windsurfProfileContent).not.toContain('apply_diff');
expect(windsurfProfileContent).not.toContain('search_files');
test('windsurf.js contains correct URL configuration', () => {
expect(windsurfProfileContent).toContain("url: 'windsurf.com'");
expect(windsurfProfileContent).toContain("docsUrl: 'docs.windsurf.com'");
// Verify the result: default mappings means tools keep their original names
expect(windsurfProfile.conversionConfig.toolNames.edit_file).toBe(
'edit_file'
);
expect(windsurfProfile.conversionConfig.toolNames.search).toBe('search');
});
});

View File

@@ -372,9 +372,7 @@ describe('rules command', () => {
expect.stringMatching(/removing rules for profile: roo/i)
);
expect(mockConsoleLog).toHaveBeenCalledWith(
expect.stringMatching(
/Summary for roo: (Rules directory removed|Skipped \(default or protected files\))/i
)
expect.stringMatching(/Summary for roo: Rule profile removed/i)
);
// Should not exit with error
expect(mockExit).not.toHaveBeenCalledWith(1);

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}`
);
});