import asyncio
from typing import Any

from ..utils.linear import comment_on_linear_issue


def linear_comment(comment_body: str, ticket_id: str) -> dict[str, Any]:
    """Post a comment to a Linear issue.

    Use this tool to communicate progress and completion to stakeholders on Linear.

    **When to use:**
    - After opening/updating a draft PR, post a comment on the Linear ticket to let
      stakeholders know the task is complete and include the PR link. For example:
      "I've completed the implementation and opened a PR: <pr_url>"
    - When answering a question or sharing an update (no code changes needed).

    Args:
        comment_body: Markdown-formatted comment text to post to the Linear issue.
        ticket_id: The Linear issue UUID to post the comment to.

    Returns:
        Dictionary with 'success' (bool) key.
    """
    success = asyncio.run(comment_on_linear_issue(ticket_id, comment_body))
    return {"success": success}
