Elffuss BraidHub

kikocis/auto-code-rover public

main · 29.7 KiBRawPermalink
1agent:
2 config:
3 _commands:
4 - arguments:
5 line_number:
6 description: the line number to move the window to (if not provided, the
7 window will start at the top of the file)
8 required: false
9 type: integer
10 path:
11 description: the path to the file to open
12 required: true
13 type: string
14 code: 'open() { if [ -z "$1" ] then echo "Usage: open <file>" return fi #
15 Check if the second argument is provided if [ -n "$2" ]; then #
16 Check if the provided argument is a valid number if ! [[ $2 =~ ^[0-9]+$
17 ]]; then echo "Usage: open <file> [<line_number>]" echo
18 "Error: <line_number> must be a number" return # Exit if the line
19 number is not valid fi local max_line=$(awk ''END {print NR}''
20 $1) if [ $2 -gt $max_line ]; then echo "Warning: <line_number>
21 ($2) is greater than the number of lines in the file ($max_line)" echo
22 "Warning: Setting <line_number> to $max_line" local line_number=$(jq
23 -n "$max_line") # Set line number to max if greater than max elif
24 [ $2 -lt 1 ]; then echo "Warning: <line_number> ($2) is less than
25 1" echo "Warning: Setting <line_number> to 1" local
26 line_number=$(jq -n "1") # Set line number to 1 if less than 1 else local
27 OFFSET=$(jq -n "$WINDOW/6" | jq ''floor'') local line_number=$(jq
28 -n "[$2 + $WINDOW/2 - $OFFSET, 1] | max | floor") fi else local
29 line_number=$(jq -n "$WINDOW/2") # Set default line number if not provided fi if
30 [ -f "$1" ]; then export CURRENT_FILE=$(realpath $1) export
31 CURRENT_LINE=$line_number _constrain_line _print elif [ -d
32 "$1" ]; then echo "Error: $1 is a directory. You can only open files.
33 Use cd or ls to navigate directories." else echo "File $1 not found" fi}'
34 docstring: opens the file at the given path in the editor. If line_number is
35 provided, the window will be move to include that line
36 end_name: null
37 name: open
38 signature: open <path> [<line_number>]
39 - arguments:
40 line_number:
41 description: the line number to move the window to
42 required: true
43 type: integer
44 code: 'goto() { if [ $# -gt 1 ]; then echo "goto allows only one line
45 number at a time." return fi if [ -z "$CURRENT_FILE" ] then echo
46 "No file open. Use the open command first." return fi if [ -z
47 "$1" ] then echo "Usage: goto <line>" return fi if
48 ! [[ $1 =~ ^[0-9]+$ ]] then echo "Usage: goto <line>" echo
49 "Error: <line> must be a number" return fi local max_line=$(awk
50 ''END {print NR}'' $CURRENT_FILE) if [ $1 -gt $max_line ] then echo
51 "Error: <line> must be less than or equal to $max_line" return fi local
52 OFFSET=$(jq -n "$WINDOW/6" | jq ''floor'') export CURRENT_LINE=$(jq -n
53 "[$1 + $WINDOW/2 - $OFFSET, 1] | max | floor") _constrain_line _print}'
54 docstring: moves the window to show <line_number>
55 end_name: null
56 name: goto
57 signature: goto <line_number>
58 - arguments: null
59 code: scroll_down() { if [ -z "$CURRENT_FILE" ] then echo "No file
60 open. Use the open command first." return fi export CURRENT_LINE=$(jq
61 -n "$CURRENT_LINE + $WINDOW - $OVERLAP") _constrain_line _print}
62 docstring: moves the window down {WINDOW} lines
63 end_name: null
64 name: scroll_down
65 signature: scroll_down
66 - arguments: null
67 code: scroll_up() { if [ -z "$CURRENT_FILE" ] then echo "No file
68 open. Use the open command first." return fi export CURRENT_LINE=$(jq
69 -n "$CURRENT_LINE - $WINDOW + $OVERLAP") _constrain_line _print}
70 docstring: moves the window down {WINDOW} lines
71 end_name: null
72 name: scroll_up
73 signature: scroll_down
74 - arguments:
75 filename:
76 description: the name of the file to create
77 required: true
78 type: string
79 code: "create() { if [ -z \"$1\" ]; then echo \"Usage: create <filename>\"\
80 \ return fi # Check if the file already exists if [ -e \"\
81 $1\" ]; then echo \"Error: File '$1' already exists.\"\t\topen \"$1\"\
82 \ return fi # Create the file an empty new line printf \"\\\
83 n\" > \"$1\" # Use the existing open command to open the created file \
84 \ open \"$1\"}"
85 docstring: creates and opens a new file with the given name
86 end_name: null
87 name: create
88 signature: create <filename>
89 - arguments: null
90 code: 'submit() { cd $ROOT # Check if the patch file exists and is non-empty if
91 [ -s "/root/test.patch" ]; then # Apply the patch in reverse git
92 apply -R < "/root/test.patch" fi git add -A git diff --cached > model.patch echo
93 "<<SUBMISSION||" cat model.patch echo "||SUBMISSION>>"}'
94 docstring: submits your current code and terminates the session
95 end_name: null
96 name: submit
97 signature: submit
98 - arguments:
99 dir:
100 description: the directory to search in (if not provided, searches in the
101 current directory)
102 required: false
103 type: string
104 search_term:
105 description: the term to search for
106 required: true
107 type: string
108 code: 'search_dir() { if [ $# -eq 1 ]; then local search_term="$1" local
109 dir="./" elif [ $# -eq 2 ]; then local search_term="$1" if
110 [ -d "$2" ]; then local dir="$2" else echo "Directory
111 $2 not found" return fi else echo "Usage: search_dir
112 <search_term> [<dir>]" return fi dir=$(realpath "$dir") local
113 matches=$(find "$dir" -type f ! -path ''*/.*'' -exec grep -nIH "$search_term"
114 {} + | cut -d: -f1 | sort | uniq -c) # if no matches, return if [ -z
115 "$matches" ]; then echo "No matches found for \"$search_term\" in $dir" return fi #
116 Calculate total number of matches local num_matches=$(echo "$matches" |
117 awk ''{sum+=$1} END {print sum}'') # calculate total number of files matched local
118 num_files=$(echo "$matches" | wc -l | awk ''{$1=$1; print $0}'') # if num_files
119 is > 100, print an error if [ $num_files -gt 100 ]; then echo "More
120 than $num_files files matched for \"$search_term\" in $dir. Please narrow
121 your search." return fi echo "Found $num_matches matches
122 for \"$search_term\" in $dir:" echo "$matches" | awk ''{$2=$2; gsub(/^\.+\/+/,
123 "./", $2); print $2 " ("$1" matches)"}'' echo "End of matches for \"$search_term\"
124 in $dir"}'
125 docstring: searches for search_term in all files in dir. If dir is not provided,
126 searches in the current directory
127 end_name: null
128 name: search_dir
129 signature: search_dir <search_term> [<dir>]
130 - arguments:
131 file:
132 description: the file to search in (if not provided, searches in the current
133 open file)
134 required: false
135 type: string
136 search_term:
137 description: the term to search for
138 required: true
139 type: string
140 code: 'search_file() { # Check if the first argument is provided if [
141 -z "$1" ]; then echo "Usage: search_file <search_term> [<file>]" return fi #
142 Check if the second argument is provided if [ -n "$2" ]; then #
143 Check if the provided argument is a valid file if [ -f "$2" ]; then local
144 file="$2" # Set file if valid else echo "Usage: search_file
145 <search_term> [<file>]" echo "Error: File name $2 not found. Please
146 provide a valid file name." return # Exit if the file is not valid fi else #
147 Check if a file is open if [ -z "$CURRENT_FILE" ]; then echo
148 "No file open. Use the open command first." return # Exit if no
149 file is open fi local file="$CURRENT_FILE" # Set file to the
150 current open file fi local search_term="$1" file=$(realpath "$file") #
151 Use grep to directly get the desired formatted output local matches=$(grep
152 -nH "$search_term" "$file") # Check if no matches were found if [ -z
153 "$matches" ]; then echo "No matches found for \"$search_term\" in $file" return fi #
154 Calculate total number of matches local num_matches=$(echo "$matches" |
155 wc -l | awk ''{$1=$1; print $0}'') # calculate total number of lines
156 matched local num_lines=$(echo "$matches" | cut -d: -f1 | sort | uniq |
157 wc -l | awk ''{$1=$1; print $0}'') # if num_lines is > 100, print an error if
158 [ $num_lines -gt 100 ]; then echo "More than $num_lines lines matched
159 for \"$search_term\" in $file. Please narrow your search." return fi #
160 Print the total number of matches and the matches themselves echo "Found
161 $num_matches matches for \"$search_term\" in $file:" echo "$matches" |
162 cut -d: -f1-2 | sort -u -t: -k2,2n | while IFS=: read -r filename line_number;
163 do echo "Line $line_number:$(sed -n "${line_number}p" "$file")" done echo
164 "End of matches for \"$search_term\" in $file"}'
165 docstring: searches for search_term in file. If file is not provided, searches
166 in the current open file
167 end_name: null
168 name: search_file
169 signature: search_file <search_term> [<file>]
170 - arguments:
171 dir:
172 description: the directory to search in (if not provided, searches in the
173 current directory)
174 required: false
175 type: string
176 file_name:
177 description: the name of the file to search for
178 required: true
179 type: string
180 code: 'find_file() { if [ $# -eq 1 ]; then local file_name="$1" local
181 dir="./" elif [ $# -eq 2 ]; then local file_name="$1" if
182 [ -d "$2" ]; then local dir="$2" else echo "Directory
183 $2 not found" return fi else echo "Usage: find_file
184 <file_name> [<dir>]" return fi dir=$(realpath "$dir") local
185 matches=$(find "$dir" -type f -name "$file_name") # if no matches, return if
186 [ -z "$matches" ]; then echo "No matches found for \"$file_name\" in
187 $dir" return fi # Calculate total number of matches local
188 num_matches=$(echo "$matches" | wc -l | awk ''{$1=$1; print $0}'') echo
189 "Found $num_matches matches for \"$file_name\" in $dir:" echo "$matches"
190 | awk ''{print $0}''}'
191 docstring: finds all files with the given name in dir. If dir is not provided,
192 searches in the current directory
193 end_name: null
194 name: find_file
195 signature: find_file <file_name> [<dir>]
196 - arguments:
197 end_line:
198 description: the line number to end the edit at (inclusive)
199 required: true
200 type: integer
201 replacement_text:
202 description: the text to replace the current selection with
203 required: true
204 type: string
205 start_line:
206 description: the line number to start the edit at
207 required: true
208 type: integer
209 code: 'edit() { if [ -z "$CURRENT_FILE" ] then echo ''No file open.
210 Use the `open` command first.'' return fi local start_line="$(echo
211 $1: | cut -d: -f1)" local end_line="$(echo $1: | cut -d: -f2)" if [
212 -z "$start_line" ] || [ -z "$end_line" ] then echo "Usage: edit
213 <start_line>:<end_line>" return fi local re=''^[0-9]+$'' if
214 ! [[ $start_line =~ $re ]]; then echo "Usage: edit <start_line>:<end_line>" echo
215 "Error: start_line must be a number" return fi if ! [[ $end_line
216 =~ $re ]]; then echo "Usage: edit <start_line>:<end_line>" echo
217 "Error: end_line must be a number" return fi # Bash array starts
218 at 0, so let''s adjust local start_line=$((start_line - 1)) local end_line=$((end_line)) local
219 line_count=0 local replacement=() while IFS= read -r line do replacement+=("$line") ((line_count++)) done #
220 Create a backup of the current file cp "$CURRENT_FILE" "/root/$(basename
221 "$CURRENT_FILE")_backup" # Read the file line by line into an array mapfile
222 -t lines < "$CURRENT_FILE" local new_lines=("${lines[@]:0:$start_line}"
223 "${replacement[@]}" "${lines[@]:$((end_line))}") # Write the new stuff
224 directly back into the original file printf "%s\n" "${new_lines[@]}" >|
225 "$CURRENT_FILE" # Run linter if [[ $CURRENT_FILE == *.py ]]; then lint_output=$(flake8
226 --select=F821,F822,F831,E111,E112,E113,E999,E902 "$CURRENT_FILE" 2>&1) else #
227 do nothing lint_output="" fi # if there is no output, then the
228 file is good if [ -z "$lint_output" ]; then export CURRENT_LINE=$start_line _constrain_line _print echo
229 "File updated. Please review the changes and make sure they are correct (correct
230 indentation, no duplicate lines, etc). Edit the file again if necessary." else echo
231 "Your proposed edit has introduced new syntax error(s). Please understand
232 the fixes and retry your edit commmand." echo "" echo "ERRORS:" _split_string
233 "$lint_output" echo "" # Save original values original_current_line=$CURRENT_LINE original_window=$WINDOW #
234 Update values export CURRENT_LINE=$(( (line_count / 2) + start_line
235 )) # Set to "center" of edit export WINDOW=$((line_count + 10)) # Show
236 +/- 5 lines around edit echo "This is how your edit would have looked
237 if applied" echo "-------------------------------------------------" _constrain_line _print echo
238 "-------------------------------------------------" echo "" #
239 Restoring CURRENT_FILE to original contents. cp "/root/$(basename "$CURRENT_FILE")_backup"
240 "$CURRENT_FILE" export CURRENT_LINE=$(( ((end_line - start_line + 1)
241 / 2) + start_line )) export WINDOW=$((end_line - start_line + 10)) echo
242 "This is the original code before your edit" echo "-------------------------------------------------" _constrain_line _print echo
243 "-------------------------------------------------" # Restore original
244 values export CURRENT_LINE=$original_current_line export WINDOW=$original_window echo
245 "Your changes have NOT been applied. Please fix your edit command and try
246 again." echo "You either need to 1) Specify the correct start/end line
247 arguments or 2) Correct your edit code." echo "DO NOT re-run the same
248 failed edit command. Running it again will lead to the same error." fi #
249 Remove backup file rm -f "/root/$(basename "$CURRENT_FILE")_backup"}'
250 docstring: replaces lines <start_line> through <end_line> (inclusive) with the
251 given text in the open file. The replacement text is terminated by a line
252 with only end_of_edit on it. All of the <replacement text> will be entered,
253 so make sure your indentation is formatted properly. Python files will be
254 checked for syntax errors after the edit. If the system detects a syntax error,
255 the edit will not be executed. Simply try to edit the file again, but make
256 sure to read the error message and modify the edit command you issue accordingly.
257 Issuing the same command a second time will just lead to the same error message
258 again.
259 end_name: end_of_edit
260 name: edit
261 signature: |-
262 edit <start_line>:<end_line>
263 <replacement_text>
264 end_of_edit
265 _subroutines: {}
266 blocklist:
267 - vim
268 - vi
269 - emacs
270 - nano
271 - nohup
272 - git
273 blocklist_error_template: Interactive operation '{name}' is not supported by this
274 environment
275 blocklist_standalone:
276 - python
277 - python3
278 - ipython
279 - bash
280 - sh
281 - exit
282 - /bin/bash
283 - /bin/sh
284 - nohup
285 - vi
286 - vim
287 - emacs
288 - nano
289 command_docs: |+
290 open:
291 docstring: opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line
292 signature: open <path> [<line_number>]
293 arguments:
294 - path (string) [required]: the path to the file to open
295 - line_number (integer) [optional]: the line number to move the window to (if not provided, the window will start at the top of the file)
296
297 goto:
298 docstring: moves the window to show <line_number>
299 signature: goto <line_number>
300 arguments:
301 - line_number (integer) [required]: the line number to move the window to
302
303 scroll_down:
304 docstring: moves the window down {WINDOW} lines
305 signature: scroll_down
306
307 scroll_up:
308 docstring: moves the window down {WINDOW} lines
309 signature: scroll_down
310
311 create:
312 docstring: creates and opens a new file with the given name
313 signature: create <filename>
314 arguments:
315 - filename (string) [required]: the name of the file to create
316
317 submit:
318 docstring: submits your current code and terminates the session
319 signature: submit
320
321 search_dir:
322 docstring: searches for search_term in all files in dir. If dir is not provided, searches in the current directory
323 signature: search_dir <search_term> [<dir>]
324 arguments:
325 - search_term (string) [required]: the term to search for
326 - dir (string) [optional]: the directory to search in (if not provided, searches in the current directory)
327
328 search_file:
329 docstring: searches for search_term in file. If file is not provided, searches in the current open file
330 signature: search_file <search_term> [<file>]
331 arguments:
332 - search_term (string) [required]: the term to search for
333 - file (string) [optional]: the file to search in (if not provided, searches in the current open file)
334
335 find_file:
336 docstring: finds all files with the given name in dir. If dir is not provided, searches in the current directory
337 signature: find_file <file_name> [<dir>]
338 arguments:
339 - file_name (string) [required]: the name of the file to search for
340 - dir (string) [optional]: the directory to search in (if not provided, searches in the current directory)
341
342 edit:
343 docstring: replaces lines <start_line> through <end_line> (inclusive) with the given text in the open file. The replacement text is terminated by a line with only end_of_edit on it. All of the <replacement text> will be entered, so make sure your indentation is formatted properly. Python files will be checked for syntax errors after the edit. If the system detects a syntax error, the edit will not be executed. Simply try to edit the file again, but make sure to read the error message and modify the edit command you issue accordingly. Issuing the same command a second time will just lead to the same error message again.
344 signature: edit <start_line>:<end_line>
345 <replacement_text>
346 end_of_edit
347 arguments:
348 - start_line (integer) [required]: the line number to start the edit at
349 - end_line (integer) [required]: the line number to end the edit at (inclusive)
350 - replacement_text (string) [required]: the text to replace the current selection with
351
352 command_files:
353 - config/commands/defaults.sh
354 - config/commands/search.sh
355 - config/commands/edit_linting.sh
356 - config/commands/_split_string.py
357 demonstration_template: |
358 Here is a demonstration of how to correctly accomplish this task.
359 It is included to show you how to correctly use the interface.
360 You do not need to follow exactly what is done in the demonstration.
361 --- DEMONSTRATION ---
362 {demonstration}
363 --- END OF DEMONSTRATION ---
364 demonstrations: []
365 env_variables:
366 CURRENT_FILE: ''
367 CURRENT_LINE: '0'
368 OVERLAP: '2'
369 SEARCH_FILES: ()
370 SEARCH_INDEX: '0'
371 SEARCH_RESULTS: ()
372 WINDOW: '100'
373 format_error_template: |
374 Your output was not formatted correctly. You must always include one discussion and one command as part of your response. Make sure you do not have multiple discussion/command tags.
375 Please make sure your output precisely matches the following format:
376 DISCUSSION
377 Discuss here with yourself about what your planning and what you're going to do in this step.
378
379 ```
380 command(s) that you're going to run
381 ```
382 history_processor: {}
383 history_processor_args: {}
384 instance_template: "We're currently solving the following issue within our repository.\
385 \ Here's the issue text:\nISSUE:\n{issue}\n\nINSTRUCTIONS:\nNow, you're going\
386 \ to solve this issue on your own. Your terminal session has started and you're\
387 \ in the repository's root directory. You can use any bash commands or the special\
388 \ interface to help you. Edit all the files you need to and run any checks or\
389 \ tests that you want. \nRemember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME.\
390 \ You should always wait for feedback after every command. \nWhen you're satisfied\
391 \ with all of the changes you've made, you can submit your changes to the code\
392 \ base by simply running the submit command.\nNote however that you cannot use\
393 \ any interactive session commands (e.g. python, vim) in this environment, but\
394 \ you can write scripts and run them. E.g. you can write a python script and\
395 \ then run it with `python <script_name>.py`.\n\nNOTE ABOUT THE EDIT COMMAND:\
396 \ Indentation really matters! When editing a file, make sure to insert appropriate\
397 \ indentation before each line! \n\nIMPORTANT TIPS:\n1. Always start by trying\
398 \ to replicate the bug that the issues discusses. \n If the issue includes\
399 \ code for reproducing the bug, we recommend that you re-implement that in your\
400 \ environment, and run it to make sure you can reproduce the bug.\n Then start\
401 \ trying to fix it.\n When you think you've fixed the bug, re-run the bug\
402 \ reproduction script to make sure that the bug has indeed been fixed.\n \n\
403 \ If the bug reproduction script does not print anything when it succesfully\
404 \ runs, we recommend adding a print(\"Script completed successfully, no errors.\"\
405 ) command at the end of the file,\n so that you can be sure that the script\
406 \ indeed ran fine all the way through. \n\n2. If you run a command and it doesn't\
407 \ work, try running a different command. A command that did not work once will\
408 \ not work the second time unless you modify it!\n\n3. If you open a file and\
409 \ need to get to an area around a specific line that is not in the first 100\
410 \ lines, say line 583, don't just use the scroll_down command multiple times.\
411 \ Instead, use the goto 583 command. It's much quicker. \n \n4. If the bug\
412 \ reproduction script requires inputting/reading a specific file, such as buggy-input.png,\
413 \ and you'd like to understand how to input that file, conduct a search in the\
414 \ existing repo code, to see whether someone else has already done that. Do\
415 \ this by running the command: find_file \"buggy-input.png\" If that doensn't\
416 \ work, use the linux 'find' command. \n\n5. Always make sure to look at the\
417 \ currently open file and the current working directory (which appears right\
418 \ after the currently open file). The currently open file might be in a different\
419 \ directory than the working directory! Note that some commands, such as 'create',\
420 \ open files, so they might change the current open file.\n\n6. When editing\
421 \ files, it is easy to accidentally specify a wrong line number or to write\
422 \ code with incorrect indentation. Always check the code after you issue an\
423 \ edit to make sure that it reflects what you wanted to accomplish. If it didn't,\
424 \ issue another command to fix it.\n \n\n(Open file: {open_file})\n(Current\
425 \ directory: {working_dir})\nbash-$"
426 next_step_no_output_template: |-
427 Your command ran successfully and did not produce any output.
428 (Open file: {open_file})
429 (Current directory: {working_dir})
430 bash-$
431 next_step_template: |-
432 {observation}
433 (Open file: {open_file})
434 (Current directory: {working_dir})
435 bash-$
436 parse_command: {}
437 parse_function: {}
438 put_demos_in_history: false
439 state_command:
440 arguments: null
441 code: |
442 state() {
443 local working_dir="$PWD";
444 if [ -z $CURRENT_FILE ]; then
445 echo '{"open_file": "n/a", "working_dir": "'$working_dir'"}';
446 else
447 echo '{"open_file": "'$(realpath $CURRENT_FILE)'", "working_dir": "'$working_dir'"}';
448 fi
449 };
450 docstring: null
451 end_name: null
452 name: state
453 signature: null
454 strategy_template: null
455 submit_command: submit
456 subroutine_types: []
457 system_template: "SETTING: You are an autonomous programmer, and you're working\
458 \ directly in the command line with a special interface.\n\nThe special interface\
459 \ consists of a file editor that shows you {WINDOW} lines of a file at a time.\n\
460 In addition to typical bash commands, you can also use the following commands\
461 \ to help you navigate and edit files.\n\nCOMMANDS:\n{command_docs}\n\nPlease\
462 \ note that THE EDIT COMMAND REQUIRES PROPER INDENTATION. \nIf you'd like to\
463 \ add the line ' print(x)' you must fully write that out, with all those\
464 \ spaces before the code! Indentation is important and code that is not idented\
465 \ correctly will fail and require fixing before it can be run.\n\nRESPONSE FORMAT:\n\
466 Your shell prompt is formatted as follows:\n(Open file: <path>) <cwd> $\n\n\
467 You need to format your output using two fields; discussion and command.\nYour\
468 \ output should always include _one_ discussion and _one_ command field EXACTLY\
469 \ as in the following example:\nDISCUSSION\nFirst I'll start by using ls to\
470 \ see what files are in the current directory. Then maybe we can look at some\
471 \ relevant files to see what they look like.\n```\nls -a\n```\n\nYou should\
472 \ only include a *SINGLE* command in the command section and then wait for a\
473 \ response from the shell before continuing with more discussion and commands.\
474 \ Everything you include in the DISCUSSION section will be saved for future\
475 \ reference.\nIf you'd like to issue two commands at once, PLEASE DO NOT DO\
476 \ THAT! Please instead first submit just the first command, and then after receiving\
477 \ a response you'll be able to issue the second command. \nYou're free to use\
478 \ any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition\
479 \ to the special commands listed above.\nHowever, the environment does NOT support\
480 \ interactive session commands (e.g. python, vim), so please do not invoke them."
481 util_functions:
482 - arguments: null
483 code: '_print() { local total_lines=$(awk ''END {print NR}'' $CURRENT_FILE) echo
484 "[File: $(realpath $CURRENT_FILE) ($total_lines lines total)]" lines_above=$(jq
485 -n "$CURRENT_LINE - $WINDOW/2" | jq ''[0, .] | max | floor'') lines_below=$(jq
486 -n "$total_lines - $CURRENT_LINE - $WINDOW/2" | jq ''[0, .] | max | round'') if
487 [ $lines_above -gt 0 ]; then echo "($lines_above more lines above)" fi cat
488 $CURRENT_FILE | grep -n $ | head -n $(jq -n "[$CURRENT_LINE + $WINDOW/2, $WINDOW/2]
489 | max | floor") | tail -n $(jq -n "$WINDOW") if [ $lines_below -gt 0 ];
490 then echo "($lines_below more lines below)" fi}'
491 docstring: null
492 end_name: null
493 name: _print
494 signature: _print
495 - arguments: null
496 code: _constrain_line() { if [ -z "$CURRENT_FILE" ] then echo "No
497 file open. Use the open command first." return fi local max_line=$(awk
498 'END {print NR}' $CURRENT_FILE) local half_window=$(jq -n "$WINDOW/2" |
499 jq 'floor') export CURRENT_LINE=$(jq -n "[$CURRENT_LINE, $max_line - $half_window]
500 | min") export CURRENT_LINE=$(jq -n "[$CURRENT_LINE, $half_window] | max")}
501 docstring: null
502 end_name: null
503 name: _constrain_line
504 signature: _constrain_line
505 config_file: config/default.yaml
506 model:
507 model_name: gpt4-0125
508 per_instance_cost_limit: 2.0
509 replay_path: null
510 temperature: 0.2
511 top_p: 0.95
512 total_cost_limit: 0.0
513environment:
514 base_commit: null
515 container_name: null
516 data_path: princeton-nlp/SWE-bench_Lite
517 image_name: swe-agent
518 install_environment: true
519 no_mirror: false
520 split: test
521 timeout: 35
522 verbose: true
523instance_filter: .*
524skip_existing: true
525suffix: ''