"""Virtual Persona assembly — Chat character_block。"""

from __future__ import annotations


def build_character_assembly_block(profile_md: str) -> str:
    """将 profile.md 拼成 Chat 注入块。"""
    text = str(profile_md or "").strip()
    if not text:
        return ""
    title = "角色"
    for line in text.splitlines():
        stripped = line.strip()
        if stripped.startswith("# ") and not stripped.startswith("## "):
            title = stripped[2:].strip() or title
            break
    return f"[扮演·{title}]\n{text}"
