-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style:Run dotnet format #496
Conversation
WalkthroughThe pull request introduces changes to the Changes
Sequence DiagramsequenceDiagram
participant User
participant DoCommand
participant FileSystemService
participant LLM
User->>DoCommand: Execute command
DoCommand->>FileSystemService: Create instance
FileSystemService-->>DoCommand: Service ready
DoCommand->>LLM: GenerateAsync(inputText)
LLM-->>DoCommand: Generate response
DoCommand->>FileSystemService: Write output
FileSystemService-->>DoCommand: Confirm write
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
src/Cli/src/Commands/FileSystemService.cs (1)
Line range hint
65-74
: Consider using a proper logging framework.Replace Console.WriteLine with a proper logging framework (e.g., Microsoft.Extensions.Logging) for better control over log levels and output destinations.
+ private readonly ILogger<FileSystemService> _logger; + + public FileSystemService(ILogger<FileSystemService>? logger = null) + { + _logger = logger ?? NullLogger<FileSystemService>.Instance; + } // In the method: - Console.WriteLine($"Found {paths.Count} files:"); + _logger.LogInformation("Found {Count} files:", paths.Count); foreach (var path in paths) { - Console.WriteLine(path); + _logger.LogInformation("Found file: {Path}", path); }
🧹 Nitpick comments (5)
src/Cli/src/Commands/DoCommand.cs (2)
26-29
: Consider adding error handling for FileSystemService initialization.While the integration looks good, consider wrapping the FileSystemService initialization and tool registration in a try-catch block to handle potential initialization failures gracefully.
+ try + { var fileSystemService = new FileSystemService(); llm.AddGlobalTools(fileSystemService.AsTools(), fileSystemService.AsCalls()); + } + catch (Exception ex) + { + Console.WriteLine($"Failed to initialize file system tools: {ex.Message}"); + throw; + }
31-31
: Add timeout handling for LLM generation.Consider adding a timeout for the LLM generation to prevent indefinite waits.
- var response = await llm.GenerateAsync(inputText); + using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5)); + var response = await llm.GenerateAsync(inputText, cts.Token);src/Cli/src/Commands/FileSystemService.cs (3)
Line range hint
37-49
: Consider making file extensions configurable.The hard-coded list of file extensions could be moved to a configuration file or made configurable through the constructor to improve flexibility.
+ private readonly IReadOnlySet<string> _allowedExtensions; + + public FileSystemService(IEnumerable<string>? allowedExtensions = null) + { + _allowedExtensions = allowedExtensions?.ToHashSet() ?? + new HashSet<string> { ".txt", ".md", ".json", ".cs", ".csproj", ".sln", ".sh", ".yml", ".yaml" }; + } public async Task<IList<string>> FindFilePathsByContentAsync(...) { // ... - if (extension is not ".txt" and not ".md" and not ".json" and not ".cs" and not ".csproj" and not ".sln" and not ".sh" and not ".yml" and not ".yaml") + if (!_allowedExtensions.Contains(extension)) { continue; }
80-83
: Add file existence check before reading.Consider adding a file existence check before attempting to read the file.
public async Task<string> ReadContentAsync( string path, CancellationToken cancellationToken = default) { + if (!File.Exists(path)) + { + throw new FileNotFoundException($"File not found: {path}"); + } Console.WriteLine($"Reading file at path: {path}"); return await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false); }
104-108
: Consider using a more robust confirmation mechanism.The current console-based confirmation might not work well in all environments (e.g., CI/CD). Consider adding a parameter to bypass confirmation in automated scenarios.
public async Task<string> WriteContentAsync( string path, string newContent, + bool skipConfirmation = false, CancellationToken cancellationToken = default) { + if (skipConfirmation) + { + await File.WriteAllTextAsync(path, newContent, cancellationToken).ConfigureAwait(false); + return "File written."; + } // ... rest of the confirmation logic }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/Cli/src/Commands/DoCommand.cs
(1 hunks)src/Cli/src/Commands/FileSystemService.cs
(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test / Build, test and publish
Created by Github Actions
Summary by CodeRabbit
New Features
Improvements