用熵值指导代码迁移,让大模型自动完成安卓到鸿蒙的完整项目转换。
Entropy-based Code Adversarial Translation for Real-world Repository Migration

- 通过生成器-判别器对抗机制,以代码熵最小化为目标优化迁移过程。
- 在真实项目上实现74.7%迁移质量,比现有方法更稳定高效。
- 适合需要跨平台迁移的大规模项目团队,尤其关注可复用知识积累。
大型语言模型在代码生成与自动修复方面表现出色,但整体仓库迁移常因长程依赖问题导致无法运行。本文提出基于熵的代码对抗迁移框架ECAT,用于自动化安卓至鸿蒙仓库迁移。ECAT将迁移过程建模为对抗熵最小化,通过判别器使用统一指标Code Entropy评估迁移质量,并生成文本梯度,指示文件级生成指令及执行技能。生成器依据这些优化信号迭代更新仓库,仅当代码熵降低时才接受更新。多轮交互逐步将初始模板演进为功能完整的鸿蒙仓库。成功低熵路径被提炼为自演化记忆树,实现跨仓库迁移知识迁移。我们还构建了首个真实世界基准A2H-RepoBench,涵盖从数万到数十万行代码的应用。基于节点对齐与代理式功能评估,ECAT达到74.7%整体迁移质量,在不同规模仓库中均优于现有方法。
原文摘要 · Abstract (English)
LLMs have demonstrated strong capabilities in code generation and automated program repair, but migrating an entire repository rarely produces a runnable application because long-horizon translation challenges LLM-based agents' ability to maintain repository-level migration objectives. In this work, we propose Entropy-based Code Adversarial Translation (ECAT), a multi-agent framework for automated Android-to-HarmonyOS repository migration. ECAT formulates repository migration as adversarial entropy minimization through a generator-discriminator architecture. The discriminator measures migration quality using a unified metric called Code Entropy and produces text gradients that specify both file-level generation directives and the skills needed to execute them. Guided by these optimization signals, the generator iteratively updates the repository, and each update is accepted only if it reduces Code Entropy. Repeated generator--discriminator interactions progressively drive the migration from an initial template toward a functionally complete HarmonyOS repository. Successful low-entropy trajectories are further distilled into a self-evolving memory tree, enabling transferable migration knowledge across repositories. We also introduce A2H-RepoBench, the first real-world benchmark for Android-to-HarmonyOS repository migration, covering applications from tens of thousands to hundreds of thousands of lines of code. Evaluated by node alignment and an agent-based functional judge, ECAT achieves 74.7% overall migration quality and consistently outperforms existing agent-based methods across repositories of different scales.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。