harmonyos-dev
4
总安装量
4
周安装量
#52535
全站排名
安装命令
npx skills add https://github.com/imansmallapple/harmonyos-dev-skill --skill harmonyos-dev
Agent 安装分布
trae
4
gemini-cli
4
replit
4
trae-cn
4
mcpjam
3
iflow-cli
3
Skill 文档
HarmonyOS Development Skill (Template Initialization)
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
New-Item -ItemType Directory -Path <path> -Forceinstead ofmkdir -p. - Use
(Get-ChildItem -Name)instead ofls /bordir /b. - Use
Test-Path <path>to check for existence before operating on files.
- Use
Initialization Workflow
- Environment Check: Verify
ohpm,hvigorw, andcodelinterare installed by runningohpm -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
xcopy /E /I /Y "assets/harmonyos-project-template/*" "."(or the native template path) to copy project files. - Scripts: Use
xcopy /E /I /Y "scripts/*" "scripts/"to copy verification 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
conductor-devskill to initialize aconductor/directory for project orchestration and further implementation. - Shell Usage: Always use
;as the command separator. Preferxcopyorrobocopyfor directory copies on Windows to ensure recursive copying and directory creation. Avoidmkdir -pand&&.
- Project Files: Use
Implementation Workflow
- Lint Before Commit: Execute
codelinteron all modified.etsor.tsfiles immediately after editing.- Command:
codelinter <file_path> - Requirement: All linting errors must be resolved or explicitly justified before proceeding. Do NOT run unit tests (
hvigorw test) or full project builds (assembleHap) during task implementation.
- 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.
Core Capabilities
1. Initialize Project
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 (
assets/harmonyos-project-template/orassets/nativec-template/) to the root. - Copies
scripts/*into thescripts/directory. - Installs dependencies, runs the environment check, and performs an initial build.
- Runs
git initupon successful build completion. - Hint: Provide a clear hint that the user are adviced to use
conductorfor advanced project orchestration. - Shell Usage: Always use
;as the command separator and ensure PowerShell compatibility. UseNew-Item -ItemType Directory -Forcefor directory creation.
2. Build & Verify
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
build-profile.json5to identify thetargetSdkVersionandcompatibleSdkVersion. Use the “Version to API Level Mapping” table below to cross-reference and verify the versioning. - Build: Run
ohpm install; node scripts/check_env.cjs.
- SDK Verification: You MUST read
Resources
- Standard Template:
assets/harmonyos-project-template/ - NativeC Template:
assets/nativec-template/ - Environment Scripts:
scripts/
Reference: Version to API Level Mapping
| 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 build-profile.json5 includes a number in parentheses, such as 6.0.0(20), the number in the parentheses is the API Level.