//! Format detection for agent files
//!
//! Supports three agent file formats:
//! - `.agent.mdx`: Markdown with @directives (primary format)
//! - `.agent.ncl`: Pure Nickel configuration
//! - `.agent.md`: Legacy markdown with YAML frontmatter

use std::path::Path;

/// Agent file format
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AgentFormat {
    /// Markdown with @directives (.agent.mdx)
    MarkdownExtended,
    /// Pure Nickel (.agent.ncl)
    Nickel,
    /// Legacy markdown with YAML frontmatter (.agent.md)
    Markdown,
}

/// Format detector based on file extension
pub struct FormatDetector;

impl FormatDetector {
    /// Detect agent format from file path extension
    pub fn detect(path: &Path) -> Option<AgentFormat> {
        let filename = path.file_name()?.to_str()?;

        if filename.ends_with(".agent.mdx") {
            Some(AgentFormat::MarkdownExtended)
        } else if filename.ends_with(".agent.ncl") {
            Some(AgentFormat::Nickel)
        } else if filename.ends_with(".agent.md") {
            Some(AgentFormat::Markdown)
        } else {
            None
        }
    }
}
