@in-the-loop-labs/pair-review 5.2.3 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +11 -3
  2. package/package.json +1 -1
  3. package/plugin/.claude-plugin/plugin.json +1 -1
  4. package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
  5. package/plugin-code-critic/skills/analyze/references/level1-thorough.md +52 -121
  6. package/plugin-code-critic/skills/analyze/references/level2-thorough.md +49 -113
  7. package/plugin-code-critic/skills/analyze/references/level3-thorough.md +46 -195
  8. package/plugin-code-critic/skills/analyze/references/orchestration-thorough.md +56 -112
  9. package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
  10. package/public/css/analysis-config.css +29 -0
  11. package/public/css/pr.css +208 -0
  12. package/public/js/components/AIPanel.js +14 -9
  13. package/public/js/components/ChatPanel.js +790 -54
  14. package/public/js/components/ConfirmDialog.js +70 -2
  15. package/public/js/modules/pierre-bridge.js +58 -97
  16. package/public/js/modules/suggestion-manager.js +9 -121
  17. package/public/js/pr.js +15 -28
  18. package/public/js/utils/scroll-into-view.js +18 -4
  19. package/src/ai/analyzer.js +30 -5
  20. package/src/ai/antigravity-provider.js +7 -6
  21. package/src/ai/claude-provider.js +4 -8
  22. package/src/ai/codex-provider.js +3 -4
  23. package/src/ai/index.js +2 -0
  24. package/src/ai/muse-provider.js +3 -4
  25. package/src/ai/omp-provider.js +27 -12
  26. package/src/ai/pi-provider.js +12 -6
  27. package/src/ai/prompts/baseline/consolidation/thorough.js +56 -43
  28. package/src/ai/prompts/baseline/level1/thorough.js +76 -138
  29. package/src/ai/prompts/baseline/level2/thorough.js +76 -129
  30. package/src/ai/prompts/baseline/level3/thorough.js +67 -212
  31. package/src/ai/prompts/baseline/orchestration/thorough.js +79 -130
  32. package/src/ai/prompts/render-for-skill.js +5 -0
  33. package/src/ai/prompts/shared/adversarial-verification.js +68 -0
  34. package/src/ai/provider.js +60 -1
  35. package/src/ai/stream-parser.js +22 -1
  36. package/src/chat/acp-bridge.js +11 -0
  37. package/src/chat/chat-models.js +348 -0
  38. package/src/chat/chat-providers.js +17 -0
  39. package/src/chat/claude-code-bridge.js +9 -0
  40. package/src/chat/codex-bridge.js +6 -1
  41. package/src/chat/omp-bridge.js +5 -0
  42. package/src/chat/pi-bridge.js +20 -5
  43. package/src/chat/session-manager.js +158 -63
  44. package/src/hooks/payloads.js +5 -1
  45. package/src/routes/chat.js +83 -11
@@ -0,0 +1,348 @@
1
+ // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Chat Model Catalog
4
+ *
5
+ * Chat sessions borrow the *review* provider model catalogs (`static getModels()` on the
6
+ * classes in `src/ai/*-provider.js`, merged with user config by `applyModelOverrides`) so
7
+ * there is only one model list to maintain. A chat provider names its catalog via
8
+ * `models_from` (see `chat-providers.js`); when that key is absent, `type` is used if it
9
+ * happens to name a registered review provider. A provider with no catalog still works —
10
+ * it simply has no models to pick from.
11
+ *
12
+ * Two pure functions, no I/O:
13
+ * - `getChatModelCatalog` builds the picker payload. It strips every CLI-facing and
14
+ * internal field (`cli_model`, `extra_args`, `env`, `aliases`, `supports_chat`) so the
15
+ * API never leaks spawn details to the browser.
16
+ * - `resolveChatModel` turns a selector (canonical id, alias, or a raw CLI string from
17
+ * `chat_providers.<id>.model`) into what a bridge needs at spawn time.
18
+ *
19
+ * Runtime fields (`cli_model`, `extra_args`, `env`) are resolved against the built-in
20
+ * definition and the config override SEPARATELY — never against the merged catalog
21
+ * entry. `mergeModels` replaces a matched built-in wholesale, so a partial override such
22
+ * as `{ id: 'opus-5-high', tier: 'thorough', name: 'Team Opus' }` erases `cli_model` and
23
+ * `env` on the merged entry; resolving off it would spawn `claude --model opus-5-high`
24
+ * (not a real CLI model) with no effort env. This mirrors `_resolveModelConfig` in the
25
+ * review providers, which has always used the field-level ladder.
26
+ */
27
+
28
+ const {
29
+ getProviderClass,
30
+ getProviderConfigOverrides,
31
+ applyModelOverrides,
32
+ modelMatches,
33
+ inferModelDefaults,
34
+ prettifyModelId,
35
+ resolveCliModelConfig,
36
+ } = require('../ai');
37
+ const { getChatProvider } = require('./chat-providers');
38
+ const logger = require('../utils/logger');
39
+
40
+ /**
41
+ * Fields exposed to the chat model picker. Whitelisted (not blacklisted) so a new
42
+ * CLI-facing field added to a review provider's catalog can never leak by default.
43
+ * @type {string[]}
44
+ */
45
+ const CATALOG_FIELDS = ['id', 'name', 'tier', 'tagline', 'badge', 'badgeClass', 'description'];
46
+
47
+ /**
48
+ * Chat provider ids already warned about for a bad `models_from`. `GET /api/chat/providers`
49
+ * walks every provider on every request, so the warning must be once per process, not once
50
+ * per request. Module-level (not per-call) on purpose: the misconfiguration is static.
51
+ * @type {Set<string>}
52
+ */
53
+ const warnedBadCatalogSource = new Set();
54
+
55
+ /**
56
+ * `<chatProviderId>:<selector>` pairs already warned about for naming an analysis-only
57
+ * model (`supports_chat: false`). Same rationale as `warnedBadCatalogSource`: the
58
+ * misconfiguration is static, and the resolver runs on every session create/resume.
59
+ * @type {Set<string>}
60
+ */
61
+ const warnedChatUnsupported = new Set();
62
+
63
+ /**
64
+ * Test seam: clear the "already warned" memos so a test can assert the once-per-id
65
+ * behaviour without leaking state into the next test file.
66
+ */
67
+ function _resetForTests() {
68
+ warnedBadCatalogSource.clear();
69
+ warnedChatUnsupported.clear();
70
+ }
71
+
72
+ /**
73
+ * The shape returned for "no model selected" / "provider default".
74
+ * @returns {{id: null, cliModel: null, extraArgs: string[], env: Object, known: boolean}}
75
+ */
76
+ function defaultResolution() {
77
+ return { id: null, cliModel: null, extraArgs: [], env: {}, known: false };
78
+ }
79
+
80
+ /**
81
+ * Resolve which review provider supplies a chat provider's model catalog.
82
+ * Precedence: explicit `models_from` > `type` when it names a registered review
83
+ * provider > no catalog. An unknown `models_from` yields no catalog rather than
84
+ * silently falling back to `type` — a typo should be visible, not papered over.
85
+ *
86
+ * @param {Object|null} providerDef - Chat provider definition from `getChatProvider`
87
+ * @returns {string|null} Registered review provider id, or null when there is no catalog
88
+ */
89
+ function resolveChatCatalogProviderId(providerDef) {
90
+ if (!providerDef) return null;
91
+
92
+ if (providerDef.models_from) {
93
+ if (getProviderClass(providerDef.models_from)) {
94
+ return providerDef.models_from;
95
+ }
96
+ // A typo here silently costs the user their whole model picker, so it is a warning,
97
+ // not a debug line. Deduped per chat provider id: the catalog is rebuilt for every
98
+ // provider on every `GET /api/chat/providers`, and a static misconfiguration should
99
+ // not scroll the log.
100
+ if (!warnedBadCatalogSource.has(providerDef.id)) {
101
+ warnedBadCatalogSource.add(providerDef.id);
102
+ logger.warn(
103
+ `[ChatModels] Chat provider "${providerDef.id}" has models_from="${providerDef.models_from}", ` +
104
+ 'which is not a registered review provider; no model catalog.'
105
+ );
106
+ }
107
+ return null;
108
+ }
109
+
110
+ if (providerDef.type && getProviderClass(providerDef.type)) {
111
+ return providerDef.type;
112
+ }
113
+
114
+ return null;
115
+ }
116
+
117
+ /**
118
+ * Everything needed to resolve a chat model for a chat provider, in one lookup.
119
+ *
120
+ * `builtInModels` and `overrides` are kept alongside the merged list on purpose:
121
+ * runtime fields must be resolved field-by-field against those two (see the module
122
+ * header), while the merged list stays the source of truth for display, canonical
123
+ * ids, aliases, and `disabled_models` filtering.
124
+ *
125
+ * @param {Object|null} providerDef - Chat provider definition
126
+ * @returns {{builtInModels: Array<Object>, overrides: Object|undefined,
127
+ * merged: Array<Object>, effective: Array<Object>}|null} null when there is no catalog
128
+ */
129
+ function catalogSourcesFor(providerDef) {
130
+ const reviewId = resolveChatCatalogProviderId(providerDef);
131
+ if (!reviewId) return null;
132
+
133
+ const ProviderClass = getProviderClass(reviewId);
134
+ if (!ProviderClass || typeof ProviderClass.getModels !== 'function') return null;
135
+
136
+ try {
137
+ const builtInModels = ProviderClass.getModels();
138
+ if (!Array.isArray(builtInModels)) return null;
139
+ const overrides = getProviderConfigOverrides(reviewId);
140
+ const merged = applyModelOverrides(builtInModels, overrides);
141
+ if (!Array.isArray(merged)) return null;
142
+ // `supports_chat: false` marks an analysis-only catalog entry (Pi's `multi-model`
143
+ // and `review-roulette` pseudo-models, whose extra_args load review skills that
144
+ // have no meaning in a conversation). Filtering here — the chat-only choke point —
145
+ // hides them from the picker AND from `resolveChatModel`, so a stale
146
+ // `chat_providers.pi.model` cannot resurrect the skill args. The analysis catalog
147
+ // is untouched.
148
+ const effective = merged.filter(m => m.supports_chat !== false);
149
+ return { builtInModels, overrides, merged, effective };
150
+ } catch (err) {
151
+ logger.warn(`[ChatModels] Failed to build model catalog from review provider "${reviewId}": ${err.message}`);
152
+ return null;
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Resolve the CLI-facing fields for one catalog entry, against the built-in definition
158
+ * and the config override separately (never the merged entry — see the module header).
159
+ *
160
+ * Precedence matches `_resolveModelConfig` in the review providers: the config override
161
+ * wins for `cli_model`, and `extra_args`/`env` are merged built-in first, override last.
162
+ * Provider-level `providers.<id>.extra_args`/`env` are deliberately NOT folded in — those
163
+ * shape the *analysis* CLI invocation; a chat session's provider-level args and env come
164
+ * from `chat_providers.<id>` and are applied by the session manager.
165
+ *
166
+ * @param {{builtInModels: Array<Object>, overrides: Object|undefined}} sources
167
+ * @param {Object} entry - A merged catalog entry (supplies the canonical id)
168
+ * @param {string} [selector] - The selector the caller matched with (may be an alias)
169
+ * @returns {{cliModel: string|null, extraArgs: string[], env: Object}}
170
+ */
171
+ function runtimeFieldsFor(sources, entry, selector) {
172
+ const builtIn = sources.builtInModels.find(bm => modelMatches(bm, entry.id)) || null;
173
+
174
+ // A config override may key the model by the canonical id, by any built-in alias, or
175
+ // by an alias it declares itself; match on the union so no lookup diverges.
176
+ const modelKeys = new Set(
177
+ [entry.id, selector, builtIn?.id, ...(builtIn?.aliases || [])].filter(Boolean)
178
+ );
179
+ const configModel = sources.overrides?.models?.find(
180
+ cm => modelKeys.has(cm.id) || (cm.aliases || []).some(a => modelKeys.has(a))
181
+ ) || null;
182
+
183
+ return {
184
+ cliModel: resolveCliModelConfig(builtIn, configModel, entry.id) ?? null,
185
+ extraArgs: [...(builtIn?.extra_args || []), ...(configModel?.extra_args || [])],
186
+ env: { ...(builtIn?.env || {}), ...(configModel?.env || {}) },
187
+ };
188
+ }
189
+
190
+ /**
191
+ * Project a review model definition onto the picker-safe field set.
192
+ * Entries missing display metadata are run through `inferModelDefaults` so the picker
193
+ * never shows a bare id. `inferModelDefaults` throws on a missing/invalid `tier`
194
+ * (possible for a hand-written config model), so it is guarded — a malformed entry
195
+ * degrades to a prettified id instead of taking down the whole catalog.
196
+ *
197
+ * @param {Object} model - Review provider model definition
198
+ * @returns {{id: string, name: string, tier: string|null, tagline: string, badge: string|null, badgeClass: string|null, description: string}}
199
+ */
200
+ function toCatalogEntry(model) {
201
+ let source = model;
202
+ if (!model.name || !model.badge || !model.badgeClass) {
203
+ try {
204
+ source = inferModelDefaults(model);
205
+ } catch {
206
+ source = { ...model, name: model.name || prettifyModelId(String(model.id)) };
207
+ }
208
+ }
209
+
210
+ const entry = {};
211
+ for (const field of CATALOG_FIELDS) {
212
+ entry[field] = source[field] ?? null;
213
+ }
214
+ entry.name = entry.name || prettifyModelId(String(model.id));
215
+ entry.tagline = entry.tagline || '';
216
+ entry.description = entry.description || '';
217
+ return entry;
218
+ }
219
+
220
+ /**
221
+ * Build the chat model catalog for a chat provider.
222
+ *
223
+ * @param {string} chatProviderId - Chat provider id (e.g. 'claude', 'cursor-acp')
224
+ * @param {Object|null} [providerDef] - Pre-resolved definition; pass it to avoid a second
225
+ * `getChatProvider` lookup (callers that already hold the def should always pass it)
226
+ * @returns {{models: Array<Object>, configuredModel: string|null, hasCatalog: boolean}}
227
+ * `models` is empty when the provider has no catalog. `configuredModel` is
228
+ * `chat_providers.<id>.model` resolved to its canonical catalog id, the raw string when
229
+ * it is not in the catalog, or null when unset. `hasCatalog` means "there is something to
230
+ * pick from" — i.e. `models.length > 0`. A provider whose `models_from` resolves to a
231
+ * review provider that returns no models (or an empty list after `disabled_models`
232
+ * filtering) reports false, because from the picker's point of view it has no catalog.
233
+ */
234
+ function getChatModelCatalog(chatProviderId, providerDef) {
235
+ const def = providerDef !== undefined ? providerDef : getChatProvider(chatProviderId);
236
+ const sources = catalogSourcesFor(def);
237
+ const effective = sources?.effective || null;
238
+
239
+ // Suppress catalog rows that ARE "provider default": no CLI model, no flags, no env
240
+ // (Pi's and OMP's `default` entries). The picker renders its own "Provider default"
241
+ // row, so listing these would show the same choice twice. Suppression is display-only —
242
+ // `resolveChatModel` still resolves the id, so a stored session keeps working.
243
+ const shown = (effective || []).filter(m => {
244
+ const runtime = runtimeFieldsFor(sources, m);
245
+ return !(runtime.cliModel === null
246
+ && runtime.extraArgs.length === 0
247
+ && Object.keys(runtime.env).length === 0);
248
+ });
249
+ const models = shown.map(toCatalogEntry);
250
+
251
+ let configuredModel = null;
252
+ const configured = def?.model;
253
+ if (typeof configured === 'string' && configured.length > 0) {
254
+ const match = effective?.find(m => modelMatches(m, configured)) || null;
255
+ if (match) {
256
+ // A configured model that is not a listed row (a suppressed "provider default"
257
+ // entry) reports null so the picker lands on its own "Provider default" option.
258
+ configuredModel = models.some(m => m.id === match.id) ? match.id : null;
259
+ } else {
260
+ // Unknown selectors pass through verbatim, except one naming an analysis-only
261
+ // model — that is not a raw CLI string, it is a stale selection.
262
+ const excluded = sources?.merged.some(m => modelMatches(m, configured) && m.supports_chat === false);
263
+ configuredModel = excluded ? null : configured;
264
+ }
265
+ }
266
+
267
+ return { models, configuredModel, hasCatalog: models.length > 0 };
268
+ }
269
+
270
+ /**
271
+ * Resolve a model selector into the pieces a chat bridge needs at spawn time.
272
+ *
273
+ * Unknown selectors pass through verbatim: `chat_providers.<id>.model` has always held
274
+ * raw CLI strings, and power users may type a model the catalog does not list.
275
+ *
276
+ * @param {string} chatProviderId - Chat provider id
277
+ * @param {string|null} [selector] - Canonical catalog id, alias, or raw CLI string
278
+ * @param {Object|null} [providerDef] - Pre-resolved definition (avoids a second lookup)
279
+ * @returns {{id: string|null, cliModel: string|null, extraArgs: string[], env: Object, known: boolean}}
280
+ * `cliModel` is the `cli_model` ladder's result (config override > built-in > id); null
281
+ * means "omit the model flag" (the bridges already treat a null model that way).
282
+ * `known` is false for a passthrough. `id` is exactly what a caller should persist:
283
+ * the canonical id when known, the raw selector for a passthrough, and null when the
284
+ * selector resolves to nothing (absent, or an analysis-only model).
285
+ */
286
+ function resolveChatModel(chatProviderId, selector, providerDef) {
287
+ if (selector === null || selector === undefined) {
288
+ return defaultResolution();
289
+ }
290
+
291
+ const def = providerDef !== undefined ? providerDef : getChatProvider(chatProviderId);
292
+ const sources = catalogSourcesFor(def);
293
+ const match = sources?.effective.find(m => modelMatches(m, selector)) || null;
294
+
295
+ if (!match) {
296
+ // A selector naming an analysis-only model (`supports_chat: false`) must NOT fall
297
+ // through to passthrough: `--model review-roulette` is not a real CLI model, and
298
+ // passing its extra_args would load a review skill into the conversation. Degrade
299
+ // to the provider's own default instead, loudly but once.
300
+ const excluded = sources?.merged.find(m => modelMatches(m, selector) && m.supports_chat === false);
301
+ if (excluded) {
302
+ const warnKey = `${chatProviderId}:${selector}`;
303
+ if (!warnedChatUnsupported.has(warnKey)) {
304
+ warnedChatUnsupported.add(warnKey);
305
+ logger.warn(
306
+ `[ChatModels] Model "${selector}" is analysis-only (supports_chat: false) and cannot be used ` +
307
+ `for chat with provider "${chatProviderId}"; falling back to the provider default.`
308
+ );
309
+ }
310
+ return defaultResolution();
311
+ }
312
+ return { id: selector, cliModel: selector, extraArgs: [], env: {}, known: false };
313
+ }
314
+
315
+ const runtime = runtimeFieldsFor(sources, match, selector);
316
+ return {
317
+ id: match.id,
318
+ cliModel: runtime.cliModel,
319
+ extraArgs: runtime.extraArgs,
320
+ env: runtime.env,
321
+ known: true,
322
+ };
323
+ }
324
+
325
+ /**
326
+ * Canonicalise a stored session model for API responses.
327
+ *
328
+ * A `chat_sessions.model` value can predate canonicalisation (an alias written by an
329
+ * older build) or be null (meaning "provider default"). Rows are never rewritten — the
330
+ * read side canonicalises so the sessions list, the create response, and the picker all
331
+ * agree on one id.
332
+ *
333
+ * @param {string} chatProviderId - Chat provider id from the session row
334
+ * @param {string|null|undefined} storedModel - `chat_sessions.model`
335
+ * @returns {string|null} Canonical catalog id, the raw string for a passthrough, or null
336
+ */
337
+ function canonicalChatModel(chatProviderId, storedModel) {
338
+ if (storedModel === null || storedModel === undefined) return null;
339
+ return resolveChatModel(chatProviderId, storedModel).id ?? null;
340
+ }
341
+
342
+ module.exports = {
343
+ getChatModelCatalog,
344
+ resolveChatModel,
345
+ canonicalChatModel,
346
+ resolveChatCatalogProviderId,
347
+ _resetForTests,
348
+ };
@@ -4,6 +4,14 @@
4
4
  *
5
5
  * Defines named chat providers (Pi, OMP, Copilot, OpenCode, Claude, Codex, Cursor) with
6
6
  * their default commands/args, config overrides, and availability checks.
7
+ *
8
+ * `models_from` names the **review** provider (`src/ai/*-provider.js`, e.g. `claude`,
9
+ * `cursor-agent`) whose model catalog this chat provider borrows for the chat model
10
+ * picker. Chat ids and review ids overlap but are not identical, so the mapping is
11
+ * explicit. A config override may set `models_from` to point a custom chat provider at
12
+ * any registered review provider's catalog. When it is absent, `type` is used if it names
13
+ * a registered review provider; otherwise the provider simply has no catalog and the
14
+ * picker offers only "Provider default". See `src/chat/chat-models.js`.
7
15
  */
8
16
 
9
17
  const { spawn } = require('child_process');
@@ -23,6 +31,7 @@ const CHAT_PROVIDERS = {
23
31
  id: 'pi',
24
32
  name: 'Pi (RPC)',
25
33
  type: 'pi',
34
+ models_from: 'pi',
26
35
  },
27
36
  // OMP (Oh My Pi) is a Pi fork that speaks the same RPC protocol with a
28
37
  // slightly different CLI surface (see OmpBridge). Like the built-in Pi
@@ -34,11 +43,13 @@ const CHAT_PROVIDERS = {
34
43
  id: 'omp',
35
44
  name: 'OMP (RPC)',
36
45
  type: 'omp',
46
+ models_from: 'omp',
37
47
  },
38
48
  'copilot-acp': {
39
49
  id: 'copilot-acp',
40
50
  name: 'Copilot (ACP)',
41
51
  type: 'acp',
52
+ models_from: 'copilot',
42
53
  command: 'copilot',
43
54
  args: ['--acp', '--stdio'],
44
55
  env: {},
@@ -47,6 +58,7 @@ const CHAT_PROVIDERS = {
47
58
  id: 'opencode-acp',
48
59
  name: 'OpenCode (ACP)',
49
60
  type: 'acp',
61
+ models_from: 'opencode',
50
62
  command: 'opencode',
51
63
  args: ['acp'],
52
64
  env: {},
@@ -55,6 +67,7 @@ const CHAT_PROVIDERS = {
55
67
  id: 'cursor-acp',
56
68
  name: 'Cursor (ACP)',
57
69
  type: 'acp',
70
+ models_from: 'cursor-agent',
58
71
  command: 'agent',
59
72
  args: ['acp'],
60
73
  env: {},
@@ -63,6 +76,7 @@ const CHAT_PROVIDERS = {
63
76
  id: 'claude',
64
77
  name: 'Claude (NDJSON)',
65
78
  type: 'claude',
79
+ models_from: 'claude',
66
80
  command: 'claude',
67
81
  args: [],
68
82
  env: {},
@@ -71,6 +85,7 @@ const CHAT_PROVIDERS = {
71
85
  id: 'codex',
72
86
  name: 'Codex (JSON-RPC)',
73
87
  type: 'codex',
88
+ models_from: 'codex',
74
89
  command: 'codex',
75
90
  sandbox: 'workspace-write',
76
91
  // Shell environment config prevents zsh -l from reconstructing PATH,
@@ -122,6 +137,7 @@ function getChatProvider(id) {
122
137
  env: overrides.env || {},
123
138
  };
124
139
  if (overrides.model) provider.model = overrides.model;
140
+ if (overrides.models_from) provider.models_from = overrides.models_from;
125
141
  if (overrides.provider) provider.provider = overrides.provider;
126
142
  if (overrides.availability_command !== undefined) {
127
143
  provider.availability_command = overrides.availability_command;
@@ -149,6 +165,7 @@ function getChatProvider(id) {
149
165
  if (overrides.name || overrides.label) merged.name = overrides.name || overrides.label;
150
166
  if (overrides.command) merged.command = overrides.command;
151
167
  if (overrides.model) merged.model = overrides.model;
168
+ if (overrides.models_from) merged.models_from = overrides.models_from;
152
169
  if (overrides.provider) merged.provider = overrides.provider;
153
170
  if (overrides.availability_command !== undefined) {
154
171
  merged.availability_command = overrides.availability_command;
@@ -38,11 +38,14 @@ class ClaudeCodeBridge extends EventEmitter {
38
38
  * @param {Object} [options.env] - Extra env vars for subprocess
39
39
  * @param {boolean} [options.useShell] - Use shell mode for multi-word commands
40
40
  * @param {string} [options.resumeSessionId] - Session ID for resumption
41
+ * @param {string[]} [options.extraArgs] - Extra CLI args appended after --model
42
+ * (e.g. model-level catalog flags). Empty by default.
41
43
  * @param {Object} [options._deps] - { spawn, createInterface } for testing
42
44
  */
43
45
  constructor(options = {}) {
44
46
  super();
45
47
  this.model = options.model || null;
48
+ this.extraArgs = options.extraArgs || [];
46
49
  this.cwd = options.cwd || process.cwd();
47
50
  this.systemPrompt = options.systemPrompt || null;
48
51
  this.claudeCommand = options.claudeCommand || process.env.PAIR_REVIEW_CLAUDE_CMD || 'claude';
@@ -338,6 +341,12 @@ class ClaudeCodeBridge extends EventEmitter {
338
341
  args.push('--model', this.model);
339
342
  }
340
343
 
344
+ // Model-level catalog args (effort flags etc.) go last so they can override
345
+ // anything set above.
346
+ if (this.extraArgs.length > 0) {
347
+ args.push(...this.extraArgs);
348
+ }
349
+
341
350
  return args;
342
351
  }
343
352
 
@@ -61,6 +61,10 @@ class CodexBridge extends EventEmitter {
61
61
  * @param {string[]} [options.codexArgs] - Args for Codex binary (default: ['app-server']); chat-providers.js adds shell env config
62
62
  * @param {Object} [options.env] - Extra env vars for subprocess
63
63
  * @param {boolean} [options.useShell] - Use shell mode for multi-word commands
64
+ * @param {string[]} [options.extraArgs] - Extra CLI args appended after codexArgs.
65
+ * `-c key=value` is a global Codex flag, so model-level effort settings
66
+ * (e.g. `-c model_reasoning_effort="high"`) ride the same mechanism as the
67
+ * built-in `-c allow_login_shell=false`.
64
68
  * @param {string} [options.resumeThreadId] - Thread ID to resume
65
69
  * @param {string|null} [options.sandbox] - Thread sandbox mode (default: 'workspace-write')
66
70
  * @param {Object|null} [options.sandboxPolicy] - Turn sandbox policy override for tests
@@ -85,6 +89,7 @@ class CodexBridge extends EventEmitter {
85
89
  || process.env.PAIR_REVIEW_CODEX_CMD
86
90
  || 'codex';
87
91
  this.codexArgs = options.codexArgs || ['app-server'];
92
+ this.extraArgs = options.extraArgs || [];
88
93
 
89
94
  this._deps = { ...defaults, ...options._deps };
90
95
  this._process = null;
@@ -114,7 +119,7 @@ class CodexBridge extends EventEmitter {
114
119
 
115
120
  const deps = this._deps;
116
121
  const command = this.codexCommand;
117
- const args = [...this.codexArgs];
122
+ const args = [...this.codexArgs, ...this.extraArgs];
118
123
  const useShell = this.useShell;
119
124
 
120
125
  // For multi-word commands (e.g. "devx codex"), use shell mode. Quote args
@@ -48,6 +48,11 @@ class OmpBridge extends PiBridge {
48
48
  this.logName = 'OmpBridge';
49
49
  this.cliName = 'OMP';
50
50
  this.sessionFlag = '--resume';
51
+ // OMP takes the model string verbatim. Its review provider (omp-provider.js)
52
+ // never splits `provider/model` into two flags, so the chat bridge must not
53
+ // either — otherwise the same config value would mean different things in
54
+ // analysis and chat.
55
+ this._splitProviderModel = false;
51
56
  }
52
57
 
53
58
  /**
@@ -25,7 +25,8 @@ const DIALOG_METHODS = new Set(['select', 'confirm', 'input', 'editor']);
25
25
  class PiBridge extends EventEmitter {
26
26
  /**
27
27
  * @param {Object} options
28
- * @param {string} [options.model] - Model ID (e.g., 'claude-sonnet-4')
28
+ * @param {string} [options.model] - Model ID (e.g., 'claude-sonnet-4'). A `provider/model`
29
+ * string is split into --provider/--model unless `options.provider` is set.
29
30
  * @param {string} [options.provider] - Provider name (e.g., 'anthropic')
30
31
  * @param {string} [options.cwd] - Working directory for Pi process
31
32
  * @param {string} [options.systemPrompt] - System prompt text
@@ -62,6 +63,11 @@ class PiBridge extends EventEmitter {
62
63
  this.logName = 'PiBridge';
63
64
  this.cliName = 'Pi';
64
65
  this.sessionFlag = '--session';
66
+ // Pi's CLI accepts a `provider/model` model string only as two flags
67
+ // (--provider <p> --model <m>), mirroring _resolveCliModelArgs in
68
+ // src/ai/pi-provider.js. OmpBridge turns this off: OMP's review provider
69
+ // never splits, so its CLI must keep receiving the raw string.
70
+ this._splitProviderModel = true;
65
71
 
66
72
  this._process = null;
67
73
  this._readline = null;
@@ -278,12 +284,21 @@ class PiBridge extends EventEmitter {
278
284
  args.push(this.sessionFlag, this.sessionPath);
279
285
  }
280
286
 
287
+ // An explicit provider always wins: the model string is then passed through
288
+ // untouched, even if it contains a slash.
281
289
  if (this.provider) {
282
290
  args.push('--provider', this.provider);
283
- }
284
-
285
- if (this.model) {
286
- args.push('--model', this.model);
291
+ if (this.model) {
292
+ args.push('--model', this.model);
293
+ }
294
+ } else if (this.model) {
295
+ const slash = this._splitProviderModel ? this.model.indexOf('/') : -1;
296
+ if (slash > 0) {
297
+ args.push('--provider', this.model.slice(0, slash));
298
+ args.push('--model', this.model.slice(slash + 1));
299
+ } else {
300
+ args.push('--model', this.model);
301
+ }
287
302
  }
288
303
 
289
304
  if (this.systemPrompt) {