Skip to content

LLM-powered code transformation engine for automated framework upgrades, language migrations, and semantic refactoring.

License

Notifications You must be signed in to change notification settings

adzynia/shiftforge

πŸ”¨ ShiftForge

License: MIT TypeScript Node.js PRs Welcome

Autonomous Code Migration Assistant - Analyze, transform, and migrate codebases automatically with AI-powered intelligence.

ShiftForge is a CLI tool and local service that automatically generates migration pull requests for framework upgrades, runtime updates, and library migrations. Powered by Claude Sonnet 4.5 for intelligent code analysis and recommendations.

πŸš€ Portfolio Project - Demonstrating AST transformations, multi-agent AI orchestration, and automated code migration techniques.

🌟 Highlights

  • πŸ€– AI-Powered Analysis - Claude Sonnet 4.5 provides deep code insights, security analysis, and migration recommendations
  • 🎯 AST-Based Transformations - Precise code modifications preserving formatting and comments
  • πŸ”„ Multi-Agent Architecture - Analyzer, Migrator, Validator, and PR Generator agents work autonomously
  • βœ… Iterative Validation - Automatically fix issues with test, lint, and type checking
  • πŸ“¦ Production Ready - TypeScript, comprehensive tests, and extensive documentation

✨ Features

Core Capabilities

  • πŸ” Static Code Analysis - Detect framework versions, dependencies, and migration opportunities
  • πŸ€– AI-Powered Intelligence - Claude Sonnet 4.5 analyzes code for technical debt, security issues, and optimal migration paths
  • 🎯 AST-Based Transformations - Precise code modifications using Abstract Syntax Trees (ts-morph, jscodeshift)
  • βœ… Automated Validation - Run tests, lints, and type checks with iterative auto-repair
  • πŸ“¦ PR Generation - Create migration branches with AI-generated, detailed pull request descriptions
  • 🌐 MCP Server - REST API for editor integrations and CI/CD pipelines
  • 🎨 Interactive Wizard - Step-by-step guided migration with preview and rollback
  • ⚑ Parallel Processing - Fast file processing with configurable concurrency

πŸš€ Supported Migrations

  • Node.js - Node 14/16/18 β†’ Node 20
  • React - React 17/18 β†’ React 19
  • Express β†’ Fastify - Framework migration with API transformations
  • More coming soon!

πŸ“‹ Prerequisites

  • Node.js >= 18.0.0
  • npm, yarn, or pnpm
  • Git repository

πŸ› οΈ Installation

# Clone the repository
git clone https://github.com/yourusername/shiftforge.git
cd shiftforge

# Install dependencies
npm install

# Build the project
npm run build

# Link globally (optional)
npm link

πŸ“– Quick Start

AI-Powered Analysis (Recommended)

Get intelligent insights about your codebase:

# Analyze with AI (requires ANTHROPIC_API_KEY)
shiftforge ai-scan --path ./my-project

# Save full AI report
shiftforge ai-scan --path ./my-project --output ai-report.json

What you get:

  • πŸ” Deep code analysis (technical debt, security vulnerabilities, performance issues)
  • 🎯 Smart migration suggestions with effort estimates and benefits
  • πŸ’‘ Actionable recommendations prioritized by impact
  • ⚠️ Risk analysis with mitigation strategies

See AI_FEATURES.md for setup instructions and detailed capabilities.

Interactive Wizard

Let ShiftForge guide you through the migration:

shiftforge wizard

The wizard will:

  1. Analyze your project
  2. Suggest available migrations
  3. Let you configure options
  4. Preview changes before applying
  5. Execute migration with validation
  6. Optionally create a PR

CLI Commands

1. Scan - Analyze your codebase

shiftforge scan

# Scan specific directory
shiftforge scan --path ./my-project

# Save analysis to file
shiftforge scan --output analysis.json

2. Run - Execute a migration

# Run migration
shiftforge run --target node20

# Dry run (preview changes)
shiftforge run --target react19 --dry-run

# Auto-fix validation issues
shiftforge run --target fastify --auto-fix

3. Validate - Check for issues

# Run all checks
shiftforge validate

# Attempt auto-fix
shiftforge validate --fix

4. PR - Generate pull request

# Create PR branch
shiftforge pr --title "Migrate to Node 20"

# Push to remote
shiftforge pr --title "Upgrade React to 19" --push

MCP Server

Start the REST API server:

npm run server

Server runs on http://localhost:3000

API Endpoints

POST /analyze - Analyze a project

curl -X POST http://localhost:3000/analyze \
  -H "Content-Type: application/json" \
  -d '{"projectPath": "/path/to/project"}'

POST /suggest - Get migration suggestions

curl -X POST http://localhost:3000/suggest \
  -H "Content-Type: application/json" \
  -d '{"projectPath": "/path/to/project"}'

