@in-the-loop-labs/pair-review 5.4.0 → 5.4.2

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 (35) hide show
  1. package/README.md +3 -3
  2. package/package.json +2 -2
  3. package/plugin/.claude-plugin/plugin.json +1 -1
  4. package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
  5. package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
  6. package/public/index.html +4 -0
  7. package/public/js/components/AdvancedConfigTab.js +18 -108
  8. package/public/js/components/VoiceCentricConfigTab.js +18 -108
  9. package/public/js/index.js +47 -5
  10. package/public/js/modules/diff-renderer.js +7 -6
  11. package/public/js/utils/council-timeout.js +203 -0
  12. package/public/local.html +4 -0
  13. package/public/pr.html +4 -0
  14. package/src/ai/antigravity-provider.js +76 -35
  15. package/src/ai/claude-provider.js +115 -39
  16. package/src/ai/codex-provider.js +19 -24
  17. package/src/ai/copilot-provider.js +59 -48
  18. package/src/ai/cursor-agent-provider.js +95 -133
  19. package/src/ai/opencode-provider.js +21 -2
  20. package/src/ai/provider.js +3 -3
  21. package/src/chat/session-manager.js +1 -1
  22. package/src/database.js +240 -59
  23. package/src/git/worktree-pool-lifecycle.js +152 -33
  24. package/src/git/worktree-pool-usage.js +20 -0
  25. package/src/git/worktree.js +14 -5
  26. package/src/main.js +25 -9
  27. package/src/routes/bulk-analysis-configs.js +1 -1
  28. package/src/routes/pr.js +11 -14
  29. package/src/routes/reviews.js +8 -30
  30. package/src/routes/setup.js +22 -9
  31. package/src/setup/pr-setup.js +12 -3
  32. package/src/utils/diff-file-content.js +62 -25
  33. package/src/utils/json-extractor.js +267 -13
  34. package/src/utils/pr-file-blob-cache.js +134 -0
  35. package/src/utils/process-liveness.js +64 -0
@@ -24,6 +24,9 @@ const BIN_DIR = path.join(__dirname, '..', '..', 'bin');
24
24
  * Descriptions follow the Codex CLI model catalog. GPT-5.6 Sol High stays the
25
25
  * recommended default during the GPT-6 rollout. GPT-6 Sol/Luna require admin
26
26
  * enablement in Enterprise; GPT-6.1 Sol requires it in Enterprise and Edu.
27
+ * GPT-6.1 Terra (2026-10-26, $1/$5 per 1M tokens, Codex CLI >= 0.159.0) runs on
28
+ * Plus, Pro, Business, Enterprise, and Edu, with Enterprise access subject to
29
+ * workspace availability and administrator controls.
27
30
  * Selecting a model locally does not grant access. testAvailability() checks
28
31
  * only `codex --version`, and model rejection does not trigger a fallback,
29
32
  * so GPT-6 and GPT-6.1 remain explicit choices.
@@ -35,8 +38,6 @@ const BIN_DIR = path.join(__dirname, '..', '..', 'bin');
35
38
  * GPT-5.6 during rollout for access compatibility.
36
39
  * Guided tours use the provider default, not the fast tier.
37
40
  *
38
- * GPT-5.5 retires from Codex on all plans on 2026-10-14 (API unaffected);
39
- * remove the gpt-5.5-* entries then.
40
41
  * Workspace access: learn.chatgpt.com/docs/enterprise/workspace-model-availability
41
42
  *
42
43
  * Reasoning-effort variants (-low / -high / -xhigh / -max) use `cli_model` to pass
@@ -55,6 +56,11 @@ const BIN_DIR = path.join(__dirname, '..', '..', 'bin');
55
56
  * verbatim with no effort override, so API-key users can still name it raw
56
57
  * (`--model gpt-5.4-mini`, or a `providers.codex.models` entry for the web UI
57
58
  * picker).
59
+ * Deprecated (October 14, 2026): gpt-5.5 (gpt-5.5-high / gpt-5.5-xhigh) — retired
60
+ * from Codex with ChatGPT sign-in (Codex rejects it with a 400) but still valid
61
+ * for API keys. OpenAI moves ChatGPT plans to GPT-6.1 Sol; it is NOT aliased
62
+ * (different model line and price). Like gpt-5.4-mini, API-key users can still
63
+ * name the raw id (`--model gpt-5.5`).
58
64
  */
