agent_m/agentm/theme/generate_theme_css.py

30 lines
852 B
Python

from agentm.theme.palette import get_theme
from pathlib import Path
import re
# Load dark theme instance
theme = get_theme("dark")
# Path setup
base_path = Path(__file__).parent
template_path = base_path / "styles.base.tcss"
output_path = base_path / "styles.tcss"
# Load template
template = template_path.read_text()
# Find all placeholders like {{FOREGROUND}}, {{BACKGROUND}}, etc.
tokens = set(re.findall(r"{{\s*([A-Z0-9_]+)\s*}}", template))
# Replace them with actual values from theme
for token in tokens:
value = getattr(theme, token, None)
if value is not None:
template = template.replace(f"{{{{{token}}}}}", value)
else:
print(f"⚠️ Warning: Theme token '{token}' not found in ThemeManager")
# Write final output
output_path.write_text(template)
print(f"✅ Synced themed CSS written to: {output_path}")