openhands.runtime.plugins.agent_skills.file_ops.file_ops
File operations module for OpenHands agent.
This module provides a collection of file manipulation skills that enable the OpenHands agent to perform various file operations such as opening, searching, and navigating through files and directories.
Functions:
- open_file(path: str, line_number: int | None = 1, context_lines: int = 100): Opens a file and optionally moves to a specific line.
- goto_line(line_number: int): Moves the window to show the specified line number.
- scroll_down(): Moves the window down by the number of lines specified in WINDOW.
- scroll_up(): Moves the window up by the number of lines specified in WINDOW.
- search_dir(search_term: str, dir_path: str = './'): Searches for a term in all files in the specified directory.
- search_file(search_term: str, file_path: str | None = None): Searches for a term in the specified file or the currently open file.
- find_file(file_name: str, dir_path: str = './'): Finds all files with the given name in the specified directory.
Notes:
All functions return string representations of their results.
open_file
def open_file(path: str,
line_number: int | None = 1,
context_lines: int | None = WINDOW) -> None
Opens a file in the editor and optionally positions at a specific line.
The function displays a limited window of content, centered around the specified line number if provided. To view the complete file content, the agent should use scroll_down and scroll_up commands iteratively.
Arguments:
path
- The path to the file to open. Absolute path is recommended.line_number
- The target line number to center the view on (if possible). Defaults to 1.context_lines
- Maximum number of lines to display in the view window. Limited to 100 lines. Defaults to 100.
goto_line
def goto_line(line_number: int) -> None
Moves the window to show the specified line number.
Arguments:
line_number
- int: The line number to move to.
scroll_down
def scroll_down() -> None
Moves the window down by 100 lines.
Arguments:
None
scroll_up
def scroll_up() -> None
Moves the window up by 100 lines.
Arguments:
None
search_dir
def search_dir(search_term: str, dir_path: str = './') -> None
Searches for search_term in all files in dir. If dir is not provided, searches in the current directory.
Arguments:
search_term
- str: The term to search for.dir_path
- str: The path to the directory to search.
search_file
def search_file(search_term: str, file_path: str | None = None) -> None
Searches for search_term in file. If file is not provided, searches in the current open file.
Arguments:
search_term
- The term to search for.file_path
- The path to the file to search.
find_file
def find_file(file_name: str, dir_path: str = './') -> None
Finds all files with the given name in the specified directory.
Arguments:
file_name
- str: The name of the file to find.dir_path
- str: The path to the directory to search.