Observed since 21 Oct, 11:19 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
LLM-powered code migrations at scale
This tool runs code migrations at scale. It is designed to be run in two phases:
Setup:
Migration:
ai-migrate migrate --project my-new-projectgh repo clone block/ai_migrate
cd ai_migrate
hermit init
uv sync
This will:
# Basic project initialization
uv run ai-migrate init
# Or initialize from a PR (recommended)
uv run ai-migrate init <project_dir> --pr=<pr_number> --description="Brief description of migration"
<project dir>/system_prompt.md: Modify this to suit your migration details.examples/: Add pairs of example files showing migration patterns. Use uv run ai-migrate migrate --manage examples
to manage examples, including generating from git history or from a PR.Add example pairs to your project's examples/ directory.
Example structure:
project/
├── examples/
│ ├── Example1.old.java
│ ├── Example1.new.java
│ ├── Example2.old.java
│ └── Example2.new.java
# Interactive CLI
uv run ai-migrate migrate
The interactive CLI provides a guided experience with:
# Initialize a new project
uv run ai-migrate init
# Migrate files
uv run ai-migrate migrate [FILE_PATHS]
# Check migration status
uv run ai-migrate status
# Check out a branch for manual fixes
uv run ai-migrate checkout FILE_PATH
# Merge all successful migrations
uv run ai-migrate merge-branches
# Get help for a specific command
uv run ai-migrate migrate --help
The interactive CLI now provides an easy way to select which migration project to use:
Automatic Project Selection: When you run a command without specifying a project directory, the CLI will:
AI_MIGRATE_PROJECT_DIR environment variable.ai-migrate file in the current directoryProject Selection Dialog:
projects/ directoryManual Project Specification:
--project-dir option to specify a project directly, or use --project to specify a pre-configured projectAI_MIGRATE_PROJECT_DIR environment variable for persistent selection.ai-migrate file in your repository for project-specific settingsThis makes it easy to work with multiple migration projects without having to remember and type their paths each time.
This will look as input for the specified file and load it if it exists as that or in the form of a .old. file. The script will write the output to the same file and move the previous version to a .old. file if not .old. previously existed. This way you can keep trying migrations having to move files around.
Here's how commands from the main branch map to the new interactive CLI:
| Main Branch Command | New Interactive CLI Command | Description |
|---|---|---|
uv run ai-migrate projects init <path> | uv run ai-migrate init | Initialize a new project |
uv run ai-migrate examples setup <ref> | uv run ai-migrate migrate --manage examples then select "setup" | Set up examples from git history |
uv run ai-migrate examples add <file> | uv run ai-migrate migrate --manage examples then select "add" | Add a file as an example |
uv run ai-migrate --files <file> | uv run ai-migrate migrate <file> | Migrate a specific file |
uv run ai-migrate projects status | uv run ai-migrate status | Show migration status |
uv run ai-migrate projects run --manifest-file=<file> | uv run ai-migrate migrate --manifest-file=<file> | Run migration using a manifest file |
uv run ai-migrate projects run --rerun-passed | uv run ai-migrate migrate --rerun-passed | Re-run migrations that have already passed |
uv run ai-migrate projects run --max-workers=<num> | uv run ai-migrate migrate --max-workers=<num> | Set maximum number of parallel workers |
uv run ai-migrate projects run --local-worktrees | uv run ai-migrate migrate --local-worktrees | Create worktrees alongside the git repo |
uv run ai-migrate projects checkout <file> | uv run ai-migrate checkout <file> | Check out the branch for a failed migration |
uv run ai-migrate projects merge-branches | uv run ai-migrate merge-branches | Merge changes from migrator branches |
The new CLI adds these capabilities not present in the main branch:
PR-Based Initialization:
uv run ai-migrate init
# Then follow interactive prompts for PR-based setup
Example Management UI:
uv run ai-migrate migrate --manage examples
# Interactive dialog for listing, adding, or generating examples
System Prompt Management:
uv run ai-migrate migrate --manage system-prompt
# Interactive dialog for viewing, editing, or generating system prompts
Automatic Evaluation Generation:
# Disable automatic evaluation generation
uv run ai-migrate migrate --dont-create-evals <file_paths>
# Manage evaluations
uv run ai-migrate migrate --manage evals
Rich Help System:
uv run ai-migrate --help
uv run ai-migrate <command> --help
The project uses Hermit to manage Python versions and development tools. Available tools:
To activate the Hermit environment in your shell:
eval "$(./bin/hermit env)"
Additional documentation is available in the docs/ directory:
The tool now supports AI-powered project setup using GitHub PRs:
PR-Based Project Initialization:
# Using the interactive CLI
uv run ai-migrate init
# Then follow the prompts
This will:
Generate Examples from PR:
# Using the interactive CLI
uv run ai-migrate migrate --manage examples
# Then select "from-pr" and follow the prompts
This will analyze the PR changes and extract representative examples of the migration pattern.
Manage System Prompt:
# Using the interactive CLI
uv run ai-migrate migrate --manage system-prompt
# Then select an action (view, edit, or generate) and follow the prompts
This allows you to view, edit, or generate a new system prompt for your migration project.
The new interactive CLI provides a more user-friendly experience with:
Rich Terminal UI:
Interactive Prompts:
Guided Workflows:
Available Commands:
init - Initialize a new migration projectmigrate - Migrate one or more files or manage project resources
--manage examples to manage example files--manage system-prompt to view or edit the system prompt--manage evals to manage evaluation test cases--manifest-file to specify a manifest file for batch processing--rerun-passed to re-run migrations that have already passed--max-workers to set the maximum number of parallel workers--local-worktrees to create worktrees alongside the git repo--dont-create-evals to disable automatic evaluation generationstatus - Show the status of migration projects
checkout - Check out the branch for a failed migration attempt
merge-branches - Merge changes from migrator branches
To use the interactive CLI, simply run:
uv run ai-migrate
For specific commands:
# Initialize a new project
uv run ai-migrate init
# Migrate files
uv run ai-migrate migrate [FILE_PATHS]
# Check migration status
uv run ai-migrate status
# Check out a branch for manual fixes
uv run ai-migrate checkout FILE_PATH
# Merge all successful migrations
uv run ai-migrate merge-branches
# Get help for a specific command
uv run ai-migrate migrate --help
The tool now automatically creates evaluation test cases from successful migrations. This helps build a comprehensive test suite and ensures that future versions of the migration system continue to work correctly.
When a migration succeeds (passes verification), the system:
evals directory with a timestamp-based namesource subdirectoryThese evaluations can then be used to:
By default, evaluations are automatically created for every successful migration. You can:
# Disable automatic evaluation creation
uv run ai-migrate migrate --dont-create-evals <file_paths>
# Manage evaluations
uv run ai-migrate migrate --manage evals
The evaluation management interface allows you to:
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.3 | 26 Mar 2025 | 8 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 11:19 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:165eebf1c91d7287e978c46f3b43fb0994d1f87dc2f07bd7599a540cf9a5458c