- attempt to improve line number commenting

- try to rephrase to be less positive
This commit is contained in:
Ville Saukkonen 2023-03-28 11:35:20 +03:00
parent d20738e432
commit 7b2312e5ab
3 changed files with 15 additions and 9 deletions

9
dist/index.js vendored

@ -105,11 +105,11 @@ function analyzeCode(parsedDiff, prDetails) {
}
function createPrompt(file, chunk, prDetails) {
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
- Do not give positive comments or compliments.
- Do not suggest commenting on the code.
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
- Write the comment in GitHub markdown.
- Don't give positive comments.
- Use the given description only for the overall context and only comment the code.
- Calculate the line number from \`@@ -WW,XX +YY,ZZ @@\` using following formula: \`YY + L = line_number\`, where \`YY\` is the starting line number from the diff hunk, and \`L\` is the number of lines (including unchanged lines) from the starting line until the line you want to comment on. Pay special attention to this instruction and ensure that you count lines accurately.
Review the following code diff in the file "${file.to}" and take the pull request title and description into account when writing the response.
@ -124,7 +124,10 @@ Git diff to review:
\`\`\`diff
${chunk.content}
${chunk.changes.map((c) => c.content).join("\n")}
${chunk.changes
// @ts-expect-error - ln and ln2 exists where needed
.map((c) => `${c.ln ? `${c.ln} ` : `${c.ln2} `}${c.content}`)
.join("\n")}
\`\`\`
`;
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

@ -80,11 +80,11 @@ async function analyzeCode(
function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
- Do not give positive comments or compliments.
- Do not suggest commenting on the code.
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
- Write the comment in GitHub markdown.
- Don't give positive comments.
- Use the given description only for the overall context and only comment the code.
- Calculate the line number from \`@@ -WW,XX +YY,ZZ @@\` using following formula: \`YY + L = line_number\`, where \`YY\` is the starting line number from the diff hunk, and \`L\` is the number of lines (including unchanged lines) from the starting line until the line you want to comment on. Pay special attention to this instruction and ensure that you count lines accurately.
Review the following code diff in the file "${
file.to
@ -101,7 +101,10 @@ Git diff to review:
\`\`\`diff
${chunk.content}
${chunk.changes.map((c) => c.content).join("\n")}
${chunk.changes
// @ts-expect-error - ln and ln2 exists where needed
.map((c) => `${c.ln ? `${c.ln} ` : `${c.ln2} `}${c.content}`)
.join("\n")}
\`\`\`
`;
}