Skip to content

Commit

Permalink
feat(review): Improve review script (#8)
Browse files Browse the repository at this point in the history
- Optimize instructions steps
- Set a title for each feedback suggestion
- Add description to feedback JSON schema
- Setup Renovate for auto-update
  • Loading branch information
skarllot authored Dec 26, 2024
1 parent 84333ae commit ff2beb8
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
8 changes: 8 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>skarllot/renovate-config"
],
"reviewers": ["skarllot"],
"assignees": ["skarllot"]
}
7 changes: 1 addition & 6 deletions src/FlowPair/Agent/Operations/ReviewChanges/ChatScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,13 @@ Only review lines of code which have been changed (added or removed) in the pull
"""
Ensure the feedback contain the file path and the line number.
Do not provide positive reinforcement or comments on good decisions. Focus solely on areas that need improvement.
Ensure the feedback details are brief, concise, and accurate. If there are multiple similar issues, only comment on the most critical.
"""),
Instruction.StepInstruction.Of(
"""
Ensure the feedback details are brief, concise, and accurate. If there are multiple similar issues, only comment on the most critical.
Include brief example code snippets in the feedback details for your suggested changes when you're confident your suggestions are improvements.
Use the same programming language as the file under review. If there are multiple improvements you suggest in the feedback details, use an ordered list to indicate the priority of the changes.
"""),
Instruction.StepInstruction.Of(
"""
Ensure the message in the feedback is in English.
Ensure the feedback do not infer unknown code, do not speculate the referenced code.
"""),
Instruction.JsonConvertInstruction.Of(
"""
Format the feedback in a valid JSON format as a list of feedbacks, or "[]" for no feedbacks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override string TransformText()
#line hidden
this.Write("</span> ");

this.Write(this.ToStringHelper.ToStringWithCulture(response.RiskDescription));
this.Write(this.ToStringHelper.ToStringWithCulture(response.Title));

#line default
#line hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#>
<div class="box">
<h2 class="subtitle">
<span class="tag<#= GetRiskLevelCssClass(response.RiskScore) #>">Risk Score: <#= response.RiskScore #></span> <#= response.RiskDescription #>
<span class="tag<#= GetRiskLevelCssClass(response.RiskScore) #>">Risk Score: <#= response.RiskScore #></span> <#= response.Title #>
</h2>
<p><strong>File:</strong> <#= response.Path #>:<#= response.LineRange #></p>
<div class="notification">
Expand Down
37 changes: 31 additions & 6 deletions src/FlowPair/Agent/Operations/ReviewChanges/v1/JsonSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ public static class JsonSchema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"description": "An array of code review feedback items",
"items": {
"type": "object",
"description": "A code review feedback item",
"properties": {
"riskScore": {
"type": "integer",
"minimum": 0,
"maximum": 3
"maximum": 3,
"description": "The risk level of the feedback based on LOGAF (Likelihood of Occurrence and Gravity of Adverse effects), ranging from 0 (lowest) to 3 (highest)"
},
"riskDescription": {
"type": "string",
Expand All @@ -25,22 +28,44 @@ public static class JsonSchema
"Low priority adjustments",
"Medium priority adjustments",
"High priority adjustments"
]
],
"description": "A textual description of the risk level"
},
"title": {
"type": "string",
"minLength": 1,
"pattern": "^[^\n\r]+$",
"description": "A brief title or summary of the feedback"
},
"category": {
"type": "string",
"minLength": 1,
"pattern": "^[^\n\r]+$",
"description": "The category or type of the feedback"
},
"language": {
"type": "string",
"minLength": 1,
"pattern": "^[A-Za-z+#]+$",
"description": "The programming language of the code being reviewed"
},
"feedback": {
"type": "string",
"minLength": 5
"minLength": 5,
"description": "Detailed feedback or comments about the code. Use Markdown delimiters (``` or `) for code snippets."
},
"path": {
"type": "string",
"pattern": "^/.*"
"pattern": "^/.*",
"description": "The file path of the code being reviewed, starting with a forward slash"
},
"lineRange": {
"type": "string",
"pattern": "^\\d+-\\d+$"
"pattern": "^\\d+(-\\d+)?$",
"description": "The range of lines affected. Can be a single line number (e.g., '42') or a range (e.g., '42-45')"
}
},
"required": ["riskScore", "riskDescription", "feedback", "path", "lineRange"],
"required": ["riskScore", "riskDescription", "title", "category", "language", "feedback", "path", "lineRange"],
"additionalProperties": false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ namespace Ciandt.FlowTools.FlowPair.Agent.Operations.ReviewChanges.v1;
public sealed record ReviewerFeedbackResponse(
int RiskScore,
string RiskDescription,
string Title,
string Category,
string Language,
string Feedback,
string Path,
string LineRange);

0 comments on commit ff2beb8

Please sign in to comment.