@in-the-loop-labs/pair-review 5.2.2 → 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 (48) hide show
  1. package/README.md +26 -16
  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 +31 -6
  20. package/src/ai/antigravity-provider.js +62 -42
  21. package/src/ai/claude-provider.js +18 -20
  22. package/src/ai/codex-provider.js +76 -81
  23. package/src/ai/executable-provider.js +3 -1
  24. package/src/ai/index.js +2 -0
  25. package/src/ai/muse-provider.js +84 -52
  26. package/src/ai/omp-provider.js +27 -12
  27. package/src/ai/pi-provider.js +12 -6
  28. package/src/ai/prompts/baseline/consolidation/thorough.js +56 -43
  29. package/src/ai/prompts/baseline/level1/thorough.js +76 -138
  30. package/src/ai/prompts/baseline/level2/thorough.js +76 -129
  31. package/src/ai/prompts/baseline/level3/thorough.js +67 -212
  32. package/src/ai/prompts/baseline/orchestration/thorough.js +79 -130
  33. package/src/ai/prompts/render-for-skill.js +5 -0
  34. package/src/ai/prompts/shared/adversarial-verification.js +68 -0
  35. package/src/ai/provider.js +61 -2
  36. package/src/ai/stream-parser.js +22 -1
  37. package/src/chat/acp-bridge.js +11 -0
  38. package/src/chat/chat-models.js +348 -0
  39. package/src/chat/chat-providers.js +17 -0
  40. package/src/chat/claude-code-bridge.js +9 -0
  41. package/src/chat/codex-bridge.js +6 -1
  42. package/src/chat/omp-bridge.js +5 -0
  43. package/src/chat/pi-bridge.js +20 -5
  44. package/src/chat/session-manager.js +158 -63
  45. package/src/config.js +1 -1
  46. package/src/hooks/payloads.js +5 -1
  47. package/src/main.js +1 -1
  48. package/src/routes/chat.js +83 -11
