search_codebase
Locate functions, classes, and docstrings across a local repository using hybrid keyword and semantic search, returning ranked code snippets with file paths and line ranges.
Instructions
Executes private local hybrid search combining BM25 keyword matching and TF-IDF semantic scoring across repository functions, classes, and docstrings, distinguishing from 'query_memory_store' and 'build_project_context' by indexing source code identifiers and docstrings rather than querying agent episodic memory or generating context trees.
Parameters:
query(str, required): Search term or natural language description of the code to locate.project_root(str, optional, default='.'): Root directory of the repository to search (default: current directory).top_k(int, optional, default=5): Maximum number of ranked results to return (default: 5).
Behavior:
Read-only: Queries local code files without writing to disk or modifying indices.
Idempotent: Deterministic ranked results for identical queries on the same codebase.
100% Offline: Executes entirely on CPU; no OpenAI/cloud embeddings, zero network egress.
Auth & Rate Limits: Zero authentication or credentials required; sub-millisecond query latency.
Error Handling: Returns empty match report with query suggestions if no relevant tokens are found.
Usage Guidelines:
When to use: Locate relevant functions, classes, or code implementations across the repository using natural language or code identifier queries.
When NOT to use: Do not use for querying persistent semantic knowledge graphs or agent memory triples (use 'query_memory_store' instead); do not use for generating full project context trees (use 'build_project_context' instead).
Returns: Ranked list of matching code snippets with file paths, line ranges, relevance scores, and matched symbol definitions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term or natural language description of the code to locate. | |
| top_k | No | Maximum number of ranked results to return (default: 5). | |
| project_root | No | Root directory of the repository to search (default: current directory). | . |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |