"""프롬프트 YAML 로더. app/prompts/*.yaml 을 읽어 dict 로 제공한다."""
from __future__ import annotations

from functools import lru_cache
from pathlib import Path
from typing import Any

import yaml

PROMPTS_DIR = Path(__file__).resolve().parent


@lru_cache(maxsize=None)
def load(name: str) -> dict[str, Any]:
    path = PROMPTS_DIR / f"{name}.yaml"
    with open(path, encoding="utf-8") as f:
        return yaml.safe_load(f) or {}


def get(name: str, key: str) -> str:
    value = load(name).get(key, "")
    return value.rstrip("\n") if isinstance(value, str) else value
