每天早上一封邮件,把昨天的 AI 梳理好订阅邮件

METAL LAB

Repo0: Design-Driven Zero-to-All Code Generation

arXiv:2608.198542026-08-19

要让AI仅凭自然语言需求就从零搭建整个代码仓库,架构设计不能一次画完就定型,而要在写代码的过程中持续修改

现有的代码生成智能体擅长在文件结构和模块边界已经定好的情况下填代码,但一旦只给自然语言需求、要求它自己设计整个仓库架构,就容易出问题。Repo0维护两张互相关联的图,一张记录需求之间的关系,一张记录实现组件之间的依赖,在编码过程中不断对组件结构进行拆分、合并、修订,而不是一开始就固定蓝图。在六个改编自真实开源项目的基准仓库上,相比最强的现有方法,功能覆盖率最高提升20.08个百分点,测试通过率最高提升29.74个百分点。

他们做了什么

  1. 以往方法如RPG先分析一次需求、生成一份仓库设计蓝图,然后严格按蓝图生成代码,但现实开发中很多模块划分的问题要写代码时才会暴露出来。
  2. Repo0维护一张需求级图(requirement-level DAG,记录需求单元之间的关联)和一张组件级图(component-level DAG,记录实现模块及其依赖),并用对齐关系把两者连接起来;需求图相对固定,组件图则持续演化。
  3. 依据内聚度(一个组件内部聚合的职责是否真正相关)和耦合度(两个组件的职责是否重叠)这两个指标,Repo0反复执行拆分、合并、修订、保留四种结构动作,直到不再需要改动为止,即达到结构收敛。
  4. 结构收敛后,采用测试驱动开发的方式生成代码:先根据对齐的需求写测试,再填充实现去满足测试,失败时只对相关部分做局部修复。
  5. 在改编自scikit-learn、pandas、sympy、statsmodels、requests、django的六个基准仓库上,分别用GPT-5 mini和DeepSeek V3.2测试,Repo0在所有设置下都取得了最高的功能覆盖率和测试通过率。
Fig. 1: Previous methods treat the graph as a fixed planning artifact, whereas Repo0 continuously evolves repository architecture during generation.
Fig. 1: Previous methods treat the graph as a fixed planning artifact, whereas Repo0 continuously evolves repository architecture during generation.
TABLE I: Overview of the six repositories and their paraphrased counterparts (Para. Name) in RepoCraft. #Files denotes the total source files, LOC the effective lines of code, and Task Counts the evaluation tasks.
Real RepoPara. Name#FilesLOCTask Counts
scikit-learnMLKit-Py18565,972236
pandasTableKit217106,447175
sympySymbolicMath699218,924192
statsmodelsStatModeler27183,325234
requestsHttpEasy172,79350
djangoPyWebEngine681109,457165
Fig. 2: Overview of the continuous decision-driven structural evolution framework.
Fig. 2: Overview of the continuous decision-driven structural evolution framework.
TABLE II: RQ1 main results on three RepoCraft repositories. For each repository, we report Functionality Coverage (Cov.), Functionality Novelty (Nov.), and Pass./Vot., which combines Pass Rate and Voting Rate. GPT-5 mini marks the highest value among methods under GPT-5 mini, and DeepSeek V3.2 marks the highest value among methods under DeepSeek V3.2.
ModelMethodrequestsstatsmodelsdjango
Cov. (%)Nov. (%)Pass./Vot. (%)Cov. (%)Nov. (%)Pass./Vot. (%)Cov. (%)Nov. (%)Pass./Vot. (%)
GPT-5 minimini-SWE-agent68.182.634.11 / 27.4018.189.090.00 / 31.8647.926.9637.04 / 44.44
Paper2Code95.507.2024.66 / 24.6644.3224.134.42 / 30.0966.6715.3030.04 / 78.60
RPG90.9113.7031.51 / 95.8970.4013.8077.90 / 92.0060.4211.5847.33 / 74.07
Repo0100.0018.2050.98 / 100.0080.6811.4885.51 / 98.6580.5013.5974.36 / 97.12
DeepSeek V3.2mini-SWE-agent86.3615.3421.92 / 47.9559.0923.392.65 / 53.9833.339.3810.70 / 47.33
Paper2Code90.9111.804.11 / 56.1614.775.0049.56 / 61.9562.5043.467.82 / 53.50
RPG95.459.2361.64 / 90.4164.7013.7039.29 / 73.5768.7526.5046.50 / 69.55
Repo0100.0024.7778.08 / 100.0078.4114.1069.03 / 86.4679.1714.2974.07 / 93.83
Human DeveloperGold Project100.0094.12 / 100.0010094.15 / 100.00100.0096.34 / 100.00
Fig. 3: Illustrative construction of the initial architectural state.
Fig. 3: Illustrative construction of the initial architectural state.
TABLE III: RQ2 ablation results on requests, statsmodels, and django.
RepositorySettingCov. (%)Nov. (%)Pass./Vot. (%)
requestsRepo0100.0018.2050.98 / 100.00
w/o Requirement Context95.45 (-4.55)9.05 (-9.15)45.39 (-5.59) / 87.86 (-12.14)
w/o Component-Graph Ordering100.00 (0.00)12.85 (-5.35)50.98 (0.00) / 100.00 (0.00)
w/o Dual-DAG95.45 (-4.55)9.14 (-9.06)48.72 (-2.26) / 87.86 (-12.14)
w/o Structural Evolution94.32 (-5.68)8.94 (-9.26)42.51 (-8.47) / 82.14 (-17.86)
statsmodelsRepo080.6811.4885.51 / 98.65
w/o Requirement Context67.92 (-12.76)11.69 (+0.21)85.51 (0.00) / 98.65 (0.00)
w/o Component-Graph Ordering80.68 (0.00)15.57 (+4.09)55.51 (-30.00) / 88.65 (-10.00)
w/o Dual-DAG78.55 (-2.13)14.66 (+3.18)85.51 (0.00) / 95.32 (-3.33)
w/o Structural Evolution75.35 (-5.33)13.50 (+2.02)73.51 (-12.00) / 93.65 (-5.00)
djangoRepo087.5013.5974.36 / 100.00
w/o Requirement Context78.29 (-9.21)12.10 (-1.49)64.36 (-10.00) / 100.00 (0.00)
w/o Component-Graph Ordering83.56 (-3.94)11.58 (-2.01)67.70 (-6.66) / 100.00 (0.00)
w/o Dual-DAG82.24 (-5.26)12.40 (-1.19)64.36 (-10.00) / 93.33 (-6.67)
w/o Structural Evolution81.58 (-5.92)10.94 (-2.65)61.03 (-13.33) / 91.66 (-8.34)
Fig. 4: RQ3 structural-convergence analysis on statsmodels with GPT-5 mini.
Fig. 4: RQ3 structural-convergence analysis on statsmodels with GPT-5 mini.

