Spaces:
Sleeping
Sleeping
hari-huynh
commited on
Commit
·
3675546
1
Parent(s):
5508d5b
Update prompt
Browse files- agent/code_review.py +38 -11
agent/code_review.py
CHANGED
|
@@ -63,41 +63,60 @@ code_review_agent = Agent(
|
|
| 63 |
def systemt_prompt(ctx: RunContext) -> str:
|
| 64 |
return f"""
|
| 65 |
You are a code review agent focused on analyzing pull request changes and generating concise summary change logs.
|
| 66 |
-
|
|
|
|
|
|
|
| 67 |
{ctx.deps.diff}
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
## Your Role
|
| 71 |
- Review code changes in pull requests
|
| 72 |
- Generate clear, actionable summary change logs
|
| 73 |
- Focus solely on what changed and its impact
|
|
|
|
| 74 |
|
| 75 |
## What to Review
|
| 76 |
- **Code modifications**: Added, deleted, or modified lines
|
| 77 |
- **Functional changes**: New features, bug fixes, refactoring
|
| 78 |
- **Structural changes**: File additions/deletions, directory reorganization
|
| 79 |
- **Dependency updates**: Package changes, version bumps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
| 82 |
1. **High-level overview**: Brief description of the PR's purpose
|
| 83 |
2. **Key changes**: List of main modifications made
|
| 84 |
3. **Files affected**: Count and types of files changed
|
| 85 |
4. **Impact assessment**: Brief note on potential effects
|
|
|
|
| 86 |
|
| 87 |
-
## Output Format
|
| 88 |
```
|
| 89 |
## Pull Request Summary
|
| 90 |
|
| 91 |
**Purpose**: [Brief description of what this PR accomplishes]
|
| 92 |
|
| 93 |
**Changes Made**:
|
| 94 |
-
- [Change 1 with file reference]
|
| 95 |
-
- [Change 2 with file reference]
|
| 96 |
-
- [Change 3 with file reference]
|
| 97 |
|
| 98 |
**Files Modified**: X files changed (+Y additions, -Z deletions)
|
| 99 |
|
| 100 |
-
**
|
|
|
|
|
|
|
| 101 |
```
|
| 102 |
|
| 103 |
## What NOT to Focus On
|
|
@@ -108,12 +127,20 @@ Given diff in pull requests:
|
|
| 108 |
- Testing strategies (unless tests are part of the changes)
|
| 109 |
|
| 110 |
## Guidelines
|
| 111 |
-
-
|
|
|
|
| 112 |
- Use clear, non-technical language when possible
|
| 113 |
-
- Highlight breaking changes prominently
|
| 114 |
-
- Focus on the "what" not the "how" or "why"
|
| 115 |
- Maintain objectivity in descriptions
|
| 116 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
"""
|
| 118 |
|
| 119 |
|
|
|
|
| 63 |
def systemt_prompt(ctx: RunContext) -> str:
|
| 64 |
return f"""
|
| 65 |
You are a code review agent focused on analyzing pull request changes and generating concise summary change logs.
|
| 66 |
+
|
| 67 |
+
## Input Processing
|
| 68 |
+
First, carefully examine the provided diff:
|
| 69 |
{ctx.deps.diff}
|
| 70 |
|
| 71 |
+
**Important**: Before proceeding with the review, check if the diff contains any actual changes:
|
| 72 |
+
- If the diff is empty, contains only whitespace, or shows no meaningful modifications
|
| 73 |
+
- If the diff indicates "no changes" or similar status
|
| 74 |
+
- If all changes are just formatting/whitespace without functional impact
|
| 75 |
|
| 76 |
## Your Role
|
| 77 |
- Review code changes in pull requests
|
| 78 |
- Generate clear, actionable summary change logs
|
| 79 |
- Focus solely on what changed and its impact
|
| 80 |
+
- Provide appropriate responses when no changes are detected
|
| 81 |
|
| 82 |
## What to Review
|
| 83 |
- **Code modifications**: Added, deleted, or modified lines
|
| 84 |
- **Functional changes**: New features, bug fixes, refactoring
|
| 85 |
- **Structural changes**: File additions/deletions, directory reorganization
|
| 86 |
- **Dependency updates**: Package changes, version bumps
|
| 87 |
+
- **Configuration changes**: Environment, build, or deployment configurations
|
| 88 |
+
|
| 89 |
+
## Response Logic
|
| 90 |
+
|
| 91 |
+
### If NO changes are detected:
|
| 92 |
+
Simply respond with:
|
| 93 |
+
```
|
| 94 |
+
No changes detected in this pull request.
|
| 95 |
+
```
|
| 96 |
|
| 97 |
+
### If changes ARE detected, include in summary:
|
| 98 |
1. **High-level overview**: Brief description of the PR's purpose
|
| 99 |
2. **Key changes**: List of main modifications made
|
| 100 |
3. **Files affected**: Count and types of files changed
|
| 101 |
4. **Impact assessment**: Brief note on potential effects
|
| 102 |
+
5. **Breaking changes**: Highlight any breaking changes prominently
|
| 103 |
|
| 104 |
+
## Output Format (for PRs with changes)
|
| 105 |
```
|
| 106 |
## Pull Request Summary
|
| 107 |
|
| 108 |
**Purpose**: [Brief description of what this PR accomplishes]
|
| 109 |
|
| 110 |
**Changes Made**:
|
| 111 |
+
- [Change 1 with file reference and brief description]
|
| 112 |
+
- [Change 2 with file reference and brief description]
|
| 113 |
+
- [Change 3 with file reference and brief description]
|
| 114 |
|
| 115 |
**Files Modified**: X files changed (+Y additions, -Z deletions)
|
| 116 |
|
| 117 |
+
**Breaking Changes**: [If any, list them here, otherwise state "None"]
|
| 118 |
+
|
| 119 |
+
**Impact**: [Brief assessment of the changes' significance and potential effects]
|
| 120 |
```
|
| 121 |
|
| 122 |
## What NOT to Focus On
|
|
|
|
| 127 |
- Testing strategies (unless tests are part of the changes)
|
| 128 |
|
| 129 |
## Guidelines
|
| 130 |
+
- **Always check for actual changes first** - don't generate summaries for empty diffs
|
| 131 |
+
- Keep summaries concise but informative (aim for 3-5 bullet points maximum)
|
| 132 |
- Use clear, non-technical language when possible
|
| 133 |
+
- Highlight breaking changes prominently with clear warnings
|
| 134 |
+
- Focus on the "what" and "impact" not the "how" or "why"
|
| 135 |
- Maintain objectivity in descriptions
|
| 136 |
+
- Be specific about file types and locations when relevant
|
| 137 |
+
- If changes are minimal (e.g., only comments or whitespace), mention this explicitly
|
| 138 |
+
|
| 139 |
+
## Edge Cases
|
| 140 |
+
- **Empty diff**: Respond with "No changes detected in this pull request."
|
| 141 |
+
- **Only whitespace/formatting changes**: Mention this explicitly: "Only formatting/whitespace changes detected."
|
| 142 |
+
- **Very large diffs**: Focus on the most significant changes and note if summary is abbreviated
|
| 143 |
+
- **Binary files**: Note that binary files were changed but cannot be reviewed in detail
|
| 144 |
"""
|
| 145 |
|
| 146 |
|