Skip to content

Commit d6cc322

Browse files
authored
Merge pull request #7 from 3coins/fix-read-notebook-tool
Updated to async tools, fix read, add cell
2 parents 8e1a693 + 8e2a330 commit d6cc322

File tree

3 files changed

+318
-85
lines changed

3 files changed

+318
-85
lines changed

jupyter_ai_tools/toolkits/file_system.py

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ def write(file_path: str, content: str) -> str:
6464
"""Writes content to a file on the local filesystem
6565
6666
Args:
67-
file_path: The absolute path to the file to write
68-
content: The content to write to the file
67+
file_path:
68+
The absolute path to the file to write
69+
content:
70+
The content to write to the file
6971
7072
Returns:
7173
A success message or error message
@@ -92,10 +94,14 @@ def edit(file_path: str, old_string: str, new_string: str, replace_all: bool = F
9294
"""Performs string replacement in a file
9395
9496
Args:
95-
file_path: The absolute path to the file to modify
96-
old_string: The text to replace
97-
new_string: The text to replace it with
98-
replace_all: Replace all occurrences of old_string (default False)
97+
file_path:
98+
The absolute path to the file to modify
99+
old_string:
100+
The text to replace
101+
new_string:
102+
The text to replace it with
103+
replace_all:
104+
Replace all occurrences of old_string (default False)
99105
100106
Returns:
101107
A success message or error message
@@ -140,10 +146,14 @@ async def search_and_replace(
140146
"""Performs pattern search and replace in a file.
141147
142148
Args:
143-
file_path: The absolute path to the file to modify
144-
pattern: The pattern to search for (supports sed syntax)
145-
replacement: The replacement text
146-
replace_all: Replace all occurrences of pattern (default False)
149+
file_path:
150+
The absolute path to the file to modify
151+
pattern:
152+
The pattern to search for (supports sed syntax)
153+
replacement:
154+
The replacement text
155+
replace_all:
156+
Replace all occurrences of pattern (default False)
147157
148158
Returns:
149159
A success message or error message
@@ -193,8 +203,10 @@ async def glob(pattern: str, path: Optional[str] = None) -> str:
193203
"""Searches for files that matches the glob pattern
194204
195205
Args:
196-
pattern: The glob pattern to match files against
197-
path: The directory to search in (optional, defaults to current directory)
206+
pattern:
207+
The glob pattern to match files against
208+
path:
209+
The directory to search in (optional, defaults to current directory)
198210
199211
Returns:
200212
A list of matching file paths sorted by modification time
@@ -237,9 +249,12 @@ async def grep(
237249
"""Fast content search using regular expressions
238250
239251
Args:
240-
pattern: The regular expression pattern to search for in file contents
241-
include: File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}") (optional)
242-
path: The directory to search in (optional, defaults to current directory)
252+
pattern:
253+
The regular expression pattern to search for in file contents
254+
include:
255+
File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}") (optional)
256+
path:
257+
The directory to search in (optional, defaults to current directory)
243258
244259
Returns:
245260
A list of file paths with at least one match
@@ -288,8 +303,10 @@ async def ls(path: str, ignore: Optional[List[str]] = None) -> str:
288303
"""Lists files and directories in a given path
289304
290305
Args:
291-
path: The absolute path to the directory to list
292-
ignore: List of glob patterns to ignore (optional)
306+
path:
307+
The absolute path to the directory to list
308+
ignore:
309+
List of glob patterns to ignore (optional)
293310
294311
Returns:
295312
A list of files and directories in the given path

0 commit comments

Comments
 (0)