openhands.runtime.plugins.agent_skills.file_ops.file_ops
file_ops.py
This module provides various file manipulation skills for the OpenHands agent.
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.
open_file
def open_file(path: str,
line_number: int | None = 1,
context_lines: int | None = WINDOW) -> None
Opens the file at the given path in the editor. IF the file is to be edited, first use scroll_down
repeatedly to read the full file!
If line_number is provided, the window will be moved to include that line.
It only shows the first 100 lines by default! context_lines
is the max number of lines to be displayed, up to 100. Use scroll_up
and scroll_down
to view more content up or down.
Arguments:
path
- str: The path to the file to open, preferred absolute path.line_number
- int | None = 1: The line number to move to. Defaults to 1.context_lines
- int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). 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