Spaces:
Runtime error

File size: 3,894 Bytes
8ab5cfe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
utils.py β€” Terminal colors, banner, and small helper utilities.
"""

import textwrap


# ── ANSI color codes ──────────────────────────────────────────────────────────

class C:
    RESET   = "\033[0m"
    BOLD    = "\033[1m"
    DIM     = "\033[2m"
    # Colors
    CYAN    = "\033[96m"
    GREEN   = "\033[92m"
    YELLOW  = "\033[93m"
    RED     = "\033[91m"
    MAGENTA = "\033[95m"
    BLUE    = "\033[94m"
    WHITE   = "\033[97m"
    GREY    = "\033[90m"


def banner():
    """Prints the Vidya V3 terminal banner."""
    print(f"\n{C.CYAN}{C.BOLD}")
    print("╔══════════════════════════════════════════════════════╗")
    print("β•‘          VIDYA V3 β€” REAL-TIME AI TUTOR               β•‘")
    print("β•‘     Powered by Gemini  β€’  Cognitive Apprenticeship   β•‘")
    print("β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•")
    print(f"{C.RESET}")


def print_tutor(text: str, phase: str):
    """Prints the tutor response with phase label."""
    phase_colors = {
        "MODEL":    C.BLUE,
        "COACH":    C.GREEN,
        "SCAFFOLD": C.YELLOW,
        "FADE":     C.MAGENTA,
    }
    color = phase_colors.get(phase, C.CYAN)
    phase_label = f"[{phase}]"

    wrapped = textwrap.fill(text, width=72)
    print(f"\n{color}{C.BOLD}πŸŽ“ Vidya {phase_label}{C.RESET}")
    print(f"{C.WHITE}{wrapped}{C.RESET}\n")


def print_debug(signals: dict, phase_reason: str = ""):
    """Prints debug signal info in dim grey."""
    active = [k for k, v in signals.items() if v]
    signal_str = ", ".join(active) if active else "none"
    print(f"{C.GREY}[DEBUG] signals={signal_str}", end="")
    if phase_reason:
        print(f"  |  phase_reason={phase_reason}", end="")
    print(f"{C.RESET}")


def print_suggestion(action: str):
    """Prints the suggested next action."""
    print(f"{C.CYAN}πŸ’‘ Next: {action}{C.RESET}")


def print_warning(msg: str):
    print(f"{C.YELLOW}⚠️  {msg}{C.RESET}")


def print_error(msg: str):
    print(f"{C.RED}❌ {msg}{C.RESET}")


def print_success(msg: str):
    print(f"{C.GREEN}βœ… {msg}{C.RESET}")


def count_words(text: str) -> int:
    return len(text.split())


def prompt_choice(label: str, choices: list[str]) -> str:
    """
    Prompts the user to pick from a numbered list.
    Returns the chosen string value.
    """
    print(f"\n{C.CYAN}{label}{C.RESET}")
    for i, choice in enumerate(choices, 1):
        print(f"  {C.BOLD}{i}.{C.RESET} {choice}")

    while True:
        raw = input(f"{C.YELLOW}Enter number (1-{len(choices)}): {C.RESET}").strip()
        if raw.isdigit() and 1 <= int(raw) <= len(choices):
            selected = choices[int(raw) - 1]
            print(f"  β†’ {C.GREEN}{selected}{C.RESET}")
            return selected
        print_warning(f"Please enter a number between 1 and {len(choices)}.")


def prompt_float(label: str, lo: float, hi: float) -> float:
    """Prompts the user for a float in [lo, hi]."""
    while True:
        raw = input(f"{C.YELLOW}{label} ({lo}–{hi}): {C.RESET}").strip()
        try:
            val = float(raw)
            if lo <= val <= hi:
                return val
            print_warning(f"Value must be between {lo} and {hi}.")
        except ValueError:
            print_warning("Please enter a decimal number like 0.3 or 0.8.")


def prompt_text(label: str) -> str:
    """Prompts the user for a non-empty string."""
    while True:
        raw = input(f"{C.YELLOW}{label}: {C.RESET}").strip()
        if raw:
            return raw
        print_warning("This field cannot be empty.")