We provide a detailed description of each step of the prompts we used, including four prompts in the Intention Extraction section and six templates in the Revision Generation section.
Intention Extraction:
Agent 2 prompt for Identifying Reversion Suggestion in Deletion Case
Agent 2 prompt for Identifying Reversion Suggestion in Addition Case
Agent 2 prompt for Identifying Reversion Suggestion in Modification Case
Agent 3 prompt for Extracting Intention from General Suggestion
Revision Generation section:
Simple Prompt Template for Generating Revisions in the Explicit Suggestion Type
RAG Prompt Template for Generating Revisions in the Explicit Suggestion Type
Self-generated Prompt Template for Generating Revisions in the Explicit Suggestion Type
Simple Prompt Template for Generating Revisions in the General Suggestion Type
RAG Prompt Template for Generating Revisions in the General Suggestion Type
Self-generated Prompt Template for Generating Revisions in the General Suggestion Type
System prompt:
You will be presented with a code review comment and a piece of code modification. Your task is to determine what is the reviewer's intention. Choose one of the following templates to describe the reviewer's intention, and no additional description is needed.
Expressing an opinion. You shouldn't delete this code.
Expressing an opinion. You still need this code.
Expressing an opinion. Change the code back.
Raising a question. Why delete this code.
Raising a question. Why did you do this.
Giving a suggestion. You should add another piece of code.
User prompt:
The reviewer gave the following comment:
<review_comment>
The review comment is related to the following code line:
<review_line>
The last code modification is as follows:
```
<last_code_diff_hunk>
```
What is the reviewer's intention?
System prompt:
You will be presented with a code review comment and a piece of code modification. Your task is to determine what is the reviewer's intention. Choose one of the following templates to describe the reviewer's intention, and no additional description is needed.
Expressing an opinion. This code is not needed.
Expressing an opinion. Don't do something.
Expressing an opinion. It was a mistake to do this.
Expressing an opinion. Adding this code is incorrect.
Giving a suggestion. Move this code to another place.
Giving a suggestion. You need to do something.
Giving a suggestion. Suggest modification and provide the suggested code.
User Prompt:
The reviewer gave the following comment:
<comment>
The review comment is related to the following code line:
<review_line>
The last code modification is as follows:
```
<kernel_last_diff>
```
What is the reviewer's intention?
System prompt:
You will be presented with a code review comment and a piece of code modification. Your task is divided into three steps. First, summarize the previous code changes succinctly. Then, analyze if the comments are related to the changes. Finally, understand the reviewer's intention based on their comments.Choose one of the following templates to describe the reviewer's intention.
Expressing an opinion. The last modification was unnecessary.
Expressing an opinion. The last modification will cause problems.
Expressing an opinion. This looks like some code tool modification, not a deliberate modification by the developer.
Expressing an opinion. Too many modifications will make it difficult to read and cause merge conflicts.
Raising a question. Ask the reason for the last modification.
Raising a question. Would it be better to modify according to the comment's suggestion?
Giving a suggestion. Do not make this modification, revert to the previous version.
Giving a suggestion. This code should be modified according to the suggested code.
Expressing an opinion. There is an issue unrelated to the previous code changes.
Giving a suggestion. Includes nitpicking suggestions or minor problem.
User Prompt:
The reviewer gave the following comment:
<comment>
The review comment is related to the following code line:
<review_line>
The last code modification is as follows:
```
<kernel_last_diff>
```
# Instruction:
**Summary of the last code modification:**
**Analysis of the comments:**
**Reviewer's intention:**
System prompt:
You will be presented with a code review comment and a code snippet. Your task is to understand the reviewer's intention of the modification without explaining the reason. Choose one of the following templates to describe the reviewer's intention. Do not change the original words in the template; fill in the words in parentheses and fill in the code inside the code block according to the context.
Single-line change. Change word (old_word) to (new_word)
Single-line change. Delete word (word_to_delete)
Single-line change. Change the code to ```new_code```
Single-line change. Delete code ```code_to_delete```
Multi-line change. Delete code lines ```code_lines_to_delete```
Multi-line change. Change the code lines ```old_code_lines``` to ```new_code_lines```
User Prompt:
The reviewer gave the following comment:
<comment>
The original code is as follows:
```
<old_code>
```
The review comment is related to the following code line:
<review_line>
What is the reviewer's intention of the modification?
During a code review, the reviewer asked the developer to revise this piece of code, the original code is as follows:
```
<old_code>
```
The review comment included a suggestion:
```
<suggestion_code>
```
The review comment is related to the following code line:
<review_line>
Revise the original code according to the review comment.
Here are some examples of code reviews, please refer to these examples and then complete the code review.
Origianl Code:
```
<example_origianl_code>
```
Review Comment: <example_review_comment>
Comment Related Line: <example_review_line>
Revised Code:
```
<example_revised_code>
```
During a code review, the reviewer asked the developer to revise this piece of code, the original code is as follows:
```
<old_code>
```
The review comment included a suggestion:
```
<suggestion_code>
```
The review comment is related to the following code line:
<review_line>
Revise the original code according to the review comment.
Let's think step by step.
During a code review, the reviewer asked the developer to revise this piece of code, the original code is as follows:
```
<old_code>
```
The review comment included a suggestion:
```
<suggestion_code>
```
The review comment is related to the following code line:
<review_line>
Revise the original code according to the review comment.
# Instruction:
## Recall relevant exemplars:
provide three code review examples. According to <Origianl Code>, <Suggestion Code> and <Comment Related Line> analyze and get <Revised Code>.
## Solve the initial problem:
Repeat the initial problem, then analyze and get <Revised Code> according to the examples.
Please solve the problem step by step.
During a code review, the reviewer asked the developer to revise this piece of code, the original code is as follows:
```
<original_code>
```
The review comment is related to the following code line:
<review_line>
The reviewer's intention is:
<intention>
Revise the original code according to the reviewer's intention.
Here are some examples of code reviews, please refer to these examples and then complete the code review.
Original Code:
```
<example_original_code>
```
Review Intention: <example_intention>
Intention Related Line: <example_review_line>
Revised Code:
```
<example_revised_code>
```
During a code review, the reviewer asked the developer to revise this piece of code, the original code is as follows:
```
<original_code>
```
The review comment is related to the following code line: <review_line>
The reviewer's intention is: <intention>
Revise the original code according to the reviewer's intention.
Let's think step by step.
During a code review, the reviewer asked the developer to revise this piece of code, the original code is as follows:
```
<original_code>
```
The review comment is related to the following code line:
<review_line>
The reviewer's intention is:
<intention>
Revise the original code according to the reviewer's intention.
# Instruction:
## Recall relevant exemplars:
provide three code review examples. According to <Origianl Code>, <Review Intention> and <Intention Related Line> analyze and get <Revised Code>.
## Solve the initial problem:
Repeat the initial problem, then analyze and get <Revised Code> according to the examples.
Please solve the problem step by step.