File size: 12,874 Bytes
9c80792
 
bf1ce45
 
9c80792
 
 
 
 
 
2af0649
9c80792
bf1ce45
9c80792
 
 
 
 
 
 
 
2af0649
9c80792
 
2af0649
9c80792
 
2af0649
9c80792
 
2af0649
 
 
 
 
9c80792
 
 
 
 
2af0649
9c80792
2af0649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf1ce45
2af0649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c80792
 
 
 
2af0649
 
 
 
9c80792
 
2af0649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf1ce45
2af0649
bf1ce45
 
2af0649
bf1ce45
 
2af0649
bf1ce45
2af0649
 
 
 
 
bf1ce45
 
 
 
 
 
 
 
 
2af0649
 
 
 
 
 
 
 
 
9c80792
 
2af0649
 
 
 
 
 
 
bf1ce45
 
2af0649
 
 
9c80792
2af0649
 
bf1ce45
 
2af0649
 
9c80792
 
 
 
 
 
 
 
 
 
 
 
2af0649
9c80792
 
2af0649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c80792
 
 
 
 
 
 
2af0649
9c80792
 
 
bf1ce45
2af0649
 
 
9c80792
 
 
2af0649
9c80792
 
 
 
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
#!/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()