arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2607.08691cs.SEcs.AIcs.IR
收藏

ProjAgent:用于仓库级代码生成的过程相似性检索

ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generation

University of California, Irvine(加州大学伊文斯分校)

QiHong Chen, Aaron Imani, Iftekhar Ahmed

AI总结:

研究仓库级代码生成问题,提出ProjAgent系统,将目标函数分解为中间推理步骤,通过代理工作流程检索相似过程行为的函数,结合语义检索构建丰富上下文,并利用静态分析反馈循环修复代码,实验表明该方法有效。

摘要:

仓库级代码生成需要在考虑复杂的跨文件依赖关系和项目特定约定的情况下实现目标函数。现有检索方法主要依赖词汇、结构或语义相似性,常常忽略那些实现相似过程逻辑但标识符或应用领域不同的仓库函数。我们提出了ProjAgent,一个仓库级代码生成系统,它引入过程相似性作为显式检索信号。ProjAgent将目标函数分解为中间推理步骤,并采用代理工作流程在每个步骤中检索表现出相似过程行为的仓库函数。检索到的过程上下文与传统语义检索相结合,为代码生成构建更丰富的仓库上下文。ProjAgent还纳入了一个保守的静态分析反馈循环,使用编译器和静态分析反馈迭代修复生成的代码。在REPOCOD上进行评估时,ProjAgent的Pass@1达到41.14% ,优于现有的基于检索的基线。这些结果表明,过程相似性是仓库级代码生成中一个有效且以前未被探索的检索维度。

英文摘要:

Repository-level code generation requires implementing target functions while accounting for complex cross-file dependencies and project-specific conventions. Existing retrieval methods predominantly rely on lexical, structural, or semantic similarity, often overlooking repository functions that implement similar procedural logic despite differing in identifiers or application domains. We propose ProjAgent, a repository-level code generation system that introduces procedural similarity as an explicit retrieval signal. ProjAgent decomposes the target function into intermediate reasoning steps and employs an agentic workflow to retrieve repository functions that exhibit similar procedural behavior at each step. The retrieved procedural context is integrated with conventional semantic retrieval to construct a richer repository context for code generation. ProjAgent further incorporates a conservative static-analysis feedback loop that iteratively repairs generated code using compiler and static-analysis feedback. Evaluated on REPOCOD, ProjAgent achieves 41.14% Pass@1, outperforming existing retrieval-based baselines. These results demonstrate that procedural similarity is an effective and previously unexplored retrieval dimension for repository-level code generation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