You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: reverts to clasic regex + ripgrep search (#776)
# Motivation
<!-- Why is this change necessary? -->
# Content
<!-- Please include a summary of the change -->
# Testing
<!-- How was the change tested? -->
# Please check the following before marking your PR as ready for review
- [ ] I have added tests for my changes
- [ ] I have updated the documentation or added new documentation as
needed
- All characters are treated literally, including special regex characters
123
-
- Exact string matching (no regex interpretation)
124
-
125
-
For regex search (use_regex=True):
126
-
- Full regex pattern support
127
-
- Case-sensitive by default
128
-
- Special characters have regex meaning and need proper escaping
129
-
- Uses ripgrep's default regex mode
130
-
131
-
If no exact matches are found, automatically falls back to semantic search
132
-
to find relevant code even without exact text matches.""",
133
-
)
134
-
135
-
target_directories: Optional[list[str]] =Field(
136
-
default=None,
137
-
description="""Optional list of directories to limit the search scope.
138
-
139
-
- Paths should be relative to the workspace root
140
-
- Multiple directories are searched in parallel
141
-
- If None, searches the entire codebase
142
-
143
-
Example: ["src/frontend", "tests/unit"]""",
144
-
)
145
-
146
-
file_extensions: Optional[list[str]] =Field(
147
-
default=None,
148
-
description="""Optional list of file extensions to filter the search.
149
-
150
-
- Include the dot in extensions (e.g. ['.py', '.ts'])
151
-
- Multiple extensions are combined with OR logic
152
-
- If None, searches all file types
153
-
- Binary files are automatically excluded
154
-
155
-
Example: [".py", ".tsx", ".md"]""",
156
-
)
157
-
158
-
page: int=Field(
159
-
default=1,
160
-
description="""Page number for paginated results (1-based indexing).
161
-
162
-
- Use with files_per_page to navigate large result sets
163
-
- If page exceeds available pages, returns last available page
164
-
- Note: When falling back to semantic search, pagination is not supported
165
-
166
-
Example: page=2 with files_per_page=10 shows files 11-20""",
167
-
)
168
-
169
-
files_per_page: int=Field(
170
-
default=10,
171
-
description="""Number of files to show per page.
172
-
173
-
- Each file can contain multiple matching lines
174
-
- Reasonable values are between 5 and 50
175
-
- Larger values may impact performance
176
-
- When falling back to semantic search, this becomes the number of semantic results
177
-
178
-
Example: files_per_page=20 shows up to 20 files with matches""",
179
-
)
180
-
181
-
use_regex: bool=Field(
182
-
default=False,
183
-
description="""Whether to treat the query as a regex pattern.
184
-
185
-
- False (default): Simple text search, case-insensitive
186
-
- True: Full regex syntax, case-sensitive
187
-
- Invalid regex patterns will return an error
188
-
- Note: Semantic fallback is used regardless of this setting when no matches found
189
-
190
-
Example: Set to True to use patterns like "test_.*_func.*" """,
119
+
description="The search query to find in the codebase. When ripgrep is available, this will be passed as a ripgrep pattern. For regex searches, set use_regex=True. Ripgrep is the preferred method.",
191
120
)
121
+
target_directories: Optional[list[str]] =Field(default=None, description="Optional list of directories to search in")
122
+
file_extensions: Optional[list[str]] =Field(default=None, description="Optional list of file extensions to search (e.g. ['.py', '.ts'])")
123
+
page: int=Field(default=1, description="Page number to return (1-based, default: 1)")
124
+
files_per_page: int=Field(default=10, description="Number of files to return per page (default: 10)")
125
+
use_regex: bool=Field(default=False, description="Whether to treat query as a regex pattern (default: False)")
192
126
193
127
194
128
classSearchTool(BaseTool):
195
129
"""Tool for searching the codebase."""
196
130
197
131
name: ClassVar[str] ="search"
198
-
description: ClassVar[str] =r"""Search the codebase using text search or regex pattern matching.
199
-
200
-
This tool provides powerful text-based search capabilities across your codebase,
201
-
with support for both simple text matching and regular expressions. It uses ripgrep
202
-
when available for high-performance searches.
203
-
204
-
If no exact matches are found, automatically falls back to semantic search to find
205
-
relevant code even without exact text matches.
206
-
207
-
Features:
208
-
- Plain text or regex pattern matching
209
-
- Directory and file type filtering
210
-
- Paginated results for large codebases
211
-
- Case-insensitive by default for simple text searches
0 commit comments