# identity.py
import json
import os

IDENTITY_PATH = os.getenv("IDENTITY_PATH", "identity.json")

def load_identity():
    """
    Load Lyra's identity/persona definition from identity.json.
    Returns a dict or None if missing/invalid.
    """

    if not os.path.exists(IDENTITY_PATH):
        print(f"[Identity] identity.json not found at {IDENTITY_PATH}")
        return None

    try:
        with open(IDENTITY_PATH, "r", encoding="utf-8") as f:
            data = json.load(f)
            print(f"[Identity] Loaded identity from {IDENTITY_PATH}")
            return data
    except Exception as e:
        print(f"[Identity] Failed to load identity.json: {e}")
        return None
