Update app.py
Browse files16 unmodified lines17181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262271 unmodified line2292302312322332342351 unmodified line2372382392402412422432442458 unmodified lines2542552562572582592602612622632642652662672682692702712722732742752762772785 unmodified lines2842852862872882892905 unmodified lines29629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735812 unmodified lines3713723733743753763774 unmodified lines38238338438538638738821 unmodified lines41041141241341441541616 unmodified lines<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Twenty IDE | Liquid Antigravity</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><style>/* --- LIQUID GLASS DƏYİŞƏNLƏRİ --- */:root {--bg-base: #020205;--glass-bg: rgba(20, 20, 30, 0.4);--glass-border: rgba(255, 255, 255, 0.08);--glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);--text-main: #f4f4f5;--text-muted: #888899;--accent: #00f2fe;--liquid-1: #00f2fe;--liquid-2: #4facfe;--liquid-3: #7f00ff;--radius: 16px;}* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }body { background-color: var(--bg-base); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }/* --- ARXA PLAN MAYE (LIQUID) ANİMASİYASI --- */.liquid-bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: var(--bg-base); }.blob { position: absolute; filter: blur(90px); opacity: 0.5; animation: blobMove 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1); }.blob-1 { width: 60vw; height: 60vw; background: var(--liquid-1); top: -20%; left: -10%; border-radius: 40% 60% 70% 30%; }.blob-2 { width: 50vw; height: 50vw; background: var(--liquid-3); bottom: -20%; right: -10%; border-radius: 60% 40% 30% 70%; animation-delay: -5s; }@keyframes blobMove {0% { transform: translate(0, 0) scale(1) rotate(0deg); border-radius: 40% 60% 70% 30%; }50% { transform: translate(10vw, 10vh) scale(1.1) rotate(45deg); border-radius: 60% 40% 30% 70%; }100% { transform: translate(-10vw, -10vh) scale(0.9) rotate(90deg); border-radius: 30% 70% 50% 50%; }}/* --- RAKET LIFTOFF (SPLASH) --- */#rocket-splash {position: fixed; inset: 0; background: #020205; z-index: 9999;display: flex; flex-direction: column; justify-content: center; align-items: center;}.rocket-icon { font-size: 100px; animation: liftoff 3.5s cubic-bezier(0.5, 0, 0.2, 1) forwards; }.splash-text { font-size: 40px; font-weight: 300; letter-spacing: 15px; margin-top: 20px; color: transparent; text-shadow: 0 0 20px var(--accent); animation: fadeOutText 3s forwards; }@keyframes liftoff {0% { transform: translateY(200px) scale(1); opacity: 1; filter: drop-shadow(0 20px 20px #ff9800); }40% { transform: translateY(0px) scale(1.1); opacity: 1; filter: drop-shadow(0 50px 30px #ff5722); }100% { transform: translateY(-1000px) scale(0.5); opacity: 0; filter: drop-shadow(0 100px 50px transparent); }}@keyframes fadeOutText { 0%, 50% { opacity: 1; } 100% { opacity: 0; letter-spacing: 30px; } }/* --- LIQUID GLASS PANELLƏR --- */.glass-panel {background: var(--glass-bg);backdrop-filter: blur(16px);-webkit-backdrop-filter: blur(16px);border: 1px solid var(--glass-border);border-radius: var(--radius);box-shadow: var(--glass-shadow);}/* --- SLIDE-IN ANİMASİYALARI --- */.top-bar { height: 65px; margin: 15px; display: flex; justify-content: space-between; align-items: center; padding: 0 25px; z-index: 100; transform: translateY(-100px); opacity: 0; animation: slideDown 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 3s; }.sidebar-left { width: 280px; display: flex; flex-direction: column; transform: translateX(-350px); opacity: 0; animation: slideRight 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 3.2s; transition: width 0.3s; }.sidebar-right { width: 350px; display: flex; flex-direction: column; transform: translateX(400px); opacity: 0; animation: slideLeft 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 3.4s; transition: width 0.3s; }.center-panel { flex: 1; display: flex; flex-direction: column; transform: scale(0.9); opacity: 0; animation: popIn 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 3.6s; }.bottom-panel { height: 300px; display: flex; flex-direction: column; border-radius: 0 0 var(--radius) var(--radius); }@keyframes slideDown { to { transform: translateY(0); opacity: 1; } }@keyframes slideRight { to { transform: translateX(0); opacity: 1; } }@keyframes slideLeft { to { transform: translateX(0); opacity: 1; } }@keyframes popIn { to { transform: scale(1); opacity: 1; } }/* --- UI ELEMENTLƏRİ --- */.brand { font-size: 18px; font-weight: 600; letter-spacing: 2px; display: flex; align-items: center; gap: 15px; }.controls { display: flex; align-items: center; gap: 15px; }.btn { background: rgba(255,255,255,0.05); color: var(--text-main); border: 1px solid var(--glass-border); padding: 10px 18px; border-radius: 8px; cursor: pointer; transition: 0.3s; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; backdrop-filter: blur(5px);}.btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); box-shadow: 0 0 15px rgba(0,242,254,0.3); }.btn-run { background: rgba(0, 242, 254, 0.15); border-color: var(--accent); color: var(--accent); }.btn-run:hover { background: var(--accent); color: #fff; box-shadow: 0 0 20px var(--accent); transform: translateY(-2px); }.main-layout { display: flex; flex: 1; overflow: hidden; padding: 0 15px 15px 15px; gap: 15px; }.panel-header { padding: 18px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; }/* Editor Area */#editor-container { flex: 1; background: transparent; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;}.resizer { height: 8px; cursor: ns-resize; background: transparent; transition: 0.3s; z-index: 50; }.resizer:hover { background: var(--accent); opacity: 0.5; }/* Terminal & Tabs */.bottom-tabs { display: flex; border-bottom: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); }.tab { padding: 12px 25px; font-size: 13px; cursor: pointer; color: var(--text-muted); transition: 0.3s; border-right: 1px solid var(--glass-border); }.tab.active { color: var(--accent); background: rgba(0,242,254,0.05); border-bottom: 2px solid var(--accent); }.tab-content { flex: 1; overflow: hidden; display: none; background: rgba(0,0,0,0.4); }.tab-content.active { display: flex; flex-direction: column; }#terminal-output { flex: 1; padding: 20px; font-family: 'Consolas', monospace; font-size: 14px; color: #e2e8f0; overflow-y: auto; white-space: pre-wrap; line-height: 1.6; }.ps-cmd { color: var(--accent); font-weight: bold; }.ps-err { color: #ff4757; }.ps-ok { color: #2ed573; }/* Exypos AI Chat */#ai-chat { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; font-size: 14px; }.msg { padding: 12px 18px; border-radius: 12px; max-width: 90%; line-height: 1.6; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }.msg.user { background: rgba(0, 242, 254, 0.15); border: 1px solid var(--accent); align-self: flex-end; border-bottom-right-radius: 2px; }.msg.ai { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); align-self: flex-start; border-bottom-left-radius: 2px; }.ai-input-zone { padding: 15px; border-top: 1px solid var(--glass-border); display: flex; gap: 10px; background: rgba(0,0,0,0.2); border-radius: 0 0 var(--radius) var(--radius); }.ai-input-zone input { flex: 1; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); color: var(--text-main); padding: 12px; border-radius: 8px; outline: none; transition: 0.3s; }.ai-input-zone input:focus { border-color: var(--accent); background: rgba(0,0,0,0.5); }/* AI Editor Actions */.ai-action-btn { background: var(--accent); color: #000; border: none; padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: bold; cursor: pointer; margin-top: 8px; transition: 0.2s; }.ai-action-btn:hover { box-shadow: 0 0 10px var(--accent); }.terminal-ai-btn { background: transparent; border: 1px solid #ff4757; color: #ff4757; padding: 4px 10px; border-radius: 4px; cursor: pointer; margin-top: 5px; font-size: 12px; transition: 0.2s; }.terminal-ai-btn:hover { background: #ff4757; color: #fff; }pre { background: #000; padding: 10px; border-radius: 6px; overflow-x: auto; border: 1px solid var(--glass-border); margin-top: 5px; }code { font-family: 'Consolas', monospace; color: #a8b2d1; }</style><script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.36.1/min/vs/loader.min.js"></script></head><body><div class="liquid-bg"><div class="blob blob-1"></div><div class="blob blob-2"></div></div><div id="rocket-splash"><div class="rocket-icon">🚀</div><div class="splash-text">LIFTOFF</div></div><div class="glass-panel top-bar" id="top-bar"><div class="brand"><i class="fa-solid fa-meteor" style="color:var(--accent); font-size:24px;"></i>TWENTY OS <span style="color:var(--text-muted); font-weight:400; font-size:14px;">| Exypos Engine</span></div><div class="controls"><button class="btn btn-run" onclick="runCode()"><i class="fa-solid fa-play"></i> Kodu İcra Et</button></div></div><div class="main-layout"><div class="glass-panel sidebar-left" id="sidebar-left"><div class="panel-header">Fayl Sistemi</div><div id="file-tree" style="padding: 15px; font-size: 14px; color: var(--text-main);"><i class="fa-brands fa-python" style="color:#ffeb3b;"></i> main.py</div></div><div class="center-panel"><div class="glass-panel" id="editor-container" style="flex: 1; border-radius: var(--radius); border-bottom-left-radius: 0; border-bottom-right-radius: 0;"></div><div class="resizer" id="resizer"></div><div class="glass-panel bottom-panel" id="bottom-panel" style="border-top-left-radius: 0; border-top-right-radius: 0; border-top: none;"><div class="bottom-tabs"><div class="tab active" onclick="switchTab('terminal')"><i class="fa-solid fa-terminal"></i> Terminal</div><i class="fa-solid fa-broom" style="margin-left:auto; margin-right:20px; margin-top:12px; cursor:pointer; color:var(--text-muted);" onclick="clearTerminal()"></i></div><div class="tab-content active" id="tab-terminal"><div id="terminal-output"><span style="color:#888;">// Twenty OS Terminalı Hazırdır...</span><br><span style="color:#888;">// 'pip install' üçün komandanın əvvəlinə ! qoyun.</span><br></div></div></div></div><div class="glass-panel sidebar-right" id="sidebar-right"><div class="panel-header"><i class="fa-solid fa-robot"></i> EXYPOS AI</div><div id="ai-chat"><div class="msg ai">Sistemlər aktivdir, komandir. Kodunu oxuyuram. Xəta olarsa, mənə göndər.</div></div><div class="ai-input-zone"><input type="text" id="ai-input" placeholder="Sualını yaz..." onkeypress="if(event.key === 'Enter') askAI()"><button onclick="askAI()" style="background:transparent; border:none; cursor:pointer;"><i class="fa-solid fa-paper-plane" style="color:var(--accent); font-size:20px;"></i></button></div></div></div><script>// Splash Animasiyasıwindow.onload = () => {setTimeout(() => {const splash = document.getElementById('rocket-splash');splash.style.display = 'none';}, 3500);};// Editor & Variableslet editor;let lastAiCode = ""; // AI tərəfindən göndərilən son kodrequire.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.36.1/min/vs' }});require(['vs/editor/editor.main'], function() {editor = monaco.editor.create(document.getElementById('editor-container'), {value: "# Twenty OS: Anti-Gravity Mode Active\\nprint('Hello Universe!')\\n",language: 'python',theme: 'vs-dark',automaticLayout: true,fontSize: 15,minimap: { enabled: false },padding: { top: 20 },scrollBeyondLastLine: false});// Glassmorphism üçün editor arxasını şəffaf etməkdocument.querySelector('.monaco-editor').style.background = 'transparent';document.querySelector('.monaco-editor .margin').style.background = 'transparent';});// Tabsfunction switchTab(tabId) {document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));document.querySelectorAll('.tab-content').forEach(tc => tc.classList.remove('active'));1 unmodified linedocument.getElementById(`tab-${tabId}`).classList.add('active');}// İcra Et & Shell (PIP)async function runCode() {if(!editor) return;const code = editor.getValue();1 unmodified lineconst isShell = code.trim().startsWith('!');if(isShell) {term.innerHTML += `<br><span class="ps-cmd">Twenty></span> ${code.trim()}<br><span style="color:#888">Shell komandası icra olunur...</span>`;} else {term.innerHTML += `<br><span class="ps-cmd">Twenty></span> python main.py<br><span style="color:#888">İcra olunur...</span>`;}term.scrollTop = term.scrollHeight;8 unmodified linesif (data.status === 'success') {term.innerHTML += `<br><span class="ps-ok">${escapeHtml(data.output)}</span>`;} else {// Xəta olduqda AI-dan soruşmaq üçün düymə əlavə ediriklet safeError = encodeURIComponent(data.output.substring(0, 500));term.innerHTML += `<br><span class="ps-err">${escapeHtml(data.output)}</span><br><button class="terminal-ai-btn" onclick="askAiAboutError('${safeError}')"><i class="fa-solid fa-wand-magic-sparkles"></i> Exypos-a Soruş</button>`;}} catch (error) {term.innerHTML += `<br><span class="ps-err">Sistem Xətası!</span>`;}term.scrollTop = term.scrollHeight;}function clearTerminal() {document.getElementById('terminal-output').innerHTML = `<span class="ps-cmd">Twenty></span> Terminal təmizləndi...`;}function escapeHtml(text) {return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");}// Exypos AI - Smart Chatasync function askAI() {const inputEl = document.getElementById('ai-input');const prompt = inputEl.value.trim();5 unmodified lineschat.scrollTop = chat.scrollHeight;const typingId = "type-" + Date.now();chat.innerHTML += `<div class="msg ai" id="${typingId}">Düşünürəm... 🚀</div>`;chat.scrollTop = chat.scrollHeight;try {5 unmodified lines});const data = await response.json();// Kodu tapmaq və düymə əlavə etməklet rawReply = escapeHtml(data.reply);// Əgər cavabda python kodu varsa, tuturuqconst codeMatch = data.reply.match(/```(?:python)?\\n([\\s\\S]*?)```/);if(codeMatch) {lastAiCode = codeMatch[1].trim();// Markdown kod blokunu HTML-ə çeviririk və "Kodu Editora Yaz" düyməsi əlavə edirikrawReply = rawReply.replace(/```(?:python)?\\n([\\s\\S]*?)```/g,`</p><pre><code>$1</code></pre><button class="ai-action-btn" onclick="insertAiCode()"><i class="fa-solid fa-code-merge"></i> Kodu Editora Yaz</button><p>`);}document.getElementById(typingId).innerHTML = rawReply.replace(/\\n/g, '<br>');} catch (e) {document.getElementById(typingId).innerHTML = "<span style='color:#ff4757'>Bağlantı xətası.</span>";}chat.scrollTop = chat.scrollHeight;}// Exypos kodunu birbaşa editora yazan funksiyafunction insertAiCode() {if(editor && lastAiCode) {// Kodu editorun mövcud koduna əlavə edir və ya əvəz edir (istəsən setValue ilə tam silib yaza bilərsən)const selection = editor.getSelection();editor.executeEdits("ai-insert", [{range: selection,text: lastAiCode,forceMoveMarkers: true}]);document.getElementById('terminal-output').innerHTML += `<br><span style="color:var(--accent)">[Exypos AI]</span> Kod editora uğurla əlavə edildi.<br>`;}}// Terminaldakı xətanı birbaşa Exypos-a göndərirfunction askAiAboutError(encodedError) {const decodedError = decodeURIComponent(encodedError);const inputEl = document.getElementById('ai-input');inputEl.value = "Bu xətanı necə həll edim? Xəta: " + decodedError;askAI();}// Resizer (Sürüşdürücü)const resizer = document.getElementById('resizer');const bottomPanel = document.getElementById('bottom-panel');let isResizing = false;resizer.addEventListener('mousedown', () => { isResizing = true; document.body.style.cursor = 'ns-resize'; });document.addEventListener('mousemove', (e) => {if (!isResizing) return;const containerHeight = document.querySelector('.center-panel').clientHeight;const newHeight = containerHeight - e.clientY + 65;if (newHeight > 100 && newHeight < containerHeight - 100) {bottomPanel.style.height = `${newHeight}px`;bottomPanel.style.flex = 'none';if(editor) editor.layout();}});document.addEventListener('mouseup', () => { isResizing = false; document.body.style.cursor = 'default'; });</script></body></html>12 unmodified linesif not code.strip():return jsonify({"status": "error", "output": "Boş kod göndərildi."})# Terminal (Shell) komandası (Məs: !pip install requests)if is_shell:shell_cmd = code.strip()[1:]try:4 unmodified linesexcept Exception as e:return jsonify({"status": "error", "output": str(e)})# Python Kodu İcra Etməkwith tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False, encoding='utf-8') as temp_file:temp_file.write(code)temp_filepath = temp_file.name21 unmodified linesprompt = data.get('prompt', '')context_code = data.get('code', '')# Exypos-a kod haqqında məlumat veririksystem_msg = "Sən Exypos AI-san, Twenty OS daxilində çalışan güclü kod köməkçisisən. Qısa, dəqiq və azərbaycanca cavab ver. Əgər kod düzəldirsənsə, mütləq mətndə yalnız python kodunu ```python ... ``` blokunun içinə yaz."user_msg = f"Sual: {prompt}\n\nHazırki kodum:\n```python\n{context_code}\n```"16 unmodified lines17181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981991 unmodified line2012022032042052061 unmodified line2082092102112122132142152168 unmodified lines2252262272282292302312322332342352362372382392402412422432442452462475 unmodified lines2532542552562572582595 unmodified lines26526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330412 unmodified lines3173183193203213224 unmodified lines32732832933033133221 unmodified lines35435535635735835916 unmodified lines<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Twenty IDE | Premium Workspace</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><style>/* --- PREMIUM MINIMALIST DARK THEME --- */:root {--bg-base: #09090b; /* Çox tünd, mat arxa plan */--bg-panel: #18181b; /* Panellər üçün biraz daha açıq */--border-color: #27272a; /* Kəskin və incə sərhədlər */--text-main: #fafafa;--text-muted: #a1a1aa;--accent: #3b82f6; /* Premium Vercel/Tailwind mavisinə yaxın */--ai-accent: #8b5cf6; /* Exypos üçün bənövşəyi premium ton */--radius: 6px; /* Daha ciddi, kəskin kənarlar */}* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; }body { background-color: var(--bg-base); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }/* Fading Intro */body { animation: fadeIn 0.5s ease-in-out forwards; }@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }/* --- PANELLƏR VƏ LAYOUT --- */.panel {background: var(--bg-panel);border: 1px solid var(--border-color);border-radius: var(--radius);box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);}.top-bar { height: 50px; margin: 8px 8px 0 8px; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; border: 1px solid var(--border-color); background: var(--bg-panel); border-radius: var(--radius); }.main-layout { display: flex; flex: 1; overflow: hidden; padding: 8px; gap: 8px; }.sidebar-left { width: 260px; display: flex; flex-direction: column; }.sidebar-right { width: 340px; display: flex; flex-direction: column; border-top: 2px solid var(--ai-accent); }.center-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }.bottom-panel { height: 280px; display: flex; flex-direction: column; border-radius: var(--radius); margin-top: 8px; }/* --- UI ELEMENTLƏRİ --- */.brand { font-size: 13px; font-weight: 600; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; color: var(--text-main); }.brand span { color: var(--text-muted); font-weight: 400; }.controls { display: flex; align-items: center; gap: 8px; }.btn { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 4px; cursor: pointer; transition: 0.2s; font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }.btn:hover { background: #27272a; border-color: #3f3f46; }.btn-run { background: var(--text-main); color: var(--bg-base); border: none; font-weight: 600; }.btn-run:hover { background: #e4e4e7; transform: none; box-shadow: none; } /* Sadə və kəskin */.panel-header { padding: 12px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }/* Explorer (Sol Panel) */#file-tree { padding: 12px; font-size: 13px; color: var(--text-main); }.file-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; color: var(--text-muted); transition: 0.1s; }.file-item:hover { background: #27272a; color: var(--text-main); }.file-item.active { background: #27272a; color: var(--text-main); font-weight: 500; }/* Editor Area */#editor-container { flex: 1; background: var(--bg-panel); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border-color); }/* Terminal & Tabs */.bottom-tabs { display: flex; border-bottom: 1px solid var(--border-color); background: #121214; border-radius: var(--radius) var(--radius) 0 0; }.tab { padding: 10px 20px; font-size: 12px; cursor: pointer; color: var(--text-muted); transition: 0.2s; border-right: 1px solid var(--border-color); }.tab.active { color: var(--text-main); border-bottom: 2px solid var(--accent); background: var(--bg-panel); }.tab-content { flex: 1; overflow: hidden; display: none; background: var(--bg-panel); border-radius: 0 0 var(--radius) var(--radius); }.tab-content.active { display: flex; flex-direction: column; }#terminal-output { flex: 1; padding: 16px; font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 13px; color: #d4d4d8; overflow-y: auto; white-space: pre-wrap; line-height: 1.6; }.ps-cmd { color: var(--accent); font-weight: 600; }.ps-err { color: #ef4444; }.ps-ok { color: #22c55e; }/* Exypos AI Chat */#ai-chat { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; font-size: 13px; background: var(--bg-panel); }.msg { padding: 12px; border-radius: var(--radius); max-width: 95%; line-height: 1.6; border: 1px solid var(--border-color); }.msg.user { background: #1f1f22; align-self: flex-end; color: #e4e4e7; }.msg.ai { background: #121214; align-self: flex-start; color: #d4d4d8; border-left: 2px solid var(--ai-accent); }.ai-input-zone { padding: 12px; border-top: 1px solid var(--border-color); display: flex; gap: 8px; background: #121214; border-radius: 0 0 var(--radius) var(--radius); }.ai-input-zone input { flex: 1; background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-main); padding: 10px 12px; border-radius: 4px; outline: none; transition: 0.2s; font-size: 13px; }.ai-input-zone input:focus { border-color: var(--ai-accent); }.send-btn { background: var(--text-main); color: var(--bg-base); border: none; border-radius: 4px; padding: 0 14px; cursor: pointer; transition: 0.2s; }.send-btn:hover { background: #e4e4e7; }/* AI Editor Actions */.ai-action-btn { background: var(--bg-base); color: var(--text-main); border: 1px solid var(--border-color); padding: 6px 10px; border-radius: 4px; font-size: 11px; font-weight: 500; cursor: pointer; margin-top: 8px; transition: 0.2s; display: flex; align-items: center; gap: 6px; }.ai-action-btn:hover { border-color: var(--text-main); }.terminal-ai-btn { background: transparent; border: 1px solid #ef4444; color: #ef4444; padding: 4px 10px; border-radius: 4px; cursor: pointer; margin-top: 5px; font-size: 11px; transition: 0.2s; display: inline-flex; align-items: center; gap: 4px; }.terminal-ai-btn:hover { background: #ef4444; color: #fff; }pre { background: #000; padding: 12px; border-radius: 4px; overflow-x: auto; border: 1px solid var(--border-color); margin-top: 8px; }code { font-family: 'JetBrains Mono', 'Consolas', monospace; color: #e4e4e7; font-size: 12px; }/* Scrollbar təmizlənməsi */::-webkit-scrollbar { width: 8px; height: 8px; }::-webkit-scrollbar-track { background: var(--bg-base); }::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }::-webkit-scrollbar-thumb:hover { background: #52525b; }</style><script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.36.1/min/vs/loader.min.js"></script></head><body><div class="top-bar"><div class="brand"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg>TWENTY OS <span>/ main.py</span></div><div class="controls"><button class="btn btn-run" onclick="runCode()"><i class="fa-solid fa-play" style="font-size: 10px;"></i> Run Code</button></div></div><div class="main-layout"><div class="panel sidebar-left" id="sidebar-left"><div class="panel-header">Explorer</div><div id="file-tree"><div class="file-item active"><i class="fa-brands fa-python" style="color:#eab308;"></i> main.py</div></div></div><div class="center-panel"><div id="editor-container"></div><div class="panel bottom-panel" id="bottom-panel"><div class="bottom-tabs"><div class="tab active" onclick="switchTab('terminal')">Terminal</div><i class="fa-solid fa-broom" style="margin-left:auto; margin-right:16px; margin-top:10px; cursor:pointer; color:var(--text-muted); font-size: 12px;" onclick="clearTerminal()" title="Clear"></i></div><div class="tab-content active" id="tab-terminal"><div id="terminal-output"><span style="color:#52525b;">// Environment Ready.</span><br></div></div></div></div><div class="panel sidebar-right" id="sidebar-right"><div class="panel-header" style="color: var(--ai-accent); border-bottom-color: var(--border-color);"><i class="fa-solid fa-bolt" style="margin-right: 4px;"></i> EXYPOS AI</div><div id="ai-chat"><div class="msg ai">Sistemlər aktivdir. Kodunu oxuyuram, xəta olarsa mənə göndər.</div></div><div class="ai-input-zone"><input type="text" id="ai-input" placeholder="Ask Exypos..." onkeypress="if(event.key === 'Enter') askAI()"><button class="send-btn" onclick="askAI()"><i class="fa-solid fa-arrow-up"></i></button></div></div></div><script>let editor;let lastAiCode = "";require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.36.1/min/vs' }});require(['vs/editor/editor.main'], function() {editor = monaco.editor.create(document.getElementById('editor-container'), {value: "# Welcome to Twenty Premium Workspace\\ndef main():\\n print('Hello, Engineer.')\\n\\nif __name__ == '__main__':\\n main()",language: 'python',theme: 'vs-dark', // Standart dark mövzu (daha peşəkar görünür)automaticLayout: true,fontSize: 14,fontFamily: "'JetBrains Mono', 'Consolas', monospace",minimap: { enabled: false },padding: { top: 16 },scrollBeyondLastLine: false,renderLineHighlight: "all",cursorBlinking: "smooth",cursorSmoothCaretAnimation: true});// Monaco Editor arxa planını bizim panel arxa planı ilə eyniləşdiririkmonaco.editor.defineTheme('twenty-dark', {base: 'vs-dark',inherit: true,rules: [],colors: { 'editor.background': '#18181b' }});monaco.editor.setTheme('twenty-dark');});function switchTab(tabId) {document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));document.querySelectorAll('.tab-content').forEach(tc => tc.classList.remove('active'));1 unmodified linedocument.getElementById(`tab-${tabId}`).classList.add('active');}async function runCode() {if(!editor) return;const code = editor.getValue();1 unmodified lineconst isShell = code.trim().startsWith('!');if(isShell) {term.innerHTML += `<br><span class="ps-cmd">$</span> ${code.trim()}<br><span style="color:#52525b">Executing...</span>`;} else {term.innerHTML += `<br><span class="ps-cmd">user@twenty:~$</span> python main.py<br><span style="color:#52525b">Executing...</span>`;}term.scrollTop = term.scrollHeight;8 unmodified linesif (data.status === 'success') {term.innerHTML += `<br><span class="ps-ok">${escapeHtml(data.output)}</span>`;} else {let safeError = encodeURIComponent(data.output.substring(0, 500));term.innerHTML += `<br><span class="ps-err">${escapeHtml(data.output)}</span><br><button class="terminal-ai-btn" onclick="askAiAboutError('${safeError}')"><i class="fa-solid fa-bug"></i> Fix with Exypos</button>`;}} catch (error) {term.innerHTML += `<br><span class="ps-err">System Error!</span>`;}term.scrollTop = term.scrollHeight;}function clearTerminal() {document.getElementById('terminal-output').innerHTML = `<span class="ps-cmd">user@twenty:~$</span> Clear...`;}function escapeHtml(text) {return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");}async function askAI() {const inputEl = document.getElementById('ai-input');const prompt = inputEl.value.trim();5 unmodified lineschat.scrollTop = chat.scrollHeight;const typingId = "type-" + Date.now();chat.innerHTML += `<div class="msg ai" id="${typingId}">Thinking...</div>`;chat.scrollTop = chat.scrollHeight;try {5 unmodified lines});const data = await response.json();let rawReply = escapeHtml(data.reply);const codeMatch = data.reply.match(/```(?:python)?\\n([\\s\\S]*?)```/);if(codeMatch) {lastAiCode = codeMatch[1].trim();rawReply = rawReply.replace(/```(?:python)?\\n([\\s\\S]*?)```/g,`</p><pre><code>$1</code></pre><button class="ai-action-btn" onclick="insertAiCode()"><i class="fa-solid fa-download"></i> Apply to Editor</button><p>`);}document.getElementById(typingId).innerHTML = rawReply.replace(/\\n/g, '<br>');} catch (e) {document.getElementById(typingId).innerHTML = "<span style='color:#ef4444'>Connection Error.</span>";}chat.scrollTop = chat.scrollHeight;}function insertAiCode() {if(editor && lastAiCode) {const selection = editor.getSelection();editor.executeEdits("ai-insert", [{range: selection,text: lastAiCode,forceMoveMarkers: true}]);document.getElementById('terminal-output').innerHTML += `<br><span style="color:var(--ai-accent)">[Exypos AI]</span> Code applied successfully.<br>`;}}function askAiAboutError(encodedError) {const decodedError = decodeURIComponent(encodedError);const inputEl = document.getElementById('ai-input');inputEl.value = "Bu xətanı necə həll edim? Xəta: " + decodedError;askAI();}</script></body></html>12 unmodified linesif not code.strip():return jsonify({"status": "error", "output": "Boş kod göndərildi."})if is_shell:shell_cmd = code.strip()[1:]try:4 unmodified linesexcept Exception as e:return jsonify({"status": "error", "output": str(e)})with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False, encoding='utf-8') as temp_file:temp_file.write(code)temp_filepath = temp_file.name21 unmodified linesprompt = data.get('prompt', '')context_code = data.get('code', '')system_msg = "Sən Exypos AI-san, Twenty OS daxilində çalışan güclü kod köməkçisisən. Qısa, dəqiq və azərbaycanca cavab ver. Əgər kod düzəldirsənsə, mütləq mətndə yalnız python kodunu ```python ... ``` blokunun içinə yaz."user_msg = f"Sual: {prompt}\n\nHazırki kodum:\n```python\n{context_code}\n```"
app.py+121-178