RPG:面向统一且可扩展代码库生成的存储库规划图
RPG: A Repository Planning Graph for Unified and Scalable Codebase Generation
September 19, 2025
作者: Jane Luo, Xin Zhang, Steven Liu, Jie Wu, Yiming Huang, Yangyu Huang, Chengyu Yin, Ying Xin, Jianfeng Liu, Yuefeng Zhan, Hao Sun, Qi Chen, Scarlett Li, Mao Yang
cs.AI
摘要
大型语言模型在函数和文件级别的代码生成方面表现出色,但从零开始生成完整的代码库仍是一项根本性挑战。这一过程需要在提案和实现两个层面进行连贯且可靠的规划,而自然语言由于其模糊性和冗长性,难以准确表达复杂的软件结构。为解决这一问题,我们引入了仓库规划图(Repository Planning Graph, RPG),这是一种持久化的表示方法,通过在一个图中编码能力、文件结构、数据流和函数,统一了提案和实现层面的规划。RPG用明确的蓝图替代了模糊的自然语言,实现了长期规划和可扩展的仓库生成。基于RPG,我们开发了ZeroRepo,一个从零开始生成仓库的图驱动框架。它分为三个阶段:提案层面的规划和实现层面的细化以构建图,随后进行图引导的代码生成及测试验证。为评估这一设置,我们构建了RepoCraft,一个包含六个真实项目、共计1,052个任务的基准测试集。在RepoCraft上,ZeroRepo生成的仓库平均接近36K行代码,约为最强基线(Claude Code)的3.9倍,其他基线的约64倍。其功能覆盖率达到81.5%,通过率为69.7%,分别比Claude Code高出27.3和35.8个百分点。进一步分析表明,RPG能够建模复杂依赖关系,通过近乎线性的扩展实现逐步精细的规划,并增强大型语言模型对仓库的理解,从而加速代理定位。
English
Large language models excel at function- and file-level code generation, yet
generating complete repositories from scratch remains a fundamental challenge.
This process demands coherent and reliable planning across proposal- and
implementation-level stages, while natural language, due to its ambiguity and
verbosity, is ill-suited for faithfully representing complex software
structures. To address this, we introduce the Repository Planning Graph (RPG),
a persistent representation that unifies proposal- and implementation-level
planning by encoding capabilities, file structures, data flows, and functions
in one graph. RPG replaces ambiguous natural language with an explicit
blueprint, enabling long-horizon planning and scalable repository generation.
Building on RPG, we develop ZeroRepo, a graph-driven framework for repository
generation from scratch. It operates in three stages: proposal-level planning
and implementation-level refinement to construct the graph, followed by
graph-guided code generation with test validation. To evaluate this setting, we
construct RepoCraft, a benchmark of six real-world projects with 1,052 tasks.
On RepoCraft, ZeroRepo produces repositories averaging nearly 36K LOC, roughly
3.9times the strongest baseline (Claude Code) and about 64times other
baselines. It attains 81.5% functional coverage and a 69.7% pass rate,
exceeding Claude Code by 27.3 and 35.8 percentage points, respectively. Further
analysis shows that RPG models complex dependencies, enables progressively more
sophisticated planning through near-linear scaling, and enhances LLM
understanding of repositories, thereby accelerating agent localization.