cc-reviewer 5.4.0 → 6.1.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ claude mcp add -s user cc-reviewer -- npx -y cc-reviewer
11
11
 
12
12
  **Step 2: Restart Claude Code**
13
13
 
14
- The MCP tools and slash commands (`/codex-review`, `/gemini-review`, `/multi-review`) are automatically installed.
14
+ The MCP tools and slash commands (`/multi-review`, `/multi-consult`) are automatically installed.
15
15
 
16
16
  **Manual command install** (if needed):
17
17
  ```bash
@@ -51,11 +51,9 @@ gemini # follow auth prompts
51
51
 
52
52
  These tools provide **external second-opinion reviews** from Codex and Gemini CLIs. They are designed to complement Claude Code's native review capabilities, not replace them.
53
53
 
54
- **Review tools** (external second-opinion on your work):
55
- - `/codex-review` or "review with codex" - Get external Codex review
56
- - `/codex-xhigh-review` - Deep-thinking Codex review with xhigh reasoning
57
- - `/gemini-review` or "review with gemini" - Get external Gemini review
58
- - `/multi-review` - Get parallel reviews from both CLIs
54
+ **Slash commands:**
55
+ - `/multi-review` - Parallel standard + adversarial reviews from all available CLIs (Codex, Gemini, Claude). For reviewing CC-produced work (plan, findings, code).
56
+ - `/multi-consult` - Ask all CLIs the same question and synthesize their answers. For consultation/Q&A — what's the best approach, how to solve X.
59
57
 
60
58
  **For regular reviews:** Just say "review" and Claude Code will use its native capabilities. These external tools are only invoked when explicitly requested.
61
59
 
@@ -64,18 +62,17 @@ These tools provide **external second-opinion reviews** from Codex and Gemini CL
64
62
  These commands are available after restart:
65
63
 
66
64
  ```bash
67
- /codex-review # Review with Codex
68
- /codex-review security # Focus on security
69
- /codex-xhigh-review # Codex with xhigh reasoning effort
70
- /gemini-review # Review with Gemini
71
- /gemini-review architecture # Focus on architecture
72
- /multi-review # Both models in parallel
65
+ /multi-review # Parallel standard + adversarial reviews from all CLIs
66
+ /multi-review focus on race conditions # Steer the adversarial focus
67
+ /multi-consult <question> # Ask all CLIs and synthesize
68
+ /multi-consult <question> [flex] # Use Codex flex tier (cheaper/slower)
73
69
  ```
74
70
 
75
71
  ## How It Works
76
72
 
77
73
  ```
78
- CC does work → User: /codex-review → External CLI reviews → CC synthesizes → Updated output
74
+ CC does work → User: /multi-review → External CLIs review → CC synthesizes → Final output
75
+ User has a question → User: /multi-consult → External CLIs answer → CC synthesizes → Consolidated answer
79
76
  ```
80
77
 
81
78
  **Key Principles:**
@@ -98,13 +95,12 @@ CC does work → User: /codex-review → External CLI reviews → CC synthesizes
98
95
 
99
96
  ## MCP Tools
100
97
 
101
- The plugin exposes three MCP tools:
98
+ The plugin exposes two MCP tools:
102
99
 
103
100
  | Tool | Description |
104
101
  |------|-------------|
105
- | `codex_review` | Get Codex review (correctness, edge cases, performance) |
106
- | `gemini_review` | Get Gemini review (design patterns, scalability, tech debt) |
107
- | `multi_review` | Parallel review from both models |
102
+ | `multi_review` | Parallel standard + adversarial review from all available CLIs (Codex, Gemini, Claude). Requires `ccOutput`. |
103
+ | `multi_consult` | Ask all available CLIs the same question and receive a 5-section structured response per model. For consultation/Q&A. |
108
104
 
109
105
  ## Output Format
110
106
 
@@ -0,0 +1,109 @@
1
+ # Multi Consult
2
+
3
+ Ask Codex, Gemini, and Claude (Opus, fresh context) the same question in parallel and synthesize their answers. Use this for **consultation** — finding the best approach, weighing alternatives, getting a panel's take. NOT for reviewing work CC has already done (use `/multi-review` for that).
4
+
5
+ ## Arguments
6
+ - `$ARGUMENTS` — the question itself, optional steering, or both
7
+
8
+ ## When to Use
9
+
10
+ Use `/multi-consult` when you have a question or problem and want a synthesized panel opinion. The panel responds in a fixed 5-section structure (Recommendation / Reasoning / Tradeoffs / Risks / Open questions). CC reads all three responses and presents one consolidated answer with a "Models said:" provenance footer.
11
+
12
+ ## Examples
13
+
14
+ ```
15
+ /multi-consult Should we use Postgres or DynamoDB for a write-heavy timeseries workload?
16
+ /multi-consult How should I refactor the auth middleware? Focus on rollback safety.
17
+ /multi-consult What's the cleanest way to memoize this expensive selector? [flex]
18
+ ```
19
+
20
+ ## Before Calling - PREPARE THE HANDOFF
21
+
22
+ ### 1. Pre-compose the question
23
+
24
+ **`$ARGUMENTS` parsing rule (pinned):**
25
+
26
+ - **If conversation context already contains the question CC has been working on:** compose `question` from that context. `$ARGUMENTS` is treated as pure steering — extract reserved tokens (see below) into schema fields; remainder goes into `customPrompt`.
27
+ - **Otherwise — `$ARGUMENTS` IS the literal question.** Set `customPrompt` to empty. Reserved tokens are extracted *only* when they appear at the *end* of `$ARGUMENTS` inside brackets or parens — e.g., `... [flex]`, `... (high reasoning)`. A bare occurrence of `flex` / `cheap` / `default tier` inside the prose is treated as part of the question, NOT a flag, to avoid corrupting questions like *"Should we offer a flex tier or default tier for customers?"*.
28
+
29
+ ### 2. Triage code-grounded questions
30
+
31
+ If the question references the codebase, populate `relevantFiles` with the minimal subset (3-10 files typically) the panel needs. For purely general questions ("Postgres vs Mongo for X workload?"), omit `relevantFiles` — the panel will answer from expertise without trawling the filesystem.
32
+
33
+ ### 3. Refuse sensitive working directories
34
+
35
+ If the current working directory is `/etc`, `~`, `~/.ssh`, or any other clearly sensitive system path, **refuse**. Tell the user: "Please invoke `/multi-consult` from a project root — `<cwd>` looks sensitive." Do not call the tool.
36
+
37
+ ### 4. Extract criteria; clarify load-bearing assumptions BEFORE calling
38
+
39
+ Pin what the question is being judged against. Once criteria are explicit, the panel's recommendation is anchored to them instead of floating — this is the fix for "ask twice, get a different answer." Stochastic re-runs converge much better against fixed criteria than against an under-specified question.
40
+
41
+ **4a. Append a CRITERIA block to the end of `question`**, priority-ordered, each tagged `[stated]` or `[assumed]`:
42
+
43
+ ```
44
+ CRITERIA (priority order):
45
+ 1. [stated] cost-per-request under $X / 1M ops
46
+ 2. [stated] team writes Go; minimize ops complexity
47
+ 3. [assumed] sustained ~10k QPS write rate
48
+ 4. [assumed] eventual consistency acceptable for analytics
49
+ ```
50
+
51
+ - `[stated]` = explicit in the user's message or earlier conversation.
52
+ - `[assumed]` = you needed to fix it to recommend; the user did NOT say.
53
+ - Cap `[assumed]` at 3. If the top 3 don't fit, the question is too vague — bounce back to the user before calling.
54
+
55
+ **4b. Pre-call clarification gate.** Scan your `[assumed]` criteria. If any is **load-bearing** (the recommendation would flip if the assumption is wrong), STOP and ask the user before invoking the tool:
56
+
57
+ > "Before I consult the panel, I need to confirm: <restate assumption>. Is that right, or should I adjust to <plausible alternative>?"
58
+
59
+ A burned panel call on a wrong assumed criterion costs more than the round-trip.
60
+
61
+ **Skip the gate when:**
62
+ - `[stated]` criteria fully pin the answer space (no assumptions needed).
63
+ - The user told you to proceed without clarification.
64
+ - Remaining assumptions are clearly incidental (would not flip the rec).
65
+
66
+ ## Tool Invocation
67
+
68
+ Call `multi_consult` with:
69
+
70
+ ```json
71
+ {
72
+ "workingDir": "<current directory>",
73
+ "question": "<CC-composed question OR literal $ARGUMENTS minus end-bracket reserved tokens>",
74
+ "relevantFiles": ["<file1>", "<file2>"],
75
+ "customPrompt": "<steering text or empty>"
76
+ }
77
+ ```
78
+
79
+ ### Reserved-token mappings (only when bracketed at end of $ARGUMENTS)
80
+
81
+ - `[flex]` / `[cheap]` / `[budget]` → `serviceTier: "flex"`
82
+ - `[default tier]` / `[standard tier]` → `serviceTier: "default"`
83
+ - `[high reasoning]` → `reasoningEffort: "high"` (overrides default `xhigh`)
84
+
85
+ If the user types one of these mid-question (not in brackets), leave it in the question.
86
+
87
+ ## After Receiving the Panel
88
+
89
+ You will receive each model's structured 5-section response. Some may carry a `⚠️ Format drift: missing sections [...]` marker — degrade synthesis confidence accordingly for that model.
90
+
91
+ ### Synthesize
92
+
93
+ 1. **Cross-compare Recommendations.** Agreement across all three → high confidence. 2-vs-1 split → take a side and *surface the dissent explicitly* in your answer (don't flatten it). All three disagree → present the tradeoff space honestly and pick.
94
+ 2. **Mine Tradeoffs and Risks.** Even when models agree on the recommendation, the *reasons* and *risks* often diverge — surface the union, not just the intersection. If a single model raised a Risk the others missed, surface it as "1 model raised: …" — *do not silently drop it.*
95
+ 3. **Forward Open questions** to the user only if material — do not dump every "what's your scale?" clarifier.
96
+ 4. **Apply your own judgment.** You have full conversation context the panel does not; you may dismiss panel suggestions that miss the user's actual constraint, but say so explicitly when overriding.
97
+ 5. **Respond with one consolidated answer**, structured as: **Recommendation** (what to do) → **Why** (synthesis of reasoning) → **Watch out for** (consolidated risks, including any single-model-only risks) → optional **Open question for you** if a real ambiguity blocks the answer.
98
+ 6. **Append a "Models said:" provenance footer** — a single line per model with the recommendation in <80 chars. Example:
99
+
100
+ ```
101
+ ---
102
+ **Models said:** Codex → Postgres + read replicas. Gemini → Postgres + Citus. Claude → DynamoDB w/ caveat on cost at scale.
103
+ ```
104
+
105
+ This is **non-negotiable**. The footer is the audit trail; without it, synthesis-only is opaque.
106
+ 7. **Do NOT paste full raw model outputs to the user** unless they explicitly ask ("show me what each model said", "raw").
107
+ 8. **All-failed special case:** if the header is `❌ All Failed`, surface the failure types and **ASK** the user *"Panel unavailable — want my solo answer instead?"*. **Do NOT silently substitute** your own answer for the panel's.
108
+
109
+ $ARGUMENTS
@@ -23,17 +23,27 @@ Use `/multi-review` when you want thorough parallel reviews from all available m
23
23
 
24
24
  ## Before Calling - PREPARE THE HANDOFF
25
25
 
26
- ### 1. Summarize What You Did (Brief!)
26
+ ### 1. Summarize What You Did + State the Acceptance Bar
27
+
28
+ Don't just say what you did — also state the bar the work needs to clear. The bar is what lets reviewers calibrate "material" vs "nice to have." Without it, reviewers default to general code-quality vibes, which produces drift across runs.
29
+
27
30
  ```
