* 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
121 lines
3.8 KiB
JavaScript
121 lines
3.8 KiB
JavaScript
// Roo Code conversion profile for rule-transformer
|
|
import path from 'path';
|
|
import fs from 'fs';
|
|
import { isSilentMode, log } from '../../scripts/modules/utils.js';
|
|
import { createProfile, COMMON_TOOL_MAPPINGS } from './base-profile.js';
|
|
import { ROO_MODES } from '../constants/profiles.js';
|
|
|
|
// Lifecycle functions for Roo profile
|
|
function onAddRulesProfile(targetDir, assetsDir) {
|
|
// Use the provided assets directory to find the roocode directory
|
|
const sourceDir = path.join(assetsDir, 'roocode');
|
|
|
|
if (!fs.existsSync(sourceDir)) {
|
|
log('error', `[Roo] Source directory does not exist: ${sourceDir}`);
|
|
return;
|
|
}
|
|
|
|
copyRecursiveSync(sourceDir, targetDir);
|
|
log('debug', `[Roo] Copied roocode directory to ${targetDir}`);
|
|
|
|
const rooModesDir = path.join(sourceDir, '.roo');
|
|
|
|
// Copy .roomodes to project root
|
|
const roomodesSrc = path.join(sourceDir, '.roomodes');
|
|
const roomodesDest = path.join(targetDir, '.roomodes');
|
|
if (fs.existsSync(roomodesSrc)) {
|
|
try {
|
|
fs.copyFileSync(roomodesSrc, roomodesDest);
|
|
log('debug', `[Roo] Copied .roomodes to ${roomodesDest}`);
|
|
} catch (err) {
|
|
log('error', `[Roo] Failed to copy .roomodes: ${err.message}`);
|
|
}
|
|
}
|
|
|
|
for (const mode of ROO_MODES) {
|
|
const src = path.join(rooModesDir, `rules-${mode}`, `${mode}-rules`);
|
|
const dest = path.join(targetDir, '.roo', `rules-${mode}`, `${mode}-rules`);
|
|
if (fs.existsSync(src)) {
|
|
try {
|
|
const destDir = path.dirname(dest);
|
|
if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true });
|
|
fs.copyFileSync(src, dest);
|
|
log('debug', `[Roo] Copied ${mode}-rules to ${dest}`);
|
|
} catch (err) {
|
|
log('error', `[Roo] Failed to copy ${src} to ${dest}: ${err.message}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function copyRecursiveSync(src, dest) {
|
|
const exists = fs.existsSync(src);
|
|
const stats = exists && fs.statSync(src);
|
|
const isDirectory = exists && stats.isDirectory();
|
|
if (isDirectory) {
|
|
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
fs.readdirSync(src).forEach((childItemName) => {
|
|
copyRecursiveSync(
|
|
path.join(src, childItemName),
|
|
path.join(dest, childItemName)
|
|
);
|
|
});
|
|
} else {
|
|
fs.copyFileSync(src, dest);
|
|
}
|
|
}
|
|
|
|
function onRemoveRulesProfile(targetDir) {
|
|
const roomodesPath = path.join(targetDir, '.roomodes');
|
|
if (fs.existsSync(roomodesPath)) {
|
|
try {
|
|
fs.rmSync(roomodesPath, { force: true });
|
|
log('debug', `[Roo] Removed .roomodes from ${roomodesPath}`);
|
|
} catch (err) {
|
|
log('error', `[Roo] Failed to remove .roomodes: ${err.message}`);
|
|
}
|
|
}
|
|
|
|
const rooDir = path.join(targetDir, '.roo');
|
|
if (fs.existsSync(rooDir)) {
|
|
fs.readdirSync(rooDir).forEach((entry) => {
|
|
if (entry.startsWith('rules-')) {
|
|
const modeDir = path.join(rooDir, entry);
|
|
try {
|
|
fs.rmSync(modeDir, { recursive: true, force: true });
|
|
log('debug', `[Roo] Removed ${entry} directory from ${modeDir}`);
|
|
} catch (err) {
|
|
log('error', `[Roo] Failed to remove ${modeDir}: ${err.message}`);
|
|
}
|
|
}
|
|
});
|
|
if (fs.readdirSync(rooDir).length === 0) {
|
|
try {
|
|
fs.rmSync(rooDir, { recursive: true, force: true });
|
|
log('debug', `[Roo] Removed empty .roo directory from ${rooDir}`);
|
|
} catch (err) {
|
|
log('error', `[Roo] Failed to remove .roo directory: ${err.message}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function onPostConvertRulesProfile(targetDir, assetsDir) {
|
|
onAddRulesProfile(targetDir, assetsDir);
|
|
}
|
|
|
|
// Create and export roo profile using the base factory
|
|
export const rooProfile = createProfile({
|
|
name: 'roo',
|
|
displayName: 'Roo Code',
|
|
url: 'roocode.com',
|
|
docsUrl: 'docs.roocode.com',
|
|
toolMappings: COMMON_TOOL_MAPPINGS.ROO_STYLE,
|
|
onAdd: onAddRulesProfile,
|
|
onRemove: onRemoveRulesProfile,
|
|
onPostConvert: onPostConvertRulesProfile
|
|
});
|
|
|
|
// Export lifecycle functions separately to avoid naming conflicts
|
|
export { onAddRulesProfile, onRemoveRulesProfile, onPostConvertRulesProfile };
|