diff --git a/README.md b/README.md index 6ce98363..3cee9ead 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/dist/index.js b/dist/index.js index 7701eb7c..d54dd7b2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4224,7 +4224,7 @@ __nccwpck_require__.r(__webpack_exports__); async function run() { - const options = new _options__WEBPACK_IMPORTED_MODULE_2__/* .Options */ .Ei((0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('debug'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('disable_review'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('disable_release_notes'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('max_files'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('review_simple_changes'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('review_comment_lgtm'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput)('path_filters'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('system_message'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_light_model'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_heavy_model'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_model_temperature'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_retries'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_timeout_ms'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_concurrency_limit'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_base_url')); + const options = new _options__WEBPACK_IMPORTED_MODULE_2__/* .Options */ .Ei((0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('debug'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('disable_review'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('disable_release_notes'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('max_files'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('review_simple_changes'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('less_verbose_review'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput)('review_comment_lgtm'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput)('path_filters'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('system_message'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_light_model'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_heavy_model'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_model_temperature'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_retries'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_timeout_ms'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_concurrency_limit'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('openai_base_url')); // print options options.print(); const prompts = new _prompts__WEBPACK_IMPORTED_MODULE_5__/* .Prompts */ .j((0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('summarize'), (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('summarize_release_notes')); @@ -6141,6 +6141,7 @@ class Options { disableReleaseNotes; maxFiles; reviewSimpleChanges; + lessVerboseReview; reviewCommentLGTM; pathFilters; systemMessage; @@ -6153,12 +6154,13 @@ class Options { lightTokenLimits; heavyTokenLimits; apiBaseUrl; - constructor(debug, disableReview, disableReleaseNotes, maxFiles = '0', reviewSimpleChanges = false, reviewCommentLGTM = false, pathFilters = null, systemMessage = '', openaiLightModel = 'gpt-3.5-turbo', openaiHeavyModel = 'gpt-3.5-turbo', openaiModelTemperature = '0.0', openaiRetries = '3', openaiTimeoutMS = '120000', openaiConcurrencyLimit = '4', apiBaseUrl = 'https://api.openai.com/v1') { + constructor(debug, disableReview, disableReleaseNotes, maxFiles = '0', reviewSimpleChanges = false, lessVerboseReview = false, reviewCommentLGTM = false, pathFilters = null, systemMessage = '', openaiLightModel = 'gpt-3.5-turbo', openaiHeavyModel = 'gpt-3.5-turbo', openaiModelTemperature = '0.0', openaiRetries = '3', openaiTimeoutMS = '120000', openaiConcurrencyLimit = '4', apiBaseUrl = 'https://api.openai.com/v1') { this.debug = debug; this.disableReview = disableReview; this.disableReleaseNotes = disableReleaseNotes; this.maxFiles = parseInt(maxFiles); this.reviewSimpleChanges = reviewSimpleChanges; + this.lessVerboseReview = lessVerboseReview; this.reviewCommentLGTM = reviewCommentLGTM; this.pathFilters = new PathFilter(pathFilters); this.systemMessage = systemMessage; @@ -6179,6 +6181,7 @@ class Options { (0,core.info)(`disable_release_notes: ${this.disableReleaseNotes}`); (0,core.info)(`max_files: ${this.maxFiles}`); (0,core.info)(`review_simple_changes: ${this.reviewSimpleChanges}`); + (0,core.info)(`less_verbose_review: ${this.lessVerboseReview}`); (0,core.info)(`review_comment_lgtm: ${this.reviewCommentLGTM}`); (0,core.info)(`path_filters: ${this.pathFilters}`); (0,core.info)(`system_message: ${this.systemMessage}`); @@ -6300,6 +6303,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]: +`; + 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]: @@ -6529,11 +6550,14 @@ $comment this.summarize = summarize; this.summarizeReleaseNotes = summarizeReleaseNotes; } - renderSummarizeFileDiff(inputs, reviewSimpleChanges) { + renderSummarizeFileDiff(inputs, reviewSimpleChanges, lessVerboseReview) { 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); } renderSummarizeChangesets(inputs) { @@ -7055,7 +7079,7 @@ ${hunks.oldHunk} } ins.filename = filename; // render prompt based on inputs so far - let tokens = (0,tokenizer/* getTokenCount */.V)(prompts.renderSummarizeFileDiff(ins, options.reviewSimpleChanges)); + let tokens = (0,tokenizer/* getTokenCount */.V)(prompts.renderSummarizeFileDiff(ins, options.reviewSimpleChanges, options.lessVerboseReview)); const diffTokens = (0,tokenizer/* getTokenCount */.V)(fileDiff); if (tokens + diffTokens > options.lightTokenLimits.requestTokens) { (0,core.info)(`summarize: diff tokens exceeds limit, skip ${filename}`); @@ -7066,7 +7090,7 @@ ${hunks.oldHunk} tokens += fileDiff.length; // summarize content try { - const [summarizeResp] = await lightBot.chat(prompts.renderSummarizeFileDiff(ins, options.reviewSimpleChanges), {}); + const [summarizeResp] = await lightBot.chat(prompts.renderSummarizeFileDiff(ins, options.reviewSimpleChanges, options.lessVerboseReview), {}); if (summarizeResp === '') { (0,core.info)('summarize: nothing fetched from RedRover'); summariesFailed.push(`${filename} (nothing fetched from RedRover)`); diff --git a/src/main.ts b/src/main.ts index e0b69db0..13e50e8e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,6 +18,7 @@ async function run(): Promise { 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'), diff --git a/src/options.ts b/src/options.ts index cc0bbe96..ef97e142 100644 --- a/src/options.ts +++ b/src/options.ts @@ -8,6 +8,7 @@ export class Options { disableReleaseNotes: boolean maxFiles: number reviewSimpleChanges: boolean + lessVerboseReview: boolean reviewCommentLGTM: boolean pathFilters: PathFilter systemMessage: string @@ -27,6 +28,7 @@ export class Options { disableReleaseNotes: boolean, maxFiles = '0', reviewSimpleChanges = false, + lessVerboseReview = false, reviewCommentLGTM = false, pathFilters: string[] | null = null, systemMessage = '', @@ -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 @@ -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}`) diff --git a/src/prompts.ts b/src/prompts.ts index d84c74e1..0a3ec91c 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -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]: +` + 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]: @@ -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) } diff --git a/src/review.ts b/src/review.ts index f0f9241a..e08ecc2d 100644 --- a/src/review.ts +++ b/src/review.ts @@ -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) @@ -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 + ), {} ) @@ -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 } }