vibecodingmachine-cli 2026.2.20-438 → 2026.2.26-1739

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 (101) hide show
  1. package/bin/auth/auth-compliance.js +126 -0
  2. package/bin/cli-program.js +104 -0
  3. package/bin/cli-setup.js +52 -0
  4. package/bin/commands/agent-commands.js +310 -0
  5. package/bin/commands/auto-commands.js +70 -0
  6. package/bin/commands/command-aliases.js +118 -0
  7. package/bin/commands/repo-commands.js +39 -0
  8. package/bin/commands/rui-commands.js +152 -0
  9. package/bin/config/cli-config.js +394 -0
  10. package/bin/init/environment-setup.js +84 -0
  11. package/bin/update/update-checker.js +126 -0
  12. package/bin/vibecodingmachine-new.js +50 -0
  13. package/bin/vibecodingmachine.js +29 -663
  14. package/package.json +8 -2
  15. package/src/commands/agents/add.js +277 -0
  16. package/src/commands/agents/check.js +380 -0
  17. package/src/commands/agents/list.js +471 -0
  18. package/src/commands/agents/remove.js +351 -0
  19. package/src/commands/analyze-file-sizes.js +428 -0
  20. package/src/commands/auto-direct/code-processor.js +282 -0
  21. package/src/commands/auto-direct/file-scanner.js +266 -0
  22. package/src/commands/auto-direct/provider-config.js +178 -0
  23. package/src/commands/auto-direct/provider-manager.js +219 -0
  24. package/src/commands/auto-direct/requirement-manager.js +172 -0
  25. package/src/commands/auto-direct/status-display.js +91 -0
  26. package/src/commands/auto-direct/utils.js +106 -0
  27. package/src/commands/auto-direct.js +875 -488
  28. package/src/commands/auto-execution.js +342 -0
  29. package/src/commands/auto-provider-management.js +102 -0
  30. package/src/commands/auto-requirement-management.js +161 -0
  31. package/src/commands/auto-status-helpers.js +141 -0
  32. package/src/commands/auto.js +105 -5155
  33. package/src/commands/check-compliance.js +536 -0
  34. package/src/commands/continuous-scan.js +119 -0
  35. package/src/commands/ide.js +16 -4
  36. package/src/commands/refactor-file.js +486 -0
  37. package/src/commands/requirements.js +301 -2
  38. package/src/commands/timeout.js +290 -0
  39. package/src/trui/TruiInterface.js +108 -0
  40. package/src/trui/agents/AgentInterface.js +580 -0
  41. package/src/utils/antigravity-installer.js +60 -6
  42. package/src/utils/clarification-actions.js +290 -0
  43. package/src/utils/config.js +123 -2
  44. package/src/utils/first-run.js +5 -5
  45. package/src/utils/ide-handlers.js +212 -0
  46. package/src/utils/interactive/clarification-actions.js +348 -0
  47. package/src/utils/interactive/core-ui.js +265 -0
  48. package/src/utils/interactive/file-backup.js +237 -0
  49. package/src/utils/interactive/file-import-export.js +305 -0
  50. package/src/utils/interactive/file-operations.js +49 -0
  51. package/src/utils/interactive/file-validation.js +276 -0
  52. package/src/utils/interactive/interactive-prompts.js +480 -0
  53. package/src/utils/interactive/requirement-actions.js +127 -0
  54. package/src/utils/interactive/requirement-crud.js +356 -0
  55. package/src/utils/interactive/requirements-navigation.js +286 -0
  56. package/src/utils/interactive.js +390 -3459
  57. package/src/utils/provider-checker/agent-checker.js +250 -0
  58. package/src/utils/provider-checker/agent-runner.js +450 -0
  59. package/src/utils/provider-checker/cli-installer.js +123 -0
  60. package/src/utils/provider-checker/cli-utils.js +15 -0
  61. package/src/utils/provider-checker/format-utils.js +32 -0
  62. package/src/utils/provider-checker/ide-manager.js +72 -0
  63. package/src/utils/provider-checker/ide-utils.js +71 -0
  64. package/src/utils/provider-checker/node-detector.js +56 -0
  65. package/src/utils/provider-checker/node-utils.js +61 -0
  66. package/src/utils/provider-checker/process-spawn.js +22 -0
  67. package/src/utils/provider-checker/process-utils.js +37 -0
  68. package/src/utils/provider-checker/provider-validator.js +160 -0
  69. package/src/utils/provider-checker/quota-checker.js +54 -0
  70. package/src/utils/provider-checker/quota-detector.js +44 -0
  71. package/src/utils/provider-checker/requirements-manager.js +94 -0
  72. package/src/utils/provider-checker/test-requirements.js +95 -0
  73. package/src/utils/provider-checker/time-formatter.js +18 -0
  74. package/src/utils/provider-checker-new.js +14 -0
  75. package/src/utils/provider-checker.js +12 -407
  76. package/src/utils/provider-checkers/ide-manager.js +128 -0
  77. package/src/utils/provider-checkers/node-executable-finder.js +51 -0
  78. package/src/utils/provider-checkers/provider-checker-core.js +172 -0
  79. package/src/utils/provider-checkers/provider-checker-main.js +107 -0
  80. package/src/utils/provider-manager.js +60 -4
  81. package/src/utils/provider-registry.js +26 -3
  82. package/src/utils/provider-utils.js +173 -0
  83. package/src/utils/quota-detectors.js +212 -0
  84. package/src/utils/requirement-action-handlers.js +288 -0
  85. package/src/utils/requirement-actions/clarification-actions.js +229 -0
  86. package/src/utils/requirement-actions/confirmation-prompts.js +93 -0
  87. package/src/utils/requirement-actions/file-operations.js +92 -0
  88. package/src/utils/requirement-actions/helpers.js +40 -0
  89. package/src/utils/requirement-actions/requirement-operations.js +335 -0
  90. package/src/utils/requirement-actions.js +46 -856
  91. package/src/utils/requirement-file-operations.js +259 -0
  92. package/src/utils/requirement-helpers.js +128 -0
  93. package/src/utils/requirement-management.js +279 -0
  94. package/src/utils/requirement-navigation.js +146 -0
  95. package/src/utils/requirement-organization.js +271 -0
  96. package/src/utils/simple-trui.js +75 -1
  97. package/src/utils/trui-navigation.js +28 -2
  98. package/src/utils/trui-req-tree.js +196 -11
  99. package/src/utils/trui-specifications.js +31 -1
  100. package/src/utils/interactive-backup.js +0 -5664
  101. package/src/utils/trui-provider-manager.js +0 -182
