diff --git a/src/Cli/src/Commands/DoCommand.cs b/src/Cli/src/Commands/DoCommand.cs index 509aca69..f1d2d30c 100644 --- a/src/Cli/src/Commands/DoCommand.cs +++ b/src/Cli/src/Commands/DoCommand.cs @@ -23,12 +23,12 @@ private static async Task HandleAsync(string input, string inputPath, string out var llm = await Helpers.GetChatModelAsync().ConfigureAwait(false); llm.RequestSent += (_, request) => Console.WriteLine($"RequestSent: {request.Messages.AsHistory()}"); llm.ResponseReceived += (_, response) => Console.WriteLine($"ResponseReceived: {response}"); - + var fileSystemService = new FileSystemService(); llm.AddGlobalTools(fileSystemService.AsTools(), fileSystemService.AsCalls()); - + var response = await llm.GenerateAsync(inputText); - + await Helpers.WriteOutputAsync(response, outputPath).ConfigureAwait(false); } } \ No newline at end of file diff --git a/src/Cli/src/Commands/FileSystemService.cs b/src/Cli/src/Commands/FileSystemService.cs index 0b4a4de0..7b674980 100644 --- a/src/Cli/src/Commands/FileSystemService.cs +++ b/src/Cli/src/Commands/FileSystemService.cs @@ -34,7 +34,7 @@ public async Task> FindFilePathsByContentAsync( CancellationToken cancellationToken = default) { var paths = new List(); - + Console.WriteLine($"Searching for files in \"{directory}\" containing \"{content}\"..."); foreach (var path in Directory.EnumerateFiles(directory, "*.*", SearchOption.AllDirectories)) @@ -46,7 +46,7 @@ public async Task> FindFilePathsByContentAsync( { continue; } - + //FileInfo info = new FileInfo(path); var text = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false); @@ -62,7 +62,7 @@ public async Task> FindFilePathsByContentAsync( // ignore } } - + Console.WriteLine($"Found {paths.Count} files:"); foreach (var path in paths) { @@ -71,16 +71,16 @@ public async Task> FindFilePathsByContentAsync( return paths; } - + public async Task ReadContentAsync( string path, CancellationToken cancellationToken = default) { Console.WriteLine($"Reading file at path: {path}"); - + return await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false); } - + public async Task WriteContentAsync( string path, string newContent, @@ -101,11 +101,11 @@ public async Task WriteContentAsync( break; } } - + await File.WriteAllTextAsync(path, newContent, cancellationToken).ConfigureAwait(false); - + Console.WriteLine("File written."); - + return "File written."; } } \ No newline at end of file