文件预览

review_output.py

查看 Founder Signal 技能包中的文件内容。

文件内容

src/founder_signal/review_output.py

"""Helpers for Founder Signal human-review outputs."""

from __future__ import annotations

from typing import Any, Mapping

_DRAFT_PREVIEW_BASE_URL = "https://draft.innosage.co/preview"


def review_url(artifact: Mapping[str, Any]) -> str:
    explicit_url = str(artifact.get("draft_public_url") or artifact.get("draft_url") or "").strip()
    if explicit_url:
        return explicit_url
    page_id = str(artifact.get("draft_page_id") or "").strip()
    if page_id:
        return f"{_DRAFT_PREVIEW_BASE_URL}/{page_id}"
    return ""


def human_review_ready(artifact: Mapping[str, Any]) -> bool:
    if not bool(artifact.get("draft_public_publish_succeeded") or artifact.get("draft_published")):
        return False
    return bool(review_url(artifact))


def human_review_message(artifact: Mapping[str, Any]) -> str:
    url = review_url(artifact)
    if not url:
        return ""
    return f"Draft review/public page: {url}"