36 lines
946 B
Python
36 lines
946 B
Python
import sys
|
|
import re
|
|
from pathlib import Path
|
|
from agentm.theme.palette import get_theme
|
|
|
|
# Check for --silent in command-line arguments
|
|
silent = "--silent" in sys.argv
|
|
|
|
# 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 tokens
|
|
for token in tokens:
|
|
value = getattr(theme, token, None)
|
|
if value is not None:
|
|
template = template.replace(f"{{{{{token}}}}}", value)
|
|
elif not silent:
|
|
print(f"⚠️ Warning: Theme token '{token}' not found in ThemeManager")
|
|
|
|
# Write final output
|
|
output_path.write_text(template)
|
|
|
|
if not silent:
|
|
print(f"✅ Synced themed CSS written to: {output_path}")
|