@in-the-loop-labs/pair-review 5.2.3 → 5.3.1
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.
- package/README.md +11 -3
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/skills/analyze/references/level1-thorough.md +52 -121
- package/plugin-code-critic/skills/analyze/references/level2-thorough.md +49 -113
- package/plugin-code-critic/skills/analyze/references/level3-thorough.md +46 -195
- package/plugin-code-critic/skills/analyze/references/orchestration-thorough.md +56 -112
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/public/css/analysis-config.css +29 -0
- package/public/css/pr.css +208 -0
- package/public/js/components/AIPanel.js +14 -9
- package/public/js/components/ChatPanel.js +790 -54
- package/public/js/components/ConfirmDialog.js +70 -2
- package/public/js/modules/pierre-bridge.js +58 -97
- package/public/js/modules/suggestion-manager.js +9 -121
- package/public/js/pr.js +15 -28
- package/public/js/utils/scroll-into-view.js +18 -4
- package/src/ai/analyzer.js +30 -5
- package/src/ai/antigravity-provider.js +7 -6
- package/src/ai/claude-provider.js +4 -8
- package/src/ai/codex-provider.js +3 -4
- package/src/ai/index.js +2 -0
- package/src/ai/muse-provider.js +3 -4
- package/src/ai/omp-provider.js +27 -12
- package/src/ai/pi-provider.js +12 -6
- package/src/ai/prompts/baseline/consolidation/thorough.js +56 -43
- package/src/ai/prompts/baseline/level1/thorough.js +76 -138
- package/src/ai/prompts/baseline/level2/thorough.js +76 -129
- package/src/ai/prompts/baseline/level3/thorough.js +67 -212
- package/src/ai/prompts/baseline/orchestration/thorough.js +79 -130
- package/src/ai/prompts/render-for-skill.js +5 -0
- package/src/ai/prompts/shared/adversarial-verification.js +68 -0
- package/src/ai/provider.js +60 -1
- package/src/ai/stream-parser.js +22 -1
- package/src/chat/acp-bridge.js +11 -0
- package/src/chat/chat-models.js +348 -0
- package/src/chat/chat-providers.js +17 -0
- package/src/chat/claude-code-bridge.js +9 -0
- package/src/chat/codex-bridge.js +6 -1
- package/src/chat/omp-bridge.js +5 -0
- package/src/chat/pi-bridge.js +20 -5
- package/src/chat/session-manager.js +158 -63
- package/src/config.js +92 -5
- package/src/git/worktree.js +29 -10
- package/src/github/client.js +30 -10
- package/src/hooks/payloads.js +5 -1
- package/src/routes/chat.js +83 -11
- package/src/setup/pr-setup.js +54 -1
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Level 1 Thorough Prompt - Changes in Isolation Analysis (Deep Review)
|
|
4
4
|
*
|
|
5
|
-
* This is the thorough tier variant of Level 1 analysis. It is
|
|
6
|
-
*
|
|
5
|
+
* This is the thorough tier variant of Level 1 analysis. It is targeted at
|
|
6
|
+
* frontier reasoning models and is optimized for depth and precision rather
|
|
7
|
+
* than instructional breadth: it states the mission and the evidence bar,
|
|
8
|
+
* and trusts the model to know what a bug is.
|
|
7
9
|
*
|
|
8
|
-
* Tier-specific
|
|
9
|
-
* -
|
|
10
|
-
* - ADDED:
|
|
11
|
-
* - ADDED:
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
*
|
|
10
|
+
* Tier-specific design decisions:
|
|
11
|
+
* - ADDED: Mission section (depth-first hunting, no checklist padding)
|
|
12
|
+
* - ADDED: Verification standard (concrete failure scenario + refute-before-report)
|
|
13
|
+
* - ADDED: Do-not-report list (false-positive suppression)
|
|
14
|
+
* - REMOVED: Category taxonomy tutoring and reasoning-encouragement boilerplate
|
|
15
|
+
* - UNIFIED: Confidence semantics (probability the finding is real, set by
|
|
16
|
+
* verification performed) shared across all pipeline stages
|
|
15
17
|
*
|
|
16
18
|
* Section categories:
|
|
17
19
|
* - locked: Cannot be modified by variants (data integrity)
|
|
@@ -50,16 +52,11 @@ const taggedPrompt = `<section name="role" required="true" tier="thorough">
|
|
|
50
52
|
{{lineNumberGuidance}}
|
|
51
53
|
</section>
|
|
52
54
|
|
|
53
|
-
<section name="
|
|
54
|
-
##
|
|
55
|
-
|
|
56
|
-
1. Consider the context and intent behind the change
|
|
57
|
-
2. Think through edge cases and failure modes
|
|
58
|
-
3. Evaluate the severity and likelihood of the issue
|
|
59
|
-
4. Consider whether this is a genuine problem or a stylistic preference
|
|
60
|
-
5. Formulate a clear, actionable suggestion when appropriate
|
|
55
|
+
<section name="mission" required="true" tier="thorough">
|
|
56
|
+
## Mission
|
|
57
|
+
Find real defects introduced by this change. Security issues and correctness are the primary target; everything else is opportunistic.
|
|
61
58
|
|
|
62
|
-
|
|
59
|
+
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.
|
|
63
60
|
</section>
|
|
64
61
|
|
|
65
62
|
<section name="generated-files" optional="true" tier="balanced,thorough">
|
|
@@ -72,59 +69,45 @@ ONLY create suggestions for files in this list. If you cannot find issues in the
|
|
|
72
69
|
{{validFiles}}
|
|
73
70
|
</section>
|
|
74
71
|
|
|
75
|
-
<section name="
|
|
76
|
-
##
|
|
77
|
-
1
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
<section name="scope" required="true" tier="thorough">
|
|
73
|
+
## Scope
|
|
74
|
+
Level 1 reviews the change itself, as visible in the diff.
|
|
75
|
+
|
|
76
|
+
- Start by running the annotated diff tool (shown above) and reading all changes to understand the overall intent.
|
|
77
|
+
- 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.
|
|
78
|
+
- 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.
|
|
82
79
|
</section>
|
|
83
80
|
|
|
84
81
|
<section name="focus-areas" required="true" tier="thorough">
|
|
85
|
-
##
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
- Duplicated logic within the changes
|
|
115
|
-
- Overly complex or hard-to-read code
|
|
116
|
-
|
|
117
|
-
### Documentation
|
|
118
|
-
- Documentation issues visible in the changed lines
|
|
119
|
-
- Missing or incorrect comments for complex logic
|
|
120
|
-
- Outdated comments that don't match the code
|
|
121
|
-
- Missing JSDoc/docstrings for public APIs
|
|
122
|
-
|
|
123
|
-
### Good Practices
|
|
124
|
-
- Good practices worth praising and reinforcing
|
|
125
|
-
- Clean, readable implementations
|
|
126
|
-
- Thoughtful error handling
|
|
127
|
-
- Well-designed abstractions
|
|
82
|
+
## What to Hunt For
|
|
83
|
+
In priority order:
|
|
84
|
+
|
|
85
|
+
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.
|
|
86
|
+
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).
|
|
87
|
+
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.
|
|
88
|
+
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.
|
|
89
|
+
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.
|
|
90
|
+
</section>
|
|
91
|
+
|
|
92
|
+
<section name="verification-standard" required="true" tier="thorough">
|
|
93
|
+
## Verification Standard
|
|
94
|
+
Every bug or security finding must survive an attempt to kill it:
|
|
95
|
+
|
|
96
|
+
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.
|
|
97
|
+
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.
|
|
98
|
+
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.
|
|
99
|
+
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.
|
|
100
|
+
5. **Simplicity findings must show the simpler version.** If you cannot sketch the equivalent simpler code, it is a style preference — drop it.
|
|
101
|
+
</section>
|
|
102
|
+
|
|
103
|
+
<section name="do-not-report" required="true" tier="thorough">
|
|
104
|
+
## Do Not Report
|
|
105
|
+
- Pre-existing issues in code this change does not touch (unless the change makes them worse)
|
|
106
|
+
- Anything a linter or formatter would catch (formatting, import ordering, semicolons)
|
|
107
|
+
- 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
|
|
108
|
+
- Style preferences framed as defects
|
|
109
|
+
- Test coverage gaps — Level 3 evaluates testing; do not go looking for missing tests here
|
|
110
|
+
- Findings that remain below 0.3 confidence even after verification
|
|
128
111
|
</section>
|
|
129
112
|
|
|
130
113
|
<section name="available-commands" required="true" tier="thorough">
|
|
@@ -133,11 +116,10 @@ You have READ-ONLY access to the codebase. You may run commands like:
|
|
|
133
116
|
- The annotated diff tool shown above (preferred for viewing changes with line numbers)
|
|
134
117
|
- \`cat -n <file>\` to view files with line numbers
|
|
135
118
|
- ls, find, grep commands as needed
|
|
119
|
+
- If your environment provides a subagent or task-delegation tool, you may use it to verify independent findings in parallel
|
|
136
120
|
|
|
137
121
|
IMPORTANT: Do NOT modify any files. Do NOT run write commands (rm, mv, git commit, etc.).
|
|
138
122
|
Your role is strictly to analyze and report findings.
|
|
139
|
-
|
|
140
|
-
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.
|
|
141
123
|
</section>
|
|
142
124
|
|
|
143
125
|
<section name="severity-classification" required="true">
|
|
@@ -183,75 +165,28 @@ The content inside the block is the complete replacement for the commented line(
|
|
|
183
165
|
</section>
|
|
184
166
|
|
|
185
167
|
<section name="diff-instructions" required="true" tier="thorough">
|
|
186
|
-
##
|
|
187
|
-
|
|
188
|
-
- **"NEW"** (default): Use the NEW column number. This is correct for:
|
|
189
|
-
- ADDED lines marked with [+]
|
|
190
|
-
- CONTEXT lines (unchanged lines that appear in both versions)
|
|
191
|
-
- **"OLD"**: Use the OLD column number. ONLY use this for DELETED lines marked with [-].
|
|
192
|
-
|
|
193
|
-
**IMPORTANT**: Context lines exist in BOTH the old and new file - always use "NEW" for context lines.
|
|
194
|
-
Only use "OLD" when the line is prefixed with [-] indicating it was deleted.
|
|
195
|
-
|
|
196
|
-
If you are unsure, use "NEW" - it is correct for the vast majority of suggestions.
|
|
168
|
+
## old_or_new Field Reference
|
|
169
|
+
Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for DELETED lines marked with [-]. When uncertain, use "NEW".
|
|
197
170
|
</section>
|
|
198
171
|
|
|
199
172
|
<section name="confidence-guidance" required="true" tier="thorough">
|
|
200
173
|
## Confidence Calibration
|
|
201
|
-
**Confidence**
|
|
202
|
-
- High (0.8-1.0): You
|
|
203
|
-
- Medium (0.5-0.79):
|
|
204
|
-
- Low (0.3-0.49):
|
|
205
|
-
- Very low (<0.3):
|
|
206
|
-
|
|
207
|
-
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.
|
|
208
|
-
</section>
|
|
174
|
+
**Confidence** is the probability that the finding is real and correctly described:
|
|
175
|
+
- High (0.8-1.0): You verified it — traced the failing path, checked the guards, confirmed the scenario
|
|
176
|
+
- Medium (0.5-0.79): Strong evidence, but part of the failure path is unverified
|
|
177
|
+
- Low (0.3-0.49): Plausible, but depends on context or runtime behavior you could not confirm
|
|
178
|
+
- Very low (<0.3): Do not report — see Do Not Report
|
|
209
179
|
|
|
210
|
-
|
|
211
|
-
## Category Definitions
|
|
212
|
-
|
|
213
|
-
### Issue Types
|
|
214
|
-
- **bug**: Errors, crashes, or incorrect behavior. Code that will fail at runtime or produce wrong results.
|
|
215
|
-
- Example: Null pointer dereference, infinite loop, incorrect calculation
|
|
216
|
-
- **improvement**: Enhancements to make existing code better. The code works but could be cleaner or more maintainable.
|
|
217
|
-
- Example: Extract duplicated code, simplify complex conditionals
|
|
218
|
-
- **praise**: Good practices worth highlighting and reinforcing. Positive feedback for well-written code.
|
|
219
|
-
- Example: Excellent error handling, clear naming, thorough edge case coverage
|
|
220
|
-
- **suggestion**: General recommendations to consider. Ideas that may or may not be appropriate.
|
|
221
|
-
- Example: Consider using a different data structure, think about caching
|
|
222
|
-
- **design**: Architecture and structural concerns visible in the changes.
|
|
223
|
-
- Example: Violates single responsibility, unclear abstraction boundaries
|
|
224
|
-
- **performance**: Speed, memory, or efficiency optimizations.
|
|
225
|
-
- Example: O(n^2) where O(n) is possible, unnecessary allocations
|
|
226
|
-
- **security**: Vulnerabilities, safety issues, or security best practice violations.
|
|
227
|
-
- Example: SQL injection, XSS, hardcoded credentials, insecure defaults
|
|
228
|
-
- **code-style**: Formatting, naming conventions, and code style issues.
|
|
229
|
-
- Example: Inconsistent naming, missing semicolons, unusual indentation
|
|
180
|
+
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.
|
|
230
181
|
</section>
|
|
231
182
|
|
|
232
183
|
<section name="guidelines" required="true" tier="thorough">
|
|
233
|
-
##
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
- Prefer line-level comments over file-level comments when the suggestion applies to a specific line or range of lines
|
|
240
|
-
- Do not review unchanged code or missing tests
|
|
241
|
-
- Do not analyze file-level patterns or consistency
|
|
242
|
-
|
|
243
|
-
### Output Quality
|
|
244
|
-
- For "praise" type suggestions: Omit the suggestion field entirely (no action needed)
|
|
245
|
-
- For other types always include specific, actionable suggestions that the developer can implement
|
|
246
|
-
- Provide enough context in the description that a developer can understand the issue without seeing the code
|
|
247
|
-
- Avoid vague suggestions like "consider improving this" - be specific about what and how
|
|
248
|
-
|
|
249
|
-
### Review Philosophy
|
|
250
|
-
- Be constructive, not critical - the goal is to help, not to find fault
|
|
251
|
-
- Consider the developer's intent and try to understand why they made certain choices
|
|
252
|
-
- Distinguish between "must fix" issues and "nice to have" improvements
|
|
253
|
-
- When in doubt, ask a question rather than making an assumption
|
|
254
|
-
- Praise good code to reinforce positive patterns
|
|
184
|
+
## Guidelines
|
|
185
|
+
- Prefer line-level comments anchored to the exact line where the issue manifests
|
|
186
|
+
- 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
|
|
187
|
+
- Write descriptions a developer can evaluate without re-deriving your analysis: the scenario, the consequence, the fix
|
|
188
|
+
- 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
|
|
189
|
+
- 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 \`{\`
|
|
255
190
|
</section>`;
|
|
256
191
|
|
|
257
192
|
/**
|
|
@@ -264,23 +199,25 @@ const sections = [
|
|
|
264
199
|
{ name: 'custom-instructions', optional: true, tier: ['balanced', 'thorough'] },
|
|
265
200
|
{ name: 'level-header', required: true, tier: ['thorough'] },
|
|
266
201
|
{ name: 'line-number-guidance', required: true, tier: ['thorough'] },
|
|
267
|
-
{ name: '
|
|
202
|
+
{ name: 'mission', required: true, tier: ['thorough'] },
|
|
268
203
|
{ name: 'generated-files', optional: true, tier: ['balanced', 'thorough'] },
|
|
269
204
|
{ name: 'valid-files', locked: true },
|
|
270
|
-
{ name: '
|
|
205
|
+
{ name: 'scope', required: true, tier: ['thorough'] },
|
|
271
206
|
{ name: 'focus-areas', required: true, tier: ['thorough'] },
|
|
207
|
+
{ name: 'verification-standard', required: true, tier: ['thorough'] },
|
|
208
|
+
{ name: 'do-not-report', required: true, tier: ['thorough'] },
|
|
272
209
|
{ name: 'available-commands', required: true, tier: ['thorough'] },
|
|
273
210
|
{ name: 'severity-classification', required: true },
|
|
274
211
|
{ name: 'output-schema', locked: true },
|
|
275
212
|
{ name: 'diff-instructions', required: true, tier: ['thorough'] },
|
|
276
213
|
{ name: 'confidence-guidance', required: true, tier: ['thorough'] },
|
|
277
|
-
{ name: 'category-definitions', required: true, tier: ['thorough'] },
|
|
278
214
|
{ name: 'guidelines', required: true, tier: ['thorough'] }
|
|
279
215
|
];
|
|
280
216
|
|
|
281
217
|
/**
|
|
282
218
|
* Default section order for Level 1 Thorough
|
|
283
|
-
* Note:
|
|
219
|
+
* Note: mission/verification-standard/do-not-report replace the former
|
|
220
|
+
* reasoning-encouragement and category-definitions sections
|
|
284
221
|
*/
|
|
285
222
|
const defaultOrder = [
|
|
286
223
|
'role',
|
|
@@ -288,17 +225,18 @@ const defaultOrder = [
|
|
|
288
225
|
'custom-instructions',
|
|
289
226
|
'level-header',
|
|
290
227
|
'line-number-guidance',
|
|
291
|
-
'
|
|
228
|
+
'mission',
|
|
292
229
|
'generated-files',
|
|
293
230
|
'valid-files',
|
|
294
|
-
'
|
|
231
|
+
'scope',
|
|
295
232
|
'focus-areas',
|
|
233
|
+
'verification-standard',
|
|
234
|
+
'do-not-report',
|
|
296
235
|
'available-commands',
|
|
297
236
|
'severity-classification',
|
|
298
237
|
'output-schema',
|
|
299
238
|
'diff-instructions',
|
|
300
239
|
'confidence-guidance',
|
|
301
|
-
'category-definitions',
|
|
302
240
|
'guidelines'
|
|
303
241
|
];
|
|
304
242
|
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
* Level 2 Thorough Prompt - File Context Analysis (Deep Review)
|
|
4
4
|
*
|
|
5
5
|
* This is the thorough tier variant of Level 2 analysis (file context).
|
|
6
|
-
* It is
|
|
7
|
-
* and
|
|
6
|
+
* It is targeted at frontier reasoning models and is optimized for depth
|
|
7
|
+
* and precision: file conventions are treated as evidence of intent, not
|
|
8
|
+
* authority, and every finding must clear a verification bar.
|
|
8
9
|
*
|
|
9
|
-
* Tier-specific
|
|
10
|
-
* -
|
|
11
|
-
* - ADDED:
|
|
12
|
-
* - ADDED:
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
10
|
+
* Tier-specific design decisions:
|
|
11
|
+
* - KEPT: Multi-phase reasoning framework (contract -> integration -> impact)
|
|
12
|
+
* - ADDED: Conventions-as-evidence section (deviations may be improvements)
|
|
13
|
+
* - ADDED: Verification standard (failure scenarios + cited pattern lines)
|
|
14
|
+
* - ADDED: Do-not-report list (false-positive suppression)
|
|
15
|
+
* - REMOVED: Category taxonomy tutoring and per-category consistency checklists
|
|
16
|
+
* - UNIFIED: Confidence semantics shared across all pipeline stages
|
|
16
17
|
*
|
|
17
18
|
* Section categories:
|
|
18
19
|
* - locked: Cannot be modified by variants (data integrity)
|
|
@@ -51,30 +52,33 @@ const taggedPrompt = `<section name="role" required="true" tier="thorough">
|
|
|
51
52
|
{{lineNumberGuidance}}
|
|
52
53
|
</section>
|
|
53
54
|
|
|
54
|
-
<section name="reasoning-
|
|
55
|
+
<section name="reasoning-framework" required="true" tier="thorough">
|
|
55
56
|
## Reasoning Framework
|
|
56
57
|
|
|
57
58
|
For each file, build a mental model before identifying issues:
|
|
58
59
|
|
|
59
60
|
**Phase 1: Understand the File's Contract**
|
|
60
|
-
- What implicit contracts does this file establish? (error handling conventions,
|
|
61
|
-
- What invariants should be maintained? (ordering, initialization patterns, resource lifecycle)
|
|
62
|
-
- What are the file's extension points and how should new code integrate with them?
|
|
61
|
+
- What implicit contracts does this file establish? (error handling conventions, invariants, resource lifecycle, extension points)
|
|
63
62
|
|
|
64
63
|
**Phase 2: Evaluate Change Integration**
|
|
65
|
-
- How do the changes interact with existing code paths?
|
|
66
|
-
- Are there implicit dependencies
|
|
67
|
-
- Do the changes respect or violate the file's established boundaries?
|
|
64
|
+
- How do the changes interact with existing code paths in the file?
|
|
65
|
+
- Are there implicit dependencies the changes break, or related sections that should have changed together but didn't?
|
|
68
66
|
|
|
69
|
-
**Phase 3:
|
|
70
|
-
-
|
|
71
|
-
- Consider edge cases: what happens at boundaries, with null/empty inputs, under concurrent access?
|
|
72
|
-
- Think about maintenance: will a future developer understand why this code exists?
|
|
67
|
+
**Phase 3: Trace Impact**
|
|
68
|
+
- If this code runs, what happens downstream within the file? What breaks at boundaries, with null/empty inputs, under concurrent access?
|
|
73
69
|
|
|
74
70
|
**Output Calibration**
|
|
75
71
|
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.
|
|
76
72
|
</section>
|
|
77
73
|
|
|
74
|
+
<section name="conventions-as-evidence" required="true" tier="thorough">
|
|
75
|
+
## Conventions Are Evidence, Not Law
|
|
76
|
+
The file's established patterns tell you what the author intended — treat them as evidence, not authority:
|
|
77
|
+
- When a change deviates from the file's pattern accidentally, flag the deviation and cite the lines that establish the pattern to match.
|
|
78
|
+
- 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.
|
|
79
|
+
- 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.
|
|
80
|
+
</section>
|
|
81
|
+
|
|
78
82
|
<section name="generated-files" optional="true" tier="balanced,thorough">
|
|
79
83
|
{{generatedFiles}}
|
|
80
84
|
</section>
|
|
@@ -95,10 +99,10 @@ For each file with changes:
|
|
|
95
99
|
1. **Build Context First**
|
|
96
100
|
- Read the full file to understand its purpose and architecture
|
|
97
101
|
- Run the annotated diff tool with the file path to see precise line numbers
|
|
98
|
-
- Identify the file's implicit rules: How does it handle errors? What
|
|
102
|
+
- Identify the file's implicit rules: How does it handle errors? What invariants does it maintain? What patterns recur?
|
|
99
103
|
|
|
100
104
|
2. **Analyze Integration Quality**
|
|
101
|
-
- Do the changes follow or violate the file's established patterns?
|
|
105
|
+
- Do the changes follow, improve, or accidentally violate the file's established patterns?
|
|
102
106
|
- Are there related code sections that should change together but didn't?
|
|
103
107
|
- Does the change maintain the file's abstraction boundaries?
|
|
104
108
|
|
|
@@ -109,53 +113,32 @@ For each file with changes:
|
|
|
109
113
|
</section>
|
|
110
114
|
|
|
111
115
|
<section name="focus-areas" required="true" tier="thorough">
|
|
112
|
-
##
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
- Caching and memoization consistency
|
|
139
|
-
- Algorithm choices consistent with similar functions in file
|
|
140
|
-
|
|
141
|
-
### Code Quality
|
|
142
|
-
- Design pattern consistency within the file
|
|
143
|
-
- Complexity appropriate for the file's style
|
|
144
|
-
- Duplication with other code in the same file
|
|
145
|
-
- Magic numbers or hardcoded values that should use file constants
|
|
146
|
-
- Type usage consistent with file patterns
|
|
147
|
-
|
|
148
|
-
### Documentation
|
|
149
|
-
- Documentation style matching file conventions
|
|
150
|
-
- Missing documentation for changes that file's style would require
|
|
151
|
-
- Outdated comments that no longer match the changed code
|
|
152
|
-
- JSDoc/docstring consistency with other functions in file
|
|
153
|
-
|
|
154
|
-
### Good Practices
|
|
155
|
-
- Good practices worth praising in the context of file conventions
|
|
156
|
-
- Clean integration with existing code
|
|
157
|
-
- Thoughtful handling of file-specific patterns
|
|
158
|
-
- Improvements to overall file quality
|
|
116
|
+
## What to Hunt For
|
|
117
|
+
In priority order:
|
|
118
|
+
|
|
119
|
+
1. **Security regressions** — the change bypasses or omits protections the file applies elsewhere: authentication or authorization checks, input validation and sanitization, sensitive-data handling.
|
|
120
|
+
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).
|
|
121
|
+
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.
|
|
122
|
+
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.
|
|
123
|
+
5. **Praise** — at most 1-2 items, and only for integration work that is genuinely thoughtful, not routine.
|
|
124
|
+
</section>
|
|
125
|
+
|
|
126
|
+
<section name="verification-standard" required="true" tier="thorough">
|
|
127
|
+
## Verification Standard
|
|
128
|
+
- 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.
|
|
129
|
+
- 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.
|
|
130
|
+
- Record the verification you performed in the reasoning array. Set confidence by verification done, not plausibility.
|
|
131
|
+
- **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.
|
|
132
|
+
- **Simplicity findings must show the simpler version.** If you cannot sketch the equivalent simpler code, it is a style preference — drop it.
|
|
133
|
+
</section>
|
|
134
|
+
|
|
135
|
+
<section name="do-not-report" required="true" tier="thorough">
|
|
136
|
+
## Do Not Report
|
|
137
|
+
- Diff-only findings (Level 1's job) or cross-file findings (Level 3's job)
|
|
138
|
+
- Pre-existing issues in parts of the file this change neither touches nor interacts with
|
|
139
|
+
- Anything a linter or formatter would catch
|
|
140
|
+
- Consistency nits where the deviation is harmless or arguably better
|
|
141
|
+
- Findings that remain below 0.3 confidence even after verification
|
|
159
142
|
</section>
|
|
160
143
|
|
|
161
144
|
<section name="available-commands" required="true" tier="thorough">
|
|
@@ -164,11 +147,10 @@ You have READ-ONLY access to the codebase. You may run commands like:
|
|
|
164
147
|
- The annotated diff tool shown above with file path (preferred for viewing changes with line numbers)
|
|
165
148
|
- \`cat -n <file>\` to view files with line numbers
|
|
166
149
|
- grep, find, ls commands as needed
|
|
150
|
+
- If your environment provides a subagent or task-delegation tool, you may use it to examine multiple files in parallel
|
|
167
151
|
|
|
168
152
|
IMPORTANT: Do NOT modify any files. Do NOT run write commands (rm, mv, git commit, etc.).
|
|
169
153
|
Your role is strictly to analyze and report findings.
|
|
170
|
-
|
|
171
|
-
Note: You may optionally use parallel read-only Tasks to examine multiple files simultaneously if that would be helpful for a thorough analysis.
|
|
172
154
|
</section>
|
|
173
155
|
|
|
174
156
|
<section name="severity-classification" required="true">
|
|
@@ -225,40 +207,18 @@ The content inside the block is the complete replacement for the commented line(
|
|
|
225
207
|
|
|
226
208
|
<section name="diff-instructions" required="true" tier="thorough">
|
|
227
209
|
## old_or_new Field Reference
|
|
228
|
-
Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for
|
|
210
|
+
Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for DELETED lines marked with [-]. When uncertain, use "NEW".
|
|
229
211
|
</section>
|
|
230
212
|
|
|
231
213
|
<section name="confidence-guidance" required="true" tier="thorough">
|
|
232
214
|
## Confidence Calibration
|
|
233
|
-
**Confidence**
|
|
234
|
-
- High (0.8-1.0): You
|
|
235
|
-
- Medium (0.5-0.79):
|
|
236
|
-
- Low (0.3-0.49):
|
|
237
|
-
- Very low (<0.3):
|
|
215
|
+
**Confidence** is the probability that the finding is real and correctly described:
|
|
216
|
+
- High (0.8-1.0): You verified it — read the relevant file sections, confirmed the pattern or failure path
|
|
217
|
+
- Medium (0.5-0.79): Strong evidence, but part of the analysis is unverified
|
|
218
|
+
- Low (0.3-0.49): Plausible, but the file's conventions are unclear or the behavior depends on context you could not confirm
|
|
219
|
+
- Very low (<0.3): Do not report — see Do Not Report
|
|
238
220
|
|
|
239
|
-
Note: Confidence is about certainty, not severity. A
|
|
240
|
-
</section>
|
|
241
|
-
|
|
242
|
-
<section name="category-definitions" required="true" tier="thorough">
|
|
243
|
-
## Category Definitions
|
|
244
|
-
|
|
245
|
-
### Issue Types
|
|
246
|
-
- **bug**: Errors visible when considering file context. Code that will fail or behave incorrectly in the context of how the file works.
|
|
247
|
-
- Example: New function doesn't follow file's error handling pattern, causing uncaught exceptions
|
|
248
|
-
- **improvement**: Enhancements to better integrate with file patterns. The code works but could be more consistent.
|
|
249
|
-
- Example: New function uses different naming convention than rest of file
|
|
250
|
-
- **praise**: Good practices that follow file conventions. Positive feedback for well-integrated code.
|
|
251
|
-
- Example: New code follows the file's established patterns perfectly
|
|
252
|
-
- **suggestion**: General recommendations based on file context. Ideas that may improve file coherence.
|
|
253
|
-
- Example: Consider grouping this function with similar ones in the file
|
|
254
|
-
- **design**: Architecture and structural concerns within the file.
|
|
255
|
-
- Example: New class breaks single responsibility pattern established in file
|
|
256
|
-
- **performance**: Efficiency issues that deviate from file's performance patterns.
|
|
257
|
-
- Example: New code doesn't use the caching pattern used elsewhere in the file
|
|
258
|
-
- **security**: Security issues visible in file context.
|
|
259
|
-
- Example: New endpoint doesn't follow file's authentication pattern
|
|
260
|
-
- **code-style**: Formatting, naming, and style inconsistencies within the file.
|
|
261
|
-
- Example: Indentation differs from rest of file, variable naming doesn't match convention
|
|
221
|
+
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.
|
|
262
222
|
</section>
|
|
263
223
|
|
|
264
224
|
<section name="file-level-guidance" required="true" tier="thorough">
|
|
@@ -276,30 +236,11 @@ File-level suggestions have no line number - they apply to the entire file.
|
|
|
276
236
|
|
|
277
237
|
<section name="guidelines" required="true" tier="thorough">
|
|
278
238
|
## Guidelines
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
-
|
|
284
|
-
|
|
285
|
-
### Output Quality
|
|
286
|
-
- For "praise" type: Omit the suggestion field (no action needed)
|
|
287
|
-
- For other types: Include specific, actionable suggestions grounded in file context
|
|
288
|
-
- Explain why file context was needed to identify the issue
|
|
289
|
-
- Be specific about what patterns exist and how to match them
|
|
290
|
-
|
|
291
|
-
### Philosophy
|
|
292
|
-
- Be constructive - the goal is to help maintain file consistency
|
|
293
|
-
- Treat the file's established conventions as authoritative
|
|
294
|
-
- Distinguish between "must fix for consistency" and "nice to have"
|
|
295
|
-
- Lower confidence when uncertain about file conventions
|
|
296
|
-
- Praise good integration to reinforce positive practices
|
|
297
|
-
|
|
298
|
-
### Priority Order
|
|
299
|
-
1. Breaking file conventions that could cause bugs or security issues
|
|
300
|
-
2. Consistency issues affecting maintainability
|
|
301
|
-
3. Stylistic suggestions for file coherence
|
|
302
|
-
4. Praise for excellent integration
|
|
239
|
+
- Explain why file context was needed to identify each issue — that is what distinguishes a Level 2 finding
|
|
240
|
+
- Every non-praise suggestion must be actionable and grounded in the file: name the pattern, cite the lines, say what to change
|
|
241
|
+
- Priority order: contract violations that could cause bugs or security issues, then consistency issues affecting maintainability, then praise for genuinely excellent integration
|
|
242
|
+
- You are assisting a human reviewer who makes the final call. Distinguish "must fix" from "worth considering"
|
|
243
|
+
- 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 \`{\`
|
|
303
244
|
</section>`;
|
|
304
245
|
|
|
305
246
|
/**
|
|
@@ -312,24 +253,28 @@ const sections = [
|
|
|
312
253
|
{ name: 'custom-instructions', optional: true, tier: ['balanced', 'thorough'] },
|
|
313
254
|
{ name: 'level-header', required: true, tier: ['thorough'] },
|
|
314
255
|
{ name: 'line-number-guidance', required: true, tier: ['thorough'] },
|
|
315
|
-
{ name: 'reasoning-
|
|
256
|
+
{ name: 'reasoning-framework', required: true, tier: ['thorough'] },
|
|
257
|
+
{ name: 'conventions-as-evidence', required: true, tier: ['thorough'] },
|
|
316
258
|
{ name: 'generated-files', optional: true, tier: ['balanced', 'thorough'] },
|
|
317
259
|
{ name: 'valid-files', locked: true },
|
|
318
260
|
{ name: 'analysis-process', required: true, tier: ['thorough'] },
|
|
319
261
|
{ name: 'focus-areas', required: true, tier: ['thorough'] },
|
|
262
|
+
{ name: 'verification-standard', required: true, tier: ['thorough'] },
|
|
263
|
+
{ name: 'do-not-report', required: true, tier: ['thorough'] },
|
|
320
264
|
{ name: 'available-commands', required: true, tier: ['thorough'] },
|
|
321
265
|
{ name: 'severity-classification', required: true },
|
|
322
266
|
{ name: 'output-schema', locked: true },
|
|
323
267
|
{ name: 'diff-instructions', required: true, tier: ['thorough'] },
|
|
324
268
|
{ name: 'confidence-guidance', required: true, tier: ['thorough'] },
|
|
325
|
-
{ name: 'category-definitions', required: true, tier: ['thorough'] },
|
|
326
269
|
{ name: 'file-level-guidance', required: true, tier: ['thorough'] },
|
|
327
270
|
{ name: 'guidelines', required: true, tier: ['thorough'] }
|
|
328
271
|
];
|
|
329
272
|
|
|
330
273
|
/**
|
|
331
274
|
* Default section order for Level 2 Thorough
|
|
332
|
-
* Note:
|
|
275
|
+
* Note: reasoning-framework/conventions-as-evidence/verification-standard/
|
|
276
|
+
* do-not-report replace the former reasoning-encouragement and
|
|
277
|
+
* category-definitions sections
|
|
333
278
|
*/
|
|
334
279
|
const defaultOrder = [
|
|
335
280
|
'role',
|
|
@@ -337,17 +282,19 @@ const defaultOrder = [
|
|
|
337
282
|
'custom-instructions',
|
|
338
283
|
'level-header',
|
|
339
284
|
'line-number-guidance',
|
|
340
|
-
'reasoning-
|
|
285
|
+
'reasoning-framework',
|
|
286
|
+
'conventions-as-evidence',
|
|
341
287
|
'generated-files',
|
|
342
288
|
'valid-files',
|
|
343
289
|
'analysis-process',
|
|
344
290
|
'focus-areas',
|
|
291
|
+
'verification-standard',
|
|
292
|
+
'do-not-report',
|
|
345
293
|
'available-commands',
|
|
346
294
|
'severity-classification',
|
|
347
295
|
'output-schema',
|
|
348
296
|
'diff-instructions',
|
|
349
297
|
'confidence-guidance',
|
|
350
|
-
'category-definitions',
|
|
351
298
|
'file-level-guidance',
|
|
352
299
|
'guidelines'
|
|
353
300
|
];
|