@@ -844,7 +844,7 @@ export class CustomModesManager {
844844 private async importRulesFiles (
845845 importMode : ExportedModeConfig ,
846846 rulesFiles : RuleFile [ ] ,
847- source : "global" | "project" ,
847+ source : "global" | "project" | "vscode" ,
848848 ) : Promise < void > {
849849 // Determine base directory and rules folder path based on source
850850 let baseDir : string
@@ -853,6 +853,10 @@ export class CustomModesManager {
853853 if ( source === "global" ) {
854854 baseDir = getGlobalRooDirectory ( )
855855 rulesFolderPath = path . join ( baseDir , `rules-${ importMode . slug } ` )
856+ } else if ( source === "vscode" ) {
857+ // VSCode-sourced modes shouldn't have rules files imported
858+ // They are read-only and managed by VS Code
859+ return
856860 } else {
857861 const workspacePath = getWorkspacePath ( )
858862 baseDir = path . join ( workspacePath , ".roo" )
@@ -919,12 +923,12 @@ export class CustomModesManager {
919923 /**
920924 * Imports modes from YAML content, including their associated rules files
921925 * @param yamlContent - The YAML content containing mode configurations
922- * @param source - Target level for import: "global" (all projects) or "project" (current workspace only)
926+ * @param source - Target level for import: "global" (all projects), "project" (current workspace only), or "vscode" (VS Code managed )
923927 * @returns Success status with optional error message
924928 */
925929 public async importModeWithRules (
926930 yamlContent : string ,
927- source : "global" | "project" = "project" ,
931+ source : "global" | "project" | "vscode" = "project" ,
928932 ) : Promise < ImportResult > {
929933 try {
930934 // Parse the YAML content with proper type validation
@@ -953,6 +957,14 @@ export class CustomModesManager {
953957 }
954958 }
955959
960+ // VSCode source is not allowed for imports
961+ if ( source === "vscode" ) {
962+ return {
963+ success : false ,
964+ error : "Cannot import modes with VSCode source. VSCode-sourced modes are managed by VS Code configuration." ,
965+ }
966+ }
967+
956968 // Process each mode in the import
957969 for ( const importMode of importData . customModes ) {
958970 const { rulesFiles, ...modeConfig } = importMode
@@ -977,9 +989,10 @@ export class CustomModesManager {
977989 }
978990
979991 // Import the mode configuration with the specified source
992+ // Note: "vscode" source is already rejected above, so this will only be "global" or "project"
980993 await this . updateCustomMode ( importMode . slug , {
981994 ...modeConfig ,
982- source : source , // Use the provided source parameter
995+ source : source as "global" | "project" , // Safe cast since "vscode" is rejected above
983996 } )
984997
985998 // Import rules files (this also handles cleanup of existing rules folders)
0 commit comments