"""
{{ display_name }} - Main automation module.

This module defines the AI analysis automation that uses LLM
to analyze content through multiple stages.
"""

from torivers_sdk import Automation, AutomationMetadata
from torivers_sdk.automation import END, START, StateGraph

from nodes import analyze, extract, summarize
from state import {{ class_name }}State


class {{ class_name }}(Automation[{{ class_name }}State]):
    """{{ display_name }} AI analysis automation."""

    def metadata(self) -> AutomationMetadata:
        """Load automation metadata from YAML manifest."""
        return AutomationMetadata.from_yaml("automation.yaml")

    def get_state_class(self) -> type[{{ class_name }}State]:
        """Return the state class for this automation."""
        return {{ class_name }}State

    def build_graph(self) -> StateGraph:
        """Build the AI analysis workflow.

        Analysis stages:
        1. summarize - Generate content summary
        2. analyze - Perform sentiment and topic analysis
        3. extract - Extract key entities and insights
        """
        graph = StateGraph({{ class_name }}State)

        # Add analysis stages
        graph.add_node("summarize", summarize)
        graph.add_node("analyze", analyze)
        graph.add_node("extract", extract)

        # Define analysis flow
        graph.add_edge(START, "summarize")
        graph.add_edge("summarize", "analyze")
        graph.add_edge("analyze", "extract")
        graph.add_edge("extract", END)

        return graph


# Export the automation class for discovery
automation = {{ class_name }}
