Skip to content

Comments

Implement Grep tool and update agent prompt#1475

Draft
yasithrashan wants to merge 174 commits intowso2:bi-copilot-code-indexingfrom
yasithrashan:feat/code-indexing-tools
Draft

Implement Grep tool and update agent prompt#1475
yasithrashan wants to merge 174 commits intowso2:bi-copilot-code-indexingfrom
yasithrashan:feat/code-indexing-tools

Conversation

@yasithrashan
Copy link
Contributor

Purpose

wso2/product-ballerina-integrator#2441

Goals

Implement grep tool and update agent prompt

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SasinduDilshara SasinduDilshara changed the base branch from main to bi-copilot-code-indexing February 18, 2026 04:47
#### 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:**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are only should visible in tool descs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

- \`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:**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack


### Understanding the CodeMap (When Provided)

If you have access to a CodeMap, understand what it provides and what it doesn't:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If and If not should be in same place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

- 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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to encourage the agent to read compnents rather than files

Comment on lines 200 to 203
**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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really needed?
It is already in the tool input schema right

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

Comment on lines 240 to 277
### 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better we can move tool specific examples and scenarios into Tool Description

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the complexity of the system prompt and the modularity of the tool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

@yasithrashan yasithrashan force-pushed the feat/code-indexing-tools branch from 020b4e5 to cff6303 Compare February 23, 2026 05:24
@yasithrashan yasithrashan force-pushed the feat/code-indexing-tools branch 2 times, most recently from dd2f3c6 to 866a881 Compare February 24, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants