用多智能体协作自动完成代码重命名,减少错误并保持开发者主导权。
Multi-Agent Coordinated Rename Refactoring
- 基于开发者初始重命名推断关联范围,生成自然语言计划
- 通过集成IDE原生接口安全执行重构,避免误改
- 适合需要频繁重命名的开发团队提升效率
AI智能体在软件开发中的核心价值在于拓展开发者的推理与行动能力,而非替代人类。为展示智能体与开发者协同工作的模式,我们设计了一种新型协同重命名方法。协同重命名指一次重命名触发多个相关标识符的重构,虽常见却极难实现。开发者需手动在大量文件中传播变更,过程繁琐且易出错。现有启发式方法误报率高,而普通大语言模型受限于上下文和无法调用重构工具,建议不完整。这导致重构不全或需过滤大量假阳性。协同重命名正是智能体可显著减轻负担的重复性任务。我们首次构建了多智能体框架来自动化该过程。其关键洞察是:开发者的初始重命名是推断相关重构范围的线索。范围推断智能体将此线索转化为显式的自然语言声明范围;计划执行智能体以此为严格计划,识别应重构的程序元素,并通过调用IDE信任的重构API安全实施变更;复制智能体则据此指导项目级搜索。我们首先对100个开源项目中60.9万次提交的协同重命名实践进行了形成性研究,并调查了205名开发者。
原文摘要 · Abstract (English)
The primary value of AI agents in software development lies in their ability to extend the developer's capacity for reasoning and action, not to supplant human involvement. To showcase how to use agents working in tandem with developers, we designed a novel approach for carrying out coordinated renaming. Coordinated renaming, where a single rename refactoring triggers refactorings in multiple, related identifiers, is a frequent yet challenging task. Developers must manually propagate these rename refactorings across numerous files and contexts, a process that is both tedious and highly error-prone. State-of-the-art heuristic-based approaches produce an overwhelming number of false positives, while vanilla Large Language Models (LLMs) provide incomplete suggestions due to their limited context and inability to interact with refactoring tools. This leaves developers with incomplete refactorings or burdens them with filtering too many false positives. Coordinated renaming is exactly the kind of repetitive task that agents can significantly reduce the developers' burden while keeping them in the driver's seat. We designed, implemented, and evaluated the first multi-agent framework that automates coordinated renaming. It operates on a key insight: a developer's initial refactoring is a clue to infer the scope of related refactorings. Our Scope Inference Agent first transforms this clue into an explicit, natural-language Declared Scope. The Planned Execution Agent then uses this as a strict plan to identify program elements that should undergo refactoring and safely executes the changes by invoking the IDE's own trusted refactoring APIs. Finally, the Replication Agent uses it to guide the project-wide search. We first conducted a formative study on the practice of coordinated renaming in 609K commits in 100 open-source projects and surveyed 205 developers ...
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。