MCPcopy Index your code
hub / github.com/codeaashu/claude-code / validateCommandForMode

Function validateCommandForMode

src/tools/BashTool/modeValidation.ts:23–56  ·  view source on GitHub ↗
(
  cmd: string,
  toolPermissionContext: ToolPermissionContext,
)

Source from the content-addressed store, hash-verified

21}
22
23function validateCommandForMode(
24 cmd: string,
25 toolPermissionContext: ToolPermissionContext,
26): PermissionResult {
27 const trimmedCmd = cmd.trim()
28 const [baseCmd] = trimmedCmd.split(/\s+/)
29
30 if (!baseCmd) {
31 return {
32 behavior: 'passthrough',
33 message: 'Base command not found',
34 }
35 }
36
37 // In Accept Edits mode, auto-allow filesystem operations
38 if (
39 toolPermissionContext.mode === 'acceptEdits' &&
40 isFilesystemCommand(baseCmd)
41 ) {
42 return {
43 behavior: 'allow',
44 updatedInput: { command: cmd },
45 decisionReason: {
46 type: 'mode',
47 mode: 'acceptEdits',
48 },
49 }
50 }
51
52 return {
53 behavior: 'passthrough',
54 message: `No mode-specific handling for '${baseCmd}' in ${toolPermissionContext.mode} mode`,
55 }
56}
57
58/**
59 * Checks if commands should be handled differently based on the current permission mode

Callers 1

checkPermissionModeFunction · 0.85

Calls 1

isFilesystemCommandFunction · 0.85

Tested by

no test coverage detected