source dump of claude code
1import { getSettingsForSource } from '../settings/settings.js'
2
3/**
4 * Plugin names locked by org policy (policySettings.enabledPlugins).
5 *
6 * Returns null when managed settings declare no plugin entries (common
7 * case — no policy in effect).
8 */
9export function getManagedPluginNames(): Set<string> | null {
10 const enabledPlugins = getSettingsForSource('policySettings')?.enabledPlugins
11 if (!enabledPlugins) {
12 return null
13 }
14 const names = new Set<string>()
15 for (const [pluginId, value] of Object.entries(enabledPlugins)) {
16 // Only plugin@marketplace boolean entries (true OR false) are
17 // protected. Legacy owner/repo array form is not.
18 if (typeof value !== 'boolean' || !pluginId.includes('@')) {
19 continue
20 }
21 const name = pluginId.split('@')[0]
22 if (name) {
23 names.add(name)
24 }
25 }
26 return names.size > 0 ? names : null
27}