59
65
  const CODEX_MODELS = [
60
66
  // ── Thorough tier ───────────────────────────────────────────────────────
@@ -147,28 +153,6 @@ const CODEX_MODELS = [
147
153
  badge: 'Extra High',
148
154
  badgeClass: 'badge-power'
149
155
  },
150
- {
151
- id: 'gpt-5.5-high',
152
- cli_model: 'gpt-5.5',
153
- extra_args: ['-c', 'model_reasoning_effort="high"'],
154
- name: 'GPT-5.5 High',
155
- tier: 'thorough',
156
- tagline: 'Legacy Coding',
157
- description: 'Legacy coding model, with high reasoning effort for demanding reviews and careful cross-file analysis. OpenAI retires GPT-5.5 from Codex on 2026-10-14.',
158
- badge: 'Legacy',
159
- badgeClass: 'badge-power'
160
- },
161
- {
162
- id: 'gpt-5.5-xhigh',
163
- cli_model: 'gpt-5.5',
164
- extra_args: ['-c', 'model_reasoning_effort="xhigh"'],
165
- name: 'GPT-5.5 XHigh',
166
- tier: 'thorough',
167
- tagline: 'Legacy Coding Depth',
168
- description: 'Legacy coding model, with extra-high reasoning effort for architecture, concurrency, and security-sensitive reviews. OpenAI retires GPT-5.5 from Codex on 2026-10-14.',
169
- badge: 'Max Reasoning',
170
- badgeClass: 'badge-power'
171
- },
172
156
  // ── Balanced tier ───────────────────────────────────────────────────────
173
157
  // Provider switching and default fallback must work without GPT-6 access.
174
158
  {
@@ -182,6 +166,17 @@ const CODEX_MODELS = [
182
166
  badge: 'Previous Gen',
183
167
  badgeClass: 'badge-balanced'
184
168
  },
169
+ {
170
+ id: 'gpt-6.1-terra-xhigh',
171
+ cli_model: 'gpt-6.1-terra',
172
+ extra_args: ['-c', 'model_reasoning_effort="xhigh"'],
173
+ name: 'GPT-6.1 Terra XHigh',
174
+ tier: 'balanced',
175
+ tagline: 'Latest Balanced',
176
+ description: 'Fast, efficient model for professional work, with extra-high reasoning effort for careful everyday reviews and scoped fixes. Requires GPT-6.1 Terra access; Enterprise access depends on workspace availability and administrator controls.',
177
+ badge: 'Newest',
178
+ badgeClass: 'badge-balanced'
179
+ },
185
180
  {
186
181
  id: 'gpt-5.6-luna-max',
187
182
  cli_model: 'gpt-5.6-luna',
@@ -22,33 +22,43 @@ const BIN_DIR = path.join(__dirname, '..', '..', 'bin');
22
22
  *
23
23
  * GitHub Copilot CLI supports multiple AI models including OpenAI,
24
24
  * Anthropic, and Google models via the --model flag.
25
- * Available models (as of April 2026): claude-haiku-4.6, claude-sonnet-4.6,
26
- * claude-sonnet-4.5, gpt-5.4, gpt-5.4-mini, gpt-5.3-codex,
27
- * claude-opus-4.5, claude-opus-4.6, claude-opus-4.6-fast.
28
- * Default is claude-sonnet-4.6.
25
+ * Built-in models (as of November 2026): claude-haiku-5.5, gpt-5.6-luna (fast);
26
+ * claude-sonnet-5.5 (default), gpt-5.6-terra (balanced); claude-opus-5.5,
27
+ * gpt-5.6-sol (thorough). Any other id Copilot supports (gpt-6.1-sol,
28
+ * claude-fable-5.2, gemini-4-argon, ...) can be passed verbatim with --model or
29
+ * added via `providers.copilot.models`.
30
+ * Ids and prices: docs.github.com/en/copilot/reference/ai-models/supported-models
31
+ *
32
+ * Deprecated (November 2026): claude-sonnet-4.6, claude-opus-4.5, claude-opus-4.6
33
+ * (retired 2026-09-01), claude-opus-4.6-fast (retired 2026-06-29), gpt-5.4 and
34
+ * gpt-5.4-mini (retired 2026-10-19), claude-haiku-4.6 (never in Copilot's
35
+ * supported list), gpt-5.3-codex (still supported, dropped from the built-ins
36
+ * as superseded by GPT-5.6). None are aliased: their successors are different
37
+ * generations at different prices, so a saved council fails loudly rather than
38
+ * silently running another model.
29
39
  */
30
40
  const COPILOT_MODELS = [
31
41
  {
32
- id: 'claude-haiku-4.6',
33
- name: 'Claude Haiku 4.6',
42
+ id: 'claude-haiku-5.5',
43
+ name: 'Claude Haiku 5.5',
34
44
  tier: 'fast',
35
45
  tagline: 'Quick Scan',
36
- description: 'Rapid feedback for obvious issues, style checks, and simple logic errors',
46
+ description: 'Rapid, very low-cost feedback for obvious issues, style checks, and simple logic errors',
37
47
  badge: 'Speedy',
38
48
  badgeClass: 'badge-speed'
39
49
  },
40
50
  {
41
- id: 'gpt-5.4-mini',
42
- name: 'GPT-5.4 Mini',
51
+ id: 'gpt-5.6-luna',
52
+ name: 'GPT-5.6 Luna',
43
53
  tier: 'fast',
44
54
  tagline: 'Fast & Cheap',
45
- description: 'Low-cost fast reviews with solid reasoning—included at no premium cost',
55
+ description: 'Low-cost OpenAI model for quick reviews with solid reasoning',
46
56
  badge: 'Fast',
47
57
  badgeClass: 'badge-speed'
48
58
  },
49
59
  {
50
- id: 'claude-sonnet-4.6',
51
- name: 'Claude Sonnet 4.6',
60
+ id: 'claude-sonnet-5.5',
61
+ name: 'Claude Sonnet 5.5',
52
62
  tier: 'balanced',
53
63
  tagline: 'Best Balance',
54
64
  description: 'Latest Sonnet—excellent code understanding with fast turnaround',
@@ -57,49 +67,31 @@ const COPILOT_MODELS = [
57
67
  default: true
58
68
  },
59
69
  {
60
- id: 'gpt-5.4',
61
- name: 'GPT-5.4',
62
- tier: 'thorough',
63
- tagline: 'Latest OpenAI',
64
- description: 'Flagship OpenAI model combining coding, reasoning, and agentic workflows',
65
- badge: 'Latest',
66
- badgeClass: 'badge-power'
67
- },
68
- {
69
- id: 'gpt-5.3-codex',
70
- name: 'GPT-5.3 Codex',
71
- tier: 'thorough',
72
- tagline: 'Deep Code Analysis',
73
- description: 'Industry-leading coding model—frontier performance for complex multi-file reviews',
74
- badge: 'Thorough',
75
- badgeClass: 'badge-power'
76
- },
77
- {
78
- id: 'claude-opus-4.5',
79
- name: 'Claude Opus 4.5',
80
- tier: 'thorough',
81
- tagline: 'Deep Analysis',
82
- description: 'Highly capable model for critical code reviews—strong reasoning for security and architecture',
83
- badge: 'Premium',
84
- badgeClass: 'badge-premium'
70
+ id: 'gpt-5.6-terra',
71
+ name: 'GPT-5.6 Terra',
72
+ tier: 'balanced',
73
+ tagline: 'Balanced OpenAI',
74
+ description: 'Mid-tier OpenAI model—strong coding quality at a moderate price',
75
+ badge: 'Balanced',
76
+ badgeClass: 'badge-balanced'
85
77
  },
86
78
  {
87
- id: 'claude-opus-4.6',
88
- name: 'Claude Opus 4.6',
79
+ id: 'claude-opus-5.5',
80
+ name: 'Claude Opus 5.5',
89
81
  tier: 'thorough',
90
82
  tagline: 'Most Capable',
91
- description: 'Most capable model for critical code reviews—deep reasoning for security and architecture',
83
+ description: 'Most capable Claude model for critical code reviews—deep reasoning for security and architecture',
92
84
  badge: 'Premium',
93
85
  badgeClass: 'badge-premium'
94
86
  },
95
87
  {
96
- id: 'claude-opus-4.6-fast',
97
- name: 'Claude Opus 4.6 Fast',
88
+ id: 'gpt-5.6-sol',
89
+ name: 'GPT-5.6 Sol',
98
90
  tier: 'thorough',
99
- tagline: 'Fast Opus',
100
- description: 'Opus-level analysis at reduced latency—preview mode for faster deep reviews',
101
- badge: 'Preview',
102
- badgeClass: 'badge-premium'
91
+ tagline: 'Deep Analysis',
92
+ description: 'Flagship OpenAI workhorse for complex multi-file and architectural reviews',
93
+ badge: 'Thorough',
94
+ badgeClass: 'badge-power'
103
95
  }
104
96
  ];
105
97
 
@@ -424,6 +416,22 @@ class CopilotProvider extends AIProvider {
424
416
  return [...baseArgs, ...providerArgs, ...modelArgs];
425
417
  }
426
418
 
419
+ /**
420
+ * Resolve merged env (provider env + model env) for the given model.
421
+ * Same merge the constructor applies for the analysis model, so the
422
+ * extraction model (possibly a different fast-tier model) gets its own env.
423
+ *
424
+ * @param {string} model - The model identifier
425
+ * @returns {Object} Env vars to merge into the child environment
426
+ */
427
+ _resolveEnvForModel(model) {
428
+ const modelConfig = this.configOverrides?.models?.find(m => m.id === model);
429
+ return {
430
+ ...(this.configOverrides?.env || {}),
431
+ ...(modelConfig?.env || {})
432
+ };
433
+ }
434
+
427
435
  /**
428
436
  * Get CLI configuration for LLM extraction.
429
437
  * Copilot reads from stdin when no -p argument is provided.
@@ -438,6 +446,7 @@ class CopilotProvider extends AIProvider {
438
446
 
439
447
  // Build args consistently using the shared method, applying provider and model extra_args
440
448
  const args = this.buildArgsForModel(model);
449
+ const env = this._resolveEnvForModel(model);
441
450
 
442
451
  // Use stdin for prompt - safer than command args for arbitrary content
443
452
  if (useShell) {
@@ -445,14 +454,16 @@ class CopilotProvider extends AIProvider {
445
454
  command: `${copilotCmd} ${quoteShellArgs(args).join(' ')}`,
446
455
  args: [],
447
456
  useShell: true,
448
- promptViaStdin: true
457
+ promptViaStdin: true,
458
+ env
449
459
  };
450
460
  }
451
461
  return {
452
462
  command: copilotCmd,
453
463
  args,
454
464
  useShell: false,
455
- promptViaStdin: true
465
+ promptViaStdin: true,
466
+ env
456
467
  };
457
468
  }
458
469
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  const path = require('path');
18
18
  const { spawn } = require('child_process');
19
- const { AIProvider, registerProvider, quoteShellArgs } = require('./provider');
19
+ const { AIProvider, registerProvider, quoteShellArgs, modelMatches } = require('./provider');
20
20
  const logger = require('../utils/logger');
21
21
  const { extractJSON } = require('../utils/json-extractor');
22
22
  const { CancellationError, isAnalysisCancelled } = require('../routes/shared');
@@ -29,11 +29,23 @@ const BIN_DIR = path.join(__dirname, '..', '..', 'bin');
29
29
  /**
30
30
  * Cursor Agent model definitions with tier mappings
31
31
  *
32
- * Tier structure:
32
+ * Tier structure (as of November 2026):
33
33
  * - free (auto): Cursor's default auto-routing model
34
- * - fast (composer-2-fast, gpt-5.3-codex-fast, gemini-3-flash): Quick analysis
35
- * - balanced (composer-1.5 (default), sonnet-4.6-thinking, sonnet-4.5-thinking, gemini-3.1-pro): Recommended for most reviews
36
- * - thorough (composer-2, gpt-5.3-codex-high, gpt-5.3-codex-xhigh, opus-4.5-thinking, opus-4.6-thinking): Deep analysis for complex code
34
+ * - fast (composer-2.5-fast): Quick analysis
35
+ * - balanced (composer-2.5 (default)): Recommended for most reviews
36
+ * - thorough (gpt-5.3-codex-high): Deep analysis for complex code
37
+ *
38
+ * Any other model the account has enabled can be passed verbatim with --model
39
+ * (see `cursor-agent --list-models`) or added via `providers.cursor-agent.models`.
40
+ * Models and prices: cursor.com/docs/models
41
+ *
42
+ * Deprecated (November 2026): composer-2 (alias → composer-2.5, same line and
43
+ * price), composer-2-fast, composer-1.5 (Composer models superseded by
44
+ * Composer 2.5); gpt-5.3-codex-fast, gpt-5.3-codex-xhigh, gpt-5.4-high,
45
+ * gpt-5.4-medium, sonnet-4.5-thinking, sonnet-4.6-thinking, opus-4.5-thinking,
46
+ * opus-4.6-thinking, gemini-3-flash, gemini-3.1-pro (older generations, hidden
47
+ * by default in Cursor). Only composer-2 is aliased; the others' successors are
48
+ * different generations at different prices.
37
49
  */
38
50
  const CURSOR_AGENT_MODELS = [
39
51
  {
@@ -46,131 +58,33 @@ const CURSOR_AGENT_MODELS = [
46
58
  badgeClass: 'badge-speed'
47
59
  },
48
60
  {
49
- id: 'composer-2',
50
- name: 'Composer 2',
51
- tier: 'thorough',
52
- tagline: 'Latest Composer',
53
- description: 'Frontier-level coding model trained with compaction-in-the-loop RL—strong on long-horizon tasks requiring hundreds of actions',
54
- badge: 'Latest',
55
- badgeClass: 'badge-power'
56
- },
57
- {
58
- id: 'composer-2-fast',
59
- name: 'Composer 2 Fast',
61
+ id: 'composer-2.5-fast',
62
+ name: 'Composer 2.5 Fast',
60
63
  tier: 'fast',
61
64
  tagline: 'Fast Composer',
62
- description: 'Same intelligence as Composer 2 with lower latency—default for interactive Cursor sessions',
63
- badge: 'Fast',
64
- badgeClass: 'badge-speed'
65
- },
66
- {
67
- id: 'composer-1.5',
68
- name: 'Composer 1.5',
69
- tier: 'balanced',
70
- tagline: 'Previous Composer',
71
- description: 'Previous generation Cursor Composer model—positioned between Sonnet and Opus for multi-file edits',
72
- badge: 'Previous Gen',
73
- badgeClass: 'badge-balanced',
74
- default: true
75
- },
76
- {
77
- id: 'gpt-5.3-codex-fast',
78
- name: 'GPT-5.3 Codex Fast',
79
- tier: 'fast',
80
- tagline: 'Lightning Fast',
81
- description: 'Latest code-specialized model optimized for speed—quick scans for obvious issues',
82
- badge: 'Fastest',
83
- badgeClass: 'badge-speed'
84
- },
85
- {
86
- id: 'gemini-3-flash',
87
- name: 'Gemini 3 Flash',
88
- tier: 'fast',
89
- tagline: 'Fast & Capable',
90
- description: 'High SWE-bench scores at a fraction of the cost—great for quick reviews',
65
+ description: 'Same intelligence as Composer 2.5 with lower latency—quick scans for obvious issues',
91
66
  badge: 'Fast',
92
67
  badgeClass: 'badge-speed'
93
68
  },
94
69
  {
95
- id: 'sonnet-4.6-thinking',
96
- name: 'Claude 4.6 Sonnet (Thinking)',
70
+ id: 'composer-2.5',
71
+ name: 'Composer 2.5',
97
72
  tier: 'balanced',
98
73
  tagline: 'Best Balance',
99
- description: 'Latest Sonnet with extended thinking—excellent quality-to-cost ratio for thorough reviews',
74
+ description: "Cursor's latest in-house coding model—near-frontier review quality at a fraction of the cost",
100
75
  badge: 'Recommended',
101
- badgeClass: 'badge-recommended'
102
- },
103
- {
104
- id: 'sonnet-4.5-thinking',
105
- name: 'Claude 4.5 Sonnet (Thinking)',
106
- tier: 'balanced',
107
- tagline: 'Previous Gen',
108
- description: 'Previous generation extended thinking—still strong for thorough analysis',
109
- badge: 'Previous Gen',
110
- badgeClass: 'badge-balanced'
111
- },
112
- {
113
- id: 'gemini-3.1-pro',
114
- name: 'Gemini 3.1 Pro',
115
- tier: 'balanced',
116
- tagline: 'Latest Gemini',
117
- description: 'Newest Gemini model—cutting-edge reasoning for complex multi-file reviews',
118
- badge: 'Latest',
119
- badgeClass: 'badge-balanced'
76
+ badgeClass: 'badge-recommended',
77
+ default: true,
78
+ aliases: ['composer-2']
120
79
  },
121
80
  {
122
81
  id: 'gpt-5.3-codex-high',
123
82
  name: 'GPT-5.3 Codex High',
124
83
  tier: 'thorough',
125
84
  tagline: 'Deep Code Analysis',
126
- description: "OpenAI's latest and most capable for complex code review with deep reasoning",
127
- badge: 'Thorough',
128
- badgeClass: 'badge-power'
129
- },
130
- {
131
- id: 'gpt-5.3-codex-xhigh',
132
- name: 'GPT-5.3 Codex Extra High',
133
- tier: 'thorough',
134
- tagline: 'Maximum Reasoning',
135
- description: 'Highest reasoning effort for the most complex architectural reviews',
136
- badge: 'Maximum',
137
- badgeClass: 'badge-power'
138
- },
139
- {
140
- id: 'opus-4.5-thinking',
141
- name: 'Claude 4.5 Opus (Thinking)',
142
- tier: 'thorough',
143
- tagline: 'Deep Analysis',
144
- description: 'Deep analysis with extended thinking for complex code reviews',
145
- badge: 'Thorough',
146
- badgeClass: 'badge-power'
147
- },
148
- {
149
- id: 'opus-4.6-thinking',
150
- name: 'Claude 4.6 Opus (Thinking)',
151
- tier: 'thorough',
152
- tagline: 'Most Capable',
153
- description: 'Deep analysis with extended thinking—Cursor default for maximum review quality',
85
+ description: 'Code-specialized OpenAI model with high reasoning effort for complex multi-file reviews',
154
86
  badge: 'Most Thorough',
155
87
  badgeClass: 'badge-power'
156
- },
157
- {
158
- id: 'gpt-5.4-high',
159
- name: 'GPT-5.4 High',
160
- tier: 'thorough',
161
- tagline: 'Latest OpenAI',
162
- description: 'Latest generation with high reasoning effort—strong for complex architectural reviews',
163
- badge: 'Latest Gen',
164
- badgeClass: 'badge-power'
165
- },
166
- {
167
- id: 'gpt-5.4-medium',
168
- name: 'GPT-5.4',
169
- tier: 'thorough',
170
- tagline: 'Latest Gen',
171
- description: 'Latest generation at medium reasoning depth',
172
- badge: 'Latest',
173
- badgeClass: 'badge-power'
174
88
  }
175
89
  ];
176
90
 
@@ -232,24 +146,21 @@ class CursorAgentProvider extends AIProvider {
232
146
  const permissionArgs = configOverrides.yolo
233
147
  ? ['--yolo']
234
148
  : ['--trust', '--sandbox', 'enabled'];
235
- const baseArgs = ['-p', '--output-format', 'stream-json', '--stream-partial-output', '--model', model, ...permissionArgs];
236
- const providerArgs = configOverrides.extra_args || [];
237
- const modelConfig = configOverrides.models?.find(m => m.id === model);
238
- const modelArgs = modelConfig?.extra_args || [];
149
+ // Alias-aware: `--model` gets the canonical id and the override is matched on
150
+ // the union of selector, canonical id and aliases (see _resolveModelConfig).
151
+ const { cliModel, extraArgs, env } = this._resolveModelConfig(model);
152
+ const baseArgs = ['-p', '--output-format', 'stream-json', '--stream-partial-output', '--model', cliModel, ...permissionArgs];
239
153
 
240
154
  // Merge env: provider env + model env
241
- this.extraEnv = {
242
- ...(configOverrides.env || {}),
243
- ...(modelConfig?.env || {})
244
- };
155
+ this.extraEnv = env;
245
156
 
246
157
  if (this.useShell) {
247
158
  // In shell mode, build full command string with args
248
- this.command = `${agentCmd} ${quoteShellArgs([...baseArgs, ...providerArgs, ...modelArgs]).join(' ')}`;
159
+ this.command = `${agentCmd} ${quoteShellArgs([...baseArgs, ...extraArgs]).join(' ')}`;
249
160
  this.args = [];
250
161
  } else {
251
162
  this.command = agentCmd;
252
- this.args = [...baseArgs, ...providerArgs, ...modelArgs];
163
+ this.args = [...baseArgs, ...extraArgs];
253
164
  }
254
165
  }
255
166
 
@@ -760,16 +671,64 @@ class CursorAgentProvider extends AIProvider {
760
671
  * @returns {string[]} Complete args array for the CLI
761
672
  */
762
673
  buildArgsForModel(model) {
674
+ // Provider extra_args + model extra_args, resolved alias-aware
675
+ const { cliModel, extraArgs } = this._resolveModelConfig(model);
763
676
  // Base args for extraction (text output, no tools needed)
764
677
  // --trust needed to auto-approve the working directory without interactive prompt
765
- const baseArgs = ['-p', '--output-format', 'text', '--trust', '--model', model];
766
- // Provider-level extra_args (from configOverrides)
767
- const providerArgs = this.configOverrides?.extra_args || [];
768
- // Model-specific extra_args (from the model config for the given model)
769
- const modelConfig = this.configOverrides?.models?.find(m => m.id === model);
770
- const modelArgs = modelConfig?.extra_args || [];
771
-
772
- return [...baseArgs, ...providerArgs, ...modelArgs];
678
+ const baseArgs = ['-p', '--output-format', 'text', '--trust', '--model', cliModel];
679
+
680
+ return [...baseArgs, ...extraArgs];
681
+ }
682
+
683
+ /**
684
+ * Resolve merged env (provider env + model env) for the given model.
685
+ * Same merge the constructor applies for the analysis model, so the
686
+ * extraction model (possibly a different fast-tier model) gets its own env.
687
+ *
688
+ * @param {string} model - The model identifier
689
+ * @returns {Object} Env vars to merge into the child environment
690
+ */
691
+ _resolveEnvForModel(model) {
692
+ return this._resolveModelConfig(model).env;
693
+ }
694
+
695
+ /**
696
+ * Single id-or-alias resolution shared by the analysis constructor, the
697
+ * extraction args, and the extraction env, so the same selector always runs
698
+ * the same model with the same override.
699
+ *
700
+ * - The built-in entry matches by canonical id or alias (`composer-2` →
701
+ * `composer-2.5`).
702
+ * - A `providers.cursor-agent.models` override matches on the union of the
703
+ * selector, the built-in's canonical id, and its aliases, or by one of the
704
+ * override's own aliases. `applyConfigOverrides()` stores alias-keyed
705
+ * overrides under the canonical id, so an exact-id match would miss them.
706
+ * - `--model` gets the canonical id. Unknown ids pass through verbatim, so
707
+ * any model the account enables can still be named directly.
708
+ *
709
+ * @param {string} modelId - Selector (canonical id, alias, or any Cursor id)
710
+ * @returns {{ builtIn: Object|undefined, configModel: Object|undefined, cliModel: string, extraArgs: string[], env: Object }}
711
+ * @private
712
+ */
713
+ _resolveModelConfig(modelId) {
714
+ const configOverrides = this.configOverrides || {};
715
+
716
+ const builtIn = CURSOR_AGENT_MODELS.find(m => modelMatches(m, modelId));
717
+ const modelKeys = new Set([modelId, builtIn?.id, ...(builtIn?.aliases || [])].filter(Boolean));
718
+ const configModel = configOverrides.models?.find(
719
+ m => modelKeys.has(m.id) || (m.aliases || []).some(a => modelKeys.has(a))
720
+ );
721
+
722
+ const cliModel = builtIn?.id || configModel?.id || modelId;
723
+
724
+ // Merge: provider config → per-model config (built-ins carry no args/env)
725
+ const extraArgs = [...(configOverrides.extra_args || []), ...(configModel?.extra_args || [])];
726
+ const env = {
727
+ ...(configOverrides.env || {}),
728
+ ...(configModel?.env || {})
729
+ };
730
+
731
+ return { builtIn, configModel, cliModel, extraArgs, env };
773
732
  }
774
733
 
775
734
  /**
@@ -785,6 +744,7 @@ class CursorAgentProvider extends AIProvider {
785
744
 
786
745
  // Build args consistently using the shared method, applying provider and model extra_args
787
746
  const args = this.buildArgsForModel(model);
747
+ const env = this._resolveEnvForModel(model);
788
748
 
789
749
  // For extraction, we pass the prompt via stdin
790
750
  if (useShell) {
@@ -792,14 +752,16 @@ class CursorAgentProvider extends AIProvider {
792
752
  command: `${agentCmd} ${quoteShellArgs(args).join(' ')}`,
793
753
  args: [],
794
754
  useShell: true,
795
- promptViaStdin: true
755
+ promptViaStdin: true,
756
+ env
796
757
  };
797
758
  }
798
759
  return {
799
760
  command: agentCmd,
800
761
  args,
801
762
  useShell: false,
802
- promptViaStdin: true
763
+ promptViaStdin: true,
764
+ env
803
765
  };
804
766
  }
805
767
 
@@ -576,6 +576,22 @@ class OpenCodeProvider extends AIProvider {
576
576
  return [...baseArgs, ...providerArgs, ...modelArgs];
577
577
  }
578
578
 
579
+ /**
580
+ * Resolve merged env (provider env + model env) for the given model.
581
+ * Same merge the constructor applies for the analysis model, so the
582
+ * extraction model (possibly a different fast-tier model) gets its own env.
583
+ *
584
+ * @param {string} model - The model identifier
585
+ * @returns {Object} Env vars to merge into the child environment
586
+ */
587
+ _resolveEnvForModel(model) {
588
+ const modelConfig = this.configOverrides?.models?.find(m => m.id === model);
589
+ return {
590
+ ...(this.configOverrides?.env || {}),
591
+ ...(modelConfig?.env || {})
592
+ };
593
+ }
594
+
579
595
  /**
580
596
  * Get CLI configuration for LLM extraction
581
597
  * @param {string} model - The model to use for extraction
@@ -589,6 +605,7 @@ class OpenCodeProvider extends AIProvider {
589
605
 
590
606
  // Build args consistently using the shared method, applying provider and model extra_args
591
607
  const args = this.buildArgsForModel(model);
608
+ const env = this._resolveEnvForModel(model);
592
609
 
593
610
  // For extraction, we pass the prompt via stdin
594
611
  // OpenCode reads from stdin when no positional message arguments are provided
@@ -597,14 +614,16 @@ class OpenCodeProvider extends AIProvider {
597
614
  command: `${opencodeCmd} ${quoteShellArgs(args).join(' ')}`,
598
615
  args: [],
599
616
  useShell: true,
600
- promptViaStdin: true
617
+ promptViaStdin: true,
618
+ env
601
619
  };
602
620
  }
603
621
  return {
604
622
  command: opencodeCmd,
605
623
  args,
606
624
  useShell: false,
607
- promptViaStdin: true
625
+ promptViaStdin: true,
626
+ env
608
627
  };
609
628
  }
610
629
 
@@ -594,7 +594,7 @@ function resolveCliModelConfig(builtIn, configModel, modelId) {
594
594
  * Match a model definition against a selector that may be the model's canonical
595
595
  * id OR one of its aliases. Used by config-driven selectors (`default_model`,
596
596
  * `models` overrides) so legacy config naming an alias (e.g.
597
- * `opus`, an alias of the canonical `opus-5.5-xhigh`) keeps working.
597
+ * `opus`, an alias of the canonical `opus-5.5-high`) keeps working.
598
598
  *
599
599
  * Optional-chaining is intentional: a model with no `aliases` short-circuits to
600
600
  * undefined/falsy, so no Array.isArray guard is needed.
@@ -785,7 +785,7 @@ function applyConfigOverrides(config) {
785
785
 
786
786
  // Canonicalize alias-keyed override ids to their built-in canonical id.
787
787
  // A config entry may key a model by a short alias (e.g. `opus` for the
788
- // canonical `opus-5.5-xhigh`). mergeModels() already resolves aliases for the
788
+ // canonical `opus-5.5-high`). mergeModels() already resolves aliases for the
789
789
  // display/metadata path, but the runtime path forwards this raw `models` array
790
790
  // to the provider instance, where per-model config is looked up by EXACT id
791
791
  // (e.g. `configOverrides.models.find(m => m.id === model)`). The frontend
@@ -897,7 +897,7 @@ function mergeModels(builtInModels, configModels) {
897
897
  }
898
898
  // Replace overridden built-ins in-place to preserve display order. An override
899
899
  // matched by alias (e.g. config `{ id: 'opus' }` against built-in
900
- // `opus-5.5-xhigh`) still replaces, but keeps the canonical built-in id.
900
+ // `opus-5.5-high`) still replaces, but keeps the canonical built-in id.
901
901
  const matched = new Set();
902
902
  const merged = builtInModels.map(bm => {
903
903
  const override = configModels.find(cm => modelMatches(bm, cm.id));
@@ -110,7 +110,7 @@ class ChatSessionManager extends EventEmitter {
110
110
  const selector = model || providerDef?.model || null;
111
111
 
112
112
  // Canonicalise BEFORE the INSERT. Both the request and `chat_providers.<id>.model`
113
- // may name a model by alias (`opus` -> `opus-5.5-xhigh`); storing the alias would
113
+ // may name a model by alias (`opus` -> `opus-5.5-high`); storing the alias would
114
114
  // leave the sessions list, the hook payload, and the picker's checkmark disagreeing
115
115
  // with the catalog. `resolution.id` is exactly what to store: the canonical id when
116
116
  // known, the raw selector for a passthrough (raw CLI strings are supported), and