diff --git a/src/i18n/locales/en/marketplace.json b/src/i18n/locales/en/marketplace.json index 17ae20078a..b911cb8ec5 100644 --- a/src/i18n/locales/en/marketplace.json +++ b/src/i18n/locales/en/marketplace.json @@ -64,6 +64,7 @@ "installError": "Failed to install \"{{itemName}}\": {{errorMessage}}", "removing": "Removing item: \"{{itemName}}\"", "removeSuccess": "\"{{itemName}}\" removed successfully", - "removeError": "Failed to remove \"{{itemName}}\": {{errorMessage}}" + "removeError": "Failed to remove \"{{itemName}}\": {{errorMessage}}", + "notInstalledForTarget": "Mode not found" } } diff --git a/src/services/marketplace/MarketplaceManager.ts b/src/services/marketplace/MarketplaceManager.ts index 704b930a21..72ac6b64da 100644 --- a/src/services/marketplace/MarketplaceManager.ts +++ b/src/services/marketplace/MarketplaceManager.ts @@ -4,7 +4,13 @@ import * as path from "path" import * as vscode from "vscode" import * as yaml from "yaml" -import type { OrganizationSettings, MarketplaceItem, MarketplaceItemType, McpMarketplaceItem, ModeConfig } from "@roo-code/types" +import type { + OrganizationSettings, + MarketplaceItem, + MarketplaceItemType, + McpMarketplaceItem, + ModeConfig, +} from "@roo-code/types" import { customModesSettingsSchema } from "@roo-code/types" import { TelemetryService } from "@roo-code/telemetry" import { CloudService } from "@roo-code/cloud" @@ -254,10 +260,7 @@ export class MarketplaceManager { } // Helper: parse YAML and collect installed mode metadata with proper typing - private collectInstalledModesFromYaml( - content: string, - out: Record, - ): void { + private collectInstalledModesFromYaml(content: string, out: Record): void { try { const parsed = yaml.parse(content) const result = customModesSettingsSchema.safeParse(parsed) @@ -266,7 +269,7 @@ export class MarketplaceManager { } for (const mode of result.data.customModes) { if (this.isMarketplaceInstalledMode(mode)) { - out[mode.marketplaceItemId!] = { type: "mode" } + out[mode.marketplaceItemId] = { type: "mode" } } } } catch { diff --git a/src/services/marketplace/SimpleInstaller.ts b/src/services/marketplace/SimpleInstaller.ts index 960dcedc0b..ac53c14fb8 100644 --- a/src/services/marketplace/SimpleInstaller.ts +++ b/src/services/marketplace/SimpleInstaller.ts @@ -2,7 +2,7 @@ import * as vscode from "vscode" import * as path from "path" import * as fs from "fs/promises" import * as yaml from "yaml" -import type { MarketplaceItem, MarketplaceItemType, InstallMarketplaceItemOptions, McpParameter, ModeConfig } from "@roo-code/types" +import type { MarketplaceItem, McpParameter, ModeConfig } from "@roo-code/types" import { GlobalFileNames } from "../../shared/globalFileNames" import { ensureSettingsDirectoryExists } from "../../utils/globalContext" import type { CustomModesManager } from "../../core/config/CustomModesManager" @@ -22,6 +22,7 @@ export class SimpleInstaller { async installItem(item: MarketplaceItem, options: InstallOptions): Promise<{ filePath: string; line?: number }> { const { target } = options + const itemType = item.type switch (item.type) { case "mode": @@ -29,7 +30,7 @@ export class SimpleInstaller { case "mcp": return await this.installMcp(item, target, options) default: - throw new Error("Unsupported item type") + throw new Error(`Unsupported item type: ${itemType}`) } } @@ -293,6 +294,7 @@ export class SimpleInstaller { async removeItem(item: MarketplaceItem, options: InstallOptions): Promise { const { target } = options + const itemType = item.type switch (item.type) { case "mode": @@ -302,7 +304,7 @@ export class SimpleInstaller { await this.removeMcp(item, target) break default: - throw new Error("Unsupported item type") + throw new Error(`Unsupported item type: ${itemType}`) } } @@ -343,16 +345,12 @@ export class SimpleInstaller { ) if (!candidate) { - throw new Error(t("common:customModes.errors.modeNotFound")) + const msg = t("marketplace:installation.notInstalledForTarget") + throw new Error(msg === "installation.notInstalledForTarget" ? "Mode not found" : msg) } // Delete only from the selected source to avoid unintended removals - if (typeof (this.customModesManager as any).deleteCustomModeForSource === "function") { - await (this.customModesManager as any).deleteCustomModeForSource(modeSlug, target, true) - } else { - // Scoped deletion not supported in this version - throw new Error("Scoped deletion is not supported in this version") - } + await this.customModesManager.deleteCustomModeForSource(modeSlug, target, true) } private async removeMcp(item: MarketplaceItem, target: "project" | "global"): Promise {