|
| 1 | +--- |
| 2 | +slug: CodeGenesis |
| 3 | +title: Code Genesis |
| 4 | +description: Ms-Agent Code Genesis Project for production-ready software project generation from natural language |
| 5 | +--- |
| 6 | + |
| 7 | +# Code Genesis |
| 8 | + |
| 9 | +Code Genesis is an open-source multi-agent framework that generates production-ready software projects from natural language requirements. It orchestrates specialized AI agents to autonomously deliver end-to-end project generation with frontend, backend, and database integration. |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +### Features |
| 14 | + |
| 15 | +- **End-to-end project generation**: Automatically generates complete projects with frontend, backend, and database integration from natural language descriptions |
| 16 | +- **High-quality code**: LSP validation and dependency resolution ensure production-ready output |
| 17 | +- **Topology-aware generation**: Eliminates reference errors through dependency-driven code generation |
| 18 | +- **Automated deployment**: Deploys to EdgeOne Pages automatically with MCP integration |
| 19 | +- **Flexible workflows**: Choose between standard (7-stage) or simple (4-stage) pipelines based on project complexity |
| 20 | + |
| 21 | +### Architecture |
| 22 | + |
| 23 | +Code Genesis provides two configurable workflow modes: |
| 24 | + |
| 25 | +#### Standard Workflow (Production-Grade) |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +The standard pipeline implements a rigorous 7-stage process optimized for complex, production-ready projects: |
| 30 | + |
| 31 | +``` |
| 32 | +User Story → Architect → File Design → File Order → Install → Coding → Refine |
| 33 | +``` |
| 34 | + |
| 35 | +**Pipeline Stages**: |
| 36 | +1. **User Story Agent**: Parses user requirements into structured user stories |
| 37 | +2. **Architect Agent**: Selects technology stack and defines system architecture |
| 38 | +3. **File Design Agent**: Generates physical file structure from architectural blueprint |
| 39 | +4. **File Order Agent**: Constructs dependency DAG and topological sort for parallel code generation |
| 40 | +5. **Install Agent**: Bootstraps environment and resolves dependencies |
| 41 | +6. **Coding Agent**: Synthesizes code with LSP validation, following dependency order |
| 42 | +7. **Refine Agent**: Performs runtime validation, bug fixing, and automated deployment |
| 43 | + |
| 44 | +Each agent produces structured intermediate outputs, ensuring engineering rigor throughout the pipeline. |
| 45 | + |
| 46 | +#### Simple Workflow (Rapid Prototyping) |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +For lightweight projects or quick iterations, the simple workflow condenses the pipeline into 4 core stages: |
| 51 | + |
| 52 | +``` |
| 53 | +Orchestrator → Install → Coding → Refine |
| 54 | +``` |
| 55 | + |
| 56 | +**Streamlined Process**: |
| 57 | +1. **Orchestrator Agent**: Unified requirement analysis, architecture design, and file planning |
| 58 | +2. **Install Agent**: Dependency resolution and environment setup |
| 59 | +3. **Coding Agent**: Direct code generation with integrated file ordering |
| 60 | +4. **Refine Agent**: Validation and deployment |
| 61 | + |
| 62 | +#### Workflow Comparison |
| 63 | + |
| 64 | +| Aspect | Standard Workflow | Simple Workflow | |
| 65 | +|--------|-------------------|-----------------| |
| 66 | +| **Agent Stages** | 7 specialized agents | 4 consolidated agents | |
| 67 | +| **Architecture Quality** | Explicit, auditable design | Implicit, monolithic design | |
| 68 | +| **Generation Time** | Moderate (thorough planning) | Fast (direct execution) | |
| 69 | +| **Use Cases** | Production systems, complex apps | Prototypes, demos, simple tools | |
| 70 | + |
| 71 | +## How to Use |
| 72 | + |
| 73 | +### Installation |
| 74 | + |
| 75 | +Clone the repository and prepare the environment: |
| 76 | + |
| 77 | +```bash |
| 78 | +git clone https://github.com/modelscope/ms-agent |
| 79 | +cd ms-agent |
| 80 | +pip install -r requirements/code.txt |
| 81 | +pip install -e . |
| 82 | +``` |
| 83 | + |
| 84 | +Prepare npm environment, following https://nodejs.org/en/download. If you are using Mac, using Homebrew is recommended: https://formulae.brew.sh/formula/node |
| 85 | + |
| 86 | +Make sure your installation is successful: |
| 87 | +```bash |
| 88 | +npm --version |
| 89 | +``` |
| 90 | + |
| 91 | +Make sure the npm installation is successful, or the npm install/build/dev will fail. |
| 92 | + |
| 93 | +### Quick Start |
| 94 | + |
| 95 | +Run the standard workflow: |
| 96 | + |
| 97 | +```bash |
| 98 | +PYTHONPATH=. openai_api_key=your-api-key openai_base_url=your-api-url \ |
| 99 | +python ms_agent/cli/cli.py run \ |
| 100 | + --config projects/code_genesis \ |
| 101 | + --query 'make a demo website' \ |
| 102 | + --trust_remote_code true |
| 103 | +``` |
| 104 | + |
| 105 | +The code will be output to the `output` folder in the current directory by default. |
| 106 | + |
| 107 | +### Advanced Configuration |
| 108 | + |
| 109 | +#### Enable Diff-Based File Editing |
| 110 | + |
| 111 | +Add `edit_file_config` to both `coding.yaml` and `refine.yaml`: |
| 112 | + |
| 113 | +```yaml |
| 114 | +edit_file_config: |
| 115 | + model: morph-v3-fast # or other compatible models |
| 116 | + api_key: your-api-key |
| 117 | + base_url: https://api.morphllm.com/v1 |
| 118 | +``` |
| 119 | +
|
| 120 | +Get your model and API key from https://www.morphllm.com |
| 121 | +
|
| 122 | +#### Enable Automated Deployment |
| 123 | +
|
| 124 | +Add `edgeone-pages-mcp` configuration to `refine.yaml`: |
| 125 | + |
| 126 | +```yaml |
| 127 | +mcp_servers: |
| 128 | + edgeone-pages: |
| 129 | + env: |
| 130 | + EDGEONE_PAGES_API_TOKEN: your-edgeone-token |
| 131 | +``` |
| 132 | + |
| 133 | +Get your `EDGEONE_PAGES_API_TOKEN` from https://pages.edgeone.ai/zh/document/pages-mcp |
0 commit comments