feat: update tool logs to be more coherent
This commit is contained in:
@@ -12,7 +12,7 @@ internal static class ToolRegistry
|
||||
return
|
||||
[
|
||||
AIFunctionFactory.Create(FileTools.ReadFile, name: "read_file", serializerOptions: jsonOptions),
|
||||
AIFunctionFactory.Create(FileTools.Grep, name: "grep_file", serializerOptions: jsonOptions),
|
||||
AIFunctionFactory.Create(FileTools.Grep, name: "grep", serializerOptions: jsonOptions),
|
||||
AIFunctionFactory.Create(FileTools.ListDir, name: "list_dir", serializerOptions: jsonOptions),
|
||||
AIFunctionFactory.Create(EditTools.ReplaceLines, name: "replace_lines", serializerOptions: jsonOptions),
|
||||
AIFunctionFactory.Create(EditTools.DeleteRange, name: "delete_range", serializerOptions: jsonOptions),
|
||||
|
||||
@@ -21,7 +21,7 @@ internal static class CommandTool
|
||||
public static string ExecuteCommand(
|
||||
[Description("The shell command to execute.")] string command)
|
||||
{
|
||||
Log($"Command request: {command}");
|
||||
Log($" ● execute_command: {command}");
|
||||
|
||||
// Prompt for user approval
|
||||
PauseSpinner?.Invoke();
|
||||
|
||||
@@ -17,7 +17,7 @@ internal static class DirTools
|
||||
{
|
||||
sourcePath = ResolvePath(sourcePath);
|
||||
destinationPath = ResolvePath(destinationPath);
|
||||
Log($"Renaming/moving directory: {sourcePath} -> {destinationPath}");
|
||||
Log($" ● rename_dir: {sourcePath} -> {destinationPath}");
|
||||
|
||||
if (!Directory.Exists(sourcePath))
|
||||
return $"ERROR: Directory not found: {sourcePath}";
|
||||
@@ -44,7 +44,7 @@ internal static class DirTools
|
||||
[Description("Path to the directory to create.")] string path)
|
||||
{
|
||||
path = ResolvePath(path);
|
||||
Log($"Creating directory: {path}");
|
||||
Log($" ● create_dir: {path}");
|
||||
|
||||
if (Directory.Exists(path))
|
||||
return $"ERROR: Directory already exists: {path}";
|
||||
|
||||
@@ -70,9 +70,8 @@ internal static partial class EditTools
|
||||
{
|
||||
newLines = SanitizeNewLines(newLines);
|
||||
path = FileTools.ResolvePath(path);
|
||||
Log($"REPLACE_LINES: {path}");
|
||||
Log($" Range: {startAnchor} -> {endAnchor}");
|
||||
Log($" Replacing {endAnchor.Split(':')[0]}-{startAnchor.Split(':')[0]} lines with {newLines.Length} new lines");
|
||||
Log($" ● replace_lines: {path}");
|
||||
Log($" {startAnchor.Split(':')[0]}-{endAnchor.Split(':')[0]} lines -> {newLines.Length} new lines");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return $"ERROR: File not found: {path}\n Check the correct path and try again.";
|
||||
@@ -107,7 +106,8 @@ internal static partial class EditTools
|
||||
[Description("Last line's line:hash anchor (e.g. '6:19').")] string endAnchor)
|
||||
{
|
||||
path = FileTools.ResolvePath(path);
|
||||
Log($"Deleting lines in file: {path}");
|
||||
Log($" ● delete_range: {path}");
|
||||
Log($" {startAnchor.Split(':')[0]}-{endAnchor.Split(':')[0]} lines");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return $"ERROR: File not found: {path}";
|
||||
@@ -142,7 +142,7 @@ internal static partial class EditTools
|
||||
{
|
||||
path = FileTools.ResolvePath(path);
|
||||
string targetType = mode.Equals("dir", StringComparison.CurrentCultureIgnoreCase) ? "directory" : "file";
|
||||
Log($"Deleting {targetType}: {path}");
|
||||
Log($" ● delete_{targetType}: {path}");
|
||||
|
||||
if (mode.Equals("dir", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
@@ -184,8 +184,8 @@ internal static partial class EditTools
|
||||
{
|
||||
sourcePath = FileTools.ResolvePath(sourcePath);
|
||||
destinationPath = FileTools.ResolvePath(destinationPath);
|
||||
string action = copy ? "Copying" : "Moving";
|
||||
Log($"{action} file: {sourcePath} -> {destinationPath}");
|
||||
string action = copy ? "copy" : "move";
|
||||
Log($" ● {action}_file: {sourcePath} -> {destinationPath}");
|
||||
|
||||
if (!File.Exists(sourcePath))
|
||||
return $"ERROR: Source file not found: {sourcePath}";
|
||||
@@ -221,9 +221,8 @@ internal static partial class EditTools
|
||||
{
|
||||
content = SanitizeNewLines(content);
|
||||
path = FileTools.ResolvePath(path);
|
||||
Log($"WRITE_TO_FILE: {path}");
|
||||
Log($" Mode: {mode}");
|
||||
Log($" Writing {content.Length} lines");
|
||||
Log($" ● write_to_file: {path}");
|
||||
Log($" mode: {mode} with {content.Length} lines");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -298,8 +297,8 @@ internal static partial class EditTools
|
||||
[Description("Array of operations to apply. Operations are applied in bottom-to-top order automatically.")] BatchOperation[] operations)
|
||||
{
|
||||
path = FileTools.ResolvePath(path);
|
||||
Log($"BATCH_EDIT: {path}");
|
||||
Log($" Operations: {operations.Length}");
|
||||
Log($" ● batch_edit: {path}");
|
||||
Log($" operations: {operations.Length}");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return $"ERROR: File not found: {path}";
|
||||
|
||||
@@ -27,7 +27,7 @@ internal static class FileTools
|
||||
[Description("Last line to return (inclusive). Use 0 for EOF. Defaults to 0.")] int endLine = 0)
|
||||
{
|
||||
path = ResolvePath(path);
|
||||
Log($"Reading file: {path} {startLine}:{endLine}L");
|
||||
Log($" ● read_file: {path} {startLine}:{endLine}L");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return $"ERROR: File not found: {path}";
|
||||
@@ -62,7 +62,7 @@ internal static class FileTools
|
||||
[Description("Path to the directory.")] string path = ".")
|
||||
{
|
||||
path = ResolvePath(path);
|
||||
Log($"Listing directory: {path}");
|
||||
Log($" ● list_dir: {path}");
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
return $"ERROR: Directory not found: {path}";
|
||||
@@ -95,7 +95,7 @@ internal static class FileTools
|
||||
[Description("Glob pattern (supports * and **).")] string pattern)
|
||||
{
|
||||
path = ResolvePath(path);
|
||||
Log($"Finding files: {pattern} in {path}");
|
||||
Log($" ● find_files: {pattern} in {path}");
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
return $"ERROR: Directory not found: {path}";
|
||||
@@ -139,7 +139,7 @@ internal static class FileTools
|
||||
|
||||
if (mode == "file")
|
||||
{
|
||||
Log($"Searching file: {path}");
|
||||
Log($" ● grep_file: {path}");
|
||||
|
||||
if (!File.Exists(path))
|
||||
if (Directory.Exists(path))
|
||||
@@ -186,7 +186,7 @@ internal static class FileTools
|
||||
}
|
||||
else if (mode == "recursive")
|
||||
{
|
||||
Log($"Recursive grep: {pattern} in {path}" + (filePattern != null ? $" (files: {filePattern})" : ""));
|
||||
Log($" ● grep_recursive: {pattern} in {path}" + (filePattern != null ? $" (files: {filePattern})" : ""));
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
if (File.Exists(path))
|
||||
@@ -297,7 +297,7 @@ internal static class FileTools
|
||||
[Description("Path to the file.")] string path)
|
||||
{
|
||||
path = ResolvePath(path);
|
||||
Log($"Getting file info: {path}");
|
||||
Log($" ● get_file_info: {path}");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return $"ERROR: File not found: {path}";
|
||||
|
||||
Reference in New Issue
Block a user