//! dirigent_anth — Claude Code Session Parser & Toolkit
//!
//! Reads Claude Code's local JSONL session storage and produces typed,
//! deduplicated, correlated Rust data structures.
//!
//! # Design
//!
//! See `docs/superpowers/plans/2026-03-23-dirigent-ant-design.md`

pub mod claude_grab;
pub mod anth_usage;
pub mod correlation;
pub mod dedup;
pub mod discovery;
pub mod error;
pub mod noise;
pub mod parser;
pub mod subagent;
pub mod tree;
pub mod types;
pub mod util;

/// Load and fully parse a session: dedup, correlate, tree, subagents.
pub fn load_session(session_ref: &types::SessionRef) -> error::Result<types::ParsedSession> {
    let messages = parser::parse_session_deduped(&session_ref.jsonl_path)?;
    let tree = tree::ConversationTree::build(&messages);
    let tool_exchanges = correlation::correlate_tools(&messages);
    let mut subagents = if let Some(ref dir) = session_ref.artifacts_dir {
        subagent::load_subagents(dir)?
    } else {
        Vec::new()
    };
    subagent::link_subagents_to_calls(&mut subagents, &tool_exchanges);

    Ok(types::ParsedSession {
        messages,
        tree,
        tool_exchanges,
        subagents,
    })
}

pub use correlation::correlate_tools;
pub use dedup::dedup_messages;
pub use discovery::{decode_project_path, discover_claude_home, discover_projects, discover_sessions, resolve_original_path};
pub use error::{AntError, Result};
pub use noise::{classify_noise, NoiseKind};
pub use parser::{parse_line, parse_session, parse_session_deduped};
pub use subagent::{link_subagents_to_calls, load_subagents};
pub use tree::{message_parent_uuid, message_uuid, ConversationNode, ConversationTree};
pub use types::*;
pub use util::parse_timestamp;
