standardize parameter order

- Fixed parameter order inconsistency in cat_file to match other filesystem tools (path first)                                                                                                                                            
- Added proper quoting around file paths to handle spaces and special characters                                                                                                                                                          
- Standardized command construction across all filesystem functions                                                                                                                                                                       
- Improved documentation with consistent formatting and examples                                                                                                                                                                          
- Maintained integration with generic_linux_command's comprehensive security filtering                                                                                                                                                    
- Enhanced usability while preserving existing security infrastructure
This commit is contained in:
Giveen 2025-12-14 13:26:23 -07:00 committed by GitHub
parent de8abf6bcc
commit c0cdccda15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 5 deletions

View File

@ -9,7 +9,7 @@ from cai.sdk.agents import function_tool
def list_dir(path: str, args: str = "", ctf=None) -> str:
"""
List the contents of a directory.
by def .
Args:
path: The directory path to list contents from
args: Additional arguments to pass to the ls command
@ -17,7 +17,7 @@ def list_dir(path: str, args: str = "", ctf=None) -> str:
Returns:
str: The output of running the ls command
"""
command = f'ls {path} {args}'
command = f'ls {args} "{path}"'
return run_command(command, ctf=ctf)
@function_tool
@ -26,13 +26,13 @@ def cat_file(file_path: str, args: str = "", ctf=None) -> str:
Display the contents of a file.
Args:
args: Additional arguments to pass to the cat command
file_path: Path to the file to display contents of
args: Additional arguments to pass to the cat command
Returns:
str: The output of running the cat command
"""
command = f'cat {args} {file_path} '
command = f'cat {args} "{file_path}"'
return run_command(command, ctf=ctf)
@ -60,6 +60,13 @@ def pwd_command(ctf=None) -> str:
def find_file(file_path: str, args: str = "", ctf=None) -> str:
"""
Find a file in the filesystem.
Args:
file_path: The search path or pattern to find files
args: Additional arguments to pass to the find command
Returns:
str: The output of running the find command
"""
command = f'find {file_path} {args}'
command = f'find {args} "{file_path}"'
return run_command(command, ctf=ctf)