为什么重要

一个能从零搭建整个项目的代码智能体要真正好用,离不开如何拆分文件和模块的软件设计判断力,这项研究用实验说明这种设计判断必须在编码过程中持续修正,而不能一次性定死。这对想用智能体从需求文档直接搭建新项目脚手架的开发者和工具建设者有直接参考价值。

Fig. 5: Action distributions of different models across the six RepoCraft repositories during structural evolution.
Fig. 5: Action distributions of different models across the six RepoCraft repositories during structural evolution.

本文术语

  • Dual-DAG · 两张相互关联的图,一张记录需求之间的关系,一张记录实现组件之间的依赖
  • DAG(有向无环图) · 由单向箭头连接、且不会绕回起点形成回路的图结构
  • 内聚度(Cohesion) · 衡量一个组件内部所聚合的需求彼此关联程度的指标,数值低说明这个组件职责杂乱
  • 耦合度(Coupling) · 衡量两个组件所负责的需求重叠程度的指标,数值高意味着可能需要合并
  • 测试驱动开发(TDD) · 先写测试代码,再编写实现代码去满足这些测试的开发方式
  • 功能覆盖率/通过率 · 衡量生成的仓库覆盖了原需求中多少功能,以及能通过多少参考测试的指标
Fig. 6: Case study of Repo0 on StatModeler. The figure shows how requirements are decomposed, aligned with components, updated through structural actions, and materialized into files.
Fig. 6: Case study of Repo0 on StatModeler. The figure shows how requirements are decomposed, aligned with components, updated through structural actions, and materialized into files.

论文原文摘要(英文)

Large language model agents have made substantial progress in code generation, yet most existing systems assume a predefined repository architecture. This assumption does not hold in zero-to-all code generation, where an agent must construct an entire software project directly from natural-language requirements while maintaining a modular repository architecture throughout development. We present Repo0, a continuous structural evolution framework for zero-to-all code generation. Repo0 maintains an explicit architectural state instantiated as a Dual-Directed-Acyclic-Graph (Dual-DAG), consisting of a requirement-level DAG, a component-level DAG, and their alignment relation. Starting from natural-language requirements, it iteratively evolves component boundaries through structural actions guided by modularity metrics until structural convergence, after which the converged architecture guides test-driven development code generation. We evaluate Repo0 on six real-world repositories from RepoCraft using GPT-5 mini and DeepSeek V3.2. Repo0 achieves the highest Functionality Coverage and Pass Rate across all settings. Compared with RPG, the strongest repository-planning baseline, Repo0 improves Functionality Coverage by up to 20.08 percentage points and Pass Rate by up to 29.74 percentage points. Ablation and structural-evolution analyses further demonstrate the importance of the Dual-DAG architectural state, modularity-guided structural evolution, and explicit structural convergence.

作者 · Silin Chen

在 arXiv 阅读

最新论文

全部论文 →

METAL LAB 最新报道

图片来源: Silin Chen et al., arXiv:2608.19854, CC BY 4.0