π OpenHands: AI-Driven Development
Minor docstring & prompt fixes for AgentSkills (#2028)
Boxuan Lic59bcbbffdf3
diff --git a/opendevin/runtime/plugins/agent_skills/agentskills.py b/opendevin/runtime/plugins/agent_skills/agentskills.pyindex 9ae7a59ef4..0351c1bd09 100644--- a/opendevin/runtime/plugins/agent_skills/agentskills.py+++ b/opendevin/runtime/plugins/agent_skills/agentskills.py@@ -12,7 +12,7 @@ Functions:- search_dir(search_term, dir_path='./'): Searches for a term in all files in the specified directory.- search_file(search_term, file_path=None): Searches for a term in the specified file or the currently open file.- find_file(file_name, dir_path='./'): Finds all files with the given name in the specified directory.-- edit_file(path, start, end, content): Replaces lines in a file with the given content.+- edit_file(start, end, content): Replaces lines in a file with the given content."""import os@@ -35,7 +35,6 @@ def _lint_file(file_path: str) -> Optional[str]:Optional[str]: A string containing the linting report if the file failed to lint, None otherwise."""- # Check if the file ends with .py and if auto-linting is enabledif file_path.endswith('.py'):# Define the flake8 command with selected error codescommand = [@@ -58,7 +57,7 @@ def _lint_file(file_path: str) -> Optional[str]:ret = 'ERRORS:\n'ret += result.stdout.decode().strip()return ret.rstrip('\n')- # Linting skipped. Either the file is not a Python file or auto-linting is disabled.+ # Not a python file, skip lintingreturn None@@ -88,7 +87,7 @@ def _cur_file_header(CURRENT_FILE, total_lines):def open_file(path: str, line_number: Optional[int] = None) -> None:"""- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.@@ -197,8 +196,8 @@ def edit_file(start: int, end: int, content: str) -> None:It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with."""global CURRENT_FILE, CURRENT_LINE, WINDOWdiff --git a/tests/integration/mock/CodeActAgent/test_edits/prompt_001.log b/tests/integration/mock/CodeActAgent/test_edits/prompt_001.logindex 1393d3d112..b721882ea1 100644--- a/tests/integration/mock/CodeActAgent/test_edits/prompt_001.log+++ b/tests/integration/mock/CodeActAgent/test_edits/prompt_001.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:diff --git a/tests/integration/mock/CodeActAgent/test_edits/prompt_002.log b/tests/integration/mock/CodeActAgent/test_edits/prompt_002.logindex ee03ee3e56..e5f4a5bfda 100644--- a/tests/integration/mock/CodeActAgent/test_edits/prompt_002.log+++ b/tests/integration/mock/CodeActAgent/test_edits/prompt_002.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:diff --git a/tests/integration/mock/CodeActAgent/test_edits/prompt_003.log b/tests/integration/mock/CodeActAgent/test_edits/prompt_003.logindex 173edca584..eab65fc73b 100644--- a/tests/integration/mock/CodeActAgent/test_edits/prompt_003.log+++ b/tests/integration/mock/CodeActAgent/test_edits/prompt_003.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:diff --git a/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.log b/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.logindex 87e319849c..0b3ad30a94 100644--- a/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.log+++ b/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -291,4 +291,4 @@ NOW, LET'S START!Use Jupyter IPython to write a text file containing 'hello world' to '/workspace/test.txt'. Do not ask me for confirmation at any point.-ENVIRONMENT REMINDER: You have 9 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 9 turns left to complete the task.diff --git a/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log b/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.logindex cd8f3c6ca2..c9f42f6137 100644--- a/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log+++ b/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -304,4 +304,4 @@ with open('/workspace/test.txt', 'w') as f:OBSERVATION:[Code executed successfully with no output]-ENVIRONMENT REMINDER: You have 8 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 8 turns left to complete the task.diff --git a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.log b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.logindex 281f5aafb4..f30d99d13f 100644--- a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.log+++ b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -291,4 +291,4 @@ NOW, LET'S START!Install and import pymsgbox==1.0.9 and print it's version in /workspace/test.txt. Do not ask me for confirmation at any point.-ENVIRONMENT REMINDER: You have 9 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 9 turns left to complete the task.diff --git a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.log b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.logindex d311991a5a..bf367ef74e 100644--- a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.log+++ b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -311,4 +311,4 @@ OBSERVATION:[Package installed successfully][Kernel restarted successfully to load the package]-ENVIRONMENT REMINDER: You have 8 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 8 turns left to complete the task.diff --git a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.log b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.logindex a75fc450f3..e7499e34a9 100644--- a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.log+++ b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -336,4 +336,4 @@ with open("/workspace/test.txt", "w") as f:OBSERVATION:[Code executed successfully with no output]-ENVIRONMENT REMINDER: You have 7 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 7 turns left to complete the task.diff --git a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.log b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.logindex 55aa8684eb..0dbd5d1143 100644--- a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.log+++ b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -291,4 +291,4 @@ NOW, LET'S START!Write a shell script 'hello.sh' that prints 'hello'. Do not ask me for confirmation at any point.-ENVIRONMENT REMINDER: You have 9 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 9 turns left to complete the task.diff --git a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.log b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.logindex a122ddf3ab..850b39b1fb 100644--- a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.log+++ b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -305,4 +305,4 @@ OBSERVATION:[Command -1 finished with exit code 0]]-ENVIRONMENT REMINDER: You have 8 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 8 turns left to complete the task.diff --git a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.log b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.logindex c3170f9980..ca6571b805 100644--- a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.log+++ b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.log@@ -21,7 +21,7 @@ If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask theApart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:- Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.+ Opens the file at the given path in the editor. If line_number is provided, the window will be moved to include that line.Args:path: str: The path to the file to open.line_number: Optional[int]: The line number to move to.@@ -50,8 +50,8 @@ edit_file(start: int, end: int, content: str) -> None:Edit a file.It replaces lines `start` through `end` (inclusive) with the given text `content` in the open file. Remember, the file must be open before editing.Args:- start: int: The start line number. Must be greater or equal to 1.- end: int: The end line number. Must be greater or equal to 1 AND greater than start AND less than or equal to the number of lines in the file.+ start: int: The start line number. Must satisfy start >= 1.+ end: int: The end line number. Must satisfy start <= end <= number of lines in the file.content: str: The content to replace the lines with.search_dir(search_term: str, dir_path: str = './') -> None:@@ -318,4 +318,4 @@ OBSERVATION:hello[Command -1 finished with exit code 0]]-ENVIRONMENT REMINDER: You have 7 turns left to complete the task.\ No newline at end of file+ENVIRONMENT REMINDER: You have 7 turns left to complete the task.