from __future__ import annotations

from app.core.agent.processes.v2.workflows.doc_update_from_feature.workflow_runtime.buffered_graph import (
    DocUpdateFromFeatureWorkflowGraph,
)
from app.core.agent.processes.v2.workflows.doc_update_from_feature.workflow_runtime.context import (
    DocUpdateFromFeatureContext,
)
from app.core.agent.processes.v2.workflows.doc_update_from_feature.steps.build_change_instructions_step import (
    BuildChangeInstructionsStep,
)
from app.core.agent.processes.v2.workflows.doc_update_from_feature.steps.build_change_plan_step import BuildChangePlanStep
from app.core.agent.processes.v2.workflows.doc_update_from_feature.steps.finalize_answer_step import FinalizeAnswerStep
from app.core.agent.processes.v2.workflows.doc_update_from_feature.steps.load_doc_rules_step import LoadDocRulesStep
from app.core.agent.processes.v2.workflows.doc_update_from_feature.steps.load_source_content_step import LoadSourceContentStep
from app.core.agent.processes.v2.workflows.doc_update_from_feature.steps.parse_feature_requirements_step import (
    ParseFeatureRequirementsStep,
)
from app.core.agent.processes.v2.workflows.doc_update_from_feature.steps.resolve_source_step import ResolveSourceStep
from app.core.agent.utils.llm import AgentLlmService


class DocUpdateFromFeatureGraph(DocUpdateFromFeatureWorkflowGraph[DocUpdateFromFeatureContext]):
    def __init__(self, llm: AgentLlmService, doc_rules_enabled: bool = True) -> None:
        super().__init__(
            workflow_id="v2.docs_update.from_feature",
            source="workflow.v2.docs_update.from_feature",
            steps=[
                ResolveSourceStep(),
                LoadSourceContentStep(),
                ParseFeatureRequirementsStep(),
                LoadDocRulesStep(),
                BuildChangePlanStep(llm=llm),
                BuildChangeInstructionsStep(llm=llm, doc_rules_enabled=doc_rules_enabled),
                FinalizeAnswerStep(),
            ],
        )