28
- "Implemented caching layer for the product catalog API using Redis.
29
- Added cache invalidation on product updates."
31
+ "Implemented caching layer for the product catalog API using Redis with cache invalidation on product updates.
32
+ Bar: safe under concurrent updates (no stale reads on the next request) AND p95 read latency under 50ms."
30
33
  ```
31
34
 
32
- ### 2. List Your Uncertainties
35
+ ### 2. List Your Uncertainties — Tag Load-Bearing vs Incidental
36
+
37
+ Tag each uncertainty:
38
+ - `[load-bearing]` = if your assumption here is wrong, the work is NOT shipping-ready
39
+ - `[incidental]` = nice to verify but won't block ship
40
+
41
+ Reviewers prioritize accordingly, and your synthesis can elevate `[load-bearing]` items above stylistic findings.
42
+
33
43
  ```
34
44
  UNCERTAINTIES:
35
- - "Is the cache TTL appropriate for this data?"
36
- - "Does the invalidation handle all update scenarios?"
45
+ - [load-bearing] "Is the cache invalidation race-free under concurrent updates?"
46
+ - [incidental] "Is the TTL value optimal could it be 60s instead of 30s?"
37
47
  ```
38
48
 
39
49
  ### 3. Ask Specific Questions
@@ -43,6 +53,16 @@ QUESTIONS:
43
53
  - "Is there a race condition in the invalidation logic?"
44
54
  ```
