@link-assistant/hive-mind 1.16.1 → 1.17.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @link-assistant/hive-mind
2
2
 
3
+ ## 1.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 52cef77: feat: automatic solve option forwarding from hive config (issue #1209)
8
+
9
+ Refactored hive-to-solve option forwarding to be fully automatic. New solve options are now
10
+ automatically available in hive and TELEGRAM_HIVE_OVERRIDES without manual code changes.
11
+ - Extracted `SOLVE_OPTION_DEFINITIONS` from solve.config.lib.mjs as a shared data structure
12
+ - hive.config.lib.mjs auto-registers all solve options (minus hive-only and solve-only exclusions)
13
+ - hive.mjs uses a generic forwarding loop instead of per-option if statements
14
+ - Added `getSolvePassthroughOptionNames()` export for programmatic access to passthrough list
15
+
3
16
  ## 1.16.1
4
17
 
5
18
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/hive-mind",
3
- "version": "1.16.1",
3
+ "version": "1.17.0",
4
4
  "description": "AI-powered issue solver and hive mind for collaborative problem solving",
5
5
  "main": "src/hive.mjs",
6
6
  "type": "module",
@@ -3,8 +3,71 @@
3
3
  // when only the yargs configuration is needed (e.g., in telegram-bot.mjs)
4
4
  // This module has no heavy dependencies to allow fast loading for --help
5
5
 
