MCPcopy Index your code
hub / github.com/codeaashu/claude-code / setPluginEnabledOp

Function setPluginEnabledOp

src/services/plugins/pluginOperations.ts:573–747  ·  view source on GitHub ↗
(
  plugin: string,
  enabled: boolean,
  scope?: InstallableScope,
)

Source from the content-addressed store, hash-verified

571 * @returns Result indicating success/failure
572 */
573export async function setPluginEnabledOp(
574 plugin: string,
575 enabled: boolean,
576 scope?: InstallableScope,
577): Promise<PluginOperationResult> {
578 const operation = enabled ? 'enable' : 'disable'
579
580 // Built-in plugins: always use user-scope settings, bypass the normal
581 // scope-resolution + installed_plugins lookup (they're not installed).
582 if (isBuiltinPluginId(plugin)) {
583 const { error } = updateSettingsForSource('userSettings', {
584 enabledPlugins: {
585 ...getSettingsForSource('userSettings')?.enabledPlugins,
586 [plugin]: enabled,
587 },
588 })
589 if (error) {
590 return {
591 success: false,
592 message: `Failed to ${operation} built-in plugin: ${error.message}`,
593 }
594 }
595 clearAllCaches()
596 const { name: pluginName } = parsePluginIdentifier(plugin)
597 return {
598 success: true,
599 message: `Successfully ${operation}d built-in plugin: ${pluginName}`,
600 pluginId: plugin,
601 pluginName,
602 scope: 'user',
603 }
604 }
605
606 if (scope) {
607 assertInstallableScope(scope)
608 }
609
610 // ── Resolve pluginId and scope from settings ──
611 // Search across editable scopes for any mention (enabled or disabled) of
612 // this plugin. Does NOT pre-gate on installed_plugins.json.
613 let pluginId: string
614 let resolvedScope: InstallableScope
615
616 const found = findPluginInSettings(plugin)
617
618 if (scope) {
619 // Explicit scope: use it. Resolve pluginId from settings if possible,
620 // otherwise require a full plugin@marketplace identifier.
621 resolvedScope = scope
622 if (found) {
623 pluginId = found.pluginId
624 } else if (plugin.includes('@')) {
625 pluginId = plugin
626 } else {
627 return {
628 success: false,
629 message: `Plugin "${plugin}" not found in settings. Use plugin@marketplace format.`,
630 }

Callers 3

enablePluginOpFunction · 0.85
disablePluginOpFunction · 0.85
disableAllPluginsOpFunction · 0.85

Calls 14

isBuiltinPluginIdFunction · 0.85
updateSettingsForSourceFunction · 0.85
getSettingsForSourceFunction · 0.85
clearAllCachesFunction · 0.85
parsePluginIdentifierFunction · 0.85
assertInstallableScopeFunction · 0.85
findPluginInSettingsFunction · 0.85
isPluginBlockedByPolicyFunction · 0.85
scopeToSettingSourceFunction · 0.85
getPluginEditableScopesFunction · 0.85
loadAllPluginsFunction · 0.85
findReverseDependentsFunction · 0.85

Tested by

no test coverage detected