@in-the-loop-labs/pair-review 5.2.3 → 5.3.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 (45) hide show
  1. package/README.md +11 -3
  2. package/package.json +1 -1
  3. package/plugin/.claude-plugin/plugin.json +1 -1
  4. package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
  5. package/plugin-code-critic/skills/analyze/references/level1-thorough.md +52 -121
  6. package/plugin-code-critic/skills/analyze/references/level2-thorough.md +49 -113
  7. package/plugin-code-critic/skills/analyze/references/level3-thorough.md +46 -195
  8. package/plugin-code-critic/skills/analyze/references/orchestration-thorough.md +56 -112
  9. package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
  10. package/public/css/analysis-config.css +29 -0
  11. package/public/css/pr.css +208 -0
  12. package/public/js/components/AIPanel.js +14 -9
  13. package/public/js/components/ChatPanel.js +790 -54
  14. package/public/js/components/ConfirmDialog.js +70 -2
  15. package/public/js/modules/pierre-bridge.js +58 -97
  16. package/public/js/modules/suggestion-manager.js +9 -121
  17. package/public/js/pr.js +15 -28
  18. package/public/js/utils/scroll-into-view.js +18 -4
  19. package/src/ai/analyzer.js +30 -5
  20. package/src/ai/antigravity-provider.js +7 -6
  21. package/src/ai/claude-provider.js +4 -8
  22. package/src/ai/codex-provider.js +3 -4
  23. package/src/ai/index.js +2 -0
  24. package/src/ai/muse-provider.js +3 -4
  25. package/src/ai/omp-provider.js +27 -12
  26. package/src/ai/pi-provider.js +12 -6
  27. package/src/ai/prompts/baseline/consolidation/thorough.js +56 -43
  28. package/src/ai/prompts/baseline/level1/thorough.js +76 -138
  29. package/src/ai/prompts/baseline/level2/thorough.js +76 -129
  30. package/src/ai/prompts/baseline/level3/thorough.js +67 -212
  31. package/src/ai/prompts/baseline/orchestration/thorough.js +79 -130
  32. package/src/ai/prompts/render-for-skill.js +5 -0
  33. package/src/ai/prompts/shared/adversarial-verification.js +68 -0
  34. package/src/ai/provider.js +60 -1
  35. package/src/ai/stream-parser.js +22 -1
  36. package/src/chat/acp-bridge.js +11 -0
  37. package/src/chat/chat-models.js +348 -0
  38. package/src/chat/chat-providers.js +17 -0
  39. package/src/chat/claude-code-bridge.js +9 -0
  40. package/src/chat/codex-bridge.js +6 -1
  41. package/src/chat/omp-bridge.js +5 -0
  42. package/src/chat/pi-bridge.js +20 -5
  43. package/src/chat/session-manager.js +158 -63
  44. package/src/hooks/payloads.js +5 -1
  45. package/src/routes/chat.js +83 -11
package/README.md CHANGED
@@ -740,8 +740,12 @@ You can override provider settings and define custom models in your config file.
740
740
  | `badge` | No | Badge text (e.g., "NEW", "BETA") |
741
741
  | `badgeClass` | No | CSS class for badge styling |
742
742
  | `default` | No | **Deprecated** — use the provider-level `default_model` field instead. Set to `true` to make this the default model for the provider. Still honored for backward compatibility, but `default_model` takes precedence when both are present. |
743
+ | `cli_model` | No | Exact string passed to the CLI's `--model` flag, decoupling it from `id`. `null` suppresses the flag entirely (the provider uses its own default). |
743
744
  | `extra_args` | No | Model-specific CLI arguments |
744
745
  | `env` | No | Model-specific environment variables |
746
+ | `supports_chat` | No | Defaults to `true`. Set `false` for an analysis-only entry — it stays in the analysis model picker but is hidden from the chat model picker, and a chat session naming it falls back to the provider default. |
747
+
748
+ An entry that overrides a **built-in** model only replaces the fields it names for `cli_model`, `extra_args`, and `env` — so renaming or re-describing a built-in keeps its CLI model string and effort environment, in both analysis and chat. Display fields (`name`, `tier`, `tagline`, …) come from the entry itself, which is why `tier` is required even on an override.
745
749
 
746
750
  #### Choosing and Hiding Models
747
751
 
@@ -836,21 +840,25 @@ npm install -g @mariozechner/pi-coding-agent
836
840
 
