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

Commit 157e0cc

Browse files
authored
update instructions (#162)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI **Release Notes** - New Feature: Added instructions for reviewing code changes in a specific format, including suggestions and replacements. Clarified the expected response format and provided an example. > "Code reviews made easy, > With format clear and breezy. > Suggestions and replacements galore, > Reviewing code has never been more." <!-- end of auto-generated comment: release notes by openai -->
1 parent beea59e commit 157e0cc

File tree

2 files changed

+82
-34
lines changed

2 files changed

+82
-34
lines changed

dist/index.js

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

src/review.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,15 @@ ${
371371

372372
// Pack instructions
373373
ins.patches += `
374-
Format for changes -
374+
Format for changes:
375375
---new_hunk_for_review---
376376
\`\`\`
377-
<new content annotated with line numbers>
377+
<new hunk annotated with line numbers>
378378
\`\`\`
379379
380380
---old_hunk_for_context---
381381
\`\`\`
382-
<old content>
382+
<old hunk that was replaced by new hunk>
383383
\`\`\`
384384
385385
---comment_chains_for_context---
@@ -390,22 +390,36 @@ Format for changes -
390390
---end_change_section---
391391
...
392392
393-
Instructions -
393+
Instructions:
394394
- Only respond in the below response format and nothing else. Each review
395395
section must consist of a line number range and a comment for
396-
that line number range. There's a separator between review sections.
396+
that line number range. Optionally, you can include replacement suggestion
397+
or new code snippets in the review comment. There's a separator between
398+
review sections.
397399
- It's important that line number ranges for each review section must
398400
be within the line number range of a specific new hunk. i.e.
399401
<start_line_number> must belong to the same hunk as the
400-
<end_line_number>. The line number range is sufficient to map your
401-
comment to the correct sections in GitHub pull request.
402+
<end_line_number>.
403+
- Do not repeat back the code being reviewed as the the line number range is
404+
sufficient to map your comment to the correct location in GitHub.
402405
- Markdown format is preferred for review comment text.
403406
- Fenced code blocks must be used for new content and replacement
404-
code/text snippets. Replacement snippets must be complete,
405-
correctly formatted and most importantly, map exactly to the line
406-
number ranges that need to be replaced inside the hunks. The line
407-
number ranges must not belong to different hunks. Do not annotate
408-
suggested content with line numbers inside the code blocks.
407+
code/text snippets.
408+
- Replacement code/text snippets must be complete and correctly
409+
formatted. The line number range must map exactly to the line
410+
number range that need to be replaced within a new_hunk_for_review.
411+
E.g. if you are suggesting to replace 2 specific lines in a
412+
new_hunk_for_review with 10 lines of code, then the line number
413+
range must be exactly the 2 lines that need to be replaced.
414+
The replacement code/text snippet must use \`suggestion\` as the
415+
language identifier in the fenced code block. Replacement code
416+
suggestions can be directly committed by the user from the GitHub
417+
UI, replacing the code within new_hunk_for_review, that is why
418+
alignment of line number ranges is important.
419+
- New code/text snippets must use the correct language identifier
420+
in the fenced code block. You can use such snippets to suggest
421+
code that can be added in some other file, e.g. test cases.
422+
- Do not annotate snippets with line numbers inside the code blocks.
409423
- If there are no issues or suggestions and the hunk is acceptable as-is,
410424
your comment on the line ranges must include the word 'LGTM!'.
411425
@@ -415,32 +429,34 @@ Response format expected -
415429
---
416430
<start_line_number>-<end_line_number>:
417431
<review comment>
418-
<replacement code/text, if applicable>
419432
\`\`\`suggestion
420433
<code/text that replaces everything between start_line_number and end_line_number>
421434
\`\`\`
422435
---
423436
<start_line_number>-<end_line_number>:
424437
<review comment>
425-
<new code, if applicable>
426438
\`\`\`<language>
427439
<new code snippet>
428440
\`\`\`
429441
---
430442
...
431443
432-
Example response -
444+
Example response:
433445
1-5:
434446
LGTM!
435447
---
436448
6-6:
449+
replace the code on line 6 with the following
437450
\`\`\`suggestion
438-
print("Hello!")
451+
for i in range(10):
452+
print("Hello!")
453+
print("World!")
454+
exit(0)
439455
\`\`\`
440456
---
441457
442458
443-
Hunks for review are below -
459+
Hunks for review are below:
444460
`
445461

446462
// calculate tokens based on inputs so far

0 commit comments

Comments
 (0)