Package com.embabel.agent.tools.file
Interface FileReadTools
-
- All Implemented Interfaces:
-
com.embabel.agent.api.common.support.SelfToolPublisher,com.embabel.agent.core.ToolPublisher,com.embabel.agent.core.ToolSpec,com.embabel.agent.tools.DirectoryBased,com.embabel.agent.tools.file.FileAccessLog,com.embabel.agent.tools.file.FileReadLog
public interface FileReadTools implements DirectoryBased, FileReadLog, FileAccessLog, SelfToolPublisher
LLM-ready ToolCallbacks and convenience methods for file operations. Use at your own risk: This makes changes to your host machine!!
-
-
Method Summary
Modifier and Type Method Description List<String>getPathsAccessed()Booleanexists()Does this file exist? IntegerfileCount()Count the total number of files in the repository (excluding .git directory). List<String>findFiles(String glob)List<String>findFiles(String glob, Boolean findHighest)Find files using glob patterns. StringsafeReadFile(String path)Use for safe reading of files. StringfileSize(String path)StringreadFile(String path)List<String>listFiles(String path)PathresolvePath(String path)PathresolveAndValidateFile(String path)abstract List<StringTransformer>getFileContentTransformers()Provide sanitizers that run on file content before returning it. -
Methods inherited from class com.embabel.agent.tools.file.FileReadLog
flushReads, getPathsRead, getReads, recordRead -
Methods inherited from class com.embabel.agent.tools.DirectoryBased
getRoot -
Methods inherited from class com.embabel.agent.api.common.support.SelfToolPublisher
getTools -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getPathsAccessed
List<String> getPathsAccessed()
-
fileCount
Integer fileCount()
Count the total number of files in the repository (excluding .git directory). Uses FileVisitor for cross-platform compatibility (Windows and Linux).
-
findFiles
List<String> findFiles(String glob, Boolean findHighest)
Find files using glob patterns.
- Parameters:
glob- the glob pattern to match files againstfindHighest- if true, only the highest matching file in the directory tree will be returned For example, if you want to find all Maven projects by looking for pom.xml files.- Returns:
list of absolute file paths matching the glob pattern
-
safeReadFile
String safeReadFile(String path)
Use for safe reading of files. Returns null if the file doesn't exist or is not readable.
-
resolvePath
Path resolvePath(String path)
-
resolveAndValidateFile
Path resolveAndValidateFile(String path)
-
getFileContentTransformers
abstract List<StringTransformer> getFileContentTransformers()
Provide sanitizers that run on file content before returning it. They must be sure not to change any content that may need to be replaced as this will break editing if editing is done in the same session.
-
-
-
-