Architecture

CLIAI follows a modular architecture designed for reliability and extensibility.

Core Components

Orchestrator

Central coordinator managing AI providers and request routing.

Intent Classifier

Determines the type of request (command, question, explanation).

Context Gatherer

Collects system information for better responses.

Command Validator

Multi-layer validation with security checks.

Execution Engine

Safe command execution with multiple modes.

Performance Monitor

Tracks metrics and system health.

Circuit Breakers

Automatic failover between providers.

Request Flow

User Input
    ↓
Intent Classification
    ↓
Context Gathering
    ↓
AI Provider (Ollama/OpenAI/Anthropic)
    ↓
Command Validation
    ↓
Safety Checks
    ↓
Execution (Manual/Auto/Dry-run)

Provider Management

CLIAI uses a sophisticated provider management system:

  • Priority-based routing: Local first, cloud fallback
  • Circuit breakers: Prevent repeated failures
  • Retry logic: Automatic retries with backoff
  • Performance monitoring: Track response times
  • Health checks: Verify provider availability