Skip to content

Commit 903052b

Browse files
authored
fix: rename search => ripgrep (#916)
# 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
1 parent c77d33d commit 903052b

File tree

7 files changed

+23
-26
lines changed

7 files changed

+23
-26
lines changed

codegen-examples/examples/deep_code_research/run.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from codegen.extensions.langchain.tools import (
1212
ListDirectoryTool,
1313
RevealSymbolTool,
14-
SearchTool,
14+
RipGrepTool,
1515
SemanticSearchTool,
1616
ViewFileTool,
1717
)
@@ -100,7 +100,7 @@ def research(repo_name: Optional[str] = None, query: Optional[str] = None, threa
100100
tools = [
101101
ViewFileTool(codebase),
102102
ListDirectoryTool(codebase),
103-
SearchTool(codebase),
103+
RipGrepTool(codebase),
104104
SemanticSearchTool(codebase),
105105
RevealSymbolTool(codebase),
106106
]

codegen-examples/examples/langchain_agent/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The agent comes with several built-in tools for code operations:
5757

5858
- `ViewFileTool`: View file contents and metadata
5959
- `ListDirectoryTool`: List directory contents
60-
- `SearchTool`: Search code using regex
60+
- `RipGrepTool`: Search code using ripgrep
6161
- `EditFileTool`: Edit file contents
6262
- `CreateFileTool`: Create new files
6363
- `DeleteFileTool`: Delete files

codegen-examples/examples/langchain_agent/run.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""Demo implementation of an agent with Codegen tools."""
22

33
from codegen import Codebase
4+
from codegen.extensions.langchain.graph import create_react_agent
5+
from codegen.extensions.langchain.llm import LLM
6+
from codegen.extensions.langchain.prompts import REASONER_SYSTEM_MESSAGE
47
from codegen.extensions.langchain.tools import (
58
CommitTool,
69
CreateFileTool,
@@ -10,18 +13,13 @@
1013
MoveSymbolTool,
1114
RenameFileTool,
1215
RevealSymbolTool,
13-
SearchTool,
16+
RipGrepTool,
1417
SemanticEditTool,
1518
ViewFileTool,
1619
)
17-
18-
from codegen.extensions.langchain.llm import LLM
19-
from codegen.extensions.langchain.prompts import REASONER_SYSTEM_MESSAGE
20-
20+
from langchain_core.messages import SystemMessage
2121
from langgraph.checkpoint.memory import MemorySaver
2222
from langgraph.graph.graph import CompiledGraph
23-
from codegen.extensions.langchain.graph import create_react_agent
24-
from langchain_core.messages import SystemMessage
2523

2624

2725
def create_codebase_agent(
@@ -57,7 +55,7 @@ def create_codebase_agent(
5755
tools = [
5856
ViewFileTool(codebase),
5957
ListDirectoryTool(codebase),
60-
SearchTool(codebase),
58+
RipGrepTool(codebase),
6159
EditFileTool(codebase),
6260
CreateFileTool(codebase),
6361
DeleteFileTool(codebase),

src/codegen/cli/commands/agent/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
MoveSymbolTool,
1717
RenameFileTool,
1818
RevealSymbolTool,
19-
SearchTool,
19+
RipGrepTool,
2020
ViewFileTool,
2121
)
2222
from codegen.sdk.core.codebase import Codebase
@@ -62,7 +62,7 @@ def say(message: str):
6262
tools = [
6363
ViewFileTool(codebase),
6464
ListDirectoryTool(codebase),
65-
SearchTool(codebase),
65+
RipGrepTool(codebase),
6666
CreateFileTool(codebase),
6767
DeleteFileTool(codebase),
6868
RenameFileTool(codebase),

src/codegen/extensions/langchain/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
EditFileTool,
1212
ListDirectoryTool,
1313
RevealSymbolTool,
14-
SearchTool,
14+
RipGrepTool,
1515
SemanticEditTool,
1616
ViewFileTool,
1717
)
@@ -24,7 +24,7 @@
2424
"EditFileTool",
2525
"ListDirectoryTool",
2626
"RevealSymbolTool",
27-
"SearchTool",
27+
"RipGrepTool",
2828
"SemanticEditTool",
2929
"ViewFileTool",
3030
# Helper functions
@@ -44,7 +44,7 @@ def get_workspace_tools(codebase: Codebase) -> list[BaseTool]:
4444
return [
4545
ViewFileTool(codebase),
4646
ListDirectoryTool(codebase),
47-
SearchTool(codebase),
47+
RipGrepTool(codebase),
4848
EditFileTool(codebase),
4949
CreateFileTool(codebase),
5050
DeleteFileTool(codebase),

src/codegen/extensions/langchain/agent.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
RenameFileTool,
2222
ReplacementEditTool,
2323
RevealSymbolTool,
24+
RipGrepTool,
2425
SearchFilesByNameTool,
25-
SearchTool,
2626
# SemanticEditTool,
2727
ViewFileTool,
2828
)
@@ -67,7 +67,7 @@ def create_codebase_agent(
6767
tools = [
6868
ViewFileTool(codebase),
6969
ListDirectoryTool(codebase),
70-
SearchTool(codebase),
70+
RipGrepTool(codebase),
7171
# EditFileTool(codebase),
7272
CreateFileTool(codebase),
7373
DeleteFileTool(codebase),
@@ -131,7 +131,7 @@ def create_chat_agent(
131131
tools = [
132132
ViewFileTool(codebase),
133133
ListDirectoryTool(codebase),
134-
SearchTool(codebase),
134+
RipGrepTool(codebase),
135135
CreateFileTool(codebase),
136136
DeleteFileTool(codebase),
137137
RenameFileTool(codebase),
@@ -177,7 +177,7 @@ def create_codebase_inspector_agent(
177177
tools = [
178178
ViewFileTool(codebase),
179179
ListDirectoryTool(codebase),
180-
SearchTool(codebase),
180+
RipGrepTool(codebase),
181181
DeleteFileTool(codebase),
182182
RevealSymbolTool(codebase),
183183
]

src/codegen/extensions/langchain/tools.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ class SearchInput(BaseModel):
126126

127127
query: str = Field(
128128
...,
129-
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.
130-
Ripgrep is the preferred method.""",
129+
description="""ripgrep query (or regex pattern) to run. For regex searches, set use_regex=True. Ripgrep is the preferred method.""",
131130
)
132131
file_extensions: list[str] | None = Field(default=None, description="Optional list of file extensions to search (e.g. ['.py', '.ts'])")
133132
page: int = Field(default=1, description="Page number to return (1-based, default: 1)")
@@ -136,11 +135,11 @@ class SearchInput(BaseModel):
136135
tool_call_id: Annotated[str, InjectedToolCallId]
137136

138137

139-
class SearchTool(BaseTool):
140-
"""Tool for searching the codebase."""
138+
class RipGrepTool(BaseTool):
139+
"""Tool for searching the codebase via RipGrep."""
141140

142141
name: ClassVar[str] = "search"
143-
description: ClassVar[str] = "Search the codebase using text search or regex pattern matching"
142+
description: ClassVar[str] = "Search the codebase using `ripgrep` or regex pattern matching"
144143
args_schema: ClassVar[type[BaseModel]] = SearchInput
145144
codebase: Codebase = Field(exclude=True)
146145

@@ -867,7 +866,7 @@ def get_workspace_tools(codebase: Codebase) -> list["BaseTool"]:
867866
RevealSymbolTool(codebase),
868867
GlobalReplacementEditTool(codebase),
869868
RunBashCommandTool(), # Note: This tool doesn't need the codebase
870-
SearchTool(codebase),
869+
RipGrepTool(codebase),
871870
SearchFilesByNameTool(codebase),
872871
# SemanticEditTool(codebase),
873872
# SemanticSearchTool(codebase),

0 commit comments

Comments
 (0)