371
371
372
372
// Pack instructions
373
373
ins . patches += `
374
- Format for changes -
374
+ Format for changes:
375
375
---new_hunk_for_review---
376
376
\`\`\`
377
- <new content annotated with line numbers>
377
+ <new hunk annotated with line numbers>
378
378
\`\`\`
379
379
380
380
---old_hunk_for_context---
381
381
\`\`\`
382
- <old content >
382
+ <old hunk that was replaced by new hunk >
383
383
\`\`\`
384
384
385
385
---comment_chains_for_context---
@@ -390,22 +390,36 @@ Format for changes -
390
390
---end_change_section---
391
391
...
392
392
393
- Instructions -
393
+ Instructions:
394
394
- Only respond in the below response format and nothing else. Each review
395
395
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.
397
399
- It's important that line number ranges for each review section must
398
400
be within the line number range of a specific new hunk. i.e.
399
401
<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.
402
405
- Markdown format is preferred for review comment text.
403
406
- 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.
409
423
- If there are no issues or suggestions and the hunk is acceptable as-is,
410
424
your comment on the line ranges must include the word 'LGTM!'.
411
425
@@ -415,32 +429,34 @@ Response format expected -
415
429
---
416
430
<start_line_number>-<end_line_number>:
417
431
<review comment>
418
- <replacement code/text, if applicable>
419
432
\`\`\`suggestion
420
433
<code/text that replaces everything between start_line_number and end_line_number>
421
434
\`\`\`
422
435
---
423
436
<start_line_number>-<end_line_number>:
424
437
<review comment>
425
- <new code, if applicable>
426
438
\`\`\`<language>
427
439
<new code snippet>
428
440
\`\`\`
429
441
---
430
442
...
431
443
432
- Example response -
444
+ Example response:
433
445
1-5:
434
446
LGTM!
435
447
---
436
448
6-6:
449
+ replace the code on line 6 with the following
437
450
\`\`\`suggestion
438
- print("Hello!")
451
+ for i in range(10):
452
+ print("Hello!")
453
+ print("World!")
454
+ exit(0)
439
455
\`\`\`
440
456
---
441
457
442
458
443
- Hunks for review are below -
459
+ Hunks for review are below:
444
460
`
445
461
446
462
// calculate tokens based on inputs so far
0 commit comments