POST /migrate - Run migration

curl -X POST http://localhost:3000/migrate \
  -H "Content-Type: application/json" \
  -d '{
    "projectPath": "/path/to/project",
    "target": "node20",
    "dryRun": true
  }'

POST /validate - Validate project

curl -X POST http://localhost:3000/validate \
  -H "Content-Type: application/json" \
  -d '{"projectPath": "/path/to/project"}'

πŸ“š Examples

Example 1: Migrate Express to Fastify

# 1. Analyze the project
shiftforge scan

# 2. Preview the migration
shiftforge run --target fastify --dry-run

# 3. Execute the migration
shiftforge run --target fastify

# 4. Validate the changes
shiftforge validate

# 5. Create a PR
shiftforge pr --title "Migrate from Express to Fastify" --push

Before:

const express = require('express');
const app = express();

app.get('/hello', (req, res) => {
  res.json({ message: 'Hello World' });
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

After:

const fastify = require('fastify');
const app = Fastify({ logger: true });

app.get('/hello', (request, reply) => {
  reply.send({ message: 'Hello World' });
});

app.listen({ port: 3000 }, (err, address) => {
  if (err) {
    app.log.error(err);
    process.exit(1);
  }
  console.log('Server running on port 3000');
});

Example 2: Upgrade to Node 20

shiftforge run --target node20

Transformations:

  • βœ… Updates package.json engines field
  • βœ… Replaces new Buffer() with Buffer.from()
  • βœ… Flags deprecated APIs for manual review
  • βœ… Updates documentation

Example 3: Migrate React to v19

shiftforge run --target react19 --auto-fix

Transformations:

  • βœ… Updates React and ReactDOM imports
  • βœ… Replaces ReactDOM.render() with createRoot()
  • βœ… Removes unnecessary React imports (new JSX transform)
  • βœ… Updates deprecated lifecycle methods
  • βœ… Replaces string refs with callback refs

πŸ—οΈ Architecture

shiftforge/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli/              # CLI commands (scan, run, validate, pr)
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ analyzer/     # Static analysis engine
β”‚   β”‚   β”œβ”€β”€ migrator/     # Code transformation engine
β”‚   β”‚   β”œβ”€β”€ validator/    # Test/lint/type validation
β”‚   β”‚   └── pr-generator/ # Git & PR creation
β”‚   β”œβ”€β”€ agents/           # LLM agent orchestration (future)
β”‚   β”œβ”€β”€ transformers/     # Language-specific transforms
β”‚   β”‚   β”œβ”€β”€ javascript/   # Expressβ†’Fastify, Node, React
β”‚   β”‚   β”œβ”€β”€ typescript/   # TypeScript-specific
β”‚   β”‚   └── java/         # Java migrations (future)
β”‚   β”œβ”€β”€ server/           # MCP REST API server
β”‚   └── types/            # TypeScript type definitions
β”œβ”€β”€ migrations/           # Migration configurations
└── examples/             # Example projects

πŸ”§ Development

# Install dependencies
npm install

# Run in development mode
npm run dev

# Run tests
npm test

# Lint code
npm run lint

# Type check
npm run typecheck

# Build
npm run build

🎯 Roadmap

  • AI Integration - Claude Sonnet 4.5 for intelligent analysis βœ…
  • Interactive Wizard - Guided migration experience βœ…
  • Parallel Processing - Fast concurrent file processing βœ…
  • Integration Tests - Comprehensive test coverage βœ…
  • More Migrations
    • Python 2 β†’ Python 3
    • Java 8 β†’ Java 17
    • Vue 2 β†’ Vue 3
    • Webpack β†’ Vite
  • GitHub Actions Integration - Automated PR creation in CI
  • VS Code Extension - Editor integration
  • Custom Migration Rules - User-defined transformations via config
  • Rollback Support - One-command rollback on failures
  • Codebase Learning - Train on your codebase patterns

πŸ’» Tech Stack

  • Language: TypeScript 5.3
  • AST Parsing: ts-morph, jscodeshift, @babel/parser
  • AI: Anthropic Claude API (Sonnet 4.5)
  • CLI: Commander.js, chalk, ora, prompts
  • Git: simple-git
  • Testing: Jest, ts-jest
  • Build: TypeScript compiler

🀝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

See CODE_OF_CONDUCT.md for community guidelines.

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

  • Built with TypeScript, Commander.js, ts-morph, and jscodeshift
  • AI powered by Anthropic Claude Sonnet 4.5
  • Inspired by Facebook's jscodeshift and Google's Refaster
  • AST transformation techniques from the codemods community

πŸ“š Documentation


Built as a portfolio project demonstrating advanced TypeScript, AST manipulation, AI integration, and automated code transformation.

About

LLM-powered code transformation engine for automated framework upgrades, language migrations, and semantic refactoring.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published