MCPcopy
hub / github.com/codeaashu/claude-code / uninstallPluginOp

Function uninstallPluginOp

src/services/plugins/pluginOperations.ts:427–558  ·  view source on GitHub ↗
(
  plugin: string,
  scope: InstallableScope = 'user',
  deleteDataDir = true,
)

Source from the content-addressed store, hash-verified

425 * @returns Result indicating success/failure
426 */
427export async function uninstallPluginOp(
428 plugin: string,
429 scope: InstallableScope = 'user',
430 deleteDataDir = true,
431): Promise<PluginOperationResult> {
432 // Validate scope at runtime for early error detection
433 assertInstallableScope(scope)
434
435 const { enabled, disabled } = await loadAllPlugins()
436 const allPlugins = [...enabled, ...disabled]
437
438 // Find the plugin
439 const foundPlugin = findPluginByIdentifier(plugin, allPlugins)
440
441 const settingSource = scopeToSettingSource(scope)
442 const settings = getSettingsForSource(settingSource)
443
444 let pluginId: string
445 let pluginName: string
446
447 if (foundPlugin) {
448 // Find the matching settings key for this plugin (may differ from `plugin`
449 // if user gave short name but settings has plugin@marketplace)
450 pluginId =
451 Object.keys(settings?.enabledPlugins ?? {}).find(
452 k =>
453 k === plugin ||
454 k === foundPlugin.name ||
455 k.startsWith(`${foundPlugin.name}@`),
456 ) ?? (plugin.includes('@') ? plugin : foundPlugin.name)
457 pluginName = foundPlugin.name
458 } else {
459 // Plugin not found via marketplace lookup — it may have been delisted.
460 // Fall back to installed_plugins.json (V2) which tracks installations
461 // independently of marketplace state.
462 const resolved = resolveDelistedPluginId(plugin)
463 if (!resolved) {
464 return {
465 success: false,
466 message: `Plugin "${plugin}" not found in installed plugins`,
467 }
468 }
469 pluginId = resolved.pluginId
470 pluginName = resolved.pluginName
471 }
472
473 // Check if the plugin is installed in this scope (in V2 file)
474 const projectPath = getProjectPathForScope(scope)
475 const installedData = loadInstalledPluginsV2()
476 const installations = installedData.plugins[pluginId]
477 const scopeInstallation = installations?.find(
478 i => i.scope === scope && i.projectPath === projectPath,
479 )
480
481 if (!scopeInstallation) {
482 // Try to find where the plugin is actually installed to provide a helpful error
483 const { scope: actualScope } = getPluginInstallationFromV2(pluginId)
484 if (actualScope !== scope && installations && installations.length > 0) {

Callers 5

handleSingleOperationFunction · 0.85
ManagePluginsFunction · 0.85
doUninstallFunction · 0.85
uninstallPluginFunction · 0.85

Calls 15

assertInstallableScopeFunction · 0.85
loadAllPluginsFunction · 0.85
findPluginByIdentifierFunction · 0.85
scopeToSettingSourceFunction · 0.85
getSettingsForSourceFunction · 0.85
resolveDelistedPluginIdFunction · 0.85
getProjectPathForScopeFunction · 0.85
loadInstalledPluginsV2Function · 0.85
updateSettingsForSourceFunction · 0.85
clearAllCachesFunction · 0.85
removePluginInstallationFunction · 0.85

Tested by

no test coverage detected