45
55
 
56
+ ### 4. Identify Decisions You Made
57
+
58
+ If you chose between alternatives — caching strategy, retry policy, error-handling shape, schema design, etc. — list them with rationale. The handoff schema's `decisions[]` field gives the adversarial reviewer a concrete hook to attack the design choice rather than just hunt for bugs. Skip if the change is a straightforward bug fix with no design choice involved.
59
+
60
+ ```
61
+ DECISIONS:
62
+ 1. Chose write-through cache over write-behind. Rationale: stronger read-after-write consistency at the cost of slightly slower writes; we prioritize correctness for catalog data.
63
+ 2. Chose 30s TTL with explicit invalidation on update. Rationale: TTL bounds staleness if invalidation misses; explicit invalidation catches the common path immediately.
64
+ ```
65
+
46
66
  ## Tool Invocation
47
67
 
48
68
  Call `multi_review` with:
@@ -67,14 +87,19 @@ Call `multi_review` with:
67
87
  ```
68
88
  SUMMARY:
69
89
  <what you did, 1-3 sentences>
90
+ Bar: <what counts as shipping-ready — concrete acceptance criteria>
70
91
 
71
92
  UNCERTAINTIES (verify these):
72
- 1. <uncertainty>
73
- 2. <uncertainty>
93
+ 1. [load-bearing|incidental] <uncertainty>
94
+ 2. [load-bearing|incidental] <uncertainty>
74
95
 
75
96
  QUESTIONS:
76
97
  1. <question>
77
98
 
99
+ DECISIONS:
100
+ 1. <choice>. Rationale: <why this over alternatives>
101
+ 2. <choice>. Rationale: <why this over alternatives>
102
+
78
103
  PRIORITY FILES:
79
104
  - <file>
80
105
  ```
@@ -44,6 +44,21 @@ export interface ReviewRequest {
44
44
  /** Review mode: standard finds bugs, adversarial challenges assumptions */
45
45
  reviewMode?: 'standard' | 'adversarial';
46
46
  }
47
+ export interface ConsultRequest {
48
+ /** Working directory containing the code (always passed) */
49
+ workingDir: string;
50
+ /** CC-composed, self-contained question for the panel */
51
+ question: string;
52
+ /** CC-triaged file subset for code-grounded questions; omitted on general questions */
53
+ relevantFiles?: string[];
54
+ /** Free-form steering from $ARGUMENTS */
55
+ customPrompt?: string;
56
+ /** Reasoning effort (Codex). Default 'xhigh' for consult (deeper questions). */
57
+ reasoningEffort?: ReasoningEffort;
58
+ /** Service tier (Codex). Same defaulting rules as ReviewRequest. */
59
+ serviceTier?: ServiceTier;
60
+ }
61
+ export type ConsultResult = ReviewResult;
47
62
  /** @deprecated Use handoff.ts roles instead */
