sbom-tools 0.1.22

Semantic SBOM diff and analysis tool
Documentation
//! Rich TUI interface using ratatui.
//!
//! This module provides an interactive terminal UI for exploring
//! SBOM diffs and viewing SBOM contents.
//!
//! Two distinct TUI applications are available:
//! - `ViewApp` - For exploring a single SBOM with hierarchical navigation
//! - `App` (`DiffApp`) - For comparing SBOMs and viewing differences
//!
//! # Architecture
//!
//! The TUI follows a state machine pattern with the `ViewState` trait
//! enabling decomposition of the monolithic App into focused, testable views.
//! See `traits` module for the core abstractions.

mod app;
mod app_impl_constructors;
mod app_impl_items;
mod app_impl_nav;
mod app_impl_search;
mod app_states;
pub use app_states::PolicyPreset;
pub(crate) mod clipboard;
pub(crate) mod constants;
mod events;
pub(crate) mod export;
pub(crate) mod license_conflicts;
pub(crate) mod license_utils;
pub(crate) mod render_context;
pub(crate) mod security;
pub(crate) mod shared;
pub mod state;
#[cfg(test)]
pub(crate) mod test_support;
pub mod theme;
pub mod traits;
mod ui;
pub mod view;
pub(crate) mod view_states;
pub mod viewmodel;
pub(crate) mod views;
pub(crate) mod widgets;

// Theme exports
pub use theme::{
    ColorScheme, FooterHints, Styles, Theme, colors, current_theme_name, set_theme, toggle_theme,
};

// Trait exports for view state machines
pub use traits::{
    EventResult, ListViewState, OverlayKind, Shortcut, TabTarget, ViewContext, ViewMode, ViewState,
};

// Shared state exports
pub use state::{ListNavigation, ListState, TreeNavigation};

// ViewModel exports for shared TUI state management
pub use viewmodel::{
    CycleFilter, FilterState, LicenseCategory, OverlayState, QualityViewMode, QualityViewState,
    QuickFilter, RiskLevel, SearchState, SearchStateCore, SecurityFilterCriteria,
    SecurityFilterState, StatusMessage, ViewModelOverlayKind,
};

// Legacy/Diff TUI exports
pub use app::{App, AppMode, ModeStates, TabKind};
pub use events::Event;
pub use ui::run_tui;

// New View TUI exports
pub use view::{ViewApp, ViewTab, run_view_tui};

/// Map a detected [`BomProfile`](crate::model::BomProfile) to the
/// [`ScoringProfile`](crate::quality::ScoringProfile) the TUI scores it with.
///
/// This is the single source of truth for the profile mapping. All TUI scoring
/// sites (the `ViewApp` constructor, the `'P'` re-score handler, and the diff
/// constructors) route through it so the mapping cannot drift — in particular,
/// `AiBom` always activates the dedicated AI-readiness scoring/rendering path.
#[must_use]
pub(crate) const fn scoring_profile_for(
    profile: crate::model::BomProfile,
) -> crate::quality::ScoringProfile {
    use crate::model::BomProfile;
    use crate::quality::ScoringProfile;
    match profile {
        BomProfile::Cbom => ScoringProfile::Cbom,
        BomProfile::AiBom => ScoringProfile::AiReadiness,
        BomProfile::Sbom => ScoringProfile::Standard,
    }
}