"""Output formatting utilities for valn8n."""

from valn8n_lib.types import Diagnostic


def format_diagnostic_text(d: Diagnostic) -> str:
    """Format a single diagnostic as a text line."""
    parts = [d.file]
    if d.location:
        parts.append(f'node:"{d.location.node_name}"')
        if d.location.field_path:
            parts.append(d.location.field_path)
    parts_str = ":".join(parts)
    line_suffix = f" (line {d.line})" if d.line is not None else ""
    return f"{parts_str}: {d.code} {d.code.severity.value}: {d.message}{line_suffix}"