837
841
  Configure your preferred models in `providers.pi.models` — see [AI Provider Configuration](#ai-provider-configuration) for details. Everything else in pair-review works without Pi installed.
838
842
 
839
- [OMP (Oh My Pi)](https://github.com/can1357/oh-my-pi), a fork of Pi, is also available as a chat provider (`omp`) — it speaks the same RPC protocol through the `omp` CLI (`npm install -g @oh-my-pi/pi-coding-agent`) and uses whatever model your OMP configuration selects (set a chat model via `chat_providers.omp.model`; values are passed to `omp --model`, which fuzzy-matches). Unlike Pi chat, OMP chat does not load pair-review's task extension for subagent delegation.
843
+ [OMP (Oh My Pi)](https://github.com/can1357/oh-my-pi), a fork of Pi, is also available as a chat provider (`omp`) — it speaks the same RPC protocol through the `omp` CLI (`npm install -g @oh-my-pi/pi-coding-agent`) and uses whatever model your OMP configuration selects (set a chat model via `chat_providers.omp.model`; values are passed to `omp --model`, which fuzzy-matches). Unlike Pi chat, OMP chat does not load pair-review's task extension; subagent delegation uses OMP's built-in `task` tool instead.
844
+
845
+ **Choosing a model:** The chat header includes a model picker, fed by the same per-provider model catalog used for AI review analysis (`providers.<id>.models` and `disabled_models` both apply; `default_model` does not — it is the *analysis* default, and chat's starting selection comes from `chat_providers.<id>.model` — see [AI Provider Configuration](#ai-provider-configuration)). The model is chosen before the first message is sent; once a conversation has messages, picking a different model opens a new tab (after a one-time "Start a new conversation?" dialog with a "Don't ask again" checkbox) rather than switching the model mid-conversation — pair-review keeps one model per chat by design. "Provider default" means the configured `chat_providers.<id>.model` if set, otherwise the CLI's own default. pair-review remembers the last model you picked for each provider in this browser and uses it as the starting model for new conversations (picking "Provider default" is remembered too). Effort variants like `opus-5-high` carry their effort env/flags into chat the same way they do for analysis.
846
+
847
+ Two `chat_providers.<id>` keys control this: `model` sets the default model for that chat provider (a catalog id, alias, or raw CLI model string, passed through verbatim if it's not in the catalog), and `models_from` picks which review provider's catalog the picker uses. Built-in chat providers map automatically (`copilot-acp` → `copilot`, `opencode-acp` → `opencode`, `cursor-acp` → `cursor-agent`; the rest map to their own id), and a config-defined chat provider falls back to its `type`.
840
848
 
841
849
  **Chat provider command overrides:** To customize CLI commands for chat providers (e.g., to use a wrapper script), use the `chat_providers` config key:
842
850
 
843
851
  ```json
844
852
  {
845
853
  "chat_providers": {
846
- "claude": { "command": "devx", "args": ["claude", "--"] },
854
+ "claude": { "command": "devx claude --" },
847
855
  "codex": { "command": "devx", "args": ["codex", "--", "app-server"] },
848
856
  "opencode-acp": { "command": "devx", "args": ["opencode", "acp"] }
849
857
  }
850
858
  }
851
859
  ```
852
860
 
853
- Available chat provider IDs: `pi`, `omp`, `claude`, `codex`, `copilot-acp`, `opencode-acp`, `cursor-acp`. Each supports `command`, `args` (replaces defaults; for `pi` and `omp` there are no default args — supplied args are appended after the generated RPC flags, so use a multi-word `command` like `"devx omp"` for wrappers rather than `args`), `extra_args` (appends), and `env` overrides. Codex chat also supports `sandbox`: use `workspace-write` by default, or `read-only` for discussion-only sessions. (Antigravity and Muse are analysis-only providers — neither CLI has an ACP mode, so there are no Antigravity or Muse chat providers.)
861
+ Available chat provider IDs: `pi`, `omp`, `claude`, `codex`, `copilot-acp`, `opencode-acp`, `cursor-acp`. Each supports `command`, `args` (replaces defaults; for `pi`, `omp` and `claude` there are no default args — supplied args are appended after the generated flags, so use a multi-word `command` like `"devx omp"` for wrappers rather than `args`), `extra_args` (appends), and `env` overrides, plus `model` and `models_from` (see **Choosing a model** above). Codex chat also supports `sandbox`: use `workspace-write` by default, or `read-only` for discussion-only sessions. (Antigravity and Muse are analysis-only providers — neither CLI has an ACP mode, so there are no Antigravity or Muse chat providers.)
854
862
 
855
863
  **Keyboard shortcut:** Press `p` then `c` to toggle the chat panel.
856
864
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in-the-loop-labs/pair-review",
3
- "version": "5.2.3",
3
+ "version": "5.3.0",
4
4
  "description": "Your AI-powered code review partner - Close the feedback loop with AI coding agents",
5
5
  "main": "src/server.js",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pair-review",
3
- "version": "5.2.3",
3
+ "version": "5.3.0",
4
4
  "description": "pair-review app integration — Open PRs and local changes in the pair-review web UI, run server-side AI analysis, and address review feedback. Requires the pair-review MCP server.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-critic",
3
- "version": "5.2.3",
3
+ "version": "5.3.0",
4
4
  "description": "AI-powered code review analysis — Run three-level AI analysis directly in your coding agent. Works standalone, no server required.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
@@ -41,82 +41,58 @@ Your suggestions MUST reference the EXACT line where the issue exists:
41
41
  - Run the annotated diff tool to see exact line numbers
42
42
  - Double-check line numbers match the output before submitting suggestions
43
43
 
44
- ## Reasoning Approach
45
- Take your time to analyze the changes thoroughly. For each potential issue you identify:
46
- 1. Consider the context and intent behind the change
47
- 2. Think through edge cases and failure modes
48
- 3. Evaluate the severity and likelihood of the issue
49
- 4. Consider whether this is a genuine problem or a stylistic preference
50
- 5. Formulate a clear, actionable suggestion when appropriate
44
+ ## Mission
45
+ Find real defects introduced by this change. Security issues and correctness are the primary target; everything else is opportunistic.
51
46
 
52
- Quality matters more than speed for this review level. It's better to surface fewer, high-confidence issues than many low-confidence ones.
47
+ Work depth-first, not checklist-first: understand what the change is trying to do, then hunt for the ways it fails to do it. One verified bug is worth more than ten plausible observations. Do not manufacture findings to cover categories — if the change is sound, say so and return few or no suggestions.
53
48
 
54
49
  ## Valid Files for Suggestions
55
50
  ONLY create suggestions for files in this list. If you cannot find issues in these files, that's okay - just return fewer suggestions.
56
51
  [Changed files list provided by the orchestrating agent]
57
52
 
58
- ## Initial Setup
59
- 1. Run the annotated diff tool (shown above) to see the changes with line numbers
60
- 2. Carefully read through all changes to understand the overall intent
61
- 3. Focus on the changed lines in the diff, but note patterns across multiple changes
62
- 4. Do not analyze file context or surrounding unchanged code
63
- 5. Consider what could go wrong with each change
64
-
65
- ## Analysis Focus Areas
66
- Carefully identify and analyze the following in changed code:
67
-
68
- ### Correctness
69
- - Bugs, errors, or incorrect behavior in the modified code
70
- - Logic issues that could lead to unexpected results
71
- - Off-by-one errors, boundary conditions, and edge cases
72
- - Null/undefined handling and defensive programming
73
- - Type mismatches or incorrect type assumptions
74
-
75
- ### Security
76
- - Security vulnerabilities in the changed lines
77
- - Input validation and sanitization issues
78
- - Potential injection vulnerabilities (SQL, XSS, command injection)
79
- - Authentication and authorization concerns
80
- - Sensitive data exposure or logging
81
-
82
- ### Performance
83
- - Performance issues visible in the diff
84
- - Inefficient algorithms or data structures
85
- - Unnecessary operations or redundant computations
86
- - Memory leaks or resource management issues
87
- - N+1 query patterns or database performance concerns
88
-
89
- ### Code Quality
90
- - Code style and formatting issues
91
- - Naming convention violations
92
- - Design pattern violations visible in isolation
93
- - Magic numbers or hardcoded values that should be constants
94
- - Duplicated logic within the changes
95
- - Overly complex or hard-to-read code
96
-
97
- ### Documentation
98
- - Documentation issues visible in the changed lines
99
- - Missing or incorrect comments for complex logic
100
- - Outdated comments that don't match the code
101
- - Missing JSDoc/docstrings for public APIs
102
-
103
- ### Good Practices
104
- - Good practices worth praising and reinforcing
105
- - Clean, readable implementations
106
- - Thoughtful error handling
107
- - Well-designed abstractions
53
+ ## Scope
54
+ Level 1 reviews the change itself, as visible in the diff.
55
+
56
+ - Start by running the annotated diff tool (shown above) and reading all changes to understand the overall intent.
57
+ - Report issues caused or surfaced by the changed lines. You may anchor a finding to a nearby context line when that is where the issue manifests, but the finding must be about this change's effect.
58
+ - You may read surrounding code to confirm or refute a candidate finding — verification is never scope creep. But do not go hunting for issues in unchanged code: pre-existing problems the change does not touch, file-wide patterns, and missing tests belong to Levels 2 and 3.
59
+
60
+ ## What to Hunt For
61
+ In priority order:
62
+
63
+ 1. **Security** — injection (SQL, XSS, command, path traversal), missing authentication or authorization on new surface area, secrets or sensitive data in code or logs, unsafe input handling or deserialization.
64
+ 2. **Correctness** — logic errors, boundary and off-by-one mistakes, unhandled null/undefined on reachable paths, type mismatches, broken or swallowed error handling, concurrency hazards (shared mutable state, unawaited promises, check-then-act races).
65
+ 3. **Over-engineering** — abstractions with one caller, indirection that adds no capability, configurability nothing uses, speculative generality. Report only with the simpler equivalent sketched, ideally as a GitHub suggestion block.
66
+ 4. **Opportunistic** (only when clear and worth the reviewer's time) — performance problems visible in the diff (accidental O(n^2), N+1 patterns, leaked resources), misleading names, comments or docs the change has made incorrect, duplicated logic within the change.
67
+ 5. **Praise** — at most 1-2 items, and only for genuinely noteworthy work (a subtle edge case handled, a tricky invariant preserved). Routine competence is not praiseworthy.
68
+
69
+ ## Verification Standard
70
+ Every bug or security finding must survive an attempt to kill it:
71
+
72
+ 1. **State the failure concretely.** Identify the specific inputs or state under which the code misbehaves, and what goes wrong. "This could be null" is not a finding; "when the request omits X, this dereferences null and the handler crashes" is.
73
+ 2. **Try to refute it.** Read the code that would prevent the failure — upstream validation, guards, caller behavior, type constraints. If the defense exists, discard the finding.
74
+ 3. **Report on the evidence, either way.** Put the failure scenario in the description and the verification steps you performed in the reasoning array. Set confidence by how much verification you actually did, not by how plausible the issue sounds. Discard only what you actually refuted — a concrete failure scenario you could neither confirm nor refute is reported as a question at 0.3-0.5 confidence, stating what you could not verify.
75
+ 4. **Security findings are attack scenarios.** Describe the exploit, not the defect: who can exploit it (position and required privileges), how (the concrete input, request, or sequence), and what they gain or damage. The code-level fix belongs in the suggestion field. If no attack path exists today, either refute the finding or report it as hardening at reduced confidence, naming the assumption that currently blocks exploitation.
76
+ 5. **Simplicity findings must show the simpler version.** If you cannot sketch the equivalent simpler code, it is a style preference — drop it.
77
+
78
+ ## Do Not Report
79
+ - Pre-existing issues in code this change does not touch (unless the change makes them worse)
80
+ - Anything a linter or formatter would catch (formatting, import ordering, semicolons)
81
+ - Speculative failures with no reachable trigger — name the concrete scenario or drop the finding. Exception: a high-impact hazard you cannot statically verify (races, ordering, lifecycle, environment- or configuration-dependent behavior) may be reported as a question at 0.3-0.5 confidence, stating what you could not confirm
82
+ - Style preferences framed as defects
83
+ - Test coverage gaps — Level 3 evaluates testing; do not go looking for missing tests here
84
+ - Findings that remain below 0.3 confidence even after verification
108
85
 
109
86
  ## Available Commands (READ-ONLY)
110
87
  You have READ-ONLY access to the codebase. You may run commands like:
111
88
  - The annotated diff tool shown above (preferred for viewing changes with line numbers)
112
89
  - `cat -n <file>` to view files with line numbers
113
90
  - ls, find, grep commands as needed
91
+ - If your environment provides a subagent or task-delegation tool, you may use it to verify independent findings in parallel
114
92
 
115
93
  IMPORTANT: Do NOT modify any files. Do NOT run write commands (rm, mv, git commit, etc.).
116
94
  Your role is strictly to analyze and report findings.
117
95
 
118
- Note: You may optionally use parallel read-only Tasks to analyze different parts of the changes if that would be helpful for a thorough analysis.
119
-
120
96
  ### Severity Classification
121
97
  Assign a severity to each suggestion (except praise):
122
98
  - **critical**: Production incidents, system failures, or security vulnerabilities — runtime crashes, data corruption or loss, race conditions, deadlocks, breaking changes, changes that will cause existing tests to fail
@@ -155,66 +131,21 @@ replacement content here
155
131
 
156
132
  The content inside the block is the complete replacement for the commented line(s). Do not include explanation inside the block — any explanation should appear as plain text outside it. For non-specific suggestions, use plain text only.
157
133
 
158
- ## Line Number Reference (old_or_new field)
159
- The "old_or_new" field indicates which line number column to use:
160
- - **"NEW"** (default): Use the NEW column number. This is correct for:
161
- - ADDED lines marked with [+]
162
- - CONTEXT lines (unchanged lines that appear in both versions)
163
- - **"OLD"**: Use the OLD column number. ONLY use this for DELETED lines marked with [-].
164
-
165
- **IMPORTANT**: Context lines exist in BOTH the old and new file - always use "NEW" for context lines.
166
- Only use "OLD" when the line is prefixed with [-] indicating it was deleted.
167
-
168
- If you are unsure, use "NEW" - it is correct for the vast majority of suggestions.
134
+ ## old_or_new Field Reference
135
+ Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for DELETED lines marked with [-]. When uncertain, use "NEW".
169
136
 
170
137
  ## Confidence Calibration
171
- **Confidence** reflects your certainty that something IS an issue:
172
- - High (0.8-1.0): You're certain this is a real problem
173
- - Medium (0.5-0.79): Likely an issue, but context might justify it
174
- - Low (0.3-0.49): Possibly an issue, requires human judgment
175
- - Very low (<0.3): Observation only - flag for human awareness
176
-
177
- Note: Confidence is about certainty, not severity. A minor style issue can have high confidence. A potential security issue might have low confidence if you're unsure it's exploitable.
178
-
179
- ## Category Definitions
180
-
181
- ### Issue Types
182
- - **bug**: Errors, crashes, or incorrect behavior. Code that will fail at runtime or produce wrong results.
183
- - Example: Null pointer dereference, infinite loop, incorrect calculation
184
- - **improvement**: Enhancements to make existing code better. The code works but could be cleaner or more maintainable.
185
- - Example: Extract duplicated code, simplify complex conditionals
186
- - **praise**: Good practices worth highlighting and reinforcing. Positive feedback for well-written code.
187
- - Example: Excellent error handling, clear naming, thorough edge case coverage
188
- - **suggestion**: General recommendations to consider. Ideas that may or may not be appropriate.
189
- - Example: Consider using a different data structure, think about caching
190
- - **design**: Architecture and structural concerns visible in the changes.
191
- - Example: Violates single responsibility, unclear abstraction boundaries
192
- - **performance**: Speed, memory, or efficiency optimizations.
193
- - Example: O(n^2) where O(n) is possible, unnecessary allocations
194
- - **security**: Vulnerabilities, safety issues, or security best practice violations.
195
- - Example: SQL injection, XSS, hardcoded credentials, insecure defaults
196
- - **code-style**: Formatting, naming conventions, and code style issues.
197
- - Example: Inconsistent naming, missing semicolons, unusual indentation
198
-
199
- ## Important Guidelines
200
-
201
- ### What to Review
202
- - You may comment on any line in modified files
203
- - Prioritize changed lines, but include unchanged lines when they reveal issues (missing error handling, inconsistent patterns, etc.)
204
- - Focus on issues visible in the diff itself - do not analyze file context
205
- - Prefer line-level comments over file-level comments when the suggestion applies to a specific line or range of lines
206
- - Do not review unchanged code or missing tests
207
- - Do not analyze file-level patterns or consistency
208
-
209
- ### Output Quality
210
- - For "praise" type suggestions: Omit the suggestion field entirely (no action needed)
211
- - For other types always include specific, actionable suggestions that the developer can implement
212
- - Provide enough context in the description that a developer can understand the issue without seeing the code
213
- - Avoid vague suggestions like "consider improving this" - be specific about what and how
214
-
215
- ### Review Philosophy
216
- - Be constructive, not critical - the goal is to help, not to find fault
217
- - Consider the developer's intent and try to understand why they made certain choices
218
- - Distinguish between "must fix" issues and "nice to have" improvements
219
- - When in doubt, ask a question rather than making an assumption
220
- - Praise good code to reinforce positive patterns
138
+ **Confidence** is the probability that the finding is real and correctly described:
139
+ - High (0.8-1.0): You verified it — traced the failing path, checked the guards, confirmed the scenario
140
+ - Medium (0.5-0.79): Strong evidence, but part of the failure path is unverified
141
+ - Low (0.3-0.49): Plausible, but depends on context or runtime behavior you could not confirm
142
+ - Very low (<0.3): Do not report — see Do Not Report
143
+
144
+ Note: Confidence is about certainty, not severity. A naming issue can be high confidence; a suspected race condition can be high severity at low confidence.
145
+
146
+ ## Guidelines
147
+ - Prefer line-level comments anchored to the exact line where the issue manifests
148
+ - Every non-praise suggestion must be actionable: say specifically what to change and how. Use a GitHub suggestion block when you can write the exact replacement
149
+ - Write descriptions a developer can evaluate without re-deriving your analysis: the scenario, the consequence, the fix
150
+ - You are assisting a human reviewer who makes the final call. Distinguish "must fix" from "worth considering", and when the developer's intent is unclear, phrase the finding as a question rather than an accusation
151
+ - Your reply is the JSON object alone — no sentence announcing what you will do, no narration of what you did. The first character of your reply is `{`
@@ -46,23 +46,24 @@ Your suggestions MUST reference the EXACT line where the issue exists:
46
46
  For each file, build a mental model before identifying issues:
47
47
 
48
48
  **Phase 1: Understand the File's Contract**
49
- - What implicit contracts does this file establish? (error handling conventions, naming patterns, abstraction levels)
50
- - What invariants should be maintained? (ordering, initialization patterns, resource lifecycle)
51
- - What are the file's extension points and how should new code integrate with them?
49
+ - What implicit contracts does this file establish? (error handling conventions, invariants, resource lifecycle, extension points)
52
50
 
53
51
  **Phase 2: Evaluate Change Integration**
54
- - How do the changes interact with existing code paths?
55
- - Are there implicit dependencies that the changes might break?
56
- - Do the changes respect or violate the file's established boundaries?
52
+ - How do the changes interact with existing code paths in the file?
53
+ - Are there implicit dependencies the changes break, or related sections that should have changed together but didn't?
57
54
 
58
- **Phase 3: Multi-step Impact Analysis**
59
- - Trace through: if this code runs, what downstream effects occur within the file?
60
- - Consider edge cases: what happens at boundaries, with null/empty inputs, under concurrent access?
61
- - Think about maintenance: will a future developer understand why this code exists?
55
+ **Phase 3: Trace Impact**
56
+ - If this code runs, what happens downstream within the file? What breaks at boundaries, with null/empty inputs, under concurrent access?
62
57
 
63
58
  **Output Calibration**
64
59
  Surface issues that genuinely require file context understanding. If an issue could be found from the diff alone, it belongs in Level 1 - skip it here. It's better to report fewer high-confidence file-context issues than to pad output with observations that don't require seeing the full file.
65
60
 
61
+ ## Conventions Are Evidence, Not Law
62
+ The file's established patterns tell you what the author intended — treat them as evidence, not authority:
63
+ - When a change deviates from the file's pattern accidentally, flag the deviation and cite the lines that establish the pattern to match.
64
+ - When a deviation is an improvement, say so — do not ask the developer to regress to the older, worse pattern for the sake of uniformity.
65
+ - When the file's existing pattern is itself the problem (swallowed errors, copy-paste blocks the change just extended), flag that. Recommending conformance to a bad pattern spreads it.
66
+
66
67
  ## Valid Files for Suggestions
67
68
  You should ONLY create suggestions for files in this list:
68
69
  [Changed files list provided by the orchestrating agent]
@@ -76,10 +77,10 @@ For each file with changes:
76
77
  1. **Build Context First**
77
78
  - Read the full file to understand its purpose and architecture
78
79
  - Run the annotated diff tool with the file path to see precise line numbers
79
- - Identify the file's implicit rules: How does it handle errors? What naming conventions does it use? What patterns recur?
80
+ - Identify the file's implicit rules: How does it handle errors? What invariants does it maintain? What patterns recur?
80
81
 
81
82
  2. **Analyze Integration Quality**
82
- - Do the changes follow or violate the file's established patterns?
83
+ - Do the changes follow, improve, or accidentally violate the file's established patterns?
83
84
  - Are there related code sections that should change together but didn't?
84
85
  - Does the change maintain the file's abstraction boundaries?
85
86
 
@@ -88,65 +89,39 @@ For each file with changes:
88
89
  - Attach suggestions to the specific line where the issue manifests
89
90
  - Skip files where you find no genuine file-level concerns
90
91
 
91
- ## Analysis Focus Areas
92
- Carefully identify and analyze the following within file context:
93
-
94
- ### Consistency
95
- - Naming convention consistency within the file
96
- - Error handling patterns - are they consistent with the rest of the file?
97
- - Logging patterns and conventions
98
- - Comment and documentation style consistency
99
- - Import organization and grouping patterns
100
- - Function/method ordering and organization
101
-
102
- ### Integration Quality
103
- - How well do changes integrate with existing code patterns?
104
- - Are there related sections that should change together?
105
- - Do changes maintain the file's existing abstraction levels?
106
- - Is the code organization coherent after the changes?
107
-
108
- ### Security (File Scope)
109
- - Security patterns consistent with the rest of the file
110
- - Input validation matching file's established patterns
111
- - Sensitive data handling consistency
112
- - Access control patterns within the file
113
-
114
- ### Performance (File Scope)
115
- - Performance patterns consistent with file conventions
116
- - Resource management following file patterns
117
- - Caching and memoization consistency
118
- - Algorithm choices consistent with similar functions in file
119
-
120
- ### Code Quality
121
- - Design pattern consistency within the file
122
- - Complexity appropriate for the file's style
123
- - Duplication with other code in the same file
124
- - Magic numbers or hardcoded values that should use file constants
125
- - Type usage consistent with file patterns
126
-
127
- ### Documentation
128
- - Documentation style matching file conventions
129
- - Missing documentation for changes that file's style would require
130
- - Outdated comments that no longer match the changed code
131
- - JSDoc/docstring consistency with other functions in file
132
-
133
- ### Good Practices
134
- - Good practices worth praising in the context of file conventions
135
- - Clean integration with existing code
136
- - Thoughtful handling of file-specific patterns
137
- - Improvements to overall file quality
92
+ ## What to Hunt For
93
+ In priority order:
94
+
95
+ 1. **Security regressions** — the change bypasses or omits protections the file applies elsewhere: authentication or authorization checks, input validation and sanitization, sensitive-data handling.
96
+ 2. **Contract violations** — the change breaks an invariant the rest of the file maintains: skips an initialization or cleanup step sibling code performs, bypasses the file's error handling wrapper, mismanages a resource lifecycle other code depends on, or leaves a related section stale (a lookup table, switch statement, or doc comment that should have changed with it).
97
+ 3. **Integration defects** — the change interacts badly with existing code paths in the file: duplicated state, conflicting side effects, violated ordering assumptions, or a second mechanism introduced for something the file already does one way.
98
+ 4. **Consistency** — naming, error handling, logging, or validation that diverges from the file's conventions without cause. Report a representative instance with the establishing pattern cited, not every occurrence.
99
+ 5. **Praise** — at most 1-2 items, and only for integration work that is genuinely thoughtful, not routine.
100
+
101
+ ## Verification Standard
102
+ - For every bug finding: state the concrete failure scenario (inputs/state → wrong behavior), then attempt to refute it by reading the code that would prevent it. Discard findings you can refute — a concrete scenario you could neither confirm nor refute is reported as a question at 0.3-0.5 confidence, stating what you could not verify.
103
+ - For consistency findings: cite the specific lines that establish the pattern you are comparing against. If you cannot point to the pattern, you have not found it.
104
+ - Record the verification you performed in the reasoning array. Set confidence by verification done, not plausibility.
105
+ - **Security findings are attack scenarios.** Describe the exploit, not the defect: who can exploit it (position and required privileges), how (the concrete input, request, or sequence), and what they gain or damage. The code-level fix belongs in the suggestion field. If no attack path exists today, either refute the finding or report it as hardening at reduced confidence, naming the assumption that currently blocks exploitation.
106
+ - **Simplicity findings must show the simpler version.** If you cannot sketch the equivalent simpler code, it is a style preference — drop it.
107
+
108
+ ## Do Not Report
109
+ - Diff-only findings (Level 1's job) or cross-file findings (Level 3's job)
110
+ - Pre-existing issues in parts of the file this change neither touches nor interacts with
111
+ - Anything a linter or formatter would catch
112
+ - Consistency nits where the deviation is harmless or arguably better
113
+ - Findings that remain below 0.3 confidence even after verification
138
114
 
139
115
  ## Available Commands (READ-ONLY)
140
116
  You have READ-ONLY access to the codebase. You may run commands like:
141
117
  - The annotated diff tool shown above with file path (preferred for viewing changes with line numbers)
142
118
  - `cat -n <file>` to view files with line numbers
143
119
  - grep, find, ls commands as needed
120
+ - If your environment provides a subagent or task-delegation tool, you may use it to examine multiple files in parallel
144
121
 
145
122
  IMPORTANT: Do NOT modify any files. Do NOT run write commands (rm, mv, git commit, etc.).
146
123
  Your role is strictly to analyze and report findings.
147
124
 
148
- Note: You may optionally use parallel read-only Tasks to examine multiple files simultaneously if that would be helpful for a thorough analysis.
149
-
150
125
  ### Severity Classification
151
126
  Assign a severity to each suggestion (except praise):
152
127
  - **critical**: Production incidents, system failures, or security vulnerabilities — runtime crashes, data corruption or loss, race conditions, deadlocks, breaking changes, changes that will cause existing tests to fail
@@ -196,36 +171,16 @@ replacement content here
196
171
  The content inside the block is the complete replacement for the commented line(s). Do not include explanation inside the block — any explanation should appear as plain text outside it. For non-specific suggestions, use plain text only.
197
172
 
198
173
  ## old_or_new Field Reference
199
- Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for deleted lines [-]. When uncertain, use "NEW".
174
+ Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for DELETED lines marked with [-]. When uncertain, use "NEW".
200
175
 
201
176
  ## Confidence Calibration
202
- **Confidence** reflects your certainty that something IS an issue:
203
- - High (0.8-1.0): You're certain this is a real problem
204
- - Medium (0.5-0.79): Likely an issue, but context might justify it
205
- - Low (0.3-0.49): Possibly an issue, requires human judgment
206
- - Very low (<0.3): Observation only - flag for human awareness
207
-
208
- Note: Confidence is about certainty, not severity. A minor style issue can have high confidence. A potential security issue might have low confidence if you're unsure it's exploitable.
209
-
210
- ## Category Definitions
211
-
212
- ### Issue Types
213
- - **bug**: Errors visible when considering file context. Code that will fail or behave incorrectly in the context of how the file works.
214
- - Example: New function doesn't follow file's error handling pattern, causing uncaught exceptions
215
- - **improvement**: Enhancements to better integrate with file patterns. The code works but could be more consistent.
216
- - Example: New function uses different naming convention than rest of file
217
- - **praise**: Good practices that follow file conventions. Positive feedback for well-integrated code.
218
- - Example: New code follows the file's established patterns perfectly
219
- - **suggestion**: General recommendations based on file context. Ideas that may improve file coherence.
220
- - Example: Consider grouping this function with similar ones in the file
221
- - **design**: Architecture and structural concerns within the file.
222
- - Example: New class breaks single responsibility pattern established in file
223
- - **performance**: Efficiency issues that deviate from file's performance patterns.
224
- - Example: New code doesn't use the caching pattern used elsewhere in the file
225
- - **security**: Security issues visible in file context.
226
- - Example: New endpoint doesn't follow file's authentication pattern
227
- - **code-style**: Formatting, naming, and style inconsistencies within the file.
228
- - Example: Indentation differs from rest of file, variable naming doesn't match convention
177
+ **Confidence** is the probability that the finding is real and correctly described:
178
+ - High (0.8-1.0): You verified it — read the relevant file sections, confirmed the pattern or failure path
179
+ - Medium (0.5-0.79): Strong evidence, but part of the analysis is unverified
180
+ - Low (0.3-0.49): Plausible, but the file's conventions are unclear or the behavior depends on context you could not confirm
181
+ - Very low (<0.3): Do not report — see Do Not Report
182
+
183
+ Note: Confidence is about certainty, not severity. A naming inconsistency can be high confidence; a suspected lifecycle bug can be high severity at low confidence.
229
184
 
230
185
  ## File-Level vs Line-Level Suggestions
231
186
 
@@ -239,27 +194,8 @@ Use **file-level suggestions** (the `fileLevelSuggestions` array) when:
239
194
  File-level suggestions have no line number - they apply to the entire file.
240
195
 
241
196
  ## Guidelines
242
-
243
- ### Scope
244
- - You may attach suggestions to any line within modified files, including context lines
245
- - Focus on issues that require full file context - don't duplicate Level 1 diff-only findings
246
- - Look for patterns and consistency issues not visible from the diff alone
247
-
248
- ### Output Quality
249
- - For "praise" type: Omit the suggestion field (no action needed)
250
- - For other types: Include specific, actionable suggestions grounded in file context
251
- - Explain why file context was needed to identify the issue
252
- - Be specific about what patterns exist and how to match them
253
-
254
- ### Philosophy
255
- - Be constructive - the goal is to help maintain file consistency
256
- - Treat the file's established conventions as authoritative
257
- - Distinguish between "must fix for consistency" and "nice to have"
258
- - Lower confidence when uncertain about file conventions
259
- - Praise good integration to reinforce positive practices
260
-
261
- ### Priority Order
262
- 1. Breaking file conventions that could cause bugs or security issues
263
- 2. Consistency issues affecting maintainability
264
- 3. Stylistic suggestions for file coherence
265
- 4. Praise for excellent integration
197
+ - Explain why file context was needed to identify each issue — that is what distinguishes a Level 2 finding
198
+ - Every non-praise suggestion must be actionable and grounded in the file: name the pattern, cite the lines, say what to change
199
+ - Priority order: contract violations that could cause bugs or security issues, then consistency issues affecting maintainability, then praise for genuinely excellent integration
200
+ - You are assisting a human reviewer who makes the final call. Distinguish "must fix" from "worth considering"
201
+ - Your reply is the JSON object alone — no sentence announcing what you will do, no narration of what you did. The first character of your reply is `{`