Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
72 changes: 34 additions & 38 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 31 additions & 2 deletions lib/relauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}

/**
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/iml1s/antigravity_for_loop"
},
"engines": {
"vscode": "^1.107.0"
"vscode": "^1.100.0"
},
"categories": [
"Other",
Expand Down Expand Up @@ -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",
Expand All @@ -134,4 +134,4 @@
"vscode-extension-tester": "^8.19.0",
"wdio-vscode-service": "^6.1.4"
}
}
}