Elffuss BraidHub

kikocis/auto-code-rover public

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