-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtdd_progress.py
More file actions
56 lines (42 loc) · 1.48 KB
/
Copy pathtdd_progress.py
File metadata and controls
56 lines (42 loc) · 1.48 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
"""TDD cycle mini progress bar for status display (#1035).
Builds a visual indicator showing current TDD phase progress:
[RED ● GREEN ○ REFACTOR ○]
Reads phase from CODINGBUDDY_TDD_PHASE env var or explicit argument.
"""
import os
from typing import Optional
# TDD phases in sequential order
TDD_PHASES = ["RED", "GREEN", "REFACTOR"]
# Display symbols
ACTIVE = "\u25cf" # ●
INACTIVE = "\u25cb" # ○
def build_tdd_indicator(
phase: Optional[str] = None,
cycle_count: Optional[int] = None,
) -> Optional[str]:
"""Build a one-line TDD cycle progress indicator.
Args:
phase: Current TDD phase (RED, GREEN, REFACTOR).
If None, reads from CODINGBUDDY_TDD_PHASE env var.
cycle_count: Number of completed TDD cycles. Appended as '#N'
when > 0.
Returns:
Formatted string like '[RED ● GREEN ○ REFACTOR ○]' or None
if no valid phase is active.
"""
if phase is None:
phase = os.environ.get("CODINGBUDDY_TDD_PHASE", "")
if not phase:
return None
phase = phase.upper().strip()
if phase not in TDD_PHASES:
return None
phase_index = TDD_PHASES.index(phase)
parts = []
for i, p in enumerate(TDD_PHASES):
symbol = ACTIVE if i <= phase_index else INACTIVE
parts.append(f"{p} {symbol}")
indicator = f"[{' '.join(parts)}]"
if cycle_count and cycle_count > 0:
indicator = f"{indicator} #{cycle_count}"
return indicator