gpt-migrate  by joshpxyne

Code migration tool using LLMs

created 2 years ago
6,974 stars

Top 7.4% on sourcepulse

GitHubView on GitHub
Project Summary

GPT-Migrate is an open-source tool designed to automate the complex and time-consuming process of migrating codebases between different programming languages and frameworks. It leverages large language models (LLMs) to analyze existing code, identify dependencies, generate new code, and create unit tests, aiming to significantly reduce the manual effort involved in software modernization. The project is targeted at developers and organizations facing significant migration challenges.

How It Works

GPT-Migrate employs a multi-step, LLM-driven approach. It first sets up a Docker environment for the target language. Then, it recursively analyzes the source code to map dependencies and rebuilds the codebase from a specified entry point, iteratively debugging and refining the output. The tool also generates unit tests using Python's unittest framework and can optionally validate these tests against the original application if it's exposed on a specific port. Debugging is an iterative process where the LLM suggests file operations (move, create, edit) based on logs and error messages, seeking user confirmation for shell commands.

Quick Start & Requirements

  • Installation: Install Docker. Install Poetry, then run poetry install. Set OPENROUTER_API_KEY and/or OPENAI_API_KEY. Install requirements: pip install -r requirements.txt.
  • Execution: Run python main.py --targetlang <target_language> --sourcedir <source_dir> --sourceentry <entry_file> --targetdir <target_dir>.
  • Prerequisites: Docker, Python 3.x, Poetry, OpenAI or OpenRouter API key. GPT-4 or GPT-4-32k is recommended.
  • Resources: Costs can accumulate quickly due to LLM API usage.
  • Docs: https://github.com/joshpxyne/gpt-migrate

Highlighted Details

  • Leverages a hierarchical prompt design for structured LLM interactions.
  • Supports iterative debugging with LLM-suggested file operations.
  • Can optionally validate generated unit tests against the original application.
  • Offers customization via numerous command-line options for source/target languages, directories, ports, and guidelines.

Maintenance & Community

The project is actively seeking contributors. Discussions and updates can be found on Twitter. A professional migration service is also offered via https://gpt-migrate.com/.

Licensing & Compatibility

The repository's license is not explicitly stated in the provided README. Users should verify licensing for commercial or closed-source integration.

Limitations & Caveats

GPT-Migrate is in alpha and not production-ready. It succeeds on simpler language pairs (e.g., Python to JavaScript) about 50% of the time and struggles with more complex languages like C++ or Rust without human intervention. The roadmap includes adding LLM input size limiting and more comprehensive benchmarks.

Health Check
Last commit

10 months ago

Responsiveness

1+ week

Pull Requests (30d)
0
Issues (30d)
0
Star History
53 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Travis Fischer Travis Fischer(Founder of Agentic), and
3 more.

AlphaCodium by Codium-ai

0.2%
4k
Code generation research paper implementation
created 1 year ago
updated 8 months ago
Feedback? Help us improve.