@nano-step/skill-manager 5.6.1 → 5.7.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.
Files changed (39) hide show
  1. package/dist/utils.d.ts +1 -1
  2. package/dist/utils.js +1 -1
  3. package/package.json +1 -1
  4. package/private-catalog.json +7 -2
  5. package/skills/deep-design/SKILL.md +402 -0
  6. package/skills/deep-design/evals/evals.json +23 -0
  7. package/skills/deep-design/skill.json +7 -0
  8. package/skills/feature-analysis/SKILL.md +290 -0
  9. package/skills/feature-analysis/skill.json +15 -0
  10. package/skills/nano-brain/skill.json +7 -0
  11. package/skills/pr-code-reviewer/CHANGELOG.md +329 -0
  12. package/skills/pr-code-reviewer/RESEARCH.md +60 -0
  13. package/skills/pr-code-reviewer/SKILL.md +537 -0
  14. package/skills/pr-code-reviewer/assets/config.json +60 -0
  15. package/skills/pr-code-reviewer/checklists/backend-express.md +357 -0
  16. package/skills/pr-code-reviewer/checklists/ci-cd.md +428 -0
  17. package/skills/pr-code-reviewer/checklists/consumer-search-matrix.md +339 -0
  18. package/skills/pr-code-reviewer/checklists/database.md +382 -0
  19. package/skills/pr-code-reviewer/checklists/frontend-vue-nuxt.md +426 -0
  20. package/skills/pr-code-reviewer/checklists/review-checklist.md +149 -0
  21. package/skills/pr-code-reviewer/references/checkpoint-system.md +58 -0
  22. package/skills/pr-code-reviewer/references/confidence-scoring.md +98 -0
  23. package/skills/pr-code-reviewer/references/framework-rules/express.md +39 -0
  24. package/skills/pr-code-reviewer/references/framework-rules/nestjs.md +41 -0
  25. package/skills/pr-code-reviewer/references/framework-rules/nextjs.md +58 -0
  26. package/skills/pr-code-reviewer/references/framework-rules/prisma.md +54 -0
  27. package/skills/pr-code-reviewer/references/framework-rules/react.md +61 -0
  28. package/skills/pr-code-reviewer/references/framework-rules/typeorm.md +52 -0
  29. package/skills/pr-code-reviewer/references/framework-rules/typescript.md +50 -0
  30. package/skills/pr-code-reviewer/references/framework-rules/vue-nuxt.md +53 -0
  31. package/skills/pr-code-reviewer/references/nano-brain-integration.md +46 -0
  32. package/skills/pr-code-reviewer/references/performance-patterns.md +26 -0
  33. package/skills/pr-code-reviewer/references/quality-patterns.md +25 -0
  34. package/skills/pr-code-reviewer/references/report-template.md +172 -0
  35. package/skills/pr-code-reviewer/references/security-patterns.md +31 -0
  36. package/skills/pr-code-reviewer/references/setup-wizard.md +207 -0
  37. package/skills/pr-code-reviewer/references/subagent-prompts.md +344 -0
  38. package/skills/pr-code-reviewer/references/verification-protocol.md +56 -0
  39. package/skills/pr-code-reviewer/skill.json +15 -0
