-
Notifications
You must be signed in to change notification settings - Fork 1
feat: REVIEW.md — repo-level review instructions #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,7 +179,13 @@ func (r *Reviewer) Run(ctx context.Context) (int, error) { | |
| } | ||
|
|
||
| // Step 4: Build prompt and call model for each chunk. | ||
| systemPrompt := model.BuildPromptWithCustom(r.cfg.CustomPrompt, r.cfg.Focus, r.cfg.ExtraRules) | ||
| // In CI mode, source REVIEW.md from the trusted base/target ref so that | ||
| // contributor-controlled branches cannot inject review instructions. | ||
| reviewMD := r.cfg.ReviewMD | ||
| if r.cfg.CIMode && r.cfg.CIDiffBaseSHA != "" { | ||
| reviewMD = readReviewMDFromRef(r.cfg.CIDiffBaseSHA) | ||
| } | ||
| systemPrompt := model.BuildPromptFull(r.cfg.CustomPrompt, reviewMD, r.cfg.Focus, r.cfg.ExtraRules) | ||
|
Comment on lines
+184
to
+188
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Fail closed when CI has no trusted base SHA. When Proposed fix- reviewMD := r.cfg.ReviewMD
- if r.cfg.CIMode && r.cfg.CIDiffBaseSHA != "" {
+ reviewMD := ""
+ if !r.cfg.CIMode {
+ reviewMD = r.cfg.ReviewMD
+ } else if r.cfg.CIDiffBaseSHA != "" {
reviewMD = readReviewMDFromRef(r.cfg.CIDiffBaseSHA)
}🤖 Prompt for AI Agents |
||
| var allFindings []model.Finding | ||
| var summary string | ||
| var totalUsage model.TokenUsage | ||
|
|
@@ -469,3 +475,25 @@ func findRepoRoot() string { | |
| dir = parent | ||
| } | ||
| } | ||
|
|
||
| // readReviewMDFromRef reads REVIEW.md from a specific git ref (e.g. base commit SHA). | ||
| // Returns empty string if the file doesn't exist at that ref or git fails. | ||
| func readReviewMDFromRef(ref string) string { | ||
| // Prevent command injection: reject refs that look like flags. | ||
| if strings.HasPrefix(ref, "-") { | ||
| slog.Warn("invalid git ref for REVIEW.md lookup, skipping", "ref", ref) | ||
| return "" | ||
| } | ||
| cmd := exec.Command("git", "show", ref+":REVIEW.md") | ||
| output, err := cmd.Output() | ||
| if err != nil { | ||
| // File doesn't exist at this ref — this is normal and expected. | ||
| slog.Debug("REVIEW.md not found at base ref", "ref", ref) | ||
| return "" | ||
|
Comment on lines
+487
to
+492
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: ast-grep outline internal/reviewer/reviewer.go --view expanded
sed -n '430,540p' internal/reviewer/reviewer.go | cat -nRepository: OpticDiff/code-reviewer Length of output: 3913 🏁 Script executed: #!/bin/bash
set -euo pipefail
ast-grep outline internal/reviewer/reviewer.go --view expanded
echo '---'
sed -n '430,540p' internal/reviewer/reviewer.go | cat -nRepository: OpticDiff/code-reviewer Length of output: 3917 Propagate the context and stop swallowing non-missing-file errors. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| } | ||
| content := strings.TrimSpace(string(output)) | ||
| if content != "" { | ||
| slog.Info("loaded REVIEW.md from trusted base ref", "ref", ref[:min(len(ref), 12)]) | ||
| } | ||
| return content | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.