import os
import yaml

CONFIG_DIR = os.path.expanduser("~/.terminal_voice")
CONFIG_FILE = os.path.join(CONFIG_DIR, "config.yaml")

def load_config():
    if not os.path.exists(CONFIG_FILE):
        return {"rules": {}}

    with open(CONFIG_FILE) as f:
        return yaml.safe_load(f)

def save_config(config):
    os.makedirs(CONFIG_DIR, exist_ok=True)

    with open(CONFIG_FILE, "w") as f:
        yaml.dump(config, f)