6
+ import { SOLVE_OPTION_DEFINITIONS } from './solve.config.lib.mjs';
7
+
8
+ // Hive-only options that are NOT solve options (hive-specific functionality).
9
+ // These are excluded when auto-registering solve-passthrough options.
10
+ const HIVE_ONLY_OPTION_NAMES = new Set(['monitor-tag', 'all-issues', 'skip-issues-with-prs', 'concurrency', 'pull-requests-per-issue', 'interval', 'max-issues', 'once', 'project-number', 'project-owner', 'project-status', 'project-mode', 'youtrack-mode', 'youtrack-stage', 'youtrack-project', 'target-branch', 'issue-order']);
11
+
12
+ // Solve-only options that should NOT be registered in hive
13
+ // (they are internal to solve and not meaningful when passed from hive)
14
+ const SOLVE_ONLY_OPTION_NAMES = new Set(['resume', 'working-directory', 'only-prepare-command', 'session-type']);
15
+
16
+ // Options that hive defines with different defaults/descriptions than solve.
17
+ // These are registered manually in hive config to preserve hive-specific behavior.
18
+ // All other solve options are auto-registered from SOLVE_OPTION_DEFINITIONS.
19
+ const HIVE_CUSTOM_SOLVE_OPTIONS = {
20
+ model: {
21
+ type: 'string',
22
+ description: 'Model to use for solve (opus, sonnet, haiku, haiku-3-5, haiku-3, or any model ID supported by the tool)',
23
+ alias: 'm',
24
+ default: 'sonnet',
25
+ },
26
+ 'dry-run': {
27
+ type: 'boolean',
28
+ description: 'List issues that would be processed without actually processing them',
29
+ default: false,
30
+ },
31
+ 'auto-continue': {
32
+ type: 'boolean',
33
+ description: 'Pass --auto-continue to solve for each issue (continues with existing PRs instead of creating new ones)',
34
+ default: true,
35
+ },
36
+ 'auto-resume-on-limit-reset': {
37
+ type: 'boolean',
38
+ description: 'Automatically resume when AI tool limit resets (calculates reset time and waits). Passed to solve command.',
39
+ default: false,
40
+ },
41
+ 'auto-cleanup': {
42
+ type: 'boolean',
43
+ description: 'Automatically clean temporary directories (/tmp/* /var/tmp/*) when finished successfully',
44
+ default: false,
45
+ },
46
+ tool: {
47
+ type: 'string',
48
+ description: 'AI tool to use for solving issues',
49
+ choices: ['claude', 'opencode', 'agent'],
50
+ default: 'claude',
51
+ },
52
+ };
53
+
54
+ // Compute the set of solve options that hive auto-registers from SOLVE_OPTION_DEFINITIONS.
55
+ // This is exported so hive.mjs can use it for automatic argument forwarding.
56
+ // An option is auto-registered if it: (1) exists in solve, (2) is not hive-only,
57
+ // (3) is not solve-only, and (4) is not customized in hive.
58
+ export const getSolvePassthroughOptionNames = () => {
59
+ const names = [];
60
+ for (const name of Object.keys(SOLVE_OPTION_DEFINITIONS)) {
61
+ if (HIVE_ONLY_OPTION_NAMES.has(name)) continue;
62
+ if (SOLVE_ONLY_OPTION_NAMES.has(name)) continue;
63
+ // Include both custom and auto-registered options as passthrough
64
+ names.push(name);
65
+ }
66
+ return names;
67
+ };
68
+
6
69
  export const createYargsConfig = yargsInstance => {
7
- return yargsInstance
70
+ let config = yargsInstance
8
71
  .command('$0 [github-url]', 'Monitor GitHub issues and create PRs', yargs => {
9
72
  yargs.positional('github-url', {
10
73
  type: 'string',
@@ -27,7 +90,10 @@ export const createYargsConfig = yargsInstance => {
27
90
  error.cause = err;
28
91
  }
29
92
  throw error;
30
- })
93
+ });
94
+
95
+ // Register hive-only options
96
+ config = config
31
97
  .option('monitor-tag', {
32
98
  type: 'string',
33
99
  description: 'GitHub label to monitor for issues',
@@ -58,12 +124,6 @@ export const createYargsConfig = yargsInstance => {
58
124
  default: 1,
59
125
  alias: 'p',
60
126
  })
61
- .option('model', {
62
- type: 'string',
63
- description: 'Model to use for solve (opus, sonnet, haiku, haiku-3-5, haiku-3, or any model ID supported by the tool)',
64
- alias: 'm',
65
- default: 'sonnet',
66
- })
67
127
  .option('interval', {
68
128
  type: 'number',
69
129
  description: 'Polling interval in seconds',
@@ -75,83 +135,11 @@ export const createYargsConfig = yargsInstance => {
75
135
  description: 'Maximum number of issues to process (0 = unlimited)',
76
136
  default: 0,
77
137
  })
78
- .option('dry-run', {
79
- type: 'boolean',
80
- description: 'List issues that would be processed without actually processing them',
81
- default: false,
82
- })
83
- .option('skip-tool-connection-check', {
84
- type: 'boolean',
85
- description: 'Skip tool connection check (useful in CI environments). Does NOT skip model validation.',
86
- default: false,
87
- })
88
- .option('skip-tool-check', {
89
- type: 'boolean',
90
- description: 'Alias for --skip-tool-connection-check (deprecated, use --skip-tool-connection-check instead)',
91
- default: false,
92
- hidden: true,
93
- })
94
- .option('skip-claude-check', {
95
- type: 'boolean',
96
- description: 'Alias for --skip-tool-connection-check (deprecated)',
97
- default: false,
98
- hidden: true,
99
- })
100
- .option('tool-connection-check', {
101
- type: 'boolean',
102
- description: 'Perform tool connection check (enabled by default, use --no-tool-connection-check to skip). Does NOT affect model validation.',
103
- default: true,
104
- hidden: true,
105
- })
106
- .option('tool-check', {
107
- type: 'boolean',
108
- description: 'Alias for --tool-connection-check (deprecated)',
109
- default: true,
110
- hidden: true,
111
- })
112
- .option('tool', {
113
- type: 'string',
114
- description: 'AI tool to use for solving issues',
115
- choices: ['claude', 'opencode', 'agent'],
116
- default: 'claude',
117
- })
118
- .option('verbose', {
119
- type: 'boolean',
120
- description: 'Enable verbose logging',
121
- alias: 'v',
122
- default: false,
123
- })
124
138
  .option('once', {
125
139
  type: 'boolean',
126
140
  description: 'Run once and exit instead of continuous monitoring',
127
141
  default: false,
128
142
  })
129
- .option('min-disk-space', {
130
- type: 'number',
131
- description: 'Minimum required disk space in MB (default: 2048)',
132
- default: 2048,
133
- })
134
- .option('auto-cleanup', {
135
- type: 'boolean',
136
- description: 'Automatically clean temporary directories (/tmp/* /var/tmp/*) when finished successfully',
137
- default: false,
138
- })
139
- .option('fork', {
140
- type: 'boolean',
141
- description: "Fork the repository if you don't have write access",
142
- alias: 'f',
143
- default: false,
144
- })
145
- .option('auto-fork', {
146
- type: 'boolean',
147
- description: 'Automatically fork public repos without write access (passed to solve command)',
148
- default: true,
149
- })
150
- .option('attach-logs', {
151
- type: 'boolean',
152
- description: 'Upload the solution draft log file to the Pull Request on completion (⚠️ WARNING: May expose sensitive data)',
153
- default: false,
154
- })
155
143
  .option('project-number', {
156
144
  type: 'number',
157
145
  description: 'GitHub Project number to monitor',
@@ -192,135 +180,32 @@ export const createYargsConfig = yargsInstance => {
192
180
  description: 'Target branch for pull requests (defaults to repository default branch)',
193
181
  alias: 'tb',
194
182
  })
195
- .option('log-dir', {
196
- type: 'string',
197
- description: 'Directory to save log files (defaults to current working directory)',
198
- alias: 'l',
199
- })
200
- .option('auto-continue', {
201
- type: 'boolean',
202
- description: 'Pass --auto-continue to solve for each issue (continues with existing PRs instead of creating new ones)',
203
- default: true,
204
- })
205
- .option('auto-resume-on-limit-reset', {
206
- type: 'boolean',
207
- description: 'Automatically resume when AI tool limit resets (calculates reset time and waits). Passed to solve command.',
208
- default: false,
209
- })
210
- .option('think', {
211
- type: 'string',
212
- description: 'Thinking level for Claude. Translated to --thinking-budget for Claude Code >= 2.1.12 (off=0, low=~8000, medium=~16000, high=~24000, max=31999). For older versions, uses thinking keywords.',
213
- choices: ['off', 'low', 'medium', 'high', 'max'],
214
- default: undefined,
215
- })
216
- .option('thinking-budget', {
217
- type: 'number',
218
- description: 'Thinking token budget for Claude Code (0-63999). Controls MAX_THINKING_TOKENS. Default: 31999 (Claude default). Set to 0 to disable thinking.',
219
- default: undefined,
220
- })
221
- .option('max-thinking-budget', {
222
- type: 'number',
223
- description: 'Maximum thinking budget for calculating --think level mappings (default: 31999 for Claude Code). Values: off=0, low=max/4, medium=max/2, high=max*3/4, max=max.',
224
- default: 31999,
225
- })
226
- .option('prompt-plan-sub-agent', {
227
- type: 'boolean',
228
- description: 'Encourage AI to use Plan sub-agent for initial planning (only works with --tool claude)',
229
- default: false,
230
- })
231
- .option('sentry', {
232
- type: 'boolean',
233
- description: 'Enable Sentry error tracking and monitoring (use --no-sentry to disable)',
234
- default: true,
235
- })
236
- .option('watch', {
237
- type: 'boolean',
238
- description: 'Monitor continuously for feedback and auto-restart when detected (stops when PR is merged)',
239
- alias: 'w',
240
- default: false,
241
- })
242
- .option('auto-merge', {
243
- type: 'boolean',
244
- description: 'Automatically merge the pull request when the working session is finished and all CI/CD statuses pass and PR is mergeable. Implies --auto-restart-until-mergable.',
245
- default: false,
246
- })
247
- .option('auto-restart-until-mergable', {
248
- type: 'boolean',
249
- description: 'Auto-restart until PR becomes mergeable (no iteration limit). Restarts on new comments from non-bot users, CI failures, merge conflicts, or other issues. Does NOT auto-merge.',
250
- default: false,
251
- })
252
183
  .option('issue-order', {
253
184
  type: 'string',
254
185
  description: 'Order issues by publication date: "asc" (oldest first) or "desc" (newest first)',
255
186
  alias: 'o',
256
187
  default: 'asc',
257
188
  choices: ['asc', 'desc'],
258
- })
259
- .option('prefix-fork-name-with-owner-name', {
260
- type: 'boolean',
261
- description: 'Prefix fork name with original owner name (e.g., "owner-repo" instead of "repo"). Useful when forking repositories with same name from different owners.',
262
- default: true,
263
- })
264
- .option('interactive-mode', {
265
- type: 'boolean',
266
- description: '[EXPERIMENTAL] Post Claude output as PR comments in real-time. Only supported for --tool claude.',
267
- default: false,
268
- })
269
- .option('prompt-explore-sub-agent', {
270
- type: 'boolean',
271
- description: 'Encourage Claude to use Explore sub-agent for codebase exploration. Only supported for --tool claude.',
272
- default: false,
273
- })
274
- .option('prompt-general-purpose-sub-agent', {
275
- type: 'boolean',
276
- description: 'Prompt AI to use general-purpose sub agents for processing large tasks with multiple files/folders. Only supported for --tool claude.',
277
- default: false,
278
- })
279
- .option('tokens-budget-stats', {
280
- type: 'boolean',
281
- description: '[EXPERIMENTAL] Show detailed token budget statistics including context window usage and ratios. Only supported for --tool claude.',
282
- default: false,
283
- })
284
- .option('prompt-issue-reporting', {
285
- type: 'boolean',
286
- description: 'Enable automatic issue creation for spotted bugs/errors not related to main task. Issues will include reproducible examples, workarounds, and fix suggestions. Works for both current and third-party repositories. Only supported for --tool claude.',
287
- default: false,
288
- })
289
- .option('prompt-case-studies', {
290
- type: 'boolean',
291
- description: 'Create comprehensive case study documentation for the issue including logs, analysis, timeline, root cause investigation, and proposed solutions. Organizes findings into ./docs/case-studies/issue-{id}/ directory. Only supported for --tool claude.',
292
- default: false,
293
- })
294
- .option('prompt-playwright-mcp', {
295
- type: 'boolean',
296
- description: 'Enable Playwright MCP browser automation hints in system prompt (enabled by default, only takes effect if Playwright MCP is installed). Use --no-prompt-playwright-mcp to disable. Only supported for --tool claude.',
297
- default: true,
298
- })
299
- .option('prompt-check-sibling-pull-requests', {
300
- type: 'boolean',
301
- description: 'Include prompt to check related/sibling pull requests when studying related work. Enabled by default, use --no-prompt-check-sibling-pull-requests to disable.',
302
- default: true,
303
- })
304
- .option('prompt-experiments-folder', {
305
- type: 'string',
306
- description: 'Path to experiments folder used in system prompt. Set to empty string to disable experiments folder prompt. Default: ./experiments',
307
- default: './experiments',
308
- })
309
- .option('prompt-examples-folder', {
310
- type: 'string',
311
- description: 'Path to examples folder used in system prompt. Set to empty string to disable examples folder prompt. Default: ./examples',
312
- default: './examples',
313
- })
314
- .option('prompt-architecture-care', {
315
- type: 'boolean',
316
- description: '[EXPERIMENTAL] Include guidance for managing REQUIREMENTS.md and ARCHITECTURE.md files. When enabled, agents will update these documentation files when changes affect requirements or architecture.',
317
- default: false,
318
- })
319
- .option('execute-tool-with-bun', {
320
- type: 'boolean',
321
- description: 'Execute the AI tool using bunx (experimental, may improve speed and memory usage) - passed to solve command',
322
- default: false,
323
- })
189
+ });
190
+
191
+ // Register options with hive-specific customizations (different defaults/descriptions than solve)
192
+ for (const [name, def] of Object.entries(HIVE_CUSTOM_SOLVE_OPTIONS)) {
193
+ config = config.option(name, def);
194
+ }
195
+
196
+ // Auto-register all remaining solve options as passthrough options.
197
+ // This ensures any new option added to solve.config.lib.mjs is automatically
198
+ // available in hive (and TELEGRAM_HIVE_OVERRIDES) without manual code changes.
199
+ // See: https://github.com/link-assistant/hive-mind/issues/1209
200
+ for (const [name, def] of Object.entries(SOLVE_OPTION_DEFINITIONS)) {
201
+ // Skip options that are hive-only, solve-only, or already registered with custom hive config
202
+ if (HIVE_ONLY_OPTION_NAMES.has(name)) continue;
203
+ if (SOLVE_ONLY_OPTION_NAMES.has(name)) continue;
204
+ if (name in HIVE_CUSTOM_SOLVE_OPTIONS) continue;
205
+ config = config.option(name, def);
206
+ }
207
+
208
+ config = config
324
209
  .parserConfiguration({
325
210
  'boolean-negation': true,
326
211
  'strip-dashed': false,
@@ -331,4 +216,6 @@ export const createYargsConfig = yargsInstance => {
331
216
  .strict()
332
217
  .help('h')
333
218
  .alias('h', 'help');
219
+
220
+ return config;
334
221
  };
package/src/hive.mjs CHANGED
@@ -745,36 +745,41 @@ if (isDirectExecution) {
745
745
  const startTime = Date.now();
746
746
  // Use spawn to get real-time streaming output while avoiding command-stream's automatic quote addition
747
747
  const { spawn } = await import('child_process');
748
- // Build arguments array to avoid shell parsing issues
748
+ // Auto-forward all solve-passthrough options from hive argv to solve.
749
+ // New options added to SOLVE_OPTION_DEFINITIONS are automatically forwarded.
750
+ // See: https://github.com/link-assistant/hive-mind/issues/1209
751
+ const { getSolvePassthroughOptionNames } = await import('./hive.config.lib.mjs');
752
+ const { SOLVE_OPTION_DEFINITIONS } = await import('./solve.config.lib.mjs');
753
+ const kebabToCamel = str => str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
749
754
  const args = [issueUrl, '--model', argv.model];
750
- if (argv.tool) args.push('--tool', argv.tool);
751
- if (argv.fork) args.push('--fork');
752
- if (argv.autoFork) args.push('--auto-fork');
753
- if (argv.verbose) args.push('--verbose');
754
- if (argv.attachLogs) args.push('--attach-logs');
755
- if (argv.targetBranch) args.push('--target-branch', argv.targetBranch);
756
- if (argv.logDir) args.push('--log-dir', argv.logDir);
757
- if (argv.dryRun) args.push('--dry-run');
755
+ // Special handling for options with different semantics in hive vs solve
756
+ if (argv.baseBranch) args.push('--base-branch', argv.baseBranch);
757
+ else if (argv.targetBranch) args.push('--base-branch', argv.targetBranch);
758
758
  if (argv.skipToolConnectionCheck || argv.toolConnectionCheck === false) args.push('--skip-tool-connection-check');
759
- args.push(argv.autoContinue ? '--auto-continue' : '--no-auto-continue');
760
- if (argv.autoResumeOnLimitReset) args.push('--auto-resume-on-limit-reset');
761
- if (argv.think) args.push('--think', argv.think);
762
- if (argv.thinkingBudget !== undefined) args.push('--thinking-budget', argv.thinkingBudget);
763
- if (argv.maxThinkingBudget !== undefined && argv.maxThinkingBudget !== 31999) args.push('--max-thinking-budget', argv.maxThinkingBudget);
764
- if (argv.promptPlanSubAgent) args.push('--prompt-plan-sub-agent');
765
- if (!argv.sentry) args.push('--no-sentry');
766
- if (argv.watch) args.push('--watch');
767
- if (argv.prefixForkNameWithOwnerName) args.push('--prefix-fork-name-with-owner-name');
768
- if (argv.interactiveMode) args.push('--interactive-mode');
769
- if (argv.promptExploreSubAgent) args.push('--prompt-explore-sub-agent');
770
- if (argv.promptIssueReporting) args.push('--prompt-issue-reporting');
771
- if (argv.promptCaseStudies) args.push('--prompt-case-studies');
772
- if (argv.promptPlaywrightMcp !== undefined) args.push(argv.promptPlaywrightMcp ? '--prompt-playwright-mcp' : '--no-prompt-playwright-mcp');
773
- if (argv.promptExperimentsFolder !== undefined) args.push('--prompt-experiments-folder', argv.promptExperimentsFolder);
774
- if (argv.promptExamplesFolder !== undefined) args.push('--prompt-examples-folder', argv.promptExamplesFolder);
775
- if (argv.executeToolWithBun) args.push('--execute-tool-with-bun');
776
- if (argv.autoMerge) args.push('--auto-merge');
777
- if (argv.autoRestartUntilMergable) args.push('--auto-restart-until-mergable');
759
+ if (argv.dryRun) args.push('--dry-run');
760
+ if (argv.autoCleanup) args.push('--auto-cleanup'); // hive default differs from solve's auto-detect default
761
+
762
+ // Options already handled above or deprecated aliases (skip in generic loop)
763
+ const SKIP_AUTO_FORWARD = new Set(['model', 'base-branch', 'skip-tool-connection-check', 'tool-connection-check', 'skip-tool-check', 'skip-claude-check', 'tool-check', 'dry-run', 'auto-cleanup']);
764
+
765
+ for (const optionName of getSolvePassthroughOptionNames()) {
766
+ if (SKIP_AUTO_FORWARD.has(optionName)) continue;
767
+ const camelName = kebabToCamel(optionName);
768
+ const value = argv[camelName];
769
+ const def = SOLVE_OPTION_DEFINITIONS[optionName];
770
+ if (!def) continue;
771
+ if (def.type === 'boolean') {
772
+ if (value === undefined) continue;
773
+ // For booleans with default true or undefined, forward both --flag and --no-flag
774
+ if (def.default === true || def.default === undefined) {
775
+ args.push(value ? `--${optionName}` : `--no-${optionName}`);
776
+ } else if (value) {
777
+ args.push(`--${optionName}`); // Default false: only forward when truthy
778
+ }
779
+ } else if ((def.type === 'string' || def.type === 'number') && value !== undefined) {
780
+ args.push(`--${optionName}`, String(value));
781
+ }
782
+ }
778
783
  // Log the actual command being executed so users can investigate/reproduce
779
784
  await log(` 📋 Command: ${solveCommand} ${args.join(' ')}`);
780
785
 
@@ -203,6 +203,18 @@ const KNOWN_OPTION_NAMES = [
203
203
  'prefix-fork-name-with-owner-name',
204
204
  'auto-restart-max-iterations',
205
205
  'auto-continue-only-on-new-comments',
206
+ 'auto-restart-on-limit-reset',
207
+ 'auto-restart-on-non-updated-pull-request-description',
208
+ 'auto-restart-until-mergable',
209
+ 'auto-merge',
210
+ 'auto-gitkeep-file',
211
+ 'playwright-mcp-auto-cleanup',
212
+ 'auto-gh-configuration-repair',
213
+ 'prompt-subagents-via-agent-commander',
214
+ 'prompt-experiments-folder',
215
+ 'prompt-examples-folder',
216
+ 'session-type',
217
+ 'working-directory',
206
218
  ];
207
219
 
208
220
  /**
@@ -22,381 +22,398 @@ export const initializeConfig = async use => {
22
22
  return { yargs, hideBin };
23
23
  };
24
24
 
25
+ // Solve option definitions as a plain data structure.
26
+ // This is the single source of truth for all solve command options.
27
+ // Exported so hive.config.lib.mjs can automatically register solve options
28
+ // without manual duplication (see issue #1209).
29
+ // NOTE: Options with function defaults (like 'model') are defined inline in createYargsConfig
30
+ // and excluded from this map since functions cannot be cleanly shared as data.
31
+ export const SOLVE_OPTION_DEFINITIONS = {
32
+ resume: {
33
+ type: 'string',
34
+ description: 'Resume from a previous session ID (when limit was reached)',
35
+ alias: 'r',
36
+ },
37
+ 'working-directory': {
38
+ type: 'string',
39
+ description: 'Use specified working directory instead of creating a new temp directory. If directory does not exist, it will be created and the repository will be cloned. Essential for --resume to work correctly with Claude Code sessions.',
40
+ alias: 'd',
41
+ },
42
+ 'only-prepare-command': {
43
+ type: 'boolean',
44
+ description: 'Only prepare and print the claude command without executing it',
45
+ },
46
+ 'dry-run': {
47
+ type: 'boolean',
48
+ description: 'Prepare everything but do not execute Claude (alias for --only-prepare-command)',
49
+ alias: 'n',
50
+ },
51
+ 'skip-tool-connection-check': {
52
+ type: 'boolean',
53
+ description: 'Skip tool connection check (useful in CI environments). Does NOT skip model validation.',
54
+ default: false,
55
+ },
56
+ 'skip-tool-check': {
57
+ type: 'boolean',
58
+ description: 'Alias for --skip-tool-connection-check (deprecated, use --skip-tool-connection-check instead)',
59
+ default: false,
60
+ hidden: true,
61
+ },
62
+ 'skip-claude-check': {
63
+ type: 'boolean',
64
+ description: 'Alias for --skip-tool-connection-check (deprecated)',
65
+ default: false,
66
+ hidden: true,
67
+ },
68
+ 'tool-connection-check': {
69
+ type: 'boolean',
70
+ description: 'Perform tool connection check (enabled by default, use --no-tool-connection-check to skip). Does NOT affect model validation.',
71
+ default: true,
72
+ hidden: true,
73
+ },
74
+ 'tool-check': {
75
+ type: 'boolean',
76
+ description: 'Alias for --tool-connection-check (deprecated)',
77
+ default: true,
78
+ hidden: true,
79
+ },
80
+ 'auto-pull-request-creation': {
81
+ type: 'boolean',
82
+ description: 'Automatically create a draft pull request before running Claude',
83
+ default: true,
84
+ },
85
+ verbose: {
86
+ type: 'boolean',
87
+ description: 'Enable verbose logging for debugging',
88
+ alias: 'v',
89
+ default: false,
90
+ },
91
+ fork: {
92
+ type: 'boolean',
93
+ description: "Fork the repository if you don't have write access",
94
+ alias: 'f',
95
+ default: false,
96
+ },
97
+ 'auto-fork': {
98
+ type: 'boolean',
99
+ description: 'Automatically fork public repositories without write access (fails for private repos)',
100
+ default: true,
101
+ },
102
+ 'claude-file': {
103
+ type: 'boolean',
104
+ description: 'Create CLAUDE.md file for task details (default for --tool claude, mutually exclusive with --gitkeep-file)',
105
+ default: true,
106
+ },
107
+ 'gitkeep-file': {
108
+ type: 'boolean',
109
+ description: 'Create .gitkeep file instead of CLAUDE.md (default for --tool agent/opencode/codex, mutually exclusive with --claude-file)',
110
+ default: false,
111
+ },
112
+ 'auto-gitkeep-file': {
113
+ type: 'boolean',
114
+ description: 'Automatically use .gitkeep if CLAUDE.md is in .gitignore (pre-checks before creating file)',
115
+ default: true,
116
+ },
117
+ 'attach-logs': {
118
+ type: 'boolean',
119
+ description: 'Upload the solution draft log file to the Pull Request on completion (⚠️ WARNING: May expose sensitive data)',
120
+ default: false,
121
+ },
122
+ 'auto-close-pull-request-on-fail': {
123
+ type: 'boolean',
124
+ description: 'Automatically close the pull request if execution fails',
125
+ default: false,
126
+ },
127
+ 'auto-continue': {
128
+ type: 'boolean',
129
+ description: 'Continue with existing PR when issue URL is provided (instead of creating new PR)',
130
+ default: true,
131
+ },
132
+ 'auto-resume-on-limit-reset': {
133
+ type: 'boolean',
134
+ description: 'Automatically resume when AI tool limit resets (maintains session context with --resume flag)',
135
+ default: false,
136
+ },
137
+ 'auto-restart-on-limit-reset': {
138
+ type: 'boolean',
139
+ description: 'Automatically restart when AI tool limit resets (fresh start without --resume flag)',
140
+ default: false,
141
+ },
142
+ 'session-type': {
143
+ type: 'string',
144
+ description: 'Internal: Session type for comment differentiation (new, resume, auto-resume, auto-restart)',
145
+ choices: ['new', 'resume', 'auto-resume', 'auto-restart'],
146
+ default: 'new',
147
+ hidden: true,
148
+ },
149
+ 'auto-resume-on-errors': {
150
+ type: 'boolean',
151
+ description: 'Automatically resume on network errors (503, etc.) with exponential backoff',
152
+ default: false,
153
+ },
154
+ 'auto-continue-only-on-new-comments': {
155
+ type: 'boolean',
156
+ description: 'Explicitly fail on absence of new comments in auto-continue or continue mode',
157
+ default: false,
158
+ },
159
+ 'auto-commit-uncommitted-changes': {
160
+ type: 'boolean',
161
+ description: 'Automatically commit and push uncommitted changes made by Claude (disabled by default)',
162
+ default: false,
163
+ },
164
+ 'auto-restart-on-uncommitted-changes': {
165
+ type: 'boolean',
166
+ description: 'Automatically restart when uncommitted changes are detected to allow the tool to handle them (default: true, use --no-auto-restart-on-uncommitted-changes to disable)',
167
+ default: true,
168
+ },
169
+ 'auto-restart-max-iterations': {
170
+ type: 'number',
171
+ description: 'Maximum number of auto-restart iterations when uncommitted changes are detected (default: 3)',
172
+ default: 3,
173
+ },
174
+ 'auto-merge': {
175
+ type: 'boolean',
176
+ description: 'Automatically merge the pull request when the working session is finished and all CI/CD statuses pass and PR is mergeable. Implies --auto-restart-until-mergable.',
177
+ default: false,
178
+ },
179
+ 'auto-restart-until-mergable': {
180
+ type: 'boolean',
181
+ description: 'Auto-restart until PR becomes mergeable (no iteration limit). Restarts on new comments from non-bot users, CI failures, merge conflicts, or other issues. Does NOT auto-merge.',
182
+ default: false,
183
+ },
184
+ 'auto-restart-on-non-updated-pull-request-description': {
185
+ type: 'boolean',
186
+ description: 'Automatically restart if PR title or description still contains auto-generated placeholder text after agent execution. Restarts with a hint about what was not updated.',
187
+ default: false,
188
+ },
189
+ 'continue-only-on-feedback': {
190
+ type: 'boolean',
191
+ description: 'Only continue if feedback is detected (works only with pull request link or issue link with --auto-continue)',
192
+ default: false,
193
+ },
194
+ watch: {
195
+ type: 'boolean',
196
+ description: 'Monitor continuously for feedback and auto-restart when detected (stops when PR is merged)',
197
+ alias: 'w',
198
+ default: false,
199
+ },
200
+ 'watch-interval': {
201
+ type: 'number',
202
+ description: 'Interval in seconds for checking feedback in watch mode (default: 60)',
203
+ default: 60,
204
+ },
205
+ 'min-disk-space': {
206
+ type: 'number',
207
+ description: 'Minimum required disk space in MB (default: 2048)',
208
+ default: 2048,
209
+ },
210
+ 'log-dir': {
211
+ type: 'string',
212
+ description: 'Directory to save log files (defaults to current working directory)',
213
+ alias: 'l',
214
+ },
215
+ think: {
216
+ type: 'string',
217
+ description: 'Thinking level for Claude. Translated to --thinking-budget for Claude Code >= 2.1.12 (off=0, low=~8000, medium=~16000, high=~24000, max=31999). For older versions, uses thinking keywords.',
218
+ choices: ['off', 'low', 'medium', 'high', 'max'],
219
+ default: undefined,
220
+ },
221
+ 'thinking-budget': {
222
+ type: 'number',
223
+ description: 'Thinking token budget for Claude Code (0-63999). Controls MAX_THINKING_TOKENS. Default: 31999 (Claude default). Set to 0 to disable thinking. For older Claude Code versions, translated back to --think level.',
224
+ default: undefined,
225
+ },
226
+ 'thinking-budget-claude-minimum-version': {
227
+ type: 'string',
228
+ description: 'Minimum Claude Code version that supports --thinking-budget (MAX_THINKING_TOKENS env var). Versions below this use thinking keywords instead.',
229
+ default: '2.1.12',
230
+ },
231
+ 'max-thinking-budget': {
232
+ type: 'number',
233
+ description: 'Maximum thinking budget for calculating --think level mappings (default: 31999 for Claude Code). Values: off=0, low=max/4, medium=max/2, high=max*3/4, max=max.',
234
+ default: 31999,
235
+ },
236
+ 'prompt-plan-sub-agent': {
237
+ type: 'boolean',
238
+ description: 'Encourage AI to use Plan sub-agent for initial planning (only works with --tool claude)',
239
+ default: false,
240
+ },
241
+ 'base-branch': {
242
+ type: 'string',
243
+ description: 'Target branch for the pull request (defaults to repository default branch)',
244
+ alias: 'b',
245
+ },
246
+ sentry: {
247
+ type: 'boolean',
248
+ description: 'Enable Sentry error tracking and monitoring (use --no-sentry to disable)',
249
+ default: true,
250
+ },
251
+ 'auto-cleanup': {
252
+ type: 'boolean',
253
+ description: 'Automatically delete temporary working directory on completion (error, success, or CTRL+C). Default: true for private repos, false for public repos. Use explicit flag to override.',
254
+ default: undefined,
255
+ },
256
+ 'auto-merge-default-branch-to-pull-request-branch': {
257
+ type: 'boolean',
258
+ description: 'Automatically merge the default branch to the pull request branch when continuing work (only in continue mode)',
259
+ default: false,
260
+ },
261
+ 'allow-fork-divergence-resolution-using-force-push-with-lease': {
262
+ type: 'boolean',
263
+ description: 'Allow automatic force-push (--force-with-lease) when fork diverges from upstream (DANGEROUS: can overwrite fork history)',
264
+ default: false,
265
+ },
266
+ 'allow-to-push-to-contributors-pull-requests-as-maintainer': {
267
+ type: 'boolean',
268
+ description: 'When continuing a fork PR as a maintainer, attempt to push directly to the contributor\'s fork if "Allow edits by maintainers" is enabled. Requires --auto-fork to be enabled.',
269
+ default: false,
270
+ },
271
+ 'prefix-fork-name-with-owner-name': {
272
+ type: 'boolean',
273
+ description: 'Prefix fork name with original owner name (e.g., "owner-repo" instead of "repo"). Useful when forking repositories with same name from different owners.',
274
+ default: true,
275
+ },
276
+ tool: {
277
+ type: 'string',
278
+ description: 'AI tool to use for solving issues',
279
+ choices: ['claude', 'opencode', 'codex', 'agent'],
280
+ default: 'claude',
281
+ },
282
+ 'execute-tool-with-bun': {
283
+ type: 'boolean',
284
+ description: 'Execute the AI tool using bunx (experimental, may improve speed and memory usage)',
285
+ default: false,
286
+ },
287
+ 'enable-workspaces': {
288
+ type: 'boolean',
289
+ description: 'Use separate workspace directory structure with repository/ and tmp/ folders. Works with all tools (claude, opencode, codex, agent). Experimental feature.',
290
+ default: false,
291
+ },
292
+ 'interactive-mode': {
293
+ type: 'boolean',
294
+ description: '[EXPERIMENTAL] Post Claude output as PR comments in real-time. Only supported for --tool claude.',
295
+ default: false,
296
+ },
297
+ 'prompt-explore-sub-agent': {
298
+ type: 'boolean',
299
+ description: 'Encourage Claude to use Explore sub-agent for codebase exploration. Only supported for --tool claude.',
300
+ default: false,
301
+ },
302
+ 'prompt-general-purpose-sub-agent': {
303
+ type: 'boolean',
304
+ description: 'Prompt AI to use general-purpose sub agents for processing large tasks with multiple files/folders. Only supported for --tool claude.',
305
+ default: false,
306
+ },
307
+ 'tokens-budget-stats': {
308
+ type: 'boolean',
309
+ description: '[EXPERIMENTAL] Show detailed token budget statistics including context window usage and ratios. Only supported for --tool claude.',
310
+ default: false,
311
+ },
312
+ 'prompt-issue-reporting': {
313
+ type: 'boolean',
314
+ description: 'Enable automatic issue creation for spotted bugs/errors not related to main task. Issues will include reproducible examples, workarounds, and fix suggestions. Works for both current and third-party repositories. Only supported for --tool claude.',
315
+ default: false,
316
+ },
317
+ 'prompt-architecture-care': {
318
+ type: 'boolean',
319
+ description: '[EXPERIMENTAL] Include guidance for managing REQUIREMENTS.md and ARCHITECTURE.md files. When enabled, agents will update these documentation files when changes affect requirements or architecture.',
320
+ default: false,
321
+ },
322
+ 'prompt-case-studies': {
323
+ type: 'boolean',
324
+ description: 'Create comprehensive case study documentation for the issue including logs, analysis, timeline, root cause investigation, and proposed solutions. Organizes findings into ./docs/case-studies/issue-{id}/ directory. Only supported for --tool claude.',
325
+ default: false,
326
+ },
327
+ 'prompt-playwright-mcp': {
328
+ type: 'boolean',
329
+ description: 'Enable Playwright MCP browser automation hints in system prompt (enabled by default, only takes effect if Playwright MCP is installed). Use --no-prompt-playwright-mcp to disable. Only supported for --tool claude.',
330
+ default: true,
331
+ },
332
+ 'prompt-check-sibling-pull-requests': {
333
+ type: 'boolean',
334
+ description: 'Include prompt to check related/sibling pull requests when studying related work. Enabled by default, use --no-prompt-check-sibling-pull-requests to disable.',
335
+ default: true,
336
+ },
337
+ 'prompt-experiments-folder': {
338
+ type: 'string',
339
+ description: 'Path to experiments folder used in system prompt. Set to empty string to disable experiments folder prompt. Default: ./experiments',
340
+ default: './experiments',
341
+ },
342
+ 'prompt-examples-folder': {
343
+ type: 'string',
344
+ description: 'Path to examples folder used in system prompt. Set to empty string to disable examples folder prompt. Default: ./examples',
345
+ default: './examples',
346
+ },
347
+ 'playwright-mcp-auto-cleanup': {
348
+ type: 'boolean',
349
+ description: 'Automatically remove .playwright-mcp/ folder before checking for uncommitted changes. This prevents browser automation artifacts from triggering auto-restart. Use --no-playwright-mcp-auto-cleanup to keep the folder for debugging.',
350
+ default: true,
351
+ },
352
+ 'auto-gh-configuration-repair': {
353
+ type: 'boolean',
354
+ description: 'Automatically repair git configuration using gh-setup-git-identity --repair when git identity is not configured. Requires gh-setup-git-identity to be installed.',
355
+ default: false,
356
+ },
357
+ 'prompt-subagents-via-agent-commander': {
358
+ type: 'boolean',
359
+ description: 'Guide Claude to use agent-commander CLI (start-agent) instead of native Task tool for subagent delegation. Allows using any supported agent type (claude, opencode, codex, agent) with unified API. Only works with --tool claude and requires agent-commander to be installed.',
360
+ default: false,
361
+ },
362
+ };
363
+
25
364
  // Function to create yargs configuration - avoids duplication
26
365
  export const createYargsConfig = yargsInstance => {
27
- return (
28
- yargsInstance
29
- .usage('Usage: solve.mjs <issue-url> [options]')
30
- .command('$0 <issue-url>', 'Solve a GitHub issue or pull request', yargs => {
31
- yargs.positional('issue-url', {
32
- type: 'string',
33
- description: 'The GitHub issue URL to solve',
34
- });
35
- })
36
- .fail((msg, err) => {
37
- // Custom fail handler to suppress yargs error output
38
- // Errors will be handled in the parseArguments catch block
39
- if (err) throw err; // Rethrow actual errors
40
- // For validation errors, throw a clean error object with the message
41
- const error = new Error(msg);
42
- error.name = 'YargsValidationError';
43
- throw error;
44
- })
45
- .option('resume', {
46
- type: 'string',
47
- description: 'Resume from a previous session ID (when limit was reached)',
48
- alias: 'r',
49
- })
50
- .option('working-directory', {
51
- type: 'string',
52
- description: 'Use specified working directory instead of creating a new temp directory. If directory does not exist, it will be created and the repository will be cloned. Essential for --resume to work correctly with Claude Code sessions.',
53
- alias: 'd',
54
- })
55
- .option('only-prepare-command', {
56
- type: 'boolean',
57
- description: 'Only prepare and print the claude command without executing it',
58
- })
59
- .option('dry-run', {
60
- type: 'boolean',
61
- description: 'Prepare everything but do not execute Claude (alias for --only-prepare-command)',
62
- alias: 'n',
63
- })
64
- .option('skip-tool-connection-check', {
65
- type: 'boolean',
66
- description: 'Skip tool connection check (useful in CI environments). Does NOT skip model validation.',
67
- default: false,
68
- })
69
- .option('skip-tool-check', {
70
- type: 'boolean',
71
- description: 'Alias for --skip-tool-connection-check (deprecated, use --skip-tool-connection-check instead)',
72
- default: false,
73
- hidden: true,
74
- })
75
- .option('skip-claude-check', {
76
- type: 'boolean',
77
- description: 'Alias for --skip-tool-connection-check (deprecated)',
78
- default: false,
79
- hidden: true,
80
- })
81
- .option('tool-connection-check', {
82
- type: 'boolean',
83
- description: 'Perform tool connection check (enabled by default, use --no-tool-connection-check to skip). Does NOT affect model validation.',
84
- default: true,
85
- hidden: true,
86
- })
87
- .option('tool-check', {
88
- type: 'boolean',
89
- description: 'Alias for --tool-connection-check (deprecated)',
90
- default: true,
91
- hidden: true,
92
- })
93
- .option('model', {
94
- type: 'string',
95
- description: 'Model to use (for claude: opus, sonnet, haiku, haiku-3-5, haiku-3; for opencode: grok, gpt4o; for codex: gpt5, gpt5-codex, o3; for agent: grok, grok-code, big-pickle)',
96
- alias: 'm',
97
- default: currentParsedArgs => {
98
- // Dynamic default based on tool selection
99
- if (currentParsedArgs?.tool === 'opencode') {
100
- return 'grok-code-fast-1';
101
- } else if (currentParsedArgs?.tool === 'codex') {
102
- return 'gpt-5';
103
- } else if (currentParsedArgs?.tool === 'agent') {
104
- return 'grok-code';
105
- }
106
- return 'sonnet';
107
- },
108
- })
109
- .option('auto-pull-request-creation', {
110
- type: 'boolean',
111
- description: 'Automatically create a draft pull request before running Claude',
112
- default: true,
113
- })
114
- .option('verbose', {
115
- type: 'boolean',
116
- description: 'Enable verbose logging for debugging',
117
- alias: 'v',
118
- default: false,
119
- })
120
- .option('fork', {
121
- type: 'boolean',
122
- description: "Fork the repository if you don't have write access",
123
- alias: 'f',
124
- default: false,
125
- })
126
- .option('auto-fork', {
127
- type: 'boolean',
128
- description: 'Automatically fork public repositories without write access (fails for private repos)',
129
- default: true,
130
- })
131
- .option('claude-file', {
132
- type: 'boolean',
133
- description: 'Create CLAUDE.md file for task details (default for --tool claude, mutually exclusive with --gitkeep-file)',
134
- default: true,
135
- })
136
- .option('gitkeep-file', {
137
- type: 'boolean',
138
- description: 'Create .gitkeep file instead of CLAUDE.md (default for --tool agent/opencode/codex, mutually exclusive with --claude-file)',
139
- default: false,
140
- })
141
- .option('auto-gitkeep-file', {
142
- type: 'boolean',
143
- description: 'Automatically use .gitkeep if CLAUDE.md is in .gitignore (pre-checks before creating file)',
144
- default: true,
145
- })
146
- .option('attach-logs', {
147
- type: 'boolean',
148
- description: 'Upload the solution draft log file to the Pull Request on completion (⚠️ WARNING: May expose sensitive data)',
149
- default: false,
150
- })
151
- .option('auto-close-pull-request-on-fail', {
152
- type: 'boolean',
153
- description: 'Automatically close the pull request if execution fails',
154
- default: false,
155
- })
156
- .option('auto-continue', {
157
- type: 'boolean',
158
- description: 'Continue with existing PR when issue URL is provided (instead of creating new PR)',
159
- default: true,
160
- })
161
- .option('auto-resume-on-limit-reset', {
162
- type: 'boolean',
163
- description: 'Automatically resume when AI tool limit resets (maintains session context with --resume flag)',
164
- default: false,
165
- })
166
- .option('auto-restart-on-limit-reset', {
167
- type: 'boolean',
168
- description: 'Automatically restart when AI tool limit resets (fresh start without --resume flag)',
169
- default: false,
170
- })
171
- .option('session-type', {
172
- type: 'string',
173
- description: 'Internal: Session type for comment differentiation (new, resume, auto-resume, auto-restart)',
174
- choices: ['new', 'resume', 'auto-resume', 'auto-restart'],
175
- default: 'new',
176
- hidden: true,
177
- })
178
- .option('auto-resume-on-errors', {
179
- type: 'boolean',
180
- description: 'Automatically resume on network errors (503, etc.) with exponential backoff',
181
- default: false,
182
- })
183
- .option('auto-continue-only-on-new-comments', {
184
- type: 'boolean',
185
- description: 'Explicitly fail on absence of new comments in auto-continue or continue mode',
186
- default: false,
187
- })
188
- .option('auto-commit-uncommitted-changes', {
189
- type: 'boolean',
190
- description: 'Automatically commit and push uncommitted changes made by Claude (disabled by default)',
191
- default: false,
192
- })
193
- .option('auto-restart-on-uncommitted-changes', {
194
- type: 'boolean',
195
- description: 'Automatically restart when uncommitted changes are detected to allow the tool to handle them (default: true, use --no-auto-restart-on-uncommitted-changes to disable)',
196
- default: true,
197
- })
198
- .option('auto-restart-max-iterations', {
199
- type: 'number',
200
- description: 'Maximum number of auto-restart iterations when uncommitted changes are detected (default: 3)',
201
- default: 3,
202
- })
203
- .option('auto-merge', {
204
- type: 'boolean',
205
- description: 'Automatically merge the pull request when the working session is finished and all CI/CD statuses pass and PR is mergeable. Implies --auto-restart-until-mergable.',
206
- default: false,
207
- })
208
- .option('auto-restart-until-mergable', {
209
- type: 'boolean',
210
- description: 'Auto-restart until PR becomes mergeable (no iteration limit). Restarts on new comments from non-bot users, CI failures, merge conflicts, or other issues. Does NOT auto-merge.',
211
- default: false,
212
- })
213
- .option('auto-restart-on-non-updated-pull-request-description', {
214
- type: 'boolean',
215
- description: 'Automatically restart if PR title or description still contains auto-generated placeholder text after agent execution. Restarts with a hint about what was not updated.',
216
- default: false,
217
- })
218
- .option('continue-only-on-feedback', {
219
- type: 'boolean',
220
- description: 'Only continue if feedback is detected (works only with pull request link or issue link with --auto-continue)',
221
- default: false,
222
- })
223
- .option('watch', {
224
- type: 'boolean',
225
- description: 'Monitor continuously for feedback and auto-restart when detected (stops when PR is merged)',
226
- alias: 'w',
227
- default: false,
228
- })
229
- .option('watch-interval', {
230
- type: 'number',
231
- description: 'Interval in seconds for checking feedback in watch mode (default: 60)',
232
- default: 60,
233
- })
234
- .option('min-disk-space', {
235
- type: 'number',
236
- description: 'Minimum required disk space in MB (default: 2048)',
237
- default: 2048,
238
- })
239
- .option('log-dir', {
240
- type: 'string',
241
- description: 'Directory to save log files (defaults to current working directory)',
242
- alias: 'l',
243
- })
244
- .option('think', {
245
- type: 'string',
246
- description: 'Thinking level for Claude. Translated to --thinking-budget for Claude Code >= 2.1.12 (off=0, low=~8000, medium=~16000, high=~24000, max=31999). For older versions, uses thinking keywords.',
247
- choices: ['off', 'low', 'medium', 'high', 'max'],
248
- default: undefined,
249
- })
250
- .option('thinking-budget', {
251
- type: 'number',
252
- description: 'Thinking token budget for Claude Code (0-63999). Controls MAX_THINKING_TOKENS. Default: 31999 (Claude default). Set to 0 to disable thinking. For older Claude Code versions, translated back to --think level.',
253
- default: undefined,
254
- })
255
- .option('thinking-budget-claude-minimum-version', {
366
+ let config = yargsInstance
367
+ .usage('Usage: solve.mjs <issue-url> [options]')
368
+ .command('$0 <issue-url>', 'Solve a GitHub issue or pull request', yargs => {
369
+ yargs.positional('issue-url', {
256
370
  type: 'string',
257
- description: 'Minimum Claude Code version that supports --thinking-budget (MAX_THINKING_TOKENS env var). Versions below this use thinking keywords instead.',
258
- default: '2.1.12',
259
- })
260
- .option('max-thinking-budget', {
261
- type: 'number',
262
- description: 'Maximum thinking budget for calculating --think level mappings (default: 31999 for Claude Code). Values: off=0, low=max/4, medium=max/2, high=max*3/4, max=max.',
263
- default: 31999,
264
- })
265
- .option('prompt-plan-sub-agent', {
266
- type: 'boolean',
267
- description: 'Encourage AI to use Plan sub-agent for initial planning (only works with --tool claude)',
268
- default: false,
269
- })
270
- .option('base-branch', {
271
- type: 'string',
272
- description: 'Target branch for the pull request (defaults to repository default branch)',
273
- alias: 'b',
274
- })
275
- .option('sentry', {
276
- type: 'boolean',
277
- description: 'Enable Sentry error tracking and monitoring (use --no-sentry to disable)',
278
- default: true,
279
- })
280
- .option('auto-cleanup', {
281
- type: 'boolean',
282
- description: 'Automatically delete temporary working directory on completion (error, success, or CTRL+C). Default: true for private repos, false for public repos. Use explicit flag to override.',
283
- default: undefined,
284
- })
285
- .option('auto-merge-default-branch-to-pull-request-branch', {
286
- type: 'boolean',
287
- description: 'Automatically merge the default branch to the pull request branch when continuing work (only in continue mode)',
288
- default: false,
289
- })
290
- .option('allow-fork-divergence-resolution-using-force-push-with-lease', {
291
- type: 'boolean',
292
- description: 'Allow automatic force-push (--force-with-lease) when fork diverges from upstream (DANGEROUS: can overwrite fork history)',
293
- default: false,
294
- })
295
- .option('allow-to-push-to-contributors-pull-requests-as-maintainer', {
296
- type: 'boolean',
297
- description: 'When continuing a fork PR as a maintainer, attempt to push directly to the contributor\'s fork if "Allow edits by maintainers" is enabled. Requires --auto-fork to be enabled.',
298
- default: false,
299
- })
300
- .option('prefix-fork-name-with-owner-name', {
301
- type: 'boolean',
302
- description: 'Prefix fork name with original owner name (e.g., "owner-repo" instead of "repo"). Useful when forking repositories with same name from different owners.',
303
- default: true,
304
- })
305
- .option('tool', {
306
- type: 'string',
307
- description: 'AI tool to use for solving issues',
308
- choices: ['claude', 'opencode', 'codex', 'agent'],
309
- default: 'claude',
310
- })
311
- .option('execute-tool-with-bun', {
312
- type: 'boolean',
313
- description: 'Execute the AI tool using bunx (experimental, may improve speed and memory usage)',
314
- default: false,
315
- })
316
- .option('enable-workspaces', {
317
- type: 'boolean',
318
- description: 'Use separate workspace directory structure with repository/ and tmp/ folders. Works with all tools (claude, opencode, codex, agent). Experimental feature.',
319
- default: false,
320
- })
321
- .option('interactive-mode', {
322
- type: 'boolean',
323
- description: '[EXPERIMENTAL] Post Claude output as PR comments in real-time. Only supported for --tool claude.',
324
- default: false,
325
- })
326
- .option('prompt-explore-sub-agent', {
327
- type: 'boolean',
328
- description: 'Encourage Claude to use Explore sub-agent for codebase exploration. Only supported for --tool claude.',
329
- default: false,
330
- })
331
- .option('prompt-general-purpose-sub-agent', {
332
- type: 'boolean',
333
- description: 'Prompt AI to use general-purpose sub agents for processing large tasks with multiple files/folders. Only supported for --tool claude.',
334
- default: false,
335
- })
336
- .option('tokens-budget-stats', {
337
- type: 'boolean',
338
- description: '[EXPERIMENTAL] Show detailed token budget statistics including context window usage and ratios. Only supported for --tool claude.',
339
- default: false,
340
- })
341
- .option('prompt-issue-reporting', {
342
- type: 'boolean',
343
- description: 'Enable automatic issue creation for spotted bugs/errors not related to main task. Issues will include reproducible examples, workarounds, and fix suggestions. Works for both current and third-party repositories. Only supported for --tool claude.',
344
- default: false,
345
- })
346
- .option('prompt-architecture-care', {
347
- type: 'boolean',
348
- description: '[EXPERIMENTAL] Include guidance for managing REQUIREMENTS.md and ARCHITECTURE.md files. When enabled, agents will update these documentation files when changes affect requirements or architecture.',
349
- default: false,
350
- })
351
- .option('prompt-case-studies', {
352
- type: 'boolean',
353
- description: 'Create comprehensive case study documentation for the issue including logs, analysis, timeline, root cause investigation, and proposed solutions. Organizes findings into ./docs/case-studies/issue-{id}/ directory. Only supported for --tool claude.',
354
- default: false,
355
- })
356
- .option('prompt-playwright-mcp', {
357
- type: 'boolean',
358
- description: 'Enable Playwright MCP browser automation hints in system prompt (enabled by default, only takes effect if Playwright MCP is installed). Use --no-prompt-playwright-mcp to disable. Only supported for --tool claude.',
359
- default: true,
360
- })
361
- .option('prompt-check-sibling-pull-requests', {
362
- type: 'boolean',
363
- description: 'Include prompt to check related/sibling pull requests when studying related work. Enabled by default, use --no-prompt-check-sibling-pull-requests to disable.',
364
- default: true,
365
- })
366
- .option('prompt-experiments-folder', {
367
- type: 'string',
368
- description: 'Path to experiments folder used in system prompt. Set to empty string to disable experiments folder prompt. Default: ./experiments',
369
- default: './experiments',
370
- })
371
- .option('prompt-examples-folder', {
372
- type: 'string',
373
- description: 'Path to examples folder used in system prompt. Set to empty string to disable examples folder prompt. Default: ./examples',
374
- default: './examples',
375
- })
376
- .option('playwright-mcp-auto-cleanup', {
377
- type: 'boolean',
378
- description: 'Automatically remove .playwright-mcp/ folder before checking for uncommitted changes. This prevents browser automation artifacts from triggering auto-restart. Use --no-playwright-mcp-auto-cleanup to keep the folder for debugging.',
379
- default: true,
380
- })
381
- .option('auto-gh-configuration-repair', {
382
- type: 'boolean',
383
- description: 'Automatically repair git configuration using gh-setup-git-identity --repair when git identity is not configured. Requires gh-setup-git-identity to be installed.',
384
- default: false,
385
- })
386
- .option('prompt-subagents-via-agent-commander', {
387
- type: 'boolean',
388
- description: 'Guide Claude to use agent-commander CLI (start-agent) instead of native Task tool for subagent delegation. Allows using any supported agent type (claude, opencode, codex, agent) with unified API. Only works with --tool claude and requires agent-commander to be installed.',
389
- default: false,
390
- })
391
- .parserConfiguration({
392
- 'boolean-negation': true,
393
- })
394
- // Use yargs built-in strict mode to reject unrecognized options
395
- // This prevents issues like #453 and #482 where unknown options are silently ignored
396
- .strict()
397
- .help('h')
398
- .alias('h', 'help')
399
- );
371
+ description: 'The GitHub issue URL to solve',
372
+ });
373
+ })
374
+ .fail((msg, err) => {
375
+ // Custom fail handler to suppress yargs error output
376
+ // Errors will be handled in the parseArguments catch block
377
+ if (err) throw err; // Rethrow actual errors
378
+ // For validation errors, throw a clean error object with the message
379
+ const error = new Error(msg);
380
+ error.name = 'YargsValidationError';
381
+ throw error;
382
+ });
383
+
384
+ // Register all options from the definitions map
385
+ for (const [name, def] of Object.entries(SOLVE_OPTION_DEFINITIONS)) {
386
+ config = config.option(name, def);
387
+ }
388
+
389
+ // 'model' has a dynamic default function, so it's defined inline (not in SOLVE_OPTION_DEFINITIONS)
390
+ config = config
391
+ .option('model', {
392
+ type: 'string',
393
+ description: 'Model to use (for claude: opus, sonnet, haiku, haiku-3-5, haiku-3; for opencode: grok, gpt4o; for codex: gpt5, gpt5-codex, o3; for agent: grok, grok-code, big-pickle)',
394
+ alias: 'm',
395
+ default: currentParsedArgs => {
396
+ // Dynamic default based on tool selection
397
+ if (currentParsedArgs?.tool === 'opencode') {
398
+ return 'grok-code-fast-1';
399
+ } else if (currentParsedArgs?.tool === 'codex') {
400
+ return 'gpt-5';
401
+ } else if (currentParsedArgs?.tool === 'agent') {
402
+ return 'grok-code';
403
+ }
404
+ return 'sonnet';
405
+ },
406
+ })
407
+ .parserConfiguration({
408
+ 'boolean-negation': true,
409
+ })
410
+ // Use yargs built-in strict mode to reject unrecognized options
411
+ // This prevents issues like #453 and #482 where unknown options are silently ignored
412
+ .strict()
413
+ .help('h')
414
+ .alias('h', 'help');
415
+
416
+ return config;
400
417
  };
401
418
 
402
419
  // Parse command line arguments - now needs yargs and hideBin passed in