1
0

feat: introduce FileTools for LLM-accessible file system operations including read, list, find, and grep.

This commit is contained in:
2026-03-06 01:23:19 +01:00
parent 003345edc0
commit 50414e8b8c

View File

@@ -142,7 +142,10 @@ internal static class FileTools
Log($"Searching file: {path}");
if (!File.Exists(path))
return $"ERROR: File not found: {path}";
if (Directory.Exists(path))
return $"ERROR: {path} is a directory, not a file.";
else
return $"ERROR: File not found: {path}";
Regex regex;
try
@@ -178,7 +181,7 @@ internal static class FileTools
}
catch (Exception ex)
{
return $"ERROR searching '{path}': {ex.Message}";
return $"ERROR searching '{path}': {ex.Message}\nThis is a bug, tell the user about it.";
}
}
else if (mode == "recursive")
@@ -186,7 +189,10 @@ internal static class FileTools
Log($"Recursive grep: {pattern} in {path}" + (filePattern != null ? $" (files: {filePattern})" : ""));
if (!Directory.Exists(path))
return $"ERROR: Directory not found: {path}";
if (File.Exists(path))
return $"ERROR: {path} is a file, not a directory.";
else
return $"ERROR: Directory not found: {path}";
Regex regex;
try
@@ -244,7 +250,7 @@ internal static class FileTools
}
catch (Exception ex)
{
return $"ERROR in recursive grep: {ex.Message}";
return $"ERROR in recursive grep: {ex.Message}.\nThis is a bug, tell the user about it.";
}
}
else