from __future__ import annotations

from datetime import datetime, timezone
from pathlib import Path
from typing import Any


def distill_draft(
    atoms_text: list[str],
    *,
    tag: str = "习惯",
    project: str = "global",
) -> dict[str, Any]:
    """自主蒸馏骨架 — 规则合并 atom 为 SKILL 草稿（待 Console 审核）。"""
    merged = "；".join(t[:120] for t in atoms_text[-10:])
    name = f"distilled-{tag}-{project}".replace("/", "-")[:48]
    body = f"""---
name: {name}
description: 从记忆碎片蒸馏的{tag}习惯（草稿）
enabled: false
triggers: [chat, assist, export]
priority: 5
origin: niannian-distiller
---

# {tag}习惯（蒸馏草稿）

{merged}

> 自动生成于 {datetime.now(timezone.utc).isoformat()}，请审核后启用。
"""
    return {"name": name, "content": body, "confidence": 0.75, "atom_count": len(atoms_text)}
