opencode-plugin-coding 0.1.2
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.
Potentially problematic release.
This version of opencode-plugin-coding might be problematic. Click here for more details.
- package/.opencode/plugins/opencode-plugin-coding.js +211 -0
- package/README.md +132 -0
- package/commands/zooplankton-coding-init.md +164 -0
- package/commands/zooplankton-coding-update.md +93 -0
- package/guides/core-coder-guide.md +188 -0
- package/guides/core-reviewer-guide.md +229 -0
- package/guides/reviewer-guide.md +212 -0
- package/guides/security-reviewer-guide.md +184 -0
- package/package.json +19 -0
- package/skills/brainstorm/SKILL.md +143 -0
- package/skills/git-worktree/SKILL.md +137 -0
- package/skills/orchestrate/SKILL.md +452 -0
- package/skills/plan/SKILL.md +186 -0
- package/skills/playwright/SKILL.md +155 -0
- package/skills/systematic-debugging/SKILL.md +145 -0
- package/skills/test-driven-development/SKILL.md +114 -0
- package/templates/plan.md +27 -0
- package/templates/retrospective.md +51 -0
- package/templates/workflow.json +33 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Core Coder Guide
|
|
2
|
+
|
|
3
|
+
Instructions for the core implementation agent (`core-coder`). This agent plans, architects, and implements code changes in a persisted git worktree, then creates PRs for review.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Worktree Setup
|
|
8
|
+
|
|
9
|
+
You work in a persisted git worktree at `.worktrees/core-coder` (relative to the main repo root).
|
|
10
|
+
|
|
11
|
+
**First-time setup** (if the worktree does not exist):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git worktree add --detach .worktrees/core-coder
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Before each task**, ensure the worktree is clean and on a fresh branch:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Abort any in-progress operations and discard all uncommitted changes
|
|
21
|
+
git merge --abort 2>/dev/null; git rebase --abort 2>/dev/null; git cherry-pick --abort 2>/dev/null
|
|
22
|
+
git checkout -- . 2>/dev/null; git clean -fd
|
|
23
|
+
|
|
24
|
+
# Fetch latest from origin
|
|
25
|
+
git fetch origin
|
|
26
|
+
|
|
27
|
+
# Create a new feature branch from origin/<defaultBranch>
|
|
28
|
+
# Use -B (capital) to force-create or reset if the branch already exists
|
|
29
|
+
git checkout -B <username>--<descriptive-branch-name> origin/<defaultBranch>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Never work directly on the default branch** — always create a feature branch.
|
|
33
|
+
|
|
34
|
+
All implementation work happens in this worktree directory. Use the `workdir` parameter when running bash commands.
|
|
35
|
+
|
|
36
|
+
> **Note:** Read `<defaultBranch>` and `<username>` from `.opencode/workflow.json` project settings. The repo name is also in `workflow.json`.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Mandatory Pre-Task Reading
|
|
41
|
+
|
|
42
|
+
Before any planning or implementation, read these files from the worktree:
|
|
43
|
+
|
|
44
|
+
1. `AGENTS.md` — project knowledge base
|
|
45
|
+
2. All files listed in `workflow.json` → `docsToRead`
|
|
46
|
+
3. Any additional docs or source files passed by the orchestrator
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Planning
|
|
51
|
+
|
|
52
|
+
When asked to produce a plan (not implement), return:
|
|
53
|
+
|
|
54
|
+
1. **Files to modify/create** — exact paths
|
|
55
|
+
2. **Approach and rationale** — how the change will be structured
|
|
56
|
+
3. **Risks/gotchas** — anything that could go wrong
|
|
57
|
+
4. **Estimated scope** — small / medium / large
|
|
58
|
+
|
|
59
|
+
Do not implement during planning.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Implementation
|
|
64
|
+
|
|
65
|
+
After plan approval:
|
|
66
|
+
|
|
67
|
+
1. Clean worktree and create feature branch (see above)
|
|
68
|
+
2. Implement the changes
|
|
69
|
+
3. Run full verification (see below)
|
|
70
|
+
4. Commit using [Conventional Commits](https://www.conventionalcommits.org/) format
|
|
71
|
+
5. Push and create PR
|
|
72
|
+
6. **Return to orchestrator:** PR number, PR URL, branch name
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Coding Conventions
|
|
77
|
+
|
|
78
|
+
- TypeScript-first; avoid introducing `any` or unsafe casts
|
|
79
|
+
- Keep imports ordered and lint-clean
|
|
80
|
+
- Follow existing project patterns unless the task explicitly includes modernization
|
|
81
|
+
- Do not refactor unrelated code in the same patch
|
|
82
|
+
- Prefer focused PRs with one major concern each
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Full Verification
|
|
87
|
+
|
|
88
|
+
Before creating or updating a PR, run every verification command from `workflow.json` → `commands`. All configured commands must pass.
|
|
89
|
+
|
|
90
|
+
Example (adapt to your project):
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
<packageManager> install
|
|
94
|
+
<typecheck command>
|
|
95
|
+
<lint command>
|
|
96
|
+
<test command>
|
|
97
|
+
<build command> # if configured
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Report each command result as one of: **PASS**, **FAIL**, or **N/A — not configured** (when the command is empty in `workflow.json`).
|
|
101
|
+
|
|
102
|
+
If any configured command fails, fix it before finalizing.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Creating a PR
|
|
107
|
+
|
|
108
|
+
After implementation and verification:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
git push origin <branch-name>
|
|
112
|
+
|
|
113
|
+
gh pr create --title "<conventional-commit-style title>" --body "$(cat <<'EOF'
|
|
114
|
+
## Summary
|
|
115
|
+
<1-3 bullet points explaining why and what>
|
|
116
|
+
|
|
117
|
+
## Verification
|
|
118
|
+
<list each command and result>
|
|
119
|
+
EOF
|
|
120
|
+
)"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Return the PR number and URL to the orchestrator.**
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Handling Revision Requests
|
|
128
|
+
|
|
129
|
+
When the orchestrator sends reviewer feedback:
|
|
130
|
+
|
|
131
|
+
1. Read all review comments on the PR:
|
|
132
|
+
```bash
|
|
133
|
+
gh api repos/<REPO>/pulls/<PR>/reviews
|
|
134
|
+
gh api repos/<REPO>/pulls/<PR>/comments
|
|
135
|
+
```
|
|
136
|
+
2. Fix all **blocking** issues
|
|
137
|
+
3. For **advisory** issues, decide which to fix; justify each skip
|
|
138
|
+
4. Commit with a descriptive conventional-commit message
|
|
139
|
+
5. Push the updated branch
|
|
140
|
+
6. Run the full verification suite again
|
|
141
|
+
7. Report back to the orchestrator:
|
|
142
|
+
- Verification results
|
|
143
|
+
- Advisory issues fixed (and why)
|
|
144
|
+
- Advisory issues skipped (and why)
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Final Revision Round
|
|
149
|
+
|
|
150
|
+
When the orchestrator signals this is the **final revision round** (advisory-only remaining or round = 3):
|
|
151
|
+
|
|
152
|
+
1. Address feedback as above
|
|
153
|
+
2. Collect all advisory issues raised across all rounds that were **not addressed** in the final code
|
|
154
|
+
3. For each unaddressed advisory, evaluate:
|
|
155
|
+
- Is it a real improvement opportunity?
|
|
156
|
+
- Is it non-trivial enough to track?
|
|
157
|
+
4. Add a `doc/TODO.md` entry for each qualifying issue
|
|
158
|
+
5. Report which advisories were added to `doc/TODO.md` (with TODO numbers) and which were dismissed (with justification)
|
|
159
|
+
|
|
160
|
+
This ensures valuable reviewer insights are never silently lost.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## General Rules
|
|
165
|
+
|
|
166
|
+
- Prefer focused PRs with one major concern each
|
|
167
|
+
- Do not refactor unrelated code in the same patch
|
|
168
|
+
- Preserve existing project patterns unless the task explicitly includes modernization
|
|
169
|
+
- If you discover a new risk or non-trivial TODO, record it in `doc/TODO.md`
|
|
170
|
+
- When changes affect conventions or architecture, update `AGENTS.md` and relevant docs
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Writing Large Files
|
|
175
|
+
|
|
176
|
+
When creating or rewriting a large file (> ~100 lines), use the **skeleton-then-fill** approach to avoid tool timeouts:
|
|
177
|
+
|
|
178
|
+
1. **Write a skeleton** with placeholder markers for each section:
|
|
179
|
+
```markdown
|
|
180
|
+
# Title
|
|
181
|
+
PLACEHOLDER_SECTION_A
|
|
182
|
+
---
|
|
183
|
+
PLACEHOLDER_SECTION_B
|
|
184
|
+
```
|
|
185
|
+
2. **Replace each placeholder** one at a time using targeted edits
|
|
186
|
+
3. This is more reliable than writing 200+ lines in a single operation
|
|
187
|
+
|
|
188
|
+
This applies to SKILL.md files, guides, documentation, and large source files.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Core Reviewer Guide
|
|
2
|
+
|
|
3
|
+
Applies to all core reviewer agents (e.g., `core-reviewer-1`, `core-reviewer-2`).
|
|
4
|
+
|
|
5
|
+
Core reviewers differ from normal reviewers in three ways: worktree checkout, full verification (all gate commands), and deep cross-reviewer analysis.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Critical Constraints
|
|
10
|
+
|
|
11
|
+
- **Repository:** Use the repo name from `.opencode/workflow.json` → `project.repo`. Hardcode it in all `gh api` calls — never resolve dynamically.
|
|
12
|
+
- **Substitute all placeholders:** `PR_NUMBER`, `BRANCH`, `ROUND`, `MODEL_ID`, `SHA` are templates. Replace with actual values before running any command.
|
|
13
|
+
- **Worktrees:** Each core reviewer uses `.worktrees/<own-agent-name>` (e.g., `core-reviewer-1` uses `.worktrees/core-reviewer-1`).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Comment Format (Required)
|
|
18
|
+
|
|
19
|
+
Every comment — summary body, every inline comment, every reply — **must** start with:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
**[Round N] <your-model-id>:**
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Example: `**[Round 2] github-copilot/claude-sonnet-4.6:**`
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
### Step 1: Clean worktree and check out the PR branch
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git merge --abort 2>/dev/null; git rebase --abort 2>/dev/null; git cherry-pick --abort 2>/dev/null
|
|
35
|
+
git checkout -- . 2>/dev/null; git clean -fd
|
|
36
|
+
git fetch origin
|
|
37
|
+
git checkout --detach origin/$BRANCH
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Step 2: Run full verification
|
|
41
|
+
|
|
42
|
+
Run every command from `workflow.json` → `commands`. Record the result and error output for each.
|
|
43
|
+
|
|
44
|
+
Report each command result as one of: **PASS**, **FAIL**, or **N/A — not configured** (when the command is empty in `workflow.json`).
|
|
45
|
+
|
|
46
|
+
Example (adapt to project):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
<packageManager> install
|
|
50
|
+
<typecheck command>
|
|
51
|
+
<lint command>
|
|
52
|
+
<test command>
|
|
53
|
+
<build command> # if configured
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Step 3: Read project standards
|
|
57
|
+
|
|
58
|
+
Read from the worktree:
|
|
59
|
+
|
|
60
|
+
1. `AGENTS.md`
|
|
61
|
+
2. All files from `workflow.json` → `docsToRead`
|
|
62
|
+
3. Any additional docs passed by the orchestrator
|
|
63
|
+
|
|
64
|
+
### Step 4: Reply to your own prior inline comments (Round > 1 only)
|
|
65
|
+
|
|
66
|
+
Find your own reviews by body prefix match, then reply to each inline comment with resolution status. Use your own review ID only — this is race-safe.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Find your own review IDs
|
|
70
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
71
|
+
--jq '[.[] | select(.body | test("^\\*\\*\\[Round [0-9]+\\] YOUR_MODEL_ID:")) | .id]'
|
|
72
|
+
|
|
73
|
+
# For each review ID, fetch your inline comments
|
|
74
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews/$REVIEW_ID/comments \
|
|
75
|
+
--jq '[.[] | {id, path, line, body}]'
|
|
76
|
+
|
|
77
|
+
# Reply to each
|
|
78
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/comments/$COMMENT_ID/replies \
|
|
79
|
+
--method POST \
|
|
80
|
+
--field body="**[Round $ROUND] $MODEL_ID:** [ADDRESSED / PARTIALLY ADDRESSED / NOT ADDRESSED] — <one sentence>"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Do **not** reply to other reviewers' comments.
|
|
84
|
+
|
|
85
|
+
### Step 5: Read all other reviewers' comments critically (every round)
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews
|
|
89
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/comments
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Read critically:
|
|
93
|
+
|
|
94
|
+
- **Missed issues** — something other reviewers didn't catch
|
|
95
|
+
- **False positives** — incorrect or overly strict findings; call these out explicitly
|
|
96
|
+
- **False negatives** — issues others raised that you independently agree with
|
|
97
|
+
- Do **not** echo-chamber: never repeat another reviewer's finding unless independently verified in the diff
|
|
98
|
+
|
|
99
|
+
### Step 6: Review the code changes
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
git diff origin/<defaultBranch>..HEAD
|
|
103
|
+
git log origin/<defaultBranch>..HEAD --oneline
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Review areas** (all areas for core reviewers):
|
|
107
|
+
|
|
108
|
+
- **Logic** — correctness, edge cases, off-by-one errors
|
|
109
|
+
- **Types** — type safety, `any`, unsafe casts, `@ts-expect-error`
|
|
110
|
+
- **Architecture** — separation of concerns, layer boundaries, dependency direction
|
|
111
|
+
- **Error handling** — input validation, null safety, async error propagation, security
|
|
112
|
+
- **Tests** — adequate coverage, missing test cases, regression risk
|
|
113
|
+
- **Docs** — should AGENTS.md, TODO.md, or other docs be updated?
|
|
114
|
+
|
|
115
|
+
Also check project-specific concerns from `workflow.json` → `reviewFocus` (short emphasis labels like `"type safety"`, `"module boundaries"`) and look up the detailed rules in the `docsToRead` files.
|
|
116
|
+
|
|
117
|
+
### Step 7: Classify findings
|
|
118
|
+
|
|
119
|
+
| Class | Criteria |
|
|
120
|
+
|-------|----------|
|
|
121
|
+
| **Blocking** | Incorrect logic, data corruption risk, crash/regression, security vulnerability, spec violation |
|
|
122
|
+
| **Advisory** | Readability, naming, non-critical UX, optional tests, style improvements |
|
|
123
|
+
|
|
124
|
+
When uncertain, prefer **advisory**.
|
|
125
|
+
|
|
126
|
+
### Step 8: Post the review
|
|
127
|
+
|
|
128
|
+
#### Get head SHA
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
COMMIT_SHA=$(gh pr view $PR_NUMBER --json headRefOid --jq '.headRefOid')
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Post with JSON heredoc (preferred — most reliable)
|
|
135
|
+
|
|
136
|
+
**If you found issues**, post them as inline comments with verification results and findings:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
140
|
+
--method POST \
|
|
141
|
+
--header "Content-Type: application/json" \
|
|
142
|
+
--input - <<'EOF'
|
|
143
|
+
{
|
|
144
|
+
"commit_id": "ACTUAL_SHA",
|
|
145
|
+
"event": "COMMENT",
|
|
146
|
+
"body": "**[Round N] model-id:**\n\n### Verification\n| Command | Result |\n|---|---|\n| `<typecheck>` | PASS / FAIL / N/A — not configured |\n| `<lint>` | PASS / FAIL / N/A — not configured |\n| `<test>` | PASS / FAIL / N/A — not configured |\n| `<build>` | PASS / FAIL / N/A — not configured |\n\n### Findings\n1. [Blocking] ...\n2. [Advisory] ...",
|
|
147
|
+
"comments": [
|
|
148
|
+
{
|
|
149
|
+
"path": "src/path/to/file.ts",
|
|
150
|
+
"line": 42,
|
|
151
|
+
"side": "RIGHT",
|
|
152
|
+
"body": "**[Round N] model-id:**\n<inline comment>"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
EOF
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**If you found NO issues**, you **must still post a review** — post verification results + LGTM:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
163
|
+
--method POST \
|
|
164
|
+
--header "Content-Type: application/json" \
|
|
165
|
+
--input - <<'EOF'
|
|
166
|
+
{
|
|
167
|
+
"commit_id": "ACTUAL_SHA",
|
|
168
|
+
"event": "COMMENT",
|
|
169
|
+
"body": "**[Round N] model-id:**\n\n### Verification\n| Command | Result |\n|---|---|\n| `<typecheck>` | PASS / FAIL / N/A — not configured |\n| `<lint>` | PASS / FAIL / N/A — not configured |\n| `<test>` | PASS / FAIL / N/A — not configured |\n| `<build>` | PASS / FAIL / N/A — not configured |\n\nLGTM"
|
|
170
|
+
}
|
|
171
|
+
EOF
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Do **not** summarize what the PR does, describe the changes, or add preambles. The review body contains **only** verification results + findings or LGTM — nothing else.
|
|
175
|
+
|
|
176
|
+
#### Alternative: Post with --field flags
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
180
|
+
--method POST \
|
|
181
|
+
--field commit_id="$COMMIT_SHA" \
|
|
182
|
+
--field event="COMMENT" \
|
|
183
|
+
--field body="<review body>" \
|
|
184
|
+
--field "comments[][path]=src/path/to/file.ts" \
|
|
185
|
+
--field "comments[][line]=42" \
|
|
186
|
+
--field "comments[][side]=RIGHT" \
|
|
187
|
+
--field "comments[][body]=**[Round $ROUND] $MODEL_ID:** <comment text>"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Rules:**
|
|
191
|
+
|
|
192
|
+
- `event`: always `"COMMENT"` — never `"APPROVE"` or `"REQUEST_CHANGES"`
|
|
193
|
+
- `body` (review summary): **must never be empty** — write verification results + findings list or LGTM
|
|
194
|
+
- `line`: must be a line number present in the **diff hunk RIGHT side** — see validation step below
|
|
195
|
+
- `side`: `"RIGHT"` always
|
|
196
|
+
- Omit `comments` entirely when no inline comments
|
|
197
|
+
- Use `<<'EOF'` (single-quoted) so the shell does not expand `$` inside JSON
|
|
198
|
+
|
|
199
|
+
#### Validate line numbers before posting
|
|
200
|
+
|
|
201
|
+
For each inline comment, confirm the target line appears in the diff. Run `git diff origin/<defaultBranch>..HEAD` in your worktree and find the file's hunk. Only lines with a `+` prefix (added) or ` ` prefix (context) on the RIGHT side are valid targets. Lines with `-` prefix (removed) are LEFT-side only and will cause a posting error. If the line number is not in any hunk, the GitHub API will reject the comment — **do not guess line numbers from the full file**; use only lines visible in the diff output.
|
|
202
|
+
|
|
203
|
+
#### Verify posting succeeded
|
|
204
|
+
|
|
205
|
+
Check that the response contains `"id":`. If absent or errored, retry once using the `--field` form. Report success/failure — **do not silently discard findings**.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Conciseness Rules (Strictly Enforced)
|
|
210
|
+
|
|
211
|
+
- Each inline comment: **1–3 sentences max** — state the issue, cite the line, done
|
|
212
|
+
- Review summary: **verification results + findings list, or verification results + LGTM** — no PR description, no preambles, no conclusion paragraphs
|
|
213
|
+
- Do **not** summarize what the PR does — reviewers report issues, not describe changes
|
|
214
|
+
- No verbose spec quotes or summaries
|
|
215
|
+
- Duplicate-post guard: check if a review from you for the current round already exists before posting
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Output to Orchestrator
|
|
220
|
+
|
|
221
|
+
Return exactly:
|
|
222
|
+
|
|
223
|
+
1. **Verification results** — pass/fail for each command
|
|
224
|
+
2. **Posting status** — review ID if succeeded, or failure description
|
|
225
|
+
3. **Total issues:** `<count>`
|
|
226
|
+
4. **Blocking issues** — count + one-line description of each
|
|
227
|
+
5. **Advisory issues** — count + one-line description of each
|
|
228
|
+
6. **Cross-reviewer notes** — missed issues / false positives / false negatives from other reviewers
|
|
229
|
+
7. **(Round > 1)** Prior issue resolution — ADDRESSED / PARTIALLY ADDRESSED / NOT ADDRESSED for each
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Normal Reviewer Guide
|
|
2
|
+
|
|
3
|
+
Applies to all normal reviewer agents (e.g., `reviewer-1`, `reviewer-2`, etc.).
|
|
4
|
+
|
|
5
|
+
Normal reviewers perform diff-based code review via GitHub API. They do not have worktree access or run verification commands.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Critical Constraints
|
|
10
|
+
|
|
11
|
+
**Allowed bash commands only:**
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
gh api * gh pr view *
|
|
15
|
+
gh pr diff * gh pr checks *
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`gh pr review` and `gh repo view` are **not** allowed.
|
|
19
|
+
|
|
20
|
+
**Repository:** Use the repo name from `.opencode/workflow.json` → `project.repo`. Hardcode it in all API calls — never resolve dynamically.
|
|
21
|
+
|
|
22
|
+
**Substitute all placeholders:** `PR_NUMBER`, `ROUND`, `MODEL_ID`, `SHA` are templates. Replace with actual values before running any command.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Comment Format (Required)
|
|
27
|
+
|
|
28
|
+
Every comment — summary body, every inline comment, every reply — **must** start with:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
**[Round N] <your-model-id> focus on <area-1>, <area-2>:**
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Include your assigned focus areas in the prefix so readers know what lens you reviewed through.
|
|
35
|
+
|
|
36
|
+
Example: `**[Round 1] alibaba-coding-plan-cn/glm-5 focus on logic, tests:**`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Workflow
|
|
41
|
+
|
|
42
|
+
### Step 1: Read project standards
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
gh api repos/<REPO>/contents/AGENTS.md --jq '.content' | base64 -d
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Also read any files from `workflow.json` → `docsToRead` and any additional files passed by the orchestrator, using the same `gh api ... contents/<path>` pattern.
|
|
49
|
+
|
|
50
|
+
### Step 2: Read the PR
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
gh pr view $PR_NUMBER --json title,body,headRefName,headRefOid,files
|
|
54
|
+
gh pr diff $PR_NUMBER
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Step 3: Reply to your own prior inline comments (Round > 1 only)
|
|
58
|
+
|
|
59
|
+
Find your own reviews by body prefix match, then reply to each inline comment. Use your own review ID only — do **not** scan all PR comments.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Find your own review IDs
|
|
63
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
64
|
+
--jq '[.[] | select(.body | test("^\\*\\*\\[Round [0-9]+\\] YOUR_MODEL_ID:")) | .id]'
|
|
65
|
+
|
|
66
|
+
# For each review ID, fetch your inline comments
|
|
67
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews/$REVIEW_ID/comments \
|
|
68
|
+
--jq '[.[] | {id, path, line, body}]'
|
|
69
|
+
|
|
70
|
+
# Reply to each
|
|
71
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/comments/$COMMENT_ID/replies \
|
|
72
|
+
--method POST \
|
|
73
|
+
--field body="**[Round $ROUND] $MODEL_ID focus on $AREAS:** [ADDRESSED / PARTIALLY ADDRESSED / NOT ADDRESSED] — <one sentence>"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Do **not** reply to other reviewers' comments.
|
|
77
|
+
|
|
78
|
+
> In Round > 1, only check **your own prior comments** (identified by your model ID prefix). Do not audit other reviewers' findings — that is the core reviewers' responsibility.
|
|
79
|
+
|
|
80
|
+
### Step 4: Review the changes
|
|
81
|
+
|
|
82
|
+
The orchestrator assigns you **1–2 focus areas** from: logic, types, architecture, error handling, tests, docs. Focus your review on your assigned areas, but report any critical issues you notice outside them.
|
|
83
|
+
|
|
84
|
+
If the orchestrator provides a **`reviewFocus`** list (from `workflow.json`), use those as an additional lens. These are short emphasis labels (e.g., `"type safety"`, `"mongoose import patterns"`, `"module boundaries"`) that highlight what the project cares most about. Look up the detailed rules in `AGENTS.md` or `docsToRead` files. Apply them alongside your assigned areas, not instead of them.
|
|
85
|
+
|
|
86
|
+
General review checklist:
|
|
87
|
+
|
|
88
|
+
- **Correctness** — logic errors, edge cases, off-by-one
|
|
89
|
+
- **Type safety** — `any`, unsafe casts, missing types
|
|
90
|
+
- **Bugs** — null/undefined risks, async issues, error handling
|
|
91
|
+
- **Security** — input validation, injection, auth checks
|
|
92
|
+
- **Architecture** — boundary violations, dependency direction
|
|
93
|
+
- **Style** — naming, consistency with project conventions
|
|
94
|
+
|
|
95
|
+
### Step 5: Classify findings
|
|
96
|
+
|
|
97
|
+
| Class | Criteria |
|
|
98
|
+
|-------|----------|
|
|
99
|
+
| **Blocking** | Incorrect logic, data corruption risk, crash/regression, security vulnerability, spec violation |
|
|
100
|
+
| **Advisory** | Readability, naming, non-critical UX, optional tests, style improvements |
|
|
101
|
+
|
|
102
|
+
When uncertain, prefer **advisory**.
|
|
103
|
+
|
|
104
|
+
### Step 6: Post the review
|
|
105
|
+
|
|
106
|
+
#### Guard: no duplicate posts
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
If a review from you (matching your model ID + current round) already exists, skip posting and go to output.
|
|
113
|
+
|
|
114
|
+
#### Get head SHA
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
COMMIT_SHA=$(gh pr view $PR_NUMBER --json headRefOid --jq '.headRefOid')
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Post with JSON heredoc (preferred)
|
|
121
|
+
|
|
122
|
+
**If you found issues**, post them as inline comments with a brief summary body:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
126
|
+
--method POST \
|
|
127
|
+
--header "Content-Type: application/json" \
|
|
128
|
+
--input - <<'EOF'
|
|
129
|
+
{
|
|
130
|
+
"commit_id": "ACTUAL_SHA",
|
|
131
|
+
"event": "COMMENT",
|
|
132
|
+
"body": "**[Round N] model-id focus on area-1, area-2:**\n\n### Findings\n1. [Blocking] ...\n2. [Advisory] ...",
|
|
133
|
+
"comments": [
|
|
134
|
+
{
|
|
135
|
+
"path": "src/path/to/file.ts",
|
|
136
|
+
"line": 42,
|
|
137
|
+
"side": "RIGHT",
|
|
138
|
+
"body": "**[Round N] model-id focus on area-1, area-2:**\n<inline comment>"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
EOF
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**If you found NO issues**, you **must still post a review** — post LGTM with no inline comments:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
149
|
+
--method POST \
|
|
150
|
+
--header "Content-Type: application/json" \
|
|
151
|
+
--input - <<'EOF'
|
|
152
|
+
{
|
|
153
|
+
"commit_id": "ACTUAL_SHA",
|
|
154
|
+
"event": "COMMENT",
|
|
155
|
+
"body": "**[Round N] model-id focus on area-1, area-2:** LGTM"
|
|
156
|
+
}
|
|
157
|
+
EOF
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Do **not** summarize what the PR does, describe the changes, or add preambles. The review body contains **only** findings or LGTM — nothing else.
|
|
161
|
+
|
|
162
|
+
#### Alternative: Post with --field flags
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
gh api repos/<REPO>/pulls/$PR_NUMBER/reviews \
|
|
166
|
+
--method POST \
|
|
167
|
+
--field commit_id="$COMMIT_SHA" \
|
|
168
|
+
--field event="COMMENT" \
|
|
169
|
+
--field body="<review body>" \
|
|
170
|
+
--field "comments[][path]=src/path/to/file.ts" \
|
|
171
|
+
--field "comments[][line]=42" \
|
|
172
|
+
--field "comments[][side]=RIGHT" \
|
|
173
|
+
--field "comments[][body]=**[Round $ROUND] $MODEL_ID focus on $AREAS:** <comment text>"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Rules:**
|
|
177
|
+
|
|
178
|
+
- `event`: always `"COMMENT"` — never `"APPROVE"` or `"REQUEST_CHANGES"`
|
|
179
|
+
- `body` (review summary): **must never be empty** — write findings list or LGTM
|
|
180
|
+
- `line`: must be a line number present in the **diff hunk RIGHT side** — see validation step below
|
|
181
|
+
- `side`: `"RIGHT"` always
|
|
182
|
+
- Omit `comments` array entirely when no inline comments
|
|
183
|
+
- Use `<<'EOF'` (single-quoted) so the shell does not expand `$` inside JSON
|
|
184
|
+
|
|
185
|
+
#### Validate line numbers before posting
|
|
186
|
+
|
|
187
|
+
For each inline comment, confirm the target line appears in the diff. Run `gh pr diff $PR_NUMBER` and find the file's hunk. Only lines with a `+` prefix (added) or ` ` prefix (context) on the RIGHT side are valid targets. Lines with `-` prefix (removed) are LEFT-side only and will cause a posting error. If the line number is not in any hunk, the GitHub API will reject the comment — **do not guess line numbers from the full file**; use only lines visible in the diff output.
|
|
188
|
+
|
|
189
|
+
#### Verify posting succeeded
|
|
190
|
+
|
|
191
|
+
Check that the response contains `"id":`. If absent or errored, retry once using the `--field` form. Report success/failure — **do not silently discard findings**.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Conciseness Rules (Strictly Enforced)
|
|
196
|
+
|
|
197
|
+
- Each inline comment: **1–3 sentences max** — state the issue, cite the line, done
|
|
198
|
+
- Review summary: **findings list only, or LGTM** — no PR description, no preambles, no conclusion paragraphs
|
|
199
|
+
- Do **not** summarize what the PR does — reviewers report issues, not describe changes
|
|
200
|
+
- No verbose spec quotes or summaries
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Output to Orchestrator
|
|
205
|
+
|
|
206
|
+
Return exactly:
|
|
207
|
+
|
|
208
|
+
1. **Posting status** — review ID if succeeded, or failure description
|
|
209
|
+
2. **Total issues:** `<count>`
|
|
210
|
+
3. **Blocking issues** — count + one-line description of each
|
|
211
|
+
4. **Advisory issues** — count + one-line description of each
|
|
212
|
+
5. **(Round > 1)** Prior issue resolution — ADDRESSED / PARTIALLY ADDRESSED / NOT ADDRESSED for each
|