mirror of
https://github.com/codeaashu/claude-code.git
synced 2026-04-09 06:38:46 +03:00
claude-code
This commit is contained in:
52
src/commands/sandbox-toggle/index.ts
Normal file
52
src/commands/sandbox-toggle/index.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import figures from 'figures'
|
||||
import type { Command } from '../../commands.js'
|
||||
import { SandboxManager } from '../../utils/sandbox/sandbox-adapter.js'
|
||||
|
||||
const command = {
|
||||
name: 'sandbox',
|
||||
get description() {
|
||||
const currentlyEnabled = SandboxManager.isSandboxingEnabled()
|
||||
const autoAllow = SandboxManager.isAutoAllowBashIfSandboxedEnabled()
|
||||
const allowUnsandboxed = SandboxManager.areUnsandboxedCommandsAllowed()
|
||||
const isLocked = SandboxManager.areSandboxSettingsLockedByPolicy()
|
||||
const hasDeps = SandboxManager.checkDependencies().errors.length === 0
|
||||
|
||||
// Show warning icon if dependencies missing, otherwise enabled/disabled status
|
||||
let icon: string
|
||||
if (!hasDeps) {
|
||||
icon = figures.warning
|
||||
} else {
|
||||
icon = currentlyEnabled ? figures.tick : figures.circle
|
||||
}
|
||||
|
||||
let statusText = 'sandbox disabled'
|
||||
if (currentlyEnabled) {
|
||||
statusText = autoAllow
|
||||
? 'sandbox enabled (auto-allow)'
|
||||
: 'sandbox enabled'
|
||||
|
||||
// Add unsandboxed fallback status
|
||||
statusText += allowUnsandboxed ? ', fallback allowed' : ''
|
||||
}
|
||||
|
||||
if (isLocked) {
|
||||
statusText += ' (managed)'
|
||||
}
|
||||
|
||||
return `${icon} ${statusText} (⏎ to configure)`
|
||||
},
|
||||
argumentHint: 'exclude "command pattern"',
|
||||
get isHidden() {
|
||||
return (
|
||||
!SandboxManager.isSupportedPlatform() ||
|
||||
!SandboxManager.isPlatformInEnabledList()
|
||||
)
|
||||
},
|
||||
immediate: true,
|
||||
type: 'local-jsx',
|
||||
load: () => import('./sandbox-toggle.js'),
|
||||
} satisfies Command
|
||||
|
||||
export default command
|
||||
|
||||
|
||||
84
src/commands/sandbox-toggle/sandbox-toggle.tsx
Normal file
84
src/commands/sandbox-toggle/sandbox-toggle.tsx
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user