#!/usr/bin/env python3
"""
Antigravity VS Code IDE Launcher - Dark Theme
Launches the actual Antigravity VS Code IDE with agents support
"""
from http.server import HTTPServer, BaseHTTPRequestHandler
import subprocess
import sys
import os
import json
from urllib.parse import parse_qs
import threading
import time
vscode_process = None
class AntigravityHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
# Check Antigravity installation
try:
result = subprocess.run(['antigravity', '--version'],
capture_output=True, text=True, timeout=5)
antigravity_status = "✅ Installed" if result.returncode == 0 else "❌ Not Available"
antigravity_version = result.stdout.strip() if result.returncode == 0 else "Error"
except Exception as e:
antigravity_status = "❌ Error"
antigravity_version = str(e)
# System info
try:
system_info = subprocess.run(['uname', '-a'], capture_output=True, text=True)
system_details = system_info.stdout
except:
system_details = "System info unavailable"
html = f"""
Antigravity VS Code IDE
📊 System Status
Antigravity: {antigravity_status}
Version: {antigravity_version}
Python: {sys.version.split()[0]}
Platform: {sys.platform}
Working Dir: {os.getcwd()}
🚀 Launch IDE
Start Antigravity VS Code:
📝 Available Commands
antigravity --serve-web
antigravity chat
antigravity agents
antigravity --list-extensions
antigravity --help
🖥️ System Details
{system_details}
⚡ Antigravity Agents
Use AI-powered agents to code, debug, and create:
$ antigravity agents
Agents enable autonomous code generation, testing, and debugging with natural language commands.
📚 Quick Start
- Click "Launch Antigravity IDE" to open VS Code
- Use "Launch Agents" to enable AI-powered coding
- Type your requirements in natural language
- Agents will generate and execute code automatically
- Use AI Chat for questions and assistance
"""
self.wfile.write(html.encode())
elif self.path == '/api/status':
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
status_data = {
'service': 'Antigravity VS Code Sandbox',
'status': 'running',
'antigravity_available': antigravity_status == 'Available',
'features': [
'VS Code CLI',
'File Management',
'Extensions',
'Web Interface',
'AI Assistant',
'Development Tools'
],
'quick_commands': [
'antigravity --serve-web',
'antigravity chat',
'antigravity --version',
'antigravity --diff',
'antigravity --list-extensions'
]
}
self.wfile.write(json.dumps(status_data).encode())
else:
self.send_response(404)
self.end_headers()
def log_message(self, format, *args):
print(f"[Antigravity VS Code] {format % args}")
def do_POST(self):
global vscode_process
if self.path == '/launch-ide':
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
try:
# Launch Antigravity VS Code web interface
if vscode_process is None or vscode_process.poll() is not None:
vscode_process = subprocess.Popen(
['antigravity', '--serve-web'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
time.sleep(2)
response = {
'success': True,
'message': 'Antigravity VS Code IDE launched on http://localhost:8000'
}
except Exception as e:
response = {
'success': False,
'error': str(e)
}
self.wfile.write(json.dumps(response).encode())
elif self.path == '/launch-agents':
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
try:
result = subprocess.run(['antigravity', 'agents'],
capture_output=True, text=True, timeout=3)
response = {
'success': True,
'message': 'Antigravity Agents activated!\n' + result.stdout
}
except Exception as e:
response = {
'success': False,
'error': str(e)
}
self.wfile.write(json.dumps(response).encode())
elif self.path == '/launch-chat':
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
try:
result = subprocess.run(['antigravity', 'chat'],
capture_output=True, text=True, timeout=3)
response = {
'success': True,
'message': 'AI Chat opened!\n' + result.stdout
}
except Exception as e:
response = {
'success': False,
'error': str(e)
}
self.wfile.write(json.dumps(response).encode())
else:
self.send_response(404)
self.end_headers()
def main():
port = int(os.environ.get('PORT', 7860))
server = HTTPServer(('0.0.0.0', port), AntigravityHandler)
print(f"🚀 Antigravity VS Code Sandbox running on port {port}")
print(f"🌐 Access at: http://localhost:{port}")
print(f"📝 VS Code features available via antigravity commands")
try:
server.serve_forever()
except KeyboardInterrupt:
print("\nShutting down Antigravity VS Code Sandbox...")
server.shutdown()
if __name__ == '__main__':
main()