Package atessera.sensei.tools
Class SourceCodeReader
java.lang.Object
atessera.sensei.tools.SourceCodeReader
LangChain4j tools that expose files inside a base directory.
Both tools accept only paths relative to the base directory supplied through the constructor. Absolute paths are rejected, and the resolved path must stay inside the base directory. Binary files are skipped during directory listing and return "BINARY" when read.
-
Constructor Summary
ConstructorsConstructorDescriptionSourceCodeReader(Path baseDirectory) Creates a reader rooted at the given directory. -
Method Summary
-
Constructor Details
-
SourceCodeReader
Creates a reader rooted at the given directory.- Parameters:
baseDirectory- base directory served by the tools
-
-
Method Details
-
listFiles
Lists files in a subdirectory of the base directory.Hidden files, whose names start with a dot, and binary files are skipped. Returned paths are relative to the base directory.
- Parameters:
subdirectory- subdirectory path relative to the base directory; use an empty string for the base directory itself- Returns:
- newline separated list of relative file paths
-
readFile
Reads a file by its path relative to the base directory.- Parameters:
relativePath- file path relative to the base directory- Returns:
- file contents or "BINARY" if the file is a binary file
-