Overview
Metamorph is an advanced CLI tool designed to completely automate complex architectural shifts and framework migrations. Instead of relying on regular expressions or manual AST transformations, Metamorph orchestrates a swarm of specialized Agents (Mapper, Worker, Reviewer, and PackageManager) to semantically rewrite your code.
- Project Intelligence Engine (PIE): Autonomously maps complex codebases, heuristics, dynamic entrypoints, and monorepos (Turborepo, pnpm workspaces, npm/yarn workspaces, Lerna).
- Polymorphic Package Manager Engine (PPME): Native, lockfile-aware execution adapting cleanly to
npm, pnpm, yarn, and bun.
- Structural Validation Plugins: Deterministic shadow workspace assertions and repair heuristics for both frontend (Vue, Svelte, Angular) and backend (Express, Fastify, NestJS, Hono) migration targets.
- Deterministic Mock LLM Provider: Offline $0.00 migrations simulating token metrics with zero external API credentials via
--mock.
- Pre-Migration Dry Run: Preview migration plans, rule sets, and package changes without executing inference via
--dry-run.
- Cascading Configuration System: Unified hierarchical settings resolution across CLI flags, environment variables, local
.metamorphrc.json, and global user config (~/.metamorphrc.json).
- Token Accounting & Cost Estimation: Live granular token telemetry and cost estimation persisted in SQLite and streamed to the dashboard.
- Zero Risk (Shadow Workspace): All file mutations and builds occur inside an isolated sandbox (
.metamorph/shadow/<runId>). Your original code is never touched until you review and apply.
- Shadow Verification Build: Migrations are strictly compiled and verified before completion.
- Real-Time Visual Telemetry: Monitor swarm operations, review feedback, cost metrics, shadow diffs, and build diagnostics in real-time via the built-in React dashboard.
System Architecture
Metamorph follows a strict hexagonal architecture with an event-driven agent swarm. For complete architectural whitepapers, see:
flowchart TB
subgraph Entry["User Entry Points"]
CLI["CLI"]
Dashboard["Dashboard"]
end
subgraph Swarm["Agent Swarm (Mozaik v4)"]
Mapper["MapperAgent"] --> Worker["WorkerAgent (x3)"]
Worker --> Reviewer["ReviewerAgent"]
Reviewer -->|Approved| Coordinator["CoordinatorAgent"]
Reviewer -->|Rejected| Worker
Coordinator --> Integration["IntegrationAgent"]
Integration -->|Build fails| Worker
Integration -->|Build passes| Reporter["ReporterAgent"]
end
subgraph IO["Infrastructure"]
Shadow[".metamorph/shadow"]
DB["SQLite"]
LLM["LLM Provider"]
end
CLI --> Swarm
Dashboard -->|REST API| DB
Worker --> LLM
Integration --> Shadow
Swarm --> DB
Monorepo Structure
Built as a scalable monorepo using Turborepo:
| Package |
Layer |
Responsibility |
packages/@nikelyh/domain |
Domain |
Entities, events, ports (zero I/O) |
packages/@nikelyh/application |
Application |
Agent definitions, migration orchestration |
packages/@nikelyh/infrastructure |
Infrastructure |
SQLite, file system, Express API, ts-morph |
packages/@nikelyh/cli |
Driving Adapter |
Commander-based CLI entry point |
apps/dashboard |
Driving Adapter |
React 18 real-time monitoring UI |
Usage
If you just want to use Metamorph to migrate a project, simply install it globally via NPM:
npm install -g @nikelyh/metamorph
And run it inside any project directory:
metamorph run
To monitor the agents in real-time, open a new terminal in the same folder and run:
metamorph ui
Other Commands
metamorph run [options]: Runs an automated migration (e.g. --from <src> --to <target> --mock --dry-run --workspace <pkg> --disable-agents <list>).
metamorph config <get|set|list|path>: Manages persistent cascading configuration (model, concurrency, timeout, retries, disabled agents).
metamorph detect [path]: Detects frameworks, libraries, package managers, and monorepo workspaces.
metamorph apply <runId> [targetPath]: Applies a completed migration to your repository, creating a new git branch.
metamorph rollback <runId>: Discards an unapplied migration and cleans up the shadow workspace.
metamorph list: Lists all migration history.
metamorph reset: Clears all migration history, cost telemetry, and events from the local database.
Supported Migrations
The list of supported architectural shifts is updated frequently as new migration catalogs are added.
See the complete, up-to-date list of all supported frontend and backend framework migrations in the official documentation:
View Supported Migrations
Local Development
Want to contribute or modify Metamorph? Follow these steps to run the monorepo locally.
Prerequisites
- Node.js >= 20
- npm >= 10.8
Setup
-
Clone the repository:
git clone https://github.com/yohanvillarp/metamorph.git
cd metamorph
-
Install dependencies:
npm install
-
Set up Environment Variables:
Create a .env file in the root directory and add your provider keys (e.g., OpenAI, Anthropic) as required by Mozaik.
OPENAI_API_KEY=sk-...
-
Run the build pipeline:
npm run build
Running Locally
To test the CLI from source without installing it globally, you can use the Turborepo dev script:
npm run dev
(Alternatively, navigate to packages/@nikelyh/cli and run npm run dev).
Contributing
We welcome contributions! If you’d like to add support for a new framework migration (e.g., SvelteKit to Nuxt, Python Django to FastAPI), please open an issue first to discuss the architecture.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature)
- Commit your Changes (
npm run changeset)
- Push to the Branch (
git push origin feature/AmazingFeature)
- Open a Pull Request
Built with Mozaik 💖
评论