File size: 18,108 Bytes
9c80792
 
9dd1c50
 
9c80792
 
 
 
 
 
2af0649
7da8fbd
9dd1c50
 
 
 
9c80792
bf1ce45
9c80792
 
 
 
 
 
9dd1c50
9c80792
2af0649
9c80792
9dd1c50
 
9c80792
9dd1c50
2af0649
9c80792
 
2af0649
 
 
 
 
9c80792
 
 
 
 
9dd1c50
9c80792
2af0649
 
 
 
c5b52ae
 
2af0649
 
 
c5b52ae
 
2af0649
 
c5b52ae
2af0649
 
c5b52ae
2af0649
 
 
 
 
c5b52ae
2af0649
 
c5b52ae
2af0649
 
c5b52ae
2af0649
 
c5b52ae
 
2af0649
 
 
 
 
 
 
 
 
 
 
 
 
 
c5b52ae
2af0649
 
c5b52ae
 
 
2af0649
 
c5b52ae
2af0649
 
 
 
c5b52ae
 
2af0649
 
 
 
 
 
 
 
c5b52ae
 
2af0649
 
c5b52ae
 
2af0649
 
c5b52ae
2af0649
 
c5b52ae
 
2af0649
 
c5b52ae
2af0649
 
c5b52ae
 
2af0649
9dd1c50
 
 
 
 
 
 
 
 
 
 
2af0649
 
 
 
 
 
 
c5b52ae
 
 
2af0649
 
c5b52ae
 
 
2af0649
9dd1c50
 
 
 
 
2af0649
c5b52ae
 
2af0649
 
 
 
 
c5b52ae
2af0649
 
c5b52ae
 
2af0649
 
 
 
c5b52ae
2af0649
9dd1c50
7da8fbd
 
 
 
 
9dd1c50
7da8fbd
 
9c80792
 
 
 
2af0649
9dd1c50
 
 
9c80792
 
2af0649
 
9dd1c50
 
 
2af0649
 
 
9dd1c50
 
2af0649
 
 
9dd1c50
 
 
 
bf1ce45
9dd1c50
 
bf1ce45
9dd1c50
 
bf1ce45
2af0649
 
 
9dd1c50
 
 
 
 
 
2af0649
 
 
9dd1c50
 
2af0649
9c80792
 
2af0649
9dd1c50
 
 
 
2af0649
7da8fbd
 
9dd1c50
 
 
 
 
 
 
 
7da8fbd
9c80792
2af0649
 
9dd1c50
 
 
 
 
 
 
 
 
 
 
2af0649
7da8fbd
9dd1c50
 
 
 
 
 
 
 
7da8fbd
9dd1c50
 
 
 
 
 
 
 
 
 
 
 
7da8fbd
9dd1c50
 
 
2af0649
9c80792
 
 
 
 
 
 
 
 
 
 
 
2af0649
9c80792
 
2af0649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c80792
 
 
 
 
 
 
2af0649
9c80792
7da8fbd
9dd1c50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7da8fbd
9dd1c50
 
 
 
 
 
7da8fbd
 
9dd1c50
 
 
 
 
 
7da8fbd
9dd1c50
 
 
 
7da8fbd
9dd1c50
 
 
7da8fbd
 
 
 
9dd1c50
 
 
 
 
 
 
 
 
 
 
 
 
7da8fbd
9dd1c50
7da8fbd
 
 
 
9c80792
 
