AI-powered DevOps assistant with Plan/Build modes
Project description
OpsPilot - AI-powered DevOps Assistant
OpsPilot is a sophisticated CLI tool for DevOps operations with AI assistance, similar to OpenCode or Claude Code but specialized for DevOps tasks.
Note: This project now features a full Textual TUI with split-screen interface! The simple CLI fallback is available if Textual is not installed.
Features
๐ง Simple Authentication
- Choose your AI provider (OpenAI, ZhipuAI, Anthropic, or OpenRouter)
- Provide your API key for the selected provider
- Automatic model selection for Plan/Build modes
- OpenRouter: Access to 100+ models from various providers
๐ Plan Mode vs Build Mode
- Plan Mode: Safe planning with reasoning models (GLM-4-Plus, GPT-4)
- Build Mode: Action-oriented with fast models (GLM-4-Flash, GPT-3.5)
- Toggle between modes with Tab key
๐ฅ๏ธ Split-Screen TUI Interface
- Left Pane (30%): Chat history with user/AI messages
- Right Pane (70%): Terminal output, logs, and markdown rendering
- Footer: Current mode, model name, authentication status, token usage, and cost
๐ก๏ธ Safety Gates
- Automatic detection of dangerous commands (
rm,kubectl apply,systemctl, etc.) - Confirmation dialogs before executing risky operations
- Secure subprocess execution with timeout controls
๐พ Session Management
- Persistent conversation history
- Export sessions (JSON, Markdown, TXT)
- Session search and organization
Installation
# Clone the repository
git clone https://github.com/cyber-goka/opspilot.git
cd opspilot
# Install OpsPilot
pip install -e .
Or use the installation script:
python install.py
Quick Start
# Install OpsPilot
pip install -e .
# Configure your API key (first time setup)
opspilot config --edit
# Start the TUI application
opspilot start
# Start with specific mode
opspilot start --mode build
# Load existing session
opspilot start --session <session-id>
# View configuration
opspilot config --show
# List sessions
opspilot sessions --list
# Show usage statistics
opspilot stats
Configuration
OpsPilot uses ~/.opspilot/config.yaml for configuration:
Configuration Example
auth:
provider: zhipu # Choose: openai, zhipu, anthropic, or openrouter
api_key: your-api-key-here
Note: When using OpenRouter, you get access to models from multiple providers through a single API key. Popular models include GPT-4, Claude, Gemini, and many others.
Environment Variables
You can also set configuration via environment variables:
export OPSPILOT_API_KEY="your-api-key"
export OPSPILOT_PROVIDER="zhipu" # openai, zhipu, anthropic, or openrouter
Getting API Keys
- OpenAI: https://platform.openai.com/api-keys
- ZhipuAI: https://open.bigmodel.cn/
- Anthropic: https://console.anthropic.com/
- OpenRouter: https://openrouter.ai/keys (provides access to 100+ models)
Usage Examples
Plan Mode - Safe Planning
User: Help me deploy a Django application to Kubernetes
Assistant: I'll help you plan the Django deployment to Kubernetes. Let me analyze your current setup first.
[Reads Dockerfile, requirements.txt, current directory structure]
Based on my analysis, here's your deployment plan:
## Phase 1: Container Preparation
1. Optimize Dockerfile for production
2. Create .dockerignore file
3. Build and test container locally
## Phase 2: Kubernetes Manifests
1. Create Deployment manifest
2. Create Service manifest
3. Create Ingress configuration
4. Add ConfigMaps for environment variables
## Phase 3: Deployment Strategy
1. Create namespace
2. Apply ConfigMaps first
3. Deploy application
4. Configure monitoring
Switch to Build Mode (Ctrl+T) to execute this plan.
Build Mode - Action Execution
User: Create the Kubernetes deployment manifest
Assistant: I'll create a Kubernetes deployment manifest for your Django application.
[Creates deployment.yaml with optimized settings]
โ
Created deployment.yaml with:
- 3 replicas with rolling updates
- Resource limits and requests
- Health checks configured
- Environment variables from ConfigMap
The deployment is ready. Would you like me to apply it to the cluster?
CLI Commands
Start Application
opspilot start [OPTIONS]
--session, -s TEXT Session ID to load
--mode, -m TEXT Start mode (plan|build)
--config, -c TEXT Custom config file path
Configuration Management
opspilot config [OPTIONS]
--show, -s Show current configuration
--edit, -e Edit configuration file
--reset, -r Reset to defaults
Session Management
opspilot sessions [OPTIONS]
--list, -l List all sessions
--delete, -d TEXT Delete session by ID
--export, -e TEXT Export session by ID
--format, -f TEXT Export format (json|markdown|txt)
Usage Statistics
opspilot stats
# Shows token usage, cost, request count, and context size
Architecture
opspilot/
โโโ opspilot/
โ โโโ __init__.py # Package initialization
โ โโโ main.py # CLI entry point
โ โโโ config.py # Configuration management
โ โโโ agent/
โ โ โโโ core.py # Agent Think-Act loop
โ โ โโโ memory.py # Chat history
โ โ โโโ tools/
โ โ โโโ system.py # Shell execution
โ โ โโโ files.py # File operations
โ โโโ tui/
โ โโโ app.py # TUI application
โ โโโ screens.py # Modal dialogs
โ โโโ styles.tcss # CSS styling
โโโ pyproject.toml # Package configuration
โโโ requirements.txt # Dependencies
โโโ install.py # Installation script
โโโ README.md # Documentation
Development
Setup Development Environment
# Clone repository
git clone https://github.com/cyber-goka/opspilot.git
cd opspilot
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run with type checking
mypy opspilot/
# Format code
black opspilot/
Project Structure
- Agent Core: Think-Act loop with mode switching
- Tools System: Secure file and shell operations
- Memory Management: Persistent conversation history
- TUI Framework: Rich terminal interface with Textual
- Configuration: Flexible authentication and model settings
Safety Features
Dangerous Command Detection
OpsPilot automatically detects and confirms commands containing:
- File deletion:
rm,delete,del - System changes:
systemctl,service,init - Container operations:
kubectl apply,docker rm - Permission changes:
chmod 777,chown - System administration:
sudo,passwd,crontab
Secure Execution
- Timeout controls for all commands
- Working directory restrictions
- Process isolation and cleanup
- Comprehensive error handling
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions
OpsPilot - Your AI-powered DevOps companion ๐
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opspilot-0.2.1.tar.gz.
File metadata
- Download URL: opspilot-0.2.1.tar.gz
- Upload date:
- Size: 58.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b7290b95e9760a8c2f2da0f4f42470c7a75a33c6bb1a0d4ed96cbade4e6e54e
|
|
| MD5 |
8ee866f95b12c9ef40d92b1306217bfa
|
|
| BLAKE2b-256 |
c35d4e5d8e8219dfc9f0740fcc845067ec8cd901c9bfb62fc7023131ea6f452d
|
File details
Details for the file opspilot-0.2.1-py3-none-any.whl.
File metadata
- Download URL: opspilot-0.2.1-py3-none-any.whl
- Upload date:
- Size: 66.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c13e09df7f402d3aec8b6b0a39cf6686be23100947eb3921e720335e0d1196ad
|
|
| MD5 |
9abf81c4a366a01b1d8533d0896e2abd
|
|
| BLAKE2b-256 |
8da0d857f72b89b13a3a1427edc77b0347e308a8cc44578b78af9fad13ff689c
|