Skip to content

Commit b120fe2

Browse files
authored
Git history context for drafter (#95)
1 parent 991810f commit b120fe2

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

review-pr/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,24 @@ runs:
182182
fi
183183
fi
184184
185+
- name: Generate file history
186+
if: hashFiles('changed_files.txt') != ''
187+
shell: bash
188+
run: |
189+
> /tmp/file_history.txt
190+
while IFS= read -r file; do
191+
# Skip new files (no git history)
192+
HISTORY=$(git log --oneline -5 -- "$file" 2>/dev/null || true)
193+
if [ -n "$HISTORY" ]; then
194+
echo "## $file" >> /tmp/file_history.txt
195+
echo "$HISTORY" >> /tmp/file_history.txt
196+
echo "" >> /tmp/file_history.txt
197+
fi
198+
done < changed_files.txt
199+
200+
ENTRIES=$(grep -c '^## ' /tmp/file_history.txt 2>/dev/null || echo "0")
201+
echo "✅ Generated history for $ENTRIES file(s)"
202+
185203
- name: Resolve stale review threads
186204
continue-on-error: true
187205
shell: bash

review-pr/agents/pr-review.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,19 @@ agents:
114114
Project context (from AGENTS.md):
115115
<contents of AGENTS.md, or "No AGENTS.md found" if absent>
116116
117+
File history (recent commits):
118+
<contents of /tmp/file_history.txt, or "No file history available" if absent>
119+
117120
Learned patterns: <any relevant memories>
118121
```
119122
120123
The drafter has `read_file` access and will read the chunk from disk. Keep the
121-
delegation message short — just the file path, chunk number, project context, and any learned patterns.
124+
delegation message short — just the file path, chunk number, project context,
125+
file history, and any learned patterns.
126+
127+
If `/tmp/file_history.txt` exists, read it and include relevant entries for the
128+
files in the current chunk. This helps the drafter understand what kinds of bugs
129+
this code has had before.
122130
123131
**Include a file listing** so the drafter knows what files exist on disk. Before
124132
delegating, run:
@@ -293,6 +301,10 @@ agents:
293301
You also have `read_file` access for reading full source files when analyzing findings
294302
(e.g., to check imports, surrounding code, or related functions).
295303
304+
The orchestrator may provide recent git commit history for changed files. Use this to
305+
understand what kinds of bugs this code has had before and what areas are actively
306+
being fixed.
307+
296308
## REQUIRED: Verify Before Reporting
297309
298310
Before reporting a finding, you MUST use `read_file` to read the full source file

0 commit comments

Comments
 (0)