Interface FileWriteTools

  • All Implemented Interfaces:
    com.embabel.agent.api.common.support.SelfToolCallbackPublisher , com.embabel.agent.core.ToolCallbackPublisher , com.embabel.agent.core.ToolCallbackSpec , com.embabel.agent.tools.DirectoryBased , com.embabel.agent.tools.file.FileAccessLog , com.embabel.agent.tools.file.FileChangeLog

    
    public interface FileWriteTools
     implements DirectoryBased, FileAccessLog, FileChangeLog, SelfToolCallbackPublisher
                        

    All file modifications must go through this interface.

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • createFile

        @Tool(description = "Create a file with the given content") String createFile(String path, String content)

        Create a file at the relative path under the root

      • createFile

         Path createFile(String path, String content, Boolean overwrite)

        Create a file with the given content.

        Parameters:
        path - the relative path to create the file at
        content - the content to write to the file
        overwrite - if true, overwrite the file if it already exists
        Returns:

        the path to the created file

      • editFile

        @Tool(description = "Edit the file at the given location. Replace oldContent with newContent. oldContent is typically just a part of the file. e.g. use it to replace a particular method to add another method") String editFile(String path, @ToolParam(description = "content to replace") String oldContent, @ToolParam(description = "replacement content") String newContent)
      • appendFile

        @Tool(description = "Append content to an existing file. The file must already exist.") String appendFile(String path, String content)
      • appendToFile

         Unit appendToFile(String path, String content, Boolean createIfNotExists)

        Append content to a file, creating it if it doesn't exist. If create is true, the file will be created if it doesn't exist. If createIfNotExists is false, an exception will be thrown if the file doesn't exist.

      • delete

        @Tool(description = "Delete a file at the given path") String delete(String path)