Spaces:
Running
Running
اريد بأن تقوم بإنشاء موقع ويب يعمل على الوضائف التاليه:
Browse files1. يوفر واجهه تمكنني من إدخال OpenAI API Keys وربط الموقع بحسابي على جتهب
2. ينتقل إلى واجهه يطلب فيها تحديد مستودع جتهب الذي اريد ان اعمل عليه (من المستودعات التي بالحساب الذي قمت بربطه بالموقع)
3. ينتقل إلى خانه المحادثه مع نموذج الذكاء الاصطناعي ويقوم بانشاء سحب جديد على المستودع الذي حددته و بحيث عندما اكتب اي امر يقوم نموذج الذكاء الاصطناعي بتنفيذه على المستودع الذي حددته مسبقا
4. عندما اريد الانتهاء من التعديلات اضغط على زر الدمج وبعدها يتم دمج جميع التغيرات على المستودع الذي حددته مسبقا
الفكره مشابهه لموقع cursor (واجهه الهاتف المحمول)
- index.html +247 -18
index.html
CHANGED
|
@@ -1,19 +1,248 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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| 3 |
+
<html lang="ar" dir="rtl">
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<title>GitHub AI Assistant</title>
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<link rel="stylesheet" href="style.css">
|
| 11 |
+
</head>
|
| 12 |
+
<body class="bg-gray-50 min-h-screen">
|
| 13 |
+
<div id="app" class="container mx-auto px-4 py-8">
|
| 14 |
+
<!-- Setup Page -->
|
| 15 |
+
<div id="setup-page" class="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden p-6">
|
| 16 |
+
<div class="text-center mb-8">
|
| 17 |
+
<h1 class="text-2xl font-bold text-gray-800 mb-2">GitHub AI Assistant</h1>
|
| 18 |
+
<p class="text-gray-600">أدخل بيانات الاعتماد الخاصة بك للبدء</p>
|
| 19 |
+
</div>
|
| 20 |
+
|
| 21 |
+
<form id="setup-form" class="space-y-4">
|
| 22 |
+
<div>
|
| 23 |
+
<label for="openai-key" class="block text-sm font-medium text-gray-700 mb-1">OpenAI API Key</label>
|
| 24 |
+
<input type="password" id="openai-key" required
|
| 25 |
+
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 26 |
+
</div>
|
| 27 |
+
|
| 28 |
+
<div>
|
| 29 |
+
<label for="github-token" class="block text-sm font-medium text-gray-700 mb-1">GitHub Token</label>
|
| 30 |
+
<input type="password" id="github-token" required
|
| 31 |
+
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<button type="submit"
|
| 35 |
+
class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition duration-200">
|
| 36 |
+
الاتصال والاستمرار
|
| 37 |
+
</button>
|
| 38 |
+
</form>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<!-- Repository Selection Page -->
|
| 42 |
+
<div id="repo-page" class="hidden max-w-2xl mx-auto bg-white rounded-xl shadow-md overflow-hidden p-6">
|
| 43 |
+
<div class="text-center mb-8">
|
| 44 |
+
<h1 class="text-2xl font-bold text-gray-800 mb-2">اختر المستودع</h1>
|
| 45 |
+
<p class="text-gray-600">اختر المستودع الذي تريد العمل عليه</p>
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
<div id="repo-list" class="space-y-3 mb-6 max-h-96 overflow-y-auto">
|
| 49 |
+
<!-- Repositories will be loaded here -->
|
| 50 |
+
</div>
|
| 51 |
+
|
| 52 |
+
<button id="back-to-setup"
|
| 53 |
+
class="w-full bg-gray-500 text-white py-2 px-4 rounded-md hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 transition duration-200">
|
| 54 |
+
العودة إلى الإعدادات
|
| 55 |
+
</button>
|
| 56 |
+
</div>
|
| 57 |
+
|
| 58 |
+
<!-- Chat Page -->
|
| 59 |
+
<div id="chat-page" class="hidden h-screen flex flex-col bg-white rounded-xl shadow-md overflow-hidden">
|
| 60 |
+
<div class="flex items-center justify-between p-4 border-b bg-gray-50">
|
| 61 |
+
<div class="flex items-center space-x-2">
|
| 62 |
+
<button id="back-to-repo" class="text-gray-600 hover:text-gray-800">
|
| 63 |
+
<i data-feather="arrow-right"></i>
|
| 64 |
+
</button>
|
| 65 |
+
<h2 id="current-repo" class="text-lg font-semibold text-gray-800">المستودع المحدد</h2>
|
| 66 |
+
</div>
|
| 67 |
+
<button id="merge-btn"
|
| 68 |
+
class="bg-green-600 text-white px-4 py-2 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 transition duration-200 hidden">
|
| 69 |
+
دمج التغييرات
|
| 70 |
+
</button>
|
| 71 |
+
</div>
|
| 72 |
+
|
| 73 |
+
<div id="chat-messages" class="flex-1 overflow-y-auto p-4 space-y-4">
|
| 74 |
+
<!-- Chat messages will appear here -->
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
<div class="border-t p-4 bg-gray-50">
|
| 78 |
+
<form id="chat-form" class="flex space-x-2">
|
| 79 |
+
<input type="text" id="message-input"
|
| 80 |
+
placeholder="اكتب أمرك هنا..."
|
| 81 |
+
class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 82 |
+
<button type="submit"
|
| 83 |
+
class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition duration-200">
|
| 84 |
+
إرسال
|
| 85 |
+
</button>
|
| 86 |
+
</form>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<script>
|
| 92 |
+
feather.replace();
|
| 93 |
+
|
| 94 |
+
// State management
|
| 95 |
+
let currentState = 'setup';
|
| 96 |
+
let selectedRepo = null;
|
| 97 |
+
let conversationHistory = [];
|
| 98 |
+
|
| 99 |
+
// DOM elements
|
| 100 |
+
const setupPage = document.getElementById('setup-page');
|
| 101 |
+
const repoPage = document.getElementById('repo-page');
|
| 102 |
+
const chatPage = document.getElementById('chat-page');
|
| 103 |
+
const setupForm = document.getElementById('setup-form');
|
| 104 |
+
const repoList = document.getElementById('repo-list');
|
| 105 |
+
const backToSetup = document.getElementById('back-to-setup');
|
| 106 |
+
const backToRepo = document.getElementById('back-to-repo');
|
| 107 |
+
const currentRepo = document.getElementById('current-repo');
|
| 108 |
+
const mergeBtn = document.getElementById('merge-btn');
|
| 109 |
+
const chatForm = document.getElementById('chat-form');
|
| 110 |
+
const messageInput = document.getElementById('message-input');
|
| 111 |
+
const chatMessages = document.getElementById('chat-messages');
|
| 112 |
+
|
| 113 |
+
// Page navigation
|
| 114 |
+
function showPage(page) {
|
| 115 |
+
setupPage.classList.add('hidden');
|
| 116 |
+
repoPage.classList.add('hidden');
|
| 117 |
+
chatPage.classList.add('hidden');
|
| 118 |
+
|
| 119 |
+
page.classList.remove('hidden');
|
| 120 |
+
currentState = page.id.split('-')[0];
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
// Setup form submission
|
| 124 |
+
setupForm.addEventListener('submit', async (e) => {
|
| 125 |
+
e.preventDefault();
|
| 126 |
+
|
| 127 |
+
const openaiKey = document.getElementById('openai-key').value;
|
| 128 |
+
const githubToken = document.getElementById('github-token').value;
|
| 129 |
+
|
| 130 |
+
// Store credentials (in a real app, use secure storage)
|
| 131 |
+
localStorage.setItem('openaiKey', openaiKey);
|
| 132 |
+
localStorage.setItem('githubToken', githubToken);
|
| 133 |
+
|
| 134 |
+
// Load repositories
|
| 135 |
+
await loadRepositories();
|
| 136 |
+
showPage(repoPage);
|
| 137 |
+
});
|
| 138 |
+
|
| 139 |
+
// Load GitHub repositories
|
| 140 |
+
async function loadRepositories() {
|
| 141 |
+
const token = localStorage.getItem('githubToken');
|
| 142 |
+
|
| 143 |
+
try {
|
| 144 |
+
const response = await fetch('https://api.github.com/user/repos', {
|
| 145 |
+
headers: {
|
| 146 |
+
'Authorization': `token ${token}`,
|
| 147 |
+
'Accept': 'application/vnd.github.v3+json'
|
| 148 |
+
}
|
| 149 |
+
});
|
| 150 |
+
|
| 151 |
+
if (!response.ok) throw new Error('Failed to fetch repositories');
|
| 152 |
+
|
| 153 |
+
const repos = await response.json();
|
| 154 |
+
displayRepositories(repos);
|
| 155 |
+
} catch (error) {
|
| 156 |
+
alert('خطأ في جلب المستودعات: ' + error.message);
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
// Display repositories
|
| 161 |
+
function displayRepositories(repos) {
|
| 162 |
+
repoList.innerHTML = '';
|
| 163 |
+
|
| 164 |
+
repos.forEach(repo => {
|
| 165 |
+
const repoElement = document.createElement('button');
|
| 166 |
+
repoElement.className = 'w-full text-right p-3 border border-gray-200 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 transition duration-200';
|
| 167 |
+
repoElement.innerHTML = `
|
| 168 |
+
<div class="font-medium text-gray-800">${repo.name}</div>
|
| 169 |
+
<div class="text-sm text-gray-600">${repo.description || 'لا يوجد وصف'}</div>
|
| 170 |
+
`;
|
| 171 |
+
|
| 172 |
+
repoElement.addEventListener('click', () => {
|
| 173 |
+
selectedRepo = repo;
|
| 174 |
+
currentRepo.textContent = repo.name;
|
| 175 |
+
showPage(chatPage);
|
| 176 |
+
addMessage('system', 'مرحباً! أنا مساعد الذكاء الاصطناعي. كيف يمكنني مساعدتك في هذا المستودع؟');
|
| 177 |
+
});
|
| 178 |
+
|
| 179 |
+
repoList.appendChild(repoElement);
|
| 180 |
+
});
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
// Navigation buttons
|
| 184 |
+
backToSetup.addEventListener('click', () => showPage(setupPage));
|
| 185 |
+
backToRepo.addEventListener('click', () => showPage(repoPage));
|
| 186 |
+
|
| 187 |
+
// Chat functionality
|
| 188 |
+
function addMessage(sender, message) {
|
| 189 |
+
const messageDiv = document.createElement('div');
|
| 190 |
+
messageDiv.className = `p-3 rounded-lg max-w-[80%] ${
|
| 191 |
+
sender === 'user'
|
| 192 |
+
? 'bg-blue-100 text-blue-900 ml-auto'
|
| 193 |
+
: 'bg-gray-100 text-gray-900 mr-auto'
|
| 194 |
+
}`;
|
| 195 |
+
messageDiv.textContent = message;
|
| 196 |
+
|
| 197 |
+
chatMessages.appendChild(messageDiv);
|
| 198 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 199 |
+
|
| 200 |
+
conversationHistory.push({ sender, message });
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
chatForm.addEventListener('submit', async (e) => {
|
| 204 |
+
e.preventDefault();
|
| 205 |
+
|
| 206 |
+
const message = messageInput.value.trim();
|
| 207 |
+
if (!message) return;
|
| 208 |
+
|
| 209 |
+
// Add user message
|
| 210 |
+
addMessage('user', message);
|
| 211 |
+
messageInput.value = '';
|
| 212 |
+
|
| 213 |
+
// Show merge button after first user message
|
| 214 |
+
mergeBtn.classList.remove('hidden');
|
| 215 |
+
|
| 216 |
+
// Simulate AI response (in a real app, this would call OpenAI API)
|
| 217 |
+
setTimeout(() => {
|
| 218 |
+
addMessage('ai', `تم معالجة أمرك "${message}" على المستودع ${selectedRepo.name}. سيتم تنفيذ التغييرات المطلوبة.`);
|
| 219 |
+
}, 1000);
|
| 220 |
+
});
|
| 221 |
+
|
| 222 |
+
// Merge functionality
|
| 223 |
+
mergeBtn.addEventListener('click', async () => {
|
| 224 |
+
if (!confirm('هل أنت متأكد أنك تريد دمج جميع التغييرات؟')) return;
|
| 225 |
+
|
| 226 |
+
// Simulate merge process
|
| 227 |
+
addMessage('system', 'جاري دمج التغييرات على المستودع...');
|
| 228 |
+
|
| 229 |
+
setTimeout(() => {
|
| 230 |
+
addMessage('system', '✅ تم دمج التغييرات بنجاح!');
|
| 231 |
+
}, 2000);
|
| 232 |
+
});
|
| 233 |
+
|
| 234 |
+
// Check for stored credentials on load
|
| 235 |
+
window.addEventListener('load', () => {
|
| 236 |
+
const storedOpenAIKey = localStorage.getItem('openaiKey');
|
| 237 |
+
const storedGitHubToken = localStorage.getItem('githubToken');
|
| 238 |
+
|
| 239 |
+
if (storedOpenAIKey && storedGitHubToken) {
|
| 240 |
+
document.getElementById('openai-key').value = storedOpenAIKey;
|
| 241 |
+
document.getElementById('github-token').value = storedGitHubToken;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
feather.replace();
|
| 245 |
+
});
|
| 246 |
+
</script>
|
| 247 |
+
</body>
|
| 248 |
</html>
|