antigravity / app.py
OsamaBinLikhon's picture
Enhanced VS Code interface with status dashboard
bf1ce45 verified
#!/usr/bin/env python3
"""
Enhanced Antigravity VS Code Interface
Provides status dashboard and easy access to VS Code features
"""
from http.server import HTTPServer, BaseHTTPRequestHandler
import subprocess
import sys
import os
import json
class AntigravityHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
# Test antigravity package
try:
result = subprocess.run(['antigravity', '--version'],
capture_output=True, text=True, timeout=5)
antigravity_status = "Available" if result.returncode == 0 else "Error"
antigravity_version = result.stdout.strip() if result.returncode == 0 else "Unable to determine"
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"""
<!DOCTYPE html>
<html>
<head>
<title>Antigravity VS Code Sandbox</title>
<style>
body {{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 20px;
background: linear-gradient(135deg, #007acc 0%, #1a1a1a 100%);
color: white;
min-height: 100vh;
}}
.container {{
background: rgba(255, 255, 255, 0.95);
color: #333;
padding: 30px;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
max-width: 1200px;
margin: 0 auto;
}}
.header {{
text-align: center;
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 2px solid #007acc;
}}
.header h1 {{
color: #007acc;
margin: 0;
font-size: 2.5em;
}}
.vscode-badge {{
background: #007acc;
color: white;
padding: 8px 20px;
border-radius: 25px;
font-size: 0.9em;
display: inline-block;
margin: 10px 0;
font-weight: bold;
}}
.grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 20px;
margin: 30px 0;
}}
.card {{
background: #f8f9fa;
padding: 25px;
border-radius: 12px;
border-left: 5px solid #007acc;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}}
.card h3 {{
color: #007acc;
margin-top: 0;
font-size: 1.3em;
}}
.button {{
background: #007acc;
color: white;
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 1em;
cursor: pointer;
text-decoration: none;
display: inline-block;
margin: 8px 8px 8px 0;
transition: background 0.3s;
border: none;
}}
.button:hover {{
background: #005999;
}}
.button.green {{
background: #28a745;
}}
.button.green:hover {{
background: #1e7e34;
}}
.button.orange {{
background: #fd7e14;
}}
.button.orange:hover {{
background: #e55a00;
}}
.status {{
padding: 15px;
border-radius: 8px;
margin: 15px 0;
font-weight: bold;
}}
.success {{
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}}
.warning {{
background: #fff3cd;
color: #856404;
border: 1px solid #ffeaa7;
}}
.pre {{
background: #2d3748;
color: #e2e8f0;
padding: 15px;
border-radius: 8px;
overflow-x: auto;
font-family: 'Courier New', monospace;
margin: 10px 0;
}}
.terminal {{
background: #1a1a1a;
color: #00ff00;
padding: 15px;
border-radius: 8px;
font-family: 'Courier New', monospace;
margin: 10px 0;
border: 2px solid #007acc;
}}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>๐Ÿš€ Antigravity VS Code Sandbox</h1>
<div class="vscode-badge">Full VS Code Environment</div>
<p>Docker-based development environment with complete VS Code functionality</p>
</div>
<div class="grid">
<div class="card">
<h3>โœ… System Status</h3>
<div class="status {'success' if antigravity_status == 'Available' else 'warning'}">
Antigravity Package: {antigravity_status}
</div>
<div><strong>Version:</strong> {antigravity_version}</div>
<div><strong>Platform:</strong> Ubuntu Docker Container</div>
<div><strong>Python:</strong> {sys.version.split()[0]}</div>
<div><strong>Working Directory:</strong> {os.getcwd()}</div>
</div>
<div class="card">
<h3>๐ŸŽฏ Quick Actions</h3>
<p>Launch VS Code features instantly:</p>
<button onclick="alert('To start VS Code web server:\\n\\n1. Use terminal tab in your space\\n2. Run: antigravity --serve-web\\n\\nThis will launch VS Code in your browser!')" class="button green">
๐ŸŒ Start VS Code Web
</button>
<button onclick="alert('To start AI chat assistant:\\n\\n1. Use terminal tab in your space\\n2. Run: antigravity chat\\n\\nThis opens the coding AI assistant!')" class="button orange">
๐Ÿค– AI Chat Assistant
</button>
<button onclick="showVersion()" class="button">
โ„น๏ธ Version Info
</button>
</div>
<div class="card">
<h3>๐Ÿ› ๏ธ VS Code Features</h3>
<p>Available Antigravity commands:</p>
<div class="pre">antigravity --serve-web # Start VS Code web
antigravity chat # AI coding assistant
antigravity --version # Check version
antigravity --diff file1 file2 # Compare files
antigravity --merge base left right output # Merge
antigravity --new-window # New editor window
antigravity --extensions-dir # Extension folder
antigravity --list-extensions # List extensions
antigravity --install-extension ext-id # Install extension</div>
</div>
<div class="card">
<h3>๐Ÿ“Š System Details</h3>
<div class="terminal">{system_details}</div>
<div style="margin-top: 15px; font-size: 0.9em; color: #666;">
<em>Container running on Hugging Face Spaces</em>
</div>
</div>
</div>
<div class="card" style="margin-top: 20px;">
<h3>๐Ÿš€ Development Environment Ready</h3>
<p>Your Antigravity Docker Space is fully configured with:</p>
<ul>
<li><strong>VS Code CLI:</strong> Full command-line interface</li>
<li><strong>File Management:</strong> Open, edit, compare, and merge files</li>
<li><strong>Extensions:</strong> Install and manage VS Code extensions</li>
<li><strong>Web Interface:</strong> Run VS Code in your browser</li>
<li><strong>AI Assistant:</strong> Built-in chat and coding help</li>
<li><strong>Development Tools:</strong> Complete development environment</li>
</ul>
</div>
</div>
<script>
function showVersion() {{
alert('Antigravity Version: {antigravity_version}\\n\\nThis is your VS Code command-line interface.\\nUse the terminal tab to run commands like:\\nโ€ข antigravity --serve-web\\nโ€ข antigravity chat\\nโ€ข antigravity --help');
}}
</script>
</body>
</html>
"""
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 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()