bf1ce45
2af0649
 
 
9c80792
 
 
2af0649
9c80792
 
 
c5b52ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#!/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"""
            <!DOCTYPE html>
            <html>
            <head>
                <title>Antigravity VS Code IDE</title>
                <style>
                    body {{ 
                        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
                        margin: 0; 
                        padding: 20px; 
                        background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
                        color: #e6edf3;
                        min-height: 100vh;
                    }}
                    .container {{ 
                        background: #0d1117; 
                        color: #e6edf3;
                        padding: 30px; 
                        border-radius: 15px; 
                        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
                        max-width: 1200px;
                        margin: 0 auto;
                        border: 1px solid #30363d;
                    }}
                    .header {{
                        text-align: center;
                        margin-bottom: 30px;
                        padding-bottom: 20px;
                        border-bottom: 2px solid #1f6feb;
                    }}
                    .header h1 {{
                        color: #1f6feb;
                        margin: 0;
                        font-size: 2.5em;
                        text-shadow: 0 0 10px rgba(31, 111, 235, 0.3);
                    }}
                    .vscode-badge {{
                        background: #1f6feb;
                        color: #0d1117;
                        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: #161b22;
                        padding: 25px;
                        border-radius: 12px;
                        border-left: 5px solid #1f6feb;
                        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
                        border: 1px solid #30363d;
                    }}
                    .card h3 {{
                        color: #58a6ff;
                        margin-top: 0;
                        font-size: 1.3em;
                    }}
                    .button {{
                        background: #1f6feb;
                        color: #0d1117;
                        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: all 0.3s;
                        font-weight: bold;
                    }}
                    .button:hover {{
                        background: #388bfd;
                        transform: translateY(-2px);
                    }}
                    .button.green {{
                        background: #3fb950;
                    }}
                    .button.green:hover {{
                        background: #56d364;
                        transform: translateY(-2px);
                    }}
                    .button.orange {{
                        background: #fb8500;
                    }}
                    .button.orange:hover {{
                        background: #ffa947;
                        transform: translateY(-2px);
                    }}
                    .button.red {{
                        background: #f85149;
                    }}
                    .button.red:hover {{
                        background: #ff7b72;
                        transform: translateY(-2px);
                    }}
                    .button:disabled {{
                        opacity: 0.5;
                        cursor: not-allowed;
                    }}
                    .status {{
                        padding: 15px;
                        border-radius: 8px;
                        margin: 15px 0;
                        font-weight: bold;
                    }}
                    .success {{
                        background: rgba(63, 185, 80, 0.15);
                        color: #3fb950;
                        border: 1px solid #3fb950;
                    }}
                    .warning {{
                        background: rgba(251, 133, 0, 0.15);
                        color: #fb8500;
                        border: 1px solid #fb8500;
                    }}
                    .error {{
                        background: rgba(248, 81, 73, 0.15);
                        color: #f85149;
                        border: 1px solid #f85149;
                    }}
                    .pre {{
                        background: #0d1117;
                        color: #79c0ff;
                        padding: 15px;
                        border-radius: 8px;
                        overflow-x: auto;
                        font-family: 'Courier New', monospace;
                        margin: 10px 0;
                        border: 1px solid #30363d;
                    }}
                    .terminal {{
                        background: #0d1117;
                        color: #39ff14;
                        padding: 15px;
                        border-radius: 8px;
                        font-family: 'Courier New', monospace;
                        margin: 10px 0;
                        border: 2px solid #1f6feb;
                    }}
                    .command-box {{
                        background: #0d1117;
                        color: #79c0ff;
                        border: 1px solid #30363d;
                        padding: 12px;
                        border-radius: 8px;
                        margin: 10px 0;
                        font-family: 'Courier New', monospace;
                    }}
                </style>
            </head>
            <body>
                <div class="container">
                    <div class="header">
                        <h1>⚑ Antigravity VS Code IDE</h1>
                        <div class="vscode-badge">Agents + Code Editor</div>
                        <p>Professional development environment with Antigravity agents</p>
                    </div>
                    
                    <div class="grid">
                        <div class="card">
                            <h3>πŸ“Š System Status</h3>
                            <div class="status {'success' if antigravity_status == 'βœ… Installed' else 'warning'}">
                                Antigravity: {antigravity_status}
                            </div>
                            <div><strong>Version:</strong> {antigravity_version}</div>
                            <div><strong>Python:</strong> {sys.version.split()[0]}</div>
                            <div><strong>Platform:</strong> {sys.platform}</div>
                            <div><strong>Working Dir:</strong> {os.getcwd()}</div>
                        </div>
                        
                        <div class="card">
                            <h3>πŸš€ Launch IDE</h3>
                            <p>Start Antigravity VS Code:</p>
                            <button onclick="launchIDE()" class="button green" style="width: 100%; margin-top: 10px;">
                                ▢️ Launch Antigravity IDE
                            </button>
                            <button onclick="launchAgents()" class="button orange" style="width: 100%; margin-top: 10px;">
                                πŸ€– Launch Agents
                            </button>
                            <button onclick="launchChat()" class="button" style="width: 100%; margin-top: 10px;">
                                πŸ’¬ AI Chat
                            </button>
                        </div>
                        
                        <div class="card">
                            <h3>πŸ“ Available Commands</h3>
                            <div class="pre" style="font-size: 12px;">antigravity --serve-web
antigravity chat
antigravity agents
antigravity --list-extensions
antigravity --help</div>
                        </div>
                        
                        <div class="card">
                            <h3>πŸ–₯️ System Details</h3>
                            <div class="terminal" style="font-size: 12px;">{system_details}</div>
                        </div>
                    </div>
                    
                    <div class="card" style="margin-top: 20px;">
                        <h3>⚑ Antigravity Agents</h3>
                        <p>Use AI-powered agents to code, debug, and create:</p>
                        <div class="command-box">$ antigravity agents</div>
                        <p style="color: #8b949e; font-size: 14px;">Agents enable autonomous code generation, testing, and debugging with natural language commands.</p>
                    </div>
                    
                    <div class="card" style="margin-top: 20px;">
                        <h3>πŸ“š Quick Start</h3>
                        <ol style="color: #e6edf3;">
                            <li>Click <strong>"Launch Antigravity IDE"</strong> to open VS Code</li>
                            <li>Use <strong>"Launch Agents"</strong> to enable AI-powered coding</li>
                            <li>Type your requirements in natural language</li>
                            <li>Agents will generate and execute code automatically</li>
                            <li>Use AI Chat for questions and assistance</li>
                        </ol>
                    </div>
                </div>
                
                <script>
                    function launchIDE() {{
                        fetch('/launch-ide', {{ method: 'POST' }})
                            .then(r => r.json())
                            .then(d => {{
                                if (d.success) {{
                                    alert('βœ… Antigravity VS Code IDE launched!\\n\\nCheck the terminal or open http://localhost:8000');
                                }} else {{
                                    alert('❌ Error: ' + d.error);
                                }}
                            }})
                            .catch(e => alert('Error: ' + e));
                    }}
                    
                    function launchAgents() {{
                        fetch('/launch-agents', {{ method: 'POST' }})
                            .then(r => r.json())
                            .then(d => {{
                                if (d.success) {{
                                    alert('βœ… Antigravity Agents launched!\\n\\n' + d.message);
                                }} else {{
                                    alert('❌ Error: ' + d.error);
                                }}
                            }})
                            .catch(e => alert('Error: ' + e));
                    }}
                    
                    function launchChat() {{
                        fetch('/launch-chat', {{ method: 'POST' }})
                            .then(r => r.json())
                            .then(d => {{
                                if (d.success) {{
                                    alert('βœ… AI Chat launched!\\n\\n' + d.message);
                                }} else {{
                                    alert('❌ Error: ' + d.error);
                                }}
                            }})
                            .catch(e => alert('Error: ' + e));
                    }}
                </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 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()