AutoDev 1.6.4 Enhanced Development Experience for HarmonyOS Applications
Generative AI holds tremendous potential in software development and knowledge management, which is why this technology is being increasingly adopted by enterprises. Emerging technologies like the HarmonyOS operating system introduce new concepts, development tools like DevEco Studio, the ArkTS language, and the ArkUI framework. In terms of implementation patterns, its integration with generative AI closely resembles the process of combining AI with enterprise infrastructure.
Therefore, we began exploring possibilities in AutoDev to integrate these new knowledge domains while reducing developers' learning burden.
Source code: https://github.com/unit-mesh/auto-dev
Three Experimental Features for HarmonyOS + Generative AI
After initial discussions with the HarmonyOS team about their self-developed tools, we identified three experimental directions for AutoDev:
- Add ArkTS support. ArkTS is an application development language based on TypeScript extensions in the HarmonyOS ecosystem.
- Automatic ArkUI page generation. ArkUI is a declarative UI development framework for building distributed application interfaces. It shares similarities with our existing AutoPage feature and can generate code/UI through chain-of-thought reasoning.
- UI layout migration. Converting code from other languages/frameworks into HarmonyOS-compatible code using generative AI.
As someone who has studied Gradle, Intellij Community, DevEco Studio source code, and authored "Frontend Architecture: From Basics to Micro Frontends", I possess relevant experience with TypeScript, ArkUI, and declarative UIs. Thus, I confidently embarked on developing new AutoDev features - only to encounter numerous challenges.
1. AI Support for ArkTS Language
After installing DevEco Studio, I discovered AutoDev didn't support TypeScript??? After testing in WebStorm, I realized the IDE difference. Using the PSIViewer plugin, I found DevEco Studio implements its own JavaScript/TypeScript PSI, e.g., com.huawei.ace.language.psi.impl.JavaScriptIdentifierNameImpl
.
The reasons are apparent:
- The JavaScript plugin for IntelliJ platform is proprietary.
- Extending TypeScript syntax directly would be simpler than creating a new language.
Thus, DevEco Studio developed custom JavaScript/TypeScript modules supporting syntax highlighting, code completion, and formatting. It also introduced the ArkTS language as a TypeScript extension.
This means three new file types appear in DevEco Studio + AutoDev:
- Huawei JavaScript
- Huawei TypeScript
- Huawei ArkTS
Headache...
Our solution in AutoDev involves preliminary abstraction based on standard PSI to support documentation generation. A more robust approach would require:
- Reusing JavaScript PSI through reflection
- Integrating DevEco Studio's JavaScript support
Considering debugging complexity and existing xxStudio code references, we temporarily abandoned this approach - assuming HarmonyOS IDEs will eventually provide their own AI capabilities.
2. AutoArkUI: RAG-enhanced ArkUI Code Generation
ArkUI is a declarative UI development framework for building distributed application interfaces.
Compared with ArkTS, integrating ArkUI presents more complexity. The current version focuses on generating pages using classic UI elements:
- Layouts: Row, Column, Stack, Flex, etc.
- Components: Button, Radio, Toggle, etc.
Since ChatGPT lacks knowledge of HarmonyOS updates, we adopted a two-step generation approach similar to AutoPage:
- Analyze user requirements to select appropriate layouts and components
- Generate corresponding ArkUI code based on detailed layout/component information
This process constitutes AutoDev's AutoArkUI feature. The step 1 prompt example:
- User: // maybe send Android Layout code, maybe some requirements
- Your Answer: [FlexLayout, Button, CheckBox, Checkbox, Button]
Considering programming DSLs' sensitivity to natural language, we use English prompts to avoid generating Chinese DSLs.
3. Migrating Android/iOS/Mini-Program Applications
Generative AI demonstrates excellent code translation capabilities, as seen in IBM's COBOL-to-Java conversions and AutoDev's legacy system modernization features.
We've implemented layout migration support in AutoDev, though current limitations exist:
- Android layout conversion often produces errors
- Need for better static code analysis integration
- Merged functionality with AutoArkUI requires refinement
4. RAG-enhanced Chat Context: C++ NAPI etc.
Through experimentation, we observed ChatGPT's lack of HarmonyOS knowledge. Thus, we implemented HarmonyOS-specific context in AutoDev 1.6.4:
- Basic declaration:
This project is a HarmonyOS project.
- Language-specific contexts:
- TypeScript/ArkTS: "Uses Flutter-like declarative UI framework"
- C++: "Uses NAPI for building native Addons"
This helps guide AI:
- For frontend code: Consider Flutter-like declarative UI patterns
- For native code: Consider NAPI-based plugin architecture
These contexts are based on preliminary understanding and require refinement.
Future Directions
Current limitations (implemented within hours):
- Android layout conversion inaccuracies
- Hardcoded component/layout information
- Lack of dynamically generated sample codes
- Incomplete C++ support
- Mini-program platform conversions
As I'm not an expert in Android/mini-program migration to HarmonyOS, challenges remain. Future improvements depend on motivation to develop more interesting features.