Skip to content

Latest commit

 

History

History

README.md

Code Genesis

An open-source multi-agent framework that generates production-ready software projects from natural language requirements. It can do:

  • End-to-end project generation with frontend, backend, and database integration
  • High-quality code with LSP validation and dependency resolution
  • Topology-aware code generation that eliminates reference errors
  • Automated deployment to EdgeOne Pages
  • Flexible workflows: standard (7-stage) or simple (4-stage) pipelines

This project needs to be used together with ms-agent.

Running Commands

  1. Clone this repo:
git clone https://github.com/modelscope/ms-agent
cd ms-agent
  1. Build the Docker sandbox image (requires Docker):
bash projects/code_genesis/tools/build_sandbox_image.sh

This builds a code-genesis-sandbox:version1 image containing Python 3.12, Node.js 20, npm, git and curl. All shell commands from the agents run inside this container for security isolation. Note: To speed up dependency downloads during image builds and at container runtime, we use some mirror registries instead of the official sources by default. If your network environment does not require mirrors, you can comment out the relevant lines.

  1. Run:
PYTHONPATH=. openai_api_key=your-api-key openai_base_url=your-api-url python ms_agent/cli/cli.py run --config projects/code_genesis --query 'make a demo website' --trust_remote_code true

The code will be output to the output folder in the current directory by default.

Configuration for Advanced Features

To enable diff-based editing and automated deployment, configure the following in your YAML files:

1. Enable Diff-Based File Editing

Add edit_file_config to both coding.yaml and refine.yaml:

edit_file_config:
  model: morph-v3-fast  # or other compatible models
  api_key: your-api-key
  base_url: https://api.morphllm.com/v1

Get your model and API key from https://www.morphllm.com

2. Enable Automated Deployment

Add edgeone-pages-mcp configuration to refine.yaml:

mcp_servers:
  edgeone-pages:
    env:
      EDGEONE_PAGES_API_TOKEN: your-edgeone-token

Get your EDGEONE_PAGES_API_TOKEN from https://pages.edgeone.ai/zh/document/pages-mcp

Architecture Principles

The workflow is defined in workflow.yaml and follows a 7-stage pipeline:

Standard Workflow:

  1. User Story Agent - Parses user requirements into structured user stories
  2. Architect Agent - Selects technology stack and defines system architecture
  3. File Design Agent - Generates physical file structure from architectural blueprint
  4. File Order Agent - Constructs dependency DAG and topological sort for parallel code generation
  5. Install Agent - Bootstraps environment and resolves dependencies
  6. Coding Agent - Synthesizes code with LSP validation, following dependency order
  7. Refine Agent - Performs runtime validation, bug fixing, and automated deployment

Each agent produces structured intermediate outputs, ensuring engineering rigor throughout the pipeline.

Developer Guide

Function of each module:

  • workflow.yaml - Entry configuration file defining the 7-stage pipeline. You can customize the workflow sequence here
  • user_story.yaml / architect.yaml / file_design.yaml / file_order.yaml / install.yaml / coding.yaml / refine.yaml - Configuration files for each agent in the workflow
  • workflow/*.py - Python implementation for each agent's logic

Human Evaluation

After all writing and compiling is finished, an input will be shown to enable human feedback:

  1. Please run both frontend and backend with npm run dev to start the website
  2. Check website problems and give error feedback from:
    • The backend console
    • The browser console
    • Page errors
  3. After the website runs normally, you can adjust the website, add new features, or refactor something
  4. If you find the token cost is huge or there's an infinite loop, stop it at any time.
  5. Feel free to optimize the code and bring new ideas