feat: add file system search tool for improved codebase navigation #2104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements a new fs_search tool that provides two modes for searching files:
The tool respects standard ignore patterns (.git, node_modules, etc.) by default and includes comprehensive test coverage. This enhancement improves the developer experience by enabling efficient file and content discovery within the codebase.
Issue #, if available:
Description of changes:
Summary
This PR introduces a new
fs_search
tool that significantly enhances the developer experience by providing efficient file and content discovery capabilities within the codebase. The tool offers two distinct search modes:Key Features
🔍 Dual Search Modes
*.rs
,**/*test*
, etc.⚡ Performance Optimized
🎯 Developer-Friendly
Implementation Details
The tool is implemented in Rust and integrates seamlessly with the existing tool infrastructure:
fs_search.rs
: Core implementation with comprehensive error handlingtool_manager.rs
to register the new tooltool_index.json
Testing
The implementation includes comprehensive tests covering:
Example Usage
Impact
This tool addresses a common developer need for efficient codebase navigation, especially useful for:
Tests:
fs-search-demo.mp4
Error Handling UX
fs-search-error-handling.mp4
fs_search Tool Evaluation Report
This report documents a comprehensive evaluation of the
fs_search
tool in Amazon Q CLI, testing its various capabilities and modes.Tool Overview
The
fs_search
tool provides two primary search modes:Key features include:
Implementation Details
The
fs_search
tool is implemented in Rust with the following key components:FsSearch Enum: The main entry point with two variants:
Name(FsSearchName)
: For file name pattern searchesContent(FsSearchContent)
: For file content searchesResource Limits:
Default Ignored Directories:
.git
,node_modules
,target
, etc.Test Scenarios
The following test scenarios were executed to evaluate the tool's functionality:
Test 1: Search for Files by Name Pattern
Command:
Results:
.git
Test 2: Search for Content in a Specific File
Command:
Results:
Test 3: Search with Context Lines
Command:
Results:
Test 4: Search for Specific File Types
Command:
Results:
Test 5: Search for Regex Patterns in Content
Command:
Results:
Test 6: Search with File Filtering
Command:
Results:
Test 7: Search with Include Ignored Parameter
Commands:
Results:
Test 8: Search for Files with a Specific Extension
Command:
Results:
Test 9: Search for Specific Content in a File
Command:
Results:
Observations and Findings
Performance: The tool performs efficiently even with large directory structures (1650+ Rust files).
Usability:
Functionality:
Robustness:
Integration:
Conclusion
The
fs_search
tool is a robust and versatile utility for searching files and their contents within the Amazon Q CLI environment. It provides functionality comparable to native tools likefind
,grep
, andripgrep
, but with a unified interface and integration with the CLI's chat capabilities.The tool successfully handles a wide range of search scenarios, from simple file name pattern matching to complex regex-based content searches with context lines. Its performance is satisfactory even with large directory structures, and it provides clear, well-formatted output.
The implementation includes appropriate resource limits and error handling to ensure stability and prevent resource exhaustion. The default ignore patterns help focus searches on relevant files while allowing users to override this behavior when needed.
Overall, the
fs_search
tool is a valuable addition to the Amazon Q CLI toolkit, enabling users to efficiently locate files and content within their development environment.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.