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

Function getPolicySettingsOrigin

src/utils/settings/settings.ts:375–407  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

373 * Priority: remote > plist/hklm > file (managed-settings.json) > hkcu
374 */
375export function getPolicySettingsOrigin():
376 | 'remote'
377 | 'plist'
378 | 'hklm'
379 | 'file'
380 | 'hkcu'
381 | null {
382 // 1. Remote (highest)
383 const remoteSettings = getRemoteManagedSettingsSyncFromCache()
384 if (remoteSettings && Object.keys(remoteSettings).length > 0) {
385 return 'remote'
386 }
387
388 // 2. Admin-only MDM (HKLM / macOS plist)
389 const mdmResult = getMdmSettings()
390 if (Object.keys(mdmResult.settings).length > 0) {
391 return getPlatform() === 'macos' ? 'plist' : 'hklm'
392 }
393
394 // 3. managed-settings.json + managed-settings.d/ (file-based, requires admin)
395 const { settings: fileSettings } = loadManagedFileSettings()
396 if (fileSettings) {
397 return 'file'
398 }
399
400 // 4. HKCU (lowest — user-writable)
401 const hkcu = getHkcuSettings()
402 if (Object.keys(hkcu.settings).length > 0) {
403 return 'hkcu'
404 }
405
406 return null
407}
408
409/**
410 * Merges `settings` into the existing settings for `source` using lodash mergeWith.

Callers 1

Calls 6

getMdmSettingsFunction · 0.85
getPlatformFunction · 0.85
loadManagedFileSettingsFunction · 0.85
getHkcuSettingsFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected