CLI AI Agent to run and schedule commands with natural language using AI
execAI is a powerful command-line tool that lets you execute system commands and schedule tasks using natural language descriptions. Powered by AI and LangGraph, it provides a secure, intuitive interface for system administration and task automation.
- Natural Language Processing: Describe what you want to do in plain English
- AI-Powered Command Interpretation: Uses GPT-4 to understand and convert requests to system commands
- Secure Execution: Safe mode with command validation and user confirmation
- Task Scheduling: Support for one-time and recurring tasks with cron expressions
- Rich CLI Interface: Beautiful terminal output with tables, panels, and progress indicators
- Comprehensive Logging: Detailed logging and error recovery mechanisms
- Environment Configuration: Secure configuration management with
.envsupport
- Python 3.8+
- OpenAI API key
- Unix-like system (Linux, macOS)
# Clone the repository
git clone https://github.com/yourusername/execai.git
cd execai
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .
# Install development dependencies (optional)
pip install -e .[dev]- Copy the environment template:
cp env.example .env- Edit
.envwith your configuration:
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4-turbo-preview
SAFE_MODE=true
CONFIRMATION_REQUIRED=true# Simple command execution
execai run "list all files in the current directory"
# Skip confirmation (use with caution)
execai run "show system information" --force
# Dry run (preview without execution)
execai run "create a backup of my documents" --dry-run# Schedule a one-time task
execai run "backup my home directory tomorrow at 2 AM" --schedule
# Schedule recurring tasks
execai run "clean temporary files every day at midnight" --schedule
# Using cron expressions
execai run "update system packages every Sunday at 3 AM" --scheduleexecai schedules# Pause a schedule
execai pause <schedule-id>
# Resume a schedule
execai resume <schedule-id>
# Cancel a schedule
execai cancel <schedule-id>execai statusexecai configexecai version--verbose, -v: Enable verbose output--debug: Enable debug mode--force, -f: Skip confirmation prompts--dry-run, -d: Show what would be executed without running--schedule, -s: Schedule command instead of running immediately
By default, execAI runs in safe mode, which:
- Restricts execution to a whitelist of safe commands
- Requires confirmation for potentially dangerous operations
- Validates all commands before execution
- Logs all activities for audit purposes
The system validates commands through multiple layers:
- AI Safety Assessment: GPT-4 evaluates command safety
- Whitelist Checking: Commands are checked against safe command lists
- User Confirmation: Dangerous commands require explicit confirmation
- Execution Monitoring: Real-time monitoring of command execution
- Secure storage of API keys and secrets
- Environment variable encryption
- Configurable execution timeouts
- Process isolation and cleanup
# Check system resources
execai run "show me CPU and memory usage"
# Find large files
execai run "find files larger than 100MB in my home directory"
# Check disk space
execai run "show disk space usage for all mounted filesystems"# Organize files
execai run "organize my Downloads folder by file type"
# Create backups
execai run "create a compressed backup of my Documents folder"
# Find and clean temporary files
execai run "find and remove temporary files older than 7 days"# Daily backups
execai run "backup my important files to external drive every day at 11 PM" --schedule
# Weekly cleanup
execai run "clean up temporary files and logs every Sunday at 2 AM" --schedule
# Monthly reports
execai run "generate system usage report on the first day of each month" --schedule# Run all tests
pytest
# Run with coverage
pytest --cov=src/execai
# Run specific test category
pytest tests/unit/
pytest tests/integration/tests/
βββ unit/ # Unit tests
β βββ domain/ # Domain entity tests
β βββ application/ # Application layer tests
β βββ infrastructure/ # Infrastructure tests
βββ integration/ # Integration tests
βββ fixtures/ # Test fixtures
execAI follows Domain-Driven Design (DDD) principles:
src/execai/
βββ domain/ # Core business logic
β βββ entities/ # Domain entities
β βββ services/ # Domain services
β βββ repositories/ # Repository interfaces
βββ application/ # Application layer
β βββ agents/ # LangGraph agents
β βββ usecases/ # Use cases
β βββ config/ # Configuration
βββ infrastructure/ # External concerns
β βββ ai/ # AI service integration
β βββ scheduler/ # Task scheduling
β βββ executor/ # Command execution
β βββ storage/ # Data persistence
βββ interfaces/ # User interfaces
βββ cli/ # Command-line interface
βββ api/ # HTTP API (future)
- Command Agent: LangGraph-based AI agent for natural language processing
- Command Executor: Secure command execution with monitoring
- Cron Scheduler: Task scheduling and cron job management
- Rich CLI: Beautiful terminal interface with Typer and Rich
# Install pre-commit hooks
pre-commit install
# Run linting
black src/ tests/
flake8 src/ tests/
mypy src/
# Run tests in watch mode
pytest-watchThe project uses:
- Black: Code formatting
- Flake8: Linting
- MyPy: Static type checking
- pytest: Testing framework
- pre-commit: Git hooks
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Ensure all tests pass:
pytest - Run linting:
black . && flake8 . && mypy . - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the GPT-4 API
- LangChain and LangGraph for the AI agent framework
- Typer and Rich for the beautiful CLI interface
- Pydantic for data validation and settings management
- Issues: GitHub Issues
- Email: [email protected]
This project is maintained with love! If you find execAI useful, consider buying me a coffee:
Your support helps keep this project alive and enables continuous improvements!
π Security: Never share your OpenAI API key or commit it to version control. Use environment variables and secure storage.