-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopilot-task-agent-mobile.html
More file actions
771 lines (668 loc) · 26.1 KB
/
copilot-task-agent-mobile.html
File metadata and controls
771 lines (668 loc) · 26.1 KB
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Copilot Task Agent - Mobile</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="theme-color" content="#007AFF">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary-color: #007AFF;
--primary-dark: #0056B3;
--success-color: #28a745;
--warning-color: #ffc107;
--error-color: #dc3545;
--bg-color: #f8f9fa;
--card-bg: #ffffff;
--text-primary: #333333;
--text-secondary: #666666;
--border-color: #e9ecef;
--shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
--shadow-md: 0 4px 12px rgba(0,0,0,0.1);
--font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
}
body {
font-family: var(--font-family);
background: var(--bg-color);
color: var(--text-primary);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.mobile-container {
min-height: 100vh;
max-width: 480px;
margin: 0 auto;
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.app-header {
background: var(--card-bg);
padding: 20px;
border-bottom: 1px solid var(--border-color);
text-align: center;
position: sticky;
top: 0;
z-index: 100;
}
.app-title {
font-size: 20px;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 4px;
}
.app-subtitle {
font-size: 13px;
color: var(--text-secondary);
font-weight: 500;
}
.main-content {
padding: 20px;
padding-bottom: 100px;
}
.quick-actions {
margin-bottom: 30px;
}
.section-title {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 8px;
}
.quick-actions-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12px;
margin-bottom: 20px;
}
.quick-action {
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 20px 16px;
text-align: center;
cursor: pointer;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: var(--shadow-sm);
}
.quick-action:hover {
border-color: var(--primary-color);
box-shadow: var(--shadow-md);
transform: translateY(-2px);
}
.quick-action:active {
transform: translateY(0);
}
.action-icon {
width: 40px;
height: 40px;
background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 12px;
font-size: 20px;
}
.action-title {
font-size: 14px;
font-weight: 600;
color: var(--text-primary);
line-height: 1.3;
}
.prompt-section {
background: var(--card-bg);
border-radius: 16px;
padding: 20px;
margin-bottom: 30px;
box-shadow: var(--shadow-sm);
}
.prompt-textarea {
width: 100%;
min-height: 120px;
padding: 16px;
border: 1px solid var(--border-color);
border-radius: 12px;
font-size: 16px;
font-family: inherit;
resize: vertical;
background: var(--bg-color);
transition: border-color 0.2s ease;
}
.prompt-textarea:focus {
outline: none;
border-color: var(--primary-color);
}
.prompt-controls {
display: flex;
align-items: center;
gap: 12px;
margin-top: 16px;
}
.voice-button {
width: 44px;
height: 44px;
border: 1px solid var(--border-color);
border-radius: 10px;
background: var(--card-bg);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s ease;
}
.voice-button:hover {
border-color: var(--primary-color);
}
.execute-button {
flex: 1;
height: 44px;
background: var(--primary-color);
border: none;
border-radius: 10px;
color: white;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}
.execute-button:disabled {
background: var(--text-secondary);
cursor: not-allowed;
}
.execute-button:hover:not(:disabled) {
background: var(--primary-dark);
transform: translateY(-1px);
box-shadow: var(--shadow-md);
}
.schema-section {
background: var(--card-bg);
border-radius: 16px;
padding: 20px;
margin-bottom: 30px;
box-shadow: var(--shadow-sm);
border-left: 4px solid var(--primary-color);
}
.schema-title {
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 8px;
}
.schema-type {
display: inline-block;
background: rgba(0, 122, 255, 0.1);
color: var(--primary-color);
padding: 4px 8px;
border-radius: 6px;
font-size: 12px;
font-weight: 500;
margin-bottom: 12px;
}
.schema-description {
color: var(--text-secondary);
line-height: 1.6;
margin-bottom: 16px;
}
.requirements-list {
list-style: none;
}
.requirement-item {
padding: 12px 0 12px 16px;
border-left: 2px solid var(--primary-color);
background: var(--bg-color);
border-radius: 8px;
margin-bottom: 8px;
color: var(--text-secondary);
font-size: 14px;
}
.validation-status {
display: flex;
align-items: center;
gap: 8px;
padding: 12px;
border-radius: 8px;
margin-top: 16px;
font-size: 14px;
font-weight: 500;
}
.validation-status.valid {
background: rgba(40, 167, 69, 0.1);
color: var(--success-color);
}
.validation-status.invalid {
background: rgba(220, 53, 69, 0.1);
color: var(--error-color);
}
.result-section {
background: var(--card-bg);
border-radius: 16px;
padding: 20px;
margin-bottom: 30px;
box-shadow: var(--shadow-sm);
}
.result-status {
font-size: 18px;
font-weight: 600;
margin-bottom: 16px;
display: flex;
align-items: center;
gap: 8px;
}
.result-status.success {
color: var(--success-color);
}
.result-status.failed {
color: var(--error-color);
}
.result-message {
color: var(--text-secondary);
line-height: 1.6;
margin-bottom: 16px;
}
.generated-files {
background: var(--bg-color);
border-radius: 8px;
padding: 16px;
margin-top: 16px;
}
.file-list {
list-style: none;
}
.file-item {
display: flex;
align-items: center;
padding: 8px 0;
color: var(--text-secondary);
font-size: 14px;
}
.file-icon {
margin-right: 12px;
font-size: 16px;
}
.loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.loading-content {
background: var(--card-bg);
padding: 30px;
border-radius: 16px;
text-align: center;
box-shadow: var(--shadow-md);
}
.loading-spinner {
width: 40px;
height: 40px;
border: 3px solid var(--border-color);
border-top: 3px solid var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 16px;
}
.loading-text {
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 4px;
}
.loading-subtext {
font-size: 14px;
color: var(--text-secondary);
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Mobile-specific optimizations */
@media (max-width: 480px) {
.mobile-container {
max-width: 100%;
padding: 0;
}
.quick-actions-grid {
grid-template-columns: 1fr;
}
.main-content {
padding: 16px;
}
}
/* Safe area for iOS */
@supports (padding: max(0px)) {
.mobile-container {
padding-left: max(env(safe-area-inset-left), 16px);
padding-right: max(env(safe-area-inset-right), 16px);
}
}
</style>
</head>
<body>
<div class="mobile-container">
<!-- App Header -->
<header class="app-header">
<h1 class="app-title">Copilot Task Agent</h1>
<p class="app-subtitle">Prompt → Schema → Execution (Terminal Speed)</p>
</header>
<!-- Main Content -->
<main class="main-content">
<!-- Quick Actions -->
<section class="quick-actions">
<h2 class="section-title">
⚡ Quick Actions
</h2>
<div class="quick-actions-grid">
<div class="quick-action" onclick="handleQuickAction('analyze')">
<div class="action-icon">🔍</div>
<div class="action-title">Analyze Repository</div>
</div>
<div class="quick-action" onclick="handleQuickAction('tech-stack')">
<div class="action-icon">🏗️</div>
<div class="action-title">Create Tech Stack</div>
</div>
<div class="quick-action" onclick="handleQuickAction('features')">
<div class="action-icon">➕</div>
<div class="action-title">Add Features</div>
</div>
<div class="quick-action" onclick="handleQuickAction('upgrade')">
<div class="action-icon">🔄</div>
<div class="action-title">Upgrade Architecture</div>
</div>
</div>
</section>
<!-- Prompt Section -->
<section class="prompt-section">
<h2 class="section-title">
📝 Describe Your Task
</h2>
<textarea
id="promptInput"
class="prompt-textarea"
placeholder="Enter natural language description of what you want to accomplish..."
oninput="handlePromptInput()"
></textarea>
<div class="prompt-controls">
<button class="voice-button" onclick="handleVoiceInput()">
🎤
</button>
<button
id="executeButton"
class="execute-button"
onclick="handleExecute()"
disabled
>
<span>🚀</span>
<span>Create & Execute</span>
</button>
</div>
</section>
<!-- Schema Section (hidden initially) -->
<section id="schemaSection" class="schema-section" style="display: none;">
<h2 class="section-title">
📋 Generated OpenSpec Schema
</h2>
<div class="schema-title" id="schemaTitle"></div>
<span class="schema-type" id="schemaType"></span>
<p class="schema-description" id="schemaDescription"></p>
<ul id="requirementsList" class="requirements-list"></ul>
<div id="validationStatus" class="validation-status"></div>
</section>
<!-- Result Section (hidden initially) -->
<section id="resultSection" class="result-section" style="display: none;">
<h2 class="section-title">
✅ Execution Result
</h2>
<div class="result-status" id="resultStatus"></div>
<p class="result-message" id="resultMessage"></p>
<div id="generatedFiles" class="generated-files" style="display: none;">
<h3 style="font-size: 14px; font-weight: 600; margin-bottom: 12px;">Generated Files:</h3>
<ul id="fileList" class="file-list"></ul>
</div>
</section>
</main>
<!-- Loading Overlay -->
<div id="loadingOverlay" class="loading-overlay" style="display: none;">
<div class="loading-content">
<div class="loading-spinner"></div>
<div class="loading-text">Processing...</div>
<div class="loading-subtext">Uplifting to OpenSpec schema...</div>
</div>
</div>
</div>
<script>
// API Configuration
const API_BASE_URL = 'http://localhost:8000';
let currentSchema = null;
let isProcessing = false;
// Quick action prompts
const quickActionPrompts = {
'analyze': 'Analyze this repository structure and suggest improvements for performance and maintainability',
'tech-stack': 'Create modern tech stack for web application with React, Node.js, PostgreSQL, and Docker deployment',
'features': 'Add authentication system with JWT tokens, user registration, login, and role-based access control',
'upgrade': 'Upgrade current monolith architecture to microservices with event-driven design, API gateway, and Kubernetes deployment'
};
// Handle quick action clicks
function handleQuickAction(action) {
const promptInput = document.getElementById('promptInput');
promptInput.value = quickActionPrompts[action];
handlePromptInput();
// Auto-execute for quick actions
setTimeout(() => {
handleExecute();
}, 500);
}
// Handle prompt input changes
function handlePromptInput() {
const promptInput = document.getElementById('promptInput');
const executeButton = document.getElementById('executeButton');
// Enable/disable execute button
if (promptInput.value.trim().length > 0) {
executeButton.disabled = false;
} else {
executeButton.disabled = true;
}
}
// Handle voice input (placeholder)
function handleVoiceInput() {
alert('Voice input is coming soon! For now, please type your description.');
}
// Show loading overlay
function showLoading(text = 'Processing...', subtext = 'Uplifting to OpenSpec schema...') {
const overlay = document.getElementById('loadingOverlay');
const loadingText = overlay.querySelector('.loading-text');
const loadingSubtext = overlay.querySelector('.loading-subtext');
loadingText.textContent = text;
loadingSubtext.textContent = subtext;
overlay.style.display = 'flex';
}
// Hide loading overlay
function hideLoading() {
const overlay = document.getElementById('loadingOverlay');
overlay.style.display = 'none';
}
// Execute prompt uplift and task execution
async function handleExecute() {
if (isProcessing) return;
const promptInput = document.getElementById('promptInput');
const prompt = promptInput.value.trim();
if (!prompt) return;
isProcessing = true;
showLoading('Processing your request...', 'Uplifting to OpenSpec schema...');
try {
// Step 1: Uplift prompt to OpenSpec
const upliftResponse = await fetch(`${API_BASE_URL}/api/v1/prompt-uplift`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
natural_input: prompt,
target_platform: 'mobile',
execution_preference: 'terminal_like',
ai_system_preference: 'auto_detect'
})
});
const upliftResult = await upliftResponse.json();
if (upliftResult.success) {
// Show generated schema
displaySchema(upliftResult.openspec_schema);
// Auto-execute if validation is good
if (upliftResult.validation_status === 'valid') {
showLoading('Executing task...', 'Running with terminal-like speed...');
// Step 2: Execute task
const executeResponse = await fetch(`${API_BASE_URL}/api/v1/execute-task`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
openspec_schema: upliftResult.openspec_schema,
execution_mode: 'terminal_like'
})
});
const executeResult = await executeResponse.json();
if (executeResult.status === 'completed') {
displayResult(executeResult.result);
} else {
displayError('Execution failed', executeResult.result?.error || 'Unknown error');
}
} else {
hideLoading();
alert('Schema validation failed. Please review the generated schema before proceeding.');
}
} else {
hideLoading();
alert('Failed to process your request: ' + (upliftResult.message || 'Unknown error'));
}
} catch (error) {
console.error('Execution failed:', error);
hideLoading();
alert('Failed to process your request. Please check your connection and try again.');
} finally {
isProcessing = false;
}
}
// Display generated OpenSpec schema
function displaySchema(schema) {
currentSchema = schema;
// Show schema section
const schemaSection = document.getElementById('schemaSection');
schemaSection.style.display = 'block';
// Populate schema details
document.getElementById('schemaTitle').textContent = schema.title;
document.getElementById('schemaType').textContent = schema.spec_type.replace('_', ' ').toUpperCase();
document.getElementById('schemaDescription').textContent = schema.description;
// Display requirements
const requirementsList = document.getElementById('requirementsList');
requirementsList.innerHTML = '';
if (schema.requirements && schema.requirements.length > 0) {
schema.requirements.forEach(req => {
const li = document.createElement('li');
li.className = 'requirement-item';
li.textContent = req;
requirementsList.appendChild(li);
});
}
// Display validation status
const validationStatus = document.getElementById('validationStatus');
validationStatus.className = `validation-status ${schema.validation_status}`;
validationStatus.innerHTML = `
${schema.validation_status === 'valid' ? '✅' : '❌'}
Status: ${schema.validation_status.toUpperCase()}
`;
}
// Display execution result
function displayResult(result) {
hideLoading();
// Show result section
const resultSection = document.getElementById('resultSection');
resultSection.style.display = 'block';
// Scroll to result
resultSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
// Populate result details
const resultStatus = document.getElementById('resultStatus');
resultStatus.className = `result-status ${result.execution_success ? 'success' : 'failed'}`;
resultStatus.innerHTML = `
${result.execution_success ? '✅' : '❌'}
${result.execution_success ? 'EXECUTION SUCCESSFUL' : 'EXECUTION FAILED'}
`;
document.getElementById('resultMessage').textContent = result.message || 'Task completed';
// Display generated files if available
if (result.generated_files && result.generated_files.length > 0) {
const generatedFiles = document.getElementById('generatedFiles');
const fileList = document.getElementById('fileList');
fileList.innerHTML = '';
result.generated_files.forEach(file => {
const li = document.createElement('li');
li.className = 'file-item';
li.innerHTML = `
<span class="file-icon">📄</span>
<span>${file}</span>
`;
fileList.appendChild(li);
});
generatedFiles.style.display = 'block';
}
}
// Display error
function displayError(title, message) {
hideLoading();
const resultSection = document.getElementById('resultSection');
resultSection.style.display = 'block';
resultSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
const resultStatus = document.getElementById('resultStatus');
resultStatus.className = 'result-status failed';
resultStatus.innerHTML = '❌ ERROR';
document.getElementById('resultMessage').textContent = message;
document.getElementById('generatedFiles').style.display = 'none';
}
// Initialize app
document.addEventListener('DOMContentLoaded', function() {
// Focus on prompt input
const promptInput = document.getElementById('promptInput');
promptInput.focus();
// Check API connection
fetch(`${API_BASE_URL}/api/v1/status`)
.then(response => response.json())
.then(data => {
if (data.status === 'active') {
console.log('✅ Connected to Copilot Task Agent API');
} else {
console.error('❌ API connection failed');
}
})
.catch(error => {
console.error('❌ Failed to connect to API:', error);
});
});
// Handle mobile viewport changes
window.addEventListener('resize', function() {
// Adjust layout for mobile
const isMobile = window.innerWidth <= 480;
document.body.classList.toggle('mobile', isMobile);
});
</script>
</body>
</html>