Skip to content

Commit 35085d4

Browse files
author
Test User
committed
Merge branch 'main' into night-watch/PRDs-web-ui
2 parents 373c7fc + 0a899f3 commit 35085d4

6 files changed

Lines changed: 539 additions & 29 deletions

File tree

.github/workflows/pr-review.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: PR Review
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, labeled, unlabeled]
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
review:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: AI PR Review
17+
uses: jonit-dev/openrouter-github-action@main
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
open_router_key: ${{ secrets.OPEN_ROUTER_KEY }}
21+
model_id: 'z-ai/glm-5'
22+
# model_id: 'openai/gpt-5.2-codex'
23+
# reasoning_effort: 'xhigh'
24+
max_tokens: '4096'
25+
max_pr_reviews: '2'
26+
cooldown_period: '5'
27+
custom_prompt: |
28+
### **AI PR Review Instructions**
29+
30+
**Objective:**
31+
Provide a clear, concise, and actionable review of the Pull Request (PR). Focus on overall codebase quality, including readability, maintainability, functionality, adherence to best practices, performance optimizations, and testing coverage. Avoid minor nitty-picky comments and repetitive feedback.
32+
33+
**Focus Areas:**
34+
1. **Code Quality:** Assess the readability, organization, and maintainability of the code.
35+
2. **Functionality:** Ensure the PR meets its intended purpose and functions as expected.
36+
3. **Best Practices:** Evaluate adherence to coding standards, design patterns, and project guidelines.
37+
4. **Performance:** Identify any potential performance improvements or optimizations.
38+
5. **Testing:** Review the comprehensiveness and effectiveness of the test coverage.
39+
6. **Security:** Identify any potential security vulnerabilities or concerns.
40+
7. **Bugs Found:** List any bugs identified in the PR.
41+
8. **Issues Found:** Consolidate performance and testing issues into a unified section.
42+
43+
**Critical Instructions:**
44+
- If you have nothing to say about a particular section, you can omit it from the review.
45+
- If you think there are no issues and the PR is good to go, mention it in the conclusion. No need to add unnecessary feedback. Don't be redundant.
46+
47+
**Scoring Criteria:**
48+
- 90-100: Exceptional quality
49+
• Clean, efficient, and well-documented code
50+
• Comprehensive test coverage (>90%)
51+
• Follows all best practices and design patterns
52+
• No security vulnerabilities
53+
• Optimal performance considerations
54+
• Clear documentation and comments
55+
56+
- 75-89: High quality
57+
• Well-structured and maintainable code
58+
• Good test coverage (70-90%)
59+
• Minor optimization opportunities
60+
• No critical security issues
61+
• Few non-critical issues
62+
• Adequate documentation
63+
64+
- 60-74: Average quality
65+
• Functional but needs improvement
66+
• Basic test coverage (40-70%)
67+
• Some code duplication
68+
• Multiple minor issues
69+
• Basic security considerations
70+
• Limited documentation
71+
72+
- 40-59: Below average
73+
• Significant structural issues
74+
• Poor test coverage (<40%)
75+
• Multiple security concerns
76+
• Performance bottlenecks
77+
• Inadequate error handling
78+
• Missing or unclear documentation
79+
80+
- 0-39: Poor quality
81+
• Major architectural problems
82+
• Missing or broken tests
83+
• Critical security vulnerabilities
84+
• Severe performance issues
85+
• No error handling
86+
• No documentation
87+
• Breaking changes without justification
88+
89+
**Review Structure:**
90+
91+
1. **Overall Summary**
92+
- **Score:** Provide a score from 0-100.
93+
- **Summary:** Brief overview of the PR, highlighting its purpose and main changes.
94+
95+
2. **Key Strengths**
96+
- Highlight 2-3 major strengths related to code quality and overall implementation.
97+
98+
3. **Areas for Improvement**
99+
- Identify 2-3 significant areas that need enhancement, if any.
100+
- Provide actionable suggestions for each identified issue.
101+
102+
4. **Bugs Found** (if any)
103+
- Present any bugs identified in the PR in a table format.
104+
- **Table Columns:** Bug Name, Affected Files, Description, Confidence (High 🟢, Medium 🟡, Low 🔴)
105+
106+
5. **Issues Found** (if any)
107+
- Consolidate performance and testing issues into a single table.
108+
- **Table Columns:** Issue Type, Issue Name, Affected Components, Description, Impact/Severity
109+
110+
6. **Conclusion**
111+
- A short closing statement summarizing the overall quality of the PR and its readiness for merging.
112+
113+
**Example Output:**
114+
115+
### **AI Review Summary**
116+
117+
**🏆 Overall Score:** 85/100
118+
119+
*The PR successfully implements XYZ with clean and well-structured code.*
120+
121+
**✅ Key Strengths**
122+
- **Feature Implementation:** Effectively adds the new feature
123+
- **Code Structure:** Well-organized with logical separation of concerns
124+
125+
**⚠️ Areas for Improvement**
126+
- **Error Handling:** Implement more robust error handling
127+
128+
**🔚 Conclusion**
129+
*The PR is well-executed. Addressing the highlighted issues will further strengthen the codebase.*

docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ All Night Watch env vars are prefixed with `NW_`:
7474
| `NW_REVIEWER_SCHEDULE` | `reviewerSchedule` |
7575
| `NW_PROVIDER` | `provider` |
7676
| `NW_REVIEWER_ENABLED` | `reviewerEnabled` |
77+
| `NW_REVIEWER_PARALLEL` | reviewer parallel fan-out (`1` enabled, `0` disabled) |
7778
| `NW_FALLBACK_ON_RATE_LIMIT` | `fallbackOnRateLimit` |
7879
| `NW_CLAUDE_MODEL` | `claudeModel` |
7980

scripts/night-watch-helpers.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,25 @@ find_eligible_prd() {
305305
}
306306

307307
# ── Clean up worktrees ───────────────────────────────────────────────────────
308-
# Removes any worktrees with "-nw-" in the path (night-watch worktrees).
308+
# Removes night-watch worktrees for this project.
309+
# Optional second argument narrows cleanup to worktrees containing that token.
310+
# This prevents parallel reviewer workers from deleting each other's worktrees.
309311

310312
cleanup_worktrees() {
311313
local project_dir="${1:?project_dir required}"
314+
local scope="${2:-}"
312315
local project_name
313316
project_name=$(basename "${project_dir}")
314317

318+
local match_token="${project_name}-nw"
319+
if [ -n "${scope}" ]; then
320+
match_token="${scope}"
321+
fi
322+
315323
git -C "${project_dir}" worktree list --porcelain 2>/dev/null \
316324
| grep '^worktree ' \
317325
| awk '{print $2}' \
318-
| grep "${project_name}-nw" \
326+
| grep -F "${match_token}" \
319327
| while read -r wt; do
320328
log "CLEANUP: Removing leftover worktree ${wt}"
321329
git -C "${project_dir}" worktree remove --force "${wt}" 2>/dev/null || true

0 commit comments

Comments
 (0)