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.
- create_file(filename: str): Creates and opens a new file with the given name.
- 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.
- edit_file_by_replace(file_name: str, to_replace: str, new_content: str): Replaces specific content in a file with new content.
- insert_content_at_line(file_name: str, line_number: int, content: str): Inserts given content at the specified line number in a file.
- append_file(file_name: str, content: str): Appends the given content to the end of the specified file.
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.