You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
view_range:tuple[int,int]=None, # Optional 1-indexed (start, end) line range for files, end=-1 for EOF. Do NOT use unless it's known that the file is too big to keep in context—simply view the WHOLE file when possible
@@ -88,7 +103,7 @@ def view(
88
103
):
89
104
'View directory or file contents with optional line range and numbers'
90
105
try:
91
-
p=valid_path(path)
106
+
p=valid_path(path, chk_perms=False)
92
107
header=None
93
108
ifp.is_dir():
94
109
lines= [sforfinp.glob('**/*') if (s:=_fmt_path(f, p, skip_folders))]
@@ -106,6 +121,7 @@ def view(
106
121
except: returnexplain_exc('viewing')
107
122
108
123
# %% ../nbs/12_tools.ipynb #36f58e38
124
+
@llmtool
109
125
defcreate(
110
126
path: str, # Path where the new file should be created
111
127
file_text: str, # Content to write to the file
@@ -122,6 +138,7 @@ def create(
122
138
except: returnexplain_exc('creating file')
123
139
124
140
# %% ../nbs/12_tools.ipynb #434147ef
141
+
@llmtool
125
142
definsert(
126
143
path: str, # Path to the file to modify
127
144
insert_line: int, # Line number where to insert (0-based indexing)
@@ -139,6 +156,7 @@ def insert(
139
156
except: returnexplain_exc('inserting text')
140
157
141
158
# %% ../nbs/12_tools.ipynb #9272ff7d
159
+
@llmtool
142
160
defstr_replace(
143
161
path: str, # Path to the file to modify
144
162
old_str: str, # Text to find and replace
@@ -157,6 +175,7 @@ def str_replace(
157
175
except: returnexplain_exc('replacing text')
158
176
159
177
# %% ../nbs/12_tools.ipynb #eb907119
178
+
@llmtool
160
179
defstrs_replace(
161
180
path:str, # Path to the file to modify
162
181
old_strs:list[str], # List of strings to find and replace
@@ -167,6 +186,7 @@ def strs_replace(
167
186
return'Results for each replacement:\n'+'; '.join(res)
168
187
169
188
# %% ../nbs/12_tools.ipynb #94dd09ed
189
+
@llmtool
170
190
defreplace_lines(
171
191
path:str, # Path to the file to modify
172
192
start_line:int, # Starting line number to replace (1-based indexing)
@@ -184,6 +204,7 @@ def replace_lines(
184
204
except: returnexplain_exc('replacing lines')
185
205
186
206
# %% ../nbs/12_tools.ipynb #b136abf8
207
+
@llmtool
187
208
defmove_lines(
188
209
path: str, # Path to the file to modify
189
210
start_line: int, # Starting line number to move (1-based)
" argstr:str, # All args to the command, will be split with shlex\n",
304
317
" disallow_re:str=None, # optional regex which, if matched on argstr, will disallow the command\n",
@@ -436,6 +449,7 @@
436
449
"outputs": [],
437
450
"source": [
438
451
"#| export\n",
452
+
"@llmtool\n",
439
453
"def sed(\n",
440
454
" argstr:str, # All args to the command, will be split with shlex\n",
441
455
" disallow_re:str=None, # optional regex which, if matched on argstr, will disallow the command\n",
@@ -539,6 +553,7 @@
539
553
"outputs": [],
540
554
"source": [
541
555
"#| export\n",
556
+
"@llmtool\n",
542
557
"def view(\n",
543
558
" path:str, # Path to directory or file to view\n",
544
559
" view_range:tuple[int,int]=None, # Optional 1-indexed (start, end) line range for files, end=-1 for EOF. Do NOT use unless it's known that the file is too big to keep in context—simply view the WHOLE file when possible\n",
@@ -547,7 +562,7 @@
547
562
"):\n",
548
563
" 'View directory or file contents with optional line range and numbers'\n",
549
564
" try:\n",
550
-
" p = valid_path(path)\n",
565
+
" p = valid_path(path, chk_perms=False)\n",
551
566
" header = None\n",
552
567
" if p.is_dir():\n",
553
568
" lines = [s for f in p.glob('**/*') if (s := _fmt_path(f, p, skip_folders))]\n",
@@ -639,6 +654,7 @@
639
654
"outputs": [],
640
655
"source": [
641
656
"#| export\n",
657
+
"@llmtool\n",
642
658
"def create(\n",
643
659
" path: str, # Path where the new file should be created\n",
644
660
" file_text: str, # Content to write to the file\n",
@@ -665,7 +681,13 @@
665
681
"name": "stdout",
666
682
"output_type": "stream",
667
683
"text": [
668
-
"Created file /path/test.txt.\n",
684
+
"Created file /path/test.txt.\n"
685
+
]
686
+
},
687
+
{
688
+
"name": "stdout",
689
+
"output_type": "stream",
690
+
"text": [
669
691
"Contents:\n",
670
692
" 1 │ Hello, world!\n"
671
693
]
@@ -686,6 +708,7 @@
686
708
"outputs": [],
687
709
"source": [
688
710
"#| export\n",
711
+
"@llmtool\n",
689
712
"def insert(\n",
690
713
" path: str, # Path to the file to modify\n",
691
714
" insert_line: int, # Line number where to insert (0-based indexing)\n",
@@ -731,6 +754,7 @@
731
754
"outputs": [],
732
755
"source": [
733
756
"#| export\n",
757
+
"@llmtool\n",
734
758
"def str_replace(\n",
735
759
" path: str, # Path to the file to modify\n",
736
760
" old_str: str, # Text to find and replace\n",
@@ -799,6 +823,7 @@
799
823
"outputs": [],
800
824
"source": [
801
825
"#| export\n",
826
+
"@llmtool\n",
802
827
"def strs_replace(\n",
803
828
" path:str, # Path to the file to modify\n",
804
829
" old_strs:list[str], # List of strings to find and replace\n",
@@ -863,6 +888,7 @@
863
888
"outputs": [],
864
889
"source": [
865
890
"#| export\n",
891
+
"@llmtool\n",
866
892
"def replace_lines(\n",
867
893
" path:str, # Path to the file to modify\n",
868
894
" start_line:int, # Starting line number to replace (1-based indexing)\n",
@@ -929,6 +955,7 @@
929
955
"outputs": [],
930
956
"source": [
931
957
"#| export\n",
958
+
"@llmtool\n",
932
959
"def move_lines(\n",
933
960
" path: str, # Path to the file to modify\n",
934
961
" start_line: int, # Starting line number to move (1-based)\n",
0 commit comments