A robust, AI-powered one-click tool that automatically detects and sets up development environments for any GitHub repository or local project. It scans code, infers dependencies using AI, generates reproducible setups (e.g., virtual environments, Dockerfiles), resolves conflicts, and validates everything in isolated environments. Designed to handle complex scenarios like multi-language monorepos, legacy code, and dependency conflicts, reducing setup time from hours to minutes.
- Automatic Language Detection: Supports Python, JavaScript/TypeScript, Java, Go, Ruby out-of-the-box; extensible via plugins.
- AI-Driven Dependency Inference: Uses pre-trained models (e.g., CodeBERT) to detect hidden dependencies, suggest versions, and provide insights (e.g., "Deprecated dep detected; auto-upgraded").
- File Generation: Creates/updates requirements.txt, package.json, pom.xml, go.mod, Gemfile, .env, and multi-stage Dockerfiles.
- Conflict Resolution: Handles version mismatches with semver, auto-locking (e.g., pip-tools, npm lock), and auto-fixes during validation.
- Validation & Simulation: Runs installs in isolated envs (virtualenv, nvm, etc.), checks for vulnerabilities (safety, npm audit), and simulates Docker builds.
- Insightful Reporting: Generates Markdown reports with previews, insights, and JSON exports for automation.
- Zero-Touch Mode:
--auto-apply
for fully automated setup without prompts. - GitHub Actions Integration: Auto-setup on PRs or pushes.
- Extensibility: Plugin system for adding new languages or custom behaviors.
- Edge Case Handling: Multi-subdir support for monorepos, caching for speed, retries on failures, OS-agnostic (Windows/Linux/macOS).
- Developers cloning unfamiliar repos.
- Open-source contributors onboarding quickly.
- Teams automating CI/CD bootstrapping.
- AI/ML projects like DCPE, where PyTorch/CUDA deps are inferred automatically.
- Achieve 95%+ accuracy for popular languages.
- Provide diagnostics like "Inferred numpy from sklearn import; confidence 0.85".
- Unlike static tools (e.g., Dependabot), it uses AI for virtual simulations and context-aware resolutions.
AutoEnvForge is available as a Python package. Requires Python 3.12+.
pip install autoenvforge
- Clone the repo:
git clone https://github.com/yourusername/autoenvforge.git
- Navigate:
cd autoenvforge
- Install dependencies:
pip install -r requirements.txt
- Install:
python setup.py install
(orpip install .
)
Prerequisites:
- Git (for repo cloning).
- Docker (optional, for Dockerfile generation/validation).
- Language runtimes (e.g., Node.js for JS validation, Maven for Java) assumed installed on host for full validation; tool uses subprocess.
Test installation: autoenvforge --help
The tool is CLI-based. Core command: autoenvforge init <repo-url-or-path> [options]
- Input: Repo URL (auto-clones) or local path.
- Output: Generated env files, report, and applied changes (with confirmation or auto).
- Process: Scan → Infer → Generate → Validate → Report → Apply.
--lang <python|js|java|go|ruby|auto>
: Force primary language (default: auto-detect).--docker
: Generate multi-stage Dockerfile (e.g., for GPU support in PyTorch projects).--auto-apply
: Zero-touch mode—no prompts, directly applies changes.--preview
: Generate report/preview without applying changes.--verbose
: Detailed logs and progress bars.--cache
: Cache scans/inferences for faster reruns.
autoenvforge init D:\table --auto-apply --docker --verbose --cache
- Scans local code.
- Infers deps (e.g., torch>=2.1.0 from imports).
- Generates requirements.txt, Dockerfile (e.g., FROM pytorch/pytorch:...).
- Validates in temp virtualenv (pip install, safety check).
- Applies files to D:\table.
- Outputs report: Insights on deps, validation status.
On Windows, use quotes for paths: autoenvforge init 'D:\table' --auto-apply
autoenvforge init https://github.com/ali-vilab/DCPE --preview --verbose
- Clones to temp dir.
- Previews report without changes (safe for testing).
- Use
--auto-apply
to apply in cloned dir (or copy back manually).
For a repo with Python in /api and JS in /web:
- Auto-detects subdirs.
- Generates per-subdir: /api/requirements.txt, /web/package.json.
- Multi-stage Dockerfile copies subdirs.
-
Activate Env:
- Python:
python -m venv venv && venv\Scripts\activate && pip install -r requirements.txt
- JS:
npm install
- Etc. (tool validates this works).
- Python:
-
Docker Build (If Generated):
docker build -t myproject . docker run --gpus all myproject # For GPU
-
Manual Extras (Tool Can't Handle):
- Model downloads (e.g., for DCPE: Hugging Face weights).
- Hardware drivers (e.g., CUDA).
Automate env setup on PRs/pushes. Add to .github/workflows/autoenv.yml
:
name: AutoEnvForge Setup
on: [push, pull_request]
jobs:
setup-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install AutoEnvForge
run: pip install autoenvforge
- name: Run AutoEnvForge
run: autoenvforge init . --auto-apply --docker --verbose
- name: Commit Changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Auto: Env setup by AutoEnvForge" || echo "No changes to commit"
git push
This auto-generates/commits env files on events.
Add support for new languages (e.g., Rust) via plugins:
- Create
autoenvforge/plugins/rust.py
:class Plugin: def parse(self, path): # Implement parsing (e.g., read Cargo.toml) return {'imports': []} def generate(self, deps, path): # Generate Cargo.toml, run cargo build pass def validate(self, path): # Run cargo test pass
- Tool auto-loads on init.
- Missing Deps in Inference: Rerun with --verbose; edit generated files manually. Tool's AI is pre-trained—fine-tune if needed.
- Validation Fails: Check report for issues (e.g., "Vuln in dep X"). Auto-fixes handle conflicts; manual downgrade if rare.
- Windows Paths: Use single quotes or double backslashes (e.g., D:\table).
- No Internet: Tool works offline post-install (models cached); version fetches fallback to 'latest'.
- Large Repos: Increase timeout if scan slow; use --cache.
- Errors: E.g., "No tree-sitter for lang" → Fallback to basic parsing. Report bugs on GitHub.
- Structure: Modular (scanner.py, inferencer.py, etc.).
- Testing: Run
pytest tests/test_main.py
. - AI Fine-Tuning: Extend inferencer.py with custom datasets for better dep prediction.
- Contributions welcome! Fork, PR with features/tests.
MIT License. See LICENSE for details.