用结构化图谱让大模型精准理解代码库构建逻辑,提升多语言项目辅助效率。
Repository Intelligence Graph: Deterministic Architectural Map for LLM Code Assistants
- 构建可验证的代码库架构图RIG,显式追踪构建与测试依赖关系
- 在8个真实项目中平均提升准确率12.2%,效率提升57.8%
- 特别适合复杂多语言项目,如MetaFFI,显著减少结构误判
代码库感知的编程代理在多语言项目中常难以恢复构建与测试结构,尤其当跨语言依赖分布在异构构建系统中时。本文提出仓库智能图(Repository Intelligence Graph, RIG),一种基于证据的确定性架构图,用于表示可构建组件、聚合器、运行器、测试、外部包及包管理器,并通过明确的依赖与覆盖边连接,追溯至具体的构建与测试定义。同时,我们设计SPADE提取器,从构建与测试产物中自动构建RIG(当前支持基于CMake File API和CTest元数据的自动插件),并将RIG以LLM友好的JSON格式暴露,供代理视为仓库结构的权威描述。我们在涵盖低到高构建复杂度的8个仓库(包括真实世界项目MetaFFI)上评估三个商用代理(Claude Code、Cursor、Codex),每项目各回答30个结构化问题,对比有无RIG时的表现。结果表明,引入RIG使平均准确率提升12.2%,完成时间减少53.9%,每正确答案耗时下降57.8%。多语言项目收益更显著:准确率提升17.7%,效率提升69.5%;单语言项目为6.6%和46.1%。定性分析显示,RIG将错误类型从结构误解转向基于正确结构的推理失误,少数退化案例表明图推理质量仍是关键挑战。
原文摘要 · Abstract (English)
Repository aware coding agents often struggle to recover build and test structure, especially in multilingual projects where cross language dependencies are encoded across heterogeneous build systems and tooling. We introduce the Repository Intelligence Graph (RIG), a deterministic, evidence backed architectural map that represents buildable components, aggregators, runners, tests, external packages, and package managers, connected by explicit dependency and coverage edges that trace back to concrete build and test definitions. We also present SPADE, a deterministic extractor that constructs RIG from build and test artifacts (currently with an automatic CMake plugin based on the CMake File API and CTest metadata), and exposes RIG as an LLM friendly JSON view that agents can treat as the authoritative description of repository structure. We evaluate three commercial agents (Claude Code, Cursor, Codex) on eight repositories spanning low to high build oriented complexity, including the real world MetaFFI project. Each agent answers thirty structured questions per repository with and without RIG in context, and we measure accuracy, wall clock completion time, and efficiency (seconds per correct answer). Across repositories and agents, providing RIG improves mean accuracy by 12.2\% and reduces completion time by 53.9\%, yielding a mean 57.8\% reduction in seconds per correct answer. Gains are larger in multilingual repositories, which improve by 17.7\% in accuracy and 69.5\% in efficiency on average, compared to 6.6\% and 46.1\% in single language repositories. Qualitative analysis suggests that RIG shifts failures from structural misunderstandings toward reasoning mistakes over a correct structure, while rare regressions highlight that graph based reasoning quality remains a key factor.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。