AI-Enhanced Universal Script Runner with automatic error fixing
Project description
AIRun ๐
AI-Enhanced Universal Script Runner with Automatic Error Fixing
AIRun is a powerful command-line tool that can execute scripts in multiple languages (Python, Shell, Node.js, PHP) with intelligent AI-powered error detection and automatic fixing capabilities.
โจ Features
- ๐ Universal Script Execution - One command for Python, Shell, Node.js, and PHP scripts
- ๐ค AI-Powered Error Fixing - Automatic detection and fixing of common errors
- ๐ฏ Smart Language Detection - Automatically detects script type from extension, shebang, or content
- ๐ Multiple LLM Support - Works with Ollama (local), OpenAI, Claude/Anthropic
- โก Real-time Error Handling - Fixes errors during execution with configurable retry attempts
- ๐ก๏ธ Safe Execution - Creates backups before applying fixes
- ๐ Detailed Analysis - Comprehensive script analysis and diagnostics
- ๐๏ธ Highly Configurable - Project-specific and global configuration support
๐ Quick Start
Installation
Option 1: Using pip (when published)
pip install airun
Option 2: From source
# Clone the repository
git clone https://github.com/yourusername/airun.git
cd airun
# Install with Poetry
poetry install
poetry shell
# Or install with pip
pip install -e .
Option 3: One-line installer
curl -sSL https://raw.githubusercontent.com/yourusername/airun/main/scripts/install.sh | bash
Setup Ollama (for local AI)
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Start Ollama service
ollama serve
# Download Code Llama model
ollama pull codellama:7b
Initialize Configuration
# Create default configuration
airun config --init
# Check system status
airun doctor
๐ Usage Examples
Basic Script Execution
# Auto-detect and run Python script
airun my_script.py
# Auto-detect and run shell script
airun deploy.sh production
# Force specific language
airun --lang=nodejs app.js
# Run with arguments
airun data_processor.py --input data.csv --output results.json
AI-Enhanced Error Fixing
# Run with automatic error fixing (default)
airun broken_script.py
# Disable automatic fixing
airun --no-fix risky_script.sh
# Interactive mode (confirm before applying fixes)
airun --interactive debug_me.py
# Specify LLM provider
airun --llm=openai:gpt-4 complex_script.py
airun --llm=ollama:codellama:13b performance_critical.py
Analysis and Debugging
# Analyze script without execution
airun analyze my_script.py
# Dry run (validate and show execution plan)
airun run --dry-run script.py
# Verbose output for debugging
airun run --verbose script.py
# Generate analysis report
airun analyze --output=report.json --format=json script.py
Batch Operations
# Run multiple scripts
airun batch script1.py script2.sh script3.js
# Parallel execution
airun batch --parallel *.py
# Stop on first error
airun batch --stop-on-error test_*.py
# Generate execution report
airun batch --report=results.html *.py
Configuration Management
# Show current configuration
airun config --show
# Edit configuration
airun config --edit
# Set configuration values
airun config --set auto_fix=false
airun config --set llm_providers.ollama.base_url=http://localhost:11434
๐ Real-World Examples
Example 1: Python Script with Syntax Error
broken_script.py:
import sys
import os
def process_data(filename):
with open(filename, 'r') as f:
data = f.read()
# Missing closing parenthesis - syntax error
result = data.replace('old', 'new'
return result
if __name__ == "__main__":
process_data(sys.argv[1])
Run with AIRun:
$ airun broken_script.py data.txt
๐ Executing broken_script.py (python)
โ Error detected: SyntaxError: unexpected EOF while parsing
๐ค Attempting AI fix...
๐ง Applied AI fix, retrying...
โ
Error fixed successfully!
Data processed successfully
โ
Execution completed in 1.23s
Example 2: Shell Script with Permission Issues
setup.sh:
#!/bin/bash
mkdir /opt/myapp
cp files/* /opt/myapp/
chmod +x /opt/myapp/start.sh
Run with AIRun:
$ airun setup.sh
๐ Executing setup.sh (shell)
โ Error detected: Permission denied
๐ค Attempting AI fix...
๐ง Applied AI fix, retrying...
# AI adds 'sudo' where needed
โ
Error fixed successfully!
โ
Execution completed in 2.45s
Example 3: Node.js with Missing Dependencies
app.js:
const express = require('express');
const missingModule = require('missing-package');
const app = express();
app.listen(3000);
Run with AIRun:
$ airun app.js
๐ Executing app.js (nodejs)
โ Error detected: Cannot find module 'missing-package'
๐ค Attempting AI fix...
๐ง Applied AI fix, retrying...
# AI suggests removing unused import or installing package
โ
Error fixed successfully!
Server running on port 3000
โ
Execution completed in 3.12s
โ๏ธ Configuration
Global Configuration
AIRun uses ~/.airun/config.yaml for global settings:
# Core Settings
auto_fix: true
interactive_mode: false
timeout: 300
max_retries: 3
# Default LLM Provider
default_llm: "ollama:codellama"
# LLM Providers
llm_providers:
ollama:
base_url: "http://localhost:11434"
models:
python: "codellama:7b"
shell: "codellama:7b"
nodejs: "codellama:7b"
php: "codellama:7b"
openai:
api_key: "${OPENAI_API_KEY}"
model: "gpt-4"
claude:
api_key: "${ANTHROPIC_API_KEY}"
model: "claude-3-sonnet-20240229"
# Script Runners
runners:
python:
executable: "python3"
flags: ["-u"]
shell:
executable: "bash"
flags: []
nodejs:
executable: "node"
flags: []
php:
executable: "php"
flags: []
Project-Specific Configuration
Create .airunner.yaml in your project directory:
# Override global settings for this project
default_llm: "openai:gpt-4"
auto_fix: true
runners:
python:
executable: "python3.11"
flags: ["-u", "-X", "dev"]
nodejs:
executable: "node"
flags: ["--experimental-modules"]
# Custom prompts for this project
prompts:
python:
system: "You are debugging a Django web application. Consider Django patterns and best practices."
Environment Variables
Override configuration with environment variables:
export AIRUN_AUTO_FIX=false
export AIRUN_DEFAULT_LLM="openai:gpt-4"
export AIRUN_TIMEOUT=600
export OPENAI_API_KEY="your-api-key"
export ANTHROPIC_API_KEY="your-claude-key"
๐ง Advanced Usage
Custom Model Configuration
# Use specific Ollama model
airun --llm=ollama:codellama:13b large_script.py
# Use OpenAI with specific model
airun --llm=openai:gpt-4-turbo complex_analysis.py
# Use Claude for shell scripts
airun --llm=claude:claude-3-opus advanced_deploy.sh
Integration with CI/CD
.github/workflows/ai-test.yml:
name: AI-Enhanced Testing
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup AIRun
run: |
curl -sSL https://raw.githubusercontent.com/yourusername/airun/main/scripts/install.sh | bash
airun doctor
- name: Run tests with AI fixing
run: |
airun batch --report=test_results.html test_*.py
airun batch --parallel --max-retries=1 integration_tests/*.sh
IDE Integration
VS Code Task (.vscode/tasks.json):
{
"version": "2.0.0",
"tasks": [
{
"label": "AIRun: Execute Current File",
"type": "shell",
"command": "airun",
"args": ["${file}"],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
}
]
}
๐ ๏ธ Development
Setup Development Environment
# Clone repository
git clone https://github.com/yourusername/airun.git
cd airun
# Setup development environment
make dev-setup
# Run tests
make test
# Run linting
make lint
# Build package
make build
Running Tests
# Run all tests
make test
# Run with coverage
make test-coverage
# Run specific test file
pytest tests/test_detector.py -v
# Run integration tests (requires real interpreters)
pytest tests/ -m integration
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and add tests
- Run the test suite:
make test - Submit a pull request
๐ Comparison with Other Tools
| Feature | AIRun | Traditional Runners | Other AI Tools |
|---|---|---|---|
| Multi-language support | โ | โ | โ ๏ธ |
| Auto error fixing | โ | โ | โ ๏ธ |
| Local AI support | โ | โ | โ |
| Script analysis | โ | โ | โ ๏ธ |
| Backup/restore | โ | โ | โ |
| Batch execution | โ | โ ๏ธ | โ |
| Configuration flexibility | โ | โ ๏ธ | โ ๏ธ |
๐จ Safety Features
- Automatic Backups: Creates backups before applying any fixes
- Confirmation Prompts: Interactive mode asks before applying changes
- Rollback Capability: Can restore original files if fixes fail
- Dry Run Mode: Analyze and validate without execution
- Configurable Limits: Set maximum retry attempts and timeouts
๐ค Supported LLM Providers
Ollama (Local)
- Models: CodeLlama, Mistral, Llama 2, custom models
- Benefits: Free, private, offline capable
- Setup:
ollama pull codellama:7b
OpenAI
- Models: GPT-4, GPT-4 Turbo, GPT-3.5 Turbo
- Benefits: High quality, fast response
- Setup: Set
OPENAI_API_KEYenvironment variable
Anthropic (Claude)
- Models: Claude 3 Sonnet, Claude 3 Opus
- Benefits: Excellent reasoning, safety-focused
- Setup: Set
ANTHROPIC_API_KEYenvironment variable
๐ Documentation
๐ Troubleshooting
Common Issues
1. "Unable to determine script type"
# Use --lang to force detection
airun --lang=python ambiguous_file.txt
2. "Required executable not found"
# Check system status
airun doctor
# Install missing interpreters
# Ubuntu/Debian: apt install python3 nodejs php-cli
# macOS: brew install python node php
3. "Ollama connection failed"
# Check if Ollama is running
curl http://localhost:11434/api/tags
# Start Ollama
ollama serve
# Pull required model
ollama pull codellama:7b
4. "AI fix failed"
# Try different model
airun --llm=openai:gpt-4 script.py
# Use interactive mode
airun --interactive script.py
# Disable AI fixing for debugging
airun --no-fix script.py
Getting Help
# System diagnosis
airun doctor
# View logs
airun logs --days=7
# Verbose execution
airun run --verbose script.py
# Get configuration template
airun config --init
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Ollama for local LLM capabilities
- OpenAI for GPT models
- Anthropic for Claude models
- Click for CLI framework
- All contributors and users of this project
โญ Star History
Made with โค๏ธ by the AIRun team
If you find AIRun useful, please consider giving it a star โญ and sharing it with others!
AIRun Project Tree Structure
๐ Current Project Structure (as tree command output)
airun/
โโโ README.md โ
COMPLETE
โโโ LICENSE โ MISSING
โโโ CONTRIBUTING.md โ
COMPLETE
โโโ CHANGELOG.md โ MISSING
โโโ CODE_OF_CONDUCT.md โ MISSING
โโโ pyproject.toml โ
COMPLETE
โโโ poetry.lock โ GENERATED (after poetry install)
โโโ Makefile โ
COMPLETE
โโโ Dockerfile โ
COMPLETE
โโโ docker-compose.yml โ
COMPLETE
โโโ .gitignore โ MISSING
โโโ .pre-commit-config.yaml โ MISSING
โโโ .dockerignore โ MISSING
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml โ
COMPLETE
โ โโโ release.yml โ MISSING
โ โโโ ISSUE_TEMPLATE/
โ โโโ bug_report.md โ MISSING
โ โโโ feature_request.md โ MISSING
โ โโโ config.yml โ MISSING
โโโ airun/
โ โโโ __init__.py โ
COMPLETE
โ โโโ __main__.py โ MISSING
โ โโโ cli.py โ
COMPLETE (needs imports fix)
โ โโโ core/
โ โ โโโ __init__.py โ MISSING
โ โ โโโ detector.py โ
COMPLETE
โ โ โโโ runners.py โ
COMPLETE
โ โ โโโ config.py โ
COMPLETE
โ โ โโโ llm_router.py โ MISSING
โ โ โโโ ai_fixer.py โ MISSING
โ โโโ providers/
โ โ โโโ __init__.py โ MISSING
โ โ โโโ base.py โ MISSING
โ โ โโโ ollama.py โ MISSING
โ โ โโโ openai.py โ MISSING
โ โ โโโ claude.py โ MISSING
โ โโโ utils/
โ โ โโโ __init__.py โ MISSING
โ โ โโโ file_ops.py โ MISSING
โ โ โโโ logging.py โ MISSING
โ โ โโโ validation.py โ MISSING
โ โ โโโ analyzer.py โ MISSING
โ โ โโโ batch_executor.py โ MISSING
โ โ โโโ log_viewer.py โ MISSING
โ โ โโโ cleaner.py โ MISSING
โ โ โโโ examples.py โ MISSING
โ โโโ templates/
โ โ โโโ prompts/
โ โ โ โโโ python.txt โ MISSING
โ โ โ โโโ shell.txt โ MISSING
โ โ โ โโโ nodejs.txt โ MISSING
โ โ โ โโโ php.txt โ MISSING
โ โ โโโ config/
โ โ โโโ default.yaml โ MISSING
โ โโโ web/ โ OPTIONAL (future enhancement)
โ โโโ __init__.py
โ โโโ app.py
โ โโโ templates/
โโโ tests/
โ โโโ __init__.py โ MISSING
โ โโโ conftest.py โ MISSING
โ โโโ test_detector.py โ
COMPLETE
โ โโโ test_runners.py โ
COMPLETE
โ โโโ test_config.py โ
COMPLETE
โ โโโ test_cli.py โ
COMPLETE (needs imports fix)
โ โโโ test_llm_router.py โ MISSING
โ โโโ fixtures/
โ โ โโโ scripts/
โ โ โ โโโ test.py โ GENERATED (by Makefile)
โ โ โ โโโ test.sh โ GENERATED (by Makefile)
โ โ โ โโโ test.js โ GENERATED (by Makefile)
โ โ โ โโโ test.php โ GENERATED (by Makefile)
โ โ โ โโโ broken_python.py โ GENERATED (by Makefile)
โ โ โ โโโ broken_shell.sh โ GENERATED (by Makefile)
โ โ โ โโโ broken_node.js โ GENERATED (by Makefile)
โ โ โ โโโ broken_php.php โ GENERATED (by Makefile)
โ โ โโโ configs/
โ โ โโโ test_config.yaml โ MISSING
โ โโโ integration/
โ โโโ __init__.py โ MISSING
โ โโโ test_end_to_end.py โ MISSING
โ โโโ test_ollama_integration.py โ MISSING
โโโ docs/
โ โโโ index.md โ MISSING
โ โโโ installation.md โ MISSING
โ โโโ configuration.md โ MISSING
โ โโโ usage.md โ MISSING
โ โโโ api/
โ โ โโโ core.md โ MISSING
โ โ โโโ providers.md โ MISSING
โ โโโ examples/
โ โ โโโ basic_usage.md โ MISSING
โ โ โโโ advanced_config.md โ MISSING
โ โโโ mkdocs.yml โ MISSING
โโโ scripts/
โ โโโ install.sh โ MISSING
โ โโโ setup_ollama.sh โ MISSING
โ โโโ setup_dev.sh โ MISSING
โ โโโ release.sh โ MISSING
โ โโโ benchmark.py โ MISSING
โ โโโ profile_runner.py โ MISSING
โ โโโ stress_test.py โ MISSING
โ โโโ memory_test.py โ MISSING
โ โโโ seed_data.py โ MISSING
โโโ examples/
โ โโโ config_examples/
โ โ โโโ minimal.yaml โ MISSING
โ โ โโโ full_featured.yaml โ MISSING
โ โ โโโ team_config.yaml โ MISSING
โ โโโ broken_scripts/
โ โ โโโ syntax_error.py โ MISSING
โ โ โโโ missing_deps.js โ MISSING
โ โ โโโ permission_error.sh โ MISSING
โ โโโ demo/
โ โโโ run_demo.py โ MISSING
โ โโโ showcase.sh โ MISSING
โโโ monitoring/ โ OPTIONAL
โ โโโ prometheus.yml
โ โโโ grafana/
โ โโโ dashboards/
โ โโโ datasources/
โโโ nginx/ โ OPTIONAL
โ โโโ nginx.conf
โ โโโ ssl/
โโโ babel.cfg โ OPTIONAL (i18n)
๐ง Files That Need to be Created/Fixed
๐จ CRITICAL (Required for basic functionality)
Missing Core Modules:
airun/core/__init__.pyairun/core/llm_router.py- LLM provider routing logicairun/core/ai_fixer.py- AI error fixing implementationairun/providers/- Complete LLM provider implementationsairun/utils/- All utility modulesairun/__main__.py- Entry point forpython -m airun
Missing Configuration Files:
.gitignore- Git ignore patterns.pre-commit-config.yaml- Pre-commit hooksLICENSE- MIT License fileairun/templates/config/default.yaml- Default configuration
Missing Test Infrastructure:
tests/__init__.pyandtests/conftest.pytests/test_llm_router.py- LLM router teststests/fixtures/configs/test_config.yaml- Test configuration
โ ๏ธ IMPORTANT (Required for full functionality)
CLI Import Fixes:
- Fix imports in
airun/cli.py- Missing imports for new modules - Fix imports in
tests/test_cli.py- Test import issues
Installation Scripts:
scripts/install.sh- Production installation scriptscripts/setup_ollama.sh- Ollama setup automationscripts/setup_dev.sh- Development environment setup
Documentation:
docs/mkdocs.yml- MkDocs configurationCHANGELOG.md- Version historyCODE_OF_CONDUCT.md- Community guidelines
๐ NICE TO HAVE (Enhancement features)
GitHub Templates:
.github/ISSUE_TEMPLATE/- Issue templates.github/workflows/release.yml- Release automation
Examples and Demos:
examples/- Example configurations and scriptsscripts/benchmark.py- Performance benchmarking
Advanced Features:
airun/web/- Web interface (future)monitoring/- Monitoring configurations (optional)
๐ ๏ธ Files That Need Fixes
airun/cli.py Import Issues:
# Missing imports that need to be added:
from .core.llm_router import LLMRouter
from .core.ai_fixer import AIFixer
from .utils.logging import setup_logging, get_logger
from .utils.validation import validate_script_path, validate_llm_provider
from .utils.analyzer import ScriptAnalyzer
from .utils.batch_executor import BatchExecutor
from .utils.log_viewer import LogViewer
from .utils.cleaner import DataCleaner
from .utils.examples import ExampleGenerator
tests/test_cli.py Import Issues:
# Missing imports that need to be added:
from airun2.utils.analyzer import ScriptAnalyzer
from airun2.utils.batch_executor import BatchExecutor
โก Priority Order for Creation
Phase 1: Core Functionality (MUST HAVE)
- Create all
__init__.pyfiles - Implement
airun/core/llm_router.py - Implement
airun/core/ai_fixer.py - Implement
airun/providers/modules - Create
.gitignoreand basic config files - Fix CLI imports
Phase 2: Essential Utils (SHOULD HAVE)
- Implement
airun/utils/modules - Create test infrastructure files
- Create installation scripts
- Create basic documentation
Phase 3: Polish & Enhancement (NICE TO HAVE)
- Create examples and demos
- Add GitHub templates
- Create monitoring and advanced features
๐ Quick Start Commands
# After creating missing files, run:
make dev-setup # Will generate test fixtures
poetry install # Will create poetry.lock
make create-test-scripts # Will create test script fixtures
make doctor # Will validate setup
This structure provides a clear roadmap for completing the AIRun project with all necessary components.
Project details
Release history Release notifications | RSS feed
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 airun-0.1.1.tar.gz.
File metadata
- Download URL: airun-0.1.1.tar.gz
- Upload date:
- Size: 49.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.4 Linux/6.14.9-300.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3a91b2eeed39d1f759b7f5f2cce4e3f286ac5bb09cd451c2504fc91cc80f744
|
|
| MD5 |
826765dd8582236429ee09db25e296d0
|
|
| BLAKE2b-256 |
8e50753a18d0c05c5c5adae4de8f3fd6da9f6f8d891bd9f7e2899d75181cca63
|
File details
Details for the file airun-0.1.1-py3-none-any.whl.
File metadata
- Download URL: airun-0.1.1-py3-none-any.whl
- Upload date:
- Size: 51.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.4 Linux/6.14.9-300.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2ab2da4be4179734c618471d11c7234a6e953ea316bbdf295bacd77d0022c8d
|
|
| MD5 |
7c0608d8d57ac6b57333904eed6c5cfa
|
|
| BLAKE2b-256 |
53aeccb6f81cfa7862330eebaa6db9c7638a1c40dc1343f0cea493c63cd99381
|