RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph

Siru Ouyang,Wenhao Yu,Kaixin Ma,Zilin Xiao,Zhihan Zhang,Mengzhao Jia,Jiawei Han,Hongming Zhang,Dong Yu
2024-10-03
Abstract:Large Language Models (LLMs) excel in code generation yet struggle with modern AI software engineering tasks. Unlike traditional function-level or file-level coding tasks, AI software engineering requires not only basic coding proficiency but also advanced skills in managing and interacting with code repositories. However, existing methods often overlook the need for repository-level code understanding, which is crucial for accurately grasping the broader context and developing effective solutions. On this basis, we present RepoGraph, a plug-in module that manages a repository-level structure for modern AI software engineering solutions. RepoGraph offers the desired guidance and serves as a repository-wide navigation for AI software engineers. We evaluate RepoGraph on the SWE-bench by plugging it into four different methods of two lines of approaches, where RepoGraph substantially boosts the performance of all systems, leading to a new state-of-the-art among open-source frameworks. Our analyses also demonstrate the extensibility and flexibility of RepoGraph by testing on another repo-level coding benchmark, CrossCodeEval. Our code is available at <a class="link-external link-https" href="https://github.com/ozyyshr/RepoGraph" rel="external noopener nofollow">this https URL</a>.
Software Engineering,Artificial Intelligence,Computation and Language
What problem does this paper attempt to address?
The problem that this paper attempts to solve is that in modern AI software engineering tasks, although large - language models (LLMs) perform well in code generation, they are deficient in handling complex, code - repository - level - based tasks. Specifically, existing methods often overlook the understanding of the entire code - repository structure, which makes it difficult to accurately grasp the broader context information when performing tasks such as code completion, feature addition, or problem - solving, thus affecting the effectiveness of solutions. To address this challenge, the paper proposes **RepoGraph**, a plug - in module designed to help AI programmers based on LLMs utilize the structure of the entire code repository. RepoGraph provides a global perspective by constructing a fine - grained graph structure to represent each line of code in the code repository and its dependencies, enabling LLMs to better understand the overall structure of the code base and make more informed decisions. The main contributions of the paper include: - **Fine - grained code understanding**: RepoGraph constructs a graph structure in units of lines, with each node representing a line of code and edges representing the dependencies between code definitions and references. - **Enhanced performance**: Experimental results show that when RepoGraph is integrated as a plug - in into four existing different methods, it can significantly improve the performance of these systems, especially reaching a new state - of - the - art level in solving practical software engineering problems. - **Flexibility and extensibility**: In addition to the evaluation on SWE - bench, the paper also tests the performance of RepoGraph on CrossCodeEval, another benchmark that requires repository - level code understanding, further verifying the generality and flexibility of its method. Through these improvements, RepoGraph not only improves the performance of LLMs in AI software engineering tasks but also provides a new direction for future related research.