cmdai/
lib.rs

1//! cmdai - Natural Language to Shell Command CLI Tool
2//!
3//! This library provides core functionality for converting natural language
4//! descriptions into safe, POSIX-compliant shell commands using local LLMs.
5//!
6//! # Core Modules
7//!
8//! - [`models`] - Core data types (CommandRequest, GeneratedCommand, enums)
9//! - [`safety`] - Safety validation with dangerous command detection
10//! - [`backends`] - Command generation backends (Embedded, Ollama, vLLM)
11//! - [`cli`] - CLI interface and argument parsing
12//! - [`cache`] - Model caching with integrity validation
13//! - [`config`] - Configuration management with TOML support
14//! - [`execution`] - Execution context capture and shell detection
15//! - [`logging`] - Structured logging with sensitive data redaction
16//!
17//! # Example
18//!
19//! ```no_run
20//! use cmdai::models::{CommandRequest, ShellType, SafetyLevel};
21//!
22//! let request = CommandRequest::new("list all files", ShellType::Bash)
23//!     .with_safety(SafetyLevel::Moderate);
24//! ```
25
26pub mod backends;
27pub mod cache;
28pub mod cli;
29pub mod config;
30pub mod execution;
31pub mod logging;
32pub mod model_loader;
33pub mod models;
34pub mod safety;
35
36// Re-export commonly used types for convenience
37pub use models::{
38    BackendInfo, BackendType, CacheManifest, CachedModel, CommandRequest, ConfigSchema,
39    ExecutionContext, GeneratedCommand, LogEntry, LogLevel, Platform, RiskLevel, SafetyLevel,
40    ShellType, UserConfiguration, UserConfigurationBuilder,
41};
42
43// Re-export infrastructure module types and errors
44pub use cache::{CacheError, CacheManager, CacheStats, IntegrityReport};
45pub use config::{ConfigError, ConfigManager};
46pub use execution::{ExecutionError, PlatformDetector, ShellDetector};
47pub use logging::{LogConfig, LogConfigBuilder, LogError, LogFormat, LogOutput, Logger, Redaction};
48pub use model_loader::ModelLoader;
49
50// Re-export backend types
51#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
52pub use backends::embedded::MlxBackend;
53pub use backends::embedded::{
54    CpuBackend, EmbeddedConfig, EmbeddedModelBackend, InferenceBackend, ModelVariant,
55};
56#[cfg(feature = "remote-backends")]
57pub use backends::remote::{OllamaBackend, VllmBackend};
58pub use backends::{BackendInfo as BackendInfoTrait, CommandGenerator, GeneratorError};