/ src / utils / settings / managedPath.ts
managedPath.ts
 1  import memoize from 'lodash-es/memoize.js'
 2  import { join } from 'path'
 3  import { getPlatform } from '../platform.js'
 4  
 5  /**
 6   * Get the path to the managed settings directory based on the current platform.
 7   */
 8  export const getManagedFilePath = memoize(function (): string {
 9    // Allow override for testing/demos (Ant-only, eliminated from external builds)
10    if (
11      process.env.USER_TYPE === 'ant' &&
12      process.env.CLAUDE_CODE_MANAGED_SETTINGS_PATH
13    ) {
14      return process.env.CLAUDE_CODE_MANAGED_SETTINGS_PATH
15    }
16  
17    switch (getPlatform()) {
18      case 'macos':
19        return '/Library/Application Support/ClaudeCode'
20      case 'windows':
21        return 'C:\\Program Files\\ClaudeCode'
22      default:
23        return '/etc/claude-code'
24    }
25  })
26  
27  /**
28   * Get the path to the managed-settings.d/ drop-in directory.
29   * managed-settings.json is merged first (base), then files in this directory
30   * are merged alphabetically on top (drop-ins override base, later files win).
31   */
32  export const getManagedSettingsDropInDir = memoize(function (): string {
33    return join(getManagedFilePath(), 'managed-settings.d')
34  })