vibecodingmachine-cli 2026.3.14-1537 → 2026.6.17-1956
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/bin/auth/auth-compliance.js +7 -7
- package/bin/commands/agent-commands.js +15 -15
- package/bin/commands/auto-commands.js +3 -3
- package/bin/commands/command-aliases.js +13 -4
- package/bin/config/cli-config.js +15 -5
- package/bin/update/update-checker.js +5 -5
- package/bin/vibecodingmachine.js +2 -2
- package/package.json +2 -2
- package/src/commands/agents/add.js +5 -5
- package/src/commands/agents/check.js +19 -19
- package/src/commands/agents/list.js +24 -24
- package/src/commands/agents/remove.js +4 -4
- package/src/commands/agents-check.js +1 -1
- package/src/commands/analyze-file-sizes.js +43 -43
- package/src/commands/auto-direct/auto-provider-manager.js +19 -19
- package/src/commands/auto-direct/auto-start-phases.js +493 -0
- package/src/commands/auto-direct/auto-status-display.js +35 -35
- package/src/commands/auto-direct/auto-utils.js +50 -50
- package/src/commands/auto-direct/cline-installer.js +56 -0
- package/src/commands/auto-direct/code-processor.js +27 -27
- package/src/commands/auto-direct/file-scanner.js +19 -19
- package/src/commands/auto-direct/ide-completion-waiter.js +485 -0
- package/src/commands/auto-direct/ide-fallback-runner.js +226 -0
- package/src/commands/auto-direct/ide-provider-runner.js +103 -0
- package/src/commands/auto-direct/iteration-handlers.js +189 -0
- package/src/commands/auto-direct/iteration-runner.js +485 -0
- package/src/commands/auto-direct/provider-config.js +38 -7
- package/src/commands/auto-direct/provider-manager.js +132 -6
- package/src/commands/auto-direct/requirement-manager.js +169 -104
- package/src/commands/auto-direct/requirement-mover.js +350 -0
- package/src/commands/auto-direct/spec-handlers.js +155 -0
- package/src/commands/auto-direct/spec-ide-runner.js +318 -0
- package/src/commands/auto-direct/spec-processing.js +203 -0
- package/src/commands/auto-direct/status-display.js +9 -9
- package/src/commands/auto-direct/utils.js +83 -1
- package/src/commands/auto-direct-refactored.js +1 -413
- package/src/commands/auto-direct.js +127 -4119
- package/src/commands/auto-execution.js +21 -21
- package/src/commands/auto-status-helpers.js +0 -2
- package/src/commands/auto.js +22 -22
- package/src/commands/check-compliance.js +65 -65
- package/src/commands/computers.js +39 -39
- package/src/commands/continuous-scan.js +19 -19
- package/src/commands/ide.js +4 -4
- package/src/commands/locale.js +7 -7
- package/src/commands/refactor-file.js +59 -59
- package/src/commands/requirements/commands.js +17 -17
- package/src/commands/requirements/default-handlers.js +30 -30
- package/src/commands/requirements/disable.js +3 -3
- package/src/commands/requirements/enable.js +3 -3
- package/src/commands/requirements/utils.js +6 -6
- package/src/commands/requirements-refactored.js +3 -3
- package/src/commands/requirements-remote.js +38 -38
- package/src/commands/requirements.js +3 -3
- package/src/commands/settings.js +111 -0
- package/src/commands/specs/count.js +60 -0
- package/src/commands/specs/disable.js +3 -3
- package/src/commands/specs/enable.js +3 -3
- package/src/commands/status.js +10 -10
- package/src/commands/sync.js +25 -25
- package/src/commands/timeout.js +35 -35
- package/src/trui/TruiInterface.js +2 -2
- package/src/trui/agents/AgentInterface.js +4 -4
- package/src/trui/agents/handlers/CommandHandler.js +4 -4
- package/src/trui/agents/handlers/ContextManager.js +1 -1
- package/src/trui/agents/handlers/DisplayHandler.js +11 -11
- package/src/trui/agents/handlers/HelpHandler.js +1 -1
- package/src/utils/agent-selector.js +6 -6
- package/src/utils/antigravity-installer.js +4 -4
- package/src/utils/asset-cleanup.js +1 -1
- package/src/utils/auth.js +9 -12
- package/src/utils/clarification-actions.js +4 -4
- package/src/utils/cline-js-handler.js +5 -5
- package/src/utils/compliance-check.js +6 -6
- package/src/utils/config.js +12 -12
- package/src/utils/display-formatters-complete.js +2 -2
- package/src/utils/display-formatters-extracted.js +2 -2
- package/src/utils/display-formatters.js +2 -2
- package/src/utils/feedback-handler.js +2 -2
- package/src/utils/first-run.js +7 -7
- package/src/utils/ide-detection.js +1 -1
- package/src/utils/ide-handlers.js +6 -6
- package/src/utils/interactive/clarification-actions.js +3 -3
- package/src/utils/interactive/core-ui.js +7 -7
- package/src/utils/interactive/file-backup.js +6 -6
- package/src/utils/interactive/file-import-export.js +49 -49
- package/src/utils/interactive/file-operations.js +3 -3
- package/src/utils/interactive/file-validation.js +41 -41
- package/src/utils/interactive/interactive-prompts.js +41 -41
- package/src/utils/interactive/requirement-actions.js +5 -5
- package/src/utils/interactive/requirement-crud.js +4 -4
- package/src/utils/interactive/requirements-navigation.js +10 -10
- package/src/utils/interactive-broken.js +6 -6
- package/src/utils/interactive.js +37 -37
- package/src/utils/keyboard-handler.js +4 -4
- package/src/utils/prompt-helper.js +6 -6
- package/src/utils/provider-checker/agent-checker.js +1 -1
- package/src/utils/provider-checker/agent-runner.js +203 -314
- package/src/utils/provider-checker/agents-file-lock.js +134 -0
- package/src/utils/provider-checker/agents-manager.js +224 -36
- package/src/utils/provider-checker/cli-installer.js +28 -28
- package/src/utils/provider-checker/cli-utils.js +2 -2
- package/src/utils/provider-checker/cursor-approval-clicker.js +108 -0
- package/src/utils/provider-checker/format-utils.js +4 -4
- package/src/utils/provider-checker/ide-installer-helper.js +96 -0
- package/src/utils/provider-checker/ide-manager.js +19 -8
- package/src/utils/provider-checker/ide-quota-checker.js +120 -0
- package/src/utils/provider-checker/ide-utils.js +2 -2
- package/src/utils/provider-checker/node-detector.js +4 -4
- package/src/utils/provider-checker/node-utils.js +5 -5
- package/src/utils/provider-checker/opencode-checker.js +107 -73
- package/src/utils/provider-checker/process-utils.js +1 -1
- package/src/utils/provider-checker/provider-validator.js +11 -11
- package/src/utils/provider-checker/quota-checker.js +5 -5
- package/src/utils/provider-checker/quota-detector.js +5 -5
- package/src/utils/provider-checker/requirements-manager.js +6 -6
- package/src/utils/provider-checker/test-requirements.js +1 -1
- package/src/utils/provider-checker/vscode-approval-clicker.js +328 -0
- package/src/utils/provider-checker-new.js +6 -6
- package/src/utils/provider-checker.js +6 -6
- package/src/utils/provider-checkers/ide-manager.js +13 -13
- package/src/utils/provider-checkers/node-executable-finder.js +4 -4
- package/src/utils/provider-checkers/provider-checker-core.js +5 -5
- package/src/utils/provider-checkers/provider-checker-main.js +17 -17
- package/src/utils/provider-registry.js +5 -6
- package/src/utils/provider-utils.js +12 -12
- package/src/utils/quota-detectors.js +32 -32
- package/src/utils/requirement-action-handlers.js +12 -12
- package/src/utils/requirement-actions/requirement-operations.js +3 -3
- package/src/utils/requirement-actions.js +1 -1
- package/src/utils/requirement-file-operations.js +5 -5
- package/src/utils/requirement-helpers.js +1 -1
- package/src/utils/requirement-management.js +5 -5
- package/src/utils/requirement-navigation.js +2 -2
- package/src/utils/requirement-organization.js +3 -3
- package/src/utils/rui-trui-adapter.js +14 -14
- package/src/utils/simple-trui.js +3 -3
- package/src/utils/status-helpers-extracted.js +3 -3
- package/src/utils/trui-clarifications.js +11 -11
- package/src/utils/trui-debug.js +3 -2
- package/src/utils/trui-devin.js +217 -0
- package/src/utils/trui-feedback.js +7 -7
- package/src/utils/trui-kiro-integration.js +34 -34
- package/src/utils/trui-main-handlers.js +20 -21
- package/src/utils/trui-main-menu.js +19 -19
- package/src/utils/trui-nav-agents.js +59 -8
- package/src/utils/trui-nav-requirements.js +3 -3
- package/src/utils/trui-nav-settings.js +10 -10
- package/src/utils/trui-nav-specifications.js +1 -1
- package/src/utils/trui-navigation-backup.js +11 -11
- package/src/utils/trui-navigation.js +9 -9
- package/src/utils/trui-provider-health.js +25 -25
- package/src/utils/trui-provider-manager.js +28 -28
- package/src/utils/trui-quick-menu.js +2 -2
- package/src/utils/trui-req-actions-backup.js +21 -21
- package/src/utils/trui-req-actions.js +20 -20
- package/src/utils/trui-req-editor.js +10 -10
- package/src/utils/trui-req-file-ops.js +3 -3
- package/src/utils/trui-req-tree.js +7 -7
- package/src/utils/trui-windsurf.js +103 -103
- package/src/utils/user-tracking.js +15 -15
- package/src/utils/trui-req-tree-old.js +0 -719
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IDE Completion Waiter - Monitor IDE Agent Work Completion
|
|
3
|
+
*
|
|
4
|
+
* This module contains the waitForIdeCompletion function that monitors
|
|
5
|
+
* the requirements file for completion signals from IDE agents.
|
|
6
|
+
*
|
|
7
|
+
* @module ide-completion-waiter
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
const fs = require('fs-extra');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const chokidar = require('chokidar');
|
|
14
|
+
const vibecodingmachineCore = require('vibecodingmachine-core');
|
|
15
|
+
const {
|
|
16
|
+
QuotaDetector,
|
|
17
|
+
AppleScriptManager,
|
|
18
|
+
getRequirementsPath,
|
|
19
|
+
t
|
|
20
|
+
} = vibecodingmachineCore;
|
|
21
|
+
|
|
22
|
+
// These will be set by the parent module (iteration-handlers.js)
|
|
23
|
+
let sharedProviderManager = null;
|
|
24
|
+
let sharedHealthTracker = null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Initialize module with shared instances from parent
|
|
28
|
+
* @param {Object} deps - Dependencies object
|
|
29
|
+
* @param {Object} deps.providerManager - Shared ProviderManager instance
|
|
30
|
+
* @param {Object} deps.healthTracker - Shared IDEHealthTracker instance
|
|
31
|
+
*/
|
|
32
|
+
function initialize(deps) {
|
|
33
|
+
sharedProviderManager = deps.providerManager;
|
|
34
|
+
sharedHealthTracker = deps.healthTracker;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Wait for IDE agent to complete work by monitoring requirements file
|
|
39
|
+
* @param {string} repoPath - Repository path
|
|
40
|
+
* @param {string} requirementText - Requirement text to watch for
|
|
41
|
+
* @param {string} ideType - IDE type (e.g., 'antigravity') for quota limit handling
|
|
42
|
+
* @param {number} timeoutMs - Timeout in milliseconds (default: 30 minutes)
|
|
43
|
+
* @returns {Promise<{success: boolean, reason?: string}>}
|
|
44
|
+
*/
|
|
45
|
+
async function waitForIdeCompletion(repoPath, requirementText, ideType = '', timeoutMs = 30 * 60 * 1000) {
|
|
46
|
+
const reqPath = await getRequirementsPath(repoPath);
|
|
47
|
+
|
|
48
|
+
return new Promise(async (resolve) => {
|
|
49
|
+
let startTime = Date.now();
|
|
50
|
+
let lastCheckTime = Date.now();
|
|
51
|
+
let quotaHandled = false;
|
|
52
|
+
let lastQuotaCheckTime = 0; // Throttle quota checks to every 30 seconds
|
|
53
|
+
const checkIntervalMs = 2000; // Check every 2 seconds
|
|
54
|
+
const quotaCheckIntervalMs = 30000; // Check quota every 30 seconds
|
|
55
|
+
|
|
56
|
+
console.log(chalk.gray(`\n� ${t('auto.direct.ide.waiting')}`));
|
|
57
|
+
console.log(chalk.gray(` ${t('auto.direct.ide.monitoring', { filename: path.basename(reqPath) })}`));
|
|
58
|
+
console.log(chalk.gray(` ${t('auto.direct.ide.timeout', { minutes: Math.floor(timeoutMs / 60000) })}\n`));
|
|
59
|
+
|
|
60
|
+
const watcher = chokidar.watch(reqPath, {
|
|
61
|
+
persistent: true,
|
|
62
|
+
ignoreInitial: false
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const checkCompletion = async () => {
|
|
66
|
+
try {
|
|
67
|
+
const content = await fs.readFile(reqPath, 'utf-8');
|
|
68
|
+
const lines = content.split('\n');
|
|
69
|
+
|
|
70
|
+
// Check 1: Is requirement in "Verified by AI" section?
|
|
71
|
+
let inVerifiedSection = false;
|
|
72
|
+
let foundInVerified = false;
|
|
73
|
+
|
|
74
|
+
for (const line of lines) {
|
|
75
|
+
if (line.includes('## Verified by AI')) {
|
|
76
|
+
inVerifiedSection = true;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (inVerifiedSection && line.startsWith('##') && !line.startsWith('###')) {
|
|
81
|
+
inVerifiedSection = false;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (inVerifiedSection && line.includes(requirementText)) {
|
|
86
|
+
foundInVerified = true;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (foundInVerified) {
|
|
92
|
+
watcher.close();
|
|
93
|
+
console.log(chalk.green(' IDE agent completed - requirement moved to Verified section\n'));
|
|
94
|
+
resolve({ success: true });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Check 2: Does status section contain "DONE"?
|
|
99
|
+
let inStatusSection = false;
|
|
100
|
+
let statusContainsDone = false;
|
|
101
|
+
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
if (line.includes('=� Current Status')) {
|
|
104
|
+
inStatusSection = true;
|
|
105
|
+
if (line.includes('DONE')) {
|
|
106
|
+
statusContainsDone = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (inStatusSection && line.startsWith('##') && !line.startsWith('###')) {
|
|
113
|
+
inStatusSection = false;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (inStatusSection && line.trim() === 'DONE') {
|
|
118
|
+
statusContainsDone = true;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (statusContainsDone) {
|
|
124
|
+
watcher.close();
|
|
125
|
+
console.log(chalk.green(' IDE agent completed - status marked as DONE\n'));
|
|
126
|
+
resolve({ success: true });
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Check 3: Detect rate-limit messages written into the REQUIREMENTS file
|
|
131
|
+
// Examples:
|
|
132
|
+
// - "You have reached the quota limit for this model. You can resume using this model at 1/19/2026, 4:07:27 PM."
|
|
133
|
+
// - "Please try again in 15m5.472s"
|
|
134
|
+
// - "Spending cap reached resets Jan 17 at 12pm"
|
|
135
|
+
// - "Usage cap reached. Try again in 15 minutes."
|
|
136
|
+
// - "You've reached your monthly chat messages quota" (GitHub Copilot)
|
|
137
|
+
// - "Upgrade to Copilot Pro" (GitHub Copilot)
|
|
138
|
+
// - "wait for your allowance to renew" (GitHub Copilot)
|
|
139
|
+
const rateLimitPattern = /(quota limit|you have reached( the)? quota|you can resume using this model at|please try again in|try again in|spending cap reached|usage cap( reached)?|you\'ve hit( the)? usage limit|you\u2019ve hit( the)? usage limit|cap reached|limit exceeded|exceeded (quota|limit)|monthly.*quota|upgrade to.*pro|allowance to renew|chat messages quota)/i;
|
|
140
|
+
// Avoid matching requirement headings or bullets (these may mention "rate limit" as part of the requirement text)
|
|
141
|
+
const matchedLine = lines.find(l => rateLimitPattern.test(l) && !l.trim().startsWith('###') && !l.trim().startsWith('-'));
|
|
142
|
+
if (matchedLine) {
|
|
143
|
+
// Mark the provider as rate limited (if we can) and signal a rate-limited completion
|
|
144
|
+
try {
|
|
145
|
+
if (ideType && sharedProviderManager && typeof sharedProviderManager.markRateLimited === 'function') {
|
|
146
|
+
sharedProviderManager.markRateLimited(ideType, undefined, matchedLine);
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {
|
|
149
|
+
// Ignore errors from marking rate-limited
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
watcher.close();
|
|
153
|
+
console.log(chalk.yellow(`\n� Rate limit message detected from IDE: ${matchedLine}\n`));
|
|
154
|
+
// Return a generic rateLimited flag and include the matched line for diagnostics
|
|
155
|
+
resolve({ success: false, rateLimited: true, providerRateLimited: ideType || undefined, matchedLine });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Check 4: Active quota detection (throttled to every 30 seconds)
|
|
160
|
+
// For Kiro: ONLY AppleScript (CDP doesn't work with webviews)
|
|
161
|
+
// For others: CDP only
|
|
162
|
+
const now = Date.now();
|
|
163
|
+
if (!quotaHandled && ideType && (now - lastQuotaCheckTime >= quotaCheckIntervalMs)) {
|
|
164
|
+
lastQuotaCheckTime = now;
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
// For Kiro: ONLY AppleScript detection (CDP doesn't work)
|
|
168
|
+
if (ideType === 'kiro' || ideType === 'amazon-q') {
|
|
169
|
+
try {
|
|
170
|
+
const appleScriptManager = new AppleScriptManager();
|
|
171
|
+
const screenshotResult = await appleScriptManager.detectQuotaWarning('kiro');
|
|
172
|
+
|
|
173
|
+
if (screenshotResult && screenshotResult.hasQuotaWarning) {
|
|
174
|
+
quotaHandled = true;
|
|
175
|
+
const quotaMessage = screenshotResult.matchedText || screenshotResult.note || 'Kiro quota limit detected via AppleScript';
|
|
176
|
+
|
|
177
|
+
// Mark the provider as rate limited
|
|
178
|
+
try {
|
|
179
|
+
if (sharedProviderManager && typeof sharedProviderManager.markRateLimited === 'function') {
|
|
180
|
+
sharedProviderManager.markRateLimited(ideType, undefined, quotaMessage);
|
|
181
|
+
}
|
|
182
|
+
} catch (e) {
|
|
183
|
+
// Ignore errors from marking rate-limited
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
watcher.close();
|
|
187
|
+
console.log(chalk.yellow(`\n� Quota warning detected via AppleScript for Kiro: ${quotaMessage.substring(0, 100)}...\n`));
|
|
188
|
+
resolve({ success: false, rateLimited: true, kiroRateLimited: true, providerRateLimited: ideType, matchedLine: quotaMessage });
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
} catch (screenshotError) {
|
|
192
|
+
console.log(chalk.red(`L AppleScript quota detection failed for Kiro: ${screenshotError.message}`));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// For Antigravity: AppleScript quota detection
|
|
196
|
+
else if (ideType === 'antigravity') {
|
|
197
|
+
try {
|
|
198
|
+
const appleScriptManager = new AppleScriptManager();
|
|
199
|
+
const antigravityQuotaResult = await appleScriptManager.checkAntigravityQuotaLimit();
|
|
200
|
+
|
|
201
|
+
if (antigravityQuotaResult && antigravityQuotaResult.isRateLimited) {
|
|
202
|
+
quotaHandled = true;
|
|
203
|
+
const quotaMessage = antigravityQuotaResult.message || 'Antigravity quota limit detected via AppleScript';
|
|
204
|
+
|
|
205
|
+
// Mark the provider as rate limited
|
|
206
|
+
try {
|
|
207
|
+
if (sharedProviderManager && typeof sharedProviderManager.markRateLimited === 'function') {
|
|
208
|
+
sharedProviderManager.markRateLimited(ideType, undefined, quotaMessage);
|
|
209
|
+
}
|
|
210
|
+
} catch (e) {
|
|
211
|
+
// Ignore errors from marking rate-limited
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
watcher.close();
|
|
215
|
+
console.log(chalk.yellow(`\n� Quota warning detected via AppleScript for Antigravity: ${quotaMessage.substring(0, 100)}...\n`));
|
|
216
|
+
resolve({ success: false, rateLimited: true, antigravityRateLimited: true, providerRateLimited: ideType, matchedLine: quotaMessage });
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
} catch (appleScriptError) {
|
|
220
|
+
console.log(chalk.red(`L AppleScript quota detection failed for Antigravity: ${appleScriptError.message}`));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// For Devin: quota detection
|
|
224
|
+
else if (ideType === 'devin') {
|
|
225
|
+
try {
|
|
226
|
+
const appleScriptManager = new AppleScriptManager();
|
|
227
|
+
const devinQuotaResult = await appleScriptManager.checkDevinRateLimit?.();
|
|
228
|
+
|
|
229
|
+
if (devinQuotaResult && devinQuotaResult.hasQuotaWarning) {
|
|
230
|
+
quotaHandled = true;
|
|
231
|
+
const quotaMessage = devinQuotaResult.matchedText || 'Devin quota limit detected';
|
|
232
|
+
|
|
233
|
+
// Mark the provider as rate limited
|
|
234
|
+
try {
|
|
235
|
+
if (sharedProviderManager && typeof sharedProviderManager.markRateLimited === 'function') {
|
|
236
|
+
sharedProviderManager.markRateLimited(ideType, undefined, quotaMessage);
|
|
237
|
+
}
|
|
238
|
+
} catch (e) {
|
|
239
|
+
// Ignore errors from marking rate-limited
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
watcher.close();
|
|
243
|
+
console.log(chalk.yellow(`\n⚠️ Devin quota warning detected: ${quotaMessage.substring(0, 100)}...\n`));
|
|
244
|
+
resolve({ success: false, rateLimited: true, devinRateLimited: true, providerRateLimited: ideType, matchedLine: quotaMessage });
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
} catch (devinQuotaError) {
|
|
248
|
+
console.log(chalk.red(`L Quota detection failed for Devin: ${devinQuotaError.message}`));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// For Cursor: Skip CDP and go directly to AppleScript
|
|
252
|
+
else if (ideType === 'cursor') {
|
|
253
|
+
try {
|
|
254
|
+
const appleScriptManager = new AppleScriptManager();
|
|
255
|
+
const cursorQuotaResult = await appleScriptManager.checkCursorQuotaLimit();
|
|
256
|
+
|
|
257
|
+
if (cursorQuotaResult && cursorQuotaResult.isRateLimited) {
|
|
258
|
+
quotaHandled = true;
|
|
259
|
+
const quotaMessage = cursorQuotaResult.message || 'Cursor quota limit detected via AppleScript';
|
|
260
|
+
|
|
261
|
+
// Mark the provider as rate limited
|
|
262
|
+
try {
|
|
263
|
+
if (sharedProviderManager && typeof sharedProviderManager.markRateLimited === 'function') {
|
|
264
|
+
sharedProviderManager.markRateLimited(ideType, undefined, quotaMessage);
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
// Ignore errors from marking rate-limited
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
watcher.close();
|
|
271
|
+
console.log(chalk.yellow(`\n� Quota warning detected via AppleScript for Cursor: ${quotaMessage.substring(0, 100)}...\n`));
|
|
272
|
+
resolve({ success: false, rateLimited: true, providerRateLimited: ideType, matchedLine: quotaMessage });
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
} catch (appleScriptError) {
|
|
276
|
+
console.log(chalk.red(`L AppleScript quota detection failed for Cursor: ${appleScriptError.message}`));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// For other IDEs: use CDP
|
|
280
|
+
else if (ideType === 'vscode' || ideType === 'github-copilot' || ideType === 'amazon-q') {
|
|
281
|
+
const quotaDetector = new QuotaDetector();
|
|
282
|
+
const ideToCheck = ideType === 'github-copilot' || ideType === 'amazon-q' ? 'vscode' : ideType;
|
|
283
|
+
|
|
284
|
+
try {
|
|
285
|
+
const quotaResult = await quotaDetector.detectQuotaWarning(ideToCheck);
|
|
286
|
+
|
|
287
|
+
if (quotaResult && quotaResult.hasQuotaWarning) {
|
|
288
|
+
quotaHandled = true;
|
|
289
|
+
const quotaMessage = quotaResult.matchedText || 'Quota limit detected in IDE UI';
|
|
290
|
+
|
|
291
|
+
// Check if this might be Kiro quota warning even when ideType is amazon-q
|
|
292
|
+
const isKiroPattern = quotaMessage.toLowerCase().includes('out of credits') ||
|
|
293
|
+
quotaMessage.toLowerCase().includes('upgrade plan') ||
|
|
294
|
+
quotaMessage.toLowerCase().includes('monthly usage limit');
|
|
295
|
+
|
|
296
|
+
// Mark the provider as rate limited
|
|
297
|
+
try {
|
|
298
|
+
if (sharedProviderManager && typeof sharedProviderManager.markRateLimited === 'function') {
|
|
299
|
+
sharedProviderManager.markRateLimited(ideType, undefined, quotaMessage);
|
|
300
|
+
}
|
|
301
|
+
} catch (e) {
|
|
302
|
+
// Ignore errors from marking rate-limited
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
watcher.close();
|
|
306
|
+
console.log(chalk.yellow(`\n� Quota warning detected via CDP in ${ideToCheck} UI: ${quotaMessage.substring(0, 100)}...\n`));
|
|
307
|
+
|
|
308
|
+
// If this looks like Kiro quota, set kiroRateLimited flag too
|
|
309
|
+
const resolveObj = {
|
|
310
|
+
success: false,
|
|
311
|
+
rateLimited: true,
|
|
312
|
+
providerRateLimited: ideType,
|
|
313
|
+
matchedLine: quotaMessage
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
if (ideType === 'amazon-q' && isKiroPattern) {
|
|
317
|
+
resolveObj.kiroRateLimited = true;
|
|
318
|
+
console.log(chalk.magenta(`=� Detected potential Kiro quota warning despite amazon-q ideType`));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
resolve(resolveObj);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
} catch (cdpError) {
|
|
325
|
+
console.log(chalk.yellow(`� CDP quota detection failed for ${ideToCheck}: ${cdpError.message}`));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} catch (quotaError) {
|
|
329
|
+
console.log(chalk.red(`L [DEBUG] Quota detection check failed: ${quotaError.message}`));
|
|
330
|
+
console.log(chalk.gray(` Stack: ${quotaError.stack}`));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Check 5: Continuation detection (check every 2 seconds)
|
|
335
|
+
const elapsed = Date.now() - startTime;
|
|
336
|
+
if (elapsed > 30000 && elapsed % 2000 < 2000) { // Start checking after 30 seconds, every 2 seconds
|
|
337
|
+
try {
|
|
338
|
+
let continuationDetected = false;
|
|
339
|
+
let continuationClicked = false;
|
|
340
|
+
|
|
341
|
+
// Use CDP for web-based IDEs
|
|
342
|
+
if (ideType === 'vscode' || ideType === 'cursor' || ideType === 'devin') {
|
|
343
|
+
const { CDPManager } = require('vibecodingmachine-core');
|
|
344
|
+
const cdpManager = new CDPManager();
|
|
345
|
+
|
|
346
|
+
try {
|
|
347
|
+
const continuationResult = await cdpManager.checkForContinuation(ideType);
|
|
348
|
+
if (continuationResult.continuationDetected) {
|
|
349
|
+
console.log(chalk.yellow(`= Continuation prompt detected in ${ideType}, clicking button...`));
|
|
350
|
+
const clickResult = await cdpManager.clickContinuationButton(ideType);
|
|
351
|
+
if (clickResult.success && clickResult.clicked) {
|
|
352
|
+
continuationDetected = true;
|
|
353
|
+
continuationClicked = true;
|
|
354
|
+
console.log(chalk.green(` Continuation button clicked successfully`));
|
|
355
|
+
} else {
|
|
356
|
+
console.log(chalk.yellow(`� Failed to click continuation button: ${clickResult.message || 'Unknown error'}`));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
} catch (cdpError) {
|
|
360
|
+
console.log(chalk.gray(` Continuation detection via CDP failed: ${cdpError.message}`));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// Use AppleScript for desktop IDEs
|
|
364
|
+
else if (ideType === 'cline' || ideType === 'claude-code') {
|
|
365
|
+
const { AppleScriptManager } = require('vibecodingmachine-core');
|
|
366
|
+
const appleScriptManager = new AppleScriptManager();
|
|
367
|
+
|
|
368
|
+
try {
|
|
369
|
+
const continuationResult = await appleScriptManager.checkForContinuation(ideType);
|
|
370
|
+
if (continuationResult.continuationDetected) {
|
|
371
|
+
console.log(chalk.yellow(`= Continuation prompt detected in ${ideType}, clicking button...`));
|
|
372
|
+
const clickResult = await appleScriptManager.clickContinuationButton(ideType);
|
|
373
|
+
if (clickResult.success && clickResult.clicked) {
|
|
374
|
+
continuationDetected = true;
|
|
375
|
+
continuationClicked = true;
|
|
376
|
+
console.log(chalk.green(` Continuation button clicked successfully`));
|
|
377
|
+
} else {
|
|
378
|
+
console.log(chalk.yellow(`� Failed to click continuation button: ${clickResult.error || 'Unknown error'}`));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
} catch (appleScriptError) {
|
|
382
|
+
console.log(chalk.gray(` Continuation detection via AppleScript failed: ${appleScriptError.message}`));
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Record continuation detection in health tracker
|
|
387
|
+
if (continuationDetected) {
|
|
388
|
+
try {
|
|
389
|
+
// Update the interaction record to include continuation detection
|
|
390
|
+
const currentMetrics = sharedHealthTracker.getHealthMetrics(ideType);
|
|
391
|
+
if (currentMetrics && currentMetrics.interactions && currentMetrics.interactions.length > 0) {
|
|
392
|
+
const lastInteraction = currentMetrics.interactions[currentMetrics.interactions.length - 1];
|
|
393
|
+
lastInteraction.continuationPromptsDetected = (lastInteraction.continuationPromptsDetected || 0) + 1;
|
|
394
|
+
}
|
|
395
|
+
} catch (trackerError) {
|
|
396
|
+
console.log(chalk.gray(` Failed to record continuation detection: ${trackerError.message}`));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
} catch (error) {
|
|
400
|
+
console.log(chalk.gray(` Continuation detection error: ${error.message}`));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// Check 6: Timeout
|
|
405
|
+
if (elapsed >= timeoutMs) {
|
|
406
|
+
watcher.close();
|
|
407
|
+
console.log(chalk.yellow(`\n� Timeout after ${Math.floor(elapsed / 60000)} minutes\n`));
|
|
408
|
+
resolve({ success: false, reason: 'timeout' });
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Check 7: Text pattern matching fallback for continuation prompts
|
|
413
|
+
const fileContent = await fs.readFile(reqPath, 'utf-8');
|
|
414
|
+
const continuationPatterns = [
|
|
415
|
+
/continue.*generation/i,
|
|
416
|
+
/keep.*going/i,
|
|
417
|
+
/continue.*writing/i,
|
|
418
|
+
/continue.*coding/i,
|
|
419
|
+
/proceed/i,
|
|
420
|
+
/next.*step/i,
|
|
421
|
+
/continue/i
|
|
422
|
+
];
|
|
423
|
+
|
|
424
|
+
const hasContinuationPrompt = continuationPatterns.some(pattern => pattern.test(fileContent));
|
|
425
|
+
if (hasContinuationPrompt && elapsed > 30000) { // Only check for text patterns after 30 seconds
|
|
426
|
+
console.log(chalk.yellow(`= Continuation prompt detected in text, attempting to continue...`));
|
|
427
|
+
// This is a fallback - we can't click buttons via text patterns, but we can log it
|
|
428
|
+
try {
|
|
429
|
+
const currentMetrics = sharedHealthTracker.getHealthMetrics(ideType);
|
|
430
|
+
if (currentMetrics && currentMetrics.interactions && currentMetrics.interactions.length > 0) {
|
|
431
|
+
const lastInteraction = currentMetrics.interactions[currentMetrics.interactions.length - 1];
|
|
432
|
+
lastInteraction.continuationPromptsDetected = (lastInteraction.continuationPromptsDetected || 0) + 1;
|
|
433
|
+
}
|
|
434
|
+
} catch (trackerError) {
|
|
435
|
+
console.log(chalk.gray(` Failed to record text continuation detection: ${trackerError.message}`));
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// Check 8: Memory monitoring
|
|
439
|
+
if (elapsed > 60000 && elapsed % 30000 < 30000) { // Check memory every 30 seconds after 1 minute
|
|
440
|
+
const memoryUsage = process.memoryUsage();
|
|
441
|
+
const heapUsedMB = Math.round(memoryUsage.heapUsed / 1024 / 1024);
|
|
442
|
+
const heapTotalMB = Math.round(memoryUsage.heapTotal / 1024 / 1024);
|
|
443
|
+
const heapUsedPercent = Math.round((memoryUsage.heapUsed / memoryUsage.heapTotal) * 100);
|
|
444
|
+
|
|
445
|
+
if (heapUsedMB > 500) { // Warn at 500MB
|
|
446
|
+
console.log(chalk.yellow(`� High memory usage detected: ${heapUsedMB}MB heap (${heapUsedPercent}% of ${heapTotalMB}MB)`));
|
|
447
|
+
console.log(chalk.gray(` RSS: ${Math.round(memoryUsage.rss / 1024 / 1024)}MB, External: ${Math.round(memoryUsage.external / 1024 / 1024)}MB`));
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Log progress every 30 seconds
|
|
452
|
+
if (Date.now() - lastCheckTime >= 30000) {
|
|
453
|
+
const elapsedMin = Math.floor(elapsed / 60000);
|
|
454
|
+
const remainingMin = Math.floor((timeoutMs - elapsed) / 60000);
|
|
455
|
+
console.log(chalk.gray(` ${t('auto.direct.ide.still.waiting', { elapsed: elapsedMin, remaining: remainingMin })}`));
|
|
456
|
+
lastCheckTime = Date.now();
|
|
457
|
+
}
|
|
458
|
+
} catch (error) {
|
|
459
|
+
console.error(chalk.red(`Error checking completion: ${error.message}`));
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// Check on file changes
|
|
464
|
+
watcher.on('change', () => {
|
|
465
|
+
checkCompletion();
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Also check periodically in case file watcher misses changes
|
|
469
|
+
const interval = setInterval(() => {
|
|
470
|
+
checkCompletion();
|
|
471
|
+
}, checkIntervalMs);
|
|
472
|
+
|
|
473
|
+
// Clean up interval when promise resolves
|
|
474
|
+
const originalResolve = resolve;
|
|
475
|
+
resolve = (result) => {
|
|
476
|
+
clearInterval(interval);
|
|
477
|
+
originalResolve(result);
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
// Initial check
|
|
481
|
+
checkCompletion();
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
module.exports = { waitForIdeCompletion, initialize };
|