Crate cmdai

Crate cmdai 

Source
Expand description

cmdai - Natural Language to Shell Command CLI Tool

This library provides core functionality for converting natural language descriptions into safe, POSIX-compliant shell commands using local LLMs.

§Core Modules

  • models - Core data types (CommandRequest, GeneratedCommand, enums)
  • safety - Safety validation with dangerous command detection
  • backends - Command generation backends (Embedded, Ollama, vLLM)
  • cli - CLI interface and argument parsing
  • cache - Model caching with integrity validation
  • config - Configuration management with TOML support
  • execution - Execution context capture and shell detection
  • logging - Structured logging with sensitive data redaction

§Example

use cmdai::models::{CommandRequest, ShellType, SafetyLevel};

let request = CommandRequest::new("list all files", ShellType::Bash)
    .with_safety(SafetyLevel::Moderate);

Re-exports§

pub use models::BackendInfo;
pub use models::BackendType;
pub use models::CacheManifest;
pub use models::CachedModel;
pub use models::CommandRequest;
pub use models::ConfigSchema;
pub use models::ExecutionContext;
pub use models::GeneratedCommand;
pub use models::LogEntry;
pub use models::LogLevel;
pub use models::Platform;
pub use models::RiskLevel;
pub use models::SafetyLevel;
pub use models::ShellType;
pub use models::UserConfiguration;
pub use models::UserConfigurationBuilder;
pub use cache::CacheError;
pub use cache::CacheManager;
pub use cache::CacheStats;
pub use cache::IntegrityReport;
pub use config::ConfigError;
pub use config::ConfigManager;
pub use execution::ExecutionError;
pub use execution::PlatformDetector;
pub use execution::ShellDetector;
pub use logging::LogConfig;
pub use logging::LogConfigBuilder;
pub use logging::LogError;
pub use logging::LogFormat;
pub use logging::LogOutput;
pub use logging::Logger;
pub use logging::Redaction;
pub use model_loader::ModelLoader;
pub use backends::embedded::CpuBackend;
pub use backends::embedded::EmbeddedConfig;
pub use backends::embedded::EmbeddedModelBackend;
pub use backends::embedded::InferenceBackend;
pub use backends::embedded::ModelVariant;
pub use backends::BackendInfo as BackendInfoTrait;
pub use backends::CommandGenerator;
pub use backends::GeneratorError;

Modules§

backends
cache
Cache module for managing Hugging Face model downloads and local storage
cli
config
Configuration module for managing user preferences and settings
execution
Execution module for capturing runtime context and shell detection
logging
Logging module with tracing integration and sensitive data redaction
model_loader
models
safety
Safety module - Command safety validation and risk assessment