用GitHub的上下文信息提升代码解释的准确性和深度。
Uncovering Code Insights: Leveraging GitHub Artifacts for Deeper Code Understanding
- 从GitHub的PR描述、问题讨论等提取上下文增强代码理解
- 用户研究显示生成的洞察有用且无幻觉
- 可集成到开发工具中,适合维护和上手新项目
理解源代码的用途是软件维护、新人上手和现代化改造的关键任务。尽管大语言模型(LLMs)在生成代码解释方面展现出潜力,但往往缺乏对更广泛软件工程背景的把握。本文提出一种新方法,利用GitHub中的自然语言资料——如拉取请求描述、问题描述与讨论、提交信息——来增强基于LLM的代码理解。系统包含三个组件:提取并结构化相关GitHub上下文;利用该上下文生成代码目的的高层解释;以及验证解释的可靠性。我们实现了该系统为独立工具,也部署于模型上下文协议(MCP)服务器,支持与其他AI辅助开发工具集成。主要应用场景是通过本系统生成的代码洞察,增强标准LLM代码解释的效果。为评估解释质量,我们对多个开源及私有项目的开发者进行了小规模用户研究。结果表明,生成的洞察通常有帮助且非平凡,且未出现幻觉。
原文摘要 · Abstract (English)
Understanding the purpose of source code is a critical task in software maintenance, onboarding, and modernization. While large language models (LLMs) have shown promise in generating code explanations, they often lack grounding in the broader software engineering context. We propose a novel approach that leverages natural language artifacts from GitHub -- such as pull request descriptions, issue descriptions and discussions, and commit messages -- to enhance LLM-based code understanding. Our system consists of three components: one that extracts and structures relevant GitHub context, another that uses this context to generate high-level explanations of the code's purpose, and a third that validates the explanation. We implemented this as a standalone tool, as well as a server within the Model Context Protocol (MCP), enabling integration with other AI-assisted development tools. Our main use case is that of enhancing a standard LLM-based code explanation with code insights that our system generates. To evaluate explanations' quality, we conducted a small scale user study, with developers of several open projects, as well as developers of proprietary projects. Our user study indicates that when insights are generated they often are helpful and non trivial, and are free from hallucinations.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。