@@ -1,48 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const path = require('path');
4
- const fs = require('fs');
5
-
6
- // Auto-load .env.cognito from root
7
- const rootDir = path.join(__dirname, '..', '..', '..');
8
- const envCognitoPath = path.join(rootDir, '.env.cognito');
9
-
10
- if (fs.existsSync(envCognitoPath)) {
11
- const envContent = fs.readFileSync(envCognitoPath, 'utf8');
12
- envContent.split('\n').forEach(line => {
13
- const trimmed = line.trim();
14
- if (trimmed && !trimmed.startsWith('#')) {
15
- const [key, ...valueParts] = trimmed.split('=');
16
- if (key && valueParts.length > 0) {
17
- process.env[key.trim()] = valueParts.join('=').trim();
18
- }
19
- }
20
- });
21
- }
22
-
23
3
  /**
24
4
  * Vibe Coding Machine CLI - Command-line interface for autonomous AI development
25
5
  * "Big Dreams + AI + VibeCodingMachine.com = Your money making apps"
26
6
  */
27
7
 
28
- const { cleanupBrokenAssets } = require('../src/utils/asset-cleanup');
29
-
30
- (async () => {
31
- // mitigate broken assets issue
32
- await cleanupBrokenAssets();
33
- })();
34
-
35
- const { program } = require('commander');
36
8
  const chalk = require('chalk');
9
+ const { program } = require('commander');
37
10
  const inquirer = require('inquirer');
38
- const { execSync, spawn } = require('child_process');
39
- const ora = require('ora');
40
- const https = require('https');
11
+ const { spawn } = require('child_process');
41
12
  const os = require('os');
42
- const { pipeline } = require('stream');
43
- const { promisify } = require('util');
44
- const streamPipeline = promisify(pipeline);
45
- // const path = require('path'); // Moved to top for .env.auth loading
46
13
  const packageJson = require('../package.json');
47
14
 
48
15
  // Import localization