@@ -2,20 +2,30 @@
2
2
  /**
3
3
  * Orchestration Thorough Prompt - Comprehensive Multi-Level Suggestion Curation
4
4
  *
5
- * This is the thorough tier variant of Orchestration analysis. It is optimized for
6
- * careful, detailed orchestration with extended reasoning and comprehensive guidance
7
- * for merging and prioritizing multi-level suggestions.
5
+ * This is the thorough tier variant of Orchestration analysis. It is targeted
6
+ * at frontier reasoning models and is optimized for evidence-weighted curation:
7
+ * confidence keeps a single pipeline-wide meaning, agreement and contradiction
8
+ * are treated as evidence rather than inputs to score arithmetic, and output
9
+ * size scales with what the PR actually contains.
8
10
  *
9
- * Tier-specific optimizations applied:
10
- * - EXTENDED: Reasoning encouragement section for thoughtful synthesis
11
- * - COMPREHENSIVE: Intelligent merging with conflict resolution and confidence combining
12
- * - COMPREHENSIVE: Priority-based curation with sub-tier reasoning and contextual adjustment
13
- * - ADDED: Confidence calibration guidance for orchestration decisions
14
- * - ADDED: Reasoning-encouragement section
15
- * - ADDED: Summary synthesis guidance (forest vs trees)
16
- * - EXPANDED: Human-centric framing with additional context
17
- * - EXPANDED: Guidelines with additional considerations and review philosophy
18
- * - INCLUDED: All optional sections including file-level-guidance
11
+ * Tier-specific design decisions:
12
+ * - ADDED: Adversarial verification, FLOW-CONDITIONAL via the
13
+ * {{adversarialVerification}} placeholder (shared text in
14
+ * ../../shared/adversarial-verification.js). Filled when this orchestration
15
+ * is the FINAL merge stage of its flow — standalone single-reviewer runs
16
+ * and the level-centric council's Pass 2 — where all sources are collected
17
+ * and overlap/conflict is visible as evidence. Passed '' when
18
+ * analyzeAllLevels runs as one voice inside a multi-voice reviewer-centric
19
+ * council (options.skipAdversarialVerification): verification there belongs
20
+ * to cross-voice consolidation, exactly once per flow, so per-voice merges
21
+ * must not pre-kill findings before cross-voice overlap is visible.
22
+ * - KEPT: Merge/contradiction handling, priority tiers, contextual priority
23
+ * adjustment, summary synthesis guidance
24
+ * - REPLACED: Confidence score arithmetic with ordinal evidence-based rules
25
+ * - REPLACED: Fixed suggestion-count target with scale-to-the-PR guidance
26
+ * - REMOVED: Reasoning-encouragement boilerplate and category balancing
27
+ * - UNIFIED: Confidence semantics (probability the finding is real) shared
28
+ * with the analysis levels
19
29
  *
20
30
  * Section categories:
21
31
  * - locked: Cannot be modified by variants (data integrity)
@@ -33,6 +43,10 @@ const { ORCHESTRATION_INPUT_SCHEMA_DOCS } = require('../../shared/output-schema'
33
43
  * - {{prContext}} - PR context section (optional, may be empty)
34
44
  * - {{customInstructions}} - Custom instructions section (optional)
35
45
  * - {{dedupInstructions}} - Dedup instructions section (optional)
46
+ * - {{adversarialVerification}} - Adversarial verification section (optional;
47
+ * filled with ADVERSARIAL_VERIFICATION_SECTION when this orchestration is
48
+ * the flow's final merge stage, '' for per-voice runs inside a multi-voice
49
+ * reviewer-centric council)
36
50
  * - {{lineNumberGuidance}} - Line number guidance section
37
51
  * - {{level1Count}} - Number of Level 1 suggestions
38
52
  * - {{level2Count}} - Number of Level 2 suggestions
@@ -59,27 +73,12 @@ const taggedPrompt = `<section name="role" required="true" tier="thorough">
59
73
 
60
74
  <section name="role-description" required="true" tier="thorough">
61
75
  ## Your Role
62
- You are helping a human reviewer by intelligently curating and merging suggestions from a 3-level analysis system. Your goal is to provide the most valuable, non-redundant guidance to accelerate the human review process while maintaining the highest quality standards.
63
-
64
- This is the orchestration layer - you are synthesizing insights from:
76
+ You are helping a human reviewer by intelligently curating and merging suggestions from a 3-level analysis system. This is the orchestration layer - you are synthesizing insights from:
65
77
  - **Level 1**: Diff-only analysis (issues visible in changed lines)
66
78
  - **Level 2**: File context analysis (issues requiring understanding of the whole file)
67
79
  - **Level 3**: Codebase context analysis (issues requiring understanding of the broader system)
68
80
 
69
- Your task is to produce a curated, thoughtful set of suggestions that represents the best insights from all three levels, merged intelligently and prioritized for maximum human reviewer value.
70
- </section>
71
-
72
- <section name="reasoning-encouragement" required="true" tier="thorough">
73
- ## Reasoning Approach
74
- Take your time to analyze and synthesize the suggestions thoroughly. For each potential issue across all levels:
75
- 1. Consider whether multiple levels identified the same or related concerns
76
- 2. Evaluate which level's framing best captures the essence of the issue
77
- 3. Think through whether combining insights adds value or creates confusion
78
- 4. Assess the confidence based on cross-level agreement and evidence strength
79
- 5. Consider how this insight will help the human reviewer make better decisions
80
- 6. Formulate clear, actionable guidance that respects reviewer autonomy
81
-
82
- Quality matters more than speed for this orchestration level. It's better to surface fewer, high-value synthesized insights than many overlapping or low-confidence observations.
81
+ Your task is to produce a curated set of suggestions representing the best insights from all three levels, merged intelligently and prioritized for maximum human reviewer value. Fewer high-value synthesized insights beat many overlapping or weakly-evidenced observations — curate, don't concatenate.
83
82
  </section>
84
83
 
85
84
  <section name="custom-instructions" optional="true" tier="balanced,thorough">
@@ -105,6 +104,10 @@ ${ORCHESTRATION_INPUT_SCHEMA_DOCS}
105
104
  {{level3Suggestions}}
106
105
  </section>
107
106
 
107
+ <section name="adversarial-verification" optional="true" tier="thorough">
108
+ {{adversarialVerification}}
109
+ </section>
110
+
108
111
  <section name="intelligent-merging" required="true" tier="thorough">
109
112
  ## Orchestration Guidelines
110
113
 
@@ -123,19 +126,20 @@ Apply careful analysis when combining suggestions across levels:
123
126
 
124
127
  **Handling Level Contradictions:**
125
128
  When levels disagree (e.g., Level 1 flags an issue that Level 3 says follows codebase patterns):
126
- - **Evaluate evidence quality**: Concrete code analysis > pattern matching > heuristics
129
+ - **Evaluate evidence quality**: Concrete code analysis with cited evidence > pattern matching > heuristics
127
130
  - **Consider scope**: Broader context (Level 3) may invalidate narrow concerns (Level 1)
128
131
  - **Weight intentionality**: If higher levels show the pattern is intentional, downgrade the concern
129
132
  - **When truly uncertain**: Include the suggestion with reduced confidence and note the tension in the description
130
133
 
131
- **Combining Confidence Scores:**
132
- - **Cross-level agreement**: If 2+ levels flag the same issue, boost confidence by 0.1-0.2
133
- - **Contradictory signals**: If levels disagree, use the lower confidence minus 0.1
134
- - **Single-level unique insight**: Preserve original confidence; don't penalize valuable unique findings
135
- - **Evidence-based adjustment**: Strong code evidence (specific line, concrete bug) > general observations
134
+ **Adjusting Confidence When Merging:**
135
+ Confidence keeps its pipeline-wide meaning: the probability the finding is real and correctly described.
136
+ - **Cross-level agreement** is strong evidence — a finding independently flagged by multiple levels warrants higher confidence than any single input assigned it
137
+ - **Contradiction** is evidence of uncertainty — lower the confidence and note the tension
138
+ - **Single-level unique insights** keep their original confidence; don't penalize valuable findings for being found once
139
+ - Set confidence from the strength of the combined evidence — never by mechanical score arithmetic
136
140
 
137
141
  **Merging Best Practices:**
138
- - Preserve the most actionable and specific details from each level
142
+ - Preserve the most actionable and specific details from each level, including concrete failure and attack scenarios and cited evidence — do not summarize an exploit description back into a code observation
139
143
  - Use the clearest framing, regardless of which level provided it
140
144
  - Do NOT mention which level found the issue - focus on the insight itself
141
145
  - When merging would lose important nuance, keep suggestions distinct
@@ -149,7 +153,7 @@ When levels disagree (e.g., Level 1 flags an issue that Level 3 says follows cod
149
153
 
150
154
  <section name="priority-curation" required="true" tier="thorough">
151
155
  ### 2. Priority-Based Curation
152
- Prioritize suggestions carefully based on impact and urgency:
156
+ Prioritize suggestions based on impact and urgency:
153
157
 
154
158
  **Critical Priority (Address First):**
155
159
  1. **Security vulnerabilities** - Authentication bypasses, injection flaws, data exposure
@@ -184,66 +188,34 @@ Adjust the base priority based on PR context:
184
188
  </section>
185
189
 
186
190
  <section name="balanced-output" required="true" tier="thorough">
187
- ### 3. Balanced Output
188
- Maintain appropriate balance in your curated suggestions:
189
-
190
- **Quantity Guidelines:**
191
- - **Limit praise suggestions** to 2-3 most noteworthy items that reinforce good practices
192
- - **Focus on actionable items** that provide clear value and specific next steps
193
- - **Avoid suggestion overload** - aim for 8-15 total suggestions for most PRs
194
- - **Include confidence scores** based on evidence strength and cross-level agreement
195
-
196
- **Quality Guidelines:**
197
- - Each suggestion should provide clear value to the reviewer
198
- - Avoid redundancy - if you've addressed an issue, don't repeat it
199
- - Be specific - vague suggestions waste reviewer time
200
- - Include context - explain why this matters, not just what to do
201
-
202
- **Balance Considerations:**
203
- - Balance between critical issues and improvement suggestions
204
- - Balance between different categories (don't focus only on style OR only on bugs)
205
- - Balance between files if multiple files are modified
206
- - Balance between being thorough and being respectful of reviewer time
191
+ ### 3. Scale Output to the PR
192
+ The right number of suggestions is a function of what is actually there — not a fixed target:
193
+ - A small, clean PR may warrant one suggestion or none. A large PR with real problems may warrant twenty. Never pad output to appear thorough, and never drop verified findings to hit a count.
194
+ - **Every suggestion must earn its place** — if it wouldn't change what the reviewer does, cut it
195
+ - **Avoid redundancy** - if you've addressed an issue, don't repeat it
196
+ - **Limit praise suggestions** to the 2-3 most noteworthy items that reinforce good practices
197
+ - **Include context** - explain why each suggestion matters, not just what to do
198
+ - **Include confidence scores** that reflect the strength of the combined evidence
207
199
  </section>
208
200
 
209
201
  <section name="human-centric-framing" required="true" tier="thorough">
210
202
  ### 4. Human-Centric Framing
211
203
  Frame all suggestions as guidance for a human reviewer, not automated mandates:
212
-
213
- **Language Principles:**
214
- - Use language like "Consider...", "You might want to review...", "Worth noting..."
215
- - Frame issues as observations, not demands
216
- - Acknowledge uncertainty where it exists
217
- - Provide reasoning, not just conclusions
218
-
219
- **Preserve Reviewer Autonomy:**
220
- - You're a pair programming partner, not an enforcer
221
- - The human reviewer has context you don't have
222
- - Some suggestions may not apply given business context
223
- - Trust the reviewer to make final decisions
224
-
225
- **Provide Helpful Context:**
226
- - Explain WHY each suggestion matters (impact, risk, etc.)
227
- - Give enough information for the reviewer to evaluate independently
228
- - Suggest specific actions when appropriate
229
- - Link related suggestions to help reviewer see patterns
230
-
231
- **Tone and Style:**
232
- - Be helpful and constructive, never critical or condescending
233
- - Acknowledge good work alongside areas for improvement
234
- - Focus on the code, not the developer
235
- - Be concise but complete
204
+ - Use language like "Consider...", "You might want to review...", "Worth noting..." - observations, not demands
205
+ - You're a pair programming partner, not an enforcer. The human reviewer has context you don't have and makes the final decisions
206
+ - Explain WHY each suggestion matters (impact, risk) with enough information for the reviewer to evaluate independently
207
+ - Acknowledge uncertainty where it exists; focus on the code, not the developer
236
208
  </section>
237
209
 
238
210
  <section name="confidence-guidance" required="true" tier="thorough">
239
211
  ## Confidence Calibration
240
- **Confidence** when curating reflects certainty the suggestion is valuable:
241
- - High (0.8-1.0): Clearly valuable insight for the reviewer
242
- - Medium (0.5-0.79): Likely helpful, worth including
243
- - Low (0.3-0.49): Marginal value, consider context
244
- - Very low (<0.3): May not add value - consider omitting
212
+ Confidence has one meaning across the pipeline: the probability that the finding is real and correctly described.
213
+ - High (0.8-1.0): Verified by a level's analysis or corroborated across levels
214
+ - Medium (0.5-0.79): Solid single-level evidence, not corroborated
215
+ - Low (0.3-0.49): Plausible but weakly evidenced — include only if the potential impact justifies human attention
216
+ - Very low (<0.3): Omit
245
217
 
246
- Note: Confidence is about certainty of value, not severity. A minor improvement suggestion can have high confidence if you're sure it's helpful.
218
+ Whether a suggestion is worth including is a separate editorial judgment — make it by dropping low-value items, not by inflating or deflating confidence scores.
247
219
  </section>
248
220
 
249
221
  <section name="summary-synthesis" required="true" tier="thorough">
@@ -324,62 +296,38 @@ When merging suggestions from multiple levels, preserve the old_or_new value fro
324
296
 
325
297
  <section name="file-level-guidance" required="true" tier="thorough">
326
298
  ## File-Level Suggestions
327
- Some input suggestions are marked as [FILE-LEVEL]. These are observations about entire files, not tied to specific lines. Handle them with special care:
328
-
329
- **Preserving File-Level Insights:**
330
- - Keep file-level suggestions in the "fileLevelSuggestions" array
331
- - File-level suggestions should NOT have a line number
332
- - Merge file-level suggestions if multiple levels identified the same file-level concern
333
-
334
- **Good Examples of File-Level Suggestions:**
335
- - Architecture concerns affecting the whole file
336
- - Missing tests for the file
337
- - Naming conventions across the file
338
- - File organization improvements
339
- - Module-level design pattern suggestions
340
- - File-wide documentation needs
341
-
342
- **When to Create File-Level Suggestions:**
343
- - The observation requires understanding the whole file
344
- - The suggestion would improve overall file coherence
345
- - The issue cannot be addressed by changing a single line
346
- - The praise applies to how well changes integrate with the file overall
347
-
348
- **Merging File-Level Suggestions:**
349
- - Combine related file-level observations from different levels
350
- - Preserve the most comprehensive and actionable framing
351
- - Use higher confidence when multiple levels agree on file-level issues
299
+ Some input suggestions are marked as [FILE-LEVEL]. These are observations about entire files, not tied to specific lines:
300
+ - Keep file-level suggestions in the "fileLevelSuggestions" array, with NO line number
301
+ - Merge file-level suggestions when multiple levels identified the same file-level concern, preserving the most comprehensive and actionable framing
302
+ - Typical file-level insights: architecture concerns affecting the whole file, missing tests, file organization, module-level design patterns, file-wide documentation needs
303
+ - Do not convert a file-level insight into a line-level suggestion (or vice versa) unless the input clearly anchors it to a specific line
352
304
  </section>
353
305
 
354
306
  <section name="guidelines" required="true" tier="thorough">
355
307
  ## Important Guidelines
356
308
 
357
309
  ### Output Quality
358
- - **Quality over quantity** - Better to have 8-12 excellent suggestions than 20 mediocre ones
359
- - **Cross-level validation** - Higher confidence for issues found in multiple levels
360
- - **Preserve actionability** - Every suggestion should give clear next steps
361
- - **Maintain context** - Don't lose important details when merging
362
- - **Be specific** - Avoid vague observations; provide concrete guidance
310
+ - **Quality over quantity** - every suggestion must be one the reviewer is glad to have seen
311
+ - **Cross-level validation** - higher confidence for issues corroborated by multiple levels
312
+ - **Preserve actionability** - every suggestion should give clear next steps, keeping concrete failure and attack scenarios and cited evidence intact
313
+ - **Maintain context** - don't lose important details when merging
314
+ - **Be specific** - avoid vague observations; provide concrete guidance
363
315
 
364
316
  ### Coverage and Scope
365
317
  - **Suggestions may target any line in modified files** - Context lines can reveal issues too
366
318
  - **Only include modified files** - Discard any suggestions for files not modified in this PR
367
319
  - **Preserve file-level insights** - Don't discard valuable file-level observations
368
- - **Balance across files** - Ensure important issues in all modified files are represented
369
-
370
- ### Review Philosophy
371
- - **Be constructive, not critical** - The goal is to help, not to find fault
372
- - **Consider the full picture** - Individual issues may be less important than overall patterns
373
- - **Respect the developer's intent** - Understand why choices were made before suggesting changes
374
- - **Acknowledge good work** - Praise reinforces positive patterns and balances criticism
375
- - **Think like a pair programmer** - You're a helpful colleague, not an automated gate
320
+ - **Cover all modified files** - Ensure real issues in every modified file are represented; do not let one noisy file crowd out the rest
376
321
 
377
322
  ### Synthesis Strategy
378
323
  - Start by identifying themes across the three levels
379
324
  - Look for issues that appear in multiple levels (high priority)
380
325
  - Identify unique insights from each level that add value
381
- - Discard redundant or low-value suggestions
326
+ - Discard redundant or weakly-evidenced suggestions
382
327
  - Ensure the final set tells a coherent story about the PR's quality
328
+
329
+ ### Reply Shape
330
+ - 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 \`{\`
383
331
  </section>`;
384
332
 
385
333
  /**
@@ -392,10 +340,10 @@ const sections = [
392
340
  { name: 'line-number-guidance', required: true, tier: ['thorough'] },
393
341
  { name: 'critical-output', locked: true },
394
342
  { name: 'role-description', required: true, tier: ['thorough'] },
395
- { name: 'reasoning-encouragement', required: true, tier: ['thorough'] },
396
343
  { name: 'custom-instructions', optional: true, tier: ['balanced', 'thorough'] },
397
344
  { name: 'dedup-instructions', optional: true },
398
345
  { name: 'input-suggestions', locked: true },
346
+ { name: 'adversarial-verification', optional: true, tier: ['thorough'] },
399
347
  { name: 'intelligent-merging', required: true, tier: ['thorough'] },
400
348
  { name: 'priority-curation', required: true, tier: ['thorough'] },
401
349
  { name: 'balanced-output', required: true, tier: ['thorough'] },
@@ -410,7 +358,8 @@ const sections = [
410
358
 
411
359
  /**
412
360
  * Default section order for Orchestration Thorough
413
- * Note: Added reasoning-encouragement and confidence-guidance sections
361
+ * Note: reasoning-encouragement removed; confidence arithmetic replaced by
362
+ * evidence-based rules inside intelligent-merging and confidence-guidance
414
363
  */