48
63
  export interface ExpertRole {
49
64
  name: string;
@@ -87,6 +102,8 @@ export interface ReviewerAdapter {
87
102
  isAvailable(): Promise<boolean>;
88
103
  /** Run a review and return structured output */
89
104
  runReview(request: ReviewRequest): Promise<ReviewResult>;
105
+ /** Run a consultation (Q&A) — required on every adapter. */
106
+ runConsult(request: ConsultRequest): Promise<ConsultResult>;
90
107
  /**
91
108
  * Optional: Run peer review of another model's output
92
109
  * Future capability - not currently implemented by any adapter
@@ -10,7 +10,7 @@
10
10
  * 2. --disallowed-tools (write tools explicitly blocked)
11
11
  * 3. Handoff prompt (explicit READ-ONLY instruction)
12
12
  */
13
- import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult } from './base.js';
13
+ import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult, ConsultRequest, ConsultResult } from './base.js';
14
14
  export declare class ClaudeAdapter implements ReviewerAdapter {
15
15
  readonly id = "claude";
16
16
  getCapabilities(): ReviewerCapabilities;
@@ -20,5 +20,6 @@ export declare class ClaudeAdapter implements ReviewerAdapter {
20
20
  private handleException;
21
21
  private categorizeError;
22
22
  private getSuggestion;
23
+ runConsult(request: ConsultRequest): Promise<ConsultResult>;
23
24
  }
24
25
  export declare const claudeAdapter: ClaudeAdapter;
@@ -16,6 +16,7 @@ import { registerAdapter, } from './base.js';
16
16
  import { CliExecutor } from '../executor.js';
17
17
  import { ClaudeEventDecoder } from '../decoders/index.js';
18
18
  import { buildSimpleHandoff, buildHandoffPrompt, buildAdversarialHandoffPrompt, selectRole, } from '../handoff.js';
19
+ import { buildConsultPrompt } from '../consult-prompt.js';
19
20
  import { getConfig } from '../config.js';
20
21
  // Write tools explicitly blocked as defense-in-depth
21
22
  const DISALLOWED_TOOLS = 'Edit Write NotebookEdit';
@@ -76,7 +77,7 @@ export class ClaudeAdapter {
76
77
  return {
77
78
  success: false,
78
79
  error: { type: 'cli_error', message: 'Claude returned empty response' },
79
- suggestion: 'Try again or use /codex-review instead',
80
+ suggestion: 'Try again or use /multi-review instead',
80
81
  executionTimeMs: Date.now() - startTime,
81
82
  };
82
83
  }
@@ -153,7 +154,7 @@ export class ClaudeAdapter {
153
154
  }
154
155
  if (err.message === 'TIMEOUT') {
155
156
  return { success: false, error: { type: 'timeout', message: 'Claude timed out — no events received' },
156
- suggestion: 'Try a smaller scope or use /codex-review', executionTimeMs: Date.now() - startTime };
157
+ suggestion: 'Try a smaller scope or use /multi-review', executionTimeMs: Date.now() - startTime };
157
158
  }
158
159
  if (err.message === 'MAX_TIMEOUT') {
159
160
  return { success: false, error: { type: 'timeout', message: 'Task exceeded 60 minute maximum' },
@@ -173,12 +174,43 @@ export class ClaudeAdapter {
173
174
  }
174
175
  getSuggestion(error) {
175
176
  switch (error.type) {
176
- case 'rate_limit': return 'Wait and retry, or use /codex-review or /gemini-review instead';
177
+ case 'rate_limit': return 'Wait and retry, or use /multi-review instead';
177
178
  case 'auth_error': return 'Run `claude auth` to authenticate';
178
179
  case 'cli_not_found': return 'Install Claude Code: https://docs.anthropic.com/en/docs/claude-code';
179
180
  default: return 'Check the error message and try again';
180
181
  }
181
182
  }
183
+ async runConsult(request) {
184
+ const startTime = Date.now();
185
+ if (!existsSync(request.workingDir)) {
186
+ return {
187
+ success: false,
188
+ error: { type: 'cli_error', message: `Working directory does not exist: ${request.workingDir}` },
189
+ suggestion: 'Check that the working directory path is correct',
190
+ executionTimeMs: Date.now() - startTime,
191
+ };
192
+ }
193
+ try {
194
+ const prompt = buildConsultPrompt(request);
195
+ const result = await this.runCli(prompt, request.workingDir);
196
+ if (result.exitCode !== 0) {
197
+ const error = this.categorizeError(result.stderr);
198
+ return { success: false, error, suggestion: this.getSuggestion(error), executionTimeMs: Date.now() - startTime };
199
+ }
200
+ if (!result.stdout.trim()) {
201
+ return {
202
+ success: false,
203
+ error: { type: 'cli_error', message: 'Claude returned empty response' },
204
+ suggestion: 'Try again or use /multi-review instead',
205
+ executionTimeMs: Date.now() - startTime,
206
+ };
207
+ }
208
+ return { success: true, output: result.stdout, executionTimeMs: Date.now() - startTime };
209
+ }
210
+ catch (error) {
211
+ return this.handleException(error, startTime);
212
+ }
213
+ }
182
214
  }
183
215
  // Register the adapter
184
216
  registerAdapter(new ClaudeAdapter());
@@ -5,7 +5,7 @@
5
5
  * Returns raw text — no JSON parsing or schema enforcement.
6
6
  * CC handles interpretation of the reviewer's response.
7
7
  */
8
- import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult } from './base.js';
8
+ import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult, ConsultRequest, ConsultResult } from './base.js';
9
9
  export declare class CodexAdapter implements ReviewerAdapter {
10
10
  readonly id = "codex";
11
11
  getCapabilities(): ReviewerCapabilities;
@@ -15,5 +15,6 @@ export declare class CodexAdapter implements ReviewerAdapter {
15
15
  private handleException;
16
16
  private categorizeError;
17
17
  private getSuggestion;
18
+ runConsult(request: ConsultRequest): Promise<ConsultResult>;
18
19
  }
19
20
  export declare const codexAdapter: CodexAdapter;
@@ -11,6 +11,7 @@ import { registerAdapter, } from './base.js';
11
11
  import { CliExecutor } from '../executor.js';
12
12
  import { CodexEventDecoder } from '../decoders/index.js';
13
13
  import { buildSimpleHandoff, buildHandoffPrompt, buildAdversarialHandoffPrompt, selectRole, } from '../handoff.js';
14
+ import { buildConsultPrompt } from '../consult-prompt.js';
14
15
  import { getConfig } from '../config.js';
15
16
  // =============================================================================
16
17
  // CODEX ADAPTER
@@ -70,7 +71,7 @@ export class CodexAdapter {
70
71
  return {
71
72
  success: false,
72
73
  error: { type: 'cli_error', message: 'Codex returned empty response' },
73
- suggestion: 'Try again or use /gemini-review instead',
74
+ suggestion: 'Try again or use /multi-review instead',
74
75
  executionTimeMs: Date.now() - startTime,
75
76
  };
76
77
  }
@@ -154,7 +155,7 @@ export class CodexAdapter {
154
155
  }
155
156
  if (err.message === 'TIMEOUT') {
156
157
  return { success: false, error: { type: 'timeout', message: 'Codex timed out — no events received' },
157
- suggestion: 'Try a smaller scope or use /gemini-review', executionTimeMs: Date.now() - startTime };
158
+ suggestion: 'Try a smaller scope or use /multi-review', executionTimeMs: Date.now() - startTime };
158
159
  }
