How Ctrip’s AI‑Powered Transpiler Automates Front‑End Migration and Java Upgrades
This article explains how Ctrip’s AI‑driven Transpiler, built on a ReAct‑inspired multi‑agent framework, automates code transpilation from CRN to xTaro and streamlines large‑scale Java 21 upgrades, dramatically reducing manual effort and improving accuracy across the software development lifecycle.
Introduction
With the rapid progress of large language models, AI coding has moved from prompt‑based approaches to context‑engineered autonomous agents, making highly autonomous AI coding feasible. This article presents Ctrip’s AI coding assistant – the Transpiler – and its application in code translation/migration scenarios.
AI Autonomy
The concept of ReAct (Reasoning & Acting) introduced by Google in 2022 has inspired many AI coding products. Ctrip’s Transpiler adopts this idea, combining reasoning and acting within a multi‑agent system.
Transpiler Overview
Keywords: ReAct, Multi‑Agent, Context.
The Transpiler implements a ReAct‑style workflow, builds a multi‑agent framework for task identification and agent scheduling, and provides a toolset for necessary context during inference. It runs both inside IDEs (via MCP) and on the terminal (CLI).
Workflow Design
When a user submits a task, the system identifies the task, dispatches it to the appropriate sub‑agent (e.g., code transpilation or migration), and the sub‑agent interacts with the large model while carrying required context. Function calls and MCP can trigger tool usage.
Context Engineering
The context layer aggregates code dependency analysis, file retrieval, memory (dialog history), rule knowledge bases, code and repository information, Bash command results, and task status management.
Project Practice
CRN to xTaro Migration
CRN (Ctrip‑enhanced React Native) is an optimized version of React Native with richer components and performance improvements. xTaro is a multi‑platform framework derived from Taro, enabling a single codebase to run on H5, CRN, and mini‑programs.
Challenges:
Hundreds of pages require migration, leading to high manual cost.
Developers must master both old and new frameworks.
Migration errors affect quality.
Concurrent business iterations cause resource conflicts and complex API compatibility issues.
Transpiler Implementation:
Two core tasks: knowledge‑base construction and tool augmentation.
Knowledge‑Base Construction
Collected internal and external documentation, component mapping tables, and migration experience. A prompt was designed to let the LLM generate a component‑mapping knowledge base, stored in a database with unique component‑name+package keys. The knowledge base supports visual inspection and incremental updates.
Tool Augmentation
Key tools include dependency analysis and conversion management. Dependency analysis determines the order of component migration by analyzing multi‑level dependencies.
# Example of dependency analysis result (image omitted)Conversion management tracks task progress and persists state to files, ensuring stable execution across IDE and terminal environments.
Java 21 Upgrade
Ctrip’s backend primarily uses Java, with versions ranging from 8 to 21 across thousands of services. Upgrading to Java 21 promises performance and resource benefits but faces challenges such as massive application count, heterogeneous middleware, and numerous compatibility changes.
Transpiler’s approach mirrors the front‑end migration: building a knowledge base of upgrade experiences and change points, and developing tools for environment checking and project type detection.
Environment Check Tool (Bash)
# Check JDK version (must contain "21")
JAVA_VERSION=$(java -version 2>&1 | head -1)
if ! echo "$JAVA_VERSION" | grep -q "21"; then
echo "错误: JDK版本必须是21,当前: $JAVA_VERSION"
exit 1
fi
# Check Maven version (must be >=3.6.0)
MVN_VERSION=$(mvn -version 2>&1 | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
if ! echo "$MVN_VERSION" | awk -F. '{if($1>3 || ($1==3 && $2>=6)) exit 0; else exit 1}'; then
echo "错误: Maven版本必须≥3.6.0,当前: $MVN_VERSION"
exit 1
fi
# ...Project Type Detection Tool (Bash)
detect_project_type() {
PROJECT_TYPE="BASIC" # default
# 1. JMockit detection (highest priority)
if grep -rq "jmockit" pom.xml */pom.xml 2>/dev/null || \
find . -name "*.java" -exec grep -l "import mockit\." {} \; 2>/dev/null | head -1 | grep -q "."; then
PROJECT_TYPE="JMOCKIT"
return 0
fi
# 2. PowerMock detection
if grep -rq "powermock" pom.xml */pom.xml 2>/dev/null || \
find . -name "*.java" -exec grep -l "import org.powermock" {} \; 2>/dev/null | head -1 | grep -q "."; then
PROJECT_TYPE="POWERMOCK"
return 0
fi
# ... other detections ...
PROJECT_TYPE="BASIC"
}These tools classify projects and retrieve relevant knowledge for automated migration.
Results
IDE‑based transpilation reduced effort by 61.4% (≈2.6× efficiency).
Terminal‑based transpilation reduced effort by 78% (≈4.7× efficiency).
Java 21 upgrade runs in 15–20 minutes with an 80%–90% issue‑resolution rate.
Experience and Summary
Comparing in‑house models with third‑party LLMs shows that scaling laws still apply; newer models improve instruction execution accuracy. Building a multi‑agent system on a base model solves most software development scenarios. Combining objective data (e.g., dependency analysis) with LLM reasoning reduces hallucinations and boosts correctness.
Full autonomy remains a goal; upstream (requirements, design) and downstream (testing, verification) stages still need human involvement, especially for high‑accuracy requirements.
Ctrip Technology
Official Ctrip Technology account, sharing and discussing growth.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
