harmonyos-dev-pro
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHarmonyOS Development Skill (Pro Template Initialization)
HarmonyOS开发技能(专业模板初始化)
Directives
指令说明
- Single Purpose: This skill is strictly for project scaffolding and initial build verification.
- Templates: Supports two templates: Standard (ArkTS only) and Native C++ (ArkTS + Native API).
- Post-Initialization: After successful build and git initialization, suggest using Conductor for project orchestration.
- PowerShell Compatibility: All commands MUST be PowerShell-compatible.
- Use as a statement separator.
; - Use instead of
New-Item -ItemType Directory -Path <path> -Force.mkdir -p - Use instead of
(Get-ChildItem -Name)orls /b.dir /b - Use to check for existence before operating on files.
Test-Path <path>
- Use
- 单一用途: 本技能仅用于项目脚手架搭建与初始构建验证。
- 模板支持: 支持两种模板:标准模板(仅ArkTS)和Native C++模板(ArkTS + Native API)。
- 初始化后操作: 构建与Git初始化成功后,建议使用Conductor进行项目编排。
- PowerShell兼容性: 所有命令必须兼容PowerShell。
- 使用作为语句分隔符。
; - 使用替代
New-Item -ItemType Directory -Path <path> -Force。mkdir -p - 使用替代
(Get-ChildItem -Name)或ls /b。dir /b - 在操作文件前,使用检查路径是否存在。
Test-Path <path>
- 使用
Initialization Workflow
初始化工作流
- Environment Check: Verify ,
ohpm, andhvigorware installed by runningcodelinter.ohpm -v; hvigorw -v; codelinter -h - Template Selection: Default to Standard ArkTS project unless the user explicitly mentions "Native C++" or "Native API". Do not ask for confirmation if the request is generic.
- Directory Check: Ensure the target directory is suitable for a new project.
- Execution:
- Project Files: Use (or the native template path) to copy project files.
xcopy /E /I /Y "assets/harmonyos-project-template/*" "." - Scripts: Use to copy verification scripts.
xcopy /E /I /Y "scripts/*" "scripts/" - Dependency Installation: Run .
ohpm install - Environment Check: Run .
node scripts/check_env.cjs - Git Initialization: If the build succeeds, run .
git init ; git add . ; git commit -m "Initial commit from HarmonyOS template" - User Hint: Advise the user that they can now use the skill to initialize a
conductor-devdirectory for project orchestration and further implementation.conductor/ - Shell Usage: Always use as the command separator. Prefer
;orxcopyfor directory copies on Windows to ensure recursive copying and directory creation. Avoidrobocopyandmkdir -p.&&
- Project Files: Use
- 环境检查: 通过运行验证
ohpm -v; hvigorw -v; codelinter -h、ohpm和hvigorw是否已安装。codelinter - 模板选择: 默认使用标准ArkTS项目模板,除非用户明确要求“Native C++”或“Native API”。如果请求为通用类型,无需确认。
- 目录检查: 确保目标目录适合创建新项目。
- 执行步骤:
- 项目文件: 使用(或Native模板路径)复制项目文件。
xcopy /E /I /Y "assets/harmonyos-project-template/*" "." - 脚本文件: 使用复制验证脚本。
xcopy /E /I /Y "scripts/*" "scripts/" - 依赖安装: 运行。
ohpm install - 环境检查: 运行。
node scripts/check_env.cjs - Git初始化: 构建成功后,运行。
git init ; git add . ; git commit -m "Initial commit from HarmonyOS template" - 用户提示: 告知用户现在可以使用技能初始化
conductor-dev目录,用于项目编排与后续开发。conductor/ - Shell使用规范: 始终使用作为命令分隔符。在Windows系统上优先使用
;或xcopy进行目录复制,确保递归复制与目录创建。避免使用robocopy和mkdir -p。&&
- 项目文件: 使用
Implementation Workflow
开发工作流
- Lint Before Commit: Execute on all modified
codelinteror.etsfiles immediately after editing..ts- Command:
codelinter <file_path> - Requirement: All linting errors must be resolved or explicitly justified before proceeding. Do NOT run unit tests () or full project builds (
hvigorw test) during task implementation.assembleHap
- Command:
- UI Component Optimization: When implementing UI components, prioritize performance by minimizing nested containers and using efficient layout managers.
- Self-Learning & Optimization: After completing a task, analyze the implementation for potential optimizations or reusable patterns. Document these "lessons learned" in the task summary or the project's internal knowledge base to improve future development speed and quality.
- 提交前代码检查: 编辑完或
.ets文件后,立即对所有修改文件执行.ts。codelinter- 命令:
codelinter <file_path> - 要求: 所有代码检查错误必须修复或给出明确理由才能继续。任务开发过程中,请勿运行单元测试()或完整项目构建(
hvigorw test)。assembleHap
- 命令:
- UI组件优化: 实现UI组件时,应优先考虑性能,尽量减少嵌套容器并使用高效布局管理器。
- 自我学习与优化: 完成任务后,分析实现方案,寻找潜在优化点或可复用模式。将这些“经验总结”记录在任务总结或项目内部知识库中,以提升未来开发速度与质量。
Core Capabilities
核心能力
1. Initialize Project
1. 项目初始化
Spatially sets up the project structure and installs dependencies.
- Trigger: "Initialize new project", "Create new HarmonyOS app", "Scaffold template"
- Action:
- Default to Standard ArkTS template unless Native C++ is requested.
- Copies the selected template (or
assets/harmonyos-project-template/) to the root.assets/nativec-template/ - Copies into the
scripts/*directory.scripts/ - Installs dependencies, runs the environment check, and performs an initial build.
- Runs upon successful build completion.
git init - Hint: Provide a clear hint that the user are adviced to use for advanced project orchestration.
conductor - Shell Usage: Always use as the command separator and ensure PowerShell compatibility. Use
;for directory creation.New-Item -ItemType Directory -Force
快速搭建项目结构并安装依赖。
- 触发指令: “初始化新项目”、“创建新HarmonyOS应用”、“搭建脚手架模板”
- 执行操作:
- 除非明确要求Native C++,否则默认使用标准ArkTS模板。
- 将选中的模板(或
assets/harmonyos-project-template/)复制到根目录。assets/nativec-template/ - 将复制到
scripts/*目录。scripts/ - 安装依赖、运行环境检查并执行初始构建。
- 构建成功后运行。
git init - 提示信息: 明确告知用户建议使用进行高级项目编排。
conductor - Shell使用规范: 始终使用作为命令分隔符,确保PowerShell兼容性。使用
;创建目录。New-Item -ItemType Directory -Force
2. Build & Verify
2. 构建与验证
Ensures the application compiles correctly and uses correct SDK versions.
- Trigger: "Build the app", "Check for errors", "Verify template"
- Action:
- SDK Verification: You MUST read to identify the
build-profile.json5andtargetSdkVersion. Use the "Version to API Level Mapping" table below to cross-reference and verify the versioning.compatibleSdkVersion - Build: Run .
ohpm install; node scripts/check_env.cjs
- SDK Verification: You MUST read
确保应用编译正确且使用正确的SDK版本。
- 触发指令: “构建应用”、“检查错误”、“验证模板”
- 执行操作:
- SDK版本验证: 必须读取文件,确认
build-profile.json5和targetSdkVersion。使用下方的“版本与API级别对应表”进行交叉验证。compatibleSdkVersion - 构建操作: 运行。
ohpm install; node scripts/check_env.cjs
- SDK版本验证: 必须读取
Resources
资源文件
- Standard Template:
assets/harmonyos-project-template/ - NativeC Template:
assets/nativec-template/ - Environment Scripts:
scripts/
- 标准模板:
assets/harmonyos-project-template/ - NativeC模板:
assets/nativec-template/ - 环境脚本:
scripts/
Reference: Version to API Level Mapping
参考:版本与API级别对应表
| Version | API Level |
|---|---|
| 4.0 | 10 |
| 4.1 | 11 |
| 5.0.0 | 12 |
| 5.0.1 | 13 |
| 5.0.2 | 14 |
| 5.0.3 | 15 |
| 5.1.0 | 18 |
| 5.1.1 | 19 |
| 6.0 | 20 |
Note: If the version string in includes a number in parentheses, such as , the number in the parentheses is the API Level.
build-profile.json56.0.0(20)| 版本号 | API级别 |
|---|---|
| 4.0 | 10 |
| 4.1 | 11 |
| 5.0.0 | 12 |
| 5.0.1 | 13 |
| 5.0.2 | 14 |
| 5.0.3 | 15 |
| 5.1.0 | 18 |
| 5.1.1 | 19 |
| 6.0 | 20 |
注意: 如果中的版本字符串包含括号内的数字,例如,则括号内的数字即为API级别。
build-profile.json56.0.0(20)