159
160
  if (err.message === 'MAX_TIMEOUT') {
160
161
  return { success: false, error: { type: 'timeout', message: 'Task exceeded 60 minute maximum' },
@@ -177,12 +178,49 @@ export class CodexAdapter {
177
178
  }
178
179
  getSuggestion(error) {
179
180
  switch (error.type) {
180
- case 'rate_limit': return 'Wait and retry, or use /gemini-review instead';
181
+ case 'rate_limit': return 'Wait and retry, or use /multi-review instead';
181
182
  case 'auth_error': return 'Run `codex login` to authenticate';
182
183
  case 'cli_not_found': return 'Install with: npm install -g @openai/codex-cli';
183
184
  default: return 'Check the error message and try again';
184
185
  }
185
186
  }
187
+ async runConsult(request) {
188
+ const startTime = Date.now();
189
+ if (!existsSync(request.workingDir)) {
190
+ return {
191
+ success: false,
192
+ error: { type: 'cli_error', message: `Working directory does not exist: ${request.workingDir}` },
193
+ suggestion: 'Check that the working directory path is correct',
194
+ executionTimeMs: Date.now() - startTime,
195
+ };
196
+ }
197
+ try {
198
+ const prompt = buildConsultPrompt(request);
199
+ // Consult-specific defaults live in config (Zod defaults to xhigh + fast).
200
+ // Request value > config value > Zod default. Users who want to cap cost
201
+ // can set codex.consultServiceTier: "flex" without touching review.
202
+ const cfg = getConfig().codex;
203
+ const reasoningEffort = request.reasoningEffort ?? cfg.consultReasoningEffort;
204
+ const serviceTier = request.serviceTier ?? cfg.consultServiceTier;
205
+ const result = await this.runCli(prompt, request.workingDir, reasoningEffort, serviceTier);
206
+ if (result.exitCode !== 0) {
207
+ const error = this.categorizeError(result.stderr);
208
+ return { success: false, error, suggestion: this.getSuggestion(error), executionTimeMs: Date.now() - startTime };
209
+ }
210
+ if (!result.stdout.trim()) {
211
+ return {
212
+ success: false,
213
+ error: { type: 'cli_error', message: 'Codex returned empty response' },
214
+ suggestion: 'Try again or use /multi-review instead',
215
+ executionTimeMs: Date.now() - startTime,
216
+ };
217
+ }
218
+ return { success: true, output: result.stdout, executionTimeMs: Date.now() - startTime };
219
+ }
220
+ catch (error) {
221
+ return this.handleException(error, startTime);
222
+ }
223
+ }
186
224
  }
187
225
  // Register the adapter
188
226
  registerAdapter(new CodexAdapter());
@@ -5,7 +5,7 @@
5
5
  * Returns raw text — no JSON parsing or schema enforcement.
6
6
  * CC handles interpretation of the reviewer's response.
7
7
  */
8
- import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult } from './base.js';
8
+ import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult, ConsultRequest, ConsultResult } from './base.js';
9
9
  export declare class GeminiAdapter implements ReviewerAdapter {
10
10
  readonly id = "gemini";
11
11
  getCapabilities(): ReviewerCapabilities;
@@ -15,5 +15,6 @@ export declare class GeminiAdapter implements ReviewerAdapter {
15
15
  private handleException;
16
16
  private categorizeError;
17
17
  private getSuggestion;
18
+ runConsult(request: ConsultRequest): Promise<ConsultResult>;
18
19
  }
19
20
  export declare const geminiAdapter: GeminiAdapter;
@@ -11,6 +11,7 @@ import { registerAdapter, } from './base.js';
11
11
  import { CliExecutor } from '../executor.js';
12
12
  import { GeminiEventDecoder } from '../decoders/index.js';
13
13
  import { buildSimpleHandoff, buildHandoffPrompt, buildAdversarialHandoffPrompt, selectRole, } from '../handoff.js';
14
+ import { buildConsultPrompt } from '../consult-prompt.js';
14
15
  import { getConfig } from '../config.js';
15
16
  // =============================================================================
16
17
  // GEMINI ADAPTER
@@ -69,7 +70,7 @@ export class GeminiAdapter {
69
70
  return {
70
71
  success: false,
71
72
  error: { type: 'cli_error', message: 'Gemini returned empty response' },
72
- suggestion: 'Try again or use /codex-review instead',
73
+ suggestion: 'Try again or use /multi-review instead',
73
74
  executionTimeMs: Date.now() - startTime,
74
75
  };
75
76
  }
@@ -133,7 +134,7 @@ export class GeminiAdapter {
133
134
  }
134
135
  if (err.message === 'TIMEOUT') {
135
136
  return { success: false, error: { type: 'timeout', message: 'Gemini timed out — no events received' },
136
- suggestion: 'Try a smaller scope or use /codex-review', executionTimeMs: Date.now() - startTime };
137
+ suggestion: 'Try a smaller scope or use /multi-review', executionTimeMs: Date.now() - startTime };
137
138
  }
