//! Frontend-agnostic progress reporting (plan §3.2).
//!
//! Core (providers, agent loop, engine) emits [`Event`]s through a [`Progress`]
//! sink; each front-end renders them its own way — the CLI with an indicatif
//! spinner, the web app over SSE, MCP/tests with [`NoopProgress`].

#[derive(Debug, Clone)]
pub enum Event {
    /// A tool/command invocation (Read/Grep/Write, or a raw-model tool name)
    /// with a short target (a file path or search pattern).
    Tool { name: String, target: String },
    /// A wiki page was created or updated (path relative to the wiki dir).
    Page { path: String },
    /// Assistant prose / intent narration.
    Note(String),
}

impl Event {
    pub fn tool(name: impl Into<String>, target: impl Into<String>) -> Event {
        Event::Tool {
            name: name.into(),
            target: target.into(),
        }
    }
    pub fn page(path: impl Into<String>) -> Event {
        Event::Page { path: path.into() }
    }
    pub fn note(text: impl Into<String>) -> Event {
        Event::Note(text.into())
    }
}

/// A sink for progress events. Implemented per front-end.
pub trait Progress: Send + Sync {
    fn event(&self, ev: Event);
}

/// Discards all events — for MCP, non-interactive runs, and tests.
pub struct NoopProgress;

impl Progress for NoopProgress {
    fn event(&self, _ev: Event) {}
}
