Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions core/tools/definitions/codebaseTool.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
```typescript
import { Tool } from "../..";
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";

export const codebaseTool: Tool = {
type: "function",
displayTitle: "Codebase Search",
wouldLikeTo: "search the codebase for: {{{ query }}}",
wouldLike: "search the codebase for: {{{ query }}}",
isCurrently: "searching the codebase for: {{{ query }}}",
hasAlready: "searched the codebase for: {{{ query }}}",
readonly: true,
isInstant: false,
group: BUILT_IN_GROUP_NAME,

function: {
name: BuiltInToolNames.CodebaseTool,
description:
"Use this tool to semantically search through the codebase and retrieve relevant code snippets based on a natural language query. This helps find relevant code context for understanding or working with the codebase.",
"Semantically search the codebase using a natural language query and retrieve relevant code snippets. Use this tool to locate implementations, trace application behavior, understand dependencies, identify relevant files, and investigate existing patterns without modifying any files.",

parameters: {
type: "object",
required: ["query"],
properties: {
query: {
type: "string",
description:
"Natural language description of what you're looking for in the codebase (e.g., 'authentication logic', 'database connection setup', 'error handling')",
"A clear, specific natural language question describing the code or behavior to find. Include relevant features, components, functions, dependencies, or expected behavior when useful. Examples: 'How is user authentication implemented?', 'Where is the database connection configured?', 'How are API errors handled?', or 'Which files implement the background job queue?'",
},
},
},
},

defaultToolPolicy: "allowedWithPermission",

systemMessageDescription: {
prefix: `To search the codebase, use the ${BuiltInToolNames.CodebaseTool} tool with a natural language query. For example, to find authentication logic, you might respond with:`,
prefix: `To search the codebase, use the ${BuiltInToolNames.CodebaseTool} tool with a clear, specific natural language query. Describe the implementation, behavior, or code context you need to find. For example:`,
exampleArgs: [
["query", "How is user authentication handled in this codebase?"],
["query", "How is user authentication implemented, including middleware, routes, and session handling?"],
],
},
};
```
Loading