opencode-bonfire 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review a GitHub pull request and post inline comments
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Review Pull Request
|
|
6
|
+
|
|
7
|
+
Review a GitHub PR in an isolated worktree, then post inline comments on findings.
|
|
8
|
+
|
|
9
|
+
## Step 1: Parse Arguments
|
|
10
|
+
|
|
11
|
+
Extract PR number from `$ARGUMENTS`:
|
|
12
|
+
- `333` or `#333` → PR number 333
|
|
13
|
+
- Empty → Show usage and abort
|
|
14
|
+
|
|
15
|
+
**Usage**: `/bonfire-review-pr <pr-number>`
|
|
16
|
+
|
|
17
|
+
If no PR number provided:
|
|
18
|
+
> "Usage: `/bonfire-review-pr <pr-number>`
|
|
19
|
+
>
|
|
20
|
+
> Example: `/bonfire-review-pr 333`"
|
|
21
|
+
|
|
22
|
+
## Step 2: Verify Environment
|
|
23
|
+
|
|
24
|
+
Check if running inside tmux:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
[ -n "$TMUX" ] && echo "tmux: yes" || echo "tmux: no"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**If not in tmux**: Provide manual instructions and abort:
|
|
31
|
+
|
|
32
|
+
> "PR review with inline comments requires tmux for worktree isolation.
|
|
33
|
+
>
|
|
34
|
+
> **Manual alternative:**
|
|
35
|
+
> 1. Create worktree: `git worktree add ../pr-<number>-review origin/<branch>`
|
|
36
|
+
> 2. Open new terminal in that directory
|
|
37
|
+
> 3. Run: `opencode 'Review this PR and help me post comments'`
|
|
38
|
+
> 4. Clean up when done: `git worktree remove ../pr-<number>-review`"
|
|
39
|
+
|
|
40
|
+
## Step 3: Fetch PR Metadata
|
|
41
|
+
|
|
42
|
+
Get PR details:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
gh pr view <number> --json number,title,headRefName,baseRefName,headRefOid,url,body,files
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**If PR not found**: Abort with "PR #<number> not found in this repository."
|
|
49
|
+
|
|
50
|
+
Extract and store:
|
|
51
|
+
- `headRefName` - PR branch name
|
|
52
|
+
- `baseRefName` - Target branch (usually main)
|
|
53
|
+
- `headRefOid` - Commit SHA for inline comments
|
|
54
|
+
- `title` - PR title
|
|
55
|
+
- `url` - PR URL
|
|
56
|
+
- `files` - Changed files list
|
|
57
|
+
|
|
58
|
+
## Step 4: Find Git Root and Compute Paths
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git rev-parse --show-toplevel
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Compute worktree path: `<git-root>/../<repo-name>-pr-<number>-review`
|
|
65
|
+
|
|
66
|
+
Example: `/Users/vieko/dev/gtm` → `/Users/vieko/dev/gtm-pr-333-review`
|
|
67
|
+
|
|
68
|
+
## Step 5: Create Worktree
|
|
69
|
+
|
|
70
|
+
Create isolated worktree for PR branch:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git fetch origin <headRefName>
|
|
74
|
+
git worktree add <worktree-path> origin/<headRefName>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**On failure** (branch conflict, dirty state, etc.):
|
|
78
|
+
|
|
79
|
+
1. Check error message
|
|
80
|
+
2. If worktree already exists: Ask user "Worktree already exists. Remove and recreate?"
|
|
81
|
+
- Yes: `git worktree remove <worktree-path> --force` then retry
|
|
82
|
+
- No: Abort
|
|
83
|
+
3. If other error: Report error and abort with suggestion to check `git worktree list`
|
|
84
|
+
|
|
85
|
+
## Step 6: Get PR Diff Summary
|
|
86
|
+
|
|
87
|
+
Get the diff for context:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
cd <worktree-path> && git diff origin/<baseRefName>...HEAD --stat
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Get changed files:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
cd <worktree-path> && git diff origin/<baseRefName>...HEAD --name-only
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Step 7: Generate Review Context
|
|
100
|
+
|
|
101
|
+
Create context document for spawned session.
|
|
102
|
+
|
|
103
|
+
Write to `<worktree-path>/.bonfire-pr-review-context.md`:
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
# PR Review Context
|
|
107
|
+
|
|
108
|
+
**PR**: #<number> - <title>
|
|
109
|
+
**URL**: <url>
|
|
110
|
+
**Branch**: <headRefName> → <baseRefName>
|
|
111
|
+
**Commit**: <headRefOid>
|
|
112
|
+
|
|
113
|
+
## Changed Files
|
|
114
|
+
|
|
115
|
+
<list of changed files>
|
|
116
|
+
|
|
117
|
+
## PR Description
|
|
118
|
+
|
|
119
|
+
<body from PR>
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Instructions
|
|
124
|
+
|
|
125
|
+
You are reviewing PR #<number> in an isolated worktree.
|
|
126
|
+
|
|
127
|
+
### Step 1: Run Review
|
|
128
|
+
|
|
129
|
+
Use the task tool to invoke the **work-reviewer** subagent:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
Review this pull request for blindspots, gaps, and improvements.
|
|
133
|
+
|
|
134
|
+
**Scope**: PR #<number> - <title>
|
|
135
|
+
|
|
136
|
+
**Files changed**:
|
|
137
|
+
<list of changed files>
|
|
138
|
+
|
|
139
|
+
**PR Description**:
|
|
140
|
+
<body>
|
|
141
|
+
|
|
142
|
+
Return categorized findings with severity, effort, and specific file:line references.
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Step 2: Present Findings
|
|
146
|
+
|
|
147
|
+
After review completes, present findings grouped by severity.
|
|
148
|
+
|
|
149
|
+
For each finding, note:
|
|
150
|
+
- File and line number (if applicable)
|
|
151
|
+
- Severity (critical/moderate/minor)
|
|
152
|
+
- Description
|
|
153
|
+
|
|
154
|
+
### Step 3: Batch Comment Selection
|
|
155
|
+
|
|
156
|
+
Ask user: "Which findings should I post as PR comments?"
|
|
157
|
+
|
|
158
|
+
Options:
|
|
159
|
+
1. List findings by number, let user select (e.g., "1, 3, 5")
|
|
160
|
+
2. "All" - post all findings
|
|
161
|
+
3. "None" - skip commenting
|
|
162
|
+
|
|
163
|
+
### Step 4: Post Inline Comments
|
|
164
|
+
|
|
165
|
+
For each selected finding with a file:line reference, post an inline comment:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
gh api repos/{owner}/{repo}/pulls/<number>/comments \
|
|
169
|
+
-f body="**Review Finding**
|
|
170
|
+
|
|
171
|
+
<finding description>
|
|
172
|
+
|
|
173
|
+
*Severity: <severity> | Effort: <effort>*" \
|
|
174
|
+
-f commit_id="<headRefOid>" \
|
|
175
|
+
-f path="<file-path>" \
|
|
176
|
+
-f line=<line-number>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
For findings without line numbers, post as general PR comment:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
gh pr comment <number> --body "**Review Finding**
|
|
183
|
+
|
|
184
|
+
<finding description>
|
|
185
|
+
|
|
186
|
+
*Severity: <severity> | Effort: <effort>*"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Note**: GitHub only allows inline comments on files that are part of the PR diff. If a finding references a file not in the diff (e.g., missing config in turbo.json when turbo.json wasn't changed), post it as a general PR comment instead.
|
|
190
|
+
|
|
191
|
+
### Step 5: Offer Cleanup
|
|
192
|
+
|
|
193
|
+
After commenting, ask: "Review complete. Remove worktree?"
|
|
194
|
+
|
|
195
|
+
If yes:
|
|
196
|
+
```bash
|
|
197
|
+
cd <original-git-root>
|
|
198
|
+
git worktree remove <worktree-path>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Report: "Worktree cleaned up. PR review complete."
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Step 8: Spawn Review Session
|
|
205
|
+
|
|
206
|
+
Spawn a new OpenCode session in the worktree:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
WORKTREE_PATH="<computed-worktree-path>"
|
|
210
|
+
CONTEXT="$(cat "$WORKTREE_PATH/.bonfire-pr-review-context.md")"
|
|
211
|
+
tmux split-window -h -c "$WORKTREE_PATH" \
|
|
212
|
+
"opencode --append-system-prompt '$CONTEXT' 'Ready to review PR #<number>. Starting work-reviewer subagent...'"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Verify spawn succeeded**: If tmux fails (terminal too small), warn user and provide manual instructions.
|
|
216
|
+
|
|
217
|
+
## Step 9: Confirm
|
|
218
|
+
|
|
219
|
+
Tell the user:
|
|
220
|
+
|
|
221
|
+
> **PR review session spawned.**
|
|
222
|
+
>
|
|
223
|
+
> - Worktree created at `<worktree-path>`
|
|
224
|
+
> - Review session opened in adjacent pane
|
|
225
|
+
> - The new session will run work-reviewer and help you post comments
|
|
226
|
+
>
|
|
227
|
+
> When done, the review session will offer to clean up the worktree.
|
|
228
|
+
>
|
|
229
|
+
> You can continue working here - your current branch is unchanged.
|