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