Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions jupyter_ai_tools/toolkits/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ def write(file_path: str, content: str) -> str:
"""Writes content to a file on the local filesystem

Args:
file_path: The absolute path to the file to write
content: The content to write to the file
file_path:
The absolute path to the file to write
content:
The content to write to the file

Returns:
A success message or error message
Expand All @@ -92,10 +94,14 @@ def edit(file_path: str, old_string: str, new_string: str, replace_all: bool = F
"""Performs string replacement in a file

Args:
file_path: The absolute path to the file to modify
old_string: The text to replace
new_string: The text to replace it with
replace_all: Replace all occurrences of old_string (default False)
file_path:
The absolute path to the file to modify
old_string:
The text to replace
new_string:
The text to replace it with
replace_all:
Replace all occurrences of old_string (default False)

Returns:
A success message or error message
Expand Down Expand Up @@ -140,10 +146,14 @@ async def search_and_replace(
"""Performs pattern search and replace in a file.

Args:
file_path: The absolute path to the file to modify
pattern: The pattern to search for (supports sed syntax)
replacement: The replacement text
replace_all: Replace all occurrences of pattern (default False)
file_path:
The absolute path to the file to modify
pattern:
The pattern to search for (supports sed syntax)
replacement:
The replacement text
replace_all:
Replace all occurrences of pattern (default False)

Returns:
A success message or error message
Expand Down Expand Up @@ -193,8 +203,10 @@ async def glob(pattern: str, path: Optional[str] = None) -> str:
"""Searches for files that matches the glob pattern

Args:
pattern: The glob pattern to match files against
path: The directory to search in (optional, defaults to current directory)
pattern:
The glob pattern to match files against
path:
The directory to search in (optional, defaults to current directory)

Returns:
A list of matching file paths sorted by modification time
Expand Down Expand Up @@ -237,9 +249,12 @@ async def grep(
"""Fast content search using regular expressions

Args:
pattern: The regular expression pattern to search for in file contents
include: File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}") (optional)
path: The directory to search in (optional, defaults to current directory)
pattern:
The regular expression pattern to search for in file contents
include:
File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}") (optional)
path:
The directory to search in (optional, defaults to current directory)

Returns:
A list of file paths with at least one match
Expand Down Expand Up @@ -288,8 +303,10 @@ async def ls(path: str, ignore: Optional[List[str]] = None) -> str:
"""Lists files and directories in a given path

Args:
path: The absolute path to the directory to list
ignore: List of glob patterns to ignore (optional)
path:
The absolute path to the directory to list
ignore:
List of glob patterns to ignore (optional)

Returns:
A list of files and directories in the given path
Expand Down
Loading