@buaa_smat/hometrans 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +112 -55
- package/agents/{logic-coding.md → logic-coder.md} +2 -2
- package/agents/logic-context-builder.md +1 -1
- package/package.json +1 -1
- package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/SKILL.md +3 -3
- package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/conversion-procedure.md +2 -2
- package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +3 -5
- package/skills/{convert_pipeline → hmos-convert-pipeline}/SKILL.md +4 -4
- package/skills/hmos-fix-build-errors/SKILL.md +265 -0
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -0
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -0
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -0
- package/skills/{hmos-ui-align → hmos-incremental-ui-align}/SKILL.md +20 -16
- package/skills/{hmos-ui-align → hmos-incremental-ui-align}/readme.md +5 -6
- package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +3 -5
- package/skills/{self-test → hmos-integration-test}/SKILL.md +1 -1
- package/skills/{spec-generator-skill → hmos-spec-generate}/SKILL.md +1 -1
- package/skills/skill-quality-evaluator/SKILL.md +138 -0
- package/skills/skill-quality-evaluator/assets/SKILL_TEMPLATE.md +77 -0
- package/skills/skill-quality-evaluator/references/Best-practices-for-skill-creators.md +277 -0
- package/skills/skill-quality-evaluator/references/Evaluating-skill-output-quality.md +300 -0
- package/skills/skill-quality-evaluator/references/Optimizing-skill-descriptions.md +196 -0
- package/skills/skill-quality-evaluator/references/Specification.md +272 -0
- package/skills/skill-quality-evaluator/references/Using-scripts-in-skills.md +308 -0
- package/skills/skill-quality-evaluator/references/report-template.md +163 -0
- package/skills/skill-quality-evaluator/references/scoring-rubric.md +269 -0
- package/agents/code-review-fix.md +0 -356
- package/dist/cli/config-store.js +0 -148
- package/dist/cli/config.js +0 -40
- package/dist/cli/index.js +0 -43
- package/dist/cli/init.js +0 -378
- package/dist/cli/mcp-setup.js +0 -262
- package/dist/cli/mcp.js +0 -94
- package/dist/cli/uninstall.js +0 -310
- package/dist/context/index.js +0 -792
- package/skills/code-dev-review-fix/SKILL.md +0 -279
- package/skills/code-dev-review-fix-workspace/evals/evals.json +0 -56
- package/skills/code-dev-review-fix-workspace/iteration-1/routing-results.md +0 -23
- package/skills/hmos-ui-align/config.json +0 -11
- /package/agents/{logic-coding → logic-coder}/scripts/platform_context_query.py +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md" +0 -0
- /package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/scripts/android_parse_fast.py +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/config-example.json +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/diff_analysis.md +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/page_align.md +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/Comparison_Template.md +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md" +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/UI_Analysis_Template.md +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/references/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/scripts/app_feature_verify.py +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/scripts/navigation-capure.md +0 -0
- /package/skills/{hmos-ui-align → hmos-incremental-ui-align}/scripts/page_capture.py +0 -0
- /package/skills/{self-test → hmos-integration-test}/readme.md +0 -0
- /package/skills/{spec-generator-skill → hmos-spec-generate}/references/android-platform-tokens.md +0 -0
- /package/skills/{spec-generator-skill → hmos-spec-generate}/references/spec-sample-1.md +0 -0
- /package/skills/{spec-generator-skill → hmos-spec-generate}/references/spec-sample-2.md +0 -0
- /package/skills/{spec-generator-skill → hmos-spec-generate}/references/spec-sample-3.md +0 -0
- /package/skills/{spec-generator-skill → hmos-spec-generate}/references/step4-report-template.md +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 HomeTrans
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 HomeTrans
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -13,13 +13,111 @@ npm install -g @buaa_smat/hometrans
|
|
|
13
13
|
ht init
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Requires Node.js **>= 18**.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Setup Guide
|
|
21
|
+
|
|
22
|
+
After running `ht init`, follow these steps to complete the installation:
|
|
23
|
+
|
|
24
|
+
### Step 1: Choose your target editor
|
|
25
|
+
|
|
26
|
+
`ht init` automatically detects supported editors (Claude Code, Cursor, OpenCode, Codex) and presents an interactive selection prompt. Use **Space** to toggle and **Enter** to confirm.
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
### Step 2: Finish initialization
|
|
31
|
+
|
|
32
|
+
After confirming your editor selection, HomeTrans installs all bundled **skills**, **agents**, and the **MCP server** into each selected editor's configuration directory. The installation is idempotent — re-running `ht init` overwrites only bundled content.
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
> **Tip:** Run `ht init --all` to skip the editor prompt and install to every detected editor automatically.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## HarmonyOS Migration Guide
|
|
41
|
+
|
|
42
|
+
鸿蒙软件迁移指导,提供完整的 Android 到 HarmonyOS 迁移流程:
|
|
43
|
+
|
|
44
|
+
### Step 1: Resource Conversion (资源转换)
|
|
45
|
+
|
|
46
|
+
> `hmos-batch-ui-align` 内部会自动调用资源转换;如果是批量UI迁移场景则可跳过此步骤。
|
|
47
|
+
|
|
48
|
+
将 Android 资源文件(图片、字符串、颜色、尺寸等)转换为 HarmonyOS 格式。
|
|
17
49
|
|
|
18
|
-
```
|
|
19
|
-
|
|
50
|
+
```
|
|
51
|
+
/hmos-resources-convert android-project-path=<安卓项目路径> harmonyos-project-path=<鸿蒙项目路径> resource_mapping_path=<资源映射文档路径>
|
|
20
52
|
```
|
|
21
53
|
|
|
22
|
-
|
|
54
|
+
| 参数 | 类型 | 说明 |
|
|
55
|
+
|------|------|------|
|
|
56
|
+
| `android-project-path` | **必选** | Android 项目根目录路径(含 `build.gradle` 或 `build.gradle.kts`) |
|
|
57
|
+
| `harmonyos-project-path` | **必选** | HarmonyOS 项目输出路径 |
|
|
58
|
+
| `resource_mapping_path` | **必选** | Android ↔ HarmonyOS 资源映射文档的完整输出路径(`.md`) |
|
|
59
|
+
| `apk-path` | 可选 | Android APK 文件路径;提供后跳过 Gradle 构建和 apktool 解包步骤,直接从 APK 提取资源 |
|
|
60
|
+
|
|
61
|
+
### Step 2: UI Migration (UI迁移)
|
|
62
|
+
|
|
63
|
+
运行以下命令之一完成 Android UI 的全量或增量迁移。
|
|
64
|
+
|
|
65
|
+
#### 全量迁移 — `hmos-batch-ui-align`
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
/hmos-batch-ui-align android_project_dir=<安卓项目路径> harmony_project_dir=<鸿蒙项目路径> ui_info_root=<页面快照目录>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| 参数 | 类型 | 说明 |
|
|
72
|
+
|------|------|------|
|
|
73
|
+
| `android_project_dir` | **必选** | Android 项目根目录路径 |
|
|
74
|
+
| `harmony_project_dir` | **必选** | HarmonyOS 项目输出路径 |
|
|
75
|
+
| `ui_info_root` | 可选 | 包含 `page_NNNN_ActivityName` 格式子目录的父目录路径(每子目录含 `meta.json` + `view.xml` + 可选 `screenshot.png`);不提供时 skill 自动通过 ADB 抓取 |
|
|
76
|
+
| `pages` | 可选 | 显式列出的页面子集(如不提供则处理所有页面) |
|
|
77
|
+
|
|
78
|
+
#### 增量迁移 — `hmos-incremental-ui-align`
|
|
79
|
+
|
|
80
|
+
项目路径通过 `config.json` 文件配置(参考 skill 目录下的 `config-example.json`),对齐目标在消息中描述(如 "帮我对齐设置页面的关于页面")。
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
/hmos-incremental-ui-align config-path=<config.json路径>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| 参数 | 类型 | 说明 |
|
|
87
|
+
|------|------|------|
|
|
88
|
+
| `config-path` | **必选** | `config.json` 文件路径,包含 `android.project_dir`, `harmony.project_dir`, `hmos_sdk_dir`, `glm_api_key`, `capture_output_dir` 等字段 |
|
|
89
|
+
|
|
90
|
+
### Step 3: Generate Spec (生成需求规格)
|
|
91
|
+
|
|
92
|
+
运行 `hmos-spec-generate` 从原始需求描述 `.txt` 文件生成原子场景需求规格文档。
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
/hmos-spec-generate requirement-description-file=<需求描述文件路径> android-project-path=<安卓项目路径> spec-output-dir=<规格输出目录>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| 参数 | 类型 | 说明 |
|
|
99
|
+
|------|------|------|
|
|
100
|
+
| `requirement-description-file` | **必选** | 需求描述 `.txt` 文件路径(每段以 `REQ` 开头,空行分隔) |
|
|
101
|
+
| `android-project-path` | **必选** | Android 项目根目录路径(必须位于 Git 仓库内) |
|
|
102
|
+
| `spec-output-dir` | **必选** | 规格文档输出目录(自动创建;每个 REQ 生成 `<feature>-SPEC.md` + `.trace/<feature>.md`) |
|
|
103
|
+
|
|
104
|
+
### Step 4: Convert Pipeline (逻辑代码开发)
|
|
105
|
+
|
|
106
|
+
运行 `hmos-convert-pipeline` 完成后续的逻辑代码开发、代码检视、集成测试流程。
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
/hmos-convert-pipeline android-project-path=<安卓项目路径> harmonyos-project-path=<鸿蒙项目路径> assets-output-path=<输出报告目录>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| 参数 | 类型 | 说明 |
|
|
113
|
+
|------|------|------|
|
|
114
|
+
| `android-project-path` | **必选** | Android 项目根目录路径 |
|
|
115
|
+
| `harmonyos-project-path` | **必选** | HarmonyOS 项目根目录路径 |
|
|
116
|
+
| `assets-output-path` | **必选** | 输出/报告文件的存放目录(需包含 `plan.md` 需求规格文件) |
|
|
117
|
+
| `max-rounds-review` | 可选 | 代码检视循环最大轮数(正整数 `>= 1`,默认 `2`) |
|
|
118
|
+
| `max-rounds-test` | 可选 | 自测循环最大轮数(正整数 `>= 1`,默认 `2`) |
|
|
119
|
+
| `variant` | 可选 | `enhanced`(默认,全功能 agent)或 `baseline`(纯 LLM baseline agent) |
|
|
120
|
+
| `skip-test` | 可选 | `true` 跳过集成测试阶段(无真机验证环境时需要设置为true,默认 `false`) |
|
|
23
121
|
|
|
24
122
|
---
|
|
25
123
|
|
|
@@ -66,56 +164,16 @@ Requires Node.js **>= 18**.
|
|
|
66
164
|
|
|
67
165
|
---
|
|
68
166
|
|
|
69
|
-
## What `ht mcp` does
|
|
70
|
-
|
|
71
|
-
Starts a stdio-mode MCP server exposing the following tool:
|
|
72
|
-
|
|
73
|
-
### `extract_commit_context`
|
|
74
|
-
|
|
75
|
-
Extracts code context index from a given git commit in a HarmonyOS project (git diff + ArkTS semantic dependency analysis), for use during AI-assisted Android-to-HarmonyOS code review.
|
|
76
|
-
|
|
77
|
-
**Input parameters:**
|
|
78
|
-
|
|
79
|
-
| Parameter | Type | Required | Description |
|
|
80
|
-
|-----------|------|----------|-------------|
|
|
81
|
-
| `projectPath` | string | Yes | Absolute path to HarmonyOS project root (must contain `.git`) |
|
|
82
|
-
| `commitId` | string | Yes | Git commit ID (diffs against its first parent) |
|
|
83
|
-
| `mode` | string | No | `"default"` builds full call graph; other values skip (default: `"default"`) |
|
|
84
|
-
| `ohosSdkPath` | string | No | OpenHarmony SDK ETS path; falls back to env var `OHOS_SDK_PATH` |
|
|
85
|
-
| `hmsSdkPath` | string | No | HMS SDK ETS path; falls back to env var `HMS_SDK_PATH` |
|
|
86
|
-
|
|
87
|
-
**Output:** `{path, kind, ranges?, resourceNames?}[]`
|
|
88
|
-
- `source` files: 1-based `[start, end]` line-range arrays
|
|
89
|
-
- `resource` files: list of referenced resource names
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
167
|
## Skills
|
|
94
168
|
|
|
95
|
-
| Skill | Trigger phrases | Description |
|
|
96
|
-
|
|
97
|
-
| `convert-pipeline` | "full Android-to-HarmonyOS pipeline", "run the conversion pipeline end-to-end", "
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `hmos-
|
|
101
|
-
| `hmos-ui-align` | "
|
|
102
|
-
| `hmos-
|
|
103
|
-
| `self-test` | "跑自测", "运行自测", "自动测试", "设备测试", "self test", "run autotest" | Runs on-device self-test for a HarmonyOS app: parses `test_case.md`, installs the HAP, executes AutoTest, and produces a verification report — optionally entering a test-and-fix loop |
|
|
104
|
-
|
|
105
|
-
### `convert-pipeline` Arguments
|
|
106
|
-
|
|
107
|
-
1. `android-project-path` (required): path to the Android source project
|
|
108
|
-
2. `harmonyos-project-path` (required): path to the target HarmonyOS project
|
|
109
|
-
3. `assets-output-path` (required): directory for output/report files
|
|
110
|
-
4. `max-rounds-review` (optional, default `2`): max Code Review → Fix loop rounds
|
|
111
|
-
5. `max-rounds-test` (optional, default `2`): max Self-Test → Fix loop rounds
|
|
112
|
-
6. `variant` (optional, default `enhanced`): `enhanced` | `baseline` — selects the Stage 1/1a agent family
|
|
113
|
-
|
|
114
|
-
### `spec-generator-skill` Arguments
|
|
115
|
-
|
|
116
|
-
1. `requirement-description-file` (required): absolute path to a single `.txt` file containing one or more REQ blocks separated by blank lines
|
|
117
|
-
2. `android-project-path` (required): absolute path to the Android project root (must be inside a Git repo)
|
|
118
|
-
3. `spec-output-dir` (required): absolute path to the directory where spec files will be written
|
|
169
|
+
| Skill | Trigger phrases | Description | Prerequisites | Arguments | Example |
|
|
170
|
+
|-------|-----------------|-------------|---------------|-----------|--------|
|
|
171
|
+
| `hmos-convert-pipeline` | "full Android-to-HarmonyOS pipeline", "run the conversion pipeline end-to-end", "hmos-convert-pipeline" | Runs all conversion agents in sequence with progress tracking, duration stats, and defect recording. 4 stages: Logic Development (Context Builder) → Logic Coding → Build → Code Review/Fix/Rebuild loop → Self-Test/Fix/Rebuild loop | `assets-output-path` 下需存在 `plan.md` 需求规格文件 | `android-project-path` (required), `harmonyos-project-path` (required), `assets-output-path` (required), `max-rounds-review` (optional, default 2), `max-rounds-test` (optional, default 2), `variant` (optional, default enhanced), `skip-test` (optional, default false) | `"/hmos-convert-pipeline android-project-path=D:/path/to/android harmonyos-project-path=D:/path/to/harmonyos assets-output-path=D:/path/to/output"` |
|
|
172
|
+
| `hmos-spec-generate` | "spec generation", "generate spec", "requirement to spec", "atomic scenarios", "scenario decomposition", "req to spec" | Generates atomic-scenario requirement specs from raw `.txt` requirement batches. Reads REQ blocks, explores the Android code graph via GitNexus, writes per-REQ trace files, then synthesizes specs from the trace | 需求描述文件 (`.txt`),每段以 `REQ` 开头 | `requirement-description-file` (required), `android-project-path` (required), `spec-output-dir` (required) | `"/hmos-spec-generate requirement-description-file=D:/path/to/req.txt android-project-path=D:/path/to/android spec-output-dir=D:/path/to/specs"` |
|
|
173
|
+
| `hmos-resources-convert` | "Android resources to HarmonyOS", "migrate Android res", "convert drawables/strings/colors" | Converts Android project resources (strings, colors, dimensions, images, drawables, icons) into HarmonyOS resources, including qualifier directories and XML→JSON format conversion | Android 项目中需包含 `res/` 资源目录 | `android-project-path` (required), `harmonyos-project-path` (required), `resource_mapping_path` (required), `apk-path` (optional) | `"/hmos-resources-convert android-project-path=D:/path/to/android harmonyos-project-path=D:/path/to/harmonyos resource_mapping_path=D:/path/to/resource_mapping.md"` |
|
|
174
|
+
| `hmos-incremental-ui-align` | "UI对齐", "页面对齐", "和安卓对齐", "鸿蒙页面修复", "UI增量开发", "align HarmonyOS with Android" | Automated HarmonyOS-Android UI alignment: navigates to target pages on both devices, captures view trees + screenshots, then aligns HarmonyOS code to match Android | 需连接 Android 设备进行 UI 对比;`config-path` 指向的 `config.json` 中需配置项目路径、SDK 路径、API key | `config-path` (required) | `"/hmos-incremental-ui-align config-path=D:/path/to/config.json 帮我对齐设置页面的关于页面"` |
|
|
175
|
+
| `hmos-batch-ui-align` | "把安卓页面迁移到鸿蒙", "Android UI 转鸿蒙", "批量转 ArkTS" | Batch-converts multiple Android Activity UI snapshots (`page_NNNN_ActivityName`) to HarmonyOS ArkUI (ArkTS) pages | `ui_info_root` 下需包含 `page_NNNN_ActivityName` 格式的页面快照子目录 | `android_project_dir` (required), `harmony_project_dir` (required), `ui_info_root` (optional), `pages` (optional) | `"/hmos-batch-ui-align android_project_dir=D:/path/to/android harmony_project_dir=D:/path/to/harmonyos ui_info_root=D:/path/to/pages"` |
|
|
176
|
+
| `hmos-integration-test` | "跑自测", "运行自测", "自动测试", "设备测试", "self test", "run autotest" | Runs on-device self-test for a HarmonyOS app: parses `test_case.md`, installs the HAP, executes AutoTest, and produces a verification report — optionally entering a test-and-fix loop | 需存在 `test_case.md` 测试用例文件,设备需安装待测 HAP | `test-case-path` (required), `hap-path` (required), `output-path` (optional), `pre-test-case-path` (optional), `android-project-path` (optional), `max-rounds` (optional, default 3) | `"/hmos-integration-test test-case-path=D:/path/to/test_case.md hap-path=D:/path/to/app-signed.hap"` |
|
|
119
177
|
|
|
120
178
|
---
|
|
121
179
|
|
|
@@ -124,10 +182,9 @@ Extracts code context index from a given git commit in a HarmonyOS project (git
|
|
|
124
182
|
| Agent | Description |
|
|
125
183
|
|-------|-------------|
|
|
126
184
|
| `logic-context-builder` | Constrains HarmonyOS ArkTS app changes into an executable decision contract |
|
|
127
|
-
| `logic-
|
|
185
|
+
| `logic-coder` | Executes HarmonyOS ArkTS code implementation from the decision contract (ships with `scripts/platform_context_query.py`) |
|
|
128
186
|
| `build-fixer` | Automatically builds a HarmonyOS project, parses compile errors, fixes them, and retries in a loop until the build succeeds |
|
|
129
187
|
| `code-reviewer` | Reviews HarmonyOS code against user scenarios to validate functional coverage |
|
|
130
|
-
| `code-review-fix` | One-pass review-fix-build cycle — reviews code, verifies and fixes confirmed issues, rebuilds the project |
|
|
131
188
|
| `review-fixer` | Fixes issues from code review reports — verifies each issue before fixing, references Android source, uses cautious per-scenario fix strategies |
|
|
132
189
|
| `spec-generator` | Generates requirement spec documents for each requirement description file in a folder by exploring the Android codebase and decomposing into atomic user scenarios |
|
|
133
190
|
| `self-tester` | Unified self-test agent — parses `test_case.md` into `testcases.json`, runs on-device AutoTest verification, and produces a report. A `setup` boolean controls whether the parse phase runs (skip on round-2+ to reuse prior artifacts) |
|
|
@@ -135,7 +192,7 @@ Extracts code context index from a given git commit in a HarmonyOS project (git
|
|
|
135
192
|
|
|
136
193
|
---
|
|
137
194
|
|
|
138
|
-
|
|
195
|
+
|
|
139
196
|
|
|
140
197
|
<p align="center">
|
|
141
198
|
<a href="https://gitcode.com/SMAT/HomeTrans">Official Repository</a> •
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: logic-
|
|
2
|
+
name: logic-coder
|
|
3
3
|
description: "Execute the HarmonyOS ArkTS app contract without reopening design choices."
|
|
4
4
|
color: blue
|
|
5
5
|
min-model: sonnet
|
|
@@ -10,7 +10,7 @@ min-model: sonnet
|
|
|
10
10
|
- `plan-file` = `{output_path}/plan.md`
|
|
11
11
|
- `harmonyos-project-path` (abs)
|
|
12
12
|
- `output-path` (abs)
|
|
13
|
-
- `plugin-path` (abs) — plugin root; `{scripts}` = `{plugin-path}/agents/logic-
|
|
13
|
+
- `plugin-path` (abs) — plugin root; `{scripts}` = `{plugin-path}/agents/logic-coder/scripts/`
|
|
14
14
|
|
|
15
15
|
## Tools
|
|
16
16
|
|
|
@@ -10,7 +10,7 @@ min-model: sonnet
|
|
|
10
10
|
- `spec-file` (abs)
|
|
11
11
|
- `harmonyos-project-path` (abs)
|
|
12
12
|
- `output-path` (abs)
|
|
13
|
-
- `plugin-path` (abs) — plugin root; `{scripts}` = `{plugin-path}/agents/logic-
|
|
13
|
+
- `plugin-path` (abs) — plugin root; `{scripts}` = `{plugin-path}/agents/logic-coder/scripts/`
|
|
14
14
|
|
|
15
15
|
## Tools
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buaa_smat/hometrans",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "HomeTrans (Android-to-HarmonyOS) skill + agent installer. Run `ht init` to distribute conversion skills and subagents into AI editors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: hmos-ui-align
|
|
3
|
-
description: Batch-convert multiple Android Activity UI snapshots to HarmonyOS ArkUI (ArkTS) pages. Use when the user wants to migrate Android UI pages to HarmonyOS in bulk, port multiple Activity screens to ArkTS, or run an Android-to-HarmonyOS UI conversion across a folder of page snapshots (page_NNNN_ActivityName). Triggers on phrases like "把安卓页面迁移到鸿蒙", "Android UI 转鸿蒙", "批量转 ArkTS", "hmos-ui-
|
|
2
|
+
name: hmos-batch-ui-align
|
|
3
|
+
description: Batch-convert multiple Android Activity UI snapshots to HarmonyOS ArkUI (ArkTS) pages. Use when the user wants to migrate Android UI pages to HarmonyOS in bulk, port multiple Activity screens to ArkTS, or run an Android-to-HarmonyOS UI conversion across a folder of page snapshots (page_NNNN_ActivityName). Triggers on phrases like "把安卓页面迁移到鸿蒙", "Android UI 转鸿蒙", "批量转 ArkTS", "hmos-batch-ui-align", or any request that supplies an Android project path + Harmony project path + a directory of page snapshots.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# hmos-ui-
|
|
6
|
+
# hmos-batch-ui-align — Android → HarmonyOS UI Batch Conversion
|
|
7
7
|
|
|
8
8
|
Batch-convert a set of Android page snapshots (each snapshot is a `page_NNNN_ActivityName/` directory containing `meta.json` + `view.xml` + optional `screenshot.png`) into HarmonyOS ArkTS pages following MVVM architecture.
|
|
9
9
|
|
package/skills/{hmos-ui-align-batch → hmos-batch-ui-align}/references/conversion-procedure.md
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Single-Page Android → HarmonyOS UI 转换流程
|
|
2
2
|
|
|
3
|
-
> 这是 `hmos-ui-
|
|
3
|
+
> 这是 `hmos-batch-ui-align` skill 在每个子 agent 中执行的单页转换流程。基于 `a2h-ui-conversion-new` agent 改写:去掉 Phase 6 build 修复(由父 skill 统一在最后做一次)。
|
|
4
4
|
|
|
5
5
|
你是一个 **UI Activity 转换器**,专门把单个 Android Activity 的某一页 UI 迁移到 HarmonyOS ArkUI(ArkTS)。
|
|
6
6
|
|
|
@@ -128,7 +128,7 @@ dialog/fragment/adapter 等必须从主页面拆出去到 `{harmony_project_dir}
|
|
|
128
128
|
|
|
129
129
|
## Phase 6 — Build 修复
|
|
130
130
|
|
|
131
|
-
**跳过**。父 skill `hmos-ui-
|
|
131
|
+
**跳过**。父 skill `hmos-batch-ui-align` 会在所有页面转换完后统一调用 `hmos_fix_build_errors` 修一次。
|
|
132
132
|
|
|
133
133
|
## 返回转换报告
|
|
134
134
|
|
|
@@ -2524,11 +2524,9 @@ Column() {
|
|
|
2524
2524
|
|
|
2525
2525
|
## 参考链接
|
|
2526
2526
|
|
|
2527
|
-
1. **
|
|
2528
|
-
2. **
|
|
2529
|
-
3. **
|
|
2530
|
-
4. **Android UI 组件总览**: https://developer.android.com/develop/ui
|
|
2531
|
-
5. **Material Design 3 规范**: https://m3.material.io/components
|
|
2527
|
+
1. **HarmonyOS 开发者文档**: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/
|
|
2528
|
+
2. **Android UI 组件总览**: https://developer.android.com/develop/ui
|
|
2529
|
+
3. **Material Design 3 规范**: https://m3.material.io/components
|
|
2532
2530
|
|
|
2533
2531
|
---
|
|
2534
2532
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: convert-pipeline
|
|
3
|
-
description: "Run the Android-to-HarmonyOS conversion pipeline — all agents in sequence with progress, duration, and defect tracking. Trigger phrases include 'full Android-to-HarmonyOS pipeline', 'run the conversion pipeline end-to-end', '
|
|
2
|
+
name: hmos-convert-pipeline
|
|
3
|
+
description: "Run the Android-to-HarmonyOS conversion pipeline — all agents in sequence with progress, duration, and defect tracking. Trigger phrases include 'full Android-to-HarmonyOS pipeline', 'run the conversion pipeline end-to-end', 'hmos-convert-pipeline', 'HarmonyOS conversion', or any request to convert an Android project to HarmonyOS with all stages (logic → build → review → fix → rebuild → self-test loop)."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Full Conversion Pipeline
|
|
@@ -20,7 +20,7 @@ Parse `$ARGUMENTS` as positional tokens:
|
|
|
20
20
|
- **Arg 3** (`assets-output-path`): Directory to store all output/report files (required)
|
|
21
21
|
- **Arg 4** (`max-rounds-review`): Maximum number of Stage 3→3a→3b code-review-fix rounds to run (optional, default `2`). Must be a positive integer `>= 1`.
|
|
22
22
|
- **Arg 5** (`max-rounds-test`): Maximum number of Stage 4→4a→4b self-test rounds to run (optional, default `2`). Must be a positive integer `>= 1`.
|
|
23
|
-
- **Arg 6** (`variant`): `enhanced` or `baseline` (optional, default `enhanced`). Selects the Stage 1 / 1a agent family. `enhanced` uses the full `logic-context-builder` + `logic-
|
|
23
|
+
- **Arg 6** (`variant`): `enhanced` or `baseline` (optional, default `enhanced`). Selects the Stage 1 / 1a agent family. `enhanced` uses the full `logic-context-builder` + `logic-coder` agents; `baseline` uses the pure-LLM `logic-context-builder-minimal` + `logic-coding-minimal` agents for A/B capability comparison. All other stages and their agents are unchanged. To pass this arg, provide explicit values for Args 4 and 5 first.
|
|
24
24
|
- **Arg 7** (`skip-test`): `true` or `false` (optional, default `false`). When `true`, skip Stage 4 / 4a / 4b (Self-Testing Loop) entirely. Use this when no real HarmonyOS device is available for on-device testing. To pass this arg, provide explicit values for Args 4, 5, and 6 first.
|
|
25
25
|
|
|
26
26
|
If any required argument is missing, ask the user before proceeding. If `max-rounds-review` or `max-rounds-test` is provided but is not a positive integer, ask the user before proceeding. If `variant` is provided but is not `enhanced` or `baseline`, ask the user before proceeding. If `skip-test` is provided but is not `true` or `false`, ask the user before proceeding.
|
|
@@ -167,7 +167,7 @@ Prompt format (applies to both Stage 1 and Stage 1a): ONLY the key-value lines b
|
|
|
167
167
|
```
|
|
168
168
|
# VARIANT=enhanced (default) — full agent
|
|
169
169
|
Agent(
|
|
170
|
-
subagent_type="logic-
|
|
170
|
+
subagent_type="logic-coder",
|
|
171
171
|
prompt="harmonyos-project-path: HMOS\nplan-file: OUTPUT/logic/plan.md\noutput-path: OUTPUT/logic"
|
|
172
172
|
)
|
|
173
173
|
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hmos-fix-build-errors
|
|
3
|
+
description: Build a HarmonyOS project via CLI and automatically fix compile errors in a loop until the build succeeds. Default unsigned HAP; pass --signed to build a signed HAP (signing config must already exist in the project's build-profile.json5).
|
|
4
|
+
argument-hint: <harmonyos-project-path> <deveco-studio-path> [--signed]
|
|
5
|
+
allowed-tools: Agent, Read, Write, Edit, Glob, Grep, Bash
|
|
6
|
+
type: tool
|
|
7
|
+
domain: engineering
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# HarmonyOS Auto Build & Fix
|
|
11
|
+
|
|
12
|
+
Automatically build a HarmonyOS NEXT project from the command line, parse compile errors, fix them, and retry — repeating until the build succeeds.
|
|
13
|
+
|
|
14
|
+
- **HarmonyOS Project**: `$ARGUMENTS[0]` (the HarmonyOS project root, e.g. `D:/MyHmosApp`)
|
|
15
|
+
- **DevEco Studio Path**: `$ARGUMENTS[1]` (DevEco Studio installation root, e.g. `D:/DevEco Studio`)
|
|
16
|
+
- **--signed** (optional): `$ARGUMENTS[2]` — if set to `--signed`, the build produces a **signed HAP**. If omitted, the build produces an **unsigned HAP** (default).
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Step 0: Validate Inputs & Setup Environment
|
|
21
|
+
|
|
22
|
+
1. **Verify project exists** — Check that `$ARGUMENTS[0]` contains a valid HarmonyOS project (look for `build-profile.json5`, `entry/src` directory, `oh-package.json5`).
|
|
23
|
+
|
|
24
|
+
2. **Verify DevEco installation** — Check that `$ARGUMENTS[1]` contains:
|
|
25
|
+
- `tools/node/node.exe`
|
|
26
|
+
- `tools/hvigor/bin/hvigorw.js`
|
|
27
|
+
- `tools/ohpm/bin/ohpm`
|
|
28
|
+
- `sdk/` directory
|
|
29
|
+
|
|
30
|
+
3. **Set up `local.properties`** — Ensure the project root has `local.properties` with:
|
|
31
|
+
```properties
|
|
32
|
+
hwsdk.dir=<deveco-path>/sdk
|
|
33
|
+
```
|
|
34
|
+
Create it if missing. Use forward slashes in the path.
|
|
35
|
+
|
|
36
|
+
4. **Run `ohpm install`** — Install dependencies before first build:
|
|
37
|
+
```bash
|
|
38
|
+
cd "<project-dir>"
|
|
39
|
+
export PATH="<deveco-path>/tools/ohpm/bin:$PATH"
|
|
40
|
+
"<deveco-path>/tools/ohpm/bin/ohpm" install
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
5. **Determine Build Mode** — Check if `$ARGUMENTS[2]` equals `--signed`:
|
|
44
|
+
- **If NOT `--signed`** → **Unsigned build mode**. Ensure `build-profile.json5` does NOT have `signingConfigs` or `signingConfig` references in products (remove them if present). Go to Step 1.
|
|
45
|
+
- **If `--signed`** → **Signed build mode**. Proceed to Step 0.5 to validate signing config.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Step 0.5: Validate Signing Config (Only for --signed Builds)
|
|
50
|
+
|
|
51
|
+
This step is ONLY executed when `--signed` is specified.
|
|
52
|
+
|
|
53
|
+
Signing information is read directly from the project's own `build-profile.json5`. The user must have already configured signing in DevEco Studio before running this skill.
|
|
54
|
+
|
|
55
|
+
### Steps:
|
|
56
|
+
|
|
57
|
+
1. **Read `build-profile.json5`** in the project root.
|
|
58
|
+
|
|
59
|
+
2. **Check for `signingConfigs`** — Look for `app.signingConfigs` array in the file.
|
|
60
|
+
- If `signingConfigs` exists and has at least one entry with valid `material` fields (`certpath`, `storeFile`, `profile`), proceed to step 3.
|
|
61
|
+
- If `signingConfigs` is missing or empty, **STOP and report to the user**:
|
|
62
|
+
> Signing configuration not found in `build-profile.json5`.
|
|
63
|
+
> Please open the project in DevEco Studio, go to **File → Project Structure → Signing Configs**, enable **Automatically generate signature**, then re-run this skill with `--signed`.
|
|
64
|
+
|
|
65
|
+
3. **Validate signing material files exist** — For the first entry in `signingConfigs`, check that the files referenced by `material.certpath`, `material.storeFile`, and `material.profile` actually exist on disk.
|
|
66
|
+
- If any file is missing, **STOP and report** which files are missing. Suggest the user re-open DevEco Studio and re-generate the signing config.
|
|
67
|
+
|
|
68
|
+
4. **Ensure product references signing** — Check that the product entry in `products` array has `"signingConfig": "default"` (or matching the signing config name). Add it if missing.
|
|
69
|
+
|
|
70
|
+
5. Proceed to Step 1.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Step 1: Build-Fix Loop
|
|
75
|
+
|
|
76
|
+
Execute the following loop. **Maximum 20 iterations** to prevent infinite loops.
|
|
77
|
+
|
|
78
|
+
### 1.1 Run CLI Build
|
|
79
|
+
|
|
80
|
+
**IMPORTANT (Windows)**: On Windows, bash `export PATH` does NOT propagate to Windows native child processes. You **must** use a temporary `.bat` file to set `PATH` and `JAVA_HOME`.
|
|
81
|
+
|
|
82
|
+
1. **Write a temporary batch file** (e.g. `<project-dir>/build_temp.bat`):
|
|
83
|
+
|
|
84
|
+
**For unsigned builds** (no `--signed`):
|
|
85
|
+
```bat
|
|
86
|
+
@echo off
|
|
87
|
+
set "DEVECO_SDK_HOME=<deveco-path>\sdk"
|
|
88
|
+
cd /d "<project-dir>"
|
|
89
|
+
"<deveco-path>\tools\node\node.exe" "<deveco-path>\tools\hvigor\bin\hvigorw.js" assembleHap --mode module -p module=entry --no-daemon
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**For signed builds** (`--signed`):
|
|
93
|
+
```bat
|
|
94
|
+
@echo off
|
|
95
|
+
set "PATH=<deveco-path>\jbr\bin;%PATH%"
|
|
96
|
+
set "JAVA_HOME=<deveco-path>\jbr"
|
|
97
|
+
set "DEVECO_SDK_HOME=<deveco-path>\sdk"
|
|
98
|
+
cd /d "<project-dir>"
|
|
99
|
+
"<deveco-path>\tools\node\node.exe" "<deveco-path>\tools\hvigor\bin\hvigorw.js" assembleHap --mode module -p module=entry --no-daemon
|
|
100
|
+
```
|
|
101
|
+
Note: Signed builds need `JAVA_HOME` and `jbr\bin` in PATH because the `SignHap` step spawns `java` as a child process.
|
|
102
|
+
|
|
103
|
+
Use backslashes (`\`) in paths inside the `.bat` file (Windows convention).
|
|
104
|
+
|
|
105
|
+
2. **Run the batch file** via `cmd.exe`:
|
|
106
|
+
```bash
|
|
107
|
+
cmd.exe //c "<project-dir>/build_temp.bat" 2>&1
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
3. **Delete the batch file** after the build completes (success or failure).
|
|
111
|
+
|
|
112
|
+
- Capture the **full output** into a variable.
|
|
113
|
+
- The build command may take 1-3 minutes. Use a timeout of 300000ms (5 minutes).
|
|
114
|
+
|
|
115
|
+
### 1.2 Check Build Result
|
|
116
|
+
|
|
117
|
+
- If output contains `BUILD SUCCESSFUL` → **Build succeeded!** Exit the loop, go to Step 2.
|
|
118
|
+
- If output contains `ERROR` or `BUILD FAILED` → Parse errors and continue to 1.3.
|
|
119
|
+
|
|
120
|
+
### 1.3 Parse Errors
|
|
121
|
+
|
|
122
|
+
Extract error information from the build output. Errors typically appear in these formats:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
ERROR: <file-path>:<line>:<col> - <error-code>: <message>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
or
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
ArkTS:ERROR File: <file-path>:<line>:<col>
|
|
132
|
+
<error message>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Group errors by file. Focus on **actual errors**, not warnings.
|
|
136
|
+
|
|
137
|
+
### 1.4 Fix Errors
|
|
138
|
+
|
|
139
|
+
Read each file that has errors and apply fixes. Use the error reference table below to identify and fix common issues:
|
|
140
|
+
|
|
141
|
+
| Error Code / Pattern | Message | Fix |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| `arkts-limited-throw` | "throw statements cannot accept values of arbitrary types" | Change `throw err` to `throw (err instanceof Error) ? err : new Error(String(err))` |
|
|
144
|
+
| `arkts-no-obj-literals-as-types` | "Object literals cannot be used as type declarations" | Define a named `interface` instead of inline `{ key: Type }` |
|
|
145
|
+
| `arkts-no-untyped-obj-literals` | "Object literal must correspond to some explicitly declared class or interface" | Assign to typed variable: `const r: MyInterface = {...}; return r;` |
|
|
146
|
+
| `arkts-no-any-type` / `any` type usage | "Use explicit types instead of any" | Replace `any` with the correct concrete type or `object` |
|
|
147
|
+
| `arkts-no-var` | "Use 'let' or 'const' instead of 'var'" | Replace `var` with `let` or `const` |
|
|
148
|
+
| `10903329` | "Unknown resource name 'xxx'" | Verify resource exists in `resources/base/media/` or `element/*.json`. Use `layered_image` as fallback for missing images. **Special case**: `$r('sys.media.ohos_ic_public_xxx')` references system icons by SDK-specific names that may not exist in the build SDK — replace with `$r('app.media.ic_public_xxx')` and add the icon file to `resources/base/media/` |
|
|
149
|
+
| `10505001` | "Resource[] is not assignable to ResourceColor" | Remove array brackets: `.fontColor($r('app.color.x'))` not `.fontColor([$r('app.color.x')])` |
|
|
150
|
+
| `00303221` | "permission must be a value that is predefined within the SDK" | Remove invalid permission from `module.json5`. See valid permissions list below |
|
|
151
|
+
| Missing import | "Cannot find name 'xxx'" | Add the correct import (see import reference below) |
|
|
152
|
+
| Missing `async` | "await expression requires async function" | Add `async` to the enclosing function |
|
|
153
|
+
| Missing `build()` | "@Component must have build() method" | Add a `build() {}` method to the @Component struct |
|
|
154
|
+
| Type mismatch | Various type errors | Fix the type annotation or cast appropriately |
|
|
155
|
+
| Duplicate identifier | "Duplicate identifier 'xxx'" | Remove or rename the duplicate declaration |
|
|
156
|
+
|
|
157
|
+
**For errors NOT in the table above**: Read the error message carefully, read the relevant source file, understand the context, and apply an appropriate fix. Use your knowledge of ArkTS/HarmonyOS to determine the correct solution.
|
|
158
|
+
|
|
159
|
+
### 1.5 Log Progress
|
|
160
|
+
|
|
161
|
+
After each fix iteration, briefly report:
|
|
162
|
+
- Iteration number
|
|
163
|
+
- Number of errors found
|
|
164
|
+
- Summary of fixes applied
|
|
165
|
+
- Whether re-building
|
|
166
|
+
|
|
167
|
+
Then go back to **1.1** and rebuild.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Step 2: Build Success Report
|
|
172
|
+
|
|
173
|
+
When the build succeeds, present a summary:
|
|
174
|
+
|
|
175
|
+
1. **Build Status**: SUCCESS
|
|
176
|
+
2. **Build Type**: Signed HAP or Unsigned HAP
|
|
177
|
+
3. **Signing** (if signed): Confirm signing config from `build-profile.json5` was used
|
|
178
|
+
4. **Iterations**: How many build-fix cycles were needed
|
|
179
|
+
5. **Total Errors Fixed**: Count of errors fixed across all iterations
|
|
180
|
+
6. **Summary of Changes**: List of files modified and what was fixed in each
|
|
181
|
+
7. **Output HAP Path**:
|
|
182
|
+
- Signed: `<project>/entry/build/default/outputs/default/entry-default-signed.hap`
|
|
183
|
+
- Unsigned: `<project>/entry/build/default/outputs/default/entry-default-unsigned.hap`
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Reference: Common HarmonyOS Imports
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Network
|
|
191
|
+
import { http } from '@kit.NetworkKit';
|
|
192
|
+
|
|
193
|
+
// Data persistence
|
|
194
|
+
import { preferences } from '@kit.ArkData';
|
|
195
|
+
import { relationalStore } from '@kit.ArkData';
|
|
196
|
+
|
|
197
|
+
// UI utilities
|
|
198
|
+
import { router } from '@kit.ArkUI';
|
|
199
|
+
import { promptAction } from '@kit.ArkUI';
|
|
200
|
+
|
|
201
|
+
// Ability & Context
|
|
202
|
+
import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit';
|
|
203
|
+
import { common } from '@kit.AbilityKit';
|
|
204
|
+
|
|
205
|
+
// File I/O
|
|
206
|
+
import { fileIo } from '@kit.CoreFileKit';
|
|
207
|
+
|
|
208
|
+
// Logging
|
|
209
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
210
|
+
|
|
211
|
+
// JSON parsing — built-in, no import needed
|
|
212
|
+
// ArkUI built-in components (Text, Column, Row, List, Button, Image, etc.) — NO import needed
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Reference: Valid Permission Names
|
|
216
|
+
|
|
217
|
+
Commonly used SDK-validated permissions for `module.json5`:
|
|
218
|
+
|
|
219
|
+
- `ohos.permission.INTERNET`
|
|
220
|
+
- `ohos.permission.GET_NETWORK_INFO`
|
|
221
|
+
- `ohos.permission.GET_WIFI_INFO`
|
|
222
|
+
- `ohos.permission.KEEP_BACKGROUND_RUNNING`
|
|
223
|
+
- `ohos.permission.PUBLISH_AGENT_REMINDER`
|
|
224
|
+
- `ohos.permission.CAMERA`
|
|
225
|
+
- `ohos.permission.MICROPHONE`
|
|
226
|
+
- `ohos.permission.APPROXIMATELY_LOCATION`
|
|
227
|
+
- `ohos.permission.LOCATION`
|
|
228
|
+
- `ohos.permission.READ_MEDIA`
|
|
229
|
+
- `ohos.permission.WRITE_MEDIA`
|
|
230
|
+
- `ohos.permission.USE_BLUETOOTH`
|
|
231
|
+
- `ohos.permission.VIBRATE`
|
|
232
|
+
|
|
233
|
+
**Note**: `ohos.permission.NOTIFICATION` does NOT exist. When in doubt, omit the permission.
|
|
234
|
+
|
|
235
|
+
## Reference: ArkTS Strict Mode Rules
|
|
236
|
+
|
|
237
|
+
All code must comply with ArkTS strict mode:
|
|
238
|
+
|
|
239
|
+
1. **No `any` type** — Use explicit types or `object`
|
|
240
|
+
2. **No `var`** — Only `let` and `const`
|
|
241
|
+
3. **No dynamic property access** — Use typed interfaces instead of `obj['key']` on typed objects
|
|
242
|
+
4. **`throw` must throw Error instances** — Never `throw 'string'` or `throw unknownVar`
|
|
243
|
+
5. **All object literals must match declared interfaces** — No anonymous `{ key: val }` returns without a matching interface
|
|
244
|
+
6. **No inline object literal types** — `function(): { a: string }` is forbidden; define a named `interface`
|
|
245
|
+
7. **All `@Component` structs must have `build()`** — Missing build method is a compile error
|
|
246
|
+
8. **`$r()` resource references validated at compile time** — All referenced resources must exist
|
|
247
|
+
9. **`fontColor()` expects `ResourceColor`**, not `Resource[]` — Don't wrap in array brackets (exception: `SymbolGlyph`)
|
|
248
|
+
10. **Permission names in `module.json5`** — Must be SDK-predefined values
|
|
249
|
+
|
|
250
|
+
## Important Notes
|
|
251
|
+
|
|
252
|
+
- **Timeout**: Individual build commands may take up to 5 minutes. Use a 300000ms timeout.
|
|
253
|
+
- **Max iterations**: Stop after 20 iterations to prevent infinite loops. If build still fails after 20 attempts, report the remaining errors to the user.
|
|
254
|
+
- **Don't over-fix**: Only fix errors reported by the compiler. Don't proactively refactor unrelated code.
|
|
255
|
+
- **Read before edit**: Always read a file before modifying it. Understand the surrounding context.
|
|
256
|
+
- **One error can cause many**: A single root-cause fix (like adding a missing interface) may resolve multiple reported errors. After fixing root causes, rebuild to see remaining issues.
|
|
257
|
+
- **ohpm errors**: If the build fails because of missing packages, run `ohpm install` again.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## References
|
|
262
|
+
|
|
263
|
+
- `references/arkts-strict-patterns.md` — ArkTS 严格模式编译错误的确定性修复 Pattern(throw/any/var/interface 等)
|
|
264
|
+
- `references/known-patterns.md` — 已知常见编译错误 Pattern 及修复方案
|
|
265
|
+
- `references/rdb-entity-pattern.md` — RDB 实体类编译错误 Pattern(数据库实体相关)
|