# UniversalMigrator

**Automatically convert source code between any programming languages — GUI & CLI**

Supports 113 programming languages — plus arbitrary custom languages — with Anthropic Claude API as the AI engine.
Batch-convert all files in a folder while preserving the directory structure.

---

## Key Features

| Feature | Description |
|---|---|
| 113 Languages + Custom | Python, Java, C/C++, C#, Go, Rust, TypeScript, COBOL, RPG, PL/I, VBA, Swift, Kotlin, and more. Any language not in the list can be specified as a custom language |
| Exponential Backoff Retry | Auto-retry on 429 / Timeout / 529 errors (up to 5 attempts) |
| Resume | SHA-256 hash-based state tracking — resume interrupted migrations |
| Output Sanitization | Strips markdown fences and natural-language explanations from AI output |
| Context Injection | Converts config/constants files first, injects them as context for other files |
| Ecosystem Conversion | `requirements.txt` → `package.json`, `pom.xml` → `requirements.txt`, etc. |
| GUI (8 languages) | English, Japanese, Chinese, Korean, Spanish, French, German, Portuguese |
| CLI | CI/CD and batch processing ready |

## Requirements

- **Anthropic API key** (get one at [console.anthropic.com](https://console.anthropic.com/))
- EXE version: No dependencies (Python not required)
- Source version: Python 3.9+

## Installation

### EXE Version (Recommended)

1. Download `UniversalMigrator.exe` from [Releases](../../releases)
2. Place it in any folder
3. Double-click to launch

### Source Version

```bash
git clone https://github.com/highdefinitionaudiodriver/UniversalMigrator.git
cd UniversalMigrator
pip install -r requirements.txt
python main.py
```

## Usage

### GUI Mode

```
python main.py
```

1. Select source and target languages
2. Choose input and output folders
3. Enter your API key (or set `ANTHROPIC_API_KEY` environment variable)
4. Click "Start Migration"

### CLI Mode

```bash
# Python → Rust
python main.py -i ./python_src -o ./rust_out -s Python -t Rust

# COBOL → Java
python main.py -i ./cobol_src -o ./java_out -s COBOL -t Java

# VBA → Python (Shift_JIS encoding)
python main.py -i ./vba_src -o ./py_out -s VBA -t Python -e cp932

# List all supported languages
python main.py --list-languages
```

### CLI Options

| Option | Description |
|---|---|
| `-i, --input` | Input folder (required) |
| `-o, --output` | Output folder (required) |
| `-s, --source` | Source language (required) |
| `-t, --target` | Target language (required) |
| `-k, --api-key` | Anthropic API key |
| `-m, --model` | Model (default: `claude-sonnet-4-20250514`) |
| `-e, --encoding` | Source encoding (default: `utf-8`) |
| `--extra` | Extra instructions for the migration prompt |
| `--no-resume` | Disable resume (re-convert all files) |
| `--no-context` | Disable context injection from priority files |
| `--no-ecosystem` | Disable ecosystem file conversion |
| `--list-languages` | List all supported languages |

## Supported Languages (66)

ABAP, Ada, AppleScript, Assembly (x86), AutoHotkey, Bash/Shell, Batch, C, C#, C++, Clojure, COBOL, CoffeeScript, Crystal, CSS, D, Dart, Delphi/Pascal, Elixir, Elm, Erlang, F#, Fortran, Go, Groovy, Hack, Haskell, HTML, Java, JavaScript, Julia, Kotlin, LabVIEW, Lisp, Lua, MATLAB, Nim, Objective-C, OCaml, Perl, PHP, PL/SQL, PowerShell, Prolog, Python, R, Racket, Ruby, Rust, SAS, Scala, Scheme, Scratch, SCSS/Sass, Smalltalk, Solidity, SQL, Swift, T-SQL, Tcl, TypeScript, VB.NET, VBA, Verilog, VHDL, Zig

## Architecture

```
main.py                    Entry point (GUI / CLI)
src/
  languages.py             66 language definitions
  migrator.py              Migration engine (Claude API + retry + resume)
  sanitizer.py             Output sanitizer (strips markdown & NL text)
  resume_state.py          Resume state manager (SHA-256 hash)
  ecosystem.py             Ecosystem file mapping + priority sorting
  gui_model.py             MVC Model
  gui_view.py              MVC View (tkinter)
  gui_controller.py        MVC Controller
  i18n.py                  Internationalization (8 languages)
```

## Building the EXE

```bash
# Windows
build.bat

# macOS / Linux
./build.sh
```

## License

MIT License - Copyright (c) 2026 highdefinitionaudiodriver
