Skip to content

Commit

Permalink
add option for less verbose reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
gwilkes-rv committed Jul 11, 2023
1 parent fa1aee6 commit a0f4ab7
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ features of this action are:
changes (e.g. typo fixes) and when changes look good for the most part. It can
be disabled by setting `review_simple_changes` and `review_comment_lgtm` to
`true`.
- **Less verbose reviews**: For more experienced users the Red Rover can err on
side of ignoring a change unless it is a major one. This is disabled by default,
to enable set `review_simple_changes` to `false` and `less_verbose_review` to
`true`.
- **Customizable prompts**: Tailor the `system_message`, `summarize`, and
`summarize_release_notes` prompts to focus on specific aspects of the review
process or even change the review objective.
Expand Down
36 changes: 30 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async function run(): Promise<void> {
getBooleanInput('disable_release_notes'),
getInput('max_files'),
getBooleanInput('review_simple_changes'),
getBooleanInput('less_verbose_review'),
getBooleanInput('review_comment_lgtm'),
getMultilineInput('path_filters'),
getInput('system_message'),
Expand Down
4 changes: 4 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class Options {
disableReleaseNotes: boolean
maxFiles: number
reviewSimpleChanges: boolean
lessVerboseReview: boolean
reviewCommentLGTM: boolean
pathFilters: PathFilter
systemMessage: string
Expand All @@ -27,6 +28,7 @@ export class Options {
disableReleaseNotes: boolean,
maxFiles = '0',
reviewSimpleChanges = false,
lessVerboseReview = false,
reviewCommentLGTM = false,
pathFilters: string[] | null = null,
systemMessage = '',
Expand All @@ -43,6 +45,7 @@ export class Options {
this.disableReleaseNotes = disableReleaseNotes
this.maxFiles = parseInt(maxFiles)
this.reviewSimpleChanges = reviewSimpleChanges
this.lessVerboseReview = lessVerboseReview
this.reviewCommentLGTM = reviewCommentLGTM
this.pathFilters = new PathFilter(pathFilters)
this.systemMessage = systemMessage
Expand All @@ -64,6 +67,7 @@ export class Options {
info(`disable_release_notes: ${this.disableReleaseNotes}`)
info(`max_files: ${this.maxFiles}`)
info(`review_simple_changes: ${this.reviewSimpleChanges}`)
info(`less_verbose_review: ${this.lessVerboseReview}`)
info(`review_comment_lgtm: ${this.reviewCommentLGTM}`)
info(`path_filters: ${this.pathFilters}`)
info(`system_message: ${this.systemMessage}`)
Expand Down
26 changes: 24 additions & 2 deletions src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ lines changed, the potential impact on the overall system, and the likelihood of
introducing new bugs or security vulnerabilities.
When in doubt, always err on the side of caution and triage the diff as \`NEEDS_REVIEW\`.
You must follow the format below strictly for triaging the diff and
do not add any additional text in your response:
[TRIAGE]: <NEEDS_REVIEW or APPROVED>
`
lessVerboseTriageFileDiff = `Below the summary, I would also like you to triage the diff as \`NEEDS_REVIEW\` or
\`APPROVED\` based on the following criteria:
- If the diff involves any major modifications to the logic or functionality triage
it as \`NEEDS_REVIEW\`. This includes changes to control structures,
function calls, or variable assignments that might impact the behavior of the code.
- If the diff contains minor changes that don't affect the code logic, such as
fixing typos, formatting, or renaming variables for clarity, triage it as \`APPROVED\`.
Please evaluate the diff thoroughly and take into account factors such as the number of
lines changed, the potential impact on the overall system, and the likelihood of
introducing new bugs or security vulnerabilities.
When in doubt, always err on the side of approving and triage the diff as \`APPROVED\`.
You must follow the format below strictly for triaging the diff and
do not add any additional text in your response:
[TRIAGE]: <NEEDS_REVIEW or APPROVED>
Expand Down Expand Up @@ -275,12 +293,16 @@ $comment

renderSummarizeFileDiff(
inputs: Inputs,
reviewSimpleChanges: boolean
reviewSimpleChanges: boolean,
lessVerboseReview: boolean
): string {
let prompt = this.summarizeFileDiff
if (reviewSimpleChanges === false) {
if (reviewSimpleChanges === false && lessVerboseReview === false) {
prompt += this.triageFileDiff
}
if (reviewSimpleChanges === false && lessVerboseReview === true) {
prompt += this.lessVerboseTriageFileDiff
}
return inputs.render(prompt)
}

Expand Down
16 changes: 13 additions & 3 deletions src/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ ${hunks.oldHunk}

// render prompt based on inputs so far
let tokens = getTokenCount(
prompts.renderSummarizeFileDiff(ins, options.reviewSimpleChanges)
prompts.renderSummarizeFileDiff(
ins,
options.reviewSimpleChanges,
options.lessVerboseReview
)
)

const diffTokens = getTokenCount(fileDiff)
Expand All @@ -282,7 +286,11 @@ ${hunks.oldHunk}
// summarize content
try {
const [summarizeResp] = await lightBot.chat(
prompts.renderSummarizeFileDiff(ins, options.reviewSimpleChanges),
prompts.renderSummarizeFileDiff(
ins,
options.reviewSimpleChanges,
options.lessVerboseReview
),
{}
)

Expand Down Expand Up @@ -312,7 +320,9 @@ ${hunks.oldHunk}
}
} catch (e: any) {
warning(`summarize: error from RedRover: ${e as string}`)
summariesFailed.push(`${filename} (error from RedRover: ${e as string})})`)
summariesFailed.push(
`${filename} (error from RedRover: ${e as string})})`
)
return null
}
}
Expand Down

0 comments on commit a0f4ab7

Please sign in to comment.