vibecodingmachine-core 2026.2.26-1739 → 2026.3.9-850
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/package.json +1 -1
- package/src/agents/AgentCheckDiscoveryService.js +180 -0
- package/src/agents/AgentCheckService.js +18 -261
- package/src/agents/AgentCheckStatisticsService.js +195 -0
- package/src/agents/EnvironmentConfigurationManager.js +31 -380
- package/src/agents/InstallationType.js +19 -6
- package/src/agents/SimpleAgentCheckService.js +472 -0
- package/src/agents/config-managers/ConfigUtils.js +72 -0
- package/src/agents/config-managers/DefaultConfig.js +58 -0
- package/src/agents/config-managers/EnvVarLoader.js +66 -0
- package/src/agents/config-managers/FileConfigLoader.js +124 -0
- package/src/agents/config-managers/TypeConverters.js +61 -0
- package/src/agents/config-managers/VariableMappings.js +92 -0
- package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
- package/src/agents/discovery/AgentDiscoveryService.js +29 -403
- package/src/agents/discovery/agent-validator.js +262 -0
- package/src/agents/discovery/discovery-results.js +176 -0
- package/src/agents/discovery/discovery-scanner.js +268 -0
- package/src/agents/discovery/discovery-utils.js +161 -0
- package/src/agents/discovery/executable-analyzer.js +290 -0
- package/src/agents/discovery/history-manager.js +310 -0
- package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
- package/src/agents/verification/ResultAnalyzer.js +30 -431
- package/src/agents/verification/analysis-utils.js +310 -0
- package/src/agents/verification/batch-analyzer.js +440 -0
- package/src/agents/verification/pattern-recognizer.js +369 -0
- package/src/agents/verification/report-generator.js +320 -0
- package/src/agents/verification/test-analyzer.js +290 -0
- package/src/agents/windows/InstallerFactory.js +4 -0
- package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
- package/src/analysis/analysis-engine.js +314 -0
- package/src/analysis/ast-analyzer.js +342 -0
- package/src/analysis/boundary-detector-refactored.js +378 -0
- package/src/analysis/boundary-detector.js +200 -603
- package/src/analysis/boundary-scanner.js +609 -0
- package/src/analysis/boundary-types.js +118 -0
- package/src/analysis/boundary-utils.js +293 -0
- package/src/analysis/deadline-priority-calculator.js +18 -0
- package/src/analysis/detection-methods.js +347 -0
- package/src/analysis/importance-priority-calculator.js +18 -0
- package/src/analysis/priority/factor-calculators.js +204 -0
- package/src/analysis/priority/factor-helpers.js +71 -0
- package/src/analysis/priority/priority-constants.js +73 -0
- package/src/analysis/priority/priority-factor-calculators.js +301 -0
- package/src/analysis/priority/reasons-generator.js +44 -0
- package/src/analysis/priority-calculator.js +15 -580
- package/src/analysis/strategy-generator.js +16 -66
- package/src/analysis/type-priority-calculator.js +18 -0
- package/src/analysis/urgency-priority-calculator.js +18 -0
- package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
- package/src/commands/disable-requirement.js +60 -0
- package/src/commands/disable-spec.js +60 -0
- package/src/commands/enable-requirement.js +60 -0
- package/src/commands/enable-spec.js +60 -0
- package/src/commands/registry.js +1 -6
- package/src/commands/requirements.js +8 -2
- package/src/ide-integration/applescript-manager.cjs +9 -24
- package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
- package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
- package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
- package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
- package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
- package/src/ide-integration/cdp-manager.js +28 -573
- package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
- package/src/ide-integration/ide-openers/claude-opener.js +171 -0
- package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
- package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
- package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
- package/src/ide-integration/macos-ide-manager.js +20 -582
- package/src/ide-integration/macos-quota-checker.js +164 -0
- package/src/ide-integration/macos-text-sender.js +19 -38
- package/src/ide-integration/provider-manager.cjs +52 -7
- package/src/index.cjs +6 -0
- package/src/index.js +10 -0
- package/src/llm/direct-llm-manager.cjs +501 -0
- package/src/localization/translations/en-part1.js +363 -0
- package/src/localization/translations/en-part2.js +320 -0
- package/src/localization/translations/en.js +4 -687
- package/src/localization/translations/es-part1.js +363 -0
- package/src/localization/translations/es-part2.js +320 -0
- package/src/localization/translations/es.js +4 -688
- package/src/models/file-analysis-collection.js +139 -0
- package/src/models/file-analysis-metrics.js +50 -0
- package/src/models/file-analysis.js +15 -262
- package/src/models/plan-manager.js +410 -0
- package/src/models/refactoring-models.js +380 -0
- package/src/models/refactoring-plan-refactored.js +81 -0
- package/src/models/refactoring-plan.js +2 -663
- package/src/monitoring/alert-system.js +4 -45
- package/src/monitoring/continuous-scan-notifications.js +37 -191
- package/src/monitoring/notification-handlers/base-handler.js +58 -0
- package/src/monitoring/notification-handlers/error-handler.js +36 -0
- package/src/monitoring/notification-handlers/index.js +21 -0
- package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
- package/src/monitoring/notification-handlers/progress-handler.js +48 -0
- package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
- package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
- package/src/provider-registry.js +8 -0
- package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
- package/src/refactoring/boundary/boundary-detector.js +26 -596
- package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
- package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
- package/src/refactoring/boundary/detectors/class-detector.js +247 -0
- package/src/refactoring/boundary/detectors/config-detector.js +270 -0
- package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
- package/src/refactoring/boundary/detectors/function-detector.js +248 -0
- package/src/refactoring/boundary/detectors/module-detector.js +249 -0
- package/src/refactoring/boundary/detectors/object-detector.js +247 -0
- package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
- package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
- package/src/refactoring/circular-dependency-resolver-original.js +16 -76
- package/src/refactoring/code-mover-refactored.js +309 -0
- package/src/refactoring/code-mover.js +48 -355
- package/src/refactoring/execution-status.js +18 -0
- package/src/refactoring/execution-strategies.js +172 -0
- package/src/refactoring/file-splitter-core.js +568 -0
- package/src/refactoring/file-splitter-types.js +136 -0
- package/src/refactoring/file-splitter.js +2 -682
- package/src/refactoring/functionality-validator.js +11 -51
- package/src/refactoring/import-manager-refactored.js +385 -0
- package/src/refactoring/import-manager.js +112 -487
- package/src/refactoring/import-models.js +189 -0
- package/src/refactoring/import-parser.js +306 -0
- package/src/refactoring/move-executor.js +431 -0
- package/src/refactoring/move-utils.js +368 -0
- package/src/refactoring/operation-executor.js +76 -0
- package/src/refactoring/plan-creator.js +36 -0
- package/src/refactoring/plan-executor.js +143 -0
- package/src/refactoring/plan-validator.js +68 -0
- package/src/refactoring/refactoring-executor-result.js +70 -0
- package/src/refactoring/refactoring-executor.js +34 -569
- package/src/refactoring/refactoring-operation.js +94 -0
- package/src/refactoring/refactoring-plan.js +69 -0
- package/src/refactoring/refactoring-rollback.js +22 -527
- package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
- package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
- package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
- package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
- package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
- package/src/refactoring/test-validator.js +32 -448
- package/src/refactoring/validation/baseline-runner.js +71 -0
- package/src/refactoring/validation/report-generator.js +136 -0
- package/src/refactoring/validation/result-comparator.js +92 -0
- package/src/refactoring/validation/test-suite.js +59 -0
- package/src/refactoring/validation/test-validation-result.js +83 -0
- package/src/refactoring/validation/validation-runner.js +95 -0
- package/src/refactoring/validation/validation-status.js +18 -0
- package/src/rui/commands/AgentCommandParser.js +60 -369
- package/src/rui/commands/AgentResponseFormatter.js +7 -47
- package/src/rui/commands/parsers/CommandMapper.js +148 -0
- package/src/rui/commands/parsers/CommandValidator.js +228 -0
- package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
- package/src/rui/commands/parsers/TokenParser.js +69 -0
- package/src/rui/commands/parsers/tokenizer.js +153 -0
- package/src/utils/current-requirement-operations.js +50 -1
- package/src/utils/report-generator.js +18 -514
- package/src/utils/report-generators/analysis-generator.js +115 -0
- package/src/utils/report-generators/base-generator.js +141 -0
- package/src/utils/report-generators/compliance-generator.js +41 -0
- package/src/utils/report-generators/format-handlers.js +185 -0
- package/src/utils/report-generators/refactoring-generator.js +46 -0
- package/src/utils/report-generators/validation-generator.js +63 -0
- package/src/utils/requirement-enable-disable.js +265 -0
- package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
- package/src/utils/requirement-helpers/requirement-mover.js +88 -1
- package/src/utils/requirement-helpers.js +5 -2
- package/src/utils/smoke-test-cli.js +45 -8
- package/src/utils/specification-enable-disable.js +122 -0
- package/src/utils/specification-helpers.js +30 -4
- package/src/utils/specification-migration.js +5 -5
- package/src/utils/test-comparator.js +118 -0
- package/src/utils/test-config.js +54 -0
- package/src/utils/test-executor.js +133 -0
- package/src/utils/test-parser.js +215 -0
- package/src/utils/test-runner-baseline.js +63 -0
- package/src/utils/test-runner-core.js +98 -0
- package/src/utils/test-runner-report.js +39 -0
- package/src/utils/test-runner-validation.js +71 -0
- package/src/utils/test-runner.js +11 -535
- package/src/validation/comparison-analyzer.js +333 -0
- package/src/validation/compliance-reporter-new.js +282 -0
- package/src/validation/compliance-reporter-refactored.js +344 -0
- package/src/validation/compliance-reporter.js +278 -591
- package/src/validation/compliance-utils.js +278 -0
- package/src/validation/html-generator.js +446 -0
- package/src/validation/metrics/category-calculator.js +137 -0
- package/src/validation/metrics/metrics-helpers.js +155 -0
- package/src/validation/metrics/overview-calculator.js +85 -0
- package/src/validation/metrics/overview-metrics.js +41 -0
- package/src/validation/metrics/quality-calculator.js +166 -0
- package/src/validation/metrics/size-calculator.js +69 -0
- package/src/validation/metrics-calculator.js +27 -551
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import CDP from 'chrome-remote-interface';
|
|
2
|
+
|
|
3
|
+
// Timeout utility function
|
|
4
|
+
function timeout(ms, promise) {
|
|
5
|
+
return Promise.race([
|
|
6
|
+
promise,
|
|
7
|
+
new Promise((_, reject) =>
|
|
8
|
+
setTimeout(() => reject(new Error(`Operation timed out after ${ms}ms`)), ms)
|
|
9
|
+
)
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Handles CDP connection to IDEs
|
|
15
|
+
*/
|
|
16
|
+
export class ConnectionHandler {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.ports = {
|
|
19
|
+
vscode: 9222,
|
|
20
|
+
cursor: 9225,
|
|
21
|
+
windsurf: 9224
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Connect to an IDE via CDP
|
|
27
|
+
* @param {string} ide - The IDE name (vscode, cursor, windsurf)
|
|
28
|
+
* @param {number} port - The CDP port (optional, will use default if not provided)
|
|
29
|
+
* @returns {Promise<Object>} CDP client and domains
|
|
30
|
+
*/
|
|
31
|
+
async connectToIDE(ide, port = null) {
|
|
32
|
+
const targetPort = port || this.ports[ide];
|
|
33
|
+
|
|
34
|
+
if (!targetPort) {
|
|
35
|
+
throw new Error(`No CDP port configured for IDE: ${ide}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
console.log(`🔍 Connecting to ${ide} on port ${targetPort}...`);
|
|
40
|
+
|
|
41
|
+
const targets = await timeout(5000, CDP.List({ port: targetPort }));
|
|
42
|
+
|
|
43
|
+
if (!targets || targets.length === 0) {
|
|
44
|
+
throw new Error(`Could not find ${ide}. Make sure ${ide} is running with --remote-debugging-port=${targetPort}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Find the appropriate target
|
|
48
|
+
let target;
|
|
49
|
+
if (ide === 'vscode') {
|
|
50
|
+
target = targets.find(t => t.url && t.url.includes('workbench')) || targets[0];
|
|
51
|
+
} else {
|
|
52
|
+
target = targets[0];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!target) {
|
|
56
|
+
throw new Error(`No suitable target found for ${ide}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(`Found ${targets.length} targets, using: ${target.title}`);
|
|
60
|
+
|
|
61
|
+
const client = await CDP({ port: targetPort, target });
|
|
62
|
+
const { Runtime, Input, Page, DOM } = client;
|
|
63
|
+
|
|
64
|
+
await Runtime.enable();
|
|
65
|
+
await DOM.enable();
|
|
66
|
+
|
|
67
|
+
if (Page && Page.bringToFront) {
|
|
68
|
+
try {
|
|
69
|
+
await Page.bringToFront();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.log('Could not bring page to front:', error.message);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
client,
|
|
77
|
+
Runtime,
|
|
78
|
+
Input,
|
|
79
|
+
Page,
|
|
80
|
+
DOM,
|
|
81
|
+
target
|
|
82
|
+
};
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(`CDP connection error for ${ide}:`, error);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles continuation prompt detection and interaction
|
|
3
|
+
*/
|
|
4
|
+
export class ContinuationHandler {
|
|
5
|
+
constructor(connectionHandler) {
|
|
6
|
+
this.connectionHandler = connectionHandler;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Detect continuation prompts using DOM inspection
|
|
11
|
+
* @param {Object} client - CDP client
|
|
12
|
+
* @returns {Promise<boolean>} True if continuation prompt detected
|
|
13
|
+
*/
|
|
14
|
+
async detectContinuationPrompt(client) {
|
|
15
|
+
try {
|
|
16
|
+
const { DOM, Runtime } = client;
|
|
17
|
+
|
|
18
|
+
// Get document root
|
|
19
|
+
const { result: { root } } = await DOM.getDocument();
|
|
20
|
+
|
|
21
|
+
// Query for continuation buttons
|
|
22
|
+
const continuationSelectors = [
|
|
23
|
+
'button[title*="Continue"]',
|
|
24
|
+
'button[title*="Proceed"]',
|
|
25
|
+
'button[title*="Next"]',
|
|
26
|
+
'button[title*="Keep Going"]',
|
|
27
|
+
'button[title*="Resume"]',
|
|
28
|
+
'button[aria-label*="Continue"]',
|
|
29
|
+
'button[aria-label*="Proceed"]',
|
|
30
|
+
'button[aria-label*="Next"]',
|
|
31
|
+
'button[aria-label*="Keep Going"]',
|
|
32
|
+
'button[aria-label*="Resume"]',
|
|
33
|
+
'[class*="continue"] button',
|
|
34
|
+
'[class*="proceed"] button',
|
|
35
|
+
'[class*="next"] button',
|
|
36
|
+
'button:contains("Continue")',
|
|
37
|
+
'button:contains("Proceed")',
|
|
38
|
+
'button:contains("Next")',
|
|
39
|
+
'button:contains("Keep Going")',
|
|
40
|
+
'button:contains("Resume")',
|
|
41
|
+
'button:contains("Continue Generation")'
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
for (const selector of continuationSelectors) {
|
|
45
|
+
try {
|
|
46
|
+
const { result: { nodes } } = await DOM.querySelectorAll({
|
|
47
|
+
nodeId: root.nodeId,
|
|
48
|
+
selector: selector.replace(':contains(', '[text*="').replace(')', '"]')
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (nodes && nodes.length > 0) {
|
|
52
|
+
// Check if button text contains continuation keywords
|
|
53
|
+
for (const node of nodes) {
|
|
54
|
+
const { result: { value } } = await DOM.getAttributes({ nodeId: node.nodeId });
|
|
55
|
+
if (value) {
|
|
56
|
+
const attributes = value.split(' ').map(attr => attr.replace(/"/g, ''));
|
|
57
|
+
const textContent = attributes.find(attr =>
|
|
58
|
+
attr.toLowerCase().includes('continue') ||
|
|
59
|
+
attr.toLowerCase().includes('proceed') ||
|
|
60
|
+
attr.toLowerCase().includes('next') ||
|
|
61
|
+
attr.toLowerCase().includes('keep going') ||
|
|
62
|
+
attr.toLowerCase().includes('resume')
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (textContent) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (e) {
|
|
72
|
+
// Continue with next selector if this one fails
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return false;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('Error detecting continuation prompt:', error);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Click detected continuation button using DOM
|
|
85
|
+
* @param {Object} client - CDP client
|
|
86
|
+
* @returns {Promise<boolean>} True if button clicked successfully
|
|
87
|
+
*/
|
|
88
|
+
async clickContinuationButtonDOM(client) {
|
|
89
|
+
try {
|
|
90
|
+
const { DOM, Runtime } = client;
|
|
91
|
+
|
|
92
|
+
// Get document root
|
|
93
|
+
const { result: { root } } = await DOM.getDocument();
|
|
94
|
+
|
|
95
|
+
// Query for continuation buttons
|
|
96
|
+
const continuationSelectors = [
|
|
97
|
+
'button[title*="Continue"]',
|
|
98
|
+
'button[title*="Proceed"]',
|
|
99
|
+
'button[title*="Next"]',
|
|
100
|
+
'button[title*="Keep Going"]',
|
|
101
|
+
'button[title*="Resume"]',
|
|
102
|
+
'button[aria-label*="Continue"]',
|
|
103
|
+
'button[aria-label*="Proceed"]',
|
|
104
|
+
'button[aria-label*="Next"]',
|
|
105
|
+
'button[aria-label*="Keep Going"]',
|
|
106
|
+
'button[aria-label*="Resume"]',
|
|
107
|
+
'[class*="continue"] button',
|
|
108
|
+
'[class*="proceed"] button',
|
|
109
|
+
'[class*="next"] button'
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
for (const selector of continuationSelectors) {
|
|
113
|
+
try {
|
|
114
|
+
const { result: { nodes } } = await DOM.querySelectorAll({
|
|
115
|
+
nodeId: root.nodeId,
|
|
116
|
+
selector: selector
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (nodes && nodes.length > 0) {
|
|
120
|
+
// Click the first found button
|
|
121
|
+
const node = nodes[0];
|
|
122
|
+
await DOM.resolveNode({ nodeId: node.nodeId });
|
|
123
|
+
|
|
124
|
+
// Use Runtime to click the button
|
|
125
|
+
const clickExpression = `document.querySelector('${selector}').click()`;
|
|
126
|
+
await Runtime.evaluate({ expression: clickExpression });
|
|
127
|
+
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
} catch (e) {
|
|
131
|
+
// Continue with next selector if this one fails
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return false;
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error('Error clicking continuation button:', error);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Check for continuation prompts in the IDE
|
|
144
|
+
* @param {string} ide - The IDE name
|
|
145
|
+
* @returns {Promise<Object>} Result with continuation detected and button info
|
|
146
|
+
*/
|
|
147
|
+
async checkForContinuation(ide) {
|
|
148
|
+
try {
|
|
149
|
+
const { Runtime } = await this.connectionHandler.connectToIDE(ide);
|
|
150
|
+
|
|
151
|
+
const expression = `(() => {
|
|
152
|
+
try {
|
|
153
|
+
// Look for continuation buttons or prompts
|
|
154
|
+
const continuationSelectors = [
|
|
155
|
+
'button[title*="Continue"]',
|
|
156
|
+
'button[title*="Proceed"]',
|
|
157
|
+
'button:contains("Continue")',
|
|
158
|
+
'button:contains("Proceed")',
|
|
159
|
+
'button:contains("Next")',
|
|
160
|
+
'button:contains("Continue Generation")',
|
|
161
|
+
'button:contains("Keep Going")',
|
|
162
|
+
'[class*="continue"] button',
|
|
163
|
+
'[class*="proceed"] button',
|
|
164
|
+
'[class*="next"] button',
|
|
165
|
+
'button[aria-label*="Continue"]',
|
|
166
|
+
'button[aria-label*="Proceed"]'
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
// Look for continuation text prompts
|
|
170
|
+
const textSelectors = [
|
|
171
|
+
'[class*="message"]:contains("Continue")',
|
|
172
|
+
'[class*="message"]:contains("Proceed")',
|
|
173
|
+
'[class*="prompt"]:contains("Continue")',
|
|
174
|
+
'[class*="prompt"]:contains("Proceed")',
|
|
175
|
+
'[class*="dialog"]:contains("Continue")',
|
|
176
|
+
'[class*="dialog"]:contains("Proceed")'
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
const foundButtons = [];
|
|
180
|
+
const foundTexts = [];
|
|
181
|
+
|
|
182
|
+
// Check for buttons
|
|
183
|
+
continuationSelectors.forEach(selector => {
|
|
184
|
+
try {
|
|
185
|
+
const elements = document.querySelectorAll(selector);
|
|
186
|
+
elements.forEach(el => {
|
|
187
|
+
if (el && el.offsetParent !== null) { // Check if visible
|
|
188
|
+
foundButtons.push({
|
|
189
|
+
selector,
|
|
190
|
+
text: el.textContent || el.innerText || '',
|
|
191
|
+
title: el.title || '',
|
|
192
|
+
ariaLabel: el.getAttribute('aria-label') || ''
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
} catch (e) {
|
|
197
|
+
// Some selectors may not be supported, ignore
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// Check for text prompts
|
|
202
|
+
textSelectors.forEach(selector => {
|
|
203
|
+
try {
|
|
204
|
+
const elements = document.querySelectorAll(selector);
|
|
205
|
+
elements.forEach(el => {
|
|
206
|
+
if (el && el.offsetParent !== null) { // Check if visible
|
|
207
|
+
const text = el.textContent || el.innerText || '';
|
|
208
|
+
if (text.toLowerCase().includes('continue') ||
|
|
209
|
+
text.toLowerCase().includes('proceed') ||
|
|
210
|
+
text.toLowerCase().includes('keep going')) {
|
|
211
|
+
foundTexts.push({
|
|
212
|
+
selector,
|
|
213
|
+
text: text.trim()
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
} catch (e) {
|
|
219
|
+
// Some selectors may not be supported, ignore
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
continuationDetected: foundButtons.length > 0 || foundTexts.length > 0,
|
|
225
|
+
buttons: foundButtons,
|
|
226
|
+
texts: foundTexts,
|
|
227
|
+
totalFound: foundButtons.length + foundTexts.length
|
|
228
|
+
};
|
|
229
|
+
} catch (error) {
|
|
230
|
+
return {
|
|
231
|
+
continuationDetected: false,
|
|
232
|
+
error: error.message,
|
|
233
|
+
buttons: [],
|
|
234
|
+
texts: []
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
})()`;
|
|
238
|
+
|
|
239
|
+
const { result } = await Runtime.evaluate({ expression, returnByValue: true });
|
|
240
|
+
return result.value || { continuationDetected: false, buttons: [], texts: [] };
|
|
241
|
+
} catch (error) {
|
|
242
|
+
console.error(`Error checking for continuation in ${ide}:`, error);
|
|
243
|
+
return { continuationDetected: false, error: error.message, buttons: [], texts: [] };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Click a continuation button if found
|
|
249
|
+
* @param {string} ide - The IDE name
|
|
250
|
+
* @returns {Promise<Object>} Result of the operation
|
|
251
|
+
*/
|
|
252
|
+
async clickContinuationButton(ide) {
|
|
253
|
+
try {
|
|
254
|
+
const { Runtime } = await this.connectionHandler.connectToIDE(ide);
|
|
255
|
+
|
|
256
|
+
const expression = `(() => {
|
|
257
|
+
try {
|
|
258
|
+
// Look for continuation buttons
|
|
259
|
+
const continuationSelectors = [
|
|
260
|
+
'button[title*="Continue"]',
|
|
261
|
+
'button[title*="Proceed"]',
|
|
262
|
+
'button:contains("Continue")',
|
|
263
|
+
'button:contains("Proceed")',
|
|
264
|
+
'button:contains("Next")',
|
|
265
|
+
'button:contains("Continue Generation")',
|
|
266
|
+
'button:contains("Keep Going")',
|
|
267
|
+
'[class*="continue"] button',
|
|
268
|
+
'[class*="proceed"] button',
|
|
269
|
+
'[class*="next"] button',
|
|
270
|
+
'button[aria-label*="Continue"]',
|
|
271
|
+
'button[aria-label*="Proceed"]'
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
for (const selector of continuationSelectors) {
|
|
275
|
+
try {
|
|
276
|
+
const elements = document.querySelectorAll(selector);
|
|
277
|
+
for (const el of elements) {
|
|
278
|
+
if (el && el.offsetParent !== null) { // Check if visible
|
|
279
|
+
el.click();
|
|
280
|
+
return {
|
|
281
|
+
success: true,
|
|
282
|
+
clicked: true,
|
|
283
|
+
selector: selector,
|
|
284
|
+
text: el.textContent || el.innerText || ''
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
} catch (e) {
|
|
289
|
+
// Some selectors may not be supported, continue
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return {
|
|
294
|
+
success: false,
|
|
295
|
+
clicked: false,
|
|
296
|
+
message: 'No continuation button found'
|
|
297
|
+
};
|
|
298
|
+
} catch (error) {
|
|
299
|
+
return {
|
|
300
|
+
success: false,
|
|
301
|
+
clicked: false,
|
|
302
|
+
error: error.message
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
})()`;
|
|
306
|
+
|
|
307
|
+
const { result } = await Runtime.evaluate({ expression, returnByValue: true });
|
|
308
|
+
return result.value || { success: false, clicked: false, message: 'No result' };
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.error(`Error clicking continuation button in ${ide}:`, error);
|
|
311
|
+
return { success: false, clicked: false, error: error.message };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles message submission in IDEs
|
|
3
|
+
*/
|
|
4
|
+
export class MessageSubmitter {
|
|
5
|
+
/**
|
|
6
|
+
* Submit a message using multiple methods
|
|
7
|
+
* @param {Object} Input - CDP Input domain
|
|
8
|
+
* @param {Object} Runtime - CDP Runtime domain
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
async submitMessage(Input, Runtime) {
|
|
12
|
+
// Wait a moment then try multiple ways to submit the message
|
|
13
|
+
setTimeout(async () => {
|
|
14
|
+
try {
|
|
15
|
+
console.log('Attempting to submit message...');
|
|
16
|
+
|
|
17
|
+
// Method 1: Press Enter
|
|
18
|
+
console.log('Method 1: Pressing Enter...');
|
|
19
|
+
await Input.dispatchKeyEvent({ type: 'keyDown', key: 'Enter' });
|
|
20
|
+
await Input.dispatchKeyEvent({ type: 'keyUp', key: 'Enter' });
|
|
21
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
22
|
+
|
|
23
|
+
// Method 2: Try clicking the send button
|
|
24
|
+
console.log('Method 2: Looking for send button...');
|
|
25
|
+
const clickSendButton = `(() => {
|
|
26
|
+
const sendButton = document.querySelector('[aria-label*="Send"]') ||
|
|
27
|
+
document.querySelector('[title*="Send"]') ||
|
|
28
|
+
document.querySelector('button[aria-label*="submit"]') ||
|
|
29
|
+
document.querySelector('button[title*="submit"]') ||
|
|
30
|
+
document.querySelector('[aria-label*="Send message"]') ||
|
|
31
|
+
document.querySelector('[title*="Send message"]') ||
|
|
32
|
+
document.querySelector('button[aria-label*="Send message"]') ||
|
|
33
|
+
document.querySelector('button[title*="Send message"]') ||
|
|
34
|
+
document.querySelector('button[aria-label*="Submit"]') ||
|
|
35
|
+
document.querySelector('button[title*="Submit"]') ||
|
|
36
|
+
document.querySelector('button[aria-label*="Send request"]') ||
|
|
37
|
+
document.querySelector('button[title*="Send request"]') ||
|
|
38
|
+
document.querySelector('button svg[data-icon*="send"]')?.closest('button') ||
|
|
39
|
+
document.querySelector('button svg[data-icon*="play"]')?.closest('button') ||
|
|
40
|
+
document.querySelector('button svg[data-icon*="arrow"]')?.closest('button') ||
|
|
41
|
+
document.querySelector('button.send-button') ||
|
|
42
|
+
document.querySelector('button.submit-button') ||
|
|
43
|
+
document.querySelector('button[class*="send"]') ||
|
|
44
|
+
document.querySelector('button[class*="submit"]');
|
|
45
|
+
|
|
46
|
+
if (sendButton) {
|
|
47
|
+
console.log('Found send button:', sendButton.getAttribute('aria-label') || sendButton.getAttribute('title') || sendButton.className);
|
|
48
|
+
sendButton.click();
|
|
49
|
+
return true;
|
|
50
|
+
} else {
|
|
51
|
+
console.log('No send button found');
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
})()`;
|
|
55
|
+
|
|
56
|
+
const { result: clickRes } = await Runtime.evaluate({ expression: clickSendButton, returnByValue: true });
|
|
57
|
+
const clickResult = clickRes && (clickRes.value ?? clickRes.unserializableValue) ? (clickRes.value ?? clickRes.unserializableValue) : false;
|
|
58
|
+
console.log('Send button click result:', clickResult);
|
|
59
|
+
|
|
60
|
+
// Method 3: Try Cmd+Enter as alternative
|
|
61
|
+
if (!clickResult) {
|
|
62
|
+
console.log('Method 3: Trying Cmd+Enter...');
|
|
63
|
+
const isDarwin = process.platform === 'darwin';
|
|
64
|
+
const enterMods = isDarwin ? 4 /* Meta */ : 2 /* Ctrl */;
|
|
65
|
+
await Input.dispatchKeyEvent({ type: 'keyDown', key: 'Enter', text: 'Enter', modifiers: enterMods });
|
|
66
|
+
await Input.dispatchKeyEvent({ type: 'keyUp', key: 'Enter', text: 'Enter', modifiers: enterMods });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log('All submission methods attempted');
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.log('Submission failed:', error.message);
|
|
72
|
+
}
|
|
73
|
+
}, 300);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles sending text to IDEs via CDP
|
|
3
|
+
*/
|
|
4
|
+
export class TextSender {
|
|
5
|
+
constructor(connectionHandler, messageSubmitter) {
|
|
6
|
+
this.connectionHandler = connectionHandler;
|
|
7
|
+
this.messageSubmitter = messageSubmitter;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Send text to an IDE via CDP
|
|
12
|
+
* @param {string} text - The text to send
|
|
13
|
+
* @param {string} ide - The IDE name
|
|
14
|
+
* @returns {Promise<Object>} Result of the operation
|
|
15
|
+
*/
|
|
16
|
+
async sendText(text, ide) {
|
|
17
|
+
if (typeof text !== 'string') {
|
|
18
|
+
return {
|
|
19
|
+
success: false,
|
|
20
|
+
error: `Invalid text type: ${typeof text}. Expected string.`
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ideName = ide === 'windsurf' ? 'Windsurf' : ide === 'cursor' ? 'Cursor' : 'VS Code';
|
|
25
|
+
|
|
26
|
+
console.log(`🔍 sendText: Starting debug session`);
|
|
27
|
+
console.log(`📋 IDE: ${ideName} (${ide})`);
|
|
28
|
+
console.log(`💬 Text: "${text.substring(0, 100)}${text.length > 100 ? '...' : ''}"`);
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const { client, Runtime, Input } = await this.connectionHandler.connectToIDE(ide);
|
|
32
|
+
|
|
33
|
+
// VS Code specific handling
|
|
34
|
+
if (ide === 'vscode') {
|
|
35
|
+
return await this.sendTextToVSCode(text, Runtime, Input);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// For other IDEs, use basic CDP approach
|
|
39
|
+
return await this.sendTextBasic(text, Runtime, Input);
|
|
40
|
+
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error(`${ideName} CDP error:`, error);
|
|
43
|
+
return {
|
|
44
|
+
success: false,
|
|
45
|
+
error: `${ideName} CDP error: ${error.message}`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Send text to VS Code using the working approach
|
|
52
|
+
* @param {string} text - The text to send
|
|
53
|
+
* @param {Object} Runtime - CDP Runtime domain
|
|
54
|
+
* @param {Object} Input - CDP Input domain
|
|
55
|
+
* @returns {Promise<Object>} Result of the operation
|
|
56
|
+
*/
|
|
57
|
+
async sendTextToVSCode(text, Runtime, Input) {
|
|
58
|
+
try {
|
|
59
|
+
try {
|
|
60
|
+
const isDarwin = process.platform === 'darwin';
|
|
61
|
+
const modifiers = (isDarwin ? 4 /* Meta */ | 2 /* Ctrl */ : 2 /* Ctrl */);
|
|
62
|
+
await Input.dispatchKeyEvent({ type: 'keyDown', key: 'I', text: 'I', modifiers });
|
|
63
|
+
await Input.dispatchKeyEvent({ type: 'keyUp', key: 'I', text: 'I', modifiers });
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.log('Could not activate chat view:', error.message);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const textToSend = String(text).slice(0, 4000);
|
|
69
|
+
|
|
70
|
+
// Use clipboard approach to avoid focus issues
|
|
71
|
+
console.log('Copying text to clipboard:', textToSend);
|
|
72
|
+
|
|
73
|
+
// Note: In VSCode extension context, we'll need to handle clipboard differently
|
|
74
|
+
// For now, we'll use character-by-character typing
|
|
75
|
+
|
|
76
|
+
// Type the text character by character
|
|
77
|
+
console.log('Starting character-by-character typing...');
|
|
78
|
+
for (let i = 0; i < textToSend.length; i++) {
|
|
79
|
+
const char = textToSend[i];
|
|
80
|
+
await Input.dispatchKeyEvent({ type: 'keyDown', key: char, text: char });
|
|
81
|
+
await Input.dispatchKeyEvent({ type: 'keyUp', key: char, text: char });
|
|
82
|
+
await new Promise(resolve => setTimeout(resolve, 20)); // Small delay between characters
|
|
83
|
+
}
|
|
84
|
+
console.log('Finished character-by-character typing');
|
|
85
|
+
|
|
86
|
+
// Submit the message
|
|
87
|
+
await this.messageSubmitter.submitMessage(Input, Runtime);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
method: 'cdp-character-typing',
|
|
92
|
+
message: `Message sent to VS Code: ${text}`,
|
|
93
|
+
note: 'Message sent via CDP with character-by-character typing'
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('VS Code CDP error:', error);
|
|
98
|
+
return { success: false, error: `VS Code CDP error: ${error.message}` };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Send text using basic CDP approach
|
|
104
|
+
* @param {string} text - The text to send
|
|
105
|
+
* @param {Object} Runtime - CDP Runtime domain
|
|
106
|
+
* @param {Object} Input - CDP Input domain
|
|
107
|
+
* @returns {Promise<Object>} Result of the operation
|
|
108
|
+
*/
|
|
109
|
+
async sendTextBasic(text, Runtime, Input) {
|
|
110
|
+
try {
|
|
111
|
+
const textToSend = String(text).slice(0, 4000);
|
|
112
|
+
|
|
113
|
+
// Type the text character by character
|
|
114
|
+
console.log('Starting character-by-character typing...');
|
|
115
|
+
for (let i = 0; i < textToSend.length; i++) {
|
|
116
|
+
const char = textToSend[i];
|
|
117
|
+
await Input.dispatchKeyEvent({ type: 'keyDown', key: char, text: char });
|
|
118
|
+
await Input.dispatchKeyEvent({ type: 'keyUp', key: char, text: char });
|
|
119
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
120
|
+
}
|
|
121
|
+
console.log('Finished character-by-character typing');
|
|
122
|
+
|
|
123
|
+
// Submit the message
|
|
124
|
+
await this.messageSubmitter.submitMessage(Input, Runtime);
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
method: 'cdp-basic',
|
|
129
|
+
message: `Message sent: ${text}`,
|
|
130
|
+
note: 'Message sent via basic CDP approach'
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error('Basic CDP error:', error);
|
|
135
|
+
return { success: false, error: `Basic CDP error: ${error.message}` };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|