415
364
  const defaultOrder = [
416
365
  'role',
@@ -418,10 +367,10 @@ const defaultOrder = [
418
367
  'line-number-guidance',
419
368
  'critical-output',
420
369
  'role-description',
421
- 'reasoning-encouragement',
422
370
  'custom-instructions',
423
371
  'dedup-instructions',
424
372
  'input-suggestions',
373
+ 'adversarial-verification',
425
374
  'intelligent-merging',
426
375
  'priority-curation',
427
376
  'balanced-output',
@@ -14,6 +14,7 @@ const {
14
14
  buildOrchestrationLineNumberGuidance,
15
15
  } = require('./line-number-guidance');
16
16
  const { buildSparseCheckoutGuidance } = require('./sparse-checkout-guidance');
17
+ const { ADVERSARIAL_VERIFICATION_SECTION } = require('./shared/adversarial-verification');
17
18
 
18
19
  /**
19
20
  * Skill-appropriate default values for prompt placeholders.
@@ -42,6 +43,10 @@ const SKILL_DEFAULTS = {
42
43
  // Dedup instructions — empty by default (section collapses)
43
44
  dedupInstructions: '',
44
45
 
46
+ // Skill usage is a standalone (single-reviewer) run, so orchestration is
47
+ // the flow's final merge stage — the adversarial verification pass applies
48
+ adversarialVerification: ADVERSARIAL_VERIFICATION_SECTION,
49
+
45
50
  // Orchestration data markers
46
51
  level1Count: '[N]',
47
52
  level2Count: '[N]',
@@ -0,0 +1,68 @@
1
+ // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Shared Adversarial Verification section (thorough tier)
4
+ *
5
+ * One fresh-context refutation pass over collected findings, run at the FINAL
6
+ * merge stage of each analysis flow — and only there. Both the orchestration
7
+ * and consolidation thorough templates carry an optional
8
+ * {{adversarialVerification}} placeholder; what varies per flow is the gate
9
+ * that controls the fill:
10
+ *
11
+ * - Single reviewer (analyzeAllLevels) and level-centric council Pass 2
12
+ * (runCouncilAnalysis): cross-level orchestration fills the placeholder in
13
+ * orchestration/thorough.js unless options.skipAdversarialVerification is
14
+ * set (threaded analyzeAllLevels → orchestrateWithAI →
15
+ * buildOrchestrationPrompt).
16
+ * - Reviewer-centric council (runReviewerCentricCouncil): each voice's
17
+ * internal cross-level orchestration passes the skip flag — cross-voice
18
+ * consolidation is this flow's final stage and fills the same placeholder
19
+ * in consolidation/thorough.js. (The single-voice council shortcut does
20
+ * not skip: with cross-voice consolidation skipped, that voice's
21
+ * orchestration IS the final stage.)
22
+ * - Level-centric council Pass 1 (_intraLevelConsolidate) passes ''
23
+ * deliberately, so findings reach the final pass with cross-voice overlap
24
+ * and conflict intact as evidence.
25
+ *
26
+ * Why once, at the end: every adversarial pass is an independent chance to
27
+ * wrongly kill a true positive, and the verifier judges best where all
28
+ * sources' agreement and contradiction are visible. Why fresh-context: a
29
+ * reviewer's in-context self-refutation cannot flip a confidently-held
30
+ * misreading; a blank-context reader with the code open can (eval
31
+ * 2026-08-15).
32
+ *
33
+ * Contract (test-pinned): drops require positive refutation evidence;
34
+ * unverifiable findings keep their original confidence; code evidence
35
+ * outranks consensus; verification steps are appended to the reasoning
36
+ * array; repository access is READ-ONLY (the warning is a real mitigation
37
+ * layer under harnesses whose shell tool is not mechanically sandboxed,
38
+ * e.g. Pi).
39
+ *
40
+ * The wording is source-neutral ("sources") so the same text serves both
41
+ * multi-reviewer consolidation and multi-level orchestration inputs.
42
+ *
43
+ * EXECUTION IS DELIBERATELY UNMENTIONED (2026-08-19, after three failed
44
+ * experiments). This READ-ONLY text is the eval-validated optimum. An
45
+ * explicit execution BAN measurably suppressed verification (fewer
46
+ * confirmed defects, more unverifiable trivia); an explicit execution
47
+ * PERMISSION conflicted with provider flag restrictions and required
48
+ * scratch/denial/no-trace machinery with defects of its own. Silence lets
49
+ * each harness's own permission system be the entire policy: capable
50
+ * models under permissive harnesses execute when their judgment says it
51
+ * is worth it (observed, with good eval results), restricted harnesses
52
+ * enforce their limits without the prompt contradicting them. Do not make
53
+ * execution explicit in EITHER direction without A/B eval evidence.
54
+ */
55
+
56
+ const ADVERSARIAL_VERIFICATION_SECTION = `## Adversarial Verification
57
+ The analyses that produced these findings believed them; you do not have to. You are the first reader with no attachment to any finding — before merging, take a fresh, skeptical pass to weed out false positives. You have READ-ONLY access to the repository: the diff tool shown above, plus \`cat -n\`, \`ls\`, \`grep\`, and \`find\`. Do NOT modify files or run write commands.
58
+
59
+ You cannot deep-verify everything, so spend verification where it changes the outcome: bug and security findings that are high-severity, corroborated by only a single source (one reviewer or one level), or whose reasoning looks thin or generic.
60
+
61
+ 1. **Check the claim against the code.** Open the cited file at the cited line. Confirm the code actually says what the finding claims — incorrect findings frequently misquote or misread the code. A finding that misdescribes the code is refuted: drop it.
62
+ 2. **Look for the defense the finding missed.** Read the surrounding code for the guard, validation, type constraint, or caller behavior that would prevent the claimed failure. If it exists, the finding is refuted: drop it, even when multiple sources agree — independent analyses share blind spots, and code evidence outranks consensus.
63
+ 3. **Dropping requires evidence; doubt does not.** Discard a finding only when you found concrete proof it is wrong. If you could not verify it either way, keep it at its original confidence — inability to verify is not refutation.
64
+ 4. **Record what you checked.** Append your verification steps to the finding's reasoning array. A finding you verified against the code warrants higher confidence than one you merely passed through.
65
+
66
+ Do all of this before writing your reply. The reply itself is only the JSON object — no sentence announcing what you will do, no narration of what you did. The first character of your reply is \`{\`.`;
67
+
68
+ module.exports = { ADVERSARIAL_VERIFICATION_SECTION };
@@ -19,6 +19,14 @@ const { TIERS, TIER_ALIASES } = require('./prompts/config');
19
19
  // Directory containing bin scripts (git-diff-lines, etc.)
20
20
  const BIN_DIR = path.join(__dirname, '..', '..', 'bin');
21
21
 
22
+ // Timeout for the LLM JSON-extraction fallback. Generous on purpose: this
23
+ // fallback is the last line of defense before a completed analysis is thrown
24
+ // away, and thorough-tier responses can exceed 100KB — a slow reformat beats
25
+ // losing the results (eval 2026-08-18: a 60s cap timed out on a 110KB
26
+ // consolidation). Providers whose extraction CLI self-terminates (agy
27
+ // --print-timeout) budget just under this value so their own error wins.
28
+ const LLM_EXTRACTION_TIMEOUT_MS = 300000;
29
+
22
30
  /**
23
31
  * Quote shell-sensitive arguments for safe shell execution.
24
32
  * Any arg containing characters that could be interpreted by the shell
@@ -299,7 +307,7 @@ ${rawResponse}
299
307
  let stdout = '';
300
308
  let stderr = '';
301
309
  let settled = false;
302
- const timeout = 60000; // 60 second timeout for extraction
310
+ const timeout = LLM_EXTRACTION_TIMEOUT_MS;
303
311
 
304
312
  // Detaching is centralized here so it ALWAYS runs when this call returns,
305
313
  // including via the timeout path that settles before the child exits.
@@ -496,6 +504,20 @@ function normalizeTier(tier) {
496
504
  /**
497
505
  * Infer default values for a model definition
498
506
  * Fills in missing optional fields based on id and tier
507
+ *
508
+ * A model definition (built-in or `providers.<id>.models` entry) may carry:
509
+ * - `id` (required) — canonical, config/URL-safe slug
510
+ * - `tier` (required) — fast | balanced | thorough | premium (aliases normalized here)
511
+ * - `aliases` — alternate selectors that resolve to this model
512
+ * - `name` / `tagline` / `description` / `badge` / `badgeClass` — picker display metadata
513
+ * - `cli_model` — exact `--model` string; `null` suppresses the flag (see
514
+ * {@link resolveCliModelConfig})
515
+ * - `extra_args` / `env` — extra CLI flags and environment for this model
516
+ * - `supports_chat` — defaults to true when absent. Set `false` for an analysis-only
517
+ * entry (e.g. a pseudo-model whose `extra_args` load a review skill): it stays in the
518
+ * analysis catalog but is hidden from the chat model picker, and a chat selector
519
+ * naming it degrades to the provider default. See `src/chat/chat-models.js`.
520
+ *
499
521
  * @param {Object} model - Model definition with at least id and tier
500
522
  * @returns {Object} - Model definition with inferred defaults
501
523
  * @throws {Error} If tier is missing or invalid
@@ -529,6 +551,41 @@ function inferModelDefaults(model) {
529
551
  };
530
552
  }
531
553
 
554
+ /**
555
+ * Resolve the CLI model string for a model, given its built-in definition and the
556
+ * matching per-model config override.
557
+ *
558
+ * This is the single `cli_model` precedence ladder shared by every provider that
559
+ * decouples the app-level model id from the CLI `--model` argument (Claude, Codex,
560
+ * Pi/OMP, and the chat resolver in `src/chat/chat-models.js`). It deliberately tests
561
+ * `!== undefined` rather than truthiness so the two meaningful non-string values
562
+ * survive:
563
+ * - `undefined` (absent): fall through to the next rung.
564
+ * - `null`: explicitly suppress the model flag — the provider uses its own default.
565
+ * - `''`: passes through so the CLI surfaces its own error rather than us guessing.
566
+ *
567
+ * Precedence: per-model config override > built-in definition > the model id itself.
568
+ *
569
+ * Note: `mergeModels` replaces a matched built-in *wholesale*, so a partial config
570
+ * override (e.g. `{ id, tier, name }`) erases `cli_model`/`env`/`extra_args` on the
571
+ * merged entry. Runtime resolution must therefore always run this ladder against the
572
+ * SEPARATE built-in and config-override definitions, never against a merged entry.
573
+ *
574
+ * @param {Object|null|undefined} builtIn - Built-in model definition, if any
575
+ * @param {Object|null|undefined} configModel - Matching `providers.<id>.models` entry, if any
576
+ * @param {string} modelId - Model id to fall back to
577
+ * @returns {string|null} CLI model string, or null when the model flag is suppressed
578
+ */
579
+ function resolveCliModelConfig(builtIn, configModel, modelId) {
580
+ if (configModel?.cli_model !== undefined) {
581
+ return configModel.cli_model;
582
+ }
583
+ if (builtIn?.cli_model !== undefined) {
584
+ return builtIn.cli_model;
585
+ }
586
+ return modelId;
587
+ }
588
+
532
589
  /**
533
590
  * Match a model definition against a selector that may be the model's canonical
534
591
  * id OR one of its aliases. Used by config-driven selectors (`default_model`,
@@ -1097,7 +1154,7 @@ async function testProviderAvailability(providerId, timeoutMs) {
1097
1154
  * model IDs (e.g. `gpt-5.4` before reasoning-effort variants were introduced)
1098
1155
  * still resolve their tier for historical analysis runs.
1099
1156
  * @param {string} providerId - Provider ID (e.g., 'claude', 'antigravity')
1100
- * @param {string} modelId - Model ID (e.g., 'sonnet', 'gemini-3.1-pro-low')
1157
+ * @param {string} modelId - Model ID (e.g., 'sonnet', 'gemini-3.8-flash-high')
1101
1158
  * @returns {string|null} Tier name or null if provider or model not found
1102
1159
  */
1103
1160
  function getTierForModel(providerId, modelId) {
@@ -1116,6 +1173,7 @@ function getTierForModel(providerId, modelId) {
1116
1173
 
1117
1174
  module.exports = {
1118
1175
  AIProvider,
1176
+ LLM_EXTRACTION_TIMEOUT_MS,
1119
1177
  MODEL_TIERS,
1120
1178
  quoteShellArgs,
1121
1179
  registerProvider,
@@ -1134,6 +1192,7 @@ module.exports = {
1134
1192
  getProviderConfigOverrides,
1135
1193
  inferModelDefaults,
1136
1194
  resolveDefaultModel,
1195
+ resolveCliModelConfig,
1137
1196
  modelMatches,
1138
1197
  mergeModels,
1139
1198
  applyModelOverrides,
@@ -50,7 +50,7 @@ function stripPathPrefix(filePath, cwdPrefix) {
50
50
  * Extract a human-readable detail string from tool input/arguments.
51
51
  * Shared across all provider-specific line parsers.
52
52
  *
53
- * Priority: command > description > file_path/filePath/path
53
+ * Priority: command > description > task > tasks[] > file_path/filePath/path
54
54
  *
55
55
  * @param {Object|string|null} input - Tool input (object or JSON string)
56
56
  * @param {string} [cwd] - Working directory to strip from file paths
@@ -75,6 +75,27 @@ function extractToolDetail(input, cwd) {
75
75
  if (parsed.description) return parsed.description;
76
76
  if (parsed.task) return parsed.task;
77
77
 
78
+ // OMP's built-in `task` tool takes { context, tasks: [...] }. Summarize the
79
+ // first task and note how many others were dispatched alongside it.
80
+ if (Array.isArray(parsed.tasks) && parsed.tasks.length > 0) {
81
+ const first = parsed.tasks[0];
82
+ let label = '';
83
+ if (typeof first === 'string') {
84
+ label = first;
85
+ } else if (first && typeof first === 'object') {
86
+ for (const field of ['description', 'task', 'prompt', 'name', 'title']) {
87
+ if (typeof first[field] === 'string' && first[field].trim()) {
88
+ label = first[field].trim();
89
+ break;
90
+ }
91
+ }
92
+ }
93
+ if (label) {
94
+ const extra = parsed.tasks.length - 1;
95
+ return extra > 0 ? `${label} (+${extra} more)` : label;
96
+ }
97
+ }
98
+
78
99
  // File path (various field naming conventions)
79
100
  const rawPath = parsed.file_path || parsed.filePath || parsed.path;
80
101
  if (rawPath) return cwd ? stripPathPrefix(rawPath, cwd) : rawPath;
@@ -42,6 +42,9 @@ class AcpBridge extends EventEmitter {
42
42
  * @param {string[]} [options.acpArgs] - Extra CLI args (default: ['--acp', '--stdio'])
43
43
  * @param {Object} [options.env] - Extra env vars for subprocess
44
44
  * @param {boolean} [options.useShell] - Use shell mode for multi-word commands
45
+ * @param {string[]} [options.extraArgs] - Model-level catalog args. ACP has no argv
46
+ * model surface (the model goes through `unstable_setSessionModel`), so these are
47
+ * accepted and ignored with a debug log rather than silently dropped.
45
48
  * @param {string} [options.resumeSessionId] - ACP session ID to resume via loadSession
46
49
  * @param {Object} [options._deps] - Dependency injection for testing
47
50
  */
@@ -55,6 +58,14 @@ class AcpBridge extends EventEmitter {
55
58
  this.env = options.env || {};
56
59
  this.useShell = options.useShell || false;
57
60
  this.resumeSessionId = options.resumeSessionId || null;
61
+ this.extraArgs = options.extraArgs || [];
62
+
63
+ if (this.extraArgs.length > 0) {
64
+ logger.debug(
65
+ `[AcpBridge] Ignoring ${this.extraArgs.length} model-level extra arg(s) ` +
66
+ `(${this.extraArgs.join(' ')}): ACP exposes no argv model surface.`
67
+ );
68
+ }
58
69
 
59
70
  this._deps = { ...defaults, ...options._deps };
60
71
  this._process = null;