GitHub 已将 GitHub Copilot CLI、Copilot 应用和 Copilot SDK 背后的运行时 从 TypeScript 和 Node.js 迁移到了 Rust,通过 AI 辅助重写替换了超过 800000 行代码。这次迁移耗时约 14.5 周,包含 128 个 PR,迁移期间 GitHub 仍持续发布该运行时版本。GitHub 报告称,对于客户端启动、会话创建与单轮交互场景,旧运行时耗时 5.25 秒,Rust 运行时进程内嵌入后耗时降至 292 毫秒。
这次迁移还改变了应用与运行时的集成方式。之前的实现需要 Node.js 和 V8,并通过进程边界与宿主应用通信。GitHub 称这会为每个客户端增加约 100MB 工作集内存。而 Rust 实现可以通过 C ABI 直接嵌入到宿主应用中,同时保留独立进程模式可选。Copilot SDK 目前支持 TypeScript、Python、Go、.NET、Java 和 Rust。
GitHub 采用了增量替换策略,而不是先并行重写再进行一次性切换。各个 TypeScript 组件被 Rust 实现逐一替换,期间通过临时的 N API 互操作层连接两者。这使得现有的端到端测试能够在其他组件仍使用 TypeScript 的情况下测试新代码。GitHub 在迁移期间发布了 135 个版本,包括 35 个稳定版和 100 个预发布版。
该兼容层在移除前,内部 N API 导出项达到 2019 个,TypeScript 调用点共 3356 处。截至 8 月 21 日,运行时包含 832378 行生产 Rust 代码以及 468689 行 Rust 单元测试代码。绝大部分实现代码由 AI 智能体生成,编译、测试和人工评审用于发现各类回归问题,包括行为、状态、生命周期处理、库语义以及优化逻辑丢失等。GitHub 记录了 4478 次直接 cargo check 执行,87.1% 可一次性校验通过。
社区的反应也聚焦于 AI 辅助 迁移的验证难题,并指出取消、重试和背压等场景需要在编译之外进行验证。PLBjt 写道:
这件事有意思的地方不在于 Copilot 使用了 Rust,而在于这次迁移能否在边界上保持运行时行为的稳定。
Leonardo XR 技术负责人 Francesco Pira 指出:
小体量、便于评审的变更、兼容层以及工程师的人工判断是该方案的重要元素。
微软高级解决方案工程师 Côme Redon 指出:
难点在于挖掘遗留系统里那些没有文档说明的行为约定。
最终的架构提供原生 Rust 运行时,既可直接嵌入宿主应用也可独立运行;Copilot SDK 在所有支持的语言中保留了语言专属接口。本次迁移将 AI 生成代码、增量集成、临时兼容边界、自动化校验和人工评审相结合,生产环境运行时在迁移过程中持续迭代更新。
查看英文原文:https://www.infoq.com/news/2026/10/github-copilot-rust-migration/
本文由 AI图鉴自动抓取并翻译,版权归原作者所有;如需查看原文请点下方链接。
GitHub has migrated from TypeScript and Node.js to Rust, replacing more than 800,000 line codes with AI-assisted rewrite, while running behind GitHub Copilot CLI, Copilot and Copilot SDK. The migration took about 14.5 weeks and comprised 128 PRs, while GitHub continued with the publish run-time version. GitHub reports that for client start-up, session creation and single-wheel interactive scenes, the old run time is 5.25 seconds, and Rust runs the embedded time of the process down to 292 ms.
The migration also changed the integration of applications and running times. Prior realization required Node.js and V8 and communication with the host through the process boundary. GitHub claims that this will add about 100 MB workset memory per client. Rust achieves this by directly embedding it in host applications through CABI, while keeping the independent process mode optional. Copilot SDK currently supports TypeScript, Python, Go,.NET, Java and Rust.
GitHub uses an incremental replacement strategy instead of rewriting it in parallel and a one-off switch. The TypeScript components are replaced one by one by Rust and are connected by the temporary NAPI interoperating layer. This allows existing end-to-end tests to test new codes while other components are still using TypeScript. GitHub produced 135 versions of publish during migration, including 35 stable versions and 100 pre-publish versions.
Before the interface is removed, there are 2019 internal NAPI exports and 3,356 TypeScript calls. As of August 21, it was running with the 832378 line production Rust code and the 468689 line Rust unit test code. The vast majority of realization codes are generated by AI AI agent and are compiled, tested and manually evaluated to detect various types of regression problems, including behavioural, state, life cycle processing, cosmologue and optimisation logic loss. GitHub has recorded 4478 direct cargo check executions, 87.1% of which can be verified once.
Community responses have also focused on AI-Auxiliary Migration Validation Challenges and pointed out that cancellation, retry and back-pressure scenarios need to be validated outside the compilation. PLBjt writes:
The interesting thing about this is not whether Copilot uses Rust, but whether the migration will maintain stability at the border.
Leonardo XR Technical Officer Francesco Pira says:
Small volume, easily evaluated changes, compatibility layers and the manual judgement of engineers are important elements of the programme.
Côme Redon, a senior Microsoft Solutions Engineer, says:
The difficulty is to dig up those engagements in the legacy system that are not documented.
The final architecture provides for original Rust to run either directly in host applications or independently; Copilot SDK retains a language-specific interface in all supported languages. This migration combines AI generation codes, incremental integration, temporary compatibility boundaries, automated verification and manual evaluation, and the production environment is continuously updated over time during the migration.
See the English original language at https://www.infoq.com/news/2026/10/github-copilot-rust-migration/
Auto-fetched and translated by AI Atlas. All rights belong to the original author.