diff --git a/mcp-server/src/core/direct-functions/rules.js b/mcp-server/src/core/direct-functions/rules.js index 387b3d1e..30204449 100644 --- a/mcp-server/src/core/direct-functions/rules.js +++ b/mcp-server/src/core/direct-functions/rules.js @@ -17,8 +17,8 @@ import { RULES_PROFILES } from '../../../../src/constants/profiles.js'; import { RULES_ACTIONS } from '../../../../src/constants/rules-actions.js'; import { wouldRemovalLeaveNoProfiles, - getInstalledRulesProfiles -} from '../../../../src/utils/rules-detection.js'; + getInstalledProfiles +} from '../../../../src/utils/profile-detection.js'; import path from 'path'; import fs from 'fs'; @@ -58,7 +58,7 @@ export async function rulesDirect(args, log, context = {}) { if (action === RULES_ACTIONS.REMOVE) { // Safety check: Ensure this won't remove all rules profiles (unless forced) if (!force && wouldRemovalLeaveNoProfiles(projectRoot, profiles)) { - const installedProfiles = getInstalledRulesProfiles(projectRoot); + const installedProfiles = getInstalledProfiles(projectRoot); const remainingProfiles = installedProfiles.filter( (profile) => !profiles.includes(profile) ); diff --git a/scripts/modules/commands.js b/scripts/modules/commands.js index 80b6d587..1f2aa002 100644 --- a/scripts/modules/commands.js +++ b/scripts/modules/commands.js @@ -74,8 +74,8 @@ import { } from '../../src/ui/confirm.js'; import { wouldRemovalLeaveNoProfiles, - getInstalledRulesProfiles -} from '../../src/utils/rules-detection.js'; + getInstalledProfiles +} from '../../src/utils/profile-detection.js'; import { initializeProject } from '../init.js'; import { @@ -2739,7 +2739,7 @@ Examples: if (!options.force) { // Check if this removal would leave no profiles remaining if (wouldRemovalLeaveNoProfiles(projectDir, expandedProfiles)) { - const installedProfiles = getInstalledRulesProfiles(projectDir); + const installedProfiles = getInstalledProfiles(projectDir); confirmed = await confirmRemoveAllRemainingProfiles( expandedProfiles, installedProfiles diff --git a/src/utils/rules-detection.js b/src/utils/profile-detection.js similarity index 78% rename from src/utils/rules-detection.js rename to src/utils/profile-detection.js index 08b3cf7f..bb3c4654 100644 --- a/src/utils/rules-detection.js +++ b/src/utils/profile-detection.js @@ -1,6 +1,6 @@ /** - * Rules Detection Utility - * Helper functions to detect existing rules profiles in a project + * Profile Detection Utility + * Helper functions to detect existing profiles in a project */ import fs from 'fs'; import path from 'path'; @@ -8,11 +8,11 @@ import { RULES_PROFILES } from '../constants/profiles.js'; import { getRulesProfile } from './rule-transformer.js'; /** - * Detect which rules profiles are currently installed in the project + * Detect which profiles are currently installed in the project * @param {string} projectRoot - Project root directory * @returns {string[]} Array of installed profile names */ -export function getInstalledRulesProfiles(projectRoot) { +export function getInstalledProfiles(projectRoot) { const installedProfiles = []; for (const profileName of RULES_PROFILES) { @@ -33,13 +33,13 @@ export function getInstalledRulesProfiles(projectRoot) { } /** - * Check if removing the specified profiles would result in no rules profiles remaining + * Check if removing the specified profiles would result in no profiles remaining * @param {string} projectRoot - Project root directory * @param {string[]} profilesToRemove - Array of profile names to remove * @returns {boolean} True if removal would result in no profiles remaining */ export function wouldRemovalLeaveNoProfiles(projectRoot, profilesToRemove) { - const installedProfiles = getInstalledRulesProfiles(projectRoot); + const installedProfiles = getInstalledProfiles(projectRoot); const remainingProfiles = installedProfiles.filter( (profile) => !profilesToRemove.includes(profile) ); diff --git a/tests/unit/rules-safety-check.test.js b/tests/unit/rules-safety-check.test.js index 3077b76c..2446a704 100644 --- a/tests/unit/rules-safety-check.test.js +++ b/tests/unit/rules-safety-check.test.js @@ -1,7 +1,7 @@ import { - getInstalledRulesProfiles, + getInstalledProfiles, wouldRemovalLeaveNoProfiles -} from '../../src/utils/rules-detection.js'; +} from '../../src/utils/profile-detection.js'; import { rulesDirect } from '../../mcp-server/src/core/direct-functions/rules.js'; import fs from 'fs'; import path from 'path'; @@ -33,7 +33,7 @@ describe('Rules Safety Check', () => { jest.restoreAllMocks(); }); - describe('getInstalledRulesProfiles', () => { + describe('getInstalledProfiles', () => { it('should detect installed profiles correctly', () => { const projectRoot = '/test/project'; @@ -45,7 +45,7 @@ describe('Rules Safety Check', () => { return false; }); - const installed = getInstalledRulesProfiles(projectRoot); + const installed = getInstalledProfiles(projectRoot); expect(installed).toContain('cursor'); expect(installed).toContain('roo'); expect(installed).not.toContain('windsurf'); @@ -58,7 +58,7 @@ describe('Rules Safety Check', () => { // Mock fs.existsSync to return false for all paths mockExistsSync.mockReturnValue(false); - const installed = getInstalledRulesProfiles(projectRoot); + const installed = getInstalledProfiles(projectRoot); expect(installed).toEqual([]); }); });