Experimental Toolset Documentation#

Generated byAI

Caution: This toolset contains experimental tools that may undergo significant changes or be removed in future updates. Use with caution and ensure you have backups of your data.

Tools#

apply_patch_to_text_file#

Purpose: Applies a patch using the diff format to a specified text file using the patch command.

Parameters#

Parameter Type Required Description
file_path String Yes The relative path to the file to be patched.
patch_content String Yes The content of the patch to apply.

Success Case Example#

Input:

{
  "file_path": "example.txt",
  "patch_content": "--- example.txt\n+++ example.txt\n@@ -1 +1 @@\n-old content\n+new content"
}

Output:

{
  "file_path": "example.txt",
  "message": "Patch applied successfully"
}

Error Case Examples#

  1. Missing File Path:

    {
      "error": "The required file_path was not specified"
    }
  2. Missing Patch Content:

    {
      "error": "The required patch_content was not specified"
    }
  3. Invalid Path:

    {
      "error": "The specified path 'example.txt' is not allowed."
    }
  4. File Does Not Exist:

    {
      "error": "The specified file 'example.txt' does not exist."
    }
  5. Patch Application Failed:

    {
      "error": "Failure: <patch output>"
    }
  6. General Error:

    {
      "error": "An error occurred while applying the patch: <error message>"
    }

Notes#

  • The tool uses the patch command with the --no-backup-if-mismatch flag.
  • It ensures the file is within the current directory and is a valid text file.

regex_text_edit_tool#

Purpose: Finds patterns using a regex in a text-based file and replaces them with new text.

Parameters#

Parameter Type Required Description
file_path String Yes The relative path to the file where you want to perform the regex replacement.
pattern String Yes The regex pattern to search for in the file.
replacement String Yes The text to replace the pattern with in the file.

Success Case Example#

Input:

{
  "file_path": "example.txt",
  "pattern": "old_text",
  "replacement": "new_text"
}

Output:

{
  "file_path": "example.txt",
  "new_content": "<updated content of the file>"
}

Error Case Examples#

  1. Missing File Path:

    {
      "error": "The required file_path was not specified"
    }
  2. Missing Pattern:

    {
      "error": "The required pattern was not specified"
    }
  3. Missing Replacement:

    {
      "error": "The required replacement was not specified"
    }
  4. Invalid Path:

    {
      "error": "The specified path 'example.txt' is not allowed."
    }
  5. File Does Not Exist:

    {
      "error": "The specified file 'example.txt' does not exist."
    }
  6. General Error:

    {
      "error": "An error occurred while modifying the file: <error message>"
    }

Notes#

  • The tool ensures the file is within the current directory and is a valid text file.
  • It uses multiline regex options for pattern matching.