@@ -0,0 +1,60 @@
1
+ # PR Code Reviewer - Research & Design Decisions
2
+
3
+ ## Why This Architecture?
4
+
5
+ | Decision | Research Source | Rationale |
6
+ |----------|-----------------|-----------|
7
+ | Orchestrator < 3000 tokens | AI tool comparison | Most tools bloat context with full file reads |
8
+ | Path-based categorization | Google CODEOWNERS | Proven at scale, no code parsing needed |
9
+ | Parallel subagents | Meta's review speed research | P75 review time correlates with satisfaction |
10
+ | Devil's Advocate verification | Senior reviewer practices | Reduces false positives significantly |
11
+ | Cross-repo awareness | Microservices research | Breaking changes are #1 cause of outages |
12
+ | Historical context check | Google Critique | "Why was this written?" prevents bad flags |
13
+
14
+ ## What We Learned from PR #3108 and PR #3088
15
+
16
+ The `rootState.currency` bug taught us:
17
+
18
+ 1. **State migrations are invisible**: Pinia stores don't appear in Vuex's rootState
19
+ 2. **Reverts compound problems**: Double-revert brought back broken state
20
+ 3. **AI misses cross-store dependencies**: Need explicit migration checklist
21
+ 4. **Pattern matching isn't enough**: Must trace actual execution paths
22
+
23
+ ### PR #3088 Post-Mortem (v5.1 trigger)
24
+
25
+ The v5.0 skill had the RIGHT instructions but WRONG enforcement:
26
+ - Instructions said "search for rootState.{storeName}"
27
+ - But subagent only reviewed PR files, not entire codebase
28
+ - `store/inventory.js` (NOT in PR) still used `rootState.currency`
29
+ - Bug was missed because consumer search was ADVISORY, not MANDATORY
30
+
31
+ **Root Cause**: Subagents only read assigned files. Consumer search requires searching ENTIRE codebase.
32
+
33
+ **Fix (v5.1)**:
34
+ - Phase 1.5: Detect breaking change signals from file paths
35
+ - Mandatory consumer search with EXACT grep commands
36
+ - Required output format for verification
37
+ - Orchestrator verification that search was performed
38
+
39
+ ## Comparison: Our Approach vs Industry
40
+
41
+ | Aspect | Google | Meta | AI Tools | Our v5.1 |
42
+ |--------|--------|------|----------|----------|
43
+ | Token efficiency | N/A | N/A | Poor | ✅ Excellent |
44
+ | Cross-repo | Glean indexing | Monorepo | Limited | ✅ Manual check |
45
+ | Speed | Hours | Minutes | Seconds | Minutes |
46
+ | False positives | Low | Low | High | Medium (Devil's Advocate) |
47
+ | Context awareness | Deep | Deep | Shallow | Medium (repo rules) |
48
+ | Breaking changes | Manual | Automated | Limited | ✅ Mandatory search |
49
+
50
+ ## Future Enhancements (v6.0 Candidates)
51
+
52
+ 1. **Automated contract testing**: Integrate Pact-style consumer checks
53
+ 2. **Review metrics**: Track time-to-review, false positive rate
54
+ 3. **Stacked diff support**: Review incremental changes like Meta
55
+ 4. **Git blame integration**: Automatic historical context lookup
56
+ 5. **Cross-repo dependency graph**: Visualize service dependencies
57
+
58
+ ## Full Research
59
+
60
+ See `.opencode/research/code-review-research-synthesis.md` for complete analysis.
@@ -0,0 +1,537 @@
1
+ ---
2
+ name: pr-code-reviewer
3
+ description: "Review pull requests and staged changes for bugs, security issues, and code quality. Use this skill whenever the user mentions: review PR, code review, check this PR, review my changes, /review, PR #123, look at this diff, is this safe to merge, or provides a GitHub PR URL. Also triggers on: 'what do you think of these changes', 'review --staged', 'check my code before merge'."
4
+ compatibility: "OpenCode with nano-brain"
5
+ metadata:
6
+ author: Sisyphus
7
+ version: "3.3.0"
8
+ severity-levels: ["critical", "warning", "improvement", "suggestion"]
9
+ ---
10
+
11
+ # PR Code Reviewer
12
+
13
+ **Version**: 3.3.0 | **Architecture**: 4 Parallel Subagents + Verification Pipeline + Confidence Scoring | **Memory**: nano-brain
14
+
15
+ ## Overview
16
+
17
+ Comprehensive PR reviewer: gathers full context, applies smart tracing by change type, runs four specialized subagents in parallel, iteratively refines findings, and produces a **short, actionable report** — only what matters. Also suggests code improvements when opportunities exist.
18
+
19
+ ### Why Every Phase Runs
20
+
21
+ Each phase catches a different class of issue. A 1-line deletion can hide a critical logic bug that only cross-repo tracing (Phase 2) would reveal. A "trivial" style change can mask a hidden logic change that only subagent consensus (Phase 3-4) would catch. The only exception: Phase 0 (clone) is skipped for `--staged` local reviews.
22
+
23
+ ## Report Philosophy
24
+
25
+ **People don't read long reports.** Every section must earn its place.
26
+
27
+ - **Critical + Warning = expanded** — full detail with file, line, impact, fix
28
+ - **Improvements = brief** — one-liner with code suggestion, only when there's a clear win
29
+ - **Suggestions = count only** — mentioned as a number, details in collapsible section or skipped
30
+ - **Praise = one line max** — or skip entirely if nothing stands out
31
+ - **No filler sections** — omit Traced Dependencies, Memory Context, Test Coverage unless they contain actionable findings
32
+ - **TL;DR at the top** — verdict + issue counts in 3 lines, reader decides whether to scroll
33
+
34
+ **Filtering rule**: If a finding wouldn't make a senior engineer stop and think, drop it.
35
+
36
+ ## Token Efficiency — Read Files On-Demand
37
+
38
+ **Do NOT load all reference files upfront.** Read each file only when the relevant phase runs:
39
+
40
+ | Phase | Read at start of phase |
41
+ |-------|------------------------|
42
+ | Phase -2 | `references/setup-wizard.md` (only if no config) |
43
+ | Phase 1 | `{workspace_root}/AGENTS.md` + `.agents/_repos/{repo}.md` + `.agents/_domains/{domain}.md` |
44
+ | Phase 1 | `references/nano-brain-integration.md` |
45
+ | Phase 2 | Domain checklist for changed file types (one file only) |
46
+ | Phase 3 | `references/subagent-prompts.md` + stack framework rules (from config) |
47
+ | Phase 4 | `references/confidence-scoring.md` |
48
+ | Phase 4.5 | `references/verification-protocol.md` |
49
+ | Phase 5 | `references/report-template.md` |
50
+ | Phase 5.5 | `references/nano-brain-integration.md` (save section only) |
51
+
52
+ Framework rules: load ONLY the files matching `stack` in `.opencode/code-reviewer.json`. Never load all framework rules.
53
+
54
+ ---
55
+
56
+ ## Prerequisites
57
+
58
+ ### GitHub MCP Server (Required for PR Reviews)
59
+
60
+ ```bash
61
+ npx create-code-reviewer # Auto-detects git remote, configures everything
62
+ ```
63
+
64
+ **Manual setup**: Add GitHub MCP to `opencode.json` — see [GitHub MCP Server](https://github.com/github/github-mcp-server). Needs `repo` scope token from https://github.com/settings/tokens.
65
+
66
+ **After setup**: Restart OpenCode. Verify with `/review PR#1`.
67
+
68
+ ### Available GitHub MCP Tools
69
+
70
+ | Tool | Purpose |
71
+ |------|---------|
72
+ | `get_pull_request` | PR metadata (title, author, base) |
73
+ | `get_pull_request_files` | Changed files with diff |
74
+ | `get_pull_request_reviews` | Existing reviews |
75
+ | `get_pull_request_status` | CI/check status |
76
+ | `get_file_contents` | File content at ref |
77
+
78
+ ### Local Reviews (No MCP Required)
79
+
80
+ For `--staged` or local reviews, uses git commands directly (`git diff --staged`, `git diff`, `git log`).
81
+
82
+ ### nano-brain (Recommended)
83
+
84
+ Persistent memory for historical context — past reviews, architectural decisions, known issues.
85
+
86
+ **Full tool reference + query patterns**: [nano-brain-integration.md](references/nano-brain-integration.md)
87
+
88
+ ### Linear MCP (Optional — Enriches Review Context)
89
+
90
+ When a Linear ticket is linked to the PR (via branch name or PR description), the reviewer fetches ticket context automatically.
91
+
92
+ **Available Linear MCP Tools:**
93
+
94
+ | Tool | Purpose |
95
+ |------|---------|
96
+ | `linear_get_issue` | Ticket title, description, acceptance criteria, status, priority, labels |
97
+ | `linear_list_comments` | Discussion thread on the ticket |
98
+ | `linear_get_attachment` | Attached specs, screenshots, designs |
99
+ | `linear_extract_images` | Extract images embedded in ticket description/comments |
100
+
101
+ **Ticket ID extraction** (checked in order):
102
+ 1. PR branch name pattern: `feature/DEV-1234-...` or `fix/DEV-1234-...` → extracts `DEV-1234`
103
+ 2. PR description: looks for `Linear: DEV-1234`, `Ticket: DEV-1234`, or Linear URL `linear.app/.../DEV-1234`
104
+ 3. PR title: looks for `[DEV-1234]` or `DEV-1234:` prefix
105
+
106
+ If no ticket ID found → skip Linear context silently (no error, no warning).
107
+
108
+ ## Configuration
109
+
110
+ Check for config at `.opencode/code-reviewer.json`. **Full example**: [config.json](assets/config.json)
111
+
112
+ ## Checkpoint System
113
+
114
+ Reviews are resumable via checkpoints saved at each phase. If the agent crashes mid-review, resume from the last completed phase.
115
+
116
+ **Full details**: [checkpoint-system.md](references/checkpoint-system.md) — manifest schema, checkpoint files, Phase 3 special handling.
117
+
118
+ ## Workflow
119
+
120
+ **Full checklist**: [review-checklist.md](checklists/review-checklist.md) — use this to track every step.
121
+
122
+ ### Phase -2: Setup Check (First Run Detection)
123
+
124
+ Before anything else, check if `.opencode/code-reviewer.json` exists.
125
+
126
+ **If it exists**: read `stack` field → load only the matching framework rule files (listed in setup-wizard.md mapping table). Continue to Phase -1.
127
+
128
+ **If it doesn't exist** (or user ran `/review --setup`):
129
+ 1. Read `references/setup-wizard.md` for the full wizard flow
130
+ 2. Ask the 5 setup questions interactively
131
+ 3. Write `.opencode/code-reviewer.json` with `stack` field filled in
132
+ 4. Show confirmation with which framework rule files will be used
133
+ 5. If called as `/review --setup` (not a real review), stop here. Otherwise continue.
134
+
135
+ **Stack → framework rules mapping** (also in setup-wizard.md):
136
+ - `frontend: nuxt/vue` → `framework-rules/vue-nuxt.md`
137
+ - `frontend: nextjs` → `framework-rules/nextjs.md`
138
+ - `frontend: react` → `framework-rules/react.md`
139
+ - `backend: express` → `framework-rules/express.md`
140
+ - `backend: nestjs` → `framework-rules/nestjs.md`
141
+ - `orm: typeorm` → `framework-rules/typeorm.md`
142
+ - `orm: prisma` → `framework-rules/prisma.md`
143
+ - `language: typescript*` → `framework-rules/typescript.md`
144
+
145
+ Store the resolved `$FRAMEWORK_RULES` content (concatenated) for Phase 3. If multiple match, concatenate them.
146
+
147
+ ### Phase -1: Resume Detection (Check Before Starting)
148
+
149
+ Before starting a new review, check for existing checkpoints to resume interrupted reviews.
150
+
151
+ **Steps:**
152
+
153
+ 1. **Look for existing checkpoint**:
154
+ ```bash
155
+ find /tmp -maxdepth 1 -type d -name "pr-review-${repo}-${pr_number}-*" 2>/dev/null
156
+ ```
157
+ For local reviews: check for `.checkpoints/manifest.json` in current directory.
158
+
159
+ 2. **If checkpoint found**, read `manifest.json`:
160
+ ```bash
161
+ cat "$REVIEW_DIR/.checkpoints/manifest.json"
162
+ ```
163
+
164
+ 3. **Validate checkpoint is still valid**:
165
+ - Check `pr.number` matches current PR
166
+ - For PR reviews: verify `head_sha` in manifest matches current PR head SHA (PR not updated since checkpoint)
167
+ - If SHA mismatch → checkpoint is stale, delete old directory and start fresh
168
+
169
+ 4. **Ask user to resume**:
170
+ ```
171
+ 📂 Found checkpoint from previous review:
172
+ Phase: {completed_phase} → {next_phase}
173
+ Started: {started_at}
174
+ Last updated: {last_updated}
175
+
176
+ Resume from phase {next_phase}? (y/n)
177
+ ```
178
+
179
+ 5. **If user says yes**:
180
+ - Load `manifest.json`
181
+ - Load all completed phase files (phase-0-clone.json, phase-1-context.json, etc.)
182
+ - Jump to `next_phase` in the workflow
183
+ - For Phase 3: check `subagent_status` and only run incomplete subagents
184
+
185
+ 6. **If user says no or checkpoint invalid**:
186
+ - Delete old checkpoint directory: `rm -rf "$REVIEW_DIR"`
187
+ - Start fresh from Phase 0
188
+
189
+ **For Local Reviews:** Checkpoint directory is `.checkpoints/` in current working directory. No SHA validation needed (working directory changes are expected).
190
+
191
+ ### Phase 0: Repository Preparation (PR Reviews Only)
192
+
193
+ **Why**: Your local repo may be on any branch, have uncommitted changes, or not exist at all. Cloning to a temp folder ensures:
194
+ - You always read the **actual PR branch code**, not whatever is checked out locally
195
+ - You can review **multiple PRs simultaneously** without branch conflicts
196
+ - Your working directory is **never disturbed**
197
+
198
+ **Steps:**
199
+
200
+ 1. **Extract repo info** from PR URL or `gh pr view`:
201
+ - `owner/repo` (e.g., `zengamingx/tradeit-backend`)
202
+ - `pr_number` (e.g., `1159`)
203
+ - `head_branch` (e.g., `feature/dev-4650-callback-url-for-payment-method`)
204
+
205
+ 2. **Create unique temp directory**:
206
+ ```bash
207
+ REVIEW_DIR="/tmp/pr-review-${repo}-${pr_number}-$(date +%s)"
208
+ mkdir -p "$REVIEW_DIR"
209
+ ```
210
+ Format: `/tmp/pr-review-{repo}-{pr_number}-{unix_timestamp}`
211
+
212
+ 3. **Clone the repo** (minimal shallow clone — only latest commit):
213
+ ```bash
214
+ git clone --depth=1 --branch="${head_branch}" \
215
+ "https://github.com/${owner}/${repo}.git" "$REVIEW_DIR"
216
+ ```
217
+ If the branch doesn't exist on remote (force-pushed/deleted), fall back to:
218
+ ```bash
219
+ git clone --depth=1 "https://github.com/${owner}/${repo}.git" "$REVIEW_DIR"
220
+ cd "$REVIEW_DIR" && gh pr checkout ${pr_number}
221
+ ```
222
+
223
+ 4. **Verify clone succeeded**:
224
+ ```bash
225
+ cd "$REVIEW_DIR" && git log --oneline -1
226
+ ```
227
+ If this fails → STOP review, report error to user.
228
+
229
+ 5. **Record the temp path** — ALL subsequent phases use `$REVIEW_DIR` for file reads, grep, LSP, etc.
230
+
231
+ 6. **Print confirmation**:
232
+ ```
233
+ 📂 Cloned to: /tmp/pr-review-tradeit-backend-1159-1741502400
234
+ 🌿 Branch: feature/dev-4650-callback-url-for-payment-method
235
+ 📝 Ready for review
236
+ ```
237
+
238
+ **For Local Reviews (`--staged`):** Skip Phase 0 — use current working directory.
239
+
240
+ Store `$REVIEW_DIR` path — every file read, grep, and subagent prompt references this path, not the original workspace repo.
241
+
242
+ **Checkpoint:** Save clone metadata to `.checkpoints/phase-0-clone.json` (clone_dir, branches, head_sha, files_changed) and create `manifest.json` with `completed_phase: 0`, `next_phase: 1`, `phase_status: {"0": "complete", ...}`.
243
+
244
+ ### Phase 1: Context Gathering
245
+
246
+ **Step 0 — Load agent knowledge base (MANDATORY if configured):**
247
+
248
+ Read `agents` config from `.opencode/code-reviewer.json`. If `has_agents_md: true`:
249
+
250
+ 1. **Read `{workspace_root}/AGENTS.md`** — keyword→domain→repo mapping table. Use this to identify which domain the PR's repo belongs to.
251
+
252
+ 2. **Read `{workspace_root}/.agents/_repos/{repo-name}.md`** (if `has_repos_dir: true`) — repo-specific context: framework, port, key files, known issues, cross-repo relationships. `repo-name` comes from the PR's `owner/repo` (e.g., PR from `tradeit-backend` → read `.agents/_repos/tradeit-backend.md`).
253
+
254
+ 3. **Read `{workspace_root}/.agents/_domains/{domain}.md`** (if `has_domains_dir: true`) — domain context for the repo's domain. Domain identified from AGENTS.md mapping (e.g., `tradeit-backend` → `trading-core` domain → read `.agents/_domains/trading-core.md`).
255
+
256
+ 4. **For cross-repo tracing (Phase 2)**: if the PR touches API contracts or shared data, also read:
257
+ - `.agents/_indexes/by-database.md` — which repo owns which DB table
258
+ - `.agents/_indexes/by-data-source.md` — which repo consumes which external API
259
+
260
+ Do NOT read all repo/domain files — only the ones relevant to the PR being reviewed. Store combined result as `$AGENTS_CONTEXT`.
261
+
262
+ If `agents` config is missing or files not found: continue without it, no error.
263
+
264
+ **For PR Reviews (GitHub MCP):**
265
+ 1. `get_pull_request` → title, description, author, base branch
266
+ 2. `get_pull_request_files` → changed files with diff stats
267
+ 3. Read full file context from `$REVIEW_DIR` (NOT from GitHub API — local reads are faster and give full file)
268
+
269
+ **For Local Reviews (git):**
270
+ 1. `git diff --staged` or `git diff` → changed files
271
+ 2. `git log --oneline -5` → recent commit context
272
+
273
+ **Then for all reviews:**
274
+ 3. Classify each file's change type:
275
+ - **LOGIC**: Conditionals, business rules, state → DEEP TRACE
276
+ - **DELETION**: Removing existing behavior/features → DEEP TRACE + PREMISE CHECK (see Phase 2)
277
+ - **STYLE**: Formatting, naming, comments → SHALLOW TRACE
278
+ - **REFACTOR**: Structure changes, no logic change → MEDIUM TRACE
279
+ - **NEW**: New files → FULL REVIEW
280
+
281
+ **DELETION classification**: Any PR that removes user-facing behavior, error messages, validation logic, UI elements, or API responses is classified as DELETION, not STYLE or REFACTOR. Deletions feel safe but can hide regressions — they require the same depth as LOGIC changes plus a Premise Check.
282
+ 4. Gather full context per changed file from `$REVIEW_DIR`: callers/callees, tests, types, usage sites
283
+ 5. **Query nano-brain** for project memory on each changed module — [query patterns](references/nano-brain-integration.md#phase-1-memory-queries)
284
+ 6. **Fetch Linear ticket context** (if ticket ID found) — see Phase 1.5
285
+
286
+ **Checkpoint:** Save results to `.checkpoints/phase-1-context.json` (PR metadata, file classifications, nano-brain context) and update `manifest.json` (`completed_phase: 1`, `next_phase: 1.5`).
287
+
288
+ ### Phase 1.5: Linear Ticket Context (Optional)
289
+
290
+ If a Linear ticket ID was extracted from the branch name, PR description, or PR title:
291
+
292
+ 1. **Fetch ticket**: `linear_get_issue(id)` → title, description (contains acceptance criteria), status, priority, labels, assignee
293
+ 2. **Fetch comments**: `linear_list_comments(issueId)` → discussion thread, clarifications, edge cases mentioned
294
+ 3. **Extract acceptance criteria** from ticket description — look for:
295
+ - Sections titled "Acceptance Criteria", "AC", "Requirements", "Definition of Done"
296
+ - Checkbox lists (`- [ ]` items)
297
+ - Numbered requirements
298
+ 4. **Extract images** if ticket description contains embedded images: `linear_extract_images(description)`
299
+
300
+ **What to do with ticket context:**
301
+ - Pass to ALL subagents as `## LINEAR TICKET CONTEXT` section
302
+ - Use acceptance criteria to verify PR completeness in Phase 4
303
+ - Flag in report if PR appears to miss acceptance criteria items
304
+ - Include ticket title + status in report header
305
+
306
+ **Ambiguity Detection:**
307
+ If acceptance criteria are vague or open to multiple interpretations (e.g., "fix it", "make it correct", "improve this", "need to fix to make it correct"):
308
+ 1. Flag it as a **warning** in the report: *"Acceptance criteria are ambiguous — PR may not match intended fix."*
309
+ 2. Identify the multiple interpretations (e.g., "remove the feature" vs "fix the condition")
310
+ 3. Evaluate which interpretation the PR implements
311
+ 4. Note in the report whether the PR's interpretation seems correct or if clarification is needed
312
+
313
+ **If Linear is unavailable or ticket not found:** Continue review without ticket context. Do NOT fail the review.
314
+
315
+ **Checkpoint:** Save results to `.checkpoints/phase-1.5-linear.json` (ticket details, acceptance criteria, comments, images) and update `manifest.json` (`completed_phase: 1.5`, `next_phase: 2`).
316
+
317
+ ### Phase 2: Smart Tracing (Based on Change Type)
318
+
319
+ **LOGIC changes:**
320
+ 1. Find ALL callers (LSP find_references) and callees
321
+ 2. Find ALL tests covering this code path
322
+ 3. Find ALL types/interfaces affected
323
+ 4. Trace data flow: input source → output destination
324
+ 5. Query nano-brain for known issues — [query patterns](references/nano-brain-integration.md#phase-2-memory-queries-logic-changes)
325
+
326
+ **DELETION changes (all LOGIC steps above, PLUS):**
327
+ 6. **Premise Check** — answer these questions before proceeding:
328
+ - Why was this code added originally? What problem did it solve?
329
+ - Is the underlying problem solved by this PR, or is a symptom being hidden?
330
+ - Would fixing the logic be more correct than removing it?
331
+ - Does removing this break any user-facing behavior that was intentional?
332
+ - Are there related components (backend config, i18n keys, API responses) that depend on this code existing?
333
+ 7. Document the Premise Check answers — they feed into the report (Phase 5)
334
+
335
+ **Cross-Repo API Tracing** (for multi-repo workspaces):
336
+ For any changed code that **consumes data from an API** (fetches, reads responses, uses values from backend):
337
+ 1. Identify the API endpoint being called (e.g., `/api/v2/inventory/my/data`)
338
+ 2. Find the backend repo that serves this endpoint (use workspace AGENTS.md domain mappings)
339
+ 3. Read the backend handler to understand:
340
+ - What the API actually returns and under what conditions
341
+ - Any config values that affect the response (e.g., cache TTLs, feature flags)
342
+ - Whether the frontend's assumptions about the data match the backend's behavior
343
+ 4. For any **hardcoded values** in the frontend that correspond to backend config (e.g., hardcoded `6 * 60 * 1000` vs backend's `steamCInvCacheTTLMinutes`), flag as a **warning**: values are out of sync.
344
+
345
+ **This applies even for deletions.** If the deleted code consumed API data, trace into the backend to understand whether the deletion is correct or whether the code should be fixed instead.
346
+
347
+ **STYLE changes:** Check convention consistency, verify no hidden logic changes.
348
+
349
+ **REFACTOR changes:** Verify behavior preservation, check all usages still work.
350
+
351
+ **Domain-Specific Checklists**: Based on the file types in the PR, read the relevant checklist for domain-specific review criteria:
352
+ - Vue/Nuxt frontend files → [frontend-vue-nuxt.md](checklists/frontend-vue-nuxt.md)
353
+ - Express/Node backend → [backend-express.md](checklists/backend-express.md)
354
+ - Database migrations/queries → [database.md](checklists/database.md)
355
+ - CI/CD configs → [ci-cd.md](checklists/ci-cd.md)
356
+ - Consumer search patterns → [consumer-search-matrix.md](checklists/consumer-search-matrix.md)
357
+
358
+ **Checkpoint:** Save results to `.checkpoints/phase-2-tracing.json` (tracing results per file, callers/callees, test coverage, data flow, premise check answers, cross-repo tracing) and update `manifest.json` (`completed_phase: 2`, `next_phase: 2.5`).
359
+
360
+ ### Phase 2.5: PR Summary Generation (REQUIRED)
361
+
362
+ Before launching subagents, generate a GitHub Copilot-style PR summary. Reviewers need this context.
363
+
364
+ 1. **What This PR Does** (1-3 sentences): Start with action verb, mention feature/bug, include business impact
365
+ 2. **Key Changes** by category: Feature, Bugfix, Refactor, Performance, Security, Docs, Tests, Config, Dependencies
366
+ 3. **File-by-File Summary**: What changed, why it matters, key modifications with line numbers
367
+ 4. **Ticket Reference**: If Linear ticket found, include ticket ID, title, and status
368
+
369
+ **Full guidelines + pseudocode**: [report-template.md](references/report-template.md#pr-summary-generation-guidelines)
370
+
371
+ **Checkpoint:** Save results to `.checkpoints/phase-2.5-summary.json` (PR summary text, key changes, file summaries) and update `manifest.json` (`completed_phase: 2.5`, `next_phase: 3`).
372
+
373
+ ### Phase 3: Parallel Subagent Execution
374
+
375
+ Launch all 4 subagents simultaneously with `run_in_background: true`. Each agent catches issues the others miss — the quality agent finds duplication the security agent ignores, the librarian catches framework anti-patterns the integration agent overlooks. Include PR Summary, nano-brain memory, Premise Check results (if DELETION), cross-repo tracing results, `$REVIEW_DIR` path, and `$FRAMEWORK_RULES` (from Phase -2) in each prompt.
376
+
377
+ Read `references/subagent-prompts.md` now for the full prompt templates.
378
+
379
+ | # | Agent | Type | Focus |
380
+ |---|-------|------|-------|
381
+ | 1 | Code Quality | `explore` | Style, naming, error handling, type safety, duplication, complexity, **code improvements** |
382
+ | 2 | Security & Logic | `oracle` | OWASP Top 10, logic correctness, edge cases, race conditions, auth, **logic improvements**, **cross-repo data flow**, **deletion premise validation** |
383
+ | 3 | Docs & Best Practices | `librarian` | API docs, framework best practices, anti-patterns, **idiomatic improvements** |
384
+ | 4 | Tests & Integration | `general` | Test coverage, edge cases, contract integrity, performance, **perf improvements** |
385
+
386
+ **Full prompt templates**: [subagent-prompts.md](references/subagent-prompts.md)
387
+
388
+ Each subagent returns JSON: `{findings: [{file, line, severity, category, message, suggestion, code_suggestion?, evidence, confidence, trace_path?}]}`
389
+
390
+ Severity values: `critical` (blocks merge), `warning` (should fix), `improvement` (code can be better), `suggestion` (nice-to-have)
391
+
392
+ New fields (v3.1): `evidence` (REQUIRED for critical/warning — concrete proof with file:line references), `confidence` (high/medium/low), `trace_path` (optional array of file:line strings showing verification trace)
393
+
394
+ **Checkpoint:** After **EACH** subagent completes, update `.checkpoints/phase-3-subagents.json` with that subagent's findings and update `manifest.json` subagent_status to `"complete"` for that subagent. After ALL subagents complete, update `manifest.json` (`completed_phase: 3`, `next_phase: 4`). On resume, only run subagents with status != `"complete"`.
395
+
396
+ ### Phase 4: Iterative Refinement & Filtering
397
+
398
+ 1. **Merge & Deduplicate**: Combine all subagent findings, remove duplicates (same issue from multiple agents)
399
+ 2. **Consensus Scoring** (NEW — reduces false positives):
400
+ - For each deduplicated finding, count how many subagents independently flagged it (match by file + line + category)
401
+ - `consensus_count >= 2` → boost confidence to `high` (multiple agents agree)
402
+ - `consensus_count == 1` + non-empty `evidence` with file:line references → keep original severity and confidence
403
+ - `consensus_count == 1` + empty/missing `evidence` + severity `critical` or `warning` → **AUTO-DOWNGRADE to `suggestion`**
404
+ 3. **Severity Filter** (keeps reports short):
405
+ - `critical` + `warning` → **KEEP with full detail**
406
+ - `improvement` → **KEEP as one-liner** with optional code suggestion
407
+ - `suggestion` → **COUNT only** — report total number, omit individual details unless < 3 total
408
+ - Drop anything a linter/formatter would catch (let tools handle those)
409
+ - Drop style nits that don't affect readability or correctness
410
+ 4. **Gap Analysis**: Did any subagent fail? Untested code paths? Unreviewed files?
411
+ 5. **Second Pass** (if gaps found): Targeted follow-up on identified gaps only
412
+
413
+ **Checkpoint:** Save results to `.checkpoints/phase-4-refined.json` (deduplicated findings with consensus scores, filtered by severity, gap analysis results) and update `manifest.json` (`completed_phase: 4`, `next_phase: 4.5`).
414
+
415
+ ### Phase 4.5: Orchestrator Verification Spot-Check (Critical + Warning Only)
416
+
417
+ Verify each critical/warning finding by reading the actual code at cited evidence locations. This catches false positives that survived subagent self-verification.
418
+
419
+ If no critical/warning findings exist after Phase 4, skip to Phase 4.6.
420
+
421
+ **Full protocol**: [verification-protocol.md](references/verification-protocol.md) — category-specific verification rules, timeout policy, checkpoint schema.
422
+
423
+ **Checkpoint:** Save to `.checkpoints/phase-4.5-verification.json`. Update manifest (`completed_phase: 4.5`, `next_phase: 4.6`).
424
+
425
+ ### Phase 4.6: Result Confidence Assessment
426
+
427
+ Score how confident we are in the review's findings — are they correct and complete? Computed from accuracy rate (40%), consensus rate (30%), and evidence rate (30%).
428
+
429
+ | Score | Label | Gate Action |
430
+ |-------|-------|-------------|
431
+ | 80–100 | 🟢 High | Proceed normally |
432
+ | 60–79 | 🟡 Medium | Add warning: "Some findings may be inaccurate" |
433
+ | < 60 | 🔴 Low | Add warning: "Low confidence — manual review recommended" |
434
+
435
+ **Full scoring details**: [confidence-scoring.md](references/confidence-scoring.md) — formula, per-finding confidence levels, special cases, checkpoint schema.
436
+
437
+ **Checkpoint:** Save to `.checkpoints/phase-4.6-confidence.json`. Update manifest (`completed_phase: 4.6`, `next_phase: 5`).
438
+
439
+ ### Phase 5: Report Generation
440
+ Save to `.opencode/reviews/{type}_{identifier}_{date}.md`. Create directory if needed.
441
+
442
+ **Report structure** (compact — omit empty sections):
443
+ 1. **TL;DR** — verdict (APPROVE/REQUEST CHANGES/COMMENT) + issue counts + Result Confidence score from Phase 4.6
444
+ 2. **PR Overview** — what this PR does (1-3 sentences) + key changes by category
445
+ 3. **Ticket Alignment** — acceptance criteria coverage check (only if Linear ticket found). Flag ambiguous criteria.
446
+ 4. **Premise Check** — only for DELETION changes: why the code existed, whether removal is correct vs fixing the logic, cross-repo implications
447
+ 5. **Critical Issues** — full detail: file, line, issue, impact, fix
448
+ 6. **Warnings** — full detail: file, line, issue, fix
449
+ 7. **Code Improvements** — one-liner each with optional code suggestion
450
+ 8. **Suggestions** — count + brief list (or omit if none)
451
+ 9. **File Summary** — table only (file, change type, one-line summary)
452
+
453
+ **Omit unless actionable**: Traced Dependencies, Memory Context, Test Coverage, Praise, Change Classification. Include only if they contain findings the developer must act on.
454
+
455
+ **Full template**: [report-template.md](references/report-template.md)
456
+
457
+ **Checkpoint:** Save final report to `.checkpoints/phase-5-report.md` (copy of the report saved to `.opencode/reviews/`) and update `manifest.json` (`completed_phase: 5`, `next_phase: 5.5`).
458
+
459
+ ### Phase 5.5: Save Review to nano-brain
460
+
461
+ Save key findings for future sessions. Includes PR number, title, date, files, critical issues, warnings, decisions, recommendation.
462
+
463
+ **Full save patterns**: [nano-brain-integration.md](references/nano-brain-integration.md#phase-55-save-review-to-nano-brain)
464
+
465
+ **Checkpoint:** Update `manifest.json` (`completed_phase: 5.5`, `next_phase: 6`).
466
+
467
+ ### Phase 6: Cleanup (PR Reviews Only)
468
+
469
+ Always ask before deleting the temp folder — the user may want to inspect files, run tests, or review multiple PRs.
470
+
471
+ 1. **Show the temp folder path and size**:
472
+ ```bash
473
+ du -sh "$REVIEW_DIR"
474
+ ```
475
+
476
+ 2. **Ask the user**:
477
+ ```
478
+ 🧹 Cleanup: Review temp folder exists at:
479
+ 📂 /tmp/pr-review-tradeit-backend-1159-1741502400 (45M)
480
+
481
+ Want me to remove it? (yes/no)
482
+ ```
483
+
484
+ 3. **Only if user confirms**: `rm -rf "$REVIEW_DIR"` (this also removes `.checkpoints/` since it's inside the clone directory)
485
+
486
+ 4. **If user declines**: Remind them to clean up later:
487
+ ```
488
+ ℹ️ Temp folder kept. Remove manually when done:
489
+ rm -rf /tmp/pr-review-tradeit-backend-1159-1741502400
490
+ ```
491
+
492
+ **If reviewing multiple PRs**: Each PR has its own temp folder. Ask about each one individually at the end.
493
+
494
+ **Note:** Checkpoints are automatically removed when the clone directory is deleted. For local reviews (`--staged`), checkpoints remain in `.checkpoints/` until manually deleted.
495
+
496
+ ### User Notification
497
+
498
+ After review completes, ALWAYS inform the user:
499
+
500
+ ```
501
+ ✅ Review complete!
502
+
503
+ 📄 Report saved to: .opencode/reviews/PR_123_2026-02-04.md
504
+
505
+ Summary:
506
+ • Critical: {count}
507
+ • Warnings: {count}
508
+ • Suggestions: {count}
509
+
510
+ 🧹 Temp clone: /tmp/pr-review-{repo}-{pr}-{ts} — want me to remove it?
511
+ ```
512
+
513
+ ## Usage Examples
514
+
515
+ ```
516
+ /review PR#123
517
+ /review https://github.com/owner/repo/pull/123
518
+ /review --staged
519
+ ```
520
+
521
+ ## Reference Documentation
522
+
523
+ | Document | Content | When to Read |
524
+ |----------|---------|--------------|
525
+ | [setup-wizard.md](references/setup-wizard.md) | Stack setup wizard — questions, mapping, config schema | Phase -2 (first run) |
526
+ | [subagent-prompts.md](references/subagent-prompts.md) | Full prompt templates for all 4 subagents | Phase 3 execution |
527
+ | [report-template.md](references/report-template.md) | Report format, PR summary guidelines, pseudocode | Phase 2.5 + Phase 5 |
528
+ | [nano-brain-integration.md](references/nano-brain-integration.md) | Tool reference, query patterns, save patterns | Phase 1, 2, 5.5 |
529
+ | [config.json](assets/config.json) | Full workspace + output + trace + stack config | Setup |
530
+ | [security-patterns.md](references/security-patterns.md) | OWASP patterns, auth checks | Phase 3 (Security agent) |
531
+ | [quality-patterns.md](references/quality-patterns.md) | Code quality anti-patterns | Phase 3 (Quality agent) |
532
+ | [performance-patterns.md](references/performance-patterns.md) | N+1, caching, allocation patterns | Phase 3 (Integration agent) |
533
+ | [framework-rules/](references/framework-rules/) | vue-nuxt, express, nestjs, typeorm, typescript, nextjs, react, prisma | Phase -2 (load only stack-matching files) |
534
+ | [checkpoint-system.md](references/checkpoint-system.md) | Manifest schema, checkpoint files, resume logic | Phase -1 (resume detection) |
535
+ | [verification-protocol.md](references/verification-protocol.md) | Category-specific verification rules | Phase 4.5 |
536
+ | [confidence-scoring.md](references/confidence-scoring.md) | Confidence formula, thresholds, display format | Phase 4.6 |
537
+ | [checklists/database.md](checklists/database.md) | MySQL/Redis patterns, transactions, migrations | Phase 2 (DB file changes) |
@@ -0,0 +1,60 @@
1
+ {
2
+ "version": "3.3.0",
3
+ "stack": {
4
+ "frontend": "nuxt",
5
+ "backend": "express",
6
+ "orm": "typeorm",
7
+ "language": "typescript",
8
+ "state": "pinia"
9
+ },
10
+ "agents": {
11
+ "workspace_root": "/path/to/workspace",
12
+ "has_agents_md": true,
13
+ "has_repos_dir": true,
14
+ "has_domains_dir": true
15
+ },
16
+ "workspace": {
17
+ "name": "my-project",
18
+ "github": {
19
+ "owner": "acme-corp",
20
+ "default_base": "main",
21
+ "token_env": "GITHUB_TOKEN"
22
+ },
23
+ "linear": {
24
+ "enabled": true,
25
+ "workspace_id": "acme",
26
+ "team_id": "ENG",
27
+ "token_env": "LINEAR_API_KEY",
28
+ "extract_from": ["branch_name", "pr_description", "pr_title"],
29
+ "fetch_comments": true,
30
+ "fetch_attachments": false
31
+ },
32
+ "jira": {
33
+ "instance": "acme.atlassian.net",
34
+ "project_key": "ACME",
35
+ "token_env": "JIRA_TOKEN"
36
+ }
37
+ },
38
+ "output": {
39
+ "directory": ".opencode/reviews",
40
+ "filename_pattern": "{type}_{identifier}_{date}",
41
+ "github_comment": false,
42
+ "notify_user": true
43
+ },
44
+ "trace_depth": {
45
+ "logic": "deep",
46
+ "style": "shallow",
47
+ "refactor": "medium"
48
+ },
49
+ "report": {
50
+ "verbosity": "compact",
51
+ "show_suggestions": false,
52
+ "show_improvements": true,
53
+ "max_suggestions_listed": 3
54
+ },
55
+ "ignore_patterns": [
56
+ "*.test.ts",
57
+ "*.spec.ts",
58
+ "__mocks__/**"
59
+ ]
60
+ }