Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit d4e14ab

Browse files
authored
refactor instructions (#241)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI Release Notes: - Documentation: Updates to the instructions for reviewing code changes in a pull request. Clarifies the format for changes, provides guidelines for review comments, and emphasizes the importance of accuracy in line number ranges and replacement snippets. > "Code reviews made easy, > With clearer instructions so breezy. > Accuracy is key, > For a better codebase, you'll see." <!-- end of auto-generated comment: release notes by openai -->
1 parent c725d0c commit d4e14ab

File tree

2 files changed

+70
-98
lines changed

2 files changed

+70
-98
lines changed

dist/index.js

Lines changed: 35 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/prompts.ts

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -146,56 +146,40 @@ Format for changes:
146146
...
147147
148148
Instructions:
149-
- The above format for changes consists of multiple change sections. Each change
150-
section consists of a new hunk (annotated with line numbers), an old hunk and
151-
optionally, existing comment chains. The line number annotation on each line
152-
in the new hunk is of the format \`<line_number><colon><whitespace>\`.
153-
- Note that the code in the old hunk does not exist anymore as it was replaced
154-
by the new hunk. The new hunk is the code that you need to review. Consider
155-
the context provided by the old hunk and associated comment chain when reviewing
156-
the new hunk.
157-
- Your task is to do a line by line review of new hunks and point out
158-
substantive issues in those line number ranges. For each issue you
159-
identify, please provide the exact line number range (inclusive) where
160-
the issue occurs.
161-
- Only respond in the below response format (consisting of review
162-
sections) and nothing else. Each review section must consist of a line
163-
number range and a review comment for that line number range. Optionally,
164-
you can include a single replacement suggestion snippet and/or multiple
165-
new code snippets in the review comment. There's a separator between review
166-
sections.
167-
- It's important that line number ranges for each review section must
168-
be within the line number range of a specific new hunk. i.e.
169-
<start_line_number> must belong to the same hunk as the
170-
<end_line_number>. The line number range is sufficient to map your
171-
comment to the code changes in GitHub pull request.
172-
- Do not summarize the changes or repeat back provided code in the review
173-
comments and only focus on pointing out substantive issues.
174-
- Use Markdown format for review comment text.
175-
- Fenced code blocks must be used for new content and replacement
176-
code/text snippets and must not be annotated with line numbers.
177-
- If needed, provide a replacement suggestion using fenced code blocks
178-
with the \`suggestion\` as the language identifier. The line number range
179-
in the review section must map exactly to the line number range (inclusive)
180-
that need to be replaced within a new_hunk.
181-
For instance, if 2 lines of code in a hunk need to be replaced with 15 lines
182-
of code, the line number range must be those exact 2 lines. If an entire hunk
183-
need to be replaced with new code, then the line number range must be the
184-
entire hunk. Replacement suggestions should be complete units that can be
185-
directly committed by the user in the GitHub UI.
186-
- Replacement code/text snippets must be complete and correctly
187-
formatted. Each replacement suggestion must be provided as a separate review
188-
section with relevant line number ranges.
149+
150+
- The format for changes provided above consists of multiple change
151+
sections, each containing a new hunk (annotated with line numbers),
152+
an old hunk, and optionally, existing comment chains. Note that the
153+
old hunk code has been replaced by the new hunk.
154+
- Your task is to review new hunks line by line, ONLY pointing out
155+
substantive issues within line number ranges. Provide the exact line
156+
number range (inclusive) for each issue. Focus on identifying specific
157+
issues and avoid summarizing changes or providing general feedback.
158+
- IMPORTANT: Respond only in the response format (consisting of review
159+
sections). Each review section must have a line number range and a review
160+
comment for that range. Do not include general feedback or summaries. You
161+
may optionally include a single replacement suggestion snippet and/or
162+
multiple new code snippets in the review comment. Separate review sections
163+
using separators.
164+
- IMPORTANT: Line number ranges for each review section must be within the
165+
range of a specific new hunk. <start_line_number> must belong to the same
166+
hunk as the <end_line_number>. The line number range is sufficient to map
167+
your comment to the code changes in the GitHub pull request.
168+
- Use Markdown format for review comment text and fenced code blocks for
169+
code snippets. Do not annotate code snippets with line numbers.
170+
- If needed, provide replacement suggestions using fenced code blocks with the
171+
\`suggestion\` language identifier. The line number range must map exactly
172+
to the range that needs to be replaced within a new hunk. Replacement
173+
suggestions should be complete and correctly formatted units for direct
174+
committing in the GitHub UI. Each suggestion must be provided as a separate
175+
review section with relevant line number ranges.
189176
- If needed, suggest new code using the correct language identifier in the
190-
fenced code blocks. These snippets may be added to a different file, such
191-
as test cases. Multiple new code snippets are allowed within a single
177+
fenced code blocks. These snippets may be added to a different file,
178+
such as test cases. Multiple new code snippets are allowed within a single
179+
review section.
180+
- If no substantive issues are detected or the implementation looks good,
181+
respond with "LGTM!" and nothing else for the respective line range in a
192182
review section.
193-
- If there are no substantive issues detected at a line range and/or the
194-
implementation looks good, you must respond with the comment "LGTM!" and
195-
nothing else for the respective line range in a review section.
196-
- Reflect on your comments and line number ranges before sending the final
197-
response to ensure accuracy of line number ranges and replacement
198-
snippets.
199183
200184
Response format expected:
201185
<start_line_number>-<end_line_number>:
@@ -229,9 +213,11 @@ Example changes:
229213
return x + y
230214
231215
Example response:
232-
3-3:
216+
1-3:
233217
There's a typo in the return statement.
234218
\`\`\`suggestion
219+
def add(x, y):
220+
z = x + y
235221
return z
236222
\`\`\`
237223
---

0 commit comments

Comments
 (0)