"""Token 系统目录 — state/system/token/（客户端持久化 · budget 共用）。"""

from __future__ import annotations

from pathlib import Path

from niannian.users.paths import user_root


def token_system_root(home: Path) -> Path:
    root = home / "state" / "system" / "token"
    root.mkdir(parents=True, exist_ok=True)
    return root


def token_budget_path(home: Path) -> Path:
    return token_system_root(home) / "budget.yaml"


def token_usage_file(home: Path) -> Path:
    return token_system_root(home) / "usage.jsonl"


def user_token_budget_path(home: Path, user_id: str) -> Path:
    return user_root(home, user_id) / "token" / "budget.yaml"
