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

Commit 9a257da

Browse files
authored
Update prompts (#408)
<!-- This is an auto-generated comment: release notes by OSS CodeRabbit --> ### Summary by CodeRabbit **New Feature:** - Introduced a `Mobile` struct in `mobile.go` to simulate the behavior of a mobile device with methods for turning on/off, usage, and charging. - Enhanced code snippets and instructions for providing replacement code suggestions in `src/prompts.ts`. - Improved parsing functionality in `src/review.ts` to handle context lines and skip annotations for the first 3 and last 3 lines. - Added a new section in the PR description promoting the Pro version of the project. > 🎉 Code's evolving, growing so fine, 🌱 > > With every pull request, it shines. ✨ > > Mobile simulation, parsing delight, 📱🎁 > > Our codebase takes an exciting flight! 🚀 <!-- end of auto-generated comment: release notes by OSS CodeRabbit -->
1 parent 6e65620 commit 9a257da

File tree

3 files changed

+58
-28
lines changed

3 files changed

+58
-28
lines changed

dist/index.js

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

src/prompts.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,9 @@ format \`<line_number><colon><whitespace>\`.
173173
line number range must map exactly to the range (inclusive) that needs to
174174
be replaced within a new hunk. For instance, if 2 lines of code in a hunk
175175
need to be replaced with 15 lines of code, the line number range must be
176-
those exact 2 lines. If an entire hunk need to be replaced with new code,
177-
then the line number range must be the entire hunk and the new code must
178-
exactly replace ALL the lines in the hunk. Replacement suggestions should be
179-
complete, correctly formatted and without the line number annotations.
176+
those exact 2 lines. You must replace all the lines in the range with your
177+
suggestion. Replacement suggestions must be complete, correctly
178+
formatted/indented and without the line number annotations.
180179
- If there are no issues found on a line range, you MUST respond with the
181180
text \`LGTM!\` for that line range in the review section.
182181
- Reflect on your comments and line number ranges before sending the final
@@ -207,18 +206,18 @@ format \`<line_number><colon><whitespace>\`.
207206
208207
---new_hunk---
209208
\`\`\`
210-
12: z = x / y
211-
13: return z
212-
14:
209+
z = x / y
210+
return z
211+
213212
15: def add(x, y):
214213
16: z = x - y
215214
17: retrn z
216215
18:
217216
19: def multiply(x, y):
218217
20: return x * y
219-
21:
220-
22: def subtract(x, y):
221-
23: z = x - y
218+
219+
def subtract(x, y):
220+
z = x - y
222221
\`\`\`
223222
224223
---old_hunk---

src/review.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@ ${SHORT_SUMMARY_END_TAG}
478478
### Ignoring further reviews
479479
- Type \`@coderabbitai: ignore\` anywhere in the PR description to ignore further reviews from the bot.
480480
481+
### Support us :)
482+
483+
If you like this project, please support us by purchasing the [Pro version](https://coderabbit.ai)! The Pro version has advanced context and several proprietary improvements compared to the open source version.
484+
481485
</details>
482486
`
483487

@@ -810,7 +814,6 @@ const parsePatch = (
810814
const oldHunkLines: string[] = []
811815
const newHunkLines: string[] = []
812816

813-
// let old_line = hunkInfo.old_hunk.start_line
814817
let newLine = hunkInfo.newHunk.startLine
815818

816819
const lines = patch.split('\n').slice(1) // Skip the @@ line
@@ -820,17 +823,32 @@ const parsePatch = (
820823
lines.pop()
821824
}
822825

826+
// Skip annotations for the first 3 and last 3 lines
827+
const skipStart = 3
828+
const skipEnd = 3
829+
830+
let currentLine = 0
831+
832+
const removalOnly = !lines.some(line => line.startsWith('+'))
833+
823834
for (const line of lines) {
835+
currentLine++
824836
if (line.startsWith('-')) {
825837
oldHunkLines.push(`${line.substring(1)}`)
826-
// old_line++
827838
} else if (line.startsWith('+')) {
828839
newHunkLines.push(`${newLine}: ${line.substring(1)}`)
829840
newLine++
830841
} else {
842+
// context line
831843
oldHunkLines.push(`${line}`)
832-
newHunkLines.push(`${newLine}: ${line}`)
833-
// old_line++
844+
if (
845+
removalOnly ||
846+
(currentLine > skipStart && currentLine <= lines.length - skipEnd)
847+
) {
848+
newHunkLines.push(`${newLine}: ${line}`)
849+
} else {
850+
newHunkLines.push(`${line}`)
851+
}
834852
newLine++
835853
}
836854
}

0 commit comments

Comments
 (0)