diff --git a/.vscodeignore b/.vscodeignore index bdbd356..90b8ee2 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -19,8 +19,17 @@ spec/ .vscode-test.mjs wdio.conf.js -# Build tools -node_modules/ +# Build tools - keep node_modules (has runtime deps like ws) +# Only exclude devDependencies +node_modules/@types/ +node_modules/@vscode/ +node_modules/@wdio/ +node_modules/@playwright/ +node_modules/mocha/ +node_modules/glob/ +node_modules/vscode-extension-tester/ +node_modules/wdio-vscode-service/ +node_modules/@mshanemc/ *.vsix # Documentation (internal) diff --git a/extension.js b/extension.js index f3a8e90..0bc06d6 100644 --- a/extension.js +++ b/extension.js @@ -1228,44 +1228,40 @@ function activate(context) { log: (msg) => outputChannel.appendLine(msg) }); - // Check if CDP is enabled and prompt user if not - if (relauncher.isCDPEnabled()) { - outputChannel.appendLine('[Init] CDP flag detected in process args'); - - // Try to connect to CDP on startup (non-blocking) - cdpManager.tryConnect().then(connected => { - if (connected) { - outputChannel.appendLine('[CDP] ✅ Connected to Antigravity webview'); - } else { - outputChannel.appendLine('[CDP] ⚠️ Could not connect - will retry on injection'); - } - }).catch(() => {}); - } else { - outputChannel.appendLine('[Init] ⚠️ CDP not enabled - auto-injection will require manual setup'); - - // Show a notification with action button - vscode.window.showWarningMessage( - 'Antigravity For Loop: CDP not enabled. Auto-Accept and prompt injection require CDP.', - 'Enable CDP', - 'Learn More', - 'Dismiss' - ).then(choice => { - if (choice === 'Enable CDP') { - enableCDP(); - } else if (choice === 'Learn More') { - outputChannel.show(); - outputChannel.appendLine('\n=== CDP Setup Instructions ==='); - outputChannel.appendLine('CDP (Chrome DevTools Protocol) allows the extension to:'); - outputChannel.appendLine(' - Automatically click Accept buttons'); - outputChannel.appendLine(' - Inject prompts directly into chat'); - outputChannel.appendLine(' - Submit messages programmatically'); - outputChannel.appendLine('\nTo enable CDP, Antigravity needs to restart with:'); - outputChannel.appendLine(' --remote-debugging-port=9000'); - outputChannel.appendLine('\nClick "Enable CDP" in the For Loop menu to set this up.'); - outputChannel.appendLine('================================\n'); - } - }); - } + // Check CDP by actually trying to connect (more reliable than checking args) + outputChannel.appendLine('[Init] Checking CDP connection...'); + + // Try to connect to CDP first + cdpManager.tryConnect().then(async connected => { + if (connected) { + outputChannel.appendLine('[CDP] ✅ Connected to Antigravity webview'); + relauncher._cdpVerified = true; + } else { + outputChannel.appendLine('[CDP] ⚠️ Could not connect to CDP port'); + + // Only show warning if CDP is really not available + vscode.window.showWarningMessage( + 'Antigravity For Loop: CDP not enabled. Auto-Accept and prompt injection require CDP.', + 'Enable CDP', + 'Learn More', + 'Dismiss' + ).then(choice => { + if (choice === 'Enable CDP') { + enableCDP(); + } else if (choice === 'Learn More') { + outputChannel.show(); + outputChannel.appendLine('\n=== CDP Setup Instructions ==='); + outputChannel.appendLine('CDP (Chrome DevTools Protocol) allows the extension to:'); + outputChannel.appendLine(' - Automatically click Accept buttons'); + outputChannel.appendLine(' - Inject prompts directly into chat'); + outputChannel.appendLine(' - Submit messages programmatically'); + outputChannel.appendLine('\nTo enable CDP, start Antigravity with:'); + outputChannel.appendLine(' /Applications/Antigravity.app/Contents/MacOS/Electron --remote-debugging-port=9000'); + outputChannel.appendLine('================================\n'); + } + }); + } + }).catch(() => { }); // Create status bar item (high priority to be visible) statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 10000); diff --git a/lib/relauncher.js b/lib/relauncher.js index 75f4fa8..32209ff 100644 --- a/lib/relauncher.js +++ b/lib/relauncher.js @@ -36,11 +36,40 @@ class Relauncher { } /** - * Check if the current process was launched with CDP flag + * Check if CDP is enabled by trying to connect to the port + * Returns cached result for performance (checked once on startup) */ isCDPEnabled() { + // First check process args (may work in some cases) const args = process.argv.join(' '); - return args.includes('--remote-debugging-port='); + if (args.includes('--remote-debugging-port=')) { + return true; + } + // Return true optimistically - actual connection will be verified by CDPManager + // This prevents the annoying prompt when CDP is actually working + return this._cdpVerified || false; + } + + /** + * Verify CDP by actually trying to connect (async) + */ + async verifyCDPConnection() { + const http = require('http'); + return new Promise((resolve) => { + const req = http.get('http://127.0.0.1:9000/json/version', (res) => { + this._cdpVerified = res.statusCode === 200; + resolve(this._cdpVerified); + }); + req.on('error', () => { + this._cdpVerified = false; + resolve(false); + }); + req.setTimeout(1000, () => { + req.destroy(); + this._cdpVerified = false; + resolve(false); + }); + }); } /** diff --git a/package.json b/package.json index 59e57a0..9016100 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/iml1s/antigravity_for_loop" }, "engines": { - "vscode": "^1.107.0" + "vscode": "^1.100.0" }, "categories": [ "Other", @@ -123,7 +123,7 @@ "@mshanemc/vscode-test-playwright": "^0.0.1-beta14", "@playwright/test": "^1.57.0", "@types/mocha": "^10.0.10", - "@types/vscode": "^1.107.0", + "@types/vscode": "^1.100.0", "@vscode/test-cli": "^0.0.12", "@vscode/test-electron": "^2.5.2", "@wdio/cli": "^8.46.0", @@ -134,4 +134,4 @@ "vscode-extension-tester": "^8.19.0", "wdio-vscode-service": "^6.1.4" } -} +} \ No newline at end of file