138
139
  if (err.message === 'MAX_TIMEOUT') {
139
140
  return { success: false, error: { type: 'timeout', message: 'Task exceeded 60 minute maximum' },
@@ -153,12 +154,43 @@ export class GeminiAdapter {
153
154
  }
154
155
  getSuggestion(error) {
155
156
  switch (error.type) {
156
- case 'rate_limit': return 'Wait and retry, or use /codex-review instead';
157
+ case 'rate_limit': return 'Wait and retry, or use /multi-review instead';
157
158
  case 'auth_error': return 'Run `gemini` and follow auth prompts, or set GEMINI_API_KEY';
158
159
  case 'cli_not_found': return 'Install with: npm install -g @google/gemini-cli';
159
160
  default: return 'Check the error message and try again';
160
161
  }
161
162
  }
163
+ async runConsult(request) {
164
+ const startTime = Date.now();
165
+ if (!existsSync(request.workingDir)) {
166
+ return {
167
+ success: false,
168
+ error: { type: 'cli_error', message: `Working directory does not exist: ${request.workingDir}` },
169
+ suggestion: 'Check that the working directory path is correct',
170
+ executionTimeMs: Date.now() - startTime,
171
+ };
172
+ }
173
+ try {
174
+ const prompt = buildConsultPrompt(request);
175
+ const result = await this.runCli(prompt, request.workingDir);
176
+ if (result.exitCode !== 0) {
177
+ const error = this.categorizeError(result.stderr);
178
+ return { success: false, error, suggestion: this.getSuggestion(error), executionTimeMs: Date.now() - startTime };
179
+ }
180
+ if (!result.stdout.trim()) {
181
+ return {
182
+ success: false,
183
+ error: { type: 'cli_error', message: 'Gemini returned empty response' },
184
+ suggestion: 'Try again or use /multi-review instead',
185
+ executionTimeMs: Date.now() - startTime,
186
+ };
187
+ }
188
+ return { success: true, output: result.stdout, executionTimeMs: Date.now() - startTime };
189
+ }
190
+ catch (error) {
191
+ return this.handleException(error, startTime);
192
+ }
193
+ }
162
194
  }
163
195
  // Register the adapter
164
196
  registerAdapter(new GeminiAdapter());
@@ -19,6 +19,10 @@ export declare function getCommandPaths(): {
19
19
  /**
20
20
  * Install slash commands to ~/.claude/commands/
21
21
  *
22
+ * @param overrides Test-only path overrides; production callers pass nothing.
22
23
  * @returns Result object with success status and installed commands
23
24
  */
24
- export declare function installCommands(): InstallResult;
25
+ export declare function installCommands(overrides?: Partial<{
26
+ source: string;
27
+ target: string;
28
+ }>): InstallResult;
package/dist/commands.js CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Used by index.ts (auto-install on MCP server startup and `update` subcommand)
5
5
  */
6
- import { existsSync, mkdirSync, copyFileSync, readdirSync, statSync, unlinkSync } from 'fs';
6
+ import { existsSync, mkdirSync, copyFileSync, readdirSync, renameSync, statSync } from 'fs';
7
7
  import { join, dirname } from 'path';
8
8
  import { homedir } from 'os';
9
9
  import { fileURLToPath } from 'url';
@@ -19,6 +19,11 @@ const DEPRECATED_COMMANDS = [
19
19
  'ask-gemini.md',
20
20
  'ask-multi.md',
21
21
  'multi-review-adv.md',
22
+ // Removed in favor of /multi-review and /multi-consult only:
23
+ 'codex-review.md',
24
+ 'codex-xhigh-review.md',
25
+ 'gemini-review.md',
26
+ 'claude-review.md',
22
27
  ];
23
28
  /**
24
29
  * Get source and target paths for command files
@@ -32,10 +37,13 @@ export function getCommandPaths() {
32
37
  /**
33
38
  * Install slash commands to ~/.claude/commands/
34
39
  *
40
+ * @param overrides Test-only path overrides; production callers pass nothing.
35
41
  * @returns Result object with success status and installed commands
36
42
  */
37
- export function installCommands() {
38
- const { source, target } = getCommandPaths();
43
+ export function installCommands(overrides) {
44
+ const defaults = getCommandPaths();
45
+ const source = overrides?.source ?? defaults.source;
46
+ const target = overrides?.target ?? defaults.target;
39
47
  // Check source exists
40
48
  if (!existsSync(source)) {
41
49
  return { success: false, installed: [], removed: [], error: 'Commands directory not found' };
@@ -59,13 +67,21 @@ export function installCommands() {
59
67
  if (files.length === 0) {
60
68
  return { success: false, installed: [], removed: [], error: 'No command files found' };
61
69
  }
62
- // Prune deprecated commands from target
70
+ // Prune deprecated commands from target by renaming to .deprecated.bak
71
+ // (lossless — preserves any user edits the operator may have made). If the
72
+ // backup already exists from a previous upgrade, leave it alone.
63
73
  const removed = [];
64
74
  for (const oldFile of DEPRECATED_COMMANDS) {
65
75
  const oldPath = join(target, oldFile);
66
76
  if (existsSync(oldPath)) {
77
+ const backupPath = `${oldPath}.deprecated.bak`;
67
78
  try {
68
- unlinkSync(oldPath);
79
+ if (!existsSync(backupPath)) {
80
+ renameSync(oldPath, backupPath);
81
+ }
82
+ // If the backup already exists, the original was already moved on a
83
+ // prior install. The file we see now must be a recreation; leave it
84
+ // alone — the user clearly wants it.
69
85
  removed.push(oldFile.replace('.md', ''));
70
86
  }
71
87
  catch {