Implement Grep tool and update agent prompt#1475
Implement Grep tool and update agent prompt#1475yasithrashan wants to merge 432 commits intowso2:bi-copilot-code-indexingfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| #### Tool 1: ${FILE_READ_TOOL_NAME} | ||
| Reads the actual source code from files. Use it to see complete implementation details, function bodies, logic, error handling, and all code nuances. | ||
|
|
||
| **Parameters:** |
There was a problem hiding this comment.
These are only should visible in tool descs
| - \`offset\`: The line number where you want to start reading (optional) | ||
| - \`limit\`: The number of lines to read from the offset (optional) | ||
|
|
||
| **When to use offset and limit:** |
There was a problem hiding this comment.
|
|
||
| ### Understanding the CodeMap (When Provided) | ||
|
|
||
| If you have access to a CodeMap, understand what it provides and what it doesn't: |
There was a problem hiding this comment.
If and If not should be in same place
| - Continue exploration as needed, following dependencies and connections | ||
| 5. **Synthesize Understanding**: List each relevant component and its specific role, understand how they interact, identify patterns | ||
| 6. **Provide Your Answer**: Only after thoroughly understanding the actual code | ||
|
|
There was a problem hiding this comment.
We need to encourage the agent to read compnents rather than files
| **Parameters:** | ||
| - \`file_path\`: The path to the file you want to read (required) | ||
| - \`offset\`: The line number where you want to start reading (optional) | ||
| - \`limit\`: The number of lines to read from the offset (optional) |
There was a problem hiding this comment.
is it really needed?
It is already in the tool input schema right
| ### Exploration Strategy: Two Scenarios | ||
|
|
||
| Your exploration strategy depends entirely on whether you have a CodeMap: | ||
|
|
||
| #### Scenario A: CodeMap IS Provided | ||
| 1. **Use the CodeMap to orient yourself**: Examine the structure, identify relevant files and components, note line numbers | ||
| 2. **Make strategic reading decisions**: Decide whether to read entire files or use offset/limit to read specific components | ||
| 3. **Read actual source code**: Use ${FILE_READ_TOOL_NAME} to read implementations | ||
| 4. **Use ${GREP_TOOL_NAME} for additional discovery**: Search for usages, references, and patterns not visible in the CodeMap | ||
| 5. **Verify and expand**: Read additional files as needed to understand interactions | ||
|
|
||
| #### Scenario B: NO CodeMap Provided | ||
| 1. **Start with grep**: Search for keywords, function names, or patterns related to your task to discover relevant files | ||
| 2. **Read discovered files**: Use ${FILE_READ_TOOL_NAME} to examine the files you found | ||
| 3. **Follow the trail**: Based on what you read, use grep again to find related files, usages, or references | ||
| 4. **Build understanding iteratively**: Continue the grep → read → grep cycle until you understand the relevant code | ||
| 5. **Verify completeness**: Ensure you haven't missed important files or connections | ||
|
|
||
| ### Exploration Workflow | ||
|
|
||
| Follow this systematic approach: | ||
| 1. **Determine Available Resources**: Check whether a CodeMap was provided and state this explicitly | ||
| 2. **Analyze the Task**: Understand what you're being asked to do | ||
| 3. **Plan Your Exploration Strategy**: Based on whether you have a CodeMap, identify relevant files/functions and plan grep searches or targeted reads | ||
| 4. **Execute Exploration**: | ||
| - Use ${GREP_TOOL_NAME} to search for function names, class names, or keywords relevant to your task | ||
| - Use ${FILE_READ_TOOL_NAME} to read actual implementations — with CodeMap: use offset/limit for targeted reads; without CodeMap: read files discovered through grep | ||
| - Continue exploration as needed, following dependencies and connections | ||
| 5. **Synthesize Understanding**: List each relevant component and its specific role, understand how they interact, identify patterns | ||
| 6. **Provide Your Answer**: Only after thoroughly understanding the actual code | ||
|
|
||
| **Critical Rules**: | ||
| 1. **ALWAYS explicitly state whether you have access to a CodeMap** at the start of your work | ||
| 2. **NEVER assume implementation details without reading the actual source code** — signatures and descriptions are not enough | ||
| 3. **If you have a CodeMap**, use it to guide exploration but remember it only shows structure, not implementation | ||
| 4. **If you do NOT have a CodeMap**, rely on grep to discover relevant files and read source code to build understanding | ||
| 5. **Always read actual source code** before making code modifications, explaining how something works, or drawing conclusions about behavior | ||
| 6. **When in doubt, explore more** — it's better to read extra files than to make incorrect assumptions |
There was a problem hiding this comment.
Better we can move tool specific examples and scenarios into Tool Description
There was a problem hiding this comment.
To reduce the complexity of the system prompt and the modularity of the tool
dd2f3c6 to
866a881
Compare
866a881 to
5d4378e
Compare
…cking performance
… ballerina-5.8.1
…cy-project-migration Improve legacy project migration by resolving nature from pom.xml
ce2b5fe to
9e02352
Compare
Purpose
wso2/product-ballerina-integrator#2441
Goals
Implement grep tool and update agent prompt