File size: 39,136 Bytes
74d8e8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
#!/usr/bin/env python3
"""
Enhanced CLI Interface Module for DeepCode
ๅขžๅผบ็‰ˆCLI็•Œ้ขๆจกๅ— - ไธ“ไธบDeepCode่ฎพ่ฎก
"""

import os
import time
import platform
from typing import Optional


class Colors:
    """ANSI color codes for terminal styling"""

    HEADER = "\033[95m"
    OKBLUE = "\033[94m"
    OKCYAN = "\033[96m"
    OKGREEN = "\033[92m"
    WARNING = "\033[93m"
    FAIL = "\033[91m"
    ENDC = "\033[0m"
    BOLD = "\033[1m"
    UNDERLINE = "\033[4m"

    # Gradient colors
    PURPLE = "\033[35m"
    MAGENTA = "\033[95m"
    BLUE = "\033[34m"
    CYAN = "\033[36m"
    GREEN = "\033[32m"
    YELLOW = "\033[33m"


class CLIInterface:
    """Enhanced CLI interface with modern styling for DeepCode"""

    def __init__(self):
        self.uploaded_file = None
        self.is_running = True
        self.processing_history = []
        self.enable_indexing = True  # Default configuration
        self.segmentation_enabled = True  # Default to smart segmentation
        self.segmentation_threshold = 50000  # Default threshold

        # Check tkinter availability for file dialogs
        self.tkinter_available = True
        try:
            import tkinter as tk

            # Test if tkinter can create a window
            test_root = tk.Tk()
            test_root.withdraw()
            test_root.destroy()
        except Exception:
            self.tkinter_available = False

    def clear_screen(self):
        """Clear terminal screen"""
        os.system("cls" if os.name == "nt" else "clear")

    def print_logo(self):
        """Print enhanced ASCII logo for DeepCode CLI"""
        logo = f"""
{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}{Colors.MAGENTA}โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—{Colors.CYAN}               โ•‘
โ•‘  {Colors.BOLD}{Colors.PURPLE}โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•{Colors.CYAN}               โ•‘
โ•‘  {Colors.BOLD}{Colors.BLUE}โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  {Colors.CYAN}               โ•‘
โ•‘  {Colors.BOLD}{Colors.OKBLUE}โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•”โ•โ•โ•โ• โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  {Colors.CYAN}               โ•‘
โ•‘  {Colors.BOLD}{Colors.OKCYAN}โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘     โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—{Colors.CYAN}               โ•‘
โ•‘  {Colors.BOLD}{Colors.GREEN}โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•      โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•{Colors.CYAN}               โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}{Colors.GREEN}๐Ÿงฌ OPEN-SOURCE CODE AGENT โ€ข DATA INTELLIGENCE LAB @ HKU ๐Ÿš€           {Colors.CYAN}โ•‘
โ•‘  {Colors.BOLD}{Colors.GREEN}โšก REVOLUTIONIZING RESEARCH REPRODUCIBILITY โšก                      {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(logo)

    def print_welcome_banner(self):
        """Print enhanced welcome banner"""
        banner = f"""
{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                             WELCOME TO DEEPCODE CLI                          โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘  {Colors.YELLOW}Open-Source Code Agent | Data Intelligence Lab @ HKU | MIT License        {Colors.CYAN}โ•‘
โ•‘  {Colors.GREEN}Status: Ready | Engine: Multi-Agent Architecture Initialized               {Colors.CYAN}โ•‘
โ•‘  {Colors.PURPLE}Mission: Revolutionizing Research Reproducibility                         {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}{Colors.OKCYAN}๐Ÿ’Ž CORE CAPABILITIES:{Colors.ENDC}                                                      {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Automated Paper-to-Code Reproduction                                {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Collaborative Multi-Agent Architecture                             {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Intelligent Code Implementation & Validation                       {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Future Vision: One Sentence โ†’ Complete Codebase                   {Colors.CYAN}โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(banner)

    def print_separator(self, char="โ•", length=79, color=Colors.CYAN):
        """Print a styled separator line"""
        print(f"{color}{char * length}{Colors.ENDC}")

    def print_status(self, message: str, status_type: str = "info"):
        """Print status message with appropriate styling"""
        status_styles = {
            "success": f"{Colors.OKGREEN}โœ…",
            "error": f"{Colors.FAIL}โŒ",
            "warning": f"{Colors.WARNING}โš ๏ธ ",
            "info": f"{Colors.OKBLUE}โ„น๏ธ ",
            "processing": f"{Colors.YELLOW}โณ",
            "upload": f"{Colors.PURPLE}๐Ÿ“",
            "download": f"{Colors.CYAN}๐Ÿ“ฅ",
            "analysis": f"{Colors.MAGENTA}๐Ÿ”",
            "implementation": f"{Colors.GREEN}โš™๏ธ ",
            "complete": f"{Colors.OKGREEN}๐ŸŽ‰",
        }

        icon = status_styles.get(status_type, status_styles["info"])
        timestamp = time.strftime("%H:%M:%S")
        print(
            f"[{Colors.BOLD}{timestamp}{Colors.ENDC}] {icon} {Colors.BOLD}{message}{Colors.ENDC}"
        )

    def create_menu(self):
        """Create enhanced interactive menu"""
        # Display current configuration
        pipeline_mode = "๐Ÿง  COMPREHENSIVE" if self.enable_indexing else "โšก OPTIMIZED"
        index_status = "โœ… Enabled" if self.enable_indexing else "๐Ÿ”ถ Disabled"
        segmentation_mode = (
            "๐Ÿ“„ SMART" if self.segmentation_enabled else "๐Ÿ“‹ TRADITIONAL"
        )

        menu = f"""
{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                MAIN MENU                                      โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘  {Colors.OKGREEN}๐ŸŒ [U] Process URL       {Colors.CYAN}โ”‚  {Colors.PURPLE}๐Ÿ“ [F] Upload File    {Colors.CYAN}โ”‚  {Colors.MAGENTA}๐Ÿ’ฌ [T] Chat Input{Colors.CYAN}    โ•‘
โ•‘  {Colors.OKCYAN}โš™๏ธ  [C] Configure        {Colors.CYAN}โ”‚  {Colors.YELLOW}๐Ÿ“Š [H] History        {Colors.CYAN}โ”‚  {Colors.FAIL}โŒ [Q] Quit{Colors.CYAN}         โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}๐Ÿค– Current Pipeline Mode: {pipeline_mode}{Colors.CYAN}                          โ•‘
โ•‘  {Colors.BOLD}๐Ÿ—‚๏ธ  Codebase Indexing: {index_status}{Colors.CYAN}                                    โ•‘
โ•‘  {Colors.BOLD}๐Ÿ“„ Document Processing: {segmentation_mode}{Colors.CYAN}                               โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.YELLOW}๐Ÿ“ URL Processing:{Colors.CYAN}                                                         โ•‘
โ•‘  {Colors.YELLOW}   โ–ถ Enter research paper URL (arXiv, IEEE, ACM, etc.)                    {Colors.CYAN}โ•‘
โ•‘  {Colors.YELLOW}   โ–ถ Supports direct PDF links and academic paper pages                   {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.PURPLE}๐Ÿ“ File Processing:{Colors.CYAN}                                                        โ•‘
โ•‘  {Colors.PURPLE}   โ–ถ Upload PDF, DOCX, PPTX, HTML, or TXT files                          {Colors.CYAN}โ•‘
โ•‘  {Colors.PURPLE}   โ–ถ Intelligent file format detection and processing                     {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.MAGENTA}๐Ÿ’ฌ Chat Input:{Colors.CYAN}                                                           โ•‘
โ•‘  {Colors.MAGENTA}   โ–ถ Describe your coding requirements in natural language                {Colors.CYAN}โ•‘
โ•‘  {Colors.MAGENTA}   โ–ถ AI generates implementation plan and code automatically             {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKCYAN}๐Ÿ”„ Processing Pipeline:{Colors.CYAN}                                                    โ•‘
โ•‘  {Colors.OKCYAN}   โ–ถ Intelligent agent orchestration โ†’ Code synthesis                     {Colors.CYAN}โ•‘
โ•‘  {Colors.OKCYAN}   โ–ถ Multi-agent coordination with progress tracking                     {Colors.CYAN}โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(menu)

    def get_user_input(self):
        """Get user input with styled prompt"""
        print(f"\n{Colors.BOLD}{Colors.OKCYAN}โžค Your choice: {Colors.ENDC}", end="")
        return input().strip().lower()

    def upload_file_gui(self) -> Optional[str]:
        """Enhanced file upload interface with better error handling"""
        if not self.tkinter_available:
            self.print_status(
                "GUI file dialog not available - using manual input", "warning"
            )
            return self._get_manual_file_path()

        def select_file():
            try:
                import tkinter as tk
                from tkinter import filedialog

                root = tk.Tk()
                root.withdraw()
                root.attributes("-topmost", True)

                file_types = [
                    ("Research Papers", "*.pdf;*.docx;*.doc"),
                    ("PDF Files", "*.pdf"),
                    ("Word Documents", "*.docx;*.doc"),
                    ("PowerPoint Files", "*.pptx;*.ppt"),
                    ("HTML Files", "*.html;*.htm"),
                    ("Text Files", "*.txt;*.md"),
                    ("All Files", "*.*"),
                ]

                if platform.system() == "Darwin":
                    file_types = [
                        ("Research Papers", ".pdf .docx .doc"),
                        ("PDF Files", ".pdf"),
                        ("Word Documents", ".docx .doc"),
                        ("PowerPoint Files", ".pptx .ppt"),
                        ("HTML Files", ".html .htm"),
                        ("Text Files", ".txt .md"),
                        ("All Files", ".*"),
                    ]

                file_path = filedialog.askopenfilename(
                    title="Select Research File - DeepCode CLI",
                    filetypes=file_types,
                    initialdir=os.getcwd(),
                )

                root.destroy()
                return file_path

            except Exception as e:
                self.print_status(f"File dialog error: {str(e)}", "error")
                return self._get_manual_file_path()

        self.print_status("Opening file browser dialog...", "upload")
        file_path = select_file()

        if file_path:
            self.print_status(
                f"File selected: {os.path.basename(file_path)}", "success"
            )
            return file_path
        else:
            self.print_status("No file selected", "warning")
            return None

    def _get_manual_file_path(self) -> Optional[str]:
        """Get file path through manual input with validation"""
        self.print_separator("โ”€", 79, Colors.YELLOW)
        print(f"{Colors.BOLD}{Colors.YELLOW}๐Ÿ“ Manual File Path Input{Colors.ENDC}")
        print(
            f"{Colors.CYAN}Please enter the full path to your research paper file:{Colors.ENDC}"
        )
        print(
            f"{Colors.CYAN}Supported formats: PDF, DOCX, PPTX, HTML, TXT, MD{Colors.ENDC}"
        )
        self.print_separator("โ”€", 79, Colors.YELLOW)

        while True:
            print(f"\n{Colors.BOLD}{Colors.OKCYAN}๐Ÿ“‚ File path: {Colors.ENDC}", end="")
            file_path = input().strip()

            if not file_path:
                self.print_status(
                    "Empty path entered. Please try again or press Ctrl+C to cancel.",
                    "warning",
                )
                continue

            file_path = os.path.expanduser(file_path)
            file_path = os.path.abspath(file_path)

            if not os.path.exists(file_path):
                self.print_status(f"File not found: {file_path}", "error")
                retry = (
                    input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}")
                    .strip()
                    .lower()
                )
                if retry != "y":
                    return None
                continue

            if not os.path.isfile(file_path):
                self.print_status(f"Path is not a file: {file_path}", "error")
                continue

            supported_extensions = {
                ".pdf",
                ".docx",
                ".doc",
                ".pptx",
                ".ppt",
                ".html",
                ".htm",
                ".txt",
                ".md",
            }
            file_ext = os.path.splitext(file_path)[1].lower()

            if file_ext not in supported_extensions:
                self.print_status(f"Unsupported file format: {file_ext}", "warning")
                proceed = (
                    input(f"{Colors.YELLOW}Process anyway? (y/n): {Colors.ENDC}")
                    .strip()
                    .lower()
                )
                if proceed != "y":
                    continue

            self.print_status(
                f"File validated: {os.path.basename(file_path)}", "success"
            )
            return file_path

    def get_url_input(self) -> str:
        """Enhanced URL input with validation"""
        self.print_separator("โ”€", 79, Colors.GREEN)
        print(f"{Colors.BOLD}{Colors.GREEN}๐ŸŒ URL Input Interface{Colors.ENDC}")
        print(
            f"{Colors.CYAN}Enter a research paper URL from supported platforms:{Colors.ENDC}"
        )
        print(
            f"{Colors.CYAN}โ€ข arXiv (arxiv.org)        โ€ข IEEE Xplore (ieeexplore.ieee.org){Colors.ENDC}"
        )
        print(
            f"{Colors.CYAN}โ€ข ACM Digital Library      โ€ข SpringerLink โ€ข Nature โ€ข Science{Colors.ENDC}"
        )
        print(
            f"{Colors.CYAN}โ€ข Direct PDF links         โ€ข Academic publisher websites{Colors.ENDC}"
        )
        self.print_separator("โ”€", 79, Colors.GREEN)

        while True:
            print(f"\n{Colors.BOLD}{Colors.OKCYAN}๐Ÿ”— URL: {Colors.ENDC}", end="")
            url = input().strip()

            if not url:
                self.print_status(
                    "Empty URL entered. Please try again or press Ctrl+C to cancel.",
                    "warning",
                )
                continue

            if not url.startswith(("http://", "https://")):
                self.print_status("URL must start with http:// or https://", "error")
                retry = (
                    input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}")
                    .strip()
                    .lower()
                )
                if retry != "y":
                    return ""
                continue

            academic_domains = [
                "arxiv.org",
                "ieeexplore.ieee.org",
                "dl.acm.org",
                "link.springer.com",
                "nature.com",
                "science.org",
                "scholar.google.com",
                "researchgate.net",
                "semanticscholar.org",
            ]

            is_academic = any(domain in url.lower() for domain in academic_domains)
            if not is_academic and not url.lower().endswith(".pdf"):
                self.print_status(
                    "URL doesn't appear to be from a known academic platform", "warning"
                )
                proceed = (
                    input(f"{Colors.YELLOW}Process anyway? (y/n): {Colors.ENDC}")
                    .strip()
                    .lower()
                )
                if proceed != "y":
                    continue

            self.print_status(f"URL validated: {url}", "success")
            return url

    def get_chat_input(self) -> str:
        """Enhanced chat input interface for coding requirements"""
        self.print_separator("โ”€", 79, Colors.PURPLE)
        print(f"{Colors.BOLD}{Colors.PURPLE}๐Ÿ’ฌ Chat Input Interface{Colors.ENDC}")
        print(
            f"{Colors.CYAN}Describe your coding requirements in natural language.{Colors.ENDC}"
        )
        print(
            f"{Colors.CYAN}Our AI will analyze your needs and generate a comprehensive implementation plan.{Colors.ENDC}"
        )
        self.print_separator("โ”€", 79, Colors.PURPLE)

        # Display examples to help users
        print(f"\n{Colors.BOLD}{Colors.YELLOW}๐Ÿ’ก Examples:{Colors.ENDC}")
        print(f"{Colors.CYAN}Academic Research:{Colors.ENDC}")
        print(
            "  โ€ข 'I need to implement a reinforcement learning algorithm for robotic control'"
        )
        print(
            "  โ€ข 'Create a neural network for image classification with attention mechanisms'"
        )
        print(f"{Colors.CYAN}Engineering Projects:{Colors.ENDC}")
        print(
            "  โ€ข 'Develop a web application for project management with user authentication'"
        )
        print("  โ€ข 'Create a data visualization dashboard for sales analytics'")
        print(f"{Colors.CYAN}Mixed Projects:{Colors.ENDC}")
        print(
            "  โ€ข 'Implement a machine learning model with a web interface for real-time predictions'"
        )

        self.print_separator("โ”€", 79, Colors.PURPLE)

        print(
            f"\n{Colors.BOLD}{Colors.OKCYAN}โœ๏ธ  Enter your coding requirements below:{Colors.ENDC}"
        )
        print(
            f"{Colors.YELLOW}(Type your description, press Enter twice when finished, or Ctrl+C to cancel){Colors.ENDC}"
        )

        lines = []
        empty_line_count = 0

        while True:
            try:
                if len(lines) == 0:
                    print(f"{Colors.BOLD}> {Colors.ENDC}", end="")
                else:
                    print(f"{Colors.BOLD}  {Colors.ENDC}", end="")

                line = input()

                if line.strip() == "":
                    empty_line_count += 1
                    if empty_line_count >= 2:
                        # Two consecutive empty lines means user finished input
                        break
                    lines.append("")  # Keep empty line for formatting
                else:
                    empty_line_count = 0
                    lines.append(line)

            except KeyboardInterrupt:
                print(f"\n{Colors.WARNING}Input cancelled by user{Colors.ENDC}")
                return ""

        # Join all lines and clean up
        user_input = "\n".join(lines).strip()

        if not user_input:
            self.print_status("No input provided", "warning")
            return ""

        if len(user_input) < 20:
            self.print_status(
                "Input too short. Please provide more detailed requirements (at least 20 characters)",
                "warning",
            )
            retry = (
                input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}").strip().lower()
            )
            if retry == "y":
                return self.get_chat_input()  # Recursive call for retry
            return ""

        # Display input summary
        word_count = len(user_input.split())
        char_count = len(user_input)

        print(f"\n{Colors.BOLD}{Colors.GREEN}๐Ÿ“‹ Input Summary:{Colors.ENDC}")
        print(f"  โ€ข {Colors.CYAN}Word count: {word_count}{Colors.ENDC}")
        print(f"  โ€ข {Colors.CYAN}Character count: {char_count}{Colors.ENDC}")

        # Show preview
        preview = user_input[:200] + "..." if len(user_input) > 200 else user_input
        print(f"\n{Colors.BOLD}{Colors.CYAN}๐Ÿ“„ Preview:{Colors.ENDC}")
        print(f"{Colors.YELLOW}{preview}{Colors.ENDC}")

        # Confirm with user
        confirm = (
            input(
                f"\n{Colors.BOLD}{Colors.OKCYAN}Proceed with this input? (y/n): {Colors.ENDC}"
            )
            .strip()
            .lower()
        )
        if confirm != "y":
            retry = (
                input(f"{Colors.YELLOW}Edit input? (y/n): {Colors.ENDC}")
                .strip()
                .lower()
            )
            if retry == "y":
                return self.get_chat_input()  # Recursive call for retry
            return ""

        self.print_status(
            f"Chat input captured: {word_count} words, {char_count} characters",
            "success",
        )
        return user_input

    def show_progress_bar(self, message: str, duration: float = 2.0):
        """Show animated progress bar"""
        print(f"\n{Colors.BOLD}{Colors.CYAN}{message}{Colors.ENDC}")

        bar_length = 50
        for i in range(bar_length + 1):
            percent = (i / bar_length) * 100
            filled = "โ–ˆ" * i
            empty = "โ–‘" * (bar_length - i)

            print(
                f"\r{Colors.OKGREEN}[{filled}{empty}] {percent:3.0f}%{Colors.ENDC}",
                end="",
                flush=True,
            )
            time.sleep(duration / bar_length)

        print(f"\n{Colors.OKGREEN}โœ“ {message} completed{Colors.ENDC}")

    def show_spinner(self, message: str, duration: float = 1.0):
        """Show spinner animation"""
        spinner_chars = "โ ‹โ ™โ นโ ธโ ผโ ดโ ฆโ งโ ‡โ "
        end_time = time.time() + duration

        print(
            f"{Colors.BOLD}{Colors.CYAN}{message}... {Colors.ENDC}", end="", flush=True
        )

        i = 0
        while time.time() < end_time:
            print(
                f"\r{Colors.BOLD}{Colors.CYAN}{message}... {Colors.YELLOW}{spinner_chars[i % len(spinner_chars)]}{Colors.ENDC}",
                end="",
                flush=True,
            )
            time.sleep(0.1)
            i += 1

        print(
            f"\r{Colors.BOLD}{Colors.CYAN}{message}... {Colors.OKGREEN}โœ“{Colors.ENDC}"
        )

    def display_processing_stages(
        self,
        current_stage: int = 0,
        enable_indexing: bool = True,
        chat_mode: bool = False,
    ):
        """Display processing pipeline stages with current progress"""
        if chat_mode:
            # Chat mode - simplified workflow for user requirements
            stages = [
                ("๐Ÿš€", "Initialize", "Setting up chat engine"),
                ("๐Ÿ’ฌ", "Planning", "Analyzing requirements"),
                ("๐Ÿ—๏ธ", "Setup", "Creating workspace"),
                ("๐Ÿ“", "Save Plan", "Saving implementation plan"),
                ("โš™๏ธ", "Implement", "Generating code"),
            ]
            pipeline_mode = "CHAT PLANNING"
        elif enable_indexing:
            # Full pipeline with all stages
            stages = [
                ("๐Ÿš€", "Initialize", "Setting up AI engine"),
                ("๐Ÿ“Š", "Analyze", "Analyzing research content"),
                ("๐Ÿ“ฅ", "Download", "Processing document"),
                ("๐Ÿ“‹", "Plan", "Generating code architecture"),
                ("๐Ÿ”", "References", "Analyzing references"),
                ("๐Ÿ“ฆ", "Repos", "Downloading repositories"),
                ("๐Ÿ—‚๏ธ", "Index", "Building code index"),
                ("โš™๏ธ", "Implement", "Implementing code"),
            ]
            pipeline_mode = "COMPREHENSIVE"
        else:
            # Fast mode - skip indexing related stages
            stages = [
                ("๐Ÿš€", "Initialize", "Setting up AI engine"),
                ("๐Ÿ“Š", "Analyze", "Analyzing research content"),
                ("๐Ÿ“ฅ", "Download", "Processing document"),
                ("๐Ÿ“‹", "Plan", "Generating code architecture"),
                ("โš™๏ธ", "Implement", "Implementing code"),
            ]
            pipeline_mode = "OPTIMIZED"

        print(
            f"\n{Colors.BOLD}{Colors.CYAN}๐Ÿ“‹ {pipeline_mode} PIPELINE STATUS{Colors.ENDC}"
        )
        self.print_separator("โ”€", 79, Colors.CYAN)

        for i, (icon, name, desc) in enumerate(stages):
            if i < current_stage:
                status = f"{Colors.OKGREEN}โœ“ COMPLETED{Colors.ENDC}"
            elif i == current_stage:
                status = f"{Colors.YELLOW}โณ IN PROGRESS{Colors.ENDC}"
            else:
                status = f"{Colors.CYAN}โธ๏ธ  PENDING{Colors.ENDC}"

            print(
                f"{icon} {Colors.BOLD}{name:<12}{Colors.ENDC} โ”‚ {desc:<25} โ”‚ {status}"
            )

        self.print_separator("โ”€", 79, Colors.CYAN)

    def print_results_header(self):
        """Print results section header"""
        header = f"""
{Colors.BOLD}{Colors.OKGREEN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                              PROCESSING RESULTS                              โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(header)

    def print_error_box(self, title: str, error_msg: str):
        """Print formatted error box"""
        print(
            f"\n{Colors.FAIL}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—"
        )
        print(f"โ•‘ {Colors.BOLD}ERROR: {title:<50}{Colors.FAIL} โ•‘")
        print("โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ")

        words = error_msg.split()
        lines = []
        current_line = ""

        for word in words:
            if len(current_line + word) <= 54:
                current_line += word + " "
            else:
                lines.append(current_line.strip())
                current_line = word + " "
        if current_line:
            lines.append(current_line.strip())

        for line in lines:
            print(f"โ•‘ {line:<56} โ•‘")

        print(
            f"โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}"
        )

    def cleanup_cache(self):
        """ๆธ…็†Python็ผ“ๅญ˜ๆ–‡ไปถ / Clean up Python cache files"""
        try:
            self.print_status("Cleaning up cache files...", "info")
            # ๆธ…็†__pycache__็›ฎๅฝ•
            os.system('find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null')
            # ๆธ…็†.pycๆ–‡ไปถ
            os.system('find . -name "*.pyc" -delete 2>/dev/null')
            self.print_status("Cache cleanup completed", "success")
        except Exception as e:
            self.print_status(f"Cache cleanup failed: {e}", "warning")

    def print_goodbye(self):
        """Print goodbye message"""
        # ๆธ…็†็ผ“ๅญ˜ๆ–‡ไปถ
        self.cleanup_cache()

        goodbye = f"""
{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                GOODBYE                                        โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘  {Colors.OKGREEN}๐ŸŽ‰ Thank you for using DeepCode CLI!                                     {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.YELLOW}๐Ÿงฌ Join our community in revolutionizing research reproducibility         {Colors.CYAN}โ•‘
โ•‘  {Colors.PURPLE}โšก Together, we're building the future of automated code generation       {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKCYAN}๐Ÿ’ก Questions? Contribute to our open-source mission at GitHub             {Colors.CYAN}โ•‘
โ•‘  {Colors.GREEN}๐Ÿงน Cache files cleaned up for optimal performance                         {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(goodbye)

    def ask_continue(self) -> bool:
        """Ask if user wants to continue with another paper"""
        self.print_separator("โ”€", 79, Colors.YELLOW)
        print(f"\n{Colors.BOLD}{Colors.YELLOW}๐Ÿ”„ Process another paper?{Colors.ENDC}")
        choice = input(f"{Colors.OKCYAN}Continue? (y/n): {Colors.ENDC}").strip().lower()
        return choice in ["y", "yes", "1", "true"]

    def add_to_history(self, input_source: str, result: dict):
        """Add processing result to history"""
        entry = {
            "timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
            "input_source": input_source,
            "status": result.get("status", "unknown"),
            "result": result,
        }
        self.processing_history.append(entry)

    def show_history(self):
        """Display processing history"""
        if not self.processing_history:
            self.print_status("No processing history available", "info")
            return

        print(f"\n{Colors.BOLD}{Colors.CYAN}๐Ÿ“š PROCESSING HISTORY{Colors.ENDC}")
        self.print_separator("โ”€", 79, Colors.CYAN)

        for i, entry in enumerate(self.processing_history, 1):
            status_icon = "โœ…" if entry["status"] == "success" else "โŒ"
            source = entry["input_source"]
            if len(source) > 50:
                source = source[:47] + "..."

            print(f"{i}. {status_icon} {entry['timestamp']} | {source}")

        self.print_separator("โ”€", 79, Colors.CYAN)

    def show_configuration_menu(self):
        """Show configuration options menu"""
        self.clear_screen()

        # Get segmentation config status
        segmentation_enabled = getattr(self, "segmentation_enabled", True)
        segmentation_threshold = getattr(self, "segmentation_threshold", 50000)

        print(f"""
{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                           CONFIGURATION MENU                                  โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}๐Ÿค– Agent Orchestration Engine Configuration{Colors.CYAN}                             โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKCYAN}[1] Pipeline Mode:{Colors.CYAN}                                                        โ•‘
โ•‘      {Colors.BOLD}๐Ÿง  Comprehensive Mode{Colors.CYAN} - Full intelligence analysis (Default)         โ•‘
โ•‘         โœ“ Research Analysis + Resource Processing                            โ•‘
โ•‘         โœ“ Reference Intelligence Discovery                                   โ•‘
โ•‘         โœ“ Automated Repository Acquisition                                   โ•‘
โ•‘         โœ“ Codebase Intelligence Orchestration                               โ•‘
โ•‘         โœ“ Intelligent Code Implementation Synthesis                         โ•‘
โ•‘                                                                               โ•‘
โ•‘      {Colors.BOLD}โšก Optimized Mode{Colors.CYAN} - Fast processing (Skip indexing)                    โ•‘
โ•‘         โœ“ Research Analysis + Resource Processing                            โ•‘
โ•‘         โœ“ Code Architecture Synthesis                                        โ•‘
โ•‘         โœ“ Intelligent Code Implementation Synthesis                         โ•‘
โ•‘         โœ— Reference Intelligence Discovery (Skipped)                        โ•‘
โ•‘         โœ— Repository Acquisition (Skipped)                                   โ•‘
โ•‘         โœ— Codebase Intelligence Orchestration (Skipped)                     โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKCYAN}[2] Document Processing:{Colors.CYAN}                                                   โ•‘
โ•‘      {Colors.BOLD}๐Ÿ“„ Smart Segmentation{Colors.CYAN} - Intelligent document analysis (Default)      โ•‘
โ•‘         โœ“ Semantic boundary detection                                        โ•‘
โ•‘         โœ“ Algorithm integrity preservation                                   โ•‘
โ•‘         โœ“ Formula chain recognition                                          โ•‘
โ•‘         โœ“ Adaptive character limits                                          โ•‘
โ•‘                                                                               โ•‘
โ•‘      {Colors.BOLD}๐Ÿ“‹ Traditional Processing{Colors.CYAN} - Full document reading                       โ•‘
โ•‘         โœ“ Complete document analysis                                         โ•‘
โ•‘         โœ— Smart segmentation (Disabled)                                      โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.YELLOW}Current Settings:{Colors.CYAN}                                                         โ•‘
โ•‘    Pipeline: {'๐Ÿง  Comprehensive Mode' if self.enable_indexing else 'โšก Optimized Mode'}                                          โ•‘
โ•‘    Document: {'๐Ÿ“„ Smart Segmentation' if segmentation_enabled else '๐Ÿ“‹ Traditional Processing'}                                โ•‘
โ•‘    Threshold: {segmentation_threshold} characters                                    โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKGREEN}[T] Toggle Pipeline    {Colors.BLUE}[S] Toggle Segmentation    {Colors.FAIL}[B] Back{Colors.CYAN}     โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
""")

        while True:
            print(
                f"\n{Colors.BOLD}{Colors.OKCYAN}โžค Configuration choice: {Colors.ENDC}",
                end="",
            )
            choice = input().strip().lower()

            if choice in ["t", "toggle"]:
                self.enable_indexing = not self.enable_indexing
                mode = "๐Ÿง  Comprehensive" if self.enable_indexing else "โšก Optimized"
                self.print_status(f"Pipeline mode switched to: {mode}", "success")
                time.sleep(1)
                self.show_configuration_menu()
                return

            elif choice in ["s", "segmentation"]:
                current_state = getattr(self, "segmentation_enabled", True)
                self.segmentation_enabled = not current_state
                seg_mode = (
                    "๐Ÿ“„ Smart Segmentation"
                    if self.segmentation_enabled
                    else "๐Ÿ“‹ Traditional Processing"
                )
                self.print_status(
                    f"Document processing switched to: {seg_mode}", "success"
                )
                time.sleep(1)
                self.show_configuration_menu()
                return

            elif choice in ["b", "back"]:
                return

            else:
                self.print_status(
                    "Invalid choice. Please enter 'T', 'S', or 'B'.", "warning"
                )