Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/core/config/CustomModesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ export class CustomModesManager {
private async importRulesFiles(
importMode: ExportedModeConfig,
rulesFiles: RuleFile[],
source: "global" | "project",
source: "global" | "project" | "vscode",
): Promise<void> {
// Determine base directory and rules folder path based on source
let baseDir: string
Expand All @@ -853,6 +853,10 @@ export class CustomModesManager {
if (source === "global") {
baseDir = getGlobalRooDirectory()
rulesFolderPath = path.join(baseDir, `rules-${importMode.slug}`)
} else if (source === "vscode") {
// VSCode-sourced modes shouldn't have rules files imported
// They are read-only and managed by VS Code
return
} else {
const workspacePath = getWorkspacePath()
baseDir = path.join(workspacePath, ".roo")
Expand Down Expand Up @@ -919,12 +923,12 @@ export class CustomModesManager {
/**
* Imports modes from YAML content, including their associated rules files
* @param yamlContent - The YAML content containing mode configurations
* @param source - Target level for import: "global" (all projects) or "project" (current workspace only)
* @param source - Target level for import: "global" (all projects), "project" (current workspace only), or "vscode" (VS Code managed)
* @returns Success status with optional error message
*/
public async importModeWithRules(
yamlContent: string,
source: "global" | "project" = "project",
source: "global" | "project" | "vscode" = "project",
): Promise<ImportResult> {
try {
// Parse the YAML content with proper type validation
Expand Down Expand Up @@ -953,6 +957,14 @@ export class CustomModesManager {
}
}

// VSCode source is not allowed for imports
if (source === "vscode") {
return {
success: false,
error: "Cannot import modes with VSCode source. VSCode-sourced modes are managed by VS Code configuration.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo/lexical consistency: The error message mixes 'VSCode' and 'VS Code'. Please standardize the naming across the message (e.g., either use 'VSCode' or 'VS Code' consistently).

Suggested change
error: "Cannot import modes with VSCode source. VSCode-sourced modes are managed by VS Code configuration.",
error: "Cannot import modes with VS Code source. VS Code-sourced modes are managed by VS Code configuration.",

}
}

// Process each mode in the import
for (const importMode of importData.customModes) {
const { rulesFiles, ...modeConfig } = importMode
Expand All @@ -977,9 +989,10 @@ export class CustomModesManager {
}

// Import the mode configuration with the specified source
// Note: "vscode" source is already rejected above, so this will only be "global" or "project"
await this.updateCustomMode(importMode.slug, {
...modeConfig,
source: source, // Use the provided source parameter
source: source as "global" | "project", // Safe cast since "vscode" is rejected above
})

// Import rules files (this also handles cleanup of existing rules folders)
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/en/mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"disconnect_servers_partial": "Failed to disconnect {{count}} MCP server(s). Check the output for details.",
"toolNotFound": "Tool '{{toolName}}' does not exist on server '{{serverName}}'. Available tools: {{availableTools}}",
"serverNotFound": "MCP server '{{serverName}}' is not configured. Available servers: {{availableServers}}",
"toolDisabled": "Tool '{{toolName}}' on server '{{serverName}}' is disabled. Available enabled tools: {{availableTools}}"
"toolDisabled": "Tool '{{toolName}}' on server '{{serverName}}' is disabled. Available enabled tools: {{availableTools}}",
"vscode_servers_readonly": "VSCode MCP servers are managed by VS Code and cannot be modified from Roo. Please edit them in VS Code settings."
},
"info": {
"server_restarting": "Restarting {{serverName}} MCP server...",
Expand Down
Loading
Loading