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.
pip install airun
# Clone the repository
git clone https://github.com/wronai/airun.git
cd airun
# Install with Poetry
poetry install
poetry shell
# Or install with pip
pip install -e .
curl -sSL https://raw.githubusercontent.com/wronai/airun/main/scripts/install.sh | bash
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Start Ollama service
ollama serve
# Download Code Llama model
ollama pull codellama:7b
# Create default configuration
airun config --init
# Check system status
airun doctor
# 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
# 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
# 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
# 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
# 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
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
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
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
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: []
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."
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"
# 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
.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/wronai/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
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"
}
}
]
}
# Clone repository
git clone https://github.com/wronai/airun.git
cd airun
# Setup development environment
make dev-setup
# Run tests
make test
# Run linting
make lint
# Build package
make build
# 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
git checkout -b feature-namemake test| Feature | AIRun | Traditional Runners | Other AI Tools |
|---|---|---|---|
| Multi-language support | β | β | β οΈ |
| Auto error fixing | β | β | β οΈ |
| Local AI support | β | β | β |
| Script analysis | β | β | β οΈ |
| Backup/restore | β | β | β |
| Batch execution | β | β οΈ | β |
| Configuration flexibility | β | β οΈ | β οΈ |
ollama pull codellama:7bOPENAI_API_KEY environment variableANTHROPIC_API_KEY environment variable1. β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
# System diagnosis
airun doctor
# View logs
airun logs --days=7
# Verbose execution
airun run --verbose script.py
# Get configuration template
airun config --init
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ by the AIRun team
If you find AIRun useful, please consider giving it a star β and sharing it with others!
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)
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 for python -m airun.gitignore - Git ignore patterns.pre-commit-config.yaml - Pre-commit hooksLICENSE - MIT License fileairun/templates/config/default.yaml - Default configurationtests/__init__.py and tests/conftest.pytests/test_llm_router.py - LLM router teststests/fixtures/configs/test_config.yaml - Test configurationairun/cli.py - Missing imports for new modulestests/test_cli.py - Test import issuesscripts/install.sh - Production installation scriptscripts/setup_ollama.sh - Ollama setup automationscripts/setup_dev.sh - Development environment setupdocs/mkdocs.yml - MkDocs configurationCHANGELOG.md - Version historyCODE_OF_CONDUCT.md - Community guidelines.github/ISSUE_TEMPLATE/ - Issue templates.github/workflows/release.yml - Release automationexamples/ - Example configurations and scriptsscripts/benchmark.py - Performance benchmarkingairun/web/ - Web interface (future)monitoring/ - Monitoring configurations (optional)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
__init__.py filesairun/core/llm_router.pyairun/core/ai_fixer.pyairun/providers/ modules.gitignore and basic config filesairun/utils/ modules# 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.