( cmd: string, toolPermissionContext: ToolPermissionContext, )
| 21 | } |
| 22 | |
| 23 | function 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 |
no test coverage detected