@@ -51,589 +18,35 @@ const { t, detectLocale, setLocale, errorReporter } = require('vibecodingmachine
51
18
  // Import prompt helper
52
19
  const { promptWithDefaultsOnce } = require('../src/utils/prompt-helper');
53
20
 
54
- // Initialize locale detection
55
- const detectedLocale = detectLocale();
56
- setLocale(detectedLocale);
57
-
58
- // Import command modules
59
- const repoCommands = require('../src/commands/repo');
60
- const autoCommands = require('../src/commands/auto');
61
- const reqCommands = require('../src/commands/requirements');
62
- const featureCommands = require('../src/commands/feature');
63
- const ideCommands = require('../src/commands/ide');
64
- const statusCommands = require('../src/commands/status');
65
-
66
- // Detect which command was used (vcm or vibecodingmachine)
67
- const commandName = path.basename(process.argv[1], '.js');
68
- const altCommandName = commandName === 'vcm' ? 'vibecodingmachine' : 'vcm';
69
-
70
- // Configure CLI
71
- program
72
- .name(commandName)
73
- .usage(`[options] [command]\n\n You can use '${commandName}' or '${altCommandName}'`)
74
- .description(t('app.name') + ' CLI - Autonomous development')
75
- .version(packageJson.version, '-v, --version', 'output the current version')
76
- .helpOption('-h, --help', 'display help for command');
77
-
78
- // Repository management commands
79
- program
80
- .command('repo')
81
- .description(t('cli.repo.manage'))
82
- .action(() => {
83
- program.outputHelp();
84
- });
85
-
86
- program
87
- .command('repo:set <path>')
88
- .description(t('cli.repo.set'))
89
- .action(repoCommands.setRepo);
90
-
91
- program
92
- .command('repo:get')
93
- .description(t('cli.repo.get'))
94
- .action(repoCommands.getRepo);
95
-
96
- program
97
- .command('repo:init')
98
- .description(t('cli.repo.init'))
99
- .action(repoCommands.initRepo);
100
-
101
- // Auto mode commands
102
- program
103
- .command('auto:start')
104
- .description(t('cli.auto.start'))
105
- .option('-i, --ide <ide>', 'IDE to use (claude-code, aider, cursor, vscode, windsurf, cline)')
106
- .option('--ide-model <model>', 'IDE agent/model to use (for IDE sub-agents like Windsurf/Antigravity)')
107
- .option('--extension <extension>', 'VS Code extension to use (amazon-q, github-copilot, windsurf)')
108
- .option('-m, --max-chats <number>', 'Maximum number of chat iterations', parseInt)
109
- .option('-n, --never-stop', 'Run indefinitely without stopping')
110
- .option('-f, --force-provider-setup', 'Force provider selection even if already configured')
111
- .action(autoCommands.start);
112
-
113
- // Direct LLM auto mode (new simplified implementation)
114
- const { handleAutoStart: handleDirectAutoStart } = require('../src/commands/auto-direct');
115
- program
116
- .command('auto:direct')
117
- .description(t('cli.auto.direct'))
118
- .option('-m, --max-chats <number>', 'Maximum number of iterations', parseInt)
119
- .option('--provider <id>', 'Force a specific provider by ID (e.g. groq, anthropic, cursor)')
120
- .action(handleDirectAutoStart);
121
-
122
- program
123
- .command('auto:stop')
124
- .description(t('cli.auto.stop'))
125
- .action(autoCommands.stop);
126
-
127
- program
128
- .command('auto:status')
129
- .description(t('cli.auto.status'))
130
- .action(autoCommands.status);
131
-
132
- program
133
- .command('auto:config')
134
- .description(t('cli.auto.config'))
135
- .option('--max-chats <number>', 'Set maximum chat iterations', parseInt)
136
- .option('--never-stop', 'Enable never stop mode')
137
- .option('--no-never-stop', 'Disable never stop mode')
138
- .action(autoCommands.config);
139
-
140
- program
141
- .command('auto:agents')
142
- .description(t('cli.auto.agents'))
143
- .action(autoCommands.listAgents);
144
-
145
- program
146
- .command('agents:check')
147
- .description('Ping all agents and show connection status')
148
- .option('--provider <id>', 'Check a specific provider by ID')
149
- .action(async (options) => {
150
- const { checkAgents } = require('../src/commands/agents-check');
151
- await checkAgents(options);
152
- });
153
-
154
- // Requirements management commands
155
- program
156
- .command('req:list')
157
- .description(t('cli.req.list'))
158
- .option('-s, --status <status>', 'Filter by status (pending, in-progress, completed)')
159
- .option('-c, --computer <hostname>', 'Filter by computer hostname')
160
- .option('-f, --focus <area>', 'Filter by focus area')
161
- .option('-a, --all-computers', 'Show requirements from all computers with computer tags')
162
- .option('-d, --detailed', 'Show detailed requirement information')
163
- .action(reqCommands.list);
164
-
165
- // Helper: print requirements in tree format
166
- async function printRequirementsTree() {
167
- const { loadAllSections } = require('../src/utils/trui-req-tree');
168
- const sections = await loadAllSections();
169
-
170
- const total = sections.verified.length + sections.verify.length + sections.todo.length;
171
- const pct = n => total > 0 ? ` — ${Math.round((n / total) * 100)}%` : '';
172
-
173
- // Specifications
174
- try {
175
- const { getSpecsList } = require('../src/utils/trui-specifications');
176
- const specs = await getSpecsList();
177
- console.log(` ▸ 📋 TODO SPECIFICATIONS (${specs.length})`);
178
- } catch (_) {
179
- console.log(' ▸ 📋 TODO SPECIFICATIONS');
180
- }
181
-
182
- const printSection = (icon, label, items) => {
183
- const count = items.length;
184
- console.log(` ▸ ${icon} ${label} (${count}${pct(count)})`);
185
- items.forEach(req => console.log(` ${req.title || req}`));
186
- };
187
-
188
- printSection('🎉', 'VERIFIED', sections.verified);
189
- printSection('✅', 'TO VERIFY', sections.verify);
190
- printSection('⏳', 'TODO REQUIREMENTS', sections.todo);
191
- }
192
-
193
- // Helper: print agents list
194
- async function printAgentsList() {
195
- const { getProviderDefinitions, getProviderPreferences } = require('../src/utils/provider-registry');
196
- const defs = getProviderDefinitions();
197
- const defMap = new Map(defs.map(d => [d.id, d]));
198
- const prefs = await getProviderPreferences();
199
- const order = prefs.order.slice();
200
- defs.forEach(d => { if (!order.includes(d.id)) order.push(d.id); });
201
-
202
- console.log(' 🤖 Agents / Providers\n');
203
- order.forEach((id, idx) => {
204
- const def = defMap.get(id);
205
- if (!def) return;
206
- const isEnabled = prefs.enabled[id] !== false;
207
- const statusIcon = isEnabled ? '🟢' : '🔴';
208
- const interfaceIcon = def.type === 'ide' ? '🖥️ ' : '⚡';
209
- const providerIcon = (def.type === 'direct' && def.category === 'llm' && id === 'ollama') ? '🏠' : '☁️ ';
210
- console.log(` ${statusIcon} ${interfaceIcon} ${providerIcon} #${idx + 1} ${def.name} (${id})`);
211
- });
212
- }
213
-
214
- // Helper: print settings
215
- async function printSettingsList() {
216
- const { getAutoConfig, getRepoPath, getStages } = require('../src/utils/config');
217
- const os = require('os');
218
-
219
- const repoPath = await getRepoPath();
220
- const autoConfig = await getAutoConfig();
221
- const stages = await getStages();
222
-
223
- console.log(' ⚙️ Settings\n');
224
- console.log(` repo: ${repoPath || '(not set)'}`);
225
- console.log(` ide: ${autoConfig.ide || autoConfig.agent || 'cline'}`);
226
- console.log(` maxChats: ${autoConfig.maxChats || '(unlimited)'}`);
227
- console.log(` neverStop:${autoConfig.neverStop ? ' true' : ' false'}`);
228
- console.log(` stages: ${stages.join(', ')}`);
229
- }
230
-
231
- // Helper: print system info
232
- async function printSystemInfo() {
233
- const os = require('os');
234
- const { getRepoPath } = require('../src/utils/config');
235
- const { checkAutoModeStatus } = require('../src/utils/auto-mode');
236
-
237
- const repoPath = await getRepoPath();
238
- let autoStatus = { running: false };
239
- try { autoStatus = await checkAutoModeStatus(); } catch (_) {}
240
-
241
- console.log(' 🖥️ System\n');
242
- console.log(` hostname: ${os.hostname()}`);
243
- console.log(` platform: ${os.platform()} ${os.release()}`);
244
- console.log(` node: ${process.version}`);
245
- console.log(` repo: ${repoPath || '(not set)'}`);
246
- console.log(` auto mode: ${autoStatus.running ? '🟢 running' : '🔴 stopped'}`);
247
- }
248
-
249
- // Dispatch for list/GET resource
250
- async function dispatchResource(resource, verb) {
251
- const r = (resource || '').toLowerCase();
252
- if (r === 'requirements' || r === 'reqs' || r === 'req') {
253
- await printRequirementsTree();
254
- } else if (r === 'agents' || r === 'agent' || r === 'providers') {
255
- await printAgentsList();
256
- } else if (r === 'settings' || r === 'setting' || r === 'config') {
257
- await printSettingsList();
258
- } else if (r === 'system' || r === 'sys' || r === 'info') {
259
- await printSystemInfo();
260
- } else {
261
- console.log(`Usage: vcm ${verb} <resource>`);
262
- console.log('Resources: requirements, agents, settings, system');
263
- process.exit(1);
264
- }
265
- }
266
-
267
- // RUI-compliant app commands for requirements
268
- program
269
- .command('list [resource]')
270
- .description('List resources (RUI pattern): requirements, agents, settings, system')
271
- .action(async (resource) => dispatchResource(resource, 'list'));
272
-
273
- program
274
- .command('get [resource]')
275
- .description('GET resource (RUI pattern): requirements, agents, settings, system')
276
- .action(async (resource) => dispatchResource(resource, 'get'));
277
-
278
- program
279
- .command('req:add <requirement>')
280
- .description(t('cli.req.add'))
281
- .action(reqCommands.add);
282
-
283
- program
284
- .command('req:current')
285
- .description(t('cli.req.current'))
286
- .action(reqCommands.current);
287
-
288
- program
289
- .command('req:next')
290
- .description(t('cli.req.next'))
291
- .action(reqCommands.next);
292
-
293
- program
294
- .command('req:edit')
295
- .description(t('cli.req.edit'))
296
- .action(reqCommands.edit);
297
-
298
- program
299
- .command('req:watch')
300
- .description(t('cli.req.watch'))
301
- .action(reqCommands.watch);
302
-
303
- program
304
- .command('req:rename <old-title> <new-title> [description...]')
305
- .description(t('cli.req.rename'))
306
- .action((oldTitle, newTitle, description) => reqCommands.rename(oldTitle, newTitle, description));
307
-
308
- program
309
- .command('req:number-all')
310
- .description('Number all existing requirements with R1, R2, R3, etc.')
311
- .action(reqCommands.numberAll);
312
-
313
- // Feature branch management commands
314
- program
315
- .command('feature:start <requirement-title>')
316
- .description('Create and checkout feature branch for requirement (e.g., "R1: Email System")')
317
- .action(featureCommands.start);
318
-
319
- program
320
- .command('feature:finish <requirement-title>')
321
- .description('Merge feature branch back to parent and delete branch')
322
- .option('-p, --parent <branch>', 'Parent branch to merge into', 'main')
323
- .action(featureCommands.finish);
324
-
325
- program
326
- .command('feature:remove <requirement-title>')
327
- .description('Remove a feature by reverting its merge commit')
328
- .action(featureCommands.remove);
329
-
330
- program
331
- .command('feature:list')
332
- .description('List all requirement feature branches')
333
- .action(featureCommands.list);
334
-
335
- // IDE integration commands
336
- program
337
- .command('ide:list')
338
- .description(t('cli.ide.list'))
339
- .action(ideCommands.list);
340
-
341
- program
342
- .command('ide:open <ide>')
343
- .description(t('cli.ide.open'))
344
- .action(ideCommands.open);
345
-
346
- program
347
- .command('ide:send <message>')
348
- .description(t('cli.ide.send'))
349
- .option('-i, --ide <ide>', 'IDE to use (cursor, vscode, windsurf)', 'cursor')
350
- .action(ideCommands.send);
351
-
352
- program
353
- .command('ide:health')
354
- .description('Test health and connectivity of all configured IDEs')
355
- .option('-v, --verbose', 'Show detailed health metrics', false)
356
- .action(ideCommands.health);
357
-
358
- // Status and monitoring commands
359
- program
360
- .command('status')
361
- .description(t('cli.status'))
362
- .action(statusCommands.show);
363
-
364
- program
365
- .command('progress')
366
- .description(t('cli.progress'))
367
- .action(statusCommands.progress);
368
-
369
- program
370
- .command('logs')
371
- .description(t('cli.logs'))
372
- .option('-n, --lines <number>', 'Number of log lines to show', '50')
373
- .action(statusCommands.logs);
374
-
375
- // Setup command
376
- program
377
- .command('setup')
378
- .description(t('cli.setup'))
379
- .action(async () => {
380
- const { setupAlias } = require('../src/commands/setup');
381
- await setupAlias();
382
- });
383
-
384
- // Authentication commands
385
- const authCommands = require('../src/commands/auth');
386
- program
387
- .command('auth:login')
388
- .description(t('cli.auth.login'))
389
- .option('--headless', 'Use headless mode (manual URL paste) for SSH/no-GUI environments')
390
- .action((options) => authCommands.login(options));
391
-
392
- program
393
- .command('auth:logout')
394
- .description(t('cli.auth.logout'))
395
- .action(authCommands.logout);
396
-
397
- program
398
- .command('auth:status')
399
- .description(t('cli.auth.status'))
400
- .action(authCommands.status);
401
-
402
- // Multi-computer management commands
403
- const computerCommands = require('../src/commands/computers');
404
- const remoteReqCommands = require('../src/commands/requirements-remote');
405
- program
406
- .command('computers')
407
- .description(t('cli.computers.list'))
408
- .option('-f, --focus <area>', 'Filter by focus area')
409
- .option('-s, --status <status>', 'Filter by status (active, idle, error)')
410
- .action(computerCommands.listComputers);
411
-
412
- program
413
- .command('computer:status <computerId>')
414
- .description(t('cli.computer.status.show'))
415
- .action(computerCommands.showComputerStatus);
416
-
417
- program
418
- .command('computer:register <focusArea>')
419
- .description(t('cli.computer.register'))
420
- .action(computerCommands.registerComputer);
421
-
422
- program
423
- .command('computer:focus [newFocusArea]')
424
- .description(t('cli.computer.focus.view'))
425
- .action((newFocusArea) => {
426
- if (newFocusArea) {
427
- computerCommands.updateFocus(newFocusArea);
428
- } else {
429
- // Show current focus
430
- computerCommands.showComputerStatus(require('os').hostname());
431
- }
432
- });
433
-
434
- program
435
- .command('computer:requirements <computerId>')
436
- .description(t('cli.computer.requirements.view'))
437
- .action(remoteReqCommands.listRemoteRequirements);
438
-
439
- program
440
- .command('computer:add-requirement <computerId> <requirement>')
441
- .description(t('cli.computer.requirement.add'))
442
- .action(remoteReqCommands.addRemoteRequirement);
443
-
444
- // Sync management commands
445
- const syncCommands = require('../src/commands/sync');
446
- program
447
- .command('sync:now')
448
- .description(t('cli.sync.trigger'))
449
- .action(syncCommands.syncNow);
450
-
451
- program
452
- .command('sync:status')
453
- .description(t('cli.sync.status.show'))
454
- .action(syncCommands.syncStatus);
455
-
456
- program
457
- .command('sync:queue')
458
- .description(t('cli.sync.queue.view'))
459
- .action(syncCommands.viewQueue);
460
-
461
- program
462
- .command('sync:force')
463
- .description(t('cli.sync.force.sync'))
464
- .action(syncCommands.forceSync);
465
-
466
- program
467
- .command('sync:history')
468
- .description(t('cli.sync.history.view'))
469
- .option('-n, --limit <number>', 'Number of history entries to show', '50')
470
- .action(syncCommands.viewHistory);
471
-
472
- // Interactive mode
473
- program
474
- .command('interactive')
475
- .alias('i')
476
- .description(t('cli.interactive'))
477
- .action(async () => {
478
- const { startInteractive } = require('../src/utils/interactive');
479
- await startInteractive();
480
- });
481
-
482
- // Error handling
483
- process.on('uncaughtException', async (error) => {
484
- console.error(chalk.red(`${t('cli.error')}:`), error.message);
485
- if (process.env.DEBUG) {
486
- console.error(chalk.gray('Stack:'), error.stack);
487
- }
488
- await errorReporter.reportError(error, { type: 'uncaughtException' });
489
- process.exit(1);
490
- });
491
-
492
- process.on('unhandledRejection', async (error) => {
493
- console.error(chalk.red(`${t('cli.error')}:`), error.message);
494
- if (process.env.DEBUG) {
495
- console.error(chalk.gray('Stack:'), error.stack);
496
- }
497
- await errorReporter.reportError(error, { type: 'unhandledRejection' });
498
- process.exit(1);
499
- });
500
-
501
- // Check for updates and display notification
502
- async function checkForUpdates() {
503
- try {
504
- if (process.env.VCM_SKIP_UPDATE_CHECK === '1' || process.env.VCM_SKIP_UPDATE_CHECK === 'true') {
505
- return;
506
- }
507
- // If running inside the repository (local development), skip update checks entirely
508
- const isDevWorkspace = fs.existsSync(path.join(rootDir, '.git'));
509
- if (isDevWorkspace) {
510
- return;
511
- }
512
- // Additional check: if we're in a workspace with package.json containing vibecodingmachine-cli
513
- const packageJsonPath = path.join(rootDir, 'package.json');
514
- if (fs.existsSync(packageJsonPath)) {
515
- try {
516
- const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
517
- if (pkg.name === 'vibecodingmachine' || (pkg.workspaces && pkg.workspaces.length > 0)) {
518
- return;
519
- }
520
- } catch (e) {
521
- // Ignore JSON parse errors
522
- }
523
- }
524
- console.log(chalk.gray(`\n🔍 Checking for updates... (current: v${packageJson.version})`));
525
- // Check npm registry for CLI updates (not S3 manifest which is for Electron)
526
- const { checkForUpdates: checkNpmUpdates } = require('vibecodingmachine-core');
527
- const updateInfo = await checkNpmUpdates('vibecodingmachine-cli', packageJson.version);
528
- console.log(chalk.gray(` Update check result: ${JSON.stringify(updateInfo)}\n`));
529
-
530
- if (updateInfo.hasUpdate) {
531
- // Store update info globally for when auto mode starts
532
- global.pendingUpdate = updateInfo;
533
-
534
- // Display update notification
535
- console.log(chalk.cyan(`\n📦 Update available: v${updateInfo.currentVersion} → v${updateInfo.latestVersion}`));
536
- console.log(chalk.gray(` Published: ${updateInfo.publishedDate}`));
537
-
538
- // Prompt user to update
539
- const answer = await promptWithDefaultsOnce([
540
- {
541
- type: 'confirm',
542
- name: 'shouldUpdate',
543
- message: 'Would you like to update now?',
544
- default: true
545
- }
546
- ]);
547
-
548
- if (answer.shouldUpdate) {
549
- console.log(chalk.cyan('\n🔄 Updating VibeCodingMachine CLI...\n'));
550
- try {
551
- // If we're running from the repository (local dev), avoid performing a global install
552
- const isDevWorkspace = fs.existsSync(path.join(rootDir, '.git'));
553
- if (isDevWorkspace) {
554
- console.log(chalk.yellow('\nDetected local development workspace; skipping automatic global install.'));
555
- console.log(chalk.gray(' To update the globally installed CLI run:') + ' ' + chalk.bold.white('npm install -g vibecodingmachine-cli@latest\n'));
556
- // Do not attempt global install during development to avoid confusing local dev flow
557
- return;
558
- }
559
-
560
- const spinner = ora('Installing update from npm...').start();
561
- try {
562
- // Use npm directly to install the latest version from registry
563
- execSync('npm install -g vibecodingmachine-cli@latest', { stdio: 'inherit', encoding: 'utf8' });
564
- spinner.succeed('Installed update');
565
- console.log(chalk.green('\n✅ Successfully updated to v' + updateInfo.latestVersion + '!'));
566
- console.log(chalk.gray(' Please restart your command to use the new version.\n'));
567
- process.exit(0);
568
- } catch (err) {
569
- spinner.fail('Installation failed');
570
- console.log(chalk.red('\n❌ Update failed:'), err.message);
571
- console.log(chalk.yellow(' You can manually update with: ') + chalk.bold.white('npm install -g vibecodingmachine-cli@latest\n'));
572
- }
573
- } catch (error) {
574
- console.log(chalk.red('\n❌ Update failed:'), error.message);
575
- console.log(chalk.yellow(' You can manually update with: ') + chalk.bold.white('npm install -g vibecodingmachine-cli@latest\n'));
576
- }
577
- } else {
578
- console.log(chalk.gray(' You can update later with: ') + chalk.bold.white('npm install -g vibecodingmachine-cli@latest\n'));
579
- }
580
- } else {
581
- console.log(chalk.gray(' No updates available - you have the latest version!\n'));
582
- }
583
- } catch (error) {
584
- // Show error but don't block CLI usage
585
- console.log(chalk.yellow(`\n⚠️ Update check failed: ${error.message}\n`));
586
- }
587
- }
21
+ // Import modular components
22
+ const { initializeEnvironment } = require('./init/environment-setup');
23
+ const { configureCli, setupBasicCommands, setupRequirementsCommands, setupFeatureAndIdeCommands, setupStatusCommands, setupAuthCommands, setupComputerCommands, setupSyncCommands } = require('./config/cli-config');
24
+ const { setupAgentCommands, setupAgentAliases } = require('./commands/agent-commands');
25
+ const { setupRuiCommands } = require('./commands/rui-commands');
26
+ const { checkForUpdates } = require('./update/update-checker');
27
+ const { setupInteractiveAuth, setupCommandAuth } = require('./auth/auth-compliance');
28
+
29
+ // Configure CLI and setup commands FIRST
30
+ const { commandName, altCommandName } = configureCli({ packageJson, t });
31
+ setupBasicCommands({ t });
32
+ setupRequirementsCommands({ t });
33
+ setupFeatureAndIdeCommands({ t });
34
+ setupStatusCommands({ t });
35
+ setupAuthCommands({ t });
36
+ setupComputerCommands({ t });
37
+ setupSyncCommands({ t });
38
+ setupAgentCommands({ t });
39
+ setupAgentAliases({ t });
40
+ setupRuiCommands({ t });
588
41
 
589
42
  // Start interactive mode if no command provided (check BEFORE parsing)
590
43
  if (!process.argv.slice(2).length) {
591
44
  (async () => {
592
45
  // Check for updates first
593
- await checkForUpdates();
594
-
595
- // Check for first run experience
596
- const { checkFirstRun } = require('../src/utils/first-run');
597
- await checkFirstRun();
598
-
599
- // Check authentication before allowing interactive mode
600
- const auth = require('../src/utils/auth');
601
- const isAuth = await auth.isAuthenticated();
46
+ await checkForUpdates({ packageJson, promptWithDefaultsOnce });
602
47
 
603
- if (!isAuth) {
604
- console.log(chalk.cyan(`\n🔐 ${t('cli.auth.opening.browser')}\n`));
605
- try {
606
- await auth.login();
607
- console.log(chalk.green(`\n✓ ${t('cli.auth.success')}\n`));
608
-
609
- // Initialize error reporter with auth token
610
- const token = await auth.getAuthToken();
611
- if (token) {
612
- errorReporter.setAuthToken(token);
613
- }
614
- } catch (error) {
615
- console.log(chalk.red(`\n✗ ${t('cli.auth.failed')}:`), error.message);
616
- process.exit(1);
617
- }
618
- } else {
619
- // Initialize error reporter with existing auth token
620
- const token = await auth.getAuthToken();
621
- if (token) {
622
- errorReporter.setAuthToken(token);
623
- }
624
- }
625
-
626
- // Check compliance after authentication
627
- const { checkCompliance } = require('../src/utils/compliance-check');
628
- const isCompliant = await checkCompliance();
629
-
630
- if (!isCompliant) {
631
- console.log(chalk.red(`\n✗ ${t('cli.compliance.failed')}\n`));
632
- process.exit(1);
633
- }
634
-
635
- // Track CLI usage - interactive mode
636
- await auth.trackCLIActivity('interactive_mode_started');
48
+ // Setup authentication and compliance for interactive mode
49
+ await setupInteractiveAuth({ t, errorReporter });
637
50
 
638
51
  const { startInteractive } = require('../src/utils/interactive');
639
52
  await startInteractive();
@@ -641,59 +54,12 @@ if (!process.argv.slice(2).length) {
641
54
  } else {
642
55
  // Check for updates before parsing commands
643
56
  (async () => {
644
- await checkForUpdates();
57
+ await checkForUpdates({ packageJson, promptWithDefaultsOnce });
645
58
 
646
- // Check authentication for all commands (except auth commands)
59
+ // Setup authentication and compliance for command execution
647
60
  const command = process.argv[2] || 'unknown';
648
- const authCommands = ['auth:login', 'auth:logout', 'auth:status'];
649
- const skipAuthCheck = authCommands.includes(command);
650
-
651
- const auth = require('../src/utils/auth');
652
-
653
- if (!skipAuthCheck) {
654
- const isAuth = await auth.isAuthenticated();
655
-
656
- if (!isAuth) {
657
- console.log(chalk.cyan(`\n🔐 ${t('cli.auth.opening.browser')}\n`));
658
- try {
659
- await auth.login();
660
- console.log(chalk.green(`\n✓ ${t('cli.auth.success')}\n`));
661
-
662
- // Initialize error reporter with auth token
663
- const token = await auth.getAuthToken();
664
- if (token) {
665
- errorReporter.setAuthToken(token);
666
- }
667
- } catch (error) {
668
- console.log(chalk.red(`\n✗ ${t('cli.auth.failed')}:`), error.message);
669
- process.exit(1);
670
- }
671
- } else {
672
- // Initialize error reporter with existing auth token
673
- const token = await auth.getAuthToken();
674
- if (token) {
675
- errorReporter.setAuthToken(token);
676
- }
677
- }
678
- }
679
-
680
- // Check compliance after authentication (skip for auth commands)
681
- if (!skipAuthCheck) {
682
- const { checkCompliance } = require('../src/utils/compliance-check');
683
- const isCompliant = await checkCompliance();
684
-
685
- if (!isCompliant) {
686
- console.log(chalk.red(`\n✗ ${t('cli.compliance.failed')}\n`));
687
- process.exit(1);
688
- }
689
-
690
- // Track CLI usage - command execution
691
- const args = process.argv.slice(3);
692
- await auth.trackCLIActivity('command_executed', {
693
- command,
694
- args: args.filter(arg => !arg.includes('password') && !arg.includes('token'))
695
- });
696
- }
61
+ const args = process.argv.slice(3);
62
+ await setupCommandAuth({ t, errorReporter }, command, args);
697
63
 
698
64
  // Parse arguments only if commands were provided
699
65
  program.parse(process.argv);