|
10 | 10 | from utils import transform_search_response_to_xml, handle_api_error |
11 | 11 |
|
12 | 12 |
|
13 | | -async def search_code( |
| 13 | +async def codebase_search( |
14 | 14 | ctx: Context, |
15 | 15 | query: str, |
16 | 16 | data_source_ids: Optional[List[str]] = None, |
17 | 17 | mode: str = "auto", |
18 | 18 | include_content: bool = False |
19 | 19 | ) -> Dict: |
20 | 20 | """ |
21 | | - SEMANTIC search across your codebases. |
| 21 | + Use `codebase_search` tool to search for code in the codebase. |
22 | 22 |
|
23 | | - This endpoint is optimized for **natural-language** questions and intent-driven queries |
24 | | - (not rigid templates). Ask it things like: |
| 23 | + Semantic search (`codebase_search`) is your MAIN exploration tool for understanding the |
| 24 | + indexed codebase (typically main/master branch or the specific branch shown in data sources). |
| 25 | +
|
| 26 | + ALWAYS prefer using `codebase_search` over grep/find for initial code exploration because: |
| 27 | + - It's much faster and more efficient for discovering relevant code |
| 28 | + - It understands semantic meaning, not just text patterns |
| 29 | + - It searches the indexed repository state with full context |
| 30 | +
|
| 31 | + IMPORTANT: This searches the INDEXED version of repositories (check branch in get_data_sources), |
| 32 | + NOT the current local files. Use grep when you specifically need to: |
| 33 | + - Search uncommitted local changes |
| 34 | + - Verify recent modifications |
| 35 | + - Check files on a different branch than the indexed one |
| 36 | +
|
| 37 | + This tool excels at natural-language questions and intent-driven queries like: |
25 | 38 | • "What is the authentication flow?" |
26 | 39 | • "Where is the user registration logic implemented?" |
27 | 40 | • "How do services communicate with the billing API?" |
28 | 41 | • "Where is rate limiting handled?" |
29 | 42 | • "Show me how we validate JWTs." |
30 | 43 |
|
31 | | - You can still include function/class names if you know them, but it's not required. |
| 44 | + You can include function/class names for more targeted results. |
32 | 45 |
|
33 | 46 | Args: |
34 | 47 | query: A natural-language description of what you're looking for. |
@@ -57,19 +70,19 @@ async def search_code( |
57 | 70 |
|
58 | 71 | Examples: |
59 | 72 | 1. Natural-language question (recommended): |
60 | | - search_code(query="What is the auth flow?", data_source_ids=["repo123"]) |
| 73 | + codebase_search(query="What is the auth flow?", data_source_ids=["repo123"]) |
61 | 74 |
|
62 | 75 | 2. Intent query: |
63 | | - search_code(query="Where is user registration logic?", data_source_ids=["repo123"]) |
| 76 | + codebase_search(query="Where is user registration logic?", data_source_ids=["repo123"]) |
64 | 77 |
|
65 | 78 | 3. Workspace-wide question: |
66 | | - search_code(query="How do microservices talk to the billing API?", data_source_ids=["workspace456"]) |
| 79 | + codebase_search(query="How do microservices talk to the billing API?", data_source_ids=["workspace456"]) |
67 | 80 |
|
68 | 81 | 4. Mixed query with a known identifier: |
69 | | - search_code(query="Where do we validate JWTs (AuthService)?", data_source_ids=["repo123"]) |
| 82 | + codebase_search(query="Where do we validate JWTs (AuthService)?", data_source_ids=["repo123"]) |
70 | 83 |
|
71 | 84 | 5. Concise results without full file contents: |
72 | | - search_code(query="Where is password reset handled?", data_source_ids=["repo123"], include_content=false) |
| 85 | + codebase_search(query="Where is password reset handled?", data_source_ids=["repo123"], include_content=false) |
73 | 86 |
|
74 | 87 | Note: |
75 | 88 | - At least one data_source_id must be provided |
|
0 commit comments