source dump of claude code
at main 50 lines 1.5 kB view raw
1import figures from 'figures' 2import type { Command } from '../../commands.js' 3import { SandboxManager } from '../../utils/sandbox/sandbox-adapter.js' 4 5const command = { 6 name: 'sandbox', 7 get description() { 8 const currentlyEnabled = SandboxManager.isSandboxingEnabled() 9 const autoAllow = SandboxManager.isAutoAllowBashIfSandboxedEnabled() 10 const allowUnsandboxed = SandboxManager.areUnsandboxedCommandsAllowed() 11 const isLocked = SandboxManager.areSandboxSettingsLockedByPolicy() 12 const hasDeps = SandboxManager.checkDependencies().errors.length === 0 13 14 // Show warning icon if dependencies missing, otherwise enabled/disabled status 15 let icon: string 16 if (!hasDeps) { 17 icon = figures.warning 18 } else { 19 icon = currentlyEnabled ? figures.tick : figures.circle 20 } 21 22 let statusText = 'sandbox disabled' 23 if (currentlyEnabled) { 24 statusText = autoAllow 25 ? 'sandbox enabled (auto-allow)' 26 : 'sandbox enabled' 27 28 // Add unsandboxed fallback status 29 statusText += allowUnsandboxed ? ', fallback allowed' : '' 30 } 31 32 if (isLocked) { 33 statusText += ' (managed)' 34 } 35 36 return `${icon} ${statusText} (⏎ to configure)` 37 }, 38 argumentHint: 'exclude "command pattern"', 39 get isHidden() { 40 return ( 41 !SandboxManager.isSupportedPlatform() || 42 !SandboxManager.isPlatformInEnabledList() 43 ) 44 }, 45 immediate: true, 46 type: 'local-jsx', 47 load: () => import('./sandbox-toggle.js'), 48} satisfies Command 49 50export default command