vibecodingmachine-core 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 (202) hide show
  1. package/README.md +240 -0
  2. package/package.json +10 -2
  3. package/src/agents/Agent.js +300 -0
  4. package/src/agents/AgentAdditionService.js +311 -0
  5. package/src/agents/AgentCheckService.js +690 -0
  6. package/src/agents/AgentInstallationService.js +140 -0
  7. package/src/agents/AgentSetupService.js +467 -0
  8. package/src/agents/AgentStatus.js +183 -0
  9. package/src/agents/AgentVerificationService.js +634 -0
  10. package/src/agents/ConfigurationSchemaValidator.js +543 -0
  11. package/src/agents/EnvironmentConfigurationManager.js +602 -0
  12. package/src/agents/InstallationErrorHandler.js +372 -0
  13. package/src/agents/InstallationLog.js +363 -0
  14. package/src/agents/InstallationMethod.js +510 -0
  15. package/src/agents/InstallationOrchestrator.js +352 -0
  16. package/src/agents/InstallationProgressReporter.js +372 -0
  17. package/src/agents/InstallationRetryManager.js +322 -0
  18. package/src/agents/InstallationType.js +254 -0
  19. package/src/agents/OperationTypes.js +310 -0
  20. package/src/agents/PerformanceMetricsCollector.js +493 -0
  21. package/src/agents/SecurityValidationService.js +534 -0
  22. package/src/agents/VerificationTest.js +354 -0
  23. package/src/agents/VerificationType.js +226 -0
  24. package/src/agents/WindowsPermissionHandler.js +518 -0
  25. package/src/agents/config/AgentConfigManager.js +393 -0
  26. package/src/agents/config/AgentDefaultsRegistry.js +373 -0
  27. package/src/agents/config/ConfigValidator.js +281 -0
  28. package/src/agents/discovery/AgentDiscoveryService.js +707 -0
  29. package/src/agents/logging/AgentLogger.js +511 -0
  30. package/src/agents/status/AgentStatusManager.js +481 -0
  31. package/src/agents/storage/FileManager.js +454 -0
  32. package/src/agents/verification/AgentCommunicationTester.js +474 -0
  33. package/src/agents/verification/BaseVerifier.js +430 -0
  34. package/src/agents/verification/CommandVerifier.js +480 -0
  35. package/src/agents/verification/FileOperationVerifier.js +453 -0
  36. package/src/agents/verification/ResultAnalyzer.js +707 -0
  37. package/src/agents/verification/TestRequirementManager.js +495 -0
  38. package/src/agents/verification/VerificationRunner.js +433 -0
  39. package/src/agents/windows/BaseWindowsInstaller.js +441 -0
  40. package/src/agents/windows/ChocolateyInstaller.js +509 -0
  41. package/src/agents/windows/DirectInstaller.js +443 -0
  42. package/src/agents/windows/InstallerFactory.js +391 -0
  43. package/src/agents/windows/NpmInstaller.js +505 -0
  44. package/src/agents/windows/PowerShellInstaller.js +458 -0
  45. package/src/agents/windows/WinGetInstaller.js +390 -0
  46. package/src/analysis/analysis-reporter.js +132 -0
  47. package/src/analysis/boundary-detector.js +712 -0
  48. package/src/analysis/categorizer.js +340 -0
  49. package/src/analysis/codebase-scanner.js +384 -0
  50. package/src/analysis/line-counter.js +513 -0
  51. package/src/analysis/priority-calculator.js +679 -0
  52. package/src/analysis/report/analysis-report.js +250 -0
  53. package/src/analysis/report/package-analyzer.js +278 -0
  54. package/src/analysis/report/recommendation-generator.js +382 -0
  55. package/src/analysis/report/statistics-generator.js +515 -0
  56. package/src/analysis/reports/analysis-report-model.js +101 -0
  57. package/src/analysis/reports/recommendation-generator.js +283 -0
  58. package/src/analysis/reports/report-generators.js +191 -0
  59. package/src/analysis/reports/statistics-calculator.js +231 -0
  60. package/src/analysis/reports/trend-analyzer.js +219 -0
  61. package/src/analysis/strategy-generator.js +814 -0
  62. package/src/auto-mode/AutoModeBusinessLogic.js +836 -0
  63. package/src/config/refactoring-config.js +307 -0
  64. package/src/health-tracking/json-storage.js +38 -2
  65. package/src/ide-integration/applescript-manager-core.js +233 -0
  66. package/src/ide-integration/applescript-manager.cjs +357 -28
  67. package/src/ide-integration/applescript-manager.js +89 -3599
  68. package/src/ide-integration/cdp-manager.js +306 -0
  69. package/src/ide-integration/claude-code-cli-manager.cjs +1 -1
  70. package/src/ide-integration/continuation-handler.js +337 -0
  71. package/src/ide-integration/ide-status-checker.js +292 -0
  72. package/src/ide-integration/macos-ide-manager.js +627 -0
  73. package/src/ide-integration/macos-text-sender.js +528 -0
  74. package/src/ide-integration/response-reader.js +548 -0
  75. package/src/ide-integration/windows-automation-manager.js +121 -0
  76. package/src/ide-integration/windows-ide-manager.js +373 -0
  77. package/src/index.cjs +25 -3
  78. package/src/index.js +15 -1
  79. package/src/llm/direct-llm-manager.cjs +90 -2
  80. package/src/models/compliance-report.js +538 -0
  81. package/src/models/file-analysis.js +681 -0
  82. package/src/models/refactoring-plan.js +770 -0
  83. package/src/monitoring/alert-system.js +834 -0
  84. package/src/monitoring/compliance-progress-tracker.js +437 -0
  85. package/src/monitoring/continuous-scan-notifications.js +661 -0
  86. package/src/monitoring/continuous-scanner.js +279 -0
  87. package/src/monitoring/file-monitor/file-analyzer.js +262 -0
  88. package/src/monitoring/file-monitor/file-monitor.js +237 -0
  89. package/src/monitoring/file-monitor/watcher.js +194 -0
  90. package/src/monitoring/file-monitor.js +17 -0
  91. package/src/monitoring/notification-manager.js +437 -0
  92. package/src/monitoring/scanner-core.js +368 -0
  93. package/src/monitoring/scanner-events.js +214 -0
  94. package/src/monitoring/violation-notification-system.js +515 -0
  95. package/src/refactoring/boundaries/cohesion-analyzer.js +316 -0
  96. package/src/refactoring/boundaries/extraction-result.js +285 -0
  97. package/src/refactoring/boundaries/extraction-strategies.js +392 -0
  98. package/src/refactoring/boundaries/module-boundary.js +209 -0
  99. package/src/refactoring/boundary/boundary-detector.js +741 -0
  100. package/src/refactoring/boundary/boundary-types.js +405 -0
  101. package/src/refactoring/boundary/extraction-strategies.js +554 -0
  102. package/src/refactoring/boundary-extraction-result.js +77 -0
  103. package/src/refactoring/boundary-extraction-strategies.js +330 -0
  104. package/src/refactoring/boundary-extractor.js +384 -0
  105. package/src/refactoring/boundary-types.js +46 -0
  106. package/src/refactoring/circular/circular-dependency.js +88 -0
  107. package/src/refactoring/circular/cycle-detection.js +147 -0
  108. package/src/refactoring/circular/dependency-node.js +82 -0
  109. package/src/refactoring/circular/dependency-result.js +107 -0
  110. package/src/refactoring/circular/dependency-types.js +58 -0
  111. package/src/refactoring/circular/graph-builder.js +213 -0
  112. package/src/refactoring/circular/resolution-strategy.js +72 -0
  113. package/src/refactoring/circular/strategy-generator.js +229 -0
  114. package/src/refactoring/circular-dependency-resolver-original.js +809 -0
  115. package/src/refactoring/circular-dependency-resolver.js +200 -0
  116. package/src/refactoring/code-mover.js +761 -0
  117. package/src/refactoring/file-splitter.js +696 -0
  118. package/src/refactoring/functionality-validator.js +816 -0
  119. package/src/refactoring/import-manager.js +774 -0
  120. package/src/refactoring/module-boundary.js +107 -0
  121. package/src/refactoring/refactoring-executor.js +672 -0
  122. package/src/refactoring/refactoring-rollback.js +614 -0
  123. package/src/refactoring/test-validator.js +631 -0
  124. package/src/requirement-management/default-requirement-manager.js +321 -0
  125. package/src/requirement-management/requirement-file-parser.js +159 -0
  126. package/src/requirement-management/requirement-sequencer.js +221 -0
  127. package/src/rui/commands/AgentCommandParser.js +600 -0
  128. package/src/rui/commands/AgentCommands.js +487 -0
  129. package/src/rui/commands/AgentResponseFormatter.js +832 -0
  130. package/src/scripts/verify-full-compliance.js +269 -0
  131. package/src/sync/sync-engine-core.js +1 -0
  132. package/src/sync/sync-engine-remote-handlers.js +135 -0
  133. package/src/task-generation/automated-task-generator.js +351 -0
  134. package/src/task-generation/prioritizer.js +287 -0
  135. package/src/task-generation/task-list-updater.js +215 -0
  136. package/src/task-generation/task-management-integration.js +480 -0
  137. package/src/task-generation/task-manager-integration.js +270 -0
  138. package/src/task-generation/violation-task-generator.js +474 -0
  139. package/src/task-management/continuous-scan-integration.js +342 -0
  140. package/src/timeout-management/index.js +12 -3
  141. package/src/timeout-management/response-time-tracker.js +167 -0
  142. package/src/timeout-management/timeout-calculator.js +159 -0
  143. package/src/timeout-management/timeout-config-manager.js +172 -0
  144. package/src/utils/ast-analyzer.js +417 -0
  145. package/src/utils/current-requirement-manager.js +276 -0
  146. package/src/utils/current-requirement-operations.js +472 -0
  147. package/src/utils/dependency-mapper.js +456 -0
  148. package/src/utils/download-with-progress.js +4 -2
  149. package/src/utils/electron-update-checker.js +4 -1
  150. package/src/utils/file-size-analyzer.js +272 -0
  151. package/src/utils/import-updater.js +280 -0
  152. package/src/utils/refactoring-tools.js +512 -0
  153. package/src/utils/report-generator.js +569 -0
  154. package/src/utils/reports/report-analysis.js +218 -0
  155. package/src/utils/reports/report-types.js +55 -0
  156. package/src/utils/reports/summary-generators.js +102 -0
  157. package/src/utils/requirement-file-management.js +157 -0
  158. package/src/utils/requirement-helpers/requirement-file-ops.js +392 -0
  159. package/src/utils/requirement-helpers/requirement-mover.js +414 -0
  160. package/src/utils/requirement-helpers/requirement-parser.js +326 -0
  161. package/src/utils/requirement-helpers/requirement-status.js +320 -0
  162. package/src/utils/requirement-helpers-new.js +55 -0
  163. package/src/utils/requirement-helpers-refactored.js +367 -0
  164. package/src/utils/requirement-helpers.js +291 -1191
  165. package/src/utils/requirement-movement-operations.js +450 -0
  166. package/src/utils/requirement-movement.js +312 -0
  167. package/src/utils/requirement-parsing-helpers.js +56 -0
  168. package/src/utils/requirement-statistics.js +200 -0
  169. package/src/utils/requirement-text-utils.js +58 -0
  170. package/src/utils/rollback/rollback-handlers.js +125 -0
  171. package/src/utils/rollback/rollback-operation.js +63 -0
  172. package/src/utils/rollback/rollback-recorder.js +166 -0
  173. package/src/utils/rollback/rollback-state-manager.js +175 -0
  174. package/src/utils/rollback/rollback-types.js +33 -0
  175. package/src/utils/rollback/rollback-utils.js +110 -0
  176. package/src/utils/rollback-manager-original.js +569 -0
  177. package/src/utils/rollback-manager.js +202 -0
  178. package/src/utils/smoke-test-cli.js +362 -0
  179. package/src/utils/smoke-test-gui.js +351 -0
  180. package/src/utils/smoke-test-orchestrator.js +321 -0
  181. package/src/utils/smoke-test-runner.js +60 -0
  182. package/src/utils/smoke-test-web.js +347 -0
  183. package/src/utils/specification-helpers.js +39 -13
  184. package/src/utils/specification-migration.js +97 -0
  185. package/src/utils/test-runner.js +579 -0
  186. package/src/utils/validation-framework.js +518 -0
  187. package/src/validation/compliance-analyzer.js +197 -0
  188. package/src/validation/compliance-report-generator.js +343 -0
  189. package/src/validation/compliance-reporter.js +711 -0
  190. package/src/validation/compliance-rules.js +127 -0
  191. package/src/validation/constitution-validator-new.js +196 -0
  192. package/src/validation/constitution-validator.js +17 -0
  193. package/src/validation/file-validators.js +170 -0
  194. package/src/validation/line-limit/file-analyzer.js +201 -0
  195. package/src/validation/line-limit/line-limit-validator.js +208 -0
  196. package/src/validation/line-limit/validation-result.js +144 -0
  197. package/src/validation/line-limit-core.js +225 -0
  198. package/src/validation/line-limit-reporter.js +134 -0
  199. package/src/validation/line-limit-result.js +125 -0
  200. package/src/validation/line-limit-validator.js +41 -0
  201. package/src/validation/metrics-calculator.js +660 -0
  202. package/src/sync/sync-engine-backup.js +0 -559
@@ -318,4 +318,310 @@ export class CDPManager {
318
318
  return `Error: ${error.message}`;
319
319
  }
320
320
  }
321
+
322
+ /**
323
+ * Detect continuation prompts using DOM inspection
324
+ * @param {Object} client - CDP client
325
+ * @returns {Promise<boolean>} True if continuation prompt detected
326
+ */
327
+ async detectContinuationPrompt(client) {
328
+ try {
329
+ const { DOM, Runtime } = client;
330
+
331
+ // Get document root
332
+ const { result: { root } } = await DOM.getDocument();
333
+
334
+ // Query for continuation buttons
335
+ const continuationSelectors = [
336
+ 'button[title*="Continue"]',
337
+ 'button[title*="Proceed"]',
338
+ 'button[title*="Next"]',
339
+ 'button[title*="Keep Going"]',
340
+ 'button[title*="Resume"]',
341
+ 'button[aria-label*="Continue"]',
342
+ 'button[aria-label*="Proceed"]',
343
+ 'button[aria-label*="Next"]',
344
+ 'button[aria-label*="Keep Going"]',
345
+ 'button[aria-label*="Resume"]',
346
+ '[class*="continue"] button',
347
+ '[class*="proceed"] button',
348
+ '[class*="next"] button',
349
+ 'button:contains("Continue")',
350
+ 'button:contains("Proceed")',
351
+ 'button:contains("Next")',
352
+ 'button:contains("Keep Going")',
353
+ 'button:contains("Resume")',
354
+ 'button:contains("Continue Generation")'
355
+ ];
356
+
357
+ for (const selector of continuationSelectors) {
358
+ try {
359
+ const { result: { nodes } } = await DOM.querySelectorAll({
360
+ nodeId: root.nodeId,
361
+ selector: selector.replace(':contains(', '[text*="').replace(')', '"]')
362
+ });
363
+
364
+ if (nodes && nodes.length > 0) {
365
+ // Check if button text contains continuation keywords
366
+ for (const node of nodes) {
367
+ const { result: { value } } = await DOM.getAttributes({ nodeId: node.nodeId });
368
+ if (value) {
369
+ const attributes = value.split(' ').map(attr => attr.replace(/"/g, ''));
370
+ const textContent = attributes.find(attr =>
371
+ attr.toLowerCase().includes('continue') ||
372
+ attr.toLowerCase().includes('proceed') ||
373
+ attr.toLowerCase().includes('next') ||
374
+ attr.toLowerCase().includes('keep going') ||
375
+ attr.toLowerCase().includes('resume')
376
+ );
377
+
378
+ if (textContent) {
379
+ return true;
380
+ }
381
+ }
382
+ }
383
+ }
384
+ } catch (e) {
385
+ // Continue with next selector if this one fails
386
+ }
387
+ }
388
+
389
+ return false;
390
+ } catch (error) {
391
+ console.error('Error detecting continuation prompt:', error);
392
+ return false;
393
+ }
394
+ }
395
+
396
+ /**
397
+ * Click detected continuation button
398
+ * @param {Object} client - CDP client
399
+ * @returns {Promise<boolean>} True if button clicked successfully
400
+ */
401
+ async clickContinuationButton(client) {
402
+ try {
403
+ const { DOM, Runtime } = client;
404
+
405
+ // Get document root
406
+ const { result: { root } } = await DOM.getDocument();
407
+
408
+ // Query for continuation buttons
409
+ const continuationSelectors = [
410
+ 'button[title*="Continue"]',
411
+ 'button[title*="Proceed"]',
412
+ 'button[title*="Next"]',
413
+ 'button[title*="Keep Going"]',
414
+ 'button[title*="Resume"]',
415
+ 'button[aria-label*="Continue"]',
416
+ 'button[aria-label*="Proceed"]',
417
+ 'button[aria-label*="Next"]',
418
+ 'button[aria-label*="Keep Going"]',
419
+ 'button[aria-label*="Resume"]',
420
+ '[class*="continue"] button',
421
+ '[class*="proceed"] button',
422
+ '[class*="next"] button'
423
+ ];
424
+
425
+ for (const selector of continuationSelectors) {
426
+ try {
427
+ const { result: { nodes } } = await DOM.querySelectorAll({
428
+ nodeId: root.nodeId,
429
+ selector: selector
430
+ });
431
+
432
+ if (nodes && nodes.length > 0) {
433
+ // Click the first found button
434
+ const node = nodes[0];
435
+ await DOM.resolveNode({ nodeId: node.nodeId });
436
+
437
+ // Use Runtime to click the button
438
+ const clickExpression = `document.querySelector('${selector}').click()`;
439
+ await Runtime.evaluate({ expression: clickExpression });
440
+
441
+ return true;
442
+ }
443
+ } catch (e) {
444
+ // Continue with next selector if this one fails
445
+ }
446
+ }
447
+
448
+ return false;
449
+ } catch (error) {
450
+ console.error('Error clicking continuation button:', error);
451
+ return false;
452
+ }
453
+ }
454
+
455
+ /**
456
+ * Check for continuation prompts in the IDE
457
+ * @param {string} ide - The IDE name
458
+ * @returns {Promise<Object>} Result with continuation detected and button info
459
+ */
460
+ async checkForContinuation(ide) {
461
+ try {
462
+ const { Runtime } = await this.connectToIDE(ide);
463
+
464
+ const expression = `(() => {
465
+ try {
466
+ // Look for continuation buttons or prompts
467
+ const continuationSelectors = [
468
+ 'button[title*="Continue"]',
469
+ 'button[title*="Proceed"]',
470
+ 'button:contains("Continue")',
471
+ 'button:contains("Proceed")',
472
+ 'button:contains("Next")',
473
+ 'button:contains("Continue Generation")',
474
+ 'button:contains("Keep Going")',
475
+ '[class*="continue"] button',
476
+ '[class*="proceed"] button',
477
+ '[class*="next"] button',
478
+ 'button[aria-label*="Continue"]',
479
+ 'button[aria-label*="Proceed"]'
480
+ ];
481
+
482
+ // Look for continuation text prompts
483
+ const textSelectors = [
484
+ '[class*="message"]:contains("Continue")',
485
+ '[class*="message"]:contains("Proceed")',
486
+ '[class*="prompt"]:contains("Continue")',
487
+ '[class*="prompt"]:contains("Proceed")',
488
+ '[class*="dialog"]:contains("Continue")',
489
+ '[class*="dialog"]:contains("Proceed")'
490
+ ];
491
+
492
+ const foundButtons = [];
493
+ const foundTexts = [];
494
+
495
+ // Check for buttons
496
+ continuationSelectors.forEach(selector => {
497
+ try {
498
+ const elements = document.querySelectorAll(selector);
499
+ elements.forEach(el => {
500
+ if (el && el.offsetParent !== null) { // Check if visible
501
+ foundButtons.push({
502
+ selector,
503
+ text: el.textContent || el.innerText || '',
504
+ title: el.title || '',
505
+ ariaLabel: el.getAttribute('aria-label') || ''
506
+ });
507
+ }
508
+ });
509
+ } catch (e) {
510
+ // Some selectors may not be supported, ignore
511
+ }
512
+ });
513
+
514
+ // Check for text prompts
515
+ textSelectors.forEach(selector => {
516
+ try {
517
+ const elements = document.querySelectorAll(selector);
518
+ elements.forEach(el => {
519
+ if (el && el.offsetParent !== null) { // Check if visible
520
+ const text = el.textContent || el.innerText || '';
521
+ if (text.toLowerCase().includes('continue') ||
522
+ text.toLowerCase().includes('proceed') ||
523
+ text.toLowerCase().includes('keep going')) {
524
+ foundTexts.push({
525
+ selector,
526
+ text: text.trim()
527
+ });
528
+ }
529
+ }
530
+ });
531
+ } catch (e) {
532
+ // Some selectors may not be supported, ignore
533
+ }
534
+ });
535
+
536
+ return {
537
+ continuationDetected: foundButtons.length > 0 || foundTexts.length > 0,
538
+ buttons: foundButtons,
539
+ texts: foundTexts,
540
+ totalFound: foundButtons.length + foundTexts.length
541
+ };
542
+ } catch (error) {
543
+ return {
544
+ continuationDetected: false,
545
+ error: error.message,
546
+ buttons: [],
547
+ texts: []
548
+ };
549
+ }
550
+ })()`;
551
+
552
+ const { result } = await Runtime.evaluate({ expression, returnByValue: true });
553
+ return result.value || { continuationDetected: false, buttons: [], texts: [] };
554
+ } catch (error) {
555
+ console.error(`Error checking for continuation in ${ide}:`, error);
556
+ return { continuationDetected: false, error: error.message, buttons: [], texts: [] };
557
+ }
558
+ }
559
+
560
+ /**
561
+ * Click a continuation button if found
562
+ * @param {string} ide - The IDE name
563
+ * @returns {Promise<Object>} Result of the operation
564
+ */
565
+ async clickContinuationButton(ide) {
566
+ try {
567
+ const { Runtime } = await this.connectToIDE(ide);
568
+
569
+ const expression = `(() => {
570
+ try {
571
+ // Look for continuation buttons
572
+ const continuationSelectors = [
573
+ 'button[title*="Continue"]',
574
+ 'button[title*="Proceed"]',
575
+ 'button:contains("Continue")',
576
+ 'button:contains("Proceed")',
577
+ 'button:contains("Next")',
578
+ 'button:contains("Continue Generation")',
579
+ 'button:contains("Keep Going")',
580
+ '[class*="continue"] button',
581
+ '[class*="proceed"] button',
582
+ '[class*="next"] button',
583
+ 'button[aria-label*="Continue"]',
584
+ 'button[aria-label*="Proceed"]'
585
+ ];
586
+
587
+ for (const selector of continuationSelectors) {
588
+ try {
589
+ const elements = document.querySelectorAll(selector);
590
+ for (const el of elements) {
591
+ if (el && el.offsetParent !== null) { // Check if visible
592
+ el.click();
593
+ return {
594
+ success: true,
595
+ clicked: true,
596
+ selector: selector,
597
+ text: el.textContent || el.innerText || ''
598
+ };
599
+ }
600
+ }
601
+ } catch (e) {
602
+ // Some selectors may not be supported, continue
603
+ }
604
+ }
605
+
606
+ return {
607
+ success: false,
608
+ clicked: false,
609
+ message: 'No continuation button found'
610
+ };
611
+ } catch (error) {
612
+ return {
613
+ success: false,
614
+ clicked: false,
615
+ error: error.message
616
+ };
617
+ }
618
+ })()`;
619
+
620
+ const { result } = await Runtime.evaluate({ expression, returnByValue: true });
621
+ return result.value || { success: false, clicked: false, message: 'No result' };
622
+ } catch (error) {
623
+ console.error(`Error clicking continuation button in ${ide}:`, error);
624
+ return { success: false, clicked: false, error: error.message };
625
+ }
626
+ }
321
627
  }
@@ -312,7 +312,7 @@ class ClaudeCodeCLIManager {
312
312
  // If we have a reset time, update the provider manager
313
313
  if (rateLimitInfo.resetTime) {
314
314
  try {
315
- const ProviderManager = require('vibecodingmachine-core/src/ide-integration/provider-manager.cjs');
315
+ const ProviderManager = require('../ide-integration/provider-manager.cjs');
316
316
  const providerManager = new ProviderManager();
317
317
  providerManager.markRateLimited('claude-code', 'claude-code-cli', rateLimitInfo.message);
318
318
  } catch (e) {
@@ -0,0 +1,337 @@
1
+ // @vibecodingmachine/core - Continuation Handler
2
+ // Cross-platform continuation button detection and clicking
3
+
4
+ const { execSync } = require('child_process');
5
+
6
+ /**
7
+ * Continuation Handler for cross-platform continuation button operations
8
+ * Handles continuation detection and clicking for all supported IDEs
9
+ */
10
+ class ContinuationHandler {
11
+ constructor(platform, windowsManager = null) {
12
+ this.logger = console;
13
+ this.platform = platform;
14
+ this.windowsManager = windowsManager;
15
+ }
16
+
17
+ /**
18
+ * Detect continuation prompts using platform-specific methods
19
+ * @returns {Promise<boolean>} True if continuation prompt detected
20
+ */
21
+ async detectContinuationPrompt() {
22
+ try {
23
+ const continuationVariations = ['Continue', 'Proceed', 'Next', 'Keep Going', 'Resume'];
24
+
25
+ for (const variation of continuationVariations) {
26
+ try {
27
+ const script = this._getContinuationButtonScript(variation);
28
+ const result = execSync(`osascript -e '${script.replace(/'/g, "'\\\\''")}'`, {
29
+ encoding: 'utf8',
30
+ timeout: 5000,
31
+ stdio: 'pipe'
32
+ }).trim();
33
+
34
+ if (result && result.toLowerCase().includes('found')) {
35
+ return true;
36
+ }
37
+ } catch (error) {
38
+ // Continue with next variation
39
+ }
40
+ }
41
+
42
+ return false;
43
+ } catch (error) {
44
+ console.error('Error detecting continuation prompt:', error);
45
+ return false;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Click detected continuation button using platform-specific methods
51
+ * @returns {Promise<boolean>} True if button clicked successfully
52
+ */
53
+ async clickContinuationButton() {
54
+ try {
55
+ const continuationVariations = ['Continue', 'Proceed', 'Next', 'Keep Going', 'Resume'];
56
+
57
+ for (const variation of continuationVariations) {
58
+ try {
59
+ const script = this._getClickButtonScript(variation);
60
+ const result = execSync(`osascript -e '${script.replace(/'/g, "'\\\\''")}'`, {
61
+ encoding: 'utf8',
62
+ timeout: 5000,
63
+ stdio: 'pipe'
64
+ }).trim();
65
+
66
+ if (result && result.toLowerCase().includes('clicked')) {
67
+ return true;
68
+ }
69
+ } catch (error) {
70
+ // Continue with next variation
71
+ }
72
+ }
73
+
74
+ return false;
75
+ } catch (error) {
76
+ console.error('Error clicking continuation button:', error);
77
+ return false;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Check for continuation prompts using platform-specific methods
83
+ * @param {string} ide - The IDE name
84
+ * @returns {Promise<Object>} Result with continuation detected and button info
85
+ */
86
+ async checkForContinuation(ide) {
87
+ try {
88
+ if (this.platform === 'darwin') {
89
+ return await this.checkForContinuationMacOS(ide);
90
+ } else if (this.platform === 'win32' && this.windowsManager) {
91
+ return await this.checkForContinuationWindows(ide);
92
+ } else {
93
+ return { continuationDetected: false, error: 'Unsupported platform' };
94
+ }
95
+ } catch (error) {
96
+ this.logger.error(`Error checking for continuation in ${ide}:`, error);
97
+ return { continuationDetected: false, error: error.message };
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Click a continuation button if found
103
+ * @param {string} ide - The IDE name
104
+ * @returns {Promise<Object>} Result of operation
105
+ */
106
+ async clickContinuationButton(ide) {
107
+ try {
108
+ if (this.platform === 'darwin') {
109
+ return await this.clickContinuationButtonMacOS(ide);
110
+ } else if (this.platform === 'win32' && this.windowsManager) {
111
+ return await this.clickContinuationButtonWindows(ide);
112
+ } else {
113
+ return { success: false, error: 'Unsupported platform' };
114
+ }
115
+ } catch (error) {
116
+ this.logger.error(`Error clicking continuation button in ${ide}:`, error);
117
+ return { success: false, error: error.message };
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Check for continuation prompts on macOS using AppleScript
123
+ * @param {string} ide - The IDE name
124
+ * @returns {Promise<Object>} Result with continuation detected and button info
125
+ */
126
+ async checkForContinuationMacOS(ide) {
127
+ try {
128
+ const script = `
129
+ tell application "System Events"
130
+ try
131
+ set frontApp to first application process whose frontmost is true
132
+ set appName to name of frontApp
133
+
134
+ -- Look for continuation buttons
135
+ set continuationButtons to {}
136
+ set buttonNames to {"Continue", "Proceed", "Next", "Continue Generation", "Keep Going"}
137
+
138
+ repeat with buttonName in buttonNames
139
+ try
140
+ set foundButtons to (buttons of frontApp whose name contains buttonName)
141
+ repeat with aButton in foundButtons
142
+ if exists aButton then
143
+ set end of continuationButtons to {name:aButton, visible:true}
144
+ end if
145
+ end repeat
146
+ end try
147
+ end repeat
148
+
149
+ -- Look for continuation text in UI elements
150
+ set continuationTexts to {}
151
+ set textElements to (static texts of frontApp)
152
+ repeat with textElement in textElements
153
+ try
154
+ set elementText to name of textElement
155
+ if elementText contains "Continue" or elementText contains "Proceed" or elementText contains "Keep Going" then
156
+ set end of continuationTexts to {name: elementText, visible: true}
157
+ end if
158
+ end try
159
+ end repeat
160
+
161
+ return {buttons: continuationButtons, texts: continuationTexts}
162
+ on error errMsg number errNum
163
+ return {errorMsg:errMsg}
164
+ end try
165
+ end tell
166
+ `;
167
+
168
+ const result = execSync(`osascript -e '${script}'`, {
169
+ encoding: 'utf8',
170
+ timeout: 10000
171
+ });
172
+
173
+ // Parse result (simplified parsing)
174
+ const continuationDetected = result.includes('Continue') || result.includes('Proceed');
175
+
176
+ return {
177
+ continuationDetected,
178
+ buttons: continuationDetected ? [{ text: 'Continue button detected' }] : [],
179
+ texts: continuationDetected ? [{ text: 'Continuation prompt detected' }] : [],
180
+ rawResult: result
181
+ };
182
+ } catch (error) {
183
+ return { continuationDetected: false, error: error.message };
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Check for continuation prompts on Windows using UI automation
189
+ * @param {string} ide - The IDE name
190
+ * @returns {Promise<Object>} Result with continuation detected and button info
191
+ */
192
+ async checkForContinuationWindows(ide) {
193
+ try {
194
+ // Use Windows automation manager to check for continuation buttons
195
+ const result = await this.windowsManager.checkForContinuationButtons(ide);
196
+ return result || { continuationDetected: false, buttons: [], texts: [] };
197
+ } catch (error) {
198
+ return { continuationDetected: false, error: error.message };
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Click continuation button on macOS using AppleScript
204
+ * @param {string} ide - The IDE name
205
+ * @returns {Promise<Object>} Result of operation
206
+ */
207
+ async clickContinuationButtonMacOS(ide) {
208
+ try {
209
+ const script = `
210
+ tell application "System Events"
211
+ try
212
+ set frontApp to first application process whose frontmost is true
213
+ set appName to name of frontApp
214
+
215
+ -- Look for and click continuation buttons
216
+ set buttonNames to {"Continue", "Proceed", "Next", "Continue Generation", "Keep Going"}
217
+
218
+ repeat with buttonName in buttonNames
219
+ try
220
+ set foundButtons to (buttons of frontApp whose name contains buttonName)
221
+ repeat with aButton in foundButtons
222
+ if exists aButton then
223
+ click aButton
224
+ return {success:true, clicked:true, button:buttonName}
225
+ end if
226
+ end repeat
227
+ end try
228
+ end repeat
229
+
230
+ return {success:false, clicked:false, message:"No continuation button found"}
231
+ on error errMsg number errNum
232
+ return {success:false, errorMsg:errMsg}
233
+ end try
234
+ end tell
235
+ `;
236
+
237
+ const result = execSync(`osascript -e '${script}'`, {
238
+ encoding: 'utf8',
239
+ timeout: 10000
240
+ });
241
+
242
+ return {
243
+ success: result.includes('success:true'),
244
+ clicked: result.includes('clicked:true'),
245
+ rawResult: result
246
+ };
247
+ } catch (error) {
248
+ return { success: false, clicked: false, error: error.message };
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Click continuation button on Windows using UI automation
254
+ * @param {string} ide - The IDE name
255
+ * @returns {Promise<Object>} Result of operation
256
+ */
257
+ async clickContinuationButtonWindows(ide) {
258
+ try {
259
+ // Use Windows automation manager to click continuation buttons
260
+ const result = await this.windowsManager.clickContinuationButton(ide);
261
+ return result || { success: false, clicked: false, message: 'No result' };
262
+ } catch (error) {
263
+ return { success: false, clicked: false, error: error.message };
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Generate AppleScript for detecting continuation buttons
269
+ * @param {string} buttonText - Text to search for (Continue, Proceed, etc.)
270
+ * @returns {string} AppleScript code
271
+ */
272
+ _getContinuationButtonScript(buttonText) {
273
+ return `
274
+ tell application "System Events"
275
+ set foundButton to false
276
+ repeat with proc in (every process)
277
+ try
278
+ repeat with w in (every window of proc)
279
+ try
280
+ repeat with btn in (every button of w)
281
+ try
282
+ set btnTitle to title of btn as string
283
+ if btnTitle contains "${buttonText}" then
284
+ set foundButton to true
285
+ exit repeat
286
+ end if
287
+ end try
288
+ end repeat
289
+ if foundButton then exit repeat
290
+ end try
291
+ end repeat
292
+ if foundButton then exit repeat
293
+ end try
294
+ end repeat
295
+
296
+ if foundButton then
297
+ return "${buttonText} button found"
298
+ else
299
+ return "${buttonText} button not found"
300
+ end if
301
+ end tell
302
+ `;
303
+ }
304
+
305
+ /**
306
+ * Generate AppleScript for clicking continuation buttons
307
+ * @param {string} buttonText - Text to search for (Continue, Proceed, etc.)
308
+ * @returns {string} AppleScript code
309
+ */
310
+ _getClickButtonScript(buttonText) {
311
+ return `
312
+ tell application "System Events"
313
+ repeat with proc in (every process)
314
+ try
315
+ repeat with w in (every window of proc)
316
+ try
317
+ repeat with btn in (every button of w)
318
+ try
319
+ set btnTitle to title of btn as string
320
+ if btnTitle contains "${buttonText}" then
321
+ click btn
322
+ return "${buttonText} button clicked"
323
+ end if
324
+ end try
325
+ end repeat
326
+ end try
327
+ end repeat
328
+ end try
329
+ end repeat
330
+
331
+ return "${buttonText} button not found"
332
+ end tell
333
+ `;
334
+ }
335
+ }
336
+
337
+ module.exports